mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-02 05:31:25 +01:00
TinyMCE wpView: handle execCommand when the "fake caret" P is selected, props avryl, see #28595
Built from https://develop.svn.wordpress.org/trunk@29184 git-svn-id: http://core.svn.wordpress.org/trunk@28968 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c6afe2dd3e
commit
5bef617d04
@ -1,4 +1,4 @@
|
||||
/* global tinymce, MediaElementPlayer, WPPlaylistView */
|
||||
/* global tinymce */
|
||||
/**
|
||||
* Note: this API is "experimental" meaning that it will probably change
|
||||
* in the next few releases based on feedback from 3.9.0.
|
||||
|
@ -10,7 +10,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
||||
TreeWalker = tinymce.dom.TreeWalker,
|
||||
toRemove = false,
|
||||
firstFocus = true,
|
||||
cursorInterval, lastKeyDownNode, setViewCursorTries, focus;
|
||||
cursorInterval, lastKeyDownNode, setViewCursorTries, focus, execCommandView;
|
||||
|
||||
function getView( node ) {
|
||||
return getParent( node, 'wpview-wrap' );
|
||||
@ -581,7 +581,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
||||
|
||||
if ( focus ) {
|
||||
if ( view ) {
|
||||
if ( className === 'wpview-selection-before' || className === 'wpview-selection-after' && editor.selection.isCollapsed() ) {
|
||||
if ( ( className === 'wpview-selection-before' || className === 'wpview-selection-after' ) && editor.selection.isCollapsed() ) {
|
||||
setViewCursorTries = 0;
|
||||
|
||||
deselect();
|
||||
@ -618,16 +618,34 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'BeforeExecCommand', function( event ) {
|
||||
var cmd = event.command,
|
||||
editor.on( 'BeforeExecCommand', function() {
|
||||
var node = editor.selection.getNode(),
|
||||
view;
|
||||
|
||||
if ( cmd === 'undo' || cmd === 'redo' || cmd === 'RemoveFormat' || cmd === 'mceToggleFormat' ) {
|
||||
return;
|
||||
if ( node && ( node.className === 'wpview-selection-before' || node.className === 'wpview-selection-after' ) && ( view = getView( node ) ) ) {
|
||||
handleEnter( view );
|
||||
execCommandView = view;
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'ExecCommand', function() {
|
||||
var toSelect, node;
|
||||
|
||||
if ( selected ) {
|
||||
toSelect = selected;
|
||||
deselect();
|
||||
select( toSelect );
|
||||
}
|
||||
|
||||
if ( view = getView( editor.selection.getNode() ) ) {
|
||||
handleEnter( view );
|
||||
if ( execCommandView ) {
|
||||
node = execCommandView.nextSibling;
|
||||
|
||||
if ( node && node.nodeName === 'P' && editor.dom.isEmpty( node ) ) {
|
||||
editor.dom.remove( node );
|
||||
setViewCursor( false, execCommandView );
|
||||
}
|
||||
|
||||
execCommandView = false;
|
||||
}
|
||||
});
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
Binary file not shown.
Loading…
Reference in New Issue
Block a user