Opened 7 years ago
Closed 4 years ago
#39423 closed enhancement (wontfix)
Create add_editor_script, analogous to add_editor_style (add JavaScript to TinyMCE)
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.8 |
Component: | TinyMCE | Keywords: | close |
Focuses: | Cc: |
Description
It would be helpful to be able to load external and inline JavaScript in to TinyMCE.
Suggestion: create an add_editor_script()
function, analogous to add_editor_style()
.
Use case: embed handlers or shortcode handlers that require custom JavaScript.
Change History (3)
Note: See
TracTickets for help on using
tickets.
Don't think this is a good idea. If you want to run js or manipulate the DOM in the editor iframe, you should use "proper" plugin. TinyMCE has extensive APIs for that, look at
editor.dom
andeditor.$
(which is pretty similar to jQuery but inside the contenteditable body).If you cannot use the editor APIs, you should look into using
wpview
that will insert an iframe and make it non-editable.Also
add_editor_style()
extends and exposes an existing TinyMCE setting, see: https://www.tinymce.com/docs/configure/content-appearance/#content_css. Adding arbitrary JS to the editor iframe is not supported.I'm also thinking of converting
wpembed
to a proper TinyMCE plugin despite that it will be mostly a copy of wp-includes/js/wp-embed.js.