Skip to content

[Svelte] Is there a way to restore the cursor location when a node's value is modified via setAttrs? #37

@dev-guy

Description

@dev-guy

When combining Milkdown and prosemirror-adapter/svelte, setAttrs({ value: 5 }) causes the Svelte component (declared via $view) to be removed and a new component takes its place. In my case, the Svelte component consists of a textarea. setAtrrs() moves the cursor out of the textarea to the top of the Milkdown editor. I guess I could capture the cursor location in update() but I'm not sure what I could do to find it later when the new Svelte component is created. I think I'm supposed to use a Svelte store for this. Is that correct? I realize that a better solution is to use a Prosemirror Editor instead of textarea and use transactions (which has better support for undo/redo and collaboration), but that's what the Milkdown Playground does eg with the diagram plugin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions