-
-
Notifications
You must be signed in to change notification settings - Fork 194
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
Default valid_elements field in pattern options adds 40kb for every RichtTextField on an edit page #3204
Comments
OMG m( |
In general I'd say this is needed because otherwise editors create theirs super duper SinglePageApp inside TinyMCE and wonder why its gone when saving it 😉 But this can be improved using the "acquired" pattern options feature from patternslib. This means we can define options on a higher level node which are then used inside every pattern inside this node (like its already done for
we can remove it from the patterns in the doc ...that said, there might be more options which could be defined globally ... /cc @plone/classicui-team |
OTOH you're absolutely right about this. that makes no sense at all. |
Instead of calculating this huge tag/option matrix we could define the general |
Also we could move heavy patternslib config to an JSON endpoint. |
Plone 5.2.3 coredev. While checking for something else I noticed a huge list in the pattern-options of the pat-mimetypeselector field. This is a small drop down to switch the mimetype of our RichText fields and it contains the default pattern options for TinyMCE based on settings in the control panel registry.
The vield valid_elements is a huge string which seems to be a matrix for all tags and all theoretically possible attributes on any tag:
"valid_elements": "a[datetime|char|coords|width|cols|shape|rules|rowspan|border|lang|prompt|maxlength|href|hreflang|compact|tabindex|longdesc|size|dir|hspace|media|start|disabled|axis|align|nowrap|rows|accept|usemap|for|type|valign|span|clear|method|target|src|name|accept-charset|id|ismap|headers|nohref|frame|noshade|alt|height|readonly|action|selected|cellspacing|charset|cite|scope|summary|accesskey|label|rev|checked|class|colspan|abbr|color|multiple|enctype|title|value|rel|vspace|cellpadding|charoff|align|style],abbr[datetime|char|coords|width|cols|shape|rules|rowspan|border|lang|prompt|maxlength|href|hreflang|compact|tabindex|longdesc|size|dir|hspace|media|start|disabled|axis|align|nowrap|rows|accept|usemap|for|type|valign|span|clear|method|target|src|name|accept-charset|id|ismap|headers|nohref|frame ....
It adds about 40Kb to the edit page of the default core Plone frontpage, going from 63,98 Kb to 108,48Kb . This edit page only contains 1 rich text area. This string will be added for every RichTextField(widget). It's easy to spot when you turn off javascript and inspect the mimetypeselector pattern html.
I tested the size increate/decrease by escaping the last line from this part of the TinyMCESettingsGenerator, which generates this 40Kb monster::
Products.CMFPlone/Products/CMFPlone/patterns/tinymce.py
Lines 209 to 226 in cba026e
It seems to me the generated valid_elements is completely incorrect, probably a left over or wrong conversion from the Plone 4 filter control panel where you could list valid attributes per html tag/container. Now it just adds all html.defs.safe_attrs to every valid tag.
But do we really need to pass TinyMCE any valid_elements when all html is filtered on save anyway server side? What's this still doing here?
The text was updated successfully, but these errors were encountered: