-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix excessive reviveSelector
execution in spacialTree
after splitting the annotatable ranges
#65
Comments
Also, notice how the Which brings us back to the #23 issue. Where I pointed out that text-annotator-js/packages/text-annotator/src/utils/trimRange.ts Lines 11 to 31 in 80c2f92
|
This was referenced Feb 27, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Current State
In the #34 PR, I added the
splitAnnotatableRanges
method that "Splits a DOM Range into one or more ranges that span annotatable content only". It works properly and the ranges it captures skip the.not-annotatable
elements.Issue
The problem is that the ranges are generated with the
.setStartAfter
&.setEndBefore
that don't precisely capture thetext
nodes:text-annotator-js/packages/text-annotator/src/utils/splitAnnotatableRanges.ts
Lines 44 to 54 in 3a70b9e
Instead, they can capture the preceding/following
![image](https://private-user-images.githubusercontent.com/68850090/308100471-a33c0770-d0c3-4dc9-a447-16f3ac0c621b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAxNTc5MDMsIm5iZiI6MTcyMDE1NzYwMywicGF0aCI6Ii82ODg1MDA5MC8zMDgxMDA0NzEtYTMzYzA3NzAtZDBjMy00ZGM5LWE0NDctMTZmM2FjMGM2MjFiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA1VDA1MzMyM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTk3NGU3YWVjMDg0ZDIxYTI0Y2U0YTk5ZTk2ZTMyMmQwODUzZGI1MzAyZjQ3ZWJkN2ZlZjVjNjMyMDU3MzZlYmMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.GXrI7WW5acu1PV9qMgl4tMkeayyUWXuCl8MERj4GzCI)
div
s as thestart
/end
containers:However, the
spacialTree
doesn't consider such ranges as "valid"! When it generates the client rects, it'll try to revive the range again from its positions:text-annotator-js/packages/text-annotator/src/state/spatialTree.ts
Lines 43 to 49 in 3a70b9e
It feels like an excessive computational step, considering that the provided range already covers only the annotatable area and it certainly doesn't improve the performance 🤷🏻♂️
Issue Demo
Screen.Recording.2024-02-27.at.10.45.42.mov
Possible Solutions
Don't run the
trimRange
right on the selection range:text-annotator-js/packages/text-annotator/src/SelectionHandler.ts
Lines 56 to 58 in 3a70b9e
But on the ranges created after splitting
The text was updated successfully, but these errors were encountered: