MCPcopy
hub / github.com/tholman/zenpen / checkTextHighlighting

Function checkTextHighlighting

js/editor.js:102–138  ·  view source on GitHub ↗
( event )

Source from the content-addressed store, hash-verified

100 }
101
102 function checkTextHighlighting( event ) {
103
104 var selection = window.getSelection();
105
106
107 if ( (event.target.className === "url-input" ||
108 event.target.classList.contains( "url" ) ||
109 event.target.parentNode.classList.contains( "ui-inputs" ) ) ) {
110
111 currentNodeList = findNodes( selection.focusNode );
112 updateBubbleStates();
113 return;
114 }
115
116 // Check selections exist
117 if ( selection.isCollapsed === true && lastType === false ) {
118
119 onSelectorBlur();
120 }
121
122 // Text is selected
123 if ( selection.isCollapsed === false && composing === false ) {
124
125 currentNodeList = findNodes( selection.focusNode );
126
127 // Find if highlighting is in the editable area
128 if ( hasNode( currentNodeList, "ARTICLE") ) {
129 updateBubbleStates();
130 updateBubblePosition();
131
132 // Show the ui bubble
133 textOptions.className = "text-options active";
134 }
135 }
136
137 lastType = selection.isCollapsed;
138 }
139
140 function updateBubblePosition() {
141 var selection = window.getSelection();

Callers 1

createEventBindingsFunction · 0.85

Calls 5

findNodesFunction · 0.85
updateBubbleStatesFunction · 0.85
onSelectorBlurFunction · 0.85
hasNodeFunction · 0.85
updateBubblePositionFunction · 0.85

Tested by

no test coverage detected