From 27806558a2b93a0e01a1f5e2d52f157ec399903e Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Fri, 26 Sep 2014 00:20:28 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@29766 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/tinymce/plugins/wpview/plugin.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/wp-includes/js/tinymce/plugins/wpview/plugin.js b/src/wp-includes/js/tinymce/plugins/wpview/plugin.js index 7bbf46657b..3de4949f86 100644 --- a/src/wp-includes/js/tinymce/plugins/wpview/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wpview/plugin.js @@ -12,7 +12,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) { firstFocus = true, _noop = function() { return false; }, isios = /iPad|iPod|iPhone/.test( navigator.userAgent ), - cursorInterval, lastKeyDownNode, setViewCursorTries, focus, execCommandView; + cursorInterval, lastKeyDownNode, setViewCursorTries, focus, execCommandView, execCommandBefore; function getView( node ) { return getParent( node, 'wpview-wrap' ); @@ -368,7 +368,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) { // Ref: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.keyCode function isSpecialKey( key ) { return ( ( key <= 47 && key !== VK.SPACEBAR && key !== VK.ENTER && key !== VK.DELETE && key !== VK.BACKSPACE && ( key < 37 || key > 40 ) ) || - key >= 224 || // OEM or non-printable + key >= 224 || // OEM or non-printable ( key >= 144 && key <= 150 ) || // Num Lock, Scroll Lock, OEM ( key >= 91 && key <= 93 ) || // Windows keys ( key >= 112 && key <= 135 ) ); // F keys @@ -649,8 +649,8 @@ tinymce.PluginManager.add( 'wpview', function( editor ) { var node = editor.selection.getNode(), view; - if ( node && ( node.className === 'wpview-selection-before' || node.className === 'wpview-selection-after' ) && ( view = getView( node ) ) ) { - handleEnter( view ); + if ( node && ( ( execCommandBefore = node.className === 'wpview-selection-before' ) || node.className === 'wpview-selection-after' ) && ( view = getView( node ) ) ) { + handleEnter( view, execCommandBefore ); execCommandView = view; } }); @@ -665,11 +665,11 @@ tinymce.PluginManager.add( 'wpview', function( editor ) { } if ( execCommandView ) { - node = execCommandView.nextSibling; + node = execCommandView[ execCommandBefore ? 'previousSibling' : 'nextSibling' ]; if ( node && node.nodeName === 'P' && editor.dom.isEmpty( node ) ) { editor.dom.remove( node ); - setViewCursor( false, execCommandView ); + setViewCursor( execCommandBefore, execCommandView ); } execCommandView = false;