yuleicul/obsidian-ketcher

`undo` just reverts what `setMolecule` did

Opened this issue · 0 comments

This is also related to the boundary case, that multiple tabs sharing the same file. In this case, when one tab calls save(), the
_check flag in setViewData() of other tabs will be false. So through wrapping render KetcherReact, we can retain the editor, and just refresh the data.

With this specific case I found another problem. If we assign the view data through ketcher.setMolecule(), and the undo operation would just revert what the funcion did.

When we have two tabs, drawing on Tab A and updating Tab B automatically, the undo stack of Tab B behaves weird. For obsidian-ketcher v0.1.2, after refreshing the editor, undo will leave a blank canvas on Tab B, because we re-render the editor, and then assign the data value to the tab. For the proposed change, undo will revert save() operation, and we will get the previous state since we retained the editor and pervious data.

If there's a way to interact with the undo stack of ketcher editor, we can even keep it on the page (init in the constructor of KetView), and just update the data. (Update: code here https://github.com/Acylation/obsidian-ketcher/tree/single-editor-instance)

Originally posted by @Acylation in #10 (comment)