diff --git a/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js b/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js index 03e2cad79c..76767d0f9f 100644 --- a/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js +++ b/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js @@ -12,8 +12,7 @@ */ ( function( tinymce, setTimeout ) { tinymce.PluginManager.add( 'wptextpattern', function( editor ) { - var $$ = editor.$, - VK = tinymce.util.VK, + var VK = tinymce.util.VK, canUndo = false, spacePatterns = [ { regExp: /^[*-]\s/, cmd: 'InsertUnorderedList' }, @@ -44,7 +43,7 @@ }, true ); editor.on( 'keyup', function( event ) { - if ( event.keyCode === VK.SPACEBAR || ! VK.modifierPressed( event ) ) { + if ( event.keyCode === VK.SPACEBAR && ! VK.modifierPressed( event ) ) { space(); } } ); @@ -79,41 +78,30 @@ function space() { var rng = editor.selection.getRng(), node = rng.startContainer, + parent, text; - if ( firstNode( node ) !== node ) { + if ( ! node || firstNode( node ) !== node ) { return; } + parent = node.parentNode; text = node.data; tinymce.each( spacePatterns, function( pattern ) { - var replace = text.replace( pattern.regExp, '' ); + var match = text.match( pattern.regExp ); - if ( text === replace ) { - return; - } - - if ( rng.startOffset !== text.length - replace.length ) { + if ( ! match || rng.startOffset !== match[0].length ) { return; } editor.undoManager.add(); editor.undoManager.transact( function() { - var parent = node.parentNode, - $$parent; + node.deleteData( 0, match[0].length ); - if ( replace ) { - $$( node ).replaceWith( document.createTextNode( replace ) ); - } else { - $$parent = $$( parent ); - - $$( node ).remove(); - - if ( ! $$parent.html() ) { - $$parent.append( '
' ); - } + if ( ! parent.innerHTML ) { + parent.appendChild( document.createElement( 'br' ) ); } editor.selection.setCursorLocation( parent ); diff --git a/wp-includes/js/tinymce/plugins/wptextpattern/plugin.min.js b/wp-includes/js/tinymce/plugins/wptextpattern/plugin.min.js index 2b989905f9..1b71fc614d 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=c.selection.getRng(),h=f.startContainer;d(h)===h&&(e=h.data,a.each(j,function(a){var d=e.replace(a.regExp,"");if(e!==d&&f.startOffset===e.length-d.length)return c.undoManager.add(),c.undoManager.transact(function(){var b,e=h.parentNode;d?g(h).replaceWith(document.createTextNode(d)):(b=g(e),g(h).remove(),b.html()||b.append("
")),c.selection.setCursorLocation(e),c.execCommand(a.cmd)}),b(function(){i=!0}),!1}))}function f(){var b,e,f=c.selection,g=f.getRng(),h=g.startOffset,i=g.startContainer,j=d(i),l=k.length;if(j){for(b=j.data;l--;)if(0===b.indexOf(k[l].start)){e=k[l];break}if(e){if(j===i){if(a.trim(b)===e.start)return;h=Math.max(0,h-e.start.length)}c.undoManager.add(),c.undoManager.transact(function(){j.deleteData(0,e.start.length),c.formatter.apply(e.format,{},i),g.setStart(i,h),g.collapse(!0),f.setRng(g)})}}}var g=c.$,h=a.util.VK,i=!1,j=[{regExp:/^[*-]\s/,cmd:"InsertUnorderedList"},{regExp:/^1[.)]\s/,cmd:"InsertOrderedList"}],k=[{start:"##",format:"h2"},{start:"###",format:"h3"},{start:"####",format:"h4"},{start:"#####",format:"h5"},{start:"######",format:"h6"},{start:">",format:"blockquote"}];c.on("selectionchange",function(){i=!1}),c.on("keydown",function(a){!i||a.keyCode!==h.BACKSPACE&&27!==a.keyCode||(c.undoManager.undo(),a.preventDefault()),a.keyCode!==h.ENTER||h.modifierPressed(a)||f()},!0),c.on("keyup",function(a){a.keyCode!==h.SPACEBAR&&h.modifierPressed(a)||e()})})}(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),b}}function e(){var e,f,g=c.selection.getRng(),j=g.startContainer;j&&d(j)===j&&(e=j.parentNode,f=j.data,a.each(i,function(a){var d=f.match(a.regExp);if(d&&g.startOffset===d[0].length)return c.undoManager.add(),c.undoManager.transact(function(){j.deleteData(0,d[0].length),e.innerHTML||e.appendChild(document.createElement("br")),c.selection.setCursorLocation(e),c.execCommand(a.cmd)}),b(function(){h=!0}),!1}))}function f(){var b,e,f=c.selection,g=f.getRng(),h=g.startOffset,i=g.startContainer,k=d(i),l=j.length;if(k){for(b=k.data;l--;)if(0===b.indexOf(j[l].start)){e=j[l];break}if(e){if(k===i){if(a.trim(b)===e.start)return;h=Math.max(0,h-e.start.length)}c.undoManager.add(),c.undoManager.transact(function(){k.deleteData(0,e.start.length),c.formatter.apply(e.format,{},i),g.setStart(i,h),g.collapse(!0),f.setRng(g)})}}}var g=a.util.VK,h=!1,i=[{regExp:/^[*-]\s/,cmd:"InsertUnorderedList"},{regExp:/^1[.)]\s/,cmd:"InsertOrderedList"}],j=[{start:"##",format:"h2"},{start:"###",format:"h3"},{start:"####",format:"h4"},{start:"#####",format:"h5"},{start:"######",format:"h6"},{start:">",format:"blockquote"}];c.on("selectionchange",function(){h=!1}),c.on("keydown",function(a){!h||a.keyCode!==g.BACKSPACE&&27!==a.keyCode||(c.undoManager.undo(),a.preventDefault()),a.keyCode!==g.ENTER||g.modifierPressed(a)||f()},!0),c.on("keyup",function(a){a.keyCode!==g.SPACEBAR||g.modifierPressed(a)||e()})})}(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 4684ddedd6..09e179dbb4 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 b37262d97d..a3b3abaffe 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.3-beta4-33457'; +$wp_version = '4.3-beta4-33458'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.