jodit
Version:
Jodit is an awesome and useful wysiwyg editor with filebrowser
11 lines • 3.92 kB
JavaScript
/*!
* jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
* Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
* Version: v4.12.2
* Url: https://xdsoft.net/jodit/
* License(s): MIT
*/
;!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var s in n)("object"==typeof exports?exports:e)[s]=n[s]}}(self,function(){return(self.webpackChunkjodit=self.webpackChunkjodit||[]).push([[486],{96206:function(e,t,n){n.r(t),n.d(t,{Debug:function(){return i}});var s=n(81937),o=n(23211),a=n(22852),r=n(18855);class i extends r.Plugin{afterInit(e){let t=e.create.div("jodit-debug"),n=e.create.div("jodit-debug__tree"),r=e.create.div("jodit-debug__events"),i=e.create.div("jodit-debug__events-clear",["x"]),d=e.create.div("jodit-debug__sel");function c(){let t=e.selection.range;n.innerHTML=function e(t,n,r){let i=window.getSelection()?.containsNode(t),d=[`<span class="jodit-debug__tree-elm-name">${t.nodeName}</span>`,o.Dom.isText(t)?"- "+function(e,t){if(!e.nodeValue)return"<span style='color:red'>empty</span>";let n=e.nodeValue;return t.collapsed?e===t.startContainer&&(n=n.slice(0,t.startOffset)+"%CURSOR%"+n.slice(t.startOffset)):e===t.startContainer&&e===t.endContainer?n=n.slice(0,t.startOffset)+"%START-CURSOR%"+n.slice(t.startOffset,t.endOffset)+"%END-CURSOR%"+n.slice(t.endOffset):e===t.startContainer?n=n.slice(0,t.startOffset)+"%CURSOR%"+n.slice(t.startOffset):e===t.endContainer&&(n=n.slice(0,t.endOffset)+"%CURSOR%"+n.slice(t.endOffset)),(0,a.stripTags)(n.replace((0,s.INVISIBLE_SPACE_REG_EXP)(),"INV")).replace(/%CURSOR%/,'<span class="jodit-debug__tree-cursor">|</span>').replace(/%START-CURSOR%/,'<span class="jodit-debug__tree-cursor">|').replace(/%END-CURSOR%/,"|</span>")}(t,r):""].map(e=>e.trim()).filter(Boolean);return`<div class="${i?"jodit-debug__tree-element_selected":""}" style='padding-left: ${5*n}px'>
${d.join(" ")}
${Array.from(t.childNodes).map((s,o)=>{let a=[];return r.startContainer===t&&o===r.startOffset&&a.push('<span class="jodit-debug__tree-cursor">|</span>'),a.push(e(s,n+1,r)),r.endContainer===t&&o===r.endOffset&&a.push('<span class="jodit-debug__tree-cursor">|</span>'),a}).flat().join("")}
</div>`}(e.editor,0,t),d.innerHTML=`start ${t.startContainer.nodeName} ${t.startOffset}<br>end ${t.endContainer.nodeName} ${t.endOffset}`}function l(t){let n=e.e.current,s=e.create.div();s.innerHTML=`<span>${new Date().toLocaleTimeString()}</span> ${function(e,t){let n=[e??t.type];switch(e){case"beforeCommand":case"afterCommand":n.push(`<span>${t.toString()}</span>`);break;case"keydown":case"keyup":case"keypress":t.shiftKey&&"Shift"!==t.key&&n.push("Shift+"),t.ctrlKey&&"Control"!==t.key&&n.push("Ctrl+"),t.altKey&&"Alt"!==t.key&&n.push("Alt"),n.push(""+t.key)}return t&&o.Dom.isNode(t.target)&&n.push(`<span>${t.target.nodeName}</span>`),n.join(" ")}(n,t)}`,r.appendChild(s),r.scrollTop=r.scrollHeight,e.async.setTimeout(()=>{r.children.length>100&&r.removeChild(r.children[0])},100)}t.appendChild(n),t.appendChild(r),r.appendChild(i),t.appendChild(d),i.addEventListener("click",()=>{r.innerHTML="",r.appendChild(i)}),e.workplace.appendChild(t),e.e.on("keydown keyup keypress change afterInit updateDebug",c).on(["activate","afterInit","beforeactivate","beforeblur","beforedeactivate","beforefocus","beforeinput","blur","change","click","compositionend","compositionstart","compositionupdate","contextmenu","copy","cut","dblclick","deactivate","focus","focusin","focusout","focusout","input","keydown","keypress","keyup","mousedown","mouseup","paste","selectionchange","selectionstart","dragstart","drop","dragover","resize touchstart touchend","updateDebug","beforeCommand","afterCommand","wheel"],l).on(e.od,"selectionchange",l).on(e.od,"selectionchange",c)}beforeDestruct(e){}}}},function(e){return e(e.s=96206)}])});