@@ -1081,12 +1081,17 @@ class AnnotoriousAnnotator extends HTMLElement {
10811081 this . shadowRoot . querySelectorAll ( ".toggleEditType" ) . forEach ( el => { el . classList . remove ( "selected" ) } )
10821082 e . target . classList . add ( "selected" )
10831083 this . #editType = "add"
1084- if ( this . #annotoriousInstance. getSelected ( ) . length ) ruler . style . display = "block"
1084+ if ( this . #annotoriousInstance. getSelected ( ) . length ) {
1085+ ruler . style . display = "block"
1086+ // Apply cursor behavior if an annotation is already selected
1087+ this . applyCursorBehavior ( )
1088+ }
10851089 }
10861090 }
10871091
10881092 toggleMergeLines ( e ) {
10891093 if ( ! this . #isLineEditing) return
1094+ // Merge mode doesn't use the ruler (only add mode does)
10901095 this . removeRuler ( )
10911096 if ( e . target . classList . contains ( "selected" ) ) {
10921097 e . target . classList . remove ( "selected" )
@@ -1097,8 +1102,13 @@ class AnnotoriousAnnotator extends HTMLElement {
10971102 this . shadowRoot . querySelectorAll ( ".toggleEditType" ) . forEach ( el => { el . classList . remove ( "selected" ) } )
10981103 e . target . classList . add ( "selected" )
10991104 this . #editType = "merge"
1100- // Don't strictly HAVE to cancel, but it helps control the cursor.
1101- this . #annotoriousInstance. cancelSelected ( )
1105+ // Apply cursor behavior if an annotation is already selected
1106+ if ( this . #annotoriousInstance. getSelected ( ) . length ) {
1107+ this . applyCursorBehavior ( )
1108+ } else {
1109+ // Don't strictly HAVE to cancel, but it helps control the cursor.
1110+ this . #annotoriousInstance. cancelSelected ( )
1111+ }
11021112 }
11031113 }
11041114
@@ -1193,6 +1203,10 @@ class AnnotoriousAnnotator extends HTMLElement {
11931203 this . shadowRoot . querySelector ( ".editOptions" ) . style . display = "block"
11941204 this . shadowRoot . querySelectorAll ( ".toggleEditType" ) . forEach ( el => { el . classList . remove ( "selected" ) } )
11951205 this . #editType = ""
1206+ // If an annotation is already selected, update the cursor behavior
1207+ if ( this . #annotoriousInstance. getSelected ( ) . length ) {
1208+ this . applyCursorBehavior ( )
1209+ }
11961210 const toast = {
11971211 message : "You started line editing" ,
11981212 status : "info"
@@ -1431,8 +1445,6 @@ class AnnotoriousAnnotator extends HTMLElement {
14311445 const cursorHandleElem = this . #annotoriousInstance. viewer . element . querySelector ( ".a9s-shape-handle" )
14321446 const ruler = this . shadowRoot . getElementById ( "ruler" )
14331447 const _this = this
1434- let mouseStart = 0
1435- let mouseFinish = 0
14361448
14371449 // Cursor support for editing options, applies when an Annotation is clicked and selected.
14381450 if ( this . #isLineEditing) {
@@ -1452,6 +1464,11 @@ class AnnotoriousAnnotator extends HTMLElement {
14521464 cursorHandleElem . style . cursor = "move"
14531465 }
14541466
1467+ // Variables for tracking mouse position during click vs drag detection
1468+ // Declared here so they're captured in the event listener closures below
1469+ let mouseStart = 0
1470+ let mouseFinish = 0
1471+
14551472 // Further cursor support when user changes edit options while an Annotation is selected.
14561473 elem . addEventListener ( 'mouseenter' , function ( e ) {
14571474 if ( _this . #isLineEditing) {
0 commit comments