Changeset 38808
- Timestamp:
- 10/17/2016 08:00:53 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/wplink.js
r38126 r38808 125 125 } else { 126 126 editor = null; 127 }128 129 if ( editor && window.tinymce.isIE ) {130 editor.windowManager.wplinkBookmark = editor.selection.getBookmark();131 127 } 132 128 } … … 307 303 wpLink.correctURL(); 308 304 309 return { 310 href: $.trim( inputs.url.val() ), 311 target: inputs.openInNewTab.prop( 'checked' ) ? '_blank' : '' 305 var attrs = { 306 href: $.trim( inputs.url.val() ) 312 307 }; 308 309 if ( inputs.openInNewTab.prop( 'checked' ) ) { 310 attrs.target = '_blank'; 311 } 312 313 return attrs; 313 314 }, 314 315 … … 392 393 mceUpdate: function() { 393 394 var attrs = wpLink.getAttrs(), 394 link, text; 395 396 if ( window.tinymce.isIE && editor.windowManager.wplinkBookmark ) { 397 editor.selection.moveToBookmark( editor.windowManager.wplinkBookmark ); 398 editor.windowManager.wplinkBookmark = null; 399 } 395 $link, text, hasText, $mceCaret; 400 396 401 397 if ( ! attrs.href ) { … … 405 401 } 406 402 407 link = getLink(); 408 409 if ( inputs.wrap.hasClass( 'has-text-field' ) ) { 410 text = inputs.text.val() || attrs.href; 411 } 412 413 if ( link ) { 414 if ( text ) { 415 if ( 'innerText' in link ) { 416 link.innerText = text; 417 } else { 418 link.textContent = text; 403 $link = editor.$( getLink() ); 404 405 editor.undoManager.transact( function() { 406 if ( ! $link.length ) { 407 editor.execCommand( 'mceInsertLink', false, { href: '_wp_link_placeholder', 'data-wp-temp-link': 1 } ); 408 $link = editor.$( 'a[data-wp-temp-link="1"]' ).removeAttr( 'data-wp-temp-link' ); 409 hasText = $.trim( $link.text() ); 410 } 411 412 if ( ! $link.length ) { 413 editor.execCommand( 'unlink' ); 414 } else { 415 if ( inputs.wrap.hasClass( 'has-text-field' ) ) { 416 text = inputs.text.val(); 417 418 if ( text ) { 419 $link.text( text ); 420 } else if ( ! hasText ) { 421 $link.text( attrs.href ); 422 } 419 423 } 420 } 421 422 // Not editing any more 423 attrs['data-wplink-edit'] = null; 424 editor.dom.setAttribs( link, attrs ); 425 } else { 426 if ( text ) { 427 editor.selection.setNode( editor.dom.create( 'a', attrs, editor.dom.encode( text ) ) ); 428 } else { 429 editor.execCommand( 'mceInsertLink', false, attrs ); 430 } 431 } 424 425 attrs['data-wplink-edit'] = null; 426 attrs['data-mce-href'] = null; // attrs.href 427 $link.attr( attrs ); 428 } 429 } ); 432 430 433 431 wpLink.close( 'noReset' ); 434 432 editor.focus(); 433 434 if ( $link.length ) { 435 $mceCaret = $link.parent( '#_mce_caret' ); 436 437 if ( $mceCaret.length ) { 438 $mceCaret.before( $link.removeAttr( 'data-mce-bogus' ) ); 439 } 440 441 editor.selection.select( $link[0] ); 442 editor.selection.collapse(); 443 444 if ( editor.plugins.wplink ) { 445 editor.plugins.wplink.checkLink( $link[0] ); 446 } 447 } 448 435 449 editor.nodeChanged(); 436 437 if ( link && editor.plugins.wplink ) {438 editor.plugins.wplink.checkLink( link );439 }440 450 441 451 // Audible confirmation message when a link has been inserted in the Editor.
Note: See TracChangeset
for help on using the changeset viewer.