y-codemirror.next icon indicating copy to clipboard operation
y-codemirror.next copied to clipboard

Export `ySyncAnnotation`

Open jacobrobertsbaca opened this issue 2 years ago • 1 comments

Export the ySyncAnnotation CodeMirror annotation type. This allows others to check if a transaction is a remote transaction using code like this:

import { ySyncAnnotation } from "y-codemirror.next";

function isRemote(tr: Transaction): boolean {
    return !!tr.annotation(ySyncAnnotation);
}

Currently this is not possible as the annotation isn't exported by the package index.js

jacobrobertsbaca avatar Dec 27 '23 22:12 jacobrobertsbaca

Alternatively this could be accomplished by tagging YJS CodeMirror transactions with Transaction.remote inside y-sync.js:

- view.dispatch({ changes, annotations: [ySyncAnnotation.of(this.conf)] })
+ view.dispatch({ changes, annotations: [ySyncAnnotation.of(this.conf), cmState.Transaction.remote] })

to be more true to CodeMirror's existing interface.

jacobrobertsbaca avatar Dec 27 '23 22:12 jacobrobertsbaca

@dmonad Are you planning to merge this pull request? I also find the changes in this PR very useful.

reiji-h avatar Jun 25 '24 05:06 reiji-h

Sure, I'll add it to the next release

dmonad avatar Jun 25 '24 07:06 dmonad

Thank you very much.

reiji-h avatar Jun 25 '24 08:06 reiji-h