TinyMCE: wptextpattern: Fix undo shortcut for inline patterns
Fixes #37092. Built from https://develop.svn.wordpress.org/trunk@39077 git-svn-id: http://core.svn.wordpress.org/trunk@39019 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2d07c3196e
commit
feb8ccf3d6
|
@ -71,12 +71,14 @@
|
||||||
event.stopImmediatePropagation();
|
event.stopImmediatePropagation();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( event.keyCode === VK.ENTER && ! VK.modifierPressed( event ) ) {
|
if ( VK.metaKeyPressed( event ) ) {
|
||||||
enter();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( event.keyCode === VK.ENTER ) {
|
||||||
|
enter();
|
||||||
// Wait for the browser to insert the character.
|
// Wait for the browser to insert the character.
|
||||||
if ( event.keyCode === VK.SPACEBAR && ! event.ctrlKey && ! event.metaKey && ! event.altKey ) {
|
} else if ( event.keyCode === VK.SPACEBAR ) {
|
||||||
setTimeout( space );
|
setTimeout( space );
|
||||||
} else if ( event.keyCode > 47 && ! ( event.keyCode >= 91 && event.keyCode <= 93 ) ) {
|
} else if ( event.keyCode > 47 && ! ( event.keyCode >= 91 && event.keyCode <= 93 ) ) {
|
||||||
setTimeout( inline );
|
setTimeout( inline );
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
!function(a,b){function c(a){return a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}a.Env.ie&&a.Env.ie<9||a.PluginManager.add("wptextpattern",function(d){function e(){var e,f,g,h,i,k=d.selection.getRng(),l=k.startContainer,m=k.startOffset;if(l&&3===l.nodeType&&l.data.length&&m&&-1!==a.inArray(p,l.data.charAt(m-1))){var n=l.data.slice(0,m);a.each(o,function(a){var b=new RegExp(c(a.start)+"\\S+"+c(a.end)+"$"),d=n.match(b);return d&&-1===l.data.slice(d.index+a.start.length,m-a.end.length).indexOf(a.start.slice(0,1))?(e=d.index,f=m-a.end.length,g=a,!1):void 0}),g&&(h=d.formatter.get(g.format),h&&h[0].inline&&(d.undoManager.add(),d.undoManager.transact(function(){l.insertData(m,"\ufeff"),l=l.splitText(e),i=l.splitText(m-e),l.deleteData(0,g.start.length),l.deleteData(l.data.length-g.end.length,g.end.length),d.formatter.apply(g.format,{},l),d.selection.setCursorLocation(i,1)}),b(function(){j="space",d.once("selectionchange",function(){var a;i&&(a=i.data.indexOf("\ufeff"),-1!==a&&i.deleteData(a,a+1))})})))}}function f(a){var b,c=d.dom.getParent(a,"p");if(c){for(;(b=c.firstChild)&&3!==b.nodeType;)c=b;if(b)return b.data||(b=b.nextSibling&&3===b.nextSibling.nodeType?b.nextSibling:null),b}}function g(){var c,e,g=d.selection.getRng(),h=g.startContainer;h&&f(h)===h&&(c=h.parentNode,e=h.data,a.each(m,function(a){var f=e.match(a.regExp);if(f&&g.startOffset===f[0].length)return d.undoManager.add(),d.undoManager.transact(function(){h.deleteData(0,f[0].length),c.innerHTML||c.appendChild(document.createElement("br")),d.selection.setCursorLocation(c),d.execCommand(a.cmd)}),b(function(){j="space"}),!1}))}function h(){var c,e,g,h=d.selection.getRng(),k=h.startContainer,l=f(k),m=n.length;if(l){for(c=l.data;m--;)if(n[m].start){if(0===c.indexOf(n[m].start)){e=n[m];break}}else if(n[m].regExp&&n[m].regExp.test(c)){e=n[m];break}e&&(l===k&&a.trim(c)===e.start||d.once("keyup",function(){d.undoManager.add(),d.undoManager.transact(function(){e.format?(d.formatter.apply(e.format,{},l),l.replaceData(0,l.data.length,i(l.data.slice(e.start.length)))):e.element&&(g=l.parentNode&&l.parentNode.parentNode,g&&g.replaceChild(document.createElement(e.element),l.parentNode))}),b(function(){j="enter"})}))}}function i(a){return a?a.replace(/^\s+/,""):""}var j,k=a.util.VK,l=d.settings.wptextpattern||{},m=l.space||[{regExp:/^[*-]\s/,cmd:"InsertUnorderedList"},{regExp:/^1[.)]\s/,cmd:"InsertOrderedList"}],n=l.enter||[{start:"##",format:"h2"},{start:"###",format:"h3"},{start:"####",format:"h4"},{start:"#####",format:"h5"},{start:"######",format:"h6"},{start:">",format:"blockquote"},{regExp:/^(-){3,}$/,element:"hr"}],o=l.inline||[{start:"`",end:"`",format:"code"}],p=[];a.each(o,function(b){a.each((b.start+b.end).split(""),function(b){-1===a.inArray(p,b)&&p.push(b)})}),d.on("selectionchange",function(){j=null}),d.on("keydown",function(a){(j&&27===a.keyCode||"space"===j&&a.keyCode===k.BACKSPACE)&&(d.undoManager.undo(),a.preventDefault(),a.stopImmediatePropagation()),a.keyCode!==k.ENTER||k.modifierPressed(a)||h(),a.keyCode!==k.SPACEBAR||a.ctrlKey||a.metaKey||a.altKey?a.keyCode>47&&!(a.keyCode>=91&&a.keyCode<=93)&&b(e):b(g)},!0)})}(window.tinymce,window.setTimeout);
|
!function(a,b){function c(a){return a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}a.Env.ie&&a.Env.ie<9||a.PluginManager.add("wptextpattern",function(d){function e(){var e,f,g,h,i,k=d.selection.getRng(),l=k.startContainer,m=k.startOffset;if(l&&3===l.nodeType&&l.data.length&&m&&-1!==a.inArray(p,l.data.charAt(m-1))){var n=l.data.slice(0,m);a.each(o,function(a){var b=new RegExp(c(a.start)+"\\S+"+c(a.end)+"$"),d=n.match(b);return d&&-1===l.data.slice(d.index+a.start.length,m-a.end.length).indexOf(a.start.slice(0,1))?(e=d.index,f=m-a.end.length,g=a,!1):void 0}),g&&(h=d.formatter.get(g.format),h&&h[0].inline&&(d.undoManager.add(),d.undoManager.transact(function(){l.insertData(m,"\ufeff"),l=l.splitText(e),i=l.splitText(m-e),l.deleteData(0,g.start.length),l.deleteData(l.data.length-g.end.length,g.end.length),d.formatter.apply(g.format,{},l),d.selection.setCursorLocation(i,1)}),b(function(){j="space",d.once("selectionchange",function(){var a;i&&(a=i.data.indexOf("\ufeff"),-1!==a&&i.deleteData(a,a+1))})})))}}function f(a){var b,c=d.dom.getParent(a,"p");if(c){for(;(b=c.firstChild)&&3!==b.nodeType;)c=b;if(b)return b.data||(b=b.nextSibling&&3===b.nextSibling.nodeType?b.nextSibling:null),b}}function g(){var c,e,g=d.selection.getRng(),h=g.startContainer;h&&f(h)===h&&(c=h.parentNode,e=h.data,a.each(m,function(a){var f=e.match(a.regExp);if(f&&g.startOffset===f[0].length)return d.undoManager.add(),d.undoManager.transact(function(){h.deleteData(0,f[0].length),c.innerHTML||c.appendChild(document.createElement("br")),d.selection.setCursorLocation(c),d.execCommand(a.cmd)}),b(function(){j="space"}),!1}))}function h(){var c,e,g,h=d.selection.getRng(),k=h.startContainer,l=f(k),m=n.length;if(l){for(c=l.data;m--;)if(n[m].start){if(0===c.indexOf(n[m].start)){e=n[m];break}}else if(n[m].regExp&&n[m].regExp.test(c)){e=n[m];break}e&&(l===k&&a.trim(c)===e.start||d.once("keyup",function(){d.undoManager.add(),d.undoManager.transact(function(){e.format?(d.formatter.apply(e.format,{},l),l.replaceData(0,l.data.length,i(l.data.slice(e.start.length)))):e.element&&(g=l.parentNode&&l.parentNode.parentNode,g&&g.replaceChild(document.createElement(e.element),l.parentNode))}),b(function(){j="enter"})}))}}function i(a){return a?a.replace(/^\s+/,""):""}var j,k=a.util.VK,l=d.settings.wptextpattern||{},m=l.space||[{regExp:/^[*-]\s/,cmd:"InsertUnorderedList"},{regExp:/^1[.)]\s/,cmd:"InsertOrderedList"}],n=l.enter||[{start:"##",format:"h2"},{start:"###",format:"h3"},{start:"####",format:"h4"},{start:"#####",format:"h5"},{start:"######",format:"h6"},{start:">",format:"blockquote"},{regExp:/^(-){3,}$/,element:"hr"}],o=l.inline||[{start:"`",end:"`",format:"code"}],p=[];a.each(o,function(b){a.each((b.start+b.end).split(""),function(b){-1===a.inArray(p,b)&&p.push(b)})}),d.on("selectionchange",function(){j=null}),d.on("keydown",function(a){(j&&27===a.keyCode||"space"===j&&a.keyCode===k.BACKSPACE)&&(d.undoManager.undo(),a.preventDefault(),a.stopImmediatePropagation()),k.metaKeyPressed(a)||(a.keyCode===k.ENTER?h():a.keyCode===k.SPACEBAR?b(g):a.keyCode>47&&!(a.keyCode>=91&&a.keyCode<=93)&&b(e))},!0)})}(window.tinymce,window.setTimeout);
|
Binary file not shown.
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.7-beta1-39076';
|
$wp_version = '4.7-beta1-39077';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue