From a2dddbf8f56cd689fe5594e9355817550e61808c Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Fri, 12 Feb 2016 04:23:26 +0000 Subject: [PATCH] TinyMCE: fix removing a space before inline tags when applying formatting shortcuts. Fixes #35798. Built from https://develop.svn.wordpress.org/trunk@36513 git-svn-id: http://core.svn.wordpress.org/trunk@36480 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../tinymce/plugins/wptextpattern/plugin.js | 10 +++++++++- .../plugins/wptextpattern/plugin.min.js | 2 +- wp-includes/js/tinymce/wp-tinymce.js.gz | Bin 163752 -> 163769 bytes wp-includes/version.php | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js b/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js index 6c894237d8..22e6dd2da5 100644 --- a/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js +++ b/wp-includes/js/tinymce/plugins/wptextpattern/plugin.js @@ -156,13 +156,21 @@ refPattern = pattern; } + function ltrim( text ) { + if ( text ) { + return text.replace( /^\s+/, '' ); + } + + return ''; + } + function enter() { if ( refNode ) { editor.undoManager.add(); editor.undoManager.transact( function() { editor.formatter.apply( refPattern.format, {}, refNode ); - refNode.replaceData( 0, refNode.data.length, tinymce.trim( refNode.data.slice( refPattern.start.length ) ) ); + refNode.replaceData( 0, refNode.data.length, ltrim( 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 d376e54989..cd569e975b 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&&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){a.keyCode!==k.SPACEBAR||a.ctrlKey||a.metaKey||a.altKey?a.keyCode!==k.ENTER||k.modifierPressed(a)||g():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&&3===b.nextSibling.nodeType?b.nextSibling:null),b}}function e(){var e,f,g=c.selection.getRng(),h=g.startContainer;h&&d(h)===h&&(e=h.parentNode,f=h.data,a.each(m,function(a){var d=f.match(a.regExp);if(d&&g.startOffset===d[0].length)return c.undoManager.add(),c.undoManager.transact(function(){h.deleteData(0,d[0].length),e.innerHTML||e.appendChild(document.createElement("br")),c.selection.setCursorLocation(e),c.execCommand(a.cmd)}),b(function(){i="space"}),!1}))}function f(){var b,e,f=c.selection.getRng(),g=f.startContainer,h=d(g),i=n.length;if(h){for(b=h.data;i--;)if(0===b.indexOf(n[i].start)){e=n[i];break}e&&(h!==g||a.trim(b)!==e.start)&&(j=h,k=e)}}function g(a){return a?a.replace(/^\s+/,""):""}function h(){j&&(c.undoManager.add(),c.undoManager.transact(function(){c.formatter.apply(k.format,{},j),j.replaceData(0,j.data.length,g(j.data.slice(k.start.length)))}),b(function(){i="enter"})),j=null,k=null}var i,j,k,l=a.util.VK,m=[{regExp:/^[*-]\s/,cmd:"InsertUnorderedList"},{regExp:/^1[.)]\s/,cmd:"InsertOrderedList"}],n=[{start:"##",format:"h2"},{start:"###",format:"h3"},{start:"####",format:"h4"},{start:"#####",format:"h5"},{start:"######",format:"h6"},{start:">",format:"blockquote"}];c.on("selectionchange",function(){i=null}),c.on("keydown",function(a){(i&&27===a.keyCode||"space"===i&&a.keyCode===l.BACKSPACE)&&(c.undoManager.undo(),a.preventDefault(),a.stopImmediatePropagation()),a.keyCode!==l.ENTER||l.modifierPressed(a)||f()},!0),c.on("keyup",function(a){a.keyCode!==l.SPACEBAR||a.ctrlKey||a.metaKey||a.altKey?a.keyCode!==l.ENTER||l.modifierPressed(a)||h():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 87826958c9cef083dbc17dd508838f062b6edd3e..b37fcbd8a45646197ae4f859eb6b22a46fccfe0a 100644 GIT binary patch delta 2912 zcmV-m3!n6;{|UMO34nwFv;t>zf6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