Closed dev-guy closed 1 year ago
The solution is to add
update: (node) => false,
to the object provided to nodeViewFactory()
Any unsaved edits do get overwritten, however. The update function is unaware of the Svelte component, so they can’t merge edits. A svelte store is needed for them to communicate.
See https://github.com/dev-guy/phoenix-ash-svelte-flowbite/blob/main/assets/svelte/milkdown/mermaid.js
A more comprehensive solution uses a prosemirror editor instead of a simple text input element to handle undo/redo in a collaborative way. https://prosemirror.net/examples/footnote/
Basic collaboration is working. Adding text to the document is sent to collaborators. However, I'm having trouble with a custom node view.
A custom node view calls
setAttrs({value: ...})
to modify the value (Mermaid code) of a diagram node, similar to the way the Milkdown Playground does it.It gets setAttrs via
const setAttrs = useNodeViewContext("setAttrs");
I don't see any errors in the JavaScript console or elsewhere. Collaborators connected to the same document don't seem to be receiving the changes. Is there something else that I need to do to modify the Y doc?
I can also guess that if I'm able to get that working, the custom nodeview won't know its node was changed. Can the store returned by
useNodeViewContext("node")
be used to re-render the component or does Prosemirror handle that?Here's my code