Make WordPress Core

Changeset 29535


Ignore:
Timestamp:
08/19/2014 03:26:14 AM (10 years ago)
Author:
azaozz
Message:

TinyMCE wpView: ignore more keys when the caret is around a view. Part props avryl, fixes #29115.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/tinymce/plugins/wpview/plugin.js

    r29530 r29535  
    354354    });
    355355
     356    // Excludes arrow keys, delete, backspace, enter, space bar.
     357    function isSpecialKey( key ) {
     358        return ( ( key <= 47 && key !== VK.SPACEBAR && key !== VK.ENTER && key !== VK.DELETE && key !== VK.BACKSPACE && ( key < 37 || key > 40 ) ) ||
     359            key === 144 || key === 145 || // Num Lock, Scroll Lock
     360            ( key >= 91 && key <= 93 ) || // Windows keys
     361            ( key >= 112 && key <= 123 ) ); // F keys
     362    }
     363
    356364    // (De)select views when arrow keys are used to navigate the content of the editor.
    357365    editor.on( 'keydown', function( event ) {
     
    411419                    setViewCursor( false, view );
    412420                }
     421
    413422                event.preventDefault();
    414423            // Ignore keys that don't insert anything.
    415             } else if ( ( key > 47 || VK.SPACEBAR || key === VK.ENTER || key === VK.DELETE || key === VK.BACKSPACE ) && key !== 144 && key !== 145 ) {
     424            } else if ( ! isSpecialKey( key ) ) {
    416425                removeView( selected );
    417426
     
    473482            }
    474483
     484            if ( isSpecialKey( key ) ) {
     485                // ignore
     486                return;
     487            }
     488
    475489            if ( ( cursorAfter && key === VK.UP ) || ( cursorBefore && key === VK.BACKSPACE ) ) {
    476490                if ( view.previousSibling ) {
Note: See TracChangeset for help on using the changeset viewer.