Changeset 44696
- Timestamp:
- 01/24/2019 11:20:25 AM (6 years ago)
- Location:
- trunk/src/js/_enqueues
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/js/_enqueues/lib/link.js
r43577 r44696 6 6 7 7 ( function( $, wpLinkL10n, wp ) { 8 var editor, searchTimer, River, Query, correctedURL, linkNode,8 var editor, searchTimer, River, Query, correctedURL, 9 9 emailRegexp = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,63}$/i, 10 10 urlRegexp = /^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,63}[^ "]*$/i, … … 14 14 15 15 function getLink() { 16 return linkNode || editor.dom.getParent( editor.selection.getNode(), 'a[href]' ); 16 if ( editor ) { 17 return editor.$( 'a[data-wplink-edit="true"]' ); 18 } 19 20 return null; 17 21 } 18 22 … … 98 102 }, 99 103 100 open: function( editorId, url, text , node) {104 open: function( editorId, url, text ) { 101 105 var ed, 102 106 $body = $( document.body ); … … 104 108 $body.addClass( 'modal-open' ); 105 109 wpLink.modalOpen = true; 106 linkNode = node;107 110 108 111 wpLink.range = null; … … 206 209 } 207 210 208 if ( linkNode ) {209 nodes = linkNode .childNodes;210 211 if ( nodes.length === 0) {211 if ( linkNode.length ) { 212 nodes = linkNode[0].childNodes; 213 214 if ( ! nodes || ! nodes.length ) { 212 215 return false; 213 216 } … … 230 233 onlyText = this.hasSelectedText( linkNode ); 231 234 232 if ( linkNode ) {233 linkText = linkNode.text Content || linkNode.innerText;234 href = editor.dom.getAttrib( linkNode,'href' );235 if ( linkNode.length ) { 236 linkText = linkNode.text(); 237 href = linkNode.attr( 'href' ); 235 238 236 239 if ( ! $.trim( linkText ) ) { … … 244 247 if ( href !== '_wp_link_placeholder' ) { 245 248 inputs.url.val( href ); 246 inputs.openInNewTab.prop( 'checked', '_blank' === editor.dom.getAttrib( linkNode,'target' ) );249 inputs.openInNewTab.prop( 'checked', '_blank' === linkNode.attr( 'target' ) ); 247 250 inputs.submit.val( wpLinkL10n.update ); 248 251 } else { … … 415 418 } 416 419 417 $link = editor.$( getLink());420 $link = getLink(); 418 421 419 422 editor.undoManager.transact( function() { … … 438 441 439 442 attrs['data-wplink-edit'] = null; 440 attrs['data-mce-href'] = null; // attrs.href443 attrs['data-mce-href'] = attrs.href; 441 444 $link.attr( attrs ); 442 445 } … … 447 450 448 451 if ( $link.length ) { 449 $mceCaret = $link.parent( '#_mce_caret' );450 451 if ( $mceCaret.length ) {452 $mceCaret.before( $link.removeAttr( 'data-mce-bogus' ) );453 }454 455 452 editor.selection.select( $link[0] ); 456 editor.selection.collapse();457 453 458 454 if ( editor.plugins.wplink ) { … … 469 465 updateFields: function( e, li ) { 470 466 inputs.url.val( li.children( '.item-permalink' ).val() ); 467 468 if ( inputs.wrap.hasClass( 'has-text-field' ) && ! inputs.text.val() ) { 469 inputs.text.val( li.children( '.item-title' ).text() ); 470 } 471 471 }, 472 472 -
trunk/src/js/_enqueues/vendor/tinymce/plugins/wplink/plugin.js
r43309 r44696 227 227 editToolbar.tempHide = false; 228 228 229 if ( linkNode ) { 230 editor.dom.setAttribs( linkNode, { 'data-wplink-edit': true } ); 231 } else { 229 if ( ! linkNode ) { 232 230 removePlaceholders(); 233 231 editor.execCommand( 'mceInsertLink', false, { href: '_wp_link_placeholder' } ); … … 236 234 editor.nodeChanged(); 237 235 } 236 237 editor.dom.setAttribs( linkNode, { 'data-wplink-edit': true } ); 238 238 } ); 239 239 … … 285 285 286 286 editor.addCommand( 'wp_link_cancel', function() { 287 inputInstance.reset(); 288 287 289 if ( ! editToolbar.tempHide ) { 288 inputInstance.reset();289 290 removePlaceholders(); 290 291 } … … 584 585 text = inputInstance.getLinkText() || null; 585 586 586 /* 587 * Accessibility note: moving focus back to the editor confuses 588 * screen readers. They will announce again the Editor ARIA role 589 * `application` and the iframe `title` attribute. 590 * 591 * Unfortunately IE looses the selection when the editor iframe 592 * looses focus, so without returning focus to the editor, the code 593 * in the modal will not be able to get the selection, place the caret 594 * at the same location, etc. 595 */ 596 if ( tinymce.Env.ie ) { 597 editor.focus(); // Needed for IE 598 } 587 window.wpLink.open( editor.id, url, text ); 599 588 600 589 editToolbar.tempHide = true; 601 window.wpLink.open( editor.id, url, text, linkNode ); 602 603 inputInstance.reset(); 590 editToolbar.hide(); 604 591 } 605 592 }
Note: See TracChangeset
for help on using the changeset viewer.