guardian / prosemirror-noting

Prosemirror plugin that adds the ability to have ranges added to the document that expand and contract around dependent on the input.
MIT License
57 stars 8 forks source link

Bring note/flag/correct behaviour in line with user expectations #6

Closed jonathonherbert closed 6 years ago

jonathonherbert commented 6 years ago

A fairly chunky PR to bring note/flag/correct behaviour in line with user expectations:

There are a few edge cases solved here, including correct mark setting for the cursor position between touching notes, correct decoration as cursor moves through inside positions across touching notes, and correct cursor behaviour when two kinds of notes are stacked and start/end on the same character.

Implementation notes:

I've created a new class to manage sharing state between noter plugins, the alluringly named SharedNoteStateTracker. Superlative name aside, this is a somewhat clunky solution - the implementation works but I'm super open to a refactor.

Similarly, we use the 'appendTransaction' hook to apply a change of state for the edge case mentioned above. Is there a better place to put this behaviour? Or can filter and append behaviours be merged? (Appending a transaction re-triggers the filter operation!)