Skip to content

Bug: Cursor is visible in multiple editor instances when more than one ProseMirror instance is synced #59

@kulla

Description

@kulla

Bug description

First of all: Thanks for the great project ❤️

In my use case I want to sync a document with multiple ProseMirror instances (e.g. a form with some inputs being rich text). I noticed that when user A has his cursor in one of the ProseMirror editors, for user B the cursor of user A is shown in all editor instances.

Minimal example

At https://github.com/kulla/2025-11-26-bug-demo-for-loro-with-two-editor-instances I have created a repository with a minimal example of the described bug. You can check it out yourself at https://kulla.github.io/2025-11-26-bug-demo-for-loro-with-two-editor-instances/:

Image

I have used prosekit and the code given at https://prosekit.dev/extensions/loro/ to simplify the development.

Assumption of reason

It seems to me that createDecorations does not check whether the cursor from the awareness is actually inside the current ProseMirror instance. For each ProseMirror instance it calculates the absolute position of the remote cursor and renders it.

Workaround

At https://github.com/kulla/2025-11-19-experiment-with-two-editor-instances I have created a workaround for this bug. Each editor instance receives a proxy for the global cursor awareness. Next to anchor and focus also an id of the editor instance for the current cursor is stored. This is used in each proxy to filter for only those cursors which belong to the current editor instance. See the code at https://github.com/kulla/2025-11-19-experiment-with-two-editor-instances/blob/8ac2c360748a399118e27f1e494a944dca4ed643/src/App.tsx#L142-L191

Note

I have written my code before #54

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