@blocknote/core 0.23.3 → 0.23.4
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.
- package/dist/blocknote.js +2 -2
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +1 -1
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +2 -2
- package/src/editor/editor.css +47 -13
- package/src/extensions/Collaboration/createCollaborationExtensions.ts +1 -3
package/dist/blocknote.umd.cjs
CHANGED
|
@@ -7,5 +7,5 @@
|
|
|
7
7
|
`);return!o||!i?(e.commands.insertContent(`
|
|
8
8
|
`),!0):e.chain().command(({tr:n})=>(n.delete(t.pos-2,t.pos),!0)).exitCode().run()},"Shift-Enter":({editor:e})=>{const{$from:t}=e.state.selection;return e.isActive(this.name)?(e.chain().insertContentAt(t.pos-t.parentOffset+t.parent.nodeSize,{type:"paragraph"}).run(),!0):!1}}}}),Gt=W(Ft,Ce);function ln(e){var t;return W(Ft.configure(e),{language:{default:e.defaultLanguage||Ce.language.default,values:((t=e.supportedLanguages)==null?void 0:t.map(o=>o.id))||Ce.language.values}})}const $t={type:"pageBreak",propSchema:{},content:"none",isFileBlock:!1,isSelectable:!1},Kt=()=>{const e=document.createElement("div");return e.className="bn-page-break",e.setAttribute("data-page-break",""),{dom:e}},Wt=e=>{if(e.tagName==="DIV"&&e.hasAttribute("data-page-break"))return{type:"pageBreak"}},qt=()=>{const e=document.createElement("div");return e.setAttribute("data-page-break",""),{dom:e}},Xt=te($t,{render:Kt,parse:Wt,toExternalHTML:qt}),dn=k.Mark.create({name:"backgroundColor",addAttributes(){return{stringValue:{default:void 0,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.stringValue})}}},parseHTML(){return[{tag:"span",getAttrs:e=>typeof e=="string"?!1:e.hasAttribute("data-background-color")?{stringValue:e.getAttribute("data-background-color")}:!1}]},renderHTML({HTMLAttributes:e}){return["span",e,0]}}),cn=X(dn,"string"),un=k.Mark.create({name:"textColor",addAttributes(){return{stringValue:{default:void 0,parseHTML:e=>e.getAttribute("data-text-color"),renderHTML:e=>({"data-text-color":e.stringValue})}}},parseHTML(){return[{tag:"span",getAttrs:e=>typeof e=="string"?!1:e.hasAttribute("data-text-color")?{stringValue:e.getAttribute("data-text-color")}:!1}]},renderHTML({HTMLAttributes:e}){return["span",e,0]}}),pn=X(un,"string"),$e=e=>({url:e.src||void 0}),Zt={backgroundColor:B.backgroundColor,name:{default:""},url:{default:""},caption:{default:""}},Jt={type:"file",propSchema:Zt,content:"none",isFileBlock:!0},Yt=(e,t)=>ye(e,t),Qt=e=>{if(e.tagName==="EMBED")return $e(e);if(e.tagName==="FIGURE"){const t=he(e,"embed");if(!t)return;const{targetElement:o,caption:i}=t;return{...$e(o),caption:i}}},eo=e=>{if(!e.props.url){const o=document.createElement("p");return o.textContent="Add file",{dom:o}}const t=document.createElement("a");return t.href=e.props.url,t.textContent=e.props.name||e.props.url,e.props.caption?me(t,e.props.caption):{dom:t}},to=te(Jt,{render:Yt,parse:Qt,toExternalHTML:eo}),T=(e,t,o)=>({state:i,dispatch:n})=>{const a=Q(i.doc.resolve(t));if(n){const r=i.schema.nodes[a.blockNoteType],s=i.schema.nodes[o.type||a.blockNoteType],l=s.isInGroup("bnBlock")?s:i.schema.nodes.blockContainer;if(a.isBlockContainer&&s.isInGroup("blockContent"))oo(o,i,e,a),hn(o,i,e,r,s,a);else if(!a.isBlockContainer&&s.isInGroup("bnBlock"))oo(o,i,e,a);else{const c=S(a.bnBlock.node,e.schema.blockSchema,e.schema.inlineContentSchema,e.schema.styleSchema,e.blockCache);return i.tr.replaceWith(a.bnBlock.beforePos,a.bnBlock.afterPos,q({children:c.children,...o},i.schema,e.schema.styleSchema)),!0}i.tr.setNodeMarkup(a.bnBlock.beforePos,l,{...a.bnBlock.node.attrs,...o.props})}return!0};function hn(e,t,o,i,n,a){let r="keep";if(e.content)if(typeof e.content=="string")r=H([e.content],t.schema,o.schema.styleSchema,n.name);else if(Array.isArray(e.content))r=H(e.content,t.schema,o.schema.styleSchema,n.name);else if(e.content.type==="tableContent")r=le(e.content,t.schema,o.schema.styleSchema);else throw new j(e.content.type);else i.spec.content===""||n.spec.content!==i.spec.content&&(r=[]);r==="keep"?t.tr.setNodeMarkup(a.blockContent.beforePos,e.type===void 0?void 0:t.schema.nodes[e.type],{...a.blockContent.node.attrs,...e.props}):t.tr.replaceWith(a.blockContent.beforePos,a.blockContent.afterPos,n.createChecked({...a.blockContent.node.attrs,...e.props},r))}function oo(e,t,o,i){if(e.children!==void 0){const n=e.children.map(a=>q(a,t.schema,o.schema.styleSchema));if(i.childContainer)t.tr.step(new be.ReplaceStep(i.childContainer.beforePos+1,i.childContainer.afterPos-1,new w.Slice(w.Fragment.from(n),0,0)));else{if(!i.isBlockContainer)throw new Error("impossible");t.tr.insert(i.blockContent.afterPos,t.schema.nodes.blockGroup.createChecked({},n))}}}function io(e,t,o){const i=e._tiptapEditor,n=typeof t=="string"?t:t.id,a=A(n,i.state.doc);if(!a)throw new Error(`Block with ID ${n} not found`);i.commands.command(({state:s,dispatch:l})=>(T(e,a.posBeforeNode,o)({state:s,dispatch:l}),!0));const r=i.state.doc.resolve(a.posBeforeNode+1).node();return S(r,e.schema.blockSchema,e.schema.inlineContentSchema,e.schema.styleSchema,e.blockCache)}const no={...B,level:{default:1,values:[1,2,3]}},mn=K({name:"heading",content:"inline*",group:"blockContent",addAttributes(){return ee(no)},addInputRules(){return[...[1,2,3].map(e=>new k.InputRule({find:new RegExp(`^(#{${e}})\\s$`),handler:({state:t,chain:o,range:i})=>{const n=C(t);!n.isBlockContainer||n.blockContent.node.type.spec.content!=="inline*"||o().command(T(this.options.editor,n.bnBlock.beforePos,{type:"heading",props:{level:e}})).deleteRange({from:i.from,to:i.to}).run()}}))]},addKeyboardShortcuts(){return{"Mod-Alt-1":()=>{const e=C(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(T(this.options.editor,e.bnBlock.beforePos,{type:"heading",props:{level:1}}))},"Mod-Alt-2":()=>{const e=C(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(T(this.options.editor,e.bnBlock.beforePos,{type:"heading",props:{level:2}}))},"Mod-Alt-3":()=>{const e=C(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(T(this.options.editor,e.bnBlock.beforePos,{type:"heading",props:{level:3}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]"},{tag:"h1",attrs:{level:1},node:"heading"},{tag:"h2",attrs:{level:2},node:"heading"},{tag:"h3",attrs:{level:3},node:"heading"}]},renderHTML({node:e,HTMLAttributes:t}){var o,i;return R(this.name,`h${e.attrs.level}`,{...((o=this.options.domAttributes)==null?void 0:o.blockContent)||{},...t},((i=this.options.domAttributes)==null?void 0:i.inlineContent)||{})}}),fn=W(mn,no),Ke=(e,t,o,i,n,a)=>{const{dom:r,destroy:s}=ye(e,t,o,n,a),l=r;e.props.url&&e.props.showPreview&&(l.style.width=`${e.props.previewWidth}px`);const c=document.createElement("div");c.className="bn-resize-handle",c.style.left="4px";const u=document.createElement("div");u.className="bn-resize-handle",u.style.right="4px";let p,m=e.props.previewWidth;const f=x=>{if(!p){!t.isEditable&&i.contains(c)&&i.contains(u)&&(i.removeChild(c),i.removeChild(u));return}let O;e.props.textAlignment==="center"?p.handleUsed==="left"?O=p.initialWidth+(p.initialClientX-x.clientX)*2:O=p.initialWidth+(x.clientX-p.initialClientX)*2:p.handleUsed==="left"?O=p.initialWidth+p.initialClientX-x.clientX:O=p.initialWidth+x.clientX-p.initialClientX,m=Math.max(O,64),l.style.width=`${m}px`},g=x=>{(!x.target||!l.contains(x.target)||!t.isEditable)&&i.contains(c)&&i.contains(u)&&(i.removeChild(c),i.removeChild(u)),p&&(p=void 0,t.updateBlock(e,{props:{previewWidth:m}}))},b=()=>{t.isEditable&&(i.appendChild(c),i.appendChild(u))},y=x=>{x.relatedTarget===c||x.relatedTarget===u||p||t.isEditable&&i.contains(c)&&i.contains(u)&&(i.removeChild(c),i.removeChild(u))},v=x=>{x.preventDefault(),p={handleUsed:"left",initialWidth:l.clientWidth,initialClientX:x.clientX}},I=x=>{x.preventDefault(),p={handleUsed:"right",initialWidth:l.clientWidth,initialClientX:x.clientX}};return window.addEventListener("mousemove",f),window.addEventListener("mouseup",g),l.addEventListener("mouseenter",b),l.addEventListener("mouseleave",y),c.addEventListener("mousedown",v),u.addEventListener("mousedown",I),{dom:l,destroy:()=>{s==null||s(),window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",g),l.removeEventListener("mouseenter",b),l.removeEventListener("mouseleave",y),c.removeEventListener("mousedown",v),u.removeEventListener("mousedown",I)}}},ao=e=>{const t=e.src||void 0,o=e.width||void 0;return{url:t,previewWidth:o}},ro='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z"></path></svg>',so={textAlignment:B.textAlignment,backgroundColor:B.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0},previewWidth:{default:512}},lo={type:"image",propSchema:so,content:"none",isFileBlock:!0,fileBlockAccept:["image/*"]},co=(e,t)=>{const o=document.createElement("div");o.innerHTML=ro;const i=document.createElement("div");i.className="bn-visual-media-wrapper";const n=document.createElement("img");return n.className="bn-visual-media",t.resolveFileUrl?t.resolveFileUrl(e.props.url).then(a=>{n.src=a}):n.src=e.props.url,n.alt=e.props.name||e.props.caption||"BlockNote image",n.contentEditable="false",n.draggable=!1,i.appendChild(n),Ke(e,t,{dom:i},i,t.dictionary.file_blocks.image.add_button_text,o.firstElementChild)},uo=e=>{if(e.tagName==="IMG")return ao(e);if(e.tagName==="FIGURE"){const t=he(e,"img");if(!t)return;const{targetElement:o,caption:i}=t;return{...ao(o),caption:i}}},po=e=>{if(!e.props.url){const o=document.createElement("p");return o.textContent="Add image",{dom:o}}let t;return e.props.showPreview?(t=document.createElement("img"),t.src=e.props.url,t.alt=e.props.name||e.props.caption||"BlockNote image",t.width=e.props.previewWidth):(t=document.createElement("a"),t.href=e.props.url,t.textContent=e.props.name||e.props.url),e.props.caption?e.props.showPreview?ve(t,e.props.caption):me(t,e.props.caption):{dom:t}},ho=te(lo,{render:co,parse:uo,toExternalHTML:po}),mo=(e,t,o)=>({state:i,dispatch:n})=>{const a=z(i.doc,e),r=F(a);if(!r.isBlockContainer)throw new Error(`BlockContainer expected when calling splitBlock, position ${e}`);const s=[{type:r.bnBlock.node.type,attrs:o?{...r.bnBlock.node.attrs,id:void 0}:{}},{type:t?r.blockContent.node.type:i.schema.nodes.paragraph,attrs:o?{...r.blockContent.node.attrs}:{}}];return n&&i.tr.split(e,2,s),!0},We=e=>{const t=e._tiptapEditor,o=C(t.state);if(!o.isBlockContainer)return!1;const{bnBlock:i,blockContent:n}=o,a=t.state.selection.anchor===t.state.selection.head;return!(n.node.type.name==="bulletListItem"||n.node.type.name==="numberedListItem"||n.node.type.name==="checkListItem")||!a?!1:t.commands.first(({state:r,chain:s,commands:l})=>[()=>l.command(()=>n.node.childCount===0?l.command(T(e,i.beforePos,{type:"paragraph",props:{}})):!1),()=>l.command(()=>n.node.childCount>0?(s().deleteSelection().command(mo(r.selection.from,!0)).run(),!0):!1)])},gn={...B},bn=K({name:"bulletListItem",content:"inline*",group:"blockContent",priority:90,addInputRules(){return[new k.InputRule({find:new RegExp("^[-+*]\\s$"),handler:({state:e,chain:t,range:o})=>{const i=C(e);!i.isBlockContainer||i.blockContent.node.type.spec.content!=="inline*"||t().command(T(this.options.editor,i.bnBlock.beforePos,{type:"bulletListItem",props:{}})).deleteRange({from:o.from,to:o.to})}})]},addKeyboardShortcuts(){return{Enter:()=>We(this.options.editor),"Mod-Shift-8":()=>{const e=C(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(T(this.options.editor,e.bnBlock.beforePos,{type:"bulletListItem",props:{}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]"},{tag:"li",getAttrs:e=>{if(typeof e=="string")return!1;const t=e.parentElement;return t===null?!1:t.tagName==="UL"||t.tagName==="DIV"&&t.parentElement.tagName==="UL"?{}:!1},node:"bulletListItem"},{tag:"p",getAttrs:e=>{if(typeof e=="string")return!1;const t=e.parentElement;return t===null?!1:t.getAttribute("data-content-type")==="bulletListItem"?{}:!1},priority:300,node:"bulletListItem"}]},renderHTML({HTMLAttributes:e}){var t,o;return R(this.name,"p",{...((t=this.options.domAttributes)==null?void 0:t.blockContent)||{},...e},((o=this.options.domAttributes)==null?void 0:o.inlineContent)||{})}}),kn=W(bn,gn),fo={...B,checked:{default:!1}},_n=K({name:"checkListItem",content:"inline*",group:"blockContent",addAttributes(){return ee(fo)},addInputRules(){return[new k.InputRule({find:new RegExp("\\[\\s*\\]\\s$"),handler:({state:e,chain:t,range:o})=>{const i=C(e);!i.isBlockContainer||i.blockContent.node.type.spec.content!=="inline*"||t().command(T(this.options.editor,i.bnBlock.beforePos,{type:"checkListItem",props:{checked:!1}})).deleteRange({from:o.from,to:o.to})}}),new k.InputRule({find:new RegExp("\\[[Xx]\\]\\s$"),handler:({state:e,chain:t,range:o})=>{const i=C(e);!i.isBlockContainer||i.blockContent.node.type.spec.content!=="inline*"||t().command(T(this.options.editor,i.bnBlock.beforePos,{type:"checkListItem",props:{checked:!0}})).deleteRange({from:o.from,to:o.to})}})]},addKeyboardShortcuts(){return{Enter:()=>We(this.options.editor),"Mod-Shift-9":()=>{const e=C(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(T(this.options.editor,e.bnBlock.beforePos,{type:"checkListItem",props:{}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]"},{tag:"input",getAttrs:e=>typeof e=="string"?!1:e.type==="checkbox"?{checked:e.checked}:!1,node:"checkListItem"},{tag:"li",getAttrs:e=>{if(typeof e=="string")return!1;const t=e.parentElement;if(t===null)return!1;if(t.tagName==="UL"||t.tagName==="DIV"&&t.parentElement.tagName==="UL"){const o=e.querySelector("input[type=checkbox]")||null;return o===null?!1:{checked:o.checked}}return!1},node:"checkListItem"}]},renderHTML({node:e,HTMLAttributes:t}){var a,r;const o=document.createElement("input");o.type="checkbox",o.checked=e.attrs.checked,e.attrs.checked&&o.setAttribute("checked","");const{dom:i,contentDOM:n}=R(this.name,"p",{...((a=this.options.domAttributes)==null?void 0:a.blockContent)||{},...t},((r=this.options.domAttributes)==null?void 0:r.inlineContent)||{});return i.insertBefore(o,n),{dom:i,contentDOM:n}},addNodeView(){return({node:e,getPos:t,editor:o,HTMLAttributes:i})=>{var u,p;const n=document.createElement("div"),a=document.createElement("div");a.contentEditable="false";const r=document.createElement("input");r.type="checkbox",r.checked=e.attrs.checked,e.attrs.checked&&r.setAttribute("checked","");const s=()=>{if(!o.isEditable){r.checked=!r.checked;return}if(typeof t!="boolean"){const m=z(o.state.doc,t());if(m.node.type.name!=="blockContainer")throw new Error(`Expected blockContainer node, got ${m.node.type.name}`);this.editor.commands.command(T(this.options.editor,m.posBeforeNode,{type:"checkListItem",props:{checked:r.checked}}))}};r.addEventListener("change",s);const{dom:l,contentDOM:c}=R(this.name,"p",{...((u=this.options.domAttributes)==null?void 0:u.blockContent)||{},...i},((p=this.options.domAttributes)==null?void 0:p.inlineContent)||{});if(typeof t!="boolean"){const f="label-"+this.editor.state.doc.resolve(t()).node().attrs.id;r.setAttribute("aria-labelledby",f),c.id=f}return l.removeChild(c),l.appendChild(n),n.appendChild(a),n.appendChild(c),a.appendChild(r),{dom:l,contentDOM:c,destroy:()=>{r.removeEventListener("change",s)}}}}}),yn=W(_n,fo),vn=new _.PluginKey("numbered-list-indexing"),wn=()=>new _.Plugin({key:vn,appendTransaction:(e,t,o)=>{const i=o.tr;i.setMeta("numberedListIndexing",!0);let n=!1;return o.doc.descendants((a,r)=>{var s;if(a.type.name==="blockContainer"&&a.firstChild.type.name==="numberedListItem"){let l=`${a.firstChild.attrs.start||1}`;const c=F({posBeforeNode:r,node:a});if(!c.isBlockContainer)throw new Error("impossible");const u=i.doc.resolve(c.bnBlock.beforePos).nodeBefore;if(u){const g=F({posBeforeNode:c.bnBlock.beforePos-u.nodeSize,node:u});if(g.blockNoteType==="numberedListItem"){if(!g.isBlockContainer)throw new Error("impossible");const y=g.blockContent.node.attrs.index;l=(parseInt(y)+1).toString()}}const p=c.blockContent.node,m=p.attrs.index,f=((s=u==null?void 0:u.firstChild)==null?void 0:s.type.name)!=="numberedListItem";if(m!==l||p.attrs.start&&!f){n=!0;const{start:g,...b}=p.attrs;i.setNodeMarkup(c.blockContent.beforePos,void 0,{...b,index:l,...typeof g=="number"&&f&&{start:g}})}}}),n?i:null}}),go={...B,start:{default:void 0,type:"number"}},Cn=K({name:"numberedListItem",content:"inline*",group:"blockContent",priority:90,addAttributes(){return{...ee(go),index:{default:null,parseHTML:e=>e.getAttribute("data-index"),renderHTML:e=>({"data-index":e.index})}}},addInputRules(){return[new k.InputRule({find:new RegExp("^(\\d+)\\.\\s$"),handler:({state:e,chain:t,range:o,match:i})=>{const n=C(e);if(!n.isBlockContainer||n.blockContent.node.type.spec.content!=="inline*"||n.blockNoteType==="numberedListItem")return;const a=parseInt(i[1]);t().command(T(this.options.editor,n.bnBlock.beforePos,{type:"numberedListItem",props:a===1&&{}||{start:a}})).deleteRange({from:o.from,to:o.to})}})]},addKeyboardShortcuts(){return{Enter:()=>We(this.options.editor),"Mod-Shift-7":()=>{const e=C(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(T(this.options.editor,e.bnBlock.beforePos,{type:"numberedListItem",props:{}}))}}},addProseMirrorPlugins(){return[wn()]},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]"},{tag:"li",getAttrs:e=>{if(typeof e=="string")return!1;const t=e.parentElement;if(t===null)return!1;if(t.tagName==="OL"||t.tagName==="DIV"&&t.parentElement.tagName==="OL"){const o=parseInt(t.getAttribute("start")||"1")||1;return e.previousSibling||o===1?{}:{start:o}}return!1},node:"numberedListItem"},{tag:"p",getAttrs:e=>{if(typeof e=="string")return!1;const t=e.parentElement;return t===null?!1:t.getAttribute("data-content-type")==="numberedListItem"?{}:!1},priority:300,node:"numberedListItem"}]},renderHTML({HTMLAttributes:e}){var t,o;return R(this.name,"p",{...((t=this.options.domAttributes)==null?void 0:t.blockContent)||{},...e},((o=this.options.domAttributes)==null?void 0:o.inlineContent)||{})}}),xn=W(Cn,go),Sn={...B},Bn=K({name:"paragraph",content:"inline*",group:"blockContent",addKeyboardShortcuts(){return{"Mod-Alt-0":()=>{const e=C(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(T(this.options.editor,e.bnBlock.beforePos,{type:"paragraph",props:{}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]"},{tag:"p",priority:200,getAttrs:e=>{var t;return typeof e=="string"||!((t=e.textContent)!=null&&t.trim())?!1:{}},node:"paragraph"}]},renderHTML({HTMLAttributes:e}){var t,o;return R(this.name,"p",{...((t=this.options.domAttributes)==null?void 0:t.blockContent)||{},...e},((o=this.options.domAttributes)==null?void 0:o.inlineContent)||{})}}),En=W(Bn,Sn),Tn=35,qe=120,In=31,Mn=k.Extension.create({name:"BlockNoteTableExtension",addProseMirrorPlugins:()=>[U.columnResizing({cellMinWidth:Tn,defaultCellMinWidth:qe,View:null}),U.tableEditing()],addKeyboardShortcuts(){return{Enter:()=>this.editor.state.selection.empty&&this.editor.state.selection.$head.parent.type.name==="tableParagraph"?(this.editor.commands.setHardBreak(),!0):!1,Backspace:()=>{const e=this.editor.state.selection,t=e.empty,o=e.$head.parentOffset===0,i=e.$head.node().type.name==="tableParagraph";return t&&o&&i},Tab:()=>this.editor.commands.command(({state:e,dispatch:t,view:o})=>U.goToNextCell(1)(e,t,o)),"Shift-Tab":()=>this.editor.commands.command(({state:e,dispatch:t,view:o})=>U.goToNextCell(-1)(e,t,o))}},extendNodeSchema(e){const t={name:e.name,options:e.options,storage:e.storage};return{tableRole:k.callOrReturn(k.getExtensionField(e,"tableRole",t))}}}),Ln={textColor:B.textColor},Pn=K({name:"table",content:"tableRow+",group:"blockContent",tableRole:"table",isolating:!0,parseHTML(){return[{tag:"table"}]},renderHTML({HTMLAttributes:e}){var t,o;return R(this.name,"table",{...((t=this.options.domAttributes)==null?void 0:t.blockContent)||{},...e},((o=this.options.domAttributes)==null?void 0:o.inlineContent)||{})},addNodeView(){return({node:e,HTMLAttributes:t})=>{var i;class o extends U.TableView{constructor(a,r,s){super(a,r),this.node=a,this.cellMinWidth=r,this.blockContentHTMLAttributes=s;const l=document.createElement("div");l.className=$("bn-block-content",s.class),l.setAttribute("data-content-type","table");for(const[m,f]of Object.entries(s))m!=="class"&&l.setAttribute(m,f);const c=this.dom,u=document.createElement("div");u.className="tableWrapper-inner",u.appendChild(c.firstChild),c.appendChild(u),l.appendChild(c);const p=document.createElement("div");p.className="table-widgets-container",p.style.position="relative",c.appendChild(p),this.dom=l}ignoreMutation(a){return!a.target.closest(".tableWrapper-inner")||super.ignoreMutation(a)}}return new o(e,qe,{...((i=this.options.domAttributes)==null?void 0:i.blockContent)||{},...t})}}}),An=k.Node.create({name:"tableParagraph",group:"tableContent",content:"inline*",parseHTML(){return[{preserveWhitespace:"full",priority:210,context:"tableContent",tag:"p",getAttrs:e=>({})},{tag:"p",getAttrs:e=>{if(typeof e=="string"||!e.textContent)return!1;const t=e.parentElement;return t===null?!1:t.tagName==="TD"?{}:!1}}]},renderHTML({HTMLAttributes:e}){return["p",e,0]}}),Nn=W(Pn,Ln,[Mn,An,Ti.TableHeader.extend({content:"tableContent"}),Ei.TableCell.extend({content:"tableContent"}),Ii.TableRow]),bo=e=>{const t=e.src||void 0,o=e.width||void 0;return{url:t,previewWidth:o}},ko='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z"></path></svg>',_o={textAlignment:B.textAlignment,backgroundColor:B.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0},previewWidth:{default:512}},yo={type:"video",propSchema:_o,content:"none",isFileBlock:!0,fileBlockAccept:["video/*"]},vo=(e,t)=>{const o=document.createElement("div");o.innerHTML=ko;const i=document.createElement("div");i.className="bn-visual-media-wrapper";const n=document.createElement("video");return n.className="bn-visual-media",t.resolveFileUrl?t.resolveFileUrl(e.props.url).then(a=>{n.src=a}):n.src=e.props.url,n.controls=!0,n.contentEditable="false",n.draggable=!1,n.width=e.props.previewWidth,i.appendChild(n),Ke(e,t,{dom:i},i,t.dictionary.file_blocks.video.add_button_text,o.firstElementChild)},wo=e=>{if(e.tagName==="VIDEO")return bo(e);if(e.tagName==="FIGURE"){const t=he(e,"video");if(!t)return;const{targetElement:o,caption:i}=t;return{...bo(o),caption:i}}},Co=e=>{if(!e.props.url){const o=document.createElement("p");return o.textContent="Add video",{dom:o}}let t;return e.props.showPreview?(t=document.createElement("video"),t.src=e.props.url,t.width=e.props.previewWidth):(t=document.createElement("a"),t.href=e.props.url,t.textContent=e.props.name||e.props.url),e.props.caption?e.props.showPreview?ve(t,e.props.caption):me(t,e.props.caption):{dom:t}},xo=te(yo,{render:vo,parse:wo,toExternalHTML:Co}),Xe={paragraph:En,heading:fn,codeBlock:Gt,bulletListItem:kn,numberedListItem:xn,checkListItem:yn,table:Nn,file:to,image:ho,video:xo,audio:Vt},So=Oe(Xe),Ze={bold:X(Ui.default,"boolean"),italic:X(Vi.default,"boolean"),underline:X(Fi.default,"boolean"),strike:X(zi.default,"boolean"),code:X(Ri.default,"boolean"),textColor:pn,backgroundColor:cn},Dn=Fe(Ze),Je={text:{config:"text",implementation:{}},link:{config:"link",implementation:{}}},Bo=Ve(Je);function N(e,t){return e in t.schema.blockSchema&&t.schema.blockSchema[e]===So[e]}function Eo(e,t){return e in t.schema.inlineContentSchema&&t.schema.inlineContentSchema[e]===Bo[e]}function To(e,t,o){return t.type===e&&t.type in o.schema.blockSchema&&N(t.type,o)}function jn(e,t){return e.type in t.schema.blockSchema&&t.schema.blockSchema[e.type].isFileBlock||!1}function Hn(e,t){return e.type in t.schema.blockSchema&&t.schema.blockSchema[e.type].isFileBlock&&"showPreview"in t.schema.blockSchema[e.type].propSchema||!1}function On(e,t){return t.schema.blockSchema[e.type].isFileBlock&&!e.props.url}function Io(e,t,o){return t in o.schema.blockSchema&&e in o.schema.blockSchema[t].propSchema&&o.schema.blockSchema[t].propSchema[e]===B[e]}function Un(e,t,o){return Io(e,t.type,o)}function Rn(e){let t=e.getTextCursorPosition().block,o=e.schema.blockSchema[t.type].content;for(;o==="none";)t=e.getTextCursorPosition().nextBlock,o=e.schema.blockSchema[t.type].content,e.setTextCursorPosition(t,"end")}function L(e,t){const o=e.getTextCursorPosition().block;if(o.content===void 0)throw new Error("Slash Menu open in a block that doesn't contain content.");let i;return Array.isArray(o.content)&&(o.content.length===1&&Y(o.content[0])&&o.content[0].type==="text"&&o.content[0].text==="/"||o.content.length===0)?(i=e.updateBlock(o,t),e.setTextCursorPosition(i)):(i=e.insertBlocks([t],o,"after")[0],e.setTextCursorPosition(e.getTextCursorPosition().nextBlock)),Rn(e),i}function Vn(e){const t=[];return N("heading",e)&&t.push({onItemClick:()=>{L(e,{type:"heading",props:{level:1}})},badge:G("Mod-Alt-1"),key:"heading",...e.dictionary.slash_menu.heading},{onItemClick:()=>{L(e,{type:"heading",props:{level:2}})},badge:G("Mod-Alt-2"),key:"heading_2",...e.dictionary.slash_menu.heading_2},{onItemClick:()=>{L(e,{type:"heading",props:{level:3}})},badge:G("Mod-Alt-3"),key:"heading_3",...e.dictionary.slash_menu.heading_3}),N("numberedListItem",e)&&t.push({onItemClick:()=>{L(e,{type:"numberedListItem"})},badge:G("Mod-Shift-7"),key:"numbered_list",...e.dictionary.slash_menu.numbered_list}),N("bulletListItem",e)&&t.push({onItemClick:()=>{L(e,{type:"bulletListItem"})},badge:G("Mod-Shift-8"),key:"bullet_list",...e.dictionary.slash_menu.bullet_list}),N("checkListItem",e)&&t.push({onItemClick:()=>{L(e,{type:"checkListItem"})},badge:G("Mod-Shift-9"),key:"check_list",...e.dictionary.slash_menu.check_list}),N("paragraph",e)&&t.push({onItemClick:()=>{L(e,{type:"paragraph"})},badge:G("Mod-Alt-0"),key:"paragraph",...e.dictionary.slash_menu.paragraph}),N("codeBlock",e)&&t.push({onItemClick:()=>{L(e,{type:"codeBlock"})},badge:G("Mod-Alt-c"),key:"code_block",...e.dictionary.slash_menu.code_block}),N("table",e)&&t.push({onItemClick:()=>{L(e,{type:"table",content:{type:"tableContent",rows:[{cells:["","",""]},{cells:["","",""]}]}})},badge:void 0,key:"table",...e.dictionary.slash_menu.table}),N("image",e)&&t.push({onItemClick:()=>{const o=L(e,{type:"image"});e.dispatch(e._tiptapEditor.state.tr.setMeta(e.filePanel.plugin,{block:o}))},key:"image",...e.dictionary.slash_menu.image}),N("video",e)&&t.push({onItemClick:()=>{const o=L(e,{type:"video"});e.dispatch(e._tiptapEditor.state.tr.setMeta(e.filePanel.plugin,{block:o}))},key:"video",...e.dictionary.slash_menu.video}),N("audio",e)&&t.push({onItemClick:()=>{const o=L(e,{type:"audio"});e.dispatch(e._tiptapEditor.state.tr.setMeta(e.filePanel.plugin,{block:o}))},key:"audio",...e.dictionary.slash_menu.audio}),N("file",e)&&t.push({onItemClick:()=>{const o=L(e,{type:"file"});e.dispatch(e._tiptapEditor.state.tr.setMeta(e.filePanel.plugin,{block:o}))},key:"file",...e.dictionary.slash_menu.file}),t.push({onItemClick:()=>{e.openSuggestionMenu(":",{deleteTriggerCharacter:!0,ignoreQueryLength:!0})},key:"emoji",...e.dictionary.slash_menu.emoji}),t}function zn(e,t){return e.filter(({title:o,aliases:i})=>o.toLowerCase().includes(t.toLowerCase())||i&&i.filter(n=>n.toLowerCase().includes(t.toLowerCase())).length!==0)}function Ye(e){return e&&Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}class oe{constructor(t){h(this,"blockSpecs");h(this,"inlineContentSpecs");h(this,"styleSpecs");h(this,"blockSchema");h(this,"inlineContentSchema");h(this,"styleSchema");h(this,"BlockNoteEditor","only for types");h(this,"Block","only for types");h(this,"PartialBlock","only for types");this.blockSpecs=Ye(t==null?void 0:t.blockSpecs)||Xe,this.inlineContentSpecs=Ye(t==null?void 0:t.inlineContentSpecs)||Je,this.styleSpecs=Ye(t==null?void 0:t.styleSpecs)||Ze,this.blockSchema=Oe(this.blockSpecs),this.inlineContentSchema=Ve(this.inlineContentSpecs),this.styleSchema=Fe(this.styleSpecs)}static create(t){return new oe(t)}}const Qe=oe.create({blockSpecs:{pageBreak:Xt}}),Fn=e=>oe.create({blockSpecs:{...e.blockSpecs,...Qe.blockSpecs},inlineContentSpecs:e.inlineContentSpecs,styleSpecs:e.styleSpecs});function Mo(e){return"pageBreak"in e.schema.blockSchema&&e.schema.blockSchema.pageBreak===Qe.blockSchema.pageBreak}function Gn(e){const t=[];return Mo(e)&&t.push({...e.dictionary.slash_menu.page_break,onItemClick:()=>{L(e,{type:"pageBreak"})},key:"page_break"}),t}const $n=async e=>{const t=new FormData;return t.append("file",e),(await(await fetch("https://tmpfiles.org/api/v1/upload",{method:"POST",body:t})).json()).data.url.replace("tmpfiles.org/","tmpfiles.org/dl/")};function Kn(e,t,o,i="before"){const n=typeof o=="string"?o:o.id,a=[];for(const l of t)a.push(q(l,e.pmSchema,e.schema.styleSchema));const r=A(n,e._tiptapEditor.state.doc);if(!r)throw new Error(`Block with ID ${n} not found`);i==="before"&&e.dispatch(e._tiptapEditor.state.tr.insert(r.posBeforeNode,a)),i==="after"&&e.dispatch(e._tiptapEditor.state.tr.insert(r.posBeforeNode+r.node.nodeSize,a));const s=[];for(const l of a)s.push(S(l,e.schema.blockSchema,e.schema.inlineContentSchema,e.schema.styleSchema,e.blockCache));return s}function Wn(e){const t=e._tiptapEditor.state,o=t.selection,i=z(t.doc,o.anchor);if(o instanceof U.CellSelection)return{type:"cell",anchorBlockId:i.node.attrs.id,anchorCellOffset:o.$anchorCell.pos-i.posBeforeNode,headCellOffset:o.$headCell.pos-i.posBeforeNode};if(e._tiptapEditor.state.selection instanceof _.NodeSelection)return{type:"node",anchorBlockId:i.node.attrs.id};{const n=z(t.doc,o.head);return{type:"text",anchorBlockId:i.node.attrs.id,headBlockId:n.node.attrs.id,anchorOffset:o.anchor-i.posBeforeNode,headOffset:o.head-n.posBeforeNode}}}function qn(e,t){var n,a;const o=(n=A(t.anchorBlockId,e._tiptapEditor.state.doc))==null?void 0:n.posBeforeNode;if(o===void 0)throw new Error(`Could not find block with ID ${t.anchorBlockId} to update selection`);let i;if(t.type==="cell")i=U.CellSelection.create(e._tiptapEditor.state.doc,o+t.anchorCellOffset,o+t.headCellOffset);else if(t.type==="node")i=_.NodeSelection.create(e._tiptapEditor.state.doc,o+1);else{const r=(a=A(t.headBlockId,e._tiptapEditor.state.doc))==null?void 0:a.posBeforeNode;if(r===void 0)throw new Error(`Could not find block with ID ${t.headBlockId} to update selection`);i=_.TextSelection.create(e._tiptapEditor.state.doc,o+t.anchorOffset,r+t.headOffset)}e.dispatch(e._tiptapEditor.state.tr.setSelection(i))}function et(e){return e.map(t=>t.type==="columnList"?t.children.map(o=>et(o.children)).flat():{...t,children:et(t.children)}).flat()}function Lo(e,t,o){var a;const i=((a=e.getSelection())==null?void 0:a.blocks)||[e.getTextCursorPosition().block],n=Wn(e);e.removeBlocks(i),e.insertBlocks(et(i),t,o),qn(e,n)}function Po(e){return!e||e.type!=="columnList"}function Ao(e,t,o){let i,n;if(t?t.children.length>0?(i=t.children[t.children.length-1],n="after"):(i=t,n="before"):o&&(i=o,n="before"),!i||!n)return;const a=e.getParentBlock(i);return Po(a)?{referenceBlock:i,placement:n}:Ao(e,n==="after"?i:e.getPrevBlock(i),a)}function No(e,t,o){let i,n;if(t?t.children.length>0?(i=t.children[0],n="before"):(i=t,n="after"):o&&(i=o,n="after"),!i||!n)return;const a=e.getParentBlock(i);return Po(a)?{referenceBlock:i,placement:n}:No(e,n==="before"?i:e.getNextBlock(i),a)}function Xn(e){const t=e.getSelection(),o=(t==null?void 0:t.blocks[0])||e.getTextCursorPosition().block,i=Ao(e,e.getPrevBlock(o),e.getParentBlock(o));i&&Lo(e,i.referenceBlock,i.placement)}function Zn(e){const t=e.getSelection(),o=(t==null?void 0:t.blocks[(t==null?void 0:t.blocks.length)-1])||e.getTextCursorPosition().block,i=No(e,e.getNextBlock(o),e.getParentBlock(o));i&&Lo(e,i.referenceBlock,i.placement)}function Jn(e,t){return function({state:o,dispatch:i}){const{$from:n,$to:a}=o.selection,r=n.blockRange(a,u=>u.childCount>0&&(u.type.name==="blockGroup"||u.type.name==="column"));if(!r)return!1;const s=r.startIndex;if(s===0)return!1;const c=r.parent.child(s-1);if(c.type!==e)return!1;if(i){const u=c.lastChild&&c.lastChild.type===t,p=w.Fragment.from(u?e.create():null),m=new w.Slice(w.Fragment.from(e.create(null,w.Fragment.from(t.create(null,p)))),u?3:1,0),f=r.start,g=r.end;i(o.tr.step(new be.ReplaceAroundStep(f-(u?3:1),g,f,g,m,1,!0)).scrollIntoView())}return!0}}function Do(e){return e._tiptapEditor.commands.command(Jn(e._tiptapEditor.schema.nodes.blockContainer,e._tiptapEditor.schema.nodes.blockGroup))}function Yn(e){e._tiptapEditor.commands.liftListItem("blockContainer")}function Qn(e){const{bnBlock:t}=C(e._tiptapEditor.state);return e._tiptapEditor.state.doc.resolve(t.beforePos).nodeBefore!==null}function ea(e){const{bnBlock:t}=C(e._tiptapEditor.state);return e._tiptapEditor.state.doc.resolve(t.beforePos).depth>1}function jo(e,t,o){const i=e._tiptapEditor;let n=i.state.tr;const a=[];for(const p of o)a.push(q(p,e.pmSchema,e.schema.styleSchema));const r=new Set(t.map(p=>typeof p=="string"?p:p.id)),s=[],l=typeof t[0]=="string"?t[0]:t[0].id;let c=0;if(i.state.doc.descendants((p,m)=>{if(r.size===0)return!1;if(!p.type.isInGroup("bnBlock")||!r.has(p.attrs.id))return!0;if(s.push(S(p,e.schema.blockSchema,e.schema.inlineContentSchema,e.schema.styleSchema,e.blockCache)),r.delete(p.attrs.id),o.length>0&&p.attrs.id===l){const y=n.doc.nodeSize;n=n.insert(m,a);const v=n.doc.nodeSize;c+=y-v}const f=n.doc.nodeSize,g=n.doc.resolve(m-c);g.node().type.name==="blockGroup"&&g.node(g.depth-1).type.name!=="doc"&&g.node().childCount===1?n=n.delete(g.before(),g.after()):n=n.delete(m-c,m-c+p.nodeSize);const b=n.doc.nodeSize;return c+=f-b,!1}),r.size>0){const p=[...r].join(`
|
|
9
9
|
`);throw Error("Blocks with the following IDs could not be found in the editor: "+p)}e.dispatch(n);const u=[];for(const p of a)u.push(S(p,e.schema.blockSchema,e.schema.inlineContentSchema,e.schema.styleSchema,e.blockCache));return{insertedBlocks:u,removedBlocks:s}}function ta(e,t,o){return jo(e,t,o)}function oa(e,t){return jo(e,t,[]).removedBlocks}function ia(e,t){const o=typeof t=="string"?t:t.id,i=A(o,e._tiptapEditor.state.doc);if(i)return S(i.node,e.schema.blockSchema,e.schema.inlineContentSchema,e.schema.styleSchema,e.blockCache)}function na(e,t){const o=typeof t=="string"?t:t.id,i=A(o,e._tiptapEditor.state.doc);if(!i)return;const a=e._tiptapEditor.state.doc.resolve(i.posBeforeNode).nodeBefore;if(a)return S(a,e.schema.blockSchema,e.schema.inlineContentSchema,e.schema.styleSchema,e.blockCache)}function aa(e,t){const o=typeof t=="string"?t:t.id,i=A(o,e._tiptapEditor.state.doc);if(!i)return;const a=e._tiptapEditor.state.doc.resolve(i.posBeforeNode+i.node.nodeSize).nodeAfter;if(a)return S(a,e.schema.blockSchema,e.schema.inlineContentSchema,e.schema.styleSchema,e.blockCache)}function ra(e,t){const o=typeof t=="string"?t:t.id,i=A(o,e._tiptapEditor.state.doc);if(!i)return;const n=e._tiptapEditor.state.doc.resolve(i.posBeforeNode),a=n.node(),r=n.node(-1),s=r.type.name!=="doc"?a.type.name==="blockGroup"?r:a:void 0;if(s)return S(s,e.schema.blockSchema,e.schema.inlineContentSchema,e.schema.styleSchema,e.blockCache)}function sa(e,t,o,i={updateSelection:!0}){const n=o._tiptapEditor.state.tr;let{from:a,to:r}=typeof e=="number"?{from:e,to:e}:{from:e.from,to:e.to},s=!0,l=!0,c="";if(t.forEach(u=>{u.check(),s&&u.isText&&u.marks.length===0?c+=u.text:s=!1,l=l?u.isBlock:!1}),a===r&&l){const{parent:u}=n.doc.resolve(a);u.isTextblock&&!u.type.spec.code&&!u.childCount&&(a-=1,r+=1)}return s?n.insertText(c,a,r):n.replaceWith(a,r,t),i.updateSelection&&k.selectionToInsertionEnd(n,n.steps.length-1,-1),o.dispatch(n),!0}function la(e){const t=e._tiptapEditor.state;if(t.selection.empty||"node"in t.selection)return;const o=t.doc.resolve(z(t.doc,t.selection.from).posBeforeNode),i=t.doc.resolve(z(t.doc,t.selection.to).posBeforeNode),n=(c,u)=>{const p=o.posAtIndex(c,u),m=t.doc.resolve(p).nodeAfter;if(!m)throw new Error(`Error getting selection - node not found at position ${p}`);return S(m,e.schema.blockSchema,e.schema.inlineContentSchema,e.schema.styleSchema,e.blockCache)},a=[],r=o.sharedDepth(i.pos),s=o.index(r),l=i.index(r);if(o.depth>r){a.push(S(o.nodeAfter,e.schema.blockSchema,e.schema.inlineContentSchema,e.schema.styleSchema,e.blockCache));for(let c=o.depth;c>r;c--)if(o.node(c).type.isInGroup("childContainer")){const p=o.index(c)+1,m=o.node(c).childCount;for(let f=p;f<m;f++)a.push(n(f,c))}}else a.push(n(s,r));for(let c=s+1;c<=l;c++)a.push(n(c,r));if(a.length===0)throw new Error(`Error getting selection - selection doesn't span any blocks (${t.selection})`);return{blocks:a}}function da(e,t,o){const i=typeof t=="string"?t:t.id,n=typeof o=="string"?o:o.id;if(i===n)throw new Error(`Attempting to set selection with the same anchor and head blocks (id ${i})`);const a=e._tiptapEditor.state.doc,r=A(i,a);if(!r)throw new Error(`Block with ID ${i} not found`);const s=A(n,a);if(!s)throw new Error(`Block with ID ${n} not found`);const l=F(r),c=F(s),u=e.schema.blockSchema[l.blockNoteType],p=e.schema.blockSchema[c.blockNoteType];if(!l.isBlockContainer||u.content==="none")throw new Error(`Attempting to set selection anchor in block without content (id ${i})`);if(!c.isBlockContainer||p.content==="none")throw new Error(`Attempting to set selection anchor in block without content (id ${n})`);let m,f;if(u.content==="table"){const g=U.TableMap.get(l.blockContent.node);m=l.blockContent.beforePos+g.positionAt(0,0,l.blockContent.node)+1+2}else m=l.blockContent.beforePos+1;if(p.content==="table"){const g=U.TableMap.get(c.blockContent.node),b=c.blockContent.beforePos+g.positionAt(g.height-1,g.width-1,c.blockContent.node)+1,y=a.resolve(b).nodeAfter.nodeSize;f=b+y-2}else f=c.blockContent.afterPos-1;e._tiptapEditor.dispatch(e._tiptapEditor.state.tr.setSelection(_.TextSelection.create(e._tiptapEditor.state.doc,m,f)))}function ca(e){const{bnBlock:t}=C(e._tiptapEditor.state),o=e._tiptapEditor.state.doc.resolve(t.beforePos),i=o.nodeBefore,n=e._tiptapEditor.state.doc.resolve(t.afterPos).nodeAfter;let a;return o.depth>1&&(a=o.node(),a.type.isInGroup("bnBlock")||(a=o.node(o.depth-1))),{block:S(t.node,e.schema.blockSchema,e.schema.inlineContentSchema,e.schema.styleSchema,e.blockCache),prevBlock:i===null?void 0:S(i,e.schema.blockSchema,e.schema.inlineContentSchema,e.schema.styleSchema,e.blockCache),nextBlock:n===null?void 0:S(n,e.schema.blockSchema,e.schema.inlineContentSchema,e.schema.styleSchema,e.blockCache),parentBlock:a===void 0?void 0:S(a,e.schema.blockSchema,e.schema.inlineContentSchema,e.schema.styleSchema,e.blockCache)}}function Ho(e,t,o="start"){const i=typeof t=="string"?t:t.id,n=A(i,e._tiptapEditor.state.doc);if(!n)throw new Error(`Block with ID ${i} not found`);const a=F(n),r=e.schema.blockSchema[a.blockNoteType].content;if(a.isBlockContainer){const s=a.blockContent;if(r==="none"){e._tiptapEditor.commands.setNodeSelection(s.beforePos);return}if(r==="inline")o==="start"?e._tiptapEditor.commands.setTextSelection(s.beforePos+1):e._tiptapEditor.commands.setTextSelection(s.afterPos-1);else if(r==="table")o==="start"?e._tiptapEditor.commands.setTextSelection(s.beforePos+4):e._tiptapEditor.commands.setTextSelection(s.afterPos-4);else throw new j(r)}else{const s=o==="start"?a.childContainer.node.firstChild:a.childContainer.node.lastChild;Ho(e,s.attrs.id,o)}}d.esmDependencies=void 0;async function xe(){if(d.esmDependencies)return d.esmDependencies;const e=await Promise.all([import("rehype-parse"),import("rehype-stringify"),import("unified"),import("hast-util-from-dom"),import("rehype-remark"),import("remark-gfm"),import("remark-stringify"),import("remark-parse"),import("remark-rehype"),import("rehype-format")]);return d.esmDependencies={rehypeParse:e[0],rehypeStringify:e[1],unified:e[2],hastUtilFromDom:e[3],rehypeRemark:e[4],remarkGfm:e[5],remarkStringify:e[6],remarkParse:e[7],remarkRehype:e[8],rehypeFormat:e[9]},d.esmDependencies}function ua(){const e=t=>{let o=t.children.length;for(let i=0;i<o;i++){const n=t.children[i];if(n.type==="element"&&(e(n),n.tagName==="u"))if(n.children.length>0){t.children.splice(i,1,...n.children);const a=n.children.length-1;o+=a,i+=a}else t.children.splice(i,1),o--,i--}};return e}function pa(){const e=d.esmDependencies;if(!e)throw new Error("addSpacesToCheckboxes requires ESM dependencies to be initialized");const t=o=>{var i;if(o.children&&"length"in o.children&&o.children.length)for(let n=o.children.length-1;n>=0;n--){const a=o.children[n],r=n+1<o.children.length?o.children[n+1]:void 0;a.type==="element"&&a.tagName==="input"&&((i=a.properties)==null?void 0:i.type)==="checkbox"&&(r==null?void 0:r.type)==="element"&&r.tagName==="p"?(r.tagName="span",r.children.splice(0,0,e.hastUtilFromDom.fromDom(document.createTextNode(" ")))):t(a)}};return t}function Se(e){const t=d.esmDependencies;if(!t)throw new Error("cleanHTMLToMarkdown requires ESM dependencies to be initialized");return t.unified.unified().use(t.rehypeParse.default,{fragment:!0}).use(ua).use(pa).use(t.rehypeRemark.default).use(t.remarkGfm.default).use(t.remarkStringify.default,{handlers:{text:i=>i.value}}).processSync(e).value}async function Oo(e,t,o,i){await xe();const a=de(t,o).exportBlocks(e,i);return Se(a)}function ha(e){return Array.prototype.indexOf.call(e.parentElement.childNodes,e)}function ma(e){return e.nodeType===3&&!/\S/.test(e.nodeValue||"")}function fa(e){e.querySelectorAll("li > ul, li > ol").forEach(t=>{const o=ha(t),i=t.parentElement,n=Array.from(i.childNodes).slice(o+1);t.remove(),n.forEach(a=>{a.remove()}),i.insertAdjacentElement("afterend",t),n.reverse().forEach(a=>{if(ma(a))return;const r=document.createElement("li");r.append(a),t.insertAdjacentElement("afterend",r)}),i.childNodes.length===0&&i.remove()})}function ga(e){e.querySelectorAll("li + ul, li + ol").forEach(t=>{var a,r;const o=t.previousElementSibling,i=document.createElement("div");o.insertAdjacentElement("afterend",i),i.append(o);const n=document.createElement("div");for(n.setAttribute("data-node-type","blockGroup"),i.append(n);((a=i.nextElementSibling)==null?void 0:a.nodeName)==="UL"||((r=i.nextElementSibling)==null?void 0:r.nodeName)==="OL";)n.append(i.nextElementSibling)})}let Uo=null;function ba(){return Uo||(Uo=document.implementation.createHTMLDocument("title"))}function Ro(e){if(typeof e=="string"){const t=ba().createElement("div");t.innerHTML=e,e=t}return fa(e),ga(e),e}async function tt(e,t,o,i,n){const a=Ro(e),s=w.DOMParser.fromSchema(n).parse(a,{topNode:n.nodes.blockGroup.create()}),l=[];for(let c=0;c<s.childCount;c++)l.push(S(s.child(c),t,o,i));return l}function ka(e,t){const o=t.value?t.value:"",i={};t.lang&&(i["data-language"]=t.lang);let n={type:"element",tagName:"code",properties:i,children:[{type:"text",value:o}]};return t.meta&&(n.data={meta:t.meta}),e.patch(t,n),n=e.applyData(t,n),n={type:"element",tagName:"pre",properties:{},children:[n]},e.patch(t,n),n}async function Vo(e,t,o,i,n){const a=await xe(),r=a.unified.unified().use(a.remarkParse.default).use(a.remarkGfm.default).use(a.remarkRehype.default,{handlers:{...a.remarkRehype.defaultHandlers,code:ka}}).use(a.rehypeStringify.default).processSync(e);return tt(r.value,t,o,i,n)}const ot=["vscode-editor-data","blocknote/html","text/html","text/plain","Files"];function _a(e,t){if(!e.startsWith(".")||!t.startsWith("."))throw new Error("The strings provided are not valid file extensions.");return e===t}function ya(e,t){const o=e.split("/"),i=t.split("/");if(o.length!==2)throw new Error(`The string ${e} is not a valid MIME type.`);if(i.length!==2)throw new Error(`The string ${t} is not a valid MIME type.`);return o[1]==="*"||i[1]==="*"?o[0]===i[0]:(o[0]==="*"||i[0]==="*"||o[0]===i[0])&&o[1]===i[1]}async function zo(e,t){var r;if(!t.uploadFile){console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");return}const o="dataTransfer"in e?e.dataTransfer:e.clipboardData;if(o===null)return;let i=null;for(const s of ot)if(o.types.includes(s)){i=s;break}if(i!=="Files")return;const n=o.items;if(!n)return;e.preventDefault();const a=Object.values(t.schema.blockSchema).filter(s=>s.isFileBlock);for(let s=0;s<n.length;s++){let l="file";for(const u of a)for(const p of u.fileBlockAccept||[]){const m=p.startsWith("."),f=n[s].getAsFile();if(f&&(!m&&f.type&&ya(n[s].type,p)||m&&_a("."+f.name.split(".").pop(),p))){l=u.type;break}}const c=n[s].getAsFile();if(c){const u={type:l,props:{name:c.name}};let p;if(e.type==="paste")p=t.insertBlocks([u],t.getTextCursorPosition().block,"after")[0].id;else if(e.type==="drop"){const g={left:e.clientX,top:e.clientY},b=(r=t.prosemirrorView)==null?void 0:r.posAtCoords(g);if(!b)return;const y=z(t._tiptapEditor.state.doc,b.pos),v=F(y);p=t.insertBlocks([u],v.bnBlock.node.attrs.id,"after")[0].id}else return;const m=await t.uploadFile(c,p),f=typeof m=="string"?{props:{url:m}}:{...m};t.updateBlock(p,f)}}}const va=e=>k.Extension.create({name:"dropFile",addProseMirrorPlugins(){return[new _.Plugin({props:{handleDOMEvents:{drop(t,o){if(!e.isEditable)return;let i=null;for(const n of ot)if(o.dataTransfer.types.includes(n)){i=n;break}return i===null?!0:i==="Files"?(zo(o,e),!0):!1}}}})]}});async function wa(e,t){const{schema:o}=t.state;if(!e.clipboardData)return!1;const i=e.clipboardData.getData("text/plain");if(!i)return!1;if(!o.nodes.codeBlock)return t.pasteText(i),!0;const n=e.clipboardData.getData("vscode-editor-data"),a=n?JSON.parse(n):void 0,r=a==null?void 0:a.mode;return r?(t.pasteHTML(`<pre><code class="language-${r}">${i.replace(/\r\n?/g,`
|
|
10
|
-
`)}</code></pre>`),!0):!1}const Ca=e=>k.Extension.create({name:"pasteFromClipboard",addProseMirrorPlugins(){return[new _.Plugin({props:{handleDOMEvents:{paste(t,o){if(o.preventDefault(),!e.isEditable)return;let i;for(const a of ot)if(o.clipboardData.types.includes(a)){i=a;break}if(!i)return!0;if(i==="vscode-editor-data")return wa(o,t),!0;if(i==="Files")return zo(o,e),!0;let n=o.clipboardData.getData(i);return i==="blocknote/html"?(t.pasteHTML(n),!0):i==="text/html"?(n=Ro(n.trim()).innerHTML,t.pasteHTML(n),!0):(t.pasteText(n),!0)}}}})]}});function Fo(e,t){const o=[];return e.descendants(i=>{var n,a;return i.type.name==="blockContainer"&&((n=i.firstChild)==null?void 0:n.type.name)==="blockGroup"?!0:i.type.name==="columnList"&&i.childCount===1?((a=i.firstChild)==null||a.forEach(r=>{o.push(S(r,t.blockSchema,t.inlineContentSchema,t.styleSchema))}),!1):i.type.isInGroup("bnBlock")?(o.push(S(i,t.blockSchema,t.inlineContentSchema,t.styleSchema)),!1):!0}),o}function xa(e,t,o){var s;let i=!1;const n=e.state.selection instanceof U.CellSelection;if(!n){const l=e.state.doc.slice(e.state.selection.from,e.state.selection.to,!1).content,c=[];for(let u=0;u<l.childCount;u++)c.push(l.child(u));i=c.find(u=>u.type.isInGroup("bnBlock")||u.type.name==="blockGroup"||u.type.spec.group==="blockContent")===void 0,i&&(t=l)}let a;const r=de(e.state.schema,o);if(n){((s=t.firstChild)==null?void 0:s.type.name)==="table"&&(t=t.firstChild.content);const l=Ue(t,o.schema.inlineContentSchema,o.schema.styleSchema);a=`<table>${r.exportInlineContent(l,{})}</table>`}else if(i){const l=pe(t,o.schema.inlineContentSchema,o.schema.styleSchema);a=r.exportInlineContent(l,{})}else{const l=Fo(t,o.schema);a=r.exportBlocks(l,{})}return a}function Go(e,t){"node"in e.state.selection&&e.state.selection.node.type.spec.group==="blockContent"&&t.dispatch(t._tiptapEditor.state.tr.setSelection(new _.NodeSelection(e.state.doc.resolve(e.state.selection.from-1))));const o=ct.__serializeForClipboard(e,e.state.selection.content()).dom.innerHTML,i=e.state.selection.content().content,n=xa(e,i,t),a=Se(n);return{clipboardHTML:o,externalHTML:n,markdown:a}}const $o=(e,t,o)=>{o.preventDefault(),o.clipboardData.clearData();const{clipboardHTML:i,externalHTML:n,markdown:a}=Go(t,e);o.clipboardData.setData("blocknote/html",i),o.clipboardData.setData("text/html",n),o.clipboardData.setData("text/plain",a)},Sa=e=>k.Extension.create({name:"copyToClipboard",addProseMirrorPlugins(){return[new _.Plugin({props:{handleDOMEvents:{copy(t,o){return $o(e,t,o),!0},cut(t,o){return $o(e,t,o),t.editable&&t.dispatch(t.state.tr.deleteSelection()),!0},dragstart(t,o){if(!("node"in t.state.selection)||t.state.selection.node.type.spec.group!=="blockContent")return;e.dispatch(e._tiptapEditor.state.tr.setSelection(new _.NodeSelection(t.state.doc.resolve(t.state.selection.from-1)))),o.preventDefault(),o.dataTransfer.clearData();const{clipboardHTML:i,externalHTML:n,markdown:a}=Go(t,e);return o.dataTransfer.setData("blocknote/html",i),o.dataTransfer.setData("text/html",n),o.dataTransfer.setData("text/plain",a),!0}}}})]}}),Ba=k.Extension.create({name:"blockBackgroundColor",addGlobalAttributes(){return[{types:["blockContainer"],attributes:{backgroundColor:{default:B.backgroundColor.default,parseHTML:e=>e.hasAttribute("data-background-color")?e.getAttribute("data-background-color"):B.backgroundColor.default,renderHTML:e=>e.backgroundColor===B.backgroundColor.default?{}:{"data-background-color":e.backgroundColor}}}}]}});class ie{constructor(){h(this,"callbacks",{})}on(t,o){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(o),()=>this.off(t,o)}emit(t,...o){const i=this.callbacks[t];i&&i.forEach(n=>n.apply(this,o))}off(t,o){const i=this.callbacks[t];i&&(o?this.callbacks[t]=i.filter(n=>n!==o):delete this.callbacks[t])}removeAllListeners(){this.callbacks={}}}class Ko{constructor(t,o,i,n){h(this,"state");h(this,"emitUpdate");h(this,"mouseDownHandler",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())});h(this,"dragstartHandler",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())});h(this,"scrollHandler",()=>{var t;if((t=this.state)!=null&&t.show){const o=this.pmView.root.querySelector(`[data-node-type="blockContainer"][data-id="${this.state.block.id}"]`);if(!o)return;this.state.referencePos=o.getBoundingClientRect(),this.emitUpdate()}});h(this,"closeMenu",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())});this.editor=t,this.pluginKey=o,this.pmView=i,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized file panel");n(this.state)},i.dom.addEventListener("mousedown",this.mouseDownHandler),i.dom.addEventListener("dragstart",this.dragstartHandler),i.root.addEventListener("scroll",this.scrollHandler,!0)}update(t,o){var n,a;const i=this.pluginKey.getState(t.state);if(!((n=this.state)!=null&&n.show)&&i.block&&this.editor.isEditable){const r=this.pmView.root.querySelector(`[data-node-type="blockContainer"][data-id="${i.block.id}"]`);if(!r)return;this.state={show:!0,referencePos:r.getBoundingClientRect(),block:i.block},this.emitUpdate();return}(!t.state.selection.eq(o.selection)||!t.state.doc.eq(o.doc)||!this.editor.isEditable)&&(a=this.state)!=null&&a.show&&(this.state.show=!1,this.emitUpdate())}destroy(){this.pmView.dom.removeEventListener("mousedown",this.mouseDownHandler),this.pmView.dom.removeEventListener("dragstart",this.dragstartHandler),this.pmView.root.removeEventListener("scroll",this.scrollHandler,!0)}}const it=new _.PluginKey("FilePanelPlugin");class Wo extends ie{constructor(o){super();h(this,"view");h(this,"plugin");h(this,"closeMenu",()=>{var o;return(o=this.view)==null?void 0:o.closeMenu()});this.plugin=new _.Plugin({key:it,view:i=>(this.view=new Ko(o,it,i,n=>{this.emit("update",n)}),this.view),props:{handleKeyDown:(i,n)=>{var a;return n.key==="Escape"&&this.shown?((a=this.view)==null||a.closeMenu(),!0):!1}},state:{init:()=>({block:void 0}),apply:i=>{var a;return{block:(a=i.getMeta(it))==null?void 0:a.block}}}})}get shown(){var o,i;return((i=(o=this.view)==null?void 0:o.state)==null?void 0:i.show)||!1}onUpdate(o){return this.on("update",o)}}class qo{constructor(t,o,i){h(this,"state");h(this,"emitUpdate");h(this,"preventHide",!1);h(this,"preventShow",!1);h(this,"shouldShow",({state:t,from:o,to:i,view:n})=>{const{doc:a,selection:r}=t,{empty:s}=r,l=!a.textBetween(o,i).length&&k.isTextSelection(t.selection);return r.$from.parent.type.spec.code||k.isNodeSelection(r)&&r.node.type.spec.code?!1:!(!n.hasFocus()||s||l)});h(this,"blurHandler",t=>{var i;if(this.preventHide){this.preventHide=!1;return}const o=this.pmView.dom.parentElement;t&&t.relatedTarget&&(o===t.relatedTarget||o.contains(t.relatedTarget)||t.relatedTarget.matches(".bn-ui-container, .bn-ui-container *"))||(i=this.state)!=null&&i.show&&(this.state.show=!1,this.emitUpdate())});h(this,"viewMousedownHandler",()=>{this.preventShow=!0});h(this,"viewMouseupHandler",()=>{this.preventShow=!1,setTimeout(()=>this.update(this.pmView))});h(this,"dragHandler",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())});h(this,"scrollHandler",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.referencePos=this.getSelectionBoundingBox(),this.emitUpdate())});h(this,"closeMenu",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())});this.editor=t,this.pmView=o,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized formatting toolbar");i(this.state)},o.dom.addEventListener("mousedown",this.viewMousedownHandler),o.dom.addEventListener("mouseup",this.viewMouseupHandler),o.dom.addEventListener("dragstart",this.dragHandler),o.dom.addEventListener("dragover",this.dragHandler),o.dom.addEventListener("blur",this.blurHandler),o.root.addEventListener("scroll",this.scrollHandler,!0)}update(t,o){var p,m;const{state:i,composing:n}=t,{selection:a}=i,r=o&&o.selection.from===i.selection.from&&o.selection.to===i.selection.to;if(n||r)return;const{ranges:s}=a,l=Math.min(...s.map(f=>f.$from.pos)),c=Math.max(...s.map(f=>f.$to.pos)),u=(p=this.shouldShow)==null?void 0:p.call(this,{view:t,state:i,from:l,to:c});if(!this.preventShow&&(u||this.preventHide)){this.state={show:!0,referencePos:this.getSelectionBoundingBox()},this.emitUpdate();return}if((m=this.state)!=null&&m.show&&!this.preventHide&&(!u||this.preventShow||!this.editor.isEditable)){this.state.show=!1,this.emitUpdate();return}}destroy(){this.pmView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.pmView.dom.removeEventListener("mouseup",this.viewMouseupHandler),this.pmView.dom.removeEventListener("dragstart",this.dragHandler),this.pmView.dom.removeEventListener("dragover",this.dragHandler),this.pmView.dom.removeEventListener("blur",this.blurHandler),this.pmView.root.removeEventListener("scroll",this.scrollHandler,!0)}getSelectionBoundingBox(){const{state:t}=this.pmView,{selection:o}=t,{ranges:i}=o,n=Math.min(...i.map(r=>r.$from.pos)),a=Math.max(...i.map(r=>r.$to.pos));if(k.isNodeSelection(o)){const r=this.pmView.nodeDOM(n);if(r)return r.getBoundingClientRect()}return k.posToDOMRect(this.pmView,n,a)}}const Xo=new _.PluginKey("FormattingToolbarPlugin");class Zo extends ie{constructor(o){super();h(this,"view");h(this,"plugin");h(this,"closeMenu",()=>this.view.closeMenu());this.plugin=new _.Plugin({key:Xo,view:i=>(this.view=new qo(o,i,n=>{this.emit("update",n)}),this.view),props:{handleKeyDown:(i,n)=>n.key==="Escape"&&this.shown?(this.view.closeMenu(),!0):!1}})}get shown(){var o,i;return((i=(o=this.view)==null?void 0:o.state)==null?void 0:i.show)||!1}onUpdate(o){return this.on("update",o)}}const Jo=(e,t)=>{const o=e.resolve(t);if(o.depth<=1)return;const i=o.posAtIndex(o.index(o.depth-1),o.depth-1);return Q(e.resolve(i))},nt=(e,t)=>{const o=e.resolve(t),i=o.index();if(i===0)return;const n=o.posAtIndex(i-1);return Q(e.resolve(n))},Yo=(e,t)=>{for(;t.childContainer;){const o=t.childContainer.node,i=e.resolve(t.childContainer.beforePos+1).posAtIndex(o.childCount-1);t=Q(e.resolve(i))}return t},Ea=(e,t)=>e.isBlockContainer&&e.blockContent.node.type.spec.content==="inline*"&&e.blockContent.node.childCount>0&&t.isBlockContainer&&t.blockContent.node.type.spec.content==="inline*",Ta=(e,t,o,i)=>{if(!i.isBlockContainer)throw new Error(`Attempted to merge block at position ${i.bnBlock.beforePos} into previous block at position ${o.bnBlock.beforePos}, but next block is not a block container`);if(i.childContainer){const n=e.doc.resolve(i.childContainer.beforePos+1),a=e.doc.resolve(i.childContainer.afterPos-1),r=n.blockRange(a);if(t){const s=e.doc.resolve(i.bnBlock.beforePos);e.tr.lift(r,s.depth)}}if(t){if(!o.isBlockContainer)throw new Error(`Attempted to merge block at position ${i.bnBlock.beforePos} into previous block at position ${o.bnBlock.beforePos}, but previous block is not a block container`);t(e.tr.delete(o.blockContent.afterPos-1,i.blockContent.beforePos+1))}return!0},Qo=e=>({state:t,dispatch:o})=>{const i=t.doc.resolve(e),n=Q(i),a=nt(t.doc,n.bnBlock.beforePos);if(!a)return!1;const r=Yo(t.doc,a);return Ea(r,n)?Ta(t,o,r,n):!1},Ia=k.Extension.create({priority:50,addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.first(({chain:i,commands:n})=>[()=>n.deleteSelection(),()=>n.undoInputRule(),()=>n.command(({state:a})=>{const r=C(a);if(!r.isBlockContainer)return!1;const s=a.selection.from===r.blockContent.beforePos+1,l=r.blockContent.node.type.name==="paragraph";return s&&!l?n.command(T(this.options.editor,r.bnBlock.beforePos,{type:"paragraph",props:{}})):!1}),()=>n.command(({state:a})=>{const r=C(a);if(!r.isBlockContainer)return!1;const{blockContent:s}=r;return a.selection.from===s.beforePos+1?n.liftListItem("blockContainer"):!1}),()=>n.command(({state:a})=>{const r=C(a);if(!r.isBlockContainer)return!1;const{bnBlock:s,blockContent:l}=r,c=a.selection.from===l.beforePos+1,u=a.selection.empty,p=s.beforePos;return c&&u?i().command(Qo(p)).scrollIntoView().run():!1}),()=>n.command(({state:a,dispatch:r})=>{const s=C(a);if(!s.isBlockContainer||!(a.selection.from===s.blockContent.beforePos+1)||nt(a.doc,s.bnBlock.beforePos))return!1;const u=Jo(a.doc,s.bnBlock.beforePos);if((u==null?void 0:u.blockNoteType)!=="column")return!1;const p=u,m=Jo(a.doc,p.bnBlock.beforePos);if((m==null?void 0:m.blockNoteType)!=="columnList")throw new Error("parent of column is not a column list");const f=p.childContainer.node.childCount===1,g=f&&m.childContainer.node.childCount===2,b=m.childContainer.node.firstChild===p.bnBlock.node;if(r){const y=a.doc.slice(s.bnBlock.beforePos,s.bnBlock.afterPos,!1);if(g)if(b){a.tr.step(new be.ReplaceAroundStep(m.bnBlock.beforePos,m.bnBlock.afterPos,p.bnBlock.afterPos+1,m.bnBlock.afterPos-2,y,y.size,!1));const v=a.tr.doc.resolve(p.bnBlock.beforePos);a.tr.setSelection(_.TextSelection.between(v,v))}else{a.tr.step(new be.ReplaceAroundStep(m.bnBlock.beforePos,m.bnBlock.afterPos,m.bnBlock.beforePos+2,p.bnBlock.beforePos-1,y,0,!1));const v=a.tr.doc.resolve(a.tr.mapping.map(p.bnBlock.beforePos-1));a.tr.setSelection(_.TextSelection.between(v,v))}else if(f)if(b){a.tr.delete(p.bnBlock.beforePos,p.bnBlock.afterPos),a.tr.insert(m.bnBlock.beforePos,y.content);const v=a.tr.doc.resolve(m.bnBlock.beforePos);a.tr.setSelection(_.TextSelection.between(v,v))}else a.tr.delete(p.bnBlock.beforePos-1,p.bnBlock.beforePos+1);else{a.tr.delete(s.bnBlock.beforePos,s.bnBlock.afterPos),b?a.tr.insert(m.bnBlock.beforePos-1,y.content):a.tr.insert(p.bnBlock.beforePos-1,y.content);const v=a.tr.doc.resolve(p.bnBlock.beforePos-1);a.tr.setSelection(_.TextSelection.between(v,v))}}return!0}),()=>n.command(({state:a})=>{const r=C(a);if(!r.isBlockContainer)throw new Error("todo");const s=a.selection.from===r.blockContent.beforePos+1,l=a.selection.empty,c=nt(a.doc,r.bnBlock.beforePos);if(c&&s&&l){const u=Yo(a.doc,c);if(!u.isBlockContainer)throw new Error("todo");if(u.blockContent.node.type.spec.content===""||u.blockContent.node.type.spec.content==="inline*"&&u.blockContent.node.childCount===0)return i().cut({from:r.bnBlock.beforePos,to:r.bnBlock.afterPos},u.bnBlock.afterPos).deleteRange({from:u.bnBlock.beforePos,to:u.bnBlock.afterPos}).run()}return!1})]),Delete:()=>this.editor.commands.first(({commands:i})=>[()=>i.deleteSelection(),()=>i.command(({state:n})=>{const a=C(n);if(!a.isBlockContainer)return!1;const{bnBlock:r,blockContent:s,childContainer:l}=a,{depth:c}=n.doc.resolve(r.beforePos),u=r.afterPos===n.doc.nodeSize-3,p=n.selection.from===s.afterPos-1,m=n.selection.empty;if(!u&&p&&m&&!(l!==void 0)){let g=c,b=r.afterPos+1,y=n.doc.resolve(b).depth;for(;y<g;)g=y,b+=2,y=n.doc.resolve(b).depth;return i.command(Qo(b-1))}return!1})]),Enter:()=>this.editor.commands.first(({commands:i})=>[()=>i.command(({state:n})=>{const a=C(n);if(!a.isBlockContainer)return!1;const{bnBlock:r,blockContent:s}=a,{depth:l}=n.doc.resolve(r.beforePos),c=n.selection.$anchor.parentOffset===0,u=n.selection.anchor===n.selection.head,p=s.node.childCount===0,m=l>1;return c&&u&&p&&m?i.liftListItem("blockContainer"):!1}),()=>i.command(({state:n,dispatch:a})=>{const r=C(n);if(!r.isBlockContainer)return!1;const{bnBlock:s,blockContent:l}=r,c=n.selection.$anchor.parentOffset===0,u=n.selection.anchor===n.selection.head,p=l.node.childCount===0;if(c&&u&&p){const m=s.afterPos,f=m+2;if(a){const g=n.schema.nodes.blockContainer.createAndFill();n.tr.insert(m,g).scrollIntoView(),n.tr.setSelection(new _.TextSelection(n.doc.resolve(f)))}return!0}return!1}),()=>i.command(({state:n,chain:a})=>{const r=C(n);if(!r.isBlockContainer)return!1;const{blockContent:s}=r,l=n.selection.$anchor.parentOffset===0;return s.node.childCount===0?!1:(a().deleteSelection().command(mo(n.selection.from,l,l)).run(),!0)})]),Tab:()=>{var i,n,a;return this.options.tabBehavior!=="prefer-indent"&&((i=this.options.editor.formattingToolbar)!=null&&i.shown||(n=this.options.editor.linkToolbar)!=null&&n.shown||(a=this.options.editor.filePanel)!=null&&a.shown)?!1:Do(this.options.editor)},"Shift-Tab":()=>{var i,n,a;return this.options.tabBehavior!=="prefer-indent"&&((i=this.options.editor.formattingToolbar)!=null&&i.shown||(n=this.options.editor.linkToolbar)!=null&&n.shown||(a=this.options.editor.filePanel)!=null&&a.shown)?!1:(this.editor.commands.liftListItem("blockContainer"),!0)},"Shift-Mod-ArrowUp":()=>(this.options.editor.moveBlocksUp(),!0),"Shift-Mod-ArrowDown":()=>(this.options.editor.moveBlocksDown(),!0)}}});class Ma{constructor(t,o,i){h(this,"state");h(this,"emitUpdate");h(this,"menuUpdateTimer");h(this,"startMenuUpdateTimer");h(this,"stopMenuUpdateTimer");h(this,"mouseHoveredLinkMark");h(this,"mouseHoveredLinkMarkRange");h(this,"keyboardHoveredLinkMark");h(this,"keyboardHoveredLinkMarkRange");h(this,"linkMark");h(this,"linkMarkRange");h(this,"mouseOverHandler",t=>{if(this.mouseHoveredLinkMark=void 0,this.mouseHoveredLinkMarkRange=void 0,this.stopMenuUpdateTimer(),t.target instanceof HTMLAnchorElement&&t.target.nodeName==="A"){const o=t.target,i=this.pmView.posAtDOM(o,0)+1,n=this.pmView.state.doc.resolve(i),a=n.marks();for(const r of a)if(r.type.name===this.pmView.state.schema.mark("link").type.name){this.mouseHoveredLinkMark=r,this.mouseHoveredLinkMarkRange=k.getMarkRange(n,r.type,r.attrs)||void 0;break}}return this.startMenuUpdateTimer(),!1});h(this,"clickHandler",t=>{var i;const o=this.pmView.dom.parentElement;this.linkMark&&t&&t.target&&!(o===t.target||o.contains(t.target))&&(i=this.state)!=null&&i.show&&(this.state.show=!1,this.emitUpdate())});h(this,"scrollHandler",()=>{var t;this.linkMark!==void 0&&(t=this.state)!=null&&t.show&&(this.state.referencePos=k.posToDOMRect(this.pmView,this.linkMarkRange.from,this.linkMarkRange.to),this.emitUpdate())});h(this,"closeMenu",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())});this.editor=t,this.pmView=o,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized link toolbar");i(this.state)},this.startMenuUpdateTimer=()=>{this.menuUpdateTimer=setTimeout(()=>{this.update(this.pmView)},250)},this.stopMenuUpdateTimer=()=>(this.menuUpdateTimer&&(clearTimeout(this.menuUpdateTimer),this.menuUpdateTimer=void 0),!1),this.pmView.dom.addEventListener("mouseover",this.mouseOverHandler),this.pmView.root.addEventListener("click",this.clickHandler,!0),this.pmView.root.addEventListener("scroll",this.scrollHandler,!0)}editLink(t,o){var n;const i=this.pmView.state.tr.insertText(o,this.linkMarkRange.from,this.linkMarkRange.to);i.addMark(this.linkMarkRange.from,this.linkMarkRange.from+o.length,this.pmView.state.schema.mark("link",{href:t})),this.editor.dispatch(i),this.pmView.focus(),(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())}deleteLink(){var t;this.editor.dispatch(this.pmView.state.tr.removeMark(this.linkMarkRange.from,this.linkMarkRange.to,this.linkMark.type).setMeta("preventAutolink",!0)),this.pmView.focus(),(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())}update(t,o){var r;const{state:i}=t;if(o&&o.selection.from===i.selection.from&&o.selection.to===i.selection.to||!this.pmView.hasFocus())return;const a=this.linkMark;if(this.linkMark=void 0,this.linkMarkRange=void 0,this.keyboardHoveredLinkMark=void 0,this.keyboardHoveredLinkMarkRange=void 0,this.pmView.state.selection.empty){const s=this.pmView.state.selection.$from.marks();for(const l of s)if(l.type.name===this.pmView.state.schema.mark("link").type.name){this.keyboardHoveredLinkMark=l,this.keyboardHoveredLinkMarkRange=k.getMarkRange(this.pmView.state.selection.$from,l.type,l.attrs)||void 0;break}}if(this.mouseHoveredLinkMark&&(this.linkMark=this.mouseHoveredLinkMark,this.linkMarkRange=this.mouseHoveredLinkMarkRange),this.keyboardHoveredLinkMark&&(this.linkMark=this.keyboardHoveredLinkMark,this.linkMarkRange=this.keyboardHoveredLinkMarkRange),this.linkMark&&this.editor.isEditable){this.state={show:!0,referencePos:k.posToDOMRect(this.pmView,this.linkMarkRange.from,this.linkMarkRange.to),url:this.linkMark.attrs.href,text:this.pmView.state.doc.textBetween(this.linkMarkRange.from,this.linkMarkRange.to)},this.emitUpdate();return}if((r=this.state)!=null&&r.show&&a&&(!this.linkMark||!this.editor.isEditable)){this.state.show=!1,this.emitUpdate();return}}destroy(){this.pmView.dom.removeEventListener("mouseover",this.mouseOverHandler),this.pmView.root.removeEventListener("scroll",this.scrollHandler,!0),this.pmView.root.removeEventListener("click",this.clickHandler,!0)}}const ei=new _.PluginKey("LinkToolbarPlugin");class ti extends ie{constructor(o){super();h(this,"view");h(this,"plugin");h(this,"editLink",(o,i)=>{this.view.editLink(o,i)});h(this,"deleteLink",()=>{this.view.deleteLink()});h(this,"startHideTimer",()=>{this.view.startMenuUpdateTimer()});h(this,"stopHideTimer",()=>{this.view.stopMenuUpdateTimer()});h(this,"closeMenu",()=>this.view.closeMenu());this.plugin=new _.Plugin({key:ei,view:i=>(this.view=new Ma(o,i,n=>{this.emit("update",n)}),this.view),props:{handleKeyDown:(i,n)=>n.key==="Escape"&&this.shown?(this.view.closeMenu(),!0):!1}})}onUpdate(o){return this.on("update",o)}get shown(){var o,i;return((i=(o=this.view)==null?void 0:o.state)==null?void 0:i.show)||!1}}const oi=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"],ii="https",La=new _.PluginKey("node-selection-keyboard");class Pa{constructor(){h(this,"plugin");this.plugin=new _.Plugin({key:La,props:{handleKeyDown:(t,o)=>{if("node"in t.state.selection){if(o.ctrlKey||o.metaKey)return!1;if(o.key.length===1)return o.preventDefault(),!0;if(o.key==="Enter"&&!o.shiftKey&&!o.altKey&&!o.ctrlKey&&!o.metaKey){const i=t.state.tr;return t.dispatch(i.insert(t.state.tr.selection.$to.after(),t.state.schema.nodes.paragraph.createChecked()).setSelection(new _.TextSelection(i.doc.resolve(t.state.tr.selection.$to.after()+1)))),!0}}return!1}}})}}const Aa=new _.PluginKey("blocknote-placeholder");class Na{constructor(t,o){h(this,"plugin");this.plugin=new _.Plugin({key:Aa,view:()=>{var l,c;const i=document.createElement("style"),n=t._tiptapEditor.options.injectNonce;n&&i.setAttribute("nonce",n),((l=t.prosemirrorView)==null?void 0:l.root)instanceof ShadowRoot?t.prosemirrorView.root.append(i):(c=t.prosemirrorView)==null||c.root.head.appendChild(i);const a=i.sheet,r=(u="")=>`.bn-block-content${u} .bn-inline-content:has(> .ProseMirror-trailingBreak:only-child):before`,s=(u,p=!0)=>{const m=p?"[data-is-empty-and-focused]":"";if(u==="default")return r(m);const f=`[data-content-type="${u}"]`;return r(m+f)};for(const[u,p]of Object.entries(o)){const m=u==="default";try{a.insertRule(`${s(u,m)} { content: ${JSON.stringify(p)}; }`),m||a.insertRule(`${s(u,!0)} { content: ${JSON.stringify(p)}; }`)}catch(f){console.warn("Failed to insert placeholder CSS rule - this is likely due to the browser not supporting certain CSS pseudo-element selectors (:has, :only-child:, or :before)",f)}}return{destroy:()=>{var u,p;((u=t.prosemirrorView)==null?void 0:u.root)instanceof ShadowRoot?t.prosemirrorView.root.removeChild(i):(p=t.prosemirrorView)==null||p.root.head.removeChild(i)}}},props:{decorations:i=>{const{doc:n,selection:a}=i;if(!t.isEditable||!a.empty||a.$from.parent.type.spec.code)return;const r=a.$anchor,s=r.parent;if(s.content.size>0)return null;const l=r.before(),c=P.Decoration.node(l,l+s.nodeSize,{"data-is-empty-and-focused":"true"});return P.DecorationSet.create(n,[c])}}})}}const ni=new _.PluginKey("previous-blocks"),Da={index:"index",level:"level",type:"type",depth:"depth","depth-change":"depth-change"};class ja{constructor(){h(this,"plugin");let t;this.plugin=new _.Plugin({key:ni,view(o){return{update:async(i,n)=>{var a;((a=this.key)==null?void 0:a.getState(i.state).updatedBlocks.size)>0&&(t=setTimeout(()=>{i.dispatch(i.state.tr.setMeta(ni,{clearUpdate:!0}))},0))},destroy:()=>{t&&clearTimeout(t)}}},state:{init(){return{prevTransactionOldBlockAttrs:{},currentTransactionOldBlockAttrs:{},updatedBlocks:new Set}},apply(o,i,n,a){if(i.currentTransactionOldBlockAttrs={},i.updatedBlocks.clear(),!o.docChanged||n.doc.eq(a.doc))return i;const r={},s=k.findChildren(n.doc,u=>u.attrs.id),l=new Map(s.map(u=>[u.node.attrs.id,u])),c=k.findChildren(a.doc,u=>u.attrs.id);for(const u of c){const p=l.get(u.node.attrs.id),m=p==null?void 0:p.node.firstChild,f=u.node.firstChild;if(p&&m&&f){const g={index:f.attrs.index,level:f.attrs.level,type:f.type.name,depth:a.doc.resolve(u.pos).depth};let b={index:m.attrs.index,level:m.attrs.level,type:m.type.name,depth:n.doc.resolve(p.pos).depth};r[u.node.attrs.id]=b,o.getMeta("numberedListIndexing")&&(u.node.attrs.id in i.prevTransactionOldBlockAttrs&&(b=i.prevTransactionOldBlockAttrs[u.node.attrs.id]),g.type==="numberedListItem"&&(b.index=g.index)),i.currentTransactionOldBlockAttrs[u.node.attrs.id]=b,JSON.stringify(b)!==JSON.stringify(g)&&(b["depth-change"]=b.depth-g.depth,i.updatedBlocks.add(u.node.attrs.id))}}return i.prevTransactionOldBlockAttrs=r,i}},props:{decorations(o){const i=this.getState(o);if(i.updatedBlocks.size===0)return;const n=[];return o.doc.descendants((a,r)=>{if(!a.attrs.id||!i.updatedBlocks.has(a.attrs.id))return;const s=i.currentTransactionOldBlockAttrs[a.attrs.id],l={};for(const[u,p]of Object.entries(s))l["data-prev-"+Da[u]]=p||"none";const c=P.Decoration.node(r,r+a.nodeSize,{...l});n.push(c)}),P.DecorationSet.create(o.doc,n)}}})}}function ai(e,t){var o,i;for(;e&&e.parentElement&&e.parentElement!==t.dom&&((o=e.getAttribute)==null?void 0:o.call(e,"data-node-type"))!=="blockContainer";)e=e.parentElement;if(((i=e.getAttribute)==null?void 0:i.call(e,"data-node-type"))==="blockContainer")return{node:e,id:e.getAttribute("data-id")}}class ne extends _.Selection{constructor(o,i){super(o,i);h(this,"nodes");const n=o.node();this.nodes=[],o.doc.nodesBetween(o.pos,i.pos,(a,r,s)=>{if(s!==null&&s.eq(n))return this.nodes.push(a),!1})}static create(o,i,n=i){return new ne(o.resolve(i),o.resolve(n))}content(){return new w.Slice(w.Fragment.from(this.nodes),0,0)}eq(o){if(!(o instanceof ne)||this.nodes.length!==o.nodes.length||this.from!==o.from||this.to!==o.to)return!1;for(let i=0;i<this.nodes.length;i++)if(!this.nodes[i].eq(o.nodes[i]))return!1;return!0}map(o,i){const n=i.mapResult(this.from),a=i.mapResult(this.to);return a.deleted?_.Selection.near(o.resolve(n.pos)):n.deleted?_.Selection.near(o.resolve(a.pos)):new ne(o.resolve(n.pos),o.resolve(a.pos))}toJSON(){return{type:"node",anchor:this.anchor,head:this.head}}}let V;function Ha(e,t){let o,i;const n=t.resolve(e.from).node().type.spec.group==="blockContent",a=t.resolve(e.to).node().type.spec.group==="blockContent",r=Math.min(e.$anchor.depth,e.$head.depth);if(n&&a){const s=e.$from.start(r-1),l=e.$to.end(r-1);o=t.resolve(s-1).pos,i=t.resolve(l+1).pos}else o=e.from,i=e.to;return{from:o,to:i}}function ri(e,t,o=t){t===o&&(o+=e.state.doc.resolve(t+1).node().nodeSize);const i=e.domAtPos(t).node.cloneNode(!0),n=e.domAtPos(t).node,a=(u,p)=>Array.prototype.indexOf.call(u.children,p),r=a(n,e.domAtPos(t+1).node.parentElement),s=a(n,e.domAtPos(o-1).node.parentElement);for(let u=n.childElementCount-1;u>=0;u--)(u>s||u<r)&&i.removeChild(i.children[u]);si(e.root),V=i;const c=e.dom.className.split(" ").filter(u=>u!=="ProseMirror"&&u!=="bn-root"&&u!=="bn-editor").join(" ");V.className=V.className+" bn-drag-preview "+c,e.root instanceof ShadowRoot?e.root.appendChild(V):e.root.body.appendChild(V)}function si(e){V!==void 0&&(e instanceof ShadowRoot?e.removeChild(V):e.body.removeChild(V),V=void 0)}function Oa(e,t,o){if(!e.dataTransfer)return;const i=o.prosemirrorView;if(!i)return;const n=A(t.id,i.state.doc);if(!n)throw new Error(`Block with ID ${t.id} not found`);const a=n.posBeforeNode;if(a!=null){const r=i.state.selection,s=i.state.doc,{from:l,to:c}=Ha(r,s),u=l<=a&&a<c,p=r.$anchor.node()!==r.$head.node()||r instanceof ne;u&&p?(i.dispatch(i.state.tr.setSelection(ne.create(s,l,c))),ri(i,l,c)):(i.dispatch(i.state.tr.setSelection(_.NodeSelection.create(i.state.doc,a))),ri(i,a));const m=i.state.selection.content(),f=o.pmSchema,g=ct.__serializeForClipboard(i,m).dom.innerHTML,b=de(f,o),y=Fo(m.content,o.schema),v=b.exportBlocks(y,{}),I=Se(v);e.dataTransfer.clearData(),e.dataTransfer.setData("blocknote/html",g),e.dataTransfer.setData("text/html",v),e.dataTransfer.setData("text/plain",I),e.dataTransfer.effectAllowed="move",e.dataTransfer.setDragImage(V,0,0)}}const fe=.1;function at(e,t,o,i=!0){const n=e.root.elementsFromPoint(t.left+(o==="editor"?50:0),t.top);for(const a of n)if(e.dom.contains(a))return i&&a.closest("[data-node-type=columnList]")?at(e,{left:t.left+50,top:t.top},o,!1):ai(a,e)}function Ua(e,t,o){if(!t.dom.firstChild)return;const i=t.dom.firstChild.getBoundingClientRect(),n={left:e.x,top:e.y},a=n.left<i.left,r=n.left>i.right;o==="viewport"&&(a&&(n.left=i.left+10),r&&(n.left=i.right-10));let s=at(t,n,o);if(!r&&s){const l=s.node.getBoundingClientRect();n.left=l.right-10,s=at(t,n,"viewport",!1)}return s}class li{constructor(t,o,i,n){h(this,"state");h(this,"emitUpdate");h(this,"mousePos");h(this,"hoveredBlock");h(this,"menuFrozen",!1);h(this,"isDragOrigin",!1);h(this,"updateState",t=>{this.state=t,this.emitUpdate(this.state)});h(this,"updateStateFromMousePos",()=>{var i,n,a,r;if(this.menuFrozen||!this.mousePos)return;const t=Ua(this.mousePos,this.pmView,this.sideMenuDetection);if(!t||!this.editor.isEditable){(i=this.state)!=null&&i.show&&(this.state.show=!1,this.updateState(this.state));return}if((n=this.state)!=null&&n.show&&((a=this.hoveredBlock)!=null&&a.hasAttribute("data-id"))&&((r=this.hoveredBlock)==null?void 0:r.getAttribute("data-id"))===t.id)return;this.hoveredBlock=t.node;const o=t.node.firstChild;if(o&&this.editor.isEditable){const s=o.getBoundingClientRect(),l=t.node.closest("[data-node-type=column]");this.updateState({show:!0,referencePos:new DOMRect(l?l.firstElementChild.getBoundingClientRect().x:this.pmView.dom.firstChild.getBoundingClientRect().x,s.y,s.width,s.height),block:this.editor.getBlock(this.hoveredBlock.getAttribute("data-id"))})}});h(this,"onDrop",t=>{var i;if(this.pmView.dragging===null||(this.editor._tiptapEditor.commands.blur(),!this.isDragOrigin&&this.pmView.dom.contains(t.target)?this.pmView.dispatch(this.pmView.state.tr.setSelection(_.TextSelection.create(this.pmView.state.tr.doc,this.pmView.state.tr.selection.to))):this.isDragOrigin&&!this.pmView.dom.contains(t.target)&&setTimeout(()=>this.pmView.dispatch(this.pmView.state.tr.deleteSelection()),0),setTimeout(()=>this.pmView.dragging=null,0),this.sideMenuDetection==="editor"||t.synthetic||!((i=t.dataTransfer)!=null&&i.types.includes("blocknote/html"))))return;const o=this.pmView.posAtCoords({left:t.clientX,top:t.clientY});if(!o||o.inside===-1){const n=this.createSyntheticEvent(t);this.pmView.dom.dispatchEvent(n)}});h(this,"onDragStart",t=>{var r;const o=(r=t.dataTransfer)==null?void 0:r.getData("blocknote/html");if(!o)return;if(this.pmView.dragging)throw new Error("New drag was started while an existing drag is ongoing");const i=document.createElement("div");i.innerHTML=o;const a=w.DOMParser.fromSchema(this.pmView.state.schema).parse(i,{topNode:this.pmView.state.schema.nodes.blockGroup.create()});this.pmView.dragging={slice:new w.Slice(a.content,0,0),move:!0}});h(this,"onDragOver",t=>{var i;if(this.sideMenuDetection==="editor"||t.synthetic||!((i=t.dataTransfer)!=null&&i.types.includes("blocknote/html")))return;const o=this.pmView.posAtCoords({left:t.clientX,top:t.clientY});if(!o||o.inside===-1&&this.pmView.dom.firstChild){const n=this.createSyntheticEvent(t);this.pmView.dom.dispatchEvent(n)}});h(this,"onKeyDown",t=>{var o;(o=this.state)!=null&&o.show&&this.editor.isFocused()&&(this.state.show=!1,this.emitUpdate(this.state))});h(this,"onMouseMove",t=>{var a;if(this.menuFrozen)return;this.mousePos={x:t.clientX,y:t.clientY};const o=this.pmView.dom.getBoundingClientRect(),i=this.mousePos.x>o.left&&this.mousePos.x<o.right&&this.mousePos.y>o.top&&this.mousePos.y<o.bottom,n=this.pmView.dom.parentElement;if(i&&t&&t.target&&!(n===t.target||n.contains(t.target))){(a=this.state)!=null&&a.show&&(this.state.show=!1,this.emitUpdate(this.state));return}this.updateStateFromMousePos()});h(this,"onScroll",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.referencePos=this.hoveredBlock.getBoundingClientRect(),this.emitUpdate(this.state))});this.editor=t,this.sideMenuDetection=o,this.pmView=i,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized side menu");n(this.state)},this.pmView.root.addEventListener("dragstart",this.onDragStart),this.pmView.root.addEventListener("dragover",this.onDragOver),this.pmView.root.addEventListener("drop",this.onDrop,!0),xe(),this.pmView.root.addEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.addEventListener("keydown",this.onKeyDown,!0),i.root.addEventListener("scroll",this.onScroll,!0)}createSyntheticEvent(t){const o=new Event(t.type,t),i=this.pmView.dom.firstChild.getBoundingClientRect();return o.clientX=t.clientX,o.clientY=t.clientY,t.clientX<i.left&&t.clientX>i.left-i.width*fe?o.clientX=i.left+i.width*fe/2:t.clientX>i.right&&t.clientX<i.right+i.width*fe?o.clientX=i.right-i.width*fe/2:(t.clientX<i.left||t.clientX>i.right)&&(o.clientX=i.left+fe*i.width*2),o.clientY=Math.min(Math.max(t.clientY,i.top),i.top+i.height),o.dataTransfer=t.dataTransfer,o.preventDefault=()=>t.preventDefault(),o.synthetic=!0,o}update(t,o){var n;!o.doc.eq(this.pmView.state.doc)&&((n=this.state)!=null&&n.show)&&this.updateStateFromMousePos()}destroy(){var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate(this.state)),this.pmView.root.removeEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.removeEventListener("dragstart",this.onDragStart),this.pmView.root.removeEventListener("dragover",this.onDragOver),this.pmView.root.removeEventListener("drop",this.onDrop,!0),this.pmView.root.removeEventListener("keydown",this.onKeyDown,!0),this.pmView.root.removeEventListener("scroll",this.onScroll,!0)}}const di=new _.PluginKey("SideMenuPlugin");class ci extends ie{constructor(o,i){super();h(this,"view");h(this,"plugin");h(this,"blockDragStart",(o,i)=>{this.view&&(this.view.isDragOrigin=!0),Oa(o,i,this.editor)});h(this,"blockDragEnd",()=>{this.editor.prosemirrorView&&si(this.editor.prosemirrorView.root),this.view&&(this.view.isDragOrigin=!1)});h(this,"freezeMenu",()=>{this.view.menuFrozen=!0,this.view.state.show=!0,this.view.emitUpdate(this.view.state)});h(this,"unfreezeMenu",()=>{this.view.menuFrozen=!1,this.view.state.show=!1,this.view.emitUpdate(this.view.state)});this.editor=o,this.plugin=new _.Plugin({key:di,view:n=>(this.view=new li(o,i,n,a=>{this.emit("update",a)}),this.view)})}onUpdate(o){return this.on("update",o)}}const Ra=k.findParentNode(e=>e.type.name==="blockContainer");class Va{constructor(t,o){h(this,"state");h(this,"emitUpdate");h(this,"rootEl");h(this,"pluginState");h(this,"handleScroll",()=>{var t,o;if((t=this.state)!=null&&t.show){const i=(o=this.rootEl)==null?void 0:o.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);if(!i)return;this.state.referencePos=i.getBoundingClientRect(),this.emitUpdate(this.pluginState.triggerCharacter)}});h(this,"closeMenu",()=>{this.editor.dispatch(this.editor._tiptapEditor.state.tr.setMeta(ae,null))});h(this,"clearQuery",()=>{this.pluginState!==void 0&&this.editor._tiptapEditor.chain().focus().deleteRange({from:this.pluginState.queryStartPos-(this.pluginState.deleteTriggerCharacter?this.pluginState.triggerCharacter.length:0),to:this.editor._tiptapEditor.state.selection.from}).run()});var i,n;this.editor=t,this.pluginState=void 0,this.emitUpdate=a=>{var r;if(!this.state)throw new Error("Attempting to update uninitialized suggestions menu");o(a,{...this.state,ignoreQueryLength:(r=this.pluginState)==null?void 0:r.ignoreQueryLength})},this.rootEl=(i=this.editor.prosemirrorView)==null?void 0:i.root,(n=this.rootEl)==null||n.addEventListener("scroll",this.handleScroll,!0)}update(t,o){var c;const i=ae.getState(o),n=ae.getState(t.state),a=i===void 0&&n!==void 0,r=i!==void 0&&n===void 0;if(!a&&!(i!==void 0&&n!==void 0)&&!r)return;if(this.pluginState=r?i:n,r||!this.editor.isEditable){this.state.show=!1,this.emitUpdate(this.pluginState.triggerCharacter);return}const l=(c=this.rootEl)==null?void 0:c.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);this.editor.isEditable&&l&&(this.state={show:!0,referencePos:l.getBoundingClientRect(),query:this.pluginState.query},this.emitUpdate(this.pluginState.triggerCharacter))}destroy(){var t;(t=this.rootEl)==null||t.removeEventListener("scroll",this.handleScroll,!0)}}const ae=new _.PluginKey("SuggestionMenuPlugin");class ui extends ie{constructor(o){super();h(this,"view");h(this,"plugin");h(this,"triggerCharacters",[]);h(this,"addTriggerCharacter",o=>{this.triggerCharacters.push(o)});h(this,"removeTriggerCharacter",o=>{this.triggerCharacters=this.triggerCharacters.filter(i=>i!==o)});h(this,"closeMenu",()=>this.view.closeMenu());h(this,"clearQuery",()=>this.view.clearQuery());const i=this.triggerCharacters;this.plugin=new _.Plugin({key:ae,view:()=>(this.view=new Va(o,(n,a)=>{this.emit(`update ${n}`,a)}),this.view),state:{init(){},apply(n,a,r,s){if(n.getMeta("orderedListIndexing")!==void 0||n.selection.$from.parent.type.spec.code)return a;const l=n.getMeta(ae);if(typeof l=="object"&&l!==null&&a===void 0)return{triggerCharacter:l.triggerCharacter,deleteTriggerCharacter:l.deleteTriggerCharacter!==!1,queryStartPos:s.selection.from,query:"",decorationId:`id_${Math.floor(Math.random()*4294967295)}`,ignoreQueryLength:l==null?void 0:l.ignoreQueryLength};if(a===void 0)return a;if(s.selection.from!==s.selection.to||l===null||n.getMeta("focus")||n.getMeta("blur")||n.getMeta("pointer")||a.triggerCharacter!==void 0&&s.selection.from<a.queryStartPos)return;const c={...a};return c.query=s.doc.textBetween(a.queryStartPos,s.selection.from),c}},props:{handleTextInput(n,a,r,s){const l=this.getState(n.state);return i.includes(s)&&l===void 0?(n.dispatch(n.state.tr.insertText(s).scrollIntoView().setMeta(ae,{triggerCharacter:s})),!0):!1},decorations(n){const a=this.getState(n);if(a===void 0)return null;if(!a.deleteTriggerCharacter){const r=Ra(n.selection);if(r)return P.DecorationSet.create(n.doc,[P.Decoration.node(r.pos,r.pos+r.node.nodeSize,{nodeName:"span",class:"bn-suggestion-decorator","data-decoration-id":a.decorationId})])}return P.DecorationSet.create(n.doc,[P.Decoration.inline(a.queryStartPos-a.triggerCharacter.length,a.queryStartPos,{nodeName:"span",class:"bn-suggestion-decorator","data-decoration-id":a.decorationId})])}}})}onUpdate(o,i){return this.triggerCharacters.includes(o)||this.addTriggerCharacter(o),this.on(`update ${o}`,i)}get shown(){var o,i;return((i=(o=this.view)==null?void 0:o.state)==null?void 0:i.show)||!1}}function za(e,t){e.suggestionMenus.addTriggerCharacter(t)}let D;function pi(e){D||(D=document.createElement("div"),D.innerHTML="_",D.style.opacity="0",D.style.height="1px",D.style.width="1px",e instanceof Document?e.body.appendChild(D):e.appendChild(D))}function Fa(e){D&&(e instanceof Document?e.body.removeChild(D):e.removeChild(D),D=void 0)}function Be(e){return Array.prototype.indexOf.call(e.parentElement.childNodes,e)}function Ga(e){let t=e;for(;t&&t.nodeName!=="TD"&&t.nodeName!=="TH"&&!t.classList.contains("tableWrapper");){if(t.classList.contains("ProseMirror"))return;const o=t.parentNode;if(!o||!(o instanceof Element))return;t=o}return t.nodeName==="TD"||t.nodeName==="TH"?{type:"cell",domNode:t,tbodyNode:t.closest("tbody")}:{type:"wrapper",domNode:t,tbodyNode:t.querySelector("tbody")}}function $a(e,t){const o=t.querySelectorAll(e);for(let i=0;i<o.length;i++)o[i].style.visibility="hidden"}class hi{constructor(t,o,i){h(this,"state");h(this,"emitUpdate");h(this,"tableId");h(this,"tablePos");h(this,"tableElement");h(this,"menuFrozen",!1);h(this,"mouseState","up");h(this,"prevWasEditable",null);h(this,"viewMousedownHandler",()=>{this.mouseState="down"});h(this,"mouseUpHandler",t=>{this.mouseState="up",this.mouseMoveHandler(t)});h(this,"mouseMoveHandler",t=>{var c,u,p,m;if(this.menuFrozen||this.mouseState==="selecting"||!(t.target instanceof Element)||!this.pmView.dom.contains(t.target))return;const o=Ga(t.target);if((o==null?void 0:o.type)==="cell"&&this.mouseState==="down"&&!((c=this.state)!=null&&c.draggingState)){this.mouseState="selecting",(u=this.state)!=null&&u.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate());return}if(!o||!this.editor.isEditable){(p=this.state)!=null&&p.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate());return}if(!o.tbodyNode)return;const i=o.tbodyNode.getBoundingClientRect(),n=ai(o.domNode,this.pmView);if(!n)return;this.tableElement=n.node;let a;const r=A(n.id,this.editor._tiptapEditor.state.doc);if(!r)throw new Error(`Block with ID ${n.id} not found`);const s=S(r.node,this.editor.schema.blockSchema,this.editor.schema.inlineContentSchema,this.editor.schema.styleSchema,this.editor.blockCache);if(To("table",s,this.editor)&&(this.tablePos=r.posBeforeNode+1,a=s),!a)return;this.tableId=n.id;const l=(m=o.domNode.closest(".tableWrapper"))==null?void 0:m.querySelector(".table-widgets-container");if((o==null?void 0:o.type)==="wrapper"){const f=t.clientY>=i.bottom-1&&t.clientY<i.bottom+20,g=t.clientX>=i.right-1&&t.clientX<i.right+20,b=t.clientX>i.right||t.clientY>i.bottom;this.state={...this.state,show:!0,showAddOrRemoveRowsButton:f,showAddOrRemoveColumnsButton:g,referencePosTable:i,block:a,widgetContainer:l,colIndex:b?void 0:this.state.colIndex,rowIndex:b?void 0:this.state.rowIndex,referencePosCell:b?void 0:this.state.referencePosCell}}else{const f=Be(o.domNode),g=Be(o.domNode.parentElement),b=o.domNode.getBoundingClientRect();if(this.state!==void 0&&this.state.show&&this.tableId===n.id&&this.state.rowIndex===g&&this.state.colIndex===f)return;this.state={show:!0,showAddOrRemoveColumnsButton:f===a.content.rows[0].cells.length-1,showAddOrRemoveRowsButton:g===a.content.rows.length-1,referencePosTable:i,block:a,draggingState:void 0,referencePosCell:b,colIndex:f,rowIndex:g,widgetContainer:l}}return this.emitUpdate(),!1});h(this,"dragOverHandler",t=>{var m;if(((m=this.state)==null?void 0:m.draggingState)===void 0)return;t.preventDefault(),t.dataTransfer.dropEffect="move",$a(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline",this.pmView.root);const o={left:Math.min(Math.max(t.clientX,this.state.referencePosTable.left+1),this.state.referencePosTable.right-1),top:Math.min(Math.max(t.clientY,this.state.referencePosTable.top+1),this.state.referencePosTable.bottom-1)},i=this.pmView.root.elementsFromPoint(o.left,o.top).filter(f=>f.tagName==="TD"||f.tagName==="TH");if(i.length===0)throw new Error("Could not find table cell element that the mouse cursor is hovering over.");const n=i[0];let a=!1;const r=Be(n.parentElement),s=Be(n),l=this.state.draggingState.draggedCellOrientation==="row"?this.state.rowIndex:this.state.colIndex,u=(this.state.draggingState.draggedCellOrientation==="row"?r:s)!==l;(this.state.rowIndex!==r||this.state.colIndex!==s)&&(this.state.rowIndex=r,this.state.colIndex=s,this.state.referencePosCell=n.getBoundingClientRect(),a=!0);const p=this.state.draggingState.draggedCellOrientation==="row"?o.top:o.left;this.state.draggingState.mousePos!==p&&(this.state.draggingState.mousePos=p,a=!0),a&&this.emitUpdate(),u&&this.editor.dispatch(this.pmView.state.tr.setMeta(re,!0))});h(this,"dropHandler",t=>{if(this.mouseState="up",this.state===void 0||this.state.draggingState===void 0)return;if(this.state.rowIndex===void 0||this.state.colIndex===void 0)throw new Error("Attempted to drop table row or column, but no table block was hovered prior.");t.preventDefault();const{draggingState:o,colIndex:i,rowIndex:n}=this.state,a=this.state.block.content.rows;if(o.draggedCellOrientation==="row"){const r=a[o.originalIndex];a.splice(o.originalIndex,1),a.splice(n,0,r)}else{const r=a.map(s=>s.cells[o.originalIndex]);a.forEach((s,l)=>{s.cells.splice(o.originalIndex,1),s.cells.splice(i,0,r[l])})}this.editor.updateBlock(this.state.block,{type:"table",content:{type:"tableContent",rows:a}}),this.editor.setTextCursorPosition(this.state.block.id)});this.editor=t,this.pmView=o,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized image toolbar");i(this.state)},o.dom.addEventListener("mousemove",this.mouseMoveHandler),o.dom.addEventListener("mousedown",this.viewMousedownHandler),window.addEventListener("mouseup",this.mouseUpHandler),o.root.addEventListener("dragover",this.dragOverHandler),o.root.addEventListener("drop",this.dropHandler)}update(){if(!this.state||!this.state.show)return;if(this.state.block=this.editor.getBlock(this.state.block.id),!this.state.block){this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate();return}const t=this.state.block.content.rows.length,o=this.state.block.content.rows[0].cells.length;this.state.rowIndex!==void 0&&this.state.colIndex!==void 0&&(this.state.rowIndex>=t&&(this.state.rowIndex=t-1),this.state.colIndex>=o&&(this.state.colIndex=o-1));const i=this.tableElement.querySelector("tbody");if(!i)throw new Error("Table block does not contain a 'tbody' HTML element. This should never happen.");if(this.state.rowIndex!==void 0&&this.state.colIndex!==void 0){const a=i.children[this.state.rowIndex].children[this.state.colIndex];this.state.referencePosCell=a.getBoundingClientRect()}this.state.referencePosTable=i.getBoundingClientRect(),this.emitUpdate()}destroy(){this.pmView.dom.removeEventListener("mousemove",this.mouseMoveHandler),window.removeEventListener("mouseup",this.mouseUpHandler),this.pmView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.pmView.root.removeEventListener("dragover",this.dragOverHandler),this.pmView.root.removeEventListener("drop",this.dropHandler)}}const re=new _.PluginKey("TableHandlesPlugin");class mi extends ie{constructor(o){super();h(this,"view");h(this,"plugin");h(this,"colDragStart",o=>{if(this.view.state===void 0||this.view.state.colIndex===void 0)throw new Error("Attempted to drag table column, but no table block was hovered prior.");if(this.view.state.draggingState={draggedCellOrientation:"col",originalIndex:this.view.state.colIndex,mousePos:o.clientX},this.view.emitUpdate(),this.editor.dispatch(this.editor._tiptapEditor.state.tr.setMeta(re,{draggedCellOrientation:this.view.state.draggingState.draggedCellOrientation,originalIndex:this.view.state.colIndex,newIndex:this.view.state.colIndex,tablePos:this.view.tablePos})),!this.editor.prosemirrorView)throw new Error("Editor view not initialized.");pi(this.editor.prosemirrorView.root),o.dataTransfer.setDragImage(D,0,0),o.dataTransfer.effectAllowed="move"});h(this,"rowDragStart",o=>{if(this.view.state===void 0||this.view.state.rowIndex===void 0)throw new Error("Attempted to drag table row, but no table block was hovered prior.");if(this.view.state.draggingState={draggedCellOrientation:"row",originalIndex:this.view.state.rowIndex,mousePos:o.clientY},this.view.emitUpdate(),this.editor.dispatch(this.editor._tiptapEditor.state.tr.setMeta(re,{draggedCellOrientation:this.view.state.draggingState.draggedCellOrientation,originalIndex:this.view.state.rowIndex,newIndex:this.view.state.rowIndex,tablePos:this.view.tablePos})),!this.editor.prosemirrorView)throw new Error("Editor view not initialized.");pi(this.editor.prosemirrorView.root),o.dataTransfer.setDragImage(D,0,0),o.dataTransfer.effectAllowed="copyMove"});h(this,"dragEnd",()=>{if(this.view.state===void 0)throw new Error("Attempted to drag table row, but no table block was hovered prior.");if(this.view.state.draggingState=void 0,this.view.emitUpdate(),this.editor.dispatch(this.editor._tiptapEditor.state.tr.setMeta(re,null)),!this.editor.prosemirrorView)throw new Error("Editor view not initialized.");Fa(this.editor.prosemirrorView.root)});h(this,"freezeHandles",()=>{this.view.menuFrozen=!0});h(this,"unfreezeHandles",()=>{this.view.menuFrozen=!1});this.editor=o,this.plugin=new _.Plugin({key:re,view:i=>(this.view=new hi(o,i,n=>{this.emit("update",n)}),this.view),props:{decorations:i=>{if(this.view===void 0||this.view.state===void 0||this.view.state.draggingState===void 0||this.view.tablePos===void 0)return;const n=this.view.state.draggingState.draggedCellOrientation==="row"?this.view.state.rowIndex:this.view.state.colIndex;if(n===void 0)return;const a=[];if(n===this.view.state.draggingState.originalIndex)return P.DecorationSet.create(i.doc,a);const r=i.doc.resolve(this.view.tablePos+1),s=r.node();if(this.view.state.draggingState.draggedCellOrientation==="row"){const l=i.doc.resolve(r.posAtIndex(n)+1),c=l.node();for(let u=0;u<c.childCount;u++){const p=i.doc.resolve(l.posAtIndex(u)+1),m=p.node(),f=p.pos+(n>this.view.state.draggingState.originalIndex?m.nodeSize-2:0);a.push(P.Decoration.widget(f,()=>{const g=document.createElement("div");return g.className="bn-table-drop-cursor",g.style.left="0",g.style.right="0",n>this.view.state.draggingState.originalIndex?g.style.bottom="-2px":g.style.top="-3px",g.style.height="4px",g}))}}else for(let l=0;l<s.childCount;l++){const c=i.doc.resolve(r.posAtIndex(l)+1),u=i.doc.resolve(c.posAtIndex(n)+1),p=u.node(),m=u.pos+(n>this.view.state.draggingState.originalIndex?p.nodeSize-2:0);a.push(P.Decoration.widget(m,()=>{const f=document.createElement("div");return f.className="bn-table-drop-cursor",f.style.top="0",f.style.bottom="0",n>this.view.state.draggingState.originalIndex?f.style.right="-2px":f.style.left="-3px",f.style.width="4px",f}))}return P.DecorationSet.create(i.doc,a)}}})}onUpdate(o){return this.on("update",o)}}const Ka=k.Extension.create({name:"textAlignment",addGlobalAttributes(){return[{types:["paragraph","heading","bulletListItem","numberedListItem","checkListItem"],attributes:{textAlignment:{default:"left",parseHTML:e=>e.getAttribute("data-text-alignment"),renderHTML:e=>e.textAlignment==="left"?{}:{"data-text-alignment":e.textAlignment}}}}]}}),Wa=k.Extension.create({name:"blockTextColor",addGlobalAttributes(){return[{types:["blockContainer"],attributes:{textColor:{default:B.textColor.default,parseHTML:e=>e.hasAttribute("data-text-color")?e.getAttribute("data-text-color"):B.textColor.default,renderHTML:e=>e.textColor===B.textColor.default?{}:{"data-text-color":e.textColor}}}}]}}),qa=k.Extension.create({name:"trailingNode",addProseMirrorPlugins(){const e=new _.PluginKey(this.name);return[new _.Plugin({key:e,appendTransaction:(t,o,i)=>{const{doc:n,tr:a,schema:r}=i,s=e.getState(i),l=n.content.size-2,c=r.nodes.blockContainer,u=r.nodes.paragraph;if(s)return a.insert(l,c.create(void 0,u.create()))},state:{init:(t,o)=>{},apply:(t,o)=>{if(!t.docChanged)return o;let i=t.doc.lastChild;if(!i||i.type.name!=="blockGroup")throw new Error("Expected blockGroup");if(i=i.lastChild,!i||i.type.name!=="blockContainer")return!0;const n=i.firstChild;if(!n)throw new Error("Expected blockContent");return i.nodeSize>4||n.type.spec.content!=="inline*"}}})]}}),Xa={blockColor:"data-block-color",blockStyle:"data-block-style",id:"data-id",depth:"data-depth",depthChange:"data-depth-change"},Za=k.Node.create({name:"blockContainer",group:"blockGroupChild bnBlock",content:"blockContent blockGroup?",priority:50,defining:!0,parseHTML(){return[{tag:"div",getAttrs:e=>{if(typeof e=="string")return!1;const t={};for(const[o,i]of Object.entries(Xa))e.getAttribute(i)&&(t[o]=e.getAttribute(i));return e.getAttribute("data-node-type")==="blockContainer"?t:!1}}]},renderHTML({HTMLAttributes:e}){var n;const t=document.createElement("div");t.className="bn-block-outer",t.setAttribute("data-node-type","blockOuter");for(const[a,r]of Object.entries(e))a!=="class"&&t.setAttribute(a,r);const o={...((n=this.options.domAttributes)==null?void 0:n.block)||{},...e},i=document.createElement("div");i.className=$("bn-block",o.class),i.setAttribute("data-node-type",this.name);for(const[a,r]of Object.entries(o))a!=="class"&&i.setAttribute(a,r);return t.appendChild(i),{dom:t,contentDOM:i}}}),Ja=k.Node.create({name:"blockGroup",group:"childContainer",content:"blockGroupChild+",parseHTML(){return[{tag:"div",getAttrs:e=>typeof e=="string"?!1:e.getAttribute("data-node-type")==="blockGroup"?null:!1}]},renderHTML({HTMLAttributes:e}){var i;const t={...((i=this.options.domAttributes)==null?void 0:i.blockGroup)||{},...e},o=document.createElement("div");o.className=$("bn-block-group",t.class),o.setAttribute("data-node-type","blockGroup");for(const[n,a]of Object.entries(t))n!=="class"&&o.setAttribute(n,a);return{dom:o,contentDOM:o}}}),Ya=k.Node.create({name:"doc",topNode:!0,content:"blockGroup"}),Qa=e=>{var i;const t=[];t.push(Gi.default.configure({fragment:e.fragment}));const o=(i=e.provider)==null?void 0:i.awareness;if(o){const n=new Map;e.showCursorLabels!=="always"&&o.on("change",({updated:s})=>{for(const l of s){const c=n.get(l);c&&(c.element.setAttribute("data-active",""),c.hideTimeout&&clearTimeout(c.hideTimeout),n.set(l,{element:c.element,hideTimeout:setTimeout(()=>{c.element.removeAttribute("data-active")},2e3)}))}});const a=s=>{const l=document.createElement("span");l.classList.add("collaboration-cursor__caret"),l.setAttribute("style",`outline-color: ${s.color}`),(e==null?void 0:e.showCursorLabels)==="always"&&l.setAttribute("data-active","");const c=document.createElement("span");return c.classList.add("collaboration-cursor__label"),c.setAttribute("style",`background-color: ${s.color}`),c.insertBefore(document.createTextNode(s.name),null),l.insertBefore(document.createTextNode(""),null),l.insertBefore(c,null),l.insertBefore(document.createTextNode(""),null),l},r=s=>{var p;const l=[...o.getStates().entries()].find(m=>m[1].user===s);if(!l)throw new Error("Could not find client state for user");const c=l[0];let u=n.get(c);if(!u){const m=((p=e==null?void 0:e.renderCursor)==null?void 0:p.call(e,s))||a(s);(e==null?void 0:e.showCursorLabels)!=="always"&&(m.addEventListener("mouseenter",()=>{const f=n.get(c);f.element.setAttribute("data-active",""),f.hideTimeout&&(clearTimeout(f.hideTimeout),n.set(c,{element:f.element,hideTimeout:void 0}))}),m.addEventListener("mouseleave",()=>{const f=n.get(c);n.set(c,{element:f.element,hideTimeout:setTimeout(()=>{f.element.removeAttribute("data-active")},2e3)})})),u={element:m,hideTimeout:void 0},n.set(c,u)}return u.element};t.push($i.default.configure({user:e.user,render:r,provider:e.provider}))}return t},fi=e=>{const t={},o=er(e);for(const n of o)t[n.name]=n;t.formattingToolbar=new Zo(e.editor),t.linkToolbar=new ti(e.editor),t.sideMenu=new ci(e.editor,e.sideMenuDetection),t.suggestionMenus=new ui(e.editor),t.filePanel=new Wo(e.editor),t.placeholder=new Na(e.editor,e.placeholders),(e.animations??!0)&&(t.animations=new ja),e.tableHandles&&(t.tableHandles=new mi(e.editor)),t.dropCursor={plugin:e.dropCursor({width:5,color:"#ddeeff",editor:e.editor})},t.nodeSelectionKeyboard=new Pa;const i=e.disableExtensions||[];for(const n of i)delete t[n];return t},er=e=>{const t=[k.extensions.ClipboardTextSerializer,k.extensions.Commands,k.extensions.Editable,k.extensions.FocusEvents,k.extensions.Tabindex,Mi.Gapcursor,J.configure({types:["blockContainer","columnList","column"],setIdAttribute:e.setIdAttribute}),Li.HardBreak.extend({priority:10}),Ni.Text,Ai.Link.extend({inclusive:!1}).configure({defaultProtocol:ii,protocols:oi}),...Object.values(e.styleSpecs).map(o=>o.implementation.mark),Wa,Ba,Ka,k.Extension.create({name:"OverrideEscape",addKeyboardShortcuts(){return{Escape:()=>e.editor.suggestionMenus.shown?!1:this.editor.commands.blur()}}}),Ya,Za.configure({editor:e.editor,domAttributes:e.domAttributes}),Ia.configure({editor:e.editor,tabBehavior:e.tabBehavior}),Ja.configure({domAttributes:e.domAttributes}),...Object.values(e.inlineContentSpecs).filter(o=>o.config!=="link"&&o.config!=="text").map(o=>o.implementation.node.configure({editor:e.editor})),...Object.values(e.blockSpecs).flatMap(o=>[...(o.implementation.requiredExtensions||[]).map(i=>i.configure({editor:e.editor,domAttributes:e.domAttributes})),o.implementation.node.configure({editor:e.editor,domAttributes:e.domAttributes})]),Sa(e.editor),Ca(e.editor),va(e.editor),...e.trailingBlock===void 0||e.trailingBlock?[qa]:[]];return e.collaboration?t.push(...Qa(e.collaboration)):t.push(Pi.History),t};function tr(e,t){const o=[];return e.forEach((i,n,a)=>{a!==t&&o.push(i)}),w.Fragment.from(o)}function or(e,t){const o=[];for(let i=0;i<e.childCount;i++)if(e.child(i).type.name==="tableRow")if(o.length>0&&o[o.length-1].type.name==="table"){const n=o[o.length-1],a=n.copy(n.content.addToEnd(e.child(i)));o[o.length-1]=a}else{const n=t.nodes.table.createChecked(void 0,e.child(i));o.push(n)}else o.push(e.child(i));return e=w.Fragment.from(o),e}function ir(e,t){let o=w.Fragment.from(e.content);if(o=or(o,t.state.schema),!nr(o,t))return new w.Slice(o,e.openStart,e.openEnd);for(let i=0;i<o.childCount;i++)if(o.child(i).type.spec.group==="blockContent"){const n=[o.child(i)];if(i+1<o.childCount&&o.child(i+1).type.name==="blockGroup"){const r=o.child(i+1).child(0).child(0);(r.type.name==="bulletListItem"||r.type.name==="numberedListItem"||r.type.name==="checkListItem")&&(n.push(o.child(i+1)),o=tr(o,i+1))}const a=t.state.schema.nodes.blockContainer.createChecked(void 0,n);o=o.replaceChild(i,a)}return new w.Slice(o,e.openStart,e.openEnd)}function nr(e,t){var a,r;const o=e.childCount===1,i=((a=e.firstChild)==null?void 0:a.type.spec.content)==="inline*",n=((r=e.firstChild)==null?void 0:r.type.spec.content)==="tableRow+";if(o){if(i)return!1;if(n){const s=C(t.state);if(s.isBlockContainer)return!(s.blockContent.node.type.spec.content==="tableRow+")}}return!0}const Ie=class Ie extends k.Editor{constructor(o,i){super({...o,content:void 0});h(this,"_state");h(this,"_creating",!1);h(this,"mount",o=>{o?(this.options.element=o,this.createViewAlternative()):(this.destroy(),this._creating=!1)});const n=this.schema;let a;const r=n.nodes.doc.createAndFill;n.nodes.doc.createAndFill=(...l)=>{if(a)return a;const c=r.apply(n.nodes.doc,l),u=JSON.parse(JSON.stringify(c.toJSON()));return u.content[0].content[0].attrs.id="initialBlockId",a=w.Node.fromJSON(n,u),a};let s;try{const l=o==null?void 0:o.content.map(c=>q(c,this.schema,i).toJSON());s=k.createDocument({type:"doc",content:[{type:"blockGroup",content:l}]},this.schema,this.options.parseOptions)}catch(l){throw console.error("Error creating document from blocks passed as `initialContent`. Caused by exception: ",l),new Error("Error creating document from blocks passed as `initialContent`:\n"+ +JSON.stringify(o.content))}this._state=_.EditorState.create({doc:s,schema:this.schema})}get state(){return this.view&&(this._state=this.view.state),this._state}dispatch(o){this.view?this.view.dispatch(o):this._state=this.state.apply(o)}createViewAlternative(){this._creating=!0,queueMicrotask(()=>{if(!this._creating)return;this.view=new P.EditorView({mount:this.options.element},{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:this.state});const o=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(o),this.createNodeViews(),this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0,this._creating=!1})}};h(Ie,"create",(o,i)=>{var a,r;const n=(a=globalThis==null?void 0:globalThis.window)==null?void 0:a.setTimeout;typeof((r=globalThis==null?void 0:globalThis.window)==null?void 0:r.setTimeout)<"u"&&(globalThis.window.setTimeout=()=>0);try{return new Ie(o,i)}finally{n&&(globalThis.window.setTimeout=n)}});let Ee=Ie;Ee.prototype.createView=function(){this.options.onPaste=this.options.onDrop=void 0};const ar={enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!1};class rt{constructor(t){h(this,"_pmSchema");h(this,"extensions",{});h(this,"headless",!1);h(this,"_tiptapEditor");h(this,"elementRenderer",null);h(this,"blockCache",new WeakMap);h(this,"dictionary");h(this,"schema");h(this,"blockImplementations");h(this,"inlineContentImplementations");h(this,"styleImplementations");h(this,"formattingToolbar");h(this,"linkToolbar");h(this,"sideMenu");h(this,"suggestionMenus");h(this,"filePanel");h(this,"tableHandles");h(this,"uploadFile");h(this,"onUploadStartCallbacks",[]);h(this,"onUploadEndCallbacks",[]);h(this,"resolveFileUrl");h(this,"mount",t=>{this._tiptapEditor.mount(t)});var s,l,c,u,p,m,f;this.options=t;const o=t;if(o.onEditorContentChange)throw new Error("onEditorContentChange initialization option is deprecated, use <BlockNoteView onChange={...} />, the useEditorChange(...) hook, or editor.onChange(...)");if(o.onTextCursorPositionChange)throw new Error("onTextCursorPositionChange initialization option is deprecated, use <BlockNoteView onSelectionChange={...} />, the useEditorSelectionChange(...) hook, or editor.onSelectionChange(...)");if(o.onEditorReady)throw new Error("onEditorReady is deprecated. Editor is immediately ready for use after creation.");if(o.editable)throw new Error("editable initialization option is deprecated, use <BlockNoteView editable={true/false} />, or alternatively editor.isEditable = true/false");this.dictionary=t.dictionary||ut;const i={defaultStyles:!0,schema:t.schema||oe.create(),_headless:!1,...t,placeholders:{...this.dictionary.placeholders,...t.placeholders}};if(this.schema=i.schema,this.blockImplementations=i.schema.blockSpecs,this.inlineContentImplementations=i.schema.inlineContentSpecs,this.styleImplementations=i.schema.styleSpecs,this.extensions=fi({editor:this,domAttributes:i.domAttributes||{},blockSpecs:this.schema.blockSpecs,styleSpecs:this.schema.styleSpecs,inlineContentSpecs:this.schema.inlineContentSpecs,collaboration:i.collaboration,trailingBlock:i.trailingBlock,disableExtensions:i.disableExtensions,setIdAttribute:i.setIdAttribute,animations:i.animations??!0,tableHandles:N("table",this),dropCursor:this.options.dropCursor??Hi.dropCursor,placeholders:i.placeholders,tabBehavior:i.tabBehavior,sideMenuDetection:i.sideMenuDetection||"viewport"}),(((s=i._tiptapOptions)==null?void 0:s.extensions)||[]).forEach(g=>{this.extensions[g.name]=g}),Object.entries(i._extensions||{}).forEach(([g,b])=>{typeof b=="function"&&(b=b(this)),this.extensions[g]=b}),this.formattingToolbar=this.extensions.formattingToolbar,this.linkToolbar=this.extensions.linkToolbar,this.sideMenu=this.extensions.sideMenu,this.suggestionMenus=this.extensions.suggestionMenus,this.filePanel=this.extensions.filePanel,this.tableHandles=this.extensions.tableHandles,i.uploadFile){const g=i.uploadFile;this.uploadFile=async(b,y)=>{this.onUploadStartCallbacks.forEach(v=>v.apply(this,[y]));try{return await g(b,y)}finally{this.onUploadEndCallbacks.forEach(v=>v.apply(this,[y]))}}}this.resolveFileUrl=i.resolveFileUrl,this.headless=i._headless,i.collaboration&&i.initialContent&&console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider");const n=i.initialContent||(t.collaboration?[{type:"paragraph",id:"initialBlockId"}]:[{type:"paragraph",id:J.options.generateID()}]);if(!Array.isArray(n)||n.length===0)throw new Error("initialContent must be a non-empty array of blocks, received: "+n);const a=[...Object.entries(this.extensions).map(([g,b])=>{if(b instanceof k.Extension||b instanceof k.Node||b instanceof k.Mark)return b;if(!b.plugin)throw new Error("Extension should either be a TipTap extension or a ProseMirror plugin in a plugin property");return k.Extension.create({name:g,addProseMirrorPlugins:()=>[b.plugin]})})],r={...ar,...i._tiptapOptions,content:n,extensions:a,editorProps:{...(l=i._tiptapOptions)==null?void 0:l.editorProps,attributes:{tabIndex:"0",...(u=(c=i._tiptapOptions)==null?void 0:c.editorProps)==null?void 0:u.attributes,...(p=i.domAttributes)==null?void 0:p.editor,class:$("bn-editor",i.defaultStyles?"bn-default-styles":"",((f=(m=i.domAttributes)==null?void 0:m.editor)==null?void 0:f.class)||"")},transformPasted:ir}};this.headless?this._pmSchema=k.getSchema(r.extensions):(this._tiptapEditor=Ee.create(r,this.schema.styleSchema),this._pmSchema=this._tiptapEditor.schema)}get pmSchema(){return this._pmSchema}static create(t={}){return new rt(t)}dispatch(t){this._tiptapEditor.dispatch(t)}get prosemirrorView(){return this._tiptapEditor.view}get domElement(){var t;return(t=this.prosemirrorView)==null?void 0:t.dom}isFocused(){var t;return((t=this.prosemirrorView)==null?void 0:t.hasFocus())||!1}focus(){var t;(t=this.prosemirrorView)==null||t.focus()}onUploadStart(t){return this.onUploadStartCallbacks.push(t),()=>{const o=this.onUploadStartCallbacks.indexOf(t);o>-1&&this.onUploadStartCallbacks.splice(o,1)}}onUploadEnd(t){return this.onUploadEndCallbacks.push(t),()=>{const o=this.onUploadEndCallbacks.indexOf(t);o>-1&&this.onUploadEndCallbacks.splice(o,1)}}get topLevelBlocks(){return this.document}get document(){const t=[];return this._tiptapEditor.state.doc.firstChild.descendants(o=>(t.push(S(o,this.schema.blockSchema,this.schema.inlineContentSchema,this.schema.styleSchema,this.blockCache)),!1)),t}getBlock(t){return ia(this,t)}getPrevBlock(t){return na(this,t)}getNextBlock(t){return aa(this,t)}getParentBlock(t){return ra(this,t)}forEachBlock(t,o=!1){const i=this.document.slice();o&&i.reverse();function n(a){for(const r of a){if(t(r)===!1)return!1;const s=o?r.children.slice().reverse():r.children;if(!n(s))return!1}return!0}n(i)}onEditorContentChange(t){this._tiptapEditor.on("update",t)}onEditorSelectionChange(t){this._tiptapEditor.on("selectionUpdate",t)}getTextCursorPosition(){return ca(this)}setTextCursorPosition(t,o="start"){Ho(this,t,o)}getSelection(){return la(this)}setSelection(t,o){da(this,t,o)}get isEditable(){if(!this._tiptapEditor){if(!this.headless)throw new Error("no editor, but also not headless?");return!1}return this._tiptapEditor.isEditable===void 0?!0:this._tiptapEditor.isEditable}set isEditable(t){if(!this._tiptapEditor){if(!this.headless)throw new Error("no editor, but also not headless?");return}this._tiptapEditor.options.editable!==t&&this._tiptapEditor.setEditable(t)}insertBlocks(t,o,i="before"){return Kn(this,t,o,i)}updateBlock(t,o){return io(this,t,o)}removeBlocks(t){return oa(this,t)}replaceBlocks(t,o){return ta(this,t,o)}insertInlineContent(t){const o=H(t,this.pmSchema,this.schema.styleSchema);sa({from:this._tiptapEditor.state.selection.from,to:this._tiptapEditor.state.selection.to},o,this)}getActiveStyles(){const t={},o=this._tiptapEditor.state.selection.$to.marks();for(const i of o){const n=this.schema.styleSchema[i.type.name];if(!n){i.type.name!=="link"&&console.warn("mark not found in styleschema",i.type.name);continue}n.propSchema==="boolean"?t[n.type]=!0:t[n.type]=i.attrs.stringValue}return t}addStyles(t){for(const[o,i]of Object.entries(t)){const n=this.schema.styleSchema[o];if(!n)throw new Error(`style ${o} not found in styleSchema`);if(n.propSchema==="boolean")this._tiptapEditor.commands.setMark(o);else if(n.propSchema==="string")this._tiptapEditor.commands.setMark(o,{stringValue:i});else throw new j(n.propSchema)}}removeStyles(t){for(const o of Object.keys(t))this._tiptapEditor.commands.unsetMark(o)}toggleStyles(t){for(const[o,i]of Object.entries(t)){const n=this.schema.styleSchema[o];if(!n)throw new Error(`style ${o} not found in styleSchema`);if(n.propSchema==="boolean")this._tiptapEditor.commands.toggleMark(o);else if(n.propSchema==="string")this._tiptapEditor.commands.toggleMark(o,{stringValue:i});else throw new j(n.propSchema)}}getSelectedText(){return this._tiptapEditor.state.doc.textBetween(this._tiptapEditor.state.selection.from,this._tiptapEditor.state.selection.to)}getSelectedLinkUrl(){return this._tiptapEditor.getAttributes("link").href}createLink(t,o){if(t==="")return;const{from:i,to:n}=this._tiptapEditor.state.selection;o||(o=this._tiptapEditor.state.doc.textBetween(i,n));const a=this.pmSchema.mark("link",{href:t});this.dispatch(this._tiptapEditor.state.tr.insertText(o,i,n).addMark(i,i+o.length,a))}canNestBlock(){return Qn(this)}nestBlock(){Do(this)}canUnnestBlock(){return ea(this)}unnestBlock(){Yn(this)}moveBlocksUp(){Xn(this)}moveBlocksDown(){Zn(this)}async blocksToHTMLLossy(t=this.document){return de(this.pmSchema,this).exportBlocks(t,{})}async blocksToFullHTML(t){return _t(this.pmSchema,this).serializeBlocks(t,{})}async tryParseHTMLToBlocks(t){return tt(t,this.schema.blockSchema,this.schema.inlineContentSchema,this.schema.styleSchema,this.pmSchema)}async blocksToMarkdownLossy(t=this.document){return Oo(t,this.pmSchema,this,{})}async tryParseMarkdownToBlocks(t){return Vo(t,this.schema.blockSchema,this.schema.inlineContentSchema,this.schema.styleSchema,this.pmSchema)}updateCollaborationUserInfo(t){if(!this.options.collaboration)throw new Error("Cannot update collaboration user info when collaboration is disabled.");this._tiptapEditor.commands.updateUser(t)}onChange(t){if(this.headless)return;const o=()=>{t(this)};return this._tiptapEditor.on("update",o),()=>{this._tiptapEditor.off("update",o)}}onSelectionChange(t){if(this.headless)return;const o=()=>{t(this)};return this._tiptapEditor.on("selectionUpdate",o),()=>{this._tiptapEditor.off("selectionUpdate",o)}}openSuggestionMenu(t,o){var a;const i=(a=this.prosemirrorView)==null?void 0:a.state.tr;if(!i)return;const n=o&&o.deleteTriggerCharacter?i.insertText(t):i;this.prosemirrorView.focus(),this.prosemirrorView.dispatch(n.scrollIntoView().setMeta(this.suggestionMenus.plugin,{triggerCharacter:t,deleteTriggerCharacter:(o==null?void 0:o.deleteTriggerCharacter)||!1,ignoreQueryLength:(o==null?void 0:o.ignoreQueryLength)||!1}))}}const rr={gray:{text:"#9b9a97",background:"#ebeced"},brown:{text:"#64473a",background:"#e9e5e3"},red:{text:"#e03e3e",background:"#fbe4e4"},orange:{text:"#d9730d",background:"#f6e9d9"},yellow:{text:"#dfab01",background:"#fbf3db"},green:{text:"#4d6461",background:"#ddedea"},blue:{text:"#0b6e99",background:"#ddebf1"},purple:{text:"#6940a5",background:"#eae4f2"},pink:{text:"#ad1a72",background:"#f4dfeb"}},sr={gray:{text:"#bebdb8",background:"#9b9a97"},brown:{text:"#8e6552",background:"#64473a"},red:{text:"#ec4040",background:"#be3434"},orange:{text:"#e3790d",background:"#b7600a"},yellow:{text:"#dfab01",background:"#b58b00"},green:{text:"#6b8b87",background:"#4d6461"},blue:{text:"#0e87bc",background:"#0b6e99"},purple:{text:"#8552d7",background:"#6940a5"},pink:{text:"#da208f",background:"#ad1a72"}};class lr{constructor(t,o,i){this.mappings=o,this.options=i}async resolveFile(t){var i;if(!((i=this.options)!=null&&i.resolveFileUrl))return(await fetch(t)).blob();const o=await this.options.resolveFileUrl(t);return o instanceof Blob?o:(await fetch(o)).blob()}mapStyles(t){return Object.entries(t).map(([i,n])=>this.mappings.styleMapping[i](n,this))}mapInlineContent(t){return this.mappings.inlineContentMapping[t.type](t,this)}transformInlineContent(t){return t.map(o=>this.mapInlineContent(o))}async mapBlock(t,o,i){return this.mappings.blockMapping[t.type](t,this,o,i)}}function dr(e){return{createBlockMapping:t=>t,createInlineContentMapping:t=>t,createStyleMapping:t=>t}}let Te,st;async function cr(e,t){if(!Eo("text",e))return[];if(!Te){Te=import("@emoji-mart/data"),st=await import("emoji-mart");const n=(await Te).default;await st.init({data:n})}const o=(await Te).default;return(t.trim()===""?Object.values(o.emojis):await st.SearchIndex.search(t)).map(n=>({id:n.skins[0].native,onItemClick:()=>e.insertInlineContent(n.skins[0].native+" ")}))}function ur(e,...t){const o=[...e];for(const i of t)for(const n of i){const a=o.findLastIndex(r=>r.group===n.group);a===-1?o.push(n):o.splice(a+1,0,n)}return o}function lt(e=""){return typeof e=="string"?[{type:"text",text:e,styles:{}}]:e}function ge(e){return typeof e=="string"?lt(e):Array.isArray(e)?e.flatMap(t=>typeof t=="string"?lt(t):Ae(t)?{...t,content:lt(t.content)}:Y(t)?t:{props:{},...t,content:ge(t.content)}):(e==null?void 0:e.type)==="tableContent"?{type:"tableContent",columnWidths:e.columnWidths,rows:e.rows.map(t=>({...t,cells:t.cells.map(o=>ge(o))}))}:e}function pr(e,t){return t.map(o=>dt(e.blockSchema,o))}function dt(e,t){var n;const o=e[t.type].content,i={id:"",type:t.type,props:{},content:o==="inline"?[]:o==="table"?{type:"tableContent",columnWidths:[],rows:[]}:void 0,children:[],...t};if(Object.entries(e[t.type].propSchema).forEach(([a,r])=>{i.props[a]===void 0&&r.default!==void 0&&(i.props[a]=r.default)}),o==="inline"){const a=i.content;i.content=ge(a)}else if(o==="table"){const a=i.content;i.content={type:"tableContent",columnWidths:(a==null?void 0:a.columnWidths)||((n=a==null?void 0:a.rows[0])==null?void 0:n.cells.map(()=>{}))||[],rows:(a==null?void 0:a.rows.map(r=>({cells:r.cells.map(s=>ge(s))})))||[]}}return{...i,content:ge(i.content),children:i.children.map(a=>dt(e,a))}}function gi(e){e.id||(e.id=J.options.generateID()),e.children&&bi(e.children)}function bi(e){for(const t of e)gi(t)}d.AudioBlock=Vt,d.BlockNoteEditor=rt,d.BlockNoteSchema=oe,d.COLORS_DARK_MODE_DEFAULT=sr,d.COLORS_DEFAULT=rr,d.CodeBlock=Gt,d.DEFAULT_LINK_PROTOCOL=ii,d.EMPTY_CELL_HEIGHT=In,d.EMPTY_CELL_WIDTH=qe,d.Exporter=lr,d.FILE_AUDIO_ICON_SVG=Dt,d.FILE_ICON_SVG=Pt,d.FILE_IMAGE_ICON_SVG=ro,d.FILE_VIDEO_ICON_SVG=ko,d.FileBlock=to,d.FilePanelProsemirrorPlugin=Wo,d.FilePanelView=Ko,d.FormattingToolbarProsemirrorPlugin=Zo,d.FormattingToolbarView=qo,d.HTMLToBlocks=tt,d.ImageBlock=ho,d.LinkToolbarProsemirrorPlugin=ti,d.PageBreak=Xt,d.SideMenuProsemirrorPlugin=ci,d.SideMenuView=li,d.SuggestionMenuProseMirrorPlugin=ui,d.TableHandlesProsemirrorPlugin=mi,d.TableHandlesView=hi,d.UniqueID=J,d.UnreachableCaseError=j,d.VALID_LINK_PROTOCOLS=oi,d.VideoBlock=xo,d.addIdsToBlock=gi,d.addIdsToBlocks=bi,d.addInlineContentAttributes=Re,d.addInlineContentKeyboardShortcuts=xt,d.addStyleAttributes=It,d.applyNonSelectableBlockFix=wt,d.assertEmpty=Xi,d.audioBlockConfig=Ht,d.audioParse=Ut,d.audioPropSchema=jt,d.audioRender=Ot,d.audioToExternalHTML=Rt,d.blockToNode=q,d.blocksToMarkdown=Oo,d.camelToDataKebab=ce,d.checkBlockHasDefaultProp=Un,d.checkBlockIsDefaultType=To,d.checkBlockIsFileBlock=jn,d.checkBlockIsFileBlockWithPlaceholder=On,d.checkBlockIsFileBlockWithPreview=Hn,d.checkBlockTypeHasDefaultProp=Io,d.checkDefaultBlockTypeInSchema=N,d.checkDefaultInlineContentTypeInSchema=Eo,d.checkPageBreakBlocksInSchema=Mo,d.cleanHTMLToMarkdown=Se,d.combineByGroup=ur,d.contentNodeToInlineContent=pe,d.contentNodeToTableContent=Ue,d.createAddFileButton=Lt,d.createBlockSpec=te,d.createBlockSpecFromStronglyTypedTiptapNode=W,d.createDefaultBlockDOMOutputSpec=R,d.createExternalHTMLExporter=de,d.createFigureWithCaption=ve,d.createFileBlockWrapper=ye,d.createFileNameWithIcon=At,d.createInlineContentSpec=rn,d.createInlineContentSpecFromTipTapNode=Bt,d.createInternalBlockSpec=He,d.createInternalHTMLSerializer=_t,d.createInternalInlineContentSpec=St,d.createInternalStyleSpec=ze,d.createLinkWithCaption=me,d.createResizableFileBlockWrapper=Ke,d.createStronglyTypedTiptapNode=K,d.createStyleSpec=sn,d.createStyleSpecFromTipTapMark=X,d.createSuggestionMenu=za,d.customizeCodeBlock=ln,d.defaultBlockSchema=So,d.defaultBlockSpecs=Xe,d.defaultBlockToHTML=De,d.defaultCodeBlockPropSchema=Ce,d.defaultInlineContentSchema=Bo,d.defaultInlineContentSpecs=Je,d.defaultProps=B,d.defaultStyleSchema=Dn,d.defaultStyleSpecs=Ze,d.fileBlockConfig=Jt,d.fileParse=Qt,d.filePropSchema=Zt,d.fileRender=Yt,d.fileToExternalHTML=eo,d.filenameFromURL=an,d.filterSuggestionItems=zn,d.formatKeyboardShortcut=G,d.formattingToolbarPluginKey=Xo,d.getBlockFromPos=vt,d.getBlockInfo=F,d.getBlockInfoFromResolvedPos=Q,d.getBlockInfoFromSelection=C,d.getBlockInfoWithManualOffset=ke,d.getBlockNoteExtensions=fi,d.getBlockSchemaFromSpecs=Oe,d.getDefaultEmojiPickerItems=cr,d.getDefaultSlashMenuItems=Vn,d.getInlineContentParseRules=Et,d.getInlineContentSchemaFromSpecs=Ve,d.getNearestBlockPos=z,d.getNodeById=A,d.getPageBreakSlashMenuItems=Gn,d.getParseRules=Ct,d.getStyleParseRules=Mt,d.getStyleSchemaFromSpecs=Fe,d.imageBlockConfig=lo,d.imageParse=uo,d.imagePropSchema=so,d.imageRender=co,d.imageToExternalHTML=po,d.inheritedProps=je,d.initializeESMDependencies=xe,d.inlineContentToNodes=H,d.insertOrUpdateBlock=L,d.isAppleOS=yt,d.isLinkInlineContent=Pe,d.isPartialLinkInlineContent=Ae,d.isSafari=nn,d.isStyledTextInlineContent=Y,d.linkToolbarPluginKey=ei,d.locales=qi,d.mappingFactory=dr,d.markdownToBlocks=Vo,d.mergeCSSClasses=$,d.nodeToBlock=S,d.nodeToCustomInlineContent=_e,d.pageBreakConfig=$t,d.pageBreakParse=Wt,d.pageBreakRender=Kt,d.pageBreakSchema=Qe,d.pageBreakToExternalHTML=qt,d.parseEmbedElement=$e,d.parseFigureElement=he,d.partialBlockToBlockForTesting=dt,d.partialBlocksToBlocksForTesting=pr,d.propsToAttributes=ee,d.shikiHighlighterPromiseSymbol=we,d.shikiParserSymbol=Ge,d.sideMenuPluginKey=di,d.stylePropsToAttributes=Tt,d.tableContentToNodes=le,d.tableHandlesPluginKey=re,d.updateBlock=io,d.updateBlockCommand=T,d.uploadToTmpFilesDotOrg_DEV_ONLY=$n,d.videoBlockConfig=yo,d.videoParse=wo,d.videoPropSchema=_o,d.videoRender=vo,d.videoToExternalHTML=Co,d.withPageBreak=Fn,d.wrapInBlockStructure=ue,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
|
10
|
+
`)}</code></pre>`),!0):!1}const Ca=e=>k.Extension.create({name:"pasteFromClipboard",addProseMirrorPlugins(){return[new _.Plugin({props:{handleDOMEvents:{paste(t,o){if(o.preventDefault(),!e.isEditable)return;let i;for(const a of ot)if(o.clipboardData.types.includes(a)){i=a;break}if(!i)return!0;if(i==="vscode-editor-data")return wa(o,t),!0;if(i==="Files")return zo(o,e),!0;let n=o.clipboardData.getData(i);return i==="blocknote/html"?(t.pasteHTML(n),!0):i==="text/html"?(n=Ro(n.trim()).innerHTML,t.pasteHTML(n),!0):(t.pasteText(n),!0)}}}})]}});function Fo(e,t){const o=[];return e.descendants(i=>{var n,a;return i.type.name==="blockContainer"&&((n=i.firstChild)==null?void 0:n.type.name)==="blockGroup"?!0:i.type.name==="columnList"&&i.childCount===1?((a=i.firstChild)==null||a.forEach(r=>{o.push(S(r,t.blockSchema,t.inlineContentSchema,t.styleSchema))}),!1):i.type.isInGroup("bnBlock")?(o.push(S(i,t.blockSchema,t.inlineContentSchema,t.styleSchema)),!1):!0}),o}function xa(e,t,o){var s;let i=!1;const n=e.state.selection instanceof U.CellSelection;if(!n){const l=e.state.doc.slice(e.state.selection.from,e.state.selection.to,!1).content,c=[];for(let u=0;u<l.childCount;u++)c.push(l.child(u));i=c.find(u=>u.type.isInGroup("bnBlock")||u.type.name==="blockGroup"||u.type.spec.group==="blockContent")===void 0,i&&(t=l)}let a;const r=de(e.state.schema,o);if(n){((s=t.firstChild)==null?void 0:s.type.name)==="table"&&(t=t.firstChild.content);const l=Ue(t,o.schema.inlineContentSchema,o.schema.styleSchema);a=`<table>${r.exportInlineContent(l,{})}</table>`}else if(i){const l=pe(t,o.schema.inlineContentSchema,o.schema.styleSchema);a=r.exportInlineContent(l,{})}else{const l=Fo(t,o.schema);a=r.exportBlocks(l,{})}return a}function Go(e,t){"node"in e.state.selection&&e.state.selection.node.type.spec.group==="blockContent"&&t.dispatch(t._tiptapEditor.state.tr.setSelection(new _.NodeSelection(e.state.doc.resolve(e.state.selection.from-1))));const o=ct.__serializeForClipboard(e,e.state.selection.content()).dom.innerHTML,i=e.state.selection.content().content,n=xa(e,i,t),a=Se(n);return{clipboardHTML:o,externalHTML:n,markdown:a}}const $o=(e,t,o)=>{o.preventDefault(),o.clipboardData.clearData();const{clipboardHTML:i,externalHTML:n,markdown:a}=Go(t,e);o.clipboardData.setData("blocknote/html",i),o.clipboardData.setData("text/html",n),o.clipboardData.setData("text/plain",a)},Sa=e=>k.Extension.create({name:"copyToClipboard",addProseMirrorPlugins(){return[new _.Plugin({props:{handleDOMEvents:{copy(t,o){return $o(e,t,o),!0},cut(t,o){return $o(e,t,o),t.editable&&t.dispatch(t.state.tr.deleteSelection()),!0},dragstart(t,o){if(!("node"in t.state.selection)||t.state.selection.node.type.spec.group!=="blockContent")return;e.dispatch(e._tiptapEditor.state.tr.setSelection(new _.NodeSelection(t.state.doc.resolve(t.state.selection.from-1)))),o.preventDefault(),o.dataTransfer.clearData();const{clipboardHTML:i,externalHTML:n,markdown:a}=Go(t,e);return o.dataTransfer.setData("blocknote/html",i),o.dataTransfer.setData("text/html",n),o.dataTransfer.setData("text/plain",a),!0}}}})]}}),Ba=k.Extension.create({name:"blockBackgroundColor",addGlobalAttributes(){return[{types:["blockContainer"],attributes:{backgroundColor:{default:B.backgroundColor.default,parseHTML:e=>e.hasAttribute("data-background-color")?e.getAttribute("data-background-color"):B.backgroundColor.default,renderHTML:e=>e.backgroundColor===B.backgroundColor.default?{}:{"data-background-color":e.backgroundColor}}}}]}});class ie{constructor(){h(this,"callbacks",{})}on(t,o){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(o),()=>this.off(t,o)}emit(t,...o){const i=this.callbacks[t];i&&i.forEach(n=>n.apply(this,o))}off(t,o){const i=this.callbacks[t];i&&(o?this.callbacks[t]=i.filter(n=>n!==o):delete this.callbacks[t])}removeAllListeners(){this.callbacks={}}}class Ko{constructor(t,o,i,n){h(this,"state");h(this,"emitUpdate");h(this,"mouseDownHandler",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())});h(this,"dragstartHandler",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())});h(this,"scrollHandler",()=>{var t;if((t=this.state)!=null&&t.show){const o=this.pmView.root.querySelector(`[data-node-type="blockContainer"][data-id="${this.state.block.id}"]`);if(!o)return;this.state.referencePos=o.getBoundingClientRect(),this.emitUpdate()}});h(this,"closeMenu",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())});this.editor=t,this.pluginKey=o,this.pmView=i,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized file panel");n(this.state)},i.dom.addEventListener("mousedown",this.mouseDownHandler),i.dom.addEventListener("dragstart",this.dragstartHandler),i.root.addEventListener("scroll",this.scrollHandler,!0)}update(t,o){var n,a;const i=this.pluginKey.getState(t.state);if(!((n=this.state)!=null&&n.show)&&i.block&&this.editor.isEditable){const r=this.pmView.root.querySelector(`[data-node-type="blockContainer"][data-id="${i.block.id}"]`);if(!r)return;this.state={show:!0,referencePos:r.getBoundingClientRect(),block:i.block},this.emitUpdate();return}(!t.state.selection.eq(o.selection)||!t.state.doc.eq(o.doc)||!this.editor.isEditable)&&(a=this.state)!=null&&a.show&&(this.state.show=!1,this.emitUpdate())}destroy(){this.pmView.dom.removeEventListener("mousedown",this.mouseDownHandler),this.pmView.dom.removeEventListener("dragstart",this.dragstartHandler),this.pmView.root.removeEventListener("scroll",this.scrollHandler,!0)}}const it=new _.PluginKey("FilePanelPlugin");class Wo extends ie{constructor(o){super();h(this,"view");h(this,"plugin");h(this,"closeMenu",()=>{var o;return(o=this.view)==null?void 0:o.closeMenu()});this.plugin=new _.Plugin({key:it,view:i=>(this.view=new Ko(o,it,i,n=>{this.emit("update",n)}),this.view),props:{handleKeyDown:(i,n)=>{var a;return n.key==="Escape"&&this.shown?((a=this.view)==null||a.closeMenu(),!0):!1}},state:{init:()=>({block:void 0}),apply:i=>{var a;return{block:(a=i.getMeta(it))==null?void 0:a.block}}}})}get shown(){var o,i;return((i=(o=this.view)==null?void 0:o.state)==null?void 0:i.show)||!1}onUpdate(o){return this.on("update",o)}}class qo{constructor(t,o,i){h(this,"state");h(this,"emitUpdate");h(this,"preventHide",!1);h(this,"preventShow",!1);h(this,"shouldShow",({state:t,from:o,to:i,view:n})=>{const{doc:a,selection:r}=t,{empty:s}=r,l=!a.textBetween(o,i).length&&k.isTextSelection(t.selection);return r.$from.parent.type.spec.code||k.isNodeSelection(r)&&r.node.type.spec.code?!1:!(!n.hasFocus()||s||l)});h(this,"blurHandler",t=>{var i;if(this.preventHide){this.preventHide=!1;return}const o=this.pmView.dom.parentElement;t&&t.relatedTarget&&(o===t.relatedTarget||o.contains(t.relatedTarget)||t.relatedTarget.matches(".bn-ui-container, .bn-ui-container *"))||(i=this.state)!=null&&i.show&&(this.state.show=!1,this.emitUpdate())});h(this,"viewMousedownHandler",()=>{this.preventShow=!0});h(this,"viewMouseupHandler",()=>{this.preventShow=!1,setTimeout(()=>this.update(this.pmView))});h(this,"dragHandler",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())});h(this,"scrollHandler",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.referencePos=this.getSelectionBoundingBox(),this.emitUpdate())});h(this,"closeMenu",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())});this.editor=t,this.pmView=o,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized formatting toolbar");i(this.state)},o.dom.addEventListener("mousedown",this.viewMousedownHandler),o.dom.addEventListener("mouseup",this.viewMouseupHandler),o.dom.addEventListener("dragstart",this.dragHandler),o.dom.addEventListener("dragover",this.dragHandler),o.dom.addEventListener("blur",this.blurHandler),o.root.addEventListener("scroll",this.scrollHandler,!0)}update(t,o){var p,m;const{state:i,composing:n}=t,{selection:a}=i,r=o&&o.selection.from===i.selection.from&&o.selection.to===i.selection.to;if(n||r)return;const{ranges:s}=a,l=Math.min(...s.map(f=>f.$from.pos)),c=Math.max(...s.map(f=>f.$to.pos)),u=(p=this.shouldShow)==null?void 0:p.call(this,{view:t,state:i,from:l,to:c});if(!this.preventShow&&(u||this.preventHide)){this.state={show:!0,referencePos:this.getSelectionBoundingBox()},this.emitUpdate();return}if((m=this.state)!=null&&m.show&&!this.preventHide&&(!u||this.preventShow||!this.editor.isEditable)){this.state.show=!1,this.emitUpdate();return}}destroy(){this.pmView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.pmView.dom.removeEventListener("mouseup",this.viewMouseupHandler),this.pmView.dom.removeEventListener("dragstart",this.dragHandler),this.pmView.dom.removeEventListener("dragover",this.dragHandler),this.pmView.dom.removeEventListener("blur",this.blurHandler),this.pmView.root.removeEventListener("scroll",this.scrollHandler,!0)}getSelectionBoundingBox(){const{state:t}=this.pmView,{selection:o}=t,{ranges:i}=o,n=Math.min(...i.map(r=>r.$from.pos)),a=Math.max(...i.map(r=>r.$to.pos));if(k.isNodeSelection(o)){const r=this.pmView.nodeDOM(n);if(r)return r.getBoundingClientRect()}return k.posToDOMRect(this.pmView,n,a)}}const Xo=new _.PluginKey("FormattingToolbarPlugin");class Zo extends ie{constructor(o){super();h(this,"view");h(this,"plugin");h(this,"closeMenu",()=>this.view.closeMenu());this.plugin=new _.Plugin({key:Xo,view:i=>(this.view=new qo(o,i,n=>{this.emit("update",n)}),this.view),props:{handleKeyDown:(i,n)=>n.key==="Escape"&&this.shown?(this.view.closeMenu(),!0):!1}})}get shown(){var o,i;return((i=(o=this.view)==null?void 0:o.state)==null?void 0:i.show)||!1}onUpdate(o){return this.on("update",o)}}const Jo=(e,t)=>{const o=e.resolve(t);if(o.depth<=1)return;const i=o.posAtIndex(o.index(o.depth-1),o.depth-1);return Q(e.resolve(i))},nt=(e,t)=>{const o=e.resolve(t),i=o.index();if(i===0)return;const n=o.posAtIndex(i-1);return Q(e.resolve(n))},Yo=(e,t)=>{for(;t.childContainer;){const o=t.childContainer.node,i=e.resolve(t.childContainer.beforePos+1).posAtIndex(o.childCount-1);t=Q(e.resolve(i))}return t},Ea=(e,t)=>e.isBlockContainer&&e.blockContent.node.type.spec.content==="inline*"&&e.blockContent.node.childCount>0&&t.isBlockContainer&&t.blockContent.node.type.spec.content==="inline*",Ta=(e,t,o,i)=>{if(!i.isBlockContainer)throw new Error(`Attempted to merge block at position ${i.bnBlock.beforePos} into previous block at position ${o.bnBlock.beforePos}, but next block is not a block container`);if(i.childContainer){const n=e.doc.resolve(i.childContainer.beforePos+1),a=e.doc.resolve(i.childContainer.afterPos-1),r=n.blockRange(a);if(t){const s=e.doc.resolve(i.bnBlock.beforePos);e.tr.lift(r,s.depth)}}if(t){if(!o.isBlockContainer)throw new Error(`Attempted to merge block at position ${i.bnBlock.beforePos} into previous block at position ${o.bnBlock.beforePos}, but previous block is not a block container`);t(e.tr.delete(o.blockContent.afterPos-1,i.blockContent.beforePos+1))}return!0},Qo=e=>({state:t,dispatch:o})=>{const i=t.doc.resolve(e),n=Q(i),a=nt(t.doc,n.bnBlock.beforePos);if(!a)return!1;const r=Yo(t.doc,a);return Ea(r,n)?Ta(t,o,r,n):!1},Ia=k.Extension.create({priority:50,addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.first(({chain:i,commands:n})=>[()=>n.deleteSelection(),()=>n.undoInputRule(),()=>n.command(({state:a})=>{const r=C(a);if(!r.isBlockContainer)return!1;const s=a.selection.from===r.blockContent.beforePos+1,l=r.blockContent.node.type.name==="paragraph";return s&&!l?n.command(T(this.options.editor,r.bnBlock.beforePos,{type:"paragraph",props:{}})):!1}),()=>n.command(({state:a})=>{const r=C(a);if(!r.isBlockContainer)return!1;const{blockContent:s}=r;return a.selection.from===s.beforePos+1?n.liftListItem("blockContainer"):!1}),()=>n.command(({state:a})=>{const r=C(a);if(!r.isBlockContainer)return!1;const{bnBlock:s,blockContent:l}=r,c=a.selection.from===l.beforePos+1,u=a.selection.empty,p=s.beforePos;return c&&u?i().command(Qo(p)).scrollIntoView().run():!1}),()=>n.command(({state:a,dispatch:r})=>{const s=C(a);if(!s.isBlockContainer||!(a.selection.from===s.blockContent.beforePos+1)||nt(a.doc,s.bnBlock.beforePos))return!1;const u=Jo(a.doc,s.bnBlock.beforePos);if((u==null?void 0:u.blockNoteType)!=="column")return!1;const p=u,m=Jo(a.doc,p.bnBlock.beforePos);if((m==null?void 0:m.blockNoteType)!=="columnList")throw new Error("parent of column is not a column list");const f=p.childContainer.node.childCount===1,g=f&&m.childContainer.node.childCount===2,b=m.childContainer.node.firstChild===p.bnBlock.node;if(r){const y=a.doc.slice(s.bnBlock.beforePos,s.bnBlock.afterPos,!1);if(g)if(b){a.tr.step(new be.ReplaceAroundStep(m.bnBlock.beforePos,m.bnBlock.afterPos,p.bnBlock.afterPos+1,m.bnBlock.afterPos-2,y,y.size,!1));const v=a.tr.doc.resolve(p.bnBlock.beforePos);a.tr.setSelection(_.TextSelection.between(v,v))}else{a.tr.step(new be.ReplaceAroundStep(m.bnBlock.beforePos,m.bnBlock.afterPos,m.bnBlock.beforePos+2,p.bnBlock.beforePos-1,y,0,!1));const v=a.tr.doc.resolve(a.tr.mapping.map(p.bnBlock.beforePos-1));a.tr.setSelection(_.TextSelection.between(v,v))}else if(f)if(b){a.tr.delete(p.bnBlock.beforePos,p.bnBlock.afterPos),a.tr.insert(m.bnBlock.beforePos,y.content);const v=a.tr.doc.resolve(m.bnBlock.beforePos);a.tr.setSelection(_.TextSelection.between(v,v))}else a.tr.delete(p.bnBlock.beforePos-1,p.bnBlock.beforePos+1);else{a.tr.delete(s.bnBlock.beforePos,s.bnBlock.afterPos),b?a.tr.insert(m.bnBlock.beforePos-1,y.content):a.tr.insert(p.bnBlock.beforePos-1,y.content);const v=a.tr.doc.resolve(p.bnBlock.beforePos-1);a.tr.setSelection(_.TextSelection.between(v,v))}}return!0}),()=>n.command(({state:a})=>{const r=C(a);if(!r.isBlockContainer)throw new Error("todo");const s=a.selection.from===r.blockContent.beforePos+1,l=a.selection.empty,c=nt(a.doc,r.bnBlock.beforePos);if(c&&s&&l){const u=Yo(a.doc,c);if(!u.isBlockContainer)throw new Error("todo");if(u.blockContent.node.type.spec.content===""||u.blockContent.node.type.spec.content==="inline*"&&u.blockContent.node.childCount===0)return i().cut({from:r.bnBlock.beforePos,to:r.bnBlock.afterPos},u.bnBlock.afterPos).deleteRange({from:u.bnBlock.beforePos,to:u.bnBlock.afterPos}).run()}return!1})]),Delete:()=>this.editor.commands.first(({commands:i})=>[()=>i.deleteSelection(),()=>i.command(({state:n})=>{const a=C(n);if(!a.isBlockContainer)return!1;const{bnBlock:r,blockContent:s,childContainer:l}=a,{depth:c}=n.doc.resolve(r.beforePos),u=r.afterPos===n.doc.nodeSize-3,p=n.selection.from===s.afterPos-1,m=n.selection.empty;if(!u&&p&&m&&!(l!==void 0)){let g=c,b=r.afterPos+1,y=n.doc.resolve(b).depth;for(;y<g;)g=y,b+=2,y=n.doc.resolve(b).depth;return i.command(Qo(b-1))}return!1})]),Enter:()=>this.editor.commands.first(({commands:i})=>[()=>i.command(({state:n})=>{const a=C(n);if(!a.isBlockContainer)return!1;const{bnBlock:r,blockContent:s}=a,{depth:l}=n.doc.resolve(r.beforePos),c=n.selection.$anchor.parentOffset===0,u=n.selection.anchor===n.selection.head,p=s.node.childCount===0,m=l>1;return c&&u&&p&&m?i.liftListItem("blockContainer"):!1}),()=>i.command(({state:n,dispatch:a})=>{const r=C(n);if(!r.isBlockContainer)return!1;const{bnBlock:s,blockContent:l}=r,c=n.selection.$anchor.parentOffset===0,u=n.selection.anchor===n.selection.head,p=l.node.childCount===0;if(c&&u&&p){const m=s.afterPos,f=m+2;if(a){const g=n.schema.nodes.blockContainer.createAndFill();n.tr.insert(m,g).scrollIntoView(),n.tr.setSelection(new _.TextSelection(n.doc.resolve(f)))}return!0}return!1}),()=>i.command(({state:n,chain:a})=>{const r=C(n);if(!r.isBlockContainer)return!1;const{blockContent:s}=r,l=n.selection.$anchor.parentOffset===0;return s.node.childCount===0?!1:(a().deleteSelection().command(mo(n.selection.from,l,l)).run(),!0)})]),Tab:()=>{var i,n,a;return this.options.tabBehavior!=="prefer-indent"&&((i=this.options.editor.formattingToolbar)!=null&&i.shown||(n=this.options.editor.linkToolbar)!=null&&n.shown||(a=this.options.editor.filePanel)!=null&&a.shown)?!1:Do(this.options.editor)},"Shift-Tab":()=>{var i,n,a;return this.options.tabBehavior!=="prefer-indent"&&((i=this.options.editor.formattingToolbar)!=null&&i.shown||(n=this.options.editor.linkToolbar)!=null&&n.shown||(a=this.options.editor.filePanel)!=null&&a.shown)?!1:(this.editor.commands.liftListItem("blockContainer"),!0)},"Shift-Mod-ArrowUp":()=>(this.options.editor.moveBlocksUp(),!0),"Shift-Mod-ArrowDown":()=>(this.options.editor.moveBlocksDown(),!0)}}});class Ma{constructor(t,o,i){h(this,"state");h(this,"emitUpdate");h(this,"menuUpdateTimer");h(this,"startMenuUpdateTimer");h(this,"stopMenuUpdateTimer");h(this,"mouseHoveredLinkMark");h(this,"mouseHoveredLinkMarkRange");h(this,"keyboardHoveredLinkMark");h(this,"keyboardHoveredLinkMarkRange");h(this,"linkMark");h(this,"linkMarkRange");h(this,"mouseOverHandler",t=>{if(this.mouseHoveredLinkMark=void 0,this.mouseHoveredLinkMarkRange=void 0,this.stopMenuUpdateTimer(),t.target instanceof HTMLAnchorElement&&t.target.nodeName==="A"){const o=t.target,i=this.pmView.posAtDOM(o,0)+1,n=this.pmView.state.doc.resolve(i),a=n.marks();for(const r of a)if(r.type.name===this.pmView.state.schema.mark("link").type.name){this.mouseHoveredLinkMark=r,this.mouseHoveredLinkMarkRange=k.getMarkRange(n,r.type,r.attrs)||void 0;break}}return this.startMenuUpdateTimer(),!1});h(this,"clickHandler",t=>{var i;const o=this.pmView.dom.parentElement;this.linkMark&&t&&t.target&&!(o===t.target||o.contains(t.target))&&(i=this.state)!=null&&i.show&&(this.state.show=!1,this.emitUpdate())});h(this,"scrollHandler",()=>{var t;this.linkMark!==void 0&&(t=this.state)!=null&&t.show&&(this.state.referencePos=k.posToDOMRect(this.pmView,this.linkMarkRange.from,this.linkMarkRange.to),this.emitUpdate())});h(this,"closeMenu",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())});this.editor=t,this.pmView=o,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized link toolbar");i(this.state)},this.startMenuUpdateTimer=()=>{this.menuUpdateTimer=setTimeout(()=>{this.update(this.pmView)},250)},this.stopMenuUpdateTimer=()=>(this.menuUpdateTimer&&(clearTimeout(this.menuUpdateTimer),this.menuUpdateTimer=void 0),!1),this.pmView.dom.addEventListener("mouseover",this.mouseOverHandler),this.pmView.root.addEventListener("click",this.clickHandler,!0),this.pmView.root.addEventListener("scroll",this.scrollHandler,!0)}editLink(t,o){var n;const i=this.pmView.state.tr.insertText(o,this.linkMarkRange.from,this.linkMarkRange.to);i.addMark(this.linkMarkRange.from,this.linkMarkRange.from+o.length,this.pmView.state.schema.mark("link",{href:t})),this.editor.dispatch(i),this.pmView.focus(),(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())}deleteLink(){var t;this.editor.dispatch(this.pmView.state.tr.removeMark(this.linkMarkRange.from,this.linkMarkRange.to,this.linkMark.type).setMeta("preventAutolink",!0)),this.pmView.focus(),(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())}update(t,o){var r;const{state:i}=t;if(o&&o.selection.from===i.selection.from&&o.selection.to===i.selection.to||!this.pmView.hasFocus())return;const a=this.linkMark;if(this.linkMark=void 0,this.linkMarkRange=void 0,this.keyboardHoveredLinkMark=void 0,this.keyboardHoveredLinkMarkRange=void 0,this.pmView.state.selection.empty){const s=this.pmView.state.selection.$from.marks();for(const l of s)if(l.type.name===this.pmView.state.schema.mark("link").type.name){this.keyboardHoveredLinkMark=l,this.keyboardHoveredLinkMarkRange=k.getMarkRange(this.pmView.state.selection.$from,l.type,l.attrs)||void 0;break}}if(this.mouseHoveredLinkMark&&(this.linkMark=this.mouseHoveredLinkMark,this.linkMarkRange=this.mouseHoveredLinkMarkRange),this.keyboardHoveredLinkMark&&(this.linkMark=this.keyboardHoveredLinkMark,this.linkMarkRange=this.keyboardHoveredLinkMarkRange),this.linkMark&&this.editor.isEditable){this.state={show:!0,referencePos:k.posToDOMRect(this.pmView,this.linkMarkRange.from,this.linkMarkRange.to),url:this.linkMark.attrs.href,text:this.pmView.state.doc.textBetween(this.linkMarkRange.from,this.linkMarkRange.to)},this.emitUpdate();return}if((r=this.state)!=null&&r.show&&a&&(!this.linkMark||!this.editor.isEditable)){this.state.show=!1,this.emitUpdate();return}}destroy(){this.pmView.dom.removeEventListener("mouseover",this.mouseOverHandler),this.pmView.root.removeEventListener("scroll",this.scrollHandler,!0),this.pmView.root.removeEventListener("click",this.clickHandler,!0)}}const ei=new _.PluginKey("LinkToolbarPlugin");class ti extends ie{constructor(o){super();h(this,"view");h(this,"plugin");h(this,"editLink",(o,i)=>{this.view.editLink(o,i)});h(this,"deleteLink",()=>{this.view.deleteLink()});h(this,"startHideTimer",()=>{this.view.startMenuUpdateTimer()});h(this,"stopHideTimer",()=>{this.view.stopMenuUpdateTimer()});h(this,"closeMenu",()=>this.view.closeMenu());this.plugin=new _.Plugin({key:ei,view:i=>(this.view=new Ma(o,i,n=>{this.emit("update",n)}),this.view),props:{handleKeyDown:(i,n)=>n.key==="Escape"&&this.shown?(this.view.closeMenu(),!0):!1}})}onUpdate(o){return this.on("update",o)}get shown(){var o,i;return((i=(o=this.view)==null?void 0:o.state)==null?void 0:i.show)||!1}}const oi=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"],ii="https",La=new _.PluginKey("node-selection-keyboard");class Pa{constructor(){h(this,"plugin");this.plugin=new _.Plugin({key:La,props:{handleKeyDown:(t,o)=>{if("node"in t.state.selection){if(o.ctrlKey||o.metaKey)return!1;if(o.key.length===1)return o.preventDefault(),!0;if(o.key==="Enter"&&!o.shiftKey&&!o.altKey&&!o.ctrlKey&&!o.metaKey){const i=t.state.tr;return t.dispatch(i.insert(t.state.tr.selection.$to.after(),t.state.schema.nodes.paragraph.createChecked()).setSelection(new _.TextSelection(i.doc.resolve(t.state.tr.selection.$to.after()+1)))),!0}}return!1}}})}}const Aa=new _.PluginKey("blocknote-placeholder");class Na{constructor(t,o){h(this,"plugin");this.plugin=new _.Plugin({key:Aa,view:()=>{var l,c;const i=document.createElement("style"),n=t._tiptapEditor.options.injectNonce;n&&i.setAttribute("nonce",n),((l=t.prosemirrorView)==null?void 0:l.root)instanceof ShadowRoot?t.prosemirrorView.root.append(i):(c=t.prosemirrorView)==null||c.root.head.appendChild(i);const a=i.sheet,r=(u="")=>`.bn-block-content${u} .bn-inline-content:has(> .ProseMirror-trailingBreak:only-child):before`,s=(u,p=!0)=>{const m=p?"[data-is-empty-and-focused]":"";if(u==="default")return r(m);const f=`[data-content-type="${u}"]`;return r(m+f)};for(const[u,p]of Object.entries(o)){const m=u==="default";try{a.insertRule(`${s(u,m)} { content: ${JSON.stringify(p)}; }`),m||a.insertRule(`${s(u,!0)} { content: ${JSON.stringify(p)}; }`)}catch(f){console.warn("Failed to insert placeholder CSS rule - this is likely due to the browser not supporting certain CSS pseudo-element selectors (:has, :only-child:, or :before)",f)}}return{destroy:()=>{var u,p;((u=t.prosemirrorView)==null?void 0:u.root)instanceof ShadowRoot?t.prosemirrorView.root.removeChild(i):(p=t.prosemirrorView)==null||p.root.head.removeChild(i)}}},props:{decorations:i=>{const{doc:n,selection:a}=i;if(!t.isEditable||!a.empty||a.$from.parent.type.spec.code)return;const r=a.$anchor,s=r.parent;if(s.content.size>0)return null;const l=r.before(),c=P.Decoration.node(l,l+s.nodeSize,{"data-is-empty-and-focused":"true"});return P.DecorationSet.create(n,[c])}}})}}const ni=new _.PluginKey("previous-blocks"),Da={index:"index",level:"level",type:"type",depth:"depth","depth-change":"depth-change"};class ja{constructor(){h(this,"plugin");let t;this.plugin=new _.Plugin({key:ni,view(o){return{update:async(i,n)=>{var a;((a=this.key)==null?void 0:a.getState(i.state).updatedBlocks.size)>0&&(t=setTimeout(()=>{i.dispatch(i.state.tr.setMeta(ni,{clearUpdate:!0}))},0))},destroy:()=>{t&&clearTimeout(t)}}},state:{init(){return{prevTransactionOldBlockAttrs:{},currentTransactionOldBlockAttrs:{},updatedBlocks:new Set}},apply(o,i,n,a){if(i.currentTransactionOldBlockAttrs={},i.updatedBlocks.clear(),!o.docChanged||n.doc.eq(a.doc))return i;const r={},s=k.findChildren(n.doc,u=>u.attrs.id),l=new Map(s.map(u=>[u.node.attrs.id,u])),c=k.findChildren(a.doc,u=>u.attrs.id);for(const u of c){const p=l.get(u.node.attrs.id),m=p==null?void 0:p.node.firstChild,f=u.node.firstChild;if(p&&m&&f){const g={index:f.attrs.index,level:f.attrs.level,type:f.type.name,depth:a.doc.resolve(u.pos).depth};let b={index:m.attrs.index,level:m.attrs.level,type:m.type.name,depth:n.doc.resolve(p.pos).depth};r[u.node.attrs.id]=b,o.getMeta("numberedListIndexing")&&(u.node.attrs.id in i.prevTransactionOldBlockAttrs&&(b=i.prevTransactionOldBlockAttrs[u.node.attrs.id]),g.type==="numberedListItem"&&(b.index=g.index)),i.currentTransactionOldBlockAttrs[u.node.attrs.id]=b,JSON.stringify(b)!==JSON.stringify(g)&&(b["depth-change"]=b.depth-g.depth,i.updatedBlocks.add(u.node.attrs.id))}}return i.prevTransactionOldBlockAttrs=r,i}},props:{decorations(o){const i=this.getState(o);if(i.updatedBlocks.size===0)return;const n=[];return o.doc.descendants((a,r)=>{if(!a.attrs.id||!i.updatedBlocks.has(a.attrs.id))return;const s=i.currentTransactionOldBlockAttrs[a.attrs.id],l={};for(const[u,p]of Object.entries(s))l["data-prev-"+Da[u]]=p||"none";const c=P.Decoration.node(r,r+a.nodeSize,{...l});n.push(c)}),P.DecorationSet.create(o.doc,n)}}})}}function ai(e,t){var o,i;for(;e&&e.parentElement&&e.parentElement!==t.dom&&((o=e.getAttribute)==null?void 0:o.call(e,"data-node-type"))!=="blockContainer";)e=e.parentElement;if(((i=e.getAttribute)==null?void 0:i.call(e,"data-node-type"))==="blockContainer")return{node:e,id:e.getAttribute("data-id")}}class ne extends _.Selection{constructor(o,i){super(o,i);h(this,"nodes");const n=o.node();this.nodes=[],o.doc.nodesBetween(o.pos,i.pos,(a,r,s)=>{if(s!==null&&s.eq(n))return this.nodes.push(a),!1})}static create(o,i,n=i){return new ne(o.resolve(i),o.resolve(n))}content(){return new w.Slice(w.Fragment.from(this.nodes),0,0)}eq(o){if(!(o instanceof ne)||this.nodes.length!==o.nodes.length||this.from!==o.from||this.to!==o.to)return!1;for(let i=0;i<this.nodes.length;i++)if(!this.nodes[i].eq(o.nodes[i]))return!1;return!0}map(o,i){const n=i.mapResult(this.from),a=i.mapResult(this.to);return a.deleted?_.Selection.near(o.resolve(n.pos)):n.deleted?_.Selection.near(o.resolve(a.pos)):new ne(o.resolve(n.pos),o.resolve(a.pos))}toJSON(){return{type:"node",anchor:this.anchor,head:this.head}}}let V;function Ha(e,t){let o,i;const n=t.resolve(e.from).node().type.spec.group==="blockContent",a=t.resolve(e.to).node().type.spec.group==="blockContent",r=Math.min(e.$anchor.depth,e.$head.depth);if(n&&a){const s=e.$from.start(r-1),l=e.$to.end(r-1);o=t.resolve(s-1).pos,i=t.resolve(l+1).pos}else o=e.from,i=e.to;return{from:o,to:i}}function ri(e,t,o=t){t===o&&(o+=e.state.doc.resolve(t+1).node().nodeSize);const i=e.domAtPos(t).node.cloneNode(!0),n=e.domAtPos(t).node,a=(u,p)=>Array.prototype.indexOf.call(u.children,p),r=a(n,e.domAtPos(t+1).node.parentElement),s=a(n,e.domAtPos(o-1).node.parentElement);for(let u=n.childElementCount-1;u>=0;u--)(u>s||u<r)&&i.removeChild(i.children[u]);si(e.root),V=i;const c=e.dom.className.split(" ").filter(u=>u!=="ProseMirror"&&u!=="bn-root"&&u!=="bn-editor").join(" ");V.className=V.className+" bn-drag-preview "+c,e.root instanceof ShadowRoot?e.root.appendChild(V):e.root.body.appendChild(V)}function si(e){V!==void 0&&(e instanceof ShadowRoot?e.removeChild(V):e.body.removeChild(V),V=void 0)}function Oa(e,t,o){if(!e.dataTransfer)return;const i=o.prosemirrorView;if(!i)return;const n=A(t.id,i.state.doc);if(!n)throw new Error(`Block with ID ${t.id} not found`);const a=n.posBeforeNode;if(a!=null){const r=i.state.selection,s=i.state.doc,{from:l,to:c}=Ha(r,s),u=l<=a&&a<c,p=r.$anchor.node()!==r.$head.node()||r instanceof ne;u&&p?(i.dispatch(i.state.tr.setSelection(ne.create(s,l,c))),ri(i,l,c)):(i.dispatch(i.state.tr.setSelection(_.NodeSelection.create(i.state.doc,a))),ri(i,a));const m=i.state.selection.content(),f=o.pmSchema,g=ct.__serializeForClipboard(i,m).dom.innerHTML,b=de(f,o),y=Fo(m.content,o.schema),v=b.exportBlocks(y,{}),I=Se(v);e.dataTransfer.clearData(),e.dataTransfer.setData("blocknote/html",g),e.dataTransfer.setData("text/html",v),e.dataTransfer.setData("text/plain",I),e.dataTransfer.effectAllowed="move",e.dataTransfer.setDragImage(V,0,0)}}const fe=.1;function at(e,t,o,i=!0){const n=e.root.elementsFromPoint(t.left+(o==="editor"?50:0),t.top);for(const a of n)if(e.dom.contains(a))return i&&a.closest("[data-node-type=columnList]")?at(e,{left:t.left+50,top:t.top},o,!1):ai(a,e)}function Ua(e,t,o){if(!t.dom.firstChild)return;const i=t.dom.firstChild.getBoundingClientRect(),n={left:e.x,top:e.y},a=n.left<i.left,r=n.left>i.right;o==="viewport"&&(a&&(n.left=i.left+10),r&&(n.left=i.right-10));let s=at(t,n,o);if(!r&&s){const l=s.node.getBoundingClientRect();n.left=l.right-10,s=at(t,n,"viewport",!1)}return s}class li{constructor(t,o,i,n){h(this,"state");h(this,"emitUpdate");h(this,"mousePos");h(this,"hoveredBlock");h(this,"menuFrozen",!1);h(this,"isDragOrigin",!1);h(this,"updateState",t=>{this.state=t,this.emitUpdate(this.state)});h(this,"updateStateFromMousePos",()=>{var i,n,a,r;if(this.menuFrozen||!this.mousePos)return;const t=Ua(this.mousePos,this.pmView,this.sideMenuDetection);if(!t||!this.editor.isEditable){(i=this.state)!=null&&i.show&&(this.state.show=!1,this.updateState(this.state));return}if((n=this.state)!=null&&n.show&&((a=this.hoveredBlock)!=null&&a.hasAttribute("data-id"))&&((r=this.hoveredBlock)==null?void 0:r.getAttribute("data-id"))===t.id)return;this.hoveredBlock=t.node;const o=t.node.firstChild;if(o&&this.editor.isEditable){const s=o.getBoundingClientRect(),l=t.node.closest("[data-node-type=column]");this.updateState({show:!0,referencePos:new DOMRect(l?l.firstElementChild.getBoundingClientRect().x:this.pmView.dom.firstChild.getBoundingClientRect().x,s.y,s.width,s.height),block:this.editor.getBlock(this.hoveredBlock.getAttribute("data-id"))})}});h(this,"onDrop",t=>{var i;if(this.pmView.dragging===null||(this.editor._tiptapEditor.commands.blur(),!this.isDragOrigin&&this.pmView.dom.contains(t.target)?this.pmView.dispatch(this.pmView.state.tr.setSelection(_.TextSelection.create(this.pmView.state.tr.doc,this.pmView.state.tr.selection.to))):this.isDragOrigin&&!this.pmView.dom.contains(t.target)&&setTimeout(()=>this.pmView.dispatch(this.pmView.state.tr.deleteSelection()),0),setTimeout(()=>this.pmView.dragging=null,0),this.sideMenuDetection==="editor"||t.synthetic||!((i=t.dataTransfer)!=null&&i.types.includes("blocknote/html"))))return;const o=this.pmView.posAtCoords({left:t.clientX,top:t.clientY});if(!o||o.inside===-1){const n=this.createSyntheticEvent(t);this.pmView.dom.dispatchEvent(n)}});h(this,"onDragStart",t=>{var r;const o=(r=t.dataTransfer)==null?void 0:r.getData("blocknote/html");if(!o)return;if(this.pmView.dragging)throw new Error("New drag was started while an existing drag is ongoing");const i=document.createElement("div");i.innerHTML=o;const a=w.DOMParser.fromSchema(this.pmView.state.schema).parse(i,{topNode:this.pmView.state.schema.nodes.blockGroup.create()});this.pmView.dragging={slice:new w.Slice(a.content,0,0),move:!0}});h(this,"onDragOver",t=>{var i;if(this.sideMenuDetection==="editor"||t.synthetic||!((i=t.dataTransfer)!=null&&i.types.includes("blocknote/html")))return;const o=this.pmView.posAtCoords({left:t.clientX,top:t.clientY});if(!o||o.inside===-1&&this.pmView.dom.firstChild){const n=this.createSyntheticEvent(t);this.pmView.dom.dispatchEvent(n)}});h(this,"onKeyDown",t=>{var o;(o=this.state)!=null&&o.show&&this.editor.isFocused()&&(this.state.show=!1,this.emitUpdate(this.state))});h(this,"onMouseMove",t=>{var a;if(this.menuFrozen)return;this.mousePos={x:t.clientX,y:t.clientY};const o=this.pmView.dom.getBoundingClientRect(),i=this.mousePos.x>o.left&&this.mousePos.x<o.right&&this.mousePos.y>o.top&&this.mousePos.y<o.bottom,n=this.pmView.dom.parentElement;if(i&&t&&t.target&&!(n===t.target||n.contains(t.target))){(a=this.state)!=null&&a.show&&(this.state.show=!1,this.emitUpdate(this.state));return}this.updateStateFromMousePos()});h(this,"onScroll",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.referencePos=this.hoveredBlock.getBoundingClientRect(),this.emitUpdate(this.state))});this.editor=t,this.sideMenuDetection=o,this.pmView=i,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized side menu");n(this.state)},this.pmView.root.addEventListener("dragstart",this.onDragStart),this.pmView.root.addEventListener("dragover",this.onDragOver),this.pmView.root.addEventListener("drop",this.onDrop,!0),xe(),this.pmView.root.addEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.addEventListener("keydown",this.onKeyDown,!0),i.root.addEventListener("scroll",this.onScroll,!0)}createSyntheticEvent(t){const o=new Event(t.type,t),i=this.pmView.dom.firstChild.getBoundingClientRect();return o.clientX=t.clientX,o.clientY=t.clientY,t.clientX<i.left&&t.clientX>i.left-i.width*fe?o.clientX=i.left+i.width*fe/2:t.clientX>i.right&&t.clientX<i.right+i.width*fe?o.clientX=i.right-i.width*fe/2:(t.clientX<i.left||t.clientX>i.right)&&(o.clientX=i.left+fe*i.width*2),o.clientY=Math.min(Math.max(t.clientY,i.top),i.top+i.height),o.dataTransfer=t.dataTransfer,o.preventDefault=()=>t.preventDefault(),o.synthetic=!0,o}update(t,o){var n;!o.doc.eq(this.pmView.state.doc)&&((n=this.state)!=null&&n.show)&&this.updateStateFromMousePos()}destroy(){var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate(this.state)),this.pmView.root.removeEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.removeEventListener("dragstart",this.onDragStart),this.pmView.root.removeEventListener("dragover",this.onDragOver),this.pmView.root.removeEventListener("drop",this.onDrop,!0),this.pmView.root.removeEventListener("keydown",this.onKeyDown,!0),this.pmView.root.removeEventListener("scroll",this.onScroll,!0)}}const di=new _.PluginKey("SideMenuPlugin");class ci extends ie{constructor(o,i){super();h(this,"view");h(this,"plugin");h(this,"blockDragStart",(o,i)=>{this.view&&(this.view.isDragOrigin=!0),Oa(o,i,this.editor)});h(this,"blockDragEnd",()=>{this.editor.prosemirrorView&&si(this.editor.prosemirrorView.root),this.view&&(this.view.isDragOrigin=!1)});h(this,"freezeMenu",()=>{this.view.menuFrozen=!0,this.view.state.show=!0,this.view.emitUpdate(this.view.state)});h(this,"unfreezeMenu",()=>{this.view.menuFrozen=!1,this.view.state.show=!1,this.view.emitUpdate(this.view.state)});this.editor=o,this.plugin=new _.Plugin({key:di,view:n=>(this.view=new li(o,i,n,a=>{this.emit("update",a)}),this.view)})}onUpdate(o){return this.on("update",o)}}const Ra=k.findParentNode(e=>e.type.name==="blockContainer");class Va{constructor(t,o){h(this,"state");h(this,"emitUpdate");h(this,"rootEl");h(this,"pluginState");h(this,"handleScroll",()=>{var t,o;if((t=this.state)!=null&&t.show){const i=(o=this.rootEl)==null?void 0:o.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);if(!i)return;this.state.referencePos=i.getBoundingClientRect(),this.emitUpdate(this.pluginState.triggerCharacter)}});h(this,"closeMenu",()=>{this.editor.dispatch(this.editor._tiptapEditor.state.tr.setMeta(ae,null))});h(this,"clearQuery",()=>{this.pluginState!==void 0&&this.editor._tiptapEditor.chain().focus().deleteRange({from:this.pluginState.queryStartPos-(this.pluginState.deleteTriggerCharacter?this.pluginState.triggerCharacter.length:0),to:this.editor._tiptapEditor.state.selection.from}).run()});var i,n;this.editor=t,this.pluginState=void 0,this.emitUpdate=a=>{var r;if(!this.state)throw new Error("Attempting to update uninitialized suggestions menu");o(a,{...this.state,ignoreQueryLength:(r=this.pluginState)==null?void 0:r.ignoreQueryLength})},this.rootEl=(i=this.editor.prosemirrorView)==null?void 0:i.root,(n=this.rootEl)==null||n.addEventListener("scroll",this.handleScroll,!0)}update(t,o){var c;const i=ae.getState(o),n=ae.getState(t.state),a=i===void 0&&n!==void 0,r=i!==void 0&&n===void 0;if(!a&&!(i!==void 0&&n!==void 0)&&!r)return;if(this.pluginState=r?i:n,r||!this.editor.isEditable){this.state.show=!1,this.emitUpdate(this.pluginState.triggerCharacter);return}const l=(c=this.rootEl)==null?void 0:c.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);this.editor.isEditable&&l&&(this.state={show:!0,referencePos:l.getBoundingClientRect(),query:this.pluginState.query},this.emitUpdate(this.pluginState.triggerCharacter))}destroy(){var t;(t=this.rootEl)==null||t.removeEventListener("scroll",this.handleScroll,!0)}}const ae=new _.PluginKey("SuggestionMenuPlugin");class ui extends ie{constructor(o){super();h(this,"view");h(this,"plugin");h(this,"triggerCharacters",[]);h(this,"addTriggerCharacter",o=>{this.triggerCharacters.push(o)});h(this,"removeTriggerCharacter",o=>{this.triggerCharacters=this.triggerCharacters.filter(i=>i!==o)});h(this,"closeMenu",()=>this.view.closeMenu());h(this,"clearQuery",()=>this.view.clearQuery());const i=this.triggerCharacters;this.plugin=new _.Plugin({key:ae,view:()=>(this.view=new Va(o,(n,a)=>{this.emit(`update ${n}`,a)}),this.view),state:{init(){},apply(n,a,r,s){if(n.getMeta("orderedListIndexing")!==void 0||n.selection.$from.parent.type.spec.code)return a;const l=n.getMeta(ae);if(typeof l=="object"&&l!==null&&a===void 0)return{triggerCharacter:l.triggerCharacter,deleteTriggerCharacter:l.deleteTriggerCharacter!==!1,queryStartPos:s.selection.from,query:"",decorationId:`id_${Math.floor(Math.random()*4294967295)}`,ignoreQueryLength:l==null?void 0:l.ignoreQueryLength};if(a===void 0)return a;if(s.selection.from!==s.selection.to||l===null||n.getMeta("focus")||n.getMeta("blur")||n.getMeta("pointer")||a.triggerCharacter!==void 0&&s.selection.from<a.queryStartPos)return;const c={...a};return c.query=s.doc.textBetween(a.queryStartPos,s.selection.from),c}},props:{handleTextInput(n,a,r,s){const l=this.getState(n.state);return i.includes(s)&&l===void 0?(n.dispatch(n.state.tr.insertText(s).scrollIntoView().setMeta(ae,{triggerCharacter:s})),!0):!1},decorations(n){const a=this.getState(n);if(a===void 0)return null;if(!a.deleteTriggerCharacter){const r=Ra(n.selection);if(r)return P.DecorationSet.create(n.doc,[P.Decoration.node(r.pos,r.pos+r.node.nodeSize,{nodeName:"span",class:"bn-suggestion-decorator","data-decoration-id":a.decorationId})])}return P.DecorationSet.create(n.doc,[P.Decoration.inline(a.queryStartPos-a.triggerCharacter.length,a.queryStartPos,{nodeName:"span",class:"bn-suggestion-decorator","data-decoration-id":a.decorationId})])}}})}onUpdate(o,i){return this.triggerCharacters.includes(o)||this.addTriggerCharacter(o),this.on(`update ${o}`,i)}get shown(){var o,i;return((i=(o=this.view)==null?void 0:o.state)==null?void 0:i.show)||!1}}function za(e,t){e.suggestionMenus.addTriggerCharacter(t)}let D;function pi(e){D||(D=document.createElement("div"),D.innerHTML="_",D.style.opacity="0",D.style.height="1px",D.style.width="1px",e instanceof Document?e.body.appendChild(D):e.appendChild(D))}function Fa(e){D&&(e instanceof Document?e.body.removeChild(D):e.removeChild(D),D=void 0)}function Be(e){return Array.prototype.indexOf.call(e.parentElement.childNodes,e)}function Ga(e){let t=e;for(;t&&t.nodeName!=="TD"&&t.nodeName!=="TH"&&!t.classList.contains("tableWrapper");){if(t.classList.contains("ProseMirror"))return;const o=t.parentNode;if(!o||!(o instanceof Element))return;t=o}return t.nodeName==="TD"||t.nodeName==="TH"?{type:"cell",domNode:t,tbodyNode:t.closest("tbody")}:{type:"wrapper",domNode:t,tbodyNode:t.querySelector("tbody")}}function $a(e,t){const o=t.querySelectorAll(e);for(let i=0;i<o.length;i++)o[i].style.visibility="hidden"}class hi{constructor(t,o,i){h(this,"state");h(this,"emitUpdate");h(this,"tableId");h(this,"tablePos");h(this,"tableElement");h(this,"menuFrozen",!1);h(this,"mouseState","up");h(this,"prevWasEditable",null);h(this,"viewMousedownHandler",()=>{this.mouseState="down"});h(this,"mouseUpHandler",t=>{this.mouseState="up",this.mouseMoveHandler(t)});h(this,"mouseMoveHandler",t=>{var c,u,p,m;if(this.menuFrozen||this.mouseState==="selecting"||!(t.target instanceof Element)||!this.pmView.dom.contains(t.target))return;const o=Ga(t.target);if((o==null?void 0:o.type)==="cell"&&this.mouseState==="down"&&!((c=this.state)!=null&&c.draggingState)){this.mouseState="selecting",(u=this.state)!=null&&u.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate());return}if(!o||!this.editor.isEditable){(p=this.state)!=null&&p.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate());return}if(!o.tbodyNode)return;const i=o.tbodyNode.getBoundingClientRect(),n=ai(o.domNode,this.pmView);if(!n)return;this.tableElement=n.node;let a;const r=A(n.id,this.editor._tiptapEditor.state.doc);if(!r)throw new Error(`Block with ID ${n.id} not found`);const s=S(r.node,this.editor.schema.blockSchema,this.editor.schema.inlineContentSchema,this.editor.schema.styleSchema,this.editor.blockCache);if(To("table",s,this.editor)&&(this.tablePos=r.posBeforeNode+1,a=s),!a)return;this.tableId=n.id;const l=(m=o.domNode.closest(".tableWrapper"))==null?void 0:m.querySelector(".table-widgets-container");if((o==null?void 0:o.type)==="wrapper"){const f=t.clientY>=i.bottom-1&&t.clientY<i.bottom+20,g=t.clientX>=i.right-1&&t.clientX<i.right+20,b=t.clientX>i.right||t.clientY>i.bottom;this.state={...this.state,show:!0,showAddOrRemoveRowsButton:f,showAddOrRemoveColumnsButton:g,referencePosTable:i,block:a,widgetContainer:l,colIndex:b?void 0:this.state.colIndex,rowIndex:b?void 0:this.state.rowIndex,referencePosCell:b?void 0:this.state.referencePosCell}}else{const f=Be(o.domNode),g=Be(o.domNode.parentElement),b=o.domNode.getBoundingClientRect();if(this.state!==void 0&&this.state.show&&this.tableId===n.id&&this.state.rowIndex===g&&this.state.colIndex===f)return;this.state={show:!0,showAddOrRemoveColumnsButton:f===a.content.rows[0].cells.length-1,showAddOrRemoveRowsButton:g===a.content.rows.length-1,referencePosTable:i,block:a,draggingState:void 0,referencePosCell:b,colIndex:f,rowIndex:g,widgetContainer:l}}return this.emitUpdate(),!1});h(this,"dragOverHandler",t=>{var m;if(((m=this.state)==null?void 0:m.draggingState)===void 0)return;t.preventDefault(),t.dataTransfer.dropEffect="move",$a(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline",this.pmView.root);const o={left:Math.min(Math.max(t.clientX,this.state.referencePosTable.left+1),this.state.referencePosTable.right-1),top:Math.min(Math.max(t.clientY,this.state.referencePosTable.top+1),this.state.referencePosTable.bottom-1)},i=this.pmView.root.elementsFromPoint(o.left,o.top).filter(f=>f.tagName==="TD"||f.tagName==="TH");if(i.length===0)throw new Error("Could not find table cell element that the mouse cursor is hovering over.");const n=i[0];let a=!1;const r=Be(n.parentElement),s=Be(n),l=this.state.draggingState.draggedCellOrientation==="row"?this.state.rowIndex:this.state.colIndex,u=(this.state.draggingState.draggedCellOrientation==="row"?r:s)!==l;(this.state.rowIndex!==r||this.state.colIndex!==s)&&(this.state.rowIndex=r,this.state.colIndex=s,this.state.referencePosCell=n.getBoundingClientRect(),a=!0);const p=this.state.draggingState.draggedCellOrientation==="row"?o.top:o.left;this.state.draggingState.mousePos!==p&&(this.state.draggingState.mousePos=p,a=!0),a&&this.emitUpdate(),u&&this.editor.dispatch(this.pmView.state.tr.setMeta(re,!0))});h(this,"dropHandler",t=>{if(this.mouseState="up",this.state===void 0||this.state.draggingState===void 0)return;if(this.state.rowIndex===void 0||this.state.colIndex===void 0)throw new Error("Attempted to drop table row or column, but no table block was hovered prior.");t.preventDefault();const{draggingState:o,colIndex:i,rowIndex:n}=this.state,a=this.state.block.content.rows;if(o.draggedCellOrientation==="row"){const r=a[o.originalIndex];a.splice(o.originalIndex,1),a.splice(n,0,r)}else{const r=a.map(s=>s.cells[o.originalIndex]);a.forEach((s,l)=>{s.cells.splice(o.originalIndex,1),s.cells.splice(i,0,r[l])})}this.editor.updateBlock(this.state.block,{type:"table",content:{type:"tableContent",rows:a}}),this.editor.setTextCursorPosition(this.state.block.id)});this.editor=t,this.pmView=o,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized image toolbar");i(this.state)},o.dom.addEventListener("mousemove",this.mouseMoveHandler),o.dom.addEventListener("mousedown",this.viewMousedownHandler),window.addEventListener("mouseup",this.mouseUpHandler),o.root.addEventListener("dragover",this.dragOverHandler),o.root.addEventListener("drop",this.dropHandler)}update(){if(!this.state||!this.state.show)return;if(this.state.block=this.editor.getBlock(this.state.block.id),!this.state.block){this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate();return}const t=this.state.block.content.rows.length,o=this.state.block.content.rows[0].cells.length;this.state.rowIndex!==void 0&&this.state.colIndex!==void 0&&(this.state.rowIndex>=t&&(this.state.rowIndex=t-1),this.state.colIndex>=o&&(this.state.colIndex=o-1));const i=this.tableElement.querySelector("tbody");if(!i)throw new Error("Table block does not contain a 'tbody' HTML element. This should never happen.");if(this.state.rowIndex!==void 0&&this.state.colIndex!==void 0){const a=i.children[this.state.rowIndex].children[this.state.colIndex];this.state.referencePosCell=a.getBoundingClientRect()}this.state.referencePosTable=i.getBoundingClientRect(),this.emitUpdate()}destroy(){this.pmView.dom.removeEventListener("mousemove",this.mouseMoveHandler),window.removeEventListener("mouseup",this.mouseUpHandler),this.pmView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.pmView.root.removeEventListener("dragover",this.dragOverHandler),this.pmView.root.removeEventListener("drop",this.dropHandler)}}const re=new _.PluginKey("TableHandlesPlugin");class mi extends ie{constructor(o){super();h(this,"view");h(this,"plugin");h(this,"colDragStart",o=>{if(this.view.state===void 0||this.view.state.colIndex===void 0)throw new Error("Attempted to drag table column, but no table block was hovered prior.");if(this.view.state.draggingState={draggedCellOrientation:"col",originalIndex:this.view.state.colIndex,mousePos:o.clientX},this.view.emitUpdate(),this.editor.dispatch(this.editor._tiptapEditor.state.tr.setMeta(re,{draggedCellOrientation:this.view.state.draggingState.draggedCellOrientation,originalIndex:this.view.state.colIndex,newIndex:this.view.state.colIndex,tablePos:this.view.tablePos})),!this.editor.prosemirrorView)throw new Error("Editor view not initialized.");pi(this.editor.prosemirrorView.root),o.dataTransfer.setDragImage(D,0,0),o.dataTransfer.effectAllowed="move"});h(this,"rowDragStart",o=>{if(this.view.state===void 0||this.view.state.rowIndex===void 0)throw new Error("Attempted to drag table row, but no table block was hovered prior.");if(this.view.state.draggingState={draggedCellOrientation:"row",originalIndex:this.view.state.rowIndex,mousePos:o.clientY},this.view.emitUpdate(),this.editor.dispatch(this.editor._tiptapEditor.state.tr.setMeta(re,{draggedCellOrientation:this.view.state.draggingState.draggedCellOrientation,originalIndex:this.view.state.rowIndex,newIndex:this.view.state.rowIndex,tablePos:this.view.tablePos})),!this.editor.prosemirrorView)throw new Error("Editor view not initialized.");pi(this.editor.prosemirrorView.root),o.dataTransfer.setDragImage(D,0,0),o.dataTransfer.effectAllowed="copyMove"});h(this,"dragEnd",()=>{if(this.view.state===void 0)throw new Error("Attempted to drag table row, but no table block was hovered prior.");if(this.view.state.draggingState=void 0,this.view.emitUpdate(),this.editor.dispatch(this.editor._tiptapEditor.state.tr.setMeta(re,null)),!this.editor.prosemirrorView)throw new Error("Editor view not initialized.");Fa(this.editor.prosemirrorView.root)});h(this,"freezeHandles",()=>{this.view.menuFrozen=!0});h(this,"unfreezeHandles",()=>{this.view.menuFrozen=!1});this.editor=o,this.plugin=new _.Plugin({key:re,view:i=>(this.view=new hi(o,i,n=>{this.emit("update",n)}),this.view),props:{decorations:i=>{if(this.view===void 0||this.view.state===void 0||this.view.state.draggingState===void 0||this.view.tablePos===void 0)return;const n=this.view.state.draggingState.draggedCellOrientation==="row"?this.view.state.rowIndex:this.view.state.colIndex;if(n===void 0)return;const a=[];if(n===this.view.state.draggingState.originalIndex)return P.DecorationSet.create(i.doc,a);const r=i.doc.resolve(this.view.tablePos+1),s=r.node();if(this.view.state.draggingState.draggedCellOrientation==="row"){const l=i.doc.resolve(r.posAtIndex(n)+1),c=l.node();for(let u=0;u<c.childCount;u++){const p=i.doc.resolve(l.posAtIndex(u)+1),m=p.node(),f=p.pos+(n>this.view.state.draggingState.originalIndex?m.nodeSize-2:0);a.push(P.Decoration.widget(f,()=>{const g=document.createElement("div");return g.className="bn-table-drop-cursor",g.style.left="0",g.style.right="0",n>this.view.state.draggingState.originalIndex?g.style.bottom="-2px":g.style.top="-3px",g.style.height="4px",g}))}}else for(let l=0;l<s.childCount;l++){const c=i.doc.resolve(r.posAtIndex(l)+1),u=i.doc.resolve(c.posAtIndex(n)+1),p=u.node(),m=u.pos+(n>this.view.state.draggingState.originalIndex?p.nodeSize-2:0);a.push(P.Decoration.widget(m,()=>{const f=document.createElement("div");return f.className="bn-table-drop-cursor",f.style.top="0",f.style.bottom="0",n>this.view.state.draggingState.originalIndex?f.style.right="-2px":f.style.left="-3px",f.style.width="4px",f}))}return P.DecorationSet.create(i.doc,a)}}})}onUpdate(o){return this.on("update",o)}}const Ka=k.Extension.create({name:"textAlignment",addGlobalAttributes(){return[{types:["paragraph","heading","bulletListItem","numberedListItem","checkListItem"],attributes:{textAlignment:{default:"left",parseHTML:e=>e.getAttribute("data-text-alignment"),renderHTML:e=>e.textAlignment==="left"?{}:{"data-text-alignment":e.textAlignment}}}}]}}),Wa=k.Extension.create({name:"blockTextColor",addGlobalAttributes(){return[{types:["blockContainer"],attributes:{textColor:{default:B.textColor.default,parseHTML:e=>e.hasAttribute("data-text-color")?e.getAttribute("data-text-color"):B.textColor.default,renderHTML:e=>e.textColor===B.textColor.default?{}:{"data-text-color":e.textColor}}}}]}}),qa=k.Extension.create({name:"trailingNode",addProseMirrorPlugins(){const e=new _.PluginKey(this.name);return[new _.Plugin({key:e,appendTransaction:(t,o,i)=>{const{doc:n,tr:a,schema:r}=i,s=e.getState(i),l=n.content.size-2,c=r.nodes.blockContainer,u=r.nodes.paragraph;if(s)return a.insert(l,c.create(void 0,u.create()))},state:{init:(t,o)=>{},apply:(t,o)=>{if(!t.docChanged)return o;let i=t.doc.lastChild;if(!i||i.type.name!=="blockGroup")throw new Error("Expected blockGroup");if(i=i.lastChild,!i||i.type.name!=="blockContainer")return!0;const n=i.firstChild;if(!n)throw new Error("Expected blockContent");return i.nodeSize>4||n.type.spec.content!=="inline*"}}})]}}),Xa={blockColor:"data-block-color",blockStyle:"data-block-style",id:"data-id",depth:"data-depth",depthChange:"data-depth-change"},Za=k.Node.create({name:"blockContainer",group:"blockGroupChild bnBlock",content:"blockContent blockGroup?",priority:50,defining:!0,parseHTML(){return[{tag:"div",getAttrs:e=>{if(typeof e=="string")return!1;const t={};for(const[o,i]of Object.entries(Xa))e.getAttribute(i)&&(t[o]=e.getAttribute(i));return e.getAttribute("data-node-type")==="blockContainer"?t:!1}}]},renderHTML({HTMLAttributes:e}){var n;const t=document.createElement("div");t.className="bn-block-outer",t.setAttribute("data-node-type","blockOuter");for(const[a,r]of Object.entries(e))a!=="class"&&t.setAttribute(a,r);const o={...((n=this.options.domAttributes)==null?void 0:n.block)||{},...e},i=document.createElement("div");i.className=$("bn-block",o.class),i.setAttribute("data-node-type",this.name);for(const[a,r]of Object.entries(o))a!=="class"&&i.setAttribute(a,r);return t.appendChild(i),{dom:t,contentDOM:i}}}),Ja=k.Node.create({name:"blockGroup",group:"childContainer",content:"blockGroupChild+",parseHTML(){return[{tag:"div",getAttrs:e=>typeof e=="string"?!1:e.getAttribute("data-node-type")==="blockGroup"?null:!1}]},renderHTML({HTMLAttributes:e}){var i;const t={...((i=this.options.domAttributes)==null?void 0:i.blockGroup)||{},...e},o=document.createElement("div");o.className=$("bn-block-group",t.class),o.setAttribute("data-node-type","blockGroup");for(const[n,a]of Object.entries(t))n!=="class"&&o.setAttribute(n,a);return{dom:o,contentDOM:o}}}),Ya=k.Node.create({name:"doc",topNode:!0,content:"blockGroup"}),Qa=e=>{var i;const t=[];t.push(Gi.default.configure({fragment:e.fragment}));const o=(i=e.provider)==null?void 0:i.awareness;if(o){const n=new Map;e.showCursorLabels!=="always"&&o.on("change",({updated:s})=>{for(const l of s){const c=n.get(l);c&&(c.element.setAttribute("data-active",""),c.hideTimeout&&clearTimeout(c.hideTimeout),n.set(l,{element:c.element,hideTimeout:setTimeout(()=>{c.element.removeAttribute("data-active")},2e3)}))}});const a=s=>{const l=document.createElement("span");l.classList.add("collaboration-cursor__caret"),l.setAttribute("style",`color: ${s.color}`),(e==null?void 0:e.showCursorLabels)==="always"&&l.setAttribute("data-active","");const c=document.createElement("span");return c.classList.add("collaboration-cursor__label"),c.setAttribute("style",`background-color: ${s.color}`),c.insertBefore(document.createTextNode(s.name),null),l.insertBefore(c,null),l},r=s=>{var p;const l=[...o.getStates().entries()].find(m=>m[1].user===s);if(!l)throw new Error("Could not find client state for user");const c=l[0];let u=n.get(c);if(!u){const m=((p=e==null?void 0:e.renderCursor)==null?void 0:p.call(e,s))||a(s);(e==null?void 0:e.showCursorLabels)!=="always"&&(m.addEventListener("mouseenter",()=>{const f=n.get(c);f.element.setAttribute("data-active",""),f.hideTimeout&&(clearTimeout(f.hideTimeout),n.set(c,{element:f.element,hideTimeout:void 0}))}),m.addEventListener("mouseleave",()=>{const f=n.get(c);n.set(c,{element:f.element,hideTimeout:setTimeout(()=>{f.element.removeAttribute("data-active")},2e3)})})),u={element:m,hideTimeout:void 0},n.set(c,u)}return u.element};t.push($i.default.configure({user:e.user,render:r,provider:e.provider}))}return t},fi=e=>{const t={},o=er(e);for(const n of o)t[n.name]=n;t.formattingToolbar=new Zo(e.editor),t.linkToolbar=new ti(e.editor),t.sideMenu=new ci(e.editor,e.sideMenuDetection),t.suggestionMenus=new ui(e.editor),t.filePanel=new Wo(e.editor),t.placeholder=new Na(e.editor,e.placeholders),(e.animations??!0)&&(t.animations=new ja),e.tableHandles&&(t.tableHandles=new mi(e.editor)),t.dropCursor={plugin:e.dropCursor({width:5,color:"#ddeeff",editor:e.editor})},t.nodeSelectionKeyboard=new Pa;const i=e.disableExtensions||[];for(const n of i)delete t[n];return t},er=e=>{const t=[k.extensions.ClipboardTextSerializer,k.extensions.Commands,k.extensions.Editable,k.extensions.FocusEvents,k.extensions.Tabindex,Mi.Gapcursor,J.configure({types:["blockContainer","columnList","column"],setIdAttribute:e.setIdAttribute}),Li.HardBreak.extend({priority:10}),Ni.Text,Ai.Link.extend({inclusive:!1}).configure({defaultProtocol:ii,protocols:oi}),...Object.values(e.styleSpecs).map(o=>o.implementation.mark),Wa,Ba,Ka,k.Extension.create({name:"OverrideEscape",addKeyboardShortcuts(){return{Escape:()=>e.editor.suggestionMenus.shown?!1:this.editor.commands.blur()}}}),Ya,Za.configure({editor:e.editor,domAttributes:e.domAttributes}),Ia.configure({editor:e.editor,tabBehavior:e.tabBehavior}),Ja.configure({domAttributes:e.domAttributes}),...Object.values(e.inlineContentSpecs).filter(o=>o.config!=="link"&&o.config!=="text").map(o=>o.implementation.node.configure({editor:e.editor})),...Object.values(e.blockSpecs).flatMap(o=>[...(o.implementation.requiredExtensions||[]).map(i=>i.configure({editor:e.editor,domAttributes:e.domAttributes})),o.implementation.node.configure({editor:e.editor,domAttributes:e.domAttributes})]),Sa(e.editor),Ca(e.editor),va(e.editor),...e.trailingBlock===void 0||e.trailingBlock?[qa]:[]];return e.collaboration?t.push(...Qa(e.collaboration)):t.push(Pi.History),t};function tr(e,t){const o=[];return e.forEach((i,n,a)=>{a!==t&&o.push(i)}),w.Fragment.from(o)}function or(e,t){const o=[];for(let i=0;i<e.childCount;i++)if(e.child(i).type.name==="tableRow")if(o.length>0&&o[o.length-1].type.name==="table"){const n=o[o.length-1],a=n.copy(n.content.addToEnd(e.child(i)));o[o.length-1]=a}else{const n=t.nodes.table.createChecked(void 0,e.child(i));o.push(n)}else o.push(e.child(i));return e=w.Fragment.from(o),e}function ir(e,t){let o=w.Fragment.from(e.content);if(o=or(o,t.state.schema),!nr(o,t))return new w.Slice(o,e.openStart,e.openEnd);for(let i=0;i<o.childCount;i++)if(o.child(i).type.spec.group==="blockContent"){const n=[o.child(i)];if(i+1<o.childCount&&o.child(i+1).type.name==="blockGroup"){const r=o.child(i+1).child(0).child(0);(r.type.name==="bulletListItem"||r.type.name==="numberedListItem"||r.type.name==="checkListItem")&&(n.push(o.child(i+1)),o=tr(o,i+1))}const a=t.state.schema.nodes.blockContainer.createChecked(void 0,n);o=o.replaceChild(i,a)}return new w.Slice(o,e.openStart,e.openEnd)}function nr(e,t){var a,r;const o=e.childCount===1,i=((a=e.firstChild)==null?void 0:a.type.spec.content)==="inline*",n=((r=e.firstChild)==null?void 0:r.type.spec.content)==="tableRow+";if(o){if(i)return!1;if(n){const s=C(t.state);if(s.isBlockContainer)return!(s.blockContent.node.type.spec.content==="tableRow+")}}return!0}const Ie=class Ie extends k.Editor{constructor(o,i){super({...o,content:void 0});h(this,"_state");h(this,"_creating",!1);h(this,"mount",o=>{o?(this.options.element=o,this.createViewAlternative()):(this.destroy(),this._creating=!1)});const n=this.schema;let a;const r=n.nodes.doc.createAndFill;n.nodes.doc.createAndFill=(...l)=>{if(a)return a;const c=r.apply(n.nodes.doc,l),u=JSON.parse(JSON.stringify(c.toJSON()));return u.content[0].content[0].attrs.id="initialBlockId",a=w.Node.fromJSON(n,u),a};let s;try{const l=o==null?void 0:o.content.map(c=>q(c,this.schema,i).toJSON());s=k.createDocument({type:"doc",content:[{type:"blockGroup",content:l}]},this.schema,this.options.parseOptions)}catch(l){throw console.error("Error creating document from blocks passed as `initialContent`. Caused by exception: ",l),new Error("Error creating document from blocks passed as `initialContent`:\n"+ +JSON.stringify(o.content))}this._state=_.EditorState.create({doc:s,schema:this.schema})}get state(){return this.view&&(this._state=this.view.state),this._state}dispatch(o){this.view?this.view.dispatch(o):this._state=this.state.apply(o)}createViewAlternative(){this._creating=!0,queueMicrotask(()=>{if(!this._creating)return;this.view=new P.EditorView({mount:this.options.element},{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:this.state});const o=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(o),this.createNodeViews(),this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0,this._creating=!1})}};h(Ie,"create",(o,i)=>{var a,r;const n=(a=globalThis==null?void 0:globalThis.window)==null?void 0:a.setTimeout;typeof((r=globalThis==null?void 0:globalThis.window)==null?void 0:r.setTimeout)<"u"&&(globalThis.window.setTimeout=()=>0);try{return new Ie(o,i)}finally{n&&(globalThis.window.setTimeout=n)}});let Ee=Ie;Ee.prototype.createView=function(){this.options.onPaste=this.options.onDrop=void 0};const ar={enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!1};class rt{constructor(t){h(this,"_pmSchema");h(this,"extensions",{});h(this,"headless",!1);h(this,"_tiptapEditor");h(this,"elementRenderer",null);h(this,"blockCache",new WeakMap);h(this,"dictionary");h(this,"schema");h(this,"blockImplementations");h(this,"inlineContentImplementations");h(this,"styleImplementations");h(this,"formattingToolbar");h(this,"linkToolbar");h(this,"sideMenu");h(this,"suggestionMenus");h(this,"filePanel");h(this,"tableHandles");h(this,"uploadFile");h(this,"onUploadStartCallbacks",[]);h(this,"onUploadEndCallbacks",[]);h(this,"resolveFileUrl");h(this,"mount",t=>{this._tiptapEditor.mount(t)});var s,l,c,u,p,m,f;this.options=t;const o=t;if(o.onEditorContentChange)throw new Error("onEditorContentChange initialization option is deprecated, use <BlockNoteView onChange={...} />, the useEditorChange(...) hook, or editor.onChange(...)");if(o.onTextCursorPositionChange)throw new Error("onTextCursorPositionChange initialization option is deprecated, use <BlockNoteView onSelectionChange={...} />, the useEditorSelectionChange(...) hook, or editor.onSelectionChange(...)");if(o.onEditorReady)throw new Error("onEditorReady is deprecated. Editor is immediately ready for use after creation.");if(o.editable)throw new Error("editable initialization option is deprecated, use <BlockNoteView editable={true/false} />, or alternatively editor.isEditable = true/false");this.dictionary=t.dictionary||ut;const i={defaultStyles:!0,schema:t.schema||oe.create(),_headless:!1,...t,placeholders:{...this.dictionary.placeholders,...t.placeholders}};if(this.schema=i.schema,this.blockImplementations=i.schema.blockSpecs,this.inlineContentImplementations=i.schema.inlineContentSpecs,this.styleImplementations=i.schema.styleSpecs,this.extensions=fi({editor:this,domAttributes:i.domAttributes||{},blockSpecs:this.schema.blockSpecs,styleSpecs:this.schema.styleSpecs,inlineContentSpecs:this.schema.inlineContentSpecs,collaboration:i.collaboration,trailingBlock:i.trailingBlock,disableExtensions:i.disableExtensions,setIdAttribute:i.setIdAttribute,animations:i.animations??!0,tableHandles:N("table",this),dropCursor:this.options.dropCursor??Hi.dropCursor,placeholders:i.placeholders,tabBehavior:i.tabBehavior,sideMenuDetection:i.sideMenuDetection||"viewport"}),(((s=i._tiptapOptions)==null?void 0:s.extensions)||[]).forEach(g=>{this.extensions[g.name]=g}),Object.entries(i._extensions||{}).forEach(([g,b])=>{typeof b=="function"&&(b=b(this)),this.extensions[g]=b}),this.formattingToolbar=this.extensions.formattingToolbar,this.linkToolbar=this.extensions.linkToolbar,this.sideMenu=this.extensions.sideMenu,this.suggestionMenus=this.extensions.suggestionMenus,this.filePanel=this.extensions.filePanel,this.tableHandles=this.extensions.tableHandles,i.uploadFile){const g=i.uploadFile;this.uploadFile=async(b,y)=>{this.onUploadStartCallbacks.forEach(v=>v.apply(this,[y]));try{return await g(b,y)}finally{this.onUploadEndCallbacks.forEach(v=>v.apply(this,[y]))}}}this.resolveFileUrl=i.resolveFileUrl,this.headless=i._headless,i.collaboration&&i.initialContent&&console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider");const n=i.initialContent||(t.collaboration?[{type:"paragraph",id:"initialBlockId"}]:[{type:"paragraph",id:J.options.generateID()}]);if(!Array.isArray(n)||n.length===0)throw new Error("initialContent must be a non-empty array of blocks, received: "+n);const a=[...Object.entries(this.extensions).map(([g,b])=>{if(b instanceof k.Extension||b instanceof k.Node||b instanceof k.Mark)return b;if(!b.plugin)throw new Error("Extension should either be a TipTap extension or a ProseMirror plugin in a plugin property");return k.Extension.create({name:g,addProseMirrorPlugins:()=>[b.plugin]})})],r={...ar,...i._tiptapOptions,content:n,extensions:a,editorProps:{...(l=i._tiptapOptions)==null?void 0:l.editorProps,attributes:{tabIndex:"0",...(u=(c=i._tiptapOptions)==null?void 0:c.editorProps)==null?void 0:u.attributes,...(p=i.domAttributes)==null?void 0:p.editor,class:$("bn-editor",i.defaultStyles?"bn-default-styles":"",((f=(m=i.domAttributes)==null?void 0:m.editor)==null?void 0:f.class)||"")},transformPasted:ir}};this.headless?this._pmSchema=k.getSchema(r.extensions):(this._tiptapEditor=Ee.create(r,this.schema.styleSchema),this._pmSchema=this._tiptapEditor.schema)}get pmSchema(){return this._pmSchema}static create(t={}){return new rt(t)}dispatch(t){this._tiptapEditor.dispatch(t)}get prosemirrorView(){return this._tiptapEditor.view}get domElement(){var t;return(t=this.prosemirrorView)==null?void 0:t.dom}isFocused(){var t;return((t=this.prosemirrorView)==null?void 0:t.hasFocus())||!1}focus(){var t;(t=this.prosemirrorView)==null||t.focus()}onUploadStart(t){return this.onUploadStartCallbacks.push(t),()=>{const o=this.onUploadStartCallbacks.indexOf(t);o>-1&&this.onUploadStartCallbacks.splice(o,1)}}onUploadEnd(t){return this.onUploadEndCallbacks.push(t),()=>{const o=this.onUploadEndCallbacks.indexOf(t);o>-1&&this.onUploadEndCallbacks.splice(o,1)}}get topLevelBlocks(){return this.document}get document(){const t=[];return this._tiptapEditor.state.doc.firstChild.descendants(o=>(t.push(S(o,this.schema.blockSchema,this.schema.inlineContentSchema,this.schema.styleSchema,this.blockCache)),!1)),t}getBlock(t){return ia(this,t)}getPrevBlock(t){return na(this,t)}getNextBlock(t){return aa(this,t)}getParentBlock(t){return ra(this,t)}forEachBlock(t,o=!1){const i=this.document.slice();o&&i.reverse();function n(a){for(const r of a){if(t(r)===!1)return!1;const s=o?r.children.slice().reverse():r.children;if(!n(s))return!1}return!0}n(i)}onEditorContentChange(t){this._tiptapEditor.on("update",t)}onEditorSelectionChange(t){this._tiptapEditor.on("selectionUpdate",t)}getTextCursorPosition(){return ca(this)}setTextCursorPosition(t,o="start"){Ho(this,t,o)}getSelection(){return la(this)}setSelection(t,o){da(this,t,o)}get isEditable(){if(!this._tiptapEditor){if(!this.headless)throw new Error("no editor, but also not headless?");return!1}return this._tiptapEditor.isEditable===void 0?!0:this._tiptapEditor.isEditable}set isEditable(t){if(!this._tiptapEditor){if(!this.headless)throw new Error("no editor, but also not headless?");return}this._tiptapEditor.options.editable!==t&&this._tiptapEditor.setEditable(t)}insertBlocks(t,o,i="before"){return Kn(this,t,o,i)}updateBlock(t,o){return io(this,t,o)}removeBlocks(t){return oa(this,t)}replaceBlocks(t,o){return ta(this,t,o)}insertInlineContent(t){const o=H(t,this.pmSchema,this.schema.styleSchema);sa({from:this._tiptapEditor.state.selection.from,to:this._tiptapEditor.state.selection.to},o,this)}getActiveStyles(){const t={},o=this._tiptapEditor.state.selection.$to.marks();for(const i of o){const n=this.schema.styleSchema[i.type.name];if(!n){i.type.name!=="link"&&console.warn("mark not found in styleschema",i.type.name);continue}n.propSchema==="boolean"?t[n.type]=!0:t[n.type]=i.attrs.stringValue}return t}addStyles(t){for(const[o,i]of Object.entries(t)){const n=this.schema.styleSchema[o];if(!n)throw new Error(`style ${o} not found in styleSchema`);if(n.propSchema==="boolean")this._tiptapEditor.commands.setMark(o);else if(n.propSchema==="string")this._tiptapEditor.commands.setMark(o,{stringValue:i});else throw new j(n.propSchema)}}removeStyles(t){for(const o of Object.keys(t))this._tiptapEditor.commands.unsetMark(o)}toggleStyles(t){for(const[o,i]of Object.entries(t)){const n=this.schema.styleSchema[o];if(!n)throw new Error(`style ${o} not found in styleSchema`);if(n.propSchema==="boolean")this._tiptapEditor.commands.toggleMark(o);else if(n.propSchema==="string")this._tiptapEditor.commands.toggleMark(o,{stringValue:i});else throw new j(n.propSchema)}}getSelectedText(){return this._tiptapEditor.state.doc.textBetween(this._tiptapEditor.state.selection.from,this._tiptapEditor.state.selection.to)}getSelectedLinkUrl(){return this._tiptapEditor.getAttributes("link").href}createLink(t,o){if(t==="")return;const{from:i,to:n}=this._tiptapEditor.state.selection;o||(o=this._tiptapEditor.state.doc.textBetween(i,n));const a=this.pmSchema.mark("link",{href:t});this.dispatch(this._tiptapEditor.state.tr.insertText(o,i,n).addMark(i,i+o.length,a))}canNestBlock(){return Qn(this)}nestBlock(){Do(this)}canUnnestBlock(){return ea(this)}unnestBlock(){Yn(this)}moveBlocksUp(){Xn(this)}moveBlocksDown(){Zn(this)}async blocksToHTMLLossy(t=this.document){return de(this.pmSchema,this).exportBlocks(t,{})}async blocksToFullHTML(t){return _t(this.pmSchema,this).serializeBlocks(t,{})}async tryParseHTMLToBlocks(t){return tt(t,this.schema.blockSchema,this.schema.inlineContentSchema,this.schema.styleSchema,this.pmSchema)}async blocksToMarkdownLossy(t=this.document){return Oo(t,this.pmSchema,this,{})}async tryParseMarkdownToBlocks(t){return Vo(t,this.schema.blockSchema,this.schema.inlineContentSchema,this.schema.styleSchema,this.pmSchema)}updateCollaborationUserInfo(t){if(!this.options.collaboration)throw new Error("Cannot update collaboration user info when collaboration is disabled.");this._tiptapEditor.commands.updateUser(t)}onChange(t){if(this.headless)return;const o=()=>{t(this)};return this._tiptapEditor.on("update",o),()=>{this._tiptapEditor.off("update",o)}}onSelectionChange(t){if(this.headless)return;const o=()=>{t(this)};return this._tiptapEditor.on("selectionUpdate",o),()=>{this._tiptapEditor.off("selectionUpdate",o)}}openSuggestionMenu(t,o){var a;const i=(a=this.prosemirrorView)==null?void 0:a.state.tr;if(!i)return;const n=o&&o.deleteTriggerCharacter?i.insertText(t):i;this.prosemirrorView.focus(),this.prosemirrorView.dispatch(n.scrollIntoView().setMeta(this.suggestionMenus.plugin,{triggerCharacter:t,deleteTriggerCharacter:(o==null?void 0:o.deleteTriggerCharacter)||!1,ignoreQueryLength:(o==null?void 0:o.ignoreQueryLength)||!1}))}}const rr={gray:{text:"#9b9a97",background:"#ebeced"},brown:{text:"#64473a",background:"#e9e5e3"},red:{text:"#e03e3e",background:"#fbe4e4"},orange:{text:"#d9730d",background:"#f6e9d9"},yellow:{text:"#dfab01",background:"#fbf3db"},green:{text:"#4d6461",background:"#ddedea"},blue:{text:"#0b6e99",background:"#ddebf1"},purple:{text:"#6940a5",background:"#eae4f2"},pink:{text:"#ad1a72",background:"#f4dfeb"}},sr={gray:{text:"#bebdb8",background:"#9b9a97"},brown:{text:"#8e6552",background:"#64473a"},red:{text:"#ec4040",background:"#be3434"},orange:{text:"#e3790d",background:"#b7600a"},yellow:{text:"#dfab01",background:"#b58b00"},green:{text:"#6b8b87",background:"#4d6461"},blue:{text:"#0e87bc",background:"#0b6e99"},purple:{text:"#8552d7",background:"#6940a5"},pink:{text:"#da208f",background:"#ad1a72"}};class lr{constructor(t,o,i){this.mappings=o,this.options=i}async resolveFile(t){var i;if(!((i=this.options)!=null&&i.resolveFileUrl))return(await fetch(t)).blob();const o=await this.options.resolveFileUrl(t);return o instanceof Blob?o:(await fetch(o)).blob()}mapStyles(t){return Object.entries(t).map(([i,n])=>this.mappings.styleMapping[i](n,this))}mapInlineContent(t){return this.mappings.inlineContentMapping[t.type](t,this)}transformInlineContent(t){return t.map(o=>this.mapInlineContent(o))}async mapBlock(t,o,i){return this.mappings.blockMapping[t.type](t,this,o,i)}}function dr(e){return{createBlockMapping:t=>t,createInlineContentMapping:t=>t,createStyleMapping:t=>t}}let Te,st;async function cr(e,t){if(!Eo("text",e))return[];if(!Te){Te=import("@emoji-mart/data"),st=await import("emoji-mart");const n=(await Te).default;await st.init({data:n})}const o=(await Te).default;return(t.trim()===""?Object.values(o.emojis):await st.SearchIndex.search(t)).map(n=>({id:n.skins[0].native,onItemClick:()=>e.insertInlineContent(n.skins[0].native+" ")}))}function ur(e,...t){const o=[...e];for(const i of t)for(const n of i){const a=o.findLastIndex(r=>r.group===n.group);a===-1?o.push(n):o.splice(a+1,0,n)}return o}function lt(e=""){return typeof e=="string"?[{type:"text",text:e,styles:{}}]:e}function ge(e){return typeof e=="string"?lt(e):Array.isArray(e)?e.flatMap(t=>typeof t=="string"?lt(t):Ae(t)?{...t,content:lt(t.content)}:Y(t)?t:{props:{},...t,content:ge(t.content)}):(e==null?void 0:e.type)==="tableContent"?{type:"tableContent",columnWidths:e.columnWidths,rows:e.rows.map(t=>({...t,cells:t.cells.map(o=>ge(o))}))}:e}function pr(e,t){return t.map(o=>dt(e.blockSchema,o))}function dt(e,t){var n;const o=e[t.type].content,i={id:"",type:t.type,props:{},content:o==="inline"?[]:o==="table"?{type:"tableContent",columnWidths:[],rows:[]}:void 0,children:[],...t};if(Object.entries(e[t.type].propSchema).forEach(([a,r])=>{i.props[a]===void 0&&r.default!==void 0&&(i.props[a]=r.default)}),o==="inline"){const a=i.content;i.content=ge(a)}else if(o==="table"){const a=i.content;i.content={type:"tableContent",columnWidths:(a==null?void 0:a.columnWidths)||((n=a==null?void 0:a.rows[0])==null?void 0:n.cells.map(()=>{}))||[],rows:(a==null?void 0:a.rows.map(r=>({cells:r.cells.map(s=>ge(s))})))||[]}}return{...i,content:ge(i.content),children:i.children.map(a=>dt(e,a))}}function gi(e){e.id||(e.id=J.options.generateID()),e.children&&bi(e.children)}function bi(e){for(const t of e)gi(t)}d.AudioBlock=Vt,d.BlockNoteEditor=rt,d.BlockNoteSchema=oe,d.COLORS_DARK_MODE_DEFAULT=sr,d.COLORS_DEFAULT=rr,d.CodeBlock=Gt,d.DEFAULT_LINK_PROTOCOL=ii,d.EMPTY_CELL_HEIGHT=In,d.EMPTY_CELL_WIDTH=qe,d.Exporter=lr,d.FILE_AUDIO_ICON_SVG=Dt,d.FILE_ICON_SVG=Pt,d.FILE_IMAGE_ICON_SVG=ro,d.FILE_VIDEO_ICON_SVG=ko,d.FileBlock=to,d.FilePanelProsemirrorPlugin=Wo,d.FilePanelView=Ko,d.FormattingToolbarProsemirrorPlugin=Zo,d.FormattingToolbarView=qo,d.HTMLToBlocks=tt,d.ImageBlock=ho,d.LinkToolbarProsemirrorPlugin=ti,d.PageBreak=Xt,d.SideMenuProsemirrorPlugin=ci,d.SideMenuView=li,d.SuggestionMenuProseMirrorPlugin=ui,d.TableHandlesProsemirrorPlugin=mi,d.TableHandlesView=hi,d.UniqueID=J,d.UnreachableCaseError=j,d.VALID_LINK_PROTOCOLS=oi,d.VideoBlock=xo,d.addIdsToBlock=gi,d.addIdsToBlocks=bi,d.addInlineContentAttributes=Re,d.addInlineContentKeyboardShortcuts=xt,d.addStyleAttributes=It,d.applyNonSelectableBlockFix=wt,d.assertEmpty=Xi,d.audioBlockConfig=Ht,d.audioParse=Ut,d.audioPropSchema=jt,d.audioRender=Ot,d.audioToExternalHTML=Rt,d.blockToNode=q,d.blocksToMarkdown=Oo,d.camelToDataKebab=ce,d.checkBlockHasDefaultProp=Un,d.checkBlockIsDefaultType=To,d.checkBlockIsFileBlock=jn,d.checkBlockIsFileBlockWithPlaceholder=On,d.checkBlockIsFileBlockWithPreview=Hn,d.checkBlockTypeHasDefaultProp=Io,d.checkDefaultBlockTypeInSchema=N,d.checkDefaultInlineContentTypeInSchema=Eo,d.checkPageBreakBlocksInSchema=Mo,d.cleanHTMLToMarkdown=Se,d.combineByGroup=ur,d.contentNodeToInlineContent=pe,d.contentNodeToTableContent=Ue,d.createAddFileButton=Lt,d.createBlockSpec=te,d.createBlockSpecFromStronglyTypedTiptapNode=W,d.createDefaultBlockDOMOutputSpec=R,d.createExternalHTMLExporter=de,d.createFigureWithCaption=ve,d.createFileBlockWrapper=ye,d.createFileNameWithIcon=At,d.createInlineContentSpec=rn,d.createInlineContentSpecFromTipTapNode=Bt,d.createInternalBlockSpec=He,d.createInternalHTMLSerializer=_t,d.createInternalInlineContentSpec=St,d.createInternalStyleSpec=ze,d.createLinkWithCaption=me,d.createResizableFileBlockWrapper=Ke,d.createStronglyTypedTiptapNode=K,d.createStyleSpec=sn,d.createStyleSpecFromTipTapMark=X,d.createSuggestionMenu=za,d.customizeCodeBlock=ln,d.defaultBlockSchema=So,d.defaultBlockSpecs=Xe,d.defaultBlockToHTML=De,d.defaultCodeBlockPropSchema=Ce,d.defaultInlineContentSchema=Bo,d.defaultInlineContentSpecs=Je,d.defaultProps=B,d.defaultStyleSchema=Dn,d.defaultStyleSpecs=Ze,d.fileBlockConfig=Jt,d.fileParse=Qt,d.filePropSchema=Zt,d.fileRender=Yt,d.fileToExternalHTML=eo,d.filenameFromURL=an,d.filterSuggestionItems=zn,d.formatKeyboardShortcut=G,d.formattingToolbarPluginKey=Xo,d.getBlockFromPos=vt,d.getBlockInfo=F,d.getBlockInfoFromResolvedPos=Q,d.getBlockInfoFromSelection=C,d.getBlockInfoWithManualOffset=ke,d.getBlockNoteExtensions=fi,d.getBlockSchemaFromSpecs=Oe,d.getDefaultEmojiPickerItems=cr,d.getDefaultSlashMenuItems=Vn,d.getInlineContentParseRules=Et,d.getInlineContentSchemaFromSpecs=Ve,d.getNearestBlockPos=z,d.getNodeById=A,d.getPageBreakSlashMenuItems=Gn,d.getParseRules=Ct,d.getStyleParseRules=Mt,d.getStyleSchemaFromSpecs=Fe,d.imageBlockConfig=lo,d.imageParse=uo,d.imagePropSchema=so,d.imageRender=co,d.imageToExternalHTML=po,d.inheritedProps=je,d.initializeESMDependencies=xe,d.inlineContentToNodes=H,d.insertOrUpdateBlock=L,d.isAppleOS=yt,d.isLinkInlineContent=Pe,d.isPartialLinkInlineContent=Ae,d.isSafari=nn,d.isStyledTextInlineContent=Y,d.linkToolbarPluginKey=ei,d.locales=qi,d.mappingFactory=dr,d.markdownToBlocks=Vo,d.mergeCSSClasses=$,d.nodeToBlock=S,d.nodeToCustomInlineContent=_e,d.pageBreakConfig=$t,d.pageBreakParse=Wt,d.pageBreakRender=Kt,d.pageBreakSchema=Qe,d.pageBreakToExternalHTML=qt,d.parseEmbedElement=$e,d.parseFigureElement=he,d.partialBlockToBlockForTesting=dt,d.partialBlocksToBlocksForTesting=pr,d.propsToAttributes=ee,d.shikiHighlighterPromiseSymbol=we,d.shikiParserSymbol=Ge,d.sideMenuPluginKey=di,d.stylePropsToAttributes=Tt,d.tableContentToNodes=le,d.tableHandlesPluginKey=re,d.updateBlock=io,d.updateBlockCommand=T,d.uploadToTmpFilesDotOrg_DEV_ONLY=$n,d.videoBlockConfig=yo,d.videoParse=wo,d.videoPropSchema=_o,d.videoRender=vo,d.videoToExternalHTML=Co,d.withPageBreak=Fn,d.wrapInBlockStructure=ue,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
|
11
11
|
//# sourceMappingURL=blocknote.umd.cjs.map
|