PHP Classes

File: Web/scripts/tinymce/plugins/textpattern/plugin.min.js

Recommend this page to a friend!
  Classes of Burge Lab   Burge CMF   Web/scripts/tinymce/plugins/textpattern/plugin.min.js   Download  
File: Web/scripts/tinymce/plugins/textpattern/plugin.min.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Burge CMF
Framework to publish managed content
Author: By
Last change:
Date: 7 years ago
Size: 2,751 bytes
 

Contents

Class file image Download
tinymce.PluginManager.add("textpattern",function(e){function t(){return c&&(l.sort(function(e,t){return e.start.length>t.start.length?-1:e.start.length<t.start.length?1:0}),c=!1),l}function n(e){for(var n=t(),r=0;r<n.length;r++)if(0===e.indexOf(n[r].start)&&(!n[r].end||e.lastIndexOf(n[r].end)==e.length-n[r].end.length))return n[r]}function r(e,n,r){var i,o,a;for(i=t(),a=0;a<i.length;a++)if(o=i[a],o.end&&e.substr(n-o.end.length-r,o.end.length)==o.end)return o}function i(t){function i(){l=l.splitText(u),l.splitText(c-u-m),l.deleteData(0,h.start.length),l.deleteData(l.data.length-h.end.length,h.end.length)}var o,a,s,l,c,u,d,f,h,m,p;return o=e.selection,a=e.dom,o.isCollapsed()&&(s=o.getRng(!0),l=s.startContainer,c=s.startOffset,d=l.data,m=t?1:0,3==l.nodeType&&(h=r(d,c,m),h&&(u=Math.max(0,c-m),u=d.lastIndexOf(h.start,u-h.end.length-1),-1!==u&&(f=a.createRng(),f.setStart(l,u),f.setEnd(l,c-m),h=n(f.toString()),h&&h.end&&!(l.data.length<=h.start.length+h.end.length)))))?(p=e.formatter.get(h.format),p&&p[0].inline?(i(),e.formatter.apply(h.format,{},l),l):void 0):void 0}function o(){var t,r,i,o,a,s,l,c,u,d,f;if(t=e.selection,r=e.dom,t.isCollapsed()&&(l=r.getParent(t.getStart(),"p"))){for(u=new tinymce.dom.TreeWalker(l,l);a=u.next();)if(3==a.nodeType){o=a;break}if(o){if(c=n(o.data),!c)return;if(d=t.getRng(!0),i=d.startContainer,f=d.startOffset,o==i&&(f=Math.max(0,f-c.start.length)),tinymce.trim(o.data).length==c.start.length)return;c.format&&(s=e.formatter.get(c.format),s&&s[0].block&&(o.deleteData(0,c.start.length),e.formatter.apply(c.format,{},o),d.setStart(i,f),d.collapse(!0),t.setRng(d))),c.cmd&&e.undoManager.transact(function(){o.deleteData(0,c.start.length),e.execCommand(c.cmd)})}}}function a(){var t,n;n=i(),n&&(t=e.dom.createRng(),t.setStart(n,n.data.length),t.setEnd(n,n.data.length),e.selection.setRng(t)),o()}function s(){var t,n,r,o,a;t=i(!0),t&&(a=e.dom,n=t.data.slice(-1),/[\u00a0 ]/.test(n)&&(t.deleteData(t.data.length-1,1),r=a.doc.createTextNode(n),t.nextSibling?a.insertAfter(r,t.nextSibling):t.parentNode.appendChild(r),o=a.createRng(),o.setStart(r,1),o.setEnd(r,1),e.selection.setRng(o)))}var l,c=!0;l=e.settings.textpattern_patterns||[{start:"*",end:"*",format:"italic"},{start:"**",end:"**",format:"bold"},{start:"#",format:"h1"},{start:"##",format:"h2"},{start:"###",format:"h3"},{start:"####",format:"h4"},{start:"#####",format:"h5"},{start:"######",format:"h6"},{start:"1. ",cmd:"InsertOrderedList"},{start:"* ",cmd:"InsertUnorderedList"},{start:"- ",cmd:"InsertUnorderedList"}],e.on("keydown",function(e){13!=e.keyCode||tinymce.util.VK.modifierPressed(e)||a()},!0),e.on("keyup",function(e){32!=e.keyCode||tinymce.util.VK.modifierPressed(e)||s()}),this.getPatterns=t,this.setPatterns=function(e){l=e,c=!0}});