diff --git a/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js b/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js index 582b42965b..8343e632b9 100644 --- a/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js +++ b/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js @@ -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. diff --git a/wp-includes/js/tinymce/plugins/wptextpattern/plugin.min.js b/wp-includes/js/tinymce/plugins/wptextpattern/plugin.min.js index 3972ccd736..08f990bedc 100644 --- a/wp-includes/js/tinymce/plugins/wptextpattern/plugin.min.js +++ b/wp-includes/js/tinymce/plugins/wptextpattern/plugin.min.js @@ -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); \ No newline at end of file +!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); \ No newline at end of file diff --git a/wp-includes/js/tinymce/wp-tinymce.js.gz b/wp-includes/js/tinymce/wp-tinymce.js.gz index 787d6049e7..2f9a9fe073 100644 Binary files a/wp-includes/js/tinymce/wp-tinymce.js.gz and b/wp-includes/js/tinymce/wp-tinymce.js.gz differ diff --git a/wp-includes/version.php b/wp-includes/version.php index f093be3200..77b9e6efe5 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.