cherry-markdown
cherry-markdown copied to clipboard
[Bug report] Preview 的 VirtualDOM 用法有问题
Describe the bug
I'm implementing a plugin that render something extra into the previewer. User may write %%specialSyntax%% and it turns into a div placeholder. An async process will load data and replace the placeholder.
However in the editor, when the previewer updates, the rendered content will be totally removed.
I noticed that CherryMarkdown take current actual HTML as snapshot and build a virtual dom tree, then compare it with a virtual dom tree from temp document fragment. Due to the async-mounting strategy, it is impossible to avoid removing my content 😢
Therefore in this PR:
- fix some werid virtual-dom usage
- support
data-cm-atomicattribute in the rendered HTML. which will ignore all children of current Node so that all async-mounted things will be preserved :)