adtec-hnyzfc-core-package 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ import{inject as R,computed as Ee,getCurrentInstance as Oe,watch as De,onMounted as Be,onBeforeUnmount as Fe,resolveComponent as Q,openBlock as z,createElementBlock as ee,Fragment as te,createVNode as _e,unref as h,normalizeStyle as ze,normalizeClass as We,withDirectives as ne,createBlock as re,vShow as oe,createCommentVNode as K,withCtx as Ve,renderSlot as Ue,normalizeProps as je,guardReactiveProps as qe,nextTick as se}from"vue";import{u as Le}from"./state-X-ofkjhe.js";import{VueNodeViewRenderer as x,VueRenderer as Ke,posToDOMRect as Xe,Editor as Ge,EditorContent as Je}from"@tiptap/vue-3";import{t as $,l as Ye}from"./i18n-hQyxfD7_.js";import Ze from"@tiptap/extension-bold";import{Details as Qe,DetailsContent as et,DetailsSummary as tt}from"@tiptap/extension-details";import nt from"@tiptap/extension-document";import rt from"@tiptap/extension-link";import{BulletList as ot,ListItem as st,OrderedList as Te,TaskList as at,TaskItem as it}from"@tiptap/extension-list";import lt from"@tiptap/extension-node-range";import ut from"@tiptap/extension-subscript";import ct from"@tiptap/extension-superscript";import{TableOfContents as dt,getHierarchicalIndexes as ft}from"@tiptap/extension-table-of-contents";import{TextStyleKit as mt}from"@tiptap/extension-text-style";import ke from"@tiptap/extension-typography";import pt from"@tiptap/extension-unique-id";import{Selection as gt,UndoRedo as ht,Focus as yt,TrailingNode as bt,Placeholder as Mt,CharacterCount as Lt,Dropcursor as Tt}from"@tiptap/extensions";import kt from"@tiptap/starter-kit";import{b as ae}from"./file-BwWjS162.js";import{s as P}from"./short-id-DJZHbKNv.js";import{Node as L,mergeAttributes as y,Mark as Ae,wrappingInputRule as At,Extension as C,nodeInputRule as xe,nodePasteRule as xt}from"@tiptap/core";import Ct from"./node-view-DsQdaAj1.js";import{TextSelection as O,PluginKey as S,Plugin as H,NodeSelection as E,AllSelection as wt}from"@tiptap/pm/state";import St,{HardBreakNode as Ht,ParagraphNode as vt,InvisibleNode as Nt}from"@tiptap/extension-invisible-characters";import It from"./node-view-j1q0uEdL.js";import{chainCommands as Rt,newlineInCode as Pt,createParagraphNear as $t,splitBlock as Et}from"@tiptap/pm/commands";import{keymap as Ot}from"@tiptap/pm/keymap";import{canSplit as Dt,liftTarget as Bt,ReplaceStep as Ft}from"@tiptap/pm/transform";import{Decoration as Ce,DecorationSet as F}from"@tiptap/pm/view";import _t from"./node-view-CqFhGDvz.js";import zt from"./node-view-CBjV65ug.js";import{F as Wt}from"./index-DB4X4foC.js";import{Fragment as B,Slice as Vt,DOMParser as Ut}from"@tiptap/pm/model";import jt from"@tiptap/extension-horizontal-rule";import qt from"./node-view-kqpt80Cn.js";import Kt from"@tiptap/extension-image";import we from"./node-view-DhXzoQcA.js";import Xt from"@tiptap/extension-mention";import{computePosition as Gt,shift as Jt,flip as Yt}from"@floating-ui/dom";import Zt from"./mentions-D1AaJTuX.js";import{u as Qt}from"./dialog-BnThXCWu.js";import en from"./node-view-C-z3oj0k.js";import{g as tn}from"./selection-BIZq2qs_.js";import{Table as nn}from"@tiptap/extension-table";import{TableCell as rn}from"@tiptap/extension-table/cell";import{TableHeader as on}from"@tiptap/extension-table/header";import{TableRow as sn}from"@tiptap/extension-table/row";import an from"./node-view-CsG70jor.js";import ln from"@tiptap/extension-text-align";import un from"./node-view-D8s_W1o0.js";import cn from"./node-view-Cw1LtcLJ.js";import{T as dn,c as fn,a as mn}from"./history-record-BccG7Xr0.js";import pn from"./node-view-BtvLsCIq.js";import{l as ie}from"./load-resource-DgkZV52W.js";import"@vueuse/core";import"@tool-belt/type-predicates";import"vue-i18n";import"./player-CIYSGQvp.js";import"tdesign-vue-next";import"pretty-bytes";import"es-drager";import"./cal-service-CTPNhNPR.js";import"./image-resizer-DI5dQsWL.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";const gn=L.create({name:"audio",group:"block",atom:!0,addAttributes(){return{vnode:{default:!0},file:{default:null},id:{default:null},name:{default:null},size:{default:null},src:{default:null},uploaded:{default:!1},previewType:{default:"audio"}}},parseHTML(){return[{tag:"audio"}]},renderHTML({HTMLAttributes:e}){return["audio",y(e)]},addNodeView(){return x(Ct)},addCommands(){return{setAudio:e=>({commands:t,editor:n})=>t.insertContentAt(n.state.selection.anchor,{type:this.name,attrs:e})}}}),hn=Ae.create({name:"bookmark",priority:1e3,keepOnSplit:!1,exitable:!0,addOptions(){return{bookmarkName:"",class:"umo-editor-bookmark"}},addAttributes(){return{bookmarkName:{default:"bookmarkName"},class:{default:this.options.class}}},parseHTML(){return[{tag:"bookmark"}]},renderHTML({HTMLAttributes:e}){return["bookmark",y(this.options,e),0]},addCommands(){return{setBookmark:e=>({chain:t,editor:n})=>{try{t().setMark(this.name,e).run();const{empty:r}=n.state.selection;return r&&e.bookmarkName&&t().focus().insertContent(e.bookmarkName).run(),!0}catch{return!1}},focusBookmark:e=>({editor:t,tr:n})=>{if(e){const r=t.view.dom.querySelector(`bookmark[bookmarkName="${e}"]`);if(r){r.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"});const o=t.view.posAtDOM(r,0);n&&(n.setSelection(new O(n.doc.resolve(o))),t.view.dispatch(n),t.view.focus())}return!0}else return!1},getAllBookmarks:e=>({editor:t})=>{const n=[];try{const r=t.getHTML(),a=new DOMParser().parseFromString(r,"text/html").body.querySelectorAll(this.name),i=[];Array.from(a).forEach(l=>{if(l!==null){const u=l.getAttribute("bookmarkName");u&&!i.includes(u)&&(i.push(u),n.push({bookmarkRowId:P(),bookmarkRowName:u}))}})}catch{}return e(n),!0}}}});class yn extends Nt{constructor(){super({type:"paragraph",predicate:t=>["heading"].includes(t.type.name)})}}const bn=St.configure({injectCSS:!1,builders:[new Ht,new vt,new yn]}),Mn=ot.extend({content:"listItem*",addAttributes(){return{...this.parent?.(),listType:{default:"disc",parseHTML:e=>e.style.getPropertyValue("list-style-type")||"disc",renderHTML:({listType:e})=>({style:`list-style-type: ${e}`,"data-type":e})}}}}),Ln=L.create({name:"callout",group:"block",content:"paragraph+",defining:!0,exitable:!0,selectable:!1,addAttributes(){return{type:{default:"primary"},icon:{default:"⭐️"},backgroundColor:{default:"rgb(217, 231, 255)"}}},parseHTML(){return[{tag:'div[data-type="callout"]'}]},renderHTML({HTMLAttributes:e}){return["div",y(e,{"data-type":"callout"}),0]},addNodeView(){return x(It)},addCommands(){return{insertCallout:e=>({chain:t,editor:n,tr:r,dispatch:o})=>{const{selection:s,schema:a}=n.state;if(!s.empty){let u=s.content().content;if(!this.type.validContent(u)){const f=n.state.doc.textBetween(s.from,s.to,`
2
+ `);u=a.nodes.paragraph.create(null,f?a.text(f):null).content}const c=this.type.create(e,u);return r.replaceSelectionWith(c,!1).scrollIntoView(),o&&o(r),!0}return t().insertContent({type:this.name,attrs:e,content:[{type:"paragraph",content:[]}]}).run()}}},addInputRules(){return[At({find:/^:::callout $/,type:this.type,getAttributes:e=>({type:e[1]})})]},addKeyboardShortcuts(){return{Enter:({editor:e})=>{const{state:t,view:n}=e,{dispatch:r}=n,{selection:o}=t,{$from:s}=o,a=s.node(-1);if(a?.type.name==="callout"&&a.content.size<=2){const i=o.from+1,l=t.tr.insert(i,t.schema.nodes.paragraph.create());return l.setSelection(t.selection.constructor.near(l.doc.resolve(i))),r(l),!0}return!1}}}}),Tn=e=>{for(let{depth:t}=e;t>0;t--){const n=e.node(t);if(n.type.name==="column")return{node:n,depth:t}}return null},kn=(e,t)=>{const{$cursor:n}=e.selection;if(!n||n.parent.content.size||n.node(n.depth-1).type.name==="column")return!1;if(n.depth>1&&n.after()!==n.end(-1)){const s=n.before();if(Dt(e.doc,s))return t&&t(e.tr.split(s).scrollIntoView()),!0}const r=n.blockRange(),o=r&&Bt(r);return o===null?!1:(t&&t(e.tr.lift(r,o).scrollIntoView()),!0)},An=Ot({Enter:Rt(Pt,$t,kn,Et),"Mod-a":(e,t,n)=>{const{selection:r}=e,{$from:o}=r,s=Tn(o);if(s){const{depth:a}=s,i=o.start(a),l=o.end(a),u=e.tr.setSelection(O.create(e.doc,i,l));return t&&t(u),!0}return!1}}),A=new S("gridResizingPlugin");class W{constructor(t,n){this.activeHandle=t,this.dragging=n}apply(t){const n=t.getMeta(A);return n?typeof n.setHandle=="number"?new W(n.setHandle,!1):n.setDragging!==void 0?new W(this.activeHandle,n.setDragging):(this.activeHandle>-1&&t.docChanged,this):this}}const xn=(e,t,n)=>{const r=t.composedPath().find(s=>s.classList?.contains("umo-node-column-container"));if(!r)return-1;const o=Array.from(r.children).filter(s=>s.classList.contains("umo-node-column"));for(let s=0;s<o.length;s++){const a=o[s],i=a.getBoundingClientRect();if(t.clientX>=i.right-n-2&&t.clientX<=i.right+10+n){const l=e.posAtDOM(a,0);if(l!==null)return l}}return-1},le=(e,t,n)=>{const r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)},X=(e,t,n,r)=>{e.dispatch(e.state.tr.setNodeMarkup(t,void 0,{...n,colWidth:r-24}))},Cn=(e,t)=>{const n=e.state.doc.resolve(t),r=n.parent;if(!r||r.type.name!=="column")return null;const o=e.domAtPos(n.pos);if(!o.node)return null;const s=o.node instanceof HTMLElement?o.node:o.node.childNodes[o.offset],a=s.offsetWidth;return{$pos:n,node:r,columnEl:s,domWidth:a}},Se=(e,t)=>{e.dispatch(e.state.tr.setMeta(A,{setHandle:t}))},wn=(e,t,n)=>{const r=A.getState(e.state);if(!r||r.dragging)return!1;const o=xn(e,t,n);return o!==r.activeHandle&&Se(e,o),!1},Sn=e=>{const t=A.getState(e.state);return t&&t.activeHandle>-1&&!t.dragging&&Se(e,-1),!1},Hn=(e,t,n)=>{const r=A.getState(e.state);if(!r||r.activeHandle===-1||r.dragging)return!1;const o=Cn(e,r.activeHandle);if(!o)return!1;const{domWidth:s,$pos:a,node:i}=o,l={...i.attrs||{}},u=a.before();e.dispatch(e.state.tr.setMeta(A,{setDragging:{startX:t.clientX,startWidth:s}}));const c=e.dom.ownerDocument.defaultView||window,f=d=>{c.removeEventListener("mouseup",f),c.removeEventListener("mousemove",m);const p=A.getState(e.state);if(!p?.dragging)return;const g=le(p.dragging,d,n);X(e,u,l,g),e.dispatch(e.state.tr.setMeta(A,{setDragging:null}))},m=d=>{if(!d.buttons){f(d);return}const p=A.getState(e.state);if(!p?.dragging)return;const g=le(p.dragging,d,n);X(e,u,l,g)};return c.addEventListener("mouseup",f),c.addEventListener("mousemove",m),X(e,u,l,s),t.preventDefault(),!0},vn=(e,t)=>{const n=[];if(e.doc.resolve(t).nodeAfter!==null){const o=document.createElement("div");o.className="grid-resize-handle";const s=document.createElement("div");s.className="grid-resize-handle-circle-btn",o.appendChild(s);const a=document.createElement("div");a.className="grid-resize-handle-icon",s.appendChild(a),n.push(Ce.widget(t,o))}return F.create(e.doc,n)},Nn=(e,t)=>{const n=t.target;if(!n||n.className!=="grid-resize-handle-circle-btn"&&n.className!=="grid-resize-handle-icon")return!1;const r=n.closest(".umo-node-column");if(!r)return!1;const o=e.posAtDOM(r,0);if(!o)return!1;const s=e.state.doc.resolve(o),{state:a}=e;return e.dispatch(a.tr.insert(s.pos+s.parent.nodeSize-1,a.schema.nodes.column.create({colWidth:100},a.schema.nodes.paragraph.create()))),!0},In=e=>{const t=e?.handleWidth,n=e?.columnMinWidth;return new H({key:A,state:{init:()=>new W(-1,!1),apply:(r,o)=>o.apply(r)},props:{attributes:r=>{const o=A.getState(r);return o&&o.activeHandle>-1?{class:"umo-node-column-resize-cursor"}:{}},handleDOMEvents:{mousemove:(r,o)=>wn(r,o,t),mouseleave:r=>Sn(r),mousedown:(r,o)=>Hn(r,o,n),mouseup:(r,o)=>Nn(r,o)},decorations:r=>{const o=A.getState(r);return!o||o.activeHandle===-1?null:vn(r,o.activeHandle)}}})},Rn=L.create({name:"column",group:"block",content:"block+",addAttributes(){return{colWidth:{default:200,parseHTML:e=>{const t=e.style.width.replace("px","");return Number(t)||200},renderHTML:e=>({style:e.colWidth?`width: ${e.colWidth}px;`:""})}}},parseHTML(){return[{tag:"div.umo-node-column"}]},renderHTML({HTMLAttributes:e}){return["div",y(e,{class:"umo-node-column"}),0]}}),Pn=L.create({name:"columnContainer",group:"block",content:"column+",parseHTML(){return[{tag:"div.umo-node-column-container"}]},renderHTML({HTMLAttributes:e}){return["div",y(e,{class:"umo-node-column-container"}),0]}}),$n=C.create({name:"columns",addExtensions(){return[Rn,Pn]},addCommands(){},addProseMirrorPlugins(){return[In({handleWidth:2,columnMinWidth:50}),An]}}),En=L.create({name:"datetime",group:"inline",inline:!0,atom:!0,selectable:!1,addAttributes(){return{type:{default:"datetime"},date:{default:null},text:{default:`[${$("insert.date")}]`},format:{default:null},withTime:{default:!1},capitalize:{default:!1}}},parseHTML(){return[{tag:'span[data-type="datetime"]'}]},renderHTML({HTMLAttributes:e}){return["span",y(e,{"data-type":"datetime"}),e.text]},addNodeView(){return x(_t)},addCommands(){return{insertDatetime:e=>({chain:t})=>t().insertContent({type:this.name,attrs:e}).run()}}}),On=L.create({name:"echarts",inline:!1,group:"block",atom:!0,addAttributes(){return{vnode:{default:!0},id:{default:null},name:{default:null},width:{default:null},height:{default:300},mode:{default:1},chartOptions:{default:null,parseHTML:e=>{const t=e.hasAttribute("chart-options")?e.getAttribute("chart-options"):null;return t?JSON.parse(t):null},renderHTML:e=>({"chart-options":e.chartOptions?JSON.stringify(e.chartOptions):null})},chartConfig:{default:null,parseHTML:e=>{const t=e.hasAttribute("chart-config")?e.getAttribute("chart-config"):null;return t?JSON.parse(t):null},renderHTML:e=>({"chart-config":e.chartConfig?JSON.stringify(e.chartConfig):null})},src:"",describe:{default:null}}},parseHTML(){return[{tag:"echarts"}]},renderHTML({HTMLAttributes:e}){return["echarts",y(e)]},addNodeView(){return x(zt)},addCommands(){return{setEcharts:e=>({commands:t,editor:n})=>t.insertContentAt(n.state.selection.anchor,{type:this.name,attrs:e}),updateEcharts:e=>({commands:t,editor:n,tr:r})=>{n.commands.selectParentNode();const{selection:o}=n.state;r.setSelection(o);const{doc:s}=r,{from:a,to:i}=o;return s.nodesBetween(a,i,(l,u)=>l.type.name===this.name?(t.updateAttributes(this.name,e),!1):!0),!0}}}});function ue(e){e=e.toUpperCase();let t=0;const n={I:1,V:5,X:10,L:50,C:100,D:500,M:1e3};let r=e.length,o=0;for(;r--;)n[e.charAt(r)]>=o?t+=n[e.charAt(r)]:t-=n[e.charAt(r)],o=n[e.charAt(r)];return t}function ce(e){const t=o=>o.toLowerCase().charCodeAt(0)-97+1;let n=0,r=e.length;for(;r--;){const o=Math.pow(26,e.length-r-1);n+=t(e.charAt(r))*o}return n}function Y(e){const t=e.parentNode;for(;e.firstChild;)t?.insertBefore(e.firstChild,e);t?.removeChild(e)}function Z(e){const t=e?.attributes.style?.value||"";return Object.fromEntries(t.split(";").map(n=>n.split(":").map(r=>r.trim())))}function He(e){if(!e)return!1;const t=e.toLowerCase(),n=t.includes("microsoft-com")&&t.includes("office")||t.includes("urn:schemas-microsoft-com:office")||t.includes("class=mso")||t.includes('class="mso')||t.includes("mso-")||t.includes("w:worddocument"),r=t.includes("wps office")||t.includes("kingsoft")||t.includes("xmlns:wps")||t.includes('name="generator" content="wps');return n||r}function Dn(e,t){const n=e.some(o=>o.type?.startsWith("image/")),r=/<(img\b|v:imagedata\b)/i.test(t||"");return n||r}function Bn(e,t="[图片]"){if(!e)return e;let n=e;return n=n.replace(/<v:shape\b[^>]*>[\s\S]*?<v:imagedata[\s\S]*?<\/v:shape>/gi,t),n=n.replace(/<v:imagedata\b[^>]*\/?>/gi,t),n=n.replace(/<img\b[^>]*>/gi,t),n}function ve(e){if(!e)return!1;const t=e.getData("text/html")||"";if(He(t))return!0;const n=Array.from(e.types||[]);return n.includes("text/rtf")||n.includes("application/rtf")}const Fn=e=>{const{key:t,editor:n,onPaste:r,onDrop:o,allowedMimeTypes:s}=e;return new H({key:t||new S("file-handler"),props:{handleDrop(a,i){const{dataTransfer:l}=i;if(!o||!l?.files.length)return!1;const u=a.posAtCoords({left:i.clientX,top:i.clientY});let c=Array.from(l.files);return s.length>0&&(c=c.filter(f=>s.includes(f.type)?!0:s.includes(`${f.type.split("/")[0]}/*`))),c.length!==0?(o(n,c,u===null?void 0:u.pos),i.preventDefault(),i.stopPropagation(),!0):!1},handlePaste(a,i){const{clipboardData:l}=i;if(i.skipFileHandler||ve(l)||!r||!l?.files.length)return!1;let u=Array.from(l.files);const c=l.getData("text/html");return s.length>0&&(u=u.filter(f=>s.includes(f.type)?!0:s.includes(`${f.type.split("/")[0]}/*`))),u.length!==0?(r(n,u,c),i.preventDefault(),i.stopPropagation(),!0):!1}}})},_n=C.create({name:"fileHandler",addOptions:()=>({onPaste:void 0,onDrop:void 0,allowedMimeTypes:[]}),addProseMirrorPlugins(){return[Fn({key:new S(this.name),editor:this.editor,allowedMimeTypes:this.options.allowedMimeTypes,onDrop:this.options.onDrop,onPaste:this.options.onPaste})]}}),zn=st.extend({name:"footnote",content(){return this.options.content},isolating:!0,defining:!0,draggable:!1,addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList",...this.parent?.(),content:"paragraph+"}},addAttributes(){return{id:{isRequired:!0},"data-fn-id":{isRequired:!0}}},parseHTML(){return[{tag:"li",getAttrs(e){return e.getAttribute("data-fn-id")?{"data-fn-id":e.getAttribute("data-fn-id")}:!1},priority:1e3}]},renderHTML({HTMLAttributes:e}){return["li",y(this.options.HTMLAttributes,e),0]},addCommands(){return{focusFootnote:e=>({editor:t,chain:n})=>{const r=t.$node("footnote",{"data-fn-id":e});return r?(n().focus().setTextSelection(r.from+r.content.size).run(),r.element.scrollIntoView(),!0):!1}}},addKeyboardShortcuts(){return{"Mod-a":({editor:e})=>{try{const{selection:t}=e.state,{$from:n}=t;for(let{depth:r}=n;r>=0;r--)if(n.node(r).type.name==="footnote"){const s=n.start(r),a=n.end(r);return e.commands.setTextSelection({from:s+1,to:a-1}),!0}return!1}catch{return!1}},Tab:({editor:e})=>{try{const{selection:t}=e.state,n=e.$pos(t.anchor);if(!n.after)return!1;if(n.after.node.type.name==="footnotes"){const r=n.after.node.child(0);return e.chain().setTextSelection(n.after.from+r.content.size).scrollIntoView().run(),!0}else{const r=t.$from.start(2);if(Number.isNaN(r))return!1;const o=e.$pos(r);return o.node.type.name!=="footnote"||!o.after?!1:(e.chain().setTextSelection(o.after.to-1).scrollIntoView().run(),!0)}}catch{return!1}},"Shift-Tab":({editor:e})=>{const{selection:t}=e.state,n=t.$from.start(2);if(Number.isNaN(n))return!1;const r=e.$pos(n);return r.node.type.name!=="footnote"||!r.before?!1:(e.chain().setTextSelection(r.before.to-1).scrollIntoView().run(),!0)}}}}),Wn=e=>{let t=1;const n=[];return e.doc.descendants((r,o)=>{if(r.type.name==="footnoteReference"){const s=`${t}`;r.attrs.referenceNumber!==s&&e.setNodeAttribute(o,"referenceNumber",s),n.push(r),t+=1}}),n},V=e=>String(e||"").replace(/\s+/g," ").trim(),Vn=e=>{const t=[];return e.content.descendants(n=>{if(n.type.name!=="paragraph")return;const r=V(n.textContent);r&&t.push(r)}),V(t.join(" "))},de=e=>{const t={};e.doc.descendants(r=>{if(r.type.name!=="footnote")return;const o=r.attrs?.["data-fn-id"];if(!o)return;const s=Vn(r);s&&(t[o]=s)});let n=!1;return e.doc.descendants((r,o)=>{if(r.type.name!=="footnoteReference")return;const s=r.attrs?.["data-fn-id"];if(!s)return;const a=t[s];a&&V(r.attrs?.caption)!==a&&(e.setNodeAttribute(o,"caption",a),n=!0)}),n},Un=e=>{let t;const n=[];return e.doc.descendants((r,o)=>{if(r.type.name==="footnote")n.push(r);else if(r.type.name==="footnotes")t={from:o,to:o+r.nodeSize};else return!1}),{footnotesRange:t,footnotes:n}},jn=e=>{if(!e||e.childCount!==1)return!1;const t=e.firstChild;return!t||t.type.name!=="paragraph"?!1:t.content.size===0},qn=(e,t)=>{const n=Wn(e),r=t.schema.nodes.footnote,o=t.schema.nodes.footnotes,s=t.schema.nodes.paragraph,a=t.schema.nodeFromJSON({type:"paragraph",content:[]}),{footnotesRange:i,footnotes:l}=Un(e),u=l.reduce((d,p)=>(d[p.attrs["data-fn-id"]]=p,d),{}),c=[],f=new Set(n.map(d=>d.attrs["data-fn-id"])),m=new Set;for(const d of l){const p=d.attrs["data-fn-id"];(!f.has(p)||m.has(p))&&(m.add(p),d.content.descendants(g=>{g.type.name==="footnoteReference"&&m.add(g.attrs["data-fn-id"])}))}for(let d=0;d<n.length;d++){const p=n[d],g=p.attrs["data-fn-id"];if(m.has(g))continue;const v=V(p.attrs?.caption);if(g in u){const N=u[g],T=v&&jn(N)?B.from([s.create(void 0,t.schema.text(v))]):N.content;c.push(r.create({...N.attrs,id:`fn:${d+1}`},T))}else{const N=v?[s.create(void 0,t.schema.text(v))]:[a],T=r.create({"data-fn-id":g,id:`fn:${d+1}`},N);c.push(T)}}c.length===0?i&&e.delete(i.from,i.to):i?e.replaceWith(i.from+1,i.to-1,B.from(c)):e.insert(e.doc.content.size,o.create(void 0,B.from(c)))},Kn=C.create({name:"footnoteRules",priority:1e3,addCommands(){return{syncFootnoteCaptions:()=>({state:e,dispatch:t})=>{const{tr:n}=e;return de(n)?(n.setMeta("addToHistory",!1),n.setMeta("footnoteAutoSync",!0),t?.(n),!0):!1}}},addProseMirrorPlugins(){return[new H({key:new S("footnoteRules"),filterTransaction(e){const{from:t,to:n}=e.selection;if(t===0&&n===e.doc.content.size)return!0;let r=!1,o=!1,s=0;return e.doc.nodesBetween(t,n,(i,l,u)=>{u?.type.name==="doc"&&i.type.name!=="footnotes"?o=!0:i.type.name==="footnote"?s+=1:i.type.name==="footnotes"&&(r=!0)}),!(o&&r)&&s<=1},appendTransaction(e,t,n){if(e.some(i=>i.getMeta("footnoteAutoSync"))||!e.some(i=>i.docChanged))return null;const r=n.tr;let o=!1;for(const i of e)if(i.docChanged)for(const l of i.steps){if(!(l instanceof Ft))continue;const u=l.from!==l.to;l.slice.size>0&&l.slice.content.descendants(f=>{if(f?.type.name==="footnoteReference")return o=!0,!1}),u&&!o&&i.before.nodesBetween(l.from,Math.min(i.before.content.size,l.to),f=>{if(f.type.name==="footnoteReference")return o=!0,!1})}let s=!1;return o&&(qn(r,n),s=!0),de(r)&&(s=!0),s?(r.setMeta("footnoteAutoSync",!0),r):null}})]}}),Xn=Te.extend({name:"footnotes",group:"",isolating:!0,defining:!0,draggable:!1,content(){return"footnote*"},addAttributes(){return{class:{default:"umo-node-footnotes"}}},parseHTML(){return[{tag:"ol.umo-node-footnotes",priority:1e3}]},addKeyboardShortcuts(){return{}},addCommands(){return{}},addInputRules(){return[]},addExtensions(){return[Kn]}}),fe="data-ref-num",G="umo-node-footnote-ref",Gn=e=>String(e||"").replace(/\s+/g," ").trim(),Jn=L.create({name:"footnoteReference",inline:!0,content:"text*",group:"inline",atom:!0,draggable:!0,parseHTML(){return[{tag:"sup",priority:1e3,getAttrs(e){const t=e.querySelector(`a.${G}:first-child`);if(!t)return!1;const n=t.getAttribute("data-fn-id"),r=t.getAttribute(fe);return{"data-fn-id":n||P(10),referenceNumber:r||t.innerText}},contentElement(e){return e.firstChild}}]},addAttributes(){return{class:{default:G},"data-fn-id":{renderHTML(e){return{"data-fn-id":e["data-fn-id"]||P(10)}}},referenceNumber:{},caption:{default:""},href:{renderHTML(e){return{href:`#fn:${e.referenceNumber}`}}}}},renderHTML({HTMLAttributes:e}){const{referenceNumber:t,...n}=e,r=y(this.options.HTMLAttributes,n);return r[fe]=t,["sup",{id:`fnref:${t}`},["a",r,`[${e.referenceNumber}]`]]},addProseMirrorPlugins(){const{editor:e}=this,t=n=>{if(n.type.name===this.name){const r={...n.attrs,"data-fn-id":P(10)};return n.type.create(r,n.content,n.marks)}if(n.content&&n.content.size>0){const r=[];let o=!1;if(n.content.forEach(s=>{const a=t(s);a!==s&&(o=!0),r.push(a)}),o)return n.copy(B.from(r))}return n};return[new H({key:new S("footnotePasteHandler"),props:{transformPasted(n){const r=[];let o=!1;return n.content.forEach(s=>{const a=t(s);a!==s&&(o=!0),r.push(a)}),o?new Vt(B.from(r),n.openStart,n.openEnd):n}}}),new H({key:new S("footnoteRefClick"),props:{handleDoubleClickOn(n,r,o,s,a){if(o.type.name!=="footnoteReference")return!1;a.preventDefault();const i=o.attrs["data-fn-id"];return e.commands.focusFootnote(i)},handleClickOn(n,r,o,s,a){if(o.type.name!=="footnoteReference")return!1;a.preventDefault();const{selection:i}=e.state.tr;if(i instanceof E&&i.node.eq(o)){const l=o.attrs["data-fn-id"];return e.commands.focusFootnote(l)}else return e.chain().setNodeSelection(s).run(),!0}}}),new H({key:new S("footnoteRefHoverTitle"),props:{handleDOMEvents:{mouseover(n,r){const o=r?.target;if(!(o instanceof Element))return!1;const s=o.closest(`a.${G}`);if(!s)return!1;const a=s.getAttribute("data-fn-id");if(!a)return!1;const i=e.$node("footnote",{"data-fn-id":a}),l=Gn(i?.node?.textContent);return l&&s.setAttribute("caption",l),!1}}}})]},addCommands(){return{addFootnote:()=>({state:e,tr:t})=>{const n=this.type.create({"data-fn-id":P(10)});return t.insert(e.selection.anchor,n),!0}}},addInputRules(){return[{find:/\[\^(.*?)\]/,type:this.type,undoable:!0,handler({range:e,match:t,chain:n}){const r=e.from,o=e.to;t[1]&&n().deleteRange({from:r,to:o}).addFootnote().run()}}]}}),Yn=C.create({name:"painter",addCommands(){return{setFormatPainter:e=>({editor:t,view:n})=>{const{tr:r}=n.state,o=t.state.selection.$head.marks();return n.painter={enabled:!0,once:e,marks:o},n.dispatch(r.setMeta("painterAction",{type:"start",marks:o})),!0},unsetFormatPainter:()=>({view:e})=>{const{tr:t}=e.state;return e.painter={enabled:!1,once:!0,marks:[]},e.dispatch(t.setMeta("painterAction",{type:"end"})),!0}}},addProseMirrorPlugins(){return[new H({key:new S("format-painter"),state:{init:()=>[],apply(e,t){const n=e.getMeta("painterAction");return n?.type==="start"?n.marks:n?.type==="end"?[]:t}},props:{handleDOMEvents:{mousedown(e){const t=this.getState(e.state),{painter:n}=e;if(!t||t.length===0)return!1;const r=()=>{if(document.removeEventListener("mouseup",r),!n.enabled)return;const{dispatch:o}=e;let{tr:s,selection:a}=e.state;s=s.removeMark(a.from,a.to);for(const i of t)i.type.name!=="link"&&(s=s.addMark(a.from,a.to,i));n.once?(n.enabled=!1,n.marks=[],o(s.setMeta("painterAction",{type:"end"}))):o(s.setMeta("painterAction",{type:"start",marks:n.marks}))};return document.addEventListener("mouseup",r),!0}}}})]}}),Zn=jt.extend({addOptions(){return{HTMLAttributes:{class:"umo-page-divider","data-line-number":!1}}},parseHTML(){return[{tag:"hr"}]},addAttributes(){return{"data-type":{parseHTML:e=>e.getAttribute("data-type")||"single"},color:{parseHTML:e=>e.getAttribute("data-color"),renderHTML:e=>({"data-color":e.color,style:`color: ${e.color||"inherit"}`})}}},addCommands(){return{setHorizontalRule:({type:e,color:t})=>({chain:n,state:r})=>{const{$to:o}=r.selection,s=n();return o.parentOffset===0?s.insertContentAt(Math.max(o.pos-2,0),{type:this.name,attrs:{"data-type":e,color:t}}):s.insertContent({type:this.name,attrs:{"data-type":e,color:t}}),s.command(({tr:a,dispatch:i})=>{if(i){const{$to:l}=a.selection,u=l.end();if(l.nodeAfter)l.nodeAfter.isTextblock?a.setSelection(O.create(a.doc,l.pos+1)):l.nodeAfter.isBlock?a.setSelection(E.create(a.doc,l.pos)):a.setSelection(O.create(a.doc,l.pos));else{const c=l.parent.type.contentMatch.defaultType?.create();c&&(a.insert(u,c),a.setSelection(O.create(a.doc,u+1)))}a.scrollIntoView()}return!0}).run()}}},addInputRules(){return[xe({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Qn=L.create({name:"iframe",inline:!1,group:"block",atom:!0,addAttributes(){return{vnode:{default:!0},type:{default:0},src:{default:null},width:{default:null},height:{default:200},clickable:{default:!1}}},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:e}){return["iframe",y(e)]},addNodeView(){return x(qt)},addCommands(){return{setIframe:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}}}),me=(e,t)=>{const n=e.style?.[t],r=e.getAttribute(t),o=n||r;if(!o)return null;const s=String(o).trim();return/^\d+(\.\d+)?px$/i.test(s)||/^\d+(\.\d+)?$/.test(s)?Number.parseFloat(s):null},Ne=Kt.extend({atom:!0,selectable:!0,addAttributes(){return{vnode:{default:!0},type:{default:"image"},name:{default:null},size:{default:null},id:{default:null},src:{default:null},config:{default:null},content:{default:null},width:{default:null,parseHTML:e=>me(e,"width"),renderHTML:e=>e.width?{width:e.width}:{}},height:{default:null,parseHTML:e=>me(e,"height"),renderHTML:e=>e.height?{height:e.height}:{}},left:{default:0},top:{default:0},angle:{default:null},draggable:{default:!1},rotatable:{default:!1},equalProportion:{default:!0},flipX:{default:!1},flipY:{default:!1},uploaded:{default:!1},error:{default:!1},previewType:{default:"image"},inline:{default:!1}}},parseHTML(){return[{tag:"img"}]},addPasteRules(){return[...this.parent?.()||[],xt({find:/!\[([^\]]*)\]\(([^)\s]+)(?:\s+"([^"]+)"?)?\)/g,type:this.type,getAttributes:e=>{const[,t,n,r]=e;return{src:n,alt:t,title:r}}})]},addInputRules(){return[...this.parent?.()||[],xe({find:/!\[([\S]+)\]\(([^)\s]+)(?:\s+"([\S]+)"?)?\)/g,type:this.type,getAttributes:e=>{const[,t,n,r]=e;return{src:n,alt:t,title:r}}})]}}),Ie=Ne.extend({addNodeView(){return x(we)},addCommands(){return{setImage:(e,t)=>({commands:n,editor:r})=>t?n.insertContent({type:this.name,attrs:{...e,inline:!1}}):n.insertContentAt(r.state.selection.anchor,{type:this.name,attrs:{...e,inline:!1}})}}}),er=Ne.extend({name:"inlineImage",inline:!0,group:"inline",addAttributes(){return{...this.parent?.(),inline:{default:!0},equalProportion:{default:!1},width:{default:150},height:{default:80}}},parseHTML(){return[{tag:"inline-img"}]},renderHTML({HTMLAttributes:e}){return["inline-img",y(e)]},addNodeView(){return x(we)},addCommands(){return{setInlineImage:e=>({commands:t,editor:n})=>t.insertContentAt(n.state.selection.anchor,{type:this.name,attrs:{...e,inline:!0}})}}}),U="em",pe=(e,t=U)=>{if(typeof e=="number")return Number.isFinite(e)?{value:e,unit:t}:null;if(typeof e!="string")return null;const n=e.trim().match(/^(-?[\d.]+)\s*([a-z%]*)$/i);if(!n)return null;const r=Number.parseFloat(n[1]);return Number.isFinite(r)?{value:r,unit:n[2]||t}:null},tr=(e,t=U)=>{if(typeof e!="string")return null;const n=e.trim().match(/^(-?[\d.]+)\s*([a-z%]*)$/i);if(!n)return null;const r=Number.parseFloat(n[1]);return Number.isFinite(r)?{value:r,unit:n[2]||t}:null},nr=C.create({name:"indent",addOptions(){return{types:["heading","listItem","taskItem","paragraph"],minLevel:0,maxLevel:20,indentSize:2,defaultUnit:U}},addGlobalAttributes(){const e=()=>pe(this.options.indentSize,this.options.defaultUnit),t=n=>{const r=e();return r?tr(n.style.textIndent,r.unit):null};return[{types:this.options.types,attributes:{indent:{default:null,renderHTML:n=>{const{indent:r,indentUnit:o}=n,{minLevel:s}=this.options;if(!r||r<=s)return{};const a=e();return a?{style:`text-indent: ${r*a.value}${o||a.unit};`}:{}},parseHTML:n=>{const r=t(n),o=e();if(!r||!o?.value)return null;const s=Math.round(r.value/o.value);return s>this.options.minLevel?s:null}},indentUnit:{default:null,renderHTML:()=>({}),parseHTML:n=>{const r=t(n),o=e();return!r||!o?.value?null:Math.round(r.value/o.value)>this.options.minLevel?r.unit:null}}}}]},addCommands(){const e=()=>pe(this.options.indentSize,this.options.defaultUnit),t=s=>{const a=e();return a?!s||s===a.unit:!0},n=(s,a,i)=>{const l=s.doc.nodeAt(a);if(!l)return s;const u=(l.attrs.indent||0)+i,{minLevel:c,maxLevel:f}=this.options;let m=u;if(u<c&&(m=c),u>f&&t(l.attrs.indentUnit)&&(m=f),m!==l.attrs.indent){const d={...l.attrs};delete d.indent,delete d.indentUnit;const p=e(),g=m>c?{...d,indent:m,indentUnit:l.attrs.indentUnit||p?.unit||U}:d;return s.setNodeMarkup(a,l.type,g,l.marks)}return s},r=(s,a)=>{const{doc:i,selection:l}=s;if(l instanceof O||l instanceof wt){const{from:u,to:c}=l;i.nodesBetween(u,c,(f,m)=>this.options.types.includes(f.type.name)?(s=n(s,m,a),!1):!0)}return s},o=s=>()=>({tr:a,state:i,dispatch:l})=>(a.setSelection(i.selection),a=r(a,s),a.docChanged?(l&&l(a),!0):!1);return{setIndent:o(1),setOutdent:o(-1)}},addKeyboardShortcuts(){return{Tab:()=>this.editor.isActive("bulletList")||this.editor.isActive("orderedList")?this.editor.commands.sinkListItem("listItem"):this.editor.isActive("taskList")?this.editor.commands.sinkListItem("taskItem"):this.editor.commands.setIndent(),"Shift-Tab":()=>this.editor.isActive("bulletList")||this.editor.isActive("orderedList")?this.editor.commands.liftListItem("listItem"):this.editor.isActive("taskList")?this.editor.commands.liftListItem("taskItem"):this.editor.commands.setOutdent()}}}),rr=Ae.create({name:"letterSpacing",addOptions(){return{types:["textStyle"]}},addAttributes(){return{spacing:{default:null,parseHTML:e=>e.style.letterSpacing?.replace(/['"]+/g,""),renderHTML:e=>e.spacing?{style:`letter-spacing: ${e.spacing}`}:{}}}},parseHTML(){return[{tag:"span",getAttrs:e=>e.style.letterSpacing?{}:!1}]},renderHTML({HTMLAttributes:e}){return["span",y(this.options.HTMLAttributes,e),0]},addCommands(){return{setLetterSpacing:e=>({chain:t})=>t().setMark(this.name,{spacing:e}).run(),unsetLetterSpacing:()=>({chain:e})=>e().unsetMark(this.name).run()}}}),or=C.create({name:"lineHeight",addOptions(){return{types:["heading","paragraph"],defaultLineHeight:1.75}},findClosestTargetNode(e,t){const{selection:n}=e;if(n instanceof E){const{node:o}=n;if(o&&t.includes(o.type.name))return{node:o,pos:n.from}}const{$from:r}=n;for(let{depth:o}=r;o>0;o-=1){const s=r.node(o);if(t.includes(s.type.name))return{node:s,pos:r.before(o)}}return null},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:this.options.defaultLineHeight,parseHTML:e=>e.style.lineHeight||this.options.defaultLineHeight,renderHTML:e=>e.lineHeight===this.options.defaultLineHeight?{}:{style:`line-height: ${e.lineHeight}`}}}}]},addCommands(){return{setLineHeight:e=>({editor:t,state:n,dispatch:r})=>{const o=this.options.types.filter(i=>t.schema.nodes[i]);let{tr:s}=n,a=!1;if(n.doc.nodesBetween(n.selection.from,n.selection.to,(i,l)=>{if(o.includes(i.type.name)){if(i.attrs.lineHeight===e){a=!0;return}s=s.setNodeMarkup(l,void 0,{...i.attrs,lineHeight:e}),a=!0}}),!a){const i=this.findClosestTargetNode(n,o);if(!i)return!1;if(i.node.attrs.lineHeight===e)return!0;s=s.setNodeMarkup(i.pos,void 0,{...i.node.attrs,lineHeight:e}),a=!0}return r&&s.docChanged&&r(s),a},unsetLineHeight:()=>({editor:e,state:t,dispatch:n})=>{const{defaultLineHeight:r}=this.options,o=this.options.types.filter(i=>e.schema.nodes[i]);let{tr:s}=t,a=!1;if(t.doc.nodesBetween(t.selection.from,t.selection.to,(i,l)=>{if(o.includes(i.type.name)){if(i.attrs.lineHeight===r){a=!0;return}s=s.setNodeMarkup(l,void 0,{...i.attrs,lineHeight:r}),a=!0}}),!a){const i=this.findClosestTargetNode(t,o);if(!i)return!1;if(i.node.attrs.lineHeight===r)return!0;s=s.setNodeMarkup(i.pos,void 0,{...i.node.attrs,lineHeight:r}),a=!0}return n&&s.docChanged&&n(s),a}}}}),j=e=>{if(e==null)return null;if(typeof e=="number")return Number.isFinite(e)?String(e):null;if(typeof e!="string")return null;const t=e.trim().replace(/px$/i,"");if(!t)return null;const n=Number.parseFloat(t);return Number.isFinite(n)?String(n):null},J=e=>{if(!e||typeof e!="object")return null;const t=j(e.top),n=j(e.bottom),r={};return t!==null&&t!==""&&t!=="0"&&(r.top=t),n!==null&&n!==""&&n!=="0"&&(r.bottom=n),Object.keys(r).length?r:null},ge=(e,t)=>{if(!e&&!t)return!0;if(!e||!t||typeof e!="object"||typeof t!="object")return!1;const n=e.top||null,r=t.top||null,o=e.bottom||null,s=t.bottom||null;return n===r&&o===s},he=(e,t)=>{const{selection:n}=e;if(n instanceof E){const{node:o}=n;if(o&&t.includes(o.type.name))return{node:o,pos:n.from}}const{$from:r}=n;for(let{depth:o}=r;o>0;o-=1){const s=r.node(o);if(t.includes(s.type.name))return{node:s,pos:r.before(o)}}return null},sr=C.create({name:"margin",addOptions(){return{types:["heading","paragraph","audio","codeBlock","file","iframe","image","toc","video","horizontalRule","table","bulletList","orderedList","taskList","echarts","callout","columns","blockMath","codeBlock"],margin:{top:0,bottom:0}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{margin:{default:null,parseHTML:e=>{const{marginTop:t,marginBottom:n}=e.style;if(t===""&&n===""||t==="0px"&&n==="0px")return null;const r={};if(t&&t!=="0px"){const o=j(t.replace(/px/g,""));o!==null&&o!==""&&o!=="0"&&(r.top=o)}if(n&&n!=="0px"){const o=j(n.replace(/px/g,""));o!==null&&o!==""&&o!=="0"&&(r.bottom=o)}return Object.keys(r).length?r:null},renderHTML:e=>{const{margin:t}=e;if(!t||typeof t!="object")return{};const{top:n,bottom:r}=t;let o="";return n!=null&&n!==""&&(o+=`margin-top: ${n}px;`),r!=null&&r!==""&&(o+=`margin-bottom: ${r}px;`),o?{style:o}:{}}}}}]},addCommands(){return{setMargin:e=>({editor:t,state:n,dispatch:r})=>{const o=this.options.types.filter(l=>t.schema.nodes[l]),s=J(e);if(!s)return t.commands.unsetMargin();let{tr:a}=n,i=!1;if(n.doc.nodesBetween(n.selection.from,n.selection.to,(l,u)=>{if(!o.includes(l.type.name))return;const c=l.attrs.margin&&typeof l.attrs.margin=="object"?l.attrs.margin:null,f=J({...c,...s});if(ge(c,f)){i=!0;return}a=a.setNodeMarkup(u,void 0,{...l.attrs,margin:f}),i=!0}),!i){const l=he(n,o);if(!l)return!1;const u=l.node.attrs.margin&&typeof l.node.attrs.margin=="object"?l.node.attrs.margin:null,c=J({...u,...s});if(ge(u,c))return!0;a=a.setNodeMarkup(l.pos,void 0,{...l.node.attrs,margin:c}),i=!0}return r&&a.docChanged&&r(a),i},unsetMargin:()=>({editor:e,state:t,dispatch:n})=>{const r=this.options.types.filter(a=>e.schema.nodes[a]);let{tr:o}=t,s=!1;if(t.doc.nodesBetween(t.selection.from,t.selection.to,(a,i)=>{if(!r.includes(a.type.name))return;const l=a.attrs.margin;if(!l||typeof l=="object"&&!Object.keys(l).length){s=!0;return}o=o.setNodeMarkup(i,void 0,{...a.attrs,margin:null}),s=!0}),!s){const a=he(t,r);if(!a)return!1;const i=a.node.attrs.margin;if(!i||typeof i=="object"&&!Object.keys(i).length)return!0;o=o.setNodeMarkup(a.pos,void 0,{...a.node.attrs,margin:null}),s=!0}return n&&o.docChanged&&n(o),s}}}}),ar=Xt.extend({addOptions(){return{...this.parent?.(),HTMLAttributes:{class:"umo-node-mention"}}},addAttributes(){return{id:{default:null},label:{default:null}}},addCommands(){return{insertMention:()=>({commands:e})=>e.insertContent(` ${this.options?.suggestion?.char||"@"}`)}}}),ye=(e,t)=>{Gt({getBoundingClientRect:()=>Xe(e.view,e.state.selection.from,e.state.selection.to)},t,{placement:"bottom-start",strategy:"absolute",middleware:[Jt(),Yt()]}).then(({x:r,y:o,strategy:s})=>{t.style.width="max-content",t.style.position=s,t.style.left=`${r}px`,t.style.top=`${o}px`})},ir=(e,t)=>({items:({query:n})=>e.filter(r=>r.label.includes(n)).slice(0,10),command:({editor:n,range:r,props:o})=>{n.chain().focus().deleteRange(r).insertContent({type:"mention",attrs:{id:o.id,label:o.label}}).run()},render:()=>{let n;return{onStart:r=>{n=new Ke(Zt,{props:r,editor:r.editor}),r.clientRect&&(n.element.style.position="absolute",document.body.appendChild(n.element),ye(r.editor,n.element))},onUpdate(r){n.updateProps(r),r.clientRect&&ye(r.editor,n.element)},onKeyDown(r){return r.event.key==="Escape"?(n.destroy(),!0):n.ref?.onKeyDown(r)},onExit(){n.element.remove(),n.destroy()}}}}),be=(e,t)=>{const{selection:n}=e;if(n instanceof E){const{node:o}=n;if(o&&t.includes(o.type.name))return{node:o,pos:n.from}}const{$from:r}=n;for(let{depth:o}=r;o>0;o-=1){const s=r.node(o);if(t.includes(s.type.name))return{node:s,pos:r.before(o)}}return null},lr=C.create({name:"nodeAlign",addOptions(){return{defaultAlignment:"center",alignments:["flex-start","center","flex-end"],types:["image","video","audio","iframe","file","echarts"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{nodeAlign:{default:this.options.defaultAlignment,parseHTML:e=>e.style.justifyContent||this.options.defaultAlignment,renderHTML:e=>({style:`justify-content: ${e.nodeAlign}`})}}}]},addCommands(){return{setNodeAlign:e=>({editor:t,state:n,dispatch:r})=>{if(!this.options.alignments.includes(e))return!1;const o=this.options.types.filter(i=>t.schema.nodes[i]);let{tr:s}=n,a=!1;if(n.doc.nodesBetween(n.selection.from,n.selection.to,(i,l)=>{if(o.includes(i.type.name)){if(i.attrs.nodeAlign===e){a=!0;return}s=s.setNodeMarkup(l,void 0,{...i.attrs,nodeAlign:e}),a=!0}}),!a){const i=be(n,o);if(!i)return!1;if(i.node.attrs.nodeAlign===e)return!0;s=s.setNodeMarkup(i.pos,void 0,{...i.node.attrs,nodeAlign:e}),a=!0}return r&&s.docChanged&&r(s),a},unsetNodeAlign:()=>({editor:e,state:t,dispatch:n})=>{const{defaultAlignment:r}=this.options,o=this.options.types.filter(i=>e.schema.nodes[i]);let{tr:s}=t,a=!1;if(t.doc.nodesBetween(t.selection.from,t.selection.to,(i,l)=>{if(o.includes(i.type.name)){if(i.attrs.nodeAlign===r){a=!0;return}s=s.setNodeMarkup(l,void 0,{...i.attrs,nodeAlign:r}),a=!0}}),!a){const i=be(t,o);if(!i)return!1;if(i.node.attrs.nodeAlign===r)return!0;s=s.setNodeMarkup(i.pos,void 0,{...i.node.attrs,nodeAlign:r}),a=!0}return n&&s.docChanged&&n(s),a}}}}),ur=C.create({name:"selectNode",addOptions(){return{types:["horizontalRule","pageBreak","blockMath","inlineMath"]}},addProseMirrorPlugins(){const{types:e}=this.options;return[new H({key:new S("select-node"),props:{handleDOMEvents:{click(t,n){const{state:r,dispatch:o}=t,s=t.posAtCoords({left:n.clientX,top:n.clientY});if(!s)return!1;const a=s.inside>=0?s.inside:s.pos,i=r.doc.nodeAt(a);if(!i||!e.includes(i.type.name))return!1;const l=E.create(r.doc,a);return o(r.tr.setSelection(l)),t.focus(),!0}}}})]}}),cr=e=>{const n=new DOMParser().parseFromString(e,"text/html");return n.querySelectorAll('[style*="mso-bookmark:"]').forEach(o=>{const s=Z(o)["mso-bookmark"],a=n.querySelector(`a[name="${s}"]`);a&&Y(a),Y(o)}),n.documentElement.outerHTML},dr=e=>{const t={};return e.split(";").map(r=>r.trim()).filter(Boolean).forEach(r=>{const[o,s]=r.split(":").map(a=>a.trim());o&&s&&(t[o]=s)}),t},fr=e=>{const t=/\.(\w+)\s*\{([^}]+)\}/g;let n;const r={};for(;(n=t.exec(e))!==null;){const[,o,s]=n,a=dr(s);r[o]=a}return r},mr=(e,t)=>{if(!t)return!1;const{clipboardData:n}=t;if(!n)return!1;const r=n.getData("text/html");if(!r)return!1;const s=new DOMParser().parseFromString(r,"text/html");if(!s?.querySelector("html")?.getAttribute("xmlns:x")?.includes("office:excel"))return!1;const i=s.querySelector("table");if(!i)return!1;const l=Array.from(s.head.querySelectorAll("style")).map(d=>d.textContent).join(`
3
+ `),u=fr(l);i.querySelectorAll("td, th").forEach(d=>{const p=u[d.getAttribute("class")];p?.background&&(d.style.background=p.background),p?.color&&(d.style.color=p.color),p?.["text-align"]&&d.setAttribute("align",p["text-align"])});const{schema:c}=e.state,f=Ut.fromSchema(c).parse(i),m=e.state.tr.replaceSelectionWith(f);return e.dispatch(m),!0},pr=e=>{const n=new DOMParser().parseFromString(e,"text/html");return n.querySelectorAll('p[class*="MsoNormal"]').forEach(r=>{r.classList.remove("MsoNormal")}),n.documentElement.outerHTML},gr=e=>{const n=new DOMParser().parseFromString(e,"text/html");return n.querySelectorAll('[class*="MsoLineNumber"]').forEach(o=>Y(o)),n.documentElement.outerHTML},hr=e=>{if(e.indexOf("mso-list:")===-1)return e;const n=new DOMParser().parseFromString(e,"text/html");let r=[],o;return n.querySelectorAll('p[style*="mso-list:"]').forEach(a=>{const i=a,[l,u]=Mr(Z(i)["mso-list"]);for(o!==l&&(yr(i)||u===1)&&(o=l,r=[]);u>r.length;){const c=Tr(i);r.length>0?r[r.length-1].appendChild(c):i.before(c),r.push(c)}for(;u<r.length;)r.pop();r[r.length-1].appendChild(br(i)),i.remove()}),n.documentElement.outerHTML},yr=e=>!e.previousElementSibling||!(e.previousElementSibling.nodeName==="OL"||e.previousElementSibling.nodeName==="UL"),br=e=>{const t=document.createElement("li");return t.innerHTML=e.innerHTML.replace(Re,""),t},Mr=e=>{const n=e.split(" "),r=n.find(s=>/l[0-9]+/.test(s))||"",o=+(n.find(s=>s.startsWith("level"))?.substring(5)||1);return[r,o]},Re=/<!--\[if \!supportLists\]-->((.|\n)*)<!--\[endif\]-->/m,Lr=e=>{const t=e.innerHTML.match(Re);return t?.length&&new DOMParser().parseFromString(t[0],"text/html").body.querySelector("span")?.textContent||""},Tr=e=>{const t=kr(Lr(e)),n=document.createElement(t.type);return t.countType&&n.setAttribute("type",t.countType),t.start>1&&n.setAttribute("start",t.start.toString()),n},D={number:/[0-9]+\./,romanLower:/(?=[mdclxvi])m*(c[md]|d?c*)(x[cl]|l?x*)(i[xv]|v?i*)\./,romanUpper:/(?=[MDCLXVI])M*(C[MD]|D?C*)(X[CL]|L?X*)(I[XV]|V?I*)\./,letterLower:/[a-z]+\./,letterUpper:/[A-Z]+\./},kr=e=>{let t="ul",n=null,r=1,o;return(o=e.match(D.number))?(t="ol",r=+o[0].replace(".","")):(o=e.match(D.romanLower))?(t="ol",n="i",r=+ue(o[0].replace(".",""))):(o=e.match(D.romanUpper))?(t="ol",n="I",r=+ue(o[0].replace(".",""))):(o=e.match(D.letterLower))?(t="ol",n="a",r=+ce(o[0].replace(".",""))):(o=e.match(D.letterUpper))&&(t="ol",n="A",r=+ce(o[0].replace(".",""))),{type:t,start:r,countType:n}},Ar=e=>{e=e.replace(/<o:p>(.*?)<\/o:p>/g,"");const n=new DOMParser().parseFromString(e,"text/html");return n.querySelectorAll('[style*="mso-"]').forEach(r=>{const o=Z(r),s=[];for(const a of Object.keys(o))a&&!a.startsWith("mso-")&&s.push(`${a}: ${o[a]}`);r.setAttribute("style",s.join(";"))}),n.querySelectorAll('[style*="color: black"]').forEach(r=>{r.style.removeProperty("color")}),n.documentElement.outerHTML},xr=()=>new H({key:new S("office-paste"),props:{transformPastedHTML(e){if(He(e)){const t=`<span style="color: var(--umo-error-color, #e34d59);">${$("officePaste.imagePlaceholder")}</span>`;e=hr(e),e=cr(e),e=Ar(e),e=pr(e),e=gr(e),e=Bn(e,t)}return e},handlePaste(e,t){const n=t?.clipboardData,r=n?.getData("text/html")||"",o=Array.from(n?.files||[]),s=ve(n),a=Dn(o,r);if(t&&s){if(a){const i=Qt({width:400,theme:"warning",header:$("officePaste.dialog.title"),body:$("officePaste.dialog.body"),onConfirm:()=>{i.destroy()}})}t.skipFileHandler=!0}return mr(e,t)}}}),Cr=C.create({priority:99999,name:"officePaste",addProseMirrorPlugins(){return[xr()]}}),wr=L.create({name:"optionBox",group:"inline",inline:!0,atom:!0,addAttributes(){return{target:{default:"checkbox"},items:{default:[],parseHTML:e=>{const t=e.hasAttribute("items")?e.getAttribute("items"):null;return t?JSON.parse(t):null},renderHTML:e=>({items:e.items?JSON.stringify(e.items):null})},checkAll:{default:!1},checked:{default:!0},updated:{default:!1}}},parseHTML(){return[{tag:'span[data-type="option-box"]'}]},renderHTML({HTMLAttributes:e}){const t=e.items||"";return["span",y(e,{"data-type":"option-box"}),t]},addNodeView(){return x(en)},addCommands(){return{insertOptionBox:e=>({chain:t,editor:n})=>{const{to:r}=n?.state?.selection||{};return t().insertContentAt(r-1,{type:this.name,attrs:e}).run()},updateOptionBox:e=>({commands:t})=>t.updateAttributes(this.name,e)}}}),Sr=Te.extend({content:"listItem*",addAttributes(){return{...this.parent?.(),listType:{default:"decimal",parseHTML:e=>e.style.getPropertyValue("list-style-type")||"decimal",renderHTML:({listType:e})=>({style:`list-style-type: ${e}`,"data-type":e})},start:{default:1,parseHTML:e=>{const t=e.getAttribute("data-start");return t?Number(t):1},renderHTML:e=>e["data-start"]===1?{}:{"data-start":e.start}}}}}),Hr=L.create({name:"pageBreak",group:"block",addOptions(){return{HTMLAttributes:{class:"umo-page-break","data-line-number":!1},getContentLabel:()=>$("page.break")}},parseHTML(){return[{tag:'div[class*="umo-page-break"]'}]},renderHTML({HTMLAttributes:e}){return["div",y(this.options.HTMLAttributes,e,{"data-content":this.options.getContentLabel()})]},addCommands(){return{setPageBreak:()=>({commands:e})=>e.insertContent({type:this.name})}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setPageBreak()}}}),vr=(e,t,n)=>RegExp(t?e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"):e,n?"gu":"gui"),Nr=(e,t,n,r)=>{const o=[],s=[];let a=[],i=0;if(!t)return{decorationsToReturn:F.empty,results:[]};e?.descendants((l,u)=>{l.isText?a[i]?a[i]={text:a[i].text+l.text,pos:a[i].pos}:a[i]={text:`${l.text}`,pos:u}:i+=1}),a=a.filter(Boolean);for(const l of a){const{text:u,pos:c}=l,f=Array.from(u.matchAll(t)).filter(([m])=>m.trim());for(const m of f){if(m[0]==="")break;m.index!==void 0&&s.push({from:c+m.index,to:c+m.index+m[0].length})}}for(let l=0;l<s.length;l+=1){const u=s[l],c=l===r?`${n} ${n}-current`:n,f=Ce.inline(u.from,u.to,{class:c});o.push(f)}return{decorationsToReturn:F.create(e,o),results:s}},Ir=(e,t,{state:n,dispatch:r})=>{const[o]=t;if(!o)return;const{from:s,to:a}=o;r&&r(n.tr.insertText(e,s,a))},Rr=(e,t,n,r)=>{const o=t+1;if(!r[o])return null;const{from:s,to:a}=r[t],i=a-s-e.length+n,{from:l,to:u}=r[o];return r[o]={to:u-i,from:l-i},[i,r]},Pr=(e,t,{tr:n,dispatch:r})=>{let o=0,s=t.slice();if(s.length){for(let a=0;a<s.length;a+=1){const{from:i,to:l}=s[a];n.insertText(e,i,l);const u=Rr(e,a,o,s);u&&([o,s]=u)}r(n)}},$r=C.create({name:"searchAndReplace",addOptions(){return{searchResultClass:"umo-search-result",disableRegex:!0}},addStorage(){return{searchTerm:"",replaceTerm:"",results:[],lastSearchTerm:"",caseSensitive:!1,lastCaseSensitive:!1,resultIndex:0,lastResultIndex:0}},addCommands(){return{setSearchTerm:e=>({editor:t})=>(t.storage.searchAndReplace.searchTerm=e,!1),setReplaceTerm:e=>({editor:t})=>(t.storage.searchAndReplace.replaceTerm=e,!1),setCaseSensitive:e=>({editor:t})=>(t.storage.searchAndReplace.caseSensitive=e,!1),resetIndex:()=>({editor:e})=>(e.storage.searchAndReplace.resultIndex=0,!1),nextSearchResult:()=>({editor:e})=>{const{results:t,resultIndex:n}=e.storage.searchAndReplace,r=n+1;return t[r]?e.storage.searchAndReplace.resultIndex=r:e.storage.searchAndReplace.resultIndex=0,!1},previousSearchResult:()=>({editor:e})=>{const{results:t,resultIndex:n}=e.storage.searchAndReplace,r=n-1;return t[r]?e.storage.searchAndReplace.resultIndex=r:e.storage.searchAndReplace.resultIndex=t.length-1,!1},replace:()=>({editor:e,state:t,dispatch:n})=>{const{replaceTerm:r,results:o}=e.storage.searchAndReplace;return Ir(r,o,{state:t,dispatch:n}),!1},replaceAll:()=>({editor:e,tr:t,dispatch:n})=>{const{replaceTerm:r,results:o}=e.storage.searchAndReplace;return Pr(r,o,{tr:t,dispatch:n}),!1}}},addProseMirrorPlugins(){const{editor:e}=this,{searchResultClass:t,disableRegex:n}=this.options,r=a=>e.storage.searchAndReplace.lastSearchTerm=a,o=a=>e.storage.searchAndReplace.lastCaseSensitive=a,s=a=>e.storage.searchAndReplace.lastResultIndex=a;return[new H({key:"search-replace",state:{init:()=>F.empty,apply({doc:a,docChanged:i},l){const{searchTerm:u,lastSearchTerm:c,caseSensitive:f,lastCaseSensitive:m,resultIndex:d,lastResultIndex:p}=e.storage.searchAndReplace;if(!i&&c===u&&m===f&&p===d)return l;if(r(u),o(f),s(d),!u)return e.storage.searchAndReplace.results=[],F.empty;const{decorationsToReturn:g,results:v}=Nr(a,vr(u,n,f),t,d);return e.storage.searchAndReplace.results=v,g}},props:{decorations(a){return this.getState(a)}}})]}}),Er=gt.extend({addOptions(){return{...this.parent?.(),className:"umo-selection"}},addCommands(){return{...this.parent?.(),setCurrentNodeSelection:()=>({editor:e,chain:t})=>{e.commands.selectParentNode();const{$anchor:n}=e.state.selection;return t().setNodeSelection(n.pos-n.depth).run()},deleteSelectionNode:()=>({editor:e,commands:t})=>{const n=tn(e);return n?t.deleteSelection()?!0:t.deleteNode(n.type.name):!1}}}}),Or=nn.extend({addOptions(){return{...this.parent?.(),HTMLAttributes:{class:"umo-node-table"},allowTableNodeSelection:!0,resizable:!0}}}),Pe={addAttributes(){return{...this.parent?.(),align:{default:null,parseHTML:e=>e.getAttribute("align")||null,renderHTML:({align:e})=>({align:e})},background:{default:null,parseHTML:e=>{const n=(e.getAttribute("style")||"").match(/background(?:-color)?:\s*([^;]+)/i);return n?n[1].trim():null},renderHTML:({background:e})=>e?{style:`background-color: ${e}`}:{}},color:{default:null,parseHTML:e=>{const t=e.getAttribute("style")||"",n=t.match(/(?<!background-)color:\s*([^;]+)/i);return t.includes("background-color")?null:n?n[1].trim():null},renderHTML:({color:e})=>e?{style:`color: ${e}`}:{}}}}},Dr=on.extend(Pe),Br=rn.extend(Pe),Fr=L.create({name:"tag",group:"inline",inline:!0,atom:!0,addAttributes(){return{type:{default:"default"},text:{default:$("bubbleMenu.tag.content")},color:{default:"#999"},backgroundColor:{default:"rgba(0, 0, 0, 0.05)"}}},parseHTML(){return[{tag:'span[data-type="tag"]'}]},renderHTML({HTMLAttributes:e}){return["span",y(e,{"data-type":"tag"}),e.text]},addNodeView(){return x(an)},addCommands(){return{insertTag:e=>({chain:t})=>t().insertContent({type:this.name,attrs:e}).run()}}}),_r=ln.extend({addOptions(){return{...this.parent?.(),types:["heading","paragraph"],alignments:["left","center","right","justify","distributed"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>e.style.textAlignLast?"distributed":e.style.textAlign||this.options.defaultAlignment,renderHTML:e=>e.textAlign===this.options.defaultAlignment?{}:e.textAlign==="distributed"?{style:"text-align-last: justify"}:{style:`text-align: ${e.textAlign}`}}}}]},addKeyboardShortcuts(){return{...this.parent?.(),"Mod-Shift-d":()=>this.editor.commands.setTextAlign("distributed")}}}),zr=L.create({name:"textBox",group:"block",content:"inline*",draggable:!1,addAttributes(){return{vnode:{default:!0},width:{default:200},height:{default:30},angle:{default:null},left:{default:0},top:{default:0},rotatable:{default:!0},borderWidth:{default:1},borderColor:{default:"#000"},borderStyle:{default:"solid"},backgroundColor:{default:"transparent"},writingMode:{default:"horizontal-tb",parseHTML:e=>e.style.writingMode||this.options.writingMode,renderHTML:({writingMode:e})=>({style:`writing-mode: ${e}`})}}},parseHTML(){return[{tag:"text-box"}]},renderHTML({HTMLAttributes:e}){return["text-box",y(e),0]},addNodeView(){return x(un)},addCommands(){return{setTextBox:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}}}),Wr=L.create({name:"toc",group:"block",atom:!0,addAttributes(){return{vnode:{default:!0}}},parseHTML(){return[{tag:"toc"}]},renderHTML({HTMLAttributes:e}){return["toc",y(this.options.HTMLAttributes,e)]},addNodeView(){return x(cn)},addGlobalAttributes(){return[{types:["heading"],attributes:{}}]},addCommands(){return{addTableOfContents:e=>({chain:t})=>t().insertContent({type:this.name,attrs:e}).run()}}}),Vr=L.create({name:"video",group:"block",atom:!0,addAttributes(){return{vnode:{default:!0},file:{default:null},id:{default:null},name:{default:null},size:{default:null},src:{default:null},width:{default:null},height:{default:200},uploaded:{default:!1},previewType:{default:"video"}}},parseHTML(){return[{tag:"video"}]},renderHTML({HTMLAttributes:e}){return["video",y(e)]},addNodeView(){return x(pn)},addCommands(){return{setVideo:e=>({commands:t,editor:n})=>t.insertContentAt(n.state.selection.anchor,{type:this.name,attrs:e})}}}),Ur=e=>{switch(e){case"break-all":return"word-break: break-all;";case"break-word":return"word-break: break-word;";case"normal":default:return"word-break: normal;"}},jr=C.create({name:"wordWrap",addOptions(){return{types:["paragraph","heading"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{wordWrap:{default:"normal",parseHTML:e=>e.style.wordWrap||e.getAttribute("data-word-wrap")||"normal",renderHTML:e=>!e.wordWrap||e.wordWrap==="normal"?{}:{"data-word-wrap":e.wordWrap,style:Ur(e.wordWrap)}}}}]},addCommands(){return{setWordWrap:e=>({state:t,commands:n})=>{const{selection:r}=t;return r instanceof E?n.updateAttributes(r.node.type.name,{wordWrap:e}):this.options.types.some(o=>n.updateAttributes(o,{wordWrap:e}))},unsetWordWrap:()=>({commands:e})=>this.options.types.some(t=>e.updateAttributes(t,{wordWrap:"normal"})),canSetWordWrap:()=>({state:e})=>{const{from:t,to:n}=e.selection;let r=!1;return e.doc.nodesBetween(t,n,o=>{if(this.options.types.includes(o.type.name))return r=!0,!1}),r}}}}),qr=["paragraph","heading","blockquote","codeBlock","hardBreak","horizontalRule","bulletList","orderedList","listItem","taskList","taskItem","details","detailsSummary","detailsContent","table","tableRow","tableHeader","tableCell","image","inlineImage","video","audio","file","callout","column","columnBlock","textBox","datetime","optionBox","iframe","echarts","toc","tag","pageBreak","mention","blockMath","inlineMath"],Kr=({container:e,options:t,uploadFileMap:n})=>{const{page:r,document:o,users:s,file:a,disableExtensions:i}=t.value,l={"ordered-list":Sr,"bullet-list":Mn,"task-list":at.configure({HTMLAttributes:{class:"umo-task-list"}}),margin:sr,link:rt.configure({openOnClick:!1,enableClickSelection:!0}),image:Ie,inlineImage:er,video:Vr,audio:gn,symbol:Symbol,tag:Fr,columns:$n,callout:Ln,mention:ar.configure({suggestion:ir(s)}),"date-time":En,"option-box":wr,bookmark:hn,footnote:[Xn,Jn,zn],"hard-break":bn.configure({visible:r?.showBreakMarks}),"horizontal-rule":Zn,toc:Wr,"text-box":zr,"web-page":Qn},u=[kt.configure({document:!1,bold:!1,codeBlock:!1,horizontalRule:!1,undoRedo:!1,link:!1,placeholder:!1,dropcursor:!1,selection:!1,bulletList:!1,orderedList:!1,trailingNode:!1,listKeymap:!0}),nt.extend({content:i.includes("footnote")?o.structure:`${o.structure} footnotes?`}),mt.configure({lineHeight:!1}),ht.extend({addKeyboardShortcuts(){return{}}}),yt.configure({className:"umo-node-focused",mode:"all"}),bt.configure({node:"paragraph"}),Mt.configure({showOnlyCurrent:!1,placeholder:({node:c,pos:f})=>c.type.name==="heading"?f===0?$("document.headingPlaceholder"):"":String(Ye(o?.placeholder||""))}),Yn,jr,Ze.extend({renderHTML:({HTMLAttributes:c})=>["b",c,0]}),ut,ct,nr,_r,lr,rr,it.configure({nested:!0}),or,$r,Wt,Qe.configure({HTMLAttributes:{class:"umo-node-details"}}),et.configure({HTMLAttributes:{class:"umo-node-details-content"}}),tt.configure({HTMLAttributes:{class:"umo-node-details-summary"}}),Or,sn,Br,Dr,On,Hr,Er,lt,ur,dt.configure({getIndex:ft,scrollParent:()=>document.querySelector(`${e} .umo-zoomable-container`),getId:()=>P(10)}),ke.configure(o?.typographyRules),Lt.configure({limit:o?.characterLimit!==0?o?.characterLimit:void 0}),_n.configure({allowedMimeTypes:a?.allowedMimeTypes,async onPaste(c,f){const m=document.querySelector(`${e} .umo-zoomable-container`),d=m?.scrollTop||0;for(const p of f){const g=await ae(p);c.commands.insertFile({file:p,uploadFileMap:n.value,autoType:!0,dimensions:g})}m&&setTimeout(()=>{m.scrollTop=d},0)},async onDrop(c,f,m){for(const d of f){const p=await ae(d);c.commands.insertFile({file:d,uploadFileMap:n.value,autoType:!0,pos:m,dimensions:p})}}}),Tt.configure({color:"var(--umo-primary-color)"}),dn,Cr];return Object.values(l).forEach(c=>{if(!i?.includes(c.name)){if(Array.isArray(c)){u.push(...c);return}u.push(c)}}),o?.enableNodeId&&u.push(pt.configure({types:qr,generateID:()=>P(10)})),u},Me=e=>{let t=!0;const n=Le("document",e);return(!e.value.document?.enableMarkdown||!n.value?.enableMarkdown)&&(t=[ke,Ie]),t},ss={__name:"index",setup(e){const t=R("destroyed"),n=R("page"),r=R("options"),o=R("uploadFileMap"),s=R("historyRecords"),a=Le("document",r),i=Ee(()=>r.value.dicts?.lineHeights?.find(b=>b.default)?.value),l=R("container"),u=Kr({container:l,options:r,uploadFileMap:o});let c=null;const f=(b=T)=>{!a.value||!b||(a.value.content=b.getHTML())},m=()=>{c!==null&&clearTimeout(c),c=setTimeout(()=>{c=null,f(T)},800)},d=()=>{c!==null&&(clearTimeout(c),c=null),f(T)},p=b=>{const{$from:M}=b,{depth:I}=M;for(let w=I;w>0;w-=1){const q=M.node(w)?.type?.name;if(q==="listItem"||q==="taskItem")return q}return null},g=(b,M)=>{const I=r.value.document?.editorProps?.handleKeyDown;if(M.key==="Enter"&&!M.shiftKey&&!M.altKey&&!M.ctrlKey&&!M.metaKey&&!M.isComposing){const w=p(b.state.selection);if(w&&T.commands.splitListItem(w))return M.preventDefault(),!0}return I?.(b,M)||!1},v=fn(r.value.document?.content),N=Oe()?.appContext,T=new Ge({editable:!r.value.document?.readOnly,autofocus:r.value.document?.autofocus,content:"",enableInputRules:Me(r),enablePasteRules:Me(r),editorProps:{attributes:{class:"umo-editor"},...r.value.document?.editorProps,handleKeyDown:g},parseOptions:r.value.document?.parseOptions,extensions:[...u,...r.value.extensions],onUpdate({editor:b}){mn(s,"editor",b?.state?.history$),m()},onBlur(){d()}});N&&(T.appContext=N);const k=R("editor");k.value=T,k.value.storage.container=l,De(()=>r.value,()=>{k.value.storage.options=r.value},{immediate:!0,deep:!0});async function $e(){await se(),await se(),!(!v||T.isDestroyed)&&T.commands.setContent(v,{emitUpdate:!1})}return Be(async()=>{await $e();const{disableExtensions:b,cdnUrl:M}=r.value,I=_=>!b.includes(_),w=`${M}/libs`;I("math")&&ie(`${w}/katex/katex.min.css`,"css","katex-style"),I("mermaid")&&ie(`${w}/mermaid/mermaid.min.js`,"script","mermaid-script"),window.addEventListener("beforeunload",d),window.addEventListener("pagehide",d),document.addEventListener("visibilitychange",d)}),Fe(()=>{window.removeEventListener("beforeunload",d),window.removeEventListener("pagehide",d),document.removeEventListener("visibilitychange",d),d(),T.unmount()}),(b,M)=>{const I=Q("menus-block"),w=Q("menus-bubble");return z(),ee(te,null,[_e(h(Je),{class:We(["umo-editor-content",{"show-bookmark":h(n).showBookmark,"show-line-number":h(n).showLineNumber,"format-painter":h(k)?.view?.painter?.enabled,"is-empty":h(k)?.isEmpty&&h(k)?.state.doc.childCount<=1,"is-readonly":!h(k)?.isEditable}]),editor:h(k),style:ze({lineHeight:i.value}),spellcheck:h(r).document?.enableSpellcheck&&h(a).enableSpellcheck},null,8,["class","editor","style","spellcheck"]),h(k)&&!h(t)?(z(),ee(te,{key:0},[h(r).document?.enableBlockMenu?ne((z(),re(I,{key:0},null,512)),[[oe,h(n).zoomLevel===100&&!h(n).preview?.enabled&&h(k).isEditable]]):K("v-if",!0),h(r).document?.enableBubbleMenu?ne((z(),re(w,{key:1},{bubble_menu:Ve(_=>[Ue(b.$slots,"bubble_menu",je(qe(_)))]),_:3},512)),[[oe,!h(k)?.view?.painter?.enabled&&!h(k)?.isEmpty]]):K("v-if",!0)],64)):K("v-if",!0)],64)}}};export{ss as default};