md-editor-rt
Version:
Markdown editor for react, developed in jsx and typescript, dark theme、beautify content by prettier、render articles directly、paste or clip the picture and upload it...
190 lines • 1.86 MB
JavaScript
(function(pe,X){typeof exports=="object"&&typeof module<"u"?X(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],X):(pe=typeof globalThis<"u"?globalThis:pe||self,X(pe.MdEditorRT={},pe.React,pe.ReactDOM))})(this,function(pe,X,bt){"use strict";var ise=Object.defineProperty;var X5=pe=>{throw TypeError(pe)};var rse=(pe,X,bt)=>X in pe?ise(pe,X,{enumerable:!0,configurable:!0,writable:!0,value:bt}):pe[X]=bt;var Ve=(pe,X,bt)=>rse(pe,typeof X!="symbol"?X+"":X,bt),gb=(pe,X,bt)=>X.has(pe)||X5("Cannot "+bt);var R=(pe,X,bt)=>(gb(pe,X,"read from private field"),bt?bt.call(pe):X.get(pe)),qe=(pe,X,bt)=>X.has(pe)?X5("Cannot add the same private member more than once"):X instanceof WeakSet?X.add(pe):X.set(pe,bt),he=(pe,X,bt,Ua)=>(gb(pe,X,"write to private field"),Ua?Ua.call(pe,bt):X.set(pe,bt),bt),se=(pe,X,bt)=>(gb(pe,X,"access private method"),bt);var fh=(pe,X,bt,Ua)=>({set _(ph){he(pe,X,ph,bt)},get _(){return R(pe,X,Ua)}});var o5,MO,a5,O5,Ai,Hn,Gi,Ta,Ii,FO,BO,Zt,Di,Rt,ot,ye,yn,Kn,dn,Lt,Li,Nt,Ni,Mi,Jn,Fi,zo,Sn,HO,ne,bb,Xa,Mr,Ou,ei,z5,_a,KO,lu,Zo,Vo,yb,dh,hh,at,Sb,pu,Co,xb;function Ua(e,t){for(var n=0;n<t.length;n++){const i=t[n];if(typeof i!="string"&&!Array.isArray(i)){for(const r in i)if(r!=="default"&&!(r in e)){const o=Object.getOwnPropertyDescriptor(i,r);o&&Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:()=>i[r]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}function ph(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Pb={exports:{}},mu={};/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var W5=X,Y5=Symbol.for("react.element"),E5=Symbol.for("react.fragment"),U5=Object.prototype.hasOwnProperty,Z5=W5.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,V5={key:!0,ref:!0,__self:!0,__source:!0};function kb(e,t,n){var i,r={},o=null,a=null;n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(a=t.ref);for(i in t)U5.call(t,i)&&!V5.hasOwnProperty(i)&&(r[i]=t[i]);if(e&&e.defaultProps)for(i in t=e.defaultProps,t)r[i]===void 0&&(r[i]=t[i]);return{$$typeof:Y5,type:e,key:o,ref:a,props:r,_owner:Z5.current}}mu.Fragment=E5,mu.jsx=kb,mu.jsxs=kb,Pb.exports=mu;var q=Pb.exports;class C5{constructor(){Ve(this,"pools",{})}remove(t,n,i){const o=this.pools[t]&&this.pools[t][n];o&&(this.pools[t][n]=o.filter(a=>a!==i))}clear(t){this.pools[t]={}}on(t,n){return this.pools[t]||(this.pools[t]={}),this.pools[t][n.name]||(this.pools[t][n.name]=[]),this.pools[t][n.name].push(n.callback),this.pools[t][n.name].includes(n.callback)}emit(t,n,...i){this.pools[t]||(this.pools[t]={});const o=this.pools[t][n];o&&o.forEach(a=>{try{a(...i)}catch(O){console.error(`${n} monitor event exception!`,O)}})}}const B=new C5,j5=(e,t=200)=>{let n=0;return(...i)=>new Promise(r=>{n&&(clearTimeout(n),r("cancel")),n=window.setTimeout(()=>{e.apply(void 0,i),n=0,r("done")},t)})},A5=(e,t={_blank:!0,nofollow:!0})=>{const n=document.createElement("a");n.href=e,t._blank&&(n.target="_blank"),t.nofollow&&(n.rel="noopener noreferrer"),n.click()},vb=()=>{let e=-1;return(t,n,i,r=100)=>{const o=()=>{i&&(typeof r=="number"?setTimeout(i,r):i())};e!==-1&&(cancelAnimationFrame(e),o());let a=t.scrollTop;const O=()=>{e=-1;const l=n-a;a=a+l/5,Math.abs(l)<1?(t.scrollTo(0,n),o()):(t.scrollTo(0,a),e=requestAnimationFrame(O))};e=requestAnimationFrame(O)}},G5=e=>{const t=n=>{const{scrollHeight:i,scrollWidth:r,offsetHeight:o,offsetWidth:a,scrollLeft:O,scrollTop:l}=e,s=n.x,u=n.y,c=d=>{const p=l+u-d.y,g=O+s-d.x,b=i-o,m=r-a,Q={};g>=0&&g<=m&&(Q.left=g),p>=0&&p<=b&&(Q.top=p),e.scroll(Q)};document.addEventListener("mousemove",c);const f=()=>{document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",f)};document.addEventListener("mouseup",f)};return e.addEventListener("mousedown",t),()=>{e.removeEventListener("mousedown",t)}},mh=()=>`${Date.now().toString(36)}${Math.random().toString(36).substring(2)}`,wb=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Tb=(e,t,n={})=>{const{excludeKeys:i}=n;for(const r in t)i&&i(r)?e[r]=t[r]:wb(t[r])&&wb(e[r])?e[r]=Tb(e[r],t[r],n):e[r]=t[r];return e},_="md-editor",tt="https://unpkg.com",I5=`${tt}/@highlightjs/cdn-assets@11.10.0/highlight.min.js`,Xb={main:`${tt}/prettier@3.3.3/standalone.js`,markdown:`${tt}/prettier@3.3.3/plugins/markdown.js`},D5={css:`${tt}/cropperjs@1.6.2/dist/cropper.min.css`,js:`${tt}/cropperjs@1.6.2/dist/cropper.min.js`},L5=`${tt}/screenfull@5.2.0/dist/screenfull.js`,N5=`${tt}/mermaid@11.3.0/dist/mermaid.min.js`,M5={js:`${tt}/katex@0.16.11/dist/katex.min.js`,css:`${tt}/katex@0.16.11/dist/katex.min.css`},gh={a11y:{light:`${tt}/@highlightjs/cdn-assets@11.10.0/styles/a11y-light.min.css`,dark:`${tt}/@highlightjs/cdn-assets@11.10.0/styles/a11y-dark.min.css`},atom:{light:`${tt}/@highlightjs/cdn-assets@11.10.0/styles/atom-one-light.min.css`,dark:`${tt}/@highlightjs/cdn-assets@11.10.0/styles/atom-one-dark.min.css`},github:{light:`${tt}/@highlightjs/cdn-assets@11.10.0/styles/github.min.css`,dark:`${tt}/@highlightjs/cdn-assets@11.10.0/styles/github-dark.min.css`},gradient:{light:`${tt}/@highlightjs/cdn-assets@11.10.0/styles/gradient-light.min.css`,dark:`${tt}/@highlightjs/cdn-assets@11.10.0/styles/gradient-dark.min.css`},kimbie:{light:`${tt}/@highlightjs/cdn-assets@11.10.0/styles/kimbie-light.min.css`,dark:`${tt}/@highlightjs/cdn-assets@11.10.0/styles/kimbie-dark.min.css`},paraiso:{light:`${tt}/@highlightjs/cdn-assets@11.10.0/styles/paraiso-light.min.css`,dark:`${tt}/@highlightjs/cdn-assets@11.10.0/styles/paraiso-dark.min.css`},qtcreator:{light:`${tt}/@highlightjs/cdn-assets@11.10.0/styles/qtcreator-light.min.css`,dark:`${tt}/@highlightjs/cdn-assets@11.10.0/styles/qtcreator-dark.min.css`},stackoverflow:{light:`${tt}/@highlightjs/cdn-assets@11.10.0/styles/stackoverflow-light.min.css`,dark:`${tt}/@highlightjs/cdn-assets@11.10.0/styles/stackoverflow-dark.min.css`}},F5={highlight:{js:{integrity:"sha384-GdEWAbCjn+ghjX0gLx7/N1hyTVmPAjdC2OvoAA0RyNcAOhqwtT8qnbCxWle2+uJX",crossOrigin:"anonymous"},css:{a11y:{light:{integrity:"sha384-qdZDAN3jffvh670RHw1wxLekabidEFaNRninYgIzBvMbL6WlHdXeHS/Bt+vx33lN",crossOrigin:"anonymous"},dark:{integrity:"sha384-2QAAjX8pqaM5azX68KWI2wExF6Q13kY4kEiQFY4b/1zPe6rpgmTByNpDEllH3sb+",crossOrigin:"anonymous"}},atom:{light:{integrity:"sha384-w6Ujm1VWa9HYFqGc89oAPn/DWDi2gUamjNrq9DRvEYm2X3ClItg9Y9xs1ViVo5b5",crossOrigin:"anonymous"},dark:{integrity:"sha384-oaMLBGEzBOJx3UHwac0cVndtX5fxGQIfnAeFZ35RTgqPcYlbprH9o9PUV/F8Le07",crossOrigin:"anonymous"}},github:{light:{integrity:"sha384-eFTL69TLRZTkNfYZOLM+G04821K1qZao/4QLJbet1pP4tcF+fdXq/9CdqAbWRl/L",crossOrigin:"anonymous"},dark:{integrity:"sha384-wH75j6z1lH97ZOpMOInqhgKzFkAInZPPSPlZpYKYTOqsaizPvhQZmAtLcPKXpLyH",crossOrigin:"anonymous"}},gradient:{light:{integrity:"sha384-yErHBR8aEZPxRl3XmR8dGSRAclMlnSRRw8sXQLcmPWzWUvb56BzQmBw3EWHl7QGI",crossOrigin:"anonymous"},dark:{integrity:"sha384-lUCvtSOdvDbp5hLWKgwz/taFu1HxlpqES2OVP5UG2JMTfnU481gXcBhGF9lAGoSr",crossOrigin:"anonymous"}},kimbie:{light:{integrity:"sha384-tloeSLUPczAvoZ48TUz+OxRie0oYLCRwlkadUXovGzzJEIbNQB2TkfUuvJ6SW5Mi",crossOrigin:"anonymous"},dark:{integrity:"sha384-o5F1vUaMNOmou1sQrsWiFo4/QUGSV0svqNZW+EesmKxWC8MpFJcveBhAyfvTHbGb",crossOrigin:"anonymous"}},paraiso:{light:{integrity:"sha384-5j6QHU2Hwg1ehtlIQNDebhETDB8bga3/88hzBFsMRaGmgQHCftqIN7GZNDNw0vTL",crossOrigin:"anonymous"},dark:{integrity:"sha384-I5vnnMQu0LWDQnHpT61xyoMwKarAB8jpZkB2ioFOlmzUFnIFaV4QbUwlBBOMKhTH",crossOrigin:"anonymous"}},qtcreator:{light:{integrity:"sha384-iEBgHrwi8Hv4dSZBz+MOGvS05rF7I7fGKM2fASQyE9jn2Istg9Qd5dSoK18WyRTB",crossOrigin:"anonymous"},dark:{integrity:"sha384-D6LXJGWNR4QV7gnpuP3ccbvOYoR02td3cU0y7lESABPg/tzCSC4m+y+M2TtrmpHc",crossOrigin:"anonymous"}},stackoverflow:{light:{integrity:"sha384-FMwt7cTGo4aLxZnno5k0xTj0W4gmi48Kwept+y/oQmE6cFk36Kr+QJZOKNOQwORe",crossOrigin:"anonymous"},dark:{integrity:"sha384-iL+x+BroCyHm/p2c6sMA9umXhdCWp2cKe4QUjPeMzHgwXAk+ZxHyIGP3NZTZensU",crossOrigin:"anonymous"}}}},prettier:{standaloneJs:{integrity:"sha384-92h6ALm8/lHpNGn6MfGlgZ+I8c/4yn/nSN8dV9ZmDxqbP9L93gk/Jj2i0LtV+AVd",crossOrigin:"anonymous"},parserMarkdownJs:{integrity:"sha384-5ufuUgoSsr/2oihBZ5d+c+yt0qaUmzLtUz41VZNJ4txtyJ6mBve3ZwuKoq/IygYX",crossOrigin:"anonymous"}},cropper:{js:{integrity:"sha384-jrOgQzBlDeUNdmQn3rUt/PZD+pdcRBdWd/HWRqRo+n2OR2QtGyjSaJC0GiCeH+ir",crossOrigin:"anonymous"},css:{integrity:"sha384-6LFfkTKLRlzFtgx8xsWyBdKGpcMMQTkv+dB7rAbugeJAu1Ym2q1Aji1cjHBG12Xh",crossOrigin:"anonymous"}},screenfull:{js:{integrity:"sha384-Qfbv8upMDu/ikv42M0Jnym2hahbDQ77Nm8PGU0G+iA6UIwt1+scE6P1qKXA0anWU",crossOrigin:"anonymous"}},mermaid:{js:{integrity:"sha384-B2tp/GqmE6VfDRB3JPTsesr0+SXypThjLSvQEQH7iv3f3/PYKCm5Q4+SGPcitStz",crossOrigin:"anonymous"}},katex:{js:{integrity:"sha384-7zkQWkzuo3B5mTepMUcHkMB5jZaolc2xDwL6VFqjFALcbeS9Ggm/Yr2r3Dy4lfFg",crossOrigin:"anonymous"},css:{integrity:"sha384-nB0miv6/jRmo5UMMR1wu3Gz6NLsoTkbqJghGIsx//Rlm+ZU03BU6SQNC66uf4l5+",crossOrigin:"anonymous"}}},Qh=["bold","underline","italic","strikeThrough","-","title","sub","sup","quote","unorderedList","orderedList","task","-","codeRow","code","link","image","table","mermaid","katex","-","revoke","next","save","=","prettier","pageFullscreen","fullscreen","preview","previewOnly","htmlPreview","catalog","github"],$h=["markdownTotal","=","scrollSwitch"],al={"zh-CN":{toolbarTips:{bold:"加粗",underline:"下划线",italic:"斜体",strikeThrough:"删除线",title:"标题",sub:"下标",sup:"上标",quote:"引用",unorderedList:"无序列表",orderedList:"有序列表",task:"任务列表",codeRow:"行内代码",code:"块级代码",link:"链接",image:"图片",table:"表格",mermaid:"mermaid图",katex:"katex公式",revoke:"后退",next:"前进",save:"保存",prettier:"美化",pageFullscreen:"浏览器全屏",fullscreen:"屏幕全屏",preview:"预览",previewOnly:"仅预览",htmlPreview:"html代码预览",catalog:"目录",github:"源码地址"},titleItem:{h1:"一级标题",h2:"二级标题",h3:"三级标题",h4:"四级标题",h5:"五级标题",h6:"六级标题"},imgTitleItem:{link:"添加链接",upload:"上传图片",clip2upload:"裁剪上传"},linkModalTips:{linkTitle:"添加链接",imageTitle:"添加图片",descLabel:"链接描述:",descLabelPlaceHolder:"请输入描述...",urlLabel:"链接地址:",urlLabelPlaceHolder:"请输入链接...",buttonOK:"确定"},clipModalTips:{title:"裁剪图片上传",buttonUpload:"上传"},copyCode:{text:"复制代码",successTips:"已复制!",failTips:"复制失败!"},mermaid:{flow:"流程图",sequence:"时序图",gantt:"甘特图",class:"类图",state:"状态图",pie:"饼图",relationship:"关系图",journey:"旅程图"},katex:{inline:"行内公式",block:"块级公式"},footer:{markdownTotal:"字数",scrollAuto:"同步滚动"}},"en-US":{toolbarTips:{bold:"bold",underline:"underline",italic:"italic",strikeThrough:"strikeThrough",title:"title",sub:"subscript",sup:"superscript",quote:"quote",unorderedList:"unordered list",orderedList:"ordered list",task:"task list",codeRow:"inline code",code:"block-level code",link:"link",image:"image",table:"table",mermaid:"mermaid",katex:"formula",revoke:"revoke",next:"undo revoke",save:"save",prettier:"prettier",pageFullscreen:"fullscreen in page",fullscreen:"fullscreen",preview:"preview",previewOnly:"preview only",htmlPreview:"html preview",catalog:"catalog",github:"source code"},titleItem:{h1:"Lv1 Heading",h2:"Lv2 Heading",h3:"Lv3 Heading",h4:"Lv4 Heading",h5:"Lv5 Heading",h6:"Lv6 Heading"},imgTitleItem:{link:"Add Image Link",upload:"Upload Images",clip2upload:"Crop And Upload"},linkModalTips:{linkTitle:"Add Link",imageTitle:"Add Image",descLabel:"Desc:",descLabelPlaceHolder:"Enter a description...",urlLabel:"Link:",urlLabelPlaceHolder:"Enter a link...",buttonOK:"OK"},clipModalTips:{title:"Crop Image",buttonUpload:"Upload"},copyCode:{text:"Copy",successTips:"Copied!",failTips:"Copy failed!"},mermaid:{flow:"flow",sequence:"sequence",gantt:"gantt",class:"class",state:"state",pie:"pie",relationship:"relationship",journey:"journey"},katex:{inline:"inline",block:"block"},footer:{markdownTotal:"Character Count",scrollAuto:"Scroll Auto"}}},ue={modelValue:"",theme:"light",className:"",onChange:()=>{},pageFullscreen:!1,preview:!0,htmlPreview:!1,language:"zh-CN",toolbars:Qh,toolbarsExclude:[],noPrettier:!1,onHtmlChanged:()=>{},onGetCatalog:()=>{},tabWidth:2,showCodeRowNumber:!0,previewTheme:"default",mdHeadingId:e=>e,tableShape:[6,4],noMermaid:!1,sanitize:e=>e,placeholder:"",noKatex:!1,defToolbars:[],onError:()=>{},codeTheme:"atom",footers:$h,defFooters:[],noUploadImg:!1,codeStyleReverse:!0,codeStyleReverseList:["default","mk-cute"],noHighlight:!1,noImgZoomIn:!1,inputBoxWidth:"50%",sanitizeMermaid:e=>Promise.resolve(e),transformImgUrl:e=>e,codeFoldable:!0,autoFoldThreshold:30,catalogLayout:"fixed"},Ot={editorExtensions:{highlight:{js:I5,css:gh},prettier:{standaloneJs:Xb.main,parserMarkdownJs:Xb.markdown},cropper:{...D5},screenfull:{js:L5},mermaid:{js:N5,enableZoom:!0},katex:{...M5}},editorExtensionsAttrs:{},editorConfig:{languageUserDefined:{},mermaidTemplate:{},renderDelay:500,zIndex:2e4},codeMirrorExtensions:(e,t)=>t,markdownItConfig:()=>{},markdownItPlugins:e=>e,mermaidConfig:e=>e,katexConfig:e=>e},B5=e=>Tb(Ot,e,{excludeKeys(t){return/[iI]{1}nstance/.test(t)}}),gu=.1,H5={copy:`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy ${_}-icon"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,"collapse-tips":`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-circle-chevron-left ${_}-icon"><circle cx="12" cy="12" r="10"/><path d="m14 16-4-4 4-4"/></svg>`,pin:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-pin"><path d="M12 17v5"/><path d="M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z"/></svg>',"pin-off":'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-pin-off"><path d="M12 17v5"/><path d="M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89"/><path d="m2 2 20 20"/><path d="M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11"/></svg>'},Ol=(e,t)=>typeof t[e]=="string"?t[e]:H5[e],K5=(e,t)=>{const n=i=>{const r=e.parentElement||document.body,o=r.offsetWidth,a=r.offsetHeight,{clientWidth:O,clientHeight:l}=document.documentElement,s=i.offsetX,u=i.offsetY,c=d=>{let p=d.x+document.body.scrollLeft-document.body.clientLeft-s,g=d.y+document.body.scrollTop-document.body.clientTop-u;p=p<1?1:p<O-o-1?p:O-o-1,g=g<1?1:g<l-a-1?g:l-a-1,t?t(p,g):(r.style.left=p+"px",r.style.top=g+"px")};document.addEventListener("mousemove",c);const f=()=>{document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",f)};document.addEventListener("mouseup",f)};return e.addEventListener("mousedown",n),()=>{e.removeEventListener("mousedown",n)}},Pi=(e,t,n="")=>{var r;const i=document.getElementById(t.id);if(i)n!==""&&(Reflect.get(window,n)?(r=t.onload)==null||r.call(i,new Event("load")):t.onload&&i.addEventListener("load",t.onload));else{const o={...t};o.onload=null;const a=eq(e,o);t.onload&&a.addEventListener("load",t.onload),document.head.appendChild(a)}},J5=(e,t)=>{const n=document.getElementById(t.id);n==null||n.remove(),Pi(e,t)},eq=(e,t)=>{const n=document.createElement(e);return Object.keys(t).forEach(i=>{t[i]!==void 0&&(n[i]=t[i])}),n},_b=(()=>{const e=n=>{if(!n)return()=>{};const i=n.firstChild;let r=1,o=0,a=0,O=!1,l,s,u,c=1;const f=()=>{i.style.transform=`translate(${o}px, ${a}px) scale(${r})`},d=$=>{$.touches.length===1?(O=!0,l=$.touches[0].clientX-o,s=$.touches[0].clientY-a):$.touches.length===2&&(u=Math.hypot($.touches[0].clientX-$.touches[1].clientX,$.touches[0].clientY-$.touches[1].clientY),c=r)},p=$=>{if($.preventDefault(),O&&$.touches.length===1)o=$.touches[0].clientX-l,a=$.touches[0].clientY-s,f();else if($.touches.length===2){const x=Math.hypot($.touches[0].clientX-$.touches[1].clientX,$.touches[0].clientY-$.touches[1].clientY)/u,v=r;r=c*(1+(x-1));const k=($.touches[0].clientX+$.touches[1].clientX)/2,C=($.touches[0].clientY+$.touches[1].clientY)/2,E=i.getBoundingClientRect(),V=(k-E.left)/v,Y=(C-E.top)/v;o-=V*(r-v),a-=Y*(r-v),f()}},g=()=>{O=!1},b=$=>{$.preventDefault();const w=.02,x=r;$.deltaY<0?r+=w:r=Math.max(.1,r-w);const v=i.getBoundingClientRect(),k=$.clientX-v.left,C=$.clientY-v.top;o-=k/x*(r-x),a-=C/x*(r-x),f()},m=$=>{O=!0,l=$.clientX-o,s=$.clientY-a},Q=$=>{O&&(o=$.clientX-l,a=$.clientY-s,f())},y=()=>{O=!1},P=()=>{O=!1};return n.addEventListener("touchstart",d,{passive:!1}),n.addEventListener("touchmove",p,{passive:!1}),n.addEventListener("touchend",g),n.addEventListener("wheel",b,{passive:!1}),n.addEventListener("mousedown",m),n.addEventListener("mousemove",Q),n.addEventListener("mouseup",y),n.addEventListener("mouseleave",P),()=>{n.removeEventListener("touchstart",d),n.removeEventListener("touchmove",p),n.removeEventListener("touchend",g),n.removeEventListener("wheel",b),n.removeEventListener("mousedown",m),n.removeEventListener("mousemove",Q),n.removeEventListener("mouseup",y),n.removeEventListener("mouseleave",P)}};return(n,i)=>{const r=new Map;return n==null||n.forEach(o=>{let a=o.querySelector(`.${_}-mermaid-action`);a||(o.insertAdjacentHTML("beforeend",`<div class="${_}-mermaid-action">${Ol("pin-off",i.customIcon)}</div>`),a=o.querySelector(`.${_}-mermaid-action`));const O=()=>{const l=r.get(o);if(l!=null&&l.removeEvent)l.removeEvent(),o.removeAttribute("data-grab"),r.set(o,{removeClick:l.removeClick}),a.innerHTML=Ol("pin-off",i.customIcon);else{const s=e(o);o.setAttribute("data-grab",""),r.set(o,{removeEvent:s,removeClick:l==null?void 0:l.removeClick}),a.innerHTML=Ol("pin",i.customIcon)}};a.addEventListener("click",O),r.set(o,{removeClick:()=>a.removeEventListener("click",O)})}),()=>{r.forEach(({removeEvent:o,removeClick:a})=>{o==null||o(),a==null||a()}),r.clear()}}})(),ll="onSave",Qu="changeCatalogVisible",bh="changeFullscreen",Rb="pageFullscreenChanged",zb="fullscreenChanged",qb="previewChanged",Wb="previewOnlyChanged",Yb="htmlPreviewChanged",Eb="catalogVisibleChanged",sl="buildFinished",xr="errorCatcher",Ne="replace",ul="uploadImage",yh="openModals",Sh="ctrlZ",xh="ctrlShiftZ",cl="catalogChanged",Ph="pushCatalog",$u="rerender",kh="eventListener",vh="taskStateChanged",wh="sendEditorView",bu="getEditorView",Wn={hljs:`${_}-hljs`,hlcss:`${_}-hlCss`,prettier:`${_}-prettier`,prettierMD:`${_}-prettierMD`,cropperjs:`${_}-cropper`,croppercss:`${_}-cropperCss`,screenfull:`${_}-screenfull`,mermaidM:`${_}-mermaid-m`,mermaid:`${_}-mermaid`,katexjs:`${_}-katex`,katexcss:`${_}-katexCss`},tq=(e,t)=>{const{value:n,modelValue:i,onSave:r}=e,{editorId:o}=t,[a,O]=X.useState({buildFinished:!1,html:""});X.useEffect(()=>{const l=s=>{O(()=>({buildFinished:!0,html:s}))};return B.on(o,{name:sl,callback:l}),()=>{B.remove(o,sl,l)}},[o]),X.useEffect(()=>{const l=()=>{if(r){const s=new Promise(u=>{if(a.buildFinished)u(a.html);else{const c=f=>{u(f),B.remove(o,sl,c)};B.on(o,{name:sl,callback:c})}});r(n||i||"",s)}};return B.on(o,{name:ll,callback:l}),()=>{B.remove(o,ll,l)}},[o,i,r,a.buildFinished,a.html,n]),X.useEffect(()=>{O(l=>({...l,buildFinished:!1}))},[n,i])},nq=e=>{const{noPrettier:t,noUploadImg:n}=e;X.useEffect(()=>{const{editorExtensions:i,editorExtensionsAttrs:r}=Ot,o=t||!!i.prettier.prettierInstance,a=t||!!i.prettier.parserMarkdownInstance;if(!(n||!!i.cropper.instance)){const{js:l={},css:s={}}=r.cropper||{};Pi("link",{...s,rel:"stylesheet",href:i.cropper.css,id:Wn.croppercss}),Pi("script",{...l,src:i.cropper.js,id:Wn.cropperjs})}if(!o){const{standaloneJs:l={}}=r.prettier||{};Pi("script",{...l,src:i.prettier.standaloneJs,id:Wn.prettier})}if(!a){const{parserMarkdownJs:l={}}=r.prettier||{};Pi("script",{...l,src:i.prettier.parserMarkdownJs,id:Wn.prettierMD})}},[t,n])},iq=(e,t)=>{X.useEffect(()=>(B.on(e,{name:xr,callback:t}),()=>{B.remove(e,xr,t)}),[e,t])},rq=(e,t)=>{const{editorId:n}=t,{onUploadImg:i}=e;X.useEffect(()=>{const r=(o,a)=>{const O=l=>{B.emit(n,Ne,"image",{desc:"",urls:l}),a==null||a()};i==null||i(o,O)};return B.on(n,{name:ul,callback:r}),()=>{B.remove(n,ul,r)}},[n,i])},oq=(e,t)=>{const{editorId:n}=t,[i,r]=X.useState(!1);return X.useEffect(()=>{const o=a=>{r(a===void 0?O=>!O:a)};return B.on(n,{name:Qu,callback:o}),()=>{B.remove(n,Qu,o)}},[n]),i};let Ub="";const Zb=e=>{const{theme:t=ue.theme,preview:n=ue.preview,htmlPreview:i=ue.htmlPreview,pageFullscreen:r=ue.pageFullscreen,previewTheme:o=ue.previewTheme,codeTheme:a=ue.codeTheme,language:O=ue.language,codeStyleReverse:l=ue.codeStyleReverse,codeStyleReverseList:s=ue.codeStyleReverseList}=e,u=X.useMemo(()=>{const b=Ot.editorExtensions.highlight,m=Ot.editorExtensionsAttrs.highlight,{js:Q}=b,y={...gh,...b.css},{js:P,css:$={}}=m||{},w=l&&s.includes(o)?"dark":t,x=y[a]?y[a][w]:gh.atom[w],v=y[a]&&$[a]?$[a][w]:$.atom?$.atom[w]:{};return{js:{src:Q,...P},css:{href:x,...v}}},[l,s,o,t,a]),c=X.useMemo(()=>{const b={...al,...Ot.editorConfig.languageUserDefined};return b[O]?b[O]:al["zh-CN"]},[O]),[f,d]=X.useState({pageFullscreen:r,fullscreen:!1,preview:n,htmlPreview:n?!1:i,previewOnly:!1}),p=X.useRef(f),g=X.useCallback((b,m)=>{d(Q=>{const y=m===void 0?!Q[b]:m,P={...Q};switch(b){case"preview":{P.htmlPreview=!1,P.previewOnly=!1;break}case"htmlPreview":{P.preview=!1,P.previewOnly=!1;break}case"previewOnly":{y?!P.preview&&!P.htmlPreview&&(P.preview=!0):(p.current.preview||(P.preview=!1),p.current.htmlPreview||(P.htmlPreview=!1));break}}return p.current[b]=y,P[b]=y,P})},[]);return X.useEffect(()=>{Ub=document.body.style.overflow},[]),X.useEffect(()=>{f.pageFullscreen||f.fullscreen?document.body.style.overflow="hidden":document.body.style.overflow=Ub},[f.pageFullscreen,f.fullscreen]),[u,c,f,g]},aq=(e,t,n,i,r,o)=>{const{editorId:a}=t;X.useEffect(()=>{B.emit(a,Rb,i.pageFullscreen)},[a,i.pageFullscreen]),X.useEffect(()=>{B.emit(a,zb,i.fullscreen)},[a,i.fullscreen]),X.useEffect(()=>{B.emit(a,qb,i.preview)},[a,i.preview]),X.useEffect(()=>{B.emit(a,Wb,i.previewOnly)},[a,i.previewOnly]),X.useEffect(()=>{B.emit(a,Yb,i.htmlPreview)},[a,i.htmlPreview]),X.useEffect(()=>{B.emit(a,Eb,n)},[n,a]),X.useImperativeHandle(e,()=>({on(l,s){switch(l){case"pageFullscreen":{B.on(a,{name:Rb,callback(u){s(u)}});break}case"fullscreen":{B.on(a,{name:zb,callback(u){s(u)}});break}case"preview":{B.on(a,{name:qb,callback(u){s(u)}});break}case"previewOnly":{B.on(a,{name:Wb,callback(u){s(u)}});break}case"htmlPreview":{B.on(a,{name:Yb,callback(u){s(u)}});break}case"catalog":{B.on(a,{name:Eb,callback(u){s(u)}});break}}},togglePageFullscreen(l){r("pageFullscreen",l)},toggleFullscreen(l){B.emit(a,bh,l)},togglePreview(l){r("preview",l)},togglePreviewOnly(l){r("previewOnly",l)},toggleHtmlPreview(l){r("htmlPreview",l)},toggleCatalog(l){B.emit(a,Qu,l)},triggerSave(){B.emit(a,ll)},insert(l){B.emit(a,Ne,"universal",{generate:l})},focus(l){var s;(s=o.current)==null||s.focus(l)},rerender(){B.emit(a,$u)},getSelectedText(){var l;return(l=o.current)==null?void 0:l.getSelectedText()},resetHistory(){var l;(l=o.current)==null||l.resetHistory()},domEventHandlers(l){B.emit(a,kh,l)},execCommand(l){B.emit(a,Ne,l)},getEditorView(){var l;return(l=o.current)==null?void 0:l.getEditorView()}}),[o,a,r])},Vb=e=>{const t=X.useId();return e.id||e.editorId||_+"-"+t.replaceAll(":","")},Oq=(e,t="image.png")=>{const n=e.split(","),i=n[0].match(/:(.*?);/);if(i){const r=i[1],o=atob(n[1]);let a=o.length;const O=new Uint8Array(a);for(;a--;)O[a]=o.charCodeAt(a);return new File([O],t,{type:r})}return null},lq=(e,t)=>{if(!e)return e;const n=t.split(`
`),i=['<span rn-wrapper aria-hidden="true">'];return n.forEach(()=>{i.push("<span></span>")}),i.push("</span>"),`<span class="${_}-code-block">${e}</span>${i.join("")}`},ve=e=>e.filter(t=>t!==!1&&t!==void 0).join(" "),sq=(e,t)=>{if(!e||!t)return 0;const n=e==null?void 0:e.getBoundingClientRect();if(t===document.documentElement)return n.top-t.clientTop;const i=t==null?void 0:t.getBoundingClientRect();return n.top-i.top},Cb=(()=>{let e=0;return()=>++e})(),nt=X.createContext({editorId:"",tabWidth:2,theme:"light",language:"zh-CN",highlight:{css:"",js:""},showCodeRowNumber:!1,usedLanguageText:al["zh-CN"],previewTheme:"default",customIcon:{},rootRef:null,disabled:void 0}),uq=()=>q.jsx("div",{className:`${_}-divider`}),jb=`${_}-dropdown-hidden`,Za=e=>{const{relative:t="html",onChange:n,disabled:i}=e,[r,o]=X.useState({overlayClass:jb,overlayStyle:{}}),a=X.useRef({triggerHover:!1,overlayHover:!1}),O=X.useRef(null),l=X.useRef(null),s=X.useCallback(()=>{var V,Y;if(i)return!1;a.current.triggerHover=!0;const m=O.current,Q=l.current;if(!m||!Q)return;const y=m.getBoundingClientRect(),P=m.offsetTop,$=m.offsetLeft,w=y.height,x=y.width,v=m.getRootNode(),k=((V=v.querySelector(t))==null?void 0:V.scrollLeft)||0,C=((Y=v.querySelector(t))==null?void 0:Y.clientWidth)||0;let E=$-Q.offsetWidth/2+x/2-k;E+Q.offsetWidth>k+C&&(E=k+C-Q.offsetWidth),E<0&&(E=0),o(T=>({...T,overlayStyle:{top:P+w+"px",left:E+"px"}})),n(!0)},[i,n,t]),u=X.useCallback(()=>{if(i)return!1;a.current.overlayHover=!0},[i]),c=X.useRef(-1),f=X.useCallback(m=>{var Q;if(i)return!1;(Q=O.current)!=null&&Q.contains(m.target)?a.current.triggerHover=!1:a.current.overlayHover=!1,clearTimeout(c.current),c.current=window.setTimeout(()=>{!a.current.overlayHover&&!a.current.triggerHover&&n(!1)},10)},[i,n]),d=e.children,p=e.overlay,g=X.cloneElement(d,{ref:O,key:"cloned-dropdown-trigger"});X.useEffect(()=>{e.visible?o(m=>({...m,overlayClass:""})):o(m=>({...m,overlayClass:jb}))},[e.visible]),X.useEffect(()=>{const m=O.current,Q=l.current;return m==null||m.addEventListener("mouseenter",s),m==null||m.addEventListener("mouseleave",f),Q==null||Q.addEventListener("mouseenter",u),Q==null||Q.addEventListener("mouseleave",f),()=>{m==null||m.removeEventListener("mouseenter",s),m==null||m.removeEventListener("mouseleave",f),Q==null||Q.removeEventListener("mouseenter",u),Q==null||Q.removeEventListener("mouseleave",f)}},[f,u,s]);const b=q.jsx("div",{className:`${_}-dropdown ${r.overlayClass}`,style:r.overlayStyle,ref:l,children:q.jsx("div",{className:`${_}-dropdown-overlay`,children:p instanceof Array?p[0]:p})});return q.jsxs(q.Fragment,{children:[g,b]})};/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const cq=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Ab=(...e)=>e.filter((t,n,i)=>!!t&&t.trim()!==""&&i.indexOf(t)===n).join(" ").trim();/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/var fq={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const dq=X.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:i,className:r="",children:o,iconNode:a,...O},l)=>X.createElement("svg",{ref:l,...fq,width:t,height:t,stroke:e,strokeWidth:i?Number(n)*24/Number(t):n,className:Ab("lucide",r),...O},[...a.map(([s,u])=>X.createElement(s,u)),...Array.isArray(o)?o:[o]]));/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ce=(e,t)=>{const n=X.forwardRef(({className:i,...r},o)=>X.createElement(dq,{ref:o,iconNode:t,className:Ab(`lucide-${cq(e)}`,i),...r}));return n.displayName=`${e}`,n};/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const hq=Ce("Bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const pq=Ce("ChartArea",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z",key:"q0gr47"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const mq=Ce("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const gq=Ce("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Qq=Ce("Expand",[["path",{d:"m21 21-6-6m6 6v-4.8m0 4.8h-4.8",key:"1c15vz"}],["path",{d:"M3 16.2V21m0 0h4.8M3 21l6-6",key:"1fsnz2"}],["path",{d:"M21 7.8V3m0 0h-4.8M21 3l-6 6",key:"hawz9i"}],["path",{d:"M3 7.8V3m0 0h4.8M3 3l6 6",key:"u9ee12"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const $q=Ce("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const bq=Ce("Forward",[["polyline",{points:"15 17 20 12 15 7",key:"1w3sku"}],["path",{d:"M4 18v-2a4 4 0 0 1 4-4h12",key:"jmiej9"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const yq=Ce("Heading",[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Sq=Ce("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const xq=Ce("Italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Pq=Ce("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const kq=Ce("ListOrdered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const vq=Ce("ListTodo",[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const wq=Ce("ListTree",[["path",{d:"M21 12h-8",key:"1bmf0i"}],["path",{d:"M21 6H8",key:"1pqkrb"}],["path",{d:"M21 18h-8",key:"1tm79t"}],["path",{d:"M3 6v4c0 1.1.9 2 2 2h3",key:"1ywdgy"}],["path",{d:"M3 10v6c0 1.1.9 2 2 2h3",key:"2wc746"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Tq=Ce("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Xq=Ce("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const _q=Ce("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Rq=Ce("Quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const zq=Ce("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const qq=Ce("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Wq=Ce("Shrink",[["path",{d:"m15 15 6 6m-6-6v4.8m0-4.8h4.8",key:"17vawe"}],["path",{d:"M9 19.8V15m0 0H4.2M9 15l-6 6",key:"chjx8e"}],["path",{d:"M15 4.2V9m0 0h4.8M15 9l6-6",key:"lav6yq"}],["path",{d:"M9 4.2V9m0 0H4.2M9 9 3 3",key:"1pxi2q"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Gb=Ce("SquareCode",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Yq=Ce("SquareSigma",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M16 8.9V7H8l4 5-4 5h8v-1.9",key:"9nih0i"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Eq=Ce("Strikethrough",[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Uq=Ce("Subscript",[["path",{d:"m4 5 8 8",key:"1eunvl"}],["path",{d:"m12 5-8 8",key:"1ah0jp"}],["path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07",key:"e8ta8j"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Zq=Ce("Superscript",[["path",{d:"m4 19 8-8",key:"hr47gm"}],["path",{d:"m12 19-8-8",key:"1dhhmo"}],["path",{d:"M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06",key:"1dfcux"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Vq=Ce("Table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Cq=Ce("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const jq=Ce("Underline",[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Aq=Ce("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Gq=Ce("View",[["path",{d:"M21 17v2a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-2",key:"mrq65r"}],["path",{d:"M21 7V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2",key:"be3xqs"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Iq=Ce("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Dq={bold:hq,underline:jq,italic:xq,"strike-through":Eq,title:yq,sub:Uq,sup:Zq,quote:Rq,"unordered-list":Tq,"ordered-list":kq,task:vq,"code-row":gq,code:Gb,link:Pq,image:Sq,table:Vq,revoke:zq,next:bq,save:qq,prettier:Gb,minimize:_q,maximize:Xq,"fullscreen-exit":Wq,fullscreen:Qq,"preview-only":Gq,preview:$q,"preview-html":mq,catalog:wq,github:e=>q.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`lucide lucide-github-icon ${e.className}`,children:[q.jsx("path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"}),q.jsx("path",{d:"M9 18c-4.51 2-5-2-7-2"})]}),mermaid:pq,formula:Yq,close:Iq,delete:Cq,upload:Aq},Lq=e=>X.createElement(Dq[e.name],{className:`${_}-icon`}),We=e=>{const{customIcon:t}=X.useContext(nt),n=t[e.name];if(typeof n=="object"){const i=n.component;return typeof i=="function"?q.jsx(i,{...n.props}):q.jsx("span",{dangerouslySetInnerHTML:{__html:n.component}})}return q.jsx(Lq,{name:e.name})},Nq=`${_}-modal-container`,yu=e=>{const{theme:t,rootRef:n}=X.useContext(nt),{onClose:i=()=>{},onAdjust:r=()=>{},style:o={},showMask:a=!0}=e,[O,l]=X.useState(e.visible),[s,u]=X.useState([`${_}-modal`]),c=X.useRef(null),f=X.useRef(null),d=X.useRef(),p=X.useRef(null),[g,b]=X.useState({maskStyle:{zIndex:-1},modalStyle:{zIndex:-1},initPos:{left:"0px",top:"0px"},historyPos:{left:"0px",top:"0px"}}),m=X.useMemo(()=>e.isFullscreen?{width:"100%",height:"100%"}:{width:e.width,height:e.height},[e.height,e.isFullscreen,e.width]);return X.useEffect(()=>{var y;const Q=(y=n.current)==null?void 0:y.getRootNode();return d.current=Q instanceof Document?document.body:Q,()=>{d.current=void 0}},[n]),X.useEffect(()=>{let Q=()=>{};return!e.isFullscreen&&e.visible&&(Q=K5(f.current,(y,P)=>{b($=>({...$,initPos:{left:y+"px",top:P+"px"}}))})),Q},[e.isFullscreen,e.visible]),X.useEffect(()=>{if(O){const Q=c.current.offsetWidth/2,y=c.current.offsetHeight/2,P=document.documentElement.clientWidth/2,$=document.documentElement.clientHeight/2;b(w=>({...w,maskStyle:{zIndex:Ot.editorConfig.zIndex+Cb()},modalStyle:{zIndex:Ot.editorConfig.zIndex+Cb()},initPos:{left:P-Q+"px",top:$-y+"px"}}))}},[O]),X.useEffect(()=>{const Q=e.visible;Q?(u(()=>[`${_}-modal`,"zoom-in"]),l(Q)):(u(()=>[`${_}-modal`,"zoom-out"]),setTimeout(()=>{l(Q)},150))},[e.visible]),q.jsx(q.Fragment,{children:d.current&&bt.createPortal(q.jsx("div",{ref:p,className:Nq,"data-theme":t,children:q.jsxs("div",{className:e.className,style:{...o,display:O?"block":"none"},children:[a&&q.jsx("div",{className:`${_}-modal-mask`,style:g.maskStyle,onClick:i}),q.jsxs("div",{className:s.join(" "),style:{...g.modalStyle,...g.initPos,...m},ref:c,children:[q.jsx("div",{className:`${_}-modal-header`,ref:f,children:e.title||""}),q.jsxs("div",{className:`${_}-modal-func`,children:[e.showAdjust&&q.jsx("div",{className:`${_}-modal-adjust`,onClick:Q=>{Q.stopPropagation(),e.isFullscreen?b(y=>({...y,initPos:y.historyPos})):b(y=>({...y,historyPos:y.initPos,initPos:{left:"0",top:"0"}})),r instanceof Function&&r(!e.isFullscreen)},children:q.jsx(We,{name:e.isFullscreen?"minimize":"maximize"})}),q.jsx("div",{className:`${_}-modal-close`,onClick:Q=>{Q.stopPropagation(),e.onClose&&e.onClose()},children:q.jsx(We,{name:"close"})})]}),q.jsx("div",{className:`${_}-modal-body`,children:e.children})]})]})}),d.current)})},Mq=e=>{var a,O,l,s,u;const{editorId:t,usedLanguageText:n}=X.useContext(nt),i=X.useMemo(()=>{var c,f;switch(e.type){case"link":return(c=n.linkModalTips)==null?void 0:c.linkTitle;case"image":return(f=n.linkModalTips)==null?void 0:f.imageTitle;default:return""}},[e.type,n]),[r,o]=X.useState({desc:"",url:""});return X.useEffect(()=>{e.visible||setTimeout(()=>{o({desc:"",url:""})},200)},[e.visible]),X.useMemo(()=>{var c,f,d,p,g;return q.jsxs(yu,{title:i,visible:e.visible,onClose:e.onCancel,children:[q.jsxs("div",{className:`${_}-form-item`,children:[q.jsx("label",{className:`${_}-label`,htmlFor:`link-desc-${t}`,children:(c=n.linkModalTips)==null?void 0:c.descLabel}),q.jsx("input",{placeholder:(f=n.linkModalTips)==null?void 0:f.descLabelPlaceHolder,className:`${_}-input`,id:`link-desc-${t}`,type:"text",value:r.desc,onChange:b=>{o(m=>({...m,desc:b.target.value}))}})]}),q.jsxs("div",{className:`${_}-form-item`,children:[q.jsx("label",{className:`${_}-label`,htmlFor:`link-url-${t}`,children:(d=n.linkModalTips)==null?void 0:d.urlLabel}),q.jsx("input",{placeholder:(p=n.linkModalTips)==null?void 0:p.urlLabelPlaceHolder,className:`${_}-input`,id:`link-url-${t}`,type:"text",value:r.url,onChange:b=>{o(m=>({...m,url:b.target.value}))}})]}),q.jsx("div",{className:`${_}-form-item`,children:q.jsx("button",{className:`${_}-btn ${_}-btn-row`,type:"button",onClick:()=>{e.onOk(r),o(b=>({...b,desc:"",url:""}))},children:(g=n.linkModalTips)==null?void 0:g.buttonOK})})]})},[i,e,t,(a=n.linkModalTips)==null?void 0:a.descLabel,(O=n.linkModalTips)==null?void 0:O.descLabelPlaceHolder,(l=n.linkModalTips)==null?void 0:l.urlLabel,(s=n.linkModalTips)==null?void 0:s.urlLabelPlaceHolder,(u=n.linkModalTips)==null?void 0:u.buttonOK,r])};let Pr=null;const Fq=e=>{var p,g,b;const t=X.useContext(nt),{editorId:n,usedLanguageText:i,rootRef:r}=t,o=Ot.editorExtensions.cropper.instance,a=X.useRef(null),O=X.useRef(null),l=X.useRef(null),[s,u]=X.useState({cropperInited:!1,imgSelected:!1,imgSrc:"",isFullscreen:!1});X.useEffect(()=>{e.visible&&!s.cropperInited&&(window.Cropper=o||window.Cropper,a.current.onchange=()=>{if(!window.Cropper){B.emit(n,xr,{name:"Cropper",message:"Cropper is undefined"});return}const m=a.current.files||[];if((m==null?void 0:m.length)>0){const Q=new FileReader;Q.onload=y=>{u(P=>({...P,imgSelected:!0,imgSrc:y.target.result}))},Q.readAsDataURL(m[0])}})},[e.visible,s.cropperInited,o,n]),X.useEffect(()=>{var m;(m=l.current)==null||m.setAttribute("style","")},[s.imgSelected]),X.useEffect(()=>{var m,Q;Pr==null||Pr.destroy(),(m=l.current)==null||m.setAttribute("style",""),O.current&&s.imgSrc&&(Pr=new window.Cropper(O.current,{viewMode:2,preview:((Q=r.current)==null?void 0:Q.getRootNode()).querySelector(`.${_}-clip-preview-target`)}))},[s.imgSrc,s.isFullscreen,r]);const c=X.useMemo(()=>s.isFullscreen?{width:"100%",height:"100%"}:{width:"668px",height:"392px"},[s.isFullscreen]),f=()=>{Pr.clear(),Pr.destroy(),Pr=null,a.current.value="",u(m=>({...m,imgSrc:"",imgSelected:!1}))},d=X.useCallback(m=>{u(Q=>({...Q,isFullscreen:m}))},[]);return X.useMemo(()=>{var m,Q,y;return q.jsxs(yu,{className:`${_}-modal-clip`,title:(m=i.clipModalTips)==null?void 0:m.title,visible:e.visible,onClose:e.onCancel,showAdjust:!0,isFullscreen:s.isFullscreen,onAdjust:d,...c,children:[q.jsxs("div",{className:`${_}-form-item ${_}-clip`,children:[q.jsx("div",{className:`${_}-clip-main`,children:s.imgSelected?q.jsxs("div",{className:`${_}-clip-cropper`,children:[q.jsx("img",{src:s.imgSrc,ref:O,style:{display:"none"},alt:""}),q.jsx("div",{className:`${_}-clip-delete`,onClick:f,children:q.jsx(We,{name:"delete"})})]}):q.jsx("div",{className:`${_}-clip-upload`,onClick:()=>{a.current.click()},role:"button",tabIndex:0,"aria-label":(Q=i.imgTitleItem)==null?void 0:Q.upload,children:q.jsx(We,{name:"upload"})})}),q.jsx("div",{className:`${_}-clip-preview`,children:q.jsx("div",{className:`${_}-clip-preview-target`,ref:l})})]}),q.jsx("div",{className:`${_}-form-item`,children:q.jsx("button",{className:`${_}-btn`,type:"button",onClick:()=>{if(Pr){const P=Pr.getCroppedCanvas();B.emit(n,ul,[Oq(P.toDataURL("image/png"))],e.onOk),f()}},children:(y=i.linkModalTips)==null?void 0:y.buttonOK})}),q.jsx("input",{ref:a,accept:"image/*",type:"file",multiple:!1,style:{display:"none"},"aria-hidden":"true"})]})},[(p=i.clipModalTips)==null?void 0:p.title,(g=i.linkModalTips)==null?void 0:g.buttonOK,(b=i.imgTitleItem)==null?void 0:b.upload,e.visible,e.onCancel,e.onOk,s.isFullscreen,s.imgSelected,s.imgSrc,d,c,n])},Bq=e=>q.jsxs(q.Fragment,{children:[q.jsx(Mq,{type:e.type,visible:e.linkVisible,onOk:e.onOk,onCancel:e.onCancel}),q.jsx(Fq,{visible:e.clipVisible,onOk:e.onOk,onCancel:e.onCancel})]}),Hq=e=>{const[t,n]=X.useState({x:-1,y:-1}),i=X.useMemo(()=>JSON.stringify(e.tableShape),[e.tableShape]),r=X.useCallback(()=>{const O=[...JSON.parse(i)];return(!O[2]||O[2]<O[0])&&(O[2]=O[0]),(!O[3]||O[3]<O[3])&&(O[3]=O[1]),O},[i]),[o,a]=X.useState(r);return X.useEffect(()=>{a(r),n({x:-1,y:-1})},[r]),q.jsx("div",{className:`${_}-table-shape`,onMouseLeave:()=>{a(r),n({x:-1,y:-1})},children:new Array(o[1]).fill("").map((O,l)=>q.jsx("div",{className:`${_}-table-shape-row`,children:new Array(o[0]).fill("").map((s,u)=>q.jsx("div",{className:`${_}-table-shape-col`,onMouseEnter:()=>{n({x:l,y:u}),u+1===o[0]&&u+1<o[2]?a(c=>{const f=[...c];return f[0]=c[0]+1,f}):u+2<o[0]&&o[0]>e.tableShape[0]&&a(c=>{const f=[...c];return f[0]=c[0]-1,f}),l+1===o[1]&&l+1<o[3]?a(c=>{const f=[...c];return f[1]=c[1]+1,f}):l+2<o[1]&&o[1]>e.tableShape[1]&&a(c=>{const f=[...c];return f[1]=c[1]-1,f})},onClick:()=>{e.onSelected(t)},children:q.jsx("div",{className:[`${_}-table-shape-col-default`,l<=t.x&&u<=t.y&&`${_}-table-shape-col-include`].filter(c=>!!c).join(" ")})},`table-shape-col-${u}`))},`table-shape-row-${l}`))})},Kq=e=>{const{updateSetting:t}=e,{editorId:n}=X.useContext(nt),i=X.useRef(Ot.editorExtensions.screenfull.instance),r=X.useRef(!1),o=X.useCallback(a=>{if(!i.current){B.emit(n,xr,{name:"fullscreen",message:"fullscreen is undefined"});return}i.current.isEnabled?(r.current=!r.curre