[wp-trac] [WordPress Trac] #35760: Provide API for TinyMCE editor to be dynamically instantiated via JS
WordPress Trac
noreply at wordpress.org
Mon Apr 17 16:52:30 UTC 2017
#35760: Provide API for TinyMCE editor to be dynamically instantiated via JS
-------------------------+-------------------------
Reporter: westonruter | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 4.8
Component: Editor | Version:
Severity: normal | Resolution:
Keywords: | Focuses: javascript
-------------------------+-------------------------
Comment (by dmo7):
Hi guys. I see that this enhancement is targeted for 4.8, but I was
wondering if anybody has had success dynamically adding the editor using
JS in some other clever way. I'm currently doing it, but it appears that
the "media" buttons don't show up. I'm basically using this command:
{{{
tinymce.execCommand( 'mceAddEditor', true, "my_id" );
}}}
The reason we want to dynamically add it is because we have a custom post
type with a repeating field (using CMB2) which has a WYSIWYG field in it.
If the users repeat that field a bunch of times (let's say 13 or more),
the page gets really really slow because there is essentially 13+
instances of the editor in the page. I'm attempting to find a way to
simply have 1 editor on the page at any given time. Essentially, each
"lazy editor" field has an edit button and when it's clicked, the JS
removes the other editors and then loads up TinyMCE in that spot. It's
mostly working, with the exception of the add media buttons. Is there
something I can do before or after the above line of code so that it loads
up correctly with all the plugins and buttons i would expect? Any
thoughts?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35760#comment:15>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list