TinyMCE wpView: ignore more keys when the caret is around a view. Part props avryl, fixes #29115.
Built from https://develop.svn.wordpress.org/trunk@29535 git-svn-id: http://core.svn.wordpress.org/trunk@29311 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f5ec2a211b
commit
74f6ddc816
|
@ -353,6 +353,14 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
|||
}
|
||||
});
|
||||
|
||||
// Excludes arrow keys, delete, backspace, enter, space bar.
|
||||
function isSpecialKey( key ) {
|
||||
return ( ( key <= 47 && key !== VK.SPACEBAR && key !== VK.ENTER && key !== VK.DELETE && key !== VK.BACKSPACE && ( key < 37 || key > 40 ) ) ||
|
||||
key === 144 || key === 145 || // Num Lock, Scroll Lock
|
||||
( key >= 91 && key <= 93 ) || // Windows keys
|
||||
( key >= 112 && key <= 123 ) ); // F keys
|
||||
}
|
||||
|
||||
// (De)select views when arrow keys are used to navigate the content of the editor.
|
||||
editor.on( 'keydown', function( event ) {
|
||||
var key = event.keyCode,
|
||||
|
@ -410,9 +418,10 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
|||
} else {
|
||||
setViewCursor( false, view );
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
// Ignore keys that don't insert anything.
|
||||
} else if ( ( key > 47 || VK.SPACEBAR || key === VK.ENTER || key === VK.DELETE || key === VK.BACKSPACE ) && key !== 144 && key !== 145 ) {
|
||||
} else if ( ! isSpecialKey( key ) ) {
|
||||
removeView( selected );
|
||||
|
||||
if ( key === VK.ENTER || key === VK.DELETE || key === VK.BACKSPACE ) {
|
||||
|
@ -472,6 +481,11 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ( isSpecialKey( key ) ) {
|
||||
// ignore
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ( cursorAfter && key === VK.UP ) || ( cursorBefore && key === VK.BACKSPACE ) ) {
|
||||
if ( view.previousSibling ) {
|
||||
if ( getView( view.previousSibling ) ) {
|
||||
|
|
File diff suppressed because one or more lines are too long
Binary file not shown.
Loading…
Reference in New Issue