jodit-pro
Version:
PRO Version of Jodit Editor
8 lines • 4.18 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 g}});var o=r(80294),i=r(20616),n=r(67709),a=r(82749),l=r(18766),s=r(23078),u=r(31635);r(36347);var h=r(65478),c=r(2748),f=r(29960),d=r(20356),p=r(2692),g=function(e){function t(){var e;return(0,i._)(this,t),e=(0,o._)(this,t,arguments),(0,a._)(e,"abortController",null),e}return(0,l._)(t,e),(0,n._)(t,[{key:"afterInit",value:function(e){Object.keys(e.o.highlightSignature.schema).length&&(e.e.on("change afterSetMode",this.walkNodes).on("afterGetValueFromEditor",t.removeUtilWrappers),this.walkNodes())}},{key:"beforeDestruct",value:function(e){e.e.off("change afterSetMode",this.walkNodes).off("afterGetValueFromEditor",t.removeUtilWrappers)}},{key:"walkNodes",value:function(){if(this.j.isEditorMode()){this.checkUtilsBoxToSchema();var e,t=this.j,r=t.ed.createNodeIterator(t.editor,NodeFilter.SHOW_TEXT);null==(e=this.abortController)||e.abort(),this.workLoop(r)}}},{key:"runWorker",value:function(e){this.j.e.mute();var t,r=0,o=this.j.o.highlightSignature.processInChunkCount;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)}},{key:"workLoop",value:function(e){var t=this;this.abortController=new AbortController,this.j.async.schedulerPostTask(function(){return t.runWorker(e)},{delay:this.j.o.highlightSignature.processDelay}).catch(function(){return null})}},{key:"checkNormalizing",value:function(e){return!!c.Dom.isText(e.nextSibling)&&(this.j.editor.normalize(),this.walkNodes(),!0)}},{key:"checkReplaceSchemas",value:function(e){if(!t.hasUtilWrapper(e)){var r=e.nodeValue;if(null!=r){var o=this.j.o.highlightSignature;for(var i in o.schema){var n=RegExp(i);if(n.test(r)){var a=r.match(n);if(!a||void 0===a.index)continue;var l=o.schema[i](this.j,a);if(l){c.Dom.markTemporary(l,{dataHighlightSchema:i}),this.replaceMatchedTextToElm(e,r,a,l);return}}}}}}},{key:"replaceMatchedTextToElm",value:function(e,t,r,o){var i,n=this.j,a=n.s.range,l=a.startContainer===e,s=a.startOffset,u=null!=(i=r.index)?i:0;e.nodeValue=t.substring(0,u);var h=t.substring(u+r[0].length);if(h.length){var f=n.createInside.text(h);c.Dom.after(e,f)}o.innerText=r[0],c.Dom.after(e,o),l&&this.restoreCursorPosition(s,e,o.firstChild,o.nextSibling)}},{key:"restoreCursorPosition",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),o=1;t>o;o++)r[o-1]=arguments[o];var i=!0,n=!1,a=void 0;try{for(var l,s=r[Symbol.iterator]();!(i=(l=s.next()).done);i=!0){var u=l.value;if(u&&u.nodeValue){var h=u.nodeValue;if(h.length>=e){var c=this.j.s.createRange();c.setStart(u,e),this.j.s.selectRange(c,!1);break}e-=h.length}}}catch(e){n=!0,a=e}finally{try{i||null==s.return||s.return()}finally{if(n)throw a}}}},{key:"checkUtilsBoxToSchema",value:function(){var e=this;c.Dom.temporaryList(this.j.editor).forEach(function(t){var r,o=(0,f.attr)(t,"dataHighlightSchema");if(o){var i=RegExp(o),n=null!=(r=t.innerText)?r:"";(!i.test(n)||n.replace(i,"").length)&&(e.j.s.save(),c.Dom.unwrap(t),e.j.s.restore())}})}}],[{key:"hasUtilWrapper",value:function(e){return c.Dom.isTemporary(e.parentElement)}},{key:"removeUtilWrappers",value:function(e){e.value=c.Dom.replaceTemporaryFromString(e.value)}}]),t}((0,s._)(d.Plugin));(0,a._)(g,"requires",["license"]),(0,u.__decorate)([(0,h.debounce)()],g.prototype,"walkNodes",null),(0,u.__decorate)([h.autobind],g.prototype,"runWorker",null),p.JoditPro.plugins.add("highlight-signature",g)}},function(e){return e(e.s=46958)}])});