reactjs-tiptap-editor 0.2.0 → 0.2.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.
@@ -1,7 +1,7 @@
1
- "use strict";var Ke=Object.defineProperty;var Ue=(e,t,n)=>t in e?Ke(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var nt=(e,t,n)=>Ue(e,typeof t!="symbol"?t+"":t,n);const ve=require("tippy.js"),g=require("./vendor-CY5IU8Xa.cjs"),x=require("react"),be=require("react-dom");function ht(e){const{state:t,transaction:n}=e;let{selection:r}=n,{doc:o}=n,{storedMarks:s}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return s},get selection(){return r},get doc(){return o},get tr(){return r=n.selection,o=n.doc,s=n.storedMarks,n}}}class ft{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:n,state:r}=this,{view:o}=n,{tr:s}=r,i=this.buildProps(s);return Object.fromEntries(Object.entries(t).map(([a,c])=>[a,(...u)=>{const d=c(...u)(i);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(s),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,n=!0){const{rawCommands:r,editor:o,state:s}=this,{view:i}=o,a=[],c=!!t,l=t||s.tr,u=()=>(!c&&n&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(l),a.every(p=>p===!0)),d={...Object.fromEntries(Object.entries(r).map(([p,h])=>[p,(...f)=>{const y=this.buildProps(l,n),v=h(...f)(y);return a.push(v),d}])),run:u};return d}createCan(t){const{rawCommands:n,state:r}=this,o=!1,s=t||r.tr,i=this.buildProps(s,o);return{...Object.fromEntries(Object.entries(n).map(([c,l])=>[c,(...u)=>l(...u)({...i,dispatch:void 0})])),chain:()=>this.createChain(s,o)}}buildProps(t,n=!0){const{rawCommands:r,editor:o,state:s}=this,{view:i}=o,a={tr:t,editor:o,view:i,state:ht({state:s,transaction:t}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(t,n),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(r).map(([c,l])=>[c,(...u)=>l(...u)(a)]))}};return a}}class qe{constructor(){this.callbacks={}}on(t,n){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(n),this}emit(t,...n){const r=this.callbacks[t];return r&&r.forEach(o=>o.apply(this,n)),this}off(t,n){const r=this.callbacks[t];return r&&(n?this.callbacks[t]=r.filter(o=>o!==n):delete this.callbacks[t]),this}once(t,n){const r=(...o)=>{this.off(t,r),n.apply(this,o)};return this.on(t,r)}removeAllListeners(){this.callbacks={}}}function w(e,t,n){return e.config[t]===void 0&&e.parent?w(e.parent,t,n):typeof e.config[t]=="function"?e.config[t].bind({...n,parent:e.parent?w(e.parent,t,n):null}):e.config[t]}function mt(e){const t=e.filter(o=>o.type==="extension"),n=e.filter(o=>o.type==="node"),r=e.filter(o=>o.type==="mark");return{baseExtensions:t,nodeExtensions:n,markExtensions:r}}function Me(e){const t=[],{nodeExtensions:n,markExtensions:r}=mt(e),o=[...n,...r],s={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach(i=>{const a={name:i.name,options:i.options,storage:i.storage,extensions:o},c=w(i,"addGlobalAttributes",a);if(!c)return;c().forEach(u=>{u.types.forEach(d=>{Object.entries(u.attributes).forEach(([p,h])=>{t.push({type:d,name:p,attribute:{...s,...h}})})})})}),o.forEach(i=>{const a={name:i.name,options:i.options,storage:i.storage},c=w(i,"addAttributes",a);if(!c)return;const l=c();Object.entries(l).forEach(([u,d])=>{const p={...s,...d};typeof(p==null?void 0:p.default)=="function"&&(p.default=p.default()),p!=null&&p.isRequired&&(p==null?void 0:p.default)===void 0&&delete p.default,t.push({type:i.name,name:u,attribute:p})})}),t}function _(e,t){if(typeof e=="string"){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}function A(...e){return e.filter(t=>!!t).reduce((t,n)=>{const r={...t};return Object.entries(n).forEach(([o,s])=>{if(!r[o]){r[o]=s;return}if(o==="class"){const a=s?String(s).split(" "):[],c=r[o]?r[o].split(" "):[],l=a.filter(u=>!c.includes(u));r[o]=[...c,...l].join(" ")}else if(o==="style"){const a=s?s.split(";").map(u=>u.trim()).filter(Boolean):[],c=r[o]?r[o].split(";").map(u=>u.trim()).filter(Boolean):[],l=new Map;c.forEach(u=>{const[d,p]=u.split(":").map(h=>h.trim());l.set(d,p)}),a.forEach(u=>{const[d,p]=u.split(":").map(h=>h.trim());l.set(d,p)}),r[o]=Array.from(l.entries()).map(([u,d])=>`${u}: ${d}`).join("; ")}else r[o]=s}),r},{})}function dt(e,t){return t.filter(n=>n.type===e.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(e.attrs)||{}:{[n.name]:e.attrs[n.name]}).reduce((n,r)=>A(n,r),{})}function Se(e){return typeof e=="function"}function T(e,t=void 0,...n){return Se(e)?t?e.bind(t)(...n):e(...n):e}function Ge(e={}){return Object.keys(e).length===0&&e.constructor===Object}function Je(e){return typeof e!="string"?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e==="true"?!0:e==="false"?!1:e}function Xt(e,t){return"style"in e?e:{...e,getAttrs:n=>{const r=e.getAttrs?e.getAttrs(n):e.attrs;if(r===!1)return!1;const o=t.reduce((s,i)=>{const a=i.attribute.parseHTML?i.attribute.parseHTML(n):Je(n.getAttribute(i.name));return a==null?s:{...s,[i.name]:a}},{});return{...r,...o}}}}function Qt(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>t==="attrs"&&Ge(n)?!1:n!=null))}function Ye(e,t){var n;const r=Me(e),{nodeExtensions:o,markExtensions:s}=mt(e),i=(n=o.find(l=>w(l,"topNode")))===null||n===void 0?void 0:n.name,a=Object.fromEntries(o.map(l=>{const u=r.filter(v=>v.type===l.name),d={name:l.name,options:l.options,storage:l.storage,editor:t},p=e.reduce((v,S)=>{const M=w(S,"extendNodeSchema",d);return{...v,...M?M(l):{}}},{}),h=Qt({...p,content:T(w(l,"content",d)),marks:T(w(l,"marks",d)),group:T(w(l,"group",d)),inline:T(w(l,"inline",d)),atom:T(w(l,"atom",d)),selectable:T(w(l,"selectable",d)),draggable:T(w(l,"draggable",d)),code:T(w(l,"code",d)),whitespace:T(w(l,"whitespace",d)),linebreakReplacement:T(w(l,"linebreakReplacement",d)),defining:T(w(l,"defining",d)),isolating:T(w(l,"isolating",d)),attrs:Object.fromEntries(u.map(v=>{var S;return[v.name,{default:(S=v==null?void 0:v.attribute)===null||S===void 0?void 0:S.default}]}))}),m=T(w(l,"parseHTML",d));m&&(h.parseDOM=m.map(v=>Xt(v,u)));const f=w(l,"renderHTML",d);f&&(h.toDOM=v=>f({node:v,HTMLAttributes:dt(v,u)}));const y=w(l,"renderText",d);return y&&(h.toText=y),[l.name,h]})),c=Object.fromEntries(s.map(l=>{const u=r.filter(y=>y.type===l.name),d={name:l.name,options:l.options,storage:l.storage,editor:t},p=e.reduce((y,v)=>{const S=w(v,"extendMarkSchema",d);return{...y,...S?S(l):{}}},{}),h=Qt({...p,inclusive:T(w(l,"inclusive",d)),excludes:T(w(l,"excludes",d)),group:T(w(l,"group",d)),spanning:T(w(l,"spanning",d)),code:T(w(l,"code",d)),attrs:Object.fromEntries(u.map(y=>{var v;return[y.name,{default:(v=y==null?void 0:y.attribute)===null||v===void 0?void 0:v.default}]}))}),m=T(w(l,"parseHTML",d));m&&(h.parseDOM=m.map(y=>Xt(y,u)));const f=w(l,"renderHTML",d);return f&&(h.toDOM=y=>f({mark:y,HTMLAttributes:dt(y,u)})),[l.name,h]}));return new g.Schema({topNode:i,nodes:a,marks:c})}function Ct(e,t){return t.nodes[e]||t.marks[e]||null}function Zt(e,t){return Array.isArray(t)?t.some(n=>(typeof n=="string"?n:n.name)===e.name):t}function zt(e,t){const n=g.DOMSerializer.fromSchema(t).serializeFragment(e),o=document.implementation.createHTMLDocument().createElement("div");return o.appendChild(n),o.innerHTML}const Xe=(e,t=500)=>{let n="";const r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(o,s,i,a)=>{var c,l;const u=((l=(c=o.type.spec).toText)===null||l===void 0?void 0:l.call(c,{node:o,pos:s,parent:i,index:a}))||o.textContent||"%leaf%";n+=o.isAtom&&!o.isText?u:u.slice(0,Math.max(0,r-s))}),n};function Vt(e){return Object.prototype.toString.call(e)==="[object RegExp]"}class gt{constructor(t){this.find=t.find,this.handler=t.handler}}const Qe=(e,t)=>{if(Vt(t))return t.exec(e);const n=t(e);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function rt(e){var t;const{editor:n,from:r,to:o,text:s,rules:i,plugin:a}=e,{view:c}=n;if(c.composing)return!1;const l=c.state.doc.resolve(r);if(l.parent.type.spec.code||!((t=l.nodeBefore||l.nodeAfter)===null||t===void 0)&&t.marks.find(p=>p.type.spec.code))return!1;let u=!1;const d=Xe(l)+s;return i.forEach(p=>{if(u)return;const h=Qe(d,p.find);if(!h)return;const m=c.state.tr,f=ht({state:c.state,transaction:m}),y={from:r-(h[0].length-s.length),to:o},{commands:v,chain:S,can:M}=new ft({editor:n,state:f});p.handler({state:f,range:y,match:h,commands:v,chain:S,can:M})===null||!m.steps.length||(m.setMeta(a,{transform:m,from:r,to:o,text:s}),c.dispatch(m),u=!0)}),u}function Ze(e){const{editor:t,rules:n}=e,r=new g.Plugin({state:{init(){return null},apply(o,s,i){const a=o.getMeta(r);if(a)return a;const c=o.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:u}=c;typeof u=="string"?u=u:u=zt(g.Fragment.from(u),i.schema);const{from:d}=c,p=d+u.length;rt({editor:t,from:d,to:p,text:u,rules:n,plugin:r})}),o.selectionSet||o.docChanged?null:s}},props:{handleTextInput(o,s,i,a){return rt({editor:t,from:s,to:i,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:o=>(setTimeout(()=>{const{$cursor:s}=o.state.selection;s&&rt({editor:t,from:s.pos,to:s.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(o,s){if(s.key!=="Enter")return!1;const{$cursor:i}=o.state.selection;return i?rt({editor:t,from:i.pos,to:i.pos,text:`
2
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function tn(e){return Object.prototype.toString.call(e).slice(8,-1)}function ot(e){return tn(e)!=="Object"?!1:e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function yt(e,t){const n={...e};return ot(e)&&ot(t)&&Object.keys(t).forEach(r=>{ot(t[r])&&ot(e[r])?n[r]=yt(e[r],t[r]):n[r]=t[r]}),n}class N{constructor(t={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=T(w(this,"addOptions",{name:this.name}))),this.storage=T(w(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new N(t)}configure(t={}){const n=this.extend({...this.config,addOptions:()=>yt(this.options,t)});return n.name=this.name,n.parent=this.parent,n}extend(t={}){const n=new N(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=T(w(n,"addOptions",{name:n.name})),n.storage=T(w(n,"addStorage",{name:n.name,options:n.options})),n}static handleExit({editor:t,mark:n}){const{tr:r}=t.state,o=t.state.selection.$from;if(o.pos===o.end()){const i=o.marks();if(!!!i.find(l=>(l==null?void 0:l.type.name)===n.name))return!1;const c=i.find(l=>(l==null?void 0:l.type.name)===n.name);return c&&r.removeStoredMark(c),r.insertText(" ",o.pos),t.view.dispatch(r),!0}return!1}}function ke(e){return typeof e=="number"}class we{constructor(t){this.find=t.find,this.handler=t.handler}}const en=(e,t,n)=>{if(Vt(t))return[...e.matchAll(t)];const r=t(e,n);return r?r.map(o=>{const s=[o.text];return s.index=o.index,s.input=e,s.data=o.data,o.replaceWith&&(o.text.includes(o.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(o.replaceWith)),s}):[]};function nn(e){const{editor:t,state:n,from:r,to:o,rule:s,pasteEvent:i,dropEvent:a}=e,{commands:c,chain:l,can:u}=new ft({editor:t,state:n}),d=[];return n.doc.nodesBetween(r,o,(h,m)=>{if(!h.isTextblock||h.type.spec.code)return;const f=Math.max(r,m),y=Math.min(o,m+h.content.size),v=h.textBetween(f-m,y-m,void 0,"");en(v,s.find,i).forEach(M=>{if(M.index===void 0)return;const b=f+M.index+1,E=b+M[0].length,k={from:n.tr.mapping.map(b),to:n.tr.mapping.map(E)},C=s.handler({state:n,range:k,match:M,commands:c,chain:l,can:u,pasteEvent:i,dropEvent:a});d.push(C)})}),d.every(h=>h!==null)}let st=null;const rn=e=>{var t;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(t=n.clipboardData)===null||t===void 0||t.setData("text/html",e),n};function on(e){const{editor:t,rules:n}=e;let r=null,o=!1,s=!1,i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}const c=({state:u,from:d,to:p,rule:h,pasteEvt:m})=>{const f=u.tr,y=ht({state:u,transaction:f});if(!(!nn({editor:t,state:y,from:Math.max(d-1,0),to:p.b-1,rule:h,pasteEvent:m,dropEvent:a})||!f.steps.length)){try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,f}};return n.map(u=>new g.Plugin({view(d){const p=m=>{var f;r=!((f=d.dom.parentElement)===null||f===void 0)&&f.contains(m.target)?d.dom.parentElement:null,r&&(st=t)},h=()=>{st&&(st=null)};return window.addEventListener("dragstart",p),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",p),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(d,p)=>{if(s=r===d.dom.parentElement,a=p,!s){const h=st;h&&setTimeout(()=>{const m=h.state.selection;m&&h.commands.deleteRange({from:m.from,to:m.to})},10)}return!1},paste:(d,p)=>{var h;const m=(h=p.clipboardData)===null||h===void 0?void 0:h.getData("text/html");return i=p,o=!!(m!=null&&m.includes("data-pm-slice")),!1}}},appendTransaction:(d,p,h)=>{const m=d[0],f=m.getMeta("uiEvent")==="paste"&&!o,y=m.getMeta("uiEvent")==="drop"&&!s,v=m.getMeta("applyPasteRules"),S=!!v;if(!f&&!y&&!S)return;if(S){let{text:E}=v;typeof E=="string"?E=E:E=zt(g.Fragment.from(E),h.schema);const{from:k}=v,C=k+E.length,L=rn(E);return c({rule:u,state:h,from:k,to:{b:C},pasteEvt:L})}const M=p.doc.content.findDiffStart(h.doc.content),b=p.doc.content.findDiffEnd(h.doc.content);if(!(!ke(M)||!b||M===b.b))return c({rule:u,state:h,from:M,to:b,pasteEvt:i})}}))}function sn(e){const t=e.filter((n,r)=>e.indexOf(n)!==r);return Array.from(new Set(t))}class Y{constructor(t,n){this.splittableMarks=[],this.editor=n,this.extensions=Y.resolve(t),this.schema=Ye(this.extensions,n),this.setupExtensions()}static resolve(t){const n=Y.sort(Y.flatten(t)),r=sn(n.map(o=>o.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(o=>`'${o}'`).join(", ")}]. This can lead to issues.`),n}static flatten(t){return t.map(n=>{const r={name:n.name,options:n.options,storage:n.storage},o=w(n,"addExtensions",r);return o?[n,...this.flatten(o())]:n}).flat(10)}static sort(t){return t.sort((r,o)=>{const s=w(r,"priority")||100,i=w(o,"priority")||100;return s>i?-1:s<i?1:0})}get commands(){return this.extensions.reduce((t,n)=>{const r={name:n.name,options:n.options,storage:n.storage,editor:this.editor,type:Ct(n.name,this.schema)},o=w(n,"addCommands",r);return o?{...t,...o()}:t},{})}get plugins(){const{editor:t}=this,n=Y.sort([...this.extensions].reverse()),r=[],o=[],s=n.map(i=>{const a={name:i.name,options:i.options,storage:i.storage,editor:t,type:Ct(i.name,this.schema)},c=[],l=w(i,"addKeyboardShortcuts",a);let u={};if(i.type==="mark"&&w(i,"exitable",a)&&(u.ArrowRight=()=>N.handleExit({editor:t,mark:i})),l){const f=Object.fromEntries(Object.entries(l()).map(([y,v])=>[y,()=>v({editor:t})]));u={...u,...f}}const d=g.keymap(u);c.push(d);const p=w(i,"addInputRules",a);Zt(i,t.options.enableInputRules)&&p&&r.push(...p());const h=w(i,"addPasteRules",a);Zt(i,t.options.enablePasteRules)&&h&&o.push(...h());const m=w(i,"addProseMirrorPlugins",a);if(m){const f=m();c.push(...f)}return c}).flat();return[Ze({editor:t,rules:r}),...on({editor:t,rules:o}),...s]}get attributes(){return Me(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:n}=mt(this.extensions);return Object.fromEntries(n.filter(r=>!!w(r,"addNodeView")).map(r=>{const o=this.attributes.filter(c=>c.type===r.name),s={name:r.name,options:r.options,storage:r.storage,editor:t,type:_(r.name,this.schema)},i=w(r,"addNodeView",s);if(!i)return[];const a=(c,l,u,d,p)=>{const h=dt(c,o);return i()({node:c,view:l,getPos:u,decorations:d,innerDecorations:p,editor:t,extension:r,HTMLAttributes:h})};return[r.name,a]}))}setupExtensions(){this.extensions.forEach(t=>{var n;this.editor.extensionStorage[t.name]=t.storage;const r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:Ct(t.name,this.schema)};t.type==="mark"&&(!((n=T(w(t,"keepOnSplit",r)))!==null&&n!==void 0)||n)&&this.splittableMarks.push(t.name);const o=w(t,"onBeforeCreate",r),s=w(t,"onCreate",r),i=w(t,"onUpdate",r),a=w(t,"onSelectionUpdate",r),c=w(t,"onTransaction",r),l=w(t,"onFocus",r),u=w(t,"onBlur",r),d=w(t,"onDestroy",r);o&&this.editor.on("beforeCreate",o),s&&this.editor.on("create",s),i&&this.editor.on("update",i),a&&this.editor.on("selectionUpdate",a),c&&this.editor.on("transaction",c),l&&this.editor.on("focus",l),u&&this.editor.on("blur",u),d&&this.editor.on("destroy",d)})}}class H{constructor(t={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=T(w(this,"addOptions",{name:this.name}))),this.storage=T(w(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new H(t)}configure(t={}){const n=this.extend({...this.config,addOptions:()=>yt(this.options,t)});return n.name=this.name,n.parent=this.parent,n}extend(t={}){const n=new H({...this.config,...t});return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=T(w(n,"addOptions",{name:n.name})),n.storage=T(w(n,"addStorage",{name:n.name,options:n.options})),n}}function Ee(e,t,n){const{from:r,to:o}=t,{blockSeparator:s=`
1
+ "use strict";var We=Object.defineProperty;var Ke=(e,t,n)=>t in e?We(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var et=(e,t,n)=>Ke(e,typeof t!="symbol"?t+"":t,n);const ye=require("tippy.js"),g=require("./vendor-CwNzD6m_.cjs"),x=require("react"),ve=require("react-dom");function pt(e){const{state:t,transaction:n}=e;let{selection:r}=n,{doc:o}=n,{storedMarks:s}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return s},get selection(){return r},get doc(){return o},get tr(){return r=n.selection,o=n.doc,s=n.storedMarks,n}}}class ht{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:n,state:r}=this,{view:o}=n,{tr:s}=r,i=this.buildProps(s);return Object.fromEntries(Object.entries(t).map(([a,c])=>[a,(...u)=>{const d=c(...u)(i);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(s),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,n=!0){const{rawCommands:r,editor:o,state:s}=this,{view:i}=o,a=[],c=!!t,l=t||s.tr,u=()=>(!c&&n&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(l),a.every(p=>p===!0)),d={...Object.fromEntries(Object.entries(r).map(([p,h])=>[p,(...f)=>{const y=this.buildProps(l,n),v=h(...f)(y);return a.push(v),d}])),run:u};return d}createCan(t){const{rawCommands:n,state:r}=this,o=!1,s=t||r.tr,i=this.buildProps(s,o);return{...Object.fromEntries(Object.entries(n).map(([c,l])=>[c,(...u)=>l(...u)({...i,dispatch:void 0})])),chain:()=>this.createChain(s,o)}}buildProps(t,n=!0){const{rawCommands:r,editor:o,state:s}=this,{view:i}=o,a={tr:t,editor:o,view:i,state:pt({state:s,transaction:t}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(t,n),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(r).map(([c,l])=>[c,(...u)=>l(...u)(a)]))}};return a}}class Ue{constructor(){this.callbacks={}}on(t,n){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(n),this}emit(t,...n){const r=this.callbacks[t];return r&&r.forEach(o=>o.apply(this,n)),this}off(t,n){const r=this.callbacks[t];return r&&(n?this.callbacks[t]=r.filter(o=>o!==n):delete this.callbacks[t]),this}once(t,n){const r=(...o)=>{this.off(t,r),n.apply(this,o)};return this.on(t,r)}removeAllListeners(){this.callbacks={}}}function w(e,t,n){return e.config[t]===void 0&&e.parent?w(e.parent,t,n):typeof e.config[t]=="function"?e.config[t].bind({...n,parent:e.parent?w(e.parent,t,n):null}):e.config[t]}function ft(e){const t=e.filter(o=>o.type==="extension"),n=e.filter(o=>o.type==="node"),r=e.filter(o=>o.type==="mark");return{baseExtensions:t,nodeExtensions:n,markExtensions:r}}function be(e){const t=[],{nodeExtensions:n,markExtensions:r}=ft(e),o=[...n,...r],s={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach(i=>{const a={name:i.name,options:i.options,storage:i.storage,extensions:o},c=w(i,"addGlobalAttributes",a);if(!c)return;c().forEach(u=>{u.types.forEach(d=>{Object.entries(u.attributes).forEach(([p,h])=>{t.push({type:d,name:p,attribute:{...s,...h}})})})})}),o.forEach(i=>{const a={name:i.name,options:i.options,storage:i.storage},c=w(i,"addAttributes",a);if(!c)return;const l=c();Object.entries(l).forEach(([u,d])=>{const p={...s,...d};typeof(p==null?void 0:p.default)=="function"&&(p.default=p.default()),p!=null&&p.isRequired&&(p==null?void 0:p.default)===void 0&&delete p.default,t.push({type:i.name,name:u,attribute:p})})}),t}function _(e,t){if(typeof e=="string"){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}function A(...e){return e.filter(t=>!!t).reduce((t,n)=>{const r={...t};return Object.entries(n).forEach(([o,s])=>{if(!r[o]){r[o]=s;return}if(o==="class"){const a=s?String(s).split(" "):[],c=r[o]?r[o].split(" "):[],l=a.filter(u=>!c.includes(u));r[o]=[...c,...l].join(" ")}else if(o==="style"){const a=s?s.split(";").map(u=>u.trim()).filter(Boolean):[],c=r[o]?r[o].split(";").map(u=>u.trim()).filter(Boolean):[],l=new Map;c.forEach(u=>{const[d,p]=u.split(":").map(h=>h.trim());l.set(d,p)}),a.forEach(u=>{const[d,p]=u.split(":").map(h=>h.trim());l.set(d,p)}),r[o]=Array.from(l.entries()).map(([u,d])=>`${u}: ${d}`).join("; ")}else r[o]=s}),r},{})}function ct(e,t){return t.filter(n=>n.type===e.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(e.attrs)||{}:{[n.name]:e.attrs[n.name]}).reduce((n,r)=>A(n,r),{})}function Me(e){return typeof e=="function"}function T(e,t=void 0,...n){return Me(e)?t?e.bind(t)(...n):e(...n):e}function qe(e={}){return Object.keys(e).length===0&&e.constructor===Object}function Ge(e){return typeof e!="string"?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e==="true"?!0:e==="false"?!1:e}function Yt(e,t){return"style"in e?e:{...e,getAttrs:n=>{const r=e.getAttrs?e.getAttrs(n):e.attrs;if(r===!1)return!1;const o=t.reduce((s,i)=>{const a=i.attribute.parseHTML?i.attribute.parseHTML(n):Ge(n.getAttribute(i.name));return a==null?s:{...s,[i.name]:a}},{});return{...r,...o}}}}function Xt(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>t==="attrs"&&qe(n)?!1:n!=null))}function Je(e,t){var n;const r=be(e),{nodeExtensions:o,markExtensions:s}=ft(e),i=(n=o.find(l=>w(l,"topNode")))===null||n===void 0?void 0:n.name,a=Object.fromEntries(o.map(l=>{const u=r.filter(v=>v.type===l.name),d={name:l.name,options:l.options,storage:l.storage,editor:t},p=e.reduce((v,S)=>{const M=w(S,"extendNodeSchema",d);return{...v,...M?M(l):{}}},{}),h=Xt({...p,content:T(w(l,"content",d)),marks:T(w(l,"marks",d)),group:T(w(l,"group",d)),inline:T(w(l,"inline",d)),atom:T(w(l,"atom",d)),selectable:T(w(l,"selectable",d)),draggable:T(w(l,"draggable",d)),code:T(w(l,"code",d)),whitespace:T(w(l,"whitespace",d)),linebreakReplacement:T(w(l,"linebreakReplacement",d)),defining:T(w(l,"defining",d)),isolating:T(w(l,"isolating",d)),attrs:Object.fromEntries(u.map(v=>{var S;return[v.name,{default:(S=v==null?void 0:v.attribute)===null||S===void 0?void 0:S.default}]}))}),m=T(w(l,"parseHTML",d));m&&(h.parseDOM=m.map(v=>Yt(v,u)));const f=w(l,"renderHTML",d);f&&(h.toDOM=v=>f({node:v,HTMLAttributes:ct(v,u)}));const y=w(l,"renderText",d);return y&&(h.toText=y),[l.name,h]})),c=Object.fromEntries(s.map(l=>{const u=r.filter(y=>y.type===l.name),d={name:l.name,options:l.options,storage:l.storage,editor:t},p=e.reduce((y,v)=>{const S=w(v,"extendMarkSchema",d);return{...y,...S?S(l):{}}},{}),h=Xt({...p,inclusive:T(w(l,"inclusive",d)),excludes:T(w(l,"excludes",d)),group:T(w(l,"group",d)),spanning:T(w(l,"spanning",d)),code:T(w(l,"code",d)),attrs:Object.fromEntries(u.map(y=>{var v;return[y.name,{default:(v=y==null?void 0:y.attribute)===null||v===void 0?void 0:v.default}]}))}),m=T(w(l,"parseHTML",d));m&&(h.parseDOM=m.map(y=>Yt(y,u)));const f=w(l,"renderHTML",d);return f&&(h.toDOM=y=>f({mark:y,HTMLAttributes:ct(y,u)})),[l.name,h]}));return new g.Schema({topNode:i,nodes:a,marks:c})}function Tt(e,t){return t.nodes[e]||t.marks[e]||null}function Qt(e,t){return Array.isArray(t)?t.some(n=>(typeof n=="string"?n:n.name)===e.name):t}function Ft(e,t){const n=g.DOMSerializer.fromSchema(t).serializeFragment(e),o=document.implementation.createHTMLDocument().createElement("div");return o.appendChild(n),o.innerHTML}const Ye=(e,t=500)=>{let n="";const r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(o,s,i,a)=>{var c,l;const u=((l=(c=o.type.spec).toText)===null||l===void 0?void 0:l.call(c,{node:o,pos:s,parent:i,index:a}))||o.textContent||"%leaf%";n+=o.isAtom&&!o.isText?u:u.slice(0,Math.max(0,r-s))}),n};function zt(e){return Object.prototype.toString.call(e)==="[object RegExp]"}class mt{constructor(t){this.find=t.find,this.handler=t.handler}}const Xe=(e,t)=>{if(zt(t))return t.exec(e);const n=t(e);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function nt(e){var t;const{editor:n,from:r,to:o,text:s,rules:i,plugin:a}=e,{view:c}=n;if(c.composing)return!1;const l=c.state.doc.resolve(r);if(l.parent.type.spec.code||!((t=l.nodeBefore||l.nodeAfter)===null||t===void 0)&&t.marks.find(p=>p.type.spec.code))return!1;let u=!1;const d=Ye(l)+s;return i.forEach(p=>{if(u)return;const h=Xe(d,p.find);if(!h)return;const m=c.state.tr,f=pt({state:c.state,transaction:m}),y={from:r-(h[0].length-s.length),to:o},{commands:v,chain:S,can:M}=new ht({editor:n,state:f});p.handler({state:f,range:y,match:h,commands:v,chain:S,can:M})===null||!m.steps.length||(m.setMeta(a,{transform:m,from:r,to:o,text:s}),c.dispatch(m),u=!0)}),u}function Qe(e){const{editor:t,rules:n}=e,r=new g.Plugin({state:{init(){return null},apply(o,s,i){const a=o.getMeta(r);if(a)return a;const c=o.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:u}=c;typeof u=="string"?u=u:u=Ft(g.Fragment.from(u),i.schema);const{from:d}=c,p=d+u.length;nt({editor:t,from:d,to:p,text:u,rules:n,plugin:r})}),o.selectionSet||o.docChanged?null:s}},props:{handleTextInput(o,s,i,a){return nt({editor:t,from:s,to:i,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:o=>(setTimeout(()=>{const{$cursor:s}=o.state.selection;s&&nt({editor:t,from:s.pos,to:s.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(o,s){if(s.key!=="Enter")return!1;const{$cursor:i}=o.state.selection;return i?nt({editor:t,from:i.pos,to:i.pos,text:`
2
+ `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function Ze(e){return Object.prototype.toString.call(e).slice(8,-1)}function rt(e){return Ze(e)!=="Object"?!1:e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function gt(e,t){const n={...e};return rt(e)&&rt(t)&&Object.keys(t).forEach(r=>{rt(t[r])&&rt(e[r])?n[r]=gt(e[r],t[r]):n[r]=t[r]}),n}class N{constructor(t={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=T(w(this,"addOptions",{name:this.name}))),this.storage=T(w(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new N(t)}configure(t={}){const n=this.extend({...this.config,addOptions:()=>gt(this.options,t)});return n.name=this.name,n.parent=this.parent,n}extend(t={}){const n=new N(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=T(w(n,"addOptions",{name:n.name})),n.storage=T(w(n,"addStorage",{name:n.name,options:n.options})),n}static handleExit({editor:t,mark:n}){const{tr:r}=t.state,o=t.state.selection.$from;if(o.pos===o.end()){const i=o.marks();if(!!!i.find(l=>(l==null?void 0:l.type.name)===n.name))return!1;const c=i.find(l=>(l==null?void 0:l.type.name)===n.name);return c&&r.removeStoredMark(c),r.insertText(" ",o.pos),t.view.dispatch(r),!0}return!1}}function Se(e){return typeof e=="number"}class ke{constructor(t){this.find=t.find,this.handler=t.handler}}const tn=(e,t,n)=>{if(zt(t))return[...e.matchAll(t)];const r=t(e,n);return r?r.map(o=>{const s=[o.text];return s.index=o.index,s.input=e,s.data=o.data,o.replaceWith&&(o.text.includes(o.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(o.replaceWith)),s}):[]};function en(e){const{editor:t,state:n,from:r,to:o,rule:s,pasteEvent:i,dropEvent:a}=e,{commands:c,chain:l,can:u}=new ht({editor:t,state:n}),d=[];return n.doc.nodesBetween(r,o,(h,m)=>{if(!h.isTextblock||h.type.spec.code)return;const f=Math.max(r,m),y=Math.min(o,m+h.content.size),v=h.textBetween(f-m,y-m,void 0,"");tn(v,s.find,i).forEach(M=>{if(M.index===void 0)return;const b=f+M.index+1,E=b+M[0].length,k={from:n.tr.mapping.map(b),to:n.tr.mapping.map(E)},C=s.handler({state:n,range:k,match:M,commands:c,chain:l,can:u,pasteEvent:i,dropEvent:a});d.push(C)})}),d.every(h=>h!==null)}let ot=null;const nn=e=>{var t;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(t=n.clipboardData)===null||t===void 0||t.setData("text/html",e),n};function rn(e){const{editor:t,rules:n}=e;let r=null,o=!1,s=!1,i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}const c=({state:u,from:d,to:p,rule:h,pasteEvt:m})=>{const f=u.tr,y=pt({state:u,transaction:f});if(!(!en({editor:t,state:y,from:Math.max(d-1,0),to:p.b-1,rule:h,pasteEvent:m,dropEvent:a})||!f.steps.length)){try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,f}};return n.map(u=>new g.Plugin({view(d){const p=m=>{var f;r=!((f=d.dom.parentElement)===null||f===void 0)&&f.contains(m.target)?d.dom.parentElement:null,r&&(ot=t)},h=()=>{ot&&(ot=null)};return window.addEventListener("dragstart",p),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",p),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(d,p)=>{if(s=r===d.dom.parentElement,a=p,!s){const h=ot;h&&setTimeout(()=>{const m=h.state.selection;m&&h.commands.deleteRange({from:m.from,to:m.to})},10)}return!1},paste:(d,p)=>{var h;const m=(h=p.clipboardData)===null||h===void 0?void 0:h.getData("text/html");return i=p,o=!!(m!=null&&m.includes("data-pm-slice")),!1}}},appendTransaction:(d,p,h)=>{const m=d[0],f=m.getMeta("uiEvent")==="paste"&&!o,y=m.getMeta("uiEvent")==="drop"&&!s,v=m.getMeta("applyPasteRules"),S=!!v;if(!f&&!y&&!S)return;if(S){let{text:E}=v;typeof E=="string"?E=E:E=Ft(g.Fragment.from(E),h.schema);const{from:k}=v,C=k+E.length,L=nn(E);return c({rule:u,state:h,from:k,to:{b:C},pasteEvt:L})}const M=p.doc.content.findDiffStart(h.doc.content),b=p.doc.content.findDiffEnd(h.doc.content);if(!(!Se(M)||!b||M===b.b))return c({rule:u,state:h,from:M,to:b,pasteEvt:i})}}))}function on(e){const t=e.filter((n,r)=>e.indexOf(n)!==r);return Array.from(new Set(t))}class Y{constructor(t,n){this.splittableMarks=[],this.editor=n,this.extensions=Y.resolve(t),this.schema=Je(this.extensions,n),this.setupExtensions()}static resolve(t){const n=Y.sort(Y.flatten(t)),r=on(n.map(o=>o.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(o=>`'${o}'`).join(", ")}]. This can lead to issues.`),n}static flatten(t){return t.map(n=>{const r={name:n.name,options:n.options,storage:n.storage},o=w(n,"addExtensions",r);return o?[n,...this.flatten(o())]:n}).flat(10)}static sort(t){return t.sort((r,o)=>{const s=w(r,"priority")||100,i=w(o,"priority")||100;return s>i?-1:s<i?1:0})}get commands(){return this.extensions.reduce((t,n)=>{const r={name:n.name,options:n.options,storage:n.storage,editor:this.editor,type:Tt(n.name,this.schema)},o=w(n,"addCommands",r);return o?{...t,...o()}:t},{})}get plugins(){const{editor:t}=this,n=Y.sort([...this.extensions].reverse()),r=[],o=[],s=n.map(i=>{const a={name:i.name,options:i.options,storage:i.storage,editor:t,type:Tt(i.name,this.schema)},c=[],l=w(i,"addKeyboardShortcuts",a);let u={};if(i.type==="mark"&&w(i,"exitable",a)&&(u.ArrowRight=()=>N.handleExit({editor:t,mark:i})),l){const f=Object.fromEntries(Object.entries(l()).map(([y,v])=>[y,()=>v({editor:t})]));u={...u,...f}}const d=g.keymap(u);c.push(d);const p=w(i,"addInputRules",a);Qt(i,t.options.enableInputRules)&&p&&r.push(...p());const h=w(i,"addPasteRules",a);Qt(i,t.options.enablePasteRules)&&h&&o.push(...h());const m=w(i,"addProseMirrorPlugins",a);if(m){const f=m();c.push(...f)}return c}).flat();return[Qe({editor:t,rules:r}),...rn({editor:t,rules:o}),...s]}get attributes(){return be(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:n}=ft(this.extensions);return Object.fromEntries(n.filter(r=>!!w(r,"addNodeView")).map(r=>{const o=this.attributes.filter(c=>c.type===r.name),s={name:r.name,options:r.options,storage:r.storage,editor:t,type:_(r.name,this.schema)},i=w(r,"addNodeView",s);if(!i)return[];const a=(c,l,u,d,p)=>{const h=ct(c,o);return i()({node:c,view:l,getPos:u,decorations:d,innerDecorations:p,editor:t,extension:r,HTMLAttributes:h})};return[r.name,a]}))}setupExtensions(){this.extensions.forEach(t=>{var n;this.editor.extensionStorage[t.name]=t.storage;const r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:Tt(t.name,this.schema)};t.type==="mark"&&(!((n=T(w(t,"keepOnSplit",r)))!==null&&n!==void 0)||n)&&this.splittableMarks.push(t.name);const o=w(t,"onBeforeCreate",r),s=w(t,"onCreate",r),i=w(t,"onUpdate",r),a=w(t,"onSelectionUpdate",r),c=w(t,"onTransaction",r),l=w(t,"onFocus",r),u=w(t,"onBlur",r),d=w(t,"onDestroy",r);o&&this.editor.on("beforeCreate",o),s&&this.editor.on("create",s),i&&this.editor.on("update",i),a&&this.editor.on("selectionUpdate",a),c&&this.editor.on("transaction",c),l&&this.editor.on("focus",l),u&&this.editor.on("blur",u),d&&this.editor.on("destroy",d)})}}class H{constructor(t={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=T(w(this,"addOptions",{name:this.name}))),this.storage=T(w(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new H(t)}configure(t={}){const n=this.extend({...this.config,addOptions:()=>gt(this.options,t)});return n.name=this.name,n.parent=this.parent,n}extend(t={}){const n=new H({...this.config,...t});return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=T(w(n,"addOptions",{name:n.name})),n.storage=T(w(n,"addStorage",{name:n.name,options:n.options})),n}}function we(e,t,n){const{from:r,to:o}=t,{blockSeparator:s=`
3
3
 
4
- `,textSerializers:i={}}=n||{};let a="";return e.nodesBetween(r,o,(c,l,u,d)=>{var p;c.isBlock&&l>r&&(a+=s);const h=i==null?void 0:i[c.type.name];if(h)return u&&(a+=h({node:c,pos:l,parent:u,index:d,range:t})),!1;c.isText&&(a+=(p=c==null?void 0:c.text)===null||p===void 0?void 0:p.slice(Math.max(r,l)-l,o-l))}),a}function Te(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,t])=>t.spec.toText).map(([t,n])=>[t,n.spec.toText]))}const an=H.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new g.Plugin({key:new g.PluginKey("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:o}=t,{ranges:s}=o,i=Math.min(...s.map(u=>u.$from.pos)),a=Math.max(...s.map(u=>u.$to.pos)),c=Te(n);return Ee(r,{from:i,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),ln=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),(n=window==null?void 0:window.getSelection())===null||n===void 0||n.removeAllRanges())}),!0),cn=(e=!1)=>({commands:t})=>t.setContent("",e),dn=()=>({state:e,tr:t,dispatch:n})=>{const{selection:r}=t,{ranges:o}=r;return n&&o.forEach(({$from:s,$to:i})=>{e.doc.nodesBetween(s.pos,i.pos,(a,c)=>{if(a.type.isText)return;const{doc:l,mapping:u}=t,d=l.resolve(u.map(c)),p=l.resolve(u.map(c+a.nodeSize)),h=d.blockRange(p);if(!h)return;const m=g.liftTarget(h);if(a.type.isTextblock){const{defaultType:f}=d.parent.contentMatchAt(d.index());t.setNodeMarkup(h.start,f)}(m||m===0)&&t.lift(h,m)})}),!0},un=e=>t=>e(t),pn=()=>({state:e,dispatch:t})=>g.createParagraphNear(e,t),hn=(e,t)=>({editor:n,tr:r})=>{const{state:o}=n,s=o.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);const i=r.mapping.map(t);return r.insert(i,s.content),r.setSelection(new g.TextSelection(r.doc.resolve(i-1))),!0},fn=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;const o=e.selection.$anchor;for(let s=o.depth;s>0;s-=1)if(o.node(s).type===r.type){if(t){const a=o.before(s),c=o.after(s);e.delete(a,c).scrollIntoView()}return!0}return!1},mn=e=>({tr:t,state:n,dispatch:r})=>{const o=_(e,n.schema),s=t.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===o){if(r){const c=s.before(i),l=s.after(i);t.delete(c,l).scrollIntoView()}return!0}return!1},gn=e=>({tr:t,dispatch:n})=>{const{from:r,to:o}=e;return n&&t.delete(r,o),!0},yn=()=>({state:e,dispatch:t})=>g.deleteSelection(e,t),vn=()=>({commands:e})=>e.keyboardShortcut("Enter"),bn=()=>({state:e,dispatch:t})=>g.exitCode(e,t);function ut(e,t,n={strict:!0}){const r=Object.keys(t);return r.length?r.every(o=>n.strict?t[o]===e[o]:Vt(t[o])?t[o].test(e[o]):t[o]===e[o]):!0}function Ce(e,t,n={}){return e.find(r=>r.type===t&&ut(Object.fromEntries(Object.keys(n).map(o=>[o,r.attrs[o]])),n))}function te(e,t,n={}){return!!Ce(e,t,n)}function vt(e,t,n){var r;if(!e||!t)return;let o=e.parent.childAfter(e.parentOffset);if((!o.node||!o.node.marks.some(u=>u.type===t))&&(o=e.parent.childBefore(e.parentOffset)),!o.node||!o.node.marks.some(u=>u.type===t)||(n=n||((r=o.node.marks[0])===null||r===void 0?void 0:r.attrs),!Ce([...o.node.marks],t,n)))return;let i=o.index,a=e.start()+o.offset,c=i+1,l=a+o.node.nodeSize;for(;i>0&&te([...e.parent.child(i-1).marks],t,n);)i-=1,a-=e.parent.child(i).nodeSize;for(;c<e.parent.childCount&&te([...e.parent.child(c).marks],t,n);)l+=e.parent.child(c).nodeSize,c+=1;return{from:a,to:l}}function V(e,t){if(typeof e=="string"){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}const Mn=(e,t={})=>({tr:n,state:r,dispatch:o})=>{const s=V(e,r.schema),{doc:i,selection:a}=n,{$from:c,from:l,to:u}=a;if(o){const d=vt(c,s,t);if(d&&d.from<=l&&d.to>=u){const p=g.TextSelection.create(i,d.from,d.to);n.setSelection(p)}}return!0},Sn=e=>t=>{const n=typeof e=="function"?e(t):e;for(let r=0;r<n.length;r+=1)if(n[r](t))return!0;return!1};function Wt(e){return e instanceof g.TextSelection}function j(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function xe(e,t=null){if(!t)return null;const n=g.Selection.atStart(e),r=g.Selection.atEnd(e);if(t==="start"||t===!0)return n;if(t==="end")return r;const o=n.from,s=r.to;return t==="all"?g.TextSelection.create(e,j(0,o,s),j(e.content.size,o,s)):g.TextSelection.create(e,j(t,o,s),j(t,o,s))}function Ae(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function bt(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const kn=(e=null,t={})=>({editor:n,view:r,tr:o,dispatch:s})=>{t={scrollIntoView:!0,...t};const i=()=>{(bt()||Ae())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),t!=null&&t.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&e===null||e===!1)return!0;if(s&&e===null&&!Wt(n.state.selection))return i(),!0;const a=xe(o.doc,e)||n.state.selection,c=n.state.selection.eq(a);return s&&(c||o.setSelection(a),c&&o.storedMarks&&o.setStoredMarks(o.storedMarks),i()),!0},wn=(e,t)=>n=>e.every((r,o)=>t(r,{...n,index:o})),En=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),Oe=e=>{const t=e.childNodes;for(let n=t.length-1;n>=0;n-=1){const r=t[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):r.nodeType===1&&Oe(r)}return e};function it(e){const t=`<body>${e}</body>`,n=new window.DOMParser().parseFromString(t,"text/html").body;return Oe(n)}function pt(e,t,n){if(e instanceof g.Node||e instanceof g.Fragment)return e;n={slice:!0,parseOptions:{},...n};const r=typeof e=="object"&&e!==null,o=typeof e=="string";if(r)try{if(Array.isArray(e)&&e.length>0)return g.Fragment.fromArray(e.map(a=>t.nodeFromJSON(a)));const i=t.nodeFromJSON(e);return n.errorOnInvalidContent&&i.check(),i}catch(s){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",s),pt("",t,n)}if(o){if(n.errorOnInvalidContent){let i=!1,a="";const c=new g.Schema({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:l=>(i=!0,a=typeof l=="string"?l:l.outerHTML,null)}]}})});if(n.slice?g.DOMParser.fromSchema(c).parseSlice(it(e),n.parseOptions):g.DOMParser.fromSchema(c).parse(it(e),n.parseOptions),n.errorOnInvalidContent&&i)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const s=g.DOMParser.fromSchema(t);return n.slice?s.parseSlice(it(e),n.parseOptions).content:s.parse(it(e),n.parseOptions)}return pt("",t,n)}function Tn(e,t,n){const r=e.steps.length-1;if(r<t)return;const o=e.steps[r];if(!(o instanceof g.ReplaceStep||o instanceof g.ReplaceAroundStep))return;const s=e.mapping.maps[r];let i=0;s.forEach((a,c,l,u)=>{i===0&&(i=u)}),e.setSelection(g.Selection.near(e.doc.resolve(i),n))}const Cn=e=>!("type"in e),xn=(e,t,n)=>({tr:r,dispatch:o,editor:s})=>{var i;if(o){n={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let a;try{a=pt(t,s.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions},errorOnInvalidContent:(i=n.errorOnInvalidContent)!==null&&i!==void 0?i:s.options.enableContentCheck})}catch(m){return s.emit("contentError",{editor:s,error:m,disableCollaboration:()=>{s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}}),!1}let{from:c,to:l}=typeof e=="number"?{from:e,to:e}:{from:e.from,to:e.to},u=!0,d=!0;if((Cn(a)?a:[a]).forEach(m=>{m.check(),u=u?m.isText&&m.marks.length===0:!1,d=d?m.isBlock:!1}),c===l&&d){const{parent:m}=r.doc.resolve(c);m.isTextblock&&!m.type.spec.code&&!m.childCount&&(c-=1,l+=1)}let h;if(u){if(Array.isArray(t))h=t.map(m=>m.text||"").join("");else if(t instanceof g.Fragment){let m="";t.forEach(f=>{f.text&&(m+=f.text)}),h=m}else typeof t=="object"&&t&&t.text?h=t.text:h=t;r.insertText(h,c,l)}else h=a,r.replaceWith(c,l,h);n.updateSelection&&Tn(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:c,text:h}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:c,text:h})}return!0},An=()=>({state:e,dispatch:t})=>g.joinUp(e,t),On=()=>({state:e,dispatch:t})=>g.joinDown(e,t),Ln=()=>({state:e,dispatch:t})=>g.joinBackward(e,t),Pn=()=>({state:e,dispatch:t})=>g.joinForward(e,t),Rn=()=>({state:e,dispatch:t,tr:n})=>{try{const r=g.joinPoint(e.doc,e.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},Hn=()=>({state:e,dispatch:t,tr:n})=>{try{const r=g.joinPoint(e.doc,e.selection.$from.pos,1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},_n=()=>({state:e,dispatch:t})=>g.joinTextblockBackward(e,t),Dn=()=>({state:e,dispatch:t})=>g.joinTextblockForward(e,t);function Le(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Nn(e){const t=e.split(/-(?!$)/);let n=t[t.length-1];n==="Space"&&(n=" ");let r,o,s,i;for(let a=0;a<t.length-1;a+=1){const c=t[a];if(/^(cmd|meta|m)$/i.test(c))i=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))o=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))bt()||Le()?i=!0:o=!0;else throw new Error(`Unrecognized modifier name: ${c}`)}return r&&(n=`Alt-${n}`),o&&(n=`Ctrl-${n}`),i&&(n=`Meta-${n}`),s&&(n=`Shift-${n}`),n}const In=e=>({editor:t,view:n,tr:r,dispatch:o})=>{const s=Nn(e).split(/-(?!$)/),i=s.find(l=>!["Alt","Ctrl","Meta","Shift"].includes(l)),a=new KeyboardEvent("keydown",{key:i==="Space"?" ":i,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),c=t.captureTransaction(()=>{n.someProp("handleKeyDown",l=>l(n,a))});return c==null||c.steps.forEach(l=>{const u=l.map(r.mapping);u&&o&&r.maybeStep(u)}),!0};function tt(e,t,n={}){const{from:r,to:o,empty:s}=e.selection,i=t?_(t,e.schema):null,a=[];e.doc.nodesBetween(r,o,(d,p)=>{if(d.isText)return;const h=Math.max(r,p),m=Math.min(o,p+d.nodeSize);a.push({node:d,from:h,to:m})});const c=o-r,l=a.filter(d=>i?i.name===d.node.type.name:!0).filter(d=>ut(d.node.attrs,n,{strict:!1}));return s?!!l.length:l.reduce((d,p)=>d+p.to-p.from,0)>=c}const $n=(e,t={})=>({state:n,dispatch:r})=>{const o=_(e,n.schema);return tt(n,o,t)?g.lift(n,r):!1},Bn=()=>({state:e,dispatch:t})=>g.liftEmptyBlock(e,t),jn=e=>({state:t,dispatch:n})=>{const r=_(e,t.schema);return g.liftListItem(r)(t,n)},Fn=()=>({state:e,dispatch:t})=>g.newlineInCode(e,t);function Mt(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function ee(e,t){const n=typeof t=="string"?[t]:t;return Object.keys(e).reduce((r,o)=>(n.includes(o)||(r[o]=e[o]),r),{})}const zn=(e,t)=>({tr:n,state:r,dispatch:o})=>{let s=null,i=null;const a=Mt(typeof e=="string"?e:e.name,r.schema);return a?(a==="node"&&(s=_(e,r.schema)),a==="mark"&&(i=V(e,r.schema)),o&&n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(l,u)=>{s&&s===l.type&&n.setNodeMarkup(u,void 0,ee(l.attrs,t)),i&&l.marks.length&&l.marks.forEach(d=>{i===d.type&&n.addMark(u,u+l.nodeSize,i.create(ee(d.attrs,t)))})})}),!0):!1},Vn=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),Wn=()=>({tr:e,dispatch:t})=>{if(t){const n=new g.AllSelection(e.doc);e.setSelection(n)}return!0},Kn=()=>({state:e,dispatch:t})=>g.selectNodeBackward(e,t),Un=()=>({state:e,dispatch:t})=>g.selectNodeForward(e,t),qn=()=>({state:e,dispatch:t})=>g.selectParentNode(e,t),Gn=()=>({state:e,dispatch:t})=>g.selectTextblockEnd(e,t),Jn=()=>({state:e,dispatch:t})=>g.selectTextblockStart(e,t);function _t(e,t,n={},r={}){return pt(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}const Yn=(e,t=!1,n={},r={})=>({editor:o,tr:s,dispatch:i,commands:a})=>{var c,l;const{doc:u}=s;if(n.preserveWhitespace!=="full"){const d=_t(e,o.schema,n,{errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:o.options.enableContentCheck});return i&&s.replaceWith(0,u.content.size,d).setMeta("preventUpdate",!t),!0}return i&&s.setMeta("preventUpdate",!t),a.insertContentAt({from:0,to:u.content.size},e,{parseOptions:n,errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:o.options.enableContentCheck})};function Pe(e,t){const n=V(t,e.schema),{from:r,to:o,empty:s}=e.selection,i=[];s?(e.storedMarks&&i.push(...e.storedMarks),i.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,o,c=>{i.push(...c.marks)});const a=i.find(c=>c.type.name===n.name);return a?{...a.attrs}:{}}function Xn(e,t){const n=new g.Transform(e);return t.forEach(r=>{r.steps.forEach(o=>{n.step(o)})}),n}function Qn(e){for(let t=0;t<e.edgeCount;t+=1){const{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Zn(e,t){const n=[];return e.descendants((r,o)=>{t(r)&&n.push({node:r,pos:o})}),n}function tr(e,t,n){const r=[];return e.nodesBetween(t.from,t.to,(o,s)=>{n(o)&&r.push({node:o,pos:s})}),r}function Re(e,t){for(let n=e.depth;n>0;n-=1){const r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function St(e){return t=>Re(t.$from,e)}function er(e,t){const n={from:0,to:e.content.size};return Ee(e,n,t)}function nr(e,t){const n=_(t,e.schema),{from:r,to:o}=e.selection,s=[];e.doc.nodesBetween(r,o,a=>{s.push(a)});const i=s.reverse().find(a=>a.type.name===n.name);return i?{...i.attrs}:{}}function He(e,t){const n=Mt(typeof t=="string"?t:t.name,e.schema);return n==="node"?nr(e,t):n==="mark"?Pe(e,t):{}}function rr(e,t=JSON.stringify){const n={};return e.filter(r=>{const o=t(r);return Object.prototype.hasOwnProperty.call(n,o)?!1:n[o]=!0})}function or(e){const t=rr(e);return t.length===1?t:t.filter((n,r)=>!t.filter((s,i)=>i!==r).some(s=>n.oldRange.from>=s.oldRange.from&&n.oldRange.to<=s.oldRange.to&&n.newRange.from>=s.newRange.from&&n.newRange.to<=s.newRange.to))}function sr(e){const{mapping:t,steps:n}=e,r=[];return t.maps.forEach((o,s)=>{const i=[];if(o.ranges.length)o.forEach((a,c)=>{i.push({from:a,to:c})});else{const{from:a,to:c}=n[s];if(a===void 0||c===void 0)return;i.push({from:a,to:c})}i.forEach(({from:a,to:c})=>{const l=t.slice(s).map(a,-1),u=t.slice(s).map(c),d=t.invert().map(l,-1),p=t.invert().map(u);r.push({oldRange:{from:d,to:p},newRange:{from:l,to:u}})})}),or(r)}function Kt(e,t,n){const r=[];return e===t?n.resolve(e).marks().forEach(o=>{const s=n.resolve(e),i=vt(s,o.type);i&&r.push({mark:o,...i})}):n.nodesBetween(e,t,(o,s)=>{!o||(o==null?void 0:o.nodeSize)===void 0||r.push(...o.marks.map(i=>({from:s,to:s+o.nodeSize,mark:i})))}),r}function ct(e,t,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const o=e.find(s=>s.type===t&&s.name===r);return o?o.attribute.keepOnSplit:!1}))}function Dt(e,t,n={}){const{empty:r,ranges:o}=e.selection,s=t?V(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(d=>s?s.name===d.type.name:!0).find(d=>ut(d.attrs,n,{strict:!1}));let i=0;const a=[];if(o.forEach(({$from:d,$to:p})=>{const h=d.pos,m=p.pos;e.doc.nodesBetween(h,m,(f,y)=>{if(!f.isText&&!f.marks.length)return;const v=Math.max(h,y),S=Math.min(m,y+f.nodeSize),M=S-v;i+=M,a.push(...f.marks.map(b=>({mark:b,from:v,to:S})))})}),i===0)return!1;const c=a.filter(d=>s?s.name===d.mark.type.name:!0).filter(d=>ut(d.mark.attrs,n,{strict:!1})).reduce((d,p)=>d+p.to-p.from,0),l=a.filter(d=>s?d.mark.type!==s&&d.mark.type.excludes(s):!0).reduce((d,p)=>d+p.to-p.from,0);return(c>0?c+l:c)>=i}function _e(e,t,n={}){if(!t)return tt(e,null,n)||Dt(e,null,n);const r=Mt(t,e.schema);return r==="node"?tt(e,t,n):r==="mark"?Dt(e,t,n):!1}function Nt(e,t){const{nodeExtensions:n}=mt(t),r=n.find(i=>i.name===e);if(!r)return!1;const o={name:r.name,options:r.options,storage:r.storage},s=T(w(r,"group",o));return typeof s!="string"?!1:s.split(" ").includes("list")}function kt(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(e.type.name==="hardBreak")return!0;if(e.isText)return/^\s*$/m.test((r=e.text)!==null&&r!==void 0?r:"")}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let o=!0;return e.content.forEach(s=>{o!==!1&&(kt(s,{ignoreWhitespace:n,checkChildren:t})||(o=!1))}),o}return!1}function De(e){return e instanceof g.NodeSelection}function ir(e,t,n){const o=e.state.doc.content.size,s=j(t,0,o),i=j(n,0,o),a=e.coordsAtPos(s),c=e.coordsAtPos(i,-1),l=Math.min(a.top,c.top),u=Math.max(a.bottom,c.bottom),d=Math.min(a.left,c.left),p=Math.max(a.right,c.right),h=p-d,m=u-l,v={top:l,bottom:u,left:d,right:p,width:h,height:m,x:d,y:l};return{...v,toJSON:()=>v}}function ar(e,t,n){var r;const{selection:o}=t;let s=null;if(Wt(o)&&(s=o.$cursor),s){const a=(r=e.storedMarks)!==null&&r!==void 0?r:s.marks();return!!n.isInSet(a)||!a.some(c=>c.type.excludes(n))}const{ranges:i}=o;return i.some(({$from:a,$to:c})=>{let l=a.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(n):!1;return e.doc.nodesBetween(a.pos,c.pos,(u,d,p)=>{if(l)return!1;if(u.isInline){const h=!p||p.type.allowsMarkType(n),m=!!n.isInSet(u.marks)||!u.marks.some(f=>f.type.excludes(n));l=h&&m}return!l}),l})}const lr=(e,t={})=>({tr:n,state:r,dispatch:o})=>{const{selection:s}=n,{empty:i,ranges:a}=s,c=V(e,r.schema);if(o)if(i){const l=Pe(r,c);n.addStoredMark(c.create({...l,...t}))}else a.forEach(l=>{const u=l.$from.pos,d=l.$to.pos;r.doc.nodesBetween(u,d,(p,h)=>{const m=Math.max(h,u),f=Math.min(h+p.nodeSize,d);p.marks.find(v=>v.type===c)?p.marks.forEach(v=>{c===v.type&&n.addMark(m,f,c.create({...v.attrs,...t}))}):n.addMark(m,f,c.create(t))})});return ar(r,n,c)},cr=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),dr=(e,t={})=>({state:n,dispatch:r,chain:o})=>{const s=_(e,n.schema);let i;return n.selection.$anchor.sameParent(n.selection.$head)&&(i=n.selection.$anchor.parent.attrs),s.isTextblock?o().command(({commands:a})=>g.setBlockType(s,{...i,...t})(n)?!0:a.clearNodes()).command(({state:a})=>g.setBlockType(s,{...i,...t})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},ur=e=>({tr:t,dispatch:n})=>{if(n){const{doc:r}=t,o=j(e,0,r.content.size),s=g.NodeSelection.create(r,o);t.setSelection(s)}return!0},pr=e=>({tr:t,dispatch:n})=>{if(n){const{doc:r}=t,{from:o,to:s}=typeof e=="number"?{from:e,to:e}:e,i=g.TextSelection.atStart(r).from,a=g.TextSelection.atEnd(r).to,c=j(o,i,a),l=j(s,i,a),u=g.TextSelection.create(r,c,l);t.setSelection(u)}return!0},hr=e=>({state:t,dispatch:n})=>{const r=_(e,t.schema);return g.sinkListItem(r)(t,n)};function ne(e,t){const n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){const r=n.filter(o=>t==null?void 0:t.includes(o.type.name));e.tr.ensureMarks(r)}}const fr=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:o})=>{const{selection:s,doc:i}=t,{$from:a,$to:c}=s,l=o.extensionManager.attributes,u=ct(l,a.node().type.name,a.node().attrs);if(s instanceof g.NodeSelection&&s.node.isBlock)return!a.parentOffset||!g.canSplit(i,a.pos)?!1:(r&&(e&&ne(n,o.extensionManager.splittableMarks),t.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const d=c.parentOffset===c.parent.content.size,p=a.depth===0?void 0:Qn(a.node(-1).contentMatchAt(a.indexAfter(-1)));let h=d&&p?[{type:p,attrs:u}]:void 0,m=g.canSplit(t.doc,t.mapping.map(a.pos),1,h);if(!h&&!m&&g.canSplit(t.doc,t.mapping.map(a.pos),1,p?[{type:p}]:void 0)&&(m=!0,h=p?[{type:p,attrs:u}]:void 0),r){if(m&&(s instanceof g.TextSelection&&t.deleteSelection(),t.split(t.mapping.map(a.pos),1,h),p&&!d&&!a.parentOffset&&a.parent.type!==p)){const f=t.mapping.map(a.before()),y=t.doc.resolve(f);a.node(-1).canReplaceWith(y.index(),y.index()+1,p)&&t.setNodeMarkup(t.mapping.map(a.before()),p)}e&&ne(n,o.extensionManager.splittableMarks),t.scrollIntoView()}return m},mr=(e,t={})=>({tr:n,state:r,dispatch:o,editor:s})=>{var i;const a=_(e,r.schema),{$from:c,$to:l}=r.selection,u=r.selection.node;if(u&&u.isBlock||c.depth<2||!c.sameParent(l))return!1;const d=c.node(-1);if(d.type!==a)return!1;const p=s.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==a||c.index(-2)!==c.node(-2).childCount-1)return!1;if(o){let v=g.Fragment.empty;const S=c.index(-1)?1:c.index(-2)?2:3;for(let L=c.depth-S;L>=c.depth-3;L-=1)v=g.Fragment.from(c.node(L).copy(v));const M=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,b={...ct(p,c.node().type.name,c.node().attrs),...t},E=((i=a.contentMatch.defaultType)===null||i===void 0?void 0:i.createAndFill(b))||void 0;v=v.append(g.Fragment.from(a.createAndFill(null,E)||void 0));const k=c.before(c.depth-(S-1));n.replace(k,c.after(-M),new g.Slice(v,4-S,0));let C=-1;n.doc.nodesBetween(k,n.doc.content.size,(L,P)=>{if(C>-1)return!1;L.isTextblock&&L.content.size===0&&(C=P+1)}),C>-1&&n.setSelection(g.TextSelection.near(n.doc.resolve(C))),n.scrollIntoView()}return!0}const h=l.pos===c.end()?d.contentMatchAt(0).defaultType:null,m={...ct(p,d.type.name,d.attrs),...t},f={...ct(p,c.node().type.name,c.node().attrs),...t};n.delete(c.pos,l.pos);const y=h?[{type:a,attrs:m},{type:h,attrs:f}]:[{type:a,attrs:m}];if(!g.canSplit(n.doc,c.pos,2))return!1;if(o){const{selection:v,storedMarks:S}=r,{splittableMarks:M}=s.extensionManager,b=S||v.$to.parentOffset&&v.$from.marks();if(n.split(c.pos,2,y).scrollIntoView(),!b||!o)return!0;const E=b.filter(k=>M.includes(k.type.name));n.ensureMarks(E)}return!0},xt=(e,t)=>{const n=St(i=>i.type===t)(e.selection);if(!n)return!0;const r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const o=e.doc.nodeAt(r);return n.node.type===(o==null?void 0:o.type)&&g.canJoin(e.doc,n.pos)&&e.join(n.pos),!0},At=(e,t)=>{const n=St(i=>i.type===t)(e.selection);if(!n)return!0;const r=e.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const o=e.doc.nodeAt(r);return n.node.type===(o==null?void 0:o.type)&&g.canJoin(e.doc,r)&&e.join(r),!0},gr=(e,t,n,r={})=>({editor:o,tr:s,state:i,dispatch:a,chain:c,commands:l,can:u})=>{const{extensions:d,splittableMarks:p}=o.extensionManager,h=_(e,i.schema),m=_(t,i.schema),{selection:f,storedMarks:y}=i,{$from:v,$to:S}=f,M=v.blockRange(S),b=y||f.$to.parentOffset&&f.$from.marks();if(!M)return!1;const E=St(k=>Nt(k.type.name,d))(f);if(M.depth>=1&&E&&M.depth-E.depth<=1){if(E.node.type===h)return l.liftListItem(m);if(Nt(E.node.type.name,d)&&h.validContent(E.node.content)&&a)return c().command(()=>(s.setNodeMarkup(E.pos,h),!0)).command(()=>xt(s,h)).command(()=>At(s,h)).run()}return!n||!b||!a?c().command(()=>u().wrapInList(h,r)?!0:l.clearNodes()).wrapInList(h,r).command(()=>xt(s,h)).command(()=>At(s,h)).run():c().command(()=>{const k=u().wrapInList(h,r),C=b.filter(L=>p.includes(L.type.name));return s.ensureMarks(C),k?!0:l.clearNodes()}).wrapInList(h,r).command(()=>xt(s,h)).command(()=>At(s,h)).run()},yr=(e,t={},n={})=>({state:r,commands:o})=>{const{extendEmptyMarkRange:s=!1}=n,i=V(e,r.schema);return Dt(r,i,t)?o.unsetMark(i,{extendEmptyMarkRange:s}):o.setMark(i,t)},vr=(e,t,n={})=>({state:r,commands:o})=>{const s=_(e,r.schema),i=_(t,r.schema),a=tt(r,s,n);let c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),a?o.setNode(i,c):o.setNode(s,{...c,...n})},br=(e,t={})=>({state:n,commands:r})=>{const o=_(e,n.schema);return tt(n,o,t)?r.lift(o):r.wrapIn(o,t)},Mr=()=>({state:e,dispatch:t})=>{const n=e.plugins;for(let r=0;r<n.length;r+=1){const o=n[r];let s;if(o.spec.isInputRules&&(s=o.getState(e))){if(t){const i=e.tr,a=s.transform;for(let c=a.steps.length-1;c>=0;c-=1)i.step(a.steps[c].invert(a.docs[c]));if(s.text){const c=i.doc.resolve(s.from).marks();i.replaceWith(s.from,s.to,e.schema.text(s.text,c))}else i.delete(s.from,s.to)}return!0}}return!1},Sr=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,{empty:r,ranges:o}=n;return r||t&&o.forEach(s=>{e.removeMark(s.$from.pos,s.$to.pos)}),!0},kr=(e,t={})=>({tr:n,state:r,dispatch:o})=>{var s;const{extendEmptyMarkRange:i=!1}=t,{selection:a}=n,c=V(e,r.schema),{$from:l,empty:u,ranges:d}=a;if(!o)return!0;if(u&&i){let{from:p,to:h}=a;const m=(s=l.marks().find(y=>y.type===c))===null||s===void 0?void 0:s.attrs,f=vt(l,c,m);f&&(p=f.from,h=f.to),n.removeMark(p,h,c)}else d.forEach(p=>{n.removeMark(p.$from.pos,p.$to.pos,c)});return n.removeStoredMark(c),!0},wr=(e,t={})=>({tr:n,state:r,dispatch:o})=>{let s=null,i=null;const a=Mt(typeof e=="string"?e:e.name,r.schema);return a?(a==="node"&&(s=_(e,r.schema)),a==="mark"&&(i=V(e,r.schema)),o&&n.selection.ranges.forEach(c=>{const l=c.$from.pos,u=c.$to.pos;let d,p,h,m;n.selection.empty?r.doc.nodesBetween(l,u,(f,y)=>{s&&s===f.type&&(h=Math.max(y,l),m=Math.min(y+f.nodeSize,u),d=y,p=f)}):r.doc.nodesBetween(l,u,(f,y)=>{y<l&&s&&s===f.type&&(h=Math.max(y,l),m=Math.min(y+f.nodeSize,u),d=y,p=f),y>=l&&y<=u&&(s&&s===f.type&&n.setNodeMarkup(y,void 0,{...f.attrs,...t}),i&&f.marks.length&&f.marks.forEach(v=>{if(i===v.type){const S=Math.max(y,l),M=Math.min(y+f.nodeSize,u);n.addMark(S,M,i.create({...v.attrs,...t}))}}))}),p&&(d!==void 0&&n.setNodeMarkup(d,void 0,{...p.attrs,...t}),i&&p.marks.length&&p.marks.forEach(f=>{i===f.type&&n.addMark(h,m,i.create({...f.attrs,...t}))}))}),!0):!1},Er=(e,t={})=>({state:n,dispatch:r})=>{const o=_(e,n.schema);return g.wrapIn(o,t)(n,r)},Tr=(e,t={})=>({state:n,dispatch:r})=>{const o=_(e,n.schema);return g.wrapInList(o,t)(n,r)};var Cr=Object.freeze({__proto__:null,blur:ln,clearContent:cn,clearNodes:dn,command:un,createParagraphNear:pn,cut:hn,deleteCurrentNode:fn,deleteNode:mn,deleteRange:gn,deleteSelection:yn,enter:vn,exitCode:bn,extendMarkRange:Mn,first:Sn,focus:kn,forEach:wn,insertContent:En,insertContentAt:xn,joinBackward:Ln,joinDown:On,joinForward:Pn,joinItemBackward:Rn,joinItemForward:Hn,joinTextblockBackward:_n,joinTextblockForward:Dn,joinUp:An,keyboardShortcut:In,lift:$n,liftEmptyBlock:Bn,liftListItem:jn,newlineInCode:Fn,resetAttributes:zn,scrollIntoView:Vn,selectAll:Wn,selectNodeBackward:Kn,selectNodeForward:Un,selectParentNode:qn,selectTextblockEnd:Gn,selectTextblockStart:Jn,setContent:Yn,setMark:lr,setMeta:cr,setNode:dr,setNodeSelection:ur,setTextSelection:pr,sinkListItem:hr,splitBlock:fr,splitListItem:mr,toggleList:gr,toggleMark:yr,toggleNode:vr,toggleWrap:br,undoInputRule:Mr,unsetAllMarks:Sr,unsetMark:kr,updateAttributes:wr,wrapIn:Er,wrapInList:Tr});const xr=H.create({name:"commands",addCommands(){return{...Cr}}}),Ar=H.create({name:"drop",addProseMirrorPlugins(){return[new g.Plugin({key:new g.PluginKey("tiptapDrop"),props:{handleDrop:(e,t,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),Or=H.create({name:"editable",addProseMirrorPlugins(){return[new g.Plugin({key:new g.PluginKey("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Lr=H.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;return[new g.Plugin({key:new g.PluginKey("focusEvents"),props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;const r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;const r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),Pr=H.create({name:"keymap",addKeyboardShortcuts(){const e=()=>this.editor.commands.first(({commands:i})=>[()=>i.undoInputRule(),()=>i.command(({tr:a})=>{const{selection:c,doc:l}=a,{empty:u,$anchor:d}=c,{pos:p,parent:h}=d,m=d.parent.isTextblock&&p>0?a.doc.resolve(p-1):d,f=m.parent.type.spec.isolating,y=d.pos-d.parentOffset,v=f&&m.parent.childCount===1?y===d.pos:g.Selection.atStart(l).from===p;return!u||!h.type.isTextblock||h.textContent.length||!v||v&&d.parent.type.name==="paragraph"?!1:i.clearNodes()}),()=>i.deleteSelection(),()=>i.joinBackward(),()=>i.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:i})=>[()=>i.deleteSelection(),()=>i.deleteCurrentNode(),()=>i.joinForward(),()=>i.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:i})=>[()=>i.newlineInCode(),()=>i.createParagraphNear(),()=>i.liftEmptyBlock(),()=>i.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},o={...r},s={...r,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return bt()||Le()?s:o},addProseMirrorPlugins(){return[new g.Plugin({key:new g.PluginKey("clearDocument"),appendTransaction:(e,t,n)=>{if(e.some(f=>f.getMeta("composition")))return;const r=e.some(f=>f.docChanged)&&!t.doc.eq(n.doc),o=e.some(f=>f.getMeta("preventClearDocument"));if(!r||o)return;const{empty:s,from:i,to:a}=t.selection,c=g.Selection.atStart(t.doc).from,l=g.Selection.atEnd(t.doc).to;if(s||!(i===c&&a===l)||!kt(n.doc))return;const p=n.tr,h=ht({state:n,transaction:p}),{commands:m}=new ft({editor:this.editor,state:h});if(m.clearNodes(),!!p.steps.length)return p}})]}}),Rr=H.create({name:"paste",addProseMirrorPlugins(){return[new g.Plugin({key:new g.PluginKey("tiptapPaste"),props:{handlePaste:(e,t,n)=>{this.editor.emit("paste",{editor:this.editor,event:t,slice:n})}}})]}}),Hr=H.create({name:"tabindex",addProseMirrorPlugins(){return[new g.Plugin({key:new g.PluginKey("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class K{get name(){return this.node.type.name}constructor(t,n,r=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=t,this.editor=n,this.currentNode=o}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var t;return(t=this.actualDepth)!==null&&t!==void 0?t:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(t){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},t)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const t=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(t);return new K(n,this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new K(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new K(t,this.editor)}get children(){const t=[];return this.node.content.forEach((n,r)=>{const o=n.isBlock&&!n.isTextblock,s=n.isAtom&&!n.isText,i=this.pos+r+(s?0:1),a=this.resolvedPos.doc.resolve(i);if(!o&&a.depth<=this.depth)return;const c=new K(a,this.editor,o,o?n:null);o&&(c.actualDepth=this.depth+1),t.push(new K(a,this.editor,o,o?n:null))}),t}get firstChild(){return this.children[0]||null}get lastChild(){const t=this.children;return t[t.length-1]||null}closest(t,n={}){let r=null,o=this.parent;for(;o&&!r;){if(o.node.type.name===t)if(Object.keys(n).length>0){const s=o.node.attrs,i=Object.keys(n);for(let a=0;a<i.length;a+=1){const c=i[a];if(s[c]!==n[c])break}}else r=o;o=o.parent}return r}querySelector(t,n={}){return this.querySelectorAll(t,n,!0)[0]||null}querySelectorAll(t,n={},r=!1){let o=[];if(!this.children||this.children.length===0)return o;const s=Object.keys(n);return this.children.forEach(i=>{r&&o.length>0||(i.node.type.name===t&&s.every(c=>n[c]===i.node.attrs[c])&&o.push(i),!(r&&o.length>0)&&(o=o.concat(i.querySelectorAll(t,n,r))))}),o}setAttribute(t){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...t}),this.editor.view.dispatch(n)}}const _r=`.ProseMirror {
4
+ `,textSerializers:i={}}=n||{};let a="";return e.nodesBetween(r,o,(c,l,u,d)=>{var p;c.isBlock&&l>r&&(a+=s);const h=i==null?void 0:i[c.type.name];if(h)return u&&(a+=h({node:c,pos:l,parent:u,index:d,range:t})),!1;c.isText&&(a+=(p=c==null?void 0:c.text)===null||p===void 0?void 0:p.slice(Math.max(r,l)-l,o-l))}),a}function Ee(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,t])=>t.spec.toText).map(([t,n])=>[t,n.spec.toText]))}const sn=H.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new g.Plugin({key:new g.PluginKey("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:o}=t,{ranges:s}=o,i=Math.min(...s.map(u=>u.$from.pos)),a=Math.max(...s.map(u=>u.$to.pos)),c=Ee(n);return we(r,{from:i,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),an=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),(n=window==null?void 0:window.getSelection())===null||n===void 0||n.removeAllRanges())}),!0),ln=(e=!1)=>({commands:t})=>t.setContent("",e),cn=()=>({state:e,tr:t,dispatch:n})=>{const{selection:r}=t,{ranges:o}=r;return n&&o.forEach(({$from:s,$to:i})=>{e.doc.nodesBetween(s.pos,i.pos,(a,c)=>{if(a.type.isText)return;const{doc:l,mapping:u}=t,d=l.resolve(u.map(c)),p=l.resolve(u.map(c+a.nodeSize)),h=d.blockRange(p);if(!h)return;const m=g.liftTarget(h);if(a.type.isTextblock){const{defaultType:f}=d.parent.contentMatchAt(d.index());t.setNodeMarkup(h.start,f)}(m||m===0)&&t.lift(h,m)})}),!0},dn=e=>t=>e(t),un=()=>({state:e,dispatch:t})=>g.createParagraphNear(e,t),pn=(e,t)=>({editor:n,tr:r})=>{const{state:o}=n,s=o.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);const i=r.mapping.map(t);return r.insert(i,s.content),r.setSelection(new g.TextSelection(r.doc.resolve(i-1))),!0},hn=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;const o=e.selection.$anchor;for(let s=o.depth;s>0;s-=1)if(o.node(s).type===r.type){if(t){const a=o.before(s),c=o.after(s);e.delete(a,c).scrollIntoView()}return!0}return!1},fn=e=>({tr:t,state:n,dispatch:r})=>{const o=_(e,n.schema),s=t.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===o){if(r){const c=s.before(i),l=s.after(i);t.delete(c,l).scrollIntoView()}return!0}return!1},mn=e=>({tr:t,dispatch:n})=>{const{from:r,to:o}=e;return n&&t.delete(r,o),!0},gn=()=>({state:e,dispatch:t})=>g.deleteSelection(e,t),yn=()=>({commands:e})=>e.keyboardShortcut("Enter"),vn=()=>({state:e,dispatch:t})=>g.exitCode(e,t);function dt(e,t,n={strict:!0}){const r=Object.keys(t);return r.length?r.every(o=>n.strict?t[o]===e[o]:zt(t[o])?t[o].test(e[o]):t[o]===e[o]):!0}function Te(e,t,n={}){return e.find(r=>r.type===t&&dt(Object.fromEntries(Object.keys(n).map(o=>[o,r.attrs[o]])),n))}function Zt(e,t,n={}){return!!Te(e,t,n)}function yt(e,t,n){var r;if(!e||!t)return;let o=e.parent.childAfter(e.parentOffset);if((!o.node||!o.node.marks.some(u=>u.type===t))&&(o=e.parent.childBefore(e.parentOffset)),!o.node||!o.node.marks.some(u=>u.type===t)||(n=n||((r=o.node.marks[0])===null||r===void 0?void 0:r.attrs),!Te([...o.node.marks],t,n)))return;let i=o.index,a=e.start()+o.offset,c=i+1,l=a+o.node.nodeSize;for(;i>0&&Zt([...e.parent.child(i-1).marks],t,n);)i-=1,a-=e.parent.child(i).nodeSize;for(;c<e.parent.childCount&&Zt([...e.parent.child(c).marks],t,n);)l+=e.parent.child(c).nodeSize,c+=1;return{from:a,to:l}}function V(e,t){if(typeof e=="string"){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}const bn=(e,t={})=>({tr:n,state:r,dispatch:o})=>{const s=V(e,r.schema),{doc:i,selection:a}=n,{$from:c,from:l,to:u}=a;if(o){const d=yt(c,s,t);if(d&&d.from<=l&&d.to>=u){const p=g.TextSelection.create(i,d.from,d.to);n.setSelection(p)}}return!0},Mn=e=>t=>{const n=typeof e=="function"?e(t):e;for(let r=0;r<n.length;r+=1)if(n[r](t))return!0;return!1};function Vt(e){return e instanceof g.TextSelection}function j(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function Ce(e,t=null){if(!t)return null;const n=g.Selection.atStart(e),r=g.Selection.atEnd(e);if(t==="start"||t===!0)return n;if(t==="end")return r;const o=n.from,s=r.to;return t==="all"?g.TextSelection.create(e,j(0,o,s),j(e.content.size,o,s)):g.TextSelection.create(e,j(t,o,s),j(t,o,s))}function xe(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function vt(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const Sn=(e=null,t={})=>({editor:n,view:r,tr:o,dispatch:s})=>{t={scrollIntoView:!0,...t};const i=()=>{(vt()||xe())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),t!=null&&t.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&e===null||e===!1)return!0;if(s&&e===null&&!Vt(n.state.selection))return i(),!0;const a=Ce(o.doc,e)||n.state.selection,c=n.state.selection.eq(a);return s&&(c||o.setSelection(a),c&&o.storedMarks&&o.setStoredMarks(o.storedMarks),i()),!0},kn=(e,t)=>n=>e.every((r,o)=>t(r,{...n,index:o})),wn=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),Ae=e=>{const t=e.childNodes;for(let n=t.length-1;n>=0;n-=1){const r=t[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):r.nodeType===1&&Ae(r)}return e};function st(e){const t=`<body>${e}</body>`,n=new window.DOMParser().parseFromString(t,"text/html").body;return Ae(n)}function ut(e,t,n){if(e instanceof g.Node||e instanceof g.Fragment)return e;n={slice:!0,parseOptions:{},...n};const r=typeof e=="object"&&e!==null,o=typeof e=="string";if(r)try{if(Array.isArray(e)&&e.length>0)return g.Fragment.fromArray(e.map(a=>t.nodeFromJSON(a)));const i=t.nodeFromJSON(e);return n.errorOnInvalidContent&&i.check(),i}catch(s){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",s),ut("",t,n)}if(o){if(n.errorOnInvalidContent){let i=!1,a="";const c=new g.Schema({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:l=>(i=!0,a=typeof l=="string"?l:l.outerHTML,null)}]}})});if(n.slice?g.DOMParser.fromSchema(c).parseSlice(st(e),n.parseOptions):g.DOMParser.fromSchema(c).parse(st(e),n.parseOptions),n.errorOnInvalidContent&&i)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const s=g.DOMParser.fromSchema(t);return n.slice?s.parseSlice(st(e),n.parseOptions).content:s.parse(st(e),n.parseOptions)}return ut("",t,n)}function En(e,t,n){const r=e.steps.length-1;if(r<t)return;const o=e.steps[r];if(!(o instanceof g.ReplaceStep||o instanceof g.ReplaceAroundStep))return;const s=e.mapping.maps[r];let i=0;s.forEach((a,c,l,u)=>{i===0&&(i=u)}),e.setSelection(g.Selection.near(e.doc.resolve(i),n))}const Tn=e=>!("type"in e),Cn=(e,t,n)=>({tr:r,dispatch:o,editor:s})=>{var i;if(o){n={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let a;try{a=ut(t,s.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions},errorOnInvalidContent:(i=n.errorOnInvalidContent)!==null&&i!==void 0?i:s.options.enableContentCheck})}catch(m){return s.emit("contentError",{editor:s,error:m,disableCollaboration:()=>{s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}}),!1}let{from:c,to:l}=typeof e=="number"?{from:e,to:e}:{from:e.from,to:e.to},u=!0,d=!0;if((Tn(a)?a:[a]).forEach(m=>{m.check(),u=u?m.isText&&m.marks.length===0:!1,d=d?m.isBlock:!1}),c===l&&d){const{parent:m}=r.doc.resolve(c);m.isTextblock&&!m.type.spec.code&&!m.childCount&&(c-=1,l+=1)}let h;if(u){if(Array.isArray(t))h=t.map(m=>m.text||"").join("");else if(t instanceof g.Fragment){let m="";t.forEach(f=>{f.text&&(m+=f.text)}),h=m}else typeof t=="object"&&t&&t.text?h=t.text:h=t;r.insertText(h,c,l)}else h=a,r.replaceWith(c,l,h);n.updateSelection&&En(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:c,text:h}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:c,text:h})}return!0},xn=()=>({state:e,dispatch:t})=>g.joinUp(e,t),An=()=>({state:e,dispatch:t})=>g.joinDown(e,t),On=()=>({state:e,dispatch:t})=>g.joinBackward(e,t),Ln=()=>({state:e,dispatch:t})=>g.joinForward(e,t),Pn=()=>({state:e,dispatch:t,tr:n})=>{try{const r=g.joinPoint(e.doc,e.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},Rn=()=>({state:e,dispatch:t,tr:n})=>{try{const r=g.joinPoint(e.doc,e.selection.$from.pos,1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},Hn=()=>({state:e,dispatch:t})=>g.joinTextblockBackward(e,t),_n=()=>({state:e,dispatch:t})=>g.joinTextblockForward(e,t);function Oe(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Dn(e){const t=e.split(/-(?!$)/);let n=t[t.length-1];n==="Space"&&(n=" ");let r,o,s,i;for(let a=0;a<t.length-1;a+=1){const c=t[a];if(/^(cmd|meta|m)$/i.test(c))i=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))o=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))vt()||Oe()?i=!0:o=!0;else throw new Error(`Unrecognized modifier name: ${c}`)}return r&&(n=`Alt-${n}`),o&&(n=`Ctrl-${n}`),i&&(n=`Meta-${n}`),s&&(n=`Shift-${n}`),n}const Nn=e=>({editor:t,view:n,tr:r,dispatch:o})=>{const s=Dn(e).split(/-(?!$)/),i=s.find(l=>!["Alt","Ctrl","Meta","Shift"].includes(l)),a=new KeyboardEvent("keydown",{key:i==="Space"?" ":i,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),c=t.captureTransaction(()=>{n.someProp("handleKeyDown",l=>l(n,a))});return c==null||c.steps.forEach(l=>{const u=l.map(r.mapping);u&&o&&r.maybeStep(u)}),!0};function tt(e,t,n={}){const{from:r,to:o,empty:s}=e.selection,i=t?_(t,e.schema):null,a=[];e.doc.nodesBetween(r,o,(d,p)=>{if(d.isText)return;const h=Math.max(r,p),m=Math.min(o,p+d.nodeSize);a.push({node:d,from:h,to:m})});const c=o-r,l=a.filter(d=>i?i.name===d.node.type.name:!0).filter(d=>dt(d.node.attrs,n,{strict:!1}));return s?!!l.length:l.reduce((d,p)=>d+p.to-p.from,0)>=c}const In=(e,t={})=>({state:n,dispatch:r})=>{const o=_(e,n.schema);return tt(n,o,t)?g.lift(n,r):!1},$n=()=>({state:e,dispatch:t})=>g.liftEmptyBlock(e,t),Bn=e=>({state:t,dispatch:n})=>{const r=_(e,t.schema);return g.liftListItem(r)(t,n)},jn=()=>({state:e,dispatch:t})=>g.newlineInCode(e,t);function bt(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function te(e,t){const n=typeof t=="string"?[t]:t;return Object.keys(e).reduce((r,o)=>(n.includes(o)||(r[o]=e[o]),r),{})}const Fn=(e,t)=>({tr:n,state:r,dispatch:o})=>{let s=null,i=null;const a=bt(typeof e=="string"?e:e.name,r.schema);return a?(a==="node"&&(s=_(e,r.schema)),a==="mark"&&(i=V(e,r.schema)),o&&n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(l,u)=>{s&&s===l.type&&n.setNodeMarkup(u,void 0,te(l.attrs,t)),i&&l.marks.length&&l.marks.forEach(d=>{i===d.type&&n.addMark(u,u+l.nodeSize,i.create(te(d.attrs,t)))})})}),!0):!1},zn=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),Vn=()=>({tr:e,dispatch:t})=>{if(t){const n=new g.AllSelection(e.doc);e.setSelection(n)}return!0},Wn=()=>({state:e,dispatch:t})=>g.selectNodeBackward(e,t),Kn=()=>({state:e,dispatch:t})=>g.selectNodeForward(e,t),Un=()=>({state:e,dispatch:t})=>g.selectParentNode(e,t),qn=()=>({state:e,dispatch:t})=>g.selectTextblockEnd(e,t),Gn=()=>({state:e,dispatch:t})=>g.selectTextblockStart(e,t);function Ht(e,t,n={},r={}){return ut(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}const Jn=(e,t=!1,n={},r={})=>({editor:o,tr:s,dispatch:i,commands:a})=>{var c,l;const{doc:u}=s;if(n.preserveWhitespace!=="full"){const d=Ht(e,o.schema,n,{errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:o.options.enableContentCheck});return i&&s.replaceWith(0,u.content.size,d).setMeta("preventUpdate",!t),!0}return i&&s.setMeta("preventUpdate",!t),a.insertContentAt({from:0,to:u.content.size},e,{parseOptions:n,errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:o.options.enableContentCheck})};function Le(e,t){const n=V(t,e.schema),{from:r,to:o,empty:s}=e.selection,i=[];s?(e.storedMarks&&i.push(...e.storedMarks),i.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,o,c=>{i.push(...c.marks)});const a=i.find(c=>c.type.name===n.name);return a?{...a.attrs}:{}}function Yn(e,t){const n=new g.Transform(e);return t.forEach(r=>{r.steps.forEach(o=>{n.step(o)})}),n}function Xn(e){for(let t=0;t<e.edgeCount;t+=1){const{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Qn(e,t){const n=[];return e.descendants((r,o)=>{t(r)&&n.push({node:r,pos:o})}),n}function Zn(e,t,n){const r=[];return e.nodesBetween(t.from,t.to,(o,s)=>{n(o)&&r.push({node:o,pos:s})}),r}function Pe(e,t){for(let n=e.depth;n>0;n-=1){const r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function Mt(e){return t=>Pe(t.$from,e)}function tr(e,t){const n={from:0,to:e.content.size};return we(e,n,t)}function er(e,t){const n=_(t,e.schema),{from:r,to:o}=e.selection,s=[];e.doc.nodesBetween(r,o,a=>{s.push(a)});const i=s.reverse().find(a=>a.type.name===n.name);return i?{...i.attrs}:{}}function Re(e,t){const n=bt(typeof t=="string"?t:t.name,e.schema);return n==="node"?er(e,t):n==="mark"?Le(e,t):{}}function nr(e,t=JSON.stringify){const n={};return e.filter(r=>{const o=t(r);return Object.prototype.hasOwnProperty.call(n,o)?!1:n[o]=!0})}function rr(e){const t=nr(e);return t.length===1?t:t.filter((n,r)=>!t.filter((s,i)=>i!==r).some(s=>n.oldRange.from>=s.oldRange.from&&n.oldRange.to<=s.oldRange.to&&n.newRange.from>=s.newRange.from&&n.newRange.to<=s.newRange.to))}function or(e){const{mapping:t,steps:n}=e,r=[];return t.maps.forEach((o,s)=>{const i=[];if(o.ranges.length)o.forEach((a,c)=>{i.push({from:a,to:c})});else{const{from:a,to:c}=n[s];if(a===void 0||c===void 0)return;i.push({from:a,to:c})}i.forEach(({from:a,to:c})=>{const l=t.slice(s).map(a,-1),u=t.slice(s).map(c),d=t.invert().map(l,-1),p=t.invert().map(u);r.push({oldRange:{from:d,to:p},newRange:{from:l,to:u}})})}),rr(r)}function Wt(e,t,n){const r=[];return e===t?n.resolve(e).marks().forEach(o=>{const s=n.resolve(e),i=yt(s,o.type);i&&r.push({mark:o,...i})}):n.nodesBetween(e,t,(o,s)=>{!o||(o==null?void 0:o.nodeSize)===void 0||r.push(...o.marks.map(i=>({from:s,to:s+o.nodeSize,mark:i})))}),r}function lt(e,t,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const o=e.find(s=>s.type===t&&s.name===r);return o?o.attribute.keepOnSplit:!1}))}function _t(e,t,n={}){const{empty:r,ranges:o}=e.selection,s=t?V(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(d=>s?s.name===d.type.name:!0).find(d=>dt(d.attrs,n,{strict:!1}));let i=0;const a=[];if(o.forEach(({$from:d,$to:p})=>{const h=d.pos,m=p.pos;e.doc.nodesBetween(h,m,(f,y)=>{if(!f.isText&&!f.marks.length)return;const v=Math.max(h,y),S=Math.min(m,y+f.nodeSize),M=S-v;i+=M,a.push(...f.marks.map(b=>({mark:b,from:v,to:S})))})}),i===0)return!1;const c=a.filter(d=>s?s.name===d.mark.type.name:!0).filter(d=>dt(d.mark.attrs,n,{strict:!1})).reduce((d,p)=>d+p.to-p.from,0),l=a.filter(d=>s?d.mark.type!==s&&d.mark.type.excludes(s):!0).reduce((d,p)=>d+p.to-p.from,0);return(c>0?c+l:c)>=i}function He(e,t,n={}){if(!t)return tt(e,null,n)||_t(e,null,n);const r=bt(t,e.schema);return r==="node"?tt(e,t,n):r==="mark"?_t(e,t,n):!1}function Dt(e,t){const{nodeExtensions:n}=ft(t),r=n.find(i=>i.name===e);if(!r)return!1;const o={name:r.name,options:r.options,storage:r.storage},s=T(w(r,"group",o));return typeof s!="string"?!1:s.split(" ").includes("list")}function St(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(e.type.name==="hardBreak")return!0;if(e.isText)return/^\s*$/m.test((r=e.text)!==null&&r!==void 0?r:"")}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let o=!0;return e.content.forEach(s=>{o!==!1&&(St(s,{ignoreWhitespace:n,checkChildren:t})||(o=!1))}),o}return!1}function _e(e){return e instanceof g.NodeSelection}function sr(e,t,n){const o=e.state.doc.content.size,s=j(t,0,o),i=j(n,0,o),a=e.coordsAtPos(s),c=e.coordsAtPos(i,-1),l=Math.min(a.top,c.top),u=Math.max(a.bottom,c.bottom),d=Math.min(a.left,c.left),p=Math.max(a.right,c.right),h=p-d,m=u-l,v={top:l,bottom:u,left:d,right:p,width:h,height:m,x:d,y:l};return{...v,toJSON:()=>v}}function ir(e,t,n){var r;const{selection:o}=t;let s=null;if(Vt(o)&&(s=o.$cursor),s){const a=(r=e.storedMarks)!==null&&r!==void 0?r:s.marks();return!!n.isInSet(a)||!a.some(c=>c.type.excludes(n))}const{ranges:i}=o;return i.some(({$from:a,$to:c})=>{let l=a.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(n):!1;return e.doc.nodesBetween(a.pos,c.pos,(u,d,p)=>{if(l)return!1;if(u.isInline){const h=!p||p.type.allowsMarkType(n),m=!!n.isInSet(u.marks)||!u.marks.some(f=>f.type.excludes(n));l=h&&m}return!l}),l})}const ar=(e,t={})=>({tr:n,state:r,dispatch:o})=>{const{selection:s}=n,{empty:i,ranges:a}=s,c=V(e,r.schema);if(o)if(i){const l=Le(r,c);n.addStoredMark(c.create({...l,...t}))}else a.forEach(l=>{const u=l.$from.pos,d=l.$to.pos;r.doc.nodesBetween(u,d,(p,h)=>{const m=Math.max(h,u),f=Math.min(h+p.nodeSize,d);p.marks.find(v=>v.type===c)?p.marks.forEach(v=>{c===v.type&&n.addMark(m,f,c.create({...v.attrs,...t}))}):n.addMark(m,f,c.create(t))})});return ir(r,n,c)},lr=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),cr=(e,t={})=>({state:n,dispatch:r,chain:o})=>{const s=_(e,n.schema);let i;return n.selection.$anchor.sameParent(n.selection.$head)&&(i=n.selection.$anchor.parent.attrs),s.isTextblock?o().command(({commands:a})=>g.setBlockType(s,{...i,...t})(n)?!0:a.clearNodes()).command(({state:a})=>g.setBlockType(s,{...i,...t})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},dr=e=>({tr:t,dispatch:n})=>{if(n){const{doc:r}=t,o=j(e,0,r.content.size),s=g.NodeSelection.create(r,o);t.setSelection(s)}return!0},ur=e=>({tr:t,dispatch:n})=>{if(n){const{doc:r}=t,{from:o,to:s}=typeof e=="number"?{from:e,to:e}:e,i=g.TextSelection.atStart(r).from,a=g.TextSelection.atEnd(r).to,c=j(o,i,a),l=j(s,i,a),u=g.TextSelection.create(r,c,l);t.setSelection(u)}return!0},pr=e=>({state:t,dispatch:n})=>{const r=_(e,t.schema);return g.sinkListItem(r)(t,n)};function ee(e,t){const n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){const r=n.filter(o=>t==null?void 0:t.includes(o.type.name));e.tr.ensureMarks(r)}}const hr=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:o})=>{const{selection:s,doc:i}=t,{$from:a,$to:c}=s,l=o.extensionManager.attributes,u=lt(l,a.node().type.name,a.node().attrs);if(s instanceof g.NodeSelection&&s.node.isBlock)return!a.parentOffset||!g.canSplit(i,a.pos)?!1:(r&&(e&&ee(n,o.extensionManager.splittableMarks),t.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const d=c.parentOffset===c.parent.content.size,p=a.depth===0?void 0:Xn(a.node(-1).contentMatchAt(a.indexAfter(-1)));let h=d&&p?[{type:p,attrs:u}]:void 0,m=g.canSplit(t.doc,t.mapping.map(a.pos),1,h);if(!h&&!m&&g.canSplit(t.doc,t.mapping.map(a.pos),1,p?[{type:p}]:void 0)&&(m=!0,h=p?[{type:p,attrs:u}]:void 0),r){if(m&&(s instanceof g.TextSelection&&t.deleteSelection(),t.split(t.mapping.map(a.pos),1,h),p&&!d&&!a.parentOffset&&a.parent.type!==p)){const f=t.mapping.map(a.before()),y=t.doc.resolve(f);a.node(-1).canReplaceWith(y.index(),y.index()+1,p)&&t.setNodeMarkup(t.mapping.map(a.before()),p)}e&&ee(n,o.extensionManager.splittableMarks),t.scrollIntoView()}return m},fr=(e,t={})=>({tr:n,state:r,dispatch:o,editor:s})=>{var i;const a=_(e,r.schema),{$from:c,$to:l}=r.selection,u=r.selection.node;if(u&&u.isBlock||c.depth<2||!c.sameParent(l))return!1;const d=c.node(-1);if(d.type!==a)return!1;const p=s.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==a||c.index(-2)!==c.node(-2).childCount-1)return!1;if(o){let v=g.Fragment.empty;const S=c.index(-1)?1:c.index(-2)?2:3;for(let L=c.depth-S;L>=c.depth-3;L-=1)v=g.Fragment.from(c.node(L).copy(v));const M=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,b={...lt(p,c.node().type.name,c.node().attrs),...t},E=((i=a.contentMatch.defaultType)===null||i===void 0?void 0:i.createAndFill(b))||void 0;v=v.append(g.Fragment.from(a.createAndFill(null,E)||void 0));const k=c.before(c.depth-(S-1));n.replace(k,c.after(-M),new g.Slice(v,4-S,0));let C=-1;n.doc.nodesBetween(k,n.doc.content.size,(L,P)=>{if(C>-1)return!1;L.isTextblock&&L.content.size===0&&(C=P+1)}),C>-1&&n.setSelection(g.TextSelection.near(n.doc.resolve(C))),n.scrollIntoView()}return!0}const h=l.pos===c.end()?d.contentMatchAt(0).defaultType:null,m={...lt(p,d.type.name,d.attrs),...t},f={...lt(p,c.node().type.name,c.node().attrs),...t};n.delete(c.pos,l.pos);const y=h?[{type:a,attrs:m},{type:h,attrs:f}]:[{type:a,attrs:m}];if(!g.canSplit(n.doc,c.pos,2))return!1;if(o){const{selection:v,storedMarks:S}=r,{splittableMarks:M}=s.extensionManager,b=S||v.$to.parentOffset&&v.$from.marks();if(n.split(c.pos,2,y).scrollIntoView(),!b||!o)return!0;const E=b.filter(k=>M.includes(k.type.name));n.ensureMarks(E)}return!0},Ct=(e,t)=>{const n=Mt(i=>i.type===t)(e.selection);if(!n)return!0;const r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const o=e.doc.nodeAt(r);return n.node.type===(o==null?void 0:o.type)&&g.canJoin(e.doc,n.pos)&&e.join(n.pos),!0},xt=(e,t)=>{const n=Mt(i=>i.type===t)(e.selection);if(!n)return!0;const r=e.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const o=e.doc.nodeAt(r);return n.node.type===(o==null?void 0:o.type)&&g.canJoin(e.doc,r)&&e.join(r),!0},mr=(e,t,n,r={})=>({editor:o,tr:s,state:i,dispatch:a,chain:c,commands:l,can:u})=>{const{extensions:d,splittableMarks:p}=o.extensionManager,h=_(e,i.schema),m=_(t,i.schema),{selection:f,storedMarks:y}=i,{$from:v,$to:S}=f,M=v.blockRange(S),b=y||f.$to.parentOffset&&f.$from.marks();if(!M)return!1;const E=Mt(k=>Dt(k.type.name,d))(f);if(M.depth>=1&&E&&M.depth-E.depth<=1){if(E.node.type===h)return l.liftListItem(m);if(Dt(E.node.type.name,d)&&h.validContent(E.node.content)&&a)return c().command(()=>(s.setNodeMarkup(E.pos,h),!0)).command(()=>Ct(s,h)).command(()=>xt(s,h)).run()}return!n||!b||!a?c().command(()=>u().wrapInList(h,r)?!0:l.clearNodes()).wrapInList(h,r).command(()=>Ct(s,h)).command(()=>xt(s,h)).run():c().command(()=>{const k=u().wrapInList(h,r),C=b.filter(L=>p.includes(L.type.name));return s.ensureMarks(C),k?!0:l.clearNodes()}).wrapInList(h,r).command(()=>Ct(s,h)).command(()=>xt(s,h)).run()},gr=(e,t={},n={})=>({state:r,commands:o})=>{const{extendEmptyMarkRange:s=!1}=n,i=V(e,r.schema);return _t(r,i,t)?o.unsetMark(i,{extendEmptyMarkRange:s}):o.setMark(i,t)},yr=(e,t,n={})=>({state:r,commands:o})=>{const s=_(e,r.schema),i=_(t,r.schema),a=tt(r,s,n);let c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),a?o.setNode(i,c):o.setNode(s,{...c,...n})},vr=(e,t={})=>({state:n,commands:r})=>{const o=_(e,n.schema);return tt(n,o,t)?r.lift(o):r.wrapIn(o,t)},br=()=>({state:e,dispatch:t})=>{const n=e.plugins;for(let r=0;r<n.length;r+=1){const o=n[r];let s;if(o.spec.isInputRules&&(s=o.getState(e))){if(t){const i=e.tr,a=s.transform;for(let c=a.steps.length-1;c>=0;c-=1)i.step(a.steps[c].invert(a.docs[c]));if(s.text){const c=i.doc.resolve(s.from).marks();i.replaceWith(s.from,s.to,e.schema.text(s.text,c))}else i.delete(s.from,s.to)}return!0}}return!1},Mr=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,{empty:r,ranges:o}=n;return r||t&&o.forEach(s=>{e.removeMark(s.$from.pos,s.$to.pos)}),!0},Sr=(e,t={})=>({tr:n,state:r,dispatch:o})=>{var s;const{extendEmptyMarkRange:i=!1}=t,{selection:a}=n,c=V(e,r.schema),{$from:l,empty:u,ranges:d}=a;if(!o)return!0;if(u&&i){let{from:p,to:h}=a;const m=(s=l.marks().find(y=>y.type===c))===null||s===void 0?void 0:s.attrs,f=yt(l,c,m);f&&(p=f.from,h=f.to),n.removeMark(p,h,c)}else d.forEach(p=>{n.removeMark(p.$from.pos,p.$to.pos,c)});return n.removeStoredMark(c),!0},kr=(e,t={})=>({tr:n,state:r,dispatch:o})=>{let s=null,i=null;const a=bt(typeof e=="string"?e:e.name,r.schema);return a?(a==="node"&&(s=_(e,r.schema)),a==="mark"&&(i=V(e,r.schema)),o&&n.selection.ranges.forEach(c=>{const l=c.$from.pos,u=c.$to.pos;let d,p,h,m;n.selection.empty?r.doc.nodesBetween(l,u,(f,y)=>{s&&s===f.type&&(h=Math.max(y,l),m=Math.min(y+f.nodeSize,u),d=y,p=f)}):r.doc.nodesBetween(l,u,(f,y)=>{y<l&&s&&s===f.type&&(h=Math.max(y,l),m=Math.min(y+f.nodeSize,u),d=y,p=f),y>=l&&y<=u&&(s&&s===f.type&&n.setNodeMarkup(y,void 0,{...f.attrs,...t}),i&&f.marks.length&&f.marks.forEach(v=>{if(i===v.type){const S=Math.max(y,l),M=Math.min(y+f.nodeSize,u);n.addMark(S,M,i.create({...v.attrs,...t}))}}))}),p&&(d!==void 0&&n.setNodeMarkup(d,void 0,{...p.attrs,...t}),i&&p.marks.length&&p.marks.forEach(f=>{i===f.type&&n.addMark(h,m,i.create({...f.attrs,...t}))}))}),!0):!1},wr=(e,t={})=>({state:n,dispatch:r})=>{const o=_(e,n.schema);return g.wrapIn(o,t)(n,r)},Er=(e,t={})=>({state:n,dispatch:r})=>{const o=_(e,n.schema);return g.wrapInList(o,t)(n,r)};var Tr=Object.freeze({__proto__:null,blur:an,clearContent:ln,clearNodes:cn,command:dn,createParagraphNear:un,cut:pn,deleteCurrentNode:hn,deleteNode:fn,deleteRange:mn,deleteSelection:gn,enter:yn,exitCode:vn,extendMarkRange:bn,first:Mn,focus:Sn,forEach:kn,insertContent:wn,insertContentAt:Cn,joinBackward:On,joinDown:An,joinForward:Ln,joinItemBackward:Pn,joinItemForward:Rn,joinTextblockBackward:Hn,joinTextblockForward:_n,joinUp:xn,keyboardShortcut:Nn,lift:In,liftEmptyBlock:$n,liftListItem:Bn,newlineInCode:jn,resetAttributes:Fn,scrollIntoView:zn,selectAll:Vn,selectNodeBackward:Wn,selectNodeForward:Kn,selectParentNode:Un,selectTextblockEnd:qn,selectTextblockStart:Gn,setContent:Jn,setMark:ar,setMeta:lr,setNode:cr,setNodeSelection:dr,setTextSelection:ur,sinkListItem:pr,splitBlock:hr,splitListItem:fr,toggleList:mr,toggleMark:gr,toggleNode:yr,toggleWrap:vr,undoInputRule:br,unsetAllMarks:Mr,unsetMark:Sr,updateAttributes:kr,wrapIn:wr,wrapInList:Er});const Cr=H.create({name:"commands",addCommands(){return{...Tr}}}),xr=H.create({name:"drop",addProseMirrorPlugins(){return[new g.Plugin({key:new g.PluginKey("tiptapDrop"),props:{handleDrop:(e,t,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),Ar=H.create({name:"editable",addProseMirrorPlugins(){return[new g.Plugin({key:new g.PluginKey("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Or=H.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;return[new g.Plugin({key:new g.PluginKey("focusEvents"),props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;const r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;const r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),Lr=H.create({name:"keymap",addKeyboardShortcuts(){const e=()=>this.editor.commands.first(({commands:i})=>[()=>i.undoInputRule(),()=>i.command(({tr:a})=>{const{selection:c,doc:l}=a,{empty:u,$anchor:d}=c,{pos:p,parent:h}=d,m=d.parent.isTextblock&&p>0?a.doc.resolve(p-1):d,f=m.parent.type.spec.isolating,y=d.pos-d.parentOffset,v=f&&m.parent.childCount===1?y===d.pos:g.Selection.atStart(l).from===p;return!u||!h.type.isTextblock||h.textContent.length||!v||v&&d.parent.type.name==="paragraph"?!1:i.clearNodes()}),()=>i.deleteSelection(),()=>i.joinBackward(),()=>i.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:i})=>[()=>i.deleteSelection(),()=>i.deleteCurrentNode(),()=>i.joinForward(),()=>i.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:i})=>[()=>i.newlineInCode(),()=>i.createParagraphNear(),()=>i.liftEmptyBlock(),()=>i.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},o={...r},s={...r,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return vt()||Oe()?s:o},addProseMirrorPlugins(){return[new g.Plugin({key:new g.PluginKey("clearDocument"),appendTransaction:(e,t,n)=>{if(e.some(f=>f.getMeta("composition")))return;const r=e.some(f=>f.docChanged)&&!t.doc.eq(n.doc),o=e.some(f=>f.getMeta("preventClearDocument"));if(!r||o)return;const{empty:s,from:i,to:a}=t.selection,c=g.Selection.atStart(t.doc).from,l=g.Selection.atEnd(t.doc).to;if(s||!(i===c&&a===l)||!St(n.doc))return;const p=n.tr,h=pt({state:n,transaction:p}),{commands:m}=new ht({editor:this.editor,state:h});if(m.clearNodes(),!!p.steps.length)return p}})]}}),Pr=H.create({name:"paste",addProseMirrorPlugins(){return[new g.Plugin({key:new g.PluginKey("tiptapPaste"),props:{handlePaste:(e,t,n)=>{this.editor.emit("paste",{editor:this.editor,event:t,slice:n})}}})]}}),Rr=H.create({name:"tabindex",addProseMirrorPlugins(){return[new g.Plugin({key:new g.PluginKey("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class K{get name(){return this.node.type.name}constructor(t,n,r=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=t,this.editor=n,this.currentNode=o}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var t;return(t=this.actualDepth)!==null&&t!==void 0?t:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(t){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},t)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const t=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(t);return new K(n,this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new K(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new K(t,this.editor)}get children(){const t=[];return this.node.content.forEach((n,r)=>{const o=n.isBlock&&!n.isTextblock,s=n.isAtom&&!n.isText,i=this.pos+r+(s?0:1),a=this.resolvedPos.doc.resolve(i);if(!o&&a.depth<=this.depth)return;const c=new K(a,this.editor,o,o?n:null);o&&(c.actualDepth=this.depth+1),t.push(new K(a,this.editor,o,o?n:null))}),t}get firstChild(){return this.children[0]||null}get lastChild(){const t=this.children;return t[t.length-1]||null}closest(t,n={}){let r=null,o=this.parent;for(;o&&!r;){if(o.node.type.name===t)if(Object.keys(n).length>0){const s=o.node.attrs,i=Object.keys(n);for(let a=0;a<i.length;a+=1){const c=i[a];if(s[c]!==n[c])break}}else r=o;o=o.parent}return r}querySelector(t,n={}){return this.querySelectorAll(t,n,!0)[0]||null}querySelectorAll(t,n={},r=!1){let o=[];if(!this.children||this.children.length===0)return o;const s=Object.keys(n);return this.children.forEach(i=>{r&&o.length>0||(i.node.type.name===t&&s.every(c=>n[c]===i.node.attrs[c])&&o.push(i),!(r&&o.length>0)&&(o=o.concat(i.querySelectorAll(t,n,r))))}),o}setAttribute(t){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...t}),this.editor.view.dispatch(n)}}const Hr=`.ProseMirror {
5
5
  position: relative;
6
6
  }
7
7
 
@@ -75,9 +75,9 @@ img.ProseMirror-separator {
75
75
 
76
76
  .tippy-box[data-animation=fade][data-state=hidden] {
77
77
  opacity: 0
78
- }`;function Dr(e,t,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const o=document.createElement("style");return t&&o.setAttribute("nonce",t),o.setAttribute("data-tiptap-style",""),o.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(o),o}class Nr extends qe{constructor(t={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:n})=>{throw n},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:n,slice:r,moved:o})=>this.options.onDrop(n,r,o)),this.on("paste",({event:n,slice:r})=>this.options.onPaste(n,r)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=Dr(_r,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,n=!0){this.setOptions({editable:t}),n&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(t,n){const r=Se(n)?n(t,[...this.state.plugins]):[...this.state.plugins,t],o=this.state.reconfigure({plugins:r});return this.view.updateState(o),o}unregisterPlugin(t){if(this.isDestroyed)return;const n=this.state.plugins;let r=n;if([].concat(t).forEach(s=>{const i=typeof s=="string"?`${s}$`:s.key;r=n.filter(a=>!a.key.startsWith(i))}),n.length===r.length)return;const o=this.state.reconfigure({plugins:r});return this.view.updateState(o),o}createExtensionManager(){var t,n;const o=[...this.options.enableCoreExtensions?[Or,an.configure({blockSeparator:(n=(t=this.options.coreExtensionOptions)===null||t===void 0?void 0:t.clipboardTextSerializer)===null||n===void 0?void 0:n.blockSeparator}),xr,Lr,Pr,Hr,Ar,Rr].filter(s=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[s.name]!==!1:!0):[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s==null?void 0:s.type));this.extensionManager=new Y(o,this)}createCommandManager(){this.commandManager=new ft({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var t;let n;try{n=_t(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(i){if(!(i instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(i.message))throw i;this.emit("contentError",{editor:this,error:i,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(a=>a.name!=="collaboration"),this.createExtensionManager()}}),n=_t(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const r=xe(n,this.options.autofocus);this.view=new g.EditorView(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(t=this.options.editorProps)===null||t===void 0?void 0:t.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:g.EditorState.create({doc:n,selection:r||void 0})});const o=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(o),this.createNodeViews(),this.prependClass();const s=this.view.dom;s.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const n=this.capturedTransaction;return this.capturedTransaction=null,n}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(i=>{var a;return(a=this.capturedTransaction)===null||a===void 0?void 0:a.step(i)});return}const n=this.state.apply(t),r=!this.state.selection.eq(n.selection);this.emit("beforeTransaction",{editor:this,transaction:t,nextState:n}),this.view.updateState(n),this.emit("transaction",{editor:this,transaction:t}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const o=t.getMeta("focus"),s=t.getMeta("blur");o&&this.emit("focus",{editor:this,event:o.event,transaction:t}),s&&this.emit("blur",{editor:this,event:s.event,transaction:t}),!(!t.docChanged||t.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:t})}getAttributes(t){return He(this.state,t)}isActive(t,n){const r=typeof t=="string"?t:null,o=typeof t=="string"?n:t;return _e(this.state,r,o)}getJSON(){return this.state.doc.toJSON()}getHTML(){return zt(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:n=`
78
+ }`;function _r(e,t,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const o=document.createElement("style");return t&&o.setAttribute("nonce",t),o.setAttribute("data-tiptap-style",""),o.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(o),o}class Dr extends Ue{constructor(t={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:n})=>{throw n},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:n,slice:r,moved:o})=>this.options.onDrop(n,r,o)),this.on("paste",({event:n,slice:r})=>this.options.onPaste(n,r)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=_r(Hr,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,n=!0){this.setOptions({editable:t}),n&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(t,n){const r=Me(n)?n(t,[...this.state.plugins]):[...this.state.plugins,t],o=this.state.reconfigure({plugins:r});return this.view.updateState(o),o}unregisterPlugin(t){if(this.isDestroyed)return;const n=this.state.plugins;let r=n;if([].concat(t).forEach(s=>{const i=typeof s=="string"?`${s}$`:s.key;r=n.filter(a=>!a.key.startsWith(i))}),n.length===r.length)return;const o=this.state.reconfigure({plugins:r});return this.view.updateState(o),o}createExtensionManager(){var t,n;const o=[...this.options.enableCoreExtensions?[Ar,sn.configure({blockSeparator:(n=(t=this.options.coreExtensionOptions)===null||t===void 0?void 0:t.clipboardTextSerializer)===null||n===void 0?void 0:n.blockSeparator}),Cr,Or,Lr,Rr,xr,Pr].filter(s=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[s.name]!==!1:!0):[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s==null?void 0:s.type));this.extensionManager=new Y(o,this)}createCommandManager(){this.commandManager=new ht({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var t;let n;try{n=Ht(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(i){if(!(i instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(i.message))throw i;this.emit("contentError",{editor:this,error:i,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(a=>a.name!=="collaboration"),this.createExtensionManager()}}),n=Ht(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const r=Ce(n,this.options.autofocus);this.view=new g.EditorView(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(t=this.options.editorProps)===null||t===void 0?void 0:t.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:g.EditorState.create({doc:n,selection:r||void 0})});const o=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(o),this.createNodeViews(),this.prependClass();const s=this.view.dom;s.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const n=this.capturedTransaction;return this.capturedTransaction=null,n}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(i=>{var a;return(a=this.capturedTransaction)===null||a===void 0?void 0:a.step(i)});return}const n=this.state.apply(t),r=!this.state.selection.eq(n.selection);this.emit("beforeTransaction",{editor:this,transaction:t,nextState:n}),this.view.updateState(n),this.emit("transaction",{editor:this,transaction:t}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const o=t.getMeta("focus"),s=t.getMeta("blur");o&&this.emit("focus",{editor:this,event:o.event,transaction:t}),s&&this.emit("blur",{editor:this,event:s.event,transaction:t}),!(!t.docChanged||t.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:t})}getAttributes(t){return Re(this.state,t)}isActive(t,n){const r=typeof t=="string"?t:null,o=typeof t=="string"?n:t;return He(this.state,r,o)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Ft(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:n=`
79
79
 
80
- `,textSerializers:r={}}=t||{};return er(this.state.doc,{blockSeparator:n,textSerializers:{...Te(this.schema),...r}})}get isEmpty(){return kt(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const t=this.view.dom;t&&t.editor&&delete t.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var t;return!(!((t=this.view)===null||t===void 0)&&t.docView)}$node(t,n){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(t,n))||null}$nodes(t,n){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(t,n))||null}$pos(t){const n=this.state.doc.resolve(t);return new K(n,this)}get $doc(){return this.$pos(0)}}function U(e){return new gt({find:e.find,handler:({state:t,range:n,match:r})=>{const o=T(e.getAttributes,void 0,r);if(o===!1||o===null)return null;const{tr:s}=t,i=r[r.length-1],a=r[0];if(i){const c=a.search(/\S/),l=n.from+a.indexOf(i),u=l+i.length;if(Kt(n.from,n.to,t.doc).filter(h=>h.mark.type.excluded.find(f=>f===e.type&&f!==h.mark.type)).filter(h=>h.to>l).length)return null;u<n.to&&s.delete(u,n.to),l>n.from&&s.delete(n.from+c,l);const p=n.from+c+i.length;s.addMark(n.from+c,p,e.type.create(o||{})),s.removeStoredMark(e.type)}}})}function Ut(e){return new gt({find:e.find,handler:({state:t,range:n,match:r})=>{const o=T(e.getAttributes,void 0,r)||{},{tr:s}=t,i=n.from;let a=n.to;const c=e.type.create(o);if(r[1]){const l=r[0].lastIndexOf(r[1]);let u=i+l;u>a?u=a:a=u+r[1].length;const d=r[0][r[0].length-1];s.insertText(d,i+r[0].length-1),s.replaceWith(u,a,c)}else if(r[0]){const l=e.type.isInline?i:i-1;s.insert(l,e.type.create(o)).delete(s.mapping.map(i),s.mapping.map(a))}s.scrollIntoView()}})}function It(e){return new gt({find:e.find,handler:({state:t,range:n,match:r})=>{const o=t.doc.resolve(n.from),s=T(e.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,s)}})}function X(e){return new gt({find:e.find,handler:({state:t,range:n,match:r,chain:o})=>{const s=T(e.getAttributes,void 0,r)||{},i=t.tr.delete(n.from,n.to),c=i.doc.resolve(n.from).blockRange(),l=c&&g.findWrapping(c,e.type,s);if(!l)return null;if(i.wrap(c,l),e.keepMarks&&e.editor){const{selection:d,storedMarks:p}=t,{splittableMarks:h}=e.editor.extensionManager,m=p||d.$to.parentOffset&&d.$from.marks();if(m){const f=m.filter(y=>h.includes(y.type.name));i.ensureMarks(f)}}if(e.keepAttributes){const d=e.type.name==="bulletList"||e.type.name==="orderedList"?"listItem":"taskList";o().updateAttributes(d,s).run()}const u=i.doc.resolve(n.from-1).nodeBefore;u&&u.type===e.type&&g.canJoin(i.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,u))&&i.join(n.from-1)}})}class R{constructor(t={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=T(w(this,"addOptions",{name:this.name}))),this.storage=T(w(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new R(t)}configure(t={}){const n=this.extend({...this.config,addOptions:()=>yt(this.options,t)});return n.name=this.name,n.parent=this.parent,n}extend(t={}){const n=new R(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=T(w(n,"addOptions",{name:n.name})),n.storage=T(w(n,"addStorage",{name:n.name,options:n.options})),n}}class Ir{constructor(t,n,r){this.isDragging=!1,this.component=t,this.editor=n.editor,this.options={stopEvent:null,ignoreMutation:null,...r},this.extension=n.extension,this.node=n.node,this.decorations=n.decorations,this.innerDecorations=n.innerDecorations,this.view=n.view,this.HTMLAttributes=n.HTMLAttributes,this.getPos=n.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var n,r,o,s,i,a,c;const{view:l}=this.editor,u=t.target,d=u.nodeType===3?(n=u.parentElement)===null||n===void 0?void 0:n.closest("[data-drag-handle]"):u.closest("[data-drag-handle]");if(!this.dom||!((r=this.contentDOM)===null||r===void 0)&&r.contains(u)||!d)return;let p=0,h=0;if(this.dom!==d){const v=this.dom.getBoundingClientRect(),S=d.getBoundingClientRect(),M=(o=t.offsetX)!==null&&o!==void 0?o:(s=t.nativeEvent)===null||s===void 0?void 0:s.offsetX,b=(i=t.offsetY)!==null&&i!==void 0?i:(a=t.nativeEvent)===null||a===void 0?void 0:a.offsetY;p=S.x-v.x+M,h=S.y-v.y+b}(c=t.dataTransfer)===null||c===void 0||c.setDragImage(this.dom,p,h);const m=this.getPos();if(typeof m!="number")return;const f=g.NodeSelection.create(l.state.doc,m),y=l.state.tr.setSelection(f);l.dispatch(y)}stopEvent(t){var n;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});const r=t.target;if(!(this.dom.contains(r)&&!(!((n=this.contentDOM)===null||n===void 0)&&n.contains(r))))return!1;const s=t.type.startsWith("drag"),i=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(r.tagName)||r.isContentEditable)&&!i&&!s)return!0;const{isEditable:c}=this.editor,{isDragging:l}=this,u=!!this.node.type.spec.draggable,d=g.NodeSelection.isSelectable(this.node),p=t.type==="copy",h=t.type==="paste",m=t.type==="cut",f=t.type==="mousedown";if(!u&&d&&s&&t.target===this.dom&&t.preventDefault(),u&&s&&!l&&t.target===this.dom)return t.preventDefault(),!1;if(u&&c&&!l&&f){const y=r.closest("[data-drag-handle]");y&&(this.dom===y||this.dom.contains(y))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(l||i||p||h||m||f&&d)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(bt()||Ae())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(r=>r.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:n})=>{const r=this.getPos();return typeof r!="number"?!1:(n.setNodeMarkup(r,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){const t=this.getPos();if(typeof t!="number")return;const n=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:n})}}function z(e){return new we({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:o})=>{const s=T(e.getAttributes,void 0,r,o);if(s===!1||s===null)return null;const{tr:i}=t,a=r[r.length-1],c=r[0];let l=n.to;if(a){const u=c.search(/\S/),d=n.from+c.indexOf(a),p=d+a.length;if(Kt(n.from,n.to,t.doc).filter(m=>m.mark.type.excluded.find(y=>y===e.type&&y!==m.mark.type)).filter(m=>m.to>d).length)return null;p<n.to&&i.delete(p,n.to),d>n.from&&i.delete(n.from+u,d),l=n.from+u+a.length,i.addMark(n.from+u,l,e.type.create(s||{})),i.removeStoredMark(e.type)}}})}function $r(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function Br(e){return new we({find:e.find,handler({match:t,chain:n,range:r,pasteEvent:o}){const s=T(e.getAttributes,void 0,t,o),i=T(e.getContent,void 0,s);if(s===!1||s===null)return null;const a={type:e.type.name,attrs:s};i&&(a.content=i),t.input&&n().deleteRange(r).insertContentAt(r.from,a)}})}class jr{constructor({editor:t,element:n,view:r,tippyOptions:o={},updateDelay:s=250,shouldShow:i}){this.preventHide=!1,this.shouldShow=({view:a,state:c,from:l,to:u})=>{const{doc:d,selection:p}=c,{empty:h}=p,m=!d.textBetween(l,u).length&&Wt(c.selection),f=this.element.contains(document.activeElement);return!(!(a.hasFocus()||f)||h||m||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:a})=>{var c;if(this.preventHide){this.preventHide=!1;return}a!=null&&a.relatedTarget&&(!((c=this.element.parentNode)===null||c===void 0)&&c.contains(a.relatedTarget))||(a==null?void 0:a.relatedTarget)!==this.editor.view.dom&&this.hide()},this.tippyBlurHandler=a=>{this.blurHandler({event:a})},this.handleDebouncedUpdate=(a,c)=>{const l=!(c!=null&&c.selection.eq(a.state.selection)),u=!(c!=null&&c.doc.eq(a.state.doc));!l&&!u||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(a,l,u,c)},this.updateDelay))},this.updateHandler=(a,c,l,u)=>{var d,p,h;const{state:m,composing:f}=a,{selection:y}=m;if(f||!c&&!l)return;this.createTooltip();const{ranges:S}=y,M=Math.min(...S.map(k=>k.$from.pos)),b=Math.max(...S.map(k=>k.$to.pos));if(!((d=this.shouldShow)===null||d===void 0?void 0:d.call(this,{editor:this.editor,element:this.element,view:a,state:m,oldState:u,from:M,to:b}))){this.hide();return}(p=this.tippy)===null||p===void 0||p.setProps({getReferenceClientRect:((h=this.tippyOptions)===null||h===void 0?void 0:h.getReferenceClientRect)||(()=>{if(De(m.selection)){let k=a.nodeDOM(M);if(k){const C=k.dataset.nodeViewWrapper?k:k.querySelector("[data-node-view-wrapper]");if(C&&(k=C.firstChild),k)return k.getBoundingClientRect()}}return ir(a,M,b)})}),this.show()},this.editor=t,this.element=n,this.view=r,this.updateDelay=s,i&&(this.shouldShow=i),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.tippyOptions=o,this.element.remove(),this.element.style.visibility="visible"}createTooltip(){const{element:t}=this.editor.options,n=!!t.parentElement;this.tippy||!n||(this.tippy=ve(t,{duration:0,getReferenceClientRect:null,content:this.element,interactive:!0,trigger:"manual",placement:"top",hideOnClick:"toggle",...this.tippyOptions}),this.tippy.popper.firstChild&&this.tippy.popper.firstChild.addEventListener("blur",this.tippyBlurHandler))}update(t,n){const{state:r}=t,o=r.selection.from!==r.selection.to;if(this.updateDelay>0&&o){this.handleDebouncedUpdate(t,n);return}const s=!(n!=null&&n.selection.eq(t.state.selection)),i=!(n!=null&&n.doc.eq(t.state.doc));this.updateHandler(t,s,i,n)}show(){var t;(t=this.tippy)===null||t===void 0||t.show()}hide(){var t;(t=this.tippy)===null||t===void 0||t.hide()}destroy(){var t,n;!((t=this.tippy)===null||t===void 0)&&t.popper.firstChild&&this.tippy.popper.firstChild.removeEventListener("blur",this.tippyBlurHandler),(n=this.tippy)===null||n===void 0||n.destroy(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler)}}const Ne=e=>new g.Plugin({key:typeof e.pluginKey=="string"?new g.PluginKey(e.pluginKey):e.pluginKey,view:t=>new jr({view:t,...e})});H.create({name:"bubbleMenu",addOptions(){return{element:null,tippyOptions:{},pluginKey:"bubbleMenu",updateDelay:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[Ne({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,tippyOptions:this.options.tippyOptions,updateDelay:this.options.updateDelay,shouldShow:this.options.shouldShow})]:[]}});var et={};function Fr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var $t={exports:{}},Ot={};/**
80
+ `,textSerializers:r={}}=t||{};return tr(this.state.doc,{blockSeparator:n,textSerializers:{...Ee(this.schema),...r}})}get isEmpty(){return St(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const t=this.view.dom;t&&t.editor&&delete t.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var t;return!(!((t=this.view)===null||t===void 0)&&t.docView)}$node(t,n){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(t,n))||null}$nodes(t,n){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(t,n))||null}$pos(t){const n=this.state.doc.resolve(t);return new K(n,this)}get $doc(){return this.$pos(0)}}function U(e){return new mt({find:e.find,handler:({state:t,range:n,match:r})=>{const o=T(e.getAttributes,void 0,r);if(o===!1||o===null)return null;const{tr:s}=t,i=r[r.length-1],a=r[0];if(i){const c=a.search(/\S/),l=n.from+a.indexOf(i),u=l+i.length;if(Wt(n.from,n.to,t.doc).filter(h=>h.mark.type.excluded.find(f=>f===e.type&&f!==h.mark.type)).filter(h=>h.to>l).length)return null;u<n.to&&s.delete(u,n.to),l>n.from&&s.delete(n.from+c,l);const p=n.from+c+i.length;s.addMark(n.from+c,p,e.type.create(o||{})),s.removeStoredMark(e.type)}}})}function Kt(e){return new mt({find:e.find,handler:({state:t,range:n,match:r})=>{const o=T(e.getAttributes,void 0,r)||{},{tr:s}=t,i=n.from;let a=n.to;const c=e.type.create(o);if(r[1]){const l=r[0].lastIndexOf(r[1]);let u=i+l;u>a?u=a:a=u+r[1].length;const d=r[0][r[0].length-1];s.insertText(d,i+r[0].length-1),s.replaceWith(u,a,c)}else if(r[0]){const l=e.type.isInline?i:i-1;s.insert(l,e.type.create(o)).delete(s.mapping.map(i),s.mapping.map(a))}s.scrollIntoView()}})}function Nt(e){return new mt({find:e.find,handler:({state:t,range:n,match:r})=>{const o=t.doc.resolve(n.from),s=T(e.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,s)}})}function X(e){return new mt({find:e.find,handler:({state:t,range:n,match:r,chain:o})=>{const s=T(e.getAttributes,void 0,r)||{},i=t.tr.delete(n.from,n.to),c=i.doc.resolve(n.from).blockRange(),l=c&&g.findWrapping(c,e.type,s);if(!l)return null;if(i.wrap(c,l),e.keepMarks&&e.editor){const{selection:d,storedMarks:p}=t,{splittableMarks:h}=e.editor.extensionManager,m=p||d.$to.parentOffset&&d.$from.marks();if(m){const f=m.filter(y=>h.includes(y.type.name));i.ensureMarks(f)}}if(e.keepAttributes){const d=e.type.name==="bulletList"||e.type.name==="orderedList"?"listItem":"taskList";o().updateAttributes(d,s).run()}const u=i.doc.resolve(n.from-1).nodeBefore;u&&u.type===e.type&&g.canJoin(i.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,u))&&i.join(n.from-1)}})}class R{constructor(t={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=T(w(this,"addOptions",{name:this.name}))),this.storage=T(w(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new R(t)}configure(t={}){const n=this.extend({...this.config,addOptions:()=>gt(this.options,t)});return n.name=this.name,n.parent=this.parent,n}extend(t={}){const n=new R(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=T(w(n,"addOptions",{name:n.name})),n.storage=T(w(n,"addStorage",{name:n.name,options:n.options})),n}}class Nr{constructor(t,n,r){this.isDragging=!1,this.component=t,this.editor=n.editor,this.options={stopEvent:null,ignoreMutation:null,...r},this.extension=n.extension,this.node=n.node,this.decorations=n.decorations,this.innerDecorations=n.innerDecorations,this.view=n.view,this.HTMLAttributes=n.HTMLAttributes,this.getPos=n.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var n,r,o,s,i,a,c;const{view:l}=this.editor,u=t.target,d=u.nodeType===3?(n=u.parentElement)===null||n===void 0?void 0:n.closest("[data-drag-handle]"):u.closest("[data-drag-handle]");if(!this.dom||!((r=this.contentDOM)===null||r===void 0)&&r.contains(u)||!d)return;let p=0,h=0;if(this.dom!==d){const v=this.dom.getBoundingClientRect(),S=d.getBoundingClientRect(),M=(o=t.offsetX)!==null&&o!==void 0?o:(s=t.nativeEvent)===null||s===void 0?void 0:s.offsetX,b=(i=t.offsetY)!==null&&i!==void 0?i:(a=t.nativeEvent)===null||a===void 0?void 0:a.offsetY;p=S.x-v.x+M,h=S.y-v.y+b}(c=t.dataTransfer)===null||c===void 0||c.setDragImage(this.dom,p,h);const m=this.getPos();if(typeof m!="number")return;const f=g.NodeSelection.create(l.state.doc,m),y=l.state.tr.setSelection(f);l.dispatch(y)}stopEvent(t){var n;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});const r=t.target;if(!(this.dom.contains(r)&&!(!((n=this.contentDOM)===null||n===void 0)&&n.contains(r))))return!1;const s=t.type.startsWith("drag"),i=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(r.tagName)||r.isContentEditable)&&!i&&!s)return!0;const{isEditable:c}=this.editor,{isDragging:l}=this,u=!!this.node.type.spec.draggable,d=g.NodeSelection.isSelectable(this.node),p=t.type==="copy",h=t.type==="paste",m=t.type==="cut",f=t.type==="mousedown";if(!u&&d&&s&&t.target===this.dom&&t.preventDefault(),u&&s&&!l&&t.target===this.dom)return t.preventDefault(),!1;if(u&&c&&!l&&f){const y=r.closest("[data-drag-handle]");y&&(this.dom===y||this.dom.contains(y))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(l||i||p||h||m||f&&d)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(vt()||xe())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(r=>r.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:n})=>{const r=this.getPos();return typeof r!="number"?!1:(n.setNodeMarkup(r,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){const t=this.getPos();if(typeof t!="number")return;const n=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:n})}}function z(e){return new ke({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:o})=>{const s=T(e.getAttributes,void 0,r,o);if(s===!1||s===null)return null;const{tr:i}=t,a=r[r.length-1],c=r[0];let l=n.to;if(a){const u=c.search(/\S/),d=n.from+c.indexOf(a),p=d+a.length;if(Wt(n.from,n.to,t.doc).filter(m=>m.mark.type.excluded.find(y=>y===e.type&&y!==m.mark.type)).filter(m=>m.to>d).length)return null;p<n.to&&i.delete(p,n.to),d>n.from&&i.delete(n.from+u,d),l=n.from+u+a.length,i.addMark(n.from+u,l,e.type.create(s||{})),i.removeStoredMark(e.type)}}})}function Ir(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function $r(e){return new ke({find:e.find,handler({match:t,chain:n,range:r,pasteEvent:o}){const s=T(e.getAttributes,void 0,t,o),i=T(e.getContent,void 0,s);if(s===!1||s===null)return null;const a={type:e.type.name,attrs:s};i&&(a.content=i),t.input&&n().deleteRange(r).insertContentAt(r.from,a)}})}class Br{constructor({editor:t,element:n,view:r,tippyOptions:o={},updateDelay:s=250,shouldShow:i}){this.preventHide=!1,this.shouldShow=({view:a,state:c,from:l,to:u})=>{const{doc:d,selection:p}=c,{empty:h}=p,m=!d.textBetween(l,u).length&&Vt(c.selection),f=this.element.contains(document.activeElement);return!(!(a.hasFocus()||f)||h||m||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:a})=>{var c;if(this.preventHide){this.preventHide=!1;return}a!=null&&a.relatedTarget&&(!((c=this.element.parentNode)===null||c===void 0)&&c.contains(a.relatedTarget))||(a==null?void 0:a.relatedTarget)!==this.editor.view.dom&&this.hide()},this.tippyBlurHandler=a=>{this.blurHandler({event:a})},this.handleDebouncedUpdate=(a,c)=>{const l=!(c!=null&&c.selection.eq(a.state.selection)),u=!(c!=null&&c.doc.eq(a.state.doc));!l&&!u||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(a,l,u,c)},this.updateDelay))},this.updateHandler=(a,c,l,u)=>{var d,p,h;const{state:m,composing:f}=a,{selection:y}=m;if(f||!c&&!l)return;this.createTooltip();const{ranges:S}=y,M=Math.min(...S.map(k=>k.$from.pos)),b=Math.max(...S.map(k=>k.$to.pos));if(!((d=this.shouldShow)===null||d===void 0?void 0:d.call(this,{editor:this.editor,element:this.element,view:a,state:m,oldState:u,from:M,to:b}))){this.hide();return}(p=this.tippy)===null||p===void 0||p.setProps({getReferenceClientRect:((h=this.tippyOptions)===null||h===void 0?void 0:h.getReferenceClientRect)||(()=>{if(_e(m.selection)){let k=a.nodeDOM(M);if(k){const C=k.dataset.nodeViewWrapper?k:k.querySelector("[data-node-view-wrapper]");if(C&&(k=C.firstChild),k)return k.getBoundingClientRect()}}return sr(a,M,b)})}),this.show()},this.editor=t,this.element=n,this.view=r,this.updateDelay=s,i&&(this.shouldShow=i),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.tippyOptions=o,this.element.remove(),this.element.style.visibility="visible"}createTooltip(){const{element:t}=this.editor.options,n=!!t.parentElement;this.tippy||!n||(this.tippy=ye(t,{duration:0,getReferenceClientRect:null,content:this.element,interactive:!0,trigger:"manual",placement:"top",hideOnClick:"toggle",...this.tippyOptions}),this.tippy.popper.firstChild&&this.tippy.popper.firstChild.addEventListener("blur",this.tippyBlurHandler))}update(t,n){const{state:r}=t,o=r.selection.from!==r.selection.to;if(this.updateDelay>0&&o){this.handleDebouncedUpdate(t,n);return}const s=!(n!=null&&n.selection.eq(t.state.selection)),i=!(n!=null&&n.doc.eq(t.state.doc));this.updateHandler(t,s,i,n)}show(){var t;(t=this.tippy)===null||t===void 0||t.show()}hide(){var t;(t=this.tippy)===null||t===void 0||t.hide()}destroy(){var t,n;!((t=this.tippy)===null||t===void 0)&&t.popper.firstChild&&this.tippy.popper.firstChild.removeEventListener("blur",this.tippyBlurHandler),(n=this.tippy)===null||n===void 0||n.destroy(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler)}}const De=e=>new g.Plugin({key:typeof e.pluginKey=="string"?new g.PluginKey(e.pluginKey):e.pluginKey,view:t=>new Br({view:t,...e})});H.create({name:"bubbleMenu",addOptions(){return{element:null,tippyOptions:{},pluginKey:"bubbleMenu",updateDelay:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[De({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,tippyOptions:this.options.tippyOptions,updateDelay:this.options.updateDelay,shouldShow:this.options.shouldShow})]:[]}});function jr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var It={exports:{}},At={};/**
81
81
  * @license React
82
82
  * use-sync-external-store-shim.production.min.js
83
83
  *
@@ -85,7 +85,7 @@ img.ProseMirror-separator {
85
85
  *
86
86
  * This source code is licensed under the MIT license found in the
87
87
  * LICENSE file in the root directory of this source tree.
88
- */var re;function zr(){if(re)return Ot;re=1;var e=x;function t(d,p){return d===p&&(d!==0||1/d===1/p)||d!==d&&p!==p}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,o=e.useEffect,s=e.useLayoutEffect,i=e.useDebugValue;function a(d,p){var h=p(),m=r({inst:{value:h,getSnapshot:p}}),f=m[0].inst,y=m[1];return s(function(){f.value=h,f.getSnapshot=p,c(f)&&y({inst:f})},[d,h,p]),o(function(){return c(f)&&y({inst:f}),d(function(){c(f)&&y({inst:f})})},[d]),i(h),h}function c(d){var p=d.getSnapshot;d=d.value;try{var h=p();return!n(d,h)}catch{return!0}}function l(d,p){return p()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l:a;return Ot.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,Ot}var Lt={};/**
88
+ */var ne;function Fr(){if(ne)return At;ne=1;var e=x;function t(d,p){return d===p&&(d!==0||1/d===1/p)||d!==d&&p!==p}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,o=e.useEffect,s=e.useLayoutEffect,i=e.useDebugValue;function a(d,p){var h=p(),m=r({inst:{value:h,getSnapshot:p}}),f=m[0].inst,y=m[1];return s(function(){f.value=h,f.getSnapshot=p,c(f)&&y({inst:f})},[d,h,p]),o(function(){return c(f)&&y({inst:f}),d(function(){c(f)&&y({inst:f})})},[d]),i(h),h}function c(d){var p=d.getSnapshot;d=d.value;try{var h=p();return!n(d,h)}catch{return!0}}function l(d,p){return p()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l:a;return At.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,At}var Ot={};/**
89
89
  * @license React
90
90
  * use-sync-external-store-shim.development.js
91
91
  *
@@ -93,7 +93,7 @@ img.ProseMirror-separator {
93
93
  *
94
94
  * This source code is licensed under the MIT license found in the
95
95
  * LICENSE file in the root directory of this source tree.
96
- */var oe;function Vr(){return oe||(oe=1,et.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=x,t=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function n(M){{for(var b=arguments.length,E=new Array(b>1?b-1:0),k=1;k<b;k++)E[k-1]=arguments[k];r("error",M,E)}}function r(M,b,E){{var k=t.ReactDebugCurrentFrame,C=k.getStackAddendum();C!==""&&(b+="%s",E=E.concat([C]));var L=E.map(function(P){return String(P)});L.unshift("Warning: "+b),Function.prototype.apply.call(console[M],console,L)}}function o(M,b){return M===b&&(M!==0||1/M===1/b)||M!==M&&b!==b}var s=typeof Object.is=="function"?Object.is:o,i=e.useState,a=e.useEffect,c=e.useLayoutEffect,l=e.useDebugValue,u=!1,d=!1;function p(M,b,E){u||e.startTransition!==void 0&&(u=!0,n("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var k=b();if(!d){var C=b();s(k,C)||(n("The result of getSnapshot should be cached to avoid an infinite loop"),d=!0)}var L=i({inst:{value:k,getSnapshot:b}}),P=L[0].inst,O=L[1];return c(function(){P.value=k,P.getSnapshot=b,h(P)&&O({inst:P})},[M,k,b]),a(function(){h(P)&&O({inst:P});var D=function(){h(P)&&O({inst:P})};return M(D)},[M]),l(k),k}function h(M){var b=M.getSnapshot,E=M.value;try{var k=b();return!s(E,k)}catch{return!0}}function m(M,b,E){return b()}var f=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",y=!f,v=y?m:p,S=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:v;Lt.useSyncExternalStore=S,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),Lt}et.NODE_ENV==="production"?$t.exports=zr():$t.exports=Vr();var wt=$t.exports;const Wr=(...e)=>t=>{e.forEach(n=>{typeof n=="function"?n(t):n&&(n.current=t)})},Kr=({contentComponent:e})=>{const t=wt.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot);return x.createElement(x.Fragment,null,Object.values(t))};function Ur(){const e=new Set;let t={};return{subscribe(n){return e.add(n),()=>{e.delete(n)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(n,r){t={...t,[n]:be.createPortal(r.reactElement,r.element,n)},e.forEach(o=>o())},removeRenderer(n){const r={...t};delete r[n],t=r,e.forEach(o=>o())}}}class qr extends x.Component{constructor(t){var n;super(t),this.editorContentRef=x.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!(!((n=t.editor)===null||n===void 0)&&n.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const t=this.props.editor;if(t&&!t.isDestroyed&&t.options.element){if(t.contentComponent)return;const n=this.editorContentRef.current;n.append(...t.options.element.childNodes),t.setOptions({element:n}),t.contentComponent=Ur(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){const t=this.props.editor;if(!t||(this.initialized=!1,t.isDestroyed||t.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),t.contentComponent=null,!t.options.element.firstChild))return;const n=document.createElement("div");n.append(...t.options.element.childNodes),t.setOptions({element:n})}render(){const{editor:t,innerRef:n,...r}=this.props;return x.createElement(x.Fragment,null,x.createElement("div",{ref:Wr(n,this.editorContentRef),...r}),(t==null?void 0:t.contentComponent)&&x.createElement(Kr,{contentComponent:t.contentComponent}))}}const Gr=x.forwardRef((e,t)=>{const n=x.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return x.createElement(qr,{key:n,innerRef:t,...e})}),Jr=x.memo(Gr);var Yr=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t=="object"&&typeof n=="object"){if(t.constructor!==n.constructor)return!1;var r,o,s;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(o=r;o--!==0;)if(!e(t[o],n[o]))return!1;return!0}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;for(o of t.entries())if(!n.has(o[0]))return!1;for(o of t.entries())if(!e(o[1],n.get(o[0])))return!1;return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;for(o of t.entries())if(!n.has(o[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(n)){if(r=t.length,r!=n.length)return!1;for(o=r;o--!==0;)if(t[o]!==n[o])return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(s=Object.keys(t),r=s.length,r!==Object.keys(n).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(n,s[o]))return!1;for(o=r;o--!==0;){var i=s[o];if(!(i==="_owner"&&t.$$typeof)&&!e(t[i],n[i]))return!1}return!0}return t!==t&&n!==n},Xr=Fr(Yr),Bt={exports:{}},Pt={};/**
96
+ */var re;function zr(){return re||(re=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=x,t=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function n(M){{for(var b=arguments.length,E=new Array(b>1?b-1:0),k=1;k<b;k++)E[k-1]=arguments[k];r("error",M,E)}}function r(M,b,E){{var k=t.ReactDebugCurrentFrame,C=k.getStackAddendum();C!==""&&(b+="%s",E=E.concat([C]));var L=E.map(function(P){return String(P)});L.unshift("Warning: "+b),Function.prototype.apply.call(console[M],console,L)}}function o(M,b){return M===b&&(M!==0||1/M===1/b)||M!==M&&b!==b}var s=typeof Object.is=="function"?Object.is:o,i=e.useState,a=e.useEffect,c=e.useLayoutEffect,l=e.useDebugValue,u=!1,d=!1;function p(M,b,E){u||e.startTransition!==void 0&&(u=!0,n("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var k=b();if(!d){var C=b();s(k,C)||(n("The result of getSnapshot should be cached to avoid an infinite loop"),d=!0)}var L=i({inst:{value:k,getSnapshot:b}}),P=L[0].inst,O=L[1];return c(function(){P.value=k,P.getSnapshot=b,h(P)&&O({inst:P})},[M,k,b]),a(function(){h(P)&&O({inst:P});var D=function(){h(P)&&O({inst:P})};return M(D)},[M]),l(k),k}function h(M){var b=M.getSnapshot,E=M.value;try{var k=b();return!s(E,k)}catch{return!0}}function m(M,b,E){return b()}var f=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",y=!f,v=y?m:p,S=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:v;Ot.useSyncExternalStore=S,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),Ot}process.env.NODE_ENV==="production"?It.exports=Fr():It.exports=zr();var kt=It.exports;const Vr=(...e)=>t=>{e.forEach(n=>{typeof n=="function"?n(t):n&&(n.current=t)})},Wr=({contentComponent:e})=>{const t=kt.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot);return x.createElement(x.Fragment,null,Object.values(t))};function Kr(){const e=new Set;let t={};return{subscribe(n){return e.add(n),()=>{e.delete(n)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(n,r){t={...t,[n]:ve.createPortal(r.reactElement,r.element,n)},e.forEach(o=>o())},removeRenderer(n){const r={...t};delete r[n],t=r,e.forEach(o=>o())}}}class Ur extends x.Component{constructor(t){var n;super(t),this.editorContentRef=x.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!(!((n=t.editor)===null||n===void 0)&&n.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const t=this.props.editor;if(t&&!t.isDestroyed&&t.options.element){if(t.contentComponent)return;const n=this.editorContentRef.current;n.append(...t.options.element.childNodes),t.setOptions({element:n}),t.contentComponent=Kr(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){const t=this.props.editor;if(!t||(this.initialized=!1,t.isDestroyed||t.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),t.contentComponent=null,!t.options.element.firstChild))return;const n=document.createElement("div");n.append(...t.options.element.childNodes),t.setOptions({element:n})}render(){const{editor:t,innerRef:n,...r}=this.props;return x.createElement(x.Fragment,null,x.createElement("div",{ref:Vr(n,this.editorContentRef),...r}),(t==null?void 0:t.contentComponent)&&x.createElement(Wr,{contentComponent:t.contentComponent}))}}const qr=x.forwardRef((e,t)=>{const n=x.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return x.createElement(Ur,{key:n,innerRef:t,...e})}),Gr=x.memo(qr);var Jr=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t=="object"&&typeof n=="object"){if(t.constructor!==n.constructor)return!1;var r,o,s;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(o=r;o--!==0;)if(!e(t[o],n[o]))return!1;return!0}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;for(o of t.entries())if(!n.has(o[0]))return!1;for(o of t.entries())if(!e(o[1],n.get(o[0])))return!1;return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;for(o of t.entries())if(!n.has(o[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(n)){if(r=t.length,r!=n.length)return!1;for(o=r;o--!==0;)if(t[o]!==n[o])return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(s=Object.keys(t),r=s.length,r!==Object.keys(n).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(n,s[o]))return!1;for(o=r;o--!==0;){var i=s[o];if(!(i==="_owner"&&t.$$typeof)&&!e(t[i],n[i]))return!1}return!0}return t!==t&&n!==n},Yr=jr(Jr),$t={exports:{}},Lt={};/**
97
97
  * @license React
98
98
  * use-sync-external-store-shim/with-selector.production.min.js
99
99
  *
@@ -101,7 +101,7 @@ img.ProseMirror-separator {
101
101
  *
102
102
  * This source code is licensed under the MIT license found in the
103
103
  * LICENSE file in the root directory of this source tree.
104
- */var se;function Qr(){if(se)return Pt;se=1;var e=x,t=wt;function n(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var r=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,s=e.useRef,i=e.useEffect,a=e.useMemo,c=e.useDebugValue;return Pt.useSyncExternalStoreWithSelector=function(l,u,d,p,h){var m=s(null);if(m.current===null){var f={hasValue:!1,value:null};m.current=f}else f=m.current;m=a(function(){function v(k){if(!S){if(S=!0,M=k,k=p(k),h!==void 0&&f.hasValue){var C=f.value;if(h(C,k))return b=C}return b=k}if(C=b,r(M,k))return C;var L=p(k);return h!==void 0&&h(C,L)?C:(M=k,b=L)}var S=!1,M,b,E=d===void 0?null:d;return[function(){return v(u())},E===null?void 0:function(){return v(E())}]},[u,d,p,h]);var y=o(l,m[0],m[1]);return i(function(){f.hasValue=!0,f.value=y},[y]),c(y),y},Pt}var Rt={};/**
104
+ */var oe;function Xr(){if(oe)return Lt;oe=1;var e=x,t=kt;function n(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var r=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,s=e.useRef,i=e.useEffect,a=e.useMemo,c=e.useDebugValue;return Lt.useSyncExternalStoreWithSelector=function(l,u,d,p,h){var m=s(null);if(m.current===null){var f={hasValue:!1,value:null};m.current=f}else f=m.current;m=a(function(){function v(k){if(!S){if(S=!0,M=k,k=p(k),h!==void 0&&f.hasValue){var C=f.value;if(h(C,k))return b=C}return b=k}if(C=b,r(M,k))return C;var L=p(k);return h!==void 0&&h(C,L)?C:(M=k,b=L)}var S=!1,M,b,E=d===void 0?null:d;return[function(){return v(u())},E===null?void 0:function(){return v(E())}]},[u,d,p,h]);var y=o(l,m[0],m[1]);return i(function(){f.hasValue=!0,f.value=y},[y]),c(y),y},Lt}var Pt={};/**
105
105
  * @license React
106
106
  * use-sync-external-store-shim/with-selector.development.js
107
107
  *
@@ -109,8 +109,8 @@ img.ProseMirror-separator {
109
109
  *
110
110
  * This source code is licensed under the MIT license found in the
111
111
  * LICENSE file in the root directory of this source tree.
112
- */var ie;function Zr(){return ie||(ie=1,et.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=x,t=wt;function n(u,d){return u===d&&(u!==0||1/u===1/d)||u!==u&&d!==d}var r=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,s=e.useRef,i=e.useEffect,a=e.useMemo,c=e.useDebugValue;function l(u,d,p,h,m){var f=s(null),y;f.current===null?(y={hasValue:!1,value:null},f.current=y):y=f.current;var v=a(function(){var E=!1,k,C,L=function(I){if(!E){E=!0,k=I;var q=h(I);if(m!==void 0&&y.hasValue){var G=y.value;if(m(G,q))return C=G,G}return C=q,q}var Q=k,B=C;if(r(Q,I))return B;var F=h(I);return m!==void 0&&m(B,F)?B:(k=I,C=F,F)},P=p===void 0?null:p,O=function(){return L(d())},D=P===null?void 0:function(){return L(P())};return[O,D]},[d,p,h,m]),S=v[0],M=v[1],b=o(u,S,M);return i(function(){y.hasValue=!0,y.value=b},[b]),c(b),b}Rt.useSyncExternalStoreWithSelector=l,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),Rt}et.NODE_ENV==="production"?Bt.exports=Qr():Bt.exports=Zr();var to=Bt.exports;const eo=typeof window<"u"?x.useLayoutEffect:x.useEffect;class no{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const n=()=>{this.transactionNumber+=1,this.subscribers.forEach(o=>o())},r=this.editor;return r.on("transaction",n),()=>{r.off("transaction",n)}}}}function ro(e){var t;const[n]=x.useState(()=>new no(e.editor)),r=to.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,e.selector,(t=e.equalityFn)!==null&&t!==void 0?t:Xr);return eo(()=>n.watch(e.editor),[e.editor,n]),x.useDebugValue(r),r}const ae=et.NODE_ENV!=="production",jt=typeof window>"u",oo=jt||!!(typeof window<"u"&&window.next);class qt{constructor(t){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=t,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(t){this.editor=t,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0)return jt||oo?(ae&&console.warn("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches."),null):this.createEditor();if(this.options.current.immediatelyRender&&jt&&ae)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const t={...this.options.current,onBeforeCreate:(...r)=>{var o,s;return(s=(o=this.options.current).onBeforeCreate)===null||s===void 0?void 0:s.call(o,...r)},onBlur:(...r)=>{var o,s;return(s=(o=this.options.current).onBlur)===null||s===void 0?void 0:s.call(o,...r)},onCreate:(...r)=>{var o,s;return(s=(o=this.options.current).onCreate)===null||s===void 0?void 0:s.call(o,...r)},onDestroy:(...r)=>{var o,s;return(s=(o=this.options.current).onDestroy)===null||s===void 0?void 0:s.call(o,...r)},onFocus:(...r)=>{var o,s;return(s=(o=this.options.current).onFocus)===null||s===void 0?void 0:s.call(o,...r)},onSelectionUpdate:(...r)=>{var o,s;return(s=(o=this.options.current).onSelectionUpdate)===null||s===void 0?void 0:s.call(o,...r)},onTransaction:(...r)=>{var o,s;return(s=(o=this.options.current).onTransaction)===null||s===void 0?void 0:s.call(o,...r)},onUpdate:(...r)=>{var o,s;return(s=(o=this.options.current).onUpdate)===null||s===void 0?void 0:s.call(o,...r)},onContentError:(...r)=>{var o,s;return(s=(o=this.options.current).onContentError)===null||s===void 0?void 0:s.call(o,...r)},onDrop:(...r)=>{var o,s;return(s=(o=this.options.current).onDrop)===null||s===void 0?void 0:s.call(o,...r)},onPaste:(...r)=>{var o,s;return(s=(o=this.options.current).onPaste)===null||s===void 0?void 0:s.call(o,...r)}};return new Nr(t)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(t){return this.subscriptions.add(t),()=>{this.subscriptions.delete(t)}}static compareOptions(t,n){return Object.keys(t).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&t.extensions&&n.extensions?t.extensions.length!==n.extensions.length?!1:t.extensions.every((o,s)=>{var i;return o===((i=n.extensions)===null||i===void 0?void 0:i[s])}):t[r]===n[r])}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&t.length===0?qt.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(t){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=t;return}if(this.previousDeps.length===t.length&&this.previousDeps.every((r,o)=>r===t[o]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=t}scheduleDestroy(){const t=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===t){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===t&&this.setEditor(null))},1)}}function so(e={},t=[]){const n=x.useRef(e);n.current=e;const[r]=x.useState(()=>new qt(n)),o=wt.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return x.useDebugValue(o),x.useEffect(r.onRender(t)),ro({editor:o,selector:({transactionNumber:s})=>e.shouldRerenderOnTransaction===!1?null:e.immediatelyRender&&s===0?0:s+1}),o}const Ie=x.createContext({editor:null});Ie.Consumer;const io=()=>x.useContext(Ie),ao=e=>{const[t,n]=x.useState(null),{editor:r}=io();return x.useEffect(()=>{var o;if(!t||!((o=e.editor)===null||o===void 0)&&o.isDestroyed||r!=null&&r.isDestroyed)return;const{pluginKey:s="bubbleMenu",editor:i,tippyOptions:a={},updateDelay:c,shouldShow:l=null}=e,u=i||r;if(!u){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const d=Ne({updateDelay:c,editor:u,element:t,pluginKey:s,shouldShow:l,tippyOptions:a});return u.registerPlugin(d),()=>{u.unregisterPlugin(s)}},[e.editor,r,t]),x.createElement("div",{ref:n,className:e.className,style:{visibility:"hidden"}},e.children)},$e=x.createContext({onDragStart:void 0}),Be=()=>x.useContext($e),lo=e=>{const t=e.as||"div",{nodeViewContentRef:n}=Be();return x.createElement(t,{...e,ref:n,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...e.style}})},co=x.forwardRef((e,t)=>{const{onDragStart:n}=Be(),r=e.as||"div";return x.createElement(r,{...e,ref:t,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...e.style}})});function uo(e){return!!(typeof e=="function"&&e.prototype&&e.prototype.isReactComponent)}function po(e){var t;return typeof e=="object"&&((t=e.$$typeof)===null||t===void 0?void 0:t.toString())==="Symbol(react.forward_ref)"}class je{constructor(t,{editor:n,props:r={},as:o="div",className:s=""}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=n,this.props=r,this.element=document.createElement(o),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),this.editor.isInitialized?be.flushSync(()=>{this.render()}):this.render()}render(){var t;const n=this.component,r=this.props,o=this.editor;(uo(n)||po(n))&&(r.ref=s=>{this.ref=s}),this.reactElement=x.createElement(n,{...r}),(t=o==null?void 0:o.contentComponent)===null||t===void 0||t.setRenderer(this.id,this)}updateProps(t={}){this.props={...this.props,...t},this.render()}destroy(){var t;const n=this.editor;(t=n==null?void 0:n.contentComponent)===null||t===void 0||t.removeRenderer(this.id)}updateAttributes(t){Object.keys(t).forEach(n=>{this.element.setAttribute(n,t[n])})}}class ho extends Ir{mount(){const t={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(l={})=>this.updateAttributes(l),deleteNode:()=>this.deleteNode()};if(!this.component.displayName){const l=u=>u.charAt(0).toUpperCase()+u.substring(1);this.component.displayName=l(this.extension.name)}const o={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:l=>{l&&this.contentDOMElement&&l.firstChild!==this.contentDOMElement&&l.appendChild(this.contentDOMElement)}},s=this.component,i=x.memo(l=>x.createElement($e.Provider,{value:o},x.createElement(s,l)));i.displayName="ReactNodeView",this.node.isLeaf?this.contentDOMElement=null:this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement&&(this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.style.whiteSpace="inherit");let a=this.node.isInline?"span":"div";this.options.as&&(a=this.options.as);const{className:c=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new je(i,{editor:this.editor,props:t,as:a,className:`node-${this.node.type.name} ${c}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var t;if(this.renderer.element.firstElementChild&&!(!((t=this.renderer.element.firstElementChild)===null||t===void 0)&&t.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){const{from:t,to:n}=this.editor.state.selection,r=this.getPos();if(typeof r=="number")if(t<=r&&n>=r+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(t,n,r){const o=s=>{this.renderer.updateProps(s),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(t.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const s=this.node,i=this.decorations,a=this.innerDecorations;return this.node=t,this.decorations=n,this.innerDecorations=r,this.options.update({oldNode:s,oldDecorations:i,newNode:t,newDecorations:n,oldInnerDecorations:a,innerDecorations:r,updateProps:()=>o({node:t,decorations:n,innerDecorations:r})})}return t===this.node&&this.decorations===n&&this.innerDecorations===r||(this.node=t,this.decorations=n,this.innerDecorations=r,o({node:t,decorations:n,innerDecorations:r})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let t={};if(typeof this.options.attrs=="function"){const n=this.editor.extensionManager.attributes,r=dt(this.node,n);t=this.options.attrs({node:this.node,HTMLAttributes:r})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}}function fo(e,t){return n=>n.editor.contentComponent?new ho(e,n,t):{}}const mo=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,go=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,yo=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,vo=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,bo=N.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>e.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:e=>e.type.name===this.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return["strong",A(this.options.HTMLAttributes,e),0]},addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[U({find:mo,type:this.type}),U({find:yo,type:this.type})]},addPasteRules(){return[z({find:go,type:this.type}),z({find:vo,type:this.type})]}}),Mo=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,So=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,ko=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,wo=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Eo=N.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>e.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",A(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[U({find:Mo,type:this.type}),U({find:ko,type:this.type})]},addPasteRules(){return[z({find:So,type:this.type}),z({find:wo,type:this.type})]}}),To=N.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["u",A(this.options.HTMLAttributes,e),0]},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Co=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,xo=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Ao=N.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["s",A(this.options.HTMLAttributes,e),0]},addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[U({find:Co,type:this.type})]},addPasteRules(){return[z({find:xo,type:this.type})]}}),Oo=/(^|[^`])`([^`]+)`(?!`)/,Lo=/(^|[^`])`([^`]+)`(?!`)/g,Po=N.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:e}){return["code",A(this.options.HTMLAttributes,e),0]},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[U({find:Oo,type:this.type})]},addPasteRules(){return[z({find:Lo,type:this.type})]}}),Ro=/^```([a-z]+)?[\s\n]$/,Ho=/^~~~([a-z]+)?[\s\n]$/,_o=R.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{var t;const{languageClassPrefix:n}=this.options,s=[...((t=e.firstElementChild)===null||t===void 0?void 0:t.classList)||[]].filter(i=>i.startsWith(n)).map(i=>i.replace(n,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:e,HTMLAttributes:t}){return["pre",A(this.options.HTMLAttributes,t),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:t}=e,{selection:n}=t,{$from:r,empty:o}=n;if(!o||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,i=r.parent.textContent.endsWith(`
112
+ */var se;function Qr(){return se||(se=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=x,t=kt;function n(u,d){return u===d&&(u!==0||1/u===1/d)||u!==u&&d!==d}var r=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,s=e.useRef,i=e.useEffect,a=e.useMemo,c=e.useDebugValue;function l(u,d,p,h,m){var f=s(null),y;f.current===null?(y={hasValue:!1,value:null},f.current=y):y=f.current;var v=a(function(){var E=!1,k,C,L=function(I){if(!E){E=!0,k=I;var q=h(I);if(m!==void 0&&y.hasValue){var G=y.value;if(m(G,q))return C=G,G}return C=q,q}var Q=k,B=C;if(r(Q,I))return B;var F=h(I);return m!==void 0&&m(B,F)?B:(k=I,C=F,F)},P=p===void 0?null:p,O=function(){return L(d())},D=P===null?void 0:function(){return L(P())};return[O,D]},[d,p,h,m]),S=v[0],M=v[1],b=o(u,S,M);return i(function(){y.hasValue=!0,y.value=b},[b]),c(b),b}Pt.useSyncExternalStoreWithSelector=l,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),Pt}process.env.NODE_ENV==="production"?$t.exports=Xr():$t.exports=Qr();var Zr=$t.exports;const to=typeof window<"u"?x.useLayoutEffect:x.useEffect;class eo{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const n=()=>{this.transactionNumber+=1,this.subscribers.forEach(o=>o())},r=this.editor;return r.on("transaction",n),()=>{r.off("transaction",n)}}}}function no(e){var t;const[n]=x.useState(()=>new eo(e.editor)),r=Zr.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,e.selector,(t=e.equalityFn)!==null&&t!==void 0?t:Yr);return to(()=>n.watch(e.editor),[e.editor,n]),x.useDebugValue(r),r}const ie=process.env.NODE_ENV!=="production",Bt=typeof window>"u",ro=Bt||!!(typeof window<"u"&&window.next);class Ut{constructor(t){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=t,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(t){this.editor=t,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0)return Bt||ro?(ie&&console.warn("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches."),null):this.createEditor();if(this.options.current.immediatelyRender&&Bt&&ie)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const t={...this.options.current,onBeforeCreate:(...r)=>{var o,s;return(s=(o=this.options.current).onBeforeCreate)===null||s===void 0?void 0:s.call(o,...r)},onBlur:(...r)=>{var o,s;return(s=(o=this.options.current).onBlur)===null||s===void 0?void 0:s.call(o,...r)},onCreate:(...r)=>{var o,s;return(s=(o=this.options.current).onCreate)===null||s===void 0?void 0:s.call(o,...r)},onDestroy:(...r)=>{var o,s;return(s=(o=this.options.current).onDestroy)===null||s===void 0?void 0:s.call(o,...r)},onFocus:(...r)=>{var o,s;return(s=(o=this.options.current).onFocus)===null||s===void 0?void 0:s.call(o,...r)},onSelectionUpdate:(...r)=>{var o,s;return(s=(o=this.options.current).onSelectionUpdate)===null||s===void 0?void 0:s.call(o,...r)},onTransaction:(...r)=>{var o,s;return(s=(o=this.options.current).onTransaction)===null||s===void 0?void 0:s.call(o,...r)},onUpdate:(...r)=>{var o,s;return(s=(o=this.options.current).onUpdate)===null||s===void 0?void 0:s.call(o,...r)},onContentError:(...r)=>{var o,s;return(s=(o=this.options.current).onContentError)===null||s===void 0?void 0:s.call(o,...r)},onDrop:(...r)=>{var o,s;return(s=(o=this.options.current).onDrop)===null||s===void 0?void 0:s.call(o,...r)},onPaste:(...r)=>{var o,s;return(s=(o=this.options.current).onPaste)===null||s===void 0?void 0:s.call(o,...r)}};return new Dr(t)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(t){return this.subscriptions.add(t),()=>{this.subscriptions.delete(t)}}static compareOptions(t,n){return Object.keys(t).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&t.extensions&&n.extensions?t.extensions.length!==n.extensions.length?!1:t.extensions.every((o,s)=>{var i;return o===((i=n.extensions)===null||i===void 0?void 0:i[s])}):t[r]===n[r])}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&t.length===0?Ut.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(t){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=t;return}if(this.previousDeps.length===t.length&&this.previousDeps.every((r,o)=>r===t[o]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=t}scheduleDestroy(){const t=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===t){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===t&&this.setEditor(null))},1)}}function oo(e={},t=[]){const n=x.useRef(e);n.current=e;const[r]=x.useState(()=>new Ut(n)),o=kt.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return x.useDebugValue(o),x.useEffect(r.onRender(t)),no({editor:o,selector:({transactionNumber:s})=>e.shouldRerenderOnTransaction===!1?null:e.immediatelyRender&&s===0?0:s+1}),o}const Ne=x.createContext({editor:null});Ne.Consumer;const so=()=>x.useContext(Ne),io=e=>{const[t,n]=x.useState(null),{editor:r}=so();return x.useEffect(()=>{var o;if(!t||!((o=e.editor)===null||o===void 0)&&o.isDestroyed||r!=null&&r.isDestroyed)return;const{pluginKey:s="bubbleMenu",editor:i,tippyOptions:a={},updateDelay:c,shouldShow:l=null}=e,u=i||r;if(!u){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const d=De({updateDelay:c,editor:u,element:t,pluginKey:s,shouldShow:l,tippyOptions:a});return u.registerPlugin(d),()=>{u.unregisterPlugin(s)}},[e.editor,r,t]),x.createElement("div",{ref:n,className:e.className,style:{visibility:"hidden"}},e.children)},Ie=x.createContext({onDragStart:void 0}),$e=()=>x.useContext(Ie),ao=e=>{const t=e.as||"div",{nodeViewContentRef:n}=$e();return x.createElement(t,{...e,ref:n,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...e.style}})},lo=x.forwardRef((e,t)=>{const{onDragStart:n}=$e(),r=e.as||"div";return x.createElement(r,{...e,ref:t,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...e.style}})});function co(e){return!!(typeof e=="function"&&e.prototype&&e.prototype.isReactComponent)}function uo(e){var t;return typeof e=="object"&&((t=e.$$typeof)===null||t===void 0?void 0:t.toString())==="Symbol(react.forward_ref)"}class Be{constructor(t,{editor:n,props:r={},as:o="div",className:s=""}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=n,this.props=r,this.element=document.createElement(o),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),this.editor.isInitialized?ve.flushSync(()=>{this.render()}):this.render()}render(){var t;const n=this.component,r=this.props,o=this.editor;(co(n)||uo(n))&&(r.ref=s=>{this.ref=s}),this.reactElement=x.createElement(n,{...r}),(t=o==null?void 0:o.contentComponent)===null||t===void 0||t.setRenderer(this.id,this)}updateProps(t={}){this.props={...this.props,...t},this.render()}destroy(){var t;const n=this.editor;(t=n==null?void 0:n.contentComponent)===null||t===void 0||t.removeRenderer(this.id)}updateAttributes(t){Object.keys(t).forEach(n=>{this.element.setAttribute(n,t[n])})}}class po extends Nr{mount(){const t={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(l={})=>this.updateAttributes(l),deleteNode:()=>this.deleteNode()};if(!this.component.displayName){const l=u=>u.charAt(0).toUpperCase()+u.substring(1);this.component.displayName=l(this.extension.name)}const o={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:l=>{l&&this.contentDOMElement&&l.firstChild!==this.contentDOMElement&&l.appendChild(this.contentDOMElement)}},s=this.component,i=x.memo(l=>x.createElement(Ie.Provider,{value:o},x.createElement(s,l)));i.displayName="ReactNodeView",this.node.isLeaf?this.contentDOMElement=null:this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement&&(this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.style.whiteSpace="inherit");let a=this.node.isInline?"span":"div";this.options.as&&(a=this.options.as);const{className:c=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new Be(i,{editor:this.editor,props:t,as:a,className:`node-${this.node.type.name} ${c}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var t;if(this.renderer.element.firstElementChild&&!(!((t=this.renderer.element.firstElementChild)===null||t===void 0)&&t.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){const{from:t,to:n}=this.editor.state.selection,r=this.getPos();if(typeof r=="number")if(t<=r&&n>=r+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(t,n,r){const o=s=>{this.renderer.updateProps(s),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(t.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const s=this.node,i=this.decorations,a=this.innerDecorations;return this.node=t,this.decorations=n,this.innerDecorations=r,this.options.update({oldNode:s,oldDecorations:i,newNode:t,newDecorations:n,oldInnerDecorations:a,innerDecorations:r,updateProps:()=>o({node:t,decorations:n,innerDecorations:r})})}return t===this.node&&this.decorations===n&&this.innerDecorations===r||(this.node=t,this.decorations=n,this.innerDecorations=r,o({node:t,decorations:n,innerDecorations:r})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let t={};if(typeof this.options.attrs=="function"){const n=this.editor.extensionManager.attributes,r=ct(this.node,n);t=this.options.attrs({node:this.node,HTMLAttributes:r})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}}function ho(e,t){return n=>n.editor.contentComponent?new po(e,n,t):{}}const fo=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,mo=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,go=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,yo=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,vo=N.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>e.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:e=>e.type.name===this.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return["strong",A(this.options.HTMLAttributes,e),0]},addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[U({find:fo,type:this.type}),U({find:go,type:this.type})]},addPasteRules(){return[z({find:mo,type:this.type}),z({find:yo,type:this.type})]}}),bo=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Mo=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,So=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,ko=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,wo=N.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>e.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",A(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[U({find:bo,type:this.type}),U({find:So,type:this.type})]},addPasteRules(){return[z({find:Mo,type:this.type}),z({find:ko,type:this.type})]}}),Eo=N.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["u",A(this.options.HTMLAttributes,e),0]},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),To=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Co=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,xo=N.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["s",A(this.options.HTMLAttributes,e),0]},addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[U({find:To,type:this.type})]},addPasteRules(){return[z({find:Co,type:this.type})]}}),Ao=/(^|[^`])`([^`]+)`(?!`)/,Oo=/(^|[^`])`([^`]+)`(?!`)/g,Lo=N.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:e}){return["code",A(this.options.HTMLAttributes,e),0]},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[U({find:Ao,type:this.type})]},addPasteRules(){return[z({find:Oo,type:this.type})]}}),Po=/^```([a-z]+)?[\s\n]$/,Ro=/^~~~([a-z]+)?[\s\n]$/,Ho=R.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{var t;const{languageClassPrefix:n}=this.options,s=[...((t=e.firstElementChild)===null||t===void 0?void 0:t.classList)||[]].filter(i=>i.startsWith(n)).map(i=>i.replace(n,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:e,HTMLAttributes:t}){return["pre",A(this.options.HTMLAttributes,t),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:t}=e,{selection:n}=t,{$from:r,empty:o}=n;if(!o||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,i=r.parent.textContent.endsWith(`
113
113
 
114
- `);return!s||!i?!1:e.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;const{state:t}=e,{selection:n,doc:r}=t,{$from:o,empty:s}=n;if(!s||o.parent.type!==this.type||!(o.parentOffset===o.parent.nodeSize-2))return!1;const a=o.after();return a===void 0?!1:r.nodeAt(a)?e.commands.command(({tr:l})=>(l.setSelection(g.Selection.near(r.resolve(a))),!0)):e.commands.exitCode()}}},addInputRules(){return[It({find:Ro,type:this.type,getAttributes:e=>({language:e[1]})}),It({find:Ho,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new g.Plugin({key:new g.PluginKey("codeBlockVSCodeHandler"),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;const n=t.clipboardData.getData("text/plain"),r=t.clipboardData.getData("vscode-editor-data"),o=r?JSON.parse(r):void 0,s=o==null?void 0:o.mode;if(!n||!s)return!1;const{tr:i,schema:a}=e.state,c=a.text(n.replace(/\r\n?/g,`
115
- `));return i.replaceSelectionWith(this.type.create({language:s},c)),i.selection.$from.parent.type!==this.type&&i.setSelection(g.TextSelection.near(i.doc.resolve(Math.max(0,i.selection.from-2)))),i.setMeta("paste",!0),e.dispatch(i),!0}}})]}}),Do=e=>{if(!e.children.length)return;const t=e.querySelectorAll("span");t&&t.forEach(n=>{var r,o;const s=n.getAttribute("style"),i=(o=(r=n.parentElement)===null||r===void 0?void 0:r.closest("span"))===null||o===void 0?void 0:o.getAttribute("style");n.setAttribute("style",`${i};${s}`)})},No=N.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:e=>e.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&Do(e),{}):!1}]},renderHTML({HTMLAttributes:e}){return["span",A(this.options.HTMLAttributes,e),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:e})=>{const{selection:t}=e;return e.doc.nodesBetween(t.from,t.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(o=>o.type===this.type).some(o=>Object.values(o.attrs).some(s=>!!s))||e.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),Io=H.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:e=>e.style.fontFamily,renderHTML:e=>e.fontFamily?{style:`font-family: ${e.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:e=>({chain:t})=>t().setMark("textStyle",{fontFamily:e}).run(),unsetFontFamily:()=>({chain:e})=>e().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),$o=R.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,A(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>It({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),Bo=H.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{const t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>e.textAlign?{style:`text-align: ${e.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).every(n=>n):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,"textAlign")).every(t=>t)}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),jo=H.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:e=>{var t;return(t=e.style.color)===null||t===void 0?void 0:t.replace(/['"]+/g,"")},renderHTML:e=>e.color?{style:`color: ${e.color}`}:{}}}}]},addCommands(){return{setColor:e=>({chain:t})=>t().setMark("textStyle",{color:e}).run(),unsetColor:()=>({chain:e})=>e().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),Fo=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,zo=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,Vo=N.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute("data-color")||e.style.backgroundColor,renderHTML:e=>e.color?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:e}){return["mark",A(this.options.HTMLAttributes,e),0]},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[U({find:Fo,type:this.type})]},addPasteRules(){return[z({find:zo,type:this.type})]}}),Wo="listItem",le="textStyle",ce=/^\s*([-+*])\s$/,Ko=R.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:e}){return["ul",A(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Wo,this.editor.getAttributes(le)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=X({find:ce,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=X({find:ce,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(le),editor:this.editor})),[e]}}),Uo="listItem",de="textStyle",ue=/^(\d+)\.\s$/,qo=R.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:void 0,parseHTML:e=>e.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:e}){const{start:t,...n}=e;return t===1?["ol",A(this.options.HTMLAttributes,n),0]:["ol",A(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Uo,this.editor.getAttributes(de)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=X({find:ue,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=X({find:ue,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(de)}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1],editor:this.editor})),[e]}}),Go=/^\s*(\[([( |x])?\])\s$/,Jo=R.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList"}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{const t=e.getAttribute("data-checked");return t===""||t==="true"},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:e,HTMLAttributes:t}){return["li",A(this.options.HTMLAttributes,t,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:e.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{const o=document.createElement("li"),s=document.createElement("label"),i=document.createElement("span"),a=document.createElement("input"),c=document.createElement("div");return s.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",l=>l.preventDefault()),a.addEventListener("change",l=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}const{checked:u}=l.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:d})=>{const p=n();if(typeof p!="number")return!1;const h=d.doc.nodeAt(p);return d.setNodeMarkup(p,void 0,{...h==null?void 0:h.attrs,checked:u}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,u)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([l,u])=>{o.setAttribute(l,u)}),o.dataset.checked=e.attrs.checked,a.checked=e.attrs.checked,s.append(a,i),o.append(s,c),Object.entries(t).forEach(([l,u])=>{o.setAttribute(l,u)}),{dom:o,contentDOM:c,update:l=>l.type!==this.type?!1:(o.dataset.checked=l.attrs.checked,a.checked=l.attrs.checked,!0)}}},addInputRules(){return[X({find:Go,type:this.type,getAttributes:e=>({checked:e[e.length-1]==="x"})})]}}),Yo=R.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return["ul",A(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),Xo=/^\s*>\s$/,Qo=R.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",A(this.options.HTMLAttributes,e),0]},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[X({find:Xo,type:this.type})]}});function Zo(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?["()","[]"].includes(e[0].value+e[2].value):!1}function ts(e){return new g.Plugin({key:new g.PluginKey("autolink"),appendTransaction:(t,n,r)=>{const o=t.some(l=>l.docChanged)&&!n.doc.eq(r.doc),s=t.some(l=>l.getMeta("preventAutolink"));if(!o||s)return;const{tr:i}=r,a=Xn(n.doc,[...t]);if(sr(a).forEach(({newRange:l})=>{const u=tr(r.doc,l,h=>h.isTextblock);let d,p;if(u.length>1?(d=u[0],p=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ")):u.length&&r.doc.textBetween(l.from,l.to," "," ").endsWith(" ")&&(d=u[0],p=r.doc.textBetween(d.pos,l.to,void 0," ")),d&&p){const h=p.split(" ").filter(v=>v!=="");if(h.length<=0)return!1;const m=h[h.length-1],f=d.pos+p.lastIndexOf(m);if(!m)return!1;const y=g.tokenize(m).map(v=>v.toObject(e.defaultProtocol));if(!Zo(y))return!1;y.filter(v=>v.isLink).map(v=>({...v,from:f+v.start+1,to:f+v.end+1})).filter(v=>r.schema.marks.code?!r.doc.rangeHasMark(v.from,v.to,r.schema.marks.code):!0).filter(v=>e.validate(v.value)).filter(v=>e.shouldAutoLink(v.value)).forEach(v=>{Kt(v.from,v.to,r.doc).some(S=>S.mark.type===e.type)||i.addMark(v.from,v.to,e.type.create({href:v.href}))})}}),!!i.steps.length)return i}})}function es(e){return new g.Plugin({key:new g.PluginKey("handleClickLink"),props:{handleClick:(t,n,r)=>{var o,s;if(r.button!==0||!t.editable)return!1;let i=r.target;const a=[];for(;i.nodeName!=="DIV";)a.push(i),i=i.parentNode;if(!a.find(p=>p.nodeName==="A"))return!1;const c=He(t.state,e.type.name),l=r.target,u=(o=l==null?void 0:l.href)!==null&&o!==void 0?o:c.href,d=(s=l==null?void 0:l.target)!==null&&s!==void 0?s:c.target;return l&&u?(window.open(u,d),!0):!1}}})}function ns(e){return new g.Plugin({key:new g.PluginKey("handlePasteLink"),props:{handlePaste:(t,n,r)=>{const{state:o}=t,{selection:s}=o,{empty:i}=s;if(i)return!1;let a="";r.content.forEach(l=>{a+=l.textContent});const c=g.find(a,{defaultProtocol:e.defaultProtocol}).find(l=>l.isLink&&l.value===a);return!a||!c?!1:e.editor.commands.setMark(e.type,{href:c.href})}}})}const rs=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function W(e,t){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return t&&t.forEach(r=>{const o=typeof r=="string"?r:r.scheme;o&&n.push(o)}),!e||e.replace(rs,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const os=N.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{if(typeof e=="string"){g.registerCustomProtocol(e);return}g.registerCustomProtocol(e.scheme,e.optionalSlashes)})},onDestroy(){g.reset()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(e,t)=>!!W(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>!!e}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:e=>{const t=e.getAttribute("href");return!t||!this.options.isAllowedUri(t,{defaultValidate:n=>!!W(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:t=>!!W(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",A(this.options.HTMLAttributes,e),0]:["a",A(this.options.HTMLAttributes,{...e,href:""}),0]},addCommands(){return{setLink:e=>({chain:t})=>{const{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:r=>!!W(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta("preventAutolink",!0).run():!1},toggleLink:e=>({chain:t})=>{const{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:r=>!!W(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[z({find:e=>{const t=[];if(e){const{protocols:n,defaultProtocol:r}=this.options,o=g.find(e).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:i=>!!W(i,n),protocols:n,defaultProtocol:r}));o.length&&o.forEach(s=>t.push({text:s.value,data:{href:s.href},index:s.start}))}return t},type:this.type,getAttributes:e=>{var t;return{href:(t=e.data)===null||t===void 0?void 0:t.href}}})]},addProseMirrorPlugins(){const e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(ts({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!W(o,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&e.push(es({type:this.type})),this.options.linkOnPaste&&e.push(ns({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),e}}),ss=R.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",A(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{const{selection:n}=t,{$from:r,$to:o}=n,s=e();return r.parentOffset===0?s.insertContentAt({from:Math.max(r.pos-1,0),to:o.pos},{type:this.name}):De(n)?s.insertContentAt(o.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({tr:i,dispatch:a})=>{var c;if(a){const{$to:l}=i.selection,u=l.end();if(l.nodeAfter)l.nodeAfter.isTextblock?i.setSelection(g.TextSelection.create(i.doc,l.pos+1)):l.nodeAfter.isBlock?i.setSelection(g.NodeSelection.create(i.doc,l.pos)):i.setSelection(g.TextSelection.create(i.doc,l.pos));else{const d=(c=l.parent.type.contentMatch.defaultType)===null||c===void 0?void 0:c.create();d&&(i.insert(u,d),i.setSelection(g.TextSelection.create(i.doc,u+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Ut({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),is=H.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>g.undo(e,t),redo:()=>({state:e,dispatch:t})=>g.redo(e,t)}},addProseMirrorPlugins(){return[g.history(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),as=H.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:e=>e.length,wordCounter:e=>e.split(" ").filter(t=>t!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{const t=(e==null?void 0:e.node)||this.editor.state.doc;if(((e==null?void 0:e.mode)||this.options.mode)==="textSize"){const r=t.textBetween(0,t.content.size,void 0," ");return this.options.textCounter(r)}return t.nodeSize},this.storage.words=e=>{const t=(e==null?void 0:e.node)||this.editor.state.doc,n=t.textBetween(0,t.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new g.Plugin({key:new g.PluginKey("characterCount"),appendTransaction:(t,n,r)=>{if(e)return;const o=this.options.limit;if(o==null||o===0){e=!0;return}const s=this.storage.characters({node:r.doc});if(s>o){const i=s-o,a=0,c=i;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);const l=r.tr.deleteRange(a,c);return e=!0,l}e=!0},filterTransaction:(t,n)=>{const r=this.options.limit;if(!t.docChanged||r===0||r===null||r===void 0)return!0;const o=this.storage.characters({node:n.doc}),s=this.storage.characters({node:t.doc});if(s<=r||o>r&&s>r&&s<=o)return!0;if(o>r&&s>r&&s>o||!t.getMeta("paste"))return!1;const a=t.selection.$head.pos,c=s-r,l=a-c,u=a;return t.deleteRange(l,u),!(this.storage.characters({node:t.doc})>r)}})]}}),ls=H.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[g.dropCursor(this.options)]}}),cs=H.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new g.Plugin({key:new g.PluginKey("focus"),props:{decorations:({doc:e,selection:t})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:o}=t,s=[];if(!n||!r)return g.DecorationSet.create(e,[]);let i=0;this.options.mode==="deepest"&&e.descendants((c,l)=>{if(c.isText)return;if(!(o>=l&&o<=l+c.nodeSize-1))return!1;i+=1});let a=0;return e.descendants((c,l)=>{if(c.isText||!(o>=l&&o<=l+c.nodeSize-1))return!1;if(a+=1,this.options.mode==="deepest"&&i-a>0||this.options.mode==="shallowest"&&a>1)return this.options.mode==="deepest";s.push(g.Decoration.node(l,l+c.nodeSize,{class:this.options.className}))}),g.DecorationSet.create(e,s)}}})]}}),ds=H.create({name:"gapCursor",addProseMirrorPlugins(){return[g.gapCursor()]},extendNodeSchema(e){var t;const n={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:(t=T(w(e,"allowGapCursor",n)))!==null&&t!==void 0?t:null}}}),us=R.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:e}){return["br",A(this.options.HTMLAttributes,e)]},renderText(){return`
116
- `},addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{const{selection:o,storedMarks:s}=n;if(o.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:a}=r.extensionManager,c=s||o.$to.parentOffset&&o.$from.marks();return t().insertContent({type:this.name}).command(({tr:l,dispatch:u})=>{if(u&&c&&i){const d=c.filter(p=>a.includes(p.type.name));l.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),ps=R.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:e}){return["li",A(this.options.HTMLAttributes,e),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),hs=R.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",A(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),fs=H.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new g.Plugin({key:new g.PluginKey("placeholder"),props:{decorations:({doc:e,selection:t})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=t,o=[];if(!n)return null;const s=this.editor.isEmpty;return e.descendants((i,a)=>{const c=r>=a&&r<=a+i.nodeSize,l=!i.isLeaf&&kt(i);if((c||!this.options.showOnlyCurrent)&&l){const u=[this.options.emptyNodeClass];s&&u.push(this.options.emptyEditorClass);const d=g.Decoration.node(a,a+i.nodeSize,{class:u.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:i,pos:a,hasAnchor:c}):this.options.placeholder});o.push(d)}return this.options.includeChildren}),g.DecorationSet.create(e,o)}}})]}}),ms=R.create({name:"text",group:"inline"}),gs=R.create({name:"doc",topNode:!0,content:"block+"}),ys=N.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(e){return e!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:e}){return["sub",A(this.options.HTMLAttributes,e),0]},addCommands(){return{setSubscript:()=>({commands:e})=>e.setMark(this.name),toggleSubscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSubscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),vs=N.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(e){return e!=="super"?!1:null}}]},renderHTML({HTMLAttributes:e}){return["sup",A(this.options.HTMLAttributes,e),0]},addCommands(){return{setSuperscript:()=>({commands:e})=>e.setMark(this.name),toggleSuperscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSuperscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}});function bs(e){var t;const{char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:s,startOfLine:i,$position:a}=e,c=r&&!o,l=$r(n),u=new RegExp(`\\s${l}$`),d=i?"^":"",p=o?"":l,h=c?new RegExp(`${d}${l}.*?(?=\\s${p}|$)`,"gm"):new RegExp(`${d}(?:^)?${l}[^\\s${p}]*`,"gm"),m=((t=a.nodeBefore)===null||t===void 0?void 0:t.isText)&&a.nodeBefore.text;if(!m)return null;const f=a.pos-m.length,y=Array.from(m.matchAll(h)).pop();if(!y||y.input===void 0||y.index===void 0)return null;const v=y.input.slice(Math.max(0,y.index-1),y.index),S=new RegExp(`^[${s==null?void 0:s.join("")}\0]?$`).test(v);if(s!==null&&!S)return null;const M=f+y.index;let b=M+y[0].length;return c&&u.test(m.slice(b-1,b+1))&&(y[0]+=" ",b+=1),M<a.pos&&b>=a.pos?{range:{from:M,to:b},query:y[0].slice(n.length),text:y[0]}:null}const Ms=new g.PluginKey("suggestion");function Fe({pluginKey:e=Ms,editor:t,char:n="@",allowSpaces:r=!1,allowToIncludeChar:o=!1,allowedPrefixes:s=[" "],startOfLine:i=!1,decorationTag:a="span",decorationClass:c="suggestion",command:l=()=>null,items:u=()=>[],render:d=()=>({}),allow:p=()=>!0,findSuggestionMatch:h=bs}){let m;const f=d==null?void 0:d(),y=new g.Plugin({key:e,view(){return{update:async(v,S)=>{var M,b,E,k,C,L,P;const O=(M=this.key)===null||M===void 0?void 0:M.getState(S),D=(b=this.key)===null||b===void 0?void 0:b.getState(v.state),I=O.active&&D.active&&O.range.from!==D.range.from,q=!O.active&&D.active,G=O.active&&!D.active,Q=!q&&!G&&O.query!==D.query,B=q||I&&Q,F=Q||I,Et=G||I&&Q;if(!B&&!F&&!Et)return;const J=Et&&!B?O:D,Yt=v.dom.querySelector(`[data-decoration-id="${J.decorationId}"]`);m={editor:t,range:J.range,query:J.query,text:J.text,items:[],command:Z=>l({editor:t,range:J.range,props:Z}),decorationNode:Yt,clientRect:Yt?()=>{var Z;const{decorationId:We}=(Z=this.key)===null||Z===void 0?void 0:Z.getState(t.state),Tt=v.dom.querySelector(`[data-decoration-id="${We}"]`);return(Tt==null?void 0:Tt.getBoundingClientRect())||null}:null},B&&((E=f==null?void 0:f.onBeforeStart)===null||E===void 0||E.call(f,m)),F&&((k=f==null?void 0:f.onBeforeUpdate)===null||k===void 0||k.call(f,m)),(F||B)&&(m.items=await u({editor:t,query:J.query})),Et&&((C=f==null?void 0:f.onExit)===null||C===void 0||C.call(f,m)),F&&((L=f==null?void 0:f.onUpdate)===null||L===void 0||L.call(f,m)),B&&((P=f==null?void 0:f.onStart)===null||P===void 0||P.call(f,m))},destroy:()=>{var v;m&&((v=f==null?void 0:f.onExit)===null||v===void 0||v.call(f,m))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(v,S,M,b){const{isEditable:E}=t,{composing:k}=t.view,{selection:C}=v,{empty:L,from:P}=C,O={...S};if(O.composing=k,E&&(L||t.view.composing)){(P<S.range.from||P>S.range.to)&&!k&&!S.composing&&(O.active=!1);const D=h({char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:s,startOfLine:i,$position:C.$from}),I=`id_${Math.floor(Math.random()*4294967295)}`;D&&p({editor:t,state:b,range:D.range,isActive:S.active})?(O.active=!0,O.decorationId=S.decorationId?S.decorationId:I,O.range=D.range,O.query=D.query,O.text=D.text):O.active=!1}else O.active=!1;return O.active||(O.decorationId=null,O.range={from:0,to:0},O.query=null,O.text=null),O}},props:{handleKeyDown(v,S){var M;const{active:b,range:E}=y.getState(v.state);return b&&((M=f==null?void 0:f.onKeyDown)===null||M===void 0?void 0:M.call(f,{view:v,event:S,range:E}))||!1},decorations(v){const{active:S,range:M,decorationId:b}=y.getState(v);return S?g.DecorationSet.create(v.doc,[g.Decoration.inline(M.from,M.to,{nodeName:a,class:c,"data-decoration-id":b})]):null}}});return y}const Ss=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,ks=R.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:e}){return["img",A(this.options.HTMLAttributes,e)]},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[Ut({find:Ss,type:this.type,getAttributes:e=>{const[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}}),ws=R.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:e}){return["tr",A(this.options.HTMLAttributes,e),0]}});function Ft(e,t){return t?["width",`${Math.max(t,e)}px`]:["min-width",`${e}px`]}function pe(e,t,n,r,o,s){var i;let a=0,c=!0,l=t.firstChild;const u=e.firstChild;if(u!==null)for(let d=0,p=0;d<u.childCount;d+=1){const{colspan:h,colwidth:m}=u.child(d).attrs;for(let f=0;f<h;f+=1,p+=1){const y=o===p?s:m&&m[f],v=y?`${y}px`:"";if(a+=y||r,y||(c=!1),l){if(l.style.width!==v){const[S,M]=Ft(r,y);l.style.setProperty(S,M)}l=l.nextSibling}else{const S=document.createElement("col"),[M,b]=Ft(r,y);S.style.setProperty(M,b),t.appendChild(S)}}}for(;l;){const d=l.nextSibling;(i=l.parentNode)===null||i===void 0||i.removeChild(l),l=d}c?(n.style.width=`${a}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${a}px`)}class Es{constructor(t,n){this.node=t,this.cellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),pe(t,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,pe(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){return t.type==="attributes"&&(t.target===this.table||this.colgroup.contains(t.target))}}function Ts(e,t,n,r){let o=0,s=!0;const i=[],a=e.firstChild;if(!a)return{};for(let d=0,p=0;d<a.childCount;d+=1){const{colspan:h,colwidth:m}=a.child(d).attrs;for(let f=0;f<h;f+=1,p+=1){const y=n===p?r:m&&m[f];o+=y||t,y||(s=!1);const[v,S]=Ft(t,y);i.push(["col",{style:`${v}: ${S}`}])}}const c=s?`${o}px`:"",l=s?"":`${o}px`;return{colgroup:["colgroup",{},...i],tableWidth:c,tableMinWidth:l}}function he(e,t){return e.createAndFill()}function Cs(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;const t={};return Object.keys(e.nodes).forEach(n=>{const r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function xs(e,t,n,r,o){const s=Cs(e),i=[],a=[];for(let l=0;l<n;l+=1){const u=he(s.cell);if(u&&a.push(u),r){const d=he(s.header_cell);d&&i.push(d)}}const c=[];for(let l=0;l<t;l+=1)c.push(s.row.createChecked(null,r&&l===0?i:a));return s.table.createChecked(null,c)}function As(e){return e instanceof g.CellSelection}const at=({editor:e})=>{const{selection:t}=e.state;if(!As(t))return!1;let n=0;const r=Re(t.ranges[0].$from,s=>s.type.name==="table");return r==null||r.node.descendants(s=>{if(s.type.name==="table")return!1;["tableCell","tableHeader"].includes(s.type.name)&&(n+=1)}),n===t.ranges.length?(e.commands.deleteTable(),!0):!1},Os=R.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:Es,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:e,HTMLAttributes:t}){const{colgroup:n,tableWidth:r,tableMinWidth:o}=Ts(e,this.options.cellMinWidth);return["table",A(this.options.HTMLAttributes,t,{style:r?`width: ${r}`:`min-width: ${o}`}),n,["tbody",0]]},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:o,editor:s})=>{const i=xs(s.schema,e,t,n);if(o){const a=r.selection.from+1;r.replaceSelectionWith(i).scrollIntoView().setSelection(g.TextSelection.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>g.addColumnBefore(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>g.addColumnAfter(e,t),deleteColumn:()=>({state:e,dispatch:t})=>g.deleteColumn(e,t),addRowBefore:()=>({state:e,dispatch:t})=>g.addRowBefore(e,t),addRowAfter:()=>({state:e,dispatch:t})=>g.addRowAfter(e,t),deleteRow:()=>({state:e,dispatch:t})=>g.deleteRow(e,t),deleteTable:()=>({state:e,dispatch:t})=>g.deleteTable(e,t),mergeCells:()=>({state:e,dispatch:t})=>g.mergeCells(e,t),splitCell:()=>({state:e,dispatch:t})=>g.splitCell(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>g.toggleHeader("column")(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>g.toggleHeader("row")(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>g.toggleHeaderCell(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>g.mergeCells(e,t)?!0:g.splitCell(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>g.setCellAttr(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>g.goToNextCell(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>g.goToNextCell(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&g.fixTables(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){const r=g.CellSelection.create(t.doc,e.anchorCell,e.headCell);t.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:at,"Mod-Backspace":at,Delete:at,"Mod-Delete":at}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[g.columnResizing({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],g.tableEditing({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(e){const t={name:e.name,options:e.options,storage:e.storage};return{tableRole:T(w(e,"tableRole",t))}}}),Ls=R.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:e}){return["td",A(this.options.HTMLAttributes,e),0]}}),Ps=R.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:e}){return["th",A(this.options.HTMLAttributes,e),0]}}),Rs=new g.PluginKey("mention"),Hs=R.create({name:"mention",priority:101,addOptions(){return{HTMLAttributes:{},renderText({options:e,node:t}){var n;return`${e.suggestion.char}${(n=t.attrs.label)!==null&&n!==void 0?n:t.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:e,node:t}){var n;return["span",A(this.HTMLAttributes,e.HTMLAttributes),`${e.suggestion.char}${(n=t.attrs.label)!==null&&n!==void 0?n:t.attrs.id}`]},suggestion:{char:"@",pluginKey:Rs,command:({editor:e,range:t,props:n})=>{var r,o,s;const i=e.view.state.selection.$to.nodeAfter;((r=i==null?void 0:i.text)===null||r===void 0?void 0:r.startsWith(" "))&&(t.to+=1),e.chain().focus().insertContentAt(t,[{type:this.name,attrs:n},{type:"text",text:" "}]).run(),(s=(o=e.view.dom.ownerDocument.defaultView)===null||o===void 0?void 0:o.getSelection())===null||s===void 0||s.collapseToEnd()},allow:({state:e,range:t})=>{const n=e.doc.resolve(t.from),r=e.schema.nodes[this.name];return!!n.parent.type.contentMatch.matchType(r)}}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>e.id?{"data-id":e.id}:{}},label:{default:null,parseHTML:e=>e.getAttribute("data-label"),renderHTML:e=>e.label?{"data-label":e.label}:{}}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:e,HTMLAttributes:t}){if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",A({"data-type":this.name},this.options.HTMLAttributes,t),this.options.renderLabel({options:this.options,node:e})];const n={...this.options};n.HTMLAttributes=A({"data-type":this.name},this.options.HTMLAttributes,t);const r=this.options.renderHTML({options:n,node:e});return typeof r=="string"?["span",A({"data-type":this.name},this.options.HTMLAttributes,t),r]:r},renderText({node:e}){return this.options.renderLabel!==void 0?(console.warn("renderLabel is deprecated use renderText and renderHTML instead"),this.options.renderLabel({options:this.options,node:e})):this.options.renderText({options:this.options,node:e})},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:e,state:t})=>{let n=!1;const{selection:r}=t,{empty:o,anchor:s}=r;return o?(t.doc.nodesBetween(s-1,s,(i,a)=>{if(i.type.name===this.name)return n=!0,e.insertText(this.options.deleteTriggerWithBackspace?"":this.options.suggestion.char||"",a,a+i.nodeSize),!1}),n):!1})}},addProseMirrorPlugins(){return[Fe({editor:this.editor,...this.options.suggestion})]}});function Gt(e,t,n){const r=[],o=e.node(0);n=typeof n=="number"&&n>=0?n:e.sameParent(t)?Math.max(0,e.sharedDepth(t.pos)-1):e.sharedDepth(t.pos);const s=new g.NodeRange(e,t,n),i=s.depth===0?0:o.resolve(s.start).posAtIndex(0);return s.parent.forEach((a,c)=>{const l=i+c,u=l+a.nodeSize;if(l<s.start||l>=s.end)return;const d=new g.SelectionRange(o.resolve(l),o.resolve(u));r.push(d)}),r}class Jt{constructor(t,n){nt(this,"anchor");nt(this,"head");this.anchor=t,this.head=n}map(t){return new Jt(t.map(this.anchor),t.map(this.head))}resolve(t){const n=t.resolve(this.anchor),r=t.resolve(this.head);return new $(n,r)}}class $ extends g.Selection{constructor(n,r,o,s=1){const{doc:i}=n,a=n===r,c=n.pos===i.content.size&&r.pos===i.content.size,l=a&&!c?i.resolve(r.pos+(s>0?1:-1)):r,u=a&&c?i.resolve(n.pos-(s>0?1:-1)):n,d=Gt(u.min(l),u.max(l),o);super(l.pos>=n.pos?d[0].$from:d[d.length-1].$to,l.pos>=n.pos?d[d.length-1].$to:d[0].$from,d);nt(this,"depth");this.depth=o}get $to(){return this.ranges[this.ranges.length-1].$to}eq(n){return n instanceof $&&n.$from.pos===this.$from.pos&&n.$to.pos===this.$to.pos}map(n,r){const o=n.resolve(r.map(this.anchor)),s=n.resolve(r.map(this.head));return new $(o,s)}toJSON(){return{type:"nodeRange",anchor:this.anchor,head:this.head}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){const{doc:n}=this.$from;if(this.isForwards&&this.ranges.length>1){const s=this.ranges.slice(0,-1),i=s[0].$from,a=s[s.length-1].$to;return new $(i,a,this.depth)}const r=this.ranges[0],o=n.resolve(Math.max(0,r.$from.pos-1));return new $(this.$anchor,o,this.depth)}extendForwards(){const{doc:n}=this.$from;if(this.isBackwards&&this.ranges.length>1){const s=this.ranges.slice(1),i=s[0].$from,a=s[s.length-1].$to;return new $(a,i,this.depth)}const r=this.ranges[this.ranges.length-1],o=n.resolve(Math.min(n.content.size,r.$to.pos+1));return new $(this.$anchor,o,this.depth)}static fromJSON(n,r){return new $(n.resolve(r.anchor),n.resolve(r.head))}static create(n,r,o,s,i=1){return new this(n.resolve(r),n.resolve(o),s,i)}getBookmark(){return new Jt(this.anchor,this.head)}}function _s(e){const t=e.cloneNode(!0),n=[e,...Array.from(e.getElementsByTagName("*"))],r=[t,...Array.from(t.getElementsByTagName("*"))];return n.forEach((o,s)=>{r[s].style.cssText=function(i){let a="";const c=getComputedStyle(i);for(let l=0;l<c.length;l+=1)a+=`${c[l]}:${c.getPropertyValue(c[l])};`;return a}(o)}),t}function lt(e,t){return window.getComputedStyle(e)[t]}function Ds(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function fe(e){e.parentNode!==null&&e.parentNode!==void 0&&e.parentNode.removeChild(e)}const ze=e=>{const{x:t,y:n,direction:r,editor:o}=e;let s=null,i=null,a=null,c=t;for(;i===null&&c<window.innerWidth&&c>0;){const l=document.elementsFromPoint(c,n),u=l.findIndex(p=>p.classList.contains("ProseMirror")),d=l.slice(0,u);if(d.length>0){const p=d[0];if(s=p,a=o.view.posAtDOM(p,0),a>=0){i=o.state.doc.nodeAt(Math.max(a-1,0)),(i===null||i.isText)&&(i=o.state.doc.nodeAt(Math.max(a-1,0))),i||(i=o.state.doc.nodeAt(Math.max(a,0)));break}}r==="left"?c-=1:c+=1}return{resultElement:s,resultNode:i,pos:a!==null?a:null}};function Ns(e,t){const{doc:n}=t.view.state,r=ze({editor:t,x:e.clientX,y:e.clientY,direction:"right"});if(!r.resultNode||r.pos===null)return[];const o=e.clientX,s=function(u,d,p){const h=parseInt(lt(u.dom,"paddingLeft"),10),m=parseInt(lt(u.dom,"paddingRight"),10),f=parseInt(lt(u.dom,"borderLeftWidth"),10),y=parseInt(lt(u.dom,"borderLeftWidth"),10),v=u.dom.getBoundingClientRect();return{left:Ds(d,v.left+h+f,v.right-m-y),top:p}}(t.view,o,e.clientY),i=t.view.posAtCoords(s);if(!i)return[];const{pos:a}=i;if(!n.resolve(a).parent)return[];const c=n.resolve(r.pos),l=n.resolve(r.pos+1);return Gt(c,l,0)}const me=(e,t)=>{const n=e.resolve(t),{depth:r}=n;return r===0?t:n.pos-n.parentOffset-1},ge=(e,t)=>{const n=e.nodeAt(t),r=e.resolve(t);let{depth:o}=r,s=n;for(;o>0;){const i=r.node(o);o-=1,o===0&&(s=i)}return s},Ht=(e,t)=>{const n=g.ySyncPluginKey.getState(e);return n?g.absolutePositionToRelativePosition(t,n.type,n.binding.mapping):null},ye=(e,t)=>{let n=t;for(;n&&n.parentNode&&n.parentNode!==e.dom;)n=n.parentNode;return n},Ve=new g.PluginKey("dragHandle"),Is=({pluginKey:e=Ve,element:t,editor:n,tippyOptions:r,onNodeChange:o})=>{const s=document.createElement("div");let i=null,a=!1,c=null,l=-1;return t.addEventListener("dragstart",u=>{const{view:d}=n;if(!u.dataTransfer)return;const{empty:p,$from:h,$to:m}=d.state.selection,f=Ns(u,n),y=Gt(h,m,0),v=y.some(P=>f.find(O=>O.$from===P.$from&&O.$to===P.$to)),S=p||!v?f:y;if(!S.length)return;const{tr:M}=d.state,b=document.createElement("div"),E=S[0].$from.pos,k=S[S.length-1].$to.pos,C=$.create(d.state.doc,E,k),L=C.content();S.forEach(P=>{const O=_s(d.nodeDOM(P.$from.pos));b.append(O)}),b.style.position="absolute",b.style.top="-10000px",document.body.append(b),u.dataTransfer.clearData(),u.dataTransfer.setDragImage(b,0,0),d.dragging={slice:L,move:!0},M.setSelection(C),d.dispatch(M),document.addEventListener("drop",()=>fe(b),{once:!0}),setTimeout(()=>{t&&(t.style.pointerEvents="none")},0)}),t.addEventListener("dragend",()=>{t&&(t.style.pointerEvents="auto")}),new g.Plugin({key:typeof e=="string"?new g.PluginKey(e):e,state:{init:()=>({locked:!1}),apply(u,d,p,h){const m=u.getMeta("lockDragHandle"),f=u.getMeta("hideDragHandle");if(m!==void 0&&(a=m),f&&i)return i.hide(),a=!1,c=null,l=-1,o==null||o({editor:n,node:null,pos:-1}),d;if(u.docChanged&&l!==-1&&t&&i){const y=u.mapping.map(l);y!==l&&(l=y,Ht(h,l))}return d}},view:u=>{var d;return t.draggable=!0,t.style.pointerEvents="auto",(d=n.view.dom.parentElement)===null||d===void 0||d.appendChild(s),s.appendChild(t),s.style.pointerEvents="none",s.style.position="absolute",s.style.top="0",s.style.left="0",i=ve(u.dom,{getReferenceClientRect:null,interactive:!0,trigger:"manual",placement:"left-start",hideOnClick:!1,duration:100,zIndex:10,popperOptions:{modifiers:[{name:"flip",enabled:!1},{name:"preventOverflow",options:{rootBoundary:"document",mainAxis:!1}}]},...r,appendTo:s,content:t}),{update(p,h){if(!t||!i||(t.draggable=!a,u.state.doc.eq(h.doc)||l===-1))return;let m=u.nodeDOM(l);if(m=ye(u,m),m===u.dom||(m==null?void 0:m.nodeType)!==1)return;const f=u.posAtDOM(m,0),y=ge(n.state.doc,f);if(y!==c){const v=me(n.state.doc,f);c=y,l=v,Ht(u.state,l),o==null||o({editor:n,node:c,pos:l}),i.setProps({getReferenceClientRect:()=>m.getBoundingClientRect()}),i.show()}},destroy(){i==null||i.destroy(),t&&fe(s)}}},props:{handleDOMEvents:{mouseleave:(u,d)=>(a||d.target&&!s.contains(d.relatedTarget)&&(i==null||i.hide(),c=null,l=-1,o==null||o({editor:n,node:null,pos:-1})),!1),mousemove(u,d){if(!t||!i||a)return!1;const p=ze({x:d.clientX,y:d.clientY,direction:"right",editor:n});if(!p.resultElement)return!1;let h=p.resultElement;if(h=ye(u,h),h===u.dom||(h==null?void 0:h.nodeType)!==1)return!1;const m=u.posAtDOM(h,0),f=ge(n.state.doc,m);if(f!==c){const y=me(n.state.doc,m);c=f,l=y,Ht(u.state,l),o==null||o({editor:n,node:c,pos:l}),i.setProps({getReferenceClientRect:()=>h.getBoundingClientRect()}),i.show()}return!1}}}})};exports.Blockquote=Qo;exports.Bold=bo;exports.BubbleMenu=ao;exports.BulletList=Ko;exports.CharacterCount=as;exports.Code=Po;exports.CodeBlock=_o;exports.Color=jo;exports.Document=gs;exports.DragHandlePlugin=Is;exports.Dropcursor=ls;exports.EditorContent=Jr;exports.Extension=H;exports.FocusClasses=cs;exports.FontFamily=Io;exports.Gapcursor=ds;exports.HardBreak=us;exports.Heading=$o;exports.Highlight=Vo;exports.History=is;exports.HorizontalRule=ss;exports.Image=ks;exports.Italic=Eo;exports.Link=os;exports.ListItem=ps;exports.Mention=Hs;exports.Node=R;exports.NodeViewContent=lo;exports.NodeViewWrapper=co;exports.OrderedList=qo;exports.Paragraph=hs;exports.Placeholder=fs;exports.ReactNodeViewRenderer=fo;exports.ReactRenderer=je;exports.Strike=Ao;exports.Subscript=ys;exports.Suggestion=Fe;exports.Superscript=vs;exports.Table=Os;exports.TableCell=Ls;exports.TableHeader=Ps;exports.TableRow=ws;exports.TaskItem=Jo;exports.TaskList=Yo;exports.Text=ms;exports.TextAlign=Bo;exports.TextStyle=No;exports.Underline=To;exports.dragHandlePluginDefaultKey=Ve;exports.findChildren=Zn;exports.findParentNode=St;exports.getMarkRange=vt;exports.isActive=_e;exports.isList=Nt;exports.isNumber=ke;exports.mergeAttributes=A;exports.nodeInputRule=Ut;exports.nodePasteRule=Br;exports.useEditor=so;
114
+ `);return!s||!i?!1:e.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;const{state:t}=e,{selection:n,doc:r}=t,{$from:o,empty:s}=n;if(!s||o.parent.type!==this.type||!(o.parentOffset===o.parent.nodeSize-2))return!1;const a=o.after();return a===void 0?!1:r.nodeAt(a)?e.commands.command(({tr:l})=>(l.setSelection(g.Selection.near(r.resolve(a))),!0)):e.commands.exitCode()}}},addInputRules(){return[Nt({find:Po,type:this.type,getAttributes:e=>({language:e[1]})}),Nt({find:Ro,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new g.Plugin({key:new g.PluginKey("codeBlockVSCodeHandler"),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;const n=t.clipboardData.getData("text/plain"),r=t.clipboardData.getData("vscode-editor-data"),o=r?JSON.parse(r):void 0,s=o==null?void 0:o.mode;if(!n||!s)return!1;const{tr:i,schema:a}=e.state,c=a.text(n.replace(/\r\n?/g,`
115
+ `));return i.replaceSelectionWith(this.type.create({language:s},c)),i.selection.$from.parent.type!==this.type&&i.setSelection(g.TextSelection.near(i.doc.resolve(Math.max(0,i.selection.from-2)))),i.setMeta("paste",!0),e.dispatch(i),!0}}})]}}),_o=e=>{if(!e.children.length)return;const t=e.querySelectorAll("span");t&&t.forEach(n=>{var r,o;const s=n.getAttribute("style"),i=(o=(r=n.parentElement)===null||r===void 0?void 0:r.closest("span"))===null||o===void 0?void 0:o.getAttribute("style");n.setAttribute("style",`${i};${s}`)})},Do=N.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:e=>e.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&_o(e),{}):!1}]},renderHTML({HTMLAttributes:e}){return["span",A(this.options.HTMLAttributes,e),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:e})=>{const{selection:t}=e;return e.doc.nodesBetween(t.from,t.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(o=>o.type===this.type).some(o=>Object.values(o.attrs).some(s=>!!s))||e.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),No=H.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:e=>e.style.fontFamily,renderHTML:e=>e.fontFamily?{style:`font-family: ${e.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:e=>({chain:t})=>t().setMark("textStyle",{fontFamily:e}).run(),unsetFontFamily:()=>({chain:e})=>e().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),Io=R.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,A(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>Nt({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),$o=H.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{const t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>e.textAlign?{style:`text-align: ${e.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).every(n=>n):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,"textAlign")).every(t=>t)}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),Bo=H.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:e=>{var t;return(t=e.style.color)===null||t===void 0?void 0:t.replace(/['"]+/g,"")},renderHTML:e=>e.color?{style:`color: ${e.color}`}:{}}}}]},addCommands(){return{setColor:e=>({chain:t})=>t().setMark("textStyle",{color:e}).run(),unsetColor:()=>({chain:e})=>e().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),jo=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,Fo=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,zo=N.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute("data-color")||e.style.backgroundColor,renderHTML:e=>e.color?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:e}){return["mark",A(this.options.HTMLAttributes,e),0]},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[U({find:jo,type:this.type})]},addPasteRules(){return[z({find:Fo,type:this.type})]}}),Vo="listItem",ae="textStyle",le=/^\s*([-+*])\s$/,Wo=R.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:e}){return["ul",A(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Vo,this.editor.getAttributes(ae)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=X({find:le,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=X({find:le,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(ae),editor:this.editor})),[e]}}),Ko="listItem",ce="textStyle",de=/^(\d+)\.\s$/,Uo=R.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:void 0,parseHTML:e=>e.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:e}){const{start:t,...n}=e;return t===1?["ol",A(this.options.HTMLAttributes,n),0]:["ol",A(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Ko,this.editor.getAttributes(ce)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=X({find:de,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=X({find:de,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(ce)}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1],editor:this.editor})),[e]}}),qo=/^\s*(\[([( |x])?\])\s$/,Go=R.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList"}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{const t=e.getAttribute("data-checked");return t===""||t==="true"},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:e,HTMLAttributes:t}){return["li",A(this.options.HTMLAttributes,t,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:e.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{const o=document.createElement("li"),s=document.createElement("label"),i=document.createElement("span"),a=document.createElement("input"),c=document.createElement("div");return s.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",l=>l.preventDefault()),a.addEventListener("change",l=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}const{checked:u}=l.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:d})=>{const p=n();if(typeof p!="number")return!1;const h=d.doc.nodeAt(p);return d.setNodeMarkup(p,void 0,{...h==null?void 0:h.attrs,checked:u}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,u)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([l,u])=>{o.setAttribute(l,u)}),o.dataset.checked=e.attrs.checked,a.checked=e.attrs.checked,s.append(a,i),o.append(s,c),Object.entries(t).forEach(([l,u])=>{o.setAttribute(l,u)}),{dom:o,contentDOM:c,update:l=>l.type!==this.type?!1:(o.dataset.checked=l.attrs.checked,a.checked=l.attrs.checked,!0)}}},addInputRules(){return[X({find:qo,type:this.type,getAttributes:e=>({checked:e[e.length-1]==="x"})})]}}),Jo=R.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return["ul",A(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),Yo=/^\s*>\s$/,Xo=R.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",A(this.options.HTMLAttributes,e),0]},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[X({find:Yo,type:this.type})]}});function Qo(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?["()","[]"].includes(e[0].value+e[2].value):!1}function Zo(e){return new g.Plugin({key:new g.PluginKey("autolink"),appendTransaction:(t,n,r)=>{const o=t.some(l=>l.docChanged)&&!n.doc.eq(r.doc),s=t.some(l=>l.getMeta("preventAutolink"));if(!o||s)return;const{tr:i}=r,a=Yn(n.doc,[...t]);if(or(a).forEach(({newRange:l})=>{const u=Zn(r.doc,l,h=>h.isTextblock);let d,p;if(u.length>1?(d=u[0],p=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ")):u.length&&r.doc.textBetween(l.from,l.to," "," ").endsWith(" ")&&(d=u[0],p=r.doc.textBetween(d.pos,l.to,void 0," ")),d&&p){const h=p.split(" ").filter(v=>v!=="");if(h.length<=0)return!1;const m=h[h.length-1],f=d.pos+p.lastIndexOf(m);if(!m)return!1;const y=g.tokenize(m).map(v=>v.toObject(e.defaultProtocol));if(!Qo(y))return!1;y.filter(v=>v.isLink).map(v=>({...v,from:f+v.start+1,to:f+v.end+1})).filter(v=>r.schema.marks.code?!r.doc.rangeHasMark(v.from,v.to,r.schema.marks.code):!0).filter(v=>e.validate(v.value)).filter(v=>e.shouldAutoLink(v.value)).forEach(v=>{Wt(v.from,v.to,r.doc).some(S=>S.mark.type===e.type)||i.addMark(v.from,v.to,e.type.create({href:v.href}))})}}),!!i.steps.length)return i}})}function ts(e){return new g.Plugin({key:new g.PluginKey("handleClickLink"),props:{handleClick:(t,n,r)=>{var o,s;if(r.button!==0||!t.editable)return!1;let i=r.target;const a=[];for(;i.nodeName!=="DIV";)a.push(i),i=i.parentNode;if(!a.find(p=>p.nodeName==="A"))return!1;const c=Re(t.state,e.type.name),l=r.target,u=(o=l==null?void 0:l.href)!==null&&o!==void 0?o:c.href,d=(s=l==null?void 0:l.target)!==null&&s!==void 0?s:c.target;return l&&u?(window.open(u,d),!0):!1}}})}function es(e){return new g.Plugin({key:new g.PluginKey("handlePasteLink"),props:{handlePaste:(t,n,r)=>{const{state:o}=t,{selection:s}=o,{empty:i}=s;if(i)return!1;let a="";r.content.forEach(l=>{a+=l.textContent});const c=g.find(a,{defaultProtocol:e.defaultProtocol}).find(l=>l.isLink&&l.value===a);return!a||!c?!1:e.editor.commands.setMark(e.type,{href:c.href})}}})}const ns=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function W(e,t){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return t&&t.forEach(r=>{const o=typeof r=="string"?r:r.scheme;o&&n.push(o)}),!e||e.replace(ns,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const rs=N.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{if(typeof e=="string"){g.registerCustomProtocol(e);return}g.registerCustomProtocol(e.scheme,e.optionalSlashes)})},onDestroy(){g.reset()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(e,t)=>!!W(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>!!e}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:e=>{const t=e.getAttribute("href");return!t||!this.options.isAllowedUri(t,{defaultValidate:n=>!!W(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:t=>!!W(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",A(this.options.HTMLAttributes,e),0]:["a",A(this.options.HTMLAttributes,{...e,href:""}),0]},addCommands(){return{setLink:e=>({chain:t})=>{const{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:r=>!!W(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta("preventAutolink",!0).run():!1},toggleLink:e=>({chain:t})=>{const{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:r=>!!W(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[z({find:e=>{const t=[];if(e){const{protocols:n,defaultProtocol:r}=this.options,o=g.find(e).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:i=>!!W(i,n),protocols:n,defaultProtocol:r}));o.length&&o.forEach(s=>t.push({text:s.value,data:{href:s.href},index:s.start}))}return t},type:this.type,getAttributes:e=>{var t;return{href:(t=e.data)===null||t===void 0?void 0:t.href}}})]},addProseMirrorPlugins(){const e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(Zo({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!W(o,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&e.push(ts({type:this.type})),this.options.linkOnPaste&&e.push(es({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),e}}),os=R.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",A(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{const{selection:n}=t,{$from:r,$to:o}=n,s=e();return r.parentOffset===0?s.insertContentAt({from:Math.max(r.pos-1,0),to:o.pos},{type:this.name}):_e(n)?s.insertContentAt(o.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({tr:i,dispatch:a})=>{var c;if(a){const{$to:l}=i.selection,u=l.end();if(l.nodeAfter)l.nodeAfter.isTextblock?i.setSelection(g.TextSelection.create(i.doc,l.pos+1)):l.nodeAfter.isBlock?i.setSelection(g.NodeSelection.create(i.doc,l.pos)):i.setSelection(g.TextSelection.create(i.doc,l.pos));else{const d=(c=l.parent.type.contentMatch.defaultType)===null||c===void 0?void 0:c.create();d&&(i.insert(u,d),i.setSelection(g.TextSelection.create(i.doc,u+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Kt({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),ss=H.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>g.undo(e,t),redo:()=>({state:e,dispatch:t})=>g.redo(e,t)}},addProseMirrorPlugins(){return[g.history(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),is=H.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:e=>e.length,wordCounter:e=>e.split(" ").filter(t=>t!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{const t=(e==null?void 0:e.node)||this.editor.state.doc;if(((e==null?void 0:e.mode)||this.options.mode)==="textSize"){const r=t.textBetween(0,t.content.size,void 0," ");return this.options.textCounter(r)}return t.nodeSize},this.storage.words=e=>{const t=(e==null?void 0:e.node)||this.editor.state.doc,n=t.textBetween(0,t.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new g.Plugin({key:new g.PluginKey("characterCount"),appendTransaction:(t,n,r)=>{if(e)return;const o=this.options.limit;if(o==null||o===0){e=!0;return}const s=this.storage.characters({node:r.doc});if(s>o){const i=s-o,a=0,c=i;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);const l=r.tr.deleteRange(a,c);return e=!0,l}e=!0},filterTransaction:(t,n)=>{const r=this.options.limit;if(!t.docChanged||r===0||r===null||r===void 0)return!0;const o=this.storage.characters({node:n.doc}),s=this.storage.characters({node:t.doc});if(s<=r||o>r&&s>r&&s<=o)return!0;if(o>r&&s>r&&s>o||!t.getMeta("paste"))return!1;const a=t.selection.$head.pos,c=s-r,l=a-c,u=a;return t.deleteRange(l,u),!(this.storage.characters({node:t.doc})>r)}})]}}),as=H.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[g.dropCursor(this.options)]}}),ls=H.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new g.Plugin({key:new g.PluginKey("focus"),props:{decorations:({doc:e,selection:t})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:o}=t,s=[];if(!n||!r)return g.DecorationSet.create(e,[]);let i=0;this.options.mode==="deepest"&&e.descendants((c,l)=>{if(c.isText)return;if(!(o>=l&&o<=l+c.nodeSize-1))return!1;i+=1});let a=0;return e.descendants((c,l)=>{if(c.isText||!(o>=l&&o<=l+c.nodeSize-1))return!1;if(a+=1,this.options.mode==="deepest"&&i-a>0||this.options.mode==="shallowest"&&a>1)return this.options.mode==="deepest";s.push(g.Decoration.node(l,l+c.nodeSize,{class:this.options.className}))}),g.DecorationSet.create(e,s)}}})]}}),cs=H.create({name:"gapCursor",addProseMirrorPlugins(){return[g.gapCursor()]},extendNodeSchema(e){var t;const n={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:(t=T(w(e,"allowGapCursor",n)))!==null&&t!==void 0?t:null}}}),ds=R.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:e}){return["br",A(this.options.HTMLAttributes,e)]},renderText(){return`
116
+ `},addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{const{selection:o,storedMarks:s}=n;if(o.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:a}=r.extensionManager,c=s||o.$to.parentOffset&&o.$from.marks();return t().insertContent({type:this.name}).command(({tr:l,dispatch:u})=>{if(u&&c&&i){const d=c.filter(p=>a.includes(p.type.name));l.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),us=R.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:e}){return["li",A(this.options.HTMLAttributes,e),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),ps=R.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",A(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),hs=H.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new g.Plugin({key:new g.PluginKey("placeholder"),props:{decorations:({doc:e,selection:t})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=t,o=[];if(!n)return null;const s=this.editor.isEmpty;return e.descendants((i,a)=>{const c=r>=a&&r<=a+i.nodeSize,l=!i.isLeaf&&St(i);if((c||!this.options.showOnlyCurrent)&&l){const u=[this.options.emptyNodeClass];s&&u.push(this.options.emptyEditorClass);const d=g.Decoration.node(a,a+i.nodeSize,{class:u.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:i,pos:a,hasAnchor:c}):this.options.placeholder});o.push(d)}return this.options.includeChildren}),g.DecorationSet.create(e,o)}}})]}}),fs=R.create({name:"text",group:"inline"}),ms=R.create({name:"doc",topNode:!0,content:"block+"}),gs=N.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(e){return e!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:e}){return["sub",A(this.options.HTMLAttributes,e),0]},addCommands(){return{setSubscript:()=>({commands:e})=>e.setMark(this.name),toggleSubscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSubscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),ys=N.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(e){return e!=="super"?!1:null}}]},renderHTML({HTMLAttributes:e}){return["sup",A(this.options.HTMLAttributes,e),0]},addCommands(){return{setSuperscript:()=>({commands:e})=>e.setMark(this.name),toggleSuperscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSuperscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}});function vs(e){var t;const{char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:s,startOfLine:i,$position:a}=e,c=r&&!o,l=Ir(n),u=new RegExp(`\\s${l}$`),d=i?"^":"",p=o?"":l,h=c?new RegExp(`${d}${l}.*?(?=\\s${p}|$)`,"gm"):new RegExp(`${d}(?:^)?${l}[^\\s${p}]*`,"gm"),m=((t=a.nodeBefore)===null||t===void 0?void 0:t.isText)&&a.nodeBefore.text;if(!m)return null;const f=a.pos-m.length,y=Array.from(m.matchAll(h)).pop();if(!y||y.input===void 0||y.index===void 0)return null;const v=y.input.slice(Math.max(0,y.index-1),y.index),S=new RegExp(`^[${s==null?void 0:s.join("")}\0]?$`).test(v);if(s!==null&&!S)return null;const M=f+y.index;let b=M+y[0].length;return c&&u.test(m.slice(b-1,b+1))&&(y[0]+=" ",b+=1),M<a.pos&&b>=a.pos?{range:{from:M,to:b},query:y[0].slice(n.length),text:y[0]}:null}const bs=new g.PluginKey("suggestion");function je({pluginKey:e=bs,editor:t,char:n="@",allowSpaces:r=!1,allowToIncludeChar:o=!1,allowedPrefixes:s=[" "],startOfLine:i=!1,decorationTag:a="span",decorationClass:c="suggestion",command:l=()=>null,items:u=()=>[],render:d=()=>({}),allow:p=()=>!0,findSuggestionMatch:h=vs}){let m;const f=d==null?void 0:d(),y=new g.Plugin({key:e,view(){return{update:async(v,S)=>{var M,b,E,k,C,L,P;const O=(M=this.key)===null||M===void 0?void 0:M.getState(S),D=(b=this.key)===null||b===void 0?void 0:b.getState(v.state),I=O.active&&D.active&&O.range.from!==D.range.from,q=!O.active&&D.active,G=O.active&&!D.active,Q=!q&&!G&&O.query!==D.query,B=q||I&&Q,F=Q||I,wt=G||I&&Q;if(!B&&!F&&!wt)return;const J=wt&&!B?O:D,Jt=v.dom.querySelector(`[data-decoration-id="${J.decorationId}"]`);m={editor:t,range:J.range,query:J.query,text:J.text,items:[],command:Z=>l({editor:t,range:J.range,props:Z}),decorationNode:Jt,clientRect:Jt?()=>{var Z;const{decorationId:Ve}=(Z=this.key)===null||Z===void 0?void 0:Z.getState(t.state),Et=v.dom.querySelector(`[data-decoration-id="${Ve}"]`);return(Et==null?void 0:Et.getBoundingClientRect())||null}:null},B&&((E=f==null?void 0:f.onBeforeStart)===null||E===void 0||E.call(f,m)),F&&((k=f==null?void 0:f.onBeforeUpdate)===null||k===void 0||k.call(f,m)),(F||B)&&(m.items=await u({editor:t,query:J.query})),wt&&((C=f==null?void 0:f.onExit)===null||C===void 0||C.call(f,m)),F&&((L=f==null?void 0:f.onUpdate)===null||L===void 0||L.call(f,m)),B&&((P=f==null?void 0:f.onStart)===null||P===void 0||P.call(f,m))},destroy:()=>{var v;m&&((v=f==null?void 0:f.onExit)===null||v===void 0||v.call(f,m))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(v,S,M,b){const{isEditable:E}=t,{composing:k}=t.view,{selection:C}=v,{empty:L,from:P}=C,O={...S};if(O.composing=k,E&&(L||t.view.composing)){(P<S.range.from||P>S.range.to)&&!k&&!S.composing&&(O.active=!1);const D=h({char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:s,startOfLine:i,$position:C.$from}),I=`id_${Math.floor(Math.random()*4294967295)}`;D&&p({editor:t,state:b,range:D.range,isActive:S.active})?(O.active=!0,O.decorationId=S.decorationId?S.decorationId:I,O.range=D.range,O.query=D.query,O.text=D.text):O.active=!1}else O.active=!1;return O.active||(O.decorationId=null,O.range={from:0,to:0},O.query=null,O.text=null),O}},props:{handleKeyDown(v,S){var M;const{active:b,range:E}=y.getState(v.state);return b&&((M=f==null?void 0:f.onKeyDown)===null||M===void 0?void 0:M.call(f,{view:v,event:S,range:E}))||!1},decorations(v){const{active:S,range:M,decorationId:b}=y.getState(v);return S?g.DecorationSet.create(v.doc,[g.Decoration.inline(M.from,M.to,{nodeName:a,class:c,"data-decoration-id":b})]):null}}});return y}const Ms=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Ss=R.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:e}){return["img",A(this.options.HTMLAttributes,e)]},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[Kt({find:Ms,type:this.type,getAttributes:e=>{const[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}}),ks=R.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:e}){return["tr",A(this.options.HTMLAttributes,e),0]}});function jt(e,t){return t?["width",`${Math.max(t,e)}px`]:["min-width",`${e}px`]}function ue(e,t,n,r,o,s){var i;let a=0,c=!0,l=t.firstChild;const u=e.firstChild;if(u!==null)for(let d=0,p=0;d<u.childCount;d+=1){const{colspan:h,colwidth:m}=u.child(d).attrs;for(let f=0;f<h;f+=1,p+=1){const y=o===p?s:m&&m[f],v=y?`${y}px`:"";if(a+=y||r,y||(c=!1),l){if(l.style.width!==v){const[S,M]=jt(r,y);l.style.setProperty(S,M)}l=l.nextSibling}else{const S=document.createElement("col"),[M,b]=jt(r,y);S.style.setProperty(M,b),t.appendChild(S)}}}for(;l;){const d=l.nextSibling;(i=l.parentNode)===null||i===void 0||i.removeChild(l),l=d}c?(n.style.width=`${a}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${a}px`)}class ws{constructor(t,n){this.node=t,this.cellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),ue(t,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,ue(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){return t.type==="attributes"&&(t.target===this.table||this.colgroup.contains(t.target))}}function Es(e,t,n,r){let o=0,s=!0;const i=[],a=e.firstChild;if(!a)return{};for(let d=0,p=0;d<a.childCount;d+=1){const{colspan:h,colwidth:m}=a.child(d).attrs;for(let f=0;f<h;f+=1,p+=1){const y=n===p?r:m&&m[f];o+=y||t,y||(s=!1);const[v,S]=jt(t,y);i.push(["col",{style:`${v}: ${S}`}])}}const c=s?`${o}px`:"",l=s?"":`${o}px`;return{colgroup:["colgroup",{},...i],tableWidth:c,tableMinWidth:l}}function pe(e,t){return e.createAndFill()}function Ts(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;const t={};return Object.keys(e.nodes).forEach(n=>{const r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function Cs(e,t,n,r,o){const s=Ts(e),i=[],a=[];for(let l=0;l<n;l+=1){const u=pe(s.cell);if(u&&a.push(u),r){const d=pe(s.header_cell);d&&i.push(d)}}const c=[];for(let l=0;l<t;l+=1)c.push(s.row.createChecked(null,r&&l===0?i:a));return s.table.createChecked(null,c)}function xs(e){return e instanceof g.CellSelection}const it=({editor:e})=>{const{selection:t}=e.state;if(!xs(t))return!1;let n=0;const r=Pe(t.ranges[0].$from,s=>s.type.name==="table");return r==null||r.node.descendants(s=>{if(s.type.name==="table")return!1;["tableCell","tableHeader"].includes(s.type.name)&&(n+=1)}),n===t.ranges.length?(e.commands.deleteTable(),!0):!1},As=R.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:ws,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:e,HTMLAttributes:t}){const{colgroup:n,tableWidth:r,tableMinWidth:o}=Es(e,this.options.cellMinWidth);return["table",A(this.options.HTMLAttributes,t,{style:r?`width: ${r}`:`min-width: ${o}`}),n,["tbody",0]]},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:o,editor:s})=>{const i=Cs(s.schema,e,t,n);if(o){const a=r.selection.from+1;r.replaceSelectionWith(i).scrollIntoView().setSelection(g.TextSelection.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>g.addColumnBefore(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>g.addColumnAfter(e,t),deleteColumn:()=>({state:e,dispatch:t})=>g.deleteColumn(e,t),addRowBefore:()=>({state:e,dispatch:t})=>g.addRowBefore(e,t),addRowAfter:()=>({state:e,dispatch:t})=>g.addRowAfter(e,t),deleteRow:()=>({state:e,dispatch:t})=>g.deleteRow(e,t),deleteTable:()=>({state:e,dispatch:t})=>g.deleteTable(e,t),mergeCells:()=>({state:e,dispatch:t})=>g.mergeCells(e,t),splitCell:()=>({state:e,dispatch:t})=>g.splitCell(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>g.toggleHeader("column")(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>g.toggleHeader("row")(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>g.toggleHeaderCell(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>g.mergeCells(e,t)?!0:g.splitCell(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>g.setCellAttr(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>g.goToNextCell(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>g.goToNextCell(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&g.fixTables(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){const r=g.CellSelection.create(t.doc,e.anchorCell,e.headCell);t.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:it,"Mod-Backspace":it,Delete:it,"Mod-Delete":it}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[g.columnResizing({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],g.tableEditing({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(e){const t={name:e.name,options:e.options,storage:e.storage};return{tableRole:T(w(e,"tableRole",t))}}}),Os=R.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:e}){return["td",A(this.options.HTMLAttributes,e),0]}}),Ls=R.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:e}){return["th",A(this.options.HTMLAttributes,e),0]}}),Ps=new g.PluginKey("mention"),Rs=R.create({name:"mention",priority:101,addOptions(){return{HTMLAttributes:{},renderText({options:e,node:t}){var n;return`${e.suggestion.char}${(n=t.attrs.label)!==null&&n!==void 0?n:t.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:e,node:t}){var n;return["span",A(this.HTMLAttributes,e.HTMLAttributes),`${e.suggestion.char}${(n=t.attrs.label)!==null&&n!==void 0?n:t.attrs.id}`]},suggestion:{char:"@",pluginKey:Ps,command:({editor:e,range:t,props:n})=>{var r,o,s;const i=e.view.state.selection.$to.nodeAfter;((r=i==null?void 0:i.text)===null||r===void 0?void 0:r.startsWith(" "))&&(t.to+=1),e.chain().focus().insertContentAt(t,[{type:this.name,attrs:n},{type:"text",text:" "}]).run(),(s=(o=e.view.dom.ownerDocument.defaultView)===null||o===void 0?void 0:o.getSelection())===null||s===void 0||s.collapseToEnd()},allow:({state:e,range:t})=>{const n=e.doc.resolve(t.from),r=e.schema.nodes[this.name];return!!n.parent.type.contentMatch.matchType(r)}}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>e.id?{"data-id":e.id}:{}},label:{default:null,parseHTML:e=>e.getAttribute("data-label"),renderHTML:e=>e.label?{"data-label":e.label}:{}}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:e,HTMLAttributes:t}){if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",A({"data-type":this.name},this.options.HTMLAttributes,t),this.options.renderLabel({options:this.options,node:e})];const n={...this.options};n.HTMLAttributes=A({"data-type":this.name},this.options.HTMLAttributes,t);const r=this.options.renderHTML({options:n,node:e});return typeof r=="string"?["span",A({"data-type":this.name},this.options.HTMLAttributes,t),r]:r},renderText({node:e}){return this.options.renderLabel!==void 0?(console.warn("renderLabel is deprecated use renderText and renderHTML instead"),this.options.renderLabel({options:this.options,node:e})):this.options.renderText({options:this.options,node:e})},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:e,state:t})=>{let n=!1;const{selection:r}=t,{empty:o,anchor:s}=r;return o?(t.doc.nodesBetween(s-1,s,(i,a)=>{if(i.type.name===this.name)return n=!0,e.insertText(this.options.deleteTriggerWithBackspace?"":this.options.suggestion.char||"",a,a+i.nodeSize),!1}),n):!1})}},addProseMirrorPlugins(){return[je({editor:this.editor,...this.options.suggestion})]}});function qt(e,t,n){const r=[],o=e.node(0);n=typeof n=="number"&&n>=0?n:e.sameParent(t)?Math.max(0,e.sharedDepth(t.pos)-1):e.sharedDepth(t.pos);const s=new g.NodeRange(e,t,n),i=s.depth===0?0:o.resolve(s.start).posAtIndex(0);return s.parent.forEach((a,c)=>{const l=i+c,u=l+a.nodeSize;if(l<s.start||l>=s.end)return;const d=new g.SelectionRange(o.resolve(l),o.resolve(u));r.push(d)}),r}class Gt{constructor(t,n){et(this,"anchor");et(this,"head");this.anchor=t,this.head=n}map(t){return new Gt(t.map(this.anchor),t.map(this.head))}resolve(t){const n=t.resolve(this.anchor),r=t.resolve(this.head);return new $(n,r)}}class $ extends g.Selection{constructor(n,r,o,s=1){const{doc:i}=n,a=n===r,c=n.pos===i.content.size&&r.pos===i.content.size,l=a&&!c?i.resolve(r.pos+(s>0?1:-1)):r,u=a&&c?i.resolve(n.pos-(s>0?1:-1)):n,d=qt(u.min(l),u.max(l),o);super(l.pos>=n.pos?d[0].$from:d[d.length-1].$to,l.pos>=n.pos?d[d.length-1].$to:d[0].$from,d);et(this,"depth");this.depth=o}get $to(){return this.ranges[this.ranges.length-1].$to}eq(n){return n instanceof $&&n.$from.pos===this.$from.pos&&n.$to.pos===this.$to.pos}map(n,r){const o=n.resolve(r.map(this.anchor)),s=n.resolve(r.map(this.head));return new $(o,s)}toJSON(){return{type:"nodeRange",anchor:this.anchor,head:this.head}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){const{doc:n}=this.$from;if(this.isForwards&&this.ranges.length>1){const s=this.ranges.slice(0,-1),i=s[0].$from,a=s[s.length-1].$to;return new $(i,a,this.depth)}const r=this.ranges[0],o=n.resolve(Math.max(0,r.$from.pos-1));return new $(this.$anchor,o,this.depth)}extendForwards(){const{doc:n}=this.$from;if(this.isBackwards&&this.ranges.length>1){const s=this.ranges.slice(1),i=s[0].$from,a=s[s.length-1].$to;return new $(a,i,this.depth)}const r=this.ranges[this.ranges.length-1],o=n.resolve(Math.min(n.content.size,r.$to.pos+1));return new $(this.$anchor,o,this.depth)}static fromJSON(n,r){return new $(n.resolve(r.anchor),n.resolve(r.head))}static create(n,r,o,s,i=1){return new this(n.resolve(r),n.resolve(o),s,i)}getBookmark(){return new Gt(this.anchor,this.head)}}function Hs(e){const t=e.cloneNode(!0),n=[e,...Array.from(e.getElementsByTagName("*"))],r=[t,...Array.from(t.getElementsByTagName("*"))];return n.forEach((o,s)=>{r[s].style.cssText=function(i){let a="";const c=getComputedStyle(i);for(let l=0;l<c.length;l+=1)a+=`${c[l]}:${c.getPropertyValue(c[l])};`;return a}(o)}),t}function at(e,t){return window.getComputedStyle(e)[t]}function _s(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function he(e){e.parentNode!==null&&e.parentNode!==void 0&&e.parentNode.removeChild(e)}const Fe=e=>{const{x:t,y:n,direction:r,editor:o}=e;let s=null,i=null,a=null,c=t;for(;i===null&&c<window.innerWidth&&c>0;){const l=document.elementsFromPoint(c,n),u=l.findIndex(p=>p.classList.contains("ProseMirror")),d=l.slice(0,u);if(d.length>0){const p=d[0];if(s=p,a=o.view.posAtDOM(p,0),a>=0){i=o.state.doc.nodeAt(Math.max(a-1,0)),(i===null||i.isText)&&(i=o.state.doc.nodeAt(Math.max(a-1,0))),i||(i=o.state.doc.nodeAt(Math.max(a,0)));break}}r==="left"?c-=1:c+=1}return{resultElement:s,resultNode:i,pos:a!==null?a:null}};function Ds(e,t){const{doc:n}=t.view.state,r=Fe({editor:t,x:e.clientX,y:e.clientY,direction:"right"});if(!r.resultNode||r.pos===null)return[];const o=e.clientX,s=function(u,d,p){const h=parseInt(at(u.dom,"paddingLeft"),10),m=parseInt(at(u.dom,"paddingRight"),10),f=parseInt(at(u.dom,"borderLeftWidth"),10),y=parseInt(at(u.dom,"borderLeftWidth"),10),v=u.dom.getBoundingClientRect();return{left:_s(d,v.left+h+f,v.right-m-y),top:p}}(t.view,o,e.clientY),i=t.view.posAtCoords(s);if(!i)return[];const{pos:a}=i;if(!n.resolve(a).parent)return[];const c=n.resolve(r.pos),l=n.resolve(r.pos+1);return qt(c,l,0)}const fe=(e,t)=>{const n=e.resolve(t),{depth:r}=n;return r===0?t:n.pos-n.parentOffset-1},me=(e,t)=>{const n=e.nodeAt(t),r=e.resolve(t);let{depth:o}=r,s=n;for(;o>0;){const i=r.node(o);o-=1,o===0&&(s=i)}return s},Rt=(e,t)=>{const n=g.ySyncPluginKey.getState(e);return n?g.absolutePositionToRelativePosition(t,n.type,n.binding.mapping):null},ge=(e,t)=>{let n=t;for(;n&&n.parentNode&&n.parentNode!==e.dom;)n=n.parentNode;return n},ze=new g.PluginKey("dragHandle"),Ns=({pluginKey:e=ze,element:t,editor:n,tippyOptions:r,onNodeChange:o})=>{const s=document.createElement("div");let i=null,a=!1,c=null,l=-1;return t.addEventListener("dragstart",u=>{const{view:d}=n;if(!u.dataTransfer)return;const{empty:p,$from:h,$to:m}=d.state.selection,f=Ds(u,n),y=qt(h,m,0),v=y.some(P=>f.find(O=>O.$from===P.$from&&O.$to===P.$to)),S=p||!v?f:y;if(!S.length)return;const{tr:M}=d.state,b=document.createElement("div"),E=S[0].$from.pos,k=S[S.length-1].$to.pos,C=$.create(d.state.doc,E,k),L=C.content();S.forEach(P=>{const O=Hs(d.nodeDOM(P.$from.pos));b.append(O)}),b.style.position="absolute",b.style.top="-10000px",document.body.append(b),u.dataTransfer.clearData(),u.dataTransfer.setDragImage(b,0,0),d.dragging={slice:L,move:!0},M.setSelection(C),d.dispatch(M),document.addEventListener("drop",()=>he(b),{once:!0}),setTimeout(()=>{t&&(t.style.pointerEvents="none")},0)}),t.addEventListener("dragend",()=>{t&&(t.style.pointerEvents="auto")}),new g.Plugin({key:typeof e=="string"?new g.PluginKey(e):e,state:{init:()=>({locked:!1}),apply(u,d,p,h){const m=u.getMeta("lockDragHandle"),f=u.getMeta("hideDragHandle");if(m!==void 0&&(a=m),f&&i)return i.hide(),a=!1,c=null,l=-1,o==null||o({editor:n,node:null,pos:-1}),d;if(u.docChanged&&l!==-1&&t&&i){const y=u.mapping.map(l);y!==l&&(l=y,Rt(h,l))}return d}},view:u=>{var d;return t.draggable=!0,t.style.pointerEvents="auto",(d=n.view.dom.parentElement)===null||d===void 0||d.appendChild(s),s.appendChild(t),s.style.pointerEvents="none",s.style.position="absolute",s.style.top="0",s.style.left="0",i=ye(u.dom,{getReferenceClientRect:null,interactive:!0,trigger:"manual",placement:"left-start",hideOnClick:!1,duration:100,zIndex:10,popperOptions:{modifiers:[{name:"flip",enabled:!1},{name:"preventOverflow",options:{rootBoundary:"document",mainAxis:!1}}]},...r,appendTo:s,content:t}),{update(p,h){if(!t||!i||(t.draggable=!a,u.state.doc.eq(h.doc)||l===-1))return;let m=u.nodeDOM(l);if(m=ge(u,m),m===u.dom||(m==null?void 0:m.nodeType)!==1)return;const f=u.posAtDOM(m,0),y=me(n.state.doc,f);if(y!==c){const v=fe(n.state.doc,f);c=y,l=v,Rt(u.state,l),o==null||o({editor:n,node:c,pos:l}),i.setProps({getReferenceClientRect:()=>m.getBoundingClientRect()}),i.show()}},destroy(){i==null||i.destroy(),t&&he(s)}}},props:{handleDOMEvents:{mouseleave:(u,d)=>(a||d.target&&!s.contains(d.relatedTarget)&&(i==null||i.hide(),c=null,l=-1,o==null||o({editor:n,node:null,pos:-1})),!1),mousemove(u,d){if(!t||!i||a)return!1;const p=Fe({x:d.clientX,y:d.clientY,direction:"right",editor:n});if(!p.resultElement)return!1;let h=p.resultElement;if(h=ge(u,h),h===u.dom||(h==null?void 0:h.nodeType)!==1)return!1;const m=u.posAtDOM(h,0),f=me(n.state.doc,m);if(f!==c){const y=fe(n.state.doc,m);c=f,l=y,Rt(u.state,l),o==null||o({editor:n,node:c,pos:l}),i.setProps({getReferenceClientRect:()=>h.getBoundingClientRect()}),i.show()}return!1}}}})};exports.Blockquote=Xo;exports.Bold=vo;exports.BubbleMenu=io;exports.BulletList=Wo;exports.CharacterCount=is;exports.Code=Lo;exports.CodeBlock=Ho;exports.Color=Bo;exports.Document=ms;exports.DragHandlePlugin=Ns;exports.Dropcursor=as;exports.EditorContent=Gr;exports.Extension=H;exports.FocusClasses=ls;exports.FontFamily=No;exports.Gapcursor=cs;exports.HardBreak=ds;exports.Heading=Io;exports.Highlight=zo;exports.History=ss;exports.HorizontalRule=os;exports.Image=Ss;exports.Italic=wo;exports.Link=rs;exports.ListItem=us;exports.Mention=Rs;exports.Node=R;exports.NodeViewContent=ao;exports.NodeViewWrapper=lo;exports.OrderedList=Uo;exports.Paragraph=ps;exports.Placeholder=hs;exports.ReactNodeViewRenderer=ho;exports.ReactRenderer=Be;exports.Strike=xo;exports.Subscript=gs;exports.Suggestion=je;exports.Superscript=ys;exports.Table=As;exports.TableCell=Os;exports.TableHeader=Ls;exports.TableRow=ks;exports.TaskItem=Go;exports.TaskList=Jo;exports.Text=fs;exports.TextAlign=$o;exports.TextStyle=Do;exports.Underline=Eo;exports.dragHandlePluginDefaultKey=ze;exports.findChildren=Qn;exports.findParentNode=Mt;exports.getMarkRange=yt;exports.isActive=He;exports.isList=Dt;exports.isNumber=Se;exports.mergeAttributes=A;exports.nodeInputRule=Kt;exports.nodePasteRule=$r;exports.useEditor=oo;