简体   繁体   中英

TinyMCE editor content missing after drag and move

I've got a page with multiple TinyMce editors and i have drag and drop feature enabled which allows me to change the order of each items.

But as i drag-drop an editor its content gets removed.

See the screen shots:

Before Drag-Drop拖放前

After Drag-Drop拖放后

Finally fixed the issue...

The solution is to first shut down the tinymce instance (id needed!)

tinymce.execCommand('mceRemoveControl',true,'editor_id');

then do the DOM action and reinit the tinymce instance

tinymce.execCommand('mceAddControl',true,'editor_id');

Add following code on drag end event:

onDragEnd(event: any) {
  var tinymceId = 'tinymceId_' + event.source.data.index; //get selected element id
  tinymce.get(tinymceId ).remove(); //remove existing instance
  $('#' + tinymceId ).closest('.mce-tinymce.mce-container').show();
  tinymce.init({id: tinymceId , selector: '#' + tinymceId , height: 200}; //you can add other properties into init()
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM