Make WordPress Core

Changeset 29766 for trunk


Ignore:
Timestamp:
09/26/2014 12:20:28 AM (10 years ago)
Author:
azaozz
Message:

TinyMCE wpView: when pasting/inserting content before a view, add new paragraph above it and insert the content there. Props avryl, fixes #29380 for trunk.

File:
1 edited

Legend:

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

    r29615 r29766  
    1313        _noop = function() { return false; },
    1414        isios = /iPad|iPod|iPhone/.test( navigator.userAgent ),
    15         cursorInterval, lastKeyDownNode, setViewCursorTries, focus, execCommandView;
     15        cursorInterval, lastKeyDownNode, setViewCursorTries, focus, execCommandView, execCommandBefore;
    1616
    1717    function getView( node ) {
     
    369369    function isSpecialKey( key ) {
    370370        return ( ( key <= 47 && key !== VK.SPACEBAR && key !== VK.ENTER && key !== VK.DELETE && key !== VK.BACKSPACE && ( key < 37 || key > 40 ) ) ||
    371             key >= 224 || // OEM or non-printable 
     371            key >= 224 || // OEM or non-printable
    372372            ( key >= 144 && key <= 150 ) || // Num Lock, Scroll Lock, OEM
    373373            ( key >= 91 && key <= 93 ) || // Windows keys
     
    650650            view;
    651651
    652         if ( node && ( node.className === 'wpview-selection-before' || node.className === 'wpview-selection-after' ) && ( view = getView( node ) ) ) {
    653             handleEnter( view );
     652        if ( node && ( ( execCommandBefore = node.className === 'wpview-selection-before' ) || node.className === 'wpview-selection-after' ) && ( view = getView( node ) ) ) {
     653            handleEnter( view, execCommandBefore );
    654654            execCommandView = view;
    655655        }
     
    666666
    667667        if ( execCommandView ) {
    668             node = execCommandView.nextSibling;
     668            node = execCommandView[ execCommandBefore ? 'previousSibling' : 'nextSibling' ];
    669669
    670670            if ( node && node.nodeName === 'P' && editor.dom.isEmpty( node ) ) {
    671671                editor.dom.remove( node );
    672                 setViewCursor( false, execCommandView );
     672                setViewCursor( execCommandBefore, execCommandView );
    673673            }
    674674
Note: See TracChangeset for help on using the changeset viewer.