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
This commit is contained in:
parent
1877b8c726
commit
a2dddbf8f5
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
!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);
|
Binary file not shown.
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.5-alpha-36512';
|
||||
$wp_version = '4.5-alpha-36513';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue