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.
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 insetViewData()
of other tabs will be false. So through wrappingrender 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 theundo
operation would just revert what the funcion did.When we have two tabs, drawing on
Tab A
and updatingTab B
automatically, the undo stack ofTab B
behaves weird. For obsidian-ketcher v0.1.2, after refreshing the editor, undo will leave a blank canvas onTab B
, because we re-render the editor, and then assign the data value to the tab. For the proposed change, undo will revertsave()
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
ofKetView
), and just update the data. (Update: code here https://github.com/Acylation/obsidian-ketcher/tree/single-editor-instance)Originally posted by @Acylation in https://github.com/yuleicul/obsidian-ketcher/issues/10#issuecomment-1674451019