On Problems Caused by Source Code Switching

Hi,guys.
I encountered a problem. In ckedtoir editor, my map was not displayed after the original code was switched. Look at the results:
image image
Initially, my button and canvas will be blocked directly,I modified it by looking at ckeditor’s filtering strategy, and my canvas and buttons did exist, but my map was still not properly displayed.

I gave another example to prove that canvas will not be re-rendered. I don’t know if there is any way to solve this problem.
image
image
image
Please help me.

There are many actions that trigger the serialization and re-rendering of the edited HTML (DOM) in CKEditor. Switching to source is just one. Think about Undo and Redo, there’s also Macro insertion, etc. The editor was made to work with static HTML. Anything that is dynamic (i.e. generated or modified with JavaScript, like the canvas element) will have issues. You’ll have to find a way to re-execute that JavaScript (e.g. that draws the canvas) each time the edited HTML is re-rendered.

Note that this is not specific to XWiki. If you really need this then best is to ask on the CKEditor community ( GitHub - ckeditor/ckeditor4: The best enterprise-grade WYSIWYG editor. Fully customizable with countless features and plugins. ). If you manage to do this on the standard / standalone CKEditor then it should be easy to do the same in version of CKEditor that is integrated in XWiki.

Thank you for your help. I will study the mechanism of ckedtior.