@blocknote/core 0.33.0 → 0.34.0

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.
Files changed (39) hide show
  1. package/dist/blocknote.cjs +9 -9
  2. package/dist/blocknote.cjs.map +1 -1
  3. package/dist/blocknote.js +1838 -1715
  4. package/dist/blocknote.js.map +1 -1
  5. package/dist/tsconfig.tsbuildinfo +1 -1
  6. package/dist/webpack-stats.json +1 -1
  7. package/package.json +2 -2
  8. package/src/api/__snapshots__/blocks-indented-changed.json +129 -0
  9. package/src/api/__snapshots__/blocks-moved-deeper-into-nesting.json +164 -0
  10. package/src/api/__snapshots__/blocks-moved-multiple-in-same-transaction.json +188 -0
  11. package/src/api/__snapshots__/blocks-moved-to-different-parent.json +78 -0
  12. package/src/api/__snapshots__/blocks-moved-to-root-level.json +78 -0
  13. package/src/api/__snapshots__/blocks-outdented-changed.json +129 -0
  14. package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +58 -59
  15. package/src/api/nodeUtil.test.ts +228 -1
  16. package/src/api/nodeUtil.ts +135 -118
  17. package/src/api/parsers/markdown/detectMarkdown.test.ts +211 -0
  18. package/src/api/parsers/markdown/detectMarkdown.ts +3 -2
  19. package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +2 -1
  20. package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +2 -1
  21. package/src/blocks/ToggleWrapper/createToggleWrapper.ts +2 -0
  22. package/src/blocks/defaultBlockTypeGuards.ts +30 -0
  23. package/src/editor/BlockNoteEditor.ts +27 -10
  24. package/src/editor/BlockNoteExtensions.ts +3 -5
  25. package/src/exporter/Exporter.ts +2 -0
  26. package/src/exporter/mapping.ts +1 -0
  27. package/src/extensions/BlockChange/BlockChangePlugin.ts +66 -0
  28. package/src/extensions/SideMenu/SideMenuPlugin.ts +290 -207
  29. package/src/schema/inlineContent/types.ts +8 -0
  30. package/types/src/api/nodeUtil.d.ts +15 -21
  31. package/types/src/api/parsers/markdown/detectMarkdown.test.d.ts +1 -0
  32. package/types/src/blocks/defaultBlockTypeGuards.d.ts +7 -1
  33. package/types/src/editor/BlockNoteEditor.d.ts +11 -8
  34. package/types/src/editor/BlockNoteExtensions.d.ts +0 -1
  35. package/types/src/exporter/Exporter.d.ts +1 -1
  36. package/types/src/exporter/mapping.d.ts +1 -1
  37. package/types/src/extensions/BlockChange/BlockChangePlugin.d.ts +15 -0
  38. package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +50 -9
  39. package/types/src/schema/inlineContent/types.d.ts +4 -0
@@ -1,13 +1,13 @@
1
- "use strict";var gr=Object.create;var st=Object.defineProperty;var br=Object.getOwnPropertyDescriptor;var kr=Object.getOwnPropertyNames;var wr=Object.getPrototypeOf,yr=Object.prototype.hasOwnProperty;var Cr=(e,n,t)=>n in e?st(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var vr=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of kr(n))!yr.call(e,r)&&r!==t&&st(e,r,{get:()=>n[r],enumerable:!(o=br(n,r))||o.enumerable});return e};var q=(e,n,t)=>(t=e!=null?gr(wr(e)):{},vr(n||!e||!e.__esModule?st(t,"default",{value:e,enumerable:!0}):t,e));var p=(e,n,t)=>Cr(e,typeof n!="symbol"?n+"":n,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("prosemirror-model"),he=require("prosemirror-transform"),k=require("@tiptap/core"),y=require("prosemirror-state"),pn=require("uuid"),Sr=require("prosemirror-highlight"),Er=require("prosemirror-highlight/shiki"),Br=require("@tiptap/extension-bold"),Tr=require("@tiptap/extension-code"),xr=require("@tiptap/extension-italic"),Pr=require("@tiptap/extension-strike"),Mr=require("@tiptap/extension-underline"),Ir=require("@tiptap/extension-table-cell"),Lr=require("@tiptap/extension-table-header"),H=require("prosemirror-tables"),Ar=require("@tiptap/extension-gapcursor"),Nr=require("@tiptap/extension-history"),Dr=require("@tiptap/extension-link"),Hr=require("@tiptap/extension-text"),N=require("y-prosemirror"),D=require("prosemirror-view"),Or=require("yjs"),jt=require("prosemirror-history"),Rr=require("prosemirror-dropcursor"),_r=require("./en-CsgPjHa4.cjs"),Be=e=>e&&typeof e=="object"&&"default"in e?e:{default:e};function Vr(e){if(e&&typeof e=="object"&&"default"in e)return e;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const Ur=Be(Br),Fr=Be(Tr),$r=Be(xr),zr=Be(Pr),Wr=Be(Mr),ie=Vr(Or);function Kr(e,n=JSON.stringify){const t={};return e.filter(o=>{const r=n(o);return Object.prototype.hasOwnProperty.call(t,r)?!1:t[r]=!0})}function qr(e){const n=e.filter((o,r)=>e.indexOf(o)!==r);return Kr(n)}const Te=k.Extension.create({name:"uniqueID",priority:1e4,addOptions(){return{attributeName:"id",types:[],setIdAttribute:!1,generateID:()=>{if(typeof window<"u"&&window.__TEST_OPTIONS){const e=window.__TEST_OPTIONS;return e.mockID===void 0?e.mockID=0:e.mockID++,e.mockID.toString()}return pn.v4()},filterTransaction:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{[this.options.attributeName]:{default:null,parseHTML:e=>e.getAttribute(`data-${this.options.attributeName}`),renderHTML:e=>{const n={[`data-${this.options.attributeName}`]:e[this.options.attributeName]};return this.options.setIdAttribute?{...n,id:e[this.options.attributeName]}:n}}}}]},addProseMirrorPlugins(){let e=null,n=!1;return[new y.Plugin({key:new y.PluginKey("uniqueID"),appendTransaction:(t,o,r)=>{const s=t.some(m=>m.docChanged)&&!o.doc.eq(r.doc),i=this.options.filterTransaction&&t.some(m=>{let g,b;return!(!((b=(g=this.options).filterTransaction)===null||b===void 0)&&b.call(g,m))});if(!s||i)return;const{tr:a}=r,{types:l,attributeName:c,generateID:d}=this.options,u=k.combineTransactionSteps(o.doc,t),{mapping:h}=u;if(k.getChangedRanges(u).forEach(({newRange:m})=>{const g=k.findChildrenInRange(r.doc,m,C=>l.includes(C.type.name)),b=g.map(({node:C})=>C.attrs[c]).filter(C=>C!==null),w=qr(b);g.forEach(({node:C,pos:v})=>{let I;const _=(I=a.doc.nodeAt(v))===null||I===void 0?void 0:I.attrs[c];if(_===null){const T=o.doc.type.createAndFill().content;if(o.doc.content.findDiffStart(T)===null){const P=JSON.parse(JSON.stringify(r.doc.toJSON()));if(P.content[0].content[0].attrs.id="initialBlockId",JSON.stringify(P.content)===JSON.stringify(T.toJSON())){a.setNodeMarkup(v,void 0,{...C.attrs,[c]:"initialBlockId"});return}}a.setNodeMarkup(v,void 0,{...C.attrs,[c]:d()});return}const{deleted:K}=h.invert().mapResult(v);K&&w.includes(_)&&a.setNodeMarkup(v,void 0,{...C.attrs,[c]:d()})})}),!!a.steps.length)return a},view(t){const o=r=>{let s;e=!((s=t.dom.parentElement)===null||s===void 0)&&s.contains(r.target)?t.dom.parentElement:null};return window.addEventListener("dragstart",o),{destroy(){window.removeEventListener("dragstart",o)}}},props:{handleDOMEvents:{drop:(t,o)=>{let r;return e!==t.dom.parentElement||((r=o.dataTransfer)===null||r===void 0?void 0:r.effectAllowed)==="copy"?n=!0:n=!1,e=null,!1},paste:()=>(n=!0,!1)},transformPasted:t=>{if(!n)return t;const{types:o,attributeName:r}=this.options,s=i=>{const a=[];return i.forEach(l=>{if(l.isText){a.push(l);return}if(!o.includes(l.type.name)){a.push(l.copy(s(l.content)));return}const c=l.type.create({...l.attrs,[r]:null},s(l.content),l.marks);a.push(c)}),S.Fragment.from(a)};return n=!1,new S.Slice(s(t.content),t.openStart,t.openEnd)}}})]}});function ct(e){return e.type==="link"}function Et(e){return typeof e!="string"&&e.type==="link"}function oe(e){return typeof e!="string"&&e.type==="text"}function Ue(e){var n,t,o,r,s;return je(e)?{...e}:fe(e)?{type:"tableCell",content:[].concat(e.content),props:{backgroundColor:((n=e.props)==null?void 0:n.backgroundColor)??"default",textColor:((t=e.props)==null?void 0:t.textColor)??"default",textAlignment:((o=e.props)==null?void 0:o.textAlignment)??"left",colspan:((r=e.props)==null?void 0:r.colspan)??1,rowspan:((s=e.props)==null?void 0:s.rowspan)??1}}:{type:"tableCell",content:[].concat(e),props:{backgroundColor:"default",textColor:"default",textAlignment:"left",colspan:1,rowspan:1}}}function fe(e){return e!=null&&typeof e!="string"&&!Array.isArray(e)&&e.type==="tableCell"}function je(e){return fe(e)&&e.props!==void 0&&e.content!==void 0}function me(e){return je(e)?e.props.colspan??1:1}function Fe(e){return je(e)?e.props.rowspan??1:1}class j extends Error{constructor(n){super(`Unreachable case: ${n}`)}}function jr(e,n=!0){const{"data-test":t,...o}=e;if(Object.keys(o).length>0&&n)throw new Error("Object must be empty "+JSON.stringify(e))}const hn=()=>typeof navigator<"u"&&(/Mac/.test(navigator.platform)||/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent));function J(e,n="Ctrl"){return hn()?e.replace("Mod","⌘"):e.replace("Mod",n)}function Q(...e){return[...new Set(e.filter(n=>n).join(" ").split(" "))].join(" ")}const Gr=()=>/^((?!chrome|android).)*safari/i.test(navigator.userAgent);function $(e,n,t,o){const r=document.createElement("div");r.className=Q("bn-block-content",t.class),r.setAttribute("data-content-type",e);for(const[i,a]of Object.entries(t))i!=="class"&&r.setAttribute(i,a);const s=document.createElement(n);s.className=Q("bn-inline-content",o.class);for(const[i,a]of Object.entries(o))i!=="class"&&s.setAttribute(i,a);return r.appendChild(s),{dom:r,contentDOM:s}}const dt=(e,n)=>{let t=se(e,n.pmSchema);t.type.name==="blockContainer"&&(t=t.firstChild);const o=n.pmSchema.nodes[t.type.name].spec.toDOM;if(o===void 0)throw new Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");const r=o(t);if(typeof r!="object"||!("dom"in r))throw new Error("Cannot use this block's default HTML serialization as its corresponding TipTap node's `renderHTML` function does not return an object with the `dom` property.");return r};function Yr(e){const n=e.querySelectorAll("p");if(n.length>1){const t=n[0];for(let o=1;o<n.length;o++){const r=n[o];t.innerHTML+="<br>"+r.innerHTML,r.remove()}}}const M={backgroundColor:{default:"default"},textColor:{default:"default"},textAlignment:{default:"left",values:["left","center","right","justify"]}},Bt=["backgroundColor","textColor"];function Se(e){return"data-"+e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function Jr(e){const n=e.split("/");return!n.length||n[n.length-1]===""?e:n[n.length-1]}function ge(e){const n={};return Object.entries(e).filter(([t,o])=>!Bt.includes(t)).forEach(([t,o])=>{n[t]={default:o.default,keepOnSplit:!0,parseHTML:r=>{const s=r.getAttribute(Se(t));if(s===null)return null;if(o.default===void 0&&o.type==="boolean"||o.default!==void 0&&typeof o.default=="boolean")return s==="true"?!0:s==="false"?!1:null;if(o.default===void 0&&o.type==="number"||o.default!==void 0&&typeof o.default=="number"){const i=parseFloat(s);return!Number.isNaN(i)&&Number.isFinite(i)?i:null}return s},renderHTML:r=>r[t]!==o.default?{[Se(t)]:r[t]}:{}}}),n}function Ge(e,n,t,o){if(typeof e=="boolean")throw new Error("Cannot find node position as getPos is a boolean, not a function.");const r=e(),i=t.state.doc.resolve(r).node().attrs.id;if(!i)throw new Error("Block doesn't have id");const a=n.getBlock(i);if(a.type!==o)throw new Error("Block type does not match");return a}function ve(e,n,t,o,r=!1,s){const i=document.createElement("div");if(s!==void 0)for(const[a,l]of Object.entries(s))a!=="class"&&i.setAttribute(a,l);i.className=Q("bn-block-content",(s==null?void 0:s.class)||""),i.setAttribute("data-content-type",n);for(const[a,l]of Object.entries(t)){const d=o[a].default;!Bt.includes(a)&&l!==d&&i.setAttribute(Se(a),l)}return r&&i.setAttribute("data-file-block",""),i.appendChild(e.dom),e.contentDOM!==void 0&&(e.contentDOM.className=Q("bn-inline-content",e.contentDOM.className)),{...e,dom:i}}function G(e){return k.Node.create(e)}function Tt(e,n){return{config:e,implementation:n}}function Z(e,n,t){return Tt({type:e.name,content:e.config.content==="inline*"?"inline":e.config.content==="tableRow+"?"table":"none",propSchema:n},{node:e,requiredExtensions:t,toInternalHTML:dt,toExternalHTML:dt})}function xt(e){return Object.fromEntries(Object.entries(e).map(([n,t])=>[n,t.config]))}function fn(e,n){e.stopEvent=t=>(t.type==="mousedown"&&setTimeout(()=>{n.view.dom.blur()},10),!0)}function mn(e,n){const t=[{tag:"[data-content-type="+e.type+"]",contentElement:".bn-inline-content"}];return n&&t.push({tag:"*",getAttrs(o){if(typeof o=="string")return!1;const r=n==null?void 0:n(o);return r===void 0?!1:r}}),t}function be(e,n){const t=G({name:e.type,content:e.content==="inline"?"inline*":"",group:"blockContent",selectable:e.isSelectable??!0,isolating:!0,addAttributes(){return ge(e.propSchema)},parseHTML(){return mn(e,n.parse)},renderHTML({HTMLAttributes:o}){const r=document.createElement("div");return ve({dom:r,contentDOM:e.content==="inline"?r:void 0},e.type,{},e.propSchema,e.isFileBlock,o)},addNodeView(){return({getPos:o})=>{var c;const r=this.options.editor,s=Ge(o,r,this.editor,e.type),i=((c=this.options.domAttributes)==null?void 0:c.blockContent)||{},a=n.render(s,r),l=ve(a,s.type,s.props,e.propSchema,e.isFileBlock,i);return e.isSelectable===!1&&fn(l,this.editor),l}}});if(t.name!==e.type)throw new Error("Node name does not match block type. This is a bug in BlockNote.");return Tt(e,{node:t,toInternalHTML:(o,r)=>{var a;const s=((a=t.options.domAttributes)==null?void 0:a.blockContent)||{},i=n.render(o,r);return ve(i,o.type,o.props,e.propSchema,e.isFileBlock,s)},toExternalHTML:(o,r)=>{var a,l;const s=((a=t.options.domAttributes)==null?void 0:a.blockContent)||{};let i=(l=n.toExternalHTML)==null?void 0:l.call(n,o,r);return i===void 0&&(i=n.render(o,r)),ve(i,o.type,o.props,e.propSchema,s)}})}function X(e,n){const t=e.resolve(n);if(t.nodeAfter&&t.nodeAfter.type.isInGroup("bnBlock"))return{posBeforeNode:t.pos,node:t.nodeAfter};let o=t.depth,r=t.node(o);for(;o>0;){if(r.type.isInGroup("bnBlock"))return{posBeforeNode:t.before(o),node:r};o--,r=t.node(o)}const s=[];e.descendants((a,l)=>{a.type.isInGroup("bnBlock")&&s.push(l)}),console.warn(`Position ${n} is not within a blockContainer node.`);const i=e.resolve(s.find(a=>a>=n)||s[s.length-1]);return{posBeforeNode:i.pos,node:i.nodeAfter}}function Ye(e,n){if(!e.type.isInGroup("bnBlock"))throw new Error(`Attempted to get bnBlock node at position but found node of different type ${e.type.name}`);const t=e,o=n,r=o+t.nodeSize,s={node:t,beforePos:o,afterPos:r};if(t.type.name==="blockContainer"){let i,a;if(t.forEach((l,c)=>{if(l.type.spec.group==="blockContent"){const d=l,u=o+c+1,h=u+l.nodeSize;i={node:d,beforePos:u,afterPos:h}}else if(l.type.name==="blockGroup"){const d=l,u=o+c+1,h=u+l.nodeSize;a={node:d,beforePos:u,afterPos:h}}}),!i)throw new Error(`blockContainer node does not contain a blockContent node in its children: ${t}`);return{isBlockContainer:!0,bnBlock:s,blockContent:i,childContainer:a,blockNoteType:i.node.type.name}}else{if(!s.node.type.isInGroup("childContainer"))throw new Error(`bnBlock node is not in the childContainer group: ${s.node}`);return{isBlockContainer:!1,bnBlock:s,childContainer:s,blockNoteType:s.node.type.name}}}function ee(e){return Ye(e.node,e.posBeforeNode)}function ke(e){if(!e.nodeAfter)throw new Error(`Attempted to get blockContainer node at position ${e.pos} but a node at this position does not exist`);return Ye(e.nodeAfter,e.pos)}function E(e){const n=X(e.doc,e.selection.anchor);return ee(n)}function xe(e){const n=X(e.doc,e.selection.anchor);return ee(n)}function O(e){return"doc"in e?e.doc.type.schema:e.type.schema}function gn(e){return e.cached.blockNoteEditor}function we(e){return gn(e).schema}function Je(e){return we(e).blockSchema}function Xe(e){return we(e).inlineContentSchema}function ce(e){return we(e).styleSchema}function Ze(e){return gn(e).blockCache}function Pt(e,n,t){var s,i;const o={type:"tableContent",columnWidths:[],headerRows:void 0,headerCols:void 0,rows:[]},r=[];e.content.forEach((a,l,c)=>{const d={cells:[]};c===0&&a.content.forEach(u=>{let h=u.attrs.colwidth;h==null&&(h=new Array(u.attrs.colspan??1).fill(void 0)),o.columnWidths.push(...h)}),d.cells=a.content.content.map((u,h)=>(r[c]||(r[c]=[]),r[c][h]=u.type.name==="tableHeader",{type:"tableCell",content:u.content.content.map(m=>Pe(m,n,t)).reduce((m,g)=>{if(!m.length)return g;const b=m[m.length-1],w=g[0];return w&&oe(b)&&oe(w)&&JSON.stringify(b.styles)===JSON.stringify(w.styles)?(b.text+=`
2
- `+w.text,m.push(...g.slice(1)),m):(m.push(...g),m)},[]),props:{colspan:u.attrs.colspan,rowspan:u.attrs.rowspan,backgroundColor:u.attrs.backgroundColor,textColor:u.attrs.textColor,textAlignment:u.attrs.textAlignment}})),o.rows.push(d)});for(let a=0;a<r.length;a++)(s=r[a])!=null&&s.every(l=>l)&&(o.headerRows=(o.headerRows??0)+1);for(let a=0;a<((i=r[0])==null?void 0:i.length);a++)r!=null&&r.every(l=>l[a])&&(o.headerCols=(o.headerCols??0)+1);return o}function Pe(e,n,t){const o=[];let r;return e.content.forEach(s=>{if(s.type.name==="hardBreak"){if(r)if(oe(r))r.text+=`
3
- `;else if(ct(r))r.content[r.content.length-1].text+=`
1
+ "use strict";var br=Object.create;var rt=Object.defineProperty;var kr=Object.getOwnPropertyDescriptor;var wr=Object.getOwnPropertyNames;var yr=Object.getPrototypeOf,Cr=Object.prototype.hasOwnProperty;var vr=(e,n,t)=>n in e?rt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var Sr=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of wr(n))!Cr.call(e,r)&&r!==t&&rt(e,r,{get:()=>n[r],enumerable:!(o=kr(n,r))||o.enumerable});return e};var q=(e,n,t)=>(t=e!=null?br(yr(e)):{},Sr(n||!e||!e.__esModule?rt(t,"default",{value:e,enumerable:!0}):t,e));var p=(e,n,t)=>vr(e,typeof n!="symbol"?n+"":n,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("prosemirror-model"),he=require("prosemirror-transform"),k=require("@tiptap/core"),y=require("prosemirror-state"),fn=require("uuid"),Er=require("prosemirror-highlight"),Br=require("prosemirror-highlight/shiki"),Tr=require("@tiptap/extension-bold"),xr=require("@tiptap/extension-code"),Pr=require("@tiptap/extension-italic"),Mr=require("@tiptap/extension-strike"),Ir=require("@tiptap/extension-underline"),Lr=require("@tiptap/extension-table-cell"),Ar=require("@tiptap/extension-table-header"),H=require("prosemirror-tables"),Nr=require("@tiptap/extension-gapcursor"),Dr=require("@tiptap/extension-history"),Hr=require("@tiptap/extension-link"),Or=require("@tiptap/extension-text"),N=require("y-prosemirror"),D=require("prosemirror-view"),Rr=require("yjs"),jt=require("prosemirror-history"),_r=require("prosemirror-dropcursor"),Vr=require("./en-CsgPjHa4.cjs"),Ee=e=>e&&typeof e=="object"&&"default"in e?e:{default:e};function Ur(e){if(e&&typeof e=="object"&&"default"in e)return e;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const Fr=Ee(Tr),$r=Ee(xr),zr=Ee(Pr),Wr=Ee(Mr),Kr=Ee(Ir),ie=Ur(Rr);function qr(e,n=JSON.stringify){const t={};return e.filter(o=>{const r=n(o);return Object.prototype.hasOwnProperty.call(t,r)?!1:t[r]=!0})}function jr(e){const n=e.filter((o,r)=>e.indexOf(o)!==r);return qr(n)}const Be=k.Extension.create({name:"uniqueID",priority:1e4,addOptions(){return{attributeName:"id",types:[],setIdAttribute:!1,generateID:()=>{if(typeof window<"u"&&window.__TEST_OPTIONS){const e=window.__TEST_OPTIONS;return e.mockID===void 0?e.mockID=0:e.mockID++,e.mockID.toString()}return fn.v4()},filterTransaction:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{[this.options.attributeName]:{default:null,parseHTML:e=>e.getAttribute(`data-${this.options.attributeName}`),renderHTML:e=>{const n={[`data-${this.options.attributeName}`]:e[this.options.attributeName]};return this.options.setIdAttribute?{...n,id:e[this.options.attributeName]}:n}}}}]},addProseMirrorPlugins(){let e=null,n=!1;return[new y.Plugin({key:new y.PluginKey("uniqueID"),appendTransaction:(t,o,r)=>{const s=t.some(m=>m.docChanged)&&!o.doc.eq(r.doc),i=this.options.filterTransaction&&t.some(m=>{let g,b;return!(!((b=(g=this.options).filterTransaction)===null||b===void 0)&&b.call(g,m))});if(!s||i)return;const{tr:a}=r,{types:l,attributeName:c,generateID:d}=this.options,u=k.combineTransactionSteps(o.doc,t),{mapping:h}=u;if(k.getChangedRanges(u).forEach(({newRange:m})=>{const g=k.findChildrenInRange(r.doc,m,C=>l.includes(C.type.name)),b=g.map(({node:C})=>C.attrs[c]).filter(C=>C!==null),w=jr(b);g.forEach(({node:C,pos:v})=>{let I;const _=(I=a.doc.nodeAt(v))===null||I===void 0?void 0:I.attrs[c];if(_===null){const T=o.doc.type.createAndFill().content;if(o.doc.content.findDiffStart(T)===null){const P=JSON.parse(JSON.stringify(r.doc.toJSON()));if(P.content[0].content[0].attrs.id="initialBlockId",JSON.stringify(P.content)===JSON.stringify(T.toJSON())){a.setNodeMarkup(v,void 0,{...C.attrs,[c]:"initialBlockId"});return}}a.setNodeMarkup(v,void 0,{...C.attrs,[c]:d()});return}const{deleted:K}=h.invert().mapResult(v);K&&w.includes(_)&&a.setNodeMarkup(v,void 0,{...C.attrs,[c]:d()})})}),!!a.steps.length)return a},view(t){const o=r=>{let s;e=!((s=t.dom.parentElement)===null||s===void 0)&&s.contains(r.target)?t.dom.parentElement:null};return window.addEventListener("dragstart",o),{destroy(){window.removeEventListener("dragstart",o)}}},props:{handleDOMEvents:{drop:(t,o)=>{let r;return e!==t.dom.parentElement||((r=o.dataTransfer)===null||r===void 0?void 0:r.effectAllowed)==="copy"?n=!0:n=!1,e=null,!1},paste:()=>(n=!0,!1)},transformPasted:t=>{if(!n)return t;const{types:o,attributeName:r}=this.options,s=i=>{const a=[];return i.forEach(l=>{if(l.isText){a.push(l);return}if(!o.includes(l.type.name)){a.push(l.copy(s(l.content)));return}const c=l.type.create({...l.attrs,[r]:null},s(l.content),l.marks);a.push(c)}),S.Fragment.from(a)};return n=!1,new S.Slice(s(t.content),t.openStart,t.openEnd)}}})]}});function lt(e){return e.type==="link"}function St(e){return typeof e!="string"&&e.type==="link"}function oe(e){return typeof e!="string"&&e.type==="text"}function Ve(e){var n,t,o,r,s;return Ke(e)?{...e}:fe(e)?{type:"tableCell",content:[].concat(e.content),props:{backgroundColor:((n=e.props)==null?void 0:n.backgroundColor)??"default",textColor:((t=e.props)==null?void 0:t.textColor)??"default",textAlignment:((o=e.props)==null?void 0:o.textAlignment)??"left",colspan:((r=e.props)==null?void 0:r.colspan)??1,rowspan:((s=e.props)==null?void 0:s.rowspan)??1}}:{type:"tableCell",content:[].concat(e),props:{backgroundColor:"default",textColor:"default",textAlignment:"left",colspan:1,rowspan:1}}}function fe(e){return e!=null&&typeof e!="string"&&!Array.isArray(e)&&e.type==="tableCell"}function Ke(e){return fe(e)&&e.props!==void 0&&e.content!==void 0}function me(e){return Ke(e)?e.props.colspan??1:1}function Ue(e){return Ke(e)?e.props.rowspan??1:1}class j extends Error{constructor(n){super(`Unreachable case: ${n}`)}}function Gr(e,n=!0){const{"data-test":t,...o}=e;if(Object.keys(o).length>0&&n)throw new Error("Object must be empty "+JSON.stringify(e))}const mn=()=>typeof navigator<"u"&&(/Mac/.test(navigator.platform)||/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent));function J(e,n="Ctrl"){return mn()?e.replace("Mod","⌘"):e.replace("Mod",n)}function Q(...e){return[...new Set(e.filter(n=>n).join(" ").split(" "))].join(" ")}const Yr=()=>/^((?!chrome|android).)*safari/i.test(navigator.userAgent);function $(e,n,t,o){const r=document.createElement("div");r.className=Q("bn-block-content",t.class),r.setAttribute("data-content-type",e);for(const[i,a]of Object.entries(t))i!=="class"&&r.setAttribute(i,a);const s=document.createElement(n);s.className=Q("bn-inline-content",o.class);for(const[i,a]of Object.entries(o))i!=="class"&&s.setAttribute(i,a);return r.appendChild(s),{dom:r,contentDOM:s}}const ct=(e,n)=>{let t=se(e,n.pmSchema);t.type.name==="blockContainer"&&(t=t.firstChild);const o=n.pmSchema.nodes[t.type.name].spec.toDOM;if(o===void 0)throw new Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");const r=o(t);if(typeof r!="object"||!("dom"in r))throw new Error("Cannot use this block's default HTML serialization as its corresponding TipTap node's `renderHTML` function does not return an object with the `dom` property.");return r};function Jr(e){const n=e.querySelectorAll("p");if(n.length>1){const t=n[0];for(let o=1;o<n.length;o++){const r=n[o];t.innerHTML+="<br>"+r.innerHTML,r.remove()}}}const M={backgroundColor:{default:"default"},textColor:{default:"default"},textAlignment:{default:"left",values:["left","center","right","justify"]}},Et=["backgroundColor","textColor"];function ve(e){return"data-"+e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function Xr(e){const n=e.split("/");return!n.length||n[n.length-1]===""?e:n[n.length-1]}function ge(e){const n={};return Object.entries(e).filter(([t,o])=>!Et.includes(t)).forEach(([t,o])=>{n[t]={default:o.default,keepOnSplit:!0,parseHTML:r=>{const s=r.getAttribute(ve(t));if(s===null)return null;if(o.default===void 0&&o.type==="boolean"||o.default!==void 0&&typeof o.default=="boolean")return s==="true"?!0:s==="false"?!1:null;if(o.default===void 0&&o.type==="number"||o.default!==void 0&&typeof o.default=="number"){const i=parseFloat(s);return!Number.isNaN(i)&&Number.isFinite(i)?i:null}return s},renderHTML:r=>r[t]!==o.default?{[ve(t)]:r[t]}:{}}}),n}function qe(e,n,t,o){if(typeof e=="boolean")throw new Error("Cannot find node position as getPos is a boolean, not a function.");const r=e(),i=t.state.doc.resolve(r).node().attrs.id;if(!i)throw new Error("Block doesn't have id");const a=n.getBlock(i);if(a.type!==o)throw new Error("Block type does not match");return a}function Ce(e,n,t,o,r=!1,s){const i=document.createElement("div");if(s!==void 0)for(const[a,l]of Object.entries(s))a!=="class"&&i.setAttribute(a,l);i.className=Q("bn-block-content",(s==null?void 0:s.class)||""),i.setAttribute("data-content-type",n);for(const[a,l]of Object.entries(t)){const d=o[a].default;!Et.includes(a)&&l!==d&&i.setAttribute(ve(a),l)}return r&&i.setAttribute("data-file-block",""),i.appendChild(e.dom),e.contentDOM!==void 0&&(e.contentDOM.className=Q("bn-inline-content",e.contentDOM.className)),{...e,dom:i}}function G(e){return k.Node.create(e)}function Bt(e,n){return{config:e,implementation:n}}function Z(e,n,t){return Bt({type:e.name,content:e.config.content==="inline*"?"inline":e.config.content==="tableRow+"?"table":"none",propSchema:n},{node:e,requiredExtensions:t,toInternalHTML:ct,toExternalHTML:ct})}function Tt(e){return Object.fromEntries(Object.entries(e).map(([n,t])=>[n,t.config]))}function gn(e,n){e.stopEvent=t=>(t.type==="mousedown"&&setTimeout(()=>{n.view.dom.blur()},10),!0)}function bn(e,n){const t=[{tag:"[data-content-type="+e.type+"]",contentElement:".bn-inline-content"}];return n&&t.push({tag:"*",getAttrs(o){if(typeof o=="string")return!1;const r=n==null?void 0:n(o);return r===void 0?!1:r}}),t}function be(e,n){const t=G({name:e.type,content:e.content==="inline"?"inline*":"",group:"blockContent",selectable:e.isSelectable??!0,isolating:!0,addAttributes(){return ge(e.propSchema)},parseHTML(){return bn(e,n.parse)},renderHTML({HTMLAttributes:o}){const r=document.createElement("div");return Ce({dom:r,contentDOM:e.content==="inline"?r:void 0},e.type,{},e.propSchema,e.isFileBlock,o)},addNodeView(){return({getPos:o})=>{var c;const r=this.options.editor,s=qe(o,r,this.editor,e.type),i=((c=this.options.domAttributes)==null?void 0:c.blockContent)||{},a=n.render(s,r),l=Ce(a,s.type,s.props,e.propSchema,e.isFileBlock,i);return e.isSelectable===!1&&gn(l,this.editor),l}}});if(t.name!==e.type)throw new Error("Node name does not match block type. This is a bug in BlockNote.");return Bt(e,{node:t,toInternalHTML:(o,r)=>{var a;const s=((a=t.options.domAttributes)==null?void 0:a.blockContent)||{},i=n.render(o,r);return Ce(i,o.type,o.props,e.propSchema,e.isFileBlock,s)},toExternalHTML:(o,r)=>{var a,l;const s=((a=t.options.domAttributes)==null?void 0:a.blockContent)||{};let i=(l=n.toExternalHTML)==null?void 0:l.call(n,o,r);return i===void 0&&(i=n.render(o,r)),Ce(i,o.type,o.props,e.propSchema,s)}})}function X(e,n){const t=e.resolve(n);if(t.nodeAfter&&t.nodeAfter.type.isInGroup("bnBlock"))return{posBeforeNode:t.pos,node:t.nodeAfter};let o=t.depth,r=t.node(o);for(;o>0;){if(r.type.isInGroup("bnBlock"))return{posBeforeNode:t.before(o),node:r};o--,r=t.node(o)}const s=[];e.descendants((a,l)=>{a.type.isInGroup("bnBlock")&&s.push(l)}),console.warn(`Position ${n} is not within a blockContainer node.`);const i=e.resolve(s.find(a=>a>=n)||s[s.length-1]);return{posBeforeNode:i.pos,node:i.nodeAfter}}function je(e,n){if(!e.type.isInGroup("bnBlock"))throw new Error(`Attempted to get bnBlock node at position but found node of different type ${e.type.name}`);const t=e,o=n,r=o+t.nodeSize,s={node:t,beforePos:o,afterPos:r};if(t.type.name==="blockContainer"){let i,a;if(t.forEach((l,c)=>{if(l.type.spec.group==="blockContent"){const d=l,u=o+c+1,h=u+l.nodeSize;i={node:d,beforePos:u,afterPos:h}}else if(l.type.name==="blockGroup"){const d=l,u=o+c+1,h=u+l.nodeSize;a={node:d,beforePos:u,afterPos:h}}}),!i)throw new Error(`blockContainer node does not contain a blockContent node in its children: ${t}`);return{isBlockContainer:!0,bnBlock:s,blockContent:i,childContainer:a,blockNoteType:i.node.type.name}}else{if(!s.node.type.isInGroup("childContainer"))throw new Error(`bnBlock node is not in the childContainer group: ${s.node}`);return{isBlockContainer:!1,bnBlock:s,childContainer:s,blockNoteType:s.node.type.name}}}function ee(e){return je(e.node,e.posBeforeNode)}function ke(e){if(!e.nodeAfter)throw new Error(`Attempted to get blockContainer node at position ${e.pos} but a node at this position does not exist`);return je(e.nodeAfter,e.pos)}function E(e){const n=X(e.doc,e.selection.anchor);return ee(n)}function Te(e){const n=X(e.doc,e.selection.anchor);return ee(n)}function R(e){return"doc"in e?e.doc.type.schema:e.type.schema}function kn(e){return e.cached.blockNoteEditor}function we(e){return kn(e).schema}function Ge(e){return we(e).blockSchema}function Ye(e){return we(e).inlineContentSchema}function ce(e){return we(e).styleSchema}function Je(e){return kn(e).blockCache}function xt(e,n,t){var s,i;const o={type:"tableContent",columnWidths:[],headerRows:void 0,headerCols:void 0,rows:[]},r=[];e.content.forEach((a,l,c)=>{const d={cells:[]};c===0&&a.content.forEach(u=>{let h=u.attrs.colwidth;h==null&&(h=new Array(u.attrs.colspan??1).fill(void 0)),o.columnWidths.push(...h)}),d.cells=a.content.content.map((u,h)=>(r[c]||(r[c]=[]),r[c][h]=u.type.name==="tableHeader",{type:"tableCell",content:u.content.content.map(m=>xe(m,n,t)).reduce((m,g)=>{if(!m.length)return g;const b=m[m.length-1],w=g[0];return w&&oe(b)&&oe(w)&&JSON.stringify(b.styles)===JSON.stringify(w.styles)?(b.text+=`
2
+ `+w.text,m.push(...g.slice(1)),m):(m.push(...g),m)},[]),props:{colspan:u.attrs.colspan,rowspan:u.attrs.rowspan,backgroundColor:u.attrs.backgroundColor,textColor:u.attrs.textColor,textAlignment:u.attrs.textAlignment}})),o.rows.push(d)});for(let a=0;a<r.length;a++)(s=r[a])!=null&&s.every(l=>l)&&(o.headerRows=(o.headerRows??0)+1);for(let a=0;a<((i=r[0])==null?void 0:i.length);a++)r!=null&&r.every(l=>l[a])&&(o.headerCols=(o.headerCols??0)+1);return o}function xe(e,n,t){const o=[];let r;return e.content.forEach(s=>{if(s.type.name==="hardBreak"){if(r)if(oe(r))r.text+=`
3
+ `;else if(lt(r))r.content[r.content.length-1].text+=`
4
4
  `;else throw new Error("unexpected");else r={type:"text",text:`
5
- `,styles:{}};return}if(s.type.name!=="link"&&s.type.name!=="text"){if(!n[s.type.name]){console.warn("unrecognized inline content type",s.type.name);return}r&&(o.push(r),r=void 0),o.push($e(s,n,t));return}const i={};let a;for(const l of s.marks)if(l.type.name==="link")a=l;else{const c=t[l.type.name];if(!c){if(l.type.spec.blocknoteIgnore)continue;throw new Error(`style ${l.type.name} not found in styleSchema`)}if(c.propSchema==="boolean")i[c.type]=!0;else if(c.propSchema==="string")i[c.type]=l.attrs.stringValue;else throw new j(c.propSchema)}r?oe(r)?a?(o.push(r),r={type:"link",href:a.attrs.href,content:[{type:"text",text:s.textContent,styles:i}]}):JSON.stringify(r.styles)===JSON.stringify(i)?r.text+=s.textContent:(o.push(r),r={type:"text",text:s.textContent,styles:i}):ct(r)&&(a?r.href===a.attrs.href?JSON.stringify(r.content[r.content.length-1].styles)===JSON.stringify(i)?r.content[r.content.length-1].text+=s.textContent:r.content.push({type:"text",text:s.textContent,styles:i}):(o.push(r),r={type:"link",href:a.attrs.href,content:[{type:"text",text:s.textContent,styles:i}]}):(o.push(r),r={type:"text",text:s.textContent,styles:i})):a?r={type:"link",href:a.attrs.href,content:[{type:"text",text:s.textContent,styles:i}]}:r={type:"text",text:s.textContent,styles:i}}),r&&o.push(r),o}function $e(e,n,t){if(e.type.name==="text"||e.type.name==="link")throw new Error("unexpected");const o={},r=n[e.type.name];for(const[a,l]of Object.entries(e.attrs)){if(!r)throw Error("ic node is of an unrecognized type: "+e.type.name);const c=r.propSchema;a in c&&(o[a]=l)}let s;return r.content==="styled"?s=Pe(e,n,t):s=void 0,{type:e.type.name,props:o,content:s}}function B(e,n,t=Je(n),o=Xe(n),r=ce(n),s=Ze(n)){var g;if(!e.type.isInGroup("bnBlock"))throw Error("Node should be a bnBlock, but is instead: "+e.type.name);const i=s==null?void 0:s.get(e);if(i)return i;const a=Ye(e,0);let l=a.bnBlock.node.attrs.id;l===null&&(l=Te.options.generateID());const c=t[a.blockNoteType];if(!c)throw Error("Block is of an unrecognized type: "+a.blockNoteType);const d={};for(const[b,w]of Object.entries({...e.attrs,...a.isBlockContainer?a.blockContent.node.attrs:{}})){const C=c.propSchema;b in C&&!(C[b].default===void 0&&w===void 0)&&(d[b]=w)}const u=t[a.blockNoteType],h=[];(g=a.childContainer)==null||g.node.forEach(b=>{h.push(B(b,n,t,o,r,s))});let f;if(u.content==="inline"){if(!a.isBlockContainer)throw new Error("impossible");f=Pe(a.blockContent.node,o,r)}else if(u.content==="table"){if(!a.isBlockContainer)throw new Error("impossible");f=Pt(a.blockContent.node,o,r)}else if(u.content==="none")f=void 0;else throw new j(u.content);const m={id:l,type:u.type,props:d,content:f,children:h};return s==null||s.set(e,m),m}function bn(e,n,t=Je(n),o=Xe(n),r=ce(n),s=Ze(n)){const i=[];return e.firstChild.descendants(a=>(i.push(B(a,n,t,o,r,s)),!1)),i}function kn(e,n,t=Je(n),o=Xe(n),r=ce(n),s=Ze(n)){function i(a,l,c){if(a.type.name!=="blockGroup")throw new Error("unexpected");const d=[];let u,h;return a.forEach((f,m,g)=>{if(f.type.name!=="blockContainer")throw new Error("unexpected");if(f.childCount===0)return;if(f.childCount===0||f.childCount>2)throw new Error("unexpected, blockContainer.childCount: "+f.childCount);const b=g===0,w=g===a.childCount-1;if(f.firstChild.type.name==="blockGroup"){if(!b)throw new Error("unexpected");const _=i(f.firstChild,Math.max(0,l-1),w?Math.max(0,c-1):0);u=_.blockCutAtStart,w&&(h=_.blockCutAtEnd),d.push(..._.blocks);return}const C=B(f,n,t,o,r,s),v=f.childCount>1?f.child(1):void 0;let I=[];if(v){const _=i(v,0,w?Math.max(0,c-1):0);I=_.blocks,w&&(h=_.blockCutAtEnd)}w&&!v&&c>1&&(h=C.id),b&&l>1&&(u=C.id),d.push({...C,children:I})}),{blocks:d,blockCutAtStart:u,blockCutAtEnd:h}}if(e.content.childCount===0)return{blocks:[],blockCutAtStart:void 0,blockCutAtEnd:void 0};if(e.content.childCount!==1)throw new Error("slice must be a single block, did you forget includeParents=true?");return i(e.content.firstChild,Math.max(e.openStart-1,0),Math.max(e.openEnd-1,0))}function ut(e,n,t,o){return e.dom.setAttribute("data-inline-content-type",n),Object.entries(t).filter(([r,s])=>{const i=o[r];return s!==i.default}).map(([r,s])=>[Se(r),s]).forEach(([r,s])=>e.dom.setAttribute(r,s)),e.contentDOM!==void 0&&e.contentDOM.setAttribute("data-editable",""),e}function wn(e){return{Backspace:({editor:n})=>{const t=n.state.selection.$from;return n.state.selection.empty&&t.node().type.name===e.type&&t.parentOffset===0}}}function yn(e,n){return{config:e,implementation:n}}function Cn(e,n){return yn({type:e.name,propSchema:n,content:e.config.content==="inline*"?"styled":"none"},{node:e})}function Mt(e){return Object.fromEntries(Object.entries(e).map(([n,t])=>[n,t.config]))}function vn(e){return[{tag:`[data-inline-content-type="${e.type}"]`,contentElement:n=>{const t=n;return t.matches("[data-editable]")?t:t.querySelector("[data-editable]")||t}}]}function Xr(e,n){const t=k.Node.create({name:e.type,inline:!0,group:"inline",selectable:e.content==="styled",atom:e.content==="none",content:e.content==="styled"?"inline*":"",addAttributes(){return ge(e.propSchema)},addKeyboardShortcuts(){return wn(e)},parseHTML(){return vn(e)},renderHTML({node:o}){const r=this.options.editor,s=n.render($e(o,r.schema.inlineContentSchema,r.schema.styleSchema),()=>{},r);return ut(s,e.type,o.attrs,e.propSchema)},addNodeView(){return({node:o,getPos:r})=>{const s=this.options.editor,i=n.render($e(o,s.schema.inlineContentSchema,s.schema.styleSchema),a=>{if(typeof r=="boolean")return;const l=W([a],s.pmSchema);s.transact(c=>c.replaceWith(r(),r()+o.nodeSize,l))},s);return ut(i,e.type,o.attrs,e.propSchema)}}});return Cn(t,e.propSchema)}function Sn(e){return e==="boolean"?{}:{stringValue:{default:void 0,keepOnSplit:!0,parseHTML:n=>n.getAttribute("data-value"),renderHTML:n=>n.stringValue!==void 0?{"data-value":n.stringValue}:{}}}}function En(e,n,t,o){return e.dom.setAttribute("data-style-type",n),o==="string"&&e.dom.setAttribute("data-value",t),e.contentDOM!==void 0&&e.contentDOM.setAttribute("data-editable",""),e}function It(e,n){return{config:e,implementation:n}}function ne(e,n){return It({type:e.name,propSchema:n},{mark:e})}function Lt(e){return Object.fromEntries(Object.entries(e).map(([n,t])=>[n,t.config]))}function Bn(e){return[{tag:`[data-style-type="${e.type}"]`,contentElement:n=>{const t=n;return t.matches("[data-editable]")?t:t.querySelector("[data-editable]")||t}}]}function Zr(e,n){const t=k.Mark.create({name:e.type,addAttributes(){return Sn(e.propSchema)},parseHTML(){return Bn(e)},renderHTML({mark:o}){let r;if(e.propSchema==="boolean")r=n.render();else if(e.propSchema==="string")r=n.render(o.attrs.stringValue);else throw new j(e.propSchema);return En(r,e.type,o.attrs.stringValue,e.propSchema)}});return It(e,{mark:t})}function re(e){const{height:n,width:t}=At(e),o=new Array(n).fill(!1).map(()=>new Array(t).fill(null)),r=(s,i)=>{for(let a=s;a<n;a++)for(let l=i;l<t;l++)if(!o[a][l])return{row:a,col:l};throw new Error("Unable to create occupancy grid for table, no more available cells")};for(let s=0;s<e.content.rows.length;s++)for(let i=0;i<e.content.rows[s].cells.length;i++){const a=Ue(e.content.rows[s].cells[i]),l=Fe(a),c=me(a),{row:d,col:u}=r(s,i);for(let h=d;h<d+l;h++)for(let f=u;f<u+c;f++){if(o[h][f])throw new Error(`Unable to create occupancy grid for table, cell at ${h},${f} is already occupied`);o[h][f]={row:s,col:i,rowspan:l,colspan:c,cell:a}}}return o}function Ee(e){const n=new Set;return e.map(t=>({cells:t.map(o=>n.has(o.row+":"+o.col)?!1:(n.add(o.row+":"+o.col),o.cell)).filter(o=>o!==!1)}))}function le(e,n,t=re(n)){for(let o=0;o<t.length;o++)for(let r=0;r<t[o].length;r++){const s=t[o][r];if(s.row===e.row&&s.col===e.col)return{row:o,col:r,cell:s.cell}}throw new Error(`Unable to resolve relative table cell indices for table, cell at ${e.row},${e.col} is not occupied`)}function At(e){const n=e.content.rows.length;let t=0;return e.content.rows.forEach(o=>{let r=0;o.cells.forEach(s=>{r+=me(s)}),t=Math.max(t,r)}),{height:n,width:t}}function Tn(e,n,t=re(n)){var r;const o=(r=t[e.row])==null?void 0:r[e.col];if(o)return{row:o.row,col:o.col,cell:o.cell}}function pt(e,n){var s;const t=re(e);if(n<0||n>=t.length)return[];let o=0;for(let i=0;i<n;i++){const a=(s=t[o])==null?void 0:s[0];if(!a)return[];o+=a.rowspan}const r=new Array(t[0].length).fill(!1).map((i,a)=>Tn({row:o,col:a},e,t)).filter(i=>i!==void 0);return r.filter((i,a)=>r.findIndex(l=>l.row===i.row&&l.col===i.col)===a)}function ht(e,n){var s;const t=re(e);if(n<0||n>=t[0].length)return[];let o=0;for(let i=0;i<n;i++){const a=(s=t[0])==null?void 0:s[o];if(!a)return[];o+=a.colspan}const r=new Array(t.length).fill(!1).map((i,a)=>Tn({row:a,col:o},e,t)).filter(i=>i!==void 0);return r.filter((i,a)=>r.findIndex(l=>l.row===i.row&&l.col===i.col)===a)}function Qr(e,n,t,o=re(e)){const{col:r}=le({row:0,col:n},e,o),{col:s}=le({row:0,col:t},e,o);return o.forEach(i=>{const[a]=i.splice(r,1);i.splice(s,0,a)}),Ee(o)}function es(e,n,t,o=re(e)){const{row:r}=le({row:n,col:0},e,o),{row:s}=le({row:t,col:0},e,o),[i]=o.splice(r,1);return o.splice(s,0,i),Ee(o)}function ft(e){return e?fe(e)?ft(e.content):typeof e=="string"?e.length===0:Array.isArray(e)?e.every(n=>typeof n=="string"?n.length===0:oe(n)?n.text.length===0:Et(n)?typeof n.content=="string"?n.content.length===0:n.content.every(t=>t.text.length===0):!1):!1:!0}function ts(e,n,t=re(e)){if(n==="columns"){let s=0;for(let i=t[0].length-1;i>=0&&t.every(l=>ft(l[i].cell)&&l[i].colspan===1);i--)s++;for(let i=t.length-1;i>=0;i--){const a=Math.max(t[i].length-s,1);t[i]=t[i].slice(0,a)}return Ee(t)}let o=0;for(let s=t.length-1;s>=0&&t[s].every(a=>ft(a.cell)&&a.rowspan===1);s--)o++;const r=Math.min(o,t.length-1);return t.splice(t.length-r,r),Ee(t)}function ns(e,n,t,o=re(e)){const{width:r,height:s}=At(e);if(n==="columns")o.forEach((i,a)=>{if(t>=0)for(let l=0;l<t;l++)i.push({row:a,col:Math.max(...i.map(c=>c.col))+1,rowspan:1,colspan:1,cell:Ue("")});else i.splice(r+t,-1*t)});else if(t>0)for(let i=0;i<t;i++){const a=new Array(r).fill(null).map((l,c)=>({row:s+i,col:c,rowspan:1,colspan:1,cell:Ue("")}));o.push(a)}else t<0&&o.splice(s+t,-1*t);return Ee(o)}function xn(e,n,t){const o=pt(e,t);if(!o.some(l=>Fe(l.cell)>1))return!0;let s=t,i=t;return o.forEach(l=>{const c=Fe(l.cell);s=Math.max(s,l.row+c-1),i=Math.min(i,l.row)}),n<t?t===s:t===i}function Pn(e,n,t){const o=ht(e,t);if(!o.some(l=>me(l.cell)>1))return!0;let s=t,i=t;return o.forEach(l=>{const c=me(l.cell);s=Math.max(s,l.col+c-1),i=Math.min(i,l.col)}),n<t?t===s:t===i}function os(e,n,t){const o=le(e,t),r=le(n,t);return o.col===r.col}function Gt(e,n,t,o){const r=[];for(const[i,a]of Object.entries(e.styles||{})){const l=t[i];if(!l)throw new Error(`style ${i} not found in styleSchema`);if(l.propSchema==="boolean")a&&r.push(n.mark(i));else if(l.propSchema==="string")a&&r.push(n.mark(i,{stringValue:a}));else throw new j(l.propSchema)}return!o||!n.nodes[o].spec.code?e.text.split(/(\n)/g).filter(i=>i.length>0).map(i=>i===`
6
- `?n.nodes.hardBreak.createChecked():n.text(i,r)):e.text.length>0?[n.text(e.text,r)]:[]}function rs(e,n,t){const o=n.marks.link.create({href:e.href});return mt(e.content,n,t).map(r=>{if(r.type.name==="text")return r.mark([...r.marks,o]);if(r.type.name==="hardBreak")return r;throw new Error("unexpected node type")})}function mt(e,n,t,o){const r=[];if(typeof e=="string")return r.push(...Gt({text:e,styles:{}},n,t,o)),r;for(const s of e)r.push(...Gt(s,n,t,o));return r}function W(e,n,t,o=ce(n)){const r=[];for(const s of e)typeof s=="string"?r.push(...mt(s,n,o,t)):Et(s)?r.push(...rs(s,n,o)):oe(s)?r.push(...mt([s],n,o,t)):r.push(Mn(s,n,o));return r}function Me(e,n,t=ce(n)){const o=[],r=new Array(e.headerRows??0).fill(!0),s=new Array(e.headerCols??0).fill(!0),i=e.columnWidths??[];for(let a=0;a<e.rows.length;a++){const l=e.rows[a],c=[],d=r[a];for(let h=0;h<l.cells.length;h++){const f=l.cells[h],m=s[h],g=void 0;let b=null;const w=le({row:a,col:h},{content:e});let C=i[w.col]?[i[w.col]]:null;if(f)if(typeof f=="string")b=n.text(f);else if(fe(f)){f.content&&(b=W(f.content,n,"tableParagraph",t));const I=me(f);I>1&&(C=new Array(I).fill(!1).map((_,K)=>i[w.col+K]??void 0))}else b=W(f,n,"tableParagraph",t);const v=n.nodes[m||d?"tableHeader":"tableCell"].createChecked({...fe(f)?f.props:{},colwidth:C},n.nodes.tableParagraph.createChecked(g,b));c.push(v)}const u=n.nodes.tableRow.createChecked({},c);o.push(u)}return o}function Mn(e,n,t){let o,r=e.type;if(r===void 0&&(r="paragraph"),!n.nodes[r])throw new Error(`node type ${r} not found in schema`);if(!e.content)o=n.nodes[r].createChecked(e.props);else if(typeof e.content=="string"){const s=W([e.content],n,r,t);o=n.nodes[r].createChecked(e.props,s)}else if(Array.isArray(e.content)){const s=W(e.content,n,r,t);o=n.nodes[r].createChecked(e.props,s)}else if(e.content.type==="tableContent"){const s=Me(e.content,n,t);o=n.nodes[r].createChecked(e.props,s)}else throw new j(e.content.type);return o}function se(e,n,t=ce(n)){let o=e.id;o===void 0&&(o=Te.options.generateID());const r=[];if(e.children)for(const i of e.children)r.push(se(i,n,t));if(!e.type||n.nodes[e.type].isInGroup("blockContent")){const i=Mn(e,n,t),a=r.length>0?n.nodes.blockGroup.createChecked({},r):void 0;return n.nodes.blockContainer.createChecked({id:o,...e.props},a?[i,a]:i)}else{if(n.nodes[e.type].isInGroup("bnBlock"))return n.nodes[e.type].createChecked({id:o,...e.props},r);throw new Error(`block type ${e.type} doesn't match blockContent or bnBlock group`)}}function z(e,n){let t,o;if(n.firstChild.descendants((r,s)=>t?!1:!ze(r)||r.attrs.id!==e?!0:(t=r,o=s+1,!1)),!(t===void 0||o===void 0))return{node:t,posBeforeNode:o}}function ze(e){return e.type.isInGroup("bnBlock")}function ss(e,n){return e.id!==n.id||e.type!==n.type||JSON.stringify(e.props)!==JSON.stringify(n.props)||JSON.stringify(e.content)!==JSON.stringify(n.content)}function In(e,n=[]){let t={type:"local"};e.getMeta("paste")?t={type:"paste"}:e.getMeta("uiEvent")==="drop"?t={type:"drop"}:e.getMeta("history$")?t={type:e.getMeta("history$").redo?"redo":"undo"}:e.getMeta("y-sync$")&&(e.getMeta("y-sync$").isUndoRedoOperation?t={type:"undo-redo"}:t={type:"yjs-remote"});const o=O(e),r=k.combineTransactionSteps(e.before,[e,...n]),s=k.getChangedRanges(r),i=s.flatMap(u=>k.findChildrenInRange(r.before,u.oldRange,ze)).map(({node:u})=>B(u,o)),a=s.flatMap(u=>k.findChildrenInRange(r.doc,u.newRange,ze)).map(({node:u})=>B(u,o)),l=new Map(a.map(u=>[u.id,u])),c=new Map(i.map(u=>[u.id,u])),d=[];for(const[u,h]of l)c.has(u)||d.push({type:"insert",block:h,source:t,prevBlock:void 0});for(const[u,h]of c)l.has(u)||d.push({type:"delete",block:h,source:t,prevBlock:void 0});for(const[u,h]of l)if(c.has(u)){const f=c.get(u);ss(f,h)&&d.push({type:"update",block:h,prevBlock:f,source:t})}return d}function Ln(e,n,t,o="before"){const r=typeof t=="string"?t:t.id,s=O(e),i=n.map(d=>se(d,s)),a=z(r,e.doc);if(!a)throw new Error(`Block with ID ${r} not found`);let l=a.posBeforeNode;return o==="after"&&(l+=a.node.nodeSize),e.step(new he.ReplaceStep(l,l,new S.Slice(S.Fragment.from(i),0,0))),i.map(d=>B(d,s))}function gt(e,n,t){const o=O(e),r=t.map(d=>se(d,o)),s=new Set(n.map(d=>typeof d=="string"?d:d.id)),i=[],a=typeof n[0]=="string"?n[0]:n[0].id;let l=0;if(e.doc.descendants((d,u)=>{if(s.size===0)return!1;if(!d.type.isInGroup("bnBlock")||!s.has(d.attrs.id))return!0;if(i.push(B(d,o)),s.delete(d.attrs.id),t.length>0&&d.attrs.id===a){const g=e.doc.nodeSize;e.insert(u,r);const b=e.doc.nodeSize;l+=g-b}const h=e.doc.nodeSize,f=e.doc.resolve(u-l);f.node().type.name==="blockGroup"&&f.node(f.depth-1).type.name!=="doc"&&f.node().childCount===1?e.delete(f.before(),f.after()):e.delete(u-l,u-l+d.nodeSize);const m=e.doc.nodeSize;return l+=h-m,!1}),s.size>0){const d=[...s].join(`
7
- `);throw Error("Blocks with the following IDs could not be found in the editor: "+d)}return{insertedBlocks:r.map(d=>B(d,o)),removedBlocks:i}}const U=(e,n)=>({tr:t,dispatch:o})=>(o&&Nt(t,e,n),!0);function Nt(e,n,t,o,r){const s=ke(e.doc.resolve(n)),i=O(e);if(o!==void 0&&r!==void 0&&o>r)throw new Error("Invalid replaceFromPos or replaceToPos");const a=i.nodes[s.blockNoteType],l=i.nodes[t.type||s.blockNoteType],c=l.isInGroup("bnBlock")?l:i.nodes.blockContainer;if(s.isBlockContainer&&l.isInGroup("blockContent")){const d=o!==void 0&&o>s.blockContent.beforePos&&o<s.blockContent.afterPos?o-s.blockContent.beforePos-1:void 0,u=r!==void 0&&r>s.blockContent.beforePos&&r<s.blockContent.afterPos?r-s.blockContent.beforePos-1:void 0;Yt(t,e,s),is(t,e,a,l,s,d,u)}else if(!s.isBlockContainer&&l.isInGroup("bnBlock"))Yt(t,e,s);else{const d=B(s.bnBlock.node,i);e.replaceWith(s.bnBlock.beforePos,s.bnBlock.afterPos,se({children:d.children,...t},i));return}e.setNodeMarkup(s.bnBlock.beforePos,c,{...s.bnBlock.node.attrs,...t.props})}function is(e,n,t,o,r,s,i){const a=O(n);let l="keep";if(e.content)if(typeof e.content=="string")l=W([e.content],a,o.name);else if(Array.isArray(e.content))l=W(e.content,a,o.name);else if(e.content.type==="tableContent")l=Me(e.content,a);else throw new j(e.content.type);else t.spec.content===""||o.spec.content!==t.spec.content&&(l=[]);if(l==="keep")n.setNodeMarkup(r.blockContent.beforePos,o,{...r.blockContent.node.attrs,...e.props});else if(s!==void 0||i!==void 0){n.setNodeMarkup(r.blockContent.beforePos,o,{...r.blockContent.node.attrs,...e.props});const c=r.blockContent.beforePos+1+(s??0),d=r.blockContent.beforePos+1+(i??r.blockContent.node.content.size),u=n.doc.resolve(r.blockContent.beforePos).depth,h=n.doc.resolve(c).depth,f=n.doc.resolve(d).depth;n.replace(c,d,new S.Slice(S.Fragment.from(l),h-u-1,f-u-1))}else n.replaceWith(r.blockContent.beforePos,r.blockContent.afterPos,o.createChecked({...r.blockContent.node.attrs,...e.props},l))}function Yt(e,n,t){const o=O(n);if(e.children!==void 0&&e.children.length>0){const r=e.children.map(s=>se(s,o));if(t.childContainer)n.step(new he.ReplaceStep(t.childContainer.beforePos+1,t.childContainer.afterPos-1,new S.Slice(S.Fragment.from(r),0,0)));else{if(!t.isBlockContainer)throw new Error("impossible");n.insert(t.blockContent.afterPos,o.nodes.blockGroup.createChecked({},r))}}}function An(e,n,t,o,r){const s=typeof n=="string"?n:n.id,i=z(s,e.doc);if(!i)throw new Error(`Block with ID ${s} not found`);Nt(e,i.posBeforeNode,t,o,r);const a=e.doc.resolve(i.posBeforeNode+1).node(),l=O(e);return B(a,l)}function Nn(e){const n=Array.from(e.classList).filter(t=>!t.startsWith("bn-"))||[];n.length>0?e.className=n.join(" "):e.removeAttribute("class")}function Dn(e,n,t,o){let r;if(n)if(typeof n=="string")r=W([n],e.pmSchema);else if(Array.isArray(n))r=W(n,e.pmSchema);else if(n.type==="tableContent")r=Me(n,e.pmSchema);else throw new j(n.type);else throw new Error("blockContent is required");const s=t.serializeFragment(S.Fragment.from(r),o);return s.nodeType===1&&Nn(s),s}function as(e,n,t,o,r,s,i){var g,b,w,C,v,I,_,K;const a=(i==null?void 0:i.document)??document,l=n.pmSchema.nodes.blockContainer;let c=t.props;if(!t.props){c={};for(const[x,T]of Object.entries(n.schema.blockSchema[t.type].propSchema))T.default!==void 0&&(c[x]=T.default)}const d=(b=(g=l.spec)==null?void 0:g.toDOM)==null?void 0:b.call(g,l.create({id:t.id,...c})),u=Array.from(d.dom.attributes),h=n.blockImplementations[t.type].implementation.toExternalHTML({...t,props:c},n),f=a.createDocumentFragment();if(h.dom.classList.contains("bn-block-content")){const x=[...u,...Array.from(h.dom.attributes)].filter(T=>T.name.startsWith("data")&&T.name!=="data-content-type"&&T.name!=="data-file-block"&&T.name!=="data-node-view-wrapper"&&T.name!=="data-node-type"&&T.name!=="data-id"&&T.name!=="data-index"&&T.name!=="data-editable");for(const T of x)h.dom.firstChild.setAttribute(T.name,T.value);Nn(h.dom.firstChild),f.append(...Array.from(h.dom.childNodes))}else f.append(h.dom);if(h.contentDOM&&t.content){const x=Dn(n,t.content,o,i);h.contentDOM.appendChild(x)}let m;if(r.has(t.type)?m="OL":s.has(t.type)&&(m="UL"),m){if(((w=e.lastChild)==null?void 0:w.nodeName)!==m){const T=a.createElement(m);m==="OL"&&(c!=null&&c.start)&&(c==null?void 0:c.start)!==1&&T.setAttribute("start",c.start+""),e.append(T)}const x=a.createElement("li");x.append(f),e.lastChild.appendChild(x)}else e.append(f);if(t.children&&t.children.length>0){const x=a.createDocumentFragment();if(Hn(x,n,t.children,o,r,s,i),((C=e.lastChild)==null?void 0:C.nodeName)==="UL"||((v=e.lastChild)==null?void 0:v.nodeName)==="OL")for(;((I=x.firstChild)==null?void 0:I.nodeName)==="UL"||((_=x.firstChild)==null?void 0:_.nodeName)==="OL";)e.lastChild.lastChild.appendChild(x.firstChild);n.pmSchema.nodes[t.type].isInGroup("blockContent")?e.append(x):(K=h.contentDOM)==null||K.append(x)}}const Hn=(e,n,t,o,r,s,i)=>{for(const a of t)as(e,n,a,o,r,s,i)},ls=(e,n,t,o,r,s)=>{const a=((s==null?void 0:s.document)??document).createDocumentFragment();return Hn(a,e,n,t,o,r,s),a},Ie=(e,n)=>{const t=S.DOMSerializer.fromSchema(e);return{exportBlocks:(o,r)=>{const s=ls(n,o,t,new Set(["numberedListItem"]),new Set(["bulletListItem","checkListItem"]),r),i=document.createElement("div");return i.append(s),i.innerHTML},exportInlineContent:(o,r)=>{const s=Dn(n,o,t,r),i=document.createElement("div");return i.append(s.cloneNode(!0)),i.innerHTML}}};function cs(e,n,t,o,r){let s;if(n)if(typeof n=="string")s=W([n],e.pmSchema,o);else if(Array.isArray(n))s=W(n,e.pmSchema,o);else if(n.type==="tableContent")s=Me(n,e.pmSchema);else throw new j(n.type);else throw new Error("blockContent is required");return t.serializeFragment(S.Fragment.from(s),r)}function ds(e,n,t,o,r){var u,h,f,m,g;const s=e.pmSchema.nodes.blockContainer;let i=n.props;if(!n.props){i={};for(const[b,w]of Object.entries(e.schema.blockSchema[n.type].propSchema))w.default!==void 0&&(i[b]=w.default)}const l=e.blockImplementations[n.type].implementation.toInternalHTML({...n,props:i},e);if(n.type==="numberedListItem"&&l.dom.setAttribute("data-index",o.toString()),l.contentDOM&&n.content){const b=cs(e,n.content,t,n.type,r);l.contentDOM.appendChild(b)}if(e.pmSchema.nodes[n.type].isInGroup("bnBlock")){if(n.children&&n.children.length>0){const b=On(e,n.children,t,r);(u=l.contentDOM)==null||u.append(b)}return l.dom}const d=(f=(h=s.spec)==null?void 0:h.toDOM)==null?void 0:f.call(h,s.create({id:n.id,...i}));return(m=d.contentDOM)==null||m.appendChild(l.dom),n.children&&n.children.length>0&&((g=d.contentDOM)==null||g.appendChild(Rn(e,n.children,t,r))),d.dom}function On(e,n,t,o){const s=((o==null?void 0:o.document)??document).createDocumentFragment();let i=0;for(const a of n){a.type==="numberedListItem"?i++:i=0;const l=ds(e,a,t,i,o);s.appendChild(l)}return s}const Rn=(e,n,t,o)=>{var a;const r=e.pmSchema.nodes.blockGroup,s=r.spec.toDOM(r.create({})),i=On(e,n,t,o);return(a=s.contentDOM)==null||a.appendChild(i),s.dom},_n=(e,n)=>{const t=S.DOMSerializer.fromSchema(e);return{serializeBlocks:(o,r)=>Rn(n,o,t,r).outerHTML}},Le=(e,n)=>{const t=e.querySelector(n);if(!t)return;const o=e.querySelector("figcaption"),r=(o==null?void 0:o.textContent)??void 0;return{targetElement:t,caption:r}},Vn=(e,n,t,o)=>{const r=document.createElement("div");r.className="bn-add-file-button";const s=document.createElement("div");s.className="bn-add-file-button-icon",o?s.appendChild(o):s.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>',r.appendChild(s);const i=document.createElement("p");i.className="bn-add-file-button-text",i.innerHTML=t||n.dictionary.file_blocks.file.add_button_text,r.appendChild(i);const a=c=>{c.preventDefault()},l=()=>{n.transact(c=>c.setMeta(n.filePanel.plugins[0],{block:e}))};return r.addEventListener("mousedown",a,!0),r.addEventListener("click",l,!0),{dom:r,destroy:()=>{r.removeEventListener("mousedown",a,!0),r.removeEventListener("click",l,!0)}}},Un='<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>',Fn=e=>{const n=document.createElement("div");n.className="bn-file-name-with-icon";const t=document.createElement("div");t.className="bn-file-icon",t.innerHTML=Un,n.appendChild(t);const o=document.createElement("p");return o.className="bn-file-name",o.textContent=e.props.name,n.appendChild(o),{dom:n}},Qe=(e,n,t,o,r)=>{const s=document.createElement("div");if(s.className="bn-file-block-content-wrapper",e.props.url===""){const a=Vn(e,n,o,r);s.appendChild(a.dom);const l=n.onUploadStart(c=>{if(c===e.id){s.removeChild(a.dom);const d=document.createElement("div");d.className="bn-file-loading-preview",d.textContent="Loading...",s.appendChild(d)}});return{dom:s,destroy:()=>{l(),a.destroy()}}}const i={dom:s};if(e.props.showPreview===!1||!t){const a=Fn(e);s.appendChild(a.dom),i.destroy=()=>{var l;(l=a.destroy)==null||l.call(a)}}else s.appendChild(t.dom);if(e.props.caption){const a=document.createElement("p");a.className="bn-file-caption",a.textContent=e.props.caption,s.appendChild(a)}return i},et=(e,n)=>{const t=document.createElement("figure"),o=document.createElement("figcaption");return o.textContent=n,t.appendChild(e),t.appendChild(o),{dom:t}},Ae=(e,n)=>{const t=document.createElement("div"),o=document.createElement("p");return o.textContent=n,t.appendChild(e),t.appendChild(o),{dom:t}},Jt=e=>({url:e.src||void 0}),$n='<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>',zn={backgroundColor:M.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0}},Wn={type:"audio",propSchema:zn,content:"none",isFileBlock:!0,fileBlockAccept:["audio/*"]},Kn=(e,n)=>{const t=document.createElement("div");t.innerHTML=$n;const o=document.createElement("audio");return o.className="bn-audio",n.resolveFileUrl?n.resolveFileUrl(e.props.url).then(r=>{o.src=r}):o.src=e.props.url,o.controls=!0,o.contentEditable="false",o.draggable=!1,Qe(e,n,{dom:o},n.dictionary.file_blocks.audio.add_button_text,t.firstElementChild)},qn=e=>{if(e.tagName==="AUDIO")return e.closest("figure")?void 0:Jt(e);if(e.tagName==="FIGURE"){const n=Le(e,"audio");if(!n)return;const{targetElement:t,caption:o}=n;return{...Jt(t),caption:o}}},jn=e=>{if(!e.props.url){const t=document.createElement("p");return t.textContent="Add audio",{dom:t}}let n;return e.props.showPreview?(n=document.createElement("audio"),n.src=e.props.url):(n=document.createElement("a"),n.href=e.props.url,n.textContent=e.props.name||e.props.url),e.props.caption?e.props.showPreview?et(n,e.props.caption):Ae(n,e.props.caption):{dom:n}},Gn=be(Wn,{render:Kn,parse:qn,toExternalHTML:jn}),bt=Symbol.for("blocknote.shikiParser"),_e=Symbol.for("blocknote.shikiHighlighterPromise"),Yn={language:{default:"text"}},us=G({name:"codeBlock",content:"inline*",group:"blockContent",marks:"insertion deletion modification",code:!0,defining:!0,addOptions(){return{defaultLanguage:"text",indentLineWithTab:!0,supportedLanguages:{}}},addAttributes(){const e=this.options;return{language:{default:e.editor.settings.codeBlock.defaultLanguage,parseHTML:n=>{let t=n,o=null;(t==null?void 0:t.tagName)==="DIV"&&(t==null?void 0:t.dataset.contentType)==="codeBlock"&&(t=t.children[0]),(t==null?void 0:t.tagName)==="PRE"&&(t=t==null?void 0:t.children[0]);const r=t==null?void 0:t.getAttribute("data-language");if(r)o=r.toLowerCase();else{const i=[...(t==null?void 0:t.className.split(" "))||[]].filter(a=>a.startsWith("language-")).map(a=>a.replace("language-",""));i.length>0&&(o=i[0].toLowerCase())}return o?it(e.editor.settings.codeBlock,o)??o:null},renderHTML:n=>n.language?{class:`language-${n.language}`,"data-language":n.language}:{}}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"pre",preserveWhitespace:"full"}]},renderHTML({HTMLAttributes:e}){var r,s;const n=document.createElement("pre"),{dom:t,contentDOM:o}=$(this.name,"code",((r=this.options.domAttributes)==null?void 0:r.blockContent)||{},{...((s=this.options.domAttributes)==null?void 0:s.inlineContent)||{},...e});return t.removeChild(o),t.appendChild(n),n.appendChild(o),{dom:t,contentDOM:o}},addNodeView(){const e=this.options;return({editor:n,node:t,getPos:o,HTMLAttributes:r})=>{var u,h;const s=document.createElement("pre"),i=document.createElement("select"),a=document.createElement("div"),{dom:l,contentDOM:c}=$(this.name,"code",{...((u=this.options.domAttributes)==null?void 0:u.blockContent)||{},...r},((h=this.options.domAttributes)==null?void 0:h.inlineContent)||{}),d=f=>{const m=f.target.value;n.commands.command(({tr:g})=>(g.setNodeAttribute(o(),"language",m),!0))};return Object.entries(e.editor.settings.codeBlock.supportedLanguages).forEach(([f,{name:m}])=>{const g=document.createElement("option");g.value=f,g.text=m,i.appendChild(g)}),a.contentEditable="false",i.value=t.attrs.language||e.editor.settings.codeBlock.defaultLanguage,l.removeChild(c),l.appendChild(a),l.appendChild(s),s.appendChild(c),a.appendChild(i),i.addEventListener("change",d),{dom:l,contentDOM:c,update:f=>f.type===this.type,destroy:()=>{i.removeEventListener("change",d)}}}},addProseMirrorPlugins(){const e=this.options,n=globalThis;let t,o,r=!1;const s=a=>{if(!e.editor.settings.codeBlock.createHighlighter)return process.env.NODE_ENV==="development"&&!r&&(console.log("For syntax highlighting of code blocks, you must provide a `codeBlock.createHighlighter` function"),r=!0),[];if(!t)return n[_e]=n[_e]||e.editor.settings.codeBlock.createHighlighter(),n[_e].then(c=>{t=c});const l=it(e.editor.settings.codeBlock,a.language);return!l||l==="text"||l==="none"||l==="plaintext"||l==="txt"?[]:t.getLoadedLanguages().includes(l)?(o||(o=n[bt]||Er.createParser(t),n[bt]=o),o(a)):t.loadLanguage(l)};return[Sr.createHighlightPlugin({parser:s,languageExtractor:a=>a.attrs.language,nodeTypes:[this.name]})]},addInputRules(){const e=this.options;return[new k.InputRule({find:/^```(.*?)\s$/,handler:({state:n,range:t,match:o})=>{const r=n.doc.resolve(t.from),s=o[1].trim(),i={language:it(e.editor.settings.codeBlock,s)??s};if(!r.node(-1).canReplaceWith(r.index(-1),r.indexAfter(-1),this.type))return null;n.tr.delete(t.from,t.to).setBlockType(t.from,t.from,this.type,i).setSelection(y.TextSelection.create(n.tr.doc,t.from))}})]},addKeyboardShortcuts(){return{Delete:({editor:e})=>{const{selection:n}=e.state,{$from:t}=n;if(e.isActive(this.name)&&!t.parent.textContent&&k.isTextSelection(n)){const o=t.pos-t.parentOffset-2;return e.chain().setNodeSelection(o).deleteSelection().run(),!0}return!1},Tab:({editor:e})=>this.options.indentLineWithTab&&e.isActive(this.name)?(e.commands.insertContent(" "),!0):!1,Enter:({editor:e})=>{const{$from:n}=e.state.selection;if(!e.isActive(this.name))return!1;const t=n.parentOffset===n.parent.nodeSize-2,o=n.parent.textContent.endsWith(`
5
+ `,styles:{}};return}if(s.type.name!=="link"&&s.type.name!=="text"){if(!n[s.type.name]){console.warn("unrecognized inline content type",s.type.name);return}r&&(o.push(r),r=void 0),o.push(Fe(s,n,t));return}const i={};let a;for(const l of s.marks)if(l.type.name==="link")a=l;else{const c=t[l.type.name];if(!c){if(l.type.spec.blocknoteIgnore)continue;throw new Error(`style ${l.type.name} not found in styleSchema`)}if(c.propSchema==="boolean")i[c.type]=!0;else if(c.propSchema==="string")i[c.type]=l.attrs.stringValue;else throw new j(c.propSchema)}r?oe(r)?a?(o.push(r),r={type:"link",href:a.attrs.href,content:[{type:"text",text:s.textContent,styles:i}]}):JSON.stringify(r.styles)===JSON.stringify(i)?r.text+=s.textContent:(o.push(r),r={type:"text",text:s.textContent,styles:i}):lt(r)&&(a?r.href===a.attrs.href?JSON.stringify(r.content[r.content.length-1].styles)===JSON.stringify(i)?r.content[r.content.length-1].text+=s.textContent:r.content.push({type:"text",text:s.textContent,styles:i}):(o.push(r),r={type:"link",href:a.attrs.href,content:[{type:"text",text:s.textContent,styles:i}]}):(o.push(r),r={type:"text",text:s.textContent,styles:i})):a?r={type:"link",href:a.attrs.href,content:[{type:"text",text:s.textContent,styles:i}]}:r={type:"text",text:s.textContent,styles:i}}),r&&o.push(r),o}function Fe(e,n,t){if(e.type.name==="text"||e.type.name==="link")throw new Error("unexpected");const o={},r=n[e.type.name];for(const[a,l]of Object.entries(e.attrs)){if(!r)throw Error("ic node is of an unrecognized type: "+e.type.name);const c=r.propSchema;a in c&&(o[a]=l)}let s;return r.content==="styled"?s=xe(e,n,t):s=void 0,{type:e.type.name,props:o,content:s}}function B(e,n,t=Ge(n),o=Ye(n),r=ce(n),s=Je(n)){var g;if(!e.type.isInGroup("bnBlock"))throw Error("Node should be a bnBlock, but is instead: "+e.type.name);const i=s==null?void 0:s.get(e);if(i)return i;const a=je(e,0);let l=a.bnBlock.node.attrs.id;l===null&&(l=Be.options.generateID());const c=t[a.blockNoteType];if(!c)throw Error("Block is of an unrecognized type: "+a.blockNoteType);const d={};for(const[b,w]of Object.entries({...e.attrs,...a.isBlockContainer?a.blockContent.node.attrs:{}})){const C=c.propSchema;b in C&&!(C[b].default===void 0&&w===void 0)&&(d[b]=w)}const u=t[a.blockNoteType],h=[];(g=a.childContainer)==null||g.node.forEach(b=>{h.push(B(b,n,t,o,r,s))});let f;if(u.content==="inline"){if(!a.isBlockContainer)throw new Error("impossible");f=xe(a.blockContent.node,o,r)}else if(u.content==="table"){if(!a.isBlockContainer)throw new Error("impossible");f=xt(a.blockContent.node,o,r)}else if(u.content==="none")f=void 0;else throw new j(u.content);const m={id:l,type:u.type,props:d,content:f,children:h};return s==null||s.set(e,m),m}function wn(e,n,t=Ge(n),o=Ye(n),r=ce(n),s=Je(n)){const i=[];return e.firstChild.descendants(a=>(i.push(B(a,n,t,o,r,s)),!1)),i}function yn(e,n,t=Ge(n),o=Ye(n),r=ce(n),s=Je(n)){function i(a,l,c){if(a.type.name!=="blockGroup")throw new Error("unexpected");const d=[];let u,h;return a.forEach((f,m,g)=>{if(f.type.name!=="blockContainer")throw new Error("unexpected");if(f.childCount===0)return;if(f.childCount===0||f.childCount>2)throw new Error("unexpected, blockContainer.childCount: "+f.childCount);const b=g===0,w=g===a.childCount-1;if(f.firstChild.type.name==="blockGroup"){if(!b)throw new Error("unexpected");const _=i(f.firstChild,Math.max(0,l-1),w?Math.max(0,c-1):0);u=_.blockCutAtStart,w&&(h=_.blockCutAtEnd),d.push(..._.blocks);return}const C=B(f,n,t,o,r,s),v=f.childCount>1?f.child(1):void 0;let I=[];if(v){const _=i(v,0,w?Math.max(0,c-1):0);I=_.blocks,w&&(h=_.blockCutAtEnd)}w&&!v&&c>1&&(h=C.id),b&&l>1&&(u=C.id),d.push({...C,children:I})}),{blocks:d,blockCutAtStart:u,blockCutAtEnd:h}}if(e.content.childCount===0)return{blocks:[],blockCutAtStart:void 0,blockCutAtEnd:void 0};if(e.content.childCount!==1)throw new Error("slice must be a single block, did you forget includeParents=true?");return i(e.content.firstChild,Math.max(e.openStart-1,0),Math.max(e.openEnd-1,0))}function dt(e,n,t,o){return e.dom.setAttribute("data-inline-content-type",n),Object.entries(t).filter(([r,s])=>{const i=o[r];return s!==i.default}).map(([r,s])=>[ve(r),s]).forEach(([r,s])=>e.dom.setAttribute(r,s)),e.contentDOM!==void 0&&e.contentDOM.setAttribute("data-editable",""),e}function Cn(e){return{Backspace:({editor:n})=>{const t=n.state.selection.$from;return n.state.selection.empty&&t.node().type.name===e.type&&t.parentOffset===0}}}function vn(e,n){return{config:e,implementation:n}}function Sn(e,n){return vn({type:e.name,propSchema:n,content:e.config.content==="inline*"?"styled":"none"},{node:e})}function Pt(e){return Object.fromEntries(Object.entries(e).map(([n,t])=>[n,t.config]))}function En(e){return[{tag:`[data-inline-content-type="${e.type}"]`,contentElement:n=>{const t=n;return t.matches("[data-editable]")?t:t.querySelector("[data-editable]")||t}}]}function Zr(e,n){const t=k.Node.create({name:e.type,inline:!0,group:"inline",selectable:e.content==="styled",atom:e.content==="none",content:e.content==="styled"?"inline*":"",addAttributes(){return ge(e.propSchema)},addKeyboardShortcuts(){return Cn(e)},parseHTML(){return En(e)},renderHTML({node:o}){const r=this.options.editor,s=n.render(Fe(o,r.schema.inlineContentSchema,r.schema.styleSchema),()=>{},r);return dt(s,e.type,o.attrs,e.propSchema)},addNodeView(){return({node:o,getPos:r})=>{const s=this.options.editor,i=n.render(Fe(o,s.schema.inlineContentSchema,s.schema.styleSchema),a=>{if(typeof r=="boolean")return;const l=W([a],s.pmSchema);s.transact(c=>c.replaceWith(r(),r()+o.nodeSize,l))},s);return dt(i,e.type,o.attrs,e.propSchema)}}});return Sn(t,e.propSchema)}function Bn(e){return e==="boolean"?{}:{stringValue:{default:void 0,keepOnSplit:!0,parseHTML:n=>n.getAttribute("data-value"),renderHTML:n=>n.stringValue!==void 0?{"data-value":n.stringValue}:{}}}}function Tn(e,n,t,o){return e.dom.setAttribute("data-style-type",n),o==="string"&&e.dom.setAttribute("data-value",t),e.contentDOM!==void 0&&e.contentDOM.setAttribute("data-editable",""),e}function Mt(e,n){return{config:e,implementation:n}}function ne(e,n){return Mt({type:e.name,propSchema:n},{mark:e})}function It(e){return Object.fromEntries(Object.entries(e).map(([n,t])=>[n,t.config]))}function xn(e){return[{tag:`[data-style-type="${e.type}"]`,contentElement:n=>{const t=n;return t.matches("[data-editable]")?t:t.querySelector("[data-editable]")||t}}]}function Qr(e,n){const t=k.Mark.create({name:e.type,addAttributes(){return Bn(e.propSchema)},parseHTML(){return xn(e)},renderHTML({mark:o}){let r;if(e.propSchema==="boolean")r=n.render();else if(e.propSchema==="string")r=n.render(o.attrs.stringValue);else throw new j(e.propSchema);return Tn(r,e.type,o.attrs.stringValue,e.propSchema)}});return Mt(e,{mark:t})}function re(e){const{height:n,width:t}=Lt(e),o=new Array(n).fill(!1).map(()=>new Array(t).fill(null)),r=(s,i)=>{for(let a=s;a<n;a++)for(let l=i;l<t;l++)if(!o[a][l])return{row:a,col:l};throw new Error("Unable to create occupancy grid for table, no more available cells")};for(let s=0;s<e.content.rows.length;s++)for(let i=0;i<e.content.rows[s].cells.length;i++){const a=Ve(e.content.rows[s].cells[i]),l=Ue(a),c=me(a),{row:d,col:u}=r(s,i);for(let h=d;h<d+l;h++)for(let f=u;f<u+c;f++){if(o[h][f])throw new Error(`Unable to create occupancy grid for table, cell at ${h},${f} is already occupied`);o[h][f]={row:s,col:i,rowspan:l,colspan:c,cell:a}}}return o}function Se(e){const n=new Set;return e.map(t=>({cells:t.map(o=>n.has(o.row+":"+o.col)?!1:(n.add(o.row+":"+o.col),o.cell)).filter(o=>o!==!1)}))}function le(e,n,t=re(n)){for(let o=0;o<t.length;o++)for(let r=0;r<t[o].length;r++){const s=t[o][r];if(s.row===e.row&&s.col===e.col)return{row:o,col:r,cell:s.cell}}throw new Error(`Unable to resolve relative table cell indices for table, cell at ${e.row},${e.col} is not occupied`)}function Lt(e){const n=e.content.rows.length;let t=0;return e.content.rows.forEach(o=>{let r=0;o.cells.forEach(s=>{r+=me(s)}),t=Math.max(t,r)}),{height:n,width:t}}function Pn(e,n,t=re(n)){var r;const o=(r=t[e.row])==null?void 0:r[e.col];if(o)return{row:o.row,col:o.col,cell:o.cell}}function ut(e,n){var s;const t=re(e);if(n<0||n>=t.length)return[];let o=0;for(let i=0;i<n;i++){const a=(s=t[o])==null?void 0:s[0];if(!a)return[];o+=a.rowspan}const r=new Array(t[0].length).fill(!1).map((i,a)=>Pn({row:o,col:a},e,t)).filter(i=>i!==void 0);return r.filter((i,a)=>r.findIndex(l=>l.row===i.row&&l.col===i.col)===a)}function pt(e,n){var s;const t=re(e);if(n<0||n>=t[0].length)return[];let o=0;for(let i=0;i<n;i++){const a=(s=t[0])==null?void 0:s[o];if(!a)return[];o+=a.colspan}const r=new Array(t.length).fill(!1).map((i,a)=>Pn({row:a,col:o},e,t)).filter(i=>i!==void 0);return r.filter((i,a)=>r.findIndex(l=>l.row===i.row&&l.col===i.col)===a)}function es(e,n,t,o=re(e)){const{col:r}=le({row:0,col:n},e,o),{col:s}=le({row:0,col:t},e,o);return o.forEach(i=>{const[a]=i.splice(r,1);i.splice(s,0,a)}),Se(o)}function ts(e,n,t,o=re(e)){const{row:r}=le({row:n,col:0},e,o),{row:s}=le({row:t,col:0},e,o),[i]=o.splice(r,1);return o.splice(s,0,i),Se(o)}function ht(e){return e?fe(e)?ht(e.content):typeof e=="string"?e.length===0:Array.isArray(e)?e.every(n=>typeof n=="string"?n.length===0:oe(n)?n.text.length===0:St(n)?typeof n.content=="string"?n.content.length===0:n.content.every(t=>t.text.length===0):!1):!1:!0}function ns(e,n,t=re(e)){if(n==="columns"){let s=0;for(let i=t[0].length-1;i>=0&&t.every(l=>ht(l[i].cell)&&l[i].colspan===1);i--)s++;for(let i=t.length-1;i>=0;i--){const a=Math.max(t[i].length-s,1);t[i]=t[i].slice(0,a)}return Se(t)}let o=0;for(let s=t.length-1;s>=0&&t[s].every(a=>ht(a.cell)&&a.rowspan===1);s--)o++;const r=Math.min(o,t.length-1);return t.splice(t.length-r,r),Se(t)}function os(e,n,t,o=re(e)){const{width:r,height:s}=Lt(e);if(n==="columns")o.forEach((i,a)=>{if(t>=0)for(let l=0;l<t;l++)i.push({row:a,col:Math.max(...i.map(c=>c.col))+1,rowspan:1,colspan:1,cell:Ve("")});else i.splice(r+t,-1*t)});else if(t>0)for(let i=0;i<t;i++){const a=new Array(r).fill(null).map((l,c)=>({row:s+i,col:c,rowspan:1,colspan:1,cell:Ve("")}));o.push(a)}else t<0&&o.splice(s+t,-1*t);return Se(o)}function Mn(e,n,t){const o=ut(e,t);if(!o.some(l=>Ue(l.cell)>1))return!0;let s=t,i=t;return o.forEach(l=>{const c=Ue(l.cell);s=Math.max(s,l.row+c-1),i=Math.min(i,l.row)}),n<t?t===s:t===i}function In(e,n,t){const o=pt(e,t);if(!o.some(l=>me(l.cell)>1))return!0;let s=t,i=t;return o.forEach(l=>{const c=me(l.cell);s=Math.max(s,l.col+c-1),i=Math.min(i,l.col)}),n<t?t===s:t===i}function rs(e,n,t){const o=le(e,t),r=le(n,t);return o.col===r.col}function Gt(e,n,t,o){const r=[];for(const[i,a]of Object.entries(e.styles||{})){const l=t[i];if(!l)throw new Error(`style ${i} not found in styleSchema`);if(l.propSchema==="boolean")a&&r.push(n.mark(i));else if(l.propSchema==="string")a&&r.push(n.mark(i,{stringValue:a}));else throw new j(l.propSchema)}return!o||!n.nodes[o].spec.code?e.text.split(/(\n)/g).filter(i=>i.length>0).map(i=>i===`
6
+ `?n.nodes.hardBreak.createChecked():n.text(i,r)):e.text.length>0?[n.text(e.text,r)]:[]}function ss(e,n,t){const o=n.marks.link.create({href:e.href});return ft(e.content,n,t).map(r=>{if(r.type.name==="text")return r.mark([...r.marks,o]);if(r.type.name==="hardBreak")return r;throw new Error("unexpected node type")})}function ft(e,n,t,o){const r=[];if(typeof e=="string")return r.push(...Gt({text:e,styles:{}},n,t,o)),r;for(const s of e)r.push(...Gt(s,n,t,o));return r}function W(e,n,t,o=ce(n)){const r=[];for(const s of e)typeof s=="string"?r.push(...ft(s,n,o,t)):St(s)?r.push(...ss(s,n,o)):oe(s)?r.push(...ft([s],n,o,t)):r.push(Ln(s,n,o));return r}function Pe(e,n,t=ce(n)){const o=[],r=new Array(e.headerRows??0).fill(!0),s=new Array(e.headerCols??0).fill(!0),i=e.columnWidths??[];for(let a=0;a<e.rows.length;a++){const l=e.rows[a],c=[],d=r[a];for(let h=0;h<l.cells.length;h++){const f=l.cells[h],m=s[h],g=void 0;let b=null;const w=le({row:a,col:h},{content:e});let C=i[w.col]?[i[w.col]]:null;if(f)if(typeof f=="string")b=n.text(f);else if(fe(f)){f.content&&(b=W(f.content,n,"tableParagraph",t));const I=me(f);I>1&&(C=new Array(I).fill(!1).map((_,K)=>i[w.col+K]??void 0))}else b=W(f,n,"tableParagraph",t);const v=n.nodes[m||d?"tableHeader":"tableCell"].createChecked({...fe(f)?f.props:{},colwidth:C},n.nodes.tableParagraph.createChecked(g,b));c.push(v)}const u=n.nodes.tableRow.createChecked({},c);o.push(u)}return o}function Ln(e,n,t){let o,r=e.type;if(r===void 0&&(r="paragraph"),!n.nodes[r])throw new Error(`node type ${r} not found in schema`);if(!e.content)o=n.nodes[r].createChecked(e.props);else if(typeof e.content=="string"){const s=W([e.content],n,r,t);o=n.nodes[r].createChecked(e.props,s)}else if(Array.isArray(e.content)){const s=W(e.content,n,r,t);o=n.nodes[r].createChecked(e.props,s)}else if(e.content.type==="tableContent"){const s=Pe(e.content,n,t);o=n.nodes[r].createChecked(e.props,s)}else throw new j(e.content.type);return o}function se(e,n,t=ce(n)){let o=e.id;o===void 0&&(o=Be.options.generateID());const r=[];if(e.children)for(const i of e.children)r.push(se(i,n,t));if(!e.type||n.nodes[e.type].isInGroup("blockContent")){const i=Ln(e,n,t),a=r.length>0?n.nodes.blockGroup.createChecked({},r):void 0;return n.nodes.blockContainer.createChecked({id:o,...e.props},a?[i,a]:i)}else{if(n.nodes[e.type].isInGroup("bnBlock"))return n.nodes[e.type].createChecked({id:o,...e.props},r);throw new Error(`block type ${e.type} doesn't match blockContent or bnBlock group`)}}function is(e,n){if(n===0)return;const t=e.resolve(n);for(let o=t.depth;o>0;o--){const r=t.node(o);if(Xe(r))return r.attrs.id}}function z(e,n){let t,o;if(n.firstChild.descendants((r,s)=>t?!1:!Xe(r)||r.attrs.id!==e?!0:(t=r,o=s+1,!1)),!(t===void 0||o===void 0))return{node:t,posBeforeNode:o}}function Xe(e){return e.type.isInGroup("bnBlock")}function as(e,n){return e.id!==n.id||e.type!==n.type||JSON.stringify(e.props)!==JSON.stringify(n.props)||JSON.stringify(e.content)!==JSON.stringify(n.content)}function ls(e){return e.getMeta("paste")?{type:"paste"}:e.getMeta("uiEvent")==="drop"?{type:"drop"}:e.getMeta("history$")?{type:e.getMeta("history$").redo?"redo":"undo"}:e.getMeta("y-sync$")?e.getMeta("y-sync$").isUndoRedoOperation?{type:"undo-redo"}:{type:"yjs-remote"}:{type:"local"}}function Yt(e){const n={},t=R(e);return e.descendants((o,r)=>{if(Xe(o)){const s=is(e,r);n[o.attrs.id]={block:B(o,t),parentId:s}}return!0}),n}function At(e,n=[]){const t=ls(e),o=k.combineTransactionSteps(e.before,[e,...n]),r=Yt(o.before),s=Yt(o.doc),i=[];return Object.keys(s).filter(a=>!(a in r)).forEach(a=>{i.push({type:"insert",block:s[a].block,source:t,prevBlock:void 0})}),Object.keys(r).filter(a=>!(a in s)).forEach(a=>{i.push({type:"delete",block:r[a].block,source:t,prevBlock:void 0})}),Object.keys(s).filter(a=>a in r).forEach(a=>{var u,h;const l=r[a],c=s[a];l.parentId!==c.parentId?i.push({type:"move",block:c.block,prevBlock:l.block,source:t,prevParent:l.parentId?(u=r[l.parentId])==null?void 0:u.block:void 0,currentParent:c.parentId?(h=s[c.parentId])==null?void 0:h.block:void 0}):as(l.block,c.block)&&i.push({type:"update",block:c.block,prevBlock:l.block,source:t})}),i}function An(e,n,t,o="before"){const r=typeof t=="string"?t:t.id,s=R(e),i=n.map(d=>se(d,s)),a=z(r,e.doc);if(!a)throw new Error(`Block with ID ${r} not found`);let l=a.posBeforeNode;return o==="after"&&(l+=a.node.nodeSize),e.step(new he.ReplaceStep(l,l,new S.Slice(S.Fragment.from(i),0,0))),i.map(d=>B(d,s))}function mt(e,n,t){const o=R(e),r=t.map(d=>se(d,o)),s=new Set(n.map(d=>typeof d=="string"?d:d.id)),i=[],a=typeof n[0]=="string"?n[0]:n[0].id;let l=0;if(e.doc.descendants((d,u)=>{if(s.size===0)return!1;if(!d.type.isInGroup("bnBlock")||!s.has(d.attrs.id))return!0;if(i.push(B(d,o)),s.delete(d.attrs.id),t.length>0&&d.attrs.id===a){const g=e.doc.nodeSize;e.insert(u,r);const b=e.doc.nodeSize;l+=g-b}const h=e.doc.nodeSize,f=e.doc.resolve(u-l);f.node().type.name==="blockGroup"&&f.node(f.depth-1).type.name!=="doc"&&f.node().childCount===1?e.delete(f.before(),f.after()):e.delete(u-l,u-l+d.nodeSize);const m=e.doc.nodeSize;return l+=h-m,!1}),s.size>0){const d=[...s].join(`
7
+ `);throw Error("Blocks with the following IDs could not be found in the editor: "+d)}return{insertedBlocks:r.map(d=>B(d,o)),removedBlocks:i}}const U=(e,n)=>({tr:t,dispatch:o})=>(o&&Nt(t,e,n),!0);function Nt(e,n,t,o,r){const s=ke(e.doc.resolve(n)),i=R(e);if(o!==void 0&&r!==void 0&&o>r)throw new Error("Invalid replaceFromPos or replaceToPos");const a=i.nodes[s.blockNoteType],l=i.nodes[t.type||s.blockNoteType],c=l.isInGroup("bnBlock")?l:i.nodes.blockContainer;if(s.isBlockContainer&&l.isInGroup("blockContent")){const d=o!==void 0&&o>s.blockContent.beforePos&&o<s.blockContent.afterPos?o-s.blockContent.beforePos-1:void 0,u=r!==void 0&&r>s.blockContent.beforePos&&r<s.blockContent.afterPos?r-s.blockContent.beforePos-1:void 0;Jt(t,e,s),cs(t,e,a,l,s,d,u)}else if(!s.isBlockContainer&&l.isInGroup("bnBlock"))Jt(t,e,s);else{const d=B(s.bnBlock.node,i);e.replaceWith(s.bnBlock.beforePos,s.bnBlock.afterPos,se({children:d.children,...t},i));return}e.setNodeMarkup(s.bnBlock.beforePos,c,{...s.bnBlock.node.attrs,...t.props})}function cs(e,n,t,o,r,s,i){const a=R(n);let l="keep";if(e.content)if(typeof e.content=="string")l=W([e.content],a,o.name);else if(Array.isArray(e.content))l=W(e.content,a,o.name);else if(e.content.type==="tableContent")l=Pe(e.content,a);else throw new j(e.content.type);else t.spec.content===""||o.spec.content!==t.spec.content&&(l=[]);if(l==="keep")n.setNodeMarkup(r.blockContent.beforePos,o,{...r.blockContent.node.attrs,...e.props});else if(s!==void 0||i!==void 0){n.setNodeMarkup(r.blockContent.beforePos,o,{...r.blockContent.node.attrs,...e.props});const c=r.blockContent.beforePos+1+(s??0),d=r.blockContent.beforePos+1+(i??r.blockContent.node.content.size),u=n.doc.resolve(r.blockContent.beforePos).depth,h=n.doc.resolve(c).depth,f=n.doc.resolve(d).depth;n.replace(c,d,new S.Slice(S.Fragment.from(l),h-u-1,f-u-1))}else n.replaceWith(r.blockContent.beforePos,r.blockContent.afterPos,o.createChecked({...r.blockContent.node.attrs,...e.props},l))}function Jt(e,n,t){const o=R(n);if(e.children!==void 0&&e.children.length>0){const r=e.children.map(s=>se(s,o));if(t.childContainer)n.step(new he.ReplaceStep(t.childContainer.beforePos+1,t.childContainer.afterPos-1,new S.Slice(S.Fragment.from(r),0,0)));else{if(!t.isBlockContainer)throw new Error("impossible");n.insert(t.blockContent.afterPos,o.nodes.blockGroup.createChecked({},r))}}}function Nn(e,n,t,o,r){const s=typeof n=="string"?n:n.id,i=z(s,e.doc);if(!i)throw new Error(`Block with ID ${s} not found`);Nt(e,i.posBeforeNode,t,o,r);const a=e.doc.resolve(i.posBeforeNode+1).node(),l=R(e);return B(a,l)}function Dn(e){const n=Array.from(e.classList).filter(t=>!t.startsWith("bn-"))||[];n.length>0?e.className=n.join(" "):e.removeAttribute("class")}function Hn(e,n,t,o){let r;if(n)if(typeof n=="string")r=W([n],e.pmSchema);else if(Array.isArray(n))r=W(n,e.pmSchema);else if(n.type==="tableContent")r=Pe(n,e.pmSchema);else throw new j(n.type);else throw new Error("blockContent is required");const s=t.serializeFragment(S.Fragment.from(r),o);return s.nodeType===1&&Dn(s),s}function ds(e,n,t,o,r,s,i){var g,b,w,C,v,I,_,K;const a=(i==null?void 0:i.document)??document,l=n.pmSchema.nodes.blockContainer;let c=t.props;if(!t.props){c={};for(const[x,T]of Object.entries(n.schema.blockSchema[t.type].propSchema))T.default!==void 0&&(c[x]=T.default)}const d=(b=(g=l.spec)==null?void 0:g.toDOM)==null?void 0:b.call(g,l.create({id:t.id,...c})),u=Array.from(d.dom.attributes),h=n.blockImplementations[t.type].implementation.toExternalHTML({...t,props:c},n),f=a.createDocumentFragment();if(h.dom.classList.contains("bn-block-content")){const x=[...u,...Array.from(h.dom.attributes)].filter(T=>T.name.startsWith("data")&&T.name!=="data-content-type"&&T.name!=="data-file-block"&&T.name!=="data-node-view-wrapper"&&T.name!=="data-node-type"&&T.name!=="data-id"&&T.name!=="data-index"&&T.name!=="data-editable");for(const T of x)h.dom.firstChild.setAttribute(T.name,T.value);Dn(h.dom.firstChild),f.append(...Array.from(h.dom.childNodes))}else f.append(h.dom);if(h.contentDOM&&t.content){const x=Hn(n,t.content,o,i);h.contentDOM.appendChild(x)}let m;if(r.has(t.type)?m="OL":s.has(t.type)&&(m="UL"),m){if(((w=e.lastChild)==null?void 0:w.nodeName)!==m){const T=a.createElement(m);m==="OL"&&(c!=null&&c.start)&&(c==null?void 0:c.start)!==1&&T.setAttribute("start",c.start+""),e.append(T)}const x=a.createElement("li");x.append(f),e.lastChild.appendChild(x)}else e.append(f);if(t.children&&t.children.length>0){const x=a.createDocumentFragment();if(On(x,n,t.children,o,r,s,i),((C=e.lastChild)==null?void 0:C.nodeName)==="UL"||((v=e.lastChild)==null?void 0:v.nodeName)==="OL")for(;((I=x.firstChild)==null?void 0:I.nodeName)==="UL"||((_=x.firstChild)==null?void 0:_.nodeName)==="OL";)e.lastChild.lastChild.appendChild(x.firstChild);n.pmSchema.nodes[t.type].isInGroup("blockContent")?e.append(x):(K=h.contentDOM)==null||K.append(x)}}const On=(e,n,t,o,r,s,i)=>{for(const a of t)ds(e,n,a,o,r,s,i)},us=(e,n,t,o,r,s)=>{const a=((s==null?void 0:s.document)??document).createDocumentFragment();return On(a,e,n,t,o,r,s),a},Me=(e,n)=>{const t=S.DOMSerializer.fromSchema(e);return{exportBlocks:(o,r)=>{const s=us(n,o,t,new Set(["numberedListItem"]),new Set(["bulletListItem","checkListItem"]),r),i=document.createElement("div");return i.append(s),i.innerHTML},exportInlineContent:(o,r)=>{const s=Hn(n,o,t,r),i=document.createElement("div");return i.append(s.cloneNode(!0)),i.innerHTML}}};function ps(e,n,t,o,r){let s;if(n)if(typeof n=="string")s=W([n],e.pmSchema,o);else if(Array.isArray(n))s=W(n,e.pmSchema,o);else if(n.type==="tableContent")s=Pe(n,e.pmSchema);else throw new j(n.type);else throw new Error("blockContent is required");return t.serializeFragment(S.Fragment.from(s),r)}function hs(e,n,t,o,r){var u,h,f,m,g;const s=e.pmSchema.nodes.blockContainer;let i=n.props;if(!n.props){i={};for(const[b,w]of Object.entries(e.schema.blockSchema[n.type].propSchema))w.default!==void 0&&(i[b]=w.default)}const l=e.blockImplementations[n.type].implementation.toInternalHTML({...n,props:i},e);if(n.type==="numberedListItem"&&l.dom.setAttribute("data-index",o.toString()),l.contentDOM&&n.content){const b=ps(e,n.content,t,n.type,r);l.contentDOM.appendChild(b)}if(e.pmSchema.nodes[n.type].isInGroup("bnBlock")){if(n.children&&n.children.length>0){const b=Rn(e,n.children,t,r);(u=l.contentDOM)==null||u.append(b)}return l.dom}const d=(f=(h=s.spec)==null?void 0:h.toDOM)==null?void 0:f.call(h,s.create({id:n.id,...i}));return(m=d.contentDOM)==null||m.appendChild(l.dom),n.children&&n.children.length>0&&((g=d.contentDOM)==null||g.appendChild(_n(e,n.children,t,r))),d.dom}function Rn(e,n,t,o){const s=((o==null?void 0:o.document)??document).createDocumentFragment();let i=0;for(const a of n){a.type==="numberedListItem"?i++:i=0;const l=hs(e,a,t,i,o);s.appendChild(l)}return s}const _n=(e,n,t,o)=>{var a;const r=e.pmSchema.nodes.blockGroup,s=r.spec.toDOM(r.create({})),i=Rn(e,n,t,o);return(a=s.contentDOM)==null||a.appendChild(i),s.dom},Vn=(e,n)=>{const t=S.DOMSerializer.fromSchema(e);return{serializeBlocks:(o,r)=>_n(n,o,t,r).outerHTML}},Ie=(e,n)=>{const t=e.querySelector(n);if(!t)return;const o=e.querySelector("figcaption"),r=(o==null?void 0:o.textContent)??void 0;return{targetElement:t,caption:r}},Un=(e,n,t,o)=>{const r=document.createElement("div");r.className="bn-add-file-button";const s=document.createElement("div");s.className="bn-add-file-button-icon",o?s.appendChild(o):s.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>',r.appendChild(s);const i=document.createElement("p");i.className="bn-add-file-button-text",i.innerHTML=t||n.dictionary.file_blocks.file.add_button_text,r.appendChild(i);const a=c=>{c.preventDefault()},l=()=>{n.transact(c=>c.setMeta(n.filePanel.plugins[0],{block:e}))};return r.addEventListener("mousedown",a,!0),r.addEventListener("click",l,!0),{dom:r,destroy:()=>{r.removeEventListener("mousedown",a,!0),r.removeEventListener("click",l,!0)}}},Fn='<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>',$n=e=>{const n=document.createElement("div");n.className="bn-file-name-with-icon";const t=document.createElement("div");t.className="bn-file-icon",t.innerHTML=Fn,n.appendChild(t);const o=document.createElement("p");return o.className="bn-file-name",o.textContent=e.props.name,n.appendChild(o),{dom:n}},Ze=(e,n,t,o,r)=>{const s=document.createElement("div");if(s.className="bn-file-block-content-wrapper",e.props.url===""){const a=Un(e,n,o,r);s.appendChild(a.dom);const l=n.onUploadStart(c=>{if(c===e.id){s.removeChild(a.dom);const d=document.createElement("div");d.className="bn-file-loading-preview",d.textContent="Loading...",s.appendChild(d)}});return{dom:s,destroy:()=>{l(),a.destroy()}}}const i={dom:s};if(e.props.showPreview===!1||!t){const a=$n(e);s.appendChild(a.dom),i.destroy=()=>{var l;(l=a.destroy)==null||l.call(a)}}else s.appendChild(t.dom);if(e.props.caption){const a=document.createElement("p");a.className="bn-file-caption",a.textContent=e.props.caption,s.appendChild(a)}return i},Qe=(e,n)=>{const t=document.createElement("figure"),o=document.createElement("figcaption");return o.textContent=n,t.appendChild(e),t.appendChild(o),{dom:t}},Le=(e,n)=>{const t=document.createElement("div"),o=document.createElement("p");return o.textContent=n,t.appendChild(e),t.appendChild(o),{dom:t}},Xt=e=>({url:e.src||void 0}),zn='<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>',Wn={backgroundColor:M.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0}},Kn={type:"audio",propSchema:Wn,content:"none",isFileBlock:!0,fileBlockAccept:["audio/*"]},qn=(e,n)=>{const t=document.createElement("div");t.innerHTML=zn;const o=document.createElement("audio");return o.className="bn-audio",n.resolveFileUrl?n.resolveFileUrl(e.props.url).then(r=>{o.src=r}):o.src=e.props.url,o.controls=!0,o.contentEditable="false",o.draggable=!1,Ze(e,n,{dom:o},n.dictionary.file_blocks.audio.add_button_text,t.firstElementChild)},jn=e=>{if(e.tagName==="AUDIO")return e.closest("figure")?void 0:Xt(e);if(e.tagName==="FIGURE"){const n=Ie(e,"audio");if(!n)return;const{targetElement:t,caption:o}=n;return{...Xt(t),caption:o}}},Gn=e=>{if(!e.props.url){const t=document.createElement("p");return t.textContent="Add audio",{dom:t}}let n;return e.props.showPreview?(n=document.createElement("audio"),n.src=e.props.url):(n=document.createElement("a"),n.href=e.props.url,n.textContent=e.props.name||e.props.url),e.props.caption?e.props.showPreview?Qe(n,e.props.caption):Le(n,e.props.caption):{dom:n}},Yn=be(Kn,{render:qn,parse:jn,toExternalHTML:Gn}),gt=Symbol.for("blocknote.shikiParser"),Re=Symbol.for("blocknote.shikiHighlighterPromise"),Jn={language:{default:"text"}},fs=G({name:"codeBlock",content:"inline*",group:"blockContent",marks:"insertion deletion modification",code:!0,defining:!0,addOptions(){return{defaultLanguage:"text",indentLineWithTab:!0,supportedLanguages:{}}},addAttributes(){const e=this.options;return{language:{default:e.editor.settings.codeBlock.defaultLanguage,parseHTML:n=>{let t=n,o=null;(t==null?void 0:t.tagName)==="DIV"&&(t==null?void 0:t.dataset.contentType)==="codeBlock"&&(t=t.children[0]),(t==null?void 0:t.tagName)==="PRE"&&(t=t==null?void 0:t.children[0]);const r=t==null?void 0:t.getAttribute("data-language");if(r)o=r.toLowerCase();else{const i=[...(t==null?void 0:t.className.split(" "))||[]].filter(a=>a.startsWith("language-")).map(a=>a.replace("language-",""));i.length>0&&(o=i[0].toLowerCase())}return o?st(e.editor.settings.codeBlock,o)??o:null},renderHTML:n=>n.language?{class:`language-${n.language}`,"data-language":n.language}:{}}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"pre",preserveWhitespace:"full"}]},renderHTML({HTMLAttributes:e}){var r,s;const n=document.createElement("pre"),{dom:t,contentDOM:o}=$(this.name,"code",((r=this.options.domAttributes)==null?void 0:r.blockContent)||{},{...((s=this.options.domAttributes)==null?void 0:s.inlineContent)||{},...e});return t.removeChild(o),t.appendChild(n),n.appendChild(o),{dom:t,contentDOM:o}},addNodeView(){const e=this.options;return({editor:n,node:t,getPos:o,HTMLAttributes:r})=>{var u,h;const s=document.createElement("pre"),i=document.createElement("select"),a=document.createElement("div"),{dom:l,contentDOM:c}=$(this.name,"code",{...((u=this.options.domAttributes)==null?void 0:u.blockContent)||{},...r},((h=this.options.domAttributes)==null?void 0:h.inlineContent)||{}),d=f=>{const m=f.target.value;n.commands.command(({tr:g})=>(g.setNodeAttribute(o(),"language",m),!0))};return Object.entries(e.editor.settings.codeBlock.supportedLanguages).forEach(([f,{name:m}])=>{const g=document.createElement("option");g.value=f,g.text=m,i.appendChild(g)}),a.contentEditable="false",i.value=t.attrs.language||e.editor.settings.codeBlock.defaultLanguage,l.removeChild(c),l.appendChild(a),l.appendChild(s),s.appendChild(c),a.appendChild(i),i.addEventListener("change",d),{dom:l,contentDOM:c,update:f=>f.type===this.type,destroy:()=>{i.removeEventListener("change",d)}}}},addProseMirrorPlugins(){const e=this.options,n=globalThis;let t,o,r=!1;const s=a=>{if(!e.editor.settings.codeBlock.createHighlighter)return process.env.NODE_ENV==="development"&&!r&&(console.log("For syntax highlighting of code blocks, you must provide a `codeBlock.createHighlighter` function"),r=!0),[];if(!t)return n[Re]=n[Re]||e.editor.settings.codeBlock.createHighlighter(),n[Re].then(c=>{t=c});const l=st(e.editor.settings.codeBlock,a.language);return!l||l==="text"||l==="none"||l==="plaintext"||l==="txt"?[]:t.getLoadedLanguages().includes(l)?(o||(o=n[gt]||Br.createParser(t),n[gt]=o),o(a)):t.loadLanguage(l)};return[Er.createHighlightPlugin({parser:s,languageExtractor:a=>a.attrs.language,nodeTypes:[this.name]})]},addInputRules(){const e=this.options;return[new k.InputRule({find:/^```(.*?)\s$/,handler:({state:n,range:t,match:o})=>{const r=n.doc.resolve(t.from),s=o[1].trim(),i={language:st(e.editor.settings.codeBlock,s)??s};if(!r.node(-1).canReplaceWith(r.index(-1),r.indexAfter(-1),this.type))return null;n.tr.delete(t.from,t.to).setBlockType(t.from,t.from,this.type,i).setSelection(y.TextSelection.create(n.tr.doc,t.from))}})]},addKeyboardShortcuts(){return{Delete:({editor:e})=>{const{selection:n}=e.state,{$from:t}=n;if(e.isActive(this.name)&&!t.parent.textContent&&k.isTextSelection(n)){const o=t.pos-t.parentOffset-2;return e.chain().setNodeSelection(o).deleteSelection().run(),!0}return!1},Tab:({editor:e})=>this.options.indentLineWithTab&&e.isActive(this.name)?(e.commands.insertContent(" "),!0):!1,Enter:({editor:e})=>{const{$from:n}=e.state.selection;if(!e.isActive(this.name))return!1;const t=n.parentOffset===n.parent.nodeSize-2,o=n.parent.textContent.endsWith(`
8
8
 
9
9
  `);return!t||!o?(e.commands.insertContent(`
10
- `),!0):e.chain().command(({tr:r})=>(r.delete(n.pos-2,n.pos),!0)).exitCode().run()},"Shift-Enter":({editor:e})=>{const{$from:n}=e.state.selection;return e.isActive(this.name)?(e.chain().insertContentAt(n.pos-n.parentOffset+n.parent.nodeSize,{type:"paragraph"}).run(),!0):!1}}}}),Jn=Z(us,Yn);function it(e,n){var t;return(t=Object.entries(e.supportedLanguages).find(([o,{aliases:r}])=>(r==null?void 0:r.includes(n))||o===n))==null?void 0:t[0]}const ps=k.Mark.create({name:"backgroundColor",addAttributes(){return{stringValue:{default:void 0,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.stringValue})}}},parseHTML(){return[{tag:"span",getAttrs:e=>typeof e=="string"?!1:e.hasAttribute("data-background-color")?{stringValue:e.getAttribute("data-background-color")}:!1}]},renderHTML({HTMLAttributes:e}){return["span",e,0]}}),hs=ne(ps,"string"),fs=k.Mark.create({name:"textColor",addAttributes(){return{stringValue:{default:void 0,parseHTML:e=>e.getAttribute("data-text-color"),renderHTML:e=>({"data-text-color":e.stringValue})}}},parseHTML(){return[{tag:"span",getAttrs:e=>typeof e=="string"?!1:e.hasAttribute("data-text-color")?{stringValue:e.getAttribute("data-text-color")}:!1}]},renderHTML({HTMLAttributes:e}){return["span",e,0]}}),ms=ne(fs,"string"),kt=e=>({url:e.src||void 0}),Xn={backgroundColor:M.backgroundColor,name:{default:""},url:{default:""},caption:{default:""}},Zn={type:"file",propSchema:Xn,content:"none",isFileBlock:!0},Qn=(e,n)=>Qe(e,n),eo=e=>{if(e.tagName==="EMBED")return e.closest("figure")?void 0:kt(e);if(e.tagName==="FIGURE"){const n=Le(e,"embed");if(!n)return;const{targetElement:t,caption:o}=n;return{...kt(t),caption:o}}},to=e=>{if(!e.props.url){const t=document.createElement("p");return t.textContent="Add file",{dom:t}}const n=document.createElement("a");return n.href=e.props.url,n.textContent=e.props.name||e.props.url,e.props.caption?Ae(n,e.props.caption):{dom:n}},no=be(Zn,{render:Qn,parse:eo,toExternalHTML:to}),oo={set:(e,n)=>window.localStorage.setItem(`toggle-${e.id}`,n?"true":"false"),get:e=>window.localStorage.getItem(`toggle-${e.id}`)==="true"},Dt=(e,n,t,o=oo)=>{if("isToggleable"in e.props&&!e.props.isToggleable)return{dom:t};const r=document.createElement("div"),s=document.createElement("div");s.className="bn-toggle-wrapper";const i=document.createElement("button");i.className="bn-toggle-button",i.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="CURRENTCOLOR"><path d="M320-200v-560l440 280-440 280Z"/></svg>';const a=m=>m.preventDefault();i.addEventListener("mousedown",a);const l=()=>{var m;s.getAttribute("data-show-children")==="true"?(s.setAttribute("data-show-children","false"),o.set(n.getBlock(e),!1),r.contains(c)&&r.removeChild(c)):(s.setAttribute("data-show-children","true"),o.set(n.getBlock(e),!0),((m=n.getBlock(e))==null?void 0:m.children.length)===0&&!r.contains(c)&&r.appendChild(c))};i.addEventListener("click",l),s.appendChild(i),s.appendChild(t);const c=document.createElement("button");c.className="bn-toggle-add-block-button",c.textContent="Empty toggle. Click to add a block.";const d=m=>m.preventDefault();c.addEventListener("mousedown",d);const u=()=>{n.transact(()=>{const m=n.updateBlock(e,{children:[{}]});n.setTextCursorPosition(m.children[0].id,"end"),n.focus()})};c.addEventListener("click",u),r.appendChild(s);let h=e.children.length;const f=n.onChange(()=>{var g;const m=((g=n.getBlock(e))==null?void 0:g.children.length)??0;m>h?(s.getAttribute("data-show-children")==="false"&&(s.setAttribute("data-show-children","true"),o.set(n.getBlock(e),!0)),r.contains(c)&&r.removeChild(c)):m===0&&m<h&&(s.getAttribute("data-show-children")==="true"&&(s.setAttribute("data-show-children","false"),o.set(n.getBlock(e),!1)),r.contains(c)&&r.removeChild(c)),h=m});return o.get(e)?(s.setAttribute("data-show-children","true"),e.children.length===0&&r.appendChild(c)):s.setAttribute("data-show-children","false"),{dom:r,ignoreMutation:m=>m instanceof MutationRecord&&(m.type==="attributes"&&m.target===s&&m.attributeName==="data-show-children"||m.type==="childList"&&(m.addedNodes[0]===c||m.removedNodes[0]===c)),destroy:()=>{i.removeEventListener("mousedown",a),i.removeEventListener("click",l),c.removeEventListener("mousedown",d),c.removeEventListener("click",u),f==null||f()}}},gs=[1,2,3,4,5,6],ro={...M,level:{default:1,values:gs},isToggleable:{default:!1}},bs=G({name:"heading",content:"inline*",group:"blockContent",addAttributes(){return ge(ro)},addInputRules(){return[...this.options.editor.settings.heading.levels.map(n=>new k.InputRule({find:new RegExp(`^(#{${n}})\\s$`),handler:({state:t,chain:o,range:r})=>{const s=E(t);!s.isBlockContainer||s.blockContent.node.type.spec.content!=="inline*"||o().command(U(s.bnBlock.beforePos,{type:"heading",props:{level:n}})).deleteRange({from:r.from,to:r.to}).run()}}))]},addKeyboardShortcuts(){const e=this.options.editor;return Object.fromEntries(e.settings.heading.levels.map(n=>[`Mod-Alt-${n}`,()=>{const t=E(this.editor.state);return!t.isBlockContainer||t.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(U(t.bnBlock.beforePos,{type:"heading",props:{level:n}}))}]))},parseHTML(){const e=this.options.editor;return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},...e.settings.heading.levels.map(n=>({tag:`h${n}`,attrs:{level:n},node:"heading"}))]},renderHTML({node:e,HTMLAttributes:n}){var t,o;return $(this.name,`h${e.attrs.level}`,{...((t=this.options.domAttributes)==null?void 0:t.blockContent)||{},...n},((o=this.options.domAttributes)==null?void 0:o.inlineContent)||{})},addNodeView(){return({node:e,HTMLAttributes:n,getPos:t})=>{var l,c;const{dom:o,contentDOM:r}=$(this.name,`h${e.attrs.level}`,{...((l=this.options.domAttributes)==null?void 0:l.blockContent)||{},...n},((c=this.options.domAttributes)==null?void 0:c.inlineContent)||{});o.removeChild(r);const s=this.options.editor,i=Ge(t,s,this.editor,this.name),a=Dt(i,s,r);return o.appendChild(a.dom),{dom:o,contentDOM:r,ignoreMutation:a.ignoreMutation,destroy:a.destroy}}}}),ks=Z(bs,ro),Ht=(e,n,t,o,r,s)=>{const{dom:i,destroy:a}=Qe(e,n,t,r,s),l=i;e.props.url&&e.props.showPreview&&(e.props.previewWidth?l.style.width=`${e.props.previewWidth}px`:l.style.width="fit-content");const c=document.createElement("div");c.className="bn-resize-handle",c.style.left="4px";const d=document.createElement("div");d.className="bn-resize-handle",d.style.right="4px";let u,h=e.props.previewWidth;const f=v=>{var K,x;if(!u){!n.isEditable&&o.contains(c)&&o.contains(d)&&(o.removeChild(c),o.removeChild(d));return}let I;e.props.textAlignment==="center"?u.handleUsed==="left"?I=u.initialWidth+(u.initialClientX-v.clientX)*2:I=u.initialWidth+(v.clientX-u.initialClientX)*2:u.handleUsed==="left"?I=u.initialWidth+u.initialClientX-v.clientX:I=u.initialWidth+v.clientX-u.initialClientX,h=Math.min(Math.max(I,64),((x=(K=n.domElement)==null?void 0:K.firstElementChild)==null?void 0:x.clientWidth)||Number.MAX_VALUE),l.style.width=`${h}px`},m=v=>{(!v.target||!l.contains(v.target)||!n.isEditable)&&o.contains(c)&&o.contains(d)&&(o.removeChild(c),o.removeChild(d)),u&&(u=void 0,n.updateBlock(e,{props:{previewWidth:h}}))},g=()=>{n.isEditable&&(o.appendChild(c),o.appendChild(d))},b=v=>{v.relatedTarget===c||v.relatedTarget===d||u||n.isEditable&&o.contains(c)&&o.contains(d)&&(o.removeChild(c),o.removeChild(d))},w=v=>{v.preventDefault(),u={handleUsed:"left",initialWidth:l.clientWidth,initialClientX:v.clientX}},C=v=>{v.preventDefault(),u={handleUsed:"right",initialWidth:l.clientWidth,initialClientX:v.clientX}};return window.addEventListener("mousemove",f),window.addEventListener("mouseup",m),l.addEventListener("mouseenter",g),l.addEventListener("mouseleave",b),c.addEventListener("mousedown",w),d.addEventListener("mousedown",C),{dom:l,destroy:()=>{a==null||a(),window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",m),l.removeEventListener("mouseenter",g),l.removeEventListener("mouseleave",b),c.removeEventListener("mousedown",w),d.removeEventListener("mousedown",C)}}},Xt=e=>{const n=e.src||void 0,t=e.width||void 0;return{url:n,previewWidth:t}},so='<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>',io={textAlignment:M.textAlignment,backgroundColor:M.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0},previewWidth:{default:void 0,type:"number"}},ao={type:"image",propSchema:io,content:"none",isFileBlock:!0,fileBlockAccept:["image/*"]},lo=(e,n)=>{const t=document.createElement("div");t.innerHTML=so;const o=document.createElement("div");o.className="bn-visual-media-wrapper";const r=document.createElement("img");return r.className="bn-visual-media",n.resolveFileUrl?n.resolveFileUrl(e.props.url).then(s=>{r.src=s}):r.src=e.props.url,r.alt=e.props.name||e.props.caption||"BlockNote image",r.contentEditable="false",r.draggable=!1,o.appendChild(r),Ht(e,n,{dom:o},o,n.dictionary.file_blocks.image.add_button_text,t.firstElementChild)},co=e=>{if(e.tagName==="IMG")return e.closest("figure")?void 0:Xt(e);if(e.tagName==="FIGURE"){const n=Le(e,"img");if(!n)return;const{targetElement:t,caption:o}=n;return{...Xt(t),caption:o}}},uo=e=>{if(!e.props.url){const t=document.createElement("p");return t.textContent="Add image",{dom:t}}let n;return e.props.showPreview?(n=document.createElement("img"),n.src=e.props.url,n.alt=e.props.name||e.props.caption||"BlockNote image",e.props.previewWidth&&(n.width=e.props.previewWidth)):(n=document.createElement("a"),n.href=e.props.url,n.textContent=e.props.name||e.props.url),e.props.caption?e.props.showPreview?et(n,e.props.caption):Ae(n,e.props.caption):{dom:n}},po=be(ao,{render:lo,parse:co,toExternalHTML:uo}),ho=(e,n,t)=>({state:o,dispatch:r})=>{const s=X(o.doc,e),i=ee(s);if(!i.isBlockContainer)throw new Error(`BlockContainer expected when calling splitBlock, position ${e}`);const a=[{type:i.bnBlock.node.type,attrs:t?{...i.bnBlock.node.attrs,id:void 0}:{}},{type:n?i.blockContent.node.type:o.schema.nodes.paragraph,attrs:t?{...i.blockContent.node.attrs}:{}}];return r&&o.tr.split(e,2,a),!0},tt=e=>{const{blockInfo:n,selectionEmpty:t}=e.transact(s=>({blockInfo:xe(s),selectionEmpty:s.selection.anchor===s.selection.head}));if(!n.isBlockContainer)return!1;const{bnBlock:o,blockContent:r}=n;return!(r.node.type.name==="toggleListItem"||r.node.type.name==="bulletListItem"||r.node.type.name==="numberedListItem"||r.node.type.name==="checkListItem")||!t?!1:e._tiptapEditor.commands.first(({state:s,chain:i,commands:a})=>[()=>a.command(()=>r.node.childCount===0?a.command(U(o.beforePos,{type:"paragraph",props:{}})):!1),()=>a.command(()=>r.node.childCount>0?(i().deleteSelection().command(ho(s.selection.from,!0)).run(),!0):!1)])},ws={...M},ys=G({name:"toggleListItem",content:"inline*",group:"blockContent",priority:90,addKeyboardShortcuts(){return{Enter:()=>tt(this.options.editor),"Mod-Shift-6":()=>{const e=E(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(U(e.bnBlock.beforePos,{type:"toggleListItem",props:{}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"}]},renderHTML({HTMLAttributes:e}){var n,t;return $(this.name,"p",{...((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},...e},((t=this.options.domAttributes)==null?void 0:t.inlineContent)||{})},addNodeView(){return({HTMLAttributes:e,getPos:n})=>{var a,l;const{dom:t,contentDOM:o}=$(this.name,"p",{...((a=this.options.domAttributes)==null?void 0:a.blockContent)||{},...e},((l=this.options.domAttributes)==null?void 0:l.inlineContent)||{}),r=this.options.editor,s=Ge(n,r,this.editor,this.name),i=Dt(s,r,o);return t.appendChild(i.dom),{dom:t,contentDOM:o,ignoreMutation:i.ignoreMutation,destroy:i.destroy}}}}),Cs=Z(ys,ws);function Ot(e,n,t){var u,h,f;const o=S.DOMParser.fromSchema(n),r=e,s=document.createElement("div");s.setAttribute("data-node-type","blockGroup");for(const m of Array.from(r.childNodes))s.appendChild(m.cloneNode(!0));let i=o.parse(s,{topNode:n.nodes.blockGroup.create()});((h=(u=i.firstChild)==null?void 0:u.firstChild)==null?void 0:h.type.name)==="checkListItem"&&(i=i.copy(i.content.cut(i.firstChild.firstChild.nodeSize+2)));const a=(f=i.firstChild)==null?void 0:f.firstChild;if(!(a!=null&&a.isTextblock))return S.Fragment.from(i);const l=n.nodes[t].create({},a.content),c=i.content.cut(a.nodeSize+2);if(c.size>0){const m=i.copy(c);return l.content.addToEnd(m)}return l.content}const vs={...M},Ss=G({name:"bulletListItem",content:"inline*",group:"blockContent",priority:90,addInputRules(){return[new k.InputRule({find:new RegExp("^[-+*]\\s$"),handler:({state:e,chain:n,range:t})=>{const o=E(e);!o.isBlockContainer||o.blockContent.node.type.spec.content!=="inline*"||n().command(U(o.bnBlock.beforePos,{type:"bulletListItem",props:{}})).deleteRange({from:t.from,to:t.to})}})]},addKeyboardShortcuts(){return{Enter:()=>tt(this.options.editor),"Mod-Shift-8":()=>{const e=E(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(U(e.bnBlock.beforePos,{type:"bulletListItem",props:{}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"li",getAttrs:e=>{var t;if(typeof e=="string")return!1;const n=e.parentElement;return n===null?!1:n.tagName==="UL"||n.tagName==="DIV"&&((t=n.parentElement)==null?void 0:t.tagName)==="UL"?{}:!1},getContent:(e,n)=>Ot(e,n,this.name),node:"bulletListItem"}]},renderHTML({HTMLAttributes:e}){var n,t;return $(this.name,"p",{...((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},...e},((t=this.options.domAttributes)==null?void 0:t.inlineContent)||{})}}),Es=Z(Ss,vs),fo={...M,checked:{default:!1}},Bs=G({name:"checkListItem",content:"inline*",group:"blockContent",addAttributes(){return ge(fo)},addInputRules(){return[new k.InputRule({find:new RegExp("\\[\\s*\\]\\s$"),handler:({state:e,chain:n,range:t})=>{const o=E(e);!o.isBlockContainer||o.blockContent.node.type.spec.content!=="inline*"||n().command(U(o.bnBlock.beforePos,{type:"checkListItem",props:{checked:!1}})).deleteRange({from:t.from,to:t.to})}}),new k.InputRule({find:new RegExp("\\[[Xx]\\]\\s$"),handler:({state:e,chain:n,range:t})=>{const o=E(e);!o.isBlockContainer||o.blockContent.node.type.spec.content!=="inline*"||n().command(U(o.bnBlock.beforePos,{type:"checkListItem",props:{checked:!0}})).deleteRange({from:t.from,to:t.to})}})]},addKeyboardShortcuts(){return{Enter:()=>tt(this.options.editor),"Mod-Shift-9":()=>{const e=E(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(U(e.bnBlock.beforePos,{type:"checkListItem",props:{}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"input",getAttrs:e=>typeof e=="string"||e.closest("[data-content-type]")||e.closest("li")?!1:e.type==="checkbox"?{checked:e.checked}:!1,node:"checkListItem"},{tag:"li",getAttrs:e=>{var t;if(typeof e=="string")return!1;const n=e.parentElement;if(n===null)return!1;if(n.tagName==="UL"||n.tagName==="DIV"&&((t=n.parentElement)==null?void 0:t.tagName)==="UL"){const o=e.querySelector("input[type=checkbox]")||null;return o===null?!1:{checked:o.checked}}return!1},getContent:(e,n)=>Ot(e,n,this.name),node:"checkListItem"}]},renderHTML({node:e,HTMLAttributes:n}){var s,i;const t=document.createElement("input");t.type="checkbox",t.checked=e.attrs.checked,e.attrs.checked&&t.setAttribute("checked","");const{dom:o,contentDOM:r}=$(this.name,"p",{...((s=this.options.domAttributes)==null?void 0:s.blockContent)||{},...n},((i=this.options.domAttributes)==null?void 0:i.inlineContent)||{});return o.insertBefore(t,r),{dom:o,contentDOM:r}},addNodeView(){return({node:e,getPos:n,editor:t,HTMLAttributes:o})=>{var d,u;const r=document.createElement("div"),s=document.createElement("div");s.contentEditable="false";const i=document.createElement("input");i.type="checkbox",i.checked=e.attrs.checked,e.attrs.checked&&i.setAttribute("checked","");const a=()=>{if(!t.isEditable){i.checked=!i.checked;return}if(typeof n!="boolean"){const h=X(t.state.doc,n());if(h.node.type.name!=="blockContainer")throw new Error(`Expected blockContainer node, got ${h.node.type.name}`);this.editor.commands.command(U(h.posBeforeNode,{type:"checkListItem",props:{checked:i.checked}}))}};i.addEventListener("change",a);const{dom:l,contentDOM:c}=$(this.name,"p",{...((d=this.options.domAttributes)==null?void 0:d.blockContent)||{},...o},((u=this.options.domAttributes)==null?void 0:u.inlineContent)||{});if(typeof n!="boolean"){const f="label-"+this.editor.state.doc.resolve(n()).node().attrs.id;i.setAttribute("aria-labelledby",f),c.id=f}return l.removeChild(c),l.appendChild(r),r.appendChild(s),r.appendChild(c),s.appendChild(i),{dom:l,contentDOM:c,destroy:()=>{i.removeEventListener("change",a)}}}}}),Ts=Z(Bs,fo),xs=new y.PluginKey("numbered-list-indexing"),Ps=()=>new y.Plugin({key:xs,appendTransaction:(e,n,t)=>{const o=t.tr;o.setMeta("numberedListIndexing",!0);let r=!1;return t.doc.descendants((s,i)=>{var a;if(s.type.name==="blockContainer"&&s.firstChild.type.name==="numberedListItem"){let l=`${s.firstChild.attrs.start||1}`;const c=ee({posBeforeNode:i,node:s});if(!c.isBlockContainer)throw new Error("impossible");const d=o.doc.resolve(c.bnBlock.beforePos).nodeBefore;if(d){const m=ee({posBeforeNode:c.bnBlock.beforePos-d.nodeSize,node:d});if(m.blockNoteType==="numberedListItem"){if(!m.isBlockContainer)throw new Error("impossible");const b=m.blockContent.node.attrs.index;l=(parseInt(b)+1).toString()}}const u=c.blockContent.node,h=u.attrs.index,f=((a=d==null?void 0:d.firstChild)==null?void 0:a.type.name)!=="numberedListItem";if(h!==l||u.attrs.start&&!f){r=!0;const{start:m,...g}=u.attrs;o.setNodeMarkup(c.blockContent.beforePos,void 0,{...g,index:l,...typeof m=="number"&&f&&{start:m}})}}}),r?o:null}}),mo={...M,start:{default:void 0,type:"number"}},Ms=G({name:"numberedListItem",content:"inline*",group:"blockContent",priority:90,addAttributes(){return{...ge(mo),index:{default:null,parseHTML:e=>e.getAttribute("data-index"),renderHTML:e=>({"data-index":e.index})}}},addInputRules(){return[new k.InputRule({find:new RegExp("^(\\d+)\\.\\s$"),handler:({state:e,chain:n,range:t,match:o})=>{const r=E(e);if(!r.isBlockContainer||r.blockContent.node.type.spec.content!=="inline*"||r.blockNoteType==="numberedListItem")return;const s=parseInt(o[1]);n().command(U(r.bnBlock.beforePos,{type:"numberedListItem",props:s===1&&{}||{start:s}})).deleteRange({from:t.from,to:t.to})}})]},addKeyboardShortcuts(){return{Enter:()=>tt(this.options.editor),"Mod-Shift-7":()=>{const e=E(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(U(e.bnBlock.beforePos,{type:"numberedListItem",props:{}}))}}},addProseMirrorPlugins(){return[Ps()]},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"li",getAttrs:e=>{var t;if(typeof e=="string")return!1;const n=e.parentElement;if(n===null)return!1;if(n.tagName==="OL"||n.tagName==="DIV"&&((t=n.parentElement)==null?void 0:t.tagName)==="OL"){const o=parseInt(n.getAttribute("start")||"1")||1;return e.previousSibling||o===1?{}:{start:o}}return!1},getContent:(e,n)=>Ot(e,n,this.name),priority:300,node:"numberedListItem"}]},renderHTML({HTMLAttributes:e}){var n,t;return $(this.name,"p",{...((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},...e},((t=this.options.domAttributes)==null?void 0:t.inlineContent)||{})}}),Is=Z(Ms,mo),Ls={...M},As=G({name:"paragraph",content:"inline*",group:"blockContent",addKeyboardShortcuts(){return{"Mod-Alt-0":()=>{const e=E(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(U(e.bnBlock.beforePos,{type:"paragraph",props:{}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"p",getAttrs:e=>{var n;return typeof e=="string"||!((n=e.textContent)!=null&&n.trim())?!1:{}},node:"paragraph"}]},renderHTML({HTMLAttributes:e}){var n,t;return $(this.name,"p",{...((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},...e},((t=this.options.domAttributes)==null?void 0:t.inlineContent)||{})}}),Ns=Z(As,Ls),Ds={...M},Hs=G({name:"quote",content:"inline*",group:"blockContent",addInputRules(){return[new k.InputRule({find:new RegExp("^>\\s$"),handler:({state:e,chain:n,range:t})=>{const o=E(e);!o.isBlockContainer||o.blockContent.node.type.spec.content!=="inline*"||n().command(U(o.bnBlock.beforePos,{type:"quote",props:{}})).deleteRange({from:t.from,to:t.to})}})]},addKeyboardShortcuts(){return{"Mod-Alt-q":()=>{const e=E(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(U(e.bnBlock.beforePos,{type:"quote"}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"blockquote",node:"quote"}]},renderHTML({HTMLAttributes:e}){var n,t;return $(this.name,"blockquote",{...((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},...e},((t=this.options.domAttributes)==null?void 0:t.inlineContent)||{})}}),Os=Z(Hs,Ds),Rs=35,Rt=120,_s=31,Vs=k.Extension.create({name:"BlockNoteTableExtension",addProseMirrorPlugins:()=>[H.columnResizing({cellMinWidth:Rs,defaultCellMinWidth:Rt,View:null}),H.tableEditing()],addKeyboardShortcuts(){return{Enter:()=>this.editor.state.selection.empty&&this.editor.state.selection.$head.parent.type.name==="tableParagraph"?(this.editor.commands.insertContent({type:"hardBreak"}),!0):!1,Backspace:()=>{const e=this.editor.state.selection,n=e.empty,t=e.$head.parentOffset===0,o=e.$head.node().type.name==="tableParagraph";return n&&t&&o},Tab:()=>this.editor.commands.command(({state:e,dispatch:n,view:t})=>H.goToNextCell(1)(e,n,t)),"Shift-Tab":()=>this.editor.commands.command(({state:e,dispatch:n,view:t})=>H.goToNextCell(-1)(e,n,t))}},extendNodeSchema(e){const n={name:e.name,options:e.options,storage:e.storage};return{tableRole:k.callOrReturn(k.getExtensionField(e,"tableRole",n))}}}),Us={textColor:M.textColor},Fs=G({name:"table",content:"tableRow+",group:"blockContent",tableRole:"table",marks:"deletion insertion modification",isolating:!0,parseHTML(){return[{tag:"table"}]},renderHTML({HTMLAttributes:e}){var n,t;return $(this.name,"table",{...((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},...e},((t=this.options.domAttributes)==null?void 0:t.inlineContent)||{})},addNodeView(){return({node:e,HTMLAttributes:n})=>{var o;class t extends H.TableView{constructor(s,i,a){super(s,i),this.node=s,this.cellMinWidth=i,this.blockContentHTMLAttributes=a;const l=document.createElement("div");l.className=Q("bn-block-content",a.class),l.setAttribute("data-content-type","table");for(const[h,f]of Object.entries(a))h!=="class"&&l.setAttribute(h,f);const c=this.dom,d=document.createElement("div");d.className="tableWrapper-inner",d.appendChild(c.firstChild),c.appendChild(d),l.appendChild(c);const u=document.createElement("div");u.className="table-widgets-container",u.style.position="relative",c.appendChild(u),this.dom=l}ignoreMutation(s){return!s.target.closest(".tableWrapper-inner")||super.ignoreMutation(s)}}return new t(e,Rt,{...((o=this.options.domAttributes)==null?void 0:o.blockContent)||{},...n})}}}),$s=G({name:"tableParagraph",group:"tableContent",content:"inline*",parseHTML(){return[{tag:"p",getAttrs:e=>{if(typeof e=="string"||!e.textContent||!e.closest("[data-content-type]"))return!1;const n=e.parentElement;return n===null?!1:n.tagName==="TD"||n.tagName==="TH"?{}:!1},node:"tableParagraph"}]},renderHTML({HTMLAttributes:e}){return["p",e,0]}}),zs=k.Node.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)+",tableRole:"row",marks:"deletion insertion modification",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:e}){return["tr",k.mergeAttributes(this.options.HTMLAttributes,e),0]}});function Zt(e,n){const o=S.DOMParser.fromSchema(n).parse(e,{topNode:n.nodes.blockGroup.create()}),r=[];return o.content.descendants(s=>{if(s.isInline)return r.push(s),!1}),S.Fragment.fromArray(r)}const Ws=Z(Fs,Us,[Vs,$s,Lr.TableHeader.extend({content:"tableContent+",parseHTML(){return[{tag:"th",getContent:(e,n)=>Zt(e,n)}]}}),Ir.TableCell.extend({content:"tableContent+",parseHTML(){return[{tag:"td",getContent:(e,n)=>Zt(e,n)}]}}),zs]),Qt=e=>{const n=e.src||void 0,t=e.width||void 0;return{url:n,previewWidth:t}},go='<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>',bo={textAlignment:M.textAlignment,backgroundColor:M.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0},previewWidth:{default:void 0,type:"number"}},ko={type:"video",propSchema:bo,content:"none",isFileBlock:!0,fileBlockAccept:["video/*"]},wo=(e,n)=>{const t=document.createElement("div");t.innerHTML=go;const o=document.createElement("div");o.className="bn-visual-media-wrapper";const r=document.createElement("video");return r.className="bn-visual-media",n.resolveFileUrl?n.resolveFileUrl(e.props.url).then(s=>{r.src=s}):r.src=e.props.url,r.controls=!0,r.contentEditable="false",r.draggable=!1,r.width=e.props.previewWidth,o.appendChild(r),Ht(e,n,{dom:o},o,n.dictionary.file_blocks.video.add_button_text,t.firstElementChild)},yo=e=>{if(e.tagName==="VIDEO")return e.closest("figure")?void 0:Qt(e);if(e.tagName==="FIGURE"){const n=Le(e,"video");if(!n)return;const{targetElement:t,caption:o}=n;return{...Qt(t),caption:o}}},Co=e=>{if(!e.props.url){const t=document.createElement("p");return t.textContent="Add video",{dom:t}}let n;return e.props.showPreview?(n=document.createElement("video"),n.src=e.props.url,e.props.previewWidth&&(n.width=e.props.previewWidth)):(n=document.createElement("a"),n.href=e.props.url,n.textContent=e.props.name||e.props.url),e.props.caption?e.props.showPreview?et(n,e.props.caption):Ae(n,e.props.caption):{dom:n}},vo=be(ko,{render:wo,parse:yo,toExternalHTML:Co}),_t={paragraph:Ns,heading:ks,quote:Os,codeBlock:Jn,toggleListItem:Cs,bulletListItem:Es,numberedListItem:Is,checkListItem:Ts,table:Ws,file:no,image:po,video:vo,audio:Gn},So=xt(_t),Vt={bold:ne(Ur.default,"boolean"),italic:ne($r.default,"boolean"),underline:ne(Wr.default,"boolean"),strike:ne(zr.default,"boolean"),code:ne(Fr.default,"boolean"),textColor:ms,backgroundColor:hs},Ks=Lt(Vt),Ut={text:{config:"text",implementation:{}},link:{config:"link",implementation:{}}},Eo=Mt(Ut);function V(e,n){return e in n.schema.blockSchema&&n.schema.blockSchema[e]===So[e]}function Bo(e,n){return e in n.schema.inlineContentSchema&&n.schema.inlineContentSchema[e]===Eo[e]}function To(e,n,t){return n.type===e&&n.type in t.schema.blockSchema&&V(n.type,t)}function qs(e,n){return e.type in n.schema.blockSchema&&n.schema.blockSchema[e.type].isFileBlock||!1}function js(e,n){return e.type in n.schema.blockSchema&&n.schema.blockSchema[e.type].isFileBlock&&"showPreview"in n.schema.blockSchema[e.type].propSchema||!1}function Gs(e,n){return n.schema.blockSchema[e.type].isFileBlock&&!e.props.url}function xo(e,n,t){return n in t.schema.blockSchema&&e in t.schema.blockSchema[n].propSchema&&t.schema.blockSchema[n].propSchema[e]===M[e]}function Ys(e,n,t){return xo(e,n.type,t)}function wt(e){return e instanceof H.CellSelection}const Js=async e=>{const n=new FormData;return n.append("file",e),(await(await fetch("https://tmpfiles.org/api/v1/upload",{method:"POST",body:n})).json()).data.url.replace("tmpfiles.org/","tmpfiles.org/dl/")};function Xs(e){let n=e.getTextCursorPosition().block,t=e.schema.blockSchema[n.type].content;for(;t==="none";){if(n=e.getTextCursorPosition().nextBlock,n===void 0)return;t=e.schema.blockSchema[n.type].content,e.setTextCursorPosition(n,"end")}}function A(e,n){const t=e.getTextCursorPosition().block;if(t.content===void 0)throw new Error("Slash Menu open in a block that doesn't contain content.");let o;return Array.isArray(t.content)&&(t.content.length===1&&oe(t.content[0])&&t.content[0].type==="text"&&t.content[0].text==="/"||t.content.length===0)?(o=e.updateBlock(t,n),e.setTextCursorPosition(o)):(o=e.insertBlocks([n],t,"after")[0],e.setTextCursorPosition(e.getTextCursorPosition().nextBlock)),Xs(e),o}function Zs(e){const n=[];return V("heading",e)&&n.push({onItemClick:()=>{A(e,{type:"heading",props:{level:1}})},badge:J("Mod-Alt-1"),key:"heading",...e.dictionary.slash_menu.heading},{onItemClick:()=>{A(e,{type:"heading",props:{level:2}})},badge:J("Mod-Alt-2"),key:"heading_2",...e.dictionary.slash_menu.heading_2},{onItemClick:()=>{A(e,{type:"heading",props:{level:3}})},badge:J("Mod-Alt-3"),key:"heading_3",...e.dictionary.slash_menu.heading_3}),V("quote",e)&&n.push({onItemClick:()=>{A(e,{type:"quote"})},key:"quote",...e.dictionary.slash_menu.quote}),V("toggleListItem",e)&&n.push({onItemClick:()=>{A(e,{type:"toggleListItem"})},badge:J("Mod-Shift-6"),key:"toggle_list",...e.dictionary.slash_menu.toggle_list}),V("numberedListItem",e)&&n.push({onItemClick:()=>{A(e,{type:"numberedListItem"})},badge:J("Mod-Shift-7"),key:"numbered_list",...e.dictionary.slash_menu.numbered_list}),V("bulletListItem",e)&&n.push({onItemClick:()=>{A(e,{type:"bulletListItem"})},badge:J("Mod-Shift-8"),key:"bullet_list",...e.dictionary.slash_menu.bullet_list}),V("checkListItem",e)&&n.push({onItemClick:()=>{A(e,{type:"checkListItem"})},badge:J("Mod-Shift-9"),key:"check_list",...e.dictionary.slash_menu.check_list}),V("paragraph",e)&&n.push({onItemClick:()=>{A(e,{type:"paragraph"})},badge:J("Mod-Alt-0"),key:"paragraph",...e.dictionary.slash_menu.paragraph}),V("codeBlock",e)&&n.push({onItemClick:()=>{A(e,{type:"codeBlock"})},badge:J("Mod-Alt-c"),key:"code_block",...e.dictionary.slash_menu.code_block}),V("table",e)&&n.push({onItemClick:()=>{A(e,{type:"table",content:{type:"tableContent",rows:[{cells:["","",""]},{cells:["","",""]}]}})},badge:void 0,key:"table",...e.dictionary.slash_menu.table}),V("image",e)&&n.push({onItemClick:()=>{const t=A(e,{type:"image"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:t}))},key:"image",...e.dictionary.slash_menu.image}),V("video",e)&&n.push({onItemClick:()=>{const t=A(e,{type:"video"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:t}))},key:"video",...e.dictionary.slash_menu.video}),V("audio",e)&&n.push({onItemClick:()=>{const t=A(e,{type:"audio"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:t}))},key:"audio",...e.dictionary.slash_menu.audio}),V("file",e)&&n.push({onItemClick:()=>{const t=A(e,{type:"file"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:t}))},key:"file",...e.dictionary.slash_menu.file}),V("heading",e)&&(n.push({onItemClick:()=>{A(e,{type:"heading",props:{level:1,isToggleable:!0}})},key:"toggle_heading",...e.dictionary.slash_menu.toggle_heading},{onItemClick:()=>{A(e,{type:"heading",props:{level:2,isToggleable:!0}})},key:"toggle_heading_2",...e.dictionary.slash_menu.toggle_heading_2},{onItemClick:()=>{A(e,{type:"heading",props:{level:3,isToggleable:!0}})},key:"toggle_heading_3",...e.dictionary.slash_menu.toggle_heading_3}),e.settings.heading.levels.filter(t=>t>3).forEach(t=>{n.push({onItemClick:()=>{A(e,{type:"heading",props:{level:t}})},key:`heading_${t}`,...e.dictionary.slash_menu[`heading_${t}`]})})),n.push({onItemClick:()=>{e.openSuggestionMenu(":",{deleteTriggerCharacter:!0,ignoreQueryLength:!0})},key:"emoji",...e.dictionary.slash_menu.emoji}),n}function Qs(e,n){return e.filter(({title:t,aliases:o})=>t.toLowerCase().includes(n.toLowerCase())||o&&o.filter(r=>r.toLowerCase().includes(n.toLowerCase())).length!==0)}function at(e){return e&&Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))}class ye{constructor(n){p(this,"blockSpecs");p(this,"inlineContentSpecs");p(this,"styleSpecs");p(this,"blockSchema");p(this,"inlineContentSchema");p(this,"styleSchema");p(this,"BlockNoteEditor","only for types");p(this,"Block","only for types");p(this,"PartialBlock","only for types");this.blockSpecs=at(n==null?void 0:n.blockSpecs)||_t,this.inlineContentSpecs=at(n==null?void 0:n.inlineContentSpecs)||Ut,this.styleSpecs=at(n==null?void 0:n.styleSpecs)||Vt,this.blockSchema=xt(this.blockSpecs),this.inlineContentSchema=Mt(this.inlineContentSpecs),this.styleSchema=Lt(this.styleSpecs)}static create(n){return new ye(n)}}const Po={type:"pageBreak",propSchema:{},content:"none",isFileBlock:!1,isSelectable:!1},Mo=()=>{const e=document.createElement("div");return e.className="bn-page-break",e.setAttribute("data-page-break",""),{dom:e}},Io=e=>{if(e.tagName==="DIV"&&e.hasAttribute("data-page-break"))return{type:"pageBreak"}},Lo=()=>{const e=document.createElement("div");return e.setAttribute("data-page-break",""),{dom:e}},Ao=be(Po,{render:Mo,parse:Io,toExternalHTML:Lo}),Ft=ye.create({blockSpecs:{pageBreak:Ao}}),ei=e=>ye.create({blockSpecs:{...e.blockSpecs,...Ft.blockSpecs},inlineContentSpecs:e.inlineContentSpecs,styleSpecs:e.styleSpecs});function No(e){return"pageBreak"in e.schema.blockSchema&&e.schema.blockSchema.pageBreak===Ft.blockSchema.pageBreak}function ti(e){const n=[];return No(e)&&n.push({...e.dictionary.slash_menu.page_break,onItemClick:()=>{A(e,{type:"pageBreak"})},key:"page_break"}),n}function ni(e){return e.transact(n=>{const t=X(n.doc,n.selection.anchor);if(n.selection instanceof H.CellSelection)return{type:"cell",anchorBlockId:t.node.attrs.id,anchorCellOffset:n.selection.$anchorCell.pos-t.posBeforeNode,headCellOffset:n.selection.$headCell.pos-t.posBeforeNode};if(n.selection instanceof y.NodeSelection)return{type:"node",anchorBlockId:t.node.attrs.id};{const o=X(n.doc,n.selection.head);return{type:"text",anchorBlockId:t.node.attrs.id,headBlockId:o.node.attrs.id,anchorOffset:n.selection.anchor-t.posBeforeNode,headOffset:n.selection.head-o.posBeforeNode}}})}function oi(e,n){var r,s;const t=(r=z(n.anchorBlockId,e.doc))==null?void 0:r.posBeforeNode;if(t===void 0)throw new Error(`Could not find block with ID ${n.anchorBlockId} to update selection`);let o;if(n.type==="cell")o=H.CellSelection.create(e.doc,t+n.anchorCellOffset,t+n.headCellOffset);else if(n.type==="node")o=y.NodeSelection.create(e.doc,t+1);else{const i=(s=z(n.headBlockId,e.doc))==null?void 0:s.posBeforeNode;if(i===void 0)throw new Error(`Could not find block with ID ${n.headBlockId} to update selection`);o=y.TextSelection.create(e.doc,t+n.anchorOffset,i+n.headOffset)}e.setSelection(o)}function yt(e){return e.map(n=>n.type==="columnList"?n.children.map(t=>yt(t.children)).flat():{...n,children:yt(n.children)}).flat()}function Do(e,n,t){e.transact(o=>{var i;const r=((i=e.getSelection())==null?void 0:i.blocks)||[e.getTextCursorPosition().block],s=ni(e);e.removeBlocks(r),e.insertBlocks(yt(r),n,t),oi(o,s)})}function Ho(e){return!e||e.type!=="columnList"}function Oo(e,n,t){let o,r;if(n?n.children.length>0?(o=n.children[n.children.length-1],r="after"):(o=n,r="before"):t&&(o=t,r="before"),!o||!r)return;const s=e.getParentBlock(o);return Ho(s)?{referenceBlock:o,placement:r}:Oo(e,r==="after"?o:e.getPrevBlock(o),s)}function Ro(e,n,t){let o,r;if(n?n.children.length>0?(o=n.children[0],r="before"):(o=n,r="after"):t&&(o=t,r="after"),!o||!r)return;const s=e.getParentBlock(o);return Ho(s)?{referenceBlock:o,placement:r}:Ro(e,r==="before"?o:e.getNextBlock(o),s)}function ri(e){e.transact(()=>{const n=e.getSelection(),t=(n==null?void 0:n.blocks[0])||e.getTextCursorPosition().block,o=Oo(e,e.getPrevBlock(t),e.getParentBlock(t));o&&Do(e,o.referenceBlock,o.placement)})}function si(e){e.transact(()=>{const n=e.getSelection(),t=(n==null?void 0:n.blocks[(n==null?void 0:n.blocks.length)-1])||e.getTextCursorPosition().block,o=Ro(e,e.getNextBlock(t),e.getParentBlock(t));o&&Do(e,o.referenceBlock,o.placement)})}function ii(e,n){return function(t,o){const{$from:r,$to:s}=t.selection,i=r.blockRange(s,d=>d.childCount>0&&(d.type.name==="blockGroup"||d.type.name==="column"));if(!i)return!1;const a=i.startIndex;if(a===0)return!1;const c=i.parent.child(a-1);if(c.type!==e)return!1;if(o){const d=c.lastChild&&c.lastChild.type===n,u=S.Fragment.from(d?e.create():null),h=new S.Slice(S.Fragment.from(e.create(null,S.Fragment.from(n.create(null,u)))),d?3:1,0),f=i.start,m=i.end;o(t.tr.step(new he.ReplaceAroundStep(f-(d?3:1),m,f,m,h,1,!0)).scrollIntoView())}return!0}}function _o(e){return e.exec((n,t)=>ii(n.schema.nodes.blockContainer,n.schema.nodes.blockGroup)(n,t))}function ai(e){e._tiptapEditor.commands.liftListItem("blockContainer")}function li(e){return e.transact(n=>{const{bnBlock:t}=xe(n);return n.doc.resolve(t.beforePos).nodeBefore!==null})}function ci(e){return e.transact(n=>{const{bnBlock:t}=xe(n);return n.doc.resolve(t.beforePos).depth>1})}function Vo(e,n){const t=typeof n=="string"?n:n.id,o=O(e),r=z(t,e);if(r)return B(r.node,o)}function Uo(e,n){const t=typeof n=="string"?n:n.id,o=z(t,e),r=O(e);if(!o)return;const i=e.resolve(o.posBeforeNode).nodeBefore;if(i)return B(i,r)}function Fo(e,n){const t=typeof n=="string"?n:n.id,o=z(t,e),r=O(e);if(!o)return;const i=e.resolve(o.posBeforeNode+o.node.nodeSize).nodeAfter;if(i)return B(i,r)}function $o(e,n){const t=typeof n=="string"?n:n.id,o=O(e),r=z(t,e);if(!r)return;const s=e.resolve(r.posBeforeNode),i=s.node(),a=s.node(-1),l=a.type.name!=="doc"?i.type.name==="blockGroup"?a:i:void 0;if(l)return B(l,o)}function di(e,n,t,o={updateSelection:!0}){let{from:r,to:s}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},i=!0,a=!0,l="";if(t.forEach(c=>{c.check(),i&&c.isText&&c.marks.length===0?l+=c.text:i=!1,a=a?c.isBlock:!1}),r===s&&a){const{parent:c}=e.doc.resolve(r);c.isTextblock&&!c.type.spec.code&&!c.childCount&&(r-=1,s+=1)}return i?e.insertText(l,r,s):e.replaceWith(r,s,t),o.updateSelection&&k.selectionToInsertionEnd(e,e.steps.length-1,-1),!0}function ui(e){const n=O(e);if(e.selection.empty||"node"in e.selection)return;const t=e.doc.resolve(X(e.doc,e.selection.from).posBeforeNode),o=e.doc.resolve(X(e.doc,e.selection.to).posBeforeNode),r=(c,d)=>{const u=t.posAtIndex(c,d),h=e.doc.resolve(u).nodeAfter;if(!h)throw new Error(`Error getting selection - node not found at position ${u}`);return B(h,n)},s=[],i=t.sharedDepth(o.pos),a=t.index(i),l=o.index(i);if(t.depth>i){s.push(B(t.nodeAfter,n));for(let c=t.depth;c>i;c--)if(t.node(c).type.isInGroup("childContainer")){const u=t.index(c)+1,h=t.node(c).childCount;for(let f=u;f<h;f++)s.push(r(f,c))}}else s.push(r(a,i));for(let c=a+1;c<=l;c++)s.push(r(c,i));if(s.length===0)throw new Error(`Error getting selection - selection doesn't span any blocks (${e.selection})`);return{blocks:s}}function pi(e,n,t){const o=typeof n=="string"?n:n.id,r=typeof t=="string"?t:t.id,s=O(e),i=we(s);if(o===r)throw new Error(`Attempting to set selection with the same anchor and head blocks (id ${o})`);const a=z(o,e.doc);if(!a)throw new Error(`Block with ID ${o} not found`);const l=z(r,e.doc);if(!l)throw new Error(`Block with ID ${r} not found`);const c=ee(a),d=ee(l),u=i.blockSchema[c.blockNoteType],h=i.blockSchema[d.blockNoteType];if(!c.isBlockContainer||u.content==="none")throw new Error(`Attempting to set selection anchor in block without content (id ${o})`);if(!d.isBlockContainer||h.content==="none")throw new Error(`Attempting to set selection anchor in block without content (id ${r})`);let f,m;if(u.content==="table"){const g=H.TableMap.get(c.blockContent.node);f=c.blockContent.beforePos+g.positionAt(0,0,c.blockContent.node)+1+2}else f=c.blockContent.beforePos+1;if(h.content==="table"){const g=H.TableMap.get(d.blockContent.node),b=d.blockContent.beforePos+g.positionAt(g.height-1,g.width-1,d.blockContent.node)+1,w=e.doc.resolve(b).nodeAfter.nodeSize;m=b+w-2}else m=d.blockContent.afterPos-1;e.setSelection(y.TextSelection.create(e.doc,f,m))}function hi(e){const n=O(e);let t=e.selection.$from,o=e.selection.$to;for(;o.parentOffset>=o.parent.nodeSize-2&&o.depth>0;)o=e.doc.resolve(o.pos+1);for(;o.parentOffset===0&&o.depth>0;)o=e.doc.resolve(o.pos-1);for(;t.parentOffset===0&&t.depth>0;)t=e.doc.resolve(t.pos-1);for(;t.parentOffset>=t.parent.nodeSize-2&&t.depth>0;)t=e.doc.resolve(t.pos+1);const r=kn(e.doc.slice(t.pos,o.pos,!0),n);return{_meta:{startPos:t.pos,endPos:o.pos},...r}}function fi(e){const{bnBlock:n}=xe(e),t=O(e.doc),o=e.doc.resolve(n.beforePos),r=o.nodeBefore,s=e.doc.resolve(n.afterPos).nodeAfter;let i;return o.depth>1&&(i=o.node(),i.type.isInGroup("bnBlock")||(i=o.node(o.depth-1))),{block:B(n.node,t),prevBlock:r===null?void 0:B(r,t),nextBlock:s===null?void 0:B(s,t),parentBlock:i===void 0?void 0:B(i,t)}}function zo(e,n,t="start"){const o=typeof n=="string"?n:n.id,r=O(e.doc),s=we(r),i=z(o,e.doc);if(!i)throw new Error(`Block with ID ${o} not found`);const a=ee(i),l=s.blockSchema[a.blockNoteType].content;if(a.isBlockContainer){const c=a.blockContent;if(l==="none"){e.setSelection(y.NodeSelection.create(e.doc,c.beforePos));return}if(l==="inline")t==="start"?e.setSelection(y.TextSelection.create(e.doc,c.beforePos+1)):e.setSelection(y.TextSelection.create(e.doc,c.afterPos-1));else if(l==="table")t==="start"?e.setSelection(y.TextSelection.create(e.doc,c.beforePos+4)):e.setSelection(y.TextSelection.create(e.doc,c.afterPos-4));else throw new j(l)}else{const c=t==="start"?a.childContainer.node.firstChild:a.childContainer.node.lastChild;zo(e,c.attrs.id,t)}}exports.esmDependencies=void 0;async function nt(){if(exports.esmDependencies)return exports.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 exports.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]},exports.esmDependencies}function mi(){const e=n=>{let t=n.children.length;for(let o=0;o<t;o++){const r=n.children[o];if(r.type==="element"&&(e(r),r.tagName==="u"))if(r.children.length>0){n.children.splice(o,1,...r.children);const s=r.children.length-1;t+=s,o+=s}else n.children.splice(o,1),t--,o--}};return e}function gi(){const e=exports.esmDependencies;if(!e)throw new Error("addSpacesToCheckboxes requires ESM dependencies to be initialized");const n=t=>{var o;if(t.children&&"length"in t.children&&t.children.length)for(let r=t.children.length-1;r>=0;r--){const s=t.children[r],i=r+1<t.children.length?t.children[r+1]:void 0;s.type==="element"&&s.tagName==="input"&&((o=s.properties)==null?void 0:o.type)==="checkbox"&&(i==null?void 0:i.type)==="element"&&i.tagName==="p"?(i.tagName="span",i.children.splice(0,0,e.hastUtilFromDom.fromDom(document.createTextNode(" ")))):n(s)}};return n}function ot(e){const n=exports.esmDependencies;if(!n)throw new Error("cleanHTMLToMarkdown requires ESM dependencies to be initialized");return n.unified.unified().use(n.rehypeParse.default,{fragment:!0}).use(mi).use(gi).use(n.rehypeRemark.default).use(n.remarkGfm.default).use(n.remarkStringify.default,{handlers:{text:o=>o.value}}).processSync(e).value}async function Wo(e,n,t,o){await nt();const s=Ie(n,t).exportBlocks(e,o);return ot(s)}function bi(e){return Array.prototype.indexOf.call(e.parentElement.childNodes,e)}function ki(e){return e.nodeType===3&&!/\S/.test(e.nodeValue||"")}function wi(e){e.querySelectorAll("li > ul, li > ol").forEach(n=>{const t=bi(n),o=n.parentElement,r=Array.from(o.childNodes).slice(t+1);n.remove(),r.forEach(s=>{s.remove()}),o.insertAdjacentElement("afterend",n),r.reverse().forEach(s=>{if(ki(s))return;const i=document.createElement("li");i.append(s),n.insertAdjacentElement("afterend",i)}),o.childNodes.length===0&&o.remove()})}function yi(e){e.querySelectorAll("li + ul, li + ol").forEach(n=>{var s,i;const t=n.previousElementSibling,o=document.createElement("div");t.insertAdjacentElement("afterend",o),o.append(t);const r=document.createElement("div");for(r.setAttribute("data-node-type","blockGroup"),o.append(r);((s=o.nextElementSibling)==null?void 0:s.nodeName)==="UL"||((i=o.nextElementSibling)==null?void 0:i.nodeName)==="OL";)r.append(o.nextElementSibling)})}let en=null;function Ci(){return en||(en=document.implementation.createHTMLDocument("title"))}function Ko(e){if(typeof e=="string"){const n=Ci().createElement("div");n.innerHTML=e,e=n}return wi(e),yi(e),e}async function $t(e,n){const t=Ko(e),r=S.DOMParser.fromSchema(n).parse(t,{topNode:n.nodes.blockGroup.create()}),s=[];for(let i=0;i<r.childCount;i++)s.push(B(r.child(i),n));return s}function vi(e,n){const t=n.value?n.value:"",o={};n.lang&&(o["data-language"]=n.lang);let r={type:"element",tagName:"code",properties:o,children:[{type:"text",value:t}]};return n.meta&&(r.data={meta:n.meta}),e.patch(n,r),r=e.applyData(n,r),r={type:"element",tagName:"pre",properties:{},children:[r]},e.patch(n,r),r}async function zt(e){const n=await nt();return n.unified.unified().use(n.remarkParse.default).use(n.remarkGfm.default).use(n.remarkRehype.default,{handlers:{...n.remarkRehype.defaultHandlers,code:vi}}).use(n.rehypeStringify.default).processSync(e).value}async function qo(e,n){const t=await zt(e);return $t(t,n)}const Wt=["vscode-editor-data","blocknote/html","text/markdown","text/html","text/plain","Files"];function Si(e,n){if(!e.startsWith(".")||!n.startsWith("."))throw new Error("The strings provided are not valid file extensions.");return e===n}function Ei(e,n){const t=e.split("/"),o=n.split("/");if(t.length!==2)throw new Error(`The string ${e} is not a valid MIME type.`);if(o.length!==2)throw new Error(`The string ${n} is not a valid MIME type.`);return t[1]==="*"||o[1]==="*"?t[0]===o[0]:(t[0]==="*"||o[0]==="*"||t[0]===o[0])&&t[1]===o[1]}function tn(e,n,t){let o;return Array.isArray(n.content)&&n.content.length===0?o=e.updateBlock(n,t).id:o=e.insertBlocks([t],n,"after")[0].id,o}async function jo(e,n){var i;if(!n.uploadFile){console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");return}const t="dataTransfer"in e?e.dataTransfer:e.clipboardData;if(t===null)return;let o=null;for(const a of Wt)if(t.types.includes(a)){o=a;break}if(o!=="Files")return;const r=t.items;if(!r)return;e.preventDefault();const s=Object.values(n.schema.blockSchema).filter(a=>a.isFileBlock);for(let a=0;a<r.length;a++){let l="file";for(const d of s)for(const u of d.fileBlockAccept||[]){const h=u.startsWith("."),f=r[a].getAsFile();if(f&&(!h&&f.type&&Ei(r[a].type,u)||h&&Si("."+f.name.split(".").pop(),u))){l=d.type;break}}const c=r[a].getAsFile();if(c){const d={type:l,props:{name:c.name}};let u;if(e.type==="paste"){const m=n.getTextCursorPosition().block;u=tn(n,m,d)}else if(e.type==="drop"){const m={left:e.clientX,top:e.clientY},g=(i=n.prosemirrorView)==null?void 0:i.posAtCoords(m);if(!g)return;u=n.transact(b=>{const w=X(b.doc,g.pos);return tn(n,n.getBlock(w.node.attrs.id),d)})}else return;const h=await n.uploadFile(c,u),f=typeof h=="string"?{props:{url:h}}:{...h};n.updateBlock(u,f)}}}const Bi=e=>k.Extension.create({name:"dropFile",addProseMirrorPlugins(){return[new y.Plugin({props:{handleDOMEvents:{drop(n,t){if(!e.isEditable)return;let o=null;for(const r of Wt)if(t.dataTransfer.types.includes(r)){o=r;break}return o===null?!0:o==="Files"?(jo(t,e),!0):!1}}}})]}}),Ti=/(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/,xi=new RegExp("(?:\\s|^)(_|__|\\*|\\*\\*|~~|==|\\+\\+)(?!\\s).{1,64}(?<!\\s)(?=\\1)"),Pi=/\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/,Mi=new RegExp("(?:\\s|^)`(?!\\s)[^`]{1,48}(?<!\\s)`([^\\w]|$)"),Ii=/(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/,Li=/(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/,Ai=/\n{2} {0,3}-{2,48}\n{2}/,Ni=/(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/,Di=/(?:\n|^)(?!\s)\w[^\n]{0,64}\r?\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/,Hi=/(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/,Oi=/^\s*\|(.+\|)+\s*$/m,Ri=/^\s*\|(\s*[-:]+[-:]\s*\|)+\s*$/m,_i=/^\s*\|(.+\|)+\s*$/m,Vi=e=>Ti.test(e)||xi.test(e)||Pi.test(e)||Mi.test(e)||Ii.test(e)||Li.test(e)||Ai.test(e)||Ni.test(e)||Di.test(e)||Hi.test(e)||Oi.test(e)||Ri.test(e)||_i.test(e);async function Ui(e,n){const{schema:t}=n.state;if(!e.clipboardData)return!1;const o=e.clipboardData.getData("text/plain");if(!o)return!1;if(!t.nodes.codeBlock)return n.pasteText(o),!0;const r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s==null?void 0:s.mode;return i?(n.pasteHTML(`<pre><code class="language-${i}">${o.replace(/\r\n?/g,`
11
- `)}</code></pre>`),!0):!1}function Fi({event:e,editor:n,prioritizeMarkdownOverHTML:t,plainTextAsMarkdown:o}){var a;if(n.transact(l=>l.selection.$from.parent.type.spec.code&&l.selection.$to.parent.type.spec.code)){const l=(a=e.clipboardData)==null?void 0:a.getData("text/plain");if(l)return n.pasteText(l),!0}let s;for(const l of Wt)if(e.clipboardData.types.includes(l)){s=l;break}if(!s)return!0;if(s==="vscode-editor-data")return Ui(e,n.prosemirrorView),!0;if(s==="Files")return jo(e,n),!0;const i=e.clipboardData.getData(s);if(s==="blocknote/html")return n.pasteHTML(i,!0),!0;if(s==="text/markdown")return n.pasteMarkdown(i),!0;if(t){const l=e.clipboardData.getData("text/plain");if(Vi(l))return n.pasteMarkdown(l),!0}return s==="text/html"?(n.pasteHTML(i),!0):o?(n.pasteMarkdown(i),!0):(n.pasteText(i),!0)}const $i=(e,n)=>k.Extension.create({name:"pasteFromClipboard",addProseMirrorPlugins(){return[new y.Plugin({props:{handleDOMEvents:{paste(t,o){if(o.preventDefault(),!!e.isEditable)return n({event:o,editor:e,defaultPasteHandler:({prioritizeMarkdownOverHTML:r=!0,plainTextAsMarkdown:s=!0}={})=>Fi({event:o,editor:e,prioritizeMarkdownOverHTML:r,plainTextAsMarkdown:s})})}}}})]}});function Go(e){const n=[];return e.descendants(t=>{var r,s;const o=O(t);return t.type.name==="blockContainer"&&((r=t.firstChild)==null?void 0:r.type.name)==="blockGroup"?!0:t.type.name==="columnList"&&t.childCount===1?((s=t.firstChild)==null||s.forEach(i=>{n.push(B(i,o))}),!1):t.type.isInGroup("bnBlock")?(n.push(B(t,o)),!1):!0}),n}function zi(e,n,t){var a;let o=!1;const r=e.state.selection instanceof H.CellSelection;if(!r){const l=e.state.doc.slice(e.state.selection.from,e.state.selection.to,!1).content,c=[];for(let d=0;d<l.childCount;d++)c.push(l.child(d));o=c.find(d=>d.type.isInGroup("bnBlock")||d.type.name==="blockGroup"||d.type.spec.group==="blockContent")===void 0,o&&(n=l)}let s;const i=Ie(e.state.schema,t);if(r){((a=n.firstChild)==null?void 0:a.type.name)==="table"&&(n=n.firstChild.content);const l=Pt(n,t.schema.inlineContentSchema,t.schema.styleSchema);s=`<table>${i.exportInlineContent(l,{})}</table>`}else if(o){const l=Pe(n,t.schema.inlineContentSchema,t.schema.styleSchema);s=i.exportInlineContent(l,{})}else{const l=Go(n);s=i.exportBlocks(l,{})}return s}function Kt(e,n){"node"in e.state.selection&&e.state.selection.node.type.spec.group==="blockContent"&&n.transact(i=>i.setSelection(new y.NodeSelection(i.doc.resolve(e.state.selection.from-1))));const t=e.serializeForClipboard(e.state.selection.content()).dom.innerHTML,o=e.state.selection.content().content,r=zi(e,o,n),s=ot(r);return{clipboardHTML:t,externalHTML:r,markdown:s}}const nn=()=>{const e=window.getSelection();if(!e||e.isCollapsed)return!0;let n=e.focusNode;for(;n;){if(n instanceof HTMLElement&&n.getAttribute("contenteditable")==="false")return!0;n=n.parentElement}return!1},on=(e,n,t)=>{t.preventDefault(),t.clipboardData.clearData();const{clipboardHTML:o,externalHTML:r,markdown:s}=Kt(n,e);t.clipboardData.setData("blocknote/html",o),t.clipboardData.setData("text/html",r),t.clipboardData.setData("text/plain",s)},Wi=e=>k.Extension.create({name:"copyToClipboard",addProseMirrorPlugins(){return[new y.Plugin({props:{handleDOMEvents:{copy(n,t){return nn()||on(e,n,t),!0},cut(n,t){return nn()||(on(e,n,t),n.editable&&n.dispatch(n.state.tr.deleteSelection())),!0},dragstart(n,t){if(!("node"in n.state.selection)||n.state.selection.node.type.spec.group!=="blockContent")return;e.transact(i=>i.setSelection(new y.NodeSelection(i.doc.resolve(n.state.selection.from-1)))),t.preventDefault(),t.dataTransfer.clearData();const{clipboardHTML:o,externalHTML:r,markdown:s}=Kt(n,e);return t.dataTransfer.setData("blocknote/html",o),t.dataTransfer.setData("text/html",r),t.dataTransfer.setData("text/plain",s),!0}}}})]}}),Ki=k.Extension.create({name:"blockBackgroundColor",addGlobalAttributes(){return[{types:["blockContainer","tableCell","tableHeader"],attributes:{backgroundColor:{default:M.backgroundColor.default,parseHTML:e=>e.hasAttribute("data-background-color")?e.getAttribute("data-background-color"):M.backgroundColor.default,renderHTML:e=>e.backgroundColor===M.backgroundColor.default?{}:{"data-background-color":e.backgroundColor}}}}]}});class rt{constructor(){p(this,"callbacks",{})}on(n,t){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(t),()=>this.off(n,t)}emit(n,...t){const o=this.callbacks[n];o&&o.forEach(r=>r.apply(this,t))}off(n,t){const o=this.callbacks[n];o&&(t?this.callbacks[n]=o.filter(r=>r!==t):delete this.callbacks[n])}removeAllListeners(){this.callbacks={}}}class R extends rt{constructor(...t){super();p(this,"plugins",[])}static key(){throw new Error("You must implement the key method in your extension")}addProsemirrorPlugin(t){this.plugins.push(t)}get priority(){}}const ue=class ue extends R{constructor(t){super();p(this,"provider");p(this,"recentlyUpdatedCursors");p(this,"renderCursor",(t,o)=>{let r=this.recentlyUpdatedCursors.get(o);if(!r){const s=(this.collaboration.renderCursor??ue.defaultCursorRender)(t);this.collaboration.showCursorLabels!=="always"&&(s.addEventListener("mouseenter",()=>{const i=this.recentlyUpdatedCursors.get(o);i.element.setAttribute("data-active",""),i.hideTimeout&&(clearTimeout(i.hideTimeout),this.recentlyUpdatedCursors.set(o,{element:i.element,hideTimeout:void 0}))}),s.addEventListener("mouseleave",()=>{const i=this.recentlyUpdatedCursors.get(o);this.recentlyUpdatedCursors.set(o,{element:i.element,hideTimeout:setTimeout(()=>{i.element.removeAttribute("data-active")},2e3)})})),r={element:s,hideTimeout:void 0},this.recentlyUpdatedCursors.set(o,r)}return r.element});p(this,"updateUser",t=>{this.provider.awareness.setLocalStateField("user",t)});this.collaboration=t,this.provider=t.provider,this.recentlyUpdatedCursors=new Map,this.provider.awareness.setLocalStateField("user",t.user),t.showCursorLabels!=="always"&&this.provider.awareness.on("change",({updated:o})=>{for(const r of o){const s=this.recentlyUpdatedCursors.get(r);s&&(s.element.setAttribute("data-active",""),s.hideTimeout&&clearTimeout(s.hideTimeout),this.recentlyUpdatedCursors.set(r,{element:s.element,hideTimeout:setTimeout(()=>{s.element.removeAttribute("data-active")},2e3)}))}}),this.addProsemirrorPlugin(N.yCursorPlugin(this.provider.awareness,{selectionBuilder:N.defaultSelectionBuilder,cursorBuilder:this.renderCursor}))}static key(){return"yCursorPlugin"}get priority(){return 999}static isDarkColor(t){const o=t.charAt(0)==="#"?t.substring(1,7):t,r=parseInt(o.substring(0,2),16),s=parseInt(o.substring(2,4),16),i=parseInt(o.substring(4,6),16),l=[r/255,s/255,i/255].map(d=>d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4));return .2126*l[0]+.7152*l[1]+.0722*l[2]<=.179}};p(ue,"defaultCursorRender",t=>{const o=document.createElement("span");o.classList.add("bn-collaboration-cursor__base");const r=document.createElement("span");r.setAttribute("contentedEditable","false"),r.classList.add("bn-collaboration-cursor__caret"),r.setAttribute("style",`background-color: ${t.color}; color: ${ue.isDarkColor(t.color)?"white":"black"}`);const s=document.createElement("span");return s.classList.add("bn-collaboration-cursor__label"),s.setAttribute("style",`background-color: ${t.color}; color: ${ue.isDarkColor(t.color)?"white":"black"}`),s.insertBefore(document.createTextNode(t.name),null),r.insertBefore(s,null),o.insertBefore(document.createTextNode("⁠"),null),o.insertBefore(r,null),o.insertBefore(document.createTextNode("⁠"),null),o});let We=ue;class Ct extends R{static key(){return"ySyncPlugin"}constructor(n){super(),this.addProsemirrorPlugin(N.ySyncPlugin(n))}get priority(){return 1001}}class vt extends R{static key(){return"yUndoPlugin"}constructor({editor:n}){super(),this.addProsemirrorPlugin(N.yUndoPlugin({trackedOrigins:[n]}))}get priority(){return 1e3}}const Yo=k.Mark.create({name:"comment",excludes:"",inclusive:!1,keepOnSplit:!0,addAttributes(){return{orphan:{parseHTML:e=>!!e.getAttribute("data-orphan"),renderHTML:e=>e.orphan?{"data-orphan":"true"}:{},default:!1},threadId:{parseHTML:e=>e.getAttribute("data-bn-thread-id"),renderHTML:e=>({"data-bn-thread-id":e.threadId}),default:""}}},renderHTML({HTMLAttributes:e}){return["span",k.mergeAttributes(e,{class:"bn-thread-mark"})]},parseHTML(){return[{tag:"span.bn-thread-mark"}]},extendMarkSchema(e){return e.name==="comment"?{blocknoteIgnore:!0}:{}}});class qi extends rt{constructor(t){super();p(this,"userCache",new Map);p(this,"loadingUsers",new Set);this.resolveUsers=t}async loadUsers(t){const o=t.filter(r=>!this.userCache.has(r)&&!this.loadingUsers.has(r));if(o.length!==0){for(const r of o)this.loadingUsers.add(r);try{const r=await this.resolveUsers(o);for(const s of r)this.userCache.set(s.id,s);this.emit("update",this.userCache)}finally{for(const r of o)this.loadingUsers.delete(r)}}}getUser(t){return this.userCache.get(t)}subscribe(t){return this.on("update",t)}}const De=new y.PluginKey("blocknote-comments"),ji="SET_SELECTED_THREAD_ID";function Gi(e,n){const t=new Map;return e.descendants((o,r)=>{o.marks.forEach(s=>{if(s.type.name===n){const i=s.attrs.threadId;if(!i)return;const a=r,l=a+o.nodeSize,c=t.get(i)??{from:1/0,to:0};t.set(i,{from:Math.min(a,c.from),to:Math.max(l,c.to)})}})}),t}class Yi extends R{constructor(t,o,r){super();p(this,"userStore");p(this,"pendingComment",!1);p(this,"selectedThreadId");p(this,"threadPositions",new Map);p(this,"updateMarksFromThreads",t=>{this.editor.transact(o=>{o.doc.descendants((r,s)=>{r.marks.forEach(i=>{if(i.type.name===this.markType){const a=i.type,l=i.attrs.threadId,c=t.get(l),d=!!(!c||c.resolved||c.deletedAt);if(d!==i.attrs.orphan){const u=Math.max(s,0),h=Math.min(s+r.nodeSize,o.doc.content.size-1,o.doc.content.size-1);o.removeMark(u,h,i),o.addMark(u,h,a.create({...i.attrs,orphan:d})),d&&this.selectedThreadId===l&&(this.selectedThreadId=void 0,this.emitStateUpdate())}}})})})});if(this.editor=t,this.threadStore=o,this.markType=r,!t.resolveUsers)throw new Error("resolveUsers is required for comments");this.userStore=new qi(t.resolveUsers),this.threadStore.subscribe(this.updateMarksFromThreads),t.onCreate(()=>{this.updateMarksFromThreads(this.threadStore.getThreads()),t.onSelectionChange(()=>{this.pendingComment&&(this.pendingComment=!1,this.emitStateUpdate())})});const s=this;this.addProsemirrorPlugin(new y.Plugin({key:De,state:{init(){return{decorations:D.DecorationSet.empty}},apply(i,a){const l=i.getMeta(De);if(!i.docChanged&&!l)return a;const c=i.docChanged?Gi(i.doc,s.markType):s.threadPositions;(c.size>0||s.threadPositions.size>0)&&(s.threadPositions=c,s.emitStateUpdate());const d=[];if(s.selectedThreadId){const u=c.get(s.selectedThreadId);u&&d.push(D.Decoration.inline(u.from,u.to,{class:"bn-thread-mark-selected"}))}return{decorations:D.DecorationSet.create(i.doc,d)}}},props:{decorations(i){var a;return((a=De.getState(i))==null?void 0:a.decorations)??D.DecorationSet.empty},handleClick:(i,a,l)=>{if(l.button!==0)return;const c=i.state.doc.nodeAt(a);if(!c){s.selectThread(void 0);return}const d=c.marks.find(h=>h.type.name===r&&h.attrs.orphan!==!0),u=d==null?void 0:d.attrs.threadId;s.selectThread(u,!1)}}}))}static key(){return"comments"}emitStateUpdate(){this.emit("update",{selectedThreadId:this.selectedThreadId,pendingComment:this.pendingComment,threadPositions:this.threadPositions})}onUpdate(t){return this.on("update",t)}selectThread(t,o=!0){var r,s;if(this.selectedThreadId!==t&&(this.selectedThreadId=t,this.emitStateUpdate(),this.editor.transact(i=>i.setMeta(De,{name:ji})),t&&o)){const i=this.threadPositions.get(t);if(!i)return;(s=(r=this.editor.prosemirrorView)==null?void 0:r.domAtPos(i.from).node)==null||s.scrollIntoView({behavior:"smooth",block:"center"})}}startPendingComment(){this.pendingComment=!0,this.emitStateUpdate()}stopPendingComment(){this.pendingComment=!1,this.emitStateUpdate()}async createThread(t){const o=await this.threadStore.createThread(t);if(this.threadStore.addThreadToDocument){const r=this.editor.prosemirrorView,s=r.state.selection,i=N.ySyncPluginKey.getState(r.state),a={prosemirror:{head:s.head,anchor:s.anchor},yjs:i?N.getRelativeSelection(i.binding,r.state):void 0};await this.threadStore.addThreadToDocument({threadId:o.id,selection:a})}else this.editor._tiptapEditor.commands.setMark(this.markType,{orphan:!1,threadId:o.id})}}class Jo{constructor(n,t,o,r){p(this,"state");p(this,"emitUpdate");p(this,"mouseDownHandler",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())});p(this,"dragstartHandler",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())});p(this,"scrollHandler",()=>{var n;if((n=this.state)!=null&&n.show){const t=this.pmView.root.querySelector(`[data-node-type="blockContainer"][data-id="${this.state.block.id}"]`);if(!t)return;this.state.referencePos=t.getBoundingClientRect(),this.emitUpdate()}});p(this,"closeMenu",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())});this.editor=n,this.pluginKey=t,this.pmView=o,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized file panel");r(this.state)},o.dom.addEventListener("mousedown",this.mouseDownHandler),o.dom.addEventListener("dragstart",this.dragstartHandler),o.root.addEventListener("scroll",this.scrollHandler,!0)}update(n,t){var a,l;const o=this.pluginKey.getState(n.state),r=this.pluginKey.getState(t);if(!((a=this.state)!=null&&a.show)&&(o!=null&&o.block)&&this.editor.isEditable){const c=this.pmView.root.querySelector(`[data-node-type="blockContainer"][data-id="${o.block.id}"]`);if(!c)return;this.state={show:!0,referencePos:c.getBoundingClientRect(),block:o.block},this.emitUpdate();return}const s=(o==null?void 0:o.block)&&!(r!=null&&r.block),i=!(o!=null&&o.block)&&(r==null?void 0:r.block);s&&this.state&&!this.state.show&&(this.state.show=!0,this.emitUpdate()),i&&((l=this.state)!=null&&l.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 lt=new y.PluginKey("FilePanelPlugin");class Xo extends R{constructor(t){super();p(this,"view");p(this,"closeMenu",()=>{var t;return(t=this.view)==null?void 0:t.closeMenu()});this.addProsemirrorPlugin(new y.Plugin({key:lt,view:o=>(this.view=new Jo(t,lt,o,r=>{this.emit("update",r)}),this.view),props:{handleKeyDown:(o,r)=>{var s;return r.key==="Escape"&&this.shown?((s=this.view)==null||s.closeMenu(),!0):!1}},state:{init:()=>({block:void 0}),apply:(o,r)=>{const s=o.getMeta(lt);return s||(!o.getMeta(N.ySyncPluginKey)&&(o.selectionSet||o.docChanged)?{block:void 0}:r)}}}))}static key(){return"filePanel"}get shown(){var t,o;return((o=(t=this.view)==null?void 0:t.state)==null?void 0:o.show)||!1}onUpdate(t){return this.on("update",t)}}class Zo{constructor(n,t,o){p(this,"state");p(this,"emitUpdate");p(this,"preventHide",!1);p(this,"preventShow",!1);p(this,"shouldShow",({view:n,state:t,from:o,to:r})=>{const{doc:s,selection:i}=t,{empty:a}=i,l=!s.textBetween(o,r).length&&k.isTextSelection(t.selection);if(i.$from.parent.type.spec.code||k.isNodeSelection(i)&&i.node.type.spec.code||a||l)return!1;const c=document.activeElement;return!(!this.isElementWithinEditorWrapper(c)&&n.editable)});p(this,"blurHandler",n=>{var o;if(this.preventHide){this.preventHide=!1;return}const t=this.pmView.dom.parentElement;n&&n.relatedTarget&&(t===n.relatedTarget||t.contains(n.relatedTarget)||n.relatedTarget.matches(".bn-ui-container, .bn-ui-container *"))||(o=this.state)!=null&&o.show&&(this.state.show=!1,this.emitUpdate())});p(this,"isElementWithinEditorWrapper",n=>{if(!n)return!1;const t=this.pmView.dom.parentElement;return t?t.contains(n):!1});p(this,"viewMousedownHandler",n=>{(!this.isElementWithinEditorWrapper(n.target)||n.button===0)&&(this.preventShow=!0)});p(this,"mouseupHandler",()=>{this.preventShow&&(this.preventShow=!1,setTimeout(()=>this.update(this.pmView)))});p(this,"dragHandler",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())});p(this,"scrollHandler",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.referencePos=this.getSelectionBoundingBox(),this.emitUpdate())});p(this,"closeMenu",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())});this.editor=n,this.pmView=t,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized formatting toolbar");o(this.state)},t.dom.addEventListener("mousedown",this.viewMousedownHandler),t.root.addEventListener("mouseup",this.mouseupHandler),t.dom.addEventListener("dragstart",this.dragHandler),t.dom.addEventListener("dragover",this.dragHandler),t.dom.addEventListener("blur",this.blurHandler),t.root.addEventListener("scroll",this.scrollHandler,!0)}update(n,t){var f,m,g;const{state:o,composing:r}=n,{doc:s,selection:i}=o,a=t&&t.doc.eq(s)&&t.selection.eq(i);if(r||a)return;const{ranges:l}=i,c=Math.min(...l.map(b=>b.$from.pos)),d=Math.max(...l.map(b=>b.$to.pos)),u=this.shouldShow({view:n,state:o,from:c,to:d}),h=typeof Range.prototype.getClientRects>"u";if(!this.preventShow&&(u||this.preventHide)&&!h){const b={show:!0,referencePos:this.getSelectionBoundingBox()};(b.show!==((f=this.state)==null?void 0:f.show)||b.referencePos.toJSON()!==((m=this.state)==null?void 0:m.referencePos.toJSON()))&&(this.state=b,this.emitUpdate());return}if((g=this.state)!=null&&g.show&&!this.preventHide&&(!u||this.preventShow||!this.editor.isEditable)){this.state.show=!1,this.emitUpdate();return}}destroy(){this.pmView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.pmView.root.removeEventListener("mouseup",this.mouseupHandler),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:n}=this.pmView,{selection:t}=n,{ranges:o}=t,r=Math.min(...o.map(i=>i.$from.pos)),s=Math.max(...o.map(i=>i.$to.pos));if(k.isNodeSelection(t)){const i=this.pmView.nodeDOM(r);if(i)return i.getBoundingClientRect()}return k.posToDOMRect(this.pmView,r,s)}}const Qo=new y.PluginKey("FormattingToolbarPlugin");class er extends R{constructor(t){super();p(this,"view");p(this,"closeMenu",()=>this.view.closeMenu());this.addProsemirrorPlugin(new y.Plugin({key:Qo,view:o=>(this.view=new Zo(t,o,r=>{this.emit("update",r)}),this.view),props:{handleKeyDown:(o,r)=>r.key==="Escape"&&this.shown?(this.view.closeMenu(),!0):!1}}))}static key(){return"formattingToolbar"}get shown(){var t,o;return((o=(t=this.view)==null?void 0:t.state)==null?void 0:o.show)||!1}onUpdate(t){return this.on("update",t)}}const Ji=k.Node.create({name:"hardBreak",inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,priority:10,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:e}){return["br",k.mergeAttributes(this.options.HTMLAttributes,e)]},renderText(){return`
12
- `}}),rn=(e,n)=>{const t=e.resolve(n);if(t.depth<=1)return;const o=t.posAtIndex(t.index(t.depth-1),t.depth-1);return ke(e.resolve(o))},Ve=(e,n)=>{const t=e.resolve(n),o=t.index();if(o===0)return;const r=t.posAtIndex(o-1);return ke(e.resolve(r))},tr=(e,n)=>{for(;n.childContainer;){const t=n.childContainer.node,o=e.resolve(n.childContainer.beforePos+1).posAtIndex(t.childCount-1);n=ke(e.resolve(o))}return n},Xi=(e,n)=>e.isBlockContainer&&e.blockContent.node.type.spec.content==="inline*"&&e.blockContent.node.childCount>0&&n.isBlockContainer&&n.blockContent.node.type.spec.content==="inline*",Zi=(e,n,t,o)=>{if(!o.isBlockContainer)throw new Error(`Attempted to merge block at position ${o.bnBlock.beforePos} into previous block at position ${t.bnBlock.beforePos}, but next block is not a block container`);if(o.childContainer){const r=e.doc.resolve(o.childContainer.beforePos+1),s=e.doc.resolve(o.childContainer.afterPos-1),i=r.blockRange(s);if(n){const a=e.doc.resolve(o.bnBlock.beforePos);e.tr.lift(i,a.depth)}}if(n){if(!t.isBlockContainer)throw new Error(`Attempted to merge block at position ${o.bnBlock.beforePos} into previous block at position ${t.bnBlock.beforePos}, but previous block is not a block container`);n(e.tr.delete(t.blockContent.afterPos-1,o.blockContent.beforePos+1))}return!0},sn=e=>({state:n,dispatch:t})=>{const o=n.doc.resolve(e),r=ke(o),s=Ve(n.doc,r.bnBlock.beforePos);if(!s)return!1;const i=tr(n.doc,s);return Xi(i,r)?Zi(n,t,i,r):!1},Qi=k.Extension.create({priority:50,addKeyboardShortcuts(){const e=()=>this.editor.commands.first(({chain:o,commands:r})=>[()=>r.deleteSelection(),()=>r.undoInputRule(),()=>r.command(({state:s})=>{const i=E(s);if(!i.isBlockContainer)return!1;const a=s.selection.from===i.blockContent.beforePos+1,l=i.blockContent.node.type.name==="paragraph";return a&&!l?r.command(U(i.bnBlock.beforePos,{type:"paragraph",props:{}})):!1}),()=>r.command(({state:s})=>{const i=E(s);if(!i.isBlockContainer)return!1;const{blockContent:a}=i;return s.selection.from===a.beforePos+1?r.liftListItem("blockContainer"):!1}),()=>r.command(({state:s})=>{const i=E(s);if(!i.isBlockContainer)return!1;const{bnBlock:a,blockContent:l}=i,c=s.selection.from===l.beforePos+1,d=s.selection.empty,u=a.beforePos;return c&&d?o().command(sn(u)).scrollIntoView().run():!1}),()=>r.command(({state:s,dispatch:i})=>{const a=E(s);if(!a.isBlockContainer||!(s.selection.from===a.blockContent.beforePos+1)||Ve(s.doc,a.bnBlock.beforePos))return!1;const d=rn(s.doc,a.bnBlock.beforePos);if((d==null?void 0:d.blockNoteType)!=="column")return!1;const u=d,h=rn(s.doc,u.bnBlock.beforePos);if((h==null?void 0:h.blockNoteType)!=="columnList")throw new Error("parent of column is not a column list");const f=u.childContainer.node.childCount===1,m=f&&h.childContainer.node.childCount===2,g=h.childContainer.node.firstChild===u.bnBlock.node;if(i){const b=s.doc.slice(a.bnBlock.beforePos,a.bnBlock.afterPos,!1);if(m)if(g){s.tr.step(new he.ReplaceAroundStep(h.bnBlock.beforePos,h.bnBlock.afterPos,u.bnBlock.afterPos+1,h.bnBlock.afterPos-2,b,b.size,!1));const w=s.tr.doc.resolve(u.bnBlock.beforePos);s.tr.setSelection(y.TextSelection.between(w,w))}else{s.tr.step(new he.ReplaceAroundStep(h.bnBlock.beforePos,h.bnBlock.afterPos,h.bnBlock.beforePos+2,u.bnBlock.beforePos-1,b,0,!1));const w=s.tr.doc.resolve(s.tr.mapping.map(u.bnBlock.beforePos-1));s.tr.setSelection(y.TextSelection.between(w,w))}else if(f)if(g){s.tr.delete(u.bnBlock.beforePos,u.bnBlock.afterPos),s.tr.insert(h.bnBlock.beforePos,b.content);const w=s.tr.doc.resolve(h.bnBlock.beforePos);s.tr.setSelection(y.TextSelection.between(w,w))}else s.tr.delete(u.bnBlock.beforePos-1,u.bnBlock.beforePos+1);else{s.tr.delete(a.bnBlock.beforePos,a.bnBlock.afterPos),g?s.tr.insert(h.bnBlock.beforePos-1,b.content):s.tr.insert(u.bnBlock.beforePos-1,b.content);const w=s.tr.doc.resolve(u.bnBlock.beforePos-1);s.tr.setSelection(y.TextSelection.between(w,w))}}return!0}),()=>r.command(({state:s})=>{const i=E(s);if(!i.isBlockContainer)return!1;if(i.blockContent.node.childCount===0&&i.blockContent.node.type.spec.content==="inline*"){const l=Ve(s.doc,i.bnBlock.beforePos);if(!l||!l.isBlockContainer)return!1;let c=o();if(l.blockContent.node.type.spec.content==="tableRow+"){const m=i.bnBlock.beforePos-1-1-1-1-1;c=c.setTextSelection(m)}else if(l.blockContent.node.type.spec.content===""){const d=l.blockContent.afterPos-l.blockContent.node.nodeSize;c=c.setNodeSelection(d)}else{const d=l.blockContent.afterPos-l.blockContent.node.nodeSize;c=c.setTextSelection(d)}return c.deleteRange({from:i.bnBlock.beforePos,to:i.bnBlock.afterPos}).scrollIntoView().run()}return!1}),()=>r.command(({state:s})=>{const i=E(s);if(!i.isBlockContainer)throw new Error("todo");const a=s.selection.from===i.blockContent.beforePos+1,l=s.selection.empty,c=Ve(s.doc,i.bnBlock.beforePos);if(c&&a&&l){const d=tr(s.doc,c);if(!d.isBlockContainer)throw new Error("todo");if(d.blockContent.node.type.spec.content===""||d.blockContent.node.type.spec.content==="inline*"&&d.blockContent.node.childCount===0)return o().cut({from:i.bnBlock.beforePos,to:i.bnBlock.afterPos},d.bnBlock.afterPos).deleteRange({from:d.bnBlock.beforePos,to:d.bnBlock.afterPos}).run()}return!1})]),n=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.command(({state:r})=>{const s=E(r);if(!s.isBlockContainer)return!1;const{bnBlock:i,blockContent:a,childContainer:l}=s,{depth:c}=r.doc.resolve(i.beforePos),d=i.afterPos===r.doc.nodeSize-3,u=r.selection.from===a.afterPos-1,h=r.selection.empty;if(!d&&u&&h&&!(l!==void 0)){let m=c,g=i.afterPos+1,b=r.doc.resolve(g).depth;for(;b<m;)m=b,g+=2,b=r.doc.resolve(g).depth;return o.command(sn(g-1))}return!1})]),t=(o=!1)=>this.editor.commands.first(({commands:r,tr:s})=>[()=>r.command(({state:i})=>{const a=E(i);if(!a.isBlockContainer)return!1;const{bnBlock:l,blockContent:c}=a,{depth:d}=i.doc.resolve(l.beforePos),u=i.selection.$anchor.parentOffset===0,h=i.selection.anchor===i.selection.head,f=c.node.childCount===0,m=d>1;return u&&h&&f&&m?r.liftListItem("blockContainer"):!1}),()=>r.command(({state:i})=>{const a=E(i),l=this.options.editor.schema.blockSchema[a.blockNoteType].hardBreakShortcut??"shift+enter";if(l==="none")return!1;if(l==="shift+enter"&&o||l==="enter"){const c=s.storedMarks||s.selection.$head.marks().filter(d=>this.editor.extensionManager.splittableMarks.includes(d.type.name));return s.insert(s.selection.head,s.doc.type.schema.nodes.hardBreak.create()).ensureMarks(c),!0}return!1}),()=>r.command(({state:i,dispatch:a})=>{const l=E(i);if(!l.isBlockContainer)return!1;const{bnBlock:c,blockContent:d}=l,u=i.selection.$anchor.parentOffset===0,h=i.selection.anchor===i.selection.head,f=d.node.childCount===0;if(u&&h&&f){const m=c.afterPos,g=m+2;if(a){const b=i.schema.nodes.blockContainer.createAndFill();i.tr.insert(m,b).scrollIntoView(),i.tr.setSelection(new y.TextSelection(i.doc.resolve(g)))}return!0}return!1}),()=>r.command(({state:i,chain:a})=>{const l=E(i);if(!l.isBlockContainer)return!1;const{blockContent:c}=l,d=i.selection.$anchor.parentOffset===0;return c.node.childCount===0?!1:(a().deleteSelection().command(ho(i.selection.from,d,d)).run(),!0)})]);return{Backspace:e,Delete:n,Enter:()=>t(),"Shift-Enter":()=>t(!0),Tab:()=>{var o,r,s;return this.options.tabBehavior!=="prefer-indent"&&((o=this.options.editor.formattingToolbar)!=null&&o.shown||(r=this.options.editor.linkToolbar)!=null&&r.shown||(s=this.options.editor.filePanel)!=null&&s.shown)?!1:_o(this.options.editor)},"Shift-Tab":()=>{var o,r,s;return this.options.tabBehavior!=="prefer-indent"&&((o=this.options.editor.formattingToolbar)!=null&&o.shown||(r=this.options.editor.linkToolbar)!=null&&r.shown||(s=this.options.editor.filePanel)!=null&&s.shown)?!1:(this.editor.commands.liftListItem("blockContainer"),!0)},"Shift-Mod-ArrowUp":()=>(this.options.editor.moveBlocksUp(),!0),"Shift-Mod-ArrowDown":()=>(this.options.editor.moveBlocksDown(),!0),"Mod-z":()=>this.options.editor.undo(),"Mod-y":()=>this.options.editor.redo(),"Shift-Mod-z":()=>this.options.editor.redo()}}});class ea{constructor(n,t,o){p(this,"state");p(this,"emitUpdate");p(this,"menuUpdateTimer");p(this,"startMenuUpdateTimer");p(this,"stopMenuUpdateTimer");p(this,"mouseHoveredLinkMark");p(this,"mouseHoveredLinkMarkRange");p(this,"keyboardHoveredLinkMark");p(this,"keyboardHoveredLinkMarkRange");p(this,"linkMark");p(this,"linkMarkRange");p(this,"mouseOverHandler",n=>{if(this.mouseHoveredLinkMark=void 0,this.mouseHoveredLinkMarkRange=void 0,this.stopMenuUpdateTimer(),n.target instanceof HTMLAnchorElement&&n.target.nodeName==="A"){const t=n.target,o=this.pmView.posAtDOM(t,0)+1,r=this.pmView.state.doc.resolve(o),s=r.marks();for(const i of s)if(i.type.name===this.pmView.state.schema.mark("link").type.name){this.mouseHoveredLinkMark=i,this.mouseHoveredLinkMarkRange=k.getMarkRange(r,i.type,i.attrs)||void 0;break}}return this.startMenuUpdateTimer(),!1});p(this,"clickHandler",n=>{var o;const t=this.pmView.dom.parentElement;this.linkMark&&n&&n.target&&!(t===n.target||t.contains(n.target))&&(o=this.state)!=null&&o.show&&(this.state.show=!1,this.emitUpdate())});p(this,"scrollHandler",()=>{var n;this.linkMark!==void 0&&(n=this.state)!=null&&n.show&&(this.state.referencePos=k.posToDOMRect(this.pmView,this.linkMarkRange.from,this.linkMarkRange.to),this.emitUpdate())});p(this,"closeMenu",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())});this.editor=n,this.pmView=t,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized link toolbar");o(this.state)},this.startMenuUpdateTimer=()=>{this.menuUpdateTimer=setTimeout(()=>{this.update(this.pmView,void 0,!0)},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(n,t){var o;this.editor.transact(r=>{const s=O(r);r.insertText(t,this.linkMarkRange.from,this.linkMarkRange.to),r.addMark(this.linkMarkRange.from,this.linkMarkRange.from+t.length,s.mark("link",{href:n}))}),this.pmView.focus(),(o=this.state)!=null&&o.show&&(this.state.show=!1,this.emitUpdate())}deleteLink(){var n;this.editor.transact(t=>t.removeMark(this.linkMarkRange.from,this.linkMarkRange.to,this.linkMark.type).setMeta("preventAutolink",!0)),this.pmView.focus(),(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())}update(n,t,o=!1){var a;const{state:r}=n;if(t&&t.selection.from===r.selection.from&&t.selection.to===r.selection.to||!this.pmView.hasFocus())return;const i=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 l=this.pmView.state.selection.$from.marks();for(const c of l)if(c.type.name===this.pmView.state.schema.mark("link").type.name){this.keyboardHoveredLinkMark=c,this.keyboardHoveredLinkMarkRange=k.getMarkRange(this.pmView.state.selection.$from,c.type,c.attrs)||void 0;break}}if(this.mouseHoveredLinkMark&&o&&(this.linkMark=this.mouseHoveredLinkMark,this.linkMarkRange=this.mouseHoveredLinkMarkRange),this.keyboardHoveredLinkMark&&(this.linkMark=this.keyboardHoveredLinkMark,this.linkMarkRange=this.keyboardHoveredLinkMarkRange),this.linkMark&&this.editor.isEditable){this.state={show:!0,referencePos:k.posToDOMRect(this.pmView,this.linkMarkRange.from,this.linkMarkRange.to),url:this.linkMark.attrs.href,text:this.pmView.state.doc.textBetween(this.linkMarkRange.from,this.linkMarkRange.to)},this.emitUpdate();return}if((a=this.state)!=null&&a.show&&i&&(!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 nr=new y.PluginKey("LinkToolbarPlugin");class or extends R{constructor(t){super();p(this,"view");p(this,"editLink",(t,o)=>{this.view.editLink(t,o)});p(this,"deleteLink",()=>{this.view.deleteLink()});p(this,"startHideTimer",()=>{this.view.startMenuUpdateTimer()});p(this,"stopHideTimer",()=>{this.view.stopMenuUpdateTimer()});p(this,"closeMenu",()=>this.view.closeMenu());this.addProsemirrorPlugin(new y.Plugin({key:nr,view:o=>(this.view=new ea(t,o,r=>{this.emit("update",r)}),this.view),props:{handleKeyDown:(o,r)=>r.key==="Escape"&&this.shown?(this.view.closeMenu(),!0):!1}}))}static key(){return"linkToolbar"}onUpdate(t){return this.on("update",t)}get shown(){var t,o;return((o=(t=this.view)==null?void 0:t.state)==null?void 0:o.show)||!1}}const rr=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"],sr="https",ta=new y.PluginKey("node-selection-keyboard");class na extends R{static key(){return"nodeSelectionKeyboard"}constructor(){super(),this.addProsemirrorPlugin(new y.Plugin({key:ta,props:{handleKeyDown:(n,t)=>{if("node"in n.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=n.state.tr;return n.dispatch(o.insert(n.state.tr.selection.$to.after(),n.state.schema.nodes.paragraph.createChecked()).setSelection(new y.TextSelection(o.doc.resolve(n.state.tr.selection.$to.after()+1)))),!0}}return!1}}}))}}const oa=new y.PluginKey("blocknote-placeholder");class ra extends R{static key(){return"placeholder"}constructor(n,t){super(),this.addProsemirrorPlugin(new y.Plugin({key:oa,view:o=>{var c,d;const r=`placeholder-selector-${pn.v4()}`;o.dom.classList.add(r);const s=document.createElement("style"),i=n._tiptapEditor.options.injectNonce;i&&s.setAttribute("nonce",i),((c=n.prosemirrorView)==null?void 0:c.root)instanceof ShadowRoot?n.prosemirrorView.root.append(s):(d=n.prosemirrorView)==null||d.root.head.appendChild(s);const a=s.sheet,l=(u="")=>`.${r} .bn-block-content${u} .bn-inline-content:has(> .ProseMirror-trailingBreak:only-child):before`;try{const{default:u,emptyDocument:h,...f}=t;for(const[b,w]of Object.entries(f)){const C=`[data-content-type="${b}"]`;a.insertRule(`${l(C)} { content: ${JSON.stringify(w)}; }`)}const m="[data-is-only-empty-block]",g="[data-is-empty-and-focused]";a.insertRule(`${l(m)} { content: ${JSON.stringify(h)}; }`),a.insertRule(`${l(g)} { content: ${JSON.stringify(u)}; }`)}catch(u){console.warn("Failed to insert placeholder CSS rule - this is likely due to the browser not supporting certain CSS pseudo-element selectors (:has, :only-child:, or :before)",u)}return{destroy:()=>{var u,h;((u=n.prosemirrorView)==null?void 0:u.root)instanceof ShadowRoot?n.prosemirrorView.root.removeChild(s):(h=n.prosemirrorView)==null||h.root.head.removeChild(s)}}},props:{decorations:o=>{const{doc:r,selection:s}=o;if(!n.isEditable||!s.empty||s.$from.parent.type.spec.code)return;const i=[];o.doc.content.size===6&&i.push(D.Decoration.node(2,4,{"data-is-only-empty-block":"true"}));const a=s.$anchor,l=a.parent;if(l.content.size===0){const c=a.before();i.push(D.Decoration.node(c,c+l.nodeSize,{"data-is-empty-and-focused":"true"}))}return D.DecorationSet.create(r,i)}}}))}}const an=new y.PluginKey("previous-blocks"),sa={index:"index",level:"level",type:"type",depth:"depth","depth-change":"depth-change"};class ia extends R{static key(){return"previousBlockType"}constructor(){super();let n;this.addProsemirrorPlugin(new y.Plugin({key:an,view(t){return{update:async(o,r)=>{var s;((s=this.key)==null?void 0:s.getState(o.state).updatedBlocks.size)>0&&(n=setTimeout(()=>{o.dispatch(o.state.tr.setMeta(an,{clearUpdate:!0}))},0))},destroy:()=>{n&&clearTimeout(n)}}},state:{init(){return{prevTransactionOldBlockAttrs:{},currentTransactionOldBlockAttrs:{},updatedBlocks:new Set}},apply(t,o,r,s){if(o.currentTransactionOldBlockAttrs={},o.updatedBlocks.clear(),!t.docChanged||r.doc.eq(s.doc))return o;const i={},a=k.findChildren(r.doc,d=>d.attrs.id),l=new Map(a.map(d=>[d.node.attrs.id,d])),c=k.findChildren(s.doc,d=>d.attrs.id);for(const d of c){const u=l.get(d.node.attrs.id),h=u==null?void 0:u.node.firstChild,f=d.node.firstChild;if(u&&h&&f){const m={index:f.attrs.index,level:f.attrs.level,type:f.type.name,depth:s.doc.resolve(d.pos).depth};let g={index:h.attrs.index,level:h.attrs.level,type:h.type.name,depth:r.doc.resolve(u.pos).depth};i[d.node.attrs.id]=g,t.getMeta("numberedListIndexing")&&(d.node.attrs.id in o.prevTransactionOldBlockAttrs&&(g=o.prevTransactionOldBlockAttrs[d.node.attrs.id]),m.type==="numberedListItem"&&(g.index=m.index)),o.currentTransactionOldBlockAttrs[d.node.attrs.id]=g,JSON.stringify(g)!==JSON.stringify(m)&&(g["depth-change"]=g.depth-m.depth,o.updatedBlocks.add(d.node.attrs.id))}}return o.prevTransactionOldBlockAttrs=i,o}},props:{decorations(t){const o=this.getState(t);if(o.updatedBlocks.size===0)return;const r=[];return t.doc.descendants((s,i)=>{if(!s.attrs.id||!o.updatedBlocks.has(s.attrs.id))return;const a=o.currentTransactionOldBlockAttrs[s.attrs.id],l={};for(const[d,u]of Object.entries(a))l["data-prev-"+sa[d]]=u||"none";const c=D.Decoration.node(i,i+s.nodeSize,{...l});r.push(c)}),D.DecorationSet.create(t.doc,r)}}}))}}const ln=new y.PluginKey("blocknote-show-selection");class aa extends R{constructor(t){super();p(this,"enabled",!1);this.editor=t,this.addProsemirrorPlugin(new y.Plugin({key:ln,props:{decorations:o=>{const{doc:r,selection:s}=o;if(!this.enabled)return D.DecorationSet.empty;const i=D.Decoration.inline(s.from,s.to,{"data-show-selection":"true"});return D.DecorationSet.create(r,[i])}}}))}static key(){return"showSelection"}setEnabled(t){this.enabled!==t&&(this.enabled=t,this.editor.transact(o=>o.setMeta(ln,{})))}getEnabled(){return this.enabled}}function ir(e,n){var t,o;for(;e&&e.parentElement&&e.parentElement!==n.dom&&((t=e.getAttribute)==null?void 0:t.call(e,"data-node-type"))!=="blockContainer";)e=e.parentElement;if(((o=e.getAttribute)==null?void 0:o.call(e,"data-node-type"))==="blockContainer")return{node:e,id:e.getAttribute("data-id")}}class ae extends y.Selection{constructor(t,o){super(t,o);p(this,"nodes");const r=t.node();this.nodes=[],t.doc.nodesBetween(t.pos,o.pos,(s,i,a)=>{if(a!==null&&a.eq(r))return this.nodes.push(s),!1})}static create(t,o,r=o){return new ae(t.resolve(o),t.resolve(r))}content(){return new S.Slice(S.Fragment.from(this.nodes),0,0)}eq(t){if(!(t instanceof ae)||this.nodes.length!==t.nodes.length||this.from!==t.from||this.to!==t.to)return!1;for(let o=0;o<this.nodes.length;o++)if(!this.nodes[o].eq(t.nodes[o]))return!1;return!0}map(t,o){const r=o.mapResult(this.from),s=o.mapResult(this.to);return s.deleted?y.Selection.near(t.resolve(r.pos)):r.deleted?y.Selection.near(t.resolve(s.pos)):new ae(t.resolve(r.pos),t.resolve(s.pos))}toJSON(){return{type:"multiple-node",anchor:this.anchor,head:this.head}}}y.Selection.jsonID("multiple-node",ae);let Y;function la(e,n){let t,o;const r=n.resolve(e.from).node().type.spec.group==="blockContent",s=n.resolve(e.to).node().type.spec.group==="blockContent",i=Math.min(e.$anchor.depth,e.$head.depth);if(r&&s){const a=e.$from.start(i-1),l=e.$to.end(i-1);t=n.resolve(a-1).pos,o=n.resolve(l+1).pos}else t=e.from,o=e.to;return{from:t,to:o}}function cn(e,n,t=n){n===t&&(t+=e.state.doc.resolve(n+1).node().nodeSize);const o=e.domAtPos(n).node.cloneNode(!0),r=e.domAtPos(n).node,s=(u,h)=>Array.prototype.indexOf.call(u.children,h),i=s(r,e.domAtPos(n+1).node.parentElement),a=s(r,e.domAtPos(t-1).node.parentElement);for(let u=r.childElementCount-1;u>=0;u--)(u>a||u<i)&&o.removeChild(o.children[u]);ar(e.root),Y=o;const l=Y.getElementsByTagName("iframe");for(let u=0;u<l.length;u++){const h=l[u],f=h.parentElement;f&&f.removeChild(h)}const d=e.dom.className.split(" ").filter(u=>u!=="ProseMirror"&&u!=="bn-root"&&u!=="bn-editor").join(" ");Y.className=Y.className+" bn-drag-preview "+d,e.root instanceof ShadowRoot?e.root.appendChild(Y):e.root.body.appendChild(Y)}function ar(e){Y!==void 0&&(e instanceof ShadowRoot?e.removeChild(Y):e.body.removeChild(Y),Y=void 0)}function ca(e,n,t){if(!e.dataTransfer)return;const o=t.prosemirrorView;if(!o)return;const r=z(n.id,o.state.doc);if(!r)throw new Error(`Block with ID ${n.id} not found`);const s=r.posBeforeNode;if(s!=null){const i=o.state.selection,a=o.state.doc,{from:l,to:c}=la(i,a),d=l<=s&&s<c,u=i.$anchor.node()!==i.$head.node()||i instanceof ae;d&&u?(o.dispatch(o.state.tr.setSelection(ae.create(a,l,c))),cn(o,l,c)):(o.dispatch(o.state.tr.setSelection(y.NodeSelection.create(o.state.doc,s))),cn(o,s));const h=o.state.selection.content(),f=t.pmSchema,m=o.serializeForClipboard(h).dom.innerHTML,g=Ie(f,t),b=Go(h.content),w=g.exportBlocks(b,{}),C=ot(w);e.dataTransfer.clearData(),e.dataTransfer.setData("blocknote/html",m),e.dataTransfer.setData("text/html",w),e.dataTransfer.setData("text/plain",C),e.dataTransfer.effectAllowed="move",e.dataTransfer.setDragImage(Y,0,0)}}const Ce=.1;function St(e,n,t,o=!0){const r=e.root.elementsFromPoint(n.left+(t==="editor"?50:0),n.top);for(const s of r)if(e.dom.contains(s))return o&&s.closest("[data-node-type=columnList]")?St(e,{left:n.left+50,top:n.top},t,!1):ir(s,e)}function da(e,n,t){if(!n.dom.firstChild)return;const o=n.dom.firstChild.getBoundingClientRect(),r={left:e.x,top:e.y},s=r.left<o.left,i=r.left>o.right;t==="viewport"&&(s&&(r.left=o.left+10),i&&(r.left=o.right-10));let a=St(n,r,t);if(!i&&a){const l=a.node.getBoundingClientRect();r.left=l.right-10,a=St(n,r,"viewport",!1)}return a}class lr{constructor(n,t,o,r){p(this,"state");p(this,"emitUpdate");p(this,"mousePos");p(this,"hoveredBlock");p(this,"menuFrozen",!1);p(this,"isDragOrigin",!1);p(this,"updateState",n=>{this.state=n,this.emitUpdate(this.state)});p(this,"updateStateFromMousePos",()=>{var o,r,s,i;if(this.menuFrozen||!this.mousePos)return;const n=da(this.mousePos,this.pmView,this.sideMenuDetection);if(!n||!this.editor.isEditable){(o=this.state)!=null&&o.show&&(this.state.show=!1,this.updateState(this.state));return}if((r=this.state)!=null&&r.show&&((s=this.hoveredBlock)!=null&&s.hasAttribute("data-id"))&&((i=this.hoveredBlock)==null?void 0:i.getAttribute("data-id"))===n.id)return;this.hoveredBlock=n.node;const t=n.node.firstChild;if(t&&this.editor.isEditable){const a=t.getBoundingClientRect(),l=n.node.closest("[data-node-type=column]");this.updateState({show:!0,referencePos:new DOMRect(l?l.firstElementChild.getBoundingClientRect().x:this.pmView.dom.firstChild.getBoundingClientRect().x,a.y,a.width,a.height),block:this.editor.getBlock(this.hoveredBlock.getAttribute("data-id"))})}});p(this,"onDrop",n=>{var r,s;if(this.pmView.dragging===null)return;this.editor._tiptapEditor.commands.blur();const t=n.target instanceof Node&&((r=n.target instanceof HTMLElement?n.target:n.target.parentElement)==null?void 0:r.closest(".bn-editor"))||null;if(t&&(!this.isDragOrigin&&this.pmView.dom===t?this.pmView.dispatch(this.pmView.state.tr.setSelection(y.TextSelection.create(this.pmView.state.tr.doc,this.pmView.state.tr.selection.to))):this.isDragOrigin&&this.pmView.dom!==t&&setTimeout(()=>this.pmView.dispatch(this.pmView.state.tr.deleteSelection()),0)),this.sideMenuDetection==="editor"||n.synthetic||!((s=n.dataTransfer)!=null&&s.types.includes("blocknote/html")))return;const o=this.pmView.posAtCoords({left:n.clientX,top:n.clientY});if(!o||o.inside===-1){const i=this.createSyntheticEvent(n);this.pmView.dom.dispatchEvent(i)}});p(this,"onDragEnd",()=>{this.pmView.dragging=null});p(this,"onDragStart",n=>{var i;const t=(i=n.dataTransfer)==null?void 0:i.getData("blocknote/html");if(!t)return;if(this.pmView.dragging)throw new Error("New drag was started while an existing drag is ongoing");const o=document.createElement("div");o.innerHTML=t;const s=S.DOMParser.fromSchema(this.pmView.state.schema).parse(o,{topNode:this.pmView.state.schema.nodes.blockGroup.create()});this.pmView.dragging={slice:new S.Slice(s.content,0,0),move:!0}});p(this,"onDragOver",n=>{var o;if(this.sideMenuDetection==="editor"||n.synthetic||!((o=n.dataTransfer)!=null&&o.types.includes("blocknote/html")))return;const t=this.pmView.posAtCoords({left:n.clientX,top:n.clientY});if(!t||t.inside===-1&&this.pmView.dom.firstChild){const r=this.createSyntheticEvent(n);this.pmView.dom.dispatchEvent(r)}});p(this,"onKeyDown",n=>{var t;(t=this.state)!=null&&t.show&&this.editor.isFocused()&&(this.state.show=!1,this.emitUpdate(this.state))});p(this,"onMouseMove",n=>{var s;if(this.menuFrozen)return;this.mousePos={x:n.clientX,y:n.clientY};const t=this.pmView.dom.getBoundingClientRect(),o=this.mousePos.x>t.left&&this.mousePos.x<t.right&&this.mousePos.y>t.top&&this.mousePos.y<t.bottom,r=this.pmView.dom.parentElement;if(o&&n&&n.target&&!(r===n.target||r.contains(n.target))){(s=this.state)!=null&&s.show&&(this.state.show=!1,this.emitUpdate(this.state));return}this.updateStateFromMousePos()});p(this,"onScroll",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.referencePos=this.hoveredBlock.getBoundingClientRect(),this.emitUpdate(this.state))});this.editor=n,this.sideMenuDetection=t,this.pmView=o,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized side menu");r(this.state)},this.pmView.root.addEventListener("dragstart",this.onDragStart),this.pmView.root.addEventListener("dragover",this.onDragOver),this.pmView.root.addEventListener("drop",this.onDrop,!0),this.pmView.root.addEventListener("dragend",this.onDragEnd,!0),nt(),this.pmView.root.addEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.addEventListener("keydown",this.onKeyDown,!0),o.root.addEventListener("scroll",this.onScroll,!0)}createSyntheticEvent(n){const t=new Event(n.type,n),o=this.pmView.dom.firstChild.getBoundingClientRect();return t.clientX=n.clientX,t.clientY=n.clientY,n.clientX<o.left&&n.clientX>o.left-o.width*Ce?t.clientX=o.left+o.width*Ce/2:n.clientX>o.right&&n.clientX<o.right+o.width*Ce?t.clientX=o.right-o.width*Ce/2:(n.clientX<o.left||n.clientX>o.right)&&(t.clientX=o.left+Ce*o.width*2),t.clientY=Math.min(Math.max(n.clientY,o.top),o.top+o.height),t.dataTransfer=n.dataTransfer,t.preventDefault=()=>n.preventDefault(),t.synthetic=!0,t}update(n,t){var r;!t.doc.eq(this.pmView.state.doc)&&((r=this.state)!=null&&r.show)&&this.updateStateFromMousePos()}destroy(){var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate(this.state)),this.pmView.root.removeEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.removeEventListener("dragstart",this.onDragStart),this.pmView.root.removeEventListener("dragover",this.onDragOver),this.pmView.root.removeEventListener("drop",this.onDrop,!0),this.pmView.root.removeEventListener("dragend",this.onDragEnd,!0),this.pmView.root.removeEventListener("keydown",this.onKeyDown,!0),this.pmView.root.removeEventListener("scroll",this.onScroll,!0)}}const cr=new y.PluginKey("SideMenuPlugin");class dr extends R{constructor(t,o){super();p(this,"view");p(this,"blockDragStart",(t,o)=>{this.view&&(this.view.isDragOrigin=!0),ca(t,o,this.editor)});p(this,"blockDragEnd",()=>{this.editor.prosemirrorView&&ar(this.editor.prosemirrorView.root),this.view&&(this.view.isDragOrigin=!1)});p(this,"freezeMenu",()=>{this.view.menuFrozen=!0,this.view.state.show=!0,this.view.emitUpdate(this.view.state)});p(this,"unfreezeMenu",()=>{this.view.menuFrozen=!1,this.view.state.show=!1,this.view.emitUpdate(this.view.state)});this.editor=t,this.addProsemirrorPlugin(new y.Plugin({key:cr,view:r=>(this.view=new lr(t,o,r,s=>{this.emit("update",s)}),this.view)}))}static key(){return"sideMenu"}onUpdate(t){return this.on("update",t)}}const He=new Map;function ua(e){if(He.has(e))return He.get(e);const n=new he.Mapping;return e._tiptapEditor.on("transaction",({transaction:t})=>{n.appendMapping(t.mapping)}),e._tiptapEditor.on("destroy",()=>{He.delete(e)}),He.set(e,n),n}function ur(e,n,t="left"){const o=N.ySyncPluginKey.getState(e._tiptapEditor.state);if(!o){const s=ua(e),i=s.maps.length;return()=>s.slice(i).map(n,t==="left"?-1:1)}const r=N.absolutePositionToRelativePosition(n+(t==="right"?1:0),o.binding.type,o.binding.mapping);return()=>{const s=N.ySyncPluginKey.getState(e._tiptapEditor.state),i=N.relativePositionToAbsolutePosition(s.doc,s.binding.type,r,s.binding.mapping);if(i===null)throw new Error("Position not found, cannot track positions");return i+(t==="right"?-1:0)}}const pa=k.findParentNode(e=>e.type.name==="blockContainer");class ha{constructor(n,t){p(this,"state");p(this,"emitUpdate");p(this,"rootEl");p(this,"pluginState");p(this,"handleScroll",()=>{var n,t;if((n=this.state)!=null&&n.show){const o=(t=this.rootEl)==null?void 0:t.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);if(!o)return;this.state.referencePos=o.getBoundingClientRect(),this.emitUpdate(this.pluginState.triggerCharacter)}});p(this,"closeMenu",()=>{this.editor.transact(n=>n.setMeta(pe,null))});p(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.transact(n=>n.selection.from)}).run()});var o,r;this.editor=n,this.pluginState=void 0,this.emitUpdate=s=>{var i;if(!this.state)throw new Error("Attempting to update uninitialized suggestions menu");t(s,{...this.state,ignoreQueryLength:(i=this.pluginState)==null?void 0:i.ignoreQueryLength})},this.rootEl=(o=this.editor.prosemirrorView)==null?void 0:o.root,(r=this.rootEl)==null||r.addEventListener("scroll",this.handleScroll,!0)}update(n,t){var c;const o=pe.getState(t),r=pe.getState(n.state),s=o===void 0&&r!==void 0,i=o!==void 0&&r===void 0;if(!s&&!(o!==void 0&&r!==void 0)&&!i)return;if(this.pluginState=i?o:r,i||!this.editor.isEditable){this.state&&(this.state.show=!1),this.emitUpdate(this.pluginState.triggerCharacter);return}const l=(c=this.rootEl)==null?void 0:c.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);this.editor.isEditable&&l&&(this.state={show:!0,referencePos:l.getBoundingClientRect(),query:this.pluginState.query},this.emitUpdate(this.pluginState.triggerCharacter))}destroy(){var n;(n=this.rootEl)==null||n.removeEventListener("scroll",this.handleScroll,!0)}}const pe=new y.PluginKey("SuggestionMenuPlugin");class pr extends R{constructor(t){super();p(this,"view");p(this,"triggerCharacters",[]);p(this,"addTriggerCharacter",t=>{this.triggerCharacters.push(t)});p(this,"removeTriggerCharacter",t=>{this.triggerCharacters=this.triggerCharacters.filter(o=>o!==t)});p(this,"closeMenu",()=>this.view.closeMenu());p(this,"clearQuery",()=>this.view.clearQuery());const o=this.triggerCharacters;this.addProsemirrorPlugin(new y.Plugin({key:pe,view:()=>(this.view=new ha(t,(r,s)=>{this.emit(`update ${r}`,s)}),this.view),state:{init(){},apply:(r,s,i,a)=>{if(r.getMeta("orderedListIndexing")!==void 0||r.selection.$from.parent.type.spec.code)return s;const l=r.getMeta(pe);if(typeof l=="object"&&l!==null){s&&this.closeMenu();const d=ur(t,a.selection.from-l.triggerCharacter.length);return{triggerCharacter:l.triggerCharacter,deleteTriggerCharacter:l.deleteTriggerCharacter!==!1,queryStartPos:()=>d()+l.triggerCharacter.length,query:"",decorationId:`id_${Math.floor(Math.random()*4294967295)}`,ignoreQueryLength:l==null?void 0:l.ignoreQueryLength}}if(s===void 0)return s;if(a.selection.from!==a.selection.to||l===null||r.getMeta("focus")||r.getMeta("blur")||r.getMeta("pointer")||s.triggerCharacter!==void 0&&a.selection.from<s.queryStartPos()||!a.selection.$from.sameParent(a.doc.resolve(s.queryStartPos())))return;const c={...s};return c.query=a.doc.textBetween(s.queryStartPos(),a.selection.from),c}},props:{handleTextInput(r,s,i,a){if(s===i){const l=r.state.doc;for(const c of o){const d=c.length>1?l.textBetween(s-c.length,s)+a:a;if(c===d)return r.dispatch(r.state.tr.insertText(a)),r.dispatch(r.state.tr.setMeta(pe,{triggerCharacter:d}).scrollIntoView()),!0}}return!1},decorations(r){const s=this.getState(r);if(s===void 0)return null;if(!s.deleteTriggerCharacter){const i=pa(r.selection);if(i)return D.DecorationSet.create(r.doc,[D.Decoration.node(i.pos,i.pos+i.node.nodeSize,{nodeName:"span",class:"bn-suggestion-decorator","data-decoration-id":s.decorationId})])}return D.DecorationSet.create(r.doc,[D.Decoration.inline(s.queryStartPos()-s.triggerCharacter.length,s.queryStartPos(),{nodeName:"span",class:"bn-suggestion-decorator","data-decoration-id":s.decorationId})])}}}))}static key(){return"suggestionMenu"}onUpdate(t,o){return this.triggerCharacters.includes(t)||this.addTriggerCharacter(t),this.on(`update ${t}`,o)}get shown(){var t,o;return((o=(t=this.view)==null?void 0:t.state)==null?void 0:o.show)||!1}}function fa(e,n){e.suggestionMenus.addTriggerCharacter(n)}const ma=k.Mark.create({name:"insertion",inclusive:!1,excludes:"deletion modification insertion",addAttributes(){return{id:{default:null,validate:"number"}}},extendMarkSchema(e){return e.name!=="insertion"?{}:{blocknoteIgnore:!0,inclusive:!1,toDOM(n,t){return["ins",{"data-id":String(n.attrs.id),"data-inline":String(t),...!t&&{style:"display: contents"}},0]},parseDOM:[{tag:"ins",getAttrs(n){return n.dataset.id?{id:parseInt(n.dataset.id,10)}:!1}}]}}}),ga=k.Mark.create({name:"deletion",inclusive:!1,excludes:"insertion modification deletion",addAttributes(){return{id:{default:null,validate:"number"}}},extendMarkSchema(e){return e.name!=="deletion"?{}:{blocknoteIgnore:!0,inclusive:!1,toDOM(n,t){return["del",{"data-id":String(n.attrs.id),"data-inline":String(t),...!t&&{style:"display: contents"}},0]},parseDOM:[{tag:"del",getAttrs(n){return n.dataset.id?{id:parseInt(n.dataset.id,10)}:!1}}]}}}),ba=k.Mark.create({name:"modification",inclusive:!1,excludes:"deletion insertion",addAttributes(){return{id:{default:null,validate:"number"},type:{validate:"string"},attrName:{default:null,validate:"string|null"},previousValue:{default:null},newValue:{default:null}}},extendMarkSchema(e){return e.name!=="modification"?{}:{blocknoteIgnore:!0,inclusive:!1,toDOM(n,t){return[t?"span":"div",{"data-type":"modification","data-id":String(n.attrs.id),"data-mod-type":n.attrs.type,"data-mod-prev-val":JSON.stringify(n.attrs.previousValue),"data-mod-new-val":JSON.stringify(n.attrs.newValue)},0]},parseDOM:[{tag:"span[data-type='modification']",getAttrs(n){return n.dataset.id?{id:parseInt(n.dataset.id,10),type:n.dataset.modType,previousValue:n.dataset.modPrevVal,newValue:n.dataset.modNewVal}:!1}},{tag:"div[data-type='modification']",getAttrs(n){return n.dataset.id?{id:parseInt(n.dataset.id,10),type:n.dataset.modType,previousValue:n.dataset.modPrevVal}:!1}}]}}});let F;function dn(e){F||(F=document.createElement("div"),F.innerHTML="_",F.style.opacity="0",F.style.height="1px",F.style.width="1px",e instanceof Document?e.body.appendChild(F):e.appendChild(F))}function ka(e){F&&(e instanceof Document?e.body.removeChild(F):e.removeChild(F),F=void 0)}function Oe(e){return Array.prototype.indexOf.call(e.parentElement.childNodes,e)}function wa(e){let n=e;for(;n&&n.nodeName!=="TD"&&n.nodeName!=="TH"&&!n.classList.contains("tableWrapper");){if(n.classList.contains("ProseMirror"))return;const t=n.parentNode;if(!t||!(t instanceof Element))return;n=t}return n.nodeName==="TD"||n.nodeName==="TH"?{type:"cell",domNode:n,tbodyNode:n.closest("tbody")}:{type:"wrapper",domNode:n,tbodyNode:n.querySelector("tbody")}}function ya(e,n){const t=n.querySelectorAll(e);for(let o=0;o<t.length;o++)t[o].style.visibility="hidden"}class hr{constructor(n,t,o){p(this,"state");p(this,"emitUpdate");p(this,"tableId");p(this,"tablePos");p(this,"tableElement");p(this,"menuFrozen",!1);p(this,"mouseState","up");p(this,"prevWasEditable",null);p(this,"viewMousedownHandler",()=>{this.mouseState="down"});p(this,"mouseUpHandler",n=>{this.mouseState="up",this.mouseMoveHandler(n)});p(this,"mouseMoveHandler",n=>{var c,d,u,h,f,m,g;if(this.menuFrozen||this.mouseState==="selecting"||!(n.target instanceof Element)||!this.pmView.dom.contains(n.target))return;const t=wa(n.target);if((t==null?void 0:t.type)==="cell"&&this.mouseState==="down"&&!((c=this.state)!=null&&c.draggingState)){this.mouseState="selecting",(d=this.state)!=null&&d.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate());return}if(!t||!this.editor.isEditable){(u=this.state)!=null&&u.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate());return}if(!t.tbodyNode)return;const o=t.tbodyNode.getBoundingClientRect(),r=ir(t.domNode,this.pmView);if(!r)return;this.tableElement=r.node;let s;const i=this.editor.transact(b=>z(r.id,b.doc));if(!i)throw new Error(`Block with ID ${r.id} not found`);const a=B(i.node,this.editor.pmSchema,this.editor.schema.blockSchema,this.editor.schema.inlineContentSchema,this.editor.schema.styleSchema);if(To("table",a,this.editor)&&(this.tablePos=i.posBeforeNode+1,s=a),!s)return;this.tableId=r.id;const l=(h=t.domNode.closest(".tableWrapper"))==null?void 0:h.querySelector(".table-widgets-container");if((t==null?void 0:t.type)==="wrapper"){const b=n.clientY>=o.bottom-1&&n.clientY<o.bottom+20,w=n.clientX>=o.right-1&&n.clientX<o.right+20,C=n.clientX>o.right||n.clientY>o.bottom;this.state={...this.state,show:!0,showAddOrRemoveRowsButton:b,showAddOrRemoveColumnsButton:w,referencePosTable:o,block:s,widgetContainer:l,colIndex:C||(f=this.state)==null?void 0:f.colIndex,rowIndex:C||(m=this.state)==null?void 0:m.rowIndex,referencePosCell:C||(g=this.state)==null?void 0:g.referencePosCell}}else{const b=Oe(t.domNode),w=Oe(t.domNode.parentElement),C=t.domNode.getBoundingClientRect();if(this.state!==void 0&&this.state.show&&this.tableId===r.id&&this.state.rowIndex===w&&this.state.colIndex===b)return;this.state={show:!0,showAddOrRemoveColumnsButton:b===s.content.rows[0].cells.length-1,showAddOrRemoveRowsButton:w===s.content.rows.length-1,referencePosTable:o,block:s,draggingState:void 0,referencePosCell:C,colIndex:b,rowIndex:w,widgetContainer:l}}return this.emitUpdate(),!1});p(this,"dragOverHandler",n=>{var h;if(((h=this.state)==null?void 0:h.draggingState)===void 0)return;n.preventDefault(),n.dataTransfer.dropEffect="move",ya(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline",this.pmView.root);const t={left:Math.min(Math.max(n.clientX,this.state.referencePosTable.left+1),this.state.referencePosTable.right-1),top:Math.min(Math.max(n.clientY,this.state.referencePosTable.top+1),this.state.referencePosTable.bottom-1)},o=this.pmView.root.elementsFromPoint(t.left,t.top).filter(f=>f.tagName==="TD"||f.tagName==="TH");if(o.length===0)return;const r=o[0];let s=!1;const i=Oe(r.parentElement),a=Oe(r),l=this.state.draggingState.draggedCellOrientation==="row"?this.state.rowIndex:this.state.colIndex,d=(this.state.draggingState.draggedCellOrientation==="row"?i:a)!==l;(this.state.rowIndex!==i||this.state.colIndex!==a)&&(this.state.rowIndex=i,this.state.colIndex=a,this.state.referencePosCell=r.getBoundingClientRect(),s=!0);const u=this.state.draggingState.draggedCellOrientation==="row"?t.top:t.left;this.state.draggingState.mousePos!==u&&(this.state.draggingState.mousePos=u,s=!0),s&&this.emitUpdate(),d&&this.editor.transact(f=>f.setMeta(de,!0))});p(this,"dropHandler",n=>{if(this.mouseState="up",this.state===void 0||this.state.draggingState===void 0)return!1;if(this.state.rowIndex===void 0||this.state.colIndex===void 0)throw new Error("Attempted to drop table row or column, but no table block was hovered prior.");n.preventDefault();const{draggingState:t,colIndex:o,rowIndex:r}=this.state,s=this.state.block.content.columnWidths;if(t.draggedCellOrientation==="row"){if(!xn(this.state.block,t.originalIndex,r))return!1;const i=es(this.state.block,t.originalIndex,r);this.editor.updateBlock(this.state.block,{type:"table",content:{...this.state.block.content,rows:i}})}else{if(!Pn(this.state.block,t.originalIndex,o))return!1;const i=Qr(this.state.block,t.originalIndex,o),[a]=s.splice(t.originalIndex,1);s.splice(o,0,a),this.editor.updateBlock(this.state.block,{type:"table",content:{...this.state.block.content,columnWidths:s,rows:i}})}return this.editor.setTextCursorPosition(this.state.block.id),!0});this.editor=n,this.pmView=t,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized image toolbar");o(this.state)},t.dom.addEventListener("mousemove",this.mouseMoveHandler),t.dom.addEventListener("mousedown",this.viewMousedownHandler),window.addEventListener("mouseup",this.mouseUpHandler),t.root.addEventListener("dragover",this.dragOverHandler),t.root.addEventListener("drop",this.dropHandler)}update(){var r;if(!this.state||!this.state.show)return;if(this.state.block=this.editor.getBlock(this.state.block.id),!this.state.block||this.state.block.type!=="table"||!((r=this.tableElement)!=null&&r.isConnected)){this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate();return}const{height:n,width:t}=At(this.state.block);this.state.rowIndex!==void 0&&this.state.colIndex!==void 0&&(this.state.rowIndex>=n&&(this.state.rowIndex=n-1),this.state.colIndex>=t&&(this.state.colIndex=t-1));const o=this.tableElement.querySelector("tbody");if(!o)throw new Error("Table block does not contain a 'tbody' HTML element. This should never happen.");if(this.state.rowIndex!==void 0&&this.state.colIndex!==void 0){const i=o.children[this.state.rowIndex].children[this.state.colIndex];i?this.state.referencePosCell=i.getBoundingClientRect():(this.state.rowIndex=void 0,this.state.colIndex=void 0)}this.state.referencePosTable=o.getBoundingClientRect(),this.emitUpdate()}destroy(){this.pmView.dom.removeEventListener("mousemove",this.mouseMoveHandler),window.removeEventListener("mouseup",this.mouseUpHandler),this.pmView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.pmView.root.removeEventListener("dragover",this.dragOverHandler),this.pmView.root.removeEventListener("drop",this.dropHandler)}}const de=new y.PluginKey("TableHandlesPlugin");class fr extends R{constructor(t){super();p(this,"view");p(this,"colDragStart",t=>{if(this.view.state===void 0||this.view.state.colIndex===void 0)throw new Error("Attempted to drag table column, but no table block was hovered prior.");if(this.view.state.draggingState={draggedCellOrientation:"col",originalIndex:this.view.state.colIndex,mousePos:t.clientX},this.view.emitUpdate(),this.editor.transact(o=>o.setMeta(de,{draggedCellOrientation:this.view.state.draggingState.draggedCellOrientation,originalIndex:this.view.state.colIndex,newIndex:this.view.state.colIndex,tablePos:this.view.tablePos})),!this.editor.prosemirrorView)throw new Error("Editor view not initialized.");dn(this.editor.prosemirrorView.root),t.dataTransfer.setDragImage(F,0,0),t.dataTransfer.effectAllowed="move"});p(this,"rowDragStart",t=>{if(this.view.state===void 0||this.view.state.rowIndex===void 0)throw new Error("Attempted to drag table row, but no table block was hovered prior.");if(this.view.state.draggingState={draggedCellOrientation:"row",originalIndex:this.view.state.rowIndex,mousePos:t.clientY},this.view.emitUpdate(),this.editor.transact(o=>o.setMeta(de,{draggedCellOrientation:this.view.state.draggingState.draggedCellOrientation,originalIndex:this.view.state.rowIndex,newIndex:this.view.state.rowIndex,tablePos:this.view.tablePos})),!this.editor.prosemirrorView)throw new Error("Editor view not initialized.");dn(this.editor.prosemirrorView.root),t.dataTransfer.setDragImage(F,0,0),t.dataTransfer.effectAllowed="copyMove"});p(this,"dragEnd",()=>{if(this.view.state===void 0)throw new Error("Attempted to drag table row, but no table block was hovered prior.");if(this.view.state.draggingState=void 0,this.view.emitUpdate(),this.editor.transact(t=>t.setMeta(de,null)),!this.editor.prosemirrorView)throw new Error("Editor view not initialized.");ka(this.editor.prosemirrorView.root)});p(this,"freezeHandles",()=>{this.view.menuFrozen=!0});p(this,"unfreezeHandles",()=>{this.view.menuFrozen=!1});p(this,"getCellsAtRowHandle",(t,o)=>pt(t,o));p(this,"getCellsAtColumnHandle",(t,o)=>ht(t,o));p(this,"setCellSelection",(t,o,r=o)=>{const s=this.view;if(!s)throw new Error("Table handles view not initialized");const i=t.doc.resolve(s.tablePos+1),a=t.doc.resolve(i.posAtIndex(o.row)+1),l=t.doc.resolve(a.posAtIndex(o.col)),c=t.doc.resolve(i.posAtIndex(r.row)+1),d=t.doc.resolve(c.posAtIndex(r.col)),u=t.tr;return u.setSelection(new H.CellSelection(l,d)),t.apply(u)});p(this,"addRowOrColumn",(t,o)=>{this.editor.exec((r,s)=>{const i=this.setCellSelection(r,o.orientation==="row"?{row:t,col:0}:{row:0,col:t});return o.orientation==="row"?o.side==="above"?H.addRowBefore(i,s):H.addRowAfter(i,s):o.side==="left"?H.addColumnBefore(i,s):H.addColumnAfter(i,s)})});p(this,"removeRowOrColumn",(t,o)=>o==="row"?this.editor.exec((r,s)=>{const i=this.setCellSelection(r,{row:t,col:0});return H.deleteRow(i,s)}):this.editor.exec((r,s)=>{const i=this.setCellSelection(r,{row:0,col:t});return H.deleteColumn(i,s)}));p(this,"mergeCells",t=>this.editor.exec((o,r)=>{const s=t?this.setCellSelection(o,t.relativeStartCell,t.relativeEndCell):o;return H.mergeCells(s,r)}));p(this,"splitCell",t=>this.editor.exec((o,r)=>{const s=t?this.setCellSelection(o,t):o;return H.splitCell(s,r)}));p(this,"getCellSelection",()=>this.editor.transact(t=>{const o=t.selection;let r=o.$from,s=o.$to;if(wt(o)){const{ranges:m}=o;m.forEach(g=>{r=g.$from.min(r??g.$from),s=g.$to.max(s??g.$to)})}else if(r=t.doc.resolve(o.$from.pos-o.$from.parentOffset-1),s=t.doc.resolve(o.$to.pos-o.$to.parentOffset-1),r.pos===0||s.pos===0)return;const i=t.doc.resolve(r.pos-r.parentOffset-1),a=t.doc.resolve(s.pos-s.parentOffset-1),l=t.doc.resolve(i.pos-i.parentOffset-1),c=r.index(i.depth),d=i.index(l.depth),u=s.index(a.depth),h=a.index(l.depth),f=[];for(let m=d;m<=h;m++)for(let g=c;g<=u;g++)f.push({row:m,col:g});return{from:{row:d,col:c},to:{row:h,col:u},cells:f}}));p(this,"getMergeDirection",t=>this.editor.transact(o=>{const r=wt(o.selection)?o.selection:void 0;if(!r||!t||r.ranges.length<=1)return;const s=this.getCellSelection();if(s)return os(s.from,s.to,t)?"vertical":"horizontal"}));p(this,"cropEmptyRowsOrColumns",(t,o)=>ts(t,o));p(this,"addRowsOrColumns",(t,o,r)=>ns(t,o,r));this.editor=t,this.addProsemirrorPlugin(new y.Plugin({key:de,view:o=>(this.view=new hr(t,o,r=>{this.emit("update",r)}),this.view),props:{decorations:o=>{if(this.view===void 0||this.view.state===void 0||this.view.state.draggingState===void 0||this.view.tablePos===void 0)return;const r=this.view.state.draggingState.draggedCellOrientation==="row"?this.view.state.rowIndex:this.view.state.colIndex;if(r===void 0)return;const s=[],{block:i,draggingState:a}=this.view.state,{originalIndex:l,draggedCellOrientation:c}=a;if(r===l||!i||c==="row"&&!xn(i,l,r)||c==="col"&&!Pn(i,l,r))return D.DecorationSet.create(o.doc,s);const d=o.doc.resolve(this.view.tablePos+1);return this.view.state.draggingState.draggedCellOrientation==="row"?pt(this.view.state.block,r).forEach(({row:h,col:f})=>{const m=o.doc.resolve(d.posAtIndex(h)+1),g=o.doc.resolve(m.posAtIndex(f)+1),b=g.node(),w=g.pos+(r>l?b.nodeSize-2:0);s.push(D.Decoration.widget(w,()=>{const C=document.createElement("div");return C.className="bn-table-drop-cursor",C.style.left="0",C.style.right="0",r>l?C.style.bottom="-2px":C.style.top="-3px",C.style.height="4px",C}))}):ht(this.view.state.block,r).forEach(({row:h,col:f})=>{const m=o.doc.resolve(d.posAtIndex(h)+1),g=o.doc.resolve(m.posAtIndex(f)+1),b=g.node(),w=g.pos+(r>l?b.nodeSize-2:0);s.push(D.Decoration.widget(w,()=>{const C=document.createElement("div");return C.className="bn-table-drop-cursor",C.style.top="0",C.style.bottom="0",r>l?C.style.right="-2px":C.style.left="-3px",C.style.width="4px",C}))}),D.DecorationSet.create(o.doc,s)}}}))}static key(){return"tableHandles"}onUpdate(t){return this.on("update",t)}}const Ca=k.Extension.create({name:"textAlignment",addGlobalAttributes(){return[{types:["paragraph","heading","bulletListItem","numberedListItem","checkListItem","tableCell","tableHeader"],attributes:{textAlignment:{default:"left",parseHTML:e=>e.getAttribute("data-text-alignment"),renderHTML:e=>e.textAlignment==="left"?{}:{"data-text-alignment":e.textAlignment}}}}]}}),va=k.Extension.create({name:"blockTextColor",addGlobalAttributes(){return[{types:["blockContainer","tableCell","tableHeader"],attributes:{textColor:{default:M.textColor.default,parseHTML:e=>e.hasAttribute("data-text-color")?e.getAttribute("data-text-color"):M.textColor.default,renderHTML:e=>e.textColor===M.textColor.default?{}:{"data-text-color":e.textColor}}}}]}}),Sa=k.Extension.create({name:"trailingNode",addProseMirrorPlugins(){const e=new y.PluginKey(this.name);return[new y.Plugin({key:e,appendTransaction:(n,t,o)=>{const{doc:r,tr:s,schema:i}=o,a=e.getState(o),l=r.content.size-2,c=i.nodes.blockContainer,d=i.nodes.paragraph;if(a)return s.insert(l,c.create(void 0,d.create()))},state:{init:(n,t)=>{},apply:(n,t)=>{if(!n.docChanged)return t;let o=n.doc.lastChild;if(!o||o.type.name!=="blockGroup")throw new Error("Expected blockGroup");if(o=o.lastChild,!o||o.type.name!=="blockContainer")return!0;const r=o.firstChild;if(!r)throw new Error("Expected blockContent");return o.nodeSize>4||r.type.spec.content!=="inline*"}}})]}}),Ea={blockColor:"data-block-color",blockStyle:"data-block-style",id:"data-id",depth:"data-depth",depthChange:"data-depth-change"},Ba=k.Node.create({name:"blockContainer",group:"blockGroupChild bnBlock",content:"blockContent blockGroup?",priority:50,defining:!0,marks:"insertion modification deletion",parseHTML(){return[{tag:"div[data-node-type="+this.name+"]",getAttrs:e=>{if(typeof e=="string")return!1;const n={};for(const[t,o]of Object.entries(Ea))e.getAttribute(o)&&(n[t]=e.getAttribute(o));return n}},{tag:'div[data-node-type="blockOuter"]',skip:!0}]},renderHTML({HTMLAttributes:e}){var r;const n=document.createElement("div");n.className="bn-block-outer",n.setAttribute("data-node-type","blockOuter");for(const[s,i]of Object.entries(e))s!=="class"&&n.setAttribute(s,i);const t={...((r=this.options.domAttributes)==null?void 0:r.block)||{},...e},o=document.createElement("div");o.className=Q("bn-block",t.class),o.setAttribute("data-node-type",this.name);for(const[s,i]of Object.entries(t))s!=="class"&&o.setAttribute(s,i);return n.appendChild(o),{dom:n,contentDOM:o}}}),Ta=k.Node.create({name:"blockGroup",group:"childContainer",content:"blockGroupChild+",marks:"deletion insertion modification",parseHTML(){return[{tag:"div",getAttrs:e=>typeof e=="string"?!1:e.getAttribute("data-node-type")==="blockGroup"?null:!1}]},renderHTML({HTMLAttributes:e}){var o;const n={...((o=this.options.domAttributes)==null?void 0:o.blockGroup)||{},...e},t=document.createElement("div");t.className=Q("bn-block-group",n.class),t.setAttribute("data-node-type","blockGroup");for(const[r,s]of Object.entries(n))r!=="class"&&t.setAttribute(r,s);return{dom:t,contentDOM:t}}}),xa=k.Node.create({name:"doc",topNode:!0,content:"blockGroup",marks:"insertion modification deletion"});class Pa extends R{constructor({editor:t,collaboration:o}){super(t);p(this,"editor");p(this,"collaboration");p(this,"forkedState");this.editor=t,this.collaboration=o}static key(){return"ForkYDocPlugin"}findTypeInOtherYdoc(t,o){const r=t.doc;if(t._item===null){const s=Array.from(r.share.keys()).find(i=>r.share.get(i)===t);if(s==null)throw new Error("type does not exist in other ydoc");return o.get(s,t.constructor)}else{const s=t._item,i=o.store.clients.get(s.id.client)??[],a=ie.findIndexSS(i,s.id.clock);return i[a].content.type}}get isForkedFromRemote(){return this.forkedState!==void 0}fork(){if(this.isForkedFromRemote)return;const t=this.collaboration.fragment;if(!t)throw new Error("No fragment to fork from");const o=new ie.Doc;ie.applyUpdate(o,ie.encodeStateAsUpdate(t.doc));const r=this.findTypeInOtherYdoc(t,o);this.forkedState={undoStack:N.yUndoPluginKey.getState(this.editor.prosemirrorState).undoManager.undoStack,originalFragment:t,forkedFragment:r},this.editor._tiptapEditor.unregisterPlugin([N.yCursorPluginKey,N.yUndoPluginKey,N.ySyncPluginKey]),this.editor._tiptapEditor.registerPlugin(new Ct(r).plugins[0]),this.editor._tiptapEditor.registerPlugin(new vt({editor:this.editor}).plugins[0]),this.emit("forked",!0)}merge({keepChanges:t}){if(!this.forkedState)return;this.editor._tiptapEditor.unregisterPlugin(N.ySyncPluginKey),this.editor._tiptapEditor.unregisterPlugin(N.yUndoPluginKey);const{originalFragment:o,forkedFragment:r,undoStack:s}=this.forkedState;if(this.editor.extensions.ySyncPlugin=new Ct(o),this.editor.extensions.yCursorPlugin=new We(this.collaboration),this.editor.extensions.yUndoPlugin=new vt({editor:this.editor}),this.editor._tiptapEditor.registerPlugin(this.editor.extensions.ySyncPlugin.plugins[0]),this.editor._tiptapEditor.registerPlugin(this.editor.extensions.yCursorPlugin.plugins[0]),this.editor._tiptapEditor.registerPlugin(this.editor.extensions.yUndoPlugin.plugins[0]),N.yUndoPluginKey.getState(this.editor.prosemirrorState).undoManager.undoStack=s,t){const i=ie.encodeStateAsUpdate(r.doc,ie.encodeStateVector(o.doc));ie.applyUpdate(o.doc,i,this.editor)}this.forkedState=void 0,this.emit("forked",!1)}}const mr=e=>{var r;const n={},t=Ma(e);for(const s of t)n[s.name]=s;e.collaboration&&(n.ySyncPlugin=new Ct(e.collaboration.fragment),n.yUndoPlugin=new vt({editor:e.editor}),(r=e.collaboration.provider)!=null&&r.awareness&&(n.yCursorPlugin=new We(e.collaboration)),n.forkYDocPlugin=new Pa({editor:e.editor,collaboration:e.collaboration})),n.formattingToolbar=new er(e.editor),n.linkToolbar=new or(e.editor),n.sideMenu=new dr(e.editor,e.sideMenuDetection),n.suggestionMenus=new pr(e.editor),n.filePanel=new Xo(e.editor),n.placeholder=new ra(e.editor,e.placeholders),(e.animations??!0)&&(n.animations=new ia),e.tableHandles&&(n.tableHandles=new fr(e.editor)),n.nodeSelectionKeyboard=new na,n.showSelection=new aa(e.editor),e.comments&&(n.comments=new Yi(e.editor,e.comments.threadStore,Yo.name));const o=e.disableExtensions||[];for(const s of o)delete n[s];return n};let un=!1;const Ma=e=>{const n=[k.extensions.ClipboardTextSerializer,k.extensions.Commands,k.extensions.Editable,k.extensions.FocusEvents,k.extensions.Tabindex,Ar.Gapcursor,k.Extension.create({name:"dropCursor",addProseMirrorPlugins:()=>[e.dropCursor({width:5,color:"#ddeeff",editor:e.editor})]}),Te.configure({types:["blockContainer","columnList","column"],setIdAttribute:e.setIdAttribute}),Ji,Hr.Text,ma,ga,ba,Dr.Link.extend({inclusive:!1}).configure({defaultProtocol:sr,protocols:un?[]:rr}),...Object.values(e.styleSpecs).map(t=>t.implementation.mark.configure({editor:e.editor})),va,Ki,Ca,k.Extension.create({name:"OverrideEscape",addKeyboardShortcuts(){return{Escape:()=>e.editor.suggestionMenus.shown?!1:this.editor.commands.blur()}}}),xa,Ba.configure({editor:e.editor,domAttributes:e.domAttributes}),Qi.configure({editor:e.editor,tabBehavior:e.tabBehavior}),Ta.configure({domAttributes:e.domAttributes}),...Object.values(e.inlineContentSpecs).filter(t=>t.config!=="link"&&t.config!=="text").map(t=>t.implementation.node.configure({editor:e.editor})),...Object.values(e.blockSpecs).flatMap(t=>[...(t.implementation.requiredExtensions||[]).map(o=>o.configure({editor:e.editor,domAttributes:e.domAttributes})),t.implementation.node.configure({editor:e.editor,domAttributes:e.domAttributes})]),Wi(e.editor),$i(e.editor,e.pasteHandler||(t=>t.defaultPasteHandler())),Bi(e.editor),...e.trailingBlock===void 0||e.trailingBlock?[Sa]:[],...e.comments?[Yo]:[]];return un=!0,e.collaboration||n.push(Nr.History),n};function Ia(e,n){const t=[];return e.forEach((o,r,s)=>{s!==n&&t.push(o)}),S.Fragment.from(t)}function La(e,n){const t=[];for(let o=0;o<e.childCount;o++)if(e.child(o).type.name==="tableRow")if(t.length>0&&t[t.length-1].type.name==="table"){const r=t[t.length-1],s=r.copy(r.content.addToEnd(e.child(o)));t[t.length-1]=s}else{const r=n.nodes.table.createChecked(void 0,e.child(o));t.push(r)}else t.push(e.child(o));return e=S.Fragment.from(t),e}function Aa(e,n){let t=S.Fragment.from(e.content);if(t=La(t,n.state.schema),!Na(t,n))return new S.Slice(t,e.openStart,e.openEnd);for(let o=0;o<t.childCount;o++)if(t.child(o).type.spec.group==="blockContent"){const r=[t.child(o)];if(o+1<t.childCount&&t.child(o+1).type.name==="blockGroup"){const i=t.child(o+1).child(0).child(0);(i.type.name==="bulletListItem"||i.type.name==="numberedListItem"||i.type.name==="checkListItem")&&(r.push(t.child(o+1)),t=Ia(t,o+1))}const s=n.state.schema.nodes.blockContainer.createChecked(void 0,r);t=t.replaceChild(o,s)}return new S.Slice(t,e.openStart,e.openEnd)}function Na(e,n){var s,i;const t=e.childCount===1,o=((s=e.firstChild)==null?void 0:s.type.spec.content)==="inline*",r=((i=e.firstChild)==null?void 0:i.type.spec.content)==="tableRow+";if(t){if(o)return!1;if(r){const a=E(n.state);if(a.isBlockContainer)return!(a.blockContent.node.type.spec.content==="tableRow+")}}return!0}const qe=class qe extends k.Editor{constructor(t,o){super({...t,content:void 0});p(this,"_state");p(this,"mount",(t,o,r)=>{o?(this.options.element=o,this.createViewAlternative(t,r)):(this.destroy(),this.isInitialized=!1)});const r=this.schema;let s;const i=r.nodes.doc.createAndFill;r.nodes.doc.createAndFill=(...l)=>{if(s)return s;const c=i.apply(r.nodes.doc,l),d=JSON.parse(JSON.stringify(c.toJSON()));return d.content[0].content[0].attrs.id="initialBlockId",s=S.Node.fromJSON(r,d),s};let a;try{const l=t==null?void 0:t.content.map(c=>se(c,this.schema,o).toJSON());a=k.createDocument({type:"doc",content:[{type:"blockGroup",content:l}]},this.schema,this.options.parseOptions)}catch(l){throw console.error("Error creating document from blocks passed as `initialContent`. Caused by exception: ",l),new Error("Error creating document from blocks passed as `initialContent`:\n"+ +JSON.stringify(t.content))}this._state=y.EditorState.create({doc:a,schema:this.schema})}get state(){return this.view&&(this._state=this.view.state),this._state}dispatch(t){if(!this.view){this._state=this.state.apply(t),this.emit("transaction",{editor:this,transaction:t});return}if(this.view.isDestroyed)return;if(this.isCapturingTransaction){this.dispatchTransaction(t);return}const{state:o,transactions:r}=this.state.applyTransaction(t),s=!this.state.selection.eq(o.selection);this.emit("beforeTransaction",{editor:this,transaction:t,nextState:o}),this.view.updateState(o),this.emit("transaction",{editor:this,transaction:t}),s&&this.emit("selectionUpdate",{editor:this,transaction:t});const i=t.getMeta("focus"),a=t.getMeta("blur");i&&this.emit("focus",{editor:this,event:i.event,transaction:t}),a&&this.emit("blur",{editor:this,event:a.event,transaction:t}),!(!t.docChanged||t.getMeta("preventUpdate"))&&(this.emit("update",{editor:this,transaction:t}),this.emit("v3-update",{editor:this,transaction:t,appendedTransactions:r.slice(1)}))}forceEnablePlugins(){if(this.view)throw new Error("forcePluginsEnabled called after view has been initialized");this._state=this.state.reconfigure({plugins:this.extensionManager.plugins})}createViewAlternative(t,o){this.contentComponent=o;const r={};this.extensionManager.extensions.forEach(i=>{i.type==="mark"&&i.config.addMarkView&&(r[i.name]=i.config.addMarkView(t))}),this.view=new D.EditorView({mount:this.options.element},{...this.options.editorProps,dispatchTransaction:this.dispatch.bind(this),state:this.state,markViews:r,nodeViews:this.extensionManager.nodeViews});const s=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(s),this.commands.focus(this.options.autofocus||this.options.element.getAttribute("data-bn-autofocus")==="true",{scrollIntoView:!1}),this.emit("create",{editor:this}),this.isInitialized=!0}};p(qe,"create",(t,o)=>{var s,i;const r=(s=globalThis==null?void 0:globalThis.window)==null?void 0:s.setTimeout;typeof((i=globalThis==null?void 0:globalThis.window)==null?void 0:i.setTimeout)<"u"&&(globalThis.window.setTimeout=()=>0);try{return new qe(t,o)}finally{r&&(globalThis.window.setTimeout=r)}});let Ke=qe;Ke.prototype.createView=function(){this.options.onPaste=this.options.onDrop=void 0};const Da={enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!1};class qt extends rt{constructor(t){var c,d,u,h,f,m,g,b,w,C,v,I,_,K,x,T;super();p(this,"pmSchema");p(this,"extensions",{});p(this,"headless",!1);p(this,"_tiptapEditor");p(this,"elementRenderer",null);p(this,"blockCache",new WeakMap);p(this,"dictionary");p(this,"schema");p(this,"blockImplementations");p(this,"inlineContentImplementations");p(this,"styleImplementations");p(this,"formattingToolbar");p(this,"linkToolbar");p(this,"sideMenu");p(this,"suggestionMenus");p(this,"filePanel");p(this,"tableHandles");p(this,"comments");p(this,"showSelectionPlugin");p(this,"forkYDocPlugin");p(this,"uploadFile");p(this,"onUploadStartCallbacks",[]);p(this,"onUploadEndCallbacks",[]);p(this,"resolveFileUrl");p(this,"resolveUsers");p(this,"settings");p(this,"activeTransaction",null);p(this,"mount",(t,o)=>{this._tiptapEditor.mount(this,t,o)});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||_r.en,this.settings={tables:{splitCells:((c=t==null?void 0:t.tables)==null?void 0:c.splitCells)??!1,cellBackgroundColor:((d=t==null?void 0:t.tables)==null?void 0:d.cellBackgroundColor)??!1,cellTextColor:((u=t==null?void 0:t.tables)==null?void 0:u.cellTextColor)??!1,headers:((h=t==null?void 0:t.tables)==null?void 0:h.headers)??!1},codeBlock:{indentLineWithTab:((f=t==null?void 0:t.codeBlock)==null?void 0:f.indentLineWithTab)??!0,defaultLanguage:((m=t==null?void 0:t.codeBlock)==null?void 0:m.defaultLanguage)??"text",supportedLanguages:((g=t==null?void 0:t.codeBlock)==null?void 0:g.supportedLanguages)??{},createHighlighter:((b=t==null?void 0:t.codeBlock)==null?void 0:b.createHighlighter)??void 0},heading:{levels:((w=t==null?void 0:t.heading)==null?void 0:w.levels)??[1,2,3]}};const r={defaultStyles:!0,schema:t.schema||ye.create(),_headless:!1,...t,placeholders:{...this.dictionary.placeholders,...t.placeholders}};if(r.comments&&!r.resolveUsers)throw new Error("resolveUsers is required when using comments");this.resolveUsers=r.resolveUsers,this.schema=r.schema,this.blockImplementations=r.schema.blockSpecs,this.inlineContentImplementations=r.schema.inlineContentSpecs,this.styleImplementations=r.schema.styleSpecs,this.extensions=mr({editor:this,domAttributes:r.domAttributes||{},blockSpecs:this.schema.blockSpecs,styleSpecs:this.schema.styleSpecs,inlineContentSpecs:this.schema.inlineContentSpecs,collaboration:r.collaboration,trailingBlock:r.trailingBlock,disableExtensions:r.disableExtensions,setIdAttribute:r.setIdAttribute,animations:r.animations??!0,tableHandles:V("table",this),dropCursor:this.options.dropCursor??Rr.dropCursor,placeholders:r.placeholders,tabBehavior:r.tabBehavior,sideMenuDetection:r.sideMenuDetection||"viewport",comments:r.comments,pasteHandler:r.pasteHandler}),(((C=r._tiptapOptions)==null?void 0:C.extensions)||[]).forEach(L=>{this.extensions[L.name]=L});for(let L of r.extensions||[]){typeof L=="function"&&(L=L(this));const P=L.constructor.key();if(!P)throw new Error(`Extension ${L.constructor.name} does not have a key method`);if(this.extensions[P])throw new Error(`Extension ${L.constructor.name} already exists with key ${P}`);this.extensions[P]=L}if(Object.entries(r._extensions||{}).forEach(([L,P])=>{const te=typeof P=="function"?P(this):P;if(!("plugin"in te)){this.extensions[L]=te;return}this.extensions[L]=new class extends R{static key(){return L}constructor(){super(),this.addProsemirrorPlugin(te.plugin)}get priority(){return te.priority}}}),this.formattingToolbar=this.extensions.formattingToolbar,this.linkToolbar=this.extensions.linkToolbar,this.sideMenu=this.extensions.sideMenu,this.suggestionMenus=this.extensions.suggestionMenus,this.filePanel=this.extensions.filePanel,this.tableHandles=this.extensions.tableHandles,this.comments=this.extensions.comments,this.showSelectionPlugin=this.extensions.showSelection,this.forkYDocPlugin=this.extensions.forkYDocPlugin,r.uploadFile){const L=r.uploadFile;this.uploadFile=async(P,Ne)=>{this.onUploadStartCallbacks.forEach(te=>te.apply(this,[Ne]));try{return await L(P,Ne)}finally{this.onUploadEndCallbacks.forEach(te=>te.apply(this,[Ne]))}}}this.resolveFileUrl=r.resolveFileUrl,this.headless=r._headless;const s="ySyncPlugin"in this.extensions||"liveblocksExtension"in this.extensions;s&&r.initialContent&&console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider");const i=r.initialContent||(s?[{type:"paragraph",id:"initialBlockId"}]:[{type:"paragraph",id:Te.options.generateID()}]);if(!Array.isArray(i)||i.length===0)throw new Error("initialContent must be a non-empty array of blocks, received: "+i);const a=[...Object.entries(this.extensions).map(([L,P])=>{if(P instanceof k.Extension||P instanceof k.Node||P instanceof k.Mark)return P;if(!(P instanceof R&&!P.plugins.length))return k.Extension.create({name:L,priority:P.priority,addProseMirrorPlugins:()=>P.plugins})})].filter(L=>L!==void 0),l={...Da,...r._tiptapOptions,content:i,extensions:a,editorProps:{...(v=r._tiptapOptions)==null?void 0:v.editorProps,attributes:{tabIndex:"0",...(_=(I=r._tiptapOptions)==null?void 0:I.editorProps)==null?void 0:_.attributes,...(K=r.domAttributes)==null?void 0:K.editor,class:Q("bn-editor",r.defaultStyles?"bn-default-styles":"",((T=(x=r.domAttributes)==null?void 0:x.editor)==null?void 0:T.class)||"")},transformPasted:Aa}};this.headless?this.pmSchema=k.getSchema(l.extensions):(this._tiptapEditor=Ke.create(l,this.schema.styleSchema),this.pmSchema=this._tiptapEditor.schema),this.pmSchema.cached.blockNoteEditor=this,this.emit("create")}static create(t={}){return new qt(t)}exec(t){if(this.activeTransaction)throw new Error("`exec` should not be called within a `transact` call, move the `exec` call outside of the `transact` call");const o=this._tiptapEditor.state,r=this._tiptapEditor.view;return t(o,i=>this._tiptapEditor.dispatch(i),r)}canExec(t){if(this.activeTransaction)throw new Error("`canExec` should not be called within a `transact` call, move the `canExec` call outside of the `transact` call");const o=this._tiptapEditor.state,r=this._tiptapEditor.view;return t(o,void 0,r)}transact(t){if(this.activeTransaction)return t(this.activeTransaction);try{this.activeTransaction=this._tiptapEditor.state.tr;const o=t(this.activeTransaction),r=this.activeTransaction;return this.activeTransaction=null,r&&(r.docChanged||r.selectionSet||r.scrolledIntoView||r.storedMarksSet||!r.isGeneric)&&this._tiptapEditor.dispatch(r),o}finally{this.activeTransaction=null}}extension(t,o=t.key()){const r=this.extensions[o];if(!r)throw new Error(`Extension ${o} not found`);return r}get prosemirrorState(){if(this.activeTransaction)throw new Error("`prosemirrorState` should not be called within a `transact` call, move the `prosemirrorState` call outside of the `transact` call or use `editor.transact` to read the current editor state");return this._tiptapEditor.state}get prosemirrorView(){return this._tiptapEditor.view}get domElement(){var t;return(t=this.prosemirrorView)==null?void 0:t.dom}isFocused(){var t;return((t=this.prosemirrorView)==null?void 0:t.hasFocus())||!1}focus(){var t;(t=this.prosemirrorView)==null||t.focus()}onUploadStart(t){return this.onUploadStartCallbacks.push(t),()=>{const o=this.onUploadStartCallbacks.indexOf(t);o>-1&&this.onUploadStartCallbacks.splice(o,1)}}onUploadEnd(t){return this.onUploadEndCallbacks.push(t),()=>{const o=this.onUploadEndCallbacks.indexOf(t);o>-1&&this.onUploadEndCallbacks.splice(o,1)}}get topLevelBlocks(){return this.document}get document(){return this.transact(t=>bn(t.doc,this.pmSchema))}getBlock(t){return this.transact(o=>Vo(o.doc,t))}getPrevBlock(t){return this.transact(o=>Uo(o.doc,t))}getNextBlock(t){return this.transact(o=>Fo(o.doc,t))}getParentBlock(t){return this.transact(o=>$o(o.doc,t))}forEachBlock(t,o=!1){const r=this.document.slice();o&&r.reverse();function s(i){for(const a of i){if(t(a)===!1)return!1;const l=o?a.children.slice().reverse():a.children;if(!s(l))return!1}return!0}s(r)}onEditorContentChange(t){this._tiptapEditor.on("update",t)}onEditorSelectionChange(t){this._tiptapEditor.on("selectionUpdate",t)}getTextCursorPosition(){return this.transact(t=>fi(t))}setTextCursorPosition(t,o="start"){return this.transact(r=>zo(r,t,o))}getSelection(){return this.transact(t=>ui(t))}getSelectionCutBlocks(){return this.transact(t=>hi(t))}setSelection(t,o){return this.transact(r=>pi(r,t,o))}get isEditable(){if(!this._tiptapEditor){if(!this.headless)throw new Error("no editor, but also not headless?");return!1}return this._tiptapEditor.isEditable===void 0?!0:this._tiptapEditor.isEditable}set isEditable(t){if(!this._tiptapEditor){if(!this.headless)throw new Error("no editor, but also not headless?");return}this._tiptapEditor.options.editable!==t&&this._tiptapEditor.setEditable(t)}insertBlocks(t,o,r="before"){return this.transact(s=>Ln(s,t,o,r))}updateBlock(t,o){return this.transact(r=>An(r,t,o))}removeBlocks(t){return this.transact(o=>gt(o,t,[]).removedBlocks)}replaceBlocks(t,o){return this.transact(r=>gt(r,t,o))}undo(){return this.options.collaboration?this.exec(N.undoCommand):this.exec(jt.undo)}redo(){return this.options.collaboration?this.exec(N.redoCommand):this.exec(jt.redo)}insertInlineContent(t,{updateSelection:o=!1}={}){const r=W(t,this.pmSchema);this.transact(s=>{di(s,{from:s.selection.from,to:s.selection.to},r,{updateSelection:o})})}getActiveStyles(){return this.transact(t=>{const o={},r=t.selection.$to.marks();for(const s of r){const i=this.schema.styleSchema[s.type.name];if(!i){s.type.name!=="link"&&!s.type.spec.blocknoteIgnore&&console.warn("mark not found in styleschema",s.type.name);continue}i.propSchema==="boolean"?o[i.type]=!0:o[i.type]=s.attrs.stringValue}return o})}addStyles(t){for(const[o,r]of Object.entries(t)){const s=this.schema.styleSchema[o];if(!s)throw new Error(`style ${o} not found in styleSchema`);if(s.propSchema==="boolean")this._tiptapEditor.commands.setMark(o);else if(s.propSchema==="string")this._tiptapEditor.commands.setMark(o,{stringValue:r});else throw new j(s.propSchema)}}removeStyles(t){for(const o of Object.keys(t))this._tiptapEditor.commands.unsetMark(o)}toggleStyles(t){for(const[o,r]of Object.entries(t)){const s=this.schema.styleSchema[o];if(!s)throw new Error(`style ${o} not found in styleSchema`);if(s.propSchema==="boolean")this._tiptapEditor.commands.toggleMark(o);else if(s.propSchema==="string")this._tiptapEditor.commands.toggleMark(o,{stringValue:r});else throw new j(s.propSchema)}}getSelectedText(){return this.transact(t=>t.doc.textBetween(t.selection.from,t.selection.to))}getSelectedLinkUrl(){return this._tiptapEditor.getAttributes("link").href}createLink(t,o){if(t==="")return;const r=this.pmSchema.mark("link",{href:t});this.transact(s=>{const{from:i,to:a}=s.selection;o?s.insertText(o,i,a).addMark(i,i+o.length,r):s.setSelection(y.TextSelection.create(s.doc,a)).addMark(i,a,r)})}canNestBlock(){return li(this)}nestBlock(){_o(this)}canUnnestBlock(){return ci(this)}unnestBlock(){ai(this)}moveBlocksUp(){return ri(this)}moveBlocksDown(){return si(this)}async blocksToHTMLLossy(t=this.document){return Ie(this.pmSchema,this).exportBlocks(t,{})}async blocksToFullHTML(t){return _n(this.pmSchema,this).serializeBlocks(t,{})}async tryParseHTMLToBlocks(t){return $t(t,this.pmSchema)}async blocksToMarkdownLossy(t=this.document){return Wo(t,this.pmSchema,this,{})}async tryParseMarkdownToBlocks(t){return qo(t,this.pmSchema)}updateCollaborationUserInfo(t){if(!this.options.collaboration)throw new Error("Cannot update collaboration user info when collaboration is disabled.");this.extensions.yCursorPlugin.updateUser(t)}onChange(t){if(this.headless)return;const o=({transaction:r,appendedTransactions:s})=>{t(this,{getChanges:()=>In(r,s)})};return this._tiptapEditor.on("v3-update",o),()=>{this._tiptapEditor.off("v3-update",o)}}onSelectionChange(t,o){if(this.headless)return;const r=s=>{s.transaction.getMeta(N.ySyncPluginKey)&&!o||t(this)};return this._tiptapEditor.on("selectionUpdate",r),()=>{this._tiptapEditor.off("selectionUpdate",r)}}onCreate(t){return this.on("create",t),()=>{this.off("create",t)}}getSelectionBoundingBox(){if(!this.prosemirrorView)return;const{selection:t}=this.prosemirrorState,{ranges:o}=t,r=Math.min(...o.map(i=>i.$from.pos)),s=Math.max(...o.map(i=>i.$to.pos));if(k.isNodeSelection(t)){const i=this.prosemirrorView.nodeDOM(r);if(i)return i.getBoundingClientRect()}return k.posToDOMRect(this.prosemirrorView,r,s)}get isEmpty(){const t=this.document;return t.length===0||t.length===1&&t[0].type==="paragraph"&&t[0].content.length===0}openSuggestionMenu(t,o){this.prosemirrorView&&(this.focus(),this.transact(r=>{o!=null&&o.deleteTriggerCharacter&&r.insertText(t),r.scrollIntoView().setMeta(this.suggestionMenus.plugins[0],{triggerCharacter:t,deleteTriggerCharacter:(o==null?void 0:o.deleteTriggerCharacter)||!1,ignoreQueryLength:(o==null?void 0:o.ignoreQueryLength)||!1})}))}getForceSelectionVisible(){return this.showSelectionPlugin.getEnabled()}setForceSelectionVisible(t){this.showSelectionPlugin.setEnabled(t)}convertHtmlToBlockNoteHtml(t){return Ko(t.trim()).innerHTML}pasteHTML(t,o=!1){var s;let r=t;o||(r=this.convertHtmlToBlockNoteHtml(t)),r&&((s=this.prosemirrorView)==null||s.pasteHTML(r))}pasteText(t){var o;return(o=this.prosemirrorView)==null?void 0:o.pasteText(t)}async pasteMarkdown(t){return this.pasteHTML(await zt(t))}}const Ha={gray:{text:"#9b9a97",background:"#ebeced"},brown:{text:"#64473a",background:"#e9e5e3"},red:{text:"#e03e3e",background:"#fbe4e4"},orange:{text:"#d9730d",background:"#f6e9d9"},yellow:{text:"#dfab01",background:"#fbf3db"},green:{text:"#4d6461",background:"#ddedea"},blue:{text:"#0b6e99",background:"#ddebf1"},purple:{text:"#6940a5",background:"#eae4f2"},pink:{text:"#ad1a72",background:"#f4dfeb"}},Oa={gray:{text:"#bebdb8",background:"#9b9a97"},brown:{text:"#8e6552",background:"#64473a"},red:{text:"#ec4040",background:"#be3434"},orange:{text:"#e3790d",background:"#b7600a"},yellow:{text:"#dfab01",background:"#b58b00"},green:{text:"#6b8b87",background:"#4d6461"},blue:{text:"#0e87bc",background:"#0b6e99"},purple:{text:"#8552d7",background:"#6940a5"},pink:{text:"#da208f",background:"#ad1a72"}};class Ra{constructor(n,t,o){this.mappings=t,this.options=o}async resolveFile(n){var o;if(!((o=this.options)!=null&&o.resolveFileUrl))return(await fetch(n)).blob();const t=await this.options.resolveFileUrl(n);return t instanceof Blob?t:(await fetch(t)).blob()}mapStyles(n){return Object.entries(n).map(([o,r])=>this.mappings.styleMapping[o](r,this))}mapInlineContent(n){return this.mappings.inlineContentMapping[n.type](n,this)}transformInlineContent(n){return n.map(t=>this.mapInlineContent(t))}async mapBlock(n,t,o){return this.mappings.blockMapping[n.type](n,this,t,o)}}function _a(e){return{createBlockMapping:n=>n,createInlineContentMapping:n=>n,createStyleMapping:n=>n}}let Re;async function Va(){return Re||(Re=(async()=>{const[e,n]=await Promise.all([import("emoji-mart"),import("@emoji-mart/data")]),t="default"in e?e.default:e,o="default"in n?n.default:n;return await t.init({data:o}),{emojiMart:t,emojiData:o}})(),Re)}async function Ua(e,n){if(!Bo("text",e))return[];const{emojiData:t,emojiMart:o}=await Va();return(n.trim()===""?Object.values(t.emojis):await o.SearchIndex.search(n)).map(s=>({id:s.skins[0].native,onItemClick:()=>e.insertInlineContent(s.skins[0].native+" ")}))}function Fa(e,...n){const t=[...e];for(const o of n)for(const r of o){const s=t.findLastIndex(i=>i.group===r.group);s===-1?t.push(r):t.splice(s+1,0,r)}return t}exports.AudioBlock=Gn;exports.BlockNoteEditor=qt;exports.BlockNoteExtension=R;exports.BlockNoteSchema=ye;exports.COLORS_DARK_MODE_DEFAULT=Oa;exports.COLORS_DEFAULT=Ha;exports.CodeBlock=Jn;exports.DEFAULT_LINK_PROTOCOL=sr;exports.EMPTY_CELL_HEIGHT=_s;exports.EMPTY_CELL_WIDTH=Rt;exports.EventEmitter=rt;exports.Exporter=Ra;exports.FILE_AUDIO_ICON_SVG=$n;exports.FILE_ICON_SVG=Un;exports.FILE_IMAGE_ICON_SVG=so;exports.FILE_VIDEO_ICON_SVG=go;exports.FileBlock=no;exports.FilePanelProsemirrorPlugin=Xo;exports.FilePanelView=Jo;exports.FormattingToolbarProsemirrorPlugin=er;exports.FormattingToolbarView=Zo;exports.HTMLToBlocks=$t;exports.ImageBlock=po;exports.LinkToolbarProsemirrorPlugin=or;exports.PageBreak=Ao;exports.SideMenuProsemirrorPlugin=dr;exports.SideMenuView=lr;exports.SuggestionMenuProseMirrorPlugin=pr;exports.TableHandlesProsemirrorPlugin=fr;exports.TableHandlesView=hr;exports.UniqueID=Te;exports.UnreachableCaseError=j;exports.VALID_LINK_PROTOCOLS=rr;exports.VideoBlock=vo;exports.addInlineContentAttributes=ut;exports.addInlineContentKeyboardShortcuts=wn;exports.addStyleAttributes=En;exports.applyNonSelectableBlockFix=fn;exports.assertEmpty=jr;exports.audioBlockConfig=Wn;exports.audioParse=qn;exports.audioPropSchema=zn;exports.audioRender=Kn;exports.audioToExternalHTML=jn;exports.blockToNode=se;exports.blocksToMarkdown=Wo;exports.camelToDataKebab=Se;exports.checkBlockHasDefaultProp=Ys;exports.checkBlockIsDefaultType=To;exports.checkBlockIsFileBlock=qs;exports.checkBlockIsFileBlockWithPlaceholder=Gs;exports.checkBlockIsFileBlockWithPreview=js;exports.checkBlockTypeHasDefaultProp=xo;exports.checkDefaultBlockTypeInSchema=V;exports.checkDefaultInlineContentTypeInSchema=Bo;exports.checkPageBreakBlocksInSchema=No;exports.cleanHTMLToMarkdown=ot;exports.combineByGroup=Fa;exports.contentNodeToInlineContent=Pe;exports.contentNodeToTableContent=Pt;exports.createAddFileButton=Vn;exports.createBlockSpec=be;exports.createBlockSpecFromStronglyTypedTiptapNode=Z;exports.createDefaultBlockDOMOutputSpec=$;exports.createExternalHTMLExporter=Ie;exports.createFigureWithCaption=et;exports.createFileBlockWrapper=Qe;exports.createFileNameWithIcon=Fn;exports.createInlineContentSpec=Xr;exports.createInlineContentSpecFromTipTapNode=Cn;exports.createInternalBlockSpec=Tt;exports.createInternalHTMLSerializer=_n;exports.createInternalInlineContentSpec=yn;exports.createInternalStyleSpec=It;exports.createLinkWithCaption=Ae;exports.createResizableFileBlockWrapper=Ht;exports.createStronglyTypedTiptapNode=G;exports.createStyleSpec=Zr;exports.createStyleSpecFromTipTapMark=ne;exports.createSuggestionMenu=fa;exports.createToggleWrapper=Dt;exports.defaultBlockSchema=So;exports.defaultBlockSpecs=_t;exports.defaultBlockToHTML=dt;exports.defaultCodeBlockPropSchema=Yn;exports.defaultInlineContentSchema=Eo;exports.defaultInlineContentSpecs=Ut;exports.defaultProps=M;exports.defaultStyleSchema=Ks;exports.defaultStyleSpecs=Vt;exports.defaultToggledState=oo;exports.docToBlocks=bn;exports.fileBlockConfig=Zn;exports.fileParse=eo;exports.filePropSchema=Xn;exports.fileRender=Qn;exports.fileToExternalHTML=to;exports.filenameFromURL=Jr;exports.filterSuggestionItems=Qs;exports.formatKeyboardShortcut=J;exports.formattingToolbarPluginKey=Qo;exports.getBlock=Vo;exports.getBlockCache=Ze;exports.getBlockFromPos=Ge;exports.getBlockInfo=ee;exports.getBlockInfoFromResolvedPos=ke;exports.getBlockInfoFromSelection=E;exports.getBlockInfoFromTransaction=xe;exports.getBlockInfoWithManualOffset=Ye;exports.getBlockNoteExtensions=mr;exports.getBlockNoteSchema=we;exports.getBlockSchema=Je;exports.getBlockSchemaFromSpecs=xt;exports.getBlocksChangedByTransaction=In;exports.getColspan=me;exports.getDefaultEmojiPickerItems=Ua;exports.getDefaultSlashMenuItems=Zs;exports.getInlineContentParseRules=vn;exports.getInlineContentSchema=Xe;exports.getInlineContentSchemaFromSpecs=Mt;exports.getNearestBlockPos=X;exports.getNextBlock=Fo;exports.getNodeById=z;exports.getPageBreakSlashMenuItems=ti;exports.getParentBlock=$o;exports.getParseRules=mn;exports.getPmSchema=O;exports.getPrevBlock=Uo;exports.getRowspan=Fe;exports.getStyleParseRules=Bn;exports.getStyleSchema=ce;exports.getStyleSchemaFromSpecs=Lt;exports.imageBlockConfig=ao;exports.imageParse=co;exports.imagePropSchema=io;exports.imageRender=lo;exports.imageToExternalHTML=uo;exports.inheritedProps=Bt;exports.initializeESMDependencies=nt;exports.inlineContentToNodes=W;exports.insertBlocks=Ln;exports.insertOrUpdateBlock=A;exports.isAppleOS=hn;exports.isLinkInlineContent=ct;exports.isNodeBlock=ze;exports.isPartialLinkInlineContent=Et;exports.isPartialTableCell=fe;exports.isSafari=Gr;exports.isStyledTextInlineContent=oe;exports.isTableCell=je;exports.isTableCellSelection=wt;exports.linkToolbarPluginKey=nr;exports.mapTableCell=Ue;exports.mappingFactory=_a;exports.markdownToBlocks=qo;exports.markdownToHTML=zt;exports.mergeCSSClasses=Q;exports.mergeParagraphs=Yr;exports.nodeToBlock=B;exports.nodeToCustomInlineContent=$e;exports.pageBreakConfig=Po;exports.pageBreakParse=Io;exports.pageBreakRender=Mo;exports.pageBreakSchema=Ft;exports.pageBreakToExternalHTML=Lo;exports.parseEmbedElement=kt;exports.parseFigureElement=Le;exports.propsToAttributes=ge;exports.prosemirrorSliceToSlicedBlocks=kn;exports.removeAndInsertBlocks=gt;exports.selectedFragmentToHTML=Kt;exports.shikiHighlighterPromiseSymbol=_e;exports.shikiParserSymbol=bt;exports.sideMenuPluginKey=cr;exports.stylePropsToAttributes=Sn;exports.tableContentToNodes=Me;exports.tableHandlesPluginKey=de;exports.trackPosition=ur;exports.updateBlock=An;exports.updateBlockCommand=U;exports.updateBlockTr=Nt;exports.uploadToTmpFilesDotOrg_DEV_ONLY=Js;exports.videoBlockConfig=ko;exports.videoParse=yo;exports.videoPropSchema=bo;exports.videoRender=wo;exports.videoToExternalHTML=Co;exports.withPageBreak=ei;exports.wrapInBlockStructure=ve;
10
+ `),!0):e.chain().command(({tr:r})=>(r.delete(n.pos-2,n.pos),!0)).exitCode().run()},"Shift-Enter":({editor:e})=>{const{$from:n}=e.state.selection;return e.isActive(this.name)?(e.chain().insertContentAt(n.pos-n.parentOffset+n.parent.nodeSize,{type:"paragraph"}).run(),!0):!1}}}}),Xn=Z(fs,Jn);function st(e,n){var t;return(t=Object.entries(e.supportedLanguages).find(([o,{aliases:r}])=>(r==null?void 0:r.includes(n))||o===n))==null?void 0:t[0]}const ms=k.Mark.create({name:"backgroundColor",addAttributes(){return{stringValue:{default:void 0,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.stringValue})}}},parseHTML(){return[{tag:"span",getAttrs:e=>typeof e=="string"?!1:e.hasAttribute("data-background-color")?{stringValue:e.getAttribute("data-background-color")}:!1}]},renderHTML({HTMLAttributes:e}){return["span",e,0]}}),gs=ne(ms,"string"),bs=k.Mark.create({name:"textColor",addAttributes(){return{stringValue:{default:void 0,parseHTML:e=>e.getAttribute("data-text-color"),renderHTML:e=>({"data-text-color":e.stringValue})}}},parseHTML(){return[{tag:"span",getAttrs:e=>typeof e=="string"?!1:e.hasAttribute("data-text-color")?{stringValue:e.getAttribute("data-text-color")}:!1}]},renderHTML({HTMLAttributes:e}){return["span",e,0]}}),ks=ne(bs,"string"),bt=e=>({url:e.src||void 0}),Zn={backgroundColor:M.backgroundColor,name:{default:""},url:{default:""},caption:{default:""}},Qn={type:"file",propSchema:Zn,content:"none",isFileBlock:!0},eo=(e,n)=>Ze(e,n),to=e=>{if(e.tagName==="EMBED")return e.closest("figure")?void 0:bt(e);if(e.tagName==="FIGURE"){const n=Ie(e,"embed");if(!n)return;const{targetElement:t,caption:o}=n;return{...bt(t),caption:o}}},no=e=>{if(!e.props.url){const t=document.createElement("p");return t.textContent="Add file",{dom:t}}const n=document.createElement("a");return n.href=e.props.url,n.textContent=e.props.name||e.props.url,e.props.caption?Le(n,e.props.caption):{dom:n}},oo=be(Qn,{render:eo,parse:to,toExternalHTML:no}),ro={set:(e,n)=>window.localStorage.setItem(`toggle-${e.id}`,n?"true":"false"),get:e=>window.localStorage.getItem(`toggle-${e.id}`)==="true"},Dt=(e,n,t,o=ro)=>{if("isToggleable"in e.props&&!e.props.isToggleable)return{dom:t};const r=document.createElement("div"),s=document.createElement("div");s.className="bn-toggle-wrapper";const i=document.createElement("button");i.className="bn-toggle-button",i.type="button",i.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="CURRENTCOLOR"><path d="M320-200v-560l440 280-440 280Z"/></svg>';const a=m=>m.preventDefault();i.addEventListener("mousedown",a);const l=()=>{var m;s.getAttribute("data-show-children")==="true"?(s.setAttribute("data-show-children","false"),o.set(n.getBlock(e),!1),r.contains(c)&&r.removeChild(c)):(s.setAttribute("data-show-children","true"),o.set(n.getBlock(e),!0),((m=n.getBlock(e))==null?void 0:m.children.length)===0&&!r.contains(c)&&r.appendChild(c))};i.addEventListener("click",l),s.appendChild(i),s.appendChild(t);const c=document.createElement("button");c.className="bn-toggle-add-block-button",c.type="button",c.textContent="Empty toggle. Click to add a block.";const d=m=>m.preventDefault();c.addEventListener("mousedown",d);const u=()=>{n.transact(()=>{const m=n.updateBlock(e,{children:[{}]});n.setTextCursorPosition(m.children[0].id,"end"),n.focus()})};c.addEventListener("click",u),r.appendChild(s);let h=e.children.length;const f=n.onChange(()=>{var g;const m=((g=n.getBlock(e))==null?void 0:g.children.length)??0;m>h?(s.getAttribute("data-show-children")==="false"&&(s.setAttribute("data-show-children","true"),o.set(n.getBlock(e),!0)),r.contains(c)&&r.removeChild(c)):m===0&&m<h&&(s.getAttribute("data-show-children")==="true"&&(s.setAttribute("data-show-children","false"),o.set(n.getBlock(e),!1)),r.contains(c)&&r.removeChild(c)),h=m});return o.get(e)?(s.setAttribute("data-show-children","true"),e.children.length===0&&r.appendChild(c)):s.setAttribute("data-show-children","false"),{dom:r,ignoreMutation:m=>m instanceof MutationRecord&&(m.type==="attributes"&&m.target===s&&m.attributeName==="data-show-children"||m.type==="childList"&&(m.addedNodes[0]===c||m.removedNodes[0]===c)),destroy:()=>{i.removeEventListener("mousedown",a),i.removeEventListener("click",l),c.removeEventListener("mousedown",d),c.removeEventListener("click",u),f==null||f()}}},ws=[1,2,3,4,5,6],so={...M,level:{default:1,values:ws},isToggleable:{default:!1}},ys=G({name:"heading",content:"inline*",group:"blockContent",addAttributes(){return ge(so)},addInputRules(){return[...this.options.editor.settings.heading.levels.map(n=>new k.InputRule({find:new RegExp(`^(#{${n}})\\s$`),handler:({state:t,chain:o,range:r})=>{const s=E(t);!s.isBlockContainer||s.blockContent.node.type.spec.content!=="inline*"||o().command(U(s.bnBlock.beforePos,{type:"heading",props:{level:n}})).deleteRange({from:r.from,to:r.to}).run()}}))]},addKeyboardShortcuts(){const e=this.options.editor;return Object.fromEntries(e.settings.heading.levels.map(n=>[`Mod-Alt-${n}`,()=>{const t=E(this.editor.state);return!t.isBlockContainer||t.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(U(t.bnBlock.beforePos,{type:"heading",props:{level:n}}))}]))},parseHTML(){const e=this.options.editor;return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},...e.settings.heading.levels.map(n=>({tag:`h${n}`,attrs:{level:n},node:"heading"}))]},renderHTML({node:e,HTMLAttributes:n}){var t,o;return $(this.name,`h${e.attrs.level}`,{...((t=this.options.domAttributes)==null?void 0:t.blockContent)||{},...n},((o=this.options.domAttributes)==null?void 0:o.inlineContent)||{})},addNodeView(){return({node:e,HTMLAttributes:n,getPos:t})=>{var l,c;const{dom:o,contentDOM:r}=$(this.name,`h${e.attrs.level}`,{...((l=this.options.domAttributes)==null?void 0:l.blockContent)||{},...n},((c=this.options.domAttributes)==null?void 0:c.inlineContent)||{});o.removeChild(r);const s=this.options.editor,i=qe(t,s,this.editor,this.name),a=Dt(i,s,r);return o.appendChild(a.dom),{dom:o,contentDOM:r,ignoreMutation:a.ignoreMutation,destroy:a.destroy}}}}),Cs=Z(ys,so),Ht=(e,n,t,o,r,s)=>{const{dom:i,destroy:a}=Ze(e,n,t,r,s),l=i;e.props.url&&e.props.showPreview&&(e.props.previewWidth?l.style.width=`${e.props.previewWidth}px`:l.style.width="fit-content");const c=document.createElement("div");c.className="bn-resize-handle",c.style.left="4px";const d=document.createElement("div");d.className="bn-resize-handle",d.style.right="4px";let u,h=e.props.previewWidth;const f=v=>{var K,x;if(!u){!n.isEditable&&o.contains(c)&&o.contains(d)&&(o.removeChild(c),o.removeChild(d));return}let I;e.props.textAlignment==="center"?u.handleUsed==="left"?I=u.initialWidth+(u.initialClientX-v.clientX)*2:I=u.initialWidth+(v.clientX-u.initialClientX)*2:u.handleUsed==="left"?I=u.initialWidth+u.initialClientX-v.clientX:I=u.initialWidth+v.clientX-u.initialClientX,h=Math.min(Math.max(I,64),((x=(K=n.domElement)==null?void 0:K.firstElementChild)==null?void 0:x.clientWidth)||Number.MAX_VALUE),l.style.width=`${h}px`},m=v=>{(!v.target||!l.contains(v.target)||!n.isEditable)&&o.contains(c)&&o.contains(d)&&(o.removeChild(c),o.removeChild(d)),u&&(u=void 0,n.updateBlock(e,{props:{previewWidth:h}}))},g=()=>{n.isEditable&&(o.appendChild(c),o.appendChild(d))},b=v=>{v.relatedTarget===c||v.relatedTarget===d||u||n.isEditable&&o.contains(c)&&o.contains(d)&&(o.removeChild(c),o.removeChild(d))},w=v=>{v.preventDefault(),u={handleUsed:"left",initialWidth:l.clientWidth,initialClientX:v.clientX}},C=v=>{v.preventDefault(),u={handleUsed:"right",initialWidth:l.clientWidth,initialClientX:v.clientX}};return window.addEventListener("mousemove",f),window.addEventListener("mouseup",m),l.addEventListener("mouseenter",g),l.addEventListener("mouseleave",b),c.addEventListener("mousedown",w),d.addEventListener("mousedown",C),{dom:l,destroy:()=>{a==null||a(),window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",m),l.removeEventListener("mouseenter",g),l.removeEventListener("mouseleave",b),c.removeEventListener("mousedown",w),d.removeEventListener("mousedown",C)}}},Zt=e=>{const n=e.src||void 0,t=e.width||void 0;return{url:n,previewWidth:t}},io='<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>',ao={textAlignment:M.textAlignment,backgroundColor:M.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0},previewWidth:{default:void 0,type:"number"}},lo={type:"image",propSchema:ao,content:"none",isFileBlock:!0,fileBlockAccept:["image/*"]},co=(e,n)=>{const t=document.createElement("div");t.innerHTML=io;const o=document.createElement("div");o.className="bn-visual-media-wrapper";const r=document.createElement("img");return r.className="bn-visual-media",n.resolveFileUrl?n.resolveFileUrl(e.props.url).then(s=>{r.src=s}):r.src=e.props.url,r.alt=e.props.name||e.props.caption||"BlockNote image",r.contentEditable="false",r.draggable=!1,o.appendChild(r),Ht(e,n,{dom:o},o,n.dictionary.file_blocks.image.add_button_text,t.firstElementChild)},uo=e=>{if(e.tagName==="IMG")return e.closest("figure")?void 0:Zt(e);if(e.tagName==="FIGURE"){const n=Ie(e,"img");if(!n)return;const{targetElement:t,caption:o}=n;return{...Zt(t),caption:o}}},po=e=>{if(!e.props.url){const t=document.createElement("p");return t.textContent="Add image",{dom:t}}let n;return e.props.showPreview?(n=document.createElement("img"),n.src=e.props.url,n.alt=e.props.name||e.props.caption||"BlockNote image",e.props.previewWidth&&(n.width=e.props.previewWidth)):(n=document.createElement("a"),n.href=e.props.url,n.textContent=e.props.name||e.props.url),e.props.caption?e.props.showPreview?Qe(n,e.props.caption):Le(n,e.props.caption):{dom:n}},ho=be(lo,{render:co,parse:uo,toExternalHTML:po}),fo=(e,n,t)=>({state:o,dispatch:r})=>{const s=X(o.doc,e),i=ee(s);if(!i.isBlockContainer)throw new Error(`BlockContainer expected when calling splitBlock, position ${e}`);const a=[{type:i.bnBlock.node.type,attrs:t?{...i.bnBlock.node.attrs,id:void 0}:{}},{type:n?i.blockContent.node.type:o.schema.nodes.paragraph,attrs:t?{...i.blockContent.node.attrs}:{}}];return r&&o.tr.split(e,2,a),!0},et=e=>{const{blockInfo:n,selectionEmpty:t}=e.transact(s=>({blockInfo:Te(s),selectionEmpty:s.selection.anchor===s.selection.head}));if(!n.isBlockContainer)return!1;const{bnBlock:o,blockContent:r}=n;return!(r.node.type.name==="toggleListItem"||r.node.type.name==="bulletListItem"||r.node.type.name==="numberedListItem"||r.node.type.name==="checkListItem")||!t?!1:e._tiptapEditor.commands.first(({state:s,chain:i,commands:a})=>[()=>a.command(()=>r.node.childCount===0?a.command(U(o.beforePos,{type:"paragraph",props:{}})):!1),()=>a.command(()=>r.node.childCount>0?(i().deleteSelection().command(fo(s.selection.from,!0)).run(),!0):!1)])},vs={...M},Ss=G({name:"toggleListItem",content:"inline*",group:"blockContent",priority:90,addKeyboardShortcuts(){return{Enter:()=>et(this.options.editor),"Mod-Shift-6":()=>{const e=E(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(U(e.bnBlock.beforePos,{type:"toggleListItem",props:{}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"}]},renderHTML({HTMLAttributes:e}){var n,t;return $(this.name,"p",{...((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},...e},((t=this.options.domAttributes)==null?void 0:t.inlineContent)||{})},addNodeView(){return({HTMLAttributes:e,getPos:n})=>{var a,l;const{dom:t,contentDOM:o}=$(this.name,"p",{...((a=this.options.domAttributes)==null?void 0:a.blockContent)||{},...e},((l=this.options.domAttributes)==null?void 0:l.inlineContent)||{}),r=this.options.editor,s=qe(n,r,this.editor,this.name),i=Dt(s,r,o);return t.appendChild(i.dom),{dom:t,contentDOM:o,ignoreMutation:i.ignoreMutation,destroy:i.destroy}}}}),Es=Z(Ss,vs);function Ot(e,n,t){var u,h,f;const o=S.DOMParser.fromSchema(n),r=e,s=document.createElement("div");s.setAttribute("data-node-type","blockGroup");for(const m of Array.from(r.childNodes))s.appendChild(m.cloneNode(!0));let i=o.parse(s,{topNode:n.nodes.blockGroup.create()});((h=(u=i.firstChild)==null?void 0:u.firstChild)==null?void 0:h.type.name)==="checkListItem"&&(i=i.copy(i.content.cut(i.firstChild.firstChild.nodeSize+2)));const a=(f=i.firstChild)==null?void 0:f.firstChild;if(!(a!=null&&a.isTextblock))return S.Fragment.from(i);const l=n.nodes[t].create({},a.content),c=i.content.cut(a.nodeSize+2);if(c.size>0){const m=i.copy(c);return l.content.addToEnd(m)}return l.content}const Bs={...M},Ts=G({name:"bulletListItem",content:"inline*",group:"blockContent",priority:90,addInputRules(){return[new k.InputRule({find:new RegExp("^[-+*]\\s$"),handler:({state:e,chain:n,range:t})=>{const o=E(e);!o.isBlockContainer||o.blockContent.node.type.spec.content!=="inline*"||o.blockNoteType==="heading"||n().command(U(o.bnBlock.beforePos,{type:"bulletListItem",props:{}})).deleteRange({from:t.from,to:t.to})}})]},addKeyboardShortcuts(){return{Enter:()=>et(this.options.editor),"Mod-Shift-8":()=>{const e=E(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(U(e.bnBlock.beforePos,{type:"bulletListItem",props:{}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"li",getAttrs:e=>{var t;if(typeof e=="string")return!1;const n=e.parentElement;return n===null?!1:n.tagName==="UL"||n.tagName==="DIV"&&((t=n.parentElement)==null?void 0:t.tagName)==="UL"?{}:!1},getContent:(e,n)=>Ot(e,n,this.name),node:"bulletListItem"}]},renderHTML({HTMLAttributes:e}){var n,t;return $(this.name,"p",{...((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},...e},((t=this.options.domAttributes)==null?void 0:t.inlineContent)||{})}}),xs=Z(Ts,Bs),mo={...M,checked:{default:!1}},Ps=G({name:"checkListItem",content:"inline*",group:"blockContent",addAttributes(){return ge(mo)},addInputRules(){return[new k.InputRule({find:new RegExp("\\[\\s*\\]\\s$"),handler:({state:e,chain:n,range:t})=>{const o=E(e);!o.isBlockContainer||o.blockContent.node.type.spec.content!=="inline*"||n().command(U(o.bnBlock.beforePos,{type:"checkListItem",props:{checked:!1}})).deleteRange({from:t.from,to:t.to})}}),new k.InputRule({find:new RegExp("\\[[Xx]\\]\\s$"),handler:({state:e,chain:n,range:t})=>{const o=E(e);!o.isBlockContainer||o.blockContent.node.type.spec.content!=="inline*"||n().command(U(o.bnBlock.beforePos,{type:"checkListItem",props:{checked:!0}})).deleteRange({from:t.from,to:t.to})}})]},addKeyboardShortcuts(){return{Enter:()=>et(this.options.editor),"Mod-Shift-9":()=>{const e=E(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(U(e.bnBlock.beforePos,{type:"checkListItem",props:{}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"input",getAttrs:e=>typeof e=="string"||e.closest("[data-content-type]")||e.closest("li")?!1:e.type==="checkbox"?{checked:e.checked}:!1,node:"checkListItem"},{tag:"li",getAttrs:e=>{var t;if(typeof e=="string")return!1;const n=e.parentElement;if(n===null)return!1;if(n.tagName==="UL"||n.tagName==="DIV"&&((t=n.parentElement)==null?void 0:t.tagName)==="UL"){const o=e.querySelector("input[type=checkbox]")||null;return o===null?!1:{checked:o.checked}}return!1},getContent:(e,n)=>Ot(e,n,this.name),node:"checkListItem"}]},renderHTML({node:e,HTMLAttributes:n}){var s,i;const t=document.createElement("input");t.type="checkbox",t.checked=e.attrs.checked,e.attrs.checked&&t.setAttribute("checked","");const{dom:o,contentDOM:r}=$(this.name,"p",{...((s=this.options.domAttributes)==null?void 0:s.blockContent)||{},...n},((i=this.options.domAttributes)==null?void 0:i.inlineContent)||{});return o.insertBefore(t,r),{dom:o,contentDOM:r}},addNodeView(){return({node:e,getPos:n,editor:t,HTMLAttributes:o})=>{var d,u;const r=document.createElement("div"),s=document.createElement("div");s.contentEditable="false";const i=document.createElement("input");i.type="checkbox",i.checked=e.attrs.checked,e.attrs.checked&&i.setAttribute("checked","");const a=()=>{if(!t.isEditable){i.checked=!i.checked;return}if(typeof n!="boolean"){const h=X(t.state.doc,n());if(h.node.type.name!=="blockContainer")throw new Error(`Expected blockContainer node, got ${h.node.type.name}`);this.editor.commands.command(U(h.posBeforeNode,{type:"checkListItem",props:{checked:i.checked}}))}};i.addEventListener("change",a);const{dom:l,contentDOM:c}=$(this.name,"p",{...((d=this.options.domAttributes)==null?void 0:d.blockContent)||{},...o},((u=this.options.domAttributes)==null?void 0:u.inlineContent)||{});if(typeof n!="boolean"){const f="label-"+this.editor.state.doc.resolve(n()).node().attrs.id;i.setAttribute("aria-labelledby",f),c.id=f}return l.removeChild(c),l.appendChild(r),r.appendChild(s),r.appendChild(c),s.appendChild(i),{dom:l,contentDOM:c,destroy:()=>{i.removeEventListener("change",a)}}}}}),Ms=Z(Ps,mo),Is=new y.PluginKey("numbered-list-indexing"),Ls=()=>new y.Plugin({key:Is,appendTransaction:(e,n,t)=>{const o=t.tr;o.setMeta("numberedListIndexing",!0);let r=!1;return t.doc.descendants((s,i)=>{var a;if(s.type.name==="blockContainer"&&s.firstChild.type.name==="numberedListItem"){let l=`${s.firstChild.attrs.start||1}`;const c=ee({posBeforeNode:i,node:s});if(!c.isBlockContainer)throw new Error("impossible");const d=o.doc.resolve(c.bnBlock.beforePos).nodeBefore;if(d){const m=ee({posBeforeNode:c.bnBlock.beforePos-d.nodeSize,node:d});if(m.blockNoteType==="numberedListItem"){if(!m.isBlockContainer)throw new Error("impossible");const b=m.blockContent.node.attrs.index;l=(parseInt(b)+1).toString()}}const u=c.blockContent.node,h=u.attrs.index,f=((a=d==null?void 0:d.firstChild)==null?void 0:a.type.name)!=="numberedListItem";if(h!==l||u.attrs.start&&!f){r=!0;const{start:m,...g}=u.attrs;o.setNodeMarkup(c.blockContent.beforePos,void 0,{...g,index:l,...typeof m=="number"&&f&&{start:m}})}}}),r?o:null}}),go={...M,start:{default:void 0,type:"number"}},As=G({name:"numberedListItem",content:"inline*",group:"blockContent",priority:90,addAttributes(){return{...ge(go),index:{default:null,parseHTML:e=>e.getAttribute("data-index"),renderHTML:e=>({"data-index":e.index})}}},addInputRules(){return[new k.InputRule({find:new RegExp("^(\\d+)\\.\\s$"),handler:({state:e,chain:n,range:t,match:o})=>{const r=E(e);if(!r.isBlockContainer||r.blockContent.node.type.spec.content!=="inline*"||r.blockNoteType==="numberedListItem"||r.blockNoteType==="heading")return;const s=parseInt(o[1]);n().command(U(r.bnBlock.beforePos,{type:"numberedListItem",props:s===1&&{}||{start:s}})).deleteRange({from:t.from,to:t.to})}})]},addKeyboardShortcuts(){return{Enter:()=>et(this.options.editor),"Mod-Shift-7":()=>{const e=E(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(U(e.bnBlock.beforePos,{type:"numberedListItem",props:{}}))}}},addProseMirrorPlugins(){return[Ls()]},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"li",getAttrs:e=>{var t;if(typeof e=="string")return!1;const n=e.parentElement;if(n===null)return!1;if(n.tagName==="OL"||n.tagName==="DIV"&&((t=n.parentElement)==null?void 0:t.tagName)==="OL"){const o=parseInt(n.getAttribute("start")||"1")||1;return e.previousSibling||o===1?{}:{start:o}}return!1},getContent:(e,n)=>Ot(e,n,this.name),priority:300,node:"numberedListItem"}]},renderHTML({HTMLAttributes:e}){var n,t;return $(this.name,"p",{...((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},...e},((t=this.options.domAttributes)==null?void 0:t.inlineContent)||{})}}),Ns=Z(As,go),Ds={...M},Hs=G({name:"paragraph",content:"inline*",group:"blockContent",addKeyboardShortcuts(){return{"Mod-Alt-0":()=>{const e=E(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(U(e.bnBlock.beforePos,{type:"paragraph",props:{}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"p",getAttrs:e=>{var n;return typeof e=="string"||!((n=e.textContent)!=null&&n.trim())?!1:{}},node:"paragraph"}]},renderHTML({HTMLAttributes:e}){var n,t;return $(this.name,"p",{...((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},...e},((t=this.options.domAttributes)==null?void 0:t.inlineContent)||{})}}),Os=Z(Hs,Ds),Rs={...M},_s=G({name:"quote",content:"inline*",group:"blockContent",addInputRules(){return[new k.InputRule({find:new RegExp("^>\\s$"),handler:({state:e,chain:n,range:t})=>{const o=E(e);!o.isBlockContainer||o.blockContent.node.type.spec.content!=="inline*"||n().command(U(o.bnBlock.beforePos,{type:"quote",props:{}})).deleteRange({from:t.from,to:t.to})}})]},addKeyboardShortcuts(){return{"Mod-Alt-q":()=>{const e=E(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(U(e.bnBlock.beforePos,{type:"quote"}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"blockquote",node:"quote"}]},renderHTML({HTMLAttributes:e}){var n,t;return $(this.name,"blockquote",{...((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},...e},((t=this.options.domAttributes)==null?void 0:t.inlineContent)||{})}}),Vs=Z(_s,Rs),Us=35,Rt=120,Fs=31,$s=k.Extension.create({name:"BlockNoteTableExtension",addProseMirrorPlugins:()=>[H.columnResizing({cellMinWidth:Us,defaultCellMinWidth:Rt,View:null}),H.tableEditing()],addKeyboardShortcuts(){return{Enter:()=>this.editor.state.selection.empty&&this.editor.state.selection.$head.parent.type.name==="tableParagraph"?(this.editor.commands.insertContent({type:"hardBreak"}),!0):!1,Backspace:()=>{const e=this.editor.state.selection,n=e.empty,t=e.$head.parentOffset===0,o=e.$head.node().type.name==="tableParagraph";return n&&t&&o},Tab:()=>this.editor.commands.command(({state:e,dispatch:n,view:t})=>H.goToNextCell(1)(e,n,t)),"Shift-Tab":()=>this.editor.commands.command(({state:e,dispatch:n,view:t})=>H.goToNextCell(-1)(e,n,t))}},extendNodeSchema(e){const n={name:e.name,options:e.options,storage:e.storage};return{tableRole:k.callOrReturn(k.getExtensionField(e,"tableRole",n))}}}),zs={textColor:M.textColor},Ws=G({name:"table",content:"tableRow+",group:"blockContent",tableRole:"table",marks:"deletion insertion modification",isolating:!0,parseHTML(){return[{tag:"table"}]},renderHTML({HTMLAttributes:e}){var n,t;return $(this.name,"table",{...((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},...e},((t=this.options.domAttributes)==null?void 0:t.inlineContent)||{})},addNodeView(){return({node:e,HTMLAttributes:n})=>{var o;class t extends H.TableView{constructor(s,i,a){super(s,i),this.node=s,this.cellMinWidth=i,this.blockContentHTMLAttributes=a;const l=document.createElement("div");l.className=Q("bn-block-content",a.class),l.setAttribute("data-content-type","table");for(const[h,f]of Object.entries(a))h!=="class"&&l.setAttribute(h,f);const c=this.dom,d=document.createElement("div");d.className="tableWrapper-inner",d.appendChild(c.firstChild),c.appendChild(d),l.appendChild(c);const u=document.createElement("div");u.className="table-widgets-container",u.style.position="relative",c.appendChild(u),this.dom=l}ignoreMutation(s){return!s.target.closest(".tableWrapper-inner")||super.ignoreMutation(s)}}return new t(e,Rt,{...((o=this.options.domAttributes)==null?void 0:o.blockContent)||{},...n})}}}),Ks=G({name:"tableParagraph",group:"tableContent",content:"inline*",parseHTML(){return[{tag:"p",getAttrs:e=>{if(typeof e=="string"||!e.textContent||!e.closest("[data-content-type]"))return!1;const n=e.parentElement;return n===null?!1:n.tagName==="TD"||n.tagName==="TH"?{}:!1},node:"tableParagraph"}]},renderHTML({HTMLAttributes:e}){return["p",e,0]}}),qs=k.Node.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)+",tableRole:"row",marks:"deletion insertion modification",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:e}){return["tr",k.mergeAttributes(this.options.HTMLAttributes,e),0]}});function Qt(e,n){const o=S.DOMParser.fromSchema(n).parse(e,{topNode:n.nodes.blockGroup.create()}),r=[];return o.content.descendants(s=>{if(s.isInline)return r.push(s),!1}),S.Fragment.fromArray(r)}const js=Z(Ws,zs,[$s,Ks,Ar.TableHeader.extend({content:"tableContent+",parseHTML(){return[{tag:"th",getContent:(e,n)=>Qt(e,n)}]}}),Lr.TableCell.extend({content:"tableContent+",parseHTML(){return[{tag:"td",getContent:(e,n)=>Qt(e,n)}]}}),qs]),en=e=>{const n=e.src||void 0,t=e.width||void 0;return{url:n,previewWidth:t}},bo='<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>',ko={textAlignment:M.textAlignment,backgroundColor:M.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0},previewWidth:{default:void 0,type:"number"}},wo={type:"video",propSchema:ko,content:"none",isFileBlock:!0,fileBlockAccept:["video/*"]},yo=(e,n)=>{const t=document.createElement("div");t.innerHTML=bo;const o=document.createElement("div");o.className="bn-visual-media-wrapper";const r=document.createElement("video");return r.className="bn-visual-media",n.resolveFileUrl?n.resolveFileUrl(e.props.url).then(s=>{r.src=s}):r.src=e.props.url,r.controls=!0,r.contentEditable="false",r.draggable=!1,r.width=e.props.previewWidth,o.appendChild(r),Ht(e,n,{dom:o},o,n.dictionary.file_blocks.video.add_button_text,t.firstElementChild)},Co=e=>{if(e.tagName==="VIDEO")return e.closest("figure")?void 0:en(e);if(e.tagName==="FIGURE"){const n=Ie(e,"video");if(!n)return;const{targetElement:t,caption:o}=n;return{...en(t),caption:o}}},vo=e=>{if(!e.props.url){const t=document.createElement("p");return t.textContent="Add video",{dom:t}}let n;return e.props.showPreview?(n=document.createElement("video"),n.src=e.props.url,e.props.previewWidth&&(n.width=e.props.previewWidth)):(n=document.createElement("a"),n.href=e.props.url,n.textContent=e.props.name||e.props.url),e.props.caption?e.props.showPreview?Qe(n,e.props.caption):Le(n,e.props.caption):{dom:n}},So=be(wo,{render:yo,parse:Co,toExternalHTML:vo}),_t={paragraph:Os,heading:Cs,quote:Vs,codeBlock:Xn,toggleListItem:Es,bulletListItem:xs,numberedListItem:Ns,checkListItem:Ms,table:js,file:oo,image:ho,video:So,audio:Yn},Eo=Tt(_t),Vt={bold:ne(Fr.default,"boolean"),italic:ne(zr.default,"boolean"),underline:ne(Kr.default,"boolean"),strike:ne(Wr.default,"boolean"),code:ne($r.default,"boolean"),textColor:ks,backgroundColor:gs},Gs=It(Vt),Ut={text:{config:"text",implementation:{}},link:{config:"link",implementation:{}}},Bo=Pt(Ut);function V(e,n){return e in n.schema.blockSchema&&n.schema.blockSchema[e]===Eo[e]}function Ys(e,n,t){return e in t.schema.blockSchema&&t.schema.blockSchema[e]===n}function To(e,n){return e in n.schema.inlineContentSchema&&n.schema.inlineContentSchema[e]===Bo[e]}function Js(e,n,t){return e in t.schema.inlineContentSchema&&t.schema.inlineContentSchema[e]===n}function xo(e,n,t){return n.type===e&&n.type in t.schema.blockSchema&&V(n.type,t)}function Xs(e,n){return e.type in n.schema.blockSchema&&n.schema.blockSchema[e.type].isFileBlock||!1}function Zs(e,n){return e.type in n.schema.blockSchema&&n.schema.blockSchema[e.type].isFileBlock&&"showPreview"in n.schema.blockSchema[e.type].propSchema||!1}function Qs(e,n){return n.schema.blockSchema[e.type].isFileBlock&&!e.props.url}function Po(e,n,t){return n in t.schema.blockSchema&&e in t.schema.blockSchema[n].propSchema&&t.schema.blockSchema[n].propSchema[e]===M[e]}function ei(e,n,t){return Po(e,n.type,t)}function kt(e){return e instanceof H.CellSelection}const ti=async e=>{const n=new FormData;return n.append("file",e),(await(await fetch("https://tmpfiles.org/api/v1/upload",{method:"POST",body:n})).json()).data.url.replace("tmpfiles.org/","tmpfiles.org/dl/")};function ni(e){let n=e.getTextCursorPosition().block,t=e.schema.blockSchema[n.type].content;for(;t==="none";){if(n=e.getTextCursorPosition().nextBlock,n===void 0)return;t=e.schema.blockSchema[n.type].content,e.setTextCursorPosition(n,"end")}}function A(e,n){const t=e.getTextCursorPosition().block;if(t.content===void 0)throw new Error("Slash Menu open in a block that doesn't contain content.");let o;return Array.isArray(t.content)&&(t.content.length===1&&oe(t.content[0])&&t.content[0].type==="text"&&t.content[0].text==="/"||t.content.length===0)?(o=e.updateBlock(t,n),e.setTextCursorPosition(o)):(o=e.insertBlocks([n],t,"after")[0],e.setTextCursorPosition(e.getTextCursorPosition().nextBlock)),ni(e),o}function oi(e){const n=[];return V("heading",e)&&n.push({onItemClick:()=>{A(e,{type:"heading",props:{level:1}})},badge:J("Mod-Alt-1"),key:"heading",...e.dictionary.slash_menu.heading},{onItemClick:()=>{A(e,{type:"heading",props:{level:2}})},badge:J("Mod-Alt-2"),key:"heading_2",...e.dictionary.slash_menu.heading_2},{onItemClick:()=>{A(e,{type:"heading",props:{level:3}})},badge:J("Mod-Alt-3"),key:"heading_3",...e.dictionary.slash_menu.heading_3}),V("quote",e)&&n.push({onItemClick:()=>{A(e,{type:"quote"})},key:"quote",...e.dictionary.slash_menu.quote}),V("toggleListItem",e)&&n.push({onItemClick:()=>{A(e,{type:"toggleListItem"})},badge:J("Mod-Shift-6"),key:"toggle_list",...e.dictionary.slash_menu.toggle_list}),V("numberedListItem",e)&&n.push({onItemClick:()=>{A(e,{type:"numberedListItem"})},badge:J("Mod-Shift-7"),key:"numbered_list",...e.dictionary.slash_menu.numbered_list}),V("bulletListItem",e)&&n.push({onItemClick:()=>{A(e,{type:"bulletListItem"})},badge:J("Mod-Shift-8"),key:"bullet_list",...e.dictionary.slash_menu.bullet_list}),V("checkListItem",e)&&n.push({onItemClick:()=>{A(e,{type:"checkListItem"})},badge:J("Mod-Shift-9"),key:"check_list",...e.dictionary.slash_menu.check_list}),V("paragraph",e)&&n.push({onItemClick:()=>{A(e,{type:"paragraph"})},badge:J("Mod-Alt-0"),key:"paragraph",...e.dictionary.slash_menu.paragraph}),V("codeBlock",e)&&n.push({onItemClick:()=>{A(e,{type:"codeBlock"})},badge:J("Mod-Alt-c"),key:"code_block",...e.dictionary.slash_menu.code_block}),V("table",e)&&n.push({onItemClick:()=>{A(e,{type:"table",content:{type:"tableContent",rows:[{cells:["","",""]},{cells:["","",""]}]}})},badge:void 0,key:"table",...e.dictionary.slash_menu.table}),V("image",e)&&n.push({onItemClick:()=>{const t=A(e,{type:"image"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:t}))},key:"image",...e.dictionary.slash_menu.image}),V("video",e)&&n.push({onItemClick:()=>{const t=A(e,{type:"video"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:t}))},key:"video",...e.dictionary.slash_menu.video}),V("audio",e)&&n.push({onItemClick:()=>{const t=A(e,{type:"audio"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:t}))},key:"audio",...e.dictionary.slash_menu.audio}),V("file",e)&&n.push({onItemClick:()=>{const t=A(e,{type:"file"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:t}))},key:"file",...e.dictionary.slash_menu.file}),V("heading",e)&&(n.push({onItemClick:()=>{A(e,{type:"heading",props:{level:1,isToggleable:!0}})},key:"toggle_heading",...e.dictionary.slash_menu.toggle_heading},{onItemClick:()=>{A(e,{type:"heading",props:{level:2,isToggleable:!0}})},key:"toggle_heading_2",...e.dictionary.slash_menu.toggle_heading_2},{onItemClick:()=>{A(e,{type:"heading",props:{level:3,isToggleable:!0}})},key:"toggle_heading_3",...e.dictionary.slash_menu.toggle_heading_3}),e.settings.heading.levels.filter(t=>t>3).forEach(t=>{n.push({onItemClick:()=>{A(e,{type:"heading",props:{level:t}})},key:`heading_${t}`,...e.dictionary.slash_menu[`heading_${t}`]})})),n.push({onItemClick:()=>{e.openSuggestionMenu(":",{deleteTriggerCharacter:!0,ignoreQueryLength:!0})},key:"emoji",...e.dictionary.slash_menu.emoji}),n}function ri(e,n){return e.filter(({title:t,aliases:o})=>t.toLowerCase().includes(n.toLowerCase())||o&&o.filter(r=>r.toLowerCase().includes(n.toLowerCase())).length!==0)}function it(e){return e&&Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))}class ye{constructor(n){p(this,"blockSpecs");p(this,"inlineContentSpecs");p(this,"styleSpecs");p(this,"blockSchema");p(this,"inlineContentSchema");p(this,"styleSchema");p(this,"BlockNoteEditor","only for types");p(this,"Block","only for types");p(this,"PartialBlock","only for types");this.blockSpecs=it(n==null?void 0:n.blockSpecs)||_t,this.inlineContentSpecs=it(n==null?void 0:n.inlineContentSpecs)||Ut,this.styleSpecs=it(n==null?void 0:n.styleSpecs)||Vt,this.blockSchema=Tt(this.blockSpecs),this.inlineContentSchema=Pt(this.inlineContentSpecs),this.styleSchema=It(this.styleSpecs)}static create(n){return new ye(n)}}const Mo={type:"pageBreak",propSchema:{},content:"none",isFileBlock:!1,isSelectable:!1},Io=()=>{const e=document.createElement("div");return e.className="bn-page-break",e.setAttribute("data-page-break",""),{dom:e}},Lo=e=>{if(e.tagName==="DIV"&&e.hasAttribute("data-page-break"))return{type:"pageBreak"}},Ao=()=>{const e=document.createElement("div");return e.setAttribute("data-page-break",""),{dom:e}},No=be(Mo,{render:Io,parse:Lo,toExternalHTML:Ao}),Ft=ye.create({blockSpecs:{pageBreak:No}}),si=e=>ye.create({blockSpecs:{...e.blockSpecs,...Ft.blockSpecs},inlineContentSpecs:e.inlineContentSpecs,styleSpecs:e.styleSpecs});function Do(e){return"pageBreak"in e.schema.blockSchema&&e.schema.blockSchema.pageBreak===Ft.blockSchema.pageBreak}function ii(e){const n=[];return Do(e)&&n.push({...e.dictionary.slash_menu.page_break,onItemClick:()=>{A(e,{type:"pageBreak"})},key:"page_break"}),n}function ai(e){return e.transact(n=>{const t=X(n.doc,n.selection.anchor);if(n.selection instanceof H.CellSelection)return{type:"cell",anchorBlockId:t.node.attrs.id,anchorCellOffset:n.selection.$anchorCell.pos-t.posBeforeNode,headCellOffset:n.selection.$headCell.pos-t.posBeforeNode};if(n.selection instanceof y.NodeSelection)return{type:"node",anchorBlockId:t.node.attrs.id};{const o=X(n.doc,n.selection.head);return{type:"text",anchorBlockId:t.node.attrs.id,headBlockId:o.node.attrs.id,anchorOffset:n.selection.anchor-t.posBeforeNode,headOffset:n.selection.head-o.posBeforeNode}}})}function li(e,n){var r,s;const t=(r=z(n.anchorBlockId,e.doc))==null?void 0:r.posBeforeNode;if(t===void 0)throw new Error(`Could not find block with ID ${n.anchorBlockId} to update selection`);let o;if(n.type==="cell")o=H.CellSelection.create(e.doc,t+n.anchorCellOffset,t+n.headCellOffset);else if(n.type==="node")o=y.NodeSelection.create(e.doc,t+1);else{const i=(s=z(n.headBlockId,e.doc))==null?void 0:s.posBeforeNode;if(i===void 0)throw new Error(`Could not find block with ID ${n.headBlockId} to update selection`);o=y.TextSelection.create(e.doc,t+n.anchorOffset,i+n.headOffset)}e.setSelection(o)}function wt(e){return e.map(n=>n.type==="columnList"?n.children.map(t=>wt(t.children)).flat():{...n,children:wt(n.children)}).flat()}function Ho(e,n,t){e.transact(o=>{var i;const r=((i=e.getSelection())==null?void 0:i.blocks)||[e.getTextCursorPosition().block],s=ai(e);e.removeBlocks(r),e.insertBlocks(wt(r),n,t),li(o,s)})}function Oo(e){return!e||e.type!=="columnList"}function Ro(e,n,t){let o,r;if(n?n.children.length>0?(o=n.children[n.children.length-1],r="after"):(o=n,r="before"):t&&(o=t,r="before"),!o||!r)return;const s=e.getParentBlock(o);return Oo(s)?{referenceBlock:o,placement:r}:Ro(e,r==="after"?o:e.getPrevBlock(o),s)}function _o(e,n,t){let o,r;if(n?n.children.length>0?(o=n.children[0],r="before"):(o=n,r="after"):t&&(o=t,r="after"),!o||!r)return;const s=e.getParentBlock(o);return Oo(s)?{referenceBlock:o,placement:r}:_o(e,r==="before"?o:e.getNextBlock(o),s)}function ci(e){e.transact(()=>{const n=e.getSelection(),t=(n==null?void 0:n.blocks[0])||e.getTextCursorPosition().block,o=Ro(e,e.getPrevBlock(t),e.getParentBlock(t));o&&Ho(e,o.referenceBlock,o.placement)})}function di(e){e.transact(()=>{const n=e.getSelection(),t=(n==null?void 0:n.blocks[(n==null?void 0:n.blocks.length)-1])||e.getTextCursorPosition().block,o=_o(e,e.getNextBlock(t),e.getParentBlock(t));o&&Ho(e,o.referenceBlock,o.placement)})}function ui(e,n,t){const{$from:o,$to:r}=e.selection,s=o.blockRange(r,m=>m.childCount>0&&(m.type.name==="blockGroup"||m.type.name==="column"));if(!s)return!1;const i=s.startIndex;if(i===0)return!1;const l=s.parent.child(i-1);if(l.type!==n)return!1;const c=l.lastChild&&l.lastChild.type===t,d=S.Fragment.from(c?n.create():null),u=new S.Slice(S.Fragment.from(n.create(null,S.Fragment.from(t.create(null,d)))),c?3:1,0),h=s.start,f=s.end;return e.step(new he.ReplaceAroundStep(h-(c?3:1),f,h,f,u,1,!0)).scrollIntoView(),!0}function Vo(e){return e.transact(n=>ui(n,e.pmSchema.nodes.blockContainer,e.pmSchema.nodes.blockGroup))}function pi(e){e._tiptapEditor.commands.liftListItem("blockContainer")}function hi(e){return e.transact(n=>{const{bnBlock:t}=Te(n);return n.doc.resolve(t.beforePos).nodeBefore!==null})}function fi(e){return e.transact(n=>{const{bnBlock:t}=Te(n);return n.doc.resolve(t.beforePos).depth>1})}function Uo(e,n){const t=typeof n=="string"?n:n.id,o=R(e),r=z(t,e);if(r)return B(r.node,o)}function Fo(e,n){const t=typeof n=="string"?n:n.id,o=z(t,e),r=R(e);if(!o)return;const i=e.resolve(o.posBeforeNode).nodeBefore;if(i)return B(i,r)}function $o(e,n){const t=typeof n=="string"?n:n.id,o=z(t,e),r=R(e);if(!o)return;const i=e.resolve(o.posBeforeNode+o.node.nodeSize).nodeAfter;if(i)return B(i,r)}function zo(e,n){const t=typeof n=="string"?n:n.id,o=R(e),r=z(t,e);if(!r)return;const s=e.resolve(r.posBeforeNode),i=s.node(),a=s.node(-1),l=a.type.name!=="doc"?i.type.name==="blockGroup"?a:i:void 0;if(l)return B(l,o)}function mi(e,n,t,o={updateSelection:!0}){let{from:r,to:s}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},i=!0,a=!0,l="";if(t.forEach(c=>{c.check(),i&&c.isText&&c.marks.length===0?l+=c.text:i=!1,a=a?c.isBlock:!1}),r===s&&a){const{parent:c}=e.doc.resolve(r);c.isTextblock&&!c.type.spec.code&&!c.childCount&&(r-=1,s+=1)}return i?e.insertText(l,r,s):e.replaceWith(r,s,t),o.updateSelection&&k.selectionToInsertionEnd(e,e.steps.length-1,-1),!0}function gi(e){const n=R(e);if(e.selection.empty||"node"in e.selection)return;const t=e.doc.resolve(X(e.doc,e.selection.from).posBeforeNode),o=e.doc.resolve(X(e.doc,e.selection.to).posBeforeNode),r=(c,d)=>{const u=t.posAtIndex(c,d),h=e.doc.resolve(u).nodeAfter;if(!h)throw new Error(`Error getting selection - node not found at position ${u}`);return B(h,n)},s=[],i=t.sharedDepth(o.pos),a=t.index(i),l=o.index(i);if(t.depth>i){s.push(B(t.nodeAfter,n));for(let c=t.depth;c>i;c--)if(t.node(c).type.isInGroup("childContainer")){const u=t.index(c)+1,h=t.node(c).childCount;for(let f=u;f<h;f++)s.push(r(f,c))}}else s.push(r(a,i));for(let c=a+1;c<=l;c++)s.push(r(c,i));if(s.length===0)throw new Error(`Error getting selection - selection doesn't span any blocks (${e.selection})`);return{blocks:s}}function bi(e,n,t){const o=typeof n=="string"?n:n.id,r=typeof t=="string"?t:t.id,s=R(e),i=we(s);if(o===r)throw new Error(`Attempting to set selection with the same anchor and head blocks (id ${o})`);const a=z(o,e.doc);if(!a)throw new Error(`Block with ID ${o} not found`);const l=z(r,e.doc);if(!l)throw new Error(`Block with ID ${r} not found`);const c=ee(a),d=ee(l),u=i.blockSchema[c.blockNoteType],h=i.blockSchema[d.blockNoteType];if(!c.isBlockContainer||u.content==="none")throw new Error(`Attempting to set selection anchor in block without content (id ${o})`);if(!d.isBlockContainer||h.content==="none")throw new Error(`Attempting to set selection anchor in block without content (id ${r})`);let f,m;if(u.content==="table"){const g=H.TableMap.get(c.blockContent.node);f=c.blockContent.beforePos+g.positionAt(0,0,c.blockContent.node)+1+2}else f=c.blockContent.beforePos+1;if(h.content==="table"){const g=H.TableMap.get(d.blockContent.node),b=d.blockContent.beforePos+g.positionAt(g.height-1,g.width-1,d.blockContent.node)+1,w=e.doc.resolve(b).nodeAfter.nodeSize;m=b+w-2}else m=d.blockContent.afterPos-1;e.setSelection(y.TextSelection.create(e.doc,f,m))}function ki(e){const n=R(e);let t=e.selection.$from,o=e.selection.$to;for(;o.parentOffset>=o.parent.nodeSize-2&&o.depth>0;)o=e.doc.resolve(o.pos+1);for(;o.parentOffset===0&&o.depth>0;)o=e.doc.resolve(o.pos-1);for(;t.parentOffset===0&&t.depth>0;)t=e.doc.resolve(t.pos-1);for(;t.parentOffset>=t.parent.nodeSize-2&&t.depth>0;)t=e.doc.resolve(t.pos+1);const r=yn(e.doc.slice(t.pos,o.pos,!0),n);return{_meta:{startPos:t.pos,endPos:o.pos},...r}}function wi(e){const{bnBlock:n}=Te(e),t=R(e.doc),o=e.doc.resolve(n.beforePos),r=o.nodeBefore,s=e.doc.resolve(n.afterPos).nodeAfter;let i;return o.depth>1&&(i=o.node(),i.type.isInGroup("bnBlock")||(i=o.node(o.depth-1))),{block:B(n.node,t),prevBlock:r===null?void 0:B(r,t),nextBlock:s===null?void 0:B(s,t),parentBlock:i===void 0?void 0:B(i,t)}}function Wo(e,n,t="start"){const o=typeof n=="string"?n:n.id,r=R(e.doc),s=we(r),i=z(o,e.doc);if(!i)throw new Error(`Block with ID ${o} not found`);const a=ee(i),l=s.blockSchema[a.blockNoteType].content;if(a.isBlockContainer){const c=a.blockContent;if(l==="none"){e.setSelection(y.NodeSelection.create(e.doc,c.beforePos));return}if(l==="inline")t==="start"?e.setSelection(y.TextSelection.create(e.doc,c.beforePos+1)):e.setSelection(y.TextSelection.create(e.doc,c.afterPos-1));else if(l==="table")t==="start"?e.setSelection(y.TextSelection.create(e.doc,c.beforePos+4)):e.setSelection(y.TextSelection.create(e.doc,c.afterPos-4));else throw new j(l)}else{const c=t==="start"?a.childContainer.node.firstChild:a.childContainer.node.lastChild;Wo(e,c.attrs.id,t)}}exports.esmDependencies=void 0;async function tt(){if(exports.esmDependencies)return exports.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 exports.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]},exports.esmDependencies}function yi(){const e=n=>{let t=n.children.length;for(let o=0;o<t;o++){const r=n.children[o];if(r.type==="element"&&(e(r),r.tagName==="u"))if(r.children.length>0){n.children.splice(o,1,...r.children);const s=r.children.length-1;t+=s,o+=s}else n.children.splice(o,1),t--,o--}};return e}function Ci(){const e=exports.esmDependencies;if(!e)throw new Error("addSpacesToCheckboxes requires ESM dependencies to be initialized");const n=t=>{var o;if(t.children&&"length"in t.children&&t.children.length)for(let r=t.children.length-1;r>=0;r--){const s=t.children[r],i=r+1<t.children.length?t.children[r+1]:void 0;s.type==="element"&&s.tagName==="input"&&((o=s.properties)==null?void 0:o.type)==="checkbox"&&(i==null?void 0:i.type)==="element"&&i.tagName==="p"?(i.tagName="span",i.children.splice(0,0,e.hastUtilFromDom.fromDom(document.createTextNode(" ")))):n(s)}};return n}function nt(e){const n=exports.esmDependencies;if(!n)throw new Error("cleanHTMLToMarkdown requires ESM dependencies to be initialized");return n.unified.unified().use(n.rehypeParse.default,{fragment:!0}).use(yi).use(Ci).use(n.rehypeRemark.default).use(n.remarkGfm.default).use(n.remarkStringify.default,{handlers:{text:o=>o.value}}).processSync(e).value}async function Ko(e,n,t,o){await tt();const s=Me(n,t).exportBlocks(e,o);return nt(s)}function vi(e){return Array.prototype.indexOf.call(e.parentElement.childNodes,e)}function Si(e){return e.nodeType===3&&!/\S/.test(e.nodeValue||"")}function Ei(e){e.querySelectorAll("li > ul, li > ol").forEach(n=>{const t=vi(n),o=n.parentElement,r=Array.from(o.childNodes).slice(t+1);n.remove(),r.forEach(s=>{s.remove()}),o.insertAdjacentElement("afterend",n),r.reverse().forEach(s=>{if(Si(s))return;const i=document.createElement("li");i.append(s),n.insertAdjacentElement("afterend",i)}),o.childNodes.length===0&&o.remove()})}function Bi(e){e.querySelectorAll("li + ul, li + ol").forEach(n=>{var s,i;const t=n.previousElementSibling,o=document.createElement("div");t.insertAdjacentElement("afterend",o),o.append(t);const r=document.createElement("div");for(r.setAttribute("data-node-type","blockGroup"),o.append(r);((s=o.nextElementSibling)==null?void 0:s.nodeName)==="UL"||((i=o.nextElementSibling)==null?void 0:i.nodeName)==="OL";)r.append(o.nextElementSibling)})}let tn=null;function Ti(){return tn||(tn=document.implementation.createHTMLDocument("title"))}function qo(e){if(typeof e=="string"){const n=Ti().createElement("div");n.innerHTML=e,e=n}return Ei(e),Bi(e),e}async function $t(e,n){const t=qo(e),r=S.DOMParser.fromSchema(n).parse(t,{topNode:n.nodes.blockGroup.create()}),s=[];for(let i=0;i<r.childCount;i++)s.push(B(r.child(i),n));return s}function xi(e,n){const t=n.value?n.value:"",o={};n.lang&&(o["data-language"]=n.lang);let r={type:"element",tagName:"code",properties:o,children:[{type:"text",value:t}]};return n.meta&&(r.data={meta:n.meta}),e.patch(n,r),r=e.applyData(n,r),r={type:"element",tagName:"pre",properties:{},children:[r]},e.patch(n,r),r}async function zt(e){const n=await tt();return n.unified.unified().use(n.remarkParse.default).use(n.remarkGfm.default).use(n.remarkRehype.default,{handlers:{...n.remarkRehype.defaultHandlers,code:xi}}).use(n.rehypeStringify.default).processSync(e).value}async function jo(e,n){const t=await zt(e);return $t(t,n)}const Wt=["vscode-editor-data","blocknote/html","text/markdown","text/html","text/plain","Files"];function Pi(e,n){if(!e.startsWith(".")||!n.startsWith("."))throw new Error("The strings provided are not valid file extensions.");return e===n}function Mi(e,n){const t=e.split("/"),o=n.split("/");if(t.length!==2)throw new Error(`The string ${e} is not a valid MIME type.`);if(o.length!==2)throw new Error(`The string ${n} is not a valid MIME type.`);return t[1]==="*"||o[1]==="*"?t[0]===o[0]:(t[0]==="*"||o[0]==="*"||t[0]===o[0])&&t[1]===o[1]}function nn(e,n,t){let o;return Array.isArray(n.content)&&n.content.length===0?o=e.updateBlock(n,t).id:o=e.insertBlocks([t],n,"after")[0].id,o}async function Go(e,n){var i;if(!n.uploadFile){console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");return}const t="dataTransfer"in e?e.dataTransfer:e.clipboardData;if(t===null)return;let o=null;for(const a of Wt)if(t.types.includes(a)){o=a;break}if(o!=="Files")return;const r=t.items;if(!r)return;e.preventDefault();const s=Object.values(n.schema.blockSchema).filter(a=>a.isFileBlock);for(let a=0;a<r.length;a++){let l="file";for(const d of s)for(const u of d.fileBlockAccept||[]){const h=u.startsWith("."),f=r[a].getAsFile();if(f&&(!h&&f.type&&Mi(r[a].type,u)||h&&Pi("."+f.name.split(".").pop(),u))){l=d.type;break}}const c=r[a].getAsFile();if(c){const d={type:l,props:{name:c.name}};let u;if(e.type==="paste"){const m=n.getTextCursorPosition().block;u=nn(n,m,d)}else if(e.type==="drop"){const m={left:e.clientX,top:e.clientY},g=(i=n.prosemirrorView)==null?void 0:i.posAtCoords(m);if(!g)return;u=n.transact(b=>{const w=X(b.doc,g.pos);return nn(n,n.getBlock(w.node.attrs.id),d)})}else return;const h=await n.uploadFile(c,u),f=typeof h=="string"?{props:{url:h}}:{...h};n.updateBlock(u,f)}}}const Ii=e=>k.Extension.create({name:"dropFile",addProseMirrorPlugins(){return[new y.Plugin({props:{handleDOMEvents:{drop(n,t){if(!e.isEditable)return;let o=null;for(const r of Wt)if(t.dataTransfer.types.includes(r)){o=r;break}return o===null?!0:o==="Files"?(Go(t,e),!0):!1}}}})]}}),Li=/(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/,Ai=/(_|__|\*|\*\*|~~|==|\+\+)(?!\s)(?:[^\s](?:.{0,62}[^\s])?|\S)(?=\1)/,Ni=/\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/,Di=/(?:\s|^)`(?!\s)(?:[^\s`](?:[^`]{0,46}[^\s`])?|[^\s`])`([^\w]|$)/,Hi=/(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/,Oi=/(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/,Ri=/\n{2} {0,3}-{2,48}\n{2}/,_i=/(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/,Vi=/(?:\n|^)(?!\s)\w[^\n]{0,64}\r?\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/,Ui=/(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/,Fi=/^\s*\|(.+\|)+\s*$/m,$i=/^\s*\|(\s*[-:]+[-:]\s*\|)+\s*$/m,zi=/^\s*\|(.+\|)+\s*$/m,Wi=e=>Li.test(e)||Ai.test(e)||Ni.test(e)||Di.test(e)||Hi.test(e)||Oi.test(e)||Ri.test(e)||_i.test(e)||Vi.test(e)||Ui.test(e)||Fi.test(e)||$i.test(e)||zi.test(e);async function Ki(e,n){const{schema:t}=n.state;if(!e.clipboardData)return!1;const o=e.clipboardData.getData("text/plain");if(!o)return!1;if(!t.nodes.codeBlock)return n.pasteText(o),!0;const r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s==null?void 0:s.mode;return i?(n.pasteHTML(`<pre><code class="language-${i}">${o.replace(/\r\n?/g,`
11
+ `)}</code></pre>`),!0):!1}function qi({event:e,editor:n,prioritizeMarkdownOverHTML:t,plainTextAsMarkdown:o}){var a;if(n.transact(l=>l.selection.$from.parent.type.spec.code&&l.selection.$to.parent.type.spec.code)){const l=(a=e.clipboardData)==null?void 0:a.getData("text/plain");if(l)return n.pasteText(l),!0}let s;for(const l of Wt)if(e.clipboardData.types.includes(l)){s=l;break}if(!s)return!0;if(s==="vscode-editor-data")return Ki(e,n.prosemirrorView),!0;if(s==="Files")return Go(e,n),!0;const i=e.clipboardData.getData(s);if(s==="blocknote/html")return n.pasteHTML(i,!0),!0;if(s==="text/markdown")return n.pasteMarkdown(i),!0;if(t){const l=e.clipboardData.getData("text/plain");if(Wi(l))return n.pasteMarkdown(l),!0}return s==="text/html"?(n.pasteHTML(i),!0):o?(n.pasteMarkdown(i),!0):(n.pasteText(i),!0)}const ji=(e,n)=>k.Extension.create({name:"pasteFromClipboard",addProseMirrorPlugins(){return[new y.Plugin({props:{handleDOMEvents:{paste(t,o){if(o.preventDefault(),!!e.isEditable)return n({event:o,editor:e,defaultPasteHandler:({prioritizeMarkdownOverHTML:r=!0,plainTextAsMarkdown:s=!0}={})=>qi({event:o,editor:e,prioritizeMarkdownOverHTML:r,plainTextAsMarkdown:s})})}}}})]}});function Yo(e){const n=[];return e.descendants(t=>{var r,s;const o=R(t);return t.type.name==="blockContainer"&&((r=t.firstChild)==null?void 0:r.type.name)==="blockGroup"?!0:t.type.name==="columnList"&&t.childCount===1?((s=t.firstChild)==null||s.forEach(i=>{n.push(B(i,o))}),!1):t.type.isInGroup("bnBlock")?(n.push(B(t,o)),!1):!0}),n}function Gi(e,n,t){var a;let o=!1;const r=e.state.selection instanceof H.CellSelection;if(!r){const l=e.state.doc.slice(e.state.selection.from,e.state.selection.to,!1).content,c=[];for(let d=0;d<l.childCount;d++)c.push(l.child(d));o=c.find(d=>d.type.isInGroup("bnBlock")||d.type.name==="blockGroup"||d.type.spec.group==="blockContent")===void 0,o&&(n=l)}let s;const i=Me(e.state.schema,t);if(r){((a=n.firstChild)==null?void 0:a.type.name)==="table"&&(n=n.firstChild.content);const l=xt(n,t.schema.inlineContentSchema,t.schema.styleSchema);s=`<table>${i.exportInlineContent(l,{})}</table>`}else if(o){const l=xe(n,t.schema.inlineContentSchema,t.schema.styleSchema);s=i.exportInlineContent(l,{})}else{const l=Yo(n);s=i.exportBlocks(l,{})}return s}function Kt(e,n){"node"in e.state.selection&&e.state.selection.node.type.spec.group==="blockContent"&&n.transact(i=>i.setSelection(new y.NodeSelection(i.doc.resolve(e.state.selection.from-1))));const t=e.serializeForClipboard(e.state.selection.content()).dom.innerHTML,o=e.state.selection.content().content,r=Gi(e,o,n),s=nt(r);return{clipboardHTML:t,externalHTML:r,markdown:s}}const on=()=>{const e=window.getSelection();if(!e||e.isCollapsed)return!0;let n=e.focusNode;for(;n;){if(n instanceof HTMLElement&&n.getAttribute("contenteditable")==="false")return!0;n=n.parentElement}return!1},rn=(e,n,t)=>{t.preventDefault(),t.clipboardData.clearData();const{clipboardHTML:o,externalHTML:r,markdown:s}=Kt(n,e);t.clipboardData.setData("blocknote/html",o),t.clipboardData.setData("text/html",r),t.clipboardData.setData("text/plain",s)},Yi=e=>k.Extension.create({name:"copyToClipboard",addProseMirrorPlugins(){return[new y.Plugin({props:{handleDOMEvents:{copy(n,t){return on()||rn(e,n,t),!0},cut(n,t){return on()||(rn(e,n,t),n.editable&&n.dispatch(n.state.tr.deleteSelection())),!0},dragstart(n,t){if(!("node"in n.state.selection)||n.state.selection.node.type.spec.group!=="blockContent")return;e.transact(i=>i.setSelection(new y.NodeSelection(i.doc.resolve(n.state.selection.from-1)))),t.preventDefault(),t.dataTransfer.clearData();const{clipboardHTML:o,externalHTML:r,markdown:s}=Kt(n,e);return t.dataTransfer.setData("blocknote/html",o),t.dataTransfer.setData("text/html",r),t.dataTransfer.setData("text/plain",s),!0}}}})]}}),Ji=k.Extension.create({name:"blockBackgroundColor",addGlobalAttributes(){return[{types:["blockContainer","tableCell","tableHeader"],attributes:{backgroundColor:{default:M.backgroundColor.default,parseHTML:e=>e.hasAttribute("data-background-color")?e.getAttribute("data-background-color"):M.backgroundColor.default,renderHTML:e=>e.backgroundColor===M.backgroundColor.default?{}:{"data-background-color":e.backgroundColor}}}}]}});class ot{constructor(){p(this,"callbacks",{})}on(n,t){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(t),()=>this.off(n,t)}emit(n,...t){const o=this.callbacks[n];o&&o.forEach(r=>r.apply(this,t))}off(n,t){const o=this.callbacks[n];o&&(t?this.callbacks[n]=o.filter(r=>r!==t):delete this.callbacks[n])}removeAllListeners(){this.callbacks={}}}class O extends ot{constructor(...t){super();p(this,"plugins",[])}static key(){throw new Error("You must implement the key method in your extension")}addProsemirrorPlugin(t){this.plugins.push(t)}get priority(){}}class Xi extends O{constructor(){super();p(this,"beforeChangeCallbacks",[]);this.addProsemirrorPlugin(new y.Plugin({filterTransaction:t=>{let o;return this.beforeChangeCallbacks.reduce((r,s)=>r===!1?r:s({getChanges(){return o||(o=At(t),o)},tr:t})!==!1,!0)}}))}static key(){return"blockChange"}subscribe(t){return this.beforeChangeCallbacks.push(t),()=>{this.beforeChangeCallbacks=this.beforeChangeCallbacks.filter(o=>o!==t)}}}const ue=class ue extends O{constructor(t){super();p(this,"provider");p(this,"recentlyUpdatedCursors");p(this,"renderCursor",(t,o)=>{let r=this.recentlyUpdatedCursors.get(o);if(!r){const s=(this.collaboration.renderCursor??ue.defaultCursorRender)(t);this.collaboration.showCursorLabels!=="always"&&(s.addEventListener("mouseenter",()=>{const i=this.recentlyUpdatedCursors.get(o);i.element.setAttribute("data-active",""),i.hideTimeout&&(clearTimeout(i.hideTimeout),this.recentlyUpdatedCursors.set(o,{element:i.element,hideTimeout:void 0}))}),s.addEventListener("mouseleave",()=>{const i=this.recentlyUpdatedCursors.get(o);this.recentlyUpdatedCursors.set(o,{element:i.element,hideTimeout:setTimeout(()=>{i.element.removeAttribute("data-active")},2e3)})})),r={element:s,hideTimeout:void 0},this.recentlyUpdatedCursors.set(o,r)}return r.element});p(this,"updateUser",t=>{this.provider.awareness.setLocalStateField("user",t)});this.collaboration=t,this.provider=t.provider,this.recentlyUpdatedCursors=new Map,this.provider.awareness.setLocalStateField("user",t.user),t.showCursorLabels!=="always"&&this.provider.awareness.on("change",({updated:o})=>{for(const r of o){const s=this.recentlyUpdatedCursors.get(r);s&&(s.element.setAttribute("data-active",""),s.hideTimeout&&clearTimeout(s.hideTimeout),this.recentlyUpdatedCursors.set(r,{element:s.element,hideTimeout:setTimeout(()=>{s.element.removeAttribute("data-active")},2e3)}))}}),this.addProsemirrorPlugin(N.yCursorPlugin(this.provider.awareness,{selectionBuilder:N.defaultSelectionBuilder,cursorBuilder:this.renderCursor}))}static key(){return"yCursorPlugin"}get priority(){return 999}static isDarkColor(t){const o=t.charAt(0)==="#"?t.substring(1,7):t,r=parseInt(o.substring(0,2),16),s=parseInt(o.substring(2,4),16),i=parseInt(o.substring(4,6),16),l=[r/255,s/255,i/255].map(d=>d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4));return .2126*l[0]+.7152*l[1]+.0722*l[2]<=.179}};p(ue,"defaultCursorRender",t=>{const o=document.createElement("span");o.classList.add("bn-collaboration-cursor__base");const r=document.createElement("span");r.setAttribute("contentedEditable","false"),r.classList.add("bn-collaboration-cursor__caret"),r.setAttribute("style",`background-color: ${t.color}; color: ${ue.isDarkColor(t.color)?"white":"black"}`);const s=document.createElement("span");return s.classList.add("bn-collaboration-cursor__label"),s.setAttribute("style",`background-color: ${t.color}; color: ${ue.isDarkColor(t.color)?"white":"black"}`),s.insertBefore(document.createTextNode(t.name),null),r.insertBefore(s,null),o.insertBefore(document.createTextNode("⁠"),null),o.insertBefore(r,null),o.insertBefore(document.createTextNode("⁠"),null),o});let $e=ue;class yt extends O{static key(){return"ySyncPlugin"}constructor(n){super(),this.addProsemirrorPlugin(N.ySyncPlugin(n))}get priority(){return 1001}}class Ct extends O{static key(){return"yUndoPlugin"}constructor({editor:n}){super(),this.addProsemirrorPlugin(N.yUndoPlugin({trackedOrigins:[n]}))}get priority(){return 1e3}}const Jo=k.Mark.create({name:"comment",excludes:"",inclusive:!1,keepOnSplit:!0,addAttributes(){return{orphan:{parseHTML:e=>!!e.getAttribute("data-orphan"),renderHTML:e=>e.orphan?{"data-orphan":"true"}:{},default:!1},threadId:{parseHTML:e=>e.getAttribute("data-bn-thread-id"),renderHTML:e=>({"data-bn-thread-id":e.threadId}),default:""}}},renderHTML({HTMLAttributes:e}){return["span",k.mergeAttributes(e,{class:"bn-thread-mark"})]},parseHTML(){return[{tag:"span.bn-thread-mark"}]},extendMarkSchema(e){return e.name==="comment"?{blocknoteIgnore:!0}:{}}});class Zi extends ot{constructor(t){super();p(this,"userCache",new Map);p(this,"loadingUsers",new Set);this.resolveUsers=t}async loadUsers(t){const o=t.filter(r=>!this.userCache.has(r)&&!this.loadingUsers.has(r));if(o.length!==0){for(const r of o)this.loadingUsers.add(r);try{const r=await this.resolveUsers(o);for(const s of r)this.userCache.set(s.id,s);this.emit("update",this.userCache)}finally{for(const r of o)this.loadingUsers.delete(r)}}}getUser(t){return this.userCache.get(t)}subscribe(t){return this.on("update",t)}}const Ne=new y.PluginKey("blocknote-comments"),Qi="SET_SELECTED_THREAD_ID";function ea(e,n){const t=new Map;return e.descendants((o,r)=>{o.marks.forEach(s=>{if(s.type.name===n){const i=s.attrs.threadId;if(!i)return;const a=r,l=a+o.nodeSize,c=t.get(i)??{from:1/0,to:0};t.set(i,{from:Math.min(a,c.from),to:Math.max(l,c.to)})}})}),t}class ta extends O{constructor(t,o,r){super();p(this,"userStore");p(this,"pendingComment",!1);p(this,"selectedThreadId");p(this,"threadPositions",new Map);p(this,"updateMarksFromThreads",t=>{this.editor.transact(o=>{o.doc.descendants((r,s)=>{r.marks.forEach(i=>{if(i.type.name===this.markType){const a=i.type,l=i.attrs.threadId,c=t.get(l),d=!!(!c||c.resolved||c.deletedAt);if(d!==i.attrs.orphan){const u=Math.max(s,0),h=Math.min(s+r.nodeSize,o.doc.content.size-1,o.doc.content.size-1);o.removeMark(u,h,i),o.addMark(u,h,a.create({...i.attrs,orphan:d})),d&&this.selectedThreadId===l&&(this.selectedThreadId=void 0,this.emitStateUpdate())}}})})})});if(this.editor=t,this.threadStore=o,this.markType=r,!t.resolveUsers)throw new Error("resolveUsers is required for comments");this.userStore=new Zi(t.resolveUsers),this.threadStore.subscribe(this.updateMarksFromThreads),t.onCreate(()=>{this.updateMarksFromThreads(this.threadStore.getThreads()),t.onSelectionChange(()=>{this.pendingComment&&(this.pendingComment=!1,this.emitStateUpdate())})});const s=this;this.addProsemirrorPlugin(new y.Plugin({key:Ne,state:{init(){return{decorations:D.DecorationSet.empty}},apply(i,a){const l=i.getMeta(Ne);if(!i.docChanged&&!l)return a;const c=i.docChanged?ea(i.doc,s.markType):s.threadPositions;(c.size>0||s.threadPositions.size>0)&&(s.threadPositions=c,s.emitStateUpdate());const d=[];if(s.selectedThreadId){const u=c.get(s.selectedThreadId);u&&d.push(D.Decoration.inline(u.from,u.to,{class:"bn-thread-mark-selected"}))}return{decorations:D.DecorationSet.create(i.doc,d)}}},props:{decorations(i){var a;return((a=Ne.getState(i))==null?void 0:a.decorations)??D.DecorationSet.empty},handleClick:(i,a,l)=>{if(l.button!==0)return;const c=i.state.doc.nodeAt(a);if(!c){s.selectThread(void 0);return}const d=c.marks.find(h=>h.type.name===r&&h.attrs.orphan!==!0),u=d==null?void 0:d.attrs.threadId;s.selectThread(u,!1)}}}))}static key(){return"comments"}emitStateUpdate(){this.emit("update",{selectedThreadId:this.selectedThreadId,pendingComment:this.pendingComment,threadPositions:this.threadPositions})}onUpdate(t){return this.on("update",t)}selectThread(t,o=!0){var r,s;if(this.selectedThreadId!==t&&(this.selectedThreadId=t,this.emitStateUpdate(),this.editor.transact(i=>i.setMeta(Ne,{name:Qi})),t&&o)){const i=this.threadPositions.get(t);if(!i)return;(s=(r=this.editor.prosemirrorView)==null?void 0:r.domAtPos(i.from).node)==null||s.scrollIntoView({behavior:"smooth",block:"center"})}}startPendingComment(){this.pendingComment=!0,this.emitStateUpdate()}stopPendingComment(){this.pendingComment=!1,this.emitStateUpdate()}async createThread(t){const o=await this.threadStore.createThread(t);if(this.threadStore.addThreadToDocument){const r=this.editor.prosemirrorView,s=r.state.selection,i=N.ySyncPluginKey.getState(r.state),a={prosemirror:{head:s.head,anchor:s.anchor},yjs:i?N.getRelativeSelection(i.binding,r.state):void 0};await this.threadStore.addThreadToDocument({threadId:o.id,selection:a})}else this.editor._tiptapEditor.commands.setMark(this.markType,{orphan:!1,threadId:o.id})}}class Xo{constructor(n,t,o,r){p(this,"state");p(this,"emitUpdate");p(this,"mouseDownHandler",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())});p(this,"dragstartHandler",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())});p(this,"scrollHandler",()=>{var n;if((n=this.state)!=null&&n.show){const t=this.pmView.root.querySelector(`[data-node-type="blockContainer"][data-id="${this.state.block.id}"]`);if(!t)return;this.state.referencePos=t.getBoundingClientRect(),this.emitUpdate()}});p(this,"closeMenu",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())});this.editor=n,this.pluginKey=t,this.pmView=o,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized file panel");r(this.state)},o.dom.addEventListener("mousedown",this.mouseDownHandler),o.dom.addEventListener("dragstart",this.dragstartHandler),o.root.addEventListener("scroll",this.scrollHandler,!0)}update(n,t){var a,l;const o=this.pluginKey.getState(n.state),r=this.pluginKey.getState(t);if(!((a=this.state)!=null&&a.show)&&(o!=null&&o.block)&&this.editor.isEditable){const c=this.pmView.root.querySelector(`[data-node-type="blockContainer"][data-id="${o.block.id}"]`);if(!c)return;this.state={show:!0,referencePos:c.getBoundingClientRect(),block:o.block},this.emitUpdate();return}const s=(o==null?void 0:o.block)&&!(r!=null&&r.block),i=!(o!=null&&o.block)&&(r==null?void 0:r.block);s&&this.state&&!this.state.show&&(this.state.show=!0,this.emitUpdate()),i&&((l=this.state)!=null&&l.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 at=new y.PluginKey("FilePanelPlugin");class Zo extends O{constructor(t){super();p(this,"view");p(this,"closeMenu",()=>{var t;return(t=this.view)==null?void 0:t.closeMenu()});this.addProsemirrorPlugin(new y.Plugin({key:at,view:o=>(this.view=new Xo(t,at,o,r=>{this.emit("update",r)}),this.view),props:{handleKeyDown:(o,r)=>{var s;return r.key==="Escape"&&this.shown?((s=this.view)==null||s.closeMenu(),!0):!1}},state:{init:()=>({block:void 0}),apply:(o,r)=>{const s=o.getMeta(at);return s||(!o.getMeta(N.ySyncPluginKey)&&(o.selectionSet||o.docChanged)?{block:void 0}:r)}}}))}static key(){return"filePanel"}get shown(){var t,o;return((o=(t=this.view)==null?void 0:t.state)==null?void 0:o.show)||!1}onUpdate(t){return this.on("update",t)}}class Qo{constructor(n,t,o){p(this,"state");p(this,"emitUpdate");p(this,"preventHide",!1);p(this,"preventShow",!1);p(this,"shouldShow",({view:n,state:t,from:o,to:r})=>{const{doc:s,selection:i}=t,{empty:a}=i,l=!s.textBetween(o,r).length&&k.isTextSelection(t.selection);if(i.$from.parent.type.spec.code||k.isNodeSelection(i)&&i.node.type.spec.code||a||l)return!1;const c=document.activeElement;return!(!this.isElementWithinEditorWrapper(c)&&n.editable)});p(this,"blurHandler",n=>{var o;if(this.preventHide){this.preventHide=!1;return}const t=this.pmView.dom.parentElement;n&&n.relatedTarget&&(t===n.relatedTarget||t.contains(n.relatedTarget)||n.relatedTarget.matches(".bn-ui-container, .bn-ui-container *"))||(o=this.state)!=null&&o.show&&(this.state.show=!1,this.emitUpdate())});p(this,"isElementWithinEditorWrapper",n=>{if(!n)return!1;const t=this.pmView.dom.parentElement;return t?t.contains(n):!1});p(this,"viewMousedownHandler",n=>{(!this.isElementWithinEditorWrapper(n.target)||n.button===0)&&(this.preventShow=!0)});p(this,"mouseupHandler",()=>{this.preventShow&&(this.preventShow=!1,setTimeout(()=>this.update(this.pmView)))});p(this,"dragHandler",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())});p(this,"scrollHandler",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.referencePos=this.getSelectionBoundingBox(),this.emitUpdate())});p(this,"closeMenu",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())});this.editor=n,this.pmView=t,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized formatting toolbar");o(this.state)},t.dom.addEventListener("mousedown",this.viewMousedownHandler),t.root.addEventListener("mouseup",this.mouseupHandler),t.dom.addEventListener("dragstart",this.dragHandler),t.dom.addEventListener("dragover",this.dragHandler),t.dom.addEventListener("blur",this.blurHandler),t.root.addEventListener("scroll",this.scrollHandler,!0)}update(n,t){var f,m,g;const{state:o,composing:r}=n,{doc:s,selection:i}=o,a=t&&t.doc.eq(s)&&t.selection.eq(i);if(r||a)return;const{ranges:l}=i,c=Math.min(...l.map(b=>b.$from.pos)),d=Math.max(...l.map(b=>b.$to.pos)),u=this.shouldShow({view:n,state:o,from:c,to:d}),h=typeof Range.prototype.getClientRects>"u";if(!this.preventShow&&(u||this.preventHide)&&!h){const b={show:!0,referencePos:this.getSelectionBoundingBox()};(b.show!==((f=this.state)==null?void 0:f.show)||b.referencePos.toJSON()!==((m=this.state)==null?void 0:m.referencePos.toJSON()))&&(this.state=b,this.emitUpdate());return}if((g=this.state)!=null&&g.show&&!this.preventHide&&(!u||this.preventShow||!this.editor.isEditable)){this.state.show=!1,this.emitUpdate();return}}destroy(){this.pmView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.pmView.root.removeEventListener("mouseup",this.mouseupHandler),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:n}=this.pmView,{selection:t}=n,{ranges:o}=t,r=Math.min(...o.map(i=>i.$from.pos)),s=Math.max(...o.map(i=>i.$to.pos));if(k.isNodeSelection(t)){const i=this.pmView.nodeDOM(r);if(i)return i.getBoundingClientRect()}return k.posToDOMRect(this.pmView,r,s)}}const er=new y.PluginKey("FormattingToolbarPlugin");class tr extends O{constructor(t){super();p(this,"view");p(this,"closeMenu",()=>this.view.closeMenu());this.addProsemirrorPlugin(new y.Plugin({key:er,view:o=>(this.view=new Qo(t,o,r=>{this.emit("update",r)}),this.view),props:{handleKeyDown:(o,r)=>r.key==="Escape"&&this.shown?(this.view.closeMenu(),!0):!1}}))}static key(){return"formattingToolbar"}get shown(){var t,o;return((o=(t=this.view)==null?void 0:t.state)==null?void 0:o.show)||!1}onUpdate(t){return this.on("update",t)}}const na=k.Node.create({name:"hardBreak",inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,priority:10,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:e}){return["br",k.mergeAttributes(this.options.HTMLAttributes,e)]},renderText(){return`
12
+ `}}),sn=(e,n)=>{const t=e.resolve(n);if(t.depth<=1)return;const o=t.posAtIndex(t.index(t.depth-1),t.depth-1);return ke(e.resolve(o))},_e=(e,n)=>{const t=e.resolve(n),o=t.index();if(o===0)return;const r=t.posAtIndex(o-1);return ke(e.resolve(r))},nr=(e,n)=>{for(;n.childContainer;){const t=n.childContainer.node,o=e.resolve(n.childContainer.beforePos+1).posAtIndex(t.childCount-1);n=ke(e.resolve(o))}return n},oa=(e,n)=>e.isBlockContainer&&e.blockContent.node.type.spec.content==="inline*"&&e.blockContent.node.childCount>0&&n.isBlockContainer&&n.blockContent.node.type.spec.content==="inline*",ra=(e,n,t,o)=>{if(!o.isBlockContainer)throw new Error(`Attempted to merge block at position ${o.bnBlock.beforePos} into previous block at position ${t.bnBlock.beforePos}, but next block is not a block container`);if(o.childContainer){const r=e.doc.resolve(o.childContainer.beforePos+1),s=e.doc.resolve(o.childContainer.afterPos-1),i=r.blockRange(s);if(n){const a=e.doc.resolve(o.bnBlock.beforePos);e.tr.lift(i,a.depth)}}if(n){if(!t.isBlockContainer)throw new Error(`Attempted to merge block at position ${o.bnBlock.beforePos} into previous block at position ${t.bnBlock.beforePos}, but previous block is not a block container`);n(e.tr.delete(t.blockContent.afterPos-1,o.blockContent.beforePos+1))}return!0},an=e=>({state:n,dispatch:t})=>{const o=n.doc.resolve(e),r=ke(o),s=_e(n.doc,r.bnBlock.beforePos);if(!s)return!1;const i=nr(n.doc,s);return oa(i,r)?ra(n,t,i,r):!1},sa=k.Extension.create({priority:50,addKeyboardShortcuts(){const e=()=>this.editor.commands.first(({chain:o,commands:r})=>[()=>r.deleteSelection(),()=>r.undoInputRule(),()=>r.command(({state:s})=>{const i=E(s);if(!i.isBlockContainer)return!1;const a=s.selection.from===i.blockContent.beforePos+1,l=i.blockContent.node.type.name==="paragraph";return a&&!l?r.command(U(i.bnBlock.beforePos,{type:"paragraph",props:{}})):!1}),()=>r.command(({state:s})=>{const i=E(s);if(!i.isBlockContainer)return!1;const{blockContent:a}=i;return s.selection.from===a.beforePos+1?r.liftListItem("blockContainer"):!1}),()=>r.command(({state:s})=>{const i=E(s);if(!i.isBlockContainer)return!1;const{bnBlock:a,blockContent:l}=i,c=s.selection.from===l.beforePos+1,d=s.selection.empty,u=a.beforePos;return c&&d?o().command(an(u)).scrollIntoView().run():!1}),()=>r.command(({state:s,dispatch:i})=>{const a=E(s);if(!a.isBlockContainer||!(s.selection.from===a.blockContent.beforePos+1)||_e(s.doc,a.bnBlock.beforePos))return!1;const d=sn(s.doc,a.bnBlock.beforePos);if((d==null?void 0:d.blockNoteType)!=="column")return!1;const u=d,h=sn(s.doc,u.bnBlock.beforePos);if((h==null?void 0:h.blockNoteType)!=="columnList")throw new Error("parent of column is not a column list");const f=u.childContainer.node.childCount===1,m=f&&h.childContainer.node.childCount===2,g=h.childContainer.node.firstChild===u.bnBlock.node;if(i){const b=s.doc.slice(a.bnBlock.beforePos,a.bnBlock.afterPos,!1);if(m)if(g){s.tr.step(new he.ReplaceAroundStep(h.bnBlock.beforePos,h.bnBlock.afterPos,u.bnBlock.afterPos+1,h.bnBlock.afterPos-2,b,b.size,!1));const w=s.tr.doc.resolve(u.bnBlock.beforePos);s.tr.setSelection(y.TextSelection.between(w,w))}else{s.tr.step(new he.ReplaceAroundStep(h.bnBlock.beforePos,h.bnBlock.afterPos,h.bnBlock.beforePos+2,u.bnBlock.beforePos-1,b,0,!1));const w=s.tr.doc.resolve(s.tr.mapping.map(u.bnBlock.beforePos-1));s.tr.setSelection(y.TextSelection.between(w,w))}else if(f)if(g){s.tr.delete(u.bnBlock.beforePos,u.bnBlock.afterPos),s.tr.insert(h.bnBlock.beforePos,b.content);const w=s.tr.doc.resolve(h.bnBlock.beforePos);s.tr.setSelection(y.TextSelection.between(w,w))}else s.tr.delete(u.bnBlock.beforePos-1,u.bnBlock.beforePos+1);else{s.tr.delete(a.bnBlock.beforePos,a.bnBlock.afterPos),g?s.tr.insert(h.bnBlock.beforePos-1,b.content):s.tr.insert(u.bnBlock.beforePos-1,b.content);const w=s.tr.doc.resolve(u.bnBlock.beforePos-1);s.tr.setSelection(y.TextSelection.between(w,w))}}return!0}),()=>r.command(({state:s})=>{const i=E(s);if(!i.isBlockContainer)return!1;if(i.blockContent.node.childCount===0&&i.blockContent.node.type.spec.content==="inline*"){const l=_e(s.doc,i.bnBlock.beforePos);if(!l||!l.isBlockContainer)return!1;let c=o();if(l.blockContent.node.type.spec.content==="tableRow+"){const m=i.bnBlock.beforePos-1-1-1-1-1;c=c.setTextSelection(m)}else if(l.blockContent.node.type.spec.content===""){const d=l.blockContent.afterPos-l.blockContent.node.nodeSize;c=c.setNodeSelection(d)}else{const d=l.blockContent.afterPos-l.blockContent.node.nodeSize;c=c.setTextSelection(d)}return c.deleteRange({from:i.bnBlock.beforePos,to:i.bnBlock.afterPos}).scrollIntoView().run()}return!1}),()=>r.command(({state:s})=>{const i=E(s);if(!i.isBlockContainer)throw new Error("todo");const a=s.selection.from===i.blockContent.beforePos+1,l=s.selection.empty,c=_e(s.doc,i.bnBlock.beforePos);if(c&&a&&l){const d=nr(s.doc,c);if(!d.isBlockContainer)throw new Error("todo");if(d.blockContent.node.type.spec.content===""||d.blockContent.node.type.spec.content==="inline*"&&d.blockContent.node.childCount===0)return o().cut({from:i.bnBlock.beforePos,to:i.bnBlock.afterPos},d.bnBlock.afterPos).deleteRange({from:d.bnBlock.beforePos,to:d.bnBlock.afterPos}).run()}return!1})]),n=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.command(({state:r})=>{const s=E(r);if(!s.isBlockContainer)return!1;const{bnBlock:i,blockContent:a,childContainer:l}=s,{depth:c}=r.doc.resolve(i.beforePos),d=i.afterPos===r.doc.nodeSize-3,u=r.selection.from===a.afterPos-1,h=r.selection.empty;if(!d&&u&&h&&!(l!==void 0)){let m=c,g=i.afterPos+1,b=r.doc.resolve(g).depth;for(;b<m;)m=b,g+=2,b=r.doc.resolve(g).depth;return o.command(an(g-1))}return!1})]),t=(o=!1)=>this.editor.commands.first(({commands:r,tr:s})=>[()=>r.command(({state:i})=>{const a=E(i);if(!a.isBlockContainer)return!1;const{bnBlock:l,blockContent:c}=a,{depth:d}=i.doc.resolve(l.beforePos),u=i.selection.$anchor.parentOffset===0,h=i.selection.anchor===i.selection.head,f=c.node.childCount===0,m=d>1;return u&&h&&f&&m?r.liftListItem("blockContainer"):!1}),()=>r.command(({state:i})=>{const a=E(i),l=this.options.editor.schema.blockSchema[a.blockNoteType].hardBreakShortcut??"shift+enter";if(l==="none")return!1;if(l==="shift+enter"&&o||l==="enter"){const c=s.storedMarks||s.selection.$head.marks().filter(d=>this.editor.extensionManager.splittableMarks.includes(d.type.name));return s.insert(s.selection.head,s.doc.type.schema.nodes.hardBreak.create()).ensureMarks(c),!0}return!1}),()=>r.command(({state:i,dispatch:a})=>{const l=E(i);if(!l.isBlockContainer)return!1;const{bnBlock:c,blockContent:d}=l,u=i.selection.$anchor.parentOffset===0,h=i.selection.anchor===i.selection.head,f=d.node.childCount===0;if(u&&h&&f){const m=c.afterPos,g=m+2;if(a){const b=i.schema.nodes.blockContainer.createAndFill();i.tr.insert(m,b).scrollIntoView(),i.tr.setSelection(new y.TextSelection(i.doc.resolve(g)))}return!0}return!1}),()=>r.command(({state:i,chain:a})=>{const l=E(i);if(!l.isBlockContainer)return!1;const{blockContent:c}=l,d=i.selection.$anchor.parentOffset===0;return c.node.childCount===0?!1:(a().deleteSelection().command(fo(i.selection.from,d,d)).run(),!0)})]);return{Backspace:e,Delete:n,Enter:()=>t(),"Shift-Enter":()=>t(!0),Tab:()=>{var o,r,s;return this.options.tabBehavior!=="prefer-indent"&&((o=this.options.editor.formattingToolbar)!=null&&o.shown||(r=this.options.editor.linkToolbar)!=null&&r.shown||(s=this.options.editor.filePanel)!=null&&s.shown)?!1:Vo(this.options.editor)},"Shift-Tab":()=>{var o,r,s;return this.options.tabBehavior!=="prefer-indent"&&((o=this.options.editor.formattingToolbar)!=null&&o.shown||(r=this.options.editor.linkToolbar)!=null&&r.shown||(s=this.options.editor.filePanel)!=null&&s.shown)?!1:(this.editor.commands.liftListItem("blockContainer"),!0)},"Shift-Mod-ArrowUp":()=>(this.options.editor.moveBlocksUp(),!0),"Shift-Mod-ArrowDown":()=>(this.options.editor.moveBlocksDown(),!0),"Mod-z":()=>this.options.editor.undo(),"Mod-y":()=>this.options.editor.redo(),"Shift-Mod-z":()=>this.options.editor.redo()}}});class ia{constructor(n,t,o){p(this,"state");p(this,"emitUpdate");p(this,"menuUpdateTimer");p(this,"startMenuUpdateTimer");p(this,"stopMenuUpdateTimer");p(this,"mouseHoveredLinkMark");p(this,"mouseHoveredLinkMarkRange");p(this,"keyboardHoveredLinkMark");p(this,"keyboardHoveredLinkMarkRange");p(this,"linkMark");p(this,"linkMarkRange");p(this,"mouseOverHandler",n=>{if(this.mouseHoveredLinkMark=void 0,this.mouseHoveredLinkMarkRange=void 0,this.stopMenuUpdateTimer(),n.target instanceof HTMLAnchorElement&&n.target.nodeName==="A"){const t=n.target,o=this.pmView.posAtDOM(t,0)+1,r=this.pmView.state.doc.resolve(o),s=r.marks();for(const i of s)if(i.type.name===this.pmView.state.schema.mark("link").type.name){this.mouseHoveredLinkMark=i,this.mouseHoveredLinkMarkRange=k.getMarkRange(r,i.type,i.attrs)||void 0;break}}return this.startMenuUpdateTimer(),!1});p(this,"clickHandler",n=>{var o;const t=this.pmView.dom.parentElement;this.linkMark&&n&&n.target&&!(t===n.target||t.contains(n.target))&&(o=this.state)!=null&&o.show&&(this.state.show=!1,this.emitUpdate())});p(this,"scrollHandler",()=>{var n;this.linkMark!==void 0&&(n=this.state)!=null&&n.show&&(this.state.referencePos=k.posToDOMRect(this.pmView,this.linkMarkRange.from,this.linkMarkRange.to),this.emitUpdate())});p(this,"closeMenu",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())});this.editor=n,this.pmView=t,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized link toolbar");o(this.state)},this.startMenuUpdateTimer=()=>{this.menuUpdateTimer=setTimeout(()=>{this.update(this.pmView,void 0,!0)},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(n,t){var o;this.editor.transact(r=>{const s=R(r);r.insertText(t,this.linkMarkRange.from,this.linkMarkRange.to),r.addMark(this.linkMarkRange.from,this.linkMarkRange.from+t.length,s.mark("link",{href:n}))}),this.pmView.focus(),(o=this.state)!=null&&o.show&&(this.state.show=!1,this.emitUpdate())}deleteLink(){var n;this.editor.transact(t=>t.removeMark(this.linkMarkRange.from,this.linkMarkRange.to,this.linkMark.type).setMeta("preventAutolink",!0)),this.pmView.focus(),(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())}update(n,t,o=!1){var a;const{state:r}=n;if(t&&t.selection.from===r.selection.from&&t.selection.to===r.selection.to||!this.pmView.hasFocus())return;const i=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 l=this.pmView.state.selection.$from.marks();for(const c of l)if(c.type.name===this.pmView.state.schema.mark("link").type.name){this.keyboardHoveredLinkMark=c,this.keyboardHoveredLinkMarkRange=k.getMarkRange(this.pmView.state.selection.$from,c.type,c.attrs)||void 0;break}}if(this.mouseHoveredLinkMark&&o&&(this.linkMark=this.mouseHoveredLinkMark,this.linkMarkRange=this.mouseHoveredLinkMarkRange),this.keyboardHoveredLinkMark&&(this.linkMark=this.keyboardHoveredLinkMark,this.linkMarkRange=this.keyboardHoveredLinkMarkRange),this.linkMark&&this.editor.isEditable){this.state={show:!0,referencePos:k.posToDOMRect(this.pmView,this.linkMarkRange.from,this.linkMarkRange.to),url:this.linkMark.attrs.href,text:this.pmView.state.doc.textBetween(this.linkMarkRange.from,this.linkMarkRange.to)},this.emitUpdate();return}if((a=this.state)!=null&&a.show&&i&&(!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 or=new y.PluginKey("LinkToolbarPlugin");class rr extends O{constructor(t){super();p(this,"view");p(this,"editLink",(t,o)=>{this.view.editLink(t,o)});p(this,"deleteLink",()=>{this.view.deleteLink()});p(this,"startHideTimer",()=>{this.view.startMenuUpdateTimer()});p(this,"stopHideTimer",()=>{this.view.stopMenuUpdateTimer()});p(this,"closeMenu",()=>this.view.closeMenu());this.addProsemirrorPlugin(new y.Plugin({key:or,view:o=>(this.view=new ia(t,o,r=>{this.emit("update",r)}),this.view),props:{handleKeyDown:(o,r)=>r.key==="Escape"&&this.shown?(this.view.closeMenu(),!0):!1}}))}static key(){return"linkToolbar"}onUpdate(t){return this.on("update",t)}get shown(){var t,o;return((o=(t=this.view)==null?void 0:t.state)==null?void 0:o.show)||!1}}const sr=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"],ir="https",aa=new y.PluginKey("node-selection-keyboard");class la extends O{static key(){return"nodeSelectionKeyboard"}constructor(){super(),this.addProsemirrorPlugin(new y.Plugin({key:aa,props:{handleKeyDown:(n,t)=>{if("node"in n.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=n.state.tr;return n.dispatch(o.insert(n.state.tr.selection.$to.after(),n.state.schema.nodes.paragraph.createChecked()).setSelection(new y.TextSelection(o.doc.resolve(n.state.tr.selection.$to.after()+1)))),!0}}return!1}}}))}}const ca=new y.PluginKey("blocknote-placeholder");class da extends O{static key(){return"placeholder"}constructor(n,t){super(),this.addProsemirrorPlugin(new y.Plugin({key:ca,view:o=>{var c,d;const r=`placeholder-selector-${fn.v4()}`;o.dom.classList.add(r);const s=document.createElement("style"),i=n._tiptapEditor.options.injectNonce;i&&s.setAttribute("nonce",i),((c=n.prosemirrorView)==null?void 0:c.root)instanceof ShadowRoot?n.prosemirrorView.root.append(s):(d=n.prosemirrorView)==null||d.root.head.appendChild(s);const a=s.sheet,l=(u="")=>`.${r} .bn-block-content${u} .bn-inline-content:has(> .ProseMirror-trailingBreak:only-child):before`;try{const{default:u,emptyDocument:h,...f}=t;for(const[b,w]of Object.entries(f)){const C=`[data-content-type="${b}"]`;a.insertRule(`${l(C)} { content: ${JSON.stringify(w)}; }`)}const m="[data-is-only-empty-block]",g="[data-is-empty-and-focused]";a.insertRule(`${l(m)} { content: ${JSON.stringify(h)}; }`),a.insertRule(`${l(g)} { content: ${JSON.stringify(u)}; }`)}catch(u){console.warn("Failed to insert placeholder CSS rule - this is likely due to the browser not supporting certain CSS pseudo-element selectors (:has, :only-child:, or :before)",u)}return{destroy:()=>{var u,h;((u=n.prosemirrorView)==null?void 0:u.root)instanceof ShadowRoot?n.prosemirrorView.root.removeChild(s):(h=n.prosemirrorView)==null||h.root.head.removeChild(s)}}},props:{decorations:o=>{const{doc:r,selection:s}=o;if(!n.isEditable||!s.empty||s.$from.parent.type.spec.code)return;const i=[];o.doc.content.size===6&&i.push(D.Decoration.node(2,4,{"data-is-only-empty-block":"true"}));const a=s.$anchor,l=a.parent;if(l.content.size===0){const c=a.before();i.push(D.Decoration.node(c,c+l.nodeSize,{"data-is-empty-and-focused":"true"}))}return D.DecorationSet.create(r,i)}}}))}}const ln=new y.PluginKey("previous-blocks"),ua={index:"index",level:"level",type:"type",depth:"depth","depth-change":"depth-change"};class pa extends O{static key(){return"previousBlockType"}constructor(){super();let n;this.addProsemirrorPlugin(new y.Plugin({key:ln,view(t){return{update:async(o,r)=>{var s;((s=this.key)==null?void 0:s.getState(o.state).updatedBlocks.size)>0&&(n=setTimeout(()=>{o.dispatch(o.state.tr.setMeta(ln,{clearUpdate:!0}))},0))},destroy:()=>{n&&clearTimeout(n)}}},state:{init(){return{prevTransactionOldBlockAttrs:{},currentTransactionOldBlockAttrs:{},updatedBlocks:new Set}},apply(t,o,r,s){if(o.currentTransactionOldBlockAttrs={},o.updatedBlocks.clear(),!t.docChanged||r.doc.eq(s.doc))return o;const i={},a=k.findChildren(r.doc,d=>d.attrs.id),l=new Map(a.map(d=>[d.node.attrs.id,d])),c=k.findChildren(s.doc,d=>d.attrs.id);for(const d of c){const u=l.get(d.node.attrs.id),h=u==null?void 0:u.node.firstChild,f=d.node.firstChild;if(u&&h&&f){const m={index:f.attrs.index,level:f.attrs.level,type:f.type.name,depth:s.doc.resolve(d.pos).depth};let g={index:h.attrs.index,level:h.attrs.level,type:h.type.name,depth:r.doc.resolve(u.pos).depth};i[d.node.attrs.id]=g,t.getMeta("numberedListIndexing")&&(d.node.attrs.id in o.prevTransactionOldBlockAttrs&&(g=o.prevTransactionOldBlockAttrs[d.node.attrs.id]),m.type==="numberedListItem"&&(g.index=m.index)),o.currentTransactionOldBlockAttrs[d.node.attrs.id]=g,JSON.stringify(g)!==JSON.stringify(m)&&(g["depth-change"]=g.depth-m.depth,o.updatedBlocks.add(d.node.attrs.id))}}return o.prevTransactionOldBlockAttrs=i,o}},props:{decorations(t){const o=this.getState(t);if(o.updatedBlocks.size===0)return;const r=[];return t.doc.descendants((s,i)=>{if(!s.attrs.id||!o.updatedBlocks.has(s.attrs.id))return;const a=o.currentTransactionOldBlockAttrs[s.attrs.id],l={};for(const[d,u]of Object.entries(a))l["data-prev-"+ua[d]]=u||"none";const c=D.Decoration.node(i,i+s.nodeSize,{...l});r.push(c)}),D.DecorationSet.create(t.doc,r)}}}))}}const cn=new y.PluginKey("blocknote-show-selection");class ha extends O{constructor(t){super();p(this,"enabled",!1);this.editor=t,this.addProsemirrorPlugin(new y.Plugin({key:cn,props:{decorations:o=>{const{doc:r,selection:s}=o;if(!this.enabled)return D.DecorationSet.empty;const i=D.Decoration.inline(s.from,s.to,{"data-show-selection":"true"});return D.DecorationSet.create(r,[i])}}}))}static key(){return"showSelection"}setEnabled(t){this.enabled!==t&&(this.enabled=t,this.editor.transact(o=>o.setMeta(cn,{})))}getEnabled(){return this.enabled}}function ar(e,n){var t,o;for(;e&&e.parentElement&&e.parentElement!==n.dom&&((t=e.getAttribute)==null?void 0:t.call(e,"data-node-type"))!=="blockContainer";)e=e.parentElement;if(((o=e.getAttribute)==null?void 0:o.call(e,"data-node-type"))==="blockContainer")return{node:e,id:e.getAttribute("data-id")}}class ae extends y.Selection{constructor(t,o){super(t,o);p(this,"nodes");const r=t.node();this.nodes=[],t.doc.nodesBetween(t.pos,o.pos,(s,i,a)=>{if(a!==null&&a.eq(r))return this.nodes.push(s),!1})}static create(t,o,r=o){return new ae(t.resolve(o),t.resolve(r))}content(){return new S.Slice(S.Fragment.from(this.nodes),0,0)}eq(t){if(!(t instanceof ae)||this.nodes.length!==t.nodes.length||this.from!==t.from||this.to!==t.to)return!1;for(let o=0;o<this.nodes.length;o++)if(!this.nodes[o].eq(t.nodes[o]))return!1;return!0}map(t,o){const r=o.mapResult(this.from),s=o.mapResult(this.to);return s.deleted?y.Selection.near(t.resolve(r.pos)):r.deleted?y.Selection.near(t.resolve(s.pos)):new ae(t.resolve(r.pos),t.resolve(s.pos))}toJSON(){return{type:"multiple-node",anchor:this.anchor,head:this.head}}}y.Selection.jsonID("multiple-node",ae);let Y;function fa(e,n){let t,o;const r=n.resolve(e.from).node().type.spec.group==="blockContent",s=n.resolve(e.to).node().type.spec.group==="blockContent",i=Math.min(e.$anchor.depth,e.$head.depth);if(r&&s){const a=e.$from.start(i-1),l=e.$to.end(i-1);t=n.resolve(a-1).pos,o=n.resolve(l+1).pos}else t=e.from,o=e.to;return{from:t,to:o}}function dn(e,n,t=n){n===t&&(t+=e.state.doc.resolve(n+1).node().nodeSize);const o=e.domAtPos(n).node.cloneNode(!0),r=e.domAtPos(n).node,s=(u,h)=>Array.prototype.indexOf.call(u.children,h),i=s(r,e.domAtPos(n+1).node.parentElement),a=s(r,e.domAtPos(t-1).node.parentElement);for(let u=r.childElementCount-1;u>=0;u--)(u>a||u<i)&&o.removeChild(o.children[u]);lr(e.root),Y=o;const l=Y.getElementsByTagName("iframe");for(let u=0;u<l.length;u++){const h=l[u],f=h.parentElement;f&&f.removeChild(h)}const d=e.dom.className.split(" ").filter(u=>u!=="ProseMirror"&&u!=="bn-root"&&u!=="bn-editor").join(" ");Y.className=Y.className+" bn-drag-preview "+d,e.root instanceof ShadowRoot?e.root.appendChild(Y):e.root.body.appendChild(Y)}function lr(e){Y!==void 0&&(e instanceof ShadowRoot?e.removeChild(Y):e.body.removeChild(Y),Y=void 0)}function ma(e,n,t){if(!e.dataTransfer)return;const o=t.prosemirrorView;if(!o)return;const r=z(n.id,o.state.doc);if(!r)throw new Error(`Block with ID ${n.id} not found`);const s=r.posBeforeNode;if(s!=null){const i=o.state.selection,a=o.state.doc,{from:l,to:c}=fa(i,a),d=l<=s&&s<c,u=i.$anchor.node()!==i.$head.node()||i instanceof ae;d&&u?(o.dispatch(o.state.tr.setSelection(ae.create(a,l,c))),dn(o,l,c)):(o.dispatch(o.state.tr.setSelection(y.NodeSelection.create(o.state.doc,s))),dn(o,s));const h=o.state.selection.content(),f=t.pmSchema,m=o.serializeForClipboard(h).dom.innerHTML,g=Me(f,t),b=Yo(h.content),w=g.exportBlocks(b,{}),C=nt(w);e.dataTransfer.clearData(),e.dataTransfer.setData("blocknote/html",m),e.dataTransfer.setData("text/html",w),e.dataTransfer.setData("text/plain",C),e.dataTransfer.effectAllowed="move",e.dataTransfer.setDragImage(Y,0,0)}}const un=250;function vt(e,n,t=!0){const o=e.root.elementsFromPoint(n.left,n.top);for(const r of o)if(e.dom.contains(r))return t&&r.closest("[data-node-type=columnList]")?vt(e,{left:n.left+50,top:n.top},!1):ar(r,e)}function ga(e,n){if(!n.dom.firstChild)return;const t=n.dom.firstChild.getBoundingClientRect(),o={left:Math.min(Math.max(t.left+10,e.x),t.right-10),top:e.y},r=vt(n,o);if(!r)return;const s=r.node.getBoundingClientRect();return vt(n,{left:s.right-10,top:e.y},!1)}class cr{constructor(n,t,o){p(this,"state");p(this,"emitUpdate");p(this,"mousePos");p(this,"hoveredBlock");p(this,"menuFrozen",!1);p(this,"isDragOrigin",!1);p(this,"updateState",n=>{this.state=n,this.emitUpdate(this.state)});p(this,"updateStateFromMousePos",()=>{var r,s,i,a,l;if(this.menuFrozen||!this.mousePos)return;const n=this.findClosestEditorElement({clientX:this.mousePos.x,clientY:this.mousePos.y});if((n==null?void 0:n.element)!==this.pmView.dom||n.distance>un){(r=this.state)!=null&&r.show&&(this.state.show=!1,this.updateState(this.state));return}const t=ga(this.mousePos,this.pmView);if(!t||!this.editor.isEditable){(s=this.state)!=null&&s.show&&(this.state.show=!1,this.updateState(this.state));return}if((i=this.state)!=null&&i.show&&((a=this.hoveredBlock)!=null&&a.hasAttribute("data-id"))&&((l=this.hoveredBlock)==null?void 0:l.getAttribute("data-id"))===t.id)return;this.hoveredBlock=t.node;const o=t.node.firstChild;if(o&&this.editor.isEditable){const c=o.getBoundingClientRect(),d=t.node.closest("[data-node-type=column]");this.updateState({show:!0,referencePos:new DOMRect(d?d.firstElementChild.getBoundingClientRect().x:this.pmView.dom.firstChild.getBoundingClientRect().x,c.y,c.width,c.height),block:this.editor.getBlock(this.hoveredBlock.getAttribute("data-id"))})}});p(this,"onDragStart",n=>{var i;const t=(i=n.dataTransfer)==null?void 0:i.getData("blocknote/html");if(!t||this.pmView.dragging)return;const o=document.createElement("div");o.innerHTML=t;const s=S.DOMParser.fromSchema(this.pmView.state.schema).parse(o,{topNode:this.pmView.state.schema.nodes.blockGroup.create()});this.pmView.dragging={slice:new S.Slice(s.content,0,0),move:!0}});p(this,"findClosestEditorElement",n=>{const t=Array.from(this.pmView.root.querySelectorAll(".bn-editor"));if(t.length===0)return null;let o=t[0],r=Number.MAX_VALUE;return t.forEach(s=>{const i=s.querySelector(".bn-block-group").getBoundingClientRect(),a=n.clientX<i.left?i.left-n.clientX:n.clientX>i.right?n.clientX-i.right:0,l=n.clientY<i.top?i.top-n.clientY:n.clientY>i.bottom?n.clientY-i.bottom:0,c=Math.sqrt(Math.pow(a,2)+Math.pow(l,2));c<r&&(r=c,o=s)}),{element:o,distance:r}});p(this,"onDragOver",n=>{if(n.synthetic)return;const t=this.getDragEventContext(n);if(!t||!t.isDropPoint){this.closeDropCursor();return}t.isDropPoint&&!t.isDropWithinEditorBounds&&this.dispatchSyntheticEvent(n)});p(this,"closeDropCursor",()=>{const n=new Event("dragleave",{bubbles:!1});n.synthetic=!0,this.pmView.dom.dispatchEvent(n)});p(this,"getDragEventContext",n=>{var l;const t=!((l=n.dataTransfer)!=null&&l.types.includes("blocknote/html"))&&!!this.pmView.dragging,o=!!this.isDragOrigin,r=t||o,s=this.findClosestEditorElement(n);if(!s||s.distance>un)return;const i=s.element===this.pmView.dom,a=i&&s.distance===0;if(!(!i&&!r))return{isDropPoint:i,isDropWithinEditorBounds:a,isDragOrigin:r}});p(this,"onDrop",n=>{if(n.synthetic)return;const t=this.getDragEventContext(n);if(!t){this.closeDropCursor();return}const{isDropPoint:o,isDropWithinEditorBounds:r,isDragOrigin:s}=t;if(r||this.dispatchSyntheticEvent(n),!(o&&s)){if(o){this.pmView.dispatch(this.pmView.state.tr.setSelection(y.TextSelection.create(this.pmView.state.tr.doc,this.pmView.state.tr.selection.anchor)));return}else if(s){setTimeout(()=>this.pmView.dispatch(this.pmView.state.tr.deleteSelection()),0);return}}});p(this,"onDragEnd",n=>{n.synthetic||(this.pmView.dragging=null)});p(this,"onKeyDown",n=>{var t;(t=this.state)!=null&&t.show&&this.editor.isFocused()&&(this.state.show=!1,this.emitUpdate(this.state))});p(this,"onMouseMove",n=>{var s;if(this.menuFrozen)return;this.mousePos={x:n.clientX,y:n.clientY};const t=this.pmView.dom.getBoundingClientRect(),o=this.mousePos.x>t.left&&this.mousePos.x<t.right&&this.mousePos.y>t.top&&this.mousePos.y<t.bottom,r=this.pmView.dom.parentElement;if(o&&n&&n.target&&!(r===n.target||r.contains(n.target))){(s=this.state)!=null&&s.show&&(this.state.show=!1,this.emitUpdate(this.state));return}this.updateStateFromMousePos()});p(this,"onScroll",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.referencePos=this.hoveredBlock.getBoundingClientRect(),this.emitUpdate(this.state)),this.updateStateFromMousePos()});this.editor=n,this.pmView=t,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized side menu");o(this.state)},this.pmView.root.addEventListener("dragstart",this.onDragStart),this.pmView.root.addEventListener("dragover",this.onDragOver),this.pmView.root.addEventListener("drop",this.onDrop,!0),this.pmView.root.addEventListener("dragend",this.onDragEnd,!0),tt(),this.pmView.root.addEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.addEventListener("keydown",this.onKeyDown,!0),t.root.addEventListener("scroll",this.onScroll,!0)}dispatchSyntheticEvent(n){const t=new Event(n.type,n),o=this.pmView.dom.firstChild.getBoundingClientRect();t.clientX=n.clientX,t.clientY=n.clientY,t.clientX=Math.min(Math.max(n.clientX,o.left),o.left+o.width),t.clientY=Math.min(Math.max(n.clientY,o.top),o.top+o.height),t.dataTransfer=n.dataTransfer,t.preventDefault=()=>n.preventDefault(),t.synthetic=!0,this.pmView.dom.dispatchEvent(t)}update(n,t){var r;!t.doc.eq(this.pmView.state.doc)&&((r=this.state)!=null&&r.show)&&this.updateStateFromMousePos()}destroy(){var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate(this.state)),this.pmView.root.removeEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.removeEventListener("dragstart",this.onDragStart),this.pmView.root.removeEventListener("dragover",this.onDragOver),this.pmView.root.removeEventListener("drop",this.onDrop,!0),this.pmView.root.removeEventListener("dragend",this.onDragEnd,!0),this.pmView.root.removeEventListener("keydown",this.onKeyDown,!0),this.pmView.root.removeEventListener("scroll",this.onScroll,!0)}}const dr=new y.PluginKey("SideMenuPlugin");class ur extends O{constructor(t){super();p(this,"view");p(this,"blockDragStart",(t,o)=>{this.view&&(this.view.isDragOrigin=!0),ma(t,o,this.editor)});p(this,"blockDragEnd",()=>{this.editor.prosemirrorView&&lr(this.editor.prosemirrorView.root),this.view&&(this.view.isDragOrigin=!1)});p(this,"freezeMenu",()=>{this.view.menuFrozen=!0,this.view.state.show=!0,this.view.emitUpdate(this.view.state)});p(this,"unfreezeMenu",()=>{this.view.menuFrozen=!1,this.view.state.show=!1,this.view.emitUpdate(this.view.state)});this.editor=t,this.addProsemirrorPlugin(new y.Plugin({key:dr,view:o=>(this.view=new cr(t,o,r=>{this.emit("update",r)}),this.view)}))}static key(){return"sideMenu"}onUpdate(t){return this.on("update",t)}}const De=new Map;function ba(e){if(De.has(e))return De.get(e);const n=new he.Mapping;return e._tiptapEditor.on("transaction",({transaction:t})=>{n.appendMapping(t.mapping)}),e._tiptapEditor.on("destroy",()=>{De.delete(e)}),De.set(e,n),n}function pr(e,n,t="left"){const o=N.ySyncPluginKey.getState(e._tiptapEditor.state);if(!o){const s=ba(e),i=s.maps.length;return()=>s.slice(i).map(n,t==="left"?-1:1)}const r=N.absolutePositionToRelativePosition(n+(t==="right"?1:0),o.binding.type,o.binding.mapping);return()=>{const s=N.ySyncPluginKey.getState(e._tiptapEditor.state),i=N.relativePositionToAbsolutePosition(s.doc,s.binding.type,r,s.binding.mapping);if(i===null)throw new Error("Position not found, cannot track positions");return i+(t==="right"?-1:0)}}const ka=k.findParentNode(e=>e.type.name==="blockContainer");class wa{constructor(n,t){p(this,"state");p(this,"emitUpdate");p(this,"rootEl");p(this,"pluginState");p(this,"handleScroll",()=>{var n,t;if((n=this.state)!=null&&n.show){const o=(t=this.rootEl)==null?void 0:t.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);if(!o)return;this.state.referencePos=o.getBoundingClientRect(),this.emitUpdate(this.pluginState.triggerCharacter)}});p(this,"closeMenu",()=>{this.editor.transact(n=>n.setMeta(pe,null))});p(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.transact(n=>n.selection.from)}).run()});var o,r;this.editor=n,this.pluginState=void 0,this.emitUpdate=s=>{var i;if(!this.state)throw new Error("Attempting to update uninitialized suggestions menu");t(s,{...this.state,ignoreQueryLength:(i=this.pluginState)==null?void 0:i.ignoreQueryLength})},this.rootEl=(o=this.editor.prosemirrorView)==null?void 0:o.root,(r=this.rootEl)==null||r.addEventListener("scroll",this.handleScroll,!0)}update(n,t){var c;const o=pe.getState(t),r=pe.getState(n.state),s=o===void 0&&r!==void 0,i=o!==void 0&&r===void 0;if(!s&&!(o!==void 0&&r!==void 0)&&!i)return;if(this.pluginState=i?o:r,i||!this.editor.isEditable){this.state&&(this.state.show=!1),this.emitUpdate(this.pluginState.triggerCharacter);return}const l=(c=this.rootEl)==null?void 0:c.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);this.editor.isEditable&&l&&(this.state={show:!0,referencePos:l.getBoundingClientRect(),query:this.pluginState.query},this.emitUpdate(this.pluginState.triggerCharacter))}destroy(){var n;(n=this.rootEl)==null||n.removeEventListener("scroll",this.handleScroll,!0)}}const pe=new y.PluginKey("SuggestionMenuPlugin");class hr extends O{constructor(t){super();p(this,"view");p(this,"triggerCharacters",[]);p(this,"addTriggerCharacter",t=>{this.triggerCharacters.push(t)});p(this,"removeTriggerCharacter",t=>{this.triggerCharacters=this.triggerCharacters.filter(o=>o!==t)});p(this,"closeMenu",()=>this.view.closeMenu());p(this,"clearQuery",()=>this.view.clearQuery());const o=this.triggerCharacters;this.addProsemirrorPlugin(new y.Plugin({key:pe,view:()=>(this.view=new wa(t,(r,s)=>{this.emit(`update ${r}`,s)}),this.view),state:{init(){},apply:(r,s,i,a)=>{if(r.getMeta("orderedListIndexing")!==void 0||r.selection.$from.parent.type.spec.code)return s;const l=r.getMeta(pe);if(typeof l=="object"&&l!==null){s&&this.closeMenu();const d=pr(t,a.selection.from-l.triggerCharacter.length);return{triggerCharacter:l.triggerCharacter,deleteTriggerCharacter:l.deleteTriggerCharacter!==!1,queryStartPos:()=>d()+l.triggerCharacter.length,query:"",decorationId:`id_${Math.floor(Math.random()*4294967295)}`,ignoreQueryLength:l==null?void 0:l.ignoreQueryLength}}if(s===void 0)return s;if(a.selection.from!==a.selection.to||l===null||r.getMeta("focus")||r.getMeta("blur")||r.getMeta("pointer")||s.triggerCharacter!==void 0&&a.selection.from<s.queryStartPos()||!a.selection.$from.sameParent(a.doc.resolve(s.queryStartPos())))return;const c={...s};return c.query=a.doc.textBetween(s.queryStartPos(),a.selection.from),c}},props:{handleTextInput(r,s,i,a){if(s===i){const l=r.state.doc;for(const c of o){const d=c.length>1?l.textBetween(s-c.length,s)+a:a;if(c===d)return r.dispatch(r.state.tr.insertText(a)),r.dispatch(r.state.tr.setMeta(pe,{triggerCharacter:d}).scrollIntoView()),!0}}return!1},decorations(r){const s=this.getState(r);if(s===void 0)return null;if(!s.deleteTriggerCharacter){const i=ka(r.selection);if(i)return D.DecorationSet.create(r.doc,[D.Decoration.node(i.pos,i.pos+i.node.nodeSize,{nodeName:"span",class:"bn-suggestion-decorator","data-decoration-id":s.decorationId})])}return D.DecorationSet.create(r.doc,[D.Decoration.inline(s.queryStartPos()-s.triggerCharacter.length,s.queryStartPos(),{nodeName:"span",class:"bn-suggestion-decorator","data-decoration-id":s.decorationId})])}}}))}static key(){return"suggestionMenu"}onUpdate(t,o){return this.triggerCharacters.includes(t)||this.addTriggerCharacter(t),this.on(`update ${t}`,o)}get shown(){var t,o;return((o=(t=this.view)==null?void 0:t.state)==null?void 0:o.show)||!1}}function ya(e,n){e.suggestionMenus.addTriggerCharacter(n)}const Ca=k.Mark.create({name:"insertion",inclusive:!1,excludes:"deletion modification insertion",addAttributes(){return{id:{default:null,validate:"number"}}},extendMarkSchema(e){return e.name!=="insertion"?{}:{blocknoteIgnore:!0,inclusive:!1,toDOM(n,t){return["ins",{"data-id":String(n.attrs.id),"data-inline":String(t),...!t&&{style:"display: contents"}},0]},parseDOM:[{tag:"ins",getAttrs(n){return n.dataset.id?{id:parseInt(n.dataset.id,10)}:!1}}]}}}),va=k.Mark.create({name:"deletion",inclusive:!1,excludes:"insertion modification deletion",addAttributes(){return{id:{default:null,validate:"number"}}},extendMarkSchema(e){return e.name!=="deletion"?{}:{blocknoteIgnore:!0,inclusive:!1,toDOM(n,t){return["del",{"data-id":String(n.attrs.id),"data-inline":String(t),...!t&&{style:"display: contents"}},0]},parseDOM:[{tag:"del",getAttrs(n){return n.dataset.id?{id:parseInt(n.dataset.id,10)}:!1}}]}}}),Sa=k.Mark.create({name:"modification",inclusive:!1,excludes:"deletion insertion",addAttributes(){return{id:{default:null,validate:"number"},type:{validate:"string"},attrName:{default:null,validate:"string|null"},previousValue:{default:null},newValue:{default:null}}},extendMarkSchema(e){return e.name!=="modification"?{}:{blocknoteIgnore:!0,inclusive:!1,toDOM(n,t){return[t?"span":"div",{"data-type":"modification","data-id":String(n.attrs.id),"data-mod-type":n.attrs.type,"data-mod-prev-val":JSON.stringify(n.attrs.previousValue),"data-mod-new-val":JSON.stringify(n.attrs.newValue)},0]},parseDOM:[{tag:"span[data-type='modification']",getAttrs(n){return n.dataset.id?{id:parseInt(n.dataset.id,10),type:n.dataset.modType,previousValue:n.dataset.modPrevVal,newValue:n.dataset.modNewVal}:!1}},{tag:"div[data-type='modification']",getAttrs(n){return n.dataset.id?{id:parseInt(n.dataset.id,10),type:n.dataset.modType,previousValue:n.dataset.modPrevVal}:!1}}]}}});let F;function pn(e){F||(F=document.createElement("div"),F.innerHTML="_",F.style.opacity="0",F.style.height="1px",F.style.width="1px",e instanceof Document?e.body.appendChild(F):e.appendChild(F))}function Ea(e){F&&(e instanceof Document?e.body.removeChild(F):e.removeChild(F),F=void 0)}function He(e){return Array.prototype.indexOf.call(e.parentElement.childNodes,e)}function Ba(e){let n=e;for(;n&&n.nodeName!=="TD"&&n.nodeName!=="TH"&&!n.classList.contains("tableWrapper");){if(n.classList.contains("ProseMirror"))return;const t=n.parentNode;if(!t||!(t instanceof Element))return;n=t}return n.nodeName==="TD"||n.nodeName==="TH"?{type:"cell",domNode:n,tbodyNode:n.closest("tbody")}:{type:"wrapper",domNode:n,tbodyNode:n.querySelector("tbody")}}function Ta(e,n){const t=n.querySelectorAll(e);for(let o=0;o<t.length;o++)t[o].style.visibility="hidden"}class fr{constructor(n,t,o){p(this,"state");p(this,"emitUpdate");p(this,"tableId");p(this,"tablePos");p(this,"tableElement");p(this,"menuFrozen",!1);p(this,"mouseState","up");p(this,"prevWasEditable",null);p(this,"viewMousedownHandler",()=>{this.mouseState="down"});p(this,"mouseUpHandler",n=>{this.mouseState="up",this.mouseMoveHandler(n)});p(this,"mouseMoveHandler",n=>{var c,d,u,h,f,m,g;if(this.menuFrozen||this.mouseState==="selecting"||!(n.target instanceof Element)||!this.pmView.dom.contains(n.target))return;const t=Ba(n.target);if((t==null?void 0:t.type)==="cell"&&this.mouseState==="down"&&!((c=this.state)!=null&&c.draggingState)){this.mouseState="selecting",(d=this.state)!=null&&d.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate());return}if(!t||!this.editor.isEditable){(u=this.state)!=null&&u.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate());return}if(!t.tbodyNode)return;const o=t.tbodyNode.getBoundingClientRect(),r=ar(t.domNode,this.pmView);if(!r)return;this.tableElement=r.node;let s;const i=this.editor.transact(b=>z(r.id,b.doc));if(!i)throw new Error(`Block with ID ${r.id} not found`);const a=B(i.node,this.editor.pmSchema,this.editor.schema.blockSchema,this.editor.schema.inlineContentSchema,this.editor.schema.styleSchema);if(xo("table",a,this.editor)&&(this.tablePos=i.posBeforeNode+1,s=a),!s)return;this.tableId=r.id;const l=(h=t.domNode.closest(".tableWrapper"))==null?void 0:h.querySelector(".table-widgets-container");if((t==null?void 0:t.type)==="wrapper"){const b=n.clientY>=o.bottom-1&&n.clientY<o.bottom+20,w=n.clientX>=o.right-1&&n.clientX<o.right+20,C=n.clientX>o.right||n.clientY>o.bottom;this.state={...this.state,show:!0,showAddOrRemoveRowsButton:b,showAddOrRemoveColumnsButton:w,referencePosTable:o,block:s,widgetContainer:l,colIndex:C||(f=this.state)==null?void 0:f.colIndex,rowIndex:C||(m=this.state)==null?void 0:m.rowIndex,referencePosCell:C||(g=this.state)==null?void 0:g.referencePosCell}}else{const b=He(t.domNode),w=He(t.domNode.parentElement),C=t.domNode.getBoundingClientRect();if(this.state!==void 0&&this.state.show&&this.tableId===r.id&&this.state.rowIndex===w&&this.state.colIndex===b)return;this.state={show:!0,showAddOrRemoveColumnsButton:b===s.content.rows[0].cells.length-1,showAddOrRemoveRowsButton:w===s.content.rows.length-1,referencePosTable:o,block:s,draggingState:void 0,referencePosCell:C,colIndex:b,rowIndex:w,widgetContainer:l}}return this.emitUpdate(),!1});p(this,"dragOverHandler",n=>{var h;if(((h=this.state)==null?void 0:h.draggingState)===void 0)return;n.preventDefault(),n.dataTransfer.dropEffect="move",Ta(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline",this.pmView.root);const t={left:Math.min(Math.max(n.clientX,this.state.referencePosTable.left+1),this.state.referencePosTable.right-1),top:Math.min(Math.max(n.clientY,this.state.referencePosTable.top+1),this.state.referencePosTable.bottom-1)},o=this.pmView.root.elementsFromPoint(t.left,t.top).filter(f=>f.tagName==="TD"||f.tagName==="TH");if(o.length===0)return;const r=o[0];let s=!1;const i=He(r.parentElement),a=He(r),l=this.state.draggingState.draggedCellOrientation==="row"?this.state.rowIndex:this.state.colIndex,d=(this.state.draggingState.draggedCellOrientation==="row"?i:a)!==l;(this.state.rowIndex!==i||this.state.colIndex!==a)&&(this.state.rowIndex=i,this.state.colIndex=a,this.state.referencePosCell=r.getBoundingClientRect(),s=!0);const u=this.state.draggingState.draggedCellOrientation==="row"?t.top:t.left;this.state.draggingState.mousePos!==u&&(this.state.draggingState.mousePos=u,s=!0),s&&this.emitUpdate(),d&&this.editor.transact(f=>f.setMeta(de,!0))});p(this,"dropHandler",n=>{if(this.mouseState="up",this.state===void 0||this.state.draggingState===void 0)return!1;if(this.state.rowIndex===void 0||this.state.colIndex===void 0)throw new Error("Attempted to drop table row or column, but no table block was hovered prior.");n.preventDefault();const{draggingState:t,colIndex:o,rowIndex:r}=this.state,s=this.state.block.content.columnWidths;if(t.draggedCellOrientation==="row"){if(!Mn(this.state.block,t.originalIndex,r))return!1;const i=ts(this.state.block,t.originalIndex,r);this.editor.updateBlock(this.state.block,{type:"table",content:{...this.state.block.content,rows:i}})}else{if(!In(this.state.block,t.originalIndex,o))return!1;const i=es(this.state.block,t.originalIndex,o),[a]=s.splice(t.originalIndex,1);s.splice(o,0,a),this.editor.updateBlock(this.state.block,{type:"table",content:{...this.state.block.content,columnWidths:s,rows:i}})}return this.editor.setTextCursorPosition(this.state.block.id),!0});this.editor=n,this.pmView=t,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized image toolbar");o(this.state)},t.dom.addEventListener("mousemove",this.mouseMoveHandler),t.dom.addEventListener("mousedown",this.viewMousedownHandler),window.addEventListener("mouseup",this.mouseUpHandler),t.root.addEventListener("dragover",this.dragOverHandler),t.root.addEventListener("drop",this.dropHandler)}update(){var r;if(!this.state||!this.state.show)return;if(this.state.block=this.editor.getBlock(this.state.block.id),!this.state.block||this.state.block.type!=="table"||!((r=this.tableElement)!=null&&r.isConnected)){this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate();return}const{height:n,width:t}=Lt(this.state.block);this.state.rowIndex!==void 0&&this.state.colIndex!==void 0&&(this.state.rowIndex>=n&&(this.state.rowIndex=n-1),this.state.colIndex>=t&&(this.state.colIndex=t-1));const o=this.tableElement.querySelector("tbody");if(!o)throw new Error("Table block does not contain a 'tbody' HTML element. This should never happen.");if(this.state.rowIndex!==void 0&&this.state.colIndex!==void 0){const i=o.children[this.state.rowIndex].children[this.state.colIndex];i?this.state.referencePosCell=i.getBoundingClientRect():(this.state.rowIndex=void 0,this.state.colIndex=void 0)}this.state.referencePosTable=o.getBoundingClientRect(),this.emitUpdate()}destroy(){this.pmView.dom.removeEventListener("mousemove",this.mouseMoveHandler),window.removeEventListener("mouseup",this.mouseUpHandler),this.pmView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.pmView.root.removeEventListener("dragover",this.dragOverHandler),this.pmView.root.removeEventListener("drop",this.dropHandler)}}const de=new y.PluginKey("TableHandlesPlugin");class mr extends O{constructor(t){super();p(this,"view");p(this,"colDragStart",t=>{if(this.view.state===void 0||this.view.state.colIndex===void 0)throw new Error("Attempted to drag table column, but no table block was hovered prior.");if(this.view.state.draggingState={draggedCellOrientation:"col",originalIndex:this.view.state.colIndex,mousePos:t.clientX},this.view.emitUpdate(),this.editor.transact(o=>o.setMeta(de,{draggedCellOrientation:this.view.state.draggingState.draggedCellOrientation,originalIndex:this.view.state.colIndex,newIndex:this.view.state.colIndex,tablePos:this.view.tablePos})),!this.editor.prosemirrorView)throw new Error("Editor view not initialized.");pn(this.editor.prosemirrorView.root),t.dataTransfer.setDragImage(F,0,0),t.dataTransfer.effectAllowed="move"});p(this,"rowDragStart",t=>{if(this.view.state===void 0||this.view.state.rowIndex===void 0)throw new Error("Attempted to drag table row, but no table block was hovered prior.");if(this.view.state.draggingState={draggedCellOrientation:"row",originalIndex:this.view.state.rowIndex,mousePos:t.clientY},this.view.emitUpdate(),this.editor.transact(o=>o.setMeta(de,{draggedCellOrientation:this.view.state.draggingState.draggedCellOrientation,originalIndex:this.view.state.rowIndex,newIndex:this.view.state.rowIndex,tablePos:this.view.tablePos})),!this.editor.prosemirrorView)throw new Error("Editor view not initialized.");pn(this.editor.prosemirrorView.root),t.dataTransfer.setDragImage(F,0,0),t.dataTransfer.effectAllowed="copyMove"});p(this,"dragEnd",()=>{if(this.view.state===void 0)throw new Error("Attempted to drag table row, but no table block was hovered prior.");if(this.view.state.draggingState=void 0,this.view.emitUpdate(),this.editor.transact(t=>t.setMeta(de,null)),!this.editor.prosemirrorView)throw new Error("Editor view not initialized.");Ea(this.editor.prosemirrorView.root)});p(this,"freezeHandles",()=>{this.view.menuFrozen=!0});p(this,"unfreezeHandles",()=>{this.view.menuFrozen=!1});p(this,"getCellsAtRowHandle",(t,o)=>ut(t,o));p(this,"getCellsAtColumnHandle",(t,o)=>pt(t,o));p(this,"setCellSelection",(t,o,r=o)=>{const s=this.view;if(!s)throw new Error("Table handles view not initialized");const i=t.doc.resolve(s.tablePos+1),a=t.doc.resolve(i.posAtIndex(o.row)+1),l=t.doc.resolve(a.posAtIndex(o.col)),c=t.doc.resolve(i.posAtIndex(r.row)+1),d=t.doc.resolve(c.posAtIndex(r.col)),u=t.tr;return u.setSelection(new H.CellSelection(l,d)),t.apply(u)});p(this,"addRowOrColumn",(t,o)=>{this.editor.exec((r,s)=>{const i=this.setCellSelection(r,o.orientation==="row"?{row:t,col:0}:{row:0,col:t});return o.orientation==="row"?o.side==="above"?H.addRowBefore(i,s):H.addRowAfter(i,s):o.side==="left"?H.addColumnBefore(i,s):H.addColumnAfter(i,s)})});p(this,"removeRowOrColumn",(t,o)=>o==="row"?this.editor.exec((r,s)=>{const i=this.setCellSelection(r,{row:t,col:0});return H.deleteRow(i,s)}):this.editor.exec((r,s)=>{const i=this.setCellSelection(r,{row:0,col:t});return H.deleteColumn(i,s)}));p(this,"mergeCells",t=>this.editor.exec((o,r)=>{const s=t?this.setCellSelection(o,t.relativeStartCell,t.relativeEndCell):o;return H.mergeCells(s,r)}));p(this,"splitCell",t=>this.editor.exec((o,r)=>{const s=t?this.setCellSelection(o,t):o;return H.splitCell(s,r)}));p(this,"getCellSelection",()=>this.editor.transact(t=>{const o=t.selection;let r=o.$from,s=o.$to;if(kt(o)){const{ranges:m}=o;m.forEach(g=>{r=g.$from.min(r??g.$from),s=g.$to.max(s??g.$to)})}else if(r=t.doc.resolve(o.$from.pos-o.$from.parentOffset-1),s=t.doc.resolve(o.$to.pos-o.$to.parentOffset-1),r.pos===0||s.pos===0)return;const i=t.doc.resolve(r.pos-r.parentOffset-1),a=t.doc.resolve(s.pos-s.parentOffset-1),l=t.doc.resolve(i.pos-i.parentOffset-1),c=r.index(i.depth),d=i.index(l.depth),u=s.index(a.depth),h=a.index(l.depth),f=[];for(let m=d;m<=h;m++)for(let g=c;g<=u;g++)f.push({row:m,col:g});return{from:{row:d,col:c},to:{row:h,col:u},cells:f}}));p(this,"getMergeDirection",t=>this.editor.transact(o=>{const r=kt(o.selection)?o.selection:void 0;if(!r||!t||r.ranges.length<=1)return;const s=this.getCellSelection();if(s)return rs(s.from,s.to,t)?"vertical":"horizontal"}));p(this,"cropEmptyRowsOrColumns",(t,o)=>ns(t,o));p(this,"addRowsOrColumns",(t,o,r)=>os(t,o,r));this.editor=t,this.addProsemirrorPlugin(new y.Plugin({key:de,view:o=>(this.view=new fr(t,o,r=>{this.emit("update",r)}),this.view),props:{decorations:o=>{if(this.view===void 0||this.view.state===void 0||this.view.state.draggingState===void 0||this.view.tablePos===void 0)return;const r=this.view.state.draggingState.draggedCellOrientation==="row"?this.view.state.rowIndex:this.view.state.colIndex;if(r===void 0)return;const s=[],{block:i,draggingState:a}=this.view.state,{originalIndex:l,draggedCellOrientation:c}=a;if(r===l||!i||c==="row"&&!Mn(i,l,r)||c==="col"&&!In(i,l,r))return D.DecorationSet.create(o.doc,s);const d=o.doc.resolve(this.view.tablePos+1);return this.view.state.draggingState.draggedCellOrientation==="row"?ut(this.view.state.block,r).forEach(({row:h,col:f})=>{const m=o.doc.resolve(d.posAtIndex(h)+1),g=o.doc.resolve(m.posAtIndex(f)+1),b=g.node(),w=g.pos+(r>l?b.nodeSize-2:0);s.push(D.Decoration.widget(w,()=>{const C=document.createElement("div");return C.className="bn-table-drop-cursor",C.style.left="0",C.style.right="0",r>l?C.style.bottom="-2px":C.style.top="-3px",C.style.height="4px",C}))}):pt(this.view.state.block,r).forEach(({row:h,col:f})=>{const m=o.doc.resolve(d.posAtIndex(h)+1),g=o.doc.resolve(m.posAtIndex(f)+1),b=g.node(),w=g.pos+(r>l?b.nodeSize-2:0);s.push(D.Decoration.widget(w,()=>{const C=document.createElement("div");return C.className="bn-table-drop-cursor",C.style.top="0",C.style.bottom="0",r>l?C.style.right="-2px":C.style.left="-3px",C.style.width="4px",C}))}),D.DecorationSet.create(o.doc,s)}}}))}static key(){return"tableHandles"}onUpdate(t){return this.on("update",t)}}const xa=k.Extension.create({name:"textAlignment",addGlobalAttributes(){return[{types:["paragraph","heading","bulletListItem","numberedListItem","checkListItem","tableCell","tableHeader"],attributes:{textAlignment:{default:"left",parseHTML:e=>e.getAttribute("data-text-alignment"),renderHTML:e=>e.textAlignment==="left"?{}:{"data-text-alignment":e.textAlignment}}}}]}}),Pa=k.Extension.create({name:"blockTextColor",addGlobalAttributes(){return[{types:["blockContainer","tableCell","tableHeader"],attributes:{textColor:{default:M.textColor.default,parseHTML:e=>e.hasAttribute("data-text-color")?e.getAttribute("data-text-color"):M.textColor.default,renderHTML:e=>e.textColor===M.textColor.default?{}:{"data-text-color":e.textColor}}}}]}}),Ma=k.Extension.create({name:"trailingNode",addProseMirrorPlugins(){const e=new y.PluginKey(this.name);return[new y.Plugin({key:e,appendTransaction:(n,t,o)=>{const{doc:r,tr:s,schema:i}=o,a=e.getState(o),l=r.content.size-2,c=i.nodes.blockContainer,d=i.nodes.paragraph;if(a)return s.insert(l,c.create(void 0,d.create()))},state:{init:(n,t)=>{},apply:(n,t)=>{if(!n.docChanged)return t;let o=n.doc.lastChild;if(!o||o.type.name!=="blockGroup")throw new Error("Expected blockGroup");if(o=o.lastChild,!o||o.type.name!=="blockContainer")return!0;const r=o.firstChild;if(!r)throw new Error("Expected blockContent");return o.nodeSize>4||r.type.spec.content!=="inline*"}}})]}}),Ia={blockColor:"data-block-color",blockStyle:"data-block-style",id:"data-id",depth:"data-depth",depthChange:"data-depth-change"},La=k.Node.create({name:"blockContainer",group:"blockGroupChild bnBlock",content:"blockContent blockGroup?",priority:50,defining:!0,marks:"insertion modification deletion",parseHTML(){return[{tag:"div[data-node-type="+this.name+"]",getAttrs:e=>{if(typeof e=="string")return!1;const n={};for(const[t,o]of Object.entries(Ia))e.getAttribute(o)&&(n[t]=e.getAttribute(o));return n}},{tag:'div[data-node-type="blockOuter"]',skip:!0}]},renderHTML({HTMLAttributes:e}){var r;const n=document.createElement("div");n.className="bn-block-outer",n.setAttribute("data-node-type","blockOuter");for(const[s,i]of Object.entries(e))s!=="class"&&n.setAttribute(s,i);const t={...((r=this.options.domAttributes)==null?void 0:r.block)||{},...e},o=document.createElement("div");o.className=Q("bn-block",t.class),o.setAttribute("data-node-type",this.name);for(const[s,i]of Object.entries(t))s!=="class"&&o.setAttribute(s,i);return n.appendChild(o),{dom:n,contentDOM:o}}}),Aa=k.Node.create({name:"blockGroup",group:"childContainer",content:"blockGroupChild+",marks:"deletion insertion modification",parseHTML(){return[{tag:"div",getAttrs:e=>typeof e=="string"?!1:e.getAttribute("data-node-type")==="blockGroup"?null:!1}]},renderHTML({HTMLAttributes:e}){var o;const n={...((o=this.options.domAttributes)==null?void 0:o.blockGroup)||{},...e},t=document.createElement("div");t.className=Q("bn-block-group",n.class),t.setAttribute("data-node-type","blockGroup");for(const[r,s]of Object.entries(n))r!=="class"&&t.setAttribute(r,s);return{dom:t,contentDOM:t}}}),Na=k.Node.create({name:"doc",topNode:!0,content:"blockGroup",marks:"insertion modification deletion"});class Da extends O{constructor({editor:t,collaboration:o}){super(t);p(this,"editor");p(this,"collaboration");p(this,"forkedState");this.editor=t,this.collaboration=o}static key(){return"ForkYDocPlugin"}findTypeInOtherYdoc(t,o){const r=t.doc;if(t._item===null){const s=Array.from(r.share.keys()).find(i=>r.share.get(i)===t);if(s==null)throw new Error("type does not exist in other ydoc");return o.get(s,t.constructor)}else{const s=t._item,i=o.store.clients.get(s.id.client)??[],a=ie.findIndexSS(i,s.id.clock);return i[a].content.type}}get isForkedFromRemote(){return this.forkedState!==void 0}fork(){if(this.isForkedFromRemote)return;const t=this.collaboration.fragment;if(!t)throw new Error("No fragment to fork from");const o=new ie.Doc;ie.applyUpdate(o,ie.encodeStateAsUpdate(t.doc));const r=this.findTypeInOtherYdoc(t,o);this.forkedState={undoStack:N.yUndoPluginKey.getState(this.editor.prosemirrorState).undoManager.undoStack,originalFragment:t,forkedFragment:r},this.editor._tiptapEditor.unregisterPlugin([N.yCursorPluginKey,N.yUndoPluginKey,N.ySyncPluginKey]),this.editor._tiptapEditor.registerPlugin(new yt(r).plugins[0]),this.editor._tiptapEditor.registerPlugin(new Ct({editor:this.editor}).plugins[0]),this.emit("forked",!0)}merge({keepChanges:t}){if(!this.forkedState)return;this.editor._tiptapEditor.unregisterPlugin(N.ySyncPluginKey),this.editor._tiptapEditor.unregisterPlugin(N.yUndoPluginKey);const{originalFragment:o,forkedFragment:r,undoStack:s}=this.forkedState;if(this.editor.extensions.ySyncPlugin=new yt(o),this.editor.extensions.yCursorPlugin=new $e(this.collaboration),this.editor.extensions.yUndoPlugin=new Ct({editor:this.editor}),this.editor._tiptapEditor.registerPlugin(this.editor.extensions.ySyncPlugin.plugins[0]),this.editor._tiptapEditor.registerPlugin(this.editor.extensions.yCursorPlugin.plugins[0]),this.editor._tiptapEditor.registerPlugin(this.editor.extensions.yUndoPlugin.plugins[0]),N.yUndoPluginKey.getState(this.editor.prosemirrorState).undoManager.undoStack=s,t){const i=ie.encodeStateAsUpdate(r.doc,ie.encodeStateVector(o.doc));ie.applyUpdate(o.doc,i,this.editor)}this.forkedState=void 0,this.emit("forked",!1)}}const gr=e=>{var r;const n={},t=Ha(e);for(const s of t)n[s.name]=s;e.collaboration&&(n.ySyncPlugin=new yt(e.collaboration.fragment),n.yUndoPlugin=new Ct({editor:e.editor}),(r=e.collaboration.provider)!=null&&r.awareness&&(n.yCursorPlugin=new $e(e.collaboration)),n.forkYDocPlugin=new Da({editor:e.editor,collaboration:e.collaboration})),n.formattingToolbar=new tr(e.editor),n.linkToolbar=new rr(e.editor),n.sideMenu=new ur(e.editor),n.suggestionMenus=new hr(e.editor),n.filePanel=new Zo(e.editor),n.placeholder=new da(e.editor,e.placeholders),(e.animations??!0)&&(n.animations=new pa),e.tableHandles&&(n.tableHandles=new mr(e.editor)),n.nodeSelectionKeyboard=new la,n.blockChange=new Xi,n.showSelection=new ha(e.editor),e.comments&&(n.comments=new ta(e.editor,e.comments.threadStore,Jo.name));const o=e.disableExtensions||[];for(const s of o)delete n[s];return n};let hn=!1;const Ha=e=>{const n=[k.extensions.ClipboardTextSerializer,k.extensions.Commands,k.extensions.Editable,k.extensions.FocusEvents,k.extensions.Tabindex,Nr.Gapcursor,k.Extension.create({name:"dropCursor",addProseMirrorPlugins:()=>[e.dropCursor({width:5,color:"#ddeeff",editor:e.editor})]}),Be.configure({types:["blockContainer","columnList","column"],setIdAttribute:e.setIdAttribute}),na,Or.Text,Ca,va,Sa,Hr.Link.extend({inclusive:!1}).configure({defaultProtocol:ir,protocols:hn?[]:sr}),...Object.values(e.styleSpecs).map(t=>t.implementation.mark.configure({editor:e.editor})),Pa,Ji,xa,k.Extension.create({name:"OverrideEscape",addKeyboardShortcuts(){return{Escape:()=>e.editor.suggestionMenus.shown?!1:this.editor.commands.blur()}}}),Na,La.configure({editor:e.editor,domAttributes:e.domAttributes}),sa.configure({editor:e.editor,tabBehavior:e.tabBehavior}),Aa.configure({domAttributes:e.domAttributes}),...Object.values(e.inlineContentSpecs).filter(t=>t.config!=="link"&&t.config!=="text").map(t=>t.implementation.node.configure({editor:e.editor})),...Object.values(e.blockSpecs).flatMap(t=>[...(t.implementation.requiredExtensions||[]).map(o=>o.configure({editor:e.editor,domAttributes:e.domAttributes})),t.implementation.node.configure({editor:e.editor,domAttributes:e.domAttributes})]),Yi(e.editor),ji(e.editor,e.pasteHandler||(t=>t.defaultPasteHandler())),Ii(e.editor),...e.trailingBlock===void 0||e.trailingBlock?[Ma]:[],...e.comments?[Jo]:[]];return hn=!0,e.collaboration||n.push(Dr.History),n};function Oa(e,n){const t=[];return e.forEach((o,r,s)=>{s!==n&&t.push(o)}),S.Fragment.from(t)}function Ra(e,n){const t=[];for(let o=0;o<e.childCount;o++)if(e.child(o).type.name==="tableRow")if(t.length>0&&t[t.length-1].type.name==="table"){const r=t[t.length-1],s=r.copy(r.content.addToEnd(e.child(o)));t[t.length-1]=s}else{const r=n.nodes.table.createChecked(void 0,e.child(o));t.push(r)}else t.push(e.child(o));return e=S.Fragment.from(t),e}function _a(e,n){let t=S.Fragment.from(e.content);if(t=Ra(t,n.state.schema),!Va(t,n))return new S.Slice(t,e.openStart,e.openEnd);for(let o=0;o<t.childCount;o++)if(t.child(o).type.spec.group==="blockContent"){const r=[t.child(o)];if(o+1<t.childCount&&t.child(o+1).type.name==="blockGroup"){const i=t.child(o+1).child(0).child(0);(i.type.name==="bulletListItem"||i.type.name==="numberedListItem"||i.type.name==="checkListItem")&&(r.push(t.child(o+1)),t=Oa(t,o+1))}const s=n.state.schema.nodes.blockContainer.createChecked(void 0,r);t=t.replaceChild(o,s)}return new S.Slice(t,e.openStart,e.openEnd)}function Va(e,n){var s,i;const t=e.childCount===1,o=((s=e.firstChild)==null?void 0:s.type.spec.content)==="inline*",r=((i=e.firstChild)==null?void 0:i.type.spec.content)==="tableRow+";if(t){if(o)return!1;if(r){const a=E(n.state);if(a.isBlockContainer)return!(a.blockContent.node.type.spec.content==="tableRow+")}}return!0}const We=class We extends k.Editor{constructor(t,o){super({...t,content:void 0});p(this,"_state");p(this,"mount",(t,o,r)=>{o?(this.options.element=o,this.createViewAlternative(t,r)):(this.destroy(),this.isInitialized=!1)});const r=this.schema;let s;const i=r.nodes.doc.createAndFill;r.nodes.doc.createAndFill=(...l)=>{if(s)return s;const c=i.apply(r.nodes.doc,l),d=JSON.parse(JSON.stringify(c.toJSON()));return d.content[0].content[0].attrs.id="initialBlockId",s=S.Node.fromJSON(r,d),s};let a;try{const l=t==null?void 0:t.content.map(c=>se(c,this.schema,o).toJSON());a=k.createDocument({type:"doc",content:[{type:"blockGroup",content:l}]},this.schema,this.options.parseOptions)}catch(l){throw console.error("Error creating document from blocks passed as `initialContent`. Caused by exception: ",l),new Error("Error creating document from blocks passed as `initialContent`:\n"+ +JSON.stringify(t.content))}this._state=y.EditorState.create({doc:a,schema:this.schema})}get state(){return this.view&&(this._state=this.view.state),this._state}dispatch(t){if(!this.view){this._state=this.state.apply(t),this.emit("transaction",{editor:this,transaction:t});return}if(this.view.isDestroyed)return;if(this.isCapturingTransaction){this.dispatchTransaction(t);return}const{state:o,transactions:r}=this.state.applyTransaction(t),s=!this.state.selection.eq(o.selection);this.emit("beforeTransaction",{editor:this,transaction:t,nextState:o}),this.view.updateState(o),this.emit("transaction",{editor:this,transaction:t}),s&&this.emit("selectionUpdate",{editor:this,transaction:t});const i=t.getMeta("focus"),a=t.getMeta("blur");i&&this.emit("focus",{editor:this,event:i.event,transaction:t}),a&&this.emit("blur",{editor:this,event:a.event,transaction:t}),!(!t.docChanged||t.getMeta("preventUpdate"))&&(this.emit("update",{editor:this,transaction:t}),this.emit("v3-update",{editor:this,transaction:t,appendedTransactions:r.slice(1)}))}forceEnablePlugins(){if(this.view)throw new Error("forcePluginsEnabled called after view has been initialized");this._state=this.state.reconfigure({plugins:this.extensionManager.plugins})}createViewAlternative(t,o){this.contentComponent=o;const r={};this.extensionManager.extensions.forEach(i=>{i.type==="mark"&&i.config.addMarkView&&(r[i.name]=i.config.addMarkView(t))}),this.view=new D.EditorView({mount:this.options.element},{...this.options.editorProps,dispatchTransaction:this.dispatch.bind(this),state:this.state,markViews:r,nodeViews:this.extensionManager.nodeViews});const s=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(s),this.commands.focus(this.options.autofocus||this.options.element.getAttribute("data-bn-autofocus")==="true",{scrollIntoView:!1}),this.emit("create",{editor:this}),this.isInitialized=!0}};p(We,"create",(t,o)=>{var s,i;const r=(s=globalThis==null?void 0:globalThis.window)==null?void 0:s.setTimeout;typeof((i=globalThis==null?void 0:globalThis.window)==null?void 0:i.setTimeout)<"u"&&(globalThis.window.setTimeout=()=>0);try{return new We(t,o)}finally{r&&(globalThis.window.setTimeout=r)}});let ze=We;ze.prototype.createView=function(){this.options.onPaste=this.options.onDrop=void 0};const Ua={enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!1};class qt extends ot{constructor(t){var c,d,u,h,f,m,g,b,w,C,v,I,_,K,x,T;super();p(this,"pmSchema");p(this,"extensions",{});p(this,"headless",!1);p(this,"_tiptapEditor");p(this,"elementRenderer",null);p(this,"blockCache",new WeakMap);p(this,"dictionary");p(this,"schema");p(this,"blockImplementations");p(this,"inlineContentImplementations");p(this,"styleImplementations");p(this,"formattingToolbar");p(this,"linkToolbar");p(this,"sideMenu");p(this,"suggestionMenus");p(this,"filePanel");p(this,"tableHandles");p(this,"comments");p(this,"showSelectionPlugin");p(this,"forkYDocPlugin");p(this,"uploadFile");p(this,"onUploadStartCallbacks",[]);p(this,"onUploadEndCallbacks",[]);p(this,"resolveFileUrl");p(this,"resolveUsers");p(this,"settings");p(this,"activeTransaction",null);p(this,"mount",(t,o)=>{this._tiptapEditor.mount(this,t,o)});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||Vr.en,this.settings={tables:{splitCells:((c=t==null?void 0:t.tables)==null?void 0:c.splitCells)??!1,cellBackgroundColor:((d=t==null?void 0:t.tables)==null?void 0:d.cellBackgroundColor)??!1,cellTextColor:((u=t==null?void 0:t.tables)==null?void 0:u.cellTextColor)??!1,headers:((h=t==null?void 0:t.tables)==null?void 0:h.headers)??!1},codeBlock:{indentLineWithTab:((f=t==null?void 0:t.codeBlock)==null?void 0:f.indentLineWithTab)??!0,defaultLanguage:((m=t==null?void 0:t.codeBlock)==null?void 0:m.defaultLanguage)??"text",supportedLanguages:((g=t==null?void 0:t.codeBlock)==null?void 0:g.supportedLanguages)??{},createHighlighter:((b=t==null?void 0:t.codeBlock)==null?void 0:b.createHighlighter)??void 0},heading:{levels:((w=t==null?void 0:t.heading)==null?void 0:w.levels)??[1,2,3]}};const r={defaultStyles:!0,schema:t.schema||ye.create(),_headless:!1,...t,placeholders:{...this.dictionary.placeholders,...t.placeholders}};if(r.comments&&!r.resolveUsers)throw new Error("resolveUsers is required when using comments");this.resolveUsers=r.resolveUsers,this.schema=r.schema,this.blockImplementations=r.schema.blockSpecs,this.inlineContentImplementations=r.schema.inlineContentSpecs,this.styleImplementations=r.schema.styleSpecs,this.extensions=gr({editor:this,domAttributes:r.domAttributes||{},blockSpecs:this.schema.blockSpecs,styleSpecs:this.schema.styleSpecs,inlineContentSpecs:this.schema.inlineContentSpecs,collaboration:r.collaboration,trailingBlock:r.trailingBlock,disableExtensions:r.disableExtensions,setIdAttribute:r.setIdAttribute,animations:r.animations??!0,tableHandles:V("table",this),dropCursor:this.options.dropCursor??_r.dropCursor,placeholders:r.placeholders,tabBehavior:r.tabBehavior,comments:r.comments,pasteHandler:r.pasteHandler}),(((C=r._tiptapOptions)==null?void 0:C.extensions)||[]).forEach(L=>{this.extensions[L.name]=L});for(let L of r.extensions||[]){typeof L=="function"&&(L=L(this));const P=L.constructor.key();if(!P)throw new Error(`Extension ${L.constructor.name} does not have a key method`);if(this.extensions[P])throw new Error(`Extension ${L.constructor.name} already exists with key ${P}`);this.extensions[P]=L}if(Object.entries(r._extensions||{}).forEach(([L,P])=>{const te=typeof P=="function"?P(this):P;if(!("plugin"in te)){this.extensions[L]=te;return}this.extensions[L]=new class extends O{static key(){return L}constructor(){super(),this.addProsemirrorPlugin(te.plugin)}get priority(){return te.priority}}}),this.formattingToolbar=this.extensions.formattingToolbar,this.linkToolbar=this.extensions.linkToolbar,this.sideMenu=this.extensions.sideMenu,this.suggestionMenus=this.extensions.suggestionMenus,this.filePanel=this.extensions.filePanel,this.tableHandles=this.extensions.tableHandles,this.comments=this.extensions.comments,this.showSelectionPlugin=this.extensions.showSelection,this.forkYDocPlugin=this.extensions.forkYDocPlugin,r.uploadFile){const L=r.uploadFile;this.uploadFile=async(P,Ae)=>{this.onUploadStartCallbacks.forEach(te=>te.apply(this,[Ae]));try{return await L(P,Ae)}finally{this.onUploadEndCallbacks.forEach(te=>te.apply(this,[Ae]))}}}this.resolveFileUrl=r.resolveFileUrl,this.headless=r._headless;const s="ySyncPlugin"in this.extensions||"liveblocksExtension"in this.extensions;s&&r.initialContent&&console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider");const i=r.initialContent||(s?[{type:"paragraph",id:"initialBlockId"}]:[{type:"paragraph",id:Be.options.generateID()}]);if(!Array.isArray(i)||i.length===0)throw new Error("initialContent must be a non-empty array of blocks, received: "+i);const a=[...Object.entries(this.extensions).map(([L,P])=>{if(P instanceof k.Extension||P instanceof k.Node||P instanceof k.Mark)return P;if(!(P instanceof O&&!P.plugins.length))return k.Extension.create({name:L,priority:P.priority,addProseMirrorPlugins:()=>P.plugins})})].filter(L=>L!==void 0),l={...Ua,...r._tiptapOptions,content:i,extensions:a,editorProps:{...(v=r._tiptapOptions)==null?void 0:v.editorProps,attributes:{tabIndex:"0",...(_=(I=r._tiptapOptions)==null?void 0:I.editorProps)==null?void 0:_.attributes,...(K=r.domAttributes)==null?void 0:K.editor,class:Q("bn-editor",r.defaultStyles?"bn-default-styles":"",((T=(x=r.domAttributes)==null?void 0:x.editor)==null?void 0:T.class)||"")},transformPasted:_a}};this.headless?this.pmSchema=k.getSchema(l.extensions):(this._tiptapEditor=ze.create(l,this.schema.styleSchema),this.pmSchema=this._tiptapEditor.schema),this.pmSchema.cached.blockNoteEditor=this,this.emit("create")}static create(t={}){return new qt(t)}exec(t){if(this.activeTransaction)throw new Error("`exec` should not be called within a `transact` call, move the `exec` call outside of the `transact` call");const o=this._tiptapEditor.state,r=this._tiptapEditor.view;return t(o,i=>this._tiptapEditor.dispatch(i),r)}canExec(t){if(this.activeTransaction)throw new Error("`canExec` should not be called within a `transact` call, move the `canExec` call outside of the `transact` call");const o=this._tiptapEditor.state,r=this._tiptapEditor.view;return t(o,void 0,r)}transact(t){if(this.activeTransaction)return t(this.activeTransaction);try{this.activeTransaction=this._tiptapEditor.state.tr;const o=t(this.activeTransaction),r=this.activeTransaction;return this.activeTransaction=null,r&&(r.docChanged||r.selectionSet||r.scrolledIntoView||r.storedMarksSet||!r.isGeneric)&&this._tiptapEditor.dispatch(r),o}finally{this.activeTransaction=null}}extension(t,o=t.key()){const r=this.extensions[o];if(!r)throw new Error(`Extension ${o} not found`);return r}get prosemirrorState(){if(this.activeTransaction)throw new Error("`prosemirrorState` should not be called within a `transact` call, move the `prosemirrorState` call outside of the `transact` call or use `editor.transact` to read the current editor state");return this._tiptapEditor.state}get prosemirrorView(){return this._tiptapEditor.view}get domElement(){var t;return(t=this.prosemirrorView)==null?void 0:t.dom}isFocused(){var t;return((t=this.prosemirrorView)==null?void 0:t.hasFocus())||!1}focus(){var t;(t=this.prosemirrorView)==null||t.focus()}onUploadStart(t){return this.onUploadStartCallbacks.push(t),()=>{const o=this.onUploadStartCallbacks.indexOf(t);o>-1&&this.onUploadStartCallbacks.splice(o,1)}}onUploadEnd(t){return this.onUploadEndCallbacks.push(t),()=>{const o=this.onUploadEndCallbacks.indexOf(t);o>-1&&this.onUploadEndCallbacks.splice(o,1)}}get topLevelBlocks(){return this.document}get document(){return this.transact(t=>wn(t.doc,this.pmSchema))}getBlock(t){return this.transact(o=>Uo(o.doc,t))}getPrevBlock(t){return this.transact(o=>Fo(o.doc,t))}getNextBlock(t){return this.transact(o=>$o(o.doc,t))}getParentBlock(t){return this.transact(o=>zo(o.doc,t))}forEachBlock(t,o=!1){const r=this.document.slice();o&&r.reverse();function s(i){for(const a of i){if(t(a)===!1)return!1;const l=o?a.children.slice().reverse():a.children;if(!s(l))return!1}return!0}s(r)}onEditorContentChange(t){this._tiptapEditor.on("update",t)}onEditorSelectionChange(t){this._tiptapEditor.on("selectionUpdate",t)}getTextCursorPosition(){return this.transact(t=>wi(t))}setTextCursorPosition(t,o="start"){return this.transact(r=>Wo(r,t,o))}getSelection(){return this.transact(t=>gi(t))}getSelectionCutBlocks(){return this.transact(t=>ki(t))}setSelection(t,o){return this.transact(r=>bi(r,t,o))}get isEditable(){if(!this._tiptapEditor){if(!this.headless)throw new Error("no editor, but also not headless?");return!1}return this._tiptapEditor.isEditable===void 0?!0:this._tiptapEditor.isEditable}set isEditable(t){if(!this._tiptapEditor){if(!this.headless)throw new Error("no editor, but also not headless?");return}this._tiptapEditor.options.editable!==t&&this._tiptapEditor.setEditable(t)}insertBlocks(t,o,r="before"){return this.transact(s=>An(s,t,o,r))}updateBlock(t,o){return this.transact(r=>Nn(r,t,o))}removeBlocks(t){return this.transact(o=>mt(o,t,[]).removedBlocks)}replaceBlocks(t,o){return this.transact(r=>mt(r,t,o))}undo(){return this.options.collaboration?this.exec(N.undoCommand):this.exec(jt.undo)}redo(){return this.options.collaboration?this.exec(N.redoCommand):this.exec(jt.redo)}insertInlineContent(t,{updateSelection:o=!1}={}){const r=W(t,this.pmSchema);this.transact(s=>{mi(s,{from:s.selection.from,to:s.selection.to},r,{updateSelection:o})})}getActiveStyles(){return this.transact(t=>{const o={},r=t.selection.$to.marks();for(const s of r){const i=this.schema.styleSchema[s.type.name];if(!i){s.type.name!=="link"&&!s.type.spec.blocknoteIgnore&&console.warn("mark not found in styleschema",s.type.name);continue}i.propSchema==="boolean"?o[i.type]=!0:o[i.type]=s.attrs.stringValue}return o})}addStyles(t){for(const[o,r]of Object.entries(t)){const s=this.schema.styleSchema[o];if(!s)throw new Error(`style ${o} not found in styleSchema`);if(s.propSchema==="boolean")this._tiptapEditor.commands.setMark(o);else if(s.propSchema==="string")this._tiptapEditor.commands.setMark(o,{stringValue:r});else throw new j(s.propSchema)}}removeStyles(t){for(const o of Object.keys(t))this._tiptapEditor.commands.unsetMark(o)}toggleStyles(t){for(const[o,r]of Object.entries(t)){const s=this.schema.styleSchema[o];if(!s)throw new Error(`style ${o} not found in styleSchema`);if(s.propSchema==="boolean")this._tiptapEditor.commands.toggleMark(o);else if(s.propSchema==="string")this._tiptapEditor.commands.toggleMark(o,{stringValue:r});else throw new j(s.propSchema)}}getSelectedText(){return this.transact(t=>t.doc.textBetween(t.selection.from,t.selection.to))}getSelectedLinkUrl(){return this._tiptapEditor.getAttributes("link").href}createLink(t,o){if(t==="")return;const r=this.pmSchema.mark("link",{href:t});this.transact(s=>{const{from:i,to:a}=s.selection;o?s.insertText(o,i,a).addMark(i,i+o.length,r):s.setSelection(y.TextSelection.create(s.doc,a)).addMark(i,a,r)})}canNestBlock(){return hi(this)}nestBlock(){Vo(this)}canUnnestBlock(){return fi(this)}unnestBlock(){pi(this)}moveBlocksUp(){return ci(this)}moveBlocksDown(){return di(this)}async blocksToHTMLLossy(t=this.document){return Me(this.pmSchema,this).exportBlocks(t,{})}async blocksToFullHTML(t){return Vn(this.pmSchema,this).serializeBlocks(t,{})}async tryParseHTMLToBlocks(t){return $t(t,this.pmSchema)}async blocksToMarkdownLossy(t=this.document){return Ko(t,this.pmSchema,this,{})}async tryParseMarkdownToBlocks(t){return jo(t,this.pmSchema)}updateCollaborationUserInfo(t){if(!this.options.collaboration)throw new Error("Cannot update collaboration user info when collaboration is disabled.");this.extensions.yCursorPlugin.updateUser(t)}beforeChange(t){return this.headless?()=>{}:this.extensions.blockChange.subscribe(o=>t(this,o))}onChange(t){if(this.headless)return;const o=({transaction:r,appendedTransactions:s})=>{t(this,{getChanges:()=>At(r,s)})};return this._tiptapEditor.on("v3-update",o),()=>{this._tiptapEditor.off("v3-update",o)}}onSelectionChange(t,o){if(this.headless)return;const r=s=>{s.transaction.getMeta(N.ySyncPluginKey)&&!o||t(this)};return this._tiptapEditor.on("selectionUpdate",r),()=>{this._tiptapEditor.off("selectionUpdate",r)}}onCreate(t){return this.on("create",t),()=>{this.off("create",t)}}getSelectionBoundingBox(){if(!this.prosemirrorView)return;const{selection:t}=this.prosemirrorState,{ranges:o}=t,r=Math.min(...o.map(i=>i.$from.pos)),s=Math.max(...o.map(i=>i.$to.pos));if(k.isNodeSelection(t)){const i=this.prosemirrorView.nodeDOM(r);if(i)return i.getBoundingClientRect()}return k.posToDOMRect(this.prosemirrorView,r,s)}get isEmpty(){const t=this.document;return t.length===0||t.length===1&&t[0].type==="paragraph"&&t[0].content.length===0}openSuggestionMenu(t,o){this.prosemirrorView&&(this.focus(),this.transact(r=>{o!=null&&o.deleteTriggerCharacter&&r.insertText(t),r.scrollIntoView().setMeta(this.suggestionMenus.plugins[0],{triggerCharacter:t,deleteTriggerCharacter:(o==null?void 0:o.deleteTriggerCharacter)||!1,ignoreQueryLength:(o==null?void 0:o.ignoreQueryLength)||!1})}))}getForceSelectionVisible(){return this.showSelectionPlugin.getEnabled()}setForceSelectionVisible(t){this.showSelectionPlugin.setEnabled(t)}convertHtmlToBlockNoteHtml(t){return qo(t.trim()).innerHTML}pasteHTML(t,o=!1){var s;let r=t;o||(r=this.convertHtmlToBlockNoteHtml(t)),r&&((s=this.prosemirrorView)==null||s.pasteHTML(r))}pasteText(t){var o;return(o=this.prosemirrorView)==null?void 0:o.pasteText(t)}async pasteMarkdown(t){return this.pasteHTML(await zt(t))}}const Fa={gray:{text:"#9b9a97",background:"#ebeced"},brown:{text:"#64473a",background:"#e9e5e3"},red:{text:"#e03e3e",background:"#fbe4e4"},orange:{text:"#d9730d",background:"#f6e9d9"},yellow:{text:"#dfab01",background:"#fbf3db"},green:{text:"#4d6461",background:"#ddedea"},blue:{text:"#0b6e99",background:"#ddebf1"},purple:{text:"#6940a5",background:"#eae4f2"},pink:{text:"#ad1a72",background:"#f4dfeb"}},$a={gray:{text:"#bebdb8",background:"#9b9a97"},brown:{text:"#8e6552",background:"#64473a"},red:{text:"#ec4040",background:"#be3434"},orange:{text:"#e3790d",background:"#b7600a"},yellow:{text:"#dfab01",background:"#b58b00"},green:{text:"#6b8b87",background:"#4d6461"},blue:{text:"#0e87bc",background:"#0b6e99"},purple:{text:"#8552d7",background:"#6940a5"},pink:{text:"#da208f",background:"#ad1a72"}};class za{constructor(n,t,o){this.mappings=t,this.options=o}async resolveFile(n){var o;if(!((o=this.options)!=null&&o.resolveFileUrl))return(await fetch(n)).blob();const t=await this.options.resolveFileUrl(n);return t instanceof Blob?t:(await fetch(t)).blob()}mapStyles(n){return Object.entries(n).map(([o,r])=>this.mappings.styleMapping[o](r,this))}mapInlineContent(n){return this.mappings.inlineContentMapping[n.type](n,this)}transformInlineContent(n){return n.map(t=>this.mapInlineContent(t))}async mapBlock(n,t,o,r){return this.mappings.blockMapping[n.type](n,this,t,o,r)}}function Wa(e){return{createBlockMapping:n=>n,createInlineContentMapping:n=>n,createStyleMapping:n=>n}}let Oe;async function Ka(){return Oe||(Oe=(async()=>{const[e,n]=await Promise.all([import("emoji-mart"),import("@emoji-mart/data")]),t="default"in e?e.default:e,o="default"in n?n.default:n;return await t.init({data:o}),{emojiMart:t,emojiData:o}})(),Oe)}async function qa(e,n){if(!To("text",e))return[];const{emojiData:t,emojiMart:o}=await Ka();return(n.trim()===""?Object.values(t.emojis):await o.SearchIndex.search(n)).map(s=>({id:s.skins[0].native,onItemClick:()=>e.insertInlineContent(s.skins[0].native+" ")}))}function ja(e,...n){const t=[...e];for(const o of n)for(const r of o){const s=t.findLastIndex(i=>i.group===r.group);s===-1?t.push(r):t.splice(s+1,0,r)}return t}exports.AudioBlock=Yn;exports.BlockNoteEditor=qt;exports.BlockNoteExtension=O;exports.BlockNoteSchema=ye;exports.COLORS_DARK_MODE_DEFAULT=$a;exports.COLORS_DEFAULT=Fa;exports.CodeBlock=Xn;exports.DEFAULT_LINK_PROTOCOL=ir;exports.EMPTY_CELL_HEIGHT=Fs;exports.EMPTY_CELL_WIDTH=Rt;exports.EventEmitter=ot;exports.Exporter=za;exports.FILE_AUDIO_ICON_SVG=zn;exports.FILE_ICON_SVG=Fn;exports.FILE_IMAGE_ICON_SVG=io;exports.FILE_VIDEO_ICON_SVG=bo;exports.FileBlock=oo;exports.FilePanelProsemirrorPlugin=Zo;exports.FilePanelView=Xo;exports.FormattingToolbarProsemirrorPlugin=tr;exports.FormattingToolbarView=Qo;exports.HTMLToBlocks=$t;exports.ImageBlock=ho;exports.LinkToolbarProsemirrorPlugin=rr;exports.PageBreak=No;exports.SideMenuProsemirrorPlugin=ur;exports.SideMenuView=cr;exports.SuggestionMenuProseMirrorPlugin=hr;exports.TableHandlesProsemirrorPlugin=mr;exports.TableHandlesView=fr;exports.UniqueID=Be;exports.UnreachableCaseError=j;exports.VALID_LINK_PROTOCOLS=sr;exports.VideoBlock=So;exports.addInlineContentAttributes=dt;exports.addInlineContentKeyboardShortcuts=Cn;exports.addStyleAttributes=Tn;exports.applyNonSelectableBlockFix=gn;exports.assertEmpty=Gr;exports.audioBlockConfig=Kn;exports.audioParse=jn;exports.audioPropSchema=Wn;exports.audioRender=qn;exports.audioToExternalHTML=Gn;exports.blockToNode=se;exports.blocksToMarkdown=Ko;exports.camelToDataKebab=ve;exports.checkBlockHasDefaultProp=ei;exports.checkBlockIsDefaultType=xo;exports.checkBlockIsFileBlock=Xs;exports.checkBlockIsFileBlockWithPlaceholder=Qs;exports.checkBlockIsFileBlockWithPreview=Zs;exports.checkBlockTypeHasDefaultProp=Po;exports.checkBlockTypeInSchema=Ys;exports.checkDefaultBlockTypeInSchema=V;exports.checkDefaultInlineContentTypeInSchema=To;exports.checkInlineContentTypeInSchema=Js;exports.checkPageBreakBlocksInSchema=Do;exports.cleanHTMLToMarkdown=nt;exports.combineByGroup=ja;exports.contentNodeToInlineContent=xe;exports.contentNodeToTableContent=xt;exports.createAddFileButton=Un;exports.createBlockSpec=be;exports.createBlockSpecFromStronglyTypedTiptapNode=Z;exports.createDefaultBlockDOMOutputSpec=$;exports.createExternalHTMLExporter=Me;exports.createFigureWithCaption=Qe;exports.createFileBlockWrapper=Ze;exports.createFileNameWithIcon=$n;exports.createInlineContentSpec=Zr;exports.createInlineContentSpecFromTipTapNode=Sn;exports.createInternalBlockSpec=Bt;exports.createInternalHTMLSerializer=Vn;exports.createInternalInlineContentSpec=vn;exports.createInternalStyleSpec=Mt;exports.createLinkWithCaption=Le;exports.createResizableFileBlockWrapper=Ht;exports.createStronglyTypedTiptapNode=G;exports.createStyleSpec=Qr;exports.createStyleSpecFromTipTapMark=ne;exports.createSuggestionMenu=ya;exports.createToggleWrapper=Dt;exports.defaultBlockSchema=Eo;exports.defaultBlockSpecs=_t;exports.defaultBlockToHTML=ct;exports.defaultCodeBlockPropSchema=Jn;exports.defaultInlineContentSchema=Bo;exports.defaultInlineContentSpecs=Ut;exports.defaultProps=M;exports.defaultStyleSchema=Gs;exports.defaultStyleSpecs=Vt;exports.defaultToggledState=ro;exports.docToBlocks=wn;exports.fileBlockConfig=Qn;exports.fileParse=to;exports.filePropSchema=Zn;exports.fileRender=eo;exports.fileToExternalHTML=no;exports.filenameFromURL=Xr;exports.filterSuggestionItems=ri;exports.formatKeyboardShortcut=J;exports.formattingToolbarPluginKey=er;exports.getBlock=Uo;exports.getBlockCache=Je;exports.getBlockFromPos=qe;exports.getBlockInfo=ee;exports.getBlockInfoFromResolvedPos=ke;exports.getBlockInfoFromSelection=E;exports.getBlockInfoFromTransaction=Te;exports.getBlockInfoWithManualOffset=je;exports.getBlockNoteExtensions=gr;exports.getBlockNoteSchema=we;exports.getBlockSchema=Ge;exports.getBlockSchemaFromSpecs=Tt;exports.getBlocksChangedByTransaction=At;exports.getColspan=me;exports.getDefaultEmojiPickerItems=qa;exports.getDefaultSlashMenuItems=oi;exports.getInlineContentParseRules=En;exports.getInlineContentSchema=Ye;exports.getInlineContentSchemaFromSpecs=Pt;exports.getNearestBlockPos=X;exports.getNextBlock=$o;exports.getNodeById=z;exports.getPageBreakSlashMenuItems=ii;exports.getParentBlock=zo;exports.getParseRules=bn;exports.getPmSchema=R;exports.getPrevBlock=Fo;exports.getRowspan=Ue;exports.getStyleParseRules=xn;exports.getStyleSchema=ce;exports.getStyleSchemaFromSpecs=It;exports.imageBlockConfig=lo;exports.imageParse=uo;exports.imagePropSchema=ao;exports.imageRender=co;exports.imageToExternalHTML=po;exports.inheritedProps=Et;exports.initializeESMDependencies=tt;exports.inlineContentToNodes=W;exports.insertBlocks=An;exports.insertOrUpdateBlock=A;exports.isAppleOS=mn;exports.isLinkInlineContent=lt;exports.isNodeBlock=Xe;exports.isPartialLinkInlineContent=St;exports.isPartialTableCell=fe;exports.isSafari=Yr;exports.isStyledTextInlineContent=oe;exports.isTableCell=Ke;exports.isTableCellSelection=kt;exports.linkToolbarPluginKey=or;exports.mapTableCell=Ve;exports.mappingFactory=Wa;exports.markdownToBlocks=jo;exports.markdownToHTML=zt;exports.mergeCSSClasses=Q;exports.mergeParagraphs=Jr;exports.nodeToBlock=B;exports.nodeToCustomInlineContent=Fe;exports.pageBreakConfig=Mo;exports.pageBreakParse=Lo;exports.pageBreakRender=Io;exports.pageBreakSchema=Ft;exports.pageBreakToExternalHTML=Ao;exports.parseEmbedElement=bt;exports.parseFigureElement=Ie;exports.propsToAttributes=ge;exports.prosemirrorSliceToSlicedBlocks=yn;exports.removeAndInsertBlocks=mt;exports.selectedFragmentToHTML=Kt;exports.shikiHighlighterPromiseSymbol=Re;exports.shikiParserSymbol=gt;exports.sideMenuPluginKey=dr;exports.stylePropsToAttributes=Bn;exports.tableContentToNodes=Pe;exports.tableHandlesPluginKey=de;exports.trackPosition=pr;exports.updateBlock=Nn;exports.updateBlockCommand=U;exports.updateBlockTr=Nt;exports.uploadToTmpFilesDotOrg_DEV_ONLY=ti;exports.videoBlockConfig=wo;exports.videoParse=Co;exports.videoPropSchema=ko;exports.videoRender=yo;exports.videoToExternalHTML=vo;exports.withPageBreak=si;exports.wrapInBlockStructure=Ce;
13
13
  //# sourceMappingURL=blocknote.cjs.map