@@ -45,7 +45,7 @@ export class NodeTagSuggestPopover {
4545
4646 // If the rect has no dimensions (collapsed cursor), try using a temporary span to get cursor position
4747 if ( rect . width === 0 && rect . height === 0 ) {
48- const span = document . createElement ( "span" ) ;
48+ const span = activeDocument . createElement ( "span" ) ;
4949 span . textContent = "\u200B" ;
5050 range . insertNode ( span ) ;
5151 const spanRect = span . getBoundingClientRect ( ) ;
@@ -73,11 +73,11 @@ export class NodeTagSuggestPopover {
7373 }
7474
7575 private createPopover ( ) : HTMLElement {
76- const popover = document . createElement ( "div" ) ;
76+ const popover = activeDocument . createElement ( "div" ) ;
7777 popover . className =
7878 "node-tag-suggest-popover fixed z-[10000] bg-primary border border-modifier-border rounded-md shadow-[0_4px_12px_rgba(0,0,0,0.15)] max-h-[300px] overflow-y-auto min-w-[200px] max-w-[400px]" ;
7979
80- const itemsContainer = document . createElement ( "div" ) ;
80+ const itemsContainer = activeDocument . createElement ( "div" ) ;
8181 itemsContainer . className = "node-tag-items-container" ;
8282 popover . appendChild ( itemsContainer ) ;
8383
@@ -90,35 +90,35 @@ export class NodeTagSuggestPopover {
9090 container . innerHTML = "" ;
9191
9292 if ( this . items . length === 0 ) {
93- const noResults = document . createElement ( "div" ) ;
93+ const noResults = activeDocument . createElement ( "div" ) ;
9494 noResults . className = "p-3 text-center text-muted text-sm" ;
9595 noResults . textContent = "No node tags available" ;
9696 container . appendChild ( noResults ) ;
9797 return ;
9898 }
9999
100100 this . items . forEach ( ( item , index ) => {
101- const itemEl = document . createElement ( "div" ) ;
101+ const itemEl = activeDocument . createElement ( "div" ) ;
102102 itemEl . className = `node-tag-item px-3 py-2 cursor-pointer flex items-center gap-2 border-b border-[var(--background-modifier-border-hover)]${
103103 index === this . selectedIndex ? " bg-modifier-hover" : ""
104104 } `;
105105 itemEl . dataset . index = index . toString ( ) ;
106106
107107 if ( item . nodeType . color ) {
108- const colorDot = document . createElement ( "div" ) ;
108+ const colorDot = activeDocument . createElement ( "div" ) ;
109109 colorDot . className = `w-3 h-3 rounded-full shrink-0` ;
110110 colorDot . style . backgroundColor = item . nodeType . color ;
111111 itemEl . appendChild ( colorDot ) ;
112112 }
113113
114- const textContainer = document . createElement ( "div" ) ;
114+ const textContainer = activeDocument . createElement ( "div" ) ;
115115 textContainer . className = "flex flex-col gap-0.5 flex-1" ;
116116
117- const tagText = document . createElement ( "div" ) ;
117+ const tagText = activeDocument . createElement ( "div" ) ;
118118 tagText . textContent = `#${ item . tag } ` ;
119119 tagText . className = "font-medium text-normal text-sm" ;
120120
121- const nodeTypeText = document . createElement ( "div" ) ;
121+ const nodeTypeText = activeDocument . createElement ( "div" ) ;
122122 nodeTypeText . textContent = item . nodeType . name ;
123123 nodeTypeText . className = "text-xs text-muted" ;
124124
@@ -224,17 +224,25 @@ export class NodeTagSuggestPopover {
224224 }
225225 } ;
226226
227- document . addEventListener ( "keydown" , this . keydownHandler , true ) ;
228- document . addEventListener ( "mousedown" , this . clickOutsideHandler , true ) ;
227+ activeDocument . addEventListener ( "keydown" , this . keydownHandler , true ) ;
228+ activeDocument . addEventListener (
229+ "mousedown" ,
230+ this . clickOutsideHandler ,
231+ true ,
232+ ) ;
229233 }
230234
231235 private removeEventHandlers ( ) {
232236 if ( this . keydownHandler ) {
233- document . removeEventListener ( "keydown" , this . keydownHandler , true ) ;
237+ activeDocument . removeEventListener ( "keydown" , this . keydownHandler , true ) ;
234238 this . keydownHandler = null ;
235239 }
236240 if ( this . clickOutsideHandler ) {
237- document . removeEventListener ( "mousedown" , this . clickOutsideHandler , true ) ;
241+ activeDocument . removeEventListener (
242+ "mousedown" ,
243+ this . clickOutsideHandler ,
244+ true ,
245+ ) ;
238246 this . clickOutsideHandler = null ;
239247 }
240248 }
@@ -251,7 +259,7 @@ export class NodeTagSuggestPopover {
251259 }
252260
253261 this . popover = this . createPopover ( ) ;
254- document . body . appendChild ( this . popover ) ;
262+ activeDocument . body . appendChild ( this . popover ) ;
255263
256264 const popoverRect = this . popover . getBoundingClientRect ( ) ;
257265 const viewportWidth = window . innerWidth ;
0 commit comments