TinyMCE, inline link: when doing undo/redo with keyboard shortcut, do not focus the inline dialog. Cannot do consecutive undo/redo if the focus is moved away from the editor.

See #33301.
Built from https://develop.svn.wordpress.org/trunk@36982


git-svn-id: http://core.svn.wordpress.org/trunk@36949 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2016-03-13 22:44:25 +00:00
parent dee2f6ccb7
commit c495d3b2b3
4 changed files with 27 additions and 4 deletions

View File

@ -90,6 +90,8 @@
var previewInstance;
var inputInstance;
var linkNode;
var doingUndoRedo;
var doingUndoRedoTimer;
var $ = window.jQuery;
function getSelectedLink() {
@ -166,8 +168,10 @@
element.value = window.wpLink.getUrlFromSelection( selection );
}
element.focus();
element.select();
if ( ! doingUndoRedo ) {
element.focus();
element.select();
}
}
} );
}
@ -301,6 +305,25 @@
}
});
// 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.altKey || ( tinymce.Env.mac && ( ! event.metaKey || event.ctrlKey ) ) ||
( ! tinymce.Env.mac && ! event.ctrlKey ) ) {
return;
}
if ( event.keyCode === 89 || event.keyCode === 90 ) { // Y or Z
doingUndoRedo = true;
window.clearTimeout( doingUndoRedoTimer );
doingUndoRedoTimer = window.setTimeout( function() {
doingUndoRedo = false;
}, 500 );
}
} );
editor.addButton( 'wp_link_preview', {
type: 'WPLinkPreview',
onPostRender: function() {

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.5-beta3-36981';
$wp_version = '4.5-beta3-36982';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.