jodit-pro
Version:
PRO Version of Jodit Editor
8 lines • 3.52 kB
JavaScript
/*!
* jodit-pro - PRO Version of Jodit Editor
* Author: Chupurnov Valerii <chupurnov@gmail.com>
* Version: v4.9.27
* Url: https://xdsoft.net/jodit/pro/
* License(s): SEE LICENSE IN LICENSE.md
*/
;!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(self,function(){return(self.webpackChunkjodit_pro=self.webpackChunkjodit_pro||[]).push([[726],{36347:function(e,t,r){r(6441).Config.prototype.highlightSignature={processDelay:0,processInChunkCount:300,schema:{},excludeTags:["pre"]}},46958:function(e,t,r){r.r(t),r.d(t,{highlightSignature:function(){return c}});var o=r(82749),i=r(31635);r(36347);var s=r(65478),a=r(2748),l=r(29960),n=r(20356),h=r(2692);class c extends n.Plugin{afterInit(e){Object.keys(e.o.highlightSignature.schema).length&&(e.e.on("change afterSetMode",this.walkNodes).on("afterGetValueFromEditor",c.removeUtilWrappers),this.walkNodes())}beforeDestruct(e){e.e.off("change afterSetMode",this.walkNodes).off("afterGetValueFromEditor",c.removeUtilWrappers)}walkNodes(){var e;if(!this.j.isEditorMode())return;this.checkUtilsBoxToSchema();let{j:t}=this,r=t.ed.createNodeIterator(t.editor,NodeFilter.SHOW_TEXT);null==(e=this.abortController)||e.abort(),this.workLoop(r)}runWorker(e){let t;this.j.e.mute();let r=0,{processInChunkCount:o}=this.j.o.highlightSignature;try{do{if(r+=1,!(t=e.nextNode())||this.checkNormalizing(t))return;this.checkReplaceSchemas(t)}while(t&&o>r)}finally{this.j.e.unmute()}this.workLoop(e)}workLoop(e){this.abortController=new AbortController,this.j.async.schedulerPostTask(()=>this.runWorker(e),{delay:this.j.o.highlightSignature.processDelay}).catch(()=>null)}checkNormalizing(e){return!!a.Dom.isText(e.nextSibling)&&(this.j.editor.normalize(),this.walkNodes(),!0)}checkReplaceSchemas(e){if(c.hasUtilWrapper(e))return;let t=e.nodeValue;if(null==t)return;let{j:r}=this,o=r.o.highlightSignature;for(let r in o.schema){let i=RegExp(r);if(i.test(t)){let s=t.match(i);if(!s||void 0===s.index)continue;let l=o.schema[r](this.j,s);if(l){a.Dom.markTemporary(l,{dataHighlightSchema:r}),this.replaceMatchedTextToElm(e,t,s,l);return}}}}replaceMatchedTextToElm(e,t,r,o){var i;let{j:s}=this,{range:l}=s.s,n=l.startContainer===e,h=l.startOffset,c=null!=(i=r.index)?i:0;e.nodeValue=t.substring(0,c);let u=t.substring(c+r[0].length);if(u.length){let t=s.createInside.text(u);a.Dom.after(e,t)}o.innerText=r[0],a.Dom.after(e,o),n&&this.restoreCursorPosition(h,e,o.firstChild,o.nextSibling)}static hasUtilWrapper(e){return a.Dom.isTemporary(e.parentElement)}static removeUtilWrappers(e){e.value=a.Dom.replaceTemporaryFromString(e.value)}restoreCursorPosition(e,...t){for(let r of t)if(r&&r.nodeValue){let t=r.nodeValue;if(t.length>=e){let t=this.j.s.createRange();t.setStart(r,e),this.j.s.selectRange(t,!1);break}e-=t.length}}checkUtilsBoxToSchema(){a.Dom.temporaryList(this.j.editor).forEach(e=>{var t;let r=(0,l.attr)(e,"dataHighlightSchema");if(!r)return;let o=RegExp(r),i=null!=(t=e.innerText)?t:"";(!o.test(i)||i.replace(o,"").length)&&(this.j.s.save(),a.Dom.unwrap(e),this.j.s.restore())})}constructor(...e){super(...e),(0,o._)(this,"abortController",null)}}(0,o._)(c,"requires",["license"]),(0,i.__decorate)([(0,s.debounce)()],c.prototype,"walkNodes",null),(0,i.__decorate)([s.autobind],c.prototype,"runWorker",null),h.JoditPro.plugins.add("highlight-signature",c)}},function(e){return e(e.s=46958)}])});