WordPress/wp-includes/js/tinymce/plugins/wptextpattern/plugin.min.js

1 line
1.2 KiB
JavaScript
Raw Normal View History

!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&&(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);