Opened 9 years ago
Closed 9 years ago
#32425 closed task (blessed) (fixed)
Update WP_Editors and TinyMCE initialization
Reported by: | azaozz | Owned by: | azaozz |
---|---|---|---|
Milestone: | 4.3 | Priority: | normal |
Severity: | normal | Version: | 4.3 |
Component: | TinyMCE | Keywords: | has-patch |
Focuses: | Cc: |
Description
There are several "weak points" in the TinyMCE initialization, filtering content for the editors, switching between them, and applying wpautop.
There is no good reason to run the editor content through the PHP wpautop() before outputting it in the textarea, and have two separate filers for it. This should be handled from JS on initializing TinyMCE. Editor.js and the inline script that initializes both editors also need updating.
Attachments (4)
Change History (25)
#3
@
9 years ago
We could, but most of the changes are related so the different pieces/tickets will have to be dependent on one another. Harder to sync :)
#4
@
9 years ago
Another idea: lets make a wpapi
plugin and add the wpautop(), preWpautop() and the wpMenu functions in it. Then ensure it is always loaded first by prepending it to the plugins list.
This ticket was mentioned in Slack in #core-editor by azaozz. View the logs.
9 years ago
#6
@
9 years ago
In 32425.2.patch:
- Move
wpautop()
andwpremovep()
(formerlypre_wpautop
) to a new TinyMCE plugin so they are always available. - Do not initialize TinyMCE in a hidden div when the Text editor is default. Initializing wpViews while hidden might cause problems. Open a new ticket for it for more testing.
- Add back-compat for the new
format_for_editor()
that normalizes escaping and replaceswp_richedit_pre()
andwp_htmledit_pre()
.
#7
@
9 years ago
In 32425.3.patch:
- Keep the JS
wpautop()
in editor.js but add it towp.editor.autop()
andwp.editor.removep()
. - Use the above to handle adding/removing of
<p>
automatically when loading or switching editors. - Do not run the post_content through wpautop() before outputting it for editing.
- Deprecate
wp_richedit_pre()
andwp_htmledit_pre()
and introduceformat_for_editor()
.
In 32425.patch:
wp_richedit_pre()
andwp_htmledit_pre()
withformat_for_editor()
. Deprecate the old functions and filters. Add back-compat for the filters. The new function only runs the content throughhtmlspecialchars()
, same aswp_htmledit_pre()
. If TinyMCE is loaded first, the content is run through the JS wpautop() on initializing the editor.tinymce.$
.Still to do: maybe move the JS
wpautop()
andpreWpautop()
to the 'wordpress' TinyMCE plugin so they are available without needing to load editor.js. That makes it a bit easier/cleaner to use only TinyMCE. Alternatively we can add them in the same file as the plugin but without being a part of it, then define them in something liketinymce.wp.*
. Also wondering about the back-compat for the jQuery events on running the content through wpautop and preWpautop.