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. git-svn-id: https://develop.svn.wordpress.org/trunk@36982 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
98c197f09f
commit
4fcb429575
|
@ -90,6 +90,8 @@
|
|||
var previewInstance;
|
||||
var inputInstance;
|
||||
var linkNode;
|
||||
var doingUndoRedo;
|
||||
var doingUndoRedoTimer;
|
||||
var $ = window.jQuery;
|
||||
|
||||
function getSelectedLink() {
|
||||
|
@ -166,9 +168,11 @@
|
|||
element.value = window.wpLink.getUrlFromSelection( selection );
|
||||
}
|
||||
|
||||
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() {
|
||||
|
|
Loading…
Reference in New Issue