- From: Di Zhang <notifications@github.com>
- Date: Tue, 22 Oct 2024 15:08:22 -0700
- To: w3c/selection-api <selection-api@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/selection-api/issues/2/2430404609@github.com>
Thanks for the explanation, very helpful. Here is my thought process. Right now, the spec says we have: * `Selection` <-> `Range (live range)`. If we introduce the concept of a live composed range, then the mapping would be: * `Selection` <-> `Composed Range (live range)` <-> `Range (live range)` * For setBaseAndExtent(), it updates this composed range. * We will need to revisit mutations. * For getRangeAt(0), we will get the live composed range and rescope it. This live range will be pointing to the live composed range and its mutation will affect it. * For getComposedRanges(), we can get the start/end boundary points of live composed range. What I am proposing instead is to not add/change Range definitions: ranges are not composed. Instead, we add a new concept of a **Composed Selection**. The composed selection internally stores anchor and focus endpoints to be across the document. It has no direct pointer to any range. * `Selection` <-> `Composed Selection` * `Selection` <-> `Range (live range)` * For setBaseAndExtent(), it updates both the Composed Selection and the Live Range. Live range might collapse if across trees, but there are no such check on composed selection. * When mutations happen to a live range, it will call UpdateSelection(), which will UpdateComposedSelection(). * For getRangeAt(0), no change needed. * For getComposedRanges, we can get the start/end by accessing the composed selection's anchor/focus. I think this approach might be easier on the specifications, while still giving the user agents enough leeway on how they want to implement it. -- Reply to this email directly or view it on GitHub: https://github.com/w3c/selection-api/issues/2#issuecomment-2430404609 You are receiving this because you are subscribed to this thread. Message ID: <w3c/selection-api/issues/2/2430404609@github.com>
Received on Tuesday, 22 October 2024 22:08:26 UTC