y-monaco icon indicating copy to clipboard operation
y-monaco copied to clipboard

Support multi-selections in awareness

Open mosquitochang opened this issue 1 year ago • 0 comments

This PR is to support multi-selections in awareness, which is requested in #18.

  • Refactored some code into util functions createSelectionAnchorAndHead and createRemoteSelectionDecoration.
  • Added a new local state field secondarySelections, which is used to render decorations for secondary selections.
  • Changed createRelativeSelection to createRelativeSelections, saving all current selections instead of only one.
  • Added new classnames yRemoteSelection-primary, yRemoteSelectionHead-primary, yRemoteSelection-secondary, yRemoteSelectionHead-secondary for multi-selection styling, and added corresponding CSS in the demo file.

Demo:

https://github.com/yjs/y-monaco/assets/11325684/9d2d3cf4-0705-41af-897b-7a7cdceb54dc

cc @dmonad


Review PR in StackBlitz Submitted with StackBlitz.

mosquitochang avatar Jan 29 '24 10:01 mosquitochang