grapesjs-plugin-ckeditor
grapesjs-plugin-ckeditor copied to clipboard
[BUG] CKEditor isn't removed from the DOM
CKEditor isn't removed from the DOM after component deselected. It could cause weird bugs like double CKEditor:
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(); } });
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 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
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 nice, thank you! @artf update the plugin to us 🙈