TinyMCE: wptextpattern: escape should undo
Props azaozz. See #31441. Built from https://develop.svn.wordpress.org/trunk@32836 git-svn-id: http://core.svn.wordpress.org/trunk@32807 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
437b1c2b6a
commit
ecec2b61cf
|
@ -13,6 +13,7 @@
|
|||
( function( tinymce, setTimeout ) {
|
||||
tinymce.PluginManager.add( 'wptextpattern', function( editor ) {
|
||||
var $$ = editor.$,
|
||||
VK = tinymce.util.VK,
|
||||
patterns = [],
|
||||
canUndo = false;
|
||||
|
||||
|
@ -52,7 +53,7 @@
|
|||
} );
|
||||
|
||||
editor.on( 'keydown', function( event ) {
|
||||
if ( canUndo && event.keyCode === tinymce.util.VK.BACKSPACE ) {
|
||||
if ( canUndo && ( event.keyCode === VK.BACKSPACE || event.keyCode === 27 /* ESCAPE */ ) ) {
|
||||
editor.undoManager.undo();
|
||||
event.preventDefault();
|
||||
}
|
||||
|
@ -61,7 +62,7 @@
|
|||
editor.on( 'keyup', function( event ) {
|
||||
var rng, node, text, parent, child;
|
||||
|
||||
if ( event.keyCode !== tinymce.util.VK.SPACEBAR ) {
|
||||
if ( event.keyCode !== VK.SPACEBAR ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
!function(a,b){a.PluginManager.add("wptextpattern",function(c){function d(a,b){f.push({regExp:a,callback:b})}var e=c.$,f=[],g=!1;d(/^[*-]\s/,function(){this.execCommand("InsertUnorderedList")}),d(/^1[.)]\s/,function(){this.execCommand("InsertOrderedList")}),d(/^>\s/,function(){this.formatter.toggle("blockquote")}),d(/^(#{2,6})\s/,function(){this.formatter.toggle("h"+arguments[1].length)}),c.on("selectionchange",function(){g=!1}),c.on("keydown",function(b){g&&b.keyCode===a.util.VK.BACKSPACE&&(c.undoManager.undo(),b.preventDefault())}),c.on("keyup",function(d){var h,i,j,k,l;if(d.keyCode===a.util.VK.SPACEBAR&&(h=c.selection.getRng(),i=h.startContainer,i&&3===i.nodeType&&(j=i.nodeValue,k=c.dom.getParent(i,"p")))){for(;(l=k.firstChild)&&3!==l.nodeType;)k=l;l.nodeValue||(l=l.nextSibling),l===i&&a.each(f,function(a){var d,f=j.replace(a.regExp,function(){return d=arguments,""});if(j!==f&&h.startOffset===j.length-f.length)return c.undoManager.add(),c.undoManager.transact(function(){var b;f?e(i).replaceWith(document.createTextNode(f)):(b=e(i.parentNode),e(i).remove(),b.html()||b.append("<br>")),c.selection.setCursorLocation(k),a.callback.apply(c,d)}),b(function(){g=!0}),!1})}})})}(window.tinymce,window.setTimeout);
|
||||
!function(a,b){a.PluginManager.add("wptextpattern",function(c){function d(a,b){g.push({regExp:a,callback:b})}var e=c.$,f=a.util.VK,g=[],h=!1;d(/^[*-]\s/,function(){this.execCommand("InsertUnorderedList")}),d(/^1[.)]\s/,function(){this.execCommand("InsertOrderedList")}),d(/^>\s/,function(){this.formatter.toggle("blockquote")}),d(/^(#{2,6})\s/,function(){this.formatter.toggle("h"+arguments[1].length)}),c.on("selectionchange",function(){h=!1}),c.on("keydown",function(a){!h||a.keyCode!==f.BACKSPACE&&27!==a.keyCode||(c.undoManager.undo(),a.preventDefault())}),c.on("keyup",function(d){var i,j,k,l,m;if(d.keyCode===f.SPACEBAR&&(i=c.selection.getRng(),j=i.startContainer,j&&3===j.nodeType&&(k=j.nodeValue,l=c.dom.getParent(j,"p")))){for(;(m=l.firstChild)&&3!==m.nodeType;)l=m;m.nodeValue||(m=m.nextSibling),m===j&&a.each(g,function(a){var d,f=k.replace(a.regExp,function(){return d=arguments,""});if(k!==f&&i.startOffset===k.length-f.length)return c.undoManager.add(),c.undoManager.transact(function(){var b;f?e(j).replaceWith(document.createTextNode(f)):(b=e(j.parentNode),e(j).remove(),b.html()||b.append("<br>")),c.selection.setCursorLocation(l),a.callback.apply(c,d)}),b(function(){h=!0}),!1})}})})}(window.tinymce,window.setTimeout);
|
Binary file not shown.
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.3-alpha-32835';
|
||||
$wp_version = '4.3-alpha-32836';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue