-
Notifications
You must be signed in to change notification settings - Fork 62
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
Conversation
@@ -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'), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Thanks for this both, I will take a look this week! |
Can't wait for the tinymce 4.4 as it seems to solve the issue with initializing it under FF - tinymce/tinymce#2671 |
Please... |
from wagtail.wagtailcore.whitelist import allow_without_attributes, attribute_rule, check_url | ||
|
||
|
||
class DbTinymceWhitelister(DbWhitelister): |
There was a problem hiding this comment.
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,
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added #15
There was a problem hiding this comment.
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.
No description provided.