[wp-trac] [WordPress Trac] #19173: Issues with wp_editor() when used inside of a meta box.
WordPress Trac
noreply at wordpress.org
Tue Sep 15 20:01:24 UTC 2015
#19173: Issues with wp_editor() when used inside of a meta box.
--------------------------+-------------------------
Reporter: goto10 | Owner: azaozz
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: Editor | Version: 3.3
Severity: normal | Resolution: maybelater
Keywords: | Focuses:
--------------------------+-------------------------
Changes (by azaozz):
* status: reopened => closed
* resolution: => maybelater
Comment:
> In Fieldmanager, we reinit the editors after the user drags them.
Yeah, that should look better. Only concern is possible "choppy" dragging
of a big/complex element that contains the editor iframe.
Looking at https://github.com/alleyinteractive/wordpress-
fieldmanager/blob/master/js/richtext.js#L58-L95:
- You can check if the Text editor is currently being used by doing
`ed.isHidden()`.
- If true, can re-initialize the instance without restoring the content,
as the latest content is in the textarea and MCE will load it on
initialization.
- If false (i.e. the Visual editor is being used) will have to "save" to
the textarea first.
So the code will be something like (untested):
{{{
if ( ! ed.isHidden() ) {
ed.save();
}
tinymce.remove( ed );
tinymce.init( tinyMCEPreInit.mceInit[ this.id ] );
}}}
This should work in WP 4.3+ as the textarea value is run through the JS
wpautop. There is no need to set the content or switch editors. For older
versions you'll still need to load the content in the new instance when
MCE is being used to keep the `<p>` tags.
I'm not sure what can be added to wp_editor() to make this simpler/easier.
It is quite straightforward to implement in a plugin. Going to re-close as
"maybelater". Feel free to reopen and attach a patch if you come up with
something that can improve it.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/19173#comment:26>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list