TinyMCE: wptextpattern: trim whitespace
Props iseulde and azaozz. Fixes #33246. Built from https://develop.svn.wordpress.org/trunk@33563 git-svn-id: http://core.svn.wordpress.org/trunk@33530 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
40e12aba22
commit
55a4ce4db2
|
@ -53,7 +53,7 @@
|
|||
}
|
||||
} );
|
||||
|
||||
function firstNode( node ) {
|
||||
function firstTextNode( node ) {
|
||||
var parent = editor.dom.getParent( node, 'p' ),
|
||||
child;
|
||||
|
||||
|
@ -74,7 +74,11 @@
|
|||
}
|
||||
|
||||
if ( ! child.data ) {
|
||||
child = child.nextSibling;
|
||||
if ( child.nextSibling && child.nextSibling.nodeType === 3 ) {
|
||||
child = child.nextSibling;
|
||||
} else {
|
||||
child = null;
|
||||
}
|
||||
}
|
||||
|
||||
return child;
|
||||
|
@ -86,7 +90,7 @@
|
|||
parent,
|
||||
text;
|
||||
|
||||
if ( ! node || firstNode( node ) !== node ) {
|
||||
if ( ! node || firstTextNode( node ) !== node ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -123,11 +127,9 @@
|
|||
}
|
||||
|
||||
function watchEnter() {
|
||||
var selection = editor.selection,
|
||||
rng = selection.getRng(),
|
||||
offset = rng.startOffset,
|
||||
var rng = editor.selection.getRng(),
|
||||
start = rng.startContainer,
|
||||
node = firstNode( start ),
|
||||
node = firstTextNode( start ),
|
||||
i = enterPatterns.length,
|
||||
text, pattern;
|
||||
|
||||
|
@ -148,12 +150,8 @@
|
|||
return;
|
||||
}
|
||||
|
||||
if ( node === start ) {
|
||||
if ( tinymce.trim( text ) === pattern.start ) {
|
||||
return;
|
||||
}
|
||||
|
||||
offset = Math.max( 0, offset - pattern.start.length );
|
||||
if ( node === start && tinymce.trim( text ) === pattern.start ) {
|
||||
return;
|
||||
}
|
||||
|
||||
refNode = node;
|
||||
|
@ -166,7 +164,7 @@
|
|||
|
||||
editor.undoManager.transact( function() {
|
||||
editor.formatter.apply( refPattern.format, {}, refNode );
|
||||
refNode.deleteData( 0, refPattern.start.length );
|
||||
refNode.replaceData( 0, refNode.data.length, tinymce.trim( refNode.data.slice( refPattern.start.length ) ) );
|
||||
} );
|
||||
|
||||
// We need to wait for native events to be triggered.
|
||||
|
|
|
@ -1 +1 @@
|
|||
!function(a,b){a.PluginManager.add("wptextpattern",function(c){function d(a){var b,d=c.dom.getParent(a,"p");if(d){for(;(b=d.firstChild)&&3!==b.nodeType;)d=b;if(b)return b.data||(b=b.nextSibling),b}}function e(){var e,f,g=c.selection.getRng(),i=g.startContainer;i&&d(i)===i&&(e=i.parentNode,f=i.data,a.each(l,function(a){var d=f.match(a.regExp);if(d&&g.startOffset===d[0].length)return c.undoManager.add(),c.undoManager.transact(function(){i.deleteData(0,d[0].length),e.innerHTML||e.appendChild(document.createElement("br")),c.selection.setCursorLocation(e),c.execCommand(a.cmd)}),b(function(){h="space"}),!1}))}function f(){var b,e,f=c.selection,g=f.getRng(),h=g.startOffset,k=g.startContainer,l=d(k),n=m.length;if(l){for(b=l.data;n--;)if(0===b.indexOf(m[n].start)){e=m[n];break}if(e){if(l===k){if(a.trim(b)===e.start)return;h=Math.max(0,h-e.start.length)}i=l,j=e}}}function g(){i&&(c.undoManager.add(),c.undoManager.transact(function(){c.formatter.apply(j.format,{},i),i.deleteData(0,j.start.length)}),b(function(){h="enter"})),i=null,j=null}var h,i,j,k=a.util.VK,l=[{regExp:/^[*-]\s/,cmd:"InsertUnorderedList"},{regExp:/^1[.)]\s/,cmd:"InsertOrderedList"}],m=[{start:"##",format:"h2"},{start:"###",format:"h3"},{start:"####",format:"h4"},{start:"#####",format:"h5"},{start:"######",format:"h6"},{start:">",format:"blockquote"}];c.on("selectionchange",function(){h=null}),c.on("keydown",function(a){(h&&27===a.keyCode||"space"===h&&a.keyCode===k.BACKSPACE)&&(c.undoManager.undo(),a.preventDefault(),a.stopImmediatePropagation()),a.keyCode!==k.ENTER||k.modifierPressed(a)||f()},!0),c.on("keyup",function(a){k.modifierPressed(a)||(a.keyCode===k.SPACEBAR?e():a.keyCode===k.ENTER&&g())})})}(window.tinymce,window.setTimeout);
|
||||
!function(a,b){a.PluginManager.add("wptextpattern",function(c){function d(a){var b,d=c.dom.getParent(a,"p");if(d){for(;(b=d.firstChild)&&3!==b.nodeType;)d=b;if(b)return b.data||(b=b.nextSibling&&3===b.nextSibling.nodeType?b.nextSibling:null),b}}function e(){var e,f,g=c.selection.getRng(),i=g.startContainer;i&&d(i)===i&&(e=i.parentNode,f=i.data,a.each(l,function(a){var d=f.match(a.regExp);if(d&&g.startOffset===d[0].length)return c.undoManager.add(),c.undoManager.transact(function(){i.deleteData(0,d[0].length),e.innerHTML||e.appendChild(document.createElement("br")),c.selection.setCursorLocation(e),c.execCommand(a.cmd)}),b(function(){h="space"}),!1}))}function f(){var b,e,f=c.selection.getRng(),g=f.startContainer,h=d(g),k=m.length;if(h){for(b=h.data;k--;)if(0===b.indexOf(m[k].start)){e=m[k];break}e&&(h!==g||a.trim(b)!==e.start)&&(i=h,j=e)}}function g(){i&&(c.undoManager.add(),c.undoManager.transact(function(){c.formatter.apply(j.format,{},i),i.replaceData(0,i.data.length,a.trim(i.data.slice(j.start.length)))}),b(function(){h="enter"})),i=null,j=null}var h,i,j,k=a.util.VK,l=[{regExp:/^[*-]\s/,cmd:"InsertUnorderedList"},{regExp:/^1[.)]\s/,cmd:"InsertOrderedList"}],m=[{start:"##",format:"h2"},{start:"###",format:"h3"},{start:"####",format:"h4"},{start:"#####",format:"h5"},{start:"######",format:"h6"},{start:">",format:"blockquote"}];c.on("selectionchange",function(){h=null}),c.on("keydown",function(a){(h&&27===a.keyCode||"space"===h&&a.keyCode===k.BACKSPACE)&&(c.undoManager.undo(),a.preventDefault(),a.stopImmediatePropagation()),a.keyCode!==k.ENTER||k.modifierPressed(a)||f()},!0),c.on("keyup",function(a){k.modifierPressed(a)||(a.keyCode===k.SPACEBAR?e():a.keyCode===k.ENTER&&g())})})}(window.tinymce,window.setTimeout);
|
Binary file not shown.
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.3-RC1-33562';
|
||||
$wp_version = '4.3-RC1-33563';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue