TinyMCE, inline link:
- Make sure the inline dialog is not showing under the advanced modal. - Fix checking if the link node contains text. - Fix undo levels so all actions can be undone and redone. See #33301. git-svn-id: https://develop.svn.wordpress.org/trunk@36716 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
6cf0caf13e
commit
1cfdb05750
@ -885,7 +885,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
|||||||
|
|
||||||
function hide( event ) {
|
function hide( event ) {
|
||||||
if ( activeToolbar ) {
|
if ( activeToolbar ) {
|
||||||
if ( event.type === 'hide' ) {
|
if ( activeToolbar.tempHide || event.type === 'hide' ) {
|
||||||
activeToolbar.hide();
|
activeToolbar.hide();
|
||||||
activeToolbar = false;
|
activeToolbar = false;
|
||||||
} else if ( ( event.type === 'resize' || event.type === 'scroll' ) && ! activeToolbar.blockHide ) {
|
} else if ( ( event.type === 'resize' || event.type === 'scroll' ) && ! activeToolbar.blockHide ) {
|
||||||
|
@ -223,13 +223,17 @@
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
editor.addCommand( 'wp_link_cancel', function() {
|
editor.addCommand( 'wp_link_cancel', function() {
|
||||||
inputInstance.reset();
|
if ( ! editToolbar.tempHide ) {
|
||||||
removePlaceholders();
|
inputInstance.reset();
|
||||||
editor.focus();
|
removePlaceholders();
|
||||||
|
editor.focus();
|
||||||
if ( tinymce.isIE ) {
|
|
||||||
editor.selection.moveToBookmark( editor.windowManager.wplinkBookmark );
|
if ( tinymce.isIE ) {
|
||||||
editor.windowManager.wplinkBookmark = null;
|
editor.selection.moveToBookmark( editor.windowManager.wplinkBookmark );
|
||||||
|
editor.windowManager.wplinkBookmark = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
editToolbar.tempHide = false;
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
@ -285,8 +289,10 @@
|
|||||||
|
|
||||||
// Prevent adding undo levels on inserting link placeholder.
|
// Prevent adding undo levels on inserting link placeholder.
|
||||||
editor.on( 'BeforeAddUndo', function( event ) {
|
editor.on( 'BeforeAddUndo', function( event ) {
|
||||||
if ( event.level.content ) {
|
if ( event.lastLevel && event.lastLevel.content && event.level.content &&
|
||||||
event.level.content = removePlaceholderStrings( event.level.content );
|
event.lastLevel.content === removePlaceholderStrings( event.level.content ) ) {
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -388,9 +394,12 @@
|
|||||||
$linkNode, href, edit;
|
$linkNode, href, edit;
|
||||||
|
|
||||||
if ( tinymce.$( document.body ).hasClass( 'modal-open' ) ) {
|
if ( tinymce.$( document.body ).hasClass( 'modal-open' ) ) {
|
||||||
|
editToolbar.tempHide = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
editToolbar.tempHide = false;
|
||||||
|
|
||||||
if ( linkNode ) {
|
if ( linkNode ) {
|
||||||
$linkNode = editor.$( linkNode );
|
$linkNode = editor.$( linkNode );
|
||||||
href = $linkNode.attr( 'href' );
|
href = $linkNode.attr( 'href' );
|
||||||
@ -432,8 +441,10 @@
|
|||||||
var url = inputInstance.getURL() || null,
|
var url = inputInstance.getURL() || null,
|
||||||
text = inputInstance.getLinkText() || null;
|
text = inputInstance.getLinkText() || null;
|
||||||
|
|
||||||
editor.focus();
|
editor.focus(); // Needed for IE
|
||||||
window.wpLink.open( editor.id, url, text );
|
window.wpLink.open( editor.id, url, text );
|
||||||
|
|
||||||
|
editToolbar.tempHide = true;
|
||||||
inputInstance.reset();
|
inputInstance.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -447,8 +458,9 @@
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
return {
|
return {
|
||||||
hideEditToolbar: function() {
|
close: function() {
|
||||||
editToolbar.hide();
|
editToolbar.tempHide = false;
|
||||||
|
editor.execCommand( 'wp_link_cancel' );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} );
|
} );
|
||||||
|
@ -244,11 +244,17 @@ var wpLink;
|
|||||||
},
|
},
|
||||||
|
|
||||||
mceRefresh: function( url, text ) {
|
mceRefresh: function( url, text ) {
|
||||||
var linkNode = editor.dom.getParent( editor.selection.getNode(), 'a[href]' ),
|
var linkText,
|
||||||
|
linkNode = getLink(),
|
||||||
onlyText = this.hasSelectedText( linkNode );
|
onlyText = this.hasSelectedText( linkNode );
|
||||||
|
|
||||||
if ( linkNode ) {
|
if ( linkNode ) {
|
||||||
text = tinymce.trim( linkNode.innerText || linkNode.textContent ) || text;
|
linkText = linkNode.innerText || linkNode.textContent;
|
||||||
|
|
||||||
|
if ( ! tinymce.trim( linkText ) ) {
|
||||||
|
linkText = text || '';
|
||||||
|
}
|
||||||
|
|
||||||
url = url || editor.dom.getAttrib( linkNode, 'href' );
|
url = url || editor.dom.getAttrib( linkNode, 'href' );
|
||||||
|
|
||||||
if ( url === '_wp_link_placeholder' ) {
|
if ( url === '_wp_link_placeholder' ) {
|
||||||
@ -264,7 +270,7 @@ var wpLink;
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( onlyText ) {
|
if ( onlyText ) {
|
||||||
inputs.text.val( text || '' );
|
inputs.text.val( linkText || '' );
|
||||||
inputs.wrap.addClass( 'has-text-field' );
|
inputs.wrap.addClass( 'has-text-field' );
|
||||||
} else {
|
} else {
|
||||||
inputs.text.val( '' );
|
inputs.text.val( '' );
|
||||||
@ -283,7 +289,10 @@ var wpLink;
|
|||||||
wpLink.range.select();
|
wpLink.range.select();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
editor.plugins.wplink.hideEditToolbar();
|
if ( editor.plugins.wplink ) {
|
||||||
|
editor.plugins.wplink.close();
|
||||||
|
}
|
||||||
|
|
||||||
editor.focus();
|
editor.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user