suneditor
Version:
Vanilla JavaScript based WYSIWYG web editor
1 lines • 759 kB
JavaScript
(()=>{var t={cfbI(t){var e,s;e="undefined"!=typeof window?window:this,s=function(t,e){const s={code:"en",align:"Align",alignBottom:"Align bottom",alignCenter:"Align center",alignJustify:"Align justify",alignLeft:"Align left",alignMiddle:"Align middle",alignRight:"Align right",alignTop:"Align top",anchor:"Anchor",asBlock:"As a block",asInline:"As a inline",asLink:"As a link",audio:"Audio",audioGallery:"Audio gallery",audio_modal_file:"Select from files",audio_modal_title:"Insert Audio",audio_modal_url:"Audio URL",autoSize:"Auto size",backgroundColor:"Background color",basic:"Basic",blockStyle:"Block style",bold:"Bold",border:"Border",border_all:"Border all",border_inside:"Border inside",border_horizontal:"Border horizontal",border_vertical:"Border vertical",border_outside:"Border outside",border_left:"Border left",border_top:"Border top",border_right:"Border right",border_bottom:"Border bottom",border_none:"Border none",bulletedList:"Bulleted list",cancel:"Cancel",caption:"Insert description",cellProperties:"Cell properties",center:"Center",close:"Close",codeView:"Code view",color:"Color",colorPicker:"Color picker",column:"Column",comment:"Comments",commentAdd:"Add comment",commentShow:"Show comments",copy:"Copy",copyFormat:"Paint Formatting",cut:"Cut",default:"Default",deleteColumn:"Delete column",deleteRow:"Delete row",dir_ltr:"Left to right",dir_rtl:"Right to left",download:"Download",drag:"Drag",drawing:"Drawing",drawing_modal_title:"Drawing",edit:"Edit",embed:"Embed",embed_modal_title:"Embed",embed_modal_source:"Embed Source / URL",exportPDF:"Export to PDF",exportWord:"Export to Word",find:"Find",decrease:"Decrease",increase:"Increase",fileBrowser:"File browser",fileGallery:"File gallery",fileUpload:"File upload",fixedColumnWidth:"Fixed column width",font:"Font",fontColor:"Font color",fontSize:"Size",formats:"Formats",fullScreen:"Full screen",height:"Height",horizontalLine:"Horizontal line",horizontalSplit:"Horizontal split",hr_dashed:"Dashed",hr_dotted:"Dotted",hr_solid:"Solid",id:"ID",image:"Image",imageGallery:"Image gallery",image_modal_altText:"Alternative text",image_modal_file:"Select from files",image_modal_title:"Insert image",image_modal_url:"Image URL",importWord:"Import from Word",indent:"Indent",inlineStyle:"Inline style",insertColumnAfter:"Insert column after",insertColumnBefore:"Insert column before",insertRowAbove:"Insert row above",insertRowBelow:"Insert row below",insertLine:"Insert line",italic:"Italic",layout:"Layout",left:"Left",lineHeight:"Line height",link:"Link",link_modal_bookmark:"Bookmark",link_modal_downloadLinkCheck:"Download link",link_modal_newWindowCheck:"Open in new window",link_modal_text:"Text to display",link_modal_title:"Insert Link",link_modal_url:"URL to link",link_modal_relAttribute:"Rel attribute",list:"List",markdownView:"Markdown view",math:"Math",math_modal_fontSizeLabel:"Font Size",math_modal_inputLabel:"Mathematical Notation",math_modal_previewLabel:"Preview",math_modal_title:"Math",maxSize:"Max size",mediaGallery:"Media gallery",mention:"Mention",menu_bordered:"Bordered",menu_code:"Code",menu_neon:"Neon",menu_shadow:"Shadow",menu_spaced:"Spaced",menu_translucent:"Translucent",mergeCells:"Merge cells",minSize:"Min size",mirrorHorizontal:"Mirror, Horizontal",mirrorVertical:"Mirror, Vertical",newDocument:"New document",numberedList:"Numbered list",outdent:"Outdent",pageBreak:"Page break",pageDown:"Page down",pageNumber:"Page number",pageUp:"Page up",paragraphStyle:"Paragraph style",preview:"Preview",print:"print",proportion:"Constrain proportions",ratio:"Ratio",redo:"Redo",remove:"Remove",removeFormat:"Remove Format",replace:"Replace",replaceAll:"Replace all",resize100:"Zoom 100%",resize25:"Zoom 25%",resize50:"Zoom 50%",resize75:"Zoom 75%",resize:"Resize",revert:"Revert",revisionHistory:"Revision History",right:"Right",rotateLeft:"Rotate left",rotateRight:"Rotate right",row:"Row",save:"Save",search:"Search",selectAll:"Select All",showBlocks:"Show blocks",size:"Size",splitCells:"Split cells",strike:"Strike",submitButton:"Submit",subscript:"Subscript",superscript:"Superscript",table:"Table",tableHeader:"Table header",tableProperties:"Table properties",tags:"Tags",tag_blockquote:"Quote",codeBlock:"Code Block",tag_div:"Normal (DIV)",tag_h:"Header",tag_p:"Paragraph",tag_pre:"Code",template:"Template",textStyle:"Text style",title:"Title",underline:"Underline",undo:"Undo",unmergeCells:"Unmerge cells",unlink:"Unlink",verticalSplit:"Vertical split",video:"Video",videoGallery:"Video gallery",video_modal_file:"Select from files",video_modal_title:"Insert Video",video_modal_url:"Media embed URL, YouTube/Vimeo",width:"Width",codeLanguage:"Language",codeLanguage_none:"None",finder_matchCase:"Match Case",finder_wholeWord:"Whole Word",finder_regex:"Regular Expression",finder_prev:"Previous Match",finder_next:"Next Match",message_copy_success:"Copied to clipboard",message_copy_fail:"Copy failed. Please copy manually."};return void 0===e&&(t.SUNEDITOR_LANG||Object.defineProperty(t,"SUNEDITOR_LANG",{enumerable:!0,writable:!1,configurable:!1,value:{}}),Object.defineProperty(t.SUNEDITOR_LANG,"en",{enumerable:!0,writable:!0,configurable:!0,value:s})),s},"object"==typeof t.exports?t.exports=e.document?s(e,!0):function(t){if(!t.document)throw new Error("SUNEDITOR_LANG a window with a document");return s(t)}:s(e)}},e={};function s(i){var n=e[i];if(void 0!==n)return n.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,s),o.exports}s.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},s.d=(t,e)=>{for(var i in e)s.o(e,i)&&!s.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{"use strict";var t={};s.r(t),s.d(t,{Browser:()=>so,ColorPicker:()=>Wo,Controller:()=>Ms,Figure:()=>qs,HueSlider:()=>Po,Modal:()=>Go});var e={};s.r(e),s.d(e,{ApiManager:()=>to,FileManager:()=>Ko});var i={};s.r(i),s.d(i,{ModalAnchorEditor:()=>Jo,SelectMenu:()=>Ls,_DragHandle:()=>ws});var n={};s.r(n),s.d(n,{EditorComponent:()=>Ha,ModuleBrowser:()=>Ea,ModuleColorPicker:()=>Ta,ModuleController:()=>Sa,ModuleHueSlider:()=>Ma,ModuleModal:()=>ka,PluginBrowser:()=>el,PluginCommand:()=>sl,PluginDropdown:()=>il,PluginDropdownFree:()=>nl,PluginField:()=>ol,PluginInput:()=>ll,PluginModal:()=>rl,PluginPopup:()=>al});const o=window,l=document,r=Symbol("noEventHandler"),a=Symbol("onOverComponent"),h=navigator.userAgent.toLowerCase();const c="function"==typeof ResizeObserver,d="function"==typeof navigator.clipboard?.write,u=/Edg/.test(navigator.userAgent),p=/(Mac|iPhone|iPod|iPad)/.test(navigator.userAgent),g=h.includes("chrome/")&&!h.includes("edge/"),m=!!h.match(/gecko\/\d+/),f=!!o.chrome,v=h.includes("applewebkit/")&&!h.includes("chrome"),b=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(h),y=navigator.maxTouchPoints>0&&"ontouchstart"in o,w=h.includes("android"),C=p?"⌘":"CTRL",_=p?"⇧":"+SHIFT",x=o.devicePixelRatio,$={_w:o,_d:l,NO_EVENT:r,ON_OVER_COMPONENT:a,getXMLHttpRequest:function(){return new XMLHttpRequest},getPageStyle:function(t){let e="";const s=(t||l).styleSheets;for(let t,i=0,n=s.length;i<n;i++){try{t=s[i].cssRules}catch{continue}if(t)for(let s=0,i=t.length;s<i;s++)e+=t[s].cssText}return e},getIncludePath:function(t,e){let s="";const i=[],n="js"===e?"script":"link",o="js"===e?"src":"href";let r="(?:";for(let e=0,s=t.length;e<s;e++)r+=t[e]+(e<s-1?"|":")");const a=new RegExp(`(^|.*[\\/])${r}(\\.[^\\/]+)?.${e}(?:\\?.*|;.*)?$`,"i"),h=new RegExp(`.+\\.${e}(?:\\?.*|;.*)?$`,"i");for(let t=l.getElementsByTagName(n),e=0;e<t.length;e++)h.test(t[e][o])&&i.push(t[e]);for(let t=0;t<i.length;t++){const e=i[t][o].match(a);if(e){s=e[0];break}}if(!s)throw new Error("[SUNEDITOR.helper.env.getIncludePath.fail] The SUNEDITOR installation path could not be automatically detected. (path: +"+s+", extension: "+e+")");return""===s&&(s=i.length>0?i[0][o]:""),s.includes(":/")||"//"===s.slice(0,2)||(s=!1===s.includes("/")?location.href.match(/^.*?:\/\/[^/]*/)[0]+s:location.href.match(/^[^?]*\/(?:)/)[0]+s),s},isResizeObserverSupported:c,isClipboardSupported:d,isEdge:u,isBlink:g,isGecko:m,isChromium:f,isSafari:v,isOSX_IOS:p,isAndroid:w,isMobile:b,isTouchDevice:y,cmdIcon:C,shiftIcon:_,DPI:x,KATEX_WEBSITE:"https://katex.org/docs/supported.html",MATHJAX_WEBSITE:"https://www.mathjax.org/"},k=8203,S=String.fromCharCode(k),E=new RegExp(String.fromCharCode(k),"g"),T=new RegExp("^"+String.fromCharCode(k)+"+$");const M={zeroWidthSpace:S,zeroWidthRegExp:E,onlyZeroWidthRegExp:T,escapeStringRegexp:function(t){if("string"!=typeof t)throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}},H=/&|\u00A0|'|"|<|>/g,L=/&| |'|"|<|>/g,N={"&":"&"," ":" ","'":"'",'"':""","<":"<",">":">"},B={"&":"&"," ":" ","'":"'",""":'"',"<":"<",">":">"},A=/[A-Z]/g,I=/-[a-zA-Z]/g,V={"xx-small":.5625,"x-small":.625,small:.8333,medium:1,large:1.125,"x-large":1.5,"xx-large":2,"xxx-large":2.5};function O(t){if(3===t.nodeType){const e=t.nodeValue.trim();return e?{type:"text",content:e}:null}if(1===t.nodeType){const e={type:"element",tag:t.tagName.toLowerCase(),attributes:{},children:[]};for(const s of t.attributes)e.attributes[s.name]=s.value;for(const s of t.childNodes){const t=O(s);t&&e.children.push(t)}return e}return null}function R(t){return t.replace(H,(t=>N[t]||t))}function z(t){return/^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(t)}const F={htmlToJson:function(t){return O((new DOMParser).parseFromString(t,"text/html").body)},jsonToHtml:function t(e){if(!e)return"";if("text"===e.type)return R(e.content||"");if("element"===e.type){const{tag:s,attributes:i={},children:n=[]}=e,o=Object.entries(i).map((([t,e])=>`${t}="${R(e)}"`)).join(" "),l=`</${s}>`;return`${o?`<${s} ${o}>`:`<${s}>`}${n.map(t).join("")}${l}`}return""},htmlToEntity:R,entityToHTML:function(t){return t.replace(L,(t=>B[t]||t))},debounce:function(t,e){let s;return function(...i){o.clearTimeout(s),s=o.setTimeout((()=>{o.clearTimeout(s),t(...i)}),e)}},syncMaps:function(t,e){e.forEach(((e,s)=>{t.set(s,e)})),t.forEach(((s,i)=>{e.has(i)||t.delete(i)}))},mergeMaps:function(...t){const e=t.filter((t=>t instanceof Map)).flatMap((t=>[...t]));return new Map(e)},getValues:function(t){return t?Object.keys(t).map((function(e){return t[e]})):[]},camelToKebabCase:function t(e){return"string"==typeof e?e.replace(A,(t=>"-"+t.toLowerCase())):e.map((function(e){return t(e)}))},kebabToCamelCase:function t(e){return"string"==typeof e?e.replace(I,(t=>t.replace("-","").toUpperCase())):e.map((function(e){return t(e)}))},toFontUnit:function(t,e){const s=e.match(/(\d+(?:\.\d+)?)(.+)/),i=s?Number(s[1]):V[e],n=s?s[2]:"rem";let o=i;switch(/em/.test(n)?o=Math.round(i/.0625):"pt"===n?o=Math.round(1.333*i):"%"===n&&(o=i/100),t){case"em":case"rem":return(.0625*o).toFixed(2)+t;case"%":return 100*Number((.0625*o).toFixed(2))+t;case"pt":return Math.round(o/1.333)+t;default:return o+t}},nodeListToArray:function(t){return t?Array.prototype.slice.call(t):[]},swapKeyValue:function(t){const e={},s=Object.prototype.hasOwnProperty;for(const i in t)s.call(t,i)&&(e[t[i]]=i);return e},createElementWhitelist:function(t){return new RegExp(`<\\/?\\b(?!\\b${(t||"").replace(/\|/g,"\\b|\\b")}\\b)[^>]*>`,"gi")},createElementBlacklist:function(t){return new RegExp(`<\\/?\\b(?:\\b${(t||"^").replace(/\|/g,"\\b|\\b")}\\b)[^>]*>`,"gi")},isHexColor:z,rgb2hex:function(t){if(z(t)||!t)return t;const e=t.match(/^rgba?[\s+]?\(([\d]+)[\s+]?,[\s+]?([\d]+)[\s+]?,[\s+]?([\d]+)[\s+]?/i);if(e&&e.length>=4){const s=("0"+parseInt(e[1],10).toString(16)).slice(-2),i=("0"+parseInt(e[2],10).toString(16)).slice(-2),n=("0"+parseInt(e[3],10).toString(16)).slice(-2);let o="";if(t.includes("rgba")){const e=t.match(/,\s*([\d]+\.?[\d]*)\s*\)/);e&&(o=("0"+Math.round(255*parseFloat(e[1])).toString(16)).slice(-2))}return`#${s}${i}${n}${o}`}return t},getWidthInPercentage:function(t,e){const s=e||t.parentElement,i=o.getComputedStyle(s),n=parseFloat(i.paddingLeft),l=parseFloat(i.paddingRight),r=s.offsetWidth-s.clientWidth,a=s.offsetWidth-n-l-r;return t.offsetWidth/a*100},textToAnchor:function(t){const e=/https?:\/\/[^\s]+/g;if(3===t.nodeType&&e.test(t.textContent)&&!/^A$/i.test(t.parentNode?.nodeName)){const s=t.textContent,i=l.createDocumentFragment();let n=0;return s.replace(e,((t,e)=>{e>n&&i.appendChild(l.createTextNode(s.slice(n,e)));const o=l.createElement("a");return o.href=t,o.target="_blank",o.textContent=t,i.appendChild(o),n=e+t.length,t})),n<s.length&&i.appendChild(l.createTextNode(s.slice(n))),t.parentNode.replaceChild(i,t),!0}return!1},spanToStyleNode:function(t,e){if(1===e.nodeType&&/^SPAN$/i.test(e.nodeName)&&e.hasAttribute("style")){const s=e.getAttribute("style"),i=[];if(Object.keys(t).forEach((e=>{if(t[e].regex.test(s)){const s=l.createElement(t[e].tag);i.push(s)}})),i.length>0){const t=l.createElement("span");let s=e.firstChild;i.forEach(((e,s)=>{0===s?t.appendChild(e):i[s-1].appendChild(e)}));const n=i[i.length-1];for(;s;){const t=s.nextSibling;n.appendChild(s),s=t}e.appendChild(t)}}},addUrlQuery:function(t,e){if(e.length>0)if(/\?/.test(t)){const s=t.split("?");t=s[0]+"?"+e+"&"+s[1]}else t+="?"+e;return t},_setDefaultOptionStyle:function(t,e){let s="";t.get("height")&&(s+="height:"+t.get("height")+";"),t.get("minHeight")&&(s+="min-height:"+t.get("minHeight")+";"),t.get("maxHeight")&&(s+="max-height:"+t.get("maxHeight")+";"),t.get("width")&&(s+="width:"+t.get("width")+";"),t.get("minWidth")&&(s+="min-width:"+t.get("minWidth")+";"),t.get("maxWidth")&&(s+="max-width:"+t.get("maxWidth")+";");let i="",n="",o="";const l=(e=s+e).split(";");for(let e,s=0,r=l.length;s<r;s++)e=l[s].trim(),e&&(/^(min-|max-)?width\s*:/.test(e)||/^(z-index|position|display)\s*:/.test(e)?i+=e+";":/^(min-|max-)?height\s*:/.test(e)?(/^height/.test(e)&&"auto"===e.split(":")[1].trim()&&t.set("height","auto"),n+=e+";"):o+=e+";");return{top:i,frame:n,editor:o}},_setIframeStyleLinks:function(t){let e="";if(t){const s=l.getElementsByTagName("link");for(let i,n=0,o=t.length;n<o;n++){i=[];const o=t[n];if("*"===o)for(let t=0,e=s.length;t<e;t++)"stylesheet"===s[t].rel&&s[t].href&&i.push(s[t].href);else if(/(^https?:\/\/)|(^data:text\/css,)/.test(o))i.push(o);else{const t=new RegExp(`(^|.*[\\/])${o}(\\..+)?.css((\\??.+?)|\\b)$`,"i");for(let e,n=0,o=s.length;n<o;n++)e=s[n].href.match(t),e&&i.push(e[0])}if(!i||0===i.length)throw new Error('[SUNEDITOR.constructor.iframe.fail] The suneditor CSS files installation path could not be automatically detected. Please set the option property "iframe_cssFileName" before creating editor instances.');for(let t=0,s=i.length;t<s;t++)e+='<link href="'+i[t]+'" rel="stylesheet">'}}return e},_setAutoHeightStyle:function(t){return"auto"===t?"<style>\n/** Iframe height auto */\nbody{height: min-content; overflow: hidden;}\n</style>":""}},P=F,D=/(\s|^)(katex|MathJax|se-exclude-format)(\s|$)/;function q(t){if(null==t)return!1;if("string"!=typeof t){if(W(t)){const e=t.children;for(let t=0,s=e.length;t<s;t++){if(!j(e[t]))return!1}}t=t.textContent}return""===t||T.test(t)}function W(t){return 1===t?.nodeType}function U(t){return/^(OL|UL)$/i.test("string"==typeof t?t:t?.nodeName)}function Z(t){return/^TABLE$/i.test("string"==typeof t?t:t?.nodeName)}function G(t){return/^BR$/i.test("string"==typeof t?t:t?.nodeName)}function j(t){return/^(BR|COLGROUP|COL|THEAD|TBODY|TFOOT|TR|AREA|BASE|EMBED|HR|IMG|INPUT|KEYGEN|LINK|META|PARAM|SOURCE|TRACK|WBR)$/i.test("string"==typeof t?t:t?.nodeName)}function K(t){if(1!==t?.nodeType)return!1;const e=t.classList;return!!e&&("BODY"===t.nodeName.toUpperCase()||e.contains("se-wrapper-wysiwyg")||e.contains("sun-editor-carrier-wrapper")||e.contains("se-wrapper"))}function Y(t){return t?.hasAttribute("data-important-disabled")}const X={isZeroWidth:q,isEdgePoint:function(t,e,s){return"end"!==s&&0===e||(!s||"front"!==s)&&!t.nodeValue&&e<=1||(!s||"end"===s)&&t.nodeValue&&e>=t.nodeValue.length},isText:function(t){return 3===t?.nodeType},isElement:W,isInputElement:function(t){return W(t)&&/^(INPUT|TEXTAREA|SELECT|OPTION)$/i.test(t.nodeName)},isButtonElement:function(t){return W(t)&&/^(BUTTON)$/i.test(t.nodeName)},isList:U,isListCell:function(t){return/^LI$/i.test("string"==typeof t?t:t?.nodeName)},isTable:Z,isTableElements:function(t){return/^(TABLE|THEAD|TBODY|TR|TH|TD|COL)$/i.test("string"==typeof t?t:t?.nodeName)},isTableCell:function(t){return/^(TD|TH)$/i.test("string"==typeof t?t:t?.nodeName)},isTableRow:function(t){return/^TR$/i.test("string"==typeof t?t:t?.nodeName)},isBreak:G,isAnchor:function(t){return/^A$/i.test("string"==typeof t?t:t?.nodeName)},isMedia:function(t){return/^(IMG|IFRAME|AUDIO|VIDEO|CANVAS)$/i.test("string"==typeof t?t:t?.nodeName)},isIFrame:function(t){return/^IFRAME$/i.test("string"==typeof t?t:t?.nodeName)},isFigure:function(t){return/^FIGURE$/i.test("string"==typeof t?t:t?.nodeName)},isContentLess:j,isEmptyLine:function(t){if(!t?.parentNode)return!0;const e=t;return!e.querySelector("IMG, IFRAME, AUDIO, VIDEO, CANVAS, TABLE")&&(e.children.length<=1||G(e.firstElementChild))&&q(e.textContent)},isComponentContainer:function(t){if(1!==t?.nodeType)return!1;const e=t.classList;return!!e&&(e.contains("se-component")||e.contains("se-flex-component"))},isWysiwygFrame:K,isNonEditable:function(t){return 1===t?.nodeType&&"false"===t.getAttribute("contenteditable")},isSpanWithoutAttr:function(t){if(1!==t?.nodeType)return!1;const e=t;return/^SPAN$/i.test(e.nodeName)&&!e.className&&0===e.style.length},isSameAttributes:function(t,e){if(3===t.nodeType&&3===e.nodeType)return!0;if(3===t.nodeType||3===e.nodeType)return!1;const s=t,i=e,n=s.style,o=i.style;let l=0;for(let t=0,e=n.length;t<e;t++)n[n[t]]===o[n[t]]&&l++;const r=s.classList,a=i.classList;let h=0;for(let t=0,e=r.length;t<e;t++)a.contains(r[t])&&h++;return l===o.length&&l===n.length&&h===a.length&&h===r.length},isExcludeFormat:function(t){return D.test(t?.className)},isUneditable:function(t){return t?.classList.contains("__se__uneditable")},isImportantDisabled:Y},J=X;function Q(t){const e=Object.prototype.toString.call(t);return"[object HTMLCollection]"===e||"[object NodeList]"===e||"[object Array]"===e}function tt(t,e,s){const i=l.createElement(t);if(e)for(const t in e)void 0!==e[t]&&null!==e[t]&&i.setAttribute(t,e[t]);return s&&("string"==typeof s?i.innerHTML=s:"object"==typeof s&&i.appendChild(s)),i}function et(t,e){let s=-1;for(let i=0,n=t.length;i<n;i++)if(t[i]===e){s=i;break}return s}function st(t,e,s){const i=t,n=e;if(n.style.length>0){const t=n.style;for(let e=0,s=t.length;e<s;e++)i.style[t[e]]=t[t[e]]}const o=n.attributes;for(let t,e=0,n=o.length;e<n;e++)t=o[e].name.toLowerCase(),s?.includes(t)||!o[e].value?i.removeAttribute(t):"style"!==t&&i.setAttribute(o[e].name,o[e].value)}function it(t,e){if(t&&1===t.nodeType)return e.split("|").some((e=>t.classList.contains(e)))}function nt(t,e){if(!t)return;const s=Q(t)?t:[t],i=e.split("|");for(let t=0,e=s.length;t<e;t++){const e=s[t];if(e&&1===e.nodeType)for(const t of i)t&&e.classList.add(t)}}function ot(t,e){if(!t)return;const s=Q(t)?t:[t],i=e.split("|");for(let t=0,e=s.length;t<e;t++){const e=s[t];if(e&&1===e.nodeType)for(const t of i)t&&e.classList.remove(t)}}function lt(t=l){return{w:t.documentElement.clientWidth,h:t.documentElement.clientHeight}}const rt={clone:function(t,e=!1){return t.cloneNode(e)},createElement:tt,createTextNode:function(t){return l.createTextNode(t||"")},getAttributesToString:function(t,e){const s=t.attributes;if(!s)return"";let i="";for(let t=0,n=s.length;t<n;t++)e?.includes(s[t].name)||(i+=s[t].name+'="'+R(s[t].value)+'" ');return i},arrayFilter:function(t,e){if(!t||0===t.length)return null;e||=()=>!0;const s=[];for(let i,n=0,o=t.length;n<o;n++)i=t[n],e(i)&&s.push(i);return s},arrayFind:function(t,e){if(!t||0===t.length)return null;e||=()=>!0;for(let s,i=0,n=t.length;i<n;i++)if(s=t[i],e(s))return s;return null},arrayIncludes:function(t,e){for(let s=0;s<t.length;s++)if(t[s]===e)return!0;return!1},getArrayIndex:et,nextIndex:function(t,e){const s=et(t,e);return-1===s?-1:s+1},prevIndex:function(t,e){const s=et(t,e);return-1===s?-1:s-1},copyTagAttributes:st,copyFormatAttributes:function(t,e){const s=e.cloneNode(!1);s.className=s.className.replace(/(\s|^)__se__format__[^\s]+/g,""),st(t,s)},removeItem:function(t){t&&("remove"in t&&"function"==typeof t.remove?t.remove():t.parentNode&&t.parentNode.removeChild(t))},changeElement:function(t,e){if(t)if("string"==typeof e)if("outerHTML"in t)t.outerHTML=e;else{const s=tt("DIV");s.innerHTML=e,t.parentNode.replaceChild(s.firstChild,t)}else 1===e?.nodeType&&t.parentNode.replaceChild(e,t)},changeTxt:function(t,e){t&&e&&(t.textContent=e)},setStyle:function(t,e,s){for(let i,n=0,o=(t=Array.isArray(t)?t:[t]).length;n<o;n++)i=t[n],i.style[e]=s,0===i.style.length&&i.removeAttribute("style")},getStyle:function(t,e){if(1===t?.nodeType)return t.style[e]},setDisabled:function(t,e,s){for(let i=0,n=t.length;i<n;i++){const n=t[i];!s&&Y(n)||(n.disabled=e),s&&(e?n.setAttribute("data-important-disabled",""):n.removeAttribute("data-important-disabled"))}},hasClass:it,addClass:nt,removeClass:ot,toggleClass:function(t,e,s){if(!t||1!==t.nodeType)return;const i=t;i.classList.toggle(e,s),i.className.trim()||i.removeAttribute("class")},flashClass:function(t,e,s=120){nt(t,e),o.setTimeout((()=>{ot(t,e)}),s)},getClientSize:lt,getViewportSize:function(){return"visualViewport"in o?{top:o.visualViewport.pageTop,left:o.visualViewport.pageLeft,scale:o.visualViewport.scale}:{top:0,left:0,scale:1}},applyInlineStylesAll:function(t,e,s){if(!t)return console.warn('"parentTarget" is not exist'),null;let i=t;const n=l.createElement("DIV");if(n.style.display="none",/body/i.test(i.nodeName)){const t=l.createElement("DIV"),e=i.attributes;for(let s=0,i=e.length;s<i;s++)t.setAttribute(e[s].name,e[s].value);t.innerHTML=i.innerHTML,i=t}else i=i.cloneNode(!0);n.appendChild(i),l.body.appendChild(n);const r=Array.from(i.querySelectorAll("*")),a=e?[i].concat(r):r;for(let t,e=0;t=a[e];e++){if(1!==t.nodeType)continue;const e=o.getComputedStyle(t),i=t.style;for(const t of s)i.setProperty(t,e.getPropertyValue(t)||"")}return l.body.removeChild(n),i},waitForMediaLoad:function(t,e=5e3){const s=t||l;return new Promise((t=>{const i=["img","video","audio","iframe"].flatMap((t=>Array.from(s.querySelectorAll(t))));if(0===i.length)return void t();const n=i.map((t=>{if(function(t){return"[object HTMLImageElement]"===Object.prototype.toString.call(t)}(t)){if(t.complete)return Promise.resolve()}else if(function(t){const e=Object.prototype.toString.call(t);return"[object HTMLVideoElement]"===e||"[object HTMLAudioElement]"===e}(t)){if(t.readyState>=2)return Promise.resolve()}else if(function(t){return"[object HTMLIFrameElement]"===Object.prototype.toString.call(t)}(t))try{if("complete"===t.contentDocument?.readyState)return Promise.resolve()}catch(t){console.warn(["[SUNEDITOR] Iframe load error",t])}return new Promise((e=>{t.addEventListener("load",e,{once:!0}),t.addEventListener("error",e,{once:!0})}))}));Promise.race([Promise.all(n),new Promise((t=>o.setTimeout(t,e)))]).then((()=>{t()}))}))},getRootCssVar:function(t){return l.documentElement.style.getPropertyValue(t)},setRootCssVar:function(t,e){l.documentElement.style.setProperty(t,e)},createTooltipInner:function(t){return`<span class="se-tooltip-inner"><span class="se-tooltip-text">${t}</span></span>`}};function at(t){let e=0;for(;t=t.previousSibling;)e+=1;return e}function ht(t,e,s){const i=[];let n=!0;return pt(t,(t=>{if(t===e&&(n=!1),n&&!J.isWysiwygFrame(t)){if(s&&3===t.nodeType){let e=null,i=null;s.s=s.e=0;let n=t.previousSibling;for(;3===n?.nodeType;)i=n.textContent.replace(E,""),s.s+=i.length,t.textContent=i+t.textContent,e=n,n=n.previousSibling,rt.removeItem(e);let o=t.nextSibling;for(;3===o?.nodeType;)i=o.textContent.replace(E,""),s.e+=i.length,t.textContent+=i,e=o,o=o.nextSibling,rt.removeItem(e)}i.push(t)}return!1})),i.map(at).reverse()}function ct(t,e){let s,i=e;for(let e=0,n=t.length;e<n&&(s=i.childNodes,0!==s.length);e++)i=s.length<=t[e]?s[s.length-1]:s[t[e]];return i}function dt(t,e,s){const i=[];return s??=1/0,!t||s<=0||0===t.childNodes.length||(e||=()=>!0,function t(n,o){if(o>s)return;if(o>0&&e(n)&&i.push(n),o===s)return;const l=n.childNodes;for(let e=0,s=l.length;e<s;e++)t(l[e],o+1)}(t,0)),i}function ut(t){if(!t||J.isWysiwygFrame(t))return-1;let e=0;for(t=t.parentNode;t&&!J.isWysiwygFrame(t);)e+=1,t=t.parentNode;return e}function pt(t,e,s){let i;if("function"==typeof e)i=e;else if("object"==typeof e)i=t=>t===e;else{let t;/^\./.test(e)?(t="className",e="(\\s|^)"+e.split(".")[1]+"(\\s|$)"):/^#/.test(e)?(t="id",e="^"+e.split("#")[1]+"$"):/^:/.test(e)?(t="name",e="^"+e.split(":")[1]+"$"):(t="nodeName",e="^"+e+"$");const s=new RegExp(e,"i");i=e=>s.test(e[t])}s||=1/0;let n=0;for(;t&&!i(t);){if(n>=s||J.isWysiwygFrame(t))return null;t=t.parentElement,n++}return t}const gt={getPositionIndex:at,getNodePath:ht,getNodeFromPath:ct,getChildNode:function(t,e){let s=null;if(!t)return s;const i=t;return i.children&&0!==i.children.length?(e||=()=>!0,function t(n){if(i!==n&&e(n))return s=n,!0;if(n.children)for(let e=0,s=n.children.length;e<s;e++)t(n.children[e])}(i),s):s},getListChildren:function(t,e,s){const i=[];if(s??=1/0,!t||s<=0)return i;const n=t;return n.children&&0!==n.children.length?(e||=()=>!0,function t(o,l){if(!(l>s)&&(l>0&&n!==o&&e(o)&&i.push(o),l!==s&&o.children))for(let e=0,s=o.children.length;e<s;e++)t(o.children[e],l+1)}(n,0),i):i},getListChildNodes:dt,getNodeDepth:ut,sortNodeByDepth:function(t,e){const s=e?1:-1,i=-1*s;t.sort((function(t,e){if(!J.isListCell(t)||!J.isListCell(e))return 0;const n=ut(t),o=ut(e);return n>o?s:n<o?i:0}))},compareElements:function(t,e){let s=t,i=e;const n=ut(t),o=ut(e);if(n>o){let t=n-o;for(;t>0&&s;)s=s.parentElement,t--}else if(o>n){let t=o-n;for(;t>0&&i;)i=i.parentElement,t--}for(;s&&i&&s.parentElement!==i.parentElement;)s=s.parentElement,i=i.parentElement;if(!s?.parentNode||!i?.parentNode)return{ancestor:null,a:t,b:e,result:0};const l=s.parentNode.childNodes,r=rt.getArrayIndex(l,s),a=rt.getArrayIndex(l,i);return{ancestor:s.parentElement,a:s,b:i,result:r>a?1:r<a?-1:0}},getParentElement:pt,getParentElements:function(t,e,s){let i;if("function"==typeof e)i=e;else if("object"==typeof e)i=t=>t===e;else{let t;/^\./.test(e)?(t="className",e="(\\s|^)"+e.split(".")[1]+"(\\s|$)"):/^#/.test(e)?(t="id",e="^"+e.split("#")[1]+"$"):/^:/.test(e)?(t="name",e="^"+e.split(":")[1]+"$"):(t="nodeName",e="^"+e+"$");const s=new RegExp(e,"i");i=e=>s.test(e[t])}const n=[];s||=1/0;let o=0;for(;o<=s&&t&&!J.isWysiwygFrame(t);)i(t)&&n.push(t),t=t.parentElement,o++;return n},getCommandTarget:function(t){let e=t;for(;e&&!/^(UL)$/i.test(e.nodeName)&&!rt.hasClass(e,"sun-editor");){if(e.hasAttribute("data-command"))return e;e=e.parentElement}return null},getEventTarget:function(t){return t.target},getEdgeChild:function(t,e,s){let i;if("function"==typeof e)i=e;else if("object"==typeof e)i=function(t){return t===e};else{let t;/^\./.test(e)?(t="className",e="(\\s|^)"+e.split(".")[1]+"(\\s|$)"):/^#/.test(e)?(t="id",e="^"+e.split("#")[1]+"$"):/^:/.test(e)?(t="name",e="^"+e.split(":")[1]+"$"):(t="nodeName",e="^"+("text"===e?"#"+e:e)+"$");const s=new RegExp(e,"i");i=function(e){return s.test(e[t])}}const n=dt(t,(t=>i(t)),null);return n[s?n.length-1:0]},getEdgeChildNodes:function(t,e){if(t){for(e||=t;t&&1===t.nodeType&&t.childNodes.length>0&&!J.isBreak(t);)t=t.firstChild;for(;e&&1===e.nodeType&&e.childNodes.length>0&&!J.isBreak(e);)e=e.lastChild;return{sc:t,ec:e||t}}},getPreviousDeepestNode:function(t,e){let s=t.previousSibling;if(!s){for(let i=t.parentNode;i;i=i.parentNode){if(i===e)return null;if(i.previousSibling){s=i.previousSibling;break}}if(!s)return null}if(J.isNonEditable(s))return s;for(;s.lastChild;)s=s.lastChild;return s},getNextDeepestNode:function(t,e){let s=t.nextSibling;if(!s){for(let i=t.parentNode;i;i=i.parentNode){if(i===e)return null;if(i.nextSibling){s=i.nextSibling;break}}if(!s)return null}if(J.isNonEditable(s))return s;for(;s.firstChild;)s=s.firstChild;return s},findTextIndexOnLine:function(t,e,s,i){if(!t)return 0;i||=()=>!0;let n=0,o=!1;return function t(l){if(!o&&8!==l.nodeType&&!i(l))if(3===l.nodeType){if(l===e)return n+=s,void(o=!0);n+=l.textContent.length}else if(1===l.nodeType){const e=l.childNodes;for(let s=0,i=e.length;s<i;s++)if(t(e[s]),o)return}}(t),n},findTabEndIndex:function(t,e,s){if(!t)return 0;const i=t.textContent,n=new RegExp(`((\\u00A0|\\s){${s},})`,"g");let o;for(n.lastIndex=e;null!==(o=n.exec(i));)if(o.index>=e){const t=o.index+o[0].length-1;return t+(i.slice(0,t+1).match(/[^\u00A0\s]/g)||[]).length+s}return 0},findVisualLastCell:function(t){if(!t||0===t.length)return null;const e={};let s=null,i=-1,n=-1;for(const o of t){const t=o.parentElement.rowIndex,l=o.rowSpan||1,r=o.colSpan||1;e[t]||=[];let a=0;const h=e[t];for(;h[a];)a++;for(let t=0;t<r;t++)h[a+t]=!0;for(let s=1;s<l;s++){const i=t+s;e[i]||=[];for(let t=0;t<r;t++)e[i][a+t]=!0}const c=t+l-1,d=a+r-1;(c>i||c===i&&d>n)&&(i=c,n=d,s=o)}return s},getScrollParents:function(t){const e=[];let s=t?.parentElement;for(;s&&!/^(body|html)$/i.test(s.nodeName);){const t=o.getComputedStyle(s),{overflow:i,overflowX:n,overflowY:l}=t;[i,n,l].some((t=>["auto","scroll","overlay"].includes(t)))&&e.push(s),s=s.parentElement}return e},getIframeDocument:function(t){return t.contentWindow?.document||t.contentDocument}};const mt={query:gt,check:J,utils:rt};function ft(t,e=0){if(!t)return 0;const s=(t+"").match(/-?\d+(\.\d+)?/);if(!s||!s[0])return 0;const i=Number(s[0]);return e<0?i:0===e?Math.round(i):Number(i.toFixed(e))}const vt={is:function(t){return/^-?\d+(\.\d+)?$/.test(t+"")},get:ft,getOverlapRangeAtIndex:function(t,e,s,i){if(t<=i?e<s:e>s)return 0;const n=(t>s?t:s)-(e<i?e:i);return(n<0?-1*n:n)+1},isEven:function(t){return!(1&t)},isOdd:function(t){return!(1&~t)}},bt="ArrowLeft|ArrowUp|ArrowRight|ArrowDown",yt="F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12",wt=bt.split("|"),Ct="Backspace|Delete".split("|"),_t=`Backspace|Tab|Enter|ShiftLeft|ShiftRight|ControlLeft|ControlRight|AltLeft|AltRight|Pause|CapsLock|Escape|PageUp|PageDown|End|Home|${bt}|Insert|Delete|${yt}|NumLock|ScrollLock`.split("|"),xt="Backspace|Enter|Delete".split("|"),$t="Backspace|Enter|Delete".split("|"),kt=`ControlLeft|ControlRight|AltLeft|AltRight|Pause|CapsLock|Escape|Insert|${yt}|NumLock|ScrollLock`.split("|");const St={write:async function(t){if(!d)return console.error("Clipboard is not supported in this browser."),!1;let e="",s="";"string"==typeof t?(e=t,s=t):W(t)?(t.querySelectorAll("iframe").forEach((t=>{const e=document.createElement("div"),s={};for(const e of Array.from(t.attributes))s[e.name]=e.value;e.setAttribute("data-se-iframe-holder","1"),e.setAttribute("data-se-iframe-holder-attrs",JSON.stringify(s)),e.innerText=`[iframe: ${t.src}]`,t.replaceWith(e)})),e=t.outerHTML,s=t.textContent):(e=t.textContent,s=t.textContent);try{await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([e],{type:"text/html"}),"text/plain":new Blob([s],{type:"text/plain"})})])}catch{console.warn("[SUNEDITOR.copy.warn] This browser is not supported Clipboard API");try{await navigator.clipboard.writeText(s||function(t){const e=document.createElement("div");return e.innerHTML=t,e.textContent||e.innerText||""}(e))}catch(t){console.error("[SUNEDITOR.copy.fail] "+t)}}}},Et=/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/i,Tt=/^[\u200B\uFEFF]+$/;function Mt(t){const e=t.trim();return""===e||Tt.test(e)}const Ht={strong:"**",b:"**",em:"*",i:"*",del:"~~",s:"~~",mark:"=="};function Lt(t){if(!t||0===t.length)return"";const e=[];for(let s=0;s<t.length;s++){const i=Ot(t[s],"",!1);if(i){if(e.length>0){const t=e[e.length-1];!t||t.endsWith(" ")||t.endsWith("\n")||i.startsWith(" ")||i.startsWith("\n")||e.push(" ")}e.push(i)}}return e.join("")}function Nt(t){return t?"text"===t.type?t.content||"":t.children?t.children.map(Nt).join(""):"":""}function Bt(t){if(!t)return"";if("text"===t.type)return t.content||"";const{tag:e,attributes:s={},children:i=[]}=t,n=Object.entries(s).map((([t,e])=>`${t}="${e}"`)).join(" "),o=n?`<${e} ${n}>`:`<${e}>`;if(Et.test(e))return o;return`${o}${i.map(Bt).join("")}</${e}>`}function At(t,e){return t?t.split("\n").map((t=>t?e+t:"")).join("\n")+"\n":""}function It(t,e,s){const i=t.children||[];let n="",o=1;for(const t of i){if("element"!==t.type||"li"!==t.tag)continue;const i=s?`${o}. `:"- ",l=t.children||[];let r="",a="";const h=e+" ".repeat(i.length);let c="";const d=l[0];d&&"element"===d.type&&"input"===d.tag&&"checkbox"===d.attributes?.type&&(c=void 0!==d.attributes.checked?"[x] ":"[ ] ");for(let t=0;t<l.length;t++){const e=l[t];if(0===t&&c)continue;if("element"!==e.type){r+=Ot(e,"",!1);continue}const s=e.tag;if("ul"===s||"ol"===s)a+=It(e,h,"ol"===s);else if("table"===s)a+=At(Vt(e),h);else if("figure"===s){const t=(e.children||[]).find((t=>"element"===t.type&&"table"===t.tag));a+=At(t?Vt(t):Ot(e,"",!0),h)}else"blockquote"===s||"pre"===s?a+=At(Ot(e,"",!0),h):r+=Ot(e,"",!1)}n+=`${e}${i}${c}${r.trim()}\n`,a&&(n+=a),o++}return n}function Vt(t){const e=[];let s=!1;if(function t(i,n){for(const o of i.children||[])if("thead"===o.tag)t(o,!0);else if("tbody"===o.tag||"tfoot"===o.tag)t(o,!1);else if("tr"===o.tag){const t=[];for(const e of o.children||[])if("td"===e.tag||"th"===e.tag){const s=Lt(e.children).trim(),i=parseInt(e.attributes?.colspan,10)||1,n=parseInt(e.attributes?.rowspan,10)||1;t.push({content:s,colspan:i,rowspan:n})}const i=n||!s&&o.children?.some((t=>"th"===t.tag));i&&(s=!0),e.push({cells:t,isHeader:i})}}(t,!1),0===e.length)return"";const i=e.filter((t=>t.isHeader)),n=e.filter((t=>!t.isHeader)),o=[...i,...n];let l=0;for(const t of o){let e=0;for(const s of t.cells)e+=s.colspan;e>l&&(l=e)}const r=Array.from({length:o.length},(()=>new Array(l).fill(null)));for(let t=0;t<o.length;t++){let e=0;for(const s of o[t].cells){for(;e<l&&null!==r[t][e];)e++;if(e>=l)break;for(let i=0;i<s.rowspan&&t+i<o.length;i++)for(let n=0;n<s.colspan&&e+n<l;n++)r[t+i][e+n]=0===i&&0===n?s.content:"";e+=s.colspan}for(let e=0;e<l;e++)null===r[t][e]&&(r[t][e]="")}let a="";if(i.length>0){a+="| "+r[0].join(" | ")+" |\n",a+="| "+r[0].map((()=>"---")).join(" | ")+" |\n";for(let t=1;t<r.length;t++)a+="| "+r[t].join(" | ")+" |\n"}else{a+="| "+new Array(l).fill(" ").join(" | ")+" |\n",a+="| "+new Array(l).fill("---").join(" | ")+" |\n";for(let t=0;t<r.length;t++)a+="| "+r[t].join(" | ")+" |\n"}return a}function Ot(t,e,s){if(!t)return"";if("text"===t.type)return(t.content||"").replace(/[\u200B\uFEFF]/g,"");if("element"!==t.type)return"";const{tag:i,attributes:n={},children:o=[]}=t;if("body"===i)return o.map((t=>Ot(t,"",!0))).join("");const l=/^h([1-6])$/.exec(i);if(l){const t=parseInt(l[1],10);return`${"#".repeat(t)} ${Lt(o).trim()}\n\n`}if("p"===i){const t=Lt(o);return t.trim()?`${t.trim()}\n\n`:"\n"}if("br"===i)return"\n";if("hr"===i)return"---\n\n";const r=Ht[i];if(r){return`${r}${Lt(o)}${r}`}if("code"===i){const t=Nt({children:o});return t.includes("`")?"`` "+t+" ``":"`"+t+"`"}if("kbd"===i){return`<kbd>${Nt({children:o})}</kbd>`}if("sub"===i){return`<sub>${Lt(o)}</sub>`}if("sup"===i){return`<sup>${Lt(o)}</sup>`}if("a"===i){const t=n.href||"",e=Lt(o),s=n.title;return s?`[${e}](${t} "${s}")`:`[${e}](${t})`}if("img"===i){const t=n.src||"";return``}if("blockquote"===i){return o.map((t=>Ot(t,"",!0))).join("").replace(/\n$/,"").split("\n").map((t=>`> ${t}`)).join("\n")+"\n\n"}if("pre"===i){let e="",s="";const i=o.find((t=>"element"===t.type&&"code"===t.tag));return i?(e=(i.attributes?.class||"").replace(/^language-/,""),s=Nt(i)):(e=(t.attributes?.class||"").match(/language-(\S+)/)?.[1]||"",s=Nt({children:o})),"```"+e+"\n"+s+"\n```\n\n"}if("details"===i)return Bt(t)+"\n\n";if("summary"===i)return Bt(t);if("ul"===i)return It(t,e,!1)+"\n";if("ol"===i)return It(t,e,!0)+"\n";if("table"===i)return Vt(t)+"\n";if("dl"===i){let t="";for(const e of o)"element"===e.type&&("dt"===e.tag?t+=Lt(e.children).trim()+"\n":"dd"===e.tag&&(t+=": "+Lt(e.children).trim()+"\n"));return t+"\n"}if("dt"===i||"dd"===i)return Lt(o).trim();if("div"===i){if(n.class&&/se-component/.test(n.class))return o.map((t=>Ot(t,e,!0))).join("");const t=Lt(o);return s?t+"\n\n":t}if("span"===i)return n.style||n.class?Bt(t):Lt(o);if("figure"===i){const t=o.map((t=>Ot(t,e,!0))).join("");return/\n$/.test(t)?t:t+"\n\n"}if("figcaption"===i){const t=Lt(o).trim();return t?t+"\n\n":""}return"video"===i||"audio"===i||"iframe"===i?Bt(t)+"\n\n":Bt(t)}function Rt(t){if(!t)return"";const e=[];function s(t){return e.push(t),""+(e.length-1)+""}return t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=t.replace(/\\([\\*_~`[\]()#!|{}<>+-])/g,((t,e)=>s(e)))).replace(/``\s(.+?)\s``/g,((t,e)=>s("<code>"+e+"</code>")))).replace(/`([^`]+)`/g,((t,e)=>s("<code>"+e+"</code>")))).replace(/!\[([^\]]*)\]\(([^)\s]+)(?:\s+"([^"]*)")?\)/g,((t,e,i,n)=>s(n?`<img src="${i}" alt="${e}" title="${n}">`:`<img src="${i}" alt="${e}">`)))).replace(/\[([^\]]+)\]\(([^)\s]+)(?:\s+"([^"]*)")?\)/g,((t,e,i,n)=>s(n?`<a href="${i}" title="${n}">${e}</a>`:`<a href="${i}">${e}</a>`)))).replace(/<(https?:\/\/[^>]+)>/g,((t,e)=>s(`<a href="${e}">${e}</a>`)))).replace(/<([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})>/g,((t,e)=>s(`<a href="mailto:${e}">${e}</a>`)))).replace(/(?<![="'\w/])(https?:\/\/[^\s<>\])"]+)/g,((t,e)=>s(`<a href="${e}">${e}</a>`)))).replace(/~~(.+?)~~/g,"<del>$1</del>")).replace(/\*{3}(.+?)\*{3}/g,"<strong><em>$1</em></strong>")).replace(/_{3}(.+?)_{3}/g,"<strong><em>$1</em></strong>")).replace(/\*{2}(.+?)\*{2}/g,"<strong>$1</strong>")).replace(/_{2}(.+?)_{2}/g,"<strong>$1</strong>")).replace(/\*(.+?)\*/g,"<em>$1</em>")).replace(/(?<![a-zA-Z0-9])_(.+?)_(?![a-zA-Z0-9])/g,"<em>$1</em>")).replace(/==(.+?)==/g,"<mark>$1</mark>")).replace(/\^([^\s^]+)\^/g,"<sup>$1</sup>")).replace(/(?<!~)~([^\s~]+)~(?!~)/g,"<sub>$1</sub>")).replace(/\uFFFC(\d+)\uFFFC/g,((t,s)=>e[parseInt(s,10)]))}function zt(t){if(t.length<2)return"";const e=t=>t.replace(/^\|/,"").replace(/\|$/,"").split("|").map((t=>t.trim())),s=e(t[0]),i=e(t[1]).map((t=>{const e=t.trim();return/^:-+:$/.test(e)?"center":/^-+:$/.test(e)?"right":/^:-+$/.test(e)?"left":""})),n=t.slice(2).map(e),o=s.length,l=s.every((t=>""===t));let r="<table>";const a=t=>{const e=i[t];return e?` style="text-align: ${e};"`:""};if(!l){r+="<thead><tr>";for(let t=0;t<o;t++)r+=`<th${a(t)}>${Rt(s[t])}</th>`;r+="</tr></thead>"}if(n.length>0||l){r+="<tbody>";for(const t of n){r+="<tr>";for(let e=0;e<o;e++)r+=`<td${a(e)}>${Rt(t[e]||"")}</td>`;r+="</tr>"}r+="</tbody>"}return r+="</table>",r}function Ft(t,e,s){const i=s?"ol":"ul",n=s?/^(\s*)\d+\.\s+(.*)/:/^(\s*)([-*+])\s+(.*)/;let o=`<${i}>`,l=e;const r=(t[l].match(/^(\s*)/)[1]||"").length;for(;l<t.length;){const e=t[l];if(Mt(e)){l++;continue}const i=(e.match(/^(\s*)/)[1]||"").length;if(i<r)break;if(i!==r)break;{if(!n.exec(e))break;const i=s?e.replace(/^\s*\d+\.\s+/,""):e.replace(/^\s*[-*+]\s+/,"");l++;let a=!1,h=!1,c=i;const d=/^\[([ xX])\]\s*(.*)/.exec(i);d&&(a=!0,h=" "!==d[1],c=d[2]);let u="";for(;l<t.length;){const e=t[l];if(Mt(e)){l++;continue}if((e.match(/^(\s*)/)[1]||"").length<=r)break;if(/^\s*[-*+]\s+/.test(e)||/^\s*\d+\.\s+/.test(e)){const s=Ft(t,l,/^\s*\d+\.\s+/.test(e));u+=s.html,l=s.index;continue}const s=e.trimStart();if(!(/^\|.*\|/.test(s)&&l+1<t.length&&/^\s*\|[\s:]*-{3,}/.test(t[l+1])))break;{const e=[];for(;l<t.length;){const s=t[l];if(Mt(s)||(s.match(/^(\s*)/)[1]||"").length<=r)break;if(!/^\s*\|/.test(s))break;e.push(s.trimStart()),l++}u+=zt(e)}}if(a){o+=`<li class="task-list-item">${h?'<input type="checkbox" checked disabled> ':'<input type="checkbox" disabled> '}${Rt(c)}${u}</li>`}else o+=`<li>${Rt(i)}${u}</li>`}}return o+=`</${i}>`,{html:o,index:l}}const Pt={jsonToMarkdown:function(t){return t?Ot(t,"",!0).replace(/\n{3,}/g,"\n\n").trim()+"\n":""},markdownToHtml:function t(e,s){if(!e)return"";s||(s="p");const i=e.split("\n"),n=[];let o=0;for(;o<i.length;){const e=i[o];if(Mt(e)){o++;continue}const r=/^(`{3,}|~{3,})(\w*)/.exec(e);if(r){const t=r[1].charAt(0),e=r[1].length,s=r[2],a=[];o++;const h=new RegExp("^"+("`"===t?"`":"~")+"{"+e+",}\\s*$");for(;o<i.length&&!h.test(i[o]);)a.push(i[o]),o++;o++;const c=s?` class="language-${s}"`:"";n.push(`<pre><code${c}>${l=a.join("\n"),l.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}</code></pre>`);continue}const a=/^(#{1,6})\s+(.+)/.exec(e);if(a){const t=a[1].length;n.push(`<h${t}>${Rt(a[2].trim())}</h${t}>`),o++;continue}if(/^(\*{3,}|-{3,}|_{3,})\s*$/.test(e)){n.push("<hr>"),o++;continue}if(/^>\s?/.test(e)){const e=[];for(;o<i.length&&/^>\s?/.test(i[o]);)e.push(i[o].replace(/^>\s?/,"")),o++;const l=t(e.join("\n"),s);n.push(`<blockquote>${l}</blockquote>`);continue}if(/^\|.*\|/.test(e)&&o+1<i.length&&/^\|[\s:]*-{3,}[\s:]*/.test(i[o+1])){const t=[];for(;o<i.length&&/^\|.*\|/.test(i[o]);)t.push(i[o]),o++;n.push(zt(t));continue}if(/^(\s*)([-*+])\s+/.test(e)){const t=Ft(i,o,!1);n.push(t.html),o=t.index;continue}if(/^(\s*)\d+\.\s+/.test(e)){const t=Ft(i,o,!0);n.push(t.html),o=t.index;continue}if(/^\s*<[a-zA-Z]/.test(e)){let t=e;if(o++,Et.test(e.match(/<(\w+)/)?.[1]||"")){n.push(t);continue}for(;o<i.length&&!Mt(i[o]);)t+="\n"+i[o],o++;n.push(t);continue}const h=[];for(;o<i.length&&!Mt(i[o])&&!/^(#{1,6}\s|`{3,}|~{3,}|>|\||(\s*)([-*+]|\d+\.)\s|(\*{3,}|-{3,}|_{3,})\s*$)/.test(i[o]);)h.push(i[o]),o++;if(h.length>0){const t=Rt(h.join("\n"));n.push(`<${s}>${t}</${s}>`)}else n.push(`<${s}>${Rt(i[o])}</${s}>`),o++}var l;return n.join("")}},Dt=$,qt=M,Wt=P,Ut=mt,Zt=vt,Gt={isShift:function(t){return t.shiftKey||16===t.keyCode},isCtrl:function(t){const e=t.code;return t.ctrlKey||t.metaKey||"MetaLeft"===e||"MetaRight"===e},isAlt:function(t){return t.altKey},isComposing:function(t){return t.isComposing||"Process"===t.key||229===t.keyCode},isBackspace:function(t){return"Backspace"===t},isTab:function(t){return"Tab"===t},isEnter:function(t){return"Enter"===t},isEsc:function(t){return"Escape"===t},isSpace:function(t){return"Space"===t},isDirectionKey:function(t){return wt.includes(t)},isRemoveKey:function(t){return Ct.includes(t)},isNonTextKey:function(t){return _t.includes(t)},isHistoryRelevantKey:function(t){return xt.includes(t)},isDocumentTypeObserverKey:function(t){return $t.includes(t)},isNonResponseKey:function(t){return kt.includes(t)}},jt=St,Kt=Pt,Yt={env:Dt,unicode:qt,converter:Wt,dom:Ut,numbers:Zt,keyCodeMap:Gt,clipboard:jt,markdown:Kt},Xt={redo:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18.4,10.6C16.55,9 14.15,8 11.5,8C6.85,8 2.92,11.03 1.54,15.22L3.9,16C4.95,12.81 7.95,10.5 11.5,10.5C13.45,10.5 15.23,11.22 16.62,12.38L13,16H22V7L18.4,10.6Z" /></svg>',undo:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12.5,8C9.85,8 7.45,9 5.6,10.6L2,7V16H11L7.38,12.38C8.77,11.22 10.54,10.5 12.5,10.5C16.04,10.5 19.05,12.81 20.1,16L22.47,15.22C21.08,11.03 17.15,8 12.5,8Z" /></svg>',bold:'<svg class="se-ci" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><path d="M304.793 243.891c33.639-18.537 53.657-54.16 53.657-95.693 0-48.236-26.25-87.626-68.626-104.179C265.138 34.01 240.849 32 209.661 32H24c-8.837 0-16 7.163-16 16v33.049c0 8.837 7.163 16 16 16h33.113v318.53H24c-8.837 0-16 7.163-16 16V464c0 8.837 7.163 16 16 16h195.69c24.203 0 44.834-1.289 66.866-7.584C337.52 457.193 376 410.647 376 350.014c0-52.168-26.573-91.684-71.207-106.123zM142.217 100.809h67.444c16.294 0 27.536 2.019 37.525 6.717 15.828 8.479 24.906 26.502 24.906 49.446 0 35.029-20.32 56.79-53.029 56.79h-76.846V100.809zm112.642 305.475c-10.14 4.056-22.677 4.907-31.409 4.907h-81.233V281.943h84.367c39.645 0 63.057 25.38 63.057 63.057.001 28.425-13.66 52.483-34.782 61.284z"/></svg>',underline:'<svg class="se-ci" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 9.78 15.74"><g><path d="M14.64,3.76h2.52v7.72a4.51,4.51,0,0,1-.59,2.31,3.76,3.76,0,0,1-1.71,1.53,6.12,6.12,0,0,1-2.64.53,5,5,0,0,1-3.57-1.18,4.17,4.17,0,0,1-1.27-3.24V3.76H9.9v7.3a3,3,0,0,0,.55,2,2.3,2.3,0,0,0,1.83.65,2.26,2.26,0,0,0,1.8-.65,3.09,3.09,0,0,0,.55-2V3.76Zm2.52,13.31V19.5H7.39V17.08h9.77Z" transform="translate(-7.38 -3.76)"/></g></svg>',italic:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M10,4V7H12.21L8.79,15H6V18H14V15H11.79L15.21,7H18V4H10Z" /></svg>',strike:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7.2 9.8C6 7.5 7.7 4.8 10.1 4.3C13.2 3.3 17.7 4.7 17.6 8.5H14.6C14.6 8.2 14.5 7.9 14.5 7.7C14.3 7.1 13.9 6.8 13.3 6.6C12.5 6.3 11.2 6.4 10.5 6.9C9 8.2 10.4 9.5 12 10H7.4C7.3 9.9 7.3 9.8 7.2 9.8M21 13V11H3V13H12.6C12.8 13.1 13 13.1 13.2 13.2C13.8 13.5 14.3 13.7 14.5 14.3C14.6 14.7 14.7 15.2 14.5 15.6C14.3 16.1 13.9 16.3 13.4 16.5C11.6 17 9.4 16.3 9.5 14.1H6.5C6.4 16.7 8.6 18.5 11 18.8C14.8 19.6 19.3 17.2 17.3 12.9L21 13Z" /></svg>',subscript:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M16,7.41L11.41,12L16,16.59L14.59,18L10,13.41L5.41,18L4,16.59L8.59,12L4,7.41L5.41,6L10,10.59L14.59,6L16,7.41M21.85,21.03H16.97V20.03L17.86,19.23C18.62,18.58 19.18,18.04 19.56,17.6C19.93,17.16 20.12,16.75 20.13,16.36C20.14,16.08 20.05,15.85 19.86,15.66C19.68,15.5 19.39,15.38 19,15.38C18.69,15.38 18.42,15.44 18.16,15.56L17.5,15.94L17.05,14.77C17.32,14.56 17.64,14.38 18.03,14.24C18.42,14.1 18.85,14 19.32,14C20.1,14.04 20.7,14.25 21.1,14.66C21.5,15.07 21.72,15.59 21.72,16.23C21.71,16.79 21.53,17.31 21.18,17.78C20.84,18.25 20.42,18.7 19.91,19.14L19.27,19.66V19.68H21.85V21.03Z" /></svg>',superscript:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M16,7.41L11.41,12L16,16.59L14.59,18L10,13.41L5.41,18L4,16.59L8.59,12L4,7.41L5.41,6L10,10.59L14.59,6L16,7.41M21.85,9H16.97V8L17.86,7.18C18.62,6.54 19.18,6 19.56,5.55C19.93,5.11 20.12,4.7 20.13,4.32C20.14,4.04 20.05,3.8 19.86,3.62C19.68,3.43 19.39,3.34 19,3.33C18.69,3.34 18.42,3.4 18.16,3.5L17.5,3.89L17.05,2.72C17.32,2.5 17.64,2.33 18.03,2.19C18.42,2.05 18.85,2 19.32,2C20.1,2 20.7,2.2 21.1,2.61C21.5,3 21.72,3.54 21.72,4.18C21.71,4.74 21.53,5.26 21.18,5.73C20.84,6.21 20.42,6.66 19.91,7.09L19.27,7.61V7.63H21.85V9Z" /></svg>',remove_color:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M22.11 21.46L2.39 1.73L1.11 3L7.65 9.54C6.74 11.03 6 12.65 6 14.23C6 17.54 8.69 20.23 12 20.23C13.74 20.23 15.3 19.5 16.4 18.29L20.84 22.73L22.11 21.46M12 18.23C9.78 18.23 8 16.45 8 14.23C8 13.5 8.5 12.27 9.14 11.03L15 16.88C14.26 17.71 13.2 18.23 12 18.23M11.14 7.94L9.71 6.5C10.57 5.38 11.25 4.61 11.25 4.61L12 3.77L12.75 4.61C12.75 4.61 14.03 6.06 15.32 7.94S18 12.07 18 14.23C18 14.41 18 14.59 17.97 14.77L15.46 12.26C15 11.23 14.37 10.07 13.68 9.07C12.84 7.85 12.44 7.42 12 6.9C11.73 7.21 11.5 7.5 11.14 7.94Z" /></svg>',remove_format:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M6,5V5.18L8.82,8H11.22L10.5,9.68L12.6,11.78L14.21,8H20V5H6M3.27,5L2,6.27L8.97,13.24L6.5,19H9.5L11.07,15.34L16.73,21L18,19.73L3.55,5.27L3.27,5Z" /></svg>',indent:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M11,13H21V11H11M11,9H21V7H11M3,3V5H21V3M11,17H21V15H11M3,8V16L7,12M3,21H21V19H3V21Z" /></svg>',outdent:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M11,13H21V11H11M11,9H21V7H11M3,3V5H21V3M3,21H21V19H3M3,12L7,16V8M11,17H21V15H11V17Z" /></svg>',expansion:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M10,21V19H6.41L10.91,14.5L9.5,13.09L5,17.59V14H3V21H10M14.5,10.91L19,6.41V10H21V3H14V5H17.59L13.09,9.5L14.5,10.91Z" /></svg>',reduction:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19.5,3.09L15,7.59V4H13V11H20V9H16.41L20.91,4.5L19.5,3.09M4,13V15H7.59L3.09,19.5L4.5,20.91L9,16.41V20H11V13H4Z" /></svg>',code_block:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M5.59 3.41L7 4.82L3.82 8L7 11.18L5.59 12.6L1 8L5.59 3.41M11.41 3.41L16 8L11.41 12.6L10 11.18L13.18 8L10 4.82L11.41 3.41M22 6V18C22 19.11 21.11 20 20 20H4C2.9 20 2 19.11 2 18V14H4V18H20V6H17.03V4H20C21.11 4 22 4.89 22 6Z" /></svg>',code_view:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12.89,3L14.85,3.4L11.11,21L9.15,20.6L12.89,3M19.59,12L16,8.41V5.58L22.42,12L16,18.41V15.58L19.59,12M1.58,12L8,5.58V8.41L4.41,12L8,15.58V18.41L1.58,12Z" /></svg>',markdown_view:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M2,16V8H4.73L7,11.19L9.27,8H12V16H10V10.6L7,14.05L4,10.6V16H2M16,8L20,12H17V16H15V12H12L16,8Z" /></svg>',preview:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12,9A3,3 0 0,1 15,12A3,3 0 0,1 12,15A3,3 0 0,1 9,12A3,3 0 0,1 12,9M12,4.5C17,4.5 21.27,7.61 23,12C21.27,16.39 17,19.5 12,19.5C7,19.5 2.73,16.39 1,12C2.73,7.61 7,4.5 12,4.5M3.18,12C4.83,15.36 8.24,17.5 12,17.5C15.76,17.5 19.17,15.36 20.82,12C19.17,8.64 15.76,6.5 12,6.5C8.24,6.5 4.83,8.64 3.18,12Z" /></svg>',print:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18,3H6V7H18M19,12A1,1 0 0,1 18,11A1,1 0 0,1 19,10A1,1 0 0,1 20,11A1,1 0 0,1 19,12M16,19H8V14H16M19,8H5A3,3 0 0,0 2,11V17H6V21H18V17H22V11A3,3 0 0,0 19,8Z" /></svg>',template:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13,7.5H18V9.5H13V7.5M13,14.5H18V16.5H13V14.5M19,3A2,2 0 0,1 21,5V19A2,2 0 0,1 19,21H5A2,2 0 0,1 3,19V5A2,2 0 0,1 5,3H19M19,19V5H5V19H19M11,6V11H6V6H11M10,10V7H7V10H10M11,13V18H6V13H11M10,17V14H7V17H10Z" /></svg>',layout:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M21 13H3A1 1 0 0 0 2 14V20A1 1 0 0 0 3 21H21A1 1 0 0 0 22 20V14A1 1 0 0 0 21 13M20 19H4V15H20M21 3H3A1 1 0 0 0 2 4V10A1 1 0 0 0 3 11H21A1 1 0 0 0 22 10V4A1 1 0 0 0 21 3M20 9H4V5H20Z" /></svg>',new_document:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M18,20H6V4H13V9H18V20Z" /></svg>',select_all:'<svg xmlns="http://www.w3.org/2000/svg" v