y-monaco
y-monaco copied to clipboard
Support multi-selections in awareness
This PR is to support multi-selections in awareness, which is requested in #18.
- Refactored some code into util functions
createSelectionAnchorAndHead
andcreateRemoteSelectionDecoration
. - Added a new local state field
secondarySelections
, which is used to render decorations for secondary selections. - Changed
createRelativeSelection
tocreateRelativeSelections
, 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
Submitted with StackBlitz.