grapesjs-plugin-ckeditor icon indicating copy to clipboard operation
grapesjs-plugin-ckeditor copied to clipboard

[BUG] CKEditor isn't removed from the DOM

Open kuhelbeher opened this issue 4 years ago • 5 comments

CKEditor isn't removed from the DOM after component deselected. It could cause weird bugs like double CKEditor:

image

image

kuhelbeher avatar May 19 '20 10:05 kuhelbeher

Have the same bug. After init Ckeditor toolbar and draggin component to another place we have 2 toolbars. Resolve with help of this command: editor.on('sorter:drag:end', ({ srcEl }) => { if (srcEl) { $(document).find(#cke_${srcEl.id}).remove(); } });

Houst0n345 avatar Jun 22 '21 11:06 Houst0n345

I found the solution: In index.js line 41:

      let rteToolbar = editor.RichTextEditor.getToolbarEl();
      [].forEach.call(rteToolbar.children, (child) => {
      	child.style.display = 'none';
      });

change to:

      let rteToolbar = editor.RichTextEditor.getToolbarEl();
      [].forEach.call(rteToolbar.children, (child) => {
      	child.remove();
      });

and run npm run build

jackyhuynh0407 avatar Oct 12 '21 02:10 jackyhuynh0407

@jackyhuynh0407 will you open a PR with it?

Well, test it.

This code doesn't allow me to edit a text anymore. 🤔 Should be other solution

ronaldohoch avatar Mar 23 '22 14:03 ronaldohoch

Yes I have other solution. But i forgot to update it. I'm not open PR yet

      let rteToolbar = editor.RichTextEditor.getToolbarEl();
      [].forEach.call(rteToolbar.children, (child) => {
        if(child.id == `cke_${el.id}`) child.remove()
      	else child.style.display = 'none';
      });

jackyhuynh0407 avatar Mar 28 '22 14:03 jackyhuynh0407

@jackyhuynh0407 nice, thank you! @artf update the plugin to us 🙈

ronaldohoch avatar Mar 28 '22 16:03 ronaldohoch