@@ -95,30 +95,30 @@ function RemoteFunctions(config = {}) {
9595 "udpateHotCornerState" // to update the hot corner button when state changes
9696 ] ;
9797
98- const _moreOptionsHandlers = new Map ( ) ;
99- function registerNodeMoreOptionsHandler ( handlerName , handler ) {
100- if ( _moreOptionsHandlers . get ( handlerName ) ) {
101- console . error ( `lp: More options handler '${ handlerName } ' already registered. Ignoring new registration` ) ;
98+ const _toolHandlers = new Map ( ) ;
99+ function registerToolHandler ( handlerName , handler ) {
100+ if ( _toolHandlers . get ( handlerName ) ) {
101+ console . error ( `lp: Tool handler '${ handlerName } ' already registered. Ignoring new registration` ) ;
102102 return ;
103103 }
104104 if ( ! handler || typeof handler !== "object" ) {
105- console . error ( `lp: More options handler '${ handlerName } ' value is invalid ${ JSON . stringify ( handler ) } .` ) ;
105+ console . error ( `lp: Tool handler '${ handlerName } ' value is invalid ${ JSON . stringify ( handler ) } .` ) ;
106106 return ;
107107 }
108108 handler . handlerName = handlerName ;
109109 for ( const key of Object . keys ( handler ) ) {
110110 if ( key !== "handlerName" && ! allowedHandlerFns . includes ( key ) ) {
111- console . warn ( `lp: More options handler '${ handlerName } ' has unknown property '${ key } '` ,
111+ console . warn ( `lp: Tool handler '${ handlerName } ' has unknown property '${ key } '` ,
112112 `should be one of ${ allowedHandlerFns . join ( "," ) } ` ) ;
113113 }
114114 }
115- _moreOptionsHandlers . set ( handlerName , handler ) ;
115+ _toolHandlers . set ( handlerName , handler ) ;
116116 }
117- function getNodeMoreOptionsHandler ( handlerName ) {
118- return _moreOptionsHandlers . get ( handlerName ) ;
117+ function getToolHandler ( handlerName ) {
118+ return _toolHandlers . get ( handlerName ) ;
119119 }
120- function getAllNodeMoreOptionsHandlers ( ) {
121- return Array . from ( _moreOptionsHandlers . values ( ) ) ;
120+ function getAllToolHandlers ( ) {
121+ return Array . from ( _toolHandlers . values ( ) ) ;
122122 }
123123
124124 /**
@@ -179,9 +179,9 @@ function RemoteFunctions(config = {}) {
179179 }
180180
181181 const LivePreviewView = {
182- registerNodeMoreOptionsHandler : registerNodeMoreOptionsHandler ,
183- getNodeMoreOptionsHandler : getNodeMoreOptionsHandler ,
184- getAllNodeMoreOptionsHandlers : getAllNodeMoreOptionsHandlers ,
182+ registerToolHandler : registerToolHandler ,
183+ getToolHandler : getToolHandler ,
184+ getAllToolHandlers : getAllToolHandlers ,
185185 isElementEditable : isElementEditable ,
186186 isElementInspectable : isElementInspectable ,
187187 screenOffset : screenOffset ,
@@ -290,8 +290,8 @@ function RemoteFunctions(config = {}) {
290290 * @param {DOMElement } element - the selected DOM element
291291 */
292292 function handleOptionClick ( e , action , element ) {
293- if ( LivePreviewView . getNodeMoreOptionsHandler ( action ) ) {
294- const handler = LivePreviewView . getNodeMoreOptionsHandler ( action ) ;
293+ if ( LivePreviewView . getToolHandler ( action ) ) {
294+ const handler = LivePreviewView . getToolHandler ( action ) ;
295295 return handler && handler . handleClick &&
296296 handler . handleClick ( e , element , _toolBox && _toolBox . _shadow ) ;
297297 }
@@ -598,7 +598,7 @@ function RemoteFunctions(config = {}) {
598598
599599 let content = `<div class="tool-items">` ;
600600 // Render handler options with ordering support
601- const handlerOptions = LivePreviewView . getAllNodeMoreOptionsHandlers ( )
601+ const handlerOptions = LivePreviewView . getAllToolHandlers ( )
602602 . map ( ( handler , index ) => {
603603 if ( ! handler . renderToolBoxItem ) {
604604 return null ;
@@ -791,7 +791,7 @@ function RemoteFunctions(config = {}) {
791791 const shadow = this . body . attachShadow ( { mode : "open" } ) ;
792792
793793 // Render handler dropdown items with ordering support
794- const handlerItems = getAllNodeMoreOptionsHandlers ( )
794+ const handlerItems = getAllToolHandlers ( )
795795 . map ( ( handler , index ) => {
796796 if ( ! handler . renderDropdownItems ) {
797797 return null ;
@@ -853,7 +853,7 @@ function RemoteFunctions(config = {}) {
853853
854854 // Check if any handler wants to handle this dropdown action
855855 let handlerHandledIt = false ;
856- const handler = LivePreviewView . getNodeMoreOptionsHandler ( action ) ;
856+ const handler = LivePreviewView . getToolHandler ( action ) ;
857857 if ( handler && handler . handleDropdownClick ) {
858858 handlerHandledIt = handler . handleDropdownClick ( event , this . targetElement , this ) ;
859859 if ( handlerHandledIt ) {
@@ -1432,7 +1432,7 @@ function RemoteFunctions(config = {}) {
14321432
14331433 // when user clicks on a non-editable element
14341434 if ( ! element . hasAttribute ( GLOBALS . DATA_BRACKETS_ID_ATTR ) ) {
1435- getAllNodeMoreOptionsHandlers ( ) . forEach ( handler => {
1435+ getAllToolHandlers ( ) . forEach ( handler => {
14361436 if ( handler . onNonEditableElementClick ) {
14371437 handler . onNonEditableElementClick ( element ) ;
14381438 }
@@ -1449,7 +1449,7 @@ function RemoteFunctions(config = {}) {
14491449 _infoBox = new InfoBox ( element ) ;
14501450
14511451 // Notify handlers about element selection
1452- getAllNodeMoreOptionsHandlers ( ) . forEach ( handler => {
1452+ getAllToolHandlers ( ) . forEach ( handler => {
14531453 if ( handler . onElementSelected ) {
14541454 handler . onElementSelected ( element ) ;
14551455 }
@@ -1653,7 +1653,7 @@ function RemoteFunctions(config = {}) {
16531653 redrawHighlights ( ) ;
16541654 redrawUIBoxes ( ) ;
16551655 // Call redraw on all registered handlers
1656- getAllNodeMoreOptionsHandlers ( ) . forEach ( handler => {
1656+ getAllToolHandlers ( ) . forEach ( handler => {
16571657 if ( handler . redraw ) {
16581658 handler . redraw ( ) ;
16591659 }
@@ -2027,7 +2027,7 @@ function RemoteFunctions(config = {}) {
20272027 config = newConfig ;
20282028
20292029 // Notify handlers about config changes
2030- getAllNodeMoreOptionsHandlers ( ) . forEach ( handler => {
2030+ getAllToolHandlers ( ) . forEach ( handler => {
20312031 if ( handler . handleConfigChange ) {
20322032 handler . handleConfigChange ( oldConfig , config ) ;
20332033 }
@@ -2125,7 +2125,7 @@ function RemoteFunctions(config = {}) {
21252125 dismissToolBox ( ) ;
21262126 dismissMoreOptionsDropdown ( ) ;
21272127 dismissInfoBox ( ) ;
2128- getAllNodeMoreOptionsHandlers ( ) . forEach ( handler => ( handler . dismiss && handler . dismiss ( ) ) ) ;
2128+ getAllToolHandlers ( ) . forEach ( handler => ( handler . dismiss && handler . dismiss ( ) ) ) ;
21292129 }
21302130
21312131 /**
@@ -2146,7 +2146,7 @@ function RemoteFunctions(config = {}) {
21462146 }
21472147
21482148 // Notify handlers about cleanup
2149- getAllNodeMoreOptionsHandlers ( ) . forEach ( handler => {
2149+ getAllToolHandlers ( ) . forEach ( handler => {
21502150 if ( handler . onElementCleanup ) {
21512151 handler . onElementCleanup ( ) ;
21522152 }
@@ -2183,7 +2183,7 @@ function RemoteFunctions(config = {}) {
21832183 window . document . removeEventListener ( "mouseover" , onElementHover ) ;
21842184 window . document . removeEventListener ( "mouseout" , onElementHoverOut ) ;
21852185 window . document . removeEventListener ( "keydown" , onKeyDown ) ;
2186- getAllNodeMoreOptionsHandlers ( ) . forEach ( handler => {
2186+ getAllToolHandlers ( ) . forEach ( handler => {
21872187 if ( handler . unregisterInteractionBlocker ) {
21882188 handler . unregisterInteractionBlocker ( ) ;
21892189 }
@@ -2203,7 +2203,7 @@ function RemoteFunctions(config = {}) {
22032203
22042204 // this is to block all the interactions of the user created elements
22052205 // so that lets say user created link doesn't redirect in edit mode
2206- getAllNodeMoreOptionsHandlers ( ) . forEach ( handler => {
2206+ getAllToolHandlers ( ) . forEach ( handler => {
22072207 if ( handler . registerInteractionBlocker ) {
22082208 handler . registerInteractionBlocker ( ) ;
22092209 }
@@ -2212,7 +2212,7 @@ function RemoteFunctions(config = {}) {
22122212 // Clean up any existing UI when edit features are disabled
22132213 dismissUIAndCleanupState ( ) ;
22142214 }
2215- getAllNodeMoreOptionsHandlers ( ) . forEach ( handler => {
2215+ getAllToolHandlers ( ) . forEach ( handler => {
22162216 if ( handler . reRegisterEventHandlers ) {
22172217 handler . reRegisterEventHandlers ( ) ;
22182218 }
@@ -2222,7 +2222,7 @@ function RemoteFunctions(config = {}) {
22222222 function _escapeKeyPressInEditor ( ) {
22232223 enableHoverListeners ( ) ; // so that if hover lock is there it will get cleared
22242224 dismissUIAndCleanupState ( ) ;
2225- getAllNodeMoreOptionsHandlers ( ) . forEach ( handler => {
2225+ getAllToolHandlers ( ) . forEach ( handler => {
22262226 if ( handler . handleEscapePressFromEditor ) {
22272227 handler . handleEscapePressFromEditor ( ) ;
22282228 }
0 commit comments