1
- function highlightSelectionAndShowModal ( ) {
1
+ function fetchSpanIds ( ) {
2
2
const selection = window . getSelection ( ) ;
3
3
if ( ! selection . rangeCount ) return ; // No selection, so exit
4
4
@@ -19,7 +19,7 @@ function highlightSelectionAndShowModal() {
19
19
}
20
20
} ) ;
21
21
startId = selectedSpanIds [ 0 ] ;
22
- endId = selectedSpanIds [ selectedSpanIds . length - 1 ]
22
+ endId = selectedSpanIds [ selectedSpanIds . length - 1 ]
23
23
24
24
// If startId and endId are set, construct the URL and open the modal
25
25
if ( startId && endId ) {
@@ -40,13 +40,20 @@ function highlightSelectionAndShowModal() {
40
40
}
41
41
42
42
// Example: bind this function to mouseup event to trigger on text selection
43
- document . addEventListener ( 'mouseup' , highlightSelectionAndShowModal ) ;
43
+ document . addEventListener ( 'mouseup' , fetchSpanIds ) ;
44
44
45
45
function highlightBetweenIdsFromUrl ( ) {
46
46
// Parse the URL parameters
47
47
const urlParams = new URLSearchParams ( window . location . search ) ;
48
48
const startId = urlParams . get ( 'start-id' ) ;
49
49
const endId = urlParams . get ( 'end-id' ) ;
50
+ const annotationSource = urlParams ( 'annotations' )
51
+ if ( annotationSource ) {
52
+ fetch ( annotationSource )
53
+ . then ( ( res ) => {
54
+ console . log ( res )
55
+ } )
56
+ }
50
57
51
58
// If startId or endId is missing, stop
52
59
if ( ! startId || ! endId ) {
@@ -92,8 +99,8 @@ function highlightBetweenIdsFromUrl() {
92
99
93
100
// Move to the next node (including text nodes, elements, etc.)
94
101
currentElement = newEl . nextSibling ;
95
-
96
-
102
+
103
+
97
104
}
98
105
}
99
106
0 commit comments