问题
The code posted by vijayscode (https://stackoverflow.com/questions/34850038/tinymce-4-not-working-with-sortable-jquery-divs/59896435#59896435) doesn't work for me.
TinyMCE doesn't work even before I start ordering. Does sorting work with TinyMCE in when using inline mode?
For example, if I add the inline: true
option to this code ... TinyMCE is not loaded immediately
http://fiddle.tinymce.com/33faab
Can you show me a working example on http://fiddle.tinymce.com/
回答1:
You are really asking two questions so let me try to answer them separately...
Inline Mode
In order to use inline mode you need to target a block element (e.g. div
) on the page as opposed to a textarea
. This is explained in the documentation:
https://www.tiny.cloud/docs/configure/editor-appearance/#inline
If you want to use TinyMCE in inline mode you will need to adjust your HTML accordingly.
Sorting
As is discussed in SO post you linked to the act of dragging and dropping parts of the DOM impacts TinyMCE because the underlying DOM element that is linked to TinyMCE technically gets removed from the DOM when you start dragging and then a new element is inserted when you perform the drop. Because of this what you want to do is remove()
TinyMCE before the DOM element is removed and then init()
again after the new DOM element is placed back into the DOM.
I would not recommend using the mceAddEditor and mceRemoveEditor to do this work. Instead I would:
- Call
remove()
to detach TinyMCE from the DOM element. - Let the drag/drop complete
- Call
init()
on the DOM element after its placed back into the page.
Calling init()
after the element is back in the page would allow you to determine the element's class/id/etc and call init()
with the correct configuration.
来源:https://stackoverflow.com/questions/59896789/sortable-div-with-tinymce-inline