TinyMCE, inline link dialog:

- Reset the internal state when doing `unlink`, pressing `Escape`, and clicking elsewhere in the editor.
- Add the unlink shortcut from the wplink plugin as it triggers the new `wp_unlink` command.

Fixes #36781, #36732, #37153.

git-svn-id: https://develop.svn.wordpress.org/trunk@37906 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2016-06-29 09:41:50 +00:00
parent 0e6a328782
commit faa1a087e3
2 changed files with 15 additions and 5 deletions

View File

@ -540,7 +540,6 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
q: 'mceBlockQuote',
u: 'InsertUnorderedList',
o: 'InsertOrderedList',
s: 'unlink',
m: 'WP_Medialib',
z: 'WP_Adv',
t: 'WP_More',

View File

@ -300,13 +300,18 @@
if ( ! editToolbar.tempHide ) {
inputInstance.reset();
removePlaceholders();
editor.focus();
editToolbar.tempHide = false;
}
} );
// WP default shortcut
editor.addCommand( 'wp_unlink', function() {
editor.execCommand( 'unlink' );
editToolbar.tempHide = false;
editor.execCommand( 'wp_link_cancel' );
} );
// WP default shortcuts
editor.addShortcut( 'access+a', '', 'WP_Link' );
editor.addShortcut( 'access+s', '', 'wp_unlink' );
// The "de-facto standard" shortcut, see #27305
editor.addShortcut( 'meta+k', '', 'WP_Link' );
@ -367,6 +372,10 @@
// When doing undo and redo with keyboard shortcuts (Ctrl|Cmd+Z, Ctrl|Cmd+Shift+Z, Ctrl|Cmd+Y),
// set a flag to not focus the inline dialog. The editor has to remain focused so the users can do consecutive undo/redo.
editor.on( 'keydown', function( event ) {
if ( event.keyCode === 27 ) { // Esc
editor.execCommand( 'wp_link_cancel' );
}
if ( event.altKey || ( tinymce.Env.mac && ( ! event.metaKey || event.ctrlKey ) ) ||
( ! tinymce.Env.mac && ! event.ctrlKey ) ) {
@ -560,6 +569,8 @@
toolbar.$el.find( '.wp-link-preview a' ).removeClass( 'wplink-url-error' ).attr( 'title', null );
}
}
} else {
editor.execCommand( 'wp_link_cancel' );
}
} );
@ -572,7 +583,7 @@
editor.addButton( 'wp_link_remove', {
tooltip: 'Remove',
icon: 'dashicon dashicons-no',
cmd: 'unlink'
cmd: 'wp_unlink'
} );
editor.addButton( 'wp_link_advanced', {