@blocknote/core 0.17.0 → 0.17.1

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.
@@ -4,5 +4,5 @@
4
4
  `;else throw new Error("unexpected");else n={type:"text",text:`
5
5
  `,styles:{}};return}if(a.type.name!=="link"&&a.type.name!=="text"&&t[a.type.name]){n&&(i.push(n),n=void 0),i.push(fe(a,t,o));return}const r={};let l;for(const s of a.marks)if(s.type.name==="link")l=s;else{const c=o[s.type.name];if(!c)throw new Error(`style ${s.type.name} not found in styleSchema`);if(c.propSchema==="boolean")r[c.type]=!0;else if(c.propSchema==="string")r[c.type]=s.attrs.stringValue;else throw new N(c.propSchema)}n?X(n)?l?(i.push(n),n={type:"link",href:l.attrs.href,content:[{type:"text",text:a.textContent,styles:r}]}):JSON.stringify(n.styles)===JSON.stringify(r)?n.text+=a.textContent:(i.push(n),n={type:"text",text:a.textContent,styles:r}):Se(n)&&(l?n.href===l.attrs.href?JSON.stringify(n.content[n.content.length-1].styles)===JSON.stringify(r)?n.content[n.content.length-1].text+=a.textContent:n.content.push({type:"text",text:a.textContent,styles:r}):(i.push(n),n={type:"link",href:l.attrs.href,content:[{type:"text",text:a.textContent,styles:r}]}):(i.push(n),n={type:"text",text:a.textContent,styles:r})):l?n={type:"link",href:l.attrs.href,content:[{type:"text",text:a.textContent,styles:r}]}:n={type:"text",text:a.textContent,styles:r}}),n&&i.push(n),i}function fe(e,t,o){if(e.type.name==="text"||e.type.name==="link")throw new Error("unexpected");const i={},n=t[e.type.name];for(const[l,s]of Object.entries(e.attrs)){if(!n)throw Error("ic node is of an unrecognized type: "+e.type.name);const c=n.propSchema;l in c&&(i[l]=s)}let a;return n.content==="styled"?a=de(e,t,o):a=void 0,{type:e.type.name,props:i,content:a}}function x(e,t,o,i,n){if(e.type.name!=="blockContainer")throw Error("Node must be of type blockContainer, but is of type"+e.type.name+".");const a=n==null?void 0:n.get(e);if(a)return a;const{blockContainer:r,blockContent:l,blockGroup:s}=me(e,0);let c=r.node.attrs.id;c===null&&(c=Z.options.generateID());const p={};for(const[k,w]of Object.entries({...e.attrs,...l.node.attrs})){const T=t[l.node.type.name];if(!T)throw Error("Block is of an unrecognized type: "+l.node.type.name);const E=T.propSchema;k in E&&(p[k]=w)}const h=t[l.node.type.name],m=[];s==null||s.node.forEach(k=>{m.push(x(k,t,o,i,n))});let g;if(h.content==="inline")g=de(l.node,o,i);else if(h.content==="table")g=Ne(l.node,o,i);else if(h.content==="none")g=void 0;else throw new N(h.content);const f={id:c,type:h.type,props:p,content:g,children:m};return n==null||n.set(e,f),f}function je(e,t,o,i){return e.dom.setAttribute("data-inline-content-type",t),Object.entries(o).filter(([n,a])=>a!==i[n].default).map(([n,a])=>[re(n),a]).forEach(([n,a])=>e.dom.setAttribute(n,a)),e.contentDOM!==void 0&&e.contentDOM.setAttribute("data-editable",""),e}function mt(e){return{Backspace:({editor:t})=>{const o=t.state.selection.$from;return t.state.selection.empty&&o.node().type.name===e.type&&o.parentOffset===0}}}function ft(e,t){return{config:e,implementation:t}}function gt(e,t){return ft({type:e.name,propSchema:t,content:e.config.content==="inline*"?"styled":"none"},{node:e})}function He(e){return Object.fromEntries(Object.entries(e).map(([t,o])=>[t,o.config]))}function bt(e){return[{tag:`[data-inline-content-type="${e.type}"]`,contentElement:t=>{const o=t;return o.matches("[data-editable]")?o:o.querySelector("[data-editable]")||o}}]}function yi(e,t){const o=b.Node.create({name:e.type,inline:!0,group:"inline",selectable:e.content==="styled",atom:e.content==="none",content:e.content==="styled"?"inline*":"",addAttributes(){return Ie(e.propSchema)},addKeyboardShortcuts(){return mt(e)},parseHTML(){return bt(e)},renderHTML({node:i}){const n=this.options.editor,a=t.render(fe(i,n.schema.inlineContentSchema,n.schema.styleSchema),()=>{},n);return je(a,e.type,i.attrs,e.propSchema)},addNodeView(){return({node:i,getPos:n})=>{const a=this.options.editor,r=t.render(fe(i,a.schema.inlineContentSchema,a.schema.styleSchema),l=>{if(typeof n=="boolean")return;const s=j([l],a._tiptapEditor.schema,a.schema.styleSchema);a._tiptapEditor.view.dispatch(a._tiptapEditor.view.state.tr.replaceWith(n(),n()+i.nodeSize,s))},a);return je(r,e.type,i.attrs,e.propSchema)}}});return gt(o,e.propSchema)}function kt(e){return e==="boolean"?{}:{stringValue:{default:void 0,keepOnSplit:!0,parseHTML:t=>t.getAttribute("data-value"),renderHTML:t=>t.stringValue!==void 0?{"data-value":t.stringValue}:{}}}}function _t(e,t,o,i){return e.dom.setAttribute("data-style-type",t),i==="string"&&e.dom.setAttribute("data-value",o),e.contentDOM!==void 0&&e.contentDOM.setAttribute("data-editable",""),e}function De(e,t){return{config:e,implementation:t}}function F(e,t){return De({type:e.name,propSchema:t},{mark:e})}function Ue(e){return Object.fromEntries(Object.entries(e).map(([t,o])=>[t,o.config]))}function yt(e){return[{tag:`[data-style-type="${e.type}"]`,contentElement:t=>{const o=t;return o.matches("[data-editable]")?o:o.querySelector("[data-editable]")||o}}]}function vi(e,t){const o=b.Mark.create({name:e.type,addAttributes(){return kt(e.propSchema)},parseHTML(){return yt(e)},renderHTML({mark:i}){let n;if(e.propSchema==="boolean")n=t.render();else if(e.propSchema==="string")n=t.render(i.attrs.stringValue);else throw new N(e.propSchema);return _t(n,e.type,i.attrs.stringValue,e.propSchema)}});return De(e,{mark:o})}const ce=(e,t,o,i,n)=>{const a=document.createElement("div");if(a.className="bn-file-block-content-wrapper",e.props.url===""){const r=vt(e,t,i,n);a.appendChild(r.dom);const l=document.createElement("div");l.className="bn-file-loading-preview",l.textContent="Loading...";const s=t.onUploadStart(p=>{p===e.id&&(a.removeChild(r.dom),a.appendChild(l))}),c=t.onUploadEnd(p=>{p===e.id&&(a.removeChild(l),a.appendChild(r.dom))});return{dom:a,destroy:()=>{var p;(p=r.destroy)==null||p.call(r),s(),c()}}}else if(e.props.showPreview===!1){const r=ze(e).dom;return{dom:J(e,r).dom}}else return a.appendChild(o.dom),{dom:a,destroy:o.destroy}},ze=e=>{const t=document.createElement("div");t.className="bn-file-default-preview";const o=document.createElement("div");o.className="bn-file-default-preview-icon",o.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z"></path></svg>';const i=document.createElement("p");return i.className="bn-file-default-preview-name",i.textContent=e.props.name||"",t.appendChild(o),t.appendChild(i),{dom:t}},J=(e,t)=>{const o=document.createElement("div");o.className="bn-file-and-caption-wrapper";const i=document.createElement("p");return i.className="bn-file-caption",i.textContent=e.props.caption,o.appendChild(t),o.appendChild(i),{dom:o}},vt=(e,t,o,i)=>{const n=document.createElement("div");n.className="bn-add-file-button";const a=document.createElement("div");a.className="bn-add-file-button-icon",i?a.appendChild(i):a.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z"></path></svg>';const r=document.createElement("p");r.className="bn-add-file-button-text",r.innerHTML=o||t.dictionary.file_blocks.file.add_button_text;const l=c=>{c.preventDefault()},s=()=>{t.dispatch(t._tiptapEditor.state.tr.setMeta(t.filePanel.plugin,{block:e}))};return n.appendChild(a),n.appendChild(r),n.addEventListener("mousedown",l,!0),n.addEventListener("click",s,!0),{dom:n,destroy:()=>{n.removeEventListener("mousedown",l,!0),n.removeEventListener("click",s,!0)}}},Oe=e=>({url:e.src||void 0}),ue=(e,t)=>{const o=e.querySelector(t);if(!o)return;const i=e.querySelector("figcaption"),n=(i==null?void 0:i.textContent)??void 0;return{targetElement:o,caption:n}},pe=(e,t)=>{const o=document.createElement("div"),i=document.createElement("p");return i.textContent=t,o.appendChild(e),o.appendChild(i),{dom:o}},ge=(e,t)=>{const o=document.createElement("figure"),i=document.createElement("figcaption");return i.textContent=t,o.appendChild(e),o.appendChild(i),{dom:o}},Re=(e,t,o,i,n)=>{if(!e.props.previewWidth)throw new Error("Block must have a `previewWidth` prop.");const a=document.createElement("div");a.className="bn-visual-media-wrapper";const r=document.createElement("div");r.className="bn-visual-media-resize-handle",r.style.left="4px";const l=document.createElement("div");l.className="bn-visual-media-resize-handle",l.style.right="4px";let s;const c=k=>{if(!s){!t.isEditable&&a.contains(r)&&a.contains(l)&&(a.removeChild(r),a.removeChild(l));return}let w;e.props.textAlignment==="center"?s.handleUsed==="left"?w=s.initialWidth+(s.initialClientX-k.clientX)*2:w=s.initialWidth+(k.clientX-s.initialClientX)*2:s.handleUsed==="left"?w=s.initialWidth+s.initialClientX-k.clientX:w=s.initialWidth+k.clientX-s.initialClientX;const T=64;w<T?n(T):w>t.domElement.firstElementChild.clientWidth?n(t.domElement.firstElementChild.clientWidth):n(w)},p=k=>{(!k.target||!a.contains(k.target)||!t.isEditable)&&a.contains(r)&&a.contains(l)&&(a.removeChild(r),a.removeChild(l)),s&&(s=void 0,t.updateBlock(e,{props:{previewWidth:i()}}))},h=()=>{t.isEditable&&(a.appendChild(r),a.appendChild(l))},m=k=>{k.relatedTarget===r||k.relatedTarget===l||s||t.isEditable&&a.contains(r)&&a.contains(l)&&(a.removeChild(r),a.removeChild(l))},g=k=>{k.preventDefault(),a.appendChild(r),a.appendChild(l),s={handleUsed:"left",initialWidth:e.props.previewWidth,initialClientX:k.clientX}},f=k=>{k.preventDefault(),a.appendChild(r),a.appendChild(l),s={handleUsed:"right",initialWidth:e.props.previewWidth,initialClientX:k.clientX}};return a.appendChild(o),window.addEventListener("mousemove",c),window.addEventListener("mouseup",p),o.addEventListener("mouseenter",h),o.addEventListener("mouseleave",m),r.addEventListener("mousedown",g),l.addEventListener("mousedown",f),{dom:a,destroy:()=>{window.removeEventListener("mousemove",c),window.removeEventListener("mouseup",p),o.removeEventListener("mouseenter",h),o.removeEventListener("mouseleave",m),r.removeEventListener("mousedown",g),l.removeEventListener("mousedown",f)}}},wt=e=>({url:e.src||void 0}),Ct={backgroundColor:C.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0}},Et={type:"audio",propSchema:Ct,content:"none",isFileBlock:!0,fileBlockAccept:["audio/*"]},xt=(e,t)=>{const o=document.createElement("div");o.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z"></path></svg>';const i=document.createElement("audio");i.className="bn-audio",t.resolveFileUrl(e.props.url).then(a=>{i.src=a}),i.controls=!0,i.contentEditable="false",i.draggable=!1;const n=J(e,i);return ce(e,t,n,t.dictionary.file_blocks.audio.add_button_text,o.firstElementChild)},St=e=>{if(e.tagName==="AUDIO")return wt(e);if(e.tagName==="FIGURE"){const t=ue(e,"audio");if(!t)return;const{targetElement:o,caption:i}=t;return{...wt(o),caption:i}}},Tt=e=>{if(!e.props.url){const o=document.createElement("p");return o.textContent="Add audio",{dom:o}}let t;return e.props.showPreview?(t=document.createElement("audio"),t.src=e.props.url):(t=document.createElement("a"),t.href=e.props.url,t.textContent=e.props.name||e.props.url),e.props.caption?e.props.showPreview?ge(t,e.props.caption):pe(t,e.props.caption):{dom:t}},Mt=se(Et,{render:xt,parse:St,toExternalHTML:Tt}),Bt={backgroundColor:C.backgroundColor,name:{default:""},url:{default:""},caption:{default:""}},Lt={type:"file",propSchema:Bt,content:"none",isFileBlock:!0},It=(e,t)=>{const o=ze(e).dom,i=J(e,o);return ce(e,t,i)},Pt=e=>{if(e.tagName==="EMBED")return Oe(e);if(e.tagName==="FIGURE"){const t=ue(e,"embed");if(!t)return;const{targetElement:o,caption:i}=t;return{...Oe(o),caption:i}}},At=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?pe(t,e.props.caption):{dom:t}},Nt=se(Lt,{render:It,parse:Pt,toExternalHTML:At}),wi=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/")},Ve=e=>{const t=e.src||void 0,o=e.width||void 0;return{url:t,previewWidth:o}},jt={textAlignment:C.textAlignment,backgroundColor:C.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0},previewWidth:{default:512}},Ht={type:"image",propSchema:jt,content:"none",isFileBlock:!0,fileBlockAccept:["image/*"]},Dt=(e,t)=>{const o=document.createElement("div");o.innerHTML='<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>';const i=document.createElement("img");i.className="bn-visual-media",t.resolveFileUrl(e.props.url).then(r=>{i.src=r}),i.alt=e.props.name||e.props.caption||"BlockNote image",i.contentEditable="false",i.draggable=!1,i.width=Math.min(e.props.previewWidth,t.domElement.firstElementChild.clientWidth);const n=Re(e,t,i,()=>i.width,r=>i.width=r),a=J(e,n.dom);return ce(e,t,a,t.dictionary.file_blocks.image.add_button_text,o.firstElementChild)},Ut=e=>{if(e.tagName==="IMG")return Ve(e);if(e.tagName==="FIGURE"){const t=ue(e,"img");if(!t)return;const{targetElement:o,caption:i}=t;return{...Ve(o),caption:i}}},zt=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?ge(t,e.props.caption):pe(t,e.props.caption):{dom:t}},Ot=se(Ht,{render:Dt,parse:Ut,toExternalHTML:zt}),Rt=e=>{const t=e.src||void 0,o=e.width||void 0;return{url:t,previewWidth:o}},Vt={textAlignment:C.textAlignment,backgroundColor:C.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0},previewWidth:{default:512}},Ft={type:"video",propSchema:Vt,content:"none",isFileBlock:!0,fileBlockAccept:["video/*"]},Kt=(e,t)=>{const o=document.createElement("div");o.innerHTML='<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>';const i=document.createElement("video");i.className="bn-visual-media",i.src=e.props.url,i.controls=!0,i.contentEditable="false",i.draggable=!1,i.width=Math.min(e.props.previewWidth,t.domElement.firstElementChild.clientWidth);const n=Re(e,t,i,()=>i.width,r=>i.width=r),a=J(e,n.dom);return ce(e,t,a,t.dictionary.file_blocks.video.add_button_text,o.firstElementChild)},Gt=e=>{if(e.tagName==="VIDEO")return Rt(e);if(e.tagName==="FIGURE"){const t=ue(e,"video");if(!t)return;const{targetElement:o,caption:i}=t;return{...Rt(o),caption:i}}},qt=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?ge(t,e.props.caption):pe(t,e.props.caption):{dom:t}},Wt=se(Ft,{render:Kt,parse:Gt,toExternalHTML:qt}),Ci=b.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]}}),Ei=F(Ci,"string"),xi=b.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]}}),Si=F(xi,"string");function be(e,t){let o,i;if(t.firstChild.descendants((n,a)=>o?!1:n.type.name!=="blockContainer"||n.attrs.id!==e?!0:(o=n,i=a+1,!1)),o===void 0||i===void 0)throw Error("Could not find block in the editor with matching ID.");return{node:o,posBeforeNode:i}}const S=(e,t,o)=>({state:i,dispatch:n})=>{const{blockContainer:a,blockContent:r,blockGroup:l}=U(i.doc.resolve(t));if(n){if(o.children!==void 0){const h=[];for(const m of o.children)h.push(q(m,i.schema,e.schema.styleSchema));l?i.tr.replace(l.beforePos+1,l.afterPos-1,new y.Slice(y.Fragment.from(h),0,0)):i.tr.insert(r.afterPos,i.schema.nodes.blockGroup.create({},h))}const s=r.node.type.name,c=o.type||s;let p="keep";if(o.content)if(typeof o.content=="string")p=j([o.content],i.schema,e.schema.styleSchema);else if(Array.isArray(o.content))p=j(o.content,i.schema,e.schema.styleSchema);else if(o.content.type==="tableContent")p=ie(o.content,i.schema,e.schema.styleSchema);else throw new N(o.content.type);else{const h=i.schema.nodes[s].spec.content,m=i.schema.nodes[c].spec.content;h===""||m!==h&&(p=[])}p==="keep"?i.tr.setNodeMarkup(r.beforePos,o.type===void 0?void 0:i.schema.nodes[o.type],{...r.node.attrs,...o.props}):i.tr.replaceWith(r.beforePos,r.afterPos,i.schema.nodes[c].create({...r.node.attrs,...o.props},p)),i.tr.setNodeMarkup(a.beforePos,void 0,{...a.node.attrs,...o.props})}return!0};function Ti(e,t,o){const i=e._tiptapEditor,n=typeof t=="string"?t:t.id,{posBeforeNode:a}=be(n,i.state.doc);i.commands.command(({state:l,dispatch:s})=>(S(e,a,o)({state:l,dispatch:s}),!0));const r=i.state.doc.resolve(a+1).node();return x(r,e.schema.blockSchema,e.schema.inlineContentSchema,e.schema.styleSchema,e.blockCache)}const Mi={...C,level:{default:1,values:[1,2,3]}},Bi=V({name:"heading",content:"inline*",group:"blockContent",addAttributes(){return{level:{default:1,parseHTML:e=>{const t=e.getAttribute("data-level"),o=parseInt(t);if(isFinite(o))return o},renderHTML:e=>({"data-level":e.level.toString()})}}},addInputRules(){return[...[1,2,3].map(e=>new b.InputRule({find:new RegExp(`^(#{${e}})\\s$`),handler:({state:t,chain:o,range:i})=>{const n=v(t);n.blockContent.node.type.spec.content==="inline*"&&o().command(S(this.options.editor,n.blockContainer.beforePos,{type:"heading",props:{level:e}})).deleteRange({from:i.from,to:i.to}).run()}}))]},addKeyboardShortcuts(){return{"Mod-Alt-1":()=>{const e=v(this.editor.state);return e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(S(this.options.editor,e.blockContainer.beforePos,{type:"heading",props:{level:1}}))},"Mod-Alt-2":()=>{const e=v(this.editor.state);return e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(S(this.options.editor,e.blockContainer.beforePos,{type:"heading",props:{level:2}}))},"Mod-Alt-3":()=>{const e=v(this.editor.state);return e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(S(this.options.editor,e.blockContainer.beforePos,{type:"heading",props:{level:3}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",getAttrs:e=>typeof e=="string"?!1:{level:e.getAttribute("data-level")}},{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)||{})}}),Li=$(Bi,Mi),$t=(e,t,o)=>({state:i,dispatch:n})=>{const a=ae(i.doc,e),{blockContainer:r,blockContent:l}=W(a),s=[{type:r.node.type,attrs:o?{...r.node.attrs,id:void 0}:{}},{type:t?l.node.type:i.schema.nodes.paragraph,attrs:o?{...l.node.attrs}:{}}];return n&&i.tr.split(e,2,s),!0},Fe=e=>{const t=e._tiptapEditor,{blockContent:o,blockContainer:i}=v(t.state),n=t.state.selection.anchor===t.state.selection.head;return!(o.node.type.name==="bulletListItem"||o.node.type.name==="numberedListItem"||o.node.type.name==="checkListItem")||!n?!1:t.commands.first(({state:a,chain:r,commands:l})=>[()=>l.command(()=>o.node.childCount===0?l.command(S(e,i.beforePos,{type:"paragraph",props:{}})):!1),()=>l.command(()=>o.node.childCount>0?(r().deleteSelection().command($t(a.selection.from,!0)).run(),!0):!1)])},Ii={...C},Pi=V({name:"bulletListItem",content:"inline*",group:"blockContent",priority:90,addInputRules(){return[new b.InputRule({find:new RegExp("^[-+*]\\s$"),handler:({state:e,chain:t,range:o})=>{const i=v(e);i.blockContent.node.type.spec.content==="inline*"&&t().command(S(this.options.editor,i.blockContainer.beforePos,{type:"bulletListItem",props:{}})).deleteRange({from:o.from,to:o.to})}})]},addKeyboardShortcuts(){return{Enter:()=>Fe(this.options.editor),"Mod-Shift-8":()=>{const e=v(this.editor.state);return e.blockContent.node.type.spec.content!=="inline*"?!0:this.options.editor.commands.command(S(this.options.editor,e.blockContainer.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)||{})}}),Ai=$(Pi,Ii),Ni={...C,checked:{default:!1}},ji=V({name:"checkListItem",content:"inline*",group:"blockContent",addAttributes(){return{checked:{default:!1,parseHTML:e=>e.getAttribute("data-checked")==="true"||void 0,renderHTML:e=>e.checked?{"data-checked":e.checked.toString()}:{}}}},addInputRules(){return[new b.InputRule({find:new RegExp("\\[\\s*\\]\\s$"),handler:({state:e,chain:t,range:o})=>{const i=v(e);i.blockContent.node.type.spec.content==="inline*"&&t().command(S(this.options.editor,i.blockContainer.beforePos,{type:"checkListItem",props:{checked:!1}})).deleteRange({from:o.from,to:o.to})}}),new b.InputRule({find:new RegExp("\\[[Xx]\\]\\s$"),handler:({state:e,chain:t,range:o})=>{const i=v(e);i.blockContent.node.type.spec.content==="inline*"&&t().command(S(this.options.editor,i.blockContainer.beforePos,{type:"checkListItem",props:{checked:!0}})).deleteRange({from:o.from,to:o.to})}})]},addKeyboardShortcuts(){return{Enter:()=>Fe(this.options.editor),"Mod-Shift-9":()=>{const e=v(this.options.editor.state);return e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(S(this.options.editor,e.blockContainer.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 p,h;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 l=()=>{if(!o.isEditable){r.checked=!r.checked;return}if(typeof t!="boolean"){const m=ae(o.state.doc,t());this.editor.commands.command(S(this.options.editor,m.posBeforeNode,{type:"checkListItem",props:{checked:r.checked}}))}};r.addEventListener("change",l);const{dom:s,contentDOM:c}=R(this.name,"p",{...((p=this.options.domAttributes)==null?void 0:p.blockContent)||{},...i},((h=this.options.domAttributes)==null?void 0:h.inlineContent)||{});if(typeof t!="boolean"){const g="label-"+this.editor.state.doc.resolve(t()).node().attrs.id;r.setAttribute("aria-labelledby",g),c.id=g}return s.removeChild(c),s.appendChild(n),n.appendChild(a),n.appendChild(c),a.appendChild(r),{dom:s,contentDOM:c,destroy:()=>{r.removeEventListener("change",l)}}}}}),Hi=$(ji,Ni),Di=new _.PluginKey("numbered-list-indexing"),Ui=()=>new _.Plugin({key:Di,appendTransaction:(e,t,o)=>{const i=o.tr;i.setMeta("numberedListIndexing",!0);let n=!1;return o.doc.descendants((a,r)=>{if(a.type.name==="blockContainer"&&a.firstChild.type.name==="numberedListItem"){let l="1";const s=W({posBeforeNode:r,node:a}),c=i.doc.resolve(s.blockContainer.beforePos).nodeBefore;if(c){const m=W({posBeforeNode:s.blockContainer.beforePos-c.nodeSize,node:c});if(m.blockContent.node.type.name==="numberedListItem"){const f=m.blockContent.node.attrs.index;l=(parseInt(f)+1).toString()}}s.blockContent.node.attrs.index!==l&&(n=!0,i.setNodeMarkup(s.blockContent.beforePos,void 0,{index:l}))}}),n?i:null}}),zi={...C},Oi=V({name:"numberedListItem",content:"inline*",group:"blockContent",priority:90,addAttributes(){return{index:{default:null,parseHTML:e=>e.getAttribute("data-index"),renderHTML:e=>({"data-index":e.index})}}},addInputRules(){return[new b.InputRule({find:new RegExp("^1\\.\\s$"),handler:({state:e,chain:t,range:o})=>{const i=v(e);i.blockContent.node.type.spec.content==="inline*"&&t().command(S(this.options.editor,i.blockContainer.beforePos,{type:"numberedListItem",props:{}})).deleteRange({from:o.from,to:o.to})}})]},addKeyboardShortcuts(){return{Enter:()=>Fe(this.options.editor),"Mod-Shift-7":()=>{const e=v(this.editor.state);return e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(S(this.options.editor,e.blockContainer.beforePos,{type:"numberedListItem",props:{}}))}}},addProseMirrorPlugins(){return[Ui()]},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==="OL"||t.tagName==="DIV"&&t.parentElement.tagName==="OL"?{}:!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)||{})}}),Ri=$(Oi,zi),Vi={...C},Fi=V({name:"paragraph",content:"inline*",group:"blockContent",addKeyboardShortcuts(){return{"Mod-Alt-0":()=>{const e=v(this.editor.state);return e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(S(this.options.editor,e.blockContainer.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)||{})}}),Ki=$(Fi,Vi),Gi=b.Extension.create({name:"BlockNoteTableExtension",addProseMirrorPlugins:()=>[oe.columnResizing({cellMinWidth:100}),oe.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}}},extendNodeSchema(e){const t={name:e.name,options:e.options,storage:e.storage};return{tableRole:b.callOrReturn(b.getExtensionField(e,"tableRole",t))}}}),qi={...C},Wi=V({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)||{})}}),$i=b.Node.create({name:"tableParagraph",group:"tableContent",content:"inline*",parseHTML(){return[{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",b.mergeAttributes(this.options.HTMLAttributes,e),0]}}),Zi=$(Wi,qi,[Gi,$i,Fo.TableHeader.extend({content:"tableContent"}),Vo.TableCell.extend({content:"tableContent"}),Ko.TableRow]),Ke={paragraph:Ki,heading:Li,bulletListItem:Ai,numberedListItem:Ri,checkListItem:Hi,table:Zi,file:Nt,image:Ot,video:Wt,audio:Mt},Zt=Ae(Ke),Ge={bold:F(ei.default,"boolean"),italic:F(oi.default,"boolean"),underline:F(ni.default,"boolean"),strike:F(ii.default,"boolean"),code:F(ti.default,"boolean"),textColor:Si,backgroundColor:Ei},Xi=Ue(Ge),qe={text:{config:"text",implementation:{}},link:{config:"link",implementation:{}}},Xt=He(qe);function P(e,t){return e in t.schema.blockSchema&&t.schema.blockSchema[e]===Zt[e]}function Jt(e,t){return e in t.schema.inlineContentSchema&&t.schema.inlineContentSchema[e]===Xt[e]}function Yt(e,t,o){return t.type===e&&t.type in o.schema.blockSchema&&P(t.type,o)}function Ji(e,t){return e.type in t.schema.blockSchema&&t.schema.blockSchema[e.type].isFileBlock||!1}function Yi(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 Qi(e,t){return t.schema.blockSchema[e.type].isFileBlock&&!e.props.url}function Qt(e,t,o){return t in o.schema.blockSchema&&e in o.schema.blockSchema[t].propSchema&&o.schema.blockSchema[t].propSchema[e]===C[e]}function en(e,t,o){return Qt(e,t.type,o)}function tn(e,t,o,i="before"){const n=typeof o=="string"?o:o.id,a=[];for(const c of t)a.push(q(c,e.pmSchema,e.schema.styleSchema));const{node:r,posBeforeNode:l}=be(n,e._tiptapEditor.state.doc);i==="before"&&e.dispatch(e._tiptapEditor.state.tr.insert(l,a)),i==="after"&&e.dispatch(e._tiptapEditor.state.tr.insert(l+r.nodeSize,a));const s=[];for(const c of a)s.push(x(c,e.schema.blockSchema,e.schema.inlineContentSchema,e.schema.styleSchema,e.blockCache));return s}function on(e){const{blockContainer:t}=v(e._tiptapEditor.state),o={blockId:t.node.attrs.id,blockPos:t.beforePos};return e._tiptapEditor.state.selection instanceof oe.CellSelection?{...o,type:"cell",anchorCell:e._tiptapEditor.state.selection.$anchorCell.pos,headCell:e._tiptapEditor.state.selection.$headCell.pos}:e._tiptapEditor.state.selection instanceof _.NodeSelection?{...o,type:"node",from:e._tiptapEditor.state.selection.from}:{...o,type:"text",anchor:e._tiptapEditor.state.selection.anchor,head:e._tiptapEditor.state.selection.head}}function nn(e,t){const o=be(t.blockId,e._tiptapEditor.state.doc).posBeforeNode;let i;t.type==="cell"?i=oe.CellSelection.create(e._tiptapEditor.state.doc,t.anchorCell+(o-t.blockPos),t.headCell+(o-t.blockPos)):t.type==="node"?i=_.NodeSelection.create(e._tiptapEditor.state.doc,t.from+(o-t.blockPos)):i=_.TextSelection.create(e._tiptapEditor.state.doc,t.anchor+(o-t.blockPos),t.head+(o-t.blockPos)),e._tiptapEditor.view.dispatch(e._tiptapEditor.state.tr.setSelection(i))}function eo(e,t,o){const{block:i}=e.getTextCursorPosition(),n=on(e);e.removeBlocks([i]),e.insertBlocks([i],t,o),nn(e,n)}function an(e){const t=e.getSelection();if(t&&t.blocks.length>1)return;const{prevBlock:o,parentBlock:i}=e.getTextCursorPosition();let n,a;o?o.children.length>0?(n=o.children[o.children.length-1].id,a="after"):(n=o.id,a="before"):i&&(n=i.id,a="before"),!(!n||!a)&&eo(e,n,a)}function rn(e){const t=e.getSelection();if(t&&t.blocks.length>1)return;const{nextBlock:o,parentBlock:i}=e.getTextCursorPosition();let n,a;o?o.children.length>0?(n=o.children[0].id,a="before"):(n=o.id,a="after"):i&&(n=i.id,a="after"),!(!n||!a)&&eo(e,n,a)}function to(e,t,o){const i=e._tiptapEditor,n=i.state.tr,a=new Set(t.map(s=>typeof s=="string"?s:s.id)),r=[];let l=0;if(i.state.doc.descendants((s,c)=>{if(a.size===0)return!1;if(s.type.name!=="blockContainer"||!a.has(s.attrs.id))return!0;r.push(x(s,e.schema.blockSchema,e.schema.inlineContentSchema,e.schema.styleSchema,e.blockCache)),a.delete(s.attrs.id),l=(o==null?void 0:o(s,c,n,l))||l;const p=n.doc.nodeSize;n.delete(c-l-1,c-l+s.nodeSize+1);const h=n.doc.nodeSize;return l+=p-h,!1}),a.size>0){const s=[...a].join(`
6
6
  `);throw Error("Blocks with the following IDs could not be found in the editor: "+s)}return e.dispatch(n),r}function ln(e,t){return to(e,t)}function sn(e,t,o){const i=[];for(const l of o)i.push(q(l,e.pmSchema,e.schema.styleSchema));const n=typeof t[0]=="string"?t[0]:t[0].id,a=to(e,t,(l,s,c,p)=>{if(l.attrs.id===n){const h=c.doc.nodeSize;c.insert(s,i);const m=c.doc.nodeSize;return p+h-m}return p}),r=[];for(const l of i)r.push(x(l,e.schema.blockSchema,e.schema.inlineContentSchema,e.schema.styleSchema,e.blockCache));return{insertedBlocks:r,removedBlocks:a}}function dn(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},l=!0,s=!0,c="";if(t.forEach(p=>{p.check(),l&&p.isText&&p.marks.length===0?c+=p.text:l=!1,s=s?p.isBlock:!1}),a===r&&s){const{parent:p}=n.doc.resolve(a);p.isTextblock&&!p.type.spec.code&&!p.childCount&&(a-=1,r+=1)}return l?n.insertText(c,a,r):n.replaceWith(a,r,t),i.updateSelection&&b.selectionToInsertionEnd(n,n.steps.length-1,-1),o.dispatch(n),!0}function cn(e){const{blockContainer:t}=v(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(o.depth-1)),{block:x(t.node,e.schema.blockSchema,e.schema.inlineContentSchema,e.schema.styleSchema,e.blockCache),prevBlock:i===null?void 0:x(i,e.schema.blockSchema,e.schema.inlineContentSchema,e.schema.styleSchema,e.blockCache),nextBlock:n===null?void 0:x(n,e.schema.blockSchema,e.schema.inlineContentSchema,e.schema.styleSchema,e.blockCache),parentBlock:a===void 0?void 0:x(a,e.schema.blockSchema,e.schema.inlineContentSchema,e.schema.styleSchema,e.blockCache)}}function un(e,t,o="start"){const i=typeof t=="string"?t:t.id,n=be(i,e._tiptapEditor.state.doc),{blockContent:a}=W(n),r=e.schema.blockSchema[a.node.type.name].content;if(r==="none"){e._tiptapEditor.commands.setNodeSelection(a.beforePos);return}if(r==="inline")o==="start"?e._tiptapEditor.commands.setTextSelection(a.beforePos+1):e._tiptapEditor.commands.setTextSelection(a.afterPos-1);else if(r==="table")o==="start"?e._tiptapEditor.commands.setTextSelection(a.beforePos+4):e._tiptapEditor.commands.setTextSelection(a.afterPos-4);else throw new N(r)}d.esmDependencies=void 0;async function ke(){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 pn(){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 hn(){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 _e(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(pn).use(hn).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 ke();const a=ne(t,o).exportBlocks(e,i);return _e(a)}function mn(e){return Array.prototype.indexOf.call(e.parentElement.childNodes,e)}function fn(e){return e.nodeType===3&&!/\S/.test(e.nodeValue||"")}function gn(e){e.querySelectorAll("li > ul, li > ol").forEach(t=>{const o=mn(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(fn(a))return;const r=document.createElement("li");r.append(a),t.insertAdjacentElement("afterend",r)}),i.childNodes.length===0&&i.remove()})}function bn(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 io=null;function kn(){return io||(io=document.implementation.createHTMLDocument("title"))}function no(e){if(typeof e=="string"){const t=kn().createElement("div");t.innerHTML=e,e=t}return gn(e),bn(e),e}async function We(e,t,o,i,n){const a=no(e),l=y.DOMParser.fromSchema(n).parse(a,{topNode:n.nodes.blockGroup.create()}),s=[];for(let c=0;c<l.childCount;c++)s.push(x(l.child(c),t,o,i));return s}function _n(e,t){const o=t.value?t.value+`
7
- `:"",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 ao(e,t,o,i,n){const a=await ke(),r=a.unified.unified().use(a.remarkParse.default).use(a.remarkGfm.default).use(a.remarkRehype.default,{handlers:{...a.remarkRehype.defaultHandlers,code:_n}}).use(a.rehypeStringify.default).processSync(e);return We(r.value,t,o,i,n)}class Y{constructor(){u(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 ro{constructor(t,o,i,n){u(this,"state");u(this,"emitUpdate");u(this,"mouseDownHandler",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())});u(this,"dragstartHandler",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())});u(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()}});u(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 $e=new _.PluginKey("FilePanelPlugin");class lo extends Y{constructor(o){super();u(this,"view");u(this,"plugin");u(this,"closeMenu",()=>{var o;return(o=this.view)==null?void 0:o.closeMenu()});this.plugin=new _.Plugin({key:$e,view:i=>(this.view=new ro(o,$e,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($e))==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 so{constructor(t,o,i){u(this,"state");u(this,"emitUpdate");u(this,"preventHide",!1);u(this,"preventShow",!1);u(this,"shouldShow",({state:t,from:o,to:i,view:n})=>{const{doc:a,selection:r}=t,{empty:l}=r,s=!a.textBetween(o,i).length&&b.isTextSelection(t.selection);return!(!n.hasFocus()||l||s)});u(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())});u(this,"viewMousedownHandler",()=>{this.preventShow=!0});u(this,"viewMouseupHandler",()=>{this.preventShow=!1,setTimeout(()=>this.update(this.pmView))});u(this,"dragHandler",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())});u(this,"scrollHandler",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.referencePos=this.getSelectionBoundingBox(),this.emitUpdate())});u(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 m,g;const{state:i,composing:n}=t,{doc:a,selection:r}=i,l=o&&o.doc.eq(a)&&o.selection.eq(r);if(n||l)return;const{ranges:s}=r,c=Math.min(...s.map(f=>f.$from.pos)),p=Math.max(...s.map(f=>f.$to.pos)),h=(m=this.shouldShow)==null?void 0:m.call(this,{view:t,state:i,from:c,to:p});if(!this.preventShow&&(h||this.preventHide)){this.state={show:!0,referencePos:this.getSelectionBoundingBox()},this.emitUpdate();return}if((g=this.state)!=null&&g.show&&!this.preventHide&&(!h||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(b.isNodeSelection(o)){const r=this.pmView.nodeDOM(n);if(r)return r.getBoundingClientRect()}return b.posToDOMRect(this.pmView,n,a)}}const co=new _.PluginKey("FormattingToolbarPlugin");class uo extends Y{constructor(o){super();u(this,"view");u(this,"plugin");u(this,"closeMenu",()=>this.view.closeMenu());this.plugin=new _.Plugin({key:co,view:i=>(this.view=new so(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)}}class yn{constructor(t,o,i){u(this,"state");u(this,"emitUpdate");u(this,"menuUpdateTimer");u(this,"startMenuUpdateTimer");u(this,"stopMenuUpdateTimer");u(this,"mouseHoveredLinkMark");u(this,"mouseHoveredLinkMarkRange");u(this,"keyboardHoveredLinkMark");u(this,"keyboardHoveredLinkMarkRange");u(this,"linkMark");u(this,"linkMarkRange");u(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=b.getMarkRange(n,r.type,r.attrs)||void 0;break}}return this.startMenuUpdateTimer(),!1});u(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())});u(this,"scrollHandler",()=>{var t;this.linkMark!==void 0&&(t=this.state)!=null&&t.show&&(this.state.referencePos=b.posToDOMRect(this.pmView,this.linkMarkRange.from,this.linkMarkRange.to),this.emitUpdate())});u(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()},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(){var o;if(!this.pmView.hasFocus())return;const t=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 i=this.pmView.state.selection.$from.marks();for(const n of i)if(n.type.name===this.pmView.state.schema.mark("link").type.name){this.keyboardHoveredLinkMark=n,this.keyboardHoveredLinkMarkRange=b.getMarkRange(this.pmView.state.selection.$from,n.type,n.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:b.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((o=this.state)!=null&&o.show&&t&&(!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 po=new _.PluginKey("LinkToolbarPlugin");class ho extends Y{constructor(o){super();u(this,"view");u(this,"plugin");u(this,"editLink",(o,i)=>{this.view.editLink(o,i)});u(this,"deleteLink",()=>{this.view.deleteLink()});u(this,"startHideTimer",()=>{this.view.startMenuUpdateTimer()});u(this,"stopHideTimer",()=>{this.view.stopMenuUpdateTimer()});u(this,"closeMenu",()=>this.view.closeMenu());this.plugin=new _.Plugin({key:po,view:i=>(this.view=new yn(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}}function mo(e,t){const o=[];return e.descendants(i=>{var n;return i.type.name==="blockContainer"?((n=i.firstChild)==null?void 0:n.type.name)==="blockGroup"?!0:(o.push(x(i,t.blockSchema,t.inlineContentSchema,t.styleSchema)),!1):!0}),o}class Q extends _.Selection{constructor(o,i){super(o,i);u(this,"nodes");const n=o.node();this.nodes=[],o.doc.nodesBetween(o.pos,i.pos,(a,r,l)=>{if(l!==null&&l.eq(n))return this.nodes.push(a),!1})}static create(o,i,n=i){return new Q(o.resolve(i),o.resolve(n))}content(){return new y.Slice(y.Fragment.from(this.nodes),0,0)}eq(o){if(!(o instanceof Q)||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 Q(o.resolve(n.pos),o.resolve(a.pos))}toJSON(){return{type:"node",anchor:this.anchor,head:this.head}}}let D;function ye(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")}}function vn(e,t){const o=ye(e,t);if(o&&o.node.nodeType===1){const i=t.docView,n=i.nearestDesc(o.node,!0);return!n||n===i?null:n.posBefore}return null}function wn(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 l=e.$from.start(r-1),s=e.$to.end(r-1);o=t.resolve(l-1).pos,i=t.resolve(s+1).pos}else o=e.from,i=e.to;return{from:o,to:i}}function fo(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=(p,h)=>Array.prototype.indexOf.call(p.children,h),r=a(n,e.domAtPos(t+1).node.parentElement),l=a(n,e.domAtPos(o-1).node.parentElement);for(let p=n.childElementCount-1;p>=0;p--)(p>l||p<r)&&i.removeChild(i.children[p]);go(e.root),D=i;const c=e.dom.className.split(" ").filter(p=>p!=="ProseMirror"&&p!=="bn-root"&&p!=="bn-editor").join(" ");D.className=D.className+" bn-drag-preview "+c,e.root instanceof ShadowRoot?e.root.appendChild(D):e.root.body.appendChild(D)}function go(e){D!==void 0&&(e instanceof ShadowRoot?e.removeChild(D):e.body.removeChild(D),D=void 0)}function Cn(e,t){if(!e.dataTransfer)return;const o=t.prosemirrorView,i=o.dom.getBoundingClientRect(),n={left:i.left+i.width/2,top:e.clientY},a=o.root.elementsFromPoint(n.left,n.top);let r;for(const s of a)if(o.dom.contains(s)){r=ye(s,o);break}if(!r)return;const l=vn(r.node,o);if(l!=null){const s=o.state.selection,c=o.state.doc,{from:p,to:h}=wn(s,c),m=p<=l&&l<h,g=s.$anchor.node()!==s.$head.node()||s instanceof Q;m&&g?(o.dispatch(o.state.tr.setSelection(Q.create(c,p,h))),fo(o,p,h)):(o.dispatch(o.state.tr.setSelection(_.NodeSelection.create(o.state.doc,l))),fo(o,l));const f=o.state.selection.content(),k=t.pmSchema,w=tt.__serializeForClipboard(o,f).dom.innerHTML,T=ne(k,t),E=mo(f.content,t.schema),H=T.exportBlocks(E,{}),K=_e(H);e.dataTransfer.clearData(),e.dataTransfer.setData("blocknote/html",w),e.dataTransfer.setData("text/html",H),e.dataTransfer.setData("text/plain",K),e.dataTransfer.effectAllowed="move",e.dataTransfer.setDragImage(D,0,0),o.dragging={slice:f,move:!0}}}const En=(e,t)=>{if(!t.dom.firstChild)return;const o=t.dom.firstChild.getBoundingClientRect(),i={left:o.left+o.width/2,top:e.y},n=t.root.elementsFromPoint(i.left,i.top);let a;for(const r of n)if(t.dom.contains(r)){a=ye(r,t);break}return a};class bo{constructor(t,o,i){u(this,"state");u(this,"emitUpdate");u(this,"mousePos");u(this,"hoveredBlock");u(this,"menuFrozen",!1);u(this,"updateState",t=>{this.state=t,this.emitUpdate(this.state)});u(this,"updateStateFromMousePos",()=>{var i,n,a,r;if(this.menuFrozen||!this.mousePos)return;const t=En(this.mousePos,this.pmView);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 l=this.pmView.dom.firstChild.getBoundingClientRect(),s=o.getBoundingClientRect();this.updateState({show:!0,referencePos:new DOMRect(l.x,s.y,s.width,s.height),block:this.editor.getBlock(this.hoveredBlock.getAttribute("data-id"))})}});u(this,"onDrop",t=>{var i;if(this.editor._tiptapEditor.commands.blur(),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=new Event("drop",t),a=this.pmView.dom.firstChild.getBoundingClientRect();n.clientX=t.clientX<a.left||t.clientX>a.left+a.width?a.left+a.width/2:t.clientX,n.clientY=Math.min(Math.max(t.clientY,a.top),a.top+a.height),n.dataTransfer=t.dataTransfer,n.preventDefault=()=>t.preventDefault(),n.synthetic=!0,this.pmView.dom.dispatchEvent(n)}});u(this,"onDragOver",t=>{var i;if(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=new Event("dragover",t),a=this.pmView.dom.firstChild.getBoundingClientRect();n.clientX=a.left+a.width/2,n.clientY=t.clientY,n.dataTransfer=t.dataTransfer,n.preventDefault=()=>t.preventDefault(),n.synthetic=!0,this.pmView.dom.dispatchEvent(n)}});u(this,"onKeyDown",t=>{var o;(o=this.state)!=null&&o.show&&this.editor.isFocused()&&(this.state.show=!1,this.emitUpdate(this.state))});u(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()});this.editor=t,this.pmView=o,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized side menu");i(this.state)},this.pmView.root.addEventListener("drop",this.onDrop,!0),this.pmView.root.addEventListener("dragover",this.onDragOver),ke(),this.pmView.root.addEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.addEventListener("keydown",this.onKeyDown,!0)}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("dragover",this.onDragOver),this.pmView.root.removeEventListener("drop",this.onDrop,!0),this.pmView.root.removeEventListener("keydown",this.onKeyDown,!0)}}const ko=new _.PluginKey("SideMenuPlugin");class _o extends Y{constructor(o){super();u(this,"view");u(this,"plugin");u(this,"blockDragStart",o=>{Cn(o,this.editor)});u(this,"blockDragEnd",()=>go(this.editor.prosemirrorView.root));u(this,"freezeMenu",()=>this.view.menuFrozen=!0);u(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:ko,view:i=>(this.view=new bo(o,i,n=>{this.emit("update",n)}),this.view)})}onUpdate(o){return this.on("update",o)}}const xn=b.findParentNode(e=>e.type.name==="blockContainer");class Sn{constructor(t,o){u(this,"state");u(this,"emitUpdate");u(this,"rootEl");u(this,"pluginState");u(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)}});u(this,"closeMenu",()=>{this.editor.dispatch(this.editor._tiptapEditor.view.state.tr.setMeta(ee,null))});u(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()});this.editor=t,this.pluginState=void 0,this.emitUpdate=i=>{var n;if(!this.state)throw new Error("Attempting to update uninitialized suggestions menu");o(i,{...this.state,ignoreQueryLength:(n=this.pluginState)==null?void 0:n.ignoreQueryLength})},this.rootEl=this.editor._tiptapEditor.view.root,this.rootEl.addEventListener("scroll",this.handleScroll,!0)}update(t,o){var c;const i=ee.getState(o),n=ee.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 s=(c=this.rootEl)==null?void 0:c.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);this.editor.isEditable&&s&&(this.state={show:!0,referencePos:s.getBoundingClientRect(),query:this.pluginState.query},this.emitUpdate(this.pluginState.triggerCharacter))}destroy(){var t;(t=this.rootEl)==null||t.removeEventListener("scroll",this.handleScroll,!0)}}const ee=new _.PluginKey("SuggestionMenuPlugin");class yo extends Y{constructor(o){super();u(this,"view");u(this,"plugin");u(this,"triggerCharacters",[]);u(this,"addTriggerCharacter",o=>{this.triggerCharacters.push(o)});u(this,"removeTriggerCharacter",o=>{this.triggerCharacters=this.triggerCharacters.filter(i=>i!==o)});u(this,"closeMenu",()=>this.view.closeMenu());u(this,"clearQuery",()=>this.view.clearQuery());const i=this.triggerCharacters;this.plugin=new _.Plugin({key:ee,view:()=>(this.view=new Sn(o,(n,a)=>{this.emit(`update ${n}`,a)}),this.view),state:{init(){},apply(n,a,r,l){if(n.getMeta("orderedListIndexing")!==void 0)return a;const s=n.getMeta(ee);if(typeof s=="object"&&s!==null&&a===void 0)return{triggerCharacter:s.triggerCharacter,deleteTriggerCharacter:s.deleteTriggerCharacter!==!1,queryStartPos:l.selection.from,query:"",decorationId:`id_${Math.floor(Math.random()*4294967295)}`,ignoreQueryLength:s==null?void 0:s.ignoreQueryLength};if(a===void 0)return a;if(l.selection.from!==l.selection.to||s===null||n.getMeta("focus")||n.getMeta("blur")||n.getMeta("pointer")||a.triggerCharacter!==void 0&&l.selection.from<a.queryStartPos)return;const c={...a};return c.query=l.doc.textBetween(a.queryStartPos,l.selection.from),c}},props:{handleTextInput(n,a,r,l){const s=this.getState(n.state);return i.includes(l)&&s===void 0?(n.dispatch(n.state.tr.insertText(l).scrollIntoView().setMeta(ee,{triggerCharacter:l})),!0):!1},decorations(n){const a=this.getState(n);if(a===void 0)return null;if(!a.deleteTriggerCharacter){const r=xn(n.selection);if(r)return L.DecorationSet.create(n.doc,[L.Decoration.node(r.pos,r.pos+r.node.nodeSize,{nodeName:"span",class:"bn-suggestion-decorator","data-decoration-id":a.decorationId})])}return L.DecorationSet.create(n.doc,[L.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 Tn(e,t){e.suggestionMenus.addTriggerCharacter(t)}let I;function vo(e){I||(I=document.createElement("div"),I.innerHTML="_",I.style.opacity="0",I.style.height="1px",I.style.width="1px",e instanceof Document?e.body.appendChild(I):e.appendChild(I))}function Mn(e){I&&(e instanceof Document?e.body.removeChild(I):e.removeChild(I),I=void 0)}function ve(e){return Array.prototype.indexOf.call(e.parentElement.childNodes,e)}function Bn(e){for(;e&&e.nodeName!=="TD"&&e.nodeName!=="TH";)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}function Ln(e,t){e.forEach(o=>{const i=t.querySelectorAll(o);for(let n=0;n<i.length;n++)i[n].style.visibility="hidden"})}class wo{constructor(t,o,i){u(this,"state");u(this,"emitUpdate");u(this,"tableId");u(this,"tablePos");u(this,"menuFrozen",!1);u(this,"mouseState","up");u(this,"prevWasEditable",null);u(this,"viewMousedownHandler",()=>{this.mouseState="down"});u(this,"viewMouseupHandler",t=>{this.mouseState="up",this.mouseMoveHandler(t)});u(this,"mouseMoveHandler",t=>{var c,p,h,m;if(this.menuFrozen||(this.mouseState==="down"&&(this.mouseState="selecting",(c=this.state)!=null&&c.show&&(this.state.show=!1,this.emitUpdate())),this.mouseState==="selecting"))return;const o=Bn(t.target);if(!o||!this.editor.isEditable){(p=this.state)!=null&&p.show&&(this.state.show=!1,this.emitUpdate());return}const i=ve(o),n=ve(o.parentElement),a=o.getBoundingClientRect(),r=(m=(h=o.parentElement)==null?void 0:h.parentElement)==null?void 0:m.getBoundingClientRect();if(!r)return;const l=ye(o,this.pmView);if(!l)return;let s;if(this.editor._tiptapEditor.state.doc.descendants((g,f)=>{if(typeof s<"u")return!1;if(g.type.name!=="blockContainer"||g.attrs.id!==l.id)return!0;const k=x(g,this.editor.schema.blockSchema,this.editor.schema.inlineContentSchema,this.editor.schema.styleSchema,this.editor.blockCache);return Yt("table",k,this.editor)&&(this.tablePos=f+1,s=k),!1}),!!s&&(this.tableId=l.id,!(this.state!==void 0&&this.state.show&&this.tableId===l.id&&this.state.rowIndex===n&&this.state.colIndex===i)))return this.state={show:!0,referencePosCell:a,referencePosTable:r,block:s,colIndex:i,rowIndex:n,draggingState:void 0},this.emitUpdate(),!1});u(this,"dragOverHandler",t=>{var m;if(((m=this.state)==null?void 0:m.draggingState)===void 0)return;t.preventDefault(),t.dataTransfer.dropEffect="move",Ln(["column-resize-handle","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(g=>g.tagName==="TD"||g.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=ve(n.parentElement),l=ve(n),s=this.state.draggingState.draggedCellOrientation==="row"?this.state.rowIndex:this.state.colIndex,p=(this.state.draggingState.draggedCellOrientation==="row"?r:l)!==s;(this.state.rowIndex!==r||this.state.colIndex!==l)&&(this.state.rowIndex=r,this.state.colIndex=l,this.state.referencePosCell=n.getBoundingClientRect(),a=!0);const h=this.state.draggingState.draggedCellOrientation==="row"?o.top:o.left;this.state.draggingState.mousePos!==h&&(this.state.draggingState.mousePos=h,a=!0),a&&this.emitUpdate(),p&&this.editor.dispatch(this.pmView.state.tr.setMeta(te,!0))});u(this,"dropHandler",t=>{if(this.state===void 0||this.state.draggingState===void 0)return;t.preventDefault();const o=this.state.block.content.rows;if(this.state.draggingState.draggedCellOrientation==="row"){const i=o[this.state.draggingState.originalIndex];o.splice(this.state.draggingState.originalIndex,1),o.splice(this.state.rowIndex,0,i)}else{const i=o.map(n=>n.cells[this.state.draggingState.originalIndex]);o.forEach((n,a)=>{n.cells.splice(this.state.draggingState.originalIndex,1),n.cells.splice(this.state.colIndex,0,i[a])})}this.editor.updateBlock(this.state.block,{type:"table",content:{type:"tableContent",rows:o}}),this.editor.setTextCursorPosition(this.state.block.id)});u(this,"scrollHandler",()=>{var t;if((t=this.state)!=null&&t.show){const o=this.pmView.root.querySelector(`[data-node-type="blockContainer"][data-id="${this.tableId}"] table`),i=o.querySelector(`tr:nth-child(${this.state.rowIndex+1}) > td:nth-child(${this.state.colIndex+1})`);this.state.referencePosTable=o.getBoundingClientRect(),this.state.referencePosCell=i.getBoundingClientRect(),this.emitUpdate()}});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),o.dom.addEventListener("mouseup",this.viewMouseupHandler),o.root.addEventListener("dragover",this.dragOverHandler),o.root.addEventListener("drop",this.dropHandler),o.root.addEventListener("scroll",this.scrollHandler,!0)}destroy(){this.pmView.dom.removeEventListener("mousemove",this.mouseMoveHandler),this.pmView.root.removeEventListener("dragover",this.dragOverHandler),this.pmView.root.removeEventListener("drop",this.dropHandler),this.pmView.root.removeEventListener("scroll",this.scrollHandler,!0)}}const te=new _.PluginKey("TableHandlesPlugin");class Co extends Y{constructor(o){super();u(this,"view");u(this,"plugin");u(this,"colDragStart",o=>{if(this.view.state===void 0)throw new Error("Attempted to drag table column, but no table block was hovered prior.");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(te,{draggedCellOrientation:this.view.state.draggingState.draggedCellOrientation,originalIndex:this.view.state.colIndex,newIndex:this.view.state.colIndex,tablePos:this.view.tablePos})),vo(this.editor._tiptapEditor.view.root),o.dataTransfer.setDragImage(I,0,0),o.dataTransfer.effectAllowed="move"});u(this,"rowDragStart",o=>{if(this.view.state===void 0)throw new Error("Attempted to drag table row, but no table block was hovered prior.");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(te,{draggedCellOrientation:this.view.state.draggingState.draggedCellOrientation,originalIndex:this.view.state.rowIndex,newIndex:this.view.state.rowIndex,tablePos:this.view.tablePos})),vo(this.editor._tiptapEditor.view.root),o.dataTransfer.setDragImage(I,0,0),o.dataTransfer.effectAllowed="copyMove"});u(this,"dragEnd",()=>{if(this.view.state===void 0)throw new Error("Attempted to drag table row, but no table block was hovered prior.");this.view.state.draggingState=void 0,this.view.emitUpdate(),this.editor.dispatch(this.editor._tiptapEditor.state.tr.setMeta(te,null)),Mn(this.editor._tiptapEditor.view.root)});u(this,"freezeHandles",()=>{this.view.menuFrozen=!0});u(this,"unfreezeHandles",()=>{this.view.menuFrozen=!1});this.editor=o,this.plugin=new _.Plugin({key:te,view:i=>(this.view=new wo(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,a=[];if(n===this.view.state.draggingState.originalIndex)return L.DecorationSet.create(i.doc,a);const r=i.doc.resolve(this.view.tablePos+1),l=r.node();if(this.view.state.draggingState.draggedCellOrientation==="row"){const s=i.doc.resolve(r.posAtIndex(n)+1),c=s.node();for(let p=0;p<c.childCount;p++){const h=i.doc.resolve(s.posAtIndex(p)+1),m=h.node(),g=h.pos+(n>this.view.state.draggingState.originalIndex?m.nodeSize-2:0);a.push(L.Decoration.widget(g,()=>{const f=document.createElement("div");return f.className="bn-table-drop-cursor",f.style.left="0",f.style.right="0",n>this.view.state.draggingState.originalIndex?f.style.bottom="-2px":f.style.top="-3px",f.style.height="4px",f}))}}else for(let s=0;s<l.childCount;s++){const c=i.doc.resolve(r.posAtIndex(s)+1),p=i.doc.resolve(c.posAtIndex(n)+1),h=p.node(),m=p.pos+(n>this.view.state.draggingState.originalIndex?h.nodeSize-2:0);a.push(L.Decoration.widget(m,()=>{const g=document.createElement("div");return g.className="bn-table-drop-cursor",g.style.top="0",g.style.bottom="0",n>this.view.state.draggingState.originalIndex?g.style.right="-2px":g.style.left="-3px",g.style.width="4px",g}))}return L.DecorationSet.create(i.doc,a)}}})}onUpdate(o){return this.on("update",o)}}const Ze=["blocknote/html","Files","text/html","text/plain"];function In(e,t){if(!e.startsWith(".")||!t.startsWith("."))throw new Error("The strings provided are not valid file extensions.");return e===t}function Pn(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 Eo(e,t){if(!t.uploadFile)return;const o="dataTransfer"in e?e.dataTransfer:e.clipboardData;if(o===null)return;let i=null;for(const r of Ze)if(o.types.includes(r)){i=r;break}if(i!=="Files")return;const n=o.items;if(!n)return;e.preventDefault();const a=Object.values(t.schema.blockSchema).filter(r=>r.isFileBlock);for(let r=0;r<n.length;r++){let l="file";for(const c of a)for(const p of c.fileBlockAccept||[]){const h=p.startsWith("."),m=n[r].getAsFile();if(m&&(!h&&m.type&&Pn(n[r].type,p)||h&&In("."+m.name.split(".").pop(),p))){l=c.type;break}}const s=n[r].getAsFile();if(s){const c={type:l,props:{name:s.name}};let p;if(e.type==="paste")p=t.insertBlocks([c],t.getTextCursorPosition().block,"after")[0].id;else if(e.type==="drop"){const g={left:e.clientX,top:e.clientY},f=t._tiptapEditor.view.posAtCoords(g);if(!f)return;const k=ae(t._tiptapEditor.state.doc,f.pos),w=W(k);p=t.insertBlocks([c],w.blockContainer.node.attrs.id,"after")[0].id}else return;const h=await t.uploadFile(s,p),m=typeof h=="string"?{props:{url:h}}:{...h};t.updateBlock(p,m)}}}const An=e=>b.Extension.create({name:"dropFile",addProseMirrorPlugins(){return[new _.Plugin({props:{handleDOMEvents:{drop(t,o){if(!e.isEditable)return;let i=null;for(const n of Ze)if(o.dataTransfer.types.includes(n)){i=n;break}return i===null?!0:i==="Files"?(Eo(o,e),!0):!1}}}})]}}),Nn=e=>b.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 Ze)if(o.clipboardData.types.includes(a)){i=a;break}if(!i)return!0;if(i==="Files")return Eo(o,e),!0;let n=o.clipboardData.getData(i);return i==="blocknote/html"?(e._tiptapEditor.view.pasteHTML(n),!0):i==="text/html"?(n=no(n.trim()).innerHTML,e._tiptapEditor.view.pasteHTML(n),!0):(e._tiptapEditor.view.pasteText(n),!0)}}}})]}});function jn(e,t,o){var l;let i=!1;const n=e.state.selection instanceof oe.CellSelection;if(!n){const s=e.state.doc.slice(e.state.selection.from,e.state.selection.to,!1).content,c=[];for(let p=0;p<s.childCount;p++)c.push(s.child(p));i=c.find(p=>p.type.name==="blockContainer"||p.type.name==="blockGroup"||p.type.spec.group==="blockContent")===void 0,i&&(t=s)}let a;const r=ne(e.state.schema,o);if(n){((l=t.firstChild)==null?void 0:l.type.name)==="table"&&(t=t.firstChild.content);const s=Ne(t,o.schema.inlineContentSchema,o.schema.styleSchema);a=r.exportInlineContent(s,{})}else if(i){const s=de(t,o.schema.inlineContentSchema,o.schema.styleSchema);a=r.exportInlineContent(s,{})}else{const s=mo(t,o.schema);a=r.exportBlocks(s,{})}return a}function xo(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=tt.__serializeForClipboard(e,e.state.selection.content()).dom.innerHTML,i=e.state.selection.content().content,n=jn(e,i,t),a=_e(n);return{clipboardHTML:o,externalHTML:n,markdown:a}}const So=(e,t,o)=>{o.preventDefault(),o.clipboardData.clearData();const{clipboardHTML:i,externalHTML:n,markdown:a}=xo(t,e);o.clipboardData.setData("blocknote/html",i),o.clipboardData.setData("text/html",n),o.clipboardData.setData("text/plain",a)},Hn=e=>b.Extension.create({name:"copyToClipboard",addProseMirrorPlugins(){return[new _.Plugin({props:{handleDOMEvents:{copy(t,o){return So(e,t,o),!0},cut(t,o){return So(e,t,o),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}=xo(t,e);return o.dataTransfer.setData("blocknote/html",i),o.dataTransfer.setData("text/html",n),o.dataTransfer.setData("text/plain",a),!0}}}})]}}),Dn=b.Extension.create({name:"blockBackgroundColor",addGlobalAttributes(){return[{types:["blockContainer"],attributes:{backgroundColor:{default:C.backgroundColor.default,parseHTML:e=>e.hasAttribute("data-background-color")?e.getAttribute("data-background-color"):C.backgroundColor.default,renderHTML:e=>e.backgroundColor===C.backgroundColor.default?{}:{"data-background-color":e.backgroundColor}}}}]}}),To=(e,t)=>{if(!t.nodeBefore)throw new Error(`Attempted to get previous blockContainer node for merge at position ${t.pos} but a previous node does not exist`);let i=t.posAtIndex(t.index()-1),n=U(e.resolve(i));for(;n.blockGroup;){const a=n.blockGroup.node;i=e.resolve(n.blockGroup.beforePos+1).posAtIndex(a.childCount-1),n=U(e.resolve(i))}return e.resolve(i)},Un=(e,t)=>{const o=U(e),i=U(t);return o.blockContent.node.type.spec.content==="inline*"&&i.blockContent.node.type.spec.content==="inline*"&&o.blockContent.node.childCount>0},zn=(e,t,o,i)=>{const n=U(i);if(n.blockGroup){const a=e.doc.resolve(n.blockGroup.beforePos+1),r=e.doc.resolve(n.blockGroup.afterPos-1),l=a.blockRange(r);t&&e.tr.lift(l,i.depth)}if(t){const a=U(o);t(e.tr.delete(a.blockContent.afterPos-1,n.blockContent.beforePos+1))}return!0},Mo=e=>({state:t,dispatch:o})=>{const i=t.doc.resolve(e),n=To(t.doc,i);return Un(n,i)?zn(t,o,n,i):!1},On=b.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=v(a),l=a.selection.from===r.blockContent.beforePos+1,s=r.blockContent.node.type.name==="paragraph";return l&&!s?n.command(S(this.options.editor,r.blockContainer.beforePos,{type:"paragraph",props:{}})):!1}),()=>n.command(({state:a})=>{const{blockContent:r}=v(a);return a.selection.from===r.beforePos+1?n.liftListItem("blockContainer"):!1}),()=>n.command(({state:a})=>{const{blockContainer:r,blockContent:l}=v(a),{depth:s}=a.doc.resolve(r.beforePos),c=a.selection.from===l.beforePos+1,p=a.selection.empty,h=r.beforePos===1,m=r.beforePos;return!h&&c&&p&&s===1?i().command(Mo(m)).scrollIntoView().run():!1}),()=>n.command(({state:a})=>{const r=v(a),{depth:l}=a.doc.resolve(r.blockContainer.beforePos),s=a.selection.from===r.blockContent.beforePos+1,c=a.selection.empty,p=r.blockContainer.beforePos===1,h=To(a.doc,a.doc.resolve(r.blockContainer.beforePos)),m=U(a.doc.resolve(h.pos)),g=m.blockContent.node.type.spec.content===""||m.blockContent.node.type.spec.content==="inline*"&&m.blockContent.node.childCount===0;return!p&&s&&c&&l===1&&g?i().cut({from:r.blockContainer.beforePos,to:r.blockContainer.afterPos},m.blockContainer.afterPos).deleteRange({from:m.blockContainer.beforePos,to:m.blockContainer.afterPos}).run():!1})]),Delete:()=>this.editor.commands.first(({commands:i})=>[()=>i.deleteSelection(),()=>i.command(({state:n})=>{const{blockContainer:a,blockContent:r,blockGroup:l}=v(n),{depth:s}=n.doc.resolve(a.beforePos),c=a.afterPos===n.doc.nodeSize-3,p=n.selection.from===r.afterPos-1,h=n.selection.empty;if(!c&&p&&h&&!(l!==void 0)){let g=s,f=a.afterPos+1,k=n.doc.resolve(f).depth;for(;k<g;)g=k,f+=2,k=n.doc.resolve(f).depth;return i.command(Mo(f-1))}return!1})]),Enter:()=>this.editor.commands.first(({commands:i})=>[()=>i.command(({state:n})=>{const{blockContent:a,blockContainer:r}=v(n),{depth:l}=n.doc.resolve(r.beforePos),s=n.selection.$anchor.parentOffset===0,c=n.selection.anchor===n.selection.head,p=a.node.childCount===0,h=l>1;return s&&c&&p&&h?i.liftListItem("blockContainer"):!1}),()=>i.command(({state:n,dispatch:a})=>{const{blockContainer:r,blockContent:l}=v(n),s=n.selection.$anchor.parentOffset===0,c=n.selection.anchor===n.selection.head,p=l.node.childCount===0;if(s&&c&&p){const h=r.afterPos,m=h+2;if(a){const g=n.schema.nodes.blockContainer.createAndFill();n.tr.insert(h,g).scrollIntoView(),n.tr.setSelection(new _.TextSelection(n.doc.resolve(m)))}return!0}return!1}),()=>i.command(({state:n,chain:a})=>{const{blockContent:r}=v(n),l=n.selection.$anchor.parentOffset===0;return r.node.childCount===0?!1:(a().deleteSelection().command($t(n.selection.from,l,l)).run(),!0)})]),Tab:()=>{var i,n,a;return(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.sinkListItem("blockContainer"),!0)},"Shift-Tab":()=>{var i,n,a;return(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.moveBlockUp(),!0),"Shift-Mod-ArrowDown":()=>(this.options.editor.moveBlockDown(),!0)}}}),Rn=b.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}}}}]}}),Vn=b.Extension.create({name:"blockTextColor",addGlobalAttributes(){return[{types:["blockContainer"],attributes:{textColor:{default:C.textColor.default,parseHTML:e=>e.hasAttribute("data-text-color")?e.getAttribute("data-text-color"):C.textColor.default,renderHTML:e=>e.textColor===C.textColor.default?{}:{"data-text-color":e.textColor}}}}]}}),Fn=b.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,l=e.getState(i),s=n.content.size-2,c=r.nodes.blockContainer,p=r.nodes.paragraph;if(l)return a.insert(s,c.create(void 0,p.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")throw new Error("Expected blockContainer");const n=i.firstChild;if(!n)throw new Error("Expected blockContent");return i.nodeSize>4||n.type.spec.content!=="inline*"}}})]}}),Kn={blockColor:"data-block-color",blockStyle:"data-block-style",id:"data-id",depth:"data-depth",depthChange:"data-depth-change"},Gn=b.Node.create({name:"blockContainer",group:"blockContainer",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(Kn))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=O("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}}}),qn=b.Node.create({name:"blockGroup",group:"blockGroup",content:"blockContainer+",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=O("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}}}),Wn=b.Node.create({name:"doc",topNode:!0,content:"blockGroup"}),Bo=e=>{var i;const t=[b.extensions.ClipboardTextSerializer,b.extensions.Commands,b.extensions.Editable,b.extensions.FocusEvents,b.extensions.Tabindex,$o.Gapcursor,Z.configure({types:["blockContainer"],setIdAttribute:e.setIdAttribute}),Zo.HardBreak.extend({priority:10}),Yo.Text,Jo.Link.extend({addKeyboardShortcuts(){return{"Mod-k":()=>(this.editor.commands.toggleLink({href:""}),!0)}}}),...Object.values(e.styleSpecs).map(n=>n.implementation.mark),Vn,Dn,Rn,b.Extension.create({name:"OverrideEscape",addKeyboardShortcuts(){return{Escape:()=>e.editor.suggestionMenus.shown?!1:this.editor.commands.blur()}}}),Wn,Gn.configure({editor:e.editor,domAttributes:e.domAttributes}),On.configure({editor:e.editor}),qn.configure({domAttributes:e.domAttributes}),...Object.values(e.inlineContentSpecs).filter(n=>n.config!=="link"&&n.config!=="text").map(n=>n.implementation.node.configure({editor:e.editor})),...Object.values(e.blockSpecs).flatMap(n=>[...(n.implementation.requiredExtensions||[]).map(a=>a.configure({editor:e.editor,domAttributes:e.domAttributes})),n.implementation.node.configure({editor:e.editor,domAttributes:e.domAttributes})]),Hn(e.editor),Nn(e.editor),An(e.editor),Wo.Dropcursor.configure({width:5,color:"#ddeeff"}),...e.trailingBlock===void 0||e.trailingBlock?[Fn]:[]];if(e.collaboration){if(t.push(ai.default.configure({fragment:e.collaboration.fragment})),(i=e.collaboration.provider)!=null&&i.awareness){const n=a=>{const r=document.createElement("span");r.classList.add("collaboration-cursor__caret"),r.setAttribute("style",`border-color: ${a.color}`);const l=document.createElement("span");l.classList.add("collaboration-cursor__label"),l.setAttribute("style",`background-color: ${a.color}`),l.insertBefore(document.createTextNode(a.name),null);const s=document.createTextNode("⁠"),c=document.createTextNode("⁠");return r.insertBefore(s,null),r.insertBefore(l,null),r.insertBefore(c,null),r};t.push(ri.default.configure({user:e.collaboration.user,render:e.collaboration.renderCursor||n,provider:e.collaboration.provider}))}}else t.push(Xo.History);const o=e.disableExtensions||[];return t.filter(n=>!o.includes(n.name))};function $n(e,t){const o=[];return e.forEach((i,n,a)=>{a!==t&&o.push(i)}),y.Fragment.from(o)}function Zn(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.create(void 0,e.child(i));o.push(n)}else o.push(e.child(i));return e=y.Fragment.from(o),e}function Xn(e,t){let o=y.Fragment.from(e.content);o=Zn(o,t.state.schema);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.spec.group==="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=$n(o,i+1))}const a=t.state.schema.nodes.blockContainer.create(void 0,n);o=o.replaceChild(i,a)}return new y.Slice(o,e.openStart,e.openEnd)}function Xe(e){return e&&Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}class we{constructor(t){u(this,"blockSpecs");u(this,"inlineContentSpecs");u(this,"styleSpecs");u(this,"blockSchema");u(this,"inlineContentSchema");u(this,"styleSchema");u(this,"BlockNoteEditor","only for types");u(this,"Block","only for types");u(this,"PartialBlock","only for types");this.blockSpecs=Xe(t==null?void 0:t.blockSpecs)||Ke,this.inlineContentSpecs=Xe(t==null?void 0:t.inlineContentSpecs)||qe,this.styleSpecs=Xe(t==null?void 0:t.styleSpecs)||Ge,this.blockSchema=Ae(this.blockSpecs),this.inlineContentSchema=He(this.inlineContentSpecs),this.styleSchema=Ue(this.styleSpecs)}static create(t){return new we(t)}}const xe=class xe extends b.Editor{constructor(o,i){super({...o,content:void 0});u(this,"_state");u(this,"mount",o=>{o?(this.options.element=o,this.createViewAlternative()):this.destroy()});const n=this.schema;let a;const r=n.nodes.doc.createAndFill;n.nodes.doc.createAndFill=(...s)=>{if(a)return a;const c=r.apply(n.nodes.doc,s),p=JSON.parse(JSON.stringify(c.toJSON()));return p.content[0].content[0].attrs.id="initialBlockId",a=y.Node.fromJSON(n,p),a};let l;try{const s=o==null?void 0:o.content.map(c=>q(c,this.schema,i).toJSON());l=b.createDocument({type:"doc",content:[{type:"blockGroup",content:s}]},this.schema,this.options.parseOptions)}catch(s){throw console.error("Error creating document from blocks passed as `initialContent`. Caused by exception: ",s),new Error("Error creating document from blocks passed as `initialContent`:\n"+ +JSON.stringify(o.content))}this._state=_.EditorState.create({doc:l,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(){queueMicrotask(()=>{this.view=new L.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})}};u(xe,"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 xe(o,i)}finally{n&&(globalThis.window.setTimeout=n)}});let Ce=xe;Ce.prototype.createView=function(){this.options.onPaste=this.options.onDrop=void 0};const Jn=new _.PluginKey("blocknote-placeholder"),Yn=(e,t)=>new _.Plugin({key:Jn,view:()=>{const o=document.createElement("style"),i=e._tiptapEditor.options.injectNonce;i&&o.setAttribute("nonce",i),e._tiptapEditor.view.root instanceof ShadowRoot?e._tiptapEditor.view.root.append(o):e._tiptapEditor.view.root.head.appendChild(o);const n=o.sheet,a=(l="")=>`.bn-block-content${l} .bn-inline-content:has(> .ProseMirror-trailingBreak:only-child):before`,r=(l,s=!0)=>{const c=s?"[data-is-empty-and-focused]":"";if(l==="default")return a(c);const p=`[data-content-type="${l}"]`;return a(c+p)};for(const[l,s]of Object.entries(t)){const c=l==="default";n.insertRule(`${r(l,c)}{ content: ${JSON.stringify(s)}; }`),c||n.insertRule(`${r(l,!0)}{ content: ${JSON.stringify(s)}; }`)}return{destroy:()=>{e._tiptapEditor.view.root instanceof ShadowRoot?e._tiptapEditor.view.root.removeChild(o):e._tiptapEditor.view.root.head.removeChild(o)}}},props:{decorations:o=>{const{doc:i,selection:n}=o;if(!e.isEditable||!n.empty)return;const a=n.$anchor,r=a.parent;if(r.content.size>0)return null;const l=a.before(),s=L.Decoration.node(l,l+r.nodeSize,{"data-is-empty-and-focused":"true"});return L.DecorationSet.create(i,[s])}}}),Qn=new _.PluginKey("node-selection-keyboard"),ea=()=>new _.Plugin({key:Qn,props:{handleKeyDown:(e,t)=>{if("node"in e.state.selection){if(t.ctrlKey||t.metaKey)return!1;if(t.key.length===1)return t.preventDefault(),!0;if(t.key==="Enter"&&!t.shiftKey&&!t.altKey&&!t.ctrlKey&&!t.metaKey){const o=e.state.tr;return e.dispatch(o.insert(e.state.tr.selection.$to.after(),e.state.schema.nodes.paragraph.create()).setSelection(new _.TextSelection(o.doc.resolve(e.state.tr.selection.$to.after()+1)))),!0}}return!1}}}),Lo=new _.PluginKey("previous-blocks"),ta={index:"index",level:"level",type:"type",depth:"depth","depth-change":"depth-change"},oa=()=>{let e;return new _.Plugin({key:Lo,view(t){return{update:async(o,i)=>{var n;((n=this.key)==null?void 0:n.getState(o.state).updatedBlocks.size)>0&&(e=setTimeout(()=>{o.dispatch(o.state.tr.setMeta(Lo,{clearUpdate:!0}))},0))},destroy:()=>{e&&clearTimeout(e)}}},state:{init(){return{prevTransactionOldBlockAttrs:{},currentTransactionOldBlockAttrs:{},updatedBlocks:new Set}},apply(t,o,i,n){if(o.currentTransactionOldBlockAttrs={},o.updatedBlocks.clear(),!t.docChanged||i.doc.eq(n.doc))return o;const a={},r=b.findChildren(i.doc,c=>c.attrs.id),l=new Map(r.map(c=>[c.node.attrs.id,c])),s=b.findChildren(n.doc,c=>c.attrs.id);for(const c of s){const p=l.get(c.node.attrs.id),h=p==null?void 0:p.node.firstChild,m=c.node.firstChild;if(p&&h&&m){const g={index:m.attrs.index,level:m.attrs.level,type:m.type.name,depth:n.doc.resolve(c.pos).depth};let f={index:h.attrs.index,level:h.attrs.level,type:h.type.name,depth:i.doc.resolve(p.pos).depth};a[c.node.attrs.id]=f,t.getMeta("numberedListIndexing")&&(c.node.attrs.id in o.prevTransactionOldBlockAttrs&&(f=o.prevTransactionOldBlockAttrs[c.node.attrs.id]),g.type==="numberedListItem"&&(f.index=g.index)),o.currentTransactionOldBlockAttrs[c.node.attrs.id]=f,JSON.stringify(f)!==JSON.stringify(g)&&(f["depth-change"]=f.depth-g.depth,o.updatedBlocks.add(c.node.attrs.id))}}return o.prevTransactionOldBlockAttrs=a,o}},props:{decorations(t){const o=this.getState(t);if(o.updatedBlocks.size===0)return;const i=[];return t.doc.descendants((n,a)=>{if(!n.attrs.id||!o.updatedBlocks.has(n.attrs.id))return;const r=o.currentTransactionOldBlockAttrs[n.attrs.id],l={};for(const[c,p]of Object.entries(r))l["data-prev-"+ta[c]]=p||"none";const s=L.Decoration.node(a,a+n.nodeSize,{...l});i.push(s)}),L.DecorationSet.create(t.doc,i)}}})},ia={enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!1};class Je{constructor(t){u(this,"_pmSchema");u(this,"headless",!1);u(this,"_tiptapEditor");u(this,"elementRenderer",null);u(this,"blockCache",new WeakMap);u(this,"dictionary");u(this,"schema");u(this,"blockImplementations");u(this,"inlineContentImplementations");u(this,"styleImplementations");u(this,"formattingToolbar");u(this,"linkToolbar");u(this,"sideMenu");u(this,"suggestionMenus");u(this,"filePanel");u(this,"tableHandles");u(this,"uploadFile");u(this,"onUploadStartCallbacks",[]);u(this,"onUploadEndCallbacks",[]);u(this,"resolveFileUrl");u(this,"mount",t=>{this._tiptapEditor.mount(t)});var s,c,p,h,m,g,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||ot;const i={defaultStyles:!0,schema:t.schema||we.create(),_headless:!1,...t,placeholders:{...this.dictionary.placeholders,...t.placeholders}};this.schema=i.schema,this.blockImplementations=i.schema.blockSpecs,this.inlineContentImplementations=i.schema.inlineContentSpecs,this.styleImplementations=i.schema.styleSpecs,this.formattingToolbar=new uo(this),this.linkToolbar=new ho(this),this.sideMenu=new _o(this),this.suggestionMenus=new yo(this),this.filePanel=new lo(this),P("table",this)&&(this.tableHandles=new Co(this));const n=Bo({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}),a=b.Extension.create({name:"BlockNoteUIExtension",addProseMirrorPlugins:()=>[this.formattingToolbar.plugin,this.linkToolbar.plugin,this.sideMenu.plugin,this.suggestionMenus.plugin,...this.filePanel?[this.filePanel.plugin]:[],...this.tableHandles?[this.tableHandles.plugin]:[],Yn(this,i.placeholders),ea(),...this.options.animations??!0?[oa()]:[]]});if(n.push(a),i.uploadFile){const k=i.uploadFile;this.uploadFile=async(w,T)=>{this.onUploadStartCallbacks.forEach(E=>E.apply(this,[T]));try{return await k(w,T)}finally{this.onUploadEndCallbacks.forEach(E=>E.apply(this,[T]))}}}this.resolveFileUrl=i.resolveFileUrl||(async k=>k),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 r=i.initialContent||(t.collaboration?[{type:"paragraph",id:"initialBlockId"}]:[{type:"paragraph",id:Z.options.generateID()}]);if(!Array.isArray(r)||r.length===0)throw new Error("initialContent must be a non-empty array of blocks, received: "+r);const l={...ia,...i._tiptapOptions,content:r,extensions:[...((s=i._tiptapOptions)==null?void 0:s.extensions)||[],...n],editorProps:{...(c=i._tiptapOptions)==null?void 0:c.editorProps,attributes:{tabIndex:"0",...(h=(p=i._tiptapOptions)==null?void 0:p.editorProps)==null?void 0:h.attributes,...(m=i.domAttributes)==null?void 0:m.editor,class:O("bn-editor",i.defaultStyles?"bn-default-styles":"",((f=(g=i.domAttributes)==null?void 0:g.editor)==null?void 0:f.class)||"")},transformPasted:Xn}};this.headless?this._pmSchema=b.getSchema(l.extensions):(this._tiptapEditor=Ce.create(l,this.schema.styleSchema),this._pmSchema=this._tiptapEditor.schema)}get pmSchema(){return this._pmSchema}static create(t={}){return new Je(t)}dispatch(t){this._tiptapEditor.dispatch(t)}get prosemirrorView(){return this._tiptapEditor.view}get domElement(){return this._tiptapEditor.view.dom}isFocused(){return this._tiptapEditor.view.hasFocus()}focus(){this._tiptapEditor.view.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(x(o,this.schema.blockSchema,this.schema.inlineContentSchema,this.schema.styleSchema,this.blockCache)),!1)),t}getBlock(t){const o=typeof t=="string"?t:t.id;let i;return this._tiptapEditor.state.doc.firstChild.descendants(n=>typeof i<"u"?!1:n.type.name!=="blockContainer"||n.attrs.id!==o?!0:(i=x(n,this.schema.blockSchema,this.schema.inlineContentSchema,this.schema.styleSchema,this.blockCache),!1)),i}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 l=o?r.children.slice().reverse():r.children;if(!n(l))return!1}return!0}n(i)}onEditorContentChange(t){this._tiptapEditor.on("update",t)}onEditorSelectionChange(t){this._tiptapEditor.on("selectionUpdate",t)}getTextCursorPosition(){return cn(this)}setTextCursorPosition(t,o="start"){un(this,t,o)}getSelection(){if(this._tiptapEditor.state.selection.from===this._tiptapEditor.state.selection.to||"node"in this._tiptapEditor.state.selection)return;const t=[];return this._tiptapEditor.state.doc.descendants((o,i)=>{if(o.type.spec.group!=="blockContent")return!0;const n=i+o.nodeSize-1,a=i+1;return n<=this._tiptapEditor.state.selection.from||a>=this._tiptapEditor.state.selection.to?!0:(t.push(x(this._tiptapEditor.state.doc.resolve(i).node(),this.schema.blockSchema,this.schema.inlineContentSchema,this.schema.styleSchema,this.blockCache)),!1)}),{blocks:t}}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 tn(this,t,o,i)}updateBlock(t,o){return Ti(this,t,o)}removeBlocks(t){return ln(this,t)}replaceBlocks(t,o){return sn(this,t,o)}insertInlineContent(t){const o=j(t,this.pmSchema,this.schema.styleSchema);dn({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 N(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 N(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(){const{blockContainer:t}=v(this._tiptapEditor.state);return this._tiptapEditor.state.doc.resolve(t.beforePos).nodeBefore!==null}nestBlock(){this._tiptapEditor.commands.sinkListItem("blockContainer")}canUnnestBlock(){const{blockContainer:t}=v(this._tiptapEditor.state);return this._tiptapEditor.state.doc.resolve(t.beforePos).depth>1}unnestBlock(){this._tiptapEditor.commands.liftListItem("blockContainer")}moveBlockUp(){an(this)}moveBlockDown(){rn(this)}async blocksToHTMLLossy(t=this.document){return ne(this.pmSchema,this).exportBlocks(t,{})}async blocksToFullHTML(t){return dt(this.pmSchema,this).serializeBlocks(t,{})}async tryParseHTMLToBlocks(t){return We(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 ao(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){const i=this.prosemirrorView.state.tr,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}))}}let Ee,Ye;async function na(e,t){if(!Jt("text",e))return[];if(!Ee){Ee=import("@emoji-mart/data"),Ye=await import("emoji-mart");const n=(await Ee).default;await Ye.init({data:n})}const o=(await Ee).default;return(t.trim()===""?Object.values(o.emojis):await Ye.SearchIndex.search(t)).map(n=>({id:n.skins[0].native,onItemClick:()=>e.insertInlineContent(n.skins[0].native+" ")}))}function aa(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 A(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&&X(o.content[0])&&o.content[0].type==="text"&&o.content[0].text==="/"||o.content.length===0)?(i=e.updateBlock(o,t),t.content&&e.setTextCursorPosition(i)):(i=e.insertBlocks([t],o,"after")[0],e.setTextCursorPosition(e.getTextCursorPosition().nextBlock)),aa(e),i}function ra(e){const t=[];return P("heading",e)&&t.push({onItemClick:()=>{A(e,{type:"heading",props:{level:1}})},badge:z("Mod-Alt-1"),key:"heading",...e.dictionary.slash_menu.heading},{onItemClick:()=>{A(e,{type:"heading",props:{level:2}})},badge:z("Mod-Alt-2"),key:"heading_2",...e.dictionary.slash_menu.heading_2},{onItemClick:()=>{A(e,{type:"heading",props:{level:3}})},badge:z("Mod-Alt-3"),key:"heading_3",...e.dictionary.slash_menu.heading_3}),P("numberedListItem",e)&&t.push({onItemClick:()=>{A(e,{type:"numberedListItem"})},badge:z("Mod-Shift-7"),key:"numbered_list",...e.dictionary.slash_menu.numbered_list}),P("bulletListItem",e)&&t.push({onItemClick:()=>{A(e,{type:"bulletListItem"})},badge:z("Mod-Shift-8"),key:"bullet_list",...e.dictionary.slash_menu.bullet_list}),P("checkListItem",e)&&t.push({onItemClick:()=>{A(e,{type:"checkListItem"})},badge:z("Mod-Shift-9"),key:"check_list",...e.dictionary.slash_menu.check_list}),P("paragraph",e)&&t.push({onItemClick:()=>{A(e,{type:"paragraph"})},badge:z("Mod-Alt-0"),key:"paragraph",...e.dictionary.slash_menu.paragraph}),P("table",e)&&t.push({onItemClick:()=>{A(e,{type:"table",content:{type:"tableContent",rows:[{cells:["","",""]},{cells:["","",""]}]}})},badge:void 0,key:"table",...e.dictionary.slash_menu.table}),P("image",e)&&t.push({onItemClick:()=>{const o=A(e,{type:"image"});e.dispatch(e._tiptapEditor.state.tr.setMeta(e.filePanel.plugin,{block:o}))},key:"image",...e.dictionary.slash_menu.image}),P("video",e)&&t.push({onItemClick:()=>{const o=A(e,{type:"video"});e.dispatch(e._tiptapEditor.state.tr.setMeta(e.filePanel.plugin,{block:o}))},key:"video",...e.dictionary.slash_menu.video}),P("audio",e)&&t.push({onItemClick:()=>{const o=A(e,{type:"audio"});e.dispatch(e._tiptapEditor.state.tr.setMeta(e.filePanel.plugin,{block:o}))},key:"audio",...e.dictionary.slash_menu.audio}),P("file",e)&&t.push({onItemClick:()=>{const o=A(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 la(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 Qe(e=""){return typeof e=="string"?[{type:"text",text:e,styles:{}}]:e}function Io(e){return typeof e=="string"?Qe(e):Array.isArray(e)?e.flatMap(t=>typeof t=="string"?Qe(t):Te(t)?{...t,content:Qe(t.content)}:X(t)?t:{props:{},...t,content:Io(t.content)}):e}function sa(e,t){return t.map(o=>et(e,o))}function et(e,t){const o={id:"",type:t.type,props:{},content:e[t.type].content==="inline"?[]:void 0,children:[],...t};return Object.entries(e[t.type].propSchema).forEach(([i,n])=>{o.props[i]===void 0&&(o.props[i]=n.default)}),{...o,content:Io(o.content),children:o.children.map(i=>et(e,i))}}function Po(e){e.id||(e.id=Z.options.generateID()),e.children&&Ao(e.children)}function Ao(e){for(const t of e)Po(t)}d.AudioBlock=Mt,d.BlockNoteEditor=Je,d.BlockNoteSchema=we,d.FileBlock=Nt,d.FilePanelProsemirrorPlugin=lo,d.FilePanelView=ro,d.FormattingToolbarProsemirrorPlugin=uo,d.FormattingToolbarView=so,d.HTMLToBlocks=We,d.ImageBlock=Ot,d.LinkToolbarProsemirrorPlugin=ho,d.SideMenuProsemirrorPlugin=_o,d.SideMenuView=bo,d.SuggestionMenuProseMirrorPlugin=yo,d.TableHandlesProsemirrorPlugin=Co,d.TableHandlesView=wo,d.UniqueID=Z,d.UnreachableCaseError=N,d.VideoBlock=Wt,d.addIdsToBlock=Po,d.addIdsToBlocks=Ao,d.addInlineContentAttributes=je,d.addInlineContentKeyboardShortcuts=mt,d.addStyleAttributes=_t,d.applyNonSelectableBlockFix=pt,d.assertEmpty=ci,d.audioBlockConfig=Et,d.audioParse=St,d.audioPropSchema=Ct,d.audioRender=xt,d.audioToExternalHTML=Tt,d.blockToNode=q,d.blocksToMarkdown=oo,d.camelToDataKebab=re,d.checkBlockHasDefaultProp=en,d.checkBlockIsDefaultType=Yt,d.checkBlockIsFileBlock=Ji,d.checkBlockIsFileBlockWithPlaceholder=Qi,d.checkBlockIsFileBlockWithPreview=Yi,d.checkBlockTypeHasDefaultProp=Qt,d.checkDefaultBlockTypeInSchema=P,d.checkDefaultInlineContentTypeInSchema=Jt,d.cleanHTMLToMarkdown=_e,d.contentNodeToInlineContent=de,d.contentNodeToTableContent=Ne,d.createAddFileButton=vt,d.createBlockSpec=se,d.createBlockSpecFromStronglyTypedTiptapNode=$,d.createDefaultBlockDOMOutputSpec=R,d.createDefaultFilePreview=ze,d.createExternalHTMLExporter=ne,d.createFigureWithCaption=ge,d.createFileAndCaptionWrapper=J,d.createFileBlockWrapper=ce,d.createInlineContentSpec=yi,d.createInlineContentSpecFromTipTapNode=gt,d.createInternalBlockSpec=Pe,d.createInternalHTMLSerializer=dt,d.createInternalInlineContentSpec=ft,d.createInternalStyleSpec=De,d.createLinkWithCaption=pe,d.createResizeHandlesWrapper=Re,d.createStronglyTypedTiptapNode=V,d.createStyleSpec=vi,d.createStyleSpecFromTipTapMark=F,d.createSuggestionMenu=Tn,d.defaultBlockSchema=Zt,d.defaultBlockSpecs=Ke,d.defaultBlockToHTML=Be,d.defaultInlineContentSchema=Xt,d.defaultInlineContentSpecs=qe,d.defaultProps=C,d.defaultStyleSchema=Xi,d.defaultStyleSpecs=Ge,d.fileBlockConfig=Lt,d.fileParse=Pt,d.filePropSchema=Bt,d.fileRender=It,d.fileToExternalHTML=At,d.filenameFromURL=_i,d.filterSuggestionItems=la,d.formatKeyboardShortcut=z,d.formattingToolbarPluginKey=co,d.getBlockFromPos=ut,d.getBlockInfo=W,d.getBlockInfoFromResolvedPos=U,d.getBlockInfoFromSelection=v,d.getBlockInfoWithManualOffset=me,d.getBlockNoteExtensions=Bo,d.getBlockSchemaFromSpecs=Ae,d.getDefaultEmojiPickerItems=na,d.getDefaultSlashMenuItems=ra,d.getInlineContentParseRules=bt,d.getInlineContentSchemaFromSpecs=He,d.getNearestBlockContainerPos=ae,d.getParseRules=ht,d.getStyleParseRules=yt,d.getStyleSchemaFromSpecs=Ue,d.imageBlockConfig=Ht,d.imageParse=Ut,d.imagePropSchema=jt,d.imageRender=Dt,d.imageToExternalHTML=zt,d.inheritedProps=Le,d.initializeESMDependencies=ke,d.inlineContentToNodes=j,d.insertOrUpdateBlock=A,d.isAppleOS=ct,d.isLinkInlineContent=Se,d.isPartialLinkInlineContent=Te,d.isSafari=ki,d.isStyledTextInlineContent=X,d.linkToolbarPluginKey=po,d.locales=di,d.markdownToBlocks=ao,d.mergeCSSClasses=O,d.nodeToBlock=x,d.nodeToCustomInlineContent=fe,d.parseEmbedElement=Oe,d.parseFigureElement=ue,d.parseImageElement=Ve,d.partialBlockToBlockForTesting=et,d.partialBlocksToBlocksForTesting=sa,d.propsToAttributes=Ie,d.sideMenuPluginKey=ko,d.stylePropsToAttributes=kt,d.tableContentToNodes=ie,d.tableHandlesPluginKey=te,d.uploadToTmpFilesDotOrg_DEV_ONLY=wi,d.videoBlockConfig=Ft,d.videoParse=Gt,d.videoPropSchema=Vt,d.videoRender=Kt,d.videoToExternalHTML=qt,d.wrapInBlockStructure=le,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
7
+ `:"",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 ao(e,t,o,i,n){const a=await ke(),r=a.unified.unified().use(a.remarkParse.default).use(a.remarkGfm.default).use(a.remarkRehype.default,{handlers:{...a.remarkRehype.defaultHandlers,code:_n}}).use(a.rehypeStringify.default).processSync(e);return We(r.value,t,o,i,n)}class Y{constructor(){u(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 ro{constructor(t,o,i,n){u(this,"state");u(this,"emitUpdate");u(this,"mouseDownHandler",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())});u(this,"dragstartHandler",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())});u(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()}});u(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 $e=new _.PluginKey("FilePanelPlugin");class lo extends Y{constructor(o){super();u(this,"view");u(this,"plugin");u(this,"closeMenu",()=>{var o;return(o=this.view)==null?void 0:o.closeMenu()});this.plugin=new _.Plugin({key:$e,view:i=>(this.view=new ro(o,$e,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($e))==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 so{constructor(t,o,i){u(this,"state");u(this,"emitUpdate");u(this,"preventHide",!1);u(this,"preventShow",!1);u(this,"shouldShow",({state:t,from:o,to:i,view:n})=>{const{doc:a,selection:r}=t,{empty:l}=r,s=!a.textBetween(o,i).length&&b.isTextSelection(t.selection);return!(!n.hasFocus()||l||s)});u(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())});u(this,"viewMousedownHandler",()=>{this.preventShow=!0});u(this,"viewMouseupHandler",()=>{this.preventShow=!1,setTimeout(()=>this.update(this.pmView))});u(this,"dragHandler",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())});u(this,"scrollHandler",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.referencePos=this.getSelectionBoundingBox(),this.emitUpdate())});u(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 m,g;const{state:i,composing:n}=t,{doc:a,selection:r}=i,l=o&&o.doc.eq(a)&&o.selection.eq(r);if(n||l)return;const{ranges:s}=r,c=Math.min(...s.map(f=>f.$from.pos)),p=Math.max(...s.map(f=>f.$to.pos)),h=(m=this.shouldShow)==null?void 0:m.call(this,{view:t,state:i,from:c,to:p});if(!this.preventShow&&(h||this.preventHide)){this.state={show:!0,referencePos:this.getSelectionBoundingBox()},this.emitUpdate();return}if((g=this.state)!=null&&g.show&&!this.preventHide&&(!h||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(b.isNodeSelection(o)){const r=this.pmView.nodeDOM(n);if(r)return r.getBoundingClientRect()}return b.posToDOMRect(this.pmView,n,a)}}const co=new _.PluginKey("FormattingToolbarPlugin");class uo extends Y{constructor(o){super();u(this,"view");u(this,"plugin");u(this,"closeMenu",()=>this.view.closeMenu());this.plugin=new _.Plugin({key:co,view:i=>(this.view=new so(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)}}class yn{constructor(t,o,i){u(this,"state");u(this,"emitUpdate");u(this,"menuUpdateTimer");u(this,"startMenuUpdateTimer");u(this,"stopMenuUpdateTimer");u(this,"mouseHoveredLinkMark");u(this,"mouseHoveredLinkMarkRange");u(this,"keyboardHoveredLinkMark");u(this,"keyboardHoveredLinkMarkRange");u(this,"linkMark");u(this,"linkMarkRange");u(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=b.getMarkRange(n,r.type,r.attrs)||void 0;break}}return this.startMenuUpdateTimer(),!1});u(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())});u(this,"scrollHandler",()=>{var t;this.linkMark!==void 0&&(t=this.state)!=null&&t.show&&(this.state.referencePos=b.posToDOMRect(this.pmView,this.linkMarkRange.from,this.linkMarkRange.to),this.emitUpdate())});u(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()},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(){var o;if(!this.pmView.hasFocus())return;const t=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 i=this.pmView.state.selection.$from.marks();for(const n of i)if(n.type.name===this.pmView.state.schema.mark("link").type.name){this.keyboardHoveredLinkMark=n,this.keyboardHoveredLinkMarkRange=b.getMarkRange(this.pmView.state.selection.$from,n.type,n.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:b.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((o=this.state)!=null&&o.show&&t&&(!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 po=new _.PluginKey("LinkToolbarPlugin");class ho extends Y{constructor(o){super();u(this,"view");u(this,"plugin");u(this,"editLink",(o,i)=>{this.view.editLink(o,i)});u(this,"deleteLink",()=>{this.view.deleteLink()});u(this,"startHideTimer",()=>{this.view.startMenuUpdateTimer()});u(this,"stopHideTimer",()=>{this.view.stopMenuUpdateTimer()});u(this,"closeMenu",()=>this.view.closeMenu());this.plugin=new _.Plugin({key:po,view:i=>(this.view=new yn(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}}function mo(e,t){const o=[];return e.descendants(i=>{var n;return i.type.name==="blockContainer"?((n=i.firstChild)==null?void 0:n.type.name)==="blockGroup"?!0:(o.push(x(i,t.blockSchema,t.inlineContentSchema,t.styleSchema)),!1):!0}),o}class Q extends _.Selection{constructor(o,i){super(o,i);u(this,"nodes");const n=o.node();this.nodes=[],o.doc.nodesBetween(o.pos,i.pos,(a,r,l)=>{if(l!==null&&l.eq(n))return this.nodes.push(a),!1})}static create(o,i,n=i){return new Q(o.resolve(i),o.resolve(n))}content(){return new y.Slice(y.Fragment.from(this.nodes),0,0)}eq(o){if(!(o instanceof Q)||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 Q(o.resolve(n.pos),o.resolve(a.pos))}toJSON(){return{type:"node",anchor:this.anchor,head:this.head}}}let D;function ye(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")}}function vn(e,t){const o=ye(e,t);if(o&&o.node.nodeType===1){const i=t.docView,n=i.nearestDesc(o.node,!0);return!n||n===i?null:n.posBefore}return null}function wn(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 l=e.$from.start(r-1),s=e.$to.end(r-1);o=t.resolve(l-1).pos,i=t.resolve(s+1).pos}else o=e.from,i=e.to;return{from:o,to:i}}function fo(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=(p,h)=>Array.prototype.indexOf.call(p.children,h),r=a(n,e.domAtPos(t+1).node.parentElement),l=a(n,e.domAtPos(o-1).node.parentElement);for(let p=n.childElementCount-1;p>=0;p--)(p>l||p<r)&&i.removeChild(i.children[p]);go(e.root),D=i;const c=e.dom.className.split(" ").filter(p=>p!=="ProseMirror"&&p!=="bn-root"&&p!=="bn-editor").join(" ");D.className=D.className+" bn-drag-preview "+c,e.root instanceof ShadowRoot?e.root.appendChild(D):e.root.body.appendChild(D)}function go(e){D!==void 0&&(e instanceof ShadowRoot?e.removeChild(D):e.body.removeChild(D),D=void 0)}function Cn(e,t){if(!e.dataTransfer)return;const o=t.prosemirrorView,i=o.dom.getBoundingClientRect(),n={left:i.left+i.width/2,top:e.clientY},a=o.root.elementsFromPoint(n.left,n.top);let r;for(const s of a)if(o.dom.contains(s)){r=ye(s,o);break}if(!r)return;const l=vn(r.node,o);if(l!=null){const s=o.state.selection,c=o.state.doc,{from:p,to:h}=wn(s,c),m=p<=l&&l<h,g=s.$anchor.node()!==s.$head.node()||s instanceof Q;m&&g?(o.dispatch(o.state.tr.setSelection(Q.create(c,p,h))),fo(o,p,h)):(o.dispatch(o.state.tr.setSelection(_.NodeSelection.create(o.state.doc,l))),fo(o,l));const f=o.state.selection.content(),k=t.pmSchema,w=tt.__serializeForClipboard(o,f).dom.innerHTML,T=ne(k,t),E=mo(f.content,t.schema),H=T.exportBlocks(E,{}),K=_e(H);e.dataTransfer.clearData(),e.dataTransfer.setData("blocknote/html",w),e.dataTransfer.setData("text/html",H),e.dataTransfer.setData("text/plain",K),e.dataTransfer.effectAllowed="move",e.dataTransfer.setDragImage(D,0,0),o.dragging={slice:f,move:!0}}}const En=(e,t)=>{if(!t.dom.firstChild)return;const o=t.dom.firstChild.getBoundingClientRect(),i={left:o.left+o.width/2,top:e.y},n=t.root.elementsFromPoint(i.left,i.top);let a;for(const r of n)if(t.dom.contains(r)){a=ye(r,t);break}return a};class bo{constructor(t,o,i){u(this,"state");u(this,"emitUpdate");u(this,"mousePos");u(this,"hoveredBlock");u(this,"menuFrozen",!1);u(this,"updateState",t=>{this.state=t,this.emitUpdate(this.state)});u(this,"updateStateFromMousePos",()=>{var i,n,a,r;if(this.menuFrozen||!this.mousePos)return;const t=En(this.mousePos,this.pmView);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 l=this.pmView.dom.firstChild.getBoundingClientRect(),s=o.getBoundingClientRect();this.updateState({show:!0,referencePos:new DOMRect(l.x,s.y,s.width,s.height),block:this.editor.getBlock(this.hoveredBlock.getAttribute("data-id"))})}});u(this,"onDrop",t=>{var i;if(this.editor._tiptapEditor.commands.blur(),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=new Event("drop",t),a=this.pmView.dom.firstChild.getBoundingClientRect();n.clientX=t.clientX<a.left||t.clientX>a.left+a.width?a.left+a.width/2:t.clientX,n.clientY=Math.min(Math.max(t.clientY,a.top),a.top+a.height),n.dataTransfer=t.dataTransfer,n.preventDefault=()=>t.preventDefault(),n.synthetic=!0,this.pmView.dom.dispatchEvent(n)}});u(this,"onDragOver",t=>{var i;if(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=new Event("dragover",t),a=this.pmView.dom.firstChild.getBoundingClientRect();n.clientX=a.left+a.width/2,n.clientY=t.clientY,n.dataTransfer=t.dataTransfer,n.preventDefault=()=>t.preventDefault(),n.synthetic=!0,this.pmView.dom.dispatchEvent(n)}});u(this,"onKeyDown",t=>{var o;(o=this.state)!=null&&o.show&&this.editor.isFocused()&&(this.state.show=!1,this.emitUpdate(this.state))});u(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()});this.editor=t,this.pmView=o,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized side menu");i(this.state)},this.pmView.root.addEventListener("drop",this.onDrop,!0),this.pmView.root.addEventListener("dragover",this.onDragOver),ke(),this.pmView.root.addEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.addEventListener("keydown",this.onKeyDown,!0)}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("dragover",this.onDragOver),this.pmView.root.removeEventListener("drop",this.onDrop,!0),this.pmView.root.removeEventListener("keydown",this.onKeyDown,!0)}}const ko=new _.PluginKey("SideMenuPlugin");class _o extends Y{constructor(o){super();u(this,"view");u(this,"plugin");u(this,"blockDragStart",o=>{Cn(o,this.editor)});u(this,"blockDragEnd",()=>go(this.editor.prosemirrorView.root));u(this,"freezeMenu",()=>this.view.menuFrozen=!0);u(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:ko,view:i=>(this.view=new bo(o,i,n=>{this.emit("update",n)}),this.view)})}onUpdate(o){return this.on("update",o)}}const xn=b.findParentNode(e=>e.type.name==="blockContainer");class Sn{constructor(t,o){u(this,"state");u(this,"emitUpdate");u(this,"rootEl");u(this,"pluginState");u(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)}});u(this,"closeMenu",()=>{this.editor.dispatch(this.editor._tiptapEditor.view.state.tr.setMeta(ee,null))});u(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()});this.editor=t,this.pluginState=void 0,this.emitUpdate=i=>{var n;if(!this.state)throw new Error("Attempting to update uninitialized suggestions menu");o(i,{...this.state,ignoreQueryLength:(n=this.pluginState)==null?void 0:n.ignoreQueryLength})},this.rootEl=this.editor._tiptapEditor.view.root,this.rootEl.addEventListener("scroll",this.handleScroll,!0)}update(t,o){var c;const i=ee.getState(o),n=ee.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 s=(c=this.rootEl)==null?void 0:c.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);this.editor.isEditable&&s&&(this.state={show:!0,referencePos:s.getBoundingClientRect(),query:this.pluginState.query},this.emitUpdate(this.pluginState.triggerCharacter))}destroy(){var t;(t=this.rootEl)==null||t.removeEventListener("scroll",this.handleScroll,!0)}}const ee=new _.PluginKey("SuggestionMenuPlugin");class yo extends Y{constructor(o){super();u(this,"view");u(this,"plugin");u(this,"triggerCharacters",[]);u(this,"addTriggerCharacter",o=>{this.triggerCharacters.push(o)});u(this,"removeTriggerCharacter",o=>{this.triggerCharacters=this.triggerCharacters.filter(i=>i!==o)});u(this,"closeMenu",()=>this.view.closeMenu());u(this,"clearQuery",()=>this.view.clearQuery());const i=this.triggerCharacters;this.plugin=new _.Plugin({key:ee,view:()=>(this.view=new Sn(o,(n,a)=>{this.emit(`update ${n}`,a)}),this.view),state:{init(){},apply(n,a,r,l){if(n.getMeta("orderedListIndexing")!==void 0)return a;const s=n.getMeta(ee);if(typeof s=="object"&&s!==null&&a===void 0)return{triggerCharacter:s.triggerCharacter,deleteTriggerCharacter:s.deleteTriggerCharacter!==!1,queryStartPos:l.selection.from,query:"",decorationId:`id_${Math.floor(Math.random()*4294967295)}`,ignoreQueryLength:s==null?void 0:s.ignoreQueryLength};if(a===void 0)return a;if(l.selection.from!==l.selection.to||s===null||n.getMeta("focus")||n.getMeta("blur")||n.getMeta("pointer")||a.triggerCharacter!==void 0&&l.selection.from<a.queryStartPos)return;const c={...a};return c.query=l.doc.textBetween(a.queryStartPos,l.selection.from),c}},props:{handleTextInput(n,a,r,l){const s=this.getState(n.state);return i.includes(l)&&s===void 0?(n.dispatch(n.state.tr.insertText(l).scrollIntoView().setMeta(ee,{triggerCharacter:l})),!0):!1},decorations(n){const a=this.getState(n);if(a===void 0)return null;if(!a.deleteTriggerCharacter){const r=xn(n.selection);if(r)return L.DecorationSet.create(n.doc,[L.Decoration.node(r.pos,r.pos+r.node.nodeSize,{nodeName:"span",class:"bn-suggestion-decorator","data-decoration-id":a.decorationId})])}return L.DecorationSet.create(n.doc,[L.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 Tn(e,t){e.suggestionMenus.addTriggerCharacter(t)}let I;function vo(e){I||(I=document.createElement("div"),I.innerHTML="_",I.style.opacity="0",I.style.height="1px",I.style.width="1px",e instanceof Document?e.body.appendChild(I):e.appendChild(I))}function Mn(e){I&&(e instanceof Document?e.body.removeChild(I):e.removeChild(I),I=void 0)}function ve(e){return Array.prototype.indexOf.call(e.parentElement.childNodes,e)}function Bn(e){for(;e&&e.nodeName!=="TD"&&e.nodeName!=="TH";)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}function Ln(e,t){e.forEach(o=>{const i=t.querySelectorAll(o);for(let n=0;n<i.length;n++)i[n].style.visibility="hidden"})}class wo{constructor(t,o,i){u(this,"state");u(this,"emitUpdate");u(this,"tableId");u(this,"tablePos");u(this,"menuFrozen",!1);u(this,"mouseState","up");u(this,"prevWasEditable",null);u(this,"viewMousedownHandler",()=>{this.mouseState="down"});u(this,"viewMouseupHandler",t=>{this.mouseState="up",this.mouseMoveHandler(t)});u(this,"mouseMoveHandler",t=>{var c,p,h,m;if(this.menuFrozen||(this.mouseState==="down"&&(this.mouseState="selecting",(c=this.state)!=null&&c.show&&(this.state.show=!1,this.emitUpdate())),this.mouseState==="selecting"))return;const o=Bn(t.target);if(!o||!this.editor.isEditable){(p=this.state)!=null&&p.show&&(this.state.show=!1,this.emitUpdate());return}const i=ve(o),n=ve(o.parentElement),a=o.getBoundingClientRect(),r=(m=(h=o.parentElement)==null?void 0:h.parentElement)==null?void 0:m.getBoundingClientRect();if(!r)return;const l=ye(o,this.pmView);if(!l)return;let s;if(this.editor._tiptapEditor.state.doc.descendants((g,f)=>{if(typeof s<"u")return!1;if(g.type.name!=="blockContainer"||g.attrs.id!==l.id)return!0;const k=x(g,this.editor.schema.blockSchema,this.editor.schema.inlineContentSchema,this.editor.schema.styleSchema,this.editor.blockCache);return Yt("table",k,this.editor)&&(this.tablePos=f+1,s=k),!1}),!!s&&(this.tableId=l.id,!(this.state!==void 0&&this.state.show&&this.tableId===l.id&&this.state.rowIndex===n&&this.state.colIndex===i)))return this.state={show:!0,referencePosCell:a,referencePosTable:r,block:s,colIndex:i,rowIndex:n,draggingState:void 0},this.emitUpdate(),!1});u(this,"dragOverHandler",t=>{var m;if(((m=this.state)==null?void 0:m.draggingState)===void 0)return;t.preventDefault(),t.dataTransfer.dropEffect="move",Ln(["column-resize-handle","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(g=>g.tagName==="TD"||g.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=ve(n.parentElement),l=ve(n),s=this.state.draggingState.draggedCellOrientation==="row"?this.state.rowIndex:this.state.colIndex,p=(this.state.draggingState.draggedCellOrientation==="row"?r:l)!==s;(this.state.rowIndex!==r||this.state.colIndex!==l)&&(this.state.rowIndex=r,this.state.colIndex=l,this.state.referencePosCell=n.getBoundingClientRect(),a=!0);const h=this.state.draggingState.draggedCellOrientation==="row"?o.top:o.left;this.state.draggingState.mousePos!==h&&(this.state.draggingState.mousePos=h,a=!0),a&&this.emitUpdate(),p&&this.editor.dispatch(this.pmView.state.tr.setMeta(te,!0))});u(this,"dropHandler",t=>{if(this.state===void 0||this.state.draggingState===void 0)return;t.preventDefault();const o=this.state.block.content.rows;if(this.state.draggingState.draggedCellOrientation==="row"){const i=o[this.state.draggingState.originalIndex];o.splice(this.state.draggingState.originalIndex,1),o.splice(this.state.rowIndex,0,i)}else{const i=o.map(n=>n.cells[this.state.draggingState.originalIndex]);o.forEach((n,a)=>{n.cells.splice(this.state.draggingState.originalIndex,1),n.cells.splice(this.state.colIndex,0,i[a])})}this.editor.updateBlock(this.state.block,{type:"table",content:{type:"tableContent",rows:o}}),this.editor.setTextCursorPosition(this.state.block.id)});u(this,"scrollHandler",()=>{var t;if((t=this.state)!=null&&t.show){const o=this.pmView.root.querySelector(`[data-node-type="blockContainer"][data-id="${this.tableId}"] table`),i=o.querySelector(`tr:nth-child(${this.state.rowIndex+1}) > td:nth-child(${this.state.colIndex+1})`);this.state.referencePosTable=o.getBoundingClientRect(),this.state.referencePosCell=i.getBoundingClientRect(),this.emitUpdate()}});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),o.dom.addEventListener("mouseup",this.viewMouseupHandler),o.root.addEventListener("dragover",this.dragOverHandler),o.root.addEventListener("drop",this.dropHandler),o.root.addEventListener("scroll",this.scrollHandler,!0)}destroy(){this.pmView.dom.removeEventListener("mousemove",this.mouseMoveHandler),this.pmView.root.removeEventListener("dragover",this.dragOverHandler),this.pmView.root.removeEventListener("drop",this.dropHandler),this.pmView.root.removeEventListener("scroll",this.scrollHandler,!0)}}const te=new _.PluginKey("TableHandlesPlugin");class Co extends Y{constructor(o){super();u(this,"view");u(this,"plugin");u(this,"colDragStart",o=>{if(this.view.state===void 0)throw new Error("Attempted to drag table column, but no table block was hovered prior.");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(te,{draggedCellOrientation:this.view.state.draggingState.draggedCellOrientation,originalIndex:this.view.state.colIndex,newIndex:this.view.state.colIndex,tablePos:this.view.tablePos})),vo(this.editor._tiptapEditor.view.root),o.dataTransfer.setDragImage(I,0,0),o.dataTransfer.effectAllowed="move"});u(this,"rowDragStart",o=>{if(this.view.state===void 0)throw new Error("Attempted to drag table row, but no table block was hovered prior.");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(te,{draggedCellOrientation:this.view.state.draggingState.draggedCellOrientation,originalIndex:this.view.state.rowIndex,newIndex:this.view.state.rowIndex,tablePos:this.view.tablePos})),vo(this.editor._tiptapEditor.view.root),o.dataTransfer.setDragImage(I,0,0),o.dataTransfer.effectAllowed="copyMove"});u(this,"dragEnd",()=>{if(this.view.state===void 0)throw new Error("Attempted to drag table row, but no table block was hovered prior.");this.view.state.draggingState=void 0,this.view.emitUpdate(),this.editor.dispatch(this.editor._tiptapEditor.state.tr.setMeta(te,null)),Mn(this.editor._tiptapEditor.view.root)});u(this,"freezeHandles",()=>{this.view.menuFrozen=!0});u(this,"unfreezeHandles",()=>{this.view.menuFrozen=!1});this.editor=o,this.plugin=new _.Plugin({key:te,view:i=>(this.view=new wo(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,a=[];if(n===this.view.state.draggingState.originalIndex)return L.DecorationSet.create(i.doc,a);const r=i.doc.resolve(this.view.tablePos+1),l=r.node();if(this.view.state.draggingState.draggedCellOrientation==="row"){const s=i.doc.resolve(r.posAtIndex(n)+1),c=s.node();for(let p=0;p<c.childCount;p++){const h=i.doc.resolve(s.posAtIndex(p)+1),m=h.node(),g=h.pos+(n>this.view.state.draggingState.originalIndex?m.nodeSize-2:0);a.push(L.Decoration.widget(g,()=>{const f=document.createElement("div");return f.className="bn-table-drop-cursor",f.style.left="0",f.style.right="0",n>this.view.state.draggingState.originalIndex?f.style.bottom="-2px":f.style.top="-3px",f.style.height="4px",f}))}}else for(let s=0;s<l.childCount;s++){const c=i.doc.resolve(r.posAtIndex(s)+1),p=i.doc.resolve(c.posAtIndex(n)+1),h=p.node(),m=p.pos+(n>this.view.state.draggingState.originalIndex?h.nodeSize-2:0);a.push(L.Decoration.widget(m,()=>{const g=document.createElement("div");return g.className="bn-table-drop-cursor",g.style.top="0",g.style.bottom="0",n>this.view.state.draggingState.originalIndex?g.style.right="-2px":g.style.left="-3px",g.style.width="4px",g}))}return L.DecorationSet.create(i.doc,a)}}})}onUpdate(o){return this.on("update",o)}}const Ze=["blocknote/html","Files","text/html","text/plain"];function In(e,t){if(!e.startsWith(".")||!t.startsWith("."))throw new Error("The strings provided are not valid file extensions.");return e===t}function Pn(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 Eo(e,t){if(!t.uploadFile)return;const o="dataTransfer"in e?e.dataTransfer:e.clipboardData;if(o===null)return;let i=null;for(const r of Ze)if(o.types.includes(r)){i=r;break}if(i!=="Files")return;const n=o.items;if(!n)return;e.preventDefault();const a=Object.values(t.schema.blockSchema).filter(r=>r.isFileBlock);for(let r=0;r<n.length;r++){let l="file";for(const c of a)for(const p of c.fileBlockAccept||[]){const h=p.startsWith("."),m=n[r].getAsFile();if(m&&(!h&&m.type&&Pn(n[r].type,p)||h&&In("."+m.name.split(".").pop(),p))){l=c.type;break}}const s=n[r].getAsFile();if(s){const c={type:l,props:{name:s.name}};let p;if(e.type==="paste")p=t.insertBlocks([c],t.getTextCursorPosition().block,"after")[0].id;else if(e.type==="drop"){const g={left:e.clientX,top:e.clientY},f=t._tiptapEditor.view.posAtCoords(g);if(!f)return;const k=ae(t._tiptapEditor.state.doc,f.pos),w=W(k);p=t.insertBlocks([c],w.blockContainer.node.attrs.id,"after")[0].id}else return;const h=await t.uploadFile(s,p),m=typeof h=="string"?{props:{url:h}}:{...h};t.updateBlock(p,m)}}}const An=e=>b.Extension.create({name:"dropFile",addProseMirrorPlugins(){return[new _.Plugin({props:{handleDOMEvents:{drop(t,o){if(!e.isEditable)return;let i=null;for(const n of Ze)if(o.dataTransfer.types.includes(n)){i=n;break}return i===null?!0:i==="Files"?(Eo(o,e),!0):!1}}}})]}}),Nn=e=>b.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 Ze)if(o.clipboardData.types.includes(a)){i=a;break}if(!i)return!0;if(i==="Files")return Eo(o,e),!0;let n=o.clipboardData.getData(i);return i==="blocknote/html"?(e._tiptapEditor.view.pasteHTML(n),!0):i==="text/html"?(n=no(n.trim()).innerHTML,e._tiptapEditor.view.pasteHTML(n),!0):(e._tiptapEditor.view.pasteText(n),!0)}}}})]}});function jn(e,t,o){var l;let i=!1;const n=e.state.selection instanceof oe.CellSelection;if(!n){const s=e.state.doc.slice(e.state.selection.from,e.state.selection.to,!1).content,c=[];for(let p=0;p<s.childCount;p++)c.push(s.child(p));i=c.find(p=>p.type.name==="blockContainer"||p.type.name==="blockGroup"||p.type.spec.group==="blockContent")===void 0,i&&(t=s)}let a;const r=ne(e.state.schema,o);if(n){((l=t.firstChild)==null?void 0:l.type.name)==="table"&&(t=t.firstChild.content);const s=Ne(t,o.schema.inlineContentSchema,o.schema.styleSchema);a=r.exportInlineContent(s,{})}else if(i){const s=de(t,o.schema.inlineContentSchema,o.schema.styleSchema);a=r.exportInlineContent(s,{})}else{const s=mo(t,o.schema);a=r.exportBlocks(s,{})}return a}function xo(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=tt.__serializeForClipboard(e,e.state.selection.content()).dom.innerHTML,i=e.state.selection.content().content,n=jn(e,i,t),a=_e(n);return{clipboardHTML:o,externalHTML:n,markdown:a}}const So=(e,t,o)=>{o.preventDefault(),o.clipboardData.clearData();const{clipboardHTML:i,externalHTML:n,markdown:a}=xo(t,e);o.clipboardData.setData("blocknote/html",i),o.clipboardData.setData("text/html",n),o.clipboardData.setData("text/plain",a)},Hn=e=>b.Extension.create({name:"copyToClipboard",addProseMirrorPlugins(){return[new _.Plugin({props:{handleDOMEvents:{copy(t,o){return So(e,t,o),!0},cut(t,o){return So(e,t,o),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}=xo(t,e);return o.dataTransfer.setData("blocknote/html",i),o.dataTransfer.setData("text/html",n),o.dataTransfer.setData("text/plain",a),!0}}}})]}}),Dn=b.Extension.create({name:"blockBackgroundColor",addGlobalAttributes(){return[{types:["blockContainer"],attributes:{backgroundColor:{default:C.backgroundColor.default,parseHTML:e=>e.hasAttribute("data-background-color")?e.getAttribute("data-background-color"):C.backgroundColor.default,renderHTML:e=>e.backgroundColor===C.backgroundColor.default?{}:{"data-background-color":e.backgroundColor}}}}]}}),To=(e,t)=>{if(!t.nodeBefore)throw new Error(`Attempted to get previous blockContainer node for merge at position ${t.pos} but a previous node does not exist`);let i=t.posAtIndex(t.index()-1),n=U(e.resolve(i));for(;n.blockGroup;){const a=n.blockGroup.node;i=e.resolve(n.blockGroup.beforePos+1).posAtIndex(a.childCount-1),n=U(e.resolve(i))}return e.resolve(i)},Un=(e,t)=>{const o=U(e),i=U(t);return o.blockContent.node.type.spec.content==="inline*"&&i.blockContent.node.type.spec.content==="inline*"&&o.blockContent.node.childCount>0},zn=(e,t,o,i)=>{const n=U(i);if(n.blockGroup){const a=e.doc.resolve(n.blockGroup.beforePos+1),r=e.doc.resolve(n.blockGroup.afterPos-1),l=a.blockRange(r);t&&e.tr.lift(l,i.depth)}if(t){const a=U(o);t(e.tr.delete(a.blockContent.afterPos-1,n.blockContent.beforePos+1))}return!0},Mo=e=>({state:t,dispatch:o})=>{const i=t.doc.resolve(e),n=To(t.doc,i);return Un(n,i)?zn(t,o,n,i):!1},On=b.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=v(a),l=a.selection.from===r.blockContent.beforePos+1,s=r.blockContent.node.type.name==="paragraph";return l&&!s?n.command(S(this.options.editor,r.blockContainer.beforePos,{type:"paragraph",props:{}})):!1}),()=>n.command(({state:a})=>{const{blockContent:r}=v(a);return a.selection.from===r.beforePos+1?n.liftListItem("blockContainer"):!1}),()=>n.command(({state:a})=>{const{blockContainer:r,blockContent:l}=v(a),{depth:s}=a.doc.resolve(r.beforePos),c=a.selection.from===l.beforePos+1,p=a.selection.empty,h=r.beforePos===1,m=r.beforePos;return!h&&c&&p&&s===1?i().command(Mo(m)).scrollIntoView().run():!1}),()=>n.command(({state:a})=>{const r=v(a),{depth:l}=a.doc.resolve(r.blockContainer.beforePos),s=a.selection.from===r.blockContent.beforePos+1,c=a.selection.empty;if(!(r.blockContainer.beforePos===1)&&s&&c&&l===1){const h=To(a.doc,a.doc.resolve(r.blockContainer.beforePos)),m=U(a.doc.resolve(h.pos));if(m.blockContent.node.type.spec.content===""||m.blockContent.node.type.spec.content==="inline*"&&m.blockContent.node.childCount===0)return i().cut({from:r.blockContainer.beforePos,to:r.blockContainer.afterPos},m.blockContainer.afterPos).deleteRange({from:m.blockContainer.beforePos,to:m.blockContainer.afterPos}).run()}return!1})]),Delete:()=>this.editor.commands.first(({commands:i})=>[()=>i.deleteSelection(),()=>i.command(({state:n})=>{const{blockContainer:a,blockContent:r,blockGroup:l}=v(n),{depth:s}=n.doc.resolve(a.beforePos),c=a.afterPos===n.doc.nodeSize-3,p=n.selection.from===r.afterPos-1,h=n.selection.empty;if(!c&&p&&h&&!(l!==void 0)){let g=s,f=a.afterPos+1,k=n.doc.resolve(f).depth;for(;k<g;)g=k,f+=2,k=n.doc.resolve(f).depth;return i.command(Mo(f-1))}return!1})]),Enter:()=>this.editor.commands.first(({commands:i})=>[()=>i.command(({state:n})=>{const{blockContent:a,blockContainer:r}=v(n),{depth:l}=n.doc.resolve(r.beforePos),s=n.selection.$anchor.parentOffset===0,c=n.selection.anchor===n.selection.head,p=a.node.childCount===0,h=l>1;return s&&c&&p&&h?i.liftListItem("blockContainer"):!1}),()=>i.command(({state:n,dispatch:a})=>{const{blockContainer:r,blockContent:l}=v(n),s=n.selection.$anchor.parentOffset===0,c=n.selection.anchor===n.selection.head,p=l.node.childCount===0;if(s&&c&&p){const h=r.afterPos,m=h+2;if(a){const g=n.schema.nodes.blockContainer.createAndFill();n.tr.insert(h,g).scrollIntoView(),n.tr.setSelection(new _.TextSelection(n.doc.resolve(m)))}return!0}return!1}),()=>i.command(({state:n,chain:a})=>{const{blockContent:r}=v(n),l=n.selection.$anchor.parentOffset===0;return r.node.childCount===0?!1:(a().deleteSelection().command($t(n.selection.from,l,l)).run(),!0)})]),Tab:()=>{var i,n,a;return(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.sinkListItem("blockContainer"),!0)},"Shift-Tab":()=>{var i,n,a;return(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.moveBlockUp(),!0),"Shift-Mod-ArrowDown":()=>(this.options.editor.moveBlockDown(),!0)}}}),Rn=b.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}}}}]}}),Vn=b.Extension.create({name:"blockTextColor",addGlobalAttributes(){return[{types:["blockContainer"],attributes:{textColor:{default:C.textColor.default,parseHTML:e=>e.hasAttribute("data-text-color")?e.getAttribute("data-text-color"):C.textColor.default,renderHTML:e=>e.textColor===C.textColor.default?{}:{"data-text-color":e.textColor}}}}]}}),Fn=b.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,l=e.getState(i),s=n.content.size-2,c=r.nodes.blockContainer,p=r.nodes.paragraph;if(l)return a.insert(s,c.create(void 0,p.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")throw new Error("Expected blockContainer");const n=i.firstChild;if(!n)throw new Error("Expected blockContent");return i.nodeSize>4||n.type.spec.content!=="inline*"}}})]}}),Kn={blockColor:"data-block-color",blockStyle:"data-block-style",id:"data-id",depth:"data-depth",depthChange:"data-depth-change"},Gn=b.Node.create({name:"blockContainer",group:"blockContainer",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(Kn))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=O("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}}}),qn=b.Node.create({name:"blockGroup",group:"blockGroup",content:"blockContainer+",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=O("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}}}),Wn=b.Node.create({name:"doc",topNode:!0,content:"blockGroup"}),Bo=e=>{var i;const t=[b.extensions.ClipboardTextSerializer,b.extensions.Commands,b.extensions.Editable,b.extensions.FocusEvents,b.extensions.Tabindex,$o.Gapcursor,Z.configure({types:["blockContainer"],setIdAttribute:e.setIdAttribute}),Zo.HardBreak.extend({priority:10}),Yo.Text,Jo.Link.extend({addKeyboardShortcuts(){return{"Mod-k":()=>(this.editor.commands.toggleLink({href:""}),!0)}}}),...Object.values(e.styleSpecs).map(n=>n.implementation.mark),Vn,Dn,Rn,b.Extension.create({name:"OverrideEscape",addKeyboardShortcuts(){return{Escape:()=>e.editor.suggestionMenus.shown?!1:this.editor.commands.blur()}}}),Wn,Gn.configure({editor:e.editor,domAttributes:e.domAttributes}),On.configure({editor:e.editor}),qn.configure({domAttributes:e.domAttributes}),...Object.values(e.inlineContentSpecs).filter(n=>n.config!=="link"&&n.config!=="text").map(n=>n.implementation.node.configure({editor:e.editor})),...Object.values(e.blockSpecs).flatMap(n=>[...(n.implementation.requiredExtensions||[]).map(a=>a.configure({editor:e.editor,domAttributes:e.domAttributes})),n.implementation.node.configure({editor:e.editor,domAttributes:e.domAttributes})]),Hn(e.editor),Nn(e.editor),An(e.editor),Wo.Dropcursor.configure({width:5,color:"#ddeeff"}),...e.trailingBlock===void 0||e.trailingBlock?[Fn]:[]];if(e.collaboration){if(t.push(ai.default.configure({fragment:e.collaboration.fragment})),(i=e.collaboration.provider)!=null&&i.awareness){const n=a=>{const r=document.createElement("span");r.classList.add("collaboration-cursor__caret"),r.setAttribute("style",`border-color: ${a.color}`);const l=document.createElement("span");l.classList.add("collaboration-cursor__label"),l.setAttribute("style",`background-color: ${a.color}`),l.insertBefore(document.createTextNode(a.name),null);const s=document.createTextNode("⁠"),c=document.createTextNode("⁠");return r.insertBefore(s,null),r.insertBefore(l,null),r.insertBefore(c,null),r};t.push(ri.default.configure({user:e.collaboration.user,render:e.collaboration.renderCursor||n,provider:e.collaboration.provider}))}}else t.push(Xo.History);const o=e.disableExtensions||[];return t.filter(n=>!o.includes(n.name))};function $n(e,t){const o=[];return e.forEach((i,n,a)=>{a!==t&&o.push(i)}),y.Fragment.from(o)}function Zn(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.create(void 0,e.child(i));o.push(n)}else o.push(e.child(i));return e=y.Fragment.from(o),e}function Xn(e,t){let o=y.Fragment.from(e.content);o=Zn(o,t.state.schema);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.spec.group==="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=$n(o,i+1))}const a=t.state.schema.nodes.blockContainer.create(void 0,n);o=o.replaceChild(i,a)}return new y.Slice(o,e.openStart,e.openEnd)}function Xe(e){return e&&Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}class we{constructor(t){u(this,"blockSpecs");u(this,"inlineContentSpecs");u(this,"styleSpecs");u(this,"blockSchema");u(this,"inlineContentSchema");u(this,"styleSchema");u(this,"BlockNoteEditor","only for types");u(this,"Block","only for types");u(this,"PartialBlock","only for types");this.blockSpecs=Xe(t==null?void 0:t.blockSpecs)||Ke,this.inlineContentSpecs=Xe(t==null?void 0:t.inlineContentSpecs)||qe,this.styleSpecs=Xe(t==null?void 0:t.styleSpecs)||Ge,this.blockSchema=Ae(this.blockSpecs),this.inlineContentSchema=He(this.inlineContentSpecs),this.styleSchema=Ue(this.styleSpecs)}static create(t){return new we(t)}}const xe=class xe extends b.Editor{constructor(o,i){super({...o,content:void 0});u(this,"_state");u(this,"mount",o=>{o?(this.options.element=o,this.createViewAlternative()):this.destroy()});const n=this.schema;let a;const r=n.nodes.doc.createAndFill;n.nodes.doc.createAndFill=(...s)=>{if(a)return a;const c=r.apply(n.nodes.doc,s),p=JSON.parse(JSON.stringify(c.toJSON()));return p.content[0].content[0].attrs.id="initialBlockId",a=y.Node.fromJSON(n,p),a};let l;try{const s=o==null?void 0:o.content.map(c=>q(c,this.schema,i).toJSON());l=b.createDocument({type:"doc",content:[{type:"blockGroup",content:s}]},this.schema,this.options.parseOptions)}catch(s){throw console.error("Error creating document from blocks passed as `initialContent`. Caused by exception: ",s),new Error("Error creating document from blocks passed as `initialContent`:\n"+ +JSON.stringify(o.content))}this._state=_.EditorState.create({doc:l,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(){queueMicrotask(()=>{this.view=new L.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})}};u(xe,"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 xe(o,i)}finally{n&&(globalThis.window.setTimeout=n)}});let Ce=xe;Ce.prototype.createView=function(){this.options.onPaste=this.options.onDrop=void 0};const Jn=new _.PluginKey("blocknote-placeholder"),Yn=(e,t)=>new _.Plugin({key:Jn,view:()=>{const o=document.createElement("style"),i=e._tiptapEditor.options.injectNonce;i&&o.setAttribute("nonce",i),e._tiptapEditor.view.root instanceof ShadowRoot?e._tiptapEditor.view.root.append(o):e._tiptapEditor.view.root.head.appendChild(o);const n=o.sheet,a=(l="")=>`.bn-block-content${l} .bn-inline-content:has(> .ProseMirror-trailingBreak:only-child):before`,r=(l,s=!0)=>{const c=s?"[data-is-empty-and-focused]":"";if(l==="default")return a(c);const p=`[data-content-type="${l}"]`;return a(c+p)};for(const[l,s]of Object.entries(t)){const c=l==="default";n.insertRule(`${r(l,c)}{ content: ${JSON.stringify(s)}; }`),c||n.insertRule(`${r(l,!0)}{ content: ${JSON.stringify(s)}; }`)}return{destroy:()=>{e._tiptapEditor.view.root instanceof ShadowRoot?e._tiptapEditor.view.root.removeChild(o):e._tiptapEditor.view.root.head.removeChild(o)}}},props:{decorations:o=>{const{doc:i,selection:n}=o;if(!e.isEditable||!n.empty)return;const a=n.$anchor,r=a.parent;if(r.content.size>0)return null;const l=a.before(),s=L.Decoration.node(l,l+r.nodeSize,{"data-is-empty-and-focused":"true"});return L.DecorationSet.create(i,[s])}}}),Qn=new _.PluginKey("node-selection-keyboard"),ea=()=>new _.Plugin({key:Qn,props:{handleKeyDown:(e,t)=>{if("node"in e.state.selection){if(t.ctrlKey||t.metaKey)return!1;if(t.key.length===1)return t.preventDefault(),!0;if(t.key==="Enter"&&!t.shiftKey&&!t.altKey&&!t.ctrlKey&&!t.metaKey){const o=e.state.tr;return e.dispatch(o.insert(e.state.tr.selection.$to.after(),e.state.schema.nodes.paragraph.create()).setSelection(new _.TextSelection(o.doc.resolve(e.state.tr.selection.$to.after()+1)))),!0}}return!1}}}),Lo=new _.PluginKey("previous-blocks"),ta={index:"index",level:"level",type:"type",depth:"depth","depth-change":"depth-change"},oa=()=>{let e;return new _.Plugin({key:Lo,view(t){return{update:async(o,i)=>{var n;((n=this.key)==null?void 0:n.getState(o.state).updatedBlocks.size)>0&&(e=setTimeout(()=>{o.dispatch(o.state.tr.setMeta(Lo,{clearUpdate:!0}))},0))},destroy:()=>{e&&clearTimeout(e)}}},state:{init(){return{prevTransactionOldBlockAttrs:{},currentTransactionOldBlockAttrs:{},updatedBlocks:new Set}},apply(t,o,i,n){if(o.currentTransactionOldBlockAttrs={},o.updatedBlocks.clear(),!t.docChanged||i.doc.eq(n.doc))return o;const a={},r=b.findChildren(i.doc,c=>c.attrs.id),l=new Map(r.map(c=>[c.node.attrs.id,c])),s=b.findChildren(n.doc,c=>c.attrs.id);for(const c of s){const p=l.get(c.node.attrs.id),h=p==null?void 0:p.node.firstChild,m=c.node.firstChild;if(p&&h&&m){const g={index:m.attrs.index,level:m.attrs.level,type:m.type.name,depth:n.doc.resolve(c.pos).depth};let f={index:h.attrs.index,level:h.attrs.level,type:h.type.name,depth:i.doc.resolve(p.pos).depth};a[c.node.attrs.id]=f,t.getMeta("numberedListIndexing")&&(c.node.attrs.id in o.prevTransactionOldBlockAttrs&&(f=o.prevTransactionOldBlockAttrs[c.node.attrs.id]),g.type==="numberedListItem"&&(f.index=g.index)),o.currentTransactionOldBlockAttrs[c.node.attrs.id]=f,JSON.stringify(f)!==JSON.stringify(g)&&(f["depth-change"]=f.depth-g.depth,o.updatedBlocks.add(c.node.attrs.id))}}return o.prevTransactionOldBlockAttrs=a,o}},props:{decorations(t){const o=this.getState(t);if(o.updatedBlocks.size===0)return;const i=[];return t.doc.descendants((n,a)=>{if(!n.attrs.id||!o.updatedBlocks.has(n.attrs.id))return;const r=o.currentTransactionOldBlockAttrs[n.attrs.id],l={};for(const[c,p]of Object.entries(r))l["data-prev-"+ta[c]]=p||"none";const s=L.Decoration.node(a,a+n.nodeSize,{...l});i.push(s)}),L.DecorationSet.create(t.doc,i)}}})},ia={enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!1};class Je{constructor(t){u(this,"_pmSchema");u(this,"headless",!1);u(this,"_tiptapEditor");u(this,"elementRenderer",null);u(this,"blockCache",new WeakMap);u(this,"dictionary");u(this,"schema");u(this,"blockImplementations");u(this,"inlineContentImplementations");u(this,"styleImplementations");u(this,"formattingToolbar");u(this,"linkToolbar");u(this,"sideMenu");u(this,"suggestionMenus");u(this,"filePanel");u(this,"tableHandles");u(this,"uploadFile");u(this,"onUploadStartCallbacks",[]);u(this,"onUploadEndCallbacks",[]);u(this,"resolveFileUrl");u(this,"mount",t=>{this._tiptapEditor.mount(t)});var s,c,p,h,m,g,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||ot;const i={defaultStyles:!0,schema:t.schema||we.create(),_headless:!1,...t,placeholders:{...this.dictionary.placeholders,...t.placeholders}};this.schema=i.schema,this.blockImplementations=i.schema.blockSpecs,this.inlineContentImplementations=i.schema.inlineContentSpecs,this.styleImplementations=i.schema.styleSpecs,this.formattingToolbar=new uo(this),this.linkToolbar=new ho(this),this.sideMenu=new _o(this),this.suggestionMenus=new yo(this),this.filePanel=new lo(this),P("table",this)&&(this.tableHandles=new Co(this));const n=Bo({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}),a=b.Extension.create({name:"BlockNoteUIExtension",addProseMirrorPlugins:()=>[this.formattingToolbar.plugin,this.linkToolbar.plugin,this.sideMenu.plugin,this.suggestionMenus.plugin,...this.filePanel?[this.filePanel.plugin]:[],...this.tableHandles?[this.tableHandles.plugin]:[],Yn(this,i.placeholders),ea(),...this.options.animations??!0?[oa()]:[]]});if(n.push(a),i.uploadFile){const k=i.uploadFile;this.uploadFile=async(w,T)=>{this.onUploadStartCallbacks.forEach(E=>E.apply(this,[T]));try{return await k(w,T)}finally{this.onUploadEndCallbacks.forEach(E=>E.apply(this,[T]))}}}this.resolveFileUrl=i.resolveFileUrl||(async k=>k),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 r=i.initialContent||(t.collaboration?[{type:"paragraph",id:"initialBlockId"}]:[{type:"paragraph",id:Z.options.generateID()}]);if(!Array.isArray(r)||r.length===0)throw new Error("initialContent must be a non-empty array of blocks, received: "+r);const l={...ia,...i._tiptapOptions,content:r,extensions:[...((s=i._tiptapOptions)==null?void 0:s.extensions)||[],...n],editorProps:{...(c=i._tiptapOptions)==null?void 0:c.editorProps,attributes:{tabIndex:"0",...(h=(p=i._tiptapOptions)==null?void 0:p.editorProps)==null?void 0:h.attributes,...(m=i.domAttributes)==null?void 0:m.editor,class:O("bn-editor",i.defaultStyles?"bn-default-styles":"",((f=(g=i.domAttributes)==null?void 0:g.editor)==null?void 0:f.class)||"")},transformPasted:Xn}};this.headless?this._pmSchema=b.getSchema(l.extensions):(this._tiptapEditor=Ce.create(l,this.schema.styleSchema),this._pmSchema=this._tiptapEditor.schema)}get pmSchema(){return this._pmSchema}static create(t={}){return new Je(t)}dispatch(t){this._tiptapEditor.dispatch(t)}get prosemirrorView(){return this._tiptapEditor.view}get domElement(){return this._tiptapEditor.view.dom}isFocused(){return this._tiptapEditor.view.hasFocus()}focus(){this._tiptapEditor.view.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(x(o,this.schema.blockSchema,this.schema.inlineContentSchema,this.schema.styleSchema,this.blockCache)),!1)),t}getBlock(t){const o=typeof t=="string"?t:t.id;let i;return this._tiptapEditor.state.doc.firstChild.descendants(n=>typeof i<"u"?!1:n.type.name!=="blockContainer"||n.attrs.id!==o?!0:(i=x(n,this.schema.blockSchema,this.schema.inlineContentSchema,this.schema.styleSchema,this.blockCache),!1)),i}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 l=o?r.children.slice().reverse():r.children;if(!n(l))return!1}return!0}n(i)}onEditorContentChange(t){this._tiptapEditor.on("update",t)}onEditorSelectionChange(t){this._tiptapEditor.on("selectionUpdate",t)}getTextCursorPosition(){return cn(this)}setTextCursorPosition(t,o="start"){un(this,t,o)}getSelection(){if(this._tiptapEditor.state.selection.from===this._tiptapEditor.state.selection.to||"node"in this._tiptapEditor.state.selection)return;const t=[];return this._tiptapEditor.state.doc.descendants((o,i)=>{if(o.type.spec.group!=="blockContent")return!0;const n=i+o.nodeSize-1,a=i+1;return n<=this._tiptapEditor.state.selection.from||a>=this._tiptapEditor.state.selection.to?!0:(t.push(x(this._tiptapEditor.state.doc.resolve(i).node(),this.schema.blockSchema,this.schema.inlineContentSchema,this.schema.styleSchema,this.blockCache)),!1)}),{blocks:t}}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 tn(this,t,o,i)}updateBlock(t,o){return Ti(this,t,o)}removeBlocks(t){return ln(this,t)}replaceBlocks(t,o){return sn(this,t,o)}insertInlineContent(t){const o=j(t,this.pmSchema,this.schema.styleSchema);dn({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 N(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 N(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(){const{blockContainer:t}=v(this._tiptapEditor.state);return this._tiptapEditor.state.doc.resolve(t.beforePos).nodeBefore!==null}nestBlock(){this._tiptapEditor.commands.sinkListItem("blockContainer")}canUnnestBlock(){const{blockContainer:t}=v(this._tiptapEditor.state);return this._tiptapEditor.state.doc.resolve(t.beforePos).depth>1}unnestBlock(){this._tiptapEditor.commands.liftListItem("blockContainer")}moveBlockUp(){an(this)}moveBlockDown(){rn(this)}async blocksToHTMLLossy(t=this.document){return ne(this.pmSchema,this).exportBlocks(t,{})}async blocksToFullHTML(t){return dt(this.pmSchema,this).serializeBlocks(t,{})}async tryParseHTMLToBlocks(t){return We(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 ao(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){const i=this.prosemirrorView.state.tr,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}))}}let Ee,Ye;async function na(e,t){if(!Jt("text",e))return[];if(!Ee){Ee=import("@emoji-mart/data"),Ye=await import("emoji-mart");const n=(await Ee).default;await Ye.init({data:n})}const o=(await Ee).default;return(t.trim()===""?Object.values(o.emojis):await Ye.SearchIndex.search(t)).map(n=>({id:n.skins[0].native,onItemClick:()=>e.insertInlineContent(n.skins[0].native+" ")}))}function aa(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 A(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&&X(o.content[0])&&o.content[0].type==="text"&&o.content[0].text==="/"||o.content.length===0)?(i=e.updateBlock(o,t),t.content&&e.setTextCursorPosition(i)):(i=e.insertBlocks([t],o,"after")[0],e.setTextCursorPosition(e.getTextCursorPosition().nextBlock)),aa(e),i}function ra(e){const t=[];return P("heading",e)&&t.push({onItemClick:()=>{A(e,{type:"heading",props:{level:1}})},badge:z("Mod-Alt-1"),key:"heading",...e.dictionary.slash_menu.heading},{onItemClick:()=>{A(e,{type:"heading",props:{level:2}})},badge:z("Mod-Alt-2"),key:"heading_2",...e.dictionary.slash_menu.heading_2},{onItemClick:()=>{A(e,{type:"heading",props:{level:3}})},badge:z("Mod-Alt-3"),key:"heading_3",...e.dictionary.slash_menu.heading_3}),P("numberedListItem",e)&&t.push({onItemClick:()=>{A(e,{type:"numberedListItem"})},badge:z("Mod-Shift-7"),key:"numbered_list",...e.dictionary.slash_menu.numbered_list}),P("bulletListItem",e)&&t.push({onItemClick:()=>{A(e,{type:"bulletListItem"})},badge:z("Mod-Shift-8"),key:"bullet_list",...e.dictionary.slash_menu.bullet_list}),P("checkListItem",e)&&t.push({onItemClick:()=>{A(e,{type:"checkListItem"})},badge:z("Mod-Shift-9"),key:"check_list",...e.dictionary.slash_menu.check_list}),P("paragraph",e)&&t.push({onItemClick:()=>{A(e,{type:"paragraph"})},badge:z("Mod-Alt-0"),key:"paragraph",...e.dictionary.slash_menu.paragraph}),P("table",e)&&t.push({onItemClick:()=>{A(e,{type:"table",content:{type:"tableContent",rows:[{cells:["","",""]},{cells:["","",""]}]}})},badge:void 0,key:"table",...e.dictionary.slash_menu.table}),P("image",e)&&t.push({onItemClick:()=>{const o=A(e,{type:"image"});e.dispatch(e._tiptapEditor.state.tr.setMeta(e.filePanel.plugin,{block:o}))},key:"image",...e.dictionary.slash_menu.image}),P("video",e)&&t.push({onItemClick:()=>{const o=A(e,{type:"video"});e.dispatch(e._tiptapEditor.state.tr.setMeta(e.filePanel.plugin,{block:o}))},key:"video",...e.dictionary.slash_menu.video}),P("audio",e)&&t.push({onItemClick:()=>{const o=A(e,{type:"audio"});e.dispatch(e._tiptapEditor.state.tr.setMeta(e.filePanel.plugin,{block:o}))},key:"audio",...e.dictionary.slash_menu.audio}),P("file",e)&&t.push({onItemClick:()=>{const o=A(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 la(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 Qe(e=""){return typeof e=="string"?[{type:"text",text:e,styles:{}}]:e}function Io(e){return typeof e=="string"?Qe(e):Array.isArray(e)?e.flatMap(t=>typeof t=="string"?Qe(t):Te(t)?{...t,content:Qe(t.content)}:X(t)?t:{props:{},...t,content:Io(t.content)}):e}function sa(e,t){return t.map(o=>et(e,o))}function et(e,t){const o={id:"",type:t.type,props:{},content:e[t.type].content==="inline"?[]:void 0,children:[],...t};return Object.entries(e[t.type].propSchema).forEach(([i,n])=>{o.props[i]===void 0&&(o.props[i]=n.default)}),{...o,content:Io(o.content),children:o.children.map(i=>et(e,i))}}function Po(e){e.id||(e.id=Z.options.generateID()),e.children&&Ao(e.children)}function Ao(e){for(const t of e)Po(t)}d.AudioBlock=Mt,d.BlockNoteEditor=Je,d.BlockNoteSchema=we,d.FileBlock=Nt,d.FilePanelProsemirrorPlugin=lo,d.FilePanelView=ro,d.FormattingToolbarProsemirrorPlugin=uo,d.FormattingToolbarView=so,d.HTMLToBlocks=We,d.ImageBlock=Ot,d.LinkToolbarProsemirrorPlugin=ho,d.SideMenuProsemirrorPlugin=_o,d.SideMenuView=bo,d.SuggestionMenuProseMirrorPlugin=yo,d.TableHandlesProsemirrorPlugin=Co,d.TableHandlesView=wo,d.UniqueID=Z,d.UnreachableCaseError=N,d.VideoBlock=Wt,d.addIdsToBlock=Po,d.addIdsToBlocks=Ao,d.addInlineContentAttributes=je,d.addInlineContentKeyboardShortcuts=mt,d.addStyleAttributes=_t,d.applyNonSelectableBlockFix=pt,d.assertEmpty=ci,d.audioBlockConfig=Et,d.audioParse=St,d.audioPropSchema=Ct,d.audioRender=xt,d.audioToExternalHTML=Tt,d.blockToNode=q,d.blocksToMarkdown=oo,d.camelToDataKebab=re,d.checkBlockHasDefaultProp=en,d.checkBlockIsDefaultType=Yt,d.checkBlockIsFileBlock=Ji,d.checkBlockIsFileBlockWithPlaceholder=Qi,d.checkBlockIsFileBlockWithPreview=Yi,d.checkBlockTypeHasDefaultProp=Qt,d.checkDefaultBlockTypeInSchema=P,d.checkDefaultInlineContentTypeInSchema=Jt,d.cleanHTMLToMarkdown=_e,d.contentNodeToInlineContent=de,d.contentNodeToTableContent=Ne,d.createAddFileButton=vt,d.createBlockSpec=se,d.createBlockSpecFromStronglyTypedTiptapNode=$,d.createDefaultBlockDOMOutputSpec=R,d.createDefaultFilePreview=ze,d.createExternalHTMLExporter=ne,d.createFigureWithCaption=ge,d.createFileAndCaptionWrapper=J,d.createFileBlockWrapper=ce,d.createInlineContentSpec=yi,d.createInlineContentSpecFromTipTapNode=gt,d.createInternalBlockSpec=Pe,d.createInternalHTMLSerializer=dt,d.createInternalInlineContentSpec=ft,d.createInternalStyleSpec=De,d.createLinkWithCaption=pe,d.createResizeHandlesWrapper=Re,d.createStronglyTypedTiptapNode=V,d.createStyleSpec=vi,d.createStyleSpecFromTipTapMark=F,d.createSuggestionMenu=Tn,d.defaultBlockSchema=Zt,d.defaultBlockSpecs=Ke,d.defaultBlockToHTML=Be,d.defaultInlineContentSchema=Xt,d.defaultInlineContentSpecs=qe,d.defaultProps=C,d.defaultStyleSchema=Xi,d.defaultStyleSpecs=Ge,d.fileBlockConfig=Lt,d.fileParse=Pt,d.filePropSchema=Bt,d.fileRender=It,d.fileToExternalHTML=At,d.filenameFromURL=_i,d.filterSuggestionItems=la,d.formatKeyboardShortcut=z,d.formattingToolbarPluginKey=co,d.getBlockFromPos=ut,d.getBlockInfo=W,d.getBlockInfoFromResolvedPos=U,d.getBlockInfoFromSelection=v,d.getBlockInfoWithManualOffset=me,d.getBlockNoteExtensions=Bo,d.getBlockSchemaFromSpecs=Ae,d.getDefaultEmojiPickerItems=na,d.getDefaultSlashMenuItems=ra,d.getInlineContentParseRules=bt,d.getInlineContentSchemaFromSpecs=He,d.getNearestBlockContainerPos=ae,d.getParseRules=ht,d.getStyleParseRules=yt,d.getStyleSchemaFromSpecs=Ue,d.imageBlockConfig=Ht,d.imageParse=Ut,d.imagePropSchema=jt,d.imageRender=Dt,d.imageToExternalHTML=zt,d.inheritedProps=Le,d.initializeESMDependencies=ke,d.inlineContentToNodes=j,d.insertOrUpdateBlock=A,d.isAppleOS=ct,d.isLinkInlineContent=Se,d.isPartialLinkInlineContent=Te,d.isSafari=ki,d.isStyledTextInlineContent=X,d.linkToolbarPluginKey=po,d.locales=di,d.markdownToBlocks=ao,d.mergeCSSClasses=O,d.nodeToBlock=x,d.nodeToCustomInlineContent=fe,d.parseEmbedElement=Oe,d.parseFigureElement=ue,d.parseImageElement=Ve,d.partialBlockToBlockForTesting=et,d.partialBlocksToBlocksForTesting=sa,d.propsToAttributes=Ie,d.sideMenuPluginKey=ko,d.stylePropsToAttributes=kt,d.tableContentToNodes=ie,d.tableHandlesPluginKey=te,d.uploadToTmpFilesDotOrg_DEV_ONLY=wi,d.videoBlockConfig=Ft,d.videoParse=Gt,d.videoPropSchema=Vt,d.videoRender=Kt,d.videoToExternalHTML=qt,d.wrapInBlockStructure=le,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
8
8
  //# sourceMappingURL=blocknote.umd.cjs.map