reedsy / quill-cursors

A multi cursor module for Quill text editor.
MIT License
250 stars 53 forks source link

Add selection `span` elements in order #30

Closed alecgibson closed 5 years ago

alecgibson commented 5 years ago

Fixes https://github.com/reedsy/quill-cursors/issues/29

At the moment, the span elements that make up a multi-line selection are not necessarily added in the correct "order" (ie from top-left to bottom-right of the document). Sometimes we may want these in order so that we can style them using CSS selectors like :first-child.

This works by accident currently in Chrome, but not in Firefox. This change actively sorts the span elements by their rectangles from top-to-bottom, and then left-to-right. Note that we ignore right-to-left text as out-of-scope for this change.