WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 4 months ago

#39423 closed enhancement (wontfix)

Create add_editor_script, analogous to add_editor_style (add JavaScript to TinyMCE)

Reported by: paulschreiber Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.8
Component: TinyMCE Keywords: close
Focuses: Cc:
PR Number:

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)

#1 @azaozz
3 years ago

  • Keywords close added

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 and editor.$ (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.

Last edited 3 years ago by azaozz (previous) (diff)

#2 @azaozz
3 years ago

  • Component changed from Editor to TinyMCE

#3 @azaozz
4 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Still don't think this is a good idea :)

Note: See TracTickets for help on using tickets.