| 271 | } |
| 272 | |
| 273 | function onUrlClick() { |
| 274 | |
| 275 | if ( optionsBox.className == 'options' ) { |
| 276 | |
| 277 | optionsBox.className = 'options url-mode'; |
| 278 | |
| 279 | // Set timeout here to debounce the focus action |
| 280 | setTimeout( function() { |
| 281 | |
| 282 | var nodeNames = findNodes( window.getSelection().focusNode ); |
| 283 | |
| 284 | if ( hasNode( nodeNames , "A" ) ) { |
| 285 | urlInput.value = nodeNames.url; |
| 286 | } else { |
| 287 | // Symbolize text turning into a link, which is temporary, and will never be seen. |
| 288 | document.execCommand( 'createLink', false, '/' ); |
| 289 | } |
| 290 | |
| 291 | // Since typing in the input box kills the highlighted text we need |
| 292 | // to save this selection, to add the url link if it is provided. |
| 293 | lastSelection = window.getSelection().getRangeAt(0); |
| 294 | lastType = false; |
| 295 | |
| 296 | urlInput.focus(); |
| 297 | |
| 298 | }, 100); |
| 299 | |
| 300 | } else { |
| 301 | |
| 302 | optionsBox.className = 'options'; |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | function onUrlInputKeyDown( event ) { |
| 307 | |