Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix html tag support, and update tinymce to v4.40 #6

Closed
wants to merge 10 commits into from

Conversation

bright-pan
Copy link

No description provided.

@bright-pan bright-pan changed the title Fix table support Fix html tag support, table, div, etc... Jul 18, 2016
@@ -56,7 +141,7 @@ def getDefaultArgs(cls):
'options': {
'browser_spellcheck': True,
'noneditable_leave_contenteditable': True,
'language': translation.to_locale(translation.get_language()),
'language': translation.to_locale(translation.get_language() or 'en'),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just looking at a problem relating to language codes and I think it might be best not to set a default language code here at all but instead leave TinyMCE to provide the default value. With the current code, if you have Django's LANGUAGE_CODE setting is set to a value that does not have a corresponding TinyMCE translation file (https://www.tinymce.com/docs/configure/localization/#language), then the editor will fail to display. For example if the LANGUAGE_CODE is 'en-us' a 404 will occur when TinyMCE tries to load wagtailtinymce/js/vendor/tinymce/langs/en_US.js.

By deferring to TinyMCE's default language at least everyone gets the editor displayed out of the box.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @nfletton

the django localization is not Compatible to the tinymce localization,
for example in django shell,

from django.utils import translation
translation.check_for_language('en')
True
translation.check_for_language('en_US')
False

so, there are two solutions for it`s problem,
the first one, fix it in initialization in TinyMCERichTextArea.
the second one, fix filename for js file name, but it ugly.

i will fix it soon.

@riceyrice
Copy link
Contributor

Thanks for this both, I will take a look this week!

@bright-pan bright-pan changed the title Fix html tag support, table, div, etc... Fix html tag support, and update tinymce to v4.40 Jul 21, 2016
@vintage
Copy link

vintage commented Jul 25, 2016

Can't wait for the tinymce 4.4 as it seems to solve the issue with initializing it under FF - tinymce/tinymce#2671

@dperetti
Copy link

Please...

from wagtail.wagtailcore.whitelist import allow_without_attributes, attribute_rule, check_url


class DbTinymceWhitelister(DbWhitelister):
Copy link

@maxpeterson maxpeterson Apr 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The recommended method for updating the whitelisted is to use a construct-whitelister-element-rules hook - this would remove the need for the DbWhitelister subclass

@hooks.register('construct_whitelister_element_rules')
def whitelister_element_rules():
    common = {
        'style': True,
        'width': True,
        'margin-left': True,
        'margin-right': True,
        'height': True,
        'border-color': True,
        'text-align': True,
        'background-color': True,
        'vertical-align': True,
        'font-family': True,
        'valign': True,
    }
    table_rule = attribute_rule(dict(common, **{
        'border': True,
        'cellpadding': True,
        'cellspacing': True,
    }))
    row_rule = attribute_rule(common)
    cell_rule = attribute_rule(dict(common, **{
        'colspan': True,
        'scope': True,
        'rowspan': True,
    }))

    return {
        'blockquote': allow_without_attributes,
        'pre': allow_without_attributes,
        'span': allow_without_attributes,
        'code': allow_without_attributes,

        'table': table_rule,
        'thead': allow_without_attributes,
        'tfoot': allow_without_attributes,
        'tbody': allow_without_attributes,
        'colgroup': allow_without_attributes,
        'col': allow_without_attributes,
        'caption': allow_without_attributes,
        'tr': row_rule,
        'th': cell_rule,
        'td': cell_rule,
    }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added #15

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok,i closed the PR.

@bright-pan bright-pan closed this Apr 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants