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
This commit is contained in:
parent
3226d8b867
commit
27806558a2
@ -12,7 +12,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
|||||||
firstFocus = true,
|
firstFocus = true,
|
||||||
_noop = function() { return false; },
|
_noop = function() { return false; },
|
||||||
isios = /iPad|iPod|iPhone/.test( navigator.userAgent ),
|
isios = /iPad|iPod|iPhone/.test( navigator.userAgent ),
|
||||||
cursorInterval, lastKeyDownNode, setViewCursorTries, focus, execCommandView;
|
cursorInterval, lastKeyDownNode, setViewCursorTries, focus, execCommandView, execCommandBefore;
|
||||||
|
|
||||||
function getView( node ) {
|
function getView( node ) {
|
||||||
return getParent( node, 'wpview-wrap' );
|
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
|
// Ref: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.keyCode
|
||||||
function isSpecialKey( key ) {
|
function isSpecialKey( key ) {
|
||||||
return ( ( key <= 47 && key !== VK.SPACEBAR && key !== VK.ENTER && key !== VK.DELETE && key !== VK.BACKSPACE && ( key < 37 || key > 40 ) ) ||
|
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 >= 144 && key <= 150 ) || // Num Lock, Scroll Lock, OEM
|
||||||
( key >= 91 && key <= 93 ) || // Windows keys
|
( key >= 91 && key <= 93 ) || // Windows keys
|
||||||
( key >= 112 && key <= 135 ) ); // F keys
|
( key >= 112 && key <= 135 ) ); // F keys
|
||||||
@ -649,8 +649,8 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
|||||||
var node = editor.selection.getNode(),
|
var node = editor.selection.getNode(),
|
||||||
view;
|
view;
|
||||||
|
|
||||||
if ( node && ( node.className === 'wpview-selection-before' || node.className === 'wpview-selection-after' ) && ( view = getView( node ) ) ) {
|
if ( node && ( ( execCommandBefore = node.className === 'wpview-selection-before' ) || node.className === 'wpview-selection-after' ) && ( view = getView( node ) ) ) {
|
||||||
handleEnter( view );
|
handleEnter( view, execCommandBefore );
|
||||||
execCommandView = view;
|
execCommandView = view;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -665,11 +665,11 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( execCommandView ) {
|
if ( execCommandView ) {
|
||||||
node = execCommandView.nextSibling;
|
node = execCommandView[ execCommandBefore ? 'previousSibling' : 'nextSibling' ];
|
||||||
|
|
||||||
if ( node && node.nodeName === 'P' && editor.dom.isEmpty( node ) ) {
|
if ( node && node.nodeName === 'P' && editor.dom.isEmpty( node ) ) {
|
||||||
editor.dom.remove( node );
|
editor.dom.remove( node );
|
||||||
setViewCursor( false, execCommandView );
|
setViewCursor( execCommandBefore, execCommandView );
|
||||||
}
|
}
|
||||||
|
|
||||||
execCommandView = false;
|
execCommandView = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user