TinyMCE wplink:
- Remove the calls to getBookmark() and moveToBookmark() in IE. This is handled automatically when blurring and focusing the editor. - When inserting a link, move it out of the caret position element. If not, it may be removed with that element on clean-up before save. Fixes #38335. Built from https://develop.svn.wordpress.org/trunk@38808 git-svn-id: http://core.svn.wordpress.org/trunk@38751 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
11cb0c06a7
commit
f76fa00288
|
@ -125,10 +125,6 @@ var wpLink;
|
|||
} else {
|
||||
editor = null;
|
||||
}
|
||||
|
||||
if ( editor && window.tinymce.isIE ) {
|
||||
editor.windowManager.wplinkBookmark = editor.selection.getBookmark();
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! wpLink.isMCE() && document.selection ) {
|
||||
|
@ -306,10 +302,15 @@ var wpLink;
|
|||
getAttrs: function() {
|
||||
wpLink.correctURL();
|
||||
|
||||
return {
|
||||
href: $.trim( inputs.url.val() ),
|
||||
target: inputs.openInNewTab.prop( 'checked' ) ? '_blank' : ''
|
||||
var attrs = {
|
||||
href: $.trim( inputs.url.val() )
|
||||
};
|
||||
|
||||
if ( inputs.openInNewTab.prop( 'checked' ) ) {
|
||||
attrs.target = '_blank';
|
||||
}
|
||||
|
||||
return attrs;
|
||||
},
|
||||
|
||||
buildHtml: function(attrs) {
|
||||
|
@ -391,12 +392,7 @@ var wpLink;
|
|||
|
||||
mceUpdate: function() {
|
||||
var attrs = wpLink.getAttrs(),
|
||||
link, text;
|
||||
|
||||
if ( window.tinymce.isIE && editor.windowManager.wplinkBookmark ) {
|
||||
editor.selection.moveToBookmark( editor.windowManager.wplinkBookmark );
|
||||
editor.windowManager.wplinkBookmark = null;
|
||||
}
|
||||
$link, text, hasText, $mceCaret;
|
||||
|
||||
if ( ! attrs.href ) {
|
||||
editor.execCommand( 'unlink' );
|
||||
|
@ -404,40 +400,54 @@ var wpLink;
|
|||
return;
|
||||
}
|
||||
|
||||
link = getLink();
|
||||
$link = editor.$( getLink() );
|
||||
|
||||
if ( inputs.wrap.hasClass( 'has-text-field' ) ) {
|
||||
text = inputs.text.val() || attrs.href;
|
||||
}
|
||||
|
||||
if ( link ) {
|
||||
if ( text ) {
|
||||
if ( 'innerText' in link ) {
|
||||
link.innerText = text;
|
||||
} else {
|
||||
link.textContent = text;
|
||||
}
|
||||
editor.undoManager.transact( function() {
|
||||
if ( ! $link.length ) {
|
||||
editor.execCommand( 'mceInsertLink', false, { href: '_wp_link_placeholder', 'data-wp-temp-link': 1 } );
|
||||
$link = editor.$( 'a[data-wp-temp-link="1"]' ).removeAttr( 'data-wp-temp-link' );
|
||||
hasText = $.trim( $link.text() );
|
||||
}
|
||||
|
||||
// Not editing any more
|
||||
attrs['data-wplink-edit'] = null;
|
||||
editor.dom.setAttribs( link, attrs );
|
||||
} else {
|
||||
if ( text ) {
|
||||
editor.selection.setNode( editor.dom.create( 'a', attrs, editor.dom.encode( text ) ) );
|
||||
if ( ! $link.length ) {
|
||||
editor.execCommand( 'unlink' );
|
||||
} else {
|
||||
editor.execCommand( 'mceInsertLink', false, attrs );
|
||||
if ( inputs.wrap.hasClass( 'has-text-field' ) ) {
|
||||
text = inputs.text.val();
|
||||
|
||||
if ( text ) {
|
||||
$link.text( text );
|
||||
} else if ( ! hasText ) {
|
||||
$link.text( attrs.href );
|
||||
}
|
||||
}
|
||||
|
||||
attrs['data-wplink-edit'] = null;
|
||||
attrs['data-mce-href'] = null; // attrs.href
|
||||
$link.attr( attrs );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
wpLink.close( 'noReset' );
|
||||
editor.focus();
|
||||
editor.nodeChanged();
|
||||
|
||||
if ( link && editor.plugins.wplink ) {
|
||||
editor.plugins.wplink.checkLink( link );
|
||||
if ( $link.length ) {
|
||||
$mceCaret = $link.parent( '#_mce_caret' );
|
||||
|
||||
if ( $mceCaret.length ) {
|
||||
$mceCaret.before( $link.removeAttr( 'data-mce-bogus' ) );
|
||||
}
|
||||
|
||||
editor.selection.select( $link[0] );
|
||||
editor.selection.collapse();
|
||||
|
||||
if ( editor.plugins.wplink ) {
|
||||
editor.plugins.wplink.checkLink( $link[0] );
|
||||
}
|
||||
}
|
||||
|
||||
editor.nodeChanged();
|
||||
|
||||
// Audible confirmation message when a link has been inserted in the Editor.
|
||||
wp.a11y.speak( wpLinkL10n.linkInserted );
|
||||
},
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.7-alpha-38807';
|
||||
$wp_version = '4.7-alpha-38808';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue