@blocknote/core 0.47.1 → 0.47.3

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 (74) hide show
  1. package/dist/BlockNoteExtension-BWw0r8Gy.cjs.map +1 -1
  2. package/dist/BlockNoteExtension-C2X7LW-V.js.map +1 -1
  3. package/dist/{BlockNoteSchema-CwhtPpVC.cjs → BlockNoteSchema-CCs_V3lo.cjs} +2 -2
  4. package/dist/{BlockNoteSchema-CwhtPpVC.cjs.map → BlockNoteSchema-CCs_V3lo.cjs.map} +1 -1
  5. package/dist/{BlockNoteSchema-dmbNkHA-.js → BlockNoteSchema-ooiKsd5B.js} +2 -2
  6. package/dist/{BlockNoteSchema-dmbNkHA-.js.map → BlockNoteSchema-ooiKsd5B.js.map} +1 -1
  7. package/dist/{TrailingNode-F9hX_UlQ.js → TrailingNode-GzE59m_7.js} +585 -415
  8. package/dist/TrailingNode-GzE59m_7.js.map +1 -0
  9. package/dist/TrailingNode-n0WdMPUl.cjs +2 -0
  10. package/dist/TrailingNode-n0WdMPUl.cjs.map +1 -0
  11. package/dist/blocknote.cjs +4 -4
  12. package/dist/blocknote.cjs.map +1 -1
  13. package/dist/blocknote.js +938 -862
  14. package/dist/blocknote.js.map +1 -1
  15. package/dist/blocks.cjs +1 -1
  16. package/dist/blocks.js +2 -2
  17. package/dist/comments.cjs.map +1 -1
  18. package/dist/comments.js.map +1 -1
  19. package/dist/defaultBlocks-Dg9kQWXm.cjs +6 -0
  20. package/dist/defaultBlocks-Dg9kQWXm.cjs.map +1 -0
  21. package/dist/{defaultBlocks-Caw1U1oV.js → defaultBlocks-ZzGbYgQn.js} +611 -530
  22. package/dist/defaultBlocks-ZzGbYgQn.js.map +1 -0
  23. package/dist/extensions.cjs +1 -1
  24. package/dist/extensions.cjs.map +1 -1
  25. package/dist/extensions.js +33 -54
  26. package/dist/extensions.js.map +1 -1
  27. package/dist/locales.cjs +1 -1
  28. package/dist/locales.cjs.map +1 -1
  29. package/dist/locales.js +25 -24
  30. package/dist/locales.js.map +1 -1
  31. package/dist/style.css +1 -1
  32. package/dist/tsconfig.tsbuildinfo +1 -1
  33. package/dist/webpack-stats.json +1 -1
  34. package/package.json +1 -10
  35. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +4 -1
  36. package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +7 -1
  37. package/src/api/parsers/html/parseHTML.ts +2 -0
  38. package/src/api/parsers/html/util/normalizeWhitespace.ts +87 -0
  39. package/src/blocks/Heading/block.ts +48 -1
  40. package/src/blocks/ListItem/ToggleListItem/block.ts +51 -1
  41. package/src/blocks/Paragraph/block.ts +1 -1
  42. package/src/blocks/getDetailsContent.ts +77 -0
  43. package/src/comments/threadstore/TipTapThreadStore.ts +5 -5
  44. package/src/comments/threadstore/tiptap/types.ts +131 -0
  45. package/src/editor/Block.css +6 -0
  46. package/src/editor/BlockNoteEditor.ts +9 -14
  47. package/src/editor/managers/ExtensionManager/symbol.ts +0 -1
  48. package/src/editor/managers/SelectionManager.ts +3 -1
  49. package/src/extensions/DropCursor/DropCursor.ts +262 -25
  50. package/src/extensions/DropCursor/utils.ts +195 -0
  51. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +15 -10
  52. package/src/i18n/locales/fa.ts +4 -21
  53. package/src/i18n/locales/index.ts +1 -1
  54. package/src/i18n/locales/ru.ts +1 -1
  55. package/src/i18n/locales/uz.ts +22 -4
  56. package/src/index.ts +1 -0
  57. package/src/schema/blocks/createSpec.ts +33 -45
  58. package/src/schema/blocks/types.ts +101 -1
  59. package/types/src/api/parsers/html/util/normalizeWhitespace.d.ts +6 -0
  60. package/types/src/blocks/getDetailsContent.d.ts +19 -0
  61. package/types/src/comments/threadstore/TipTapThreadStore.d.ts +1 -1
  62. package/types/src/comments/threadstore/tiptap/types.d.ts +73 -0
  63. package/types/src/editor/BlockNoteEditor.d.ts +6 -9
  64. package/types/src/extensions/DropCursor/DropCursor.d.ts +42 -5
  65. package/types/src/extensions/DropCursor/utils.d.ts +48 -0
  66. package/types/src/index.d.ts +1 -0
  67. package/types/src/schema/blocks/createSpec.d.ts +3 -3
  68. package/types/src/schema/blocks/types.d.ts +31 -1
  69. package/dist/TrailingNode-DHOdUVUO.cjs +0 -2
  70. package/dist/TrailingNode-DHOdUVUO.cjs.map +0 -1
  71. package/dist/TrailingNode-F9hX_UlQ.js.map +0 -1
  72. package/dist/defaultBlocks-CSB5GiAu.cjs +0 -6
  73. package/dist/defaultBlocks-CSB5GiAu.cjs.map +0 -1
  74. package/dist/defaultBlocks-Caw1U1oV.js.map +0 -1
@@ -1,5 +1,5 @@
1
- "use strict";var Pe=Object.defineProperty;var Ie=(o,e,t)=>e in o?Pe(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var b=(o,e,t)=>Ie(o,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("prosemirror-model"),F=require("prosemirror-transform"),u=require("./blockToNode-CumVjgem.cjs"),d=require("./defaultBlocks-CSB5GiAu.cjs"),B=require("./TrailingNode-DHOdUVUO.cjs"),I=require("./BlockNoteSchema-CwhtPpVC.cjs"),S=require("@tiptap/core"),z=require("./EventEmitter-CLwfmbqG.cjs"),w=require("@tiptap/pm/model"),Me=require("./en-Cl87Uuyf.cjs"),Y=require("@handlewithcare/prosemirror-inputrules"),we=require("@tiptap/pm/keymap"),H=require("./BlockNoteExtension-BWw0r8Gy.cjs"),ve=require("@tiptap/extensions/gap-cursor"),Ae=require("@tiptap/extension-link"),Ne=require("@tiptap/extension-text"),T=require("prosemirror-state"),D=require("prosemirror-tables"),Le=require("./ShowSelection-BxnbRvy4.cjs"),_e=require("remark-gfm"),De=require("remark-parse"),R=require("remark-rehype"),Fe=require("rehype-stringify"),Oe=require("unified"),He=require("@tiptap/pm/state"),$=o=>o&&typeof o=="object"&&"default"in o?o:{default:o},$e=$(_e),Re=$(De),Ve=$(R),Ue=$(Fe);function ne(o,e){const t=[{tag:`[data-inline-content-type="${o.type}"]`,contentElement:n=>{const r=n;return r.matches("[data-editable]")?r:r.querySelector("[data-editable]")||r}}];return e&&t.push({tag:"*",getAttrs(n){if(typeof n=="string")return!1;const r=e==null?void 0:e(n);return r===void 0?!1:r}}),t}function ze(o,e){var n;const t=S.Node.create({name:o.type,inline:!0,group:"inline",draggable:(n=e.meta)==null?void 0:n.draggable,selectable:o.content==="styled",atom:o.content==="none",content:o.content==="styled"?"inline*":"",addAttributes(){return d.propsToAttributes(o.propSchema)},addKeyboardShortcuts(){return d.addInlineContentKeyboardShortcuts(o)},parseHTML(){return ne(o,e.parse)},renderHTML({node:r}){const s=this.options.editor,i=e.render.call({renderType:"dom",props:void 0},u.nodeToCustomInlineContent(r,s.schema.inlineContentSchema,s.schema.styleSchema),()=>{},s);return d.addInlineContentAttributes(i,o.type,r.attrs,o.propSchema)},addNodeView(){return r=>{const{node:s,getPos:i}=r,a=this.options.editor,c=e.render.call({renderType:"nodeView",props:r},u.nodeToCustomInlineContent(s,a.schema.inlineContentSchema,a.schema.styleSchema),l=>{const p=u.inlineContentToNodes([l],a.pmSchema),f=i();f&&a.transact(h=>h.replaceWith(f,f+s.nodeSize,p))},a);return d.addInlineContentAttributes(c,o.type,s.attrs,o.propSchema)}}});return d.createInlineContentSpecFromTipTapNode(t,o.propSchema,{...e,toExternalHTML:e.toExternalHTML,render(r,s,i){const a=e.render(r,s,i);return d.addInlineContentAttributes(a,o.type,r.props,o.propSchema)}})}function re(o,e,t,n="before"){const r=typeof t=="string"?t:t.id,s=u.getPmSchema(o),i=e.map(p=>u.blockToNode(p,s)),a=d.getNodeById(r,o.doc);if(!a)throw new Error(`Block with ID ${r} not found`);let c=a.posBeforeNode;return n==="after"&&(c+=a.node.nodeSize),o.step(new F.ReplaceStep(c,c,new E.Slice(E.Fragment.from(i),0,0))),i.map(p=>u.nodeToBlock(p,s))}function O(o){if(!o||o.type.name!=="column")throw new Error("Invalid columnPos: does not point to column node.");const e=o.firstChild;if(!e)throw new Error("Invalid column: does not have child node.");const t=e.firstChild;if(!t)throw new Error("Invalid blockContainer: does not have child node.");return o.childCount===1&&e.childCount===1&&t.type.name==="paragraph"&&t.content.content.length===0}function se(o,e){const t=o.doc.resolve(e),n=t.nodeAfter;if(!n||n.type.name!=="columnList")throw new Error("Invalid columnListPos: does not point to columnList node.");for(let r=n.childCount-1;r>=0;r--){const s=o.doc.resolve(t.pos+1).posAtIndex(r),a=o.doc.resolve(s).nodeAfter;if(!a||a.type.name!=="column")throw new Error("Invalid columnPos: does not point to column node.");O(a)&&o.delete(s,s+a.nodeSize)}}function _(o,e){se(o,e);const n=o.doc.resolve(e).nodeAfter;if(!n||n.type.name!=="columnList")throw new Error("Invalid columnListPos: does not point to columnList node.");if(n.childCount>2)return;if(n.childCount<2)throw new Error("Invalid columnList: contains fewer than two children.");const r=e+1,i=o.doc.resolve(r).nodeAfter,a=e+n.nodeSize-1,l=o.doc.resolve(a).nodeBefore;if(!i||!l)throw new Error("Invalid columnList: does not contain children.");const p=O(i),f=O(l);if(p&&f){o.delete(e,e+n.nodeSize);return}if(p){o.step(new F.ReplaceAroundStep(e,e+n.nodeSize,a-l.nodeSize+1,a-1,E.Slice.empty,0,!1));return}if(f){o.step(new F.ReplaceAroundStep(e,e+n.nodeSize,r+1,r+i.nodeSize-1,E.Slice.empty,0,!1));return}}function V(o,e,t){const n=u.getPmSchema(o),r=t.map(f=>u.blockToNode(f,n)),s=new Set(e.map(f=>typeof f=="string"?f:f.id)),i=[],a=new Set,c=typeof e[0]=="string"?e[0]:e[0].id;let l=0;if(o.doc.descendants((f,h)=>{if(s.size===0)return!1;if(!f.type.isInGroup("bnBlock")||!s.has(f.attrs.id))return!0;if(i.push(u.nodeToBlock(f,n)),s.delete(f.attrs.id),t.length>0&&f.attrs.id===c){const C=o.doc.nodeSize;o.insert(h,r);const y=o.doc.nodeSize;l+=C-y}const k=o.doc.nodeSize,m=o.doc.resolve(h-l);m.node().type.name==="column"?a.add(m.before(-1)):m.node().type.name==="columnList"&&a.add(m.before()),m.node().type.name==="blockGroup"&&m.node(m.depth-1).type.name!=="doc"&&m.node().childCount===1?o.delete(m.before(),m.after()):o.delete(h-l,h-l+f.nodeSize);const g=o.doc.nodeSize;return l+=k-g,!1}),s.size>0){const f=[...s].join(`
2
- `);throw Error("Blocks with the following IDs could not be found in the editor: "+f)}return a.forEach(f=>_(o,f)),{insertedBlocks:r.map(f=>u.nodeToBlock(f,n)),removedBlocks:i}}function Ge(o,e,t,n,r){let s;if(e)if(typeof e=="string")s=u.inlineContentToNodes([e],o.pmSchema,n);else if(Array.isArray(e))s=u.inlineContentToNodes(e,o.pmSchema,n);else if(e.type==="tableContent")s=u.tableContentToNodes(e,o.pmSchema);else throw new u.UnreachableCaseError(e.type);else throw new Error("blockContent is required");const a=((r==null?void 0:r.document)??document).createDocumentFragment();for(const c of s)if(c.type.name!=="text"&&o.schema.inlineContentSchema[c.type.name]){const l=o.schema.inlineContentSpecs[c.type.name].implementation;if(l){const p=u.nodeToCustomInlineContent(c,o.schema.inlineContentSchema,o.schema.styleSchema),f=l.render.call({renderType:"dom",props:void 0},p,()=>{},o);if(f){if(a.appendChild(f.dom),f.contentDOM){const h=t.serializeFragment(c.content,r);f.contentDOM.dataset.editable="",f.contentDOM.appendChild(h)}continue}}}else if(c.type.name==="text"){let l=document.createTextNode(c.textContent);for(const p of c.marks.toReversed())if(p.type.name in o.schema.styleSpecs){const f=o.schema.styleSpecs[p.type.name].implementation.render(p.attrs.stringValue,o);f.contentDOM.appendChild(l),l=f.dom}else{const f=p.type.spec.toDOM(p,!0),h=E.DOMSerializer.renderSpec(document,f);h.contentDOM.appendChild(l),l=h.dom}a.appendChild(l)}else{const l=t.serializeFragment(E.Fragment.from([c]),r);a.appendChild(l)}return a}function qe(o,e,t,n){var f,h,k,m,g;const r=o.pmSchema.nodes.blockContainer,s=e.props||{};for(const[C,y]of Object.entries(o.schema.blockSchema[e.type].propSchema))!(C in s)&&y.default!==void 0&&(s[C]=y.default);const i=e.children||[],c=o.blockImplementations[e.type].implementation.render.call({renderType:"dom",props:void 0},{...e,props:s,children:i},o);if(c.contentDOM&&e.content){const C=Ge(o,e.content,t,e.type,n);c.contentDOM.appendChild(C)}if(o.pmSchema.nodes[e.type].isInGroup("bnBlock")){if(e.children&&e.children.length>0){const C=ie(o,e.children,t,n);(f=c.contentDOM)==null||f.append(C)}return c.dom}const p=(k=(h=r.spec)==null?void 0:h.toDOM)==null?void 0:k.call(h,r.create({id:e.id,...s}));return(m=p.contentDOM)==null||m.appendChild(c.dom),e.children&&e.children.length>0&&((g=p.contentDOM)==null||g.appendChild(ce(o,e.children,t,n))),p.dom}function ie(o,e,t,n){const s=((n==null?void 0:n.document)??document).createDocumentFragment();for(const i of e){const a=qe(o,i,t,n);s.appendChild(a)}return s}const ce=(o,e,t,n)=>{var a;const r=o.pmSchema.nodes.blockGroup,s=r.spec.toDOM(r.create({})),i=ie(o,e,t,n);return(a=s.contentDOM)==null||a.appendChild(i),s.dom},We=o=>(o.querySelectorAll('[data-content-type="numberedListItem"]').forEach(t=>{var r,s;const n=(s=(r=t.closest(".bn-block-outer"))==null?void 0:r.previousElementSibling)==null?void 0:s.querySelector('[data-content-type="numberedListItem"]');if(!n)t.setAttribute("data-index",t.getAttribute("data-start")||"1");else{const i=n.getAttribute("data-index");t.setAttribute("data-index",(parseInt(i||"0")+1).toString())}}),o),je=o=>(o.querySelectorAll('[data-content-type="checkListItem"] input').forEach(t=>{t.disabled=!0}),o),Ke=o=>(o.querySelectorAll('.bn-toggle-wrapper[data-show-children="false"]').forEach(t=>{t.setAttribute("data-show-children","true")}),o),Ye=o=>(o.querySelectorAll('[data-content-type="table"] table').forEach(t=>{t.setAttribute("style",`--default-cell-min-width: ${d.EMPTY_CELL_WIDTH}px;`),t.setAttribute("data-show-children","true")}),o),Je=o=>(o.querySelectorAll('[data-content-type="table"] table').forEach(t=>{var s;const n=document.createElement("div");n.className="tableWrapper";const r=document.createElement("div");r.className="tableWrapper-inner",n.appendChild(r),(s=t.parentElement)==null||s.appendChild(n),n.appendChild(t)}),o),Qe=o=>(o.querySelectorAll(".bn-inline-content:empty").forEach(t=>{const n=document.createElement("span");n.className="ProseMirror-trailingBreak",n.setAttribute("style","display: inline-block;"),t.appendChild(n)}),o),le=(o,e)=>{const t=E.DOMSerializer.fromSchema(o),n=[We,je,Ke,Ye,Je,Qe];return{serializeBlocks:(r,s)=>{let i=ce(e,r,t,s);for(const a of n)i=a(i);return i.outerHTML}}};function Xe(o){return o.transact(e=>{const t=u.getNearestBlockPos(e.doc,e.selection.anchor);if(e.selection instanceof D.CellSelection)return{type:"cell",anchorBlockId:t.node.attrs.id,anchorCellOffset:e.selection.$anchorCell.pos-t.posBeforeNode,headCellOffset:e.selection.$headCell.pos-t.posBeforeNode};if(e.selection instanceof T.NodeSelection)return{type:"node",anchorBlockId:t.node.attrs.id};{const n=u.getNearestBlockPos(e.doc,e.selection.head);return{type:"text",anchorBlockId:t.node.attrs.id,headBlockId:n.node.attrs.id,anchorOffset:e.selection.anchor-t.posBeforeNode,headOffset:e.selection.head-n.posBeforeNode}}})}function Ze(o,e){var r,s;const t=(r=d.getNodeById(e.anchorBlockId,o.doc))==null?void 0:r.posBeforeNode;if(t===void 0)throw new Error(`Could not find block with ID ${e.anchorBlockId} to update selection`);let n;if(e.type==="cell")n=D.CellSelection.create(o.doc,t+e.anchorCellOffset,t+e.headCellOffset);else if(e.type==="node")n=T.NodeSelection.create(o.doc,t+1);else{const i=(s=d.getNodeById(e.headBlockId,o.doc))==null?void 0:s.posBeforeNode;if(i===void 0)throw new Error(`Could not find block with ID ${e.headBlockId} to update selection`);n=T.TextSelection.create(o.doc,t+e.anchorOffset,i+e.headOffset)}o.setSelection(n)}function U(o){return o.map(e=>e.type==="columnList"?e.children.map(t=>U(t.children)).flat():{...e,children:U(e.children)}).flat()}function ae(o,e,t){o.transact(n=>{var i;const r=((i=o.getSelection())==null?void 0:i.blocks)||[o.getTextCursorPosition().block],s=Xe(o);o.removeBlocks(r),o.insertBlocks(U(r),e,t),Ze(n,s)})}function de(o){return!o||o.type!=="columnList"}function ue(o,e,t){let n,r;if(e?e.children.length>0?(n=e.children[e.children.length-1],r="after"):(n=e,r="before"):t&&(n=t,r="before"),!n||!r)return;const s=o.getParentBlock(n);return de(s)?{referenceBlock:n,placement:r}:ue(o,r==="after"?n:o.getPrevBlock(n),s)}function pe(o,e,t){let n,r;if(e?e.children.length>0?(n=e.children[0],r="before"):(n=e,r="after"):t&&(n=t,r="after"),!n||!r)return;const s=o.getParentBlock(n);return de(s)?{referenceBlock:n,placement:r}:pe(o,r==="before"?n:o.getNextBlock(n),s)}function et(o){o.transact(()=>{const e=o.getSelection(),t=(e==null?void 0:e.blocks[0])||o.getTextCursorPosition().block,n=ue(o,o.getPrevBlock(t),o.getParentBlock(t));n&&ae(o,n.referenceBlock,n.placement)})}function tt(o){o.transact(()=>{const e=o.getSelection(),t=(e==null?void 0:e.blocks[(e==null?void 0:e.blocks.length)-1])||o.getTextCursorPosition().block,n=pe(o,o.getNextBlock(t),o.getParentBlock(t));n&&ae(o,n.referenceBlock,n.placement)})}function ot(o,e,t){const{$from:n,$to:r}=o.selection,s=n.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 c=s.parent.child(i-1);if(c.type!==e)return!1;const l=c.lastChild&&c.lastChild.type===t,p=E.Fragment.from(l?e.create():null),f=new E.Slice(E.Fragment.from(e.create(null,E.Fragment.from(t.create(null,p)))),l?3:1,0),h=s.start,k=s.end;return o.step(new F.ReplaceAroundStep(h-(l?3:1),k,h,k,f,1,!0)).scrollIntoView(),!0}function fe(o){return o.transact(e=>ot(e,o.pmSchema.nodes.blockContainer,o.pmSchema.nodes.blockGroup))}function nt(o){o._tiptapEditor.commands.liftListItem("blockContainer")}function rt(o){return o.transact(e=>{const{bnBlock:t}=u.getBlockInfoFromTransaction(e);return e.doc.resolve(t.beforePos).nodeBefore!==null})}function st(o){return o.transact(e=>{const{bnBlock:t}=u.getBlockInfoFromTransaction(e);return e.doc.resolve(t.beforePos).depth>1})}function he(o,e){const t=typeof e=="string"?e:e.id,n=u.getPmSchema(o),r=d.getNodeById(t,o);if(r)return u.nodeToBlock(r.node,n)}function me(o,e){const t=typeof e=="string"?e:e.id,n=d.getNodeById(t,o),r=u.getPmSchema(o);if(!n)return;const i=o.resolve(n.posBeforeNode).nodeBefore;if(i)return u.nodeToBlock(i,r)}function ke(o,e){const t=typeof e=="string"?e:e.id,n=d.getNodeById(t,o),r=u.getPmSchema(o);if(!n)return;const i=o.resolve(n.posBeforeNode+n.node.nodeSize).nodeAfter;if(i)return u.nodeToBlock(i,r)}function ge(o,e){const t=typeof e=="string"?e:e.id,n=u.getPmSchema(o),r=d.getNodeById(t,o);if(!r)return;const s=o.resolve(r.posBeforeNode),i=s.node(),a=s.node(-1),c=a.type.name!=="doc"?i.type.name==="blockGroup"?a:i:void 0;if(c)return u.nodeToBlock(c,n)}class it{constructor(e){this.editor=e}get document(){return this.editor.transact(e=>u.docToBlocks(e.doc,this.editor.pmSchema))}getBlock(e){return this.editor.transact(t=>he(t.doc,e))}getPrevBlock(e){return this.editor.transact(t=>me(t.doc,e))}getNextBlock(e){return this.editor.transact(t=>ke(t.doc,e))}getParentBlock(e){return this.editor.transact(t=>ge(t.doc,e))}forEachBlock(e,t=!1){const n=this.document.slice();t&&n.reverse();function r(s){for(const i of s){if(e(i)===!1)return!1;const a=t?i.children.slice().reverse():i.children;if(!r(a))return!1}return!0}r(n)}insertBlocks(e,t,n="before"){return this.editor.transact(r=>re(r,e,t,n))}updateBlock(e,t){return this.editor.transact(n=>d.updateBlock(n,e,t))}removeBlocks(e){return this.editor.transact(t=>V(t,e,[]).removedBlocks)}replaceBlocks(e,t){return this.editor.transact(n=>V(n,e,t))}canNestBlock(){return rt(this.editor)}nestBlock(){fe(this.editor)}canUnnestBlock(){return st(this.editor)}unnestBlock(){nt(this.editor)}moveBlocksUp(){return et(this.editor)}moveBlocksDown(){return tt(this.editor)}}class ct extends z.EventEmitter{constructor(e){super(),this.editor=e,e.on("create",()=>{e._tiptapEditor.on("update",({transaction:t,appendedTransactions:n})=>{this.emit("onChange",{editor:e,transaction:t,appendedTransactions:n})}),e._tiptapEditor.on("selectionUpdate",({transaction:t})=>{this.emit("onSelectionChange",{editor:e,transaction:t})}),e._tiptapEditor.on("mount",()=>{this.emit("onMount",{editor:e})}),e._tiptapEditor.on("unmount",()=>{this.emit("onUnmount",{editor:e})})})}onChange(e,t=!0){const n=({transaction:r,appendedTransactions:s})=>{!t&&J(r)||e(this.editor,{getChanges(){return B.getBlocksChangedByTransaction(r,s)}})};return this.on("onChange",n),()=>{this.off("onChange",n)}}onSelectionChange(e,t=!1){const n=r=>{!t&&J(r.transaction)||e(this.editor)};return this.on("onSelectionChange",n),()=>{this.off("onSelectionChange",n)}}onMount(e){return this.on("onMount",e),()=>{this.off("onMount",e)}}onUnmount(e){return this.on("onUnmount",e),()=>{this.off("onUnmount",e)}}}function J(o){return!!o.getMeta("y-sync$")}function lt(o){return Array.prototype.indexOf.call(o.parentElement.childNodes,o)}function at(o){return o.nodeType===3&&!/\S/.test(o.nodeValue||"")}function dt(o){o.querySelectorAll("li > ul, li > ol").forEach(e=>{const t=lt(e),n=e.parentElement,r=Array.from(n.childNodes).slice(t+1);e.remove(),r.forEach(s=>{s.remove()}),n.insertAdjacentElement("afterend",e),r.reverse().forEach(s=>{if(at(s))return;const i=document.createElement("li");i.append(s),e.insertAdjacentElement("afterend",i)}),n.childNodes.length===0&&n.remove()})}function ut(o){o.querySelectorAll("li + ul, li + ol").forEach(e=>{var s,i;const t=e.previousElementSibling,n=document.createElement("div");t.insertAdjacentElement("afterend",n),n.append(t);const r=document.createElement("div");for(r.setAttribute("data-node-type","blockGroup"),n.append(r);((s=n.nextElementSibling)==null?void 0:s.nodeName)==="UL"||((i=n.nextElementSibling)==null?void 0:i.nodeName)==="OL";)r.append(n.nextElementSibling)})}let Q=null;function pt(){return Q||(Q=document.implementation.createHTMLDocument("title"))}function ft(o){if(typeof o=="string"){const e=pt().createElement("div");e.innerHTML=o,o=e}return dt(o),ut(o),o}function G(o,e){const t=ft(o),r=E.DOMParser.fromSchema(e).parse(t,{topNode:e.nodes.blockGroup.create()}),s=[];for(let i=0;i<r.childCount;i++)s.push(u.nodeToBlock(r.child(i),e));return s}function ht(o,e){const t=e.value?e.value:"",n={};e.lang&&(n["data-language"]=e.lang);let r={type:"element",tagName:"code",properties:n,children:[{type:"text",value:t}]};return e.meta&&(r.data={meta:e.meta}),o.patch(e,r),r=o.applyData(e,r),r={type:"element",tagName:"pre",properties:{},children:[r]},o.patch(e,r),r}function mt(o,e){var s;const t=String((e==null?void 0:e.url)||""),n=e!=null&&e.title?String(e.title):void 0;let r={type:"element",tagName:"video",properties:{src:t,"data-name":n,"data-url":t,controls:!0},children:[]};return(s=o.patch)==null||s.call(o,e,r),r=o.applyData?o.applyData(e,r):r,r}function q(o){return Oe.unified().use(Re.default).use($e.default).use(Ve.default,{handlers:{...R.defaultHandlers,image:(t,n)=>{const r=String((n==null?void 0:n.url)||"");return d.isVideoUrl(r)?mt(t,n):R.defaultHandlers.image(t,n)},code:ht,blockquote:(t,n)=>{const r={type:"element",tagName:"blockquote",properties:{},children:t.wrap(t.all(n),!1)};return t.patch(n,r),t.applyData(n,r)}}}).use(Ue.default).processSync(o).value}function be(o,e){const t=q(o);return G(t,e)}class kt{constructor(e){this.editor=e}blocksToHTMLLossy(e=this.editor.document){return B.createExternalHTMLExporter(this.editor.pmSchema,this.editor).exportBlocks(e,{})}blocksToFullHTML(e=this.editor.document){return le(this.editor.pmSchema,this.editor).serializeBlocks(e,{})}tryParseHTMLToBlocks(e){return G(e,this.editor.pmSchema)}blocksToMarkdownLossy(e=this.editor.document){return B.blocksToMarkdown(e,this.editor.pmSchema,this.editor,{})}tryParseMarkdownToBlocks(e){return be(e,this.editor.pmSchema)}pasteHTML(e,t=!1){var r;let n=e;if(!t){const s=this.tryParseHTMLToBlocks(e);n=this.blocksToFullHTML(s)}n&&((r=this.editor.prosemirrorView)==null||r.pasteHTML(n))}pasteText(e){var t;return(t=this.editor.prosemirrorView)==null?void 0:t.pasteText(e)}pasteMarkdown(e){const t=q(e);return this.pasteHTML(t)}}const W=["vscode-editor-data","blocknote/html","text/markdown","text/html","text/plain","Files"];function gt(o,e){if(!o.startsWith(".")||!e.startsWith("."))throw new Error("The strings provided are not valid file extensions.");return o===e}function bt(o,e){const t=o.split("/"),n=e.split("/");if(t.length!==2)throw new Error(`The string ${o} is not a valid MIME type.`);if(n.length!==2)throw new Error(`The string ${e} is not a valid MIME type.`);return t[1]==="*"||n[1]==="*"?t[0]===n[0]:(t[0]==="*"||n[0]==="*"||t[0]===n[0])&&t[1]===n[1]}function X(o,e,t,n="after"){let r;return Array.isArray(e.content)&&e.content.length===0?r=o.updateBlock(e,t).id:r=o.insertBlocks([t],e,n)[0].id,r}async function Be(o,e){var s;if(!e.uploadFile){console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");return}const t="dataTransfer"in o?o.dataTransfer:o.clipboardData;if(t===null)return;let n=null;for(const i of W)if(t.types.includes(i)){n=i;break}if(n!=="Files")return;const r=t.items;if(r){o.preventDefault();for(let i=0;i<r.length;i++){let a="file";for(const l of Object.values(e.schema.blockSpecs))for(const p of((s=l.implementation.meta)==null?void 0:s.fileBlockAccept)||[]){const f=p.startsWith("."),h=r[i].getAsFile();if(h&&(!f&&h.type&&bt(r[i].type,p)||f&&gt("."+h.name.split(".").pop(),p))){a=l.config.type;break}}const c=r[i].getAsFile();if(c){const l={type:a,props:{name:c.name}};let p;if(o.type==="paste"){const k=e.getTextCursorPosition().block;p=X(e,k,l)}else if(o.type==="drop"){const k={left:o.clientX,top:o.clientY},m=e.prosemirrorView.posAtCoords(k);if(!m)return;p=e.transact(g=>{var x;const C=u.getNearestBlockPos(g.doc,m.pos),y=(x=e.domElement)==null?void 0:x.querySelector(`[data-id="${C.node.attrs.id}"]`),P=y==null?void 0:y.getBoundingClientRect();return X(e,e.getBlock(C.node.attrs.id),l,P&&(P.top+P.bottom)/2>k.top?"before":"after")})}else return;const f=await e.uploadFile(c,p),h=typeof f=="string"?{props:{url:f}}:{...f};e.updateBlock(p,h)}}}}const Bt=o=>S.Extension.create({name:"dropFile",addProseMirrorPlugins(){return[new T.Plugin({props:{handleDOMEvents:{drop(e,t){if(!o.isEditable)return;let n=null;for(const r of W)if(t.dataTransfer.types.includes(r)){n=r;break}return n===null?!0:n==="Files"?(Be(t,o),!0):!1}}}})]}}),St=/(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/,Ct=/(_|__|\*|\*\*|~~|==|\+\+)(?!\s)(?:[^\s](?:.{0,62}[^\s])?|\S)(?=\1)/,yt=/\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/,Tt=/(?:\s|^)`(?!\s)(?:[^\s`](?:[^`]{0,46}[^\s`])?|[^\s`])`([^\w]|$)/,xt=/(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/,Et=/(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/,Pt=/\n{2} {0,3}-{2,48}\n{2}/,It=/(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/,Mt=/(?:\n|^)(?!\s)\w[^\n]{0,64}\r?\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/,wt=/(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/,vt=/^\s*\|(.+\|)+\s*$/m,At=/^\s*\|(\s*[-:]+[-:]\s*\|)+\s*$/m,Nt=/^\s*\|(.+\|)+\s*$/m,Lt=o=>St.test(o)||Ct.test(o)||yt.test(o)||Tt.test(o)||xt.test(o)||Et.test(o)||Pt.test(o)||It.test(o)||Mt.test(o)||wt.test(o)||vt.test(o)||At.test(o)||Nt.test(o);async function _t(o,e){const{schema:t}=e.state;if(!o.clipboardData)return!1;const n=o.clipboardData.getData("text/plain");if(!n)return!1;if(!t.nodes.codeBlock)return e.pasteText(n),!0;const r=o.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s==null?void 0:s.mode;return i?(e.pasteHTML(`<pre><code class="language-${i}">${n.replace(/\r\n?/g,`
3
- `)}</code></pre>`),!0):!1}function Dt({event:o,editor:e,prioritizeMarkdownOverHTML:t,plainTextAsMarkdown:n}){var a;if(e.transact(c=>c.selection.$from.parent.type.spec.code&&c.selection.$to.parent.type.spec.code)){const c=(a=o.clipboardData)==null?void 0:a.getData("text/plain");if(c)return e.pasteText(c),!0}let s;for(const c of W)if(o.clipboardData.types.includes(c)){s=c;break}if(!s)return!0;if(s==="vscode-editor-data")return _t(o,e.prosemirrorView),!0;if(s==="Files")return Be(o,e),!0;const i=o.clipboardData.getData(s);if(s==="blocknote/html")return e.pasteHTML(i,!0),!0;if(s==="text/markdown")return e.pasteMarkdown(i),!0;if(t){const c=o.clipboardData.getData("text/plain");if(Lt(c))return e.pasteMarkdown(c),!0}return s==="text/html"?(e.pasteHTML(i),!0):n?(e.pasteMarkdown(i),!0):(e.pasteText(i),!0)}const Ft=(o,e)=>S.Extension.create({name:"pasteFromClipboard",addProseMirrorPlugins(){return[new T.Plugin({props:{handleDOMEvents:{paste(t,n){if(n.preventDefault(),!!o.isEditable)return e({event:n,editor:o,defaultPasteHandler:({prioritizeMarkdownOverHTML:r=!0,plainTextAsMarkdown:s=!0}={})=>Dt({event:n,editor:o,prioritizeMarkdownOverHTML:r,plainTextAsMarkdown:s})})}}}})]}});function Ot(o,e,t){var a;let n=!1;const r=o.state.selection instanceof D.CellSelection;if(!r){const c=o.state.doc.slice(o.state.selection.from,o.state.selection.to,!1).content,l=[];for(let p=0;p<c.childCount;p++)l.push(c.child(p));n=l.find(p=>p.type.isInGroup("bnBlock")||p.type.name==="blockGroup"||p.type.spec.group==="blockContent")===void 0,n&&(e=c)}let s;const i=B.createExternalHTMLExporter(o.state.schema,t);if(r){((a=e.firstChild)==null?void 0:a.type.name)==="table"&&(e=e.firstChild.content);const c=u.contentNodeToTableContent(e,t.schema.inlineContentSchema,t.schema.styleSchema);s=`<table>${i.exportInlineContent(c,{})}</table>`}else if(n){const c=u.contentNodeToInlineContent(e,t.schema.inlineContentSchema,t.schema.styleSchema);s=i.exportInlineContent(c,{})}else{const c=B.fragmentToBlocks(e);s=i.exportBlocks(c,{})}return s}function j(o,e){"node"in o.state.selection&&o.state.selection.node.type.spec.group==="blockContent"&&e.transact(i=>i.setSelection(new T.NodeSelection(i.doc.resolve(o.state.selection.from-1))));const t=o.serializeForClipboard(o.state.selection.content()).dom.innerHTML,n=o.state.selection.content().content,r=Ot(o,n,e),s=B.cleanHTMLToMarkdown(r);return{clipboardHTML:t,externalHTML:r,markdown:s}}const Z=()=>{const o=window.getSelection();if(!o||o.isCollapsed)return!0;let e=o.focusNode;for(;e;){if(e instanceof HTMLElement&&e.getAttribute("contenteditable")==="false")return!0;e=e.parentElement}return!1},ee=(o,e,t)=>{t.preventDefault(),t.clipboardData.clearData();const{clipboardHTML:n,externalHTML:r,markdown:s}=j(e,o);t.clipboardData.setData("blocknote/html",n),t.clipboardData.setData("text/html",r),t.clipboardData.setData("text/plain",s)},Ht=o=>S.Extension.create({name:"copyToClipboard",addProseMirrorPlugins(){return[new T.Plugin({props:{handleDOMEvents:{copy(e,t){return Z()||ee(o,e,t),!0},cut(e,t){return Z()||(ee(o,e,t),e.editable&&e.dispatch(e.state.tr.deleteSelection())),!0},dragstart(e,t){if(!("node"in e.state.selection)||e.state.selection.node.type.spec.group!=="blockContent")return;o.transact(i=>i.setSelection(new T.NodeSelection(i.doc.resolve(e.state.selection.from-1)))),t.preventDefault(),t.dataTransfer.clearData();const{clipboardHTML:n,externalHTML:r,markdown:s}=j(e,o);return t.dataTransfer.setData("blocknote/html",n),t.dataTransfer.setData("text/html",r),t.dataTransfer.setData("text/plain",s),!0}}}})]}}),$t=S.Extension.create({name:"blockBackgroundColor",addGlobalAttributes(){return[{types:["tableCell","tableHeader"],attributes:{backgroundColor:d.getBackgroundColorAttribute()}}]}}),Rt=S.Node.create({name:"hardBreak",inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,priority:10,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:o}){return["br",S.mergeAttributes(this.options.HTMLAttributes,o)]},renderText(){return`
4
- `}}),Se=(o,e)=>{var a;const t=o.resolve(e),n=t.depth-1,r=t.before(n),s=o.resolve(r).nodeAfter;return s?(a=s.type.spec.group)!=null&&a.includes("bnBlock")?u.getBlockInfoFromResolvedPos(o.resolve(r)):Se(o,r):void 0},L=(o,e)=>{const t=o.resolve(e),n=t.index();if(n===0)return;const r=t.posAtIndex(n-1);return u.getBlockInfoFromResolvedPos(o.resolve(r))},N=(o,e)=>{const t=o.resolve(e),n=t.index();if(n===t.node().childCount-1)return;const r=t.posAtIndex(n+1);return u.getBlockInfoFromResolvedPos(o.resolve(r))},Ce=(o,e)=>{for(;e.childContainer;){const t=e.childContainer.node,n=o.resolve(e.childContainer.beforePos+1).posAtIndex(t.childCount-1);e=u.getBlockInfoFromResolvedPos(o.resolve(n))}return e},Vt=(o,e)=>o.isBlockContainer&&o.blockContent.node.type.spec.content==="inline*"&&o.blockContent.node.childCount>0&&e.isBlockContainer&&e.blockContent.node.type.spec.content==="inline*",Ut=(o,e,t,n)=>{if(!n.isBlockContainer)throw new Error(`Attempted to merge block at position ${n.bnBlock.beforePos} into previous block at position ${t.bnBlock.beforePos}, but next block is not a block container`);if(n.childContainer){const r=o.doc.resolve(n.childContainer.beforePos+1),s=o.doc.resolve(n.childContainer.afterPos-1),i=r.blockRange(s);if(e){const a=o.doc.resolve(n.bnBlock.beforePos);o.tr.lift(i,a.depth)}}if(e){if(!t.isBlockContainer)throw new Error(`Attempted to merge block at position ${n.bnBlock.beforePos} into previous block at position ${t.bnBlock.beforePos}, but previous block is not a block container`);e(o.tr.delete(t.blockContent.afterPos-1,n.blockContent.beforePos+1))}return!0},te=o=>({state:e,dispatch:t})=>{const n=e.doc.resolve(o),r=u.getBlockInfoFromResolvedPos(n),s=L(e.doc,r.bnBlock.beforePos);if(!s)return!1;const i=Ce(e.doc,s);return Vt(i,r)?Ut(e,t,i,r):!1},zt=S.Extension.create({priority:50,addKeyboardShortcuts(){const o=()=>this.editor.commands.first(({chain:n,commands:r})=>[()=>r.deleteSelection(),()=>r.undoInputRule(),()=>r.command(({state:s})=>{const i=u.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;const a=s.selection.from===i.blockContent.beforePos+1,c=i.blockContent.node.type.name==="paragraph";return a&&!c?r.command(d.updateBlockCommand(i.bnBlock.beforePos,{type:"paragraph",props:{}})):!1}),()=>r.command(({state:s})=>{const i=u.getBlockInfoFromSelection(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=u.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;const{bnBlock:a,blockContent:c}=i,l=L(s.doc,i.bnBlock.beforePos);if(!l||!l.isBlockContainer||l.blockContent.node.type.spec.content!=="inline*")return!1;const p=s.selection.from===c.beforePos+1,f=s.selection.empty,h=a.beforePos;return p&&f?n().command(te(h)).scrollIntoView().run():!1}),()=>r.command(({state:s,tr:i,dispatch:a})=>{const c=u.getBlockInfoFromSelection(s);if(!c.isBlockContainer)return!1;const l=L(s.doc,c.bnBlock.beforePos);if(!l||l.isBlockContainer)return!1;if(a){const p=l.bnBlock.afterPos-1,f=i.doc.resolve(p-1);return i.delete(c.bnBlock.beforePos,c.bnBlock.afterPos),i.insert(f.pos,c.bnBlock.node),i.setSelection(T.TextSelection.near(i.doc.resolve(f.pos+1))),!0}return!1}),()=>r.command(({state:s,tr:i,dispatch:a})=>{const c=u.getBlockInfoFromSelection(s);if(!c.isBlockContainer||!(i.selection.from===c.blockContent.beforePos+1))return!1;const p=i.doc.resolve(c.bnBlock.beforePos);if(p.nodeBefore||p.node().type.name!=="column")return!1;const k=i.doc.resolve(c.bnBlock.beforePos),m=i.doc.resolve(k.before()),g=m.before();return a&&(i.delete(c.bnBlock.beforePos,c.bnBlock.afterPos),_(i,g),m.pos===g+1?(i.insert(g,c.bnBlock.node),i.setSelection(T.TextSelection.near(i.doc.resolve(g)))):(i.insert(m.pos-1,c.bnBlock.node),i.setSelection(T.TextSelection.near(i.doc.resolve(m.pos))))),!0}),()=>r.command(({state:s})=>{var c;const i=u.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;if(i.blockContent.node.childCount===0&&i.blockContent.node.type.spec.content==="inline*"){const l=L(s.doc,i.bnBlock.beforePos);if(!l||!l.isBlockContainer)return!1;let p=n();if(i.childContainer&&p.insertContentAt(i.bnBlock.afterPos,(c=i.childContainer)==null?void 0:c.node.content),l.blockContent.node.type.spec.content==="tableRow+"){const g=i.bnBlock.beforePos-1-1-1-1-1;p=p.setTextSelection(g)}else if(l.blockContent.node.type.spec.content==="")p=p.setNodeSelection(l.blockContent.beforePos);else{const f=l.blockContent.afterPos-1;p=p.setTextSelection(f)}return p.deleteRange({from:i.bnBlock.beforePos,to:i.bnBlock.afterPos}).scrollIntoView().run()}return!1}),()=>r.command(({state:s})=>{const i=u.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;const a=s.selection.from===i.blockContent.beforePos+1,c=s.selection.empty,l=L(s.doc,i.bnBlock.beforePos);if(l&&a&&c){const p=Ce(s.doc,l);if(!p.isBlockContainer)return!1;if(p.blockContent.node.type.spec.content===""||p.blockContent.node.type.spec.content==="inline*"&&p.blockContent.node.childCount===0)return n().cut({from:i.bnBlock.beforePos,to:i.bnBlock.afterPos},p.bnBlock.afterPos).deleteRange({from:p.bnBlock.beforePos,to:p.bnBlock.afterPos}).run()}return!1})]),e=()=>this.editor.commands.first(({chain:n,commands:r})=>[()=>r.deleteSelection(),()=>r.command(({state:s})=>{var h;const i=u.getBlockInfoFromSelection(s);if(!i.isBlockContainer||!i.childContainer)return!1;const{blockContent:a,childContainer:c}=i,l=s.selection.from===a.afterPos-1,p=s.selection.empty,f=u.getBlockInfoFromResolvedPos(s.doc.resolve(c.beforePos+1));if(!f.isBlockContainer)return!1;if(l&&p){const k=f.blockContent.node,m=k.type.spec.content==="inline*",g=a.node.type.spec.content==="inline*";return n().insertContentAt(f.bnBlock.afterPos,((h=f.childContainer)==null?void 0:h.node.content)||E.Fragment.empty).deleteRange(c.node.childCount===1?{from:c.beforePos,to:c.afterPos}:{from:f.bnBlock.beforePos,to:f.bnBlock.afterPos}).insertContentAt(s.selection.from,m&&g?k.content:null).setTextSelection(s.selection.from).scrollIntoView().run()}return!1}),()=>r.command(({state:s})=>{const i=u.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;const{bnBlock:a,blockContent:c}=i,l=N(s.doc,i.bnBlock.beforePos);if(!l||!l.isBlockContainer)return!1;const p=s.selection.from===c.afterPos-1,f=s.selection.empty,h=a.afterPos;return p&&f?n().command(te(h)).scrollIntoView().run():!1}),()=>r.command(({state:s,tr:i,dispatch:a})=>{const c=u.getBlockInfoFromSelection(s);if(!c.isBlockContainer)return!1;const l=N(s.doc,c.bnBlock.beforePos);if(!l||l.isBlockContainer)return!1;if(a){const p=l.bnBlock.beforePos+1,f=i.doc.resolve(p+1);return i.delete(f.pos,f.pos+f.nodeAfter.nodeSize),_(i,l.bnBlock.beforePos),i.insert(c.bnBlock.afterPos,f.nodeAfter),i.setSelection(T.TextSelection.near(i.doc.resolve(f.pos))),!0}return!1}),()=>r.command(({state:s,tr:i,dispatch:a})=>{const c=u.getBlockInfoFromSelection(s);if(!c.isBlockContainer||!(i.selection.from===c.blockContent.afterPos-1))return!1;const p=i.doc.resolve(c.bnBlock.afterPos);if(p.nodeAfter||p.node().type.name!=="column")return!1;const k=i.doc.resolve(c.bnBlock.afterPos),m=i.doc.resolve(k.after()),g=m.after();if(a){const C=m.pos===g-1?g:m.pos+1,y=u.getBlockInfoFromResolvedPos(i.doc.resolve(C));i.delete(y.bnBlock.beforePos,y.bnBlock.afterPos),_(i,g-m.node().nodeSize),i.insert(k.pos,y.bnBlock.node),i.setSelection(T.TextSelection.near(i.doc.resolve(C)))}return!0}),()=>r.command(({state:s})=>{var p;const i=u.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;const{blockContent:a}=i,c=s.selection.from===a.afterPos-1,l=s.selection.empty;if(c&&l){const f=(C,y)=>{const P=N(C,y);if(P)return P;const x=Se(C,y);if(x)return f(C,x.bnBlock.beforePos)},h=f(s.doc,i.bnBlock.beforePos);if(!h||!h.isBlockContainer)return!1;const k=h.blockContent.node,m=k.type.spec.content==="inline*",g=a.node.type.spec.content==="inline*";return n().insertContentAt(h.bnBlock.afterPos,((p=h.childContainer)==null?void 0:p.node.content)||E.Fragment.empty).deleteRange({from:h.bnBlock.beforePos,to:h.bnBlock.afterPos}).insertContentAt(s.selection.from,m&&g?k.content:null).setTextSelection(s.selection.from).scrollIntoView().run()}return!1}),()=>r.command(({state:s})=>{const i=u.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;if(i.blockContent.node.childCount===0&&i.blockContent.node.type.spec.content==="inline*"){const c=N(s.doc,i.bnBlock.beforePos);if(!c||!c.isBlockContainer)return!1;let l=n();if(c.blockContent.node.type.spec.content==="tableRow+"){const m=i.bnBlock.afterPos+1+1+1+1+1;l=l.setTextSelection(m)}else c.blockContent.node.type.spec.content===""?l=l.setNodeSelection(c.blockContent.beforePos):l=l.setTextSelection(c.blockContent.beforePos+1);return l.deleteRange({from:i.bnBlock.beforePos,to:i.bnBlock.afterPos}).scrollIntoView().run()}return!1}),()=>r.command(({state:s})=>{const i=u.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;const a=s.selection.from===i.blockContent.afterPos-1,c=s.selection.empty,l=N(s.doc,i.bnBlock.beforePos);if(!l||!l.isBlockContainer)return!1;if(l&&a&&c&&(l.blockContent.node.type.spec.content===""||l.blockContent.node.type.spec.content==="inline*"&&l.blockContent.node.childCount===0)){const f=l.bnBlock.node.lastChild.content;return n().deleteRange({from:l.bnBlock.beforePos,to:l.bnBlock.afterPos}).insertContentAt(i.bnBlock.afterPos,l.bnBlock.node.childCount===2?f:null).run()}return!1})]),t=(n=!1)=>this.editor.commands.first(({commands:r,tr:s})=>[()=>r.command(({state:i})=>{const a=u.getBlockInfoFromSelection(i);if(!a.isBlockContainer)return!1;const{bnBlock:c,blockContent:l}=a,{depth:p}=i.doc.resolve(c.beforePos),f=i.selection.$anchor.parentOffset===0,h=i.selection.anchor===i.selection.head,k=l.node.childCount===0,m=p>1;return f&&h&&k&&m?r.liftListItem("blockContainer"):!1}),()=>r.command(({state:i})=>{var l;const a=u.getBlockInfoFromSelection(i),c=((l=this.options.editor.schema.blockSchema[a.blockNoteType].meta)==null?void 0:l.hardBreakShortcut)??"shift+enter";if(c==="none")return!1;if(c==="shift+enter"&&n||c==="enter"){const p=s.storedMarks||s.selection.$head.marks().filter(f=>this.editor.extensionManager.splittableMarks.includes(f.type.name));return s.insert(s.selection.head,s.doc.type.schema.nodes.hardBreak.create()).ensureMarks(p),!0}return!1}),()=>r.command(({state:i,dispatch:a,tr:c})=>{var g;const l=u.getBlockInfoFromSelection(i);if(!l.isBlockContainer)return!1;const{bnBlock:p,blockContent:f}=l,h=i.selection.$anchor.parentOffset===0,k=i.selection.anchor===i.selection.head,m=f.node.childCount===0;if(h&&k&&m){const C=p.afterPos,y=C+2;if(a){const P=i.schema.nodes.blockContainer.createAndFill(void 0,[i.schema.nodes.paragraph.createAndFill()||void 0,(g=l.childContainer)==null?void 0:g.node].filter(x=>x!==void 0));c.insert(C,P).setSelection(new T.TextSelection(c.doc.resolve(y))).scrollIntoView(),l.childContainer&&c.delete(l.childContainer.beforePos,l.childContainer.afterPos)}return!0}return!1}),()=>r.command(({state:i,chain:a})=>{const c=u.getBlockInfoFromSelection(i);if(!c.isBlockContainer)return!1;const{blockContent:l}=c,p=i.selection.$anchor.parentOffset===0;return l.node.childCount===0?!1:(a().deleteSelection().command(d.splitBlockCommand(i.selection.from,p,p)).run(),!0)})]);return{Backspace:o,Delete:e,Enter:()=>t(),"Shift-Enter":()=>t(!0),Tab:()=>{var n,r;return this.options.tabBehavior!=="prefer-indent"&&((n=this.options.editor.getExtension(B.FormattingToolbarExtension))!=null&&n.store.state||((r=this.options.editor.getExtension(d.FilePanelExtension))==null?void 0:r.store.state)!==void 0)?!1:fe(this.options.editor)},"Shift-Tab":()=>{var n,r;return this.options.tabBehavior!=="prefer-indent"&&((n=this.options.editor.getExtension(B.FormattingToolbarExtension))!=null&&n.store.state||((r=this.options.editor.getExtension(d.FilePanelExtension))==null?void 0:r.store.state)!==void 0)?!1:this.editor.commands.liftListItem("blockContainer")},"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()}}}),Gt=S.Mark.create({name:"insertion",inclusive:!1,excludes:"deletion modification insertion",addAttributes(){return{id:{default:null,validate:"number"}}},extendMarkSchema(o){return o.name!=="insertion"?{}:{blocknoteIgnore:!0,inclusive:!1,toDOM(e,t){return["ins",{"data-id":String(e.attrs.id),"data-inline":String(t),...!t&&{style:"display: contents"}},0]},parseDOM:[{tag:"ins",getAttrs(e){return e.dataset.id?{id:parseInt(e.dataset.id,10)}:!1}}]}}}),qt=S.Mark.create({name:"deletion",inclusive:!1,excludes:"insertion modification deletion",addAttributes(){return{id:{default:null,validate:"number"}}},extendMarkSchema(o){return o.name!=="deletion"?{}:{blocknoteIgnore:!0,inclusive:!1,toDOM(e,t){return["del",{"data-id":String(e.attrs.id),"data-inline":String(t),...!t&&{style:"display: contents"}},0]},parseDOM:[{tag:"del",getAttrs(e){return e.dataset.id?{id:parseInt(e.dataset.id,10)}:!1}}]}}}),Wt=S.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(o){return o.name!=="modification"?{}:{blocknoteIgnore:!0,inclusive:!1,toDOM(e,t){return[t?"span":"div",{"data-type":"modification","data-id":String(e.attrs.id),"data-mod-type":e.attrs.type,"data-mod-prev-val":JSON.stringify(e.attrs.previousValue),"data-mod-new-val":JSON.stringify(e.attrs.newValue)},0]},parseDOM:[{tag:"span[data-type='modification']",getAttrs(e){return e.dataset.id?{id:parseInt(e.dataset.id,10),type:e.dataset.modType,previousValue:e.dataset.modPrevVal,newValue:e.dataset.modNewVal}:!1}},{tag:"div[data-type='modification']",getAttrs(e){return e.dataset.id?{id:parseInt(e.dataset.id,10),type:e.dataset.modType,previousValue:e.dataset.modPrevVal}:!1}}]}}}),jt=S.Extension.create({name:"textAlignment",addGlobalAttributes(){return[{types:["tableCell","tableHeader"],attributes:{textAlignment:{default:"left",parseHTML:o=>o.getAttribute("data-text-alignment"),renderHTML:o=>o.textAlignment==="left"?{}:{"data-text-alignment":o.textAlignment}}}}]}}),Kt=S.Extension.create({name:"blockTextColor",addGlobalAttributes(){return[{types:["table","tableCell","tableHeader"],attributes:{textColor:d.getTextColorAttribute()}}]}}),Yt={blockColor:"data-block-color",blockStyle:"data-block-style",id:"data-id",depth:"data-depth",depthChange:"data-depth-change"},Jt=S.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:o=>{if(typeof o=="string")return!1;const e={};for(const[t,n]of Object.entries(Yt))o.getAttribute(n)&&(e[t]=o.getAttribute(n));return e}},{tag:'div[data-node-type="blockOuter"]',skip:!0}]},renderHTML({HTMLAttributes:o}){var r;const e=document.createElement("div");e.className="bn-block-outer",e.setAttribute("data-node-type","blockOuter");for(const[s,i]of Object.entries(o))s!=="class"&&e.setAttribute(s,i);const t={...((r=this.options.domAttributes)==null?void 0:r.block)||{},...o},n=document.createElement("div");n.className=d.mergeCSSClasses("bn-block",t.class),n.setAttribute("data-node-type",this.name);for(const[s,i]of Object.entries(t))s!=="class"&&n.setAttribute(s,i);return e.appendChild(n),{dom:e,contentDOM:n}}}),Qt=S.Node.create({name:"blockGroup",group:"childContainer",content:"blockGroupChild+",marks:"deletion insertion modification",parseHTML(){return[{tag:"div",getAttrs:o=>typeof o=="string"?!1:o.getAttribute("data-node-type")==="blockGroup"?null:!1}]},renderHTML({HTMLAttributes:o}){var n;const e={...((n=this.options.domAttributes)==null?void 0:n.blockGroup)||{},...o},t=document.createElement("div");t.className=d.mergeCSSClasses("bn-block-group",e.class),t.setAttribute("data-node-type","blockGroup");for(const[r,s]of Object.entries(e))r!=="class"&&t.setAttribute(r,s);return{dom:t,contentDOM:t}}}),Xt=S.Node.create({name:"doc",topNode:!0,content:"blockGroup",marks:"insertion modification deletion"}),Zt=H.createExtension(({options:o})=>({key:"collaboration",blockNoteExtensions:[B.ForkYDocExtension(o),B.YCursorExtension(o),B.YSyncExtension(o),B.YUndoExtension(),B.SchemaMigration(o)]}));let oe=!1;function eo(o,e){const t=[S.extensions.ClipboardTextSerializer,S.extensions.Commands,S.extensions.Editable,S.extensions.FocusEvents,S.extensions.Tabindex,ve.Gapcursor,u.UniqueID.configure({types:["blockContainer","columnList","column"],setIdAttribute:e.setIdAttribute}),Rt,Ne.Text,Gt,qt,Wt,Ae.Link.extend({inclusive:!1}).configure({defaultProtocol:B.DEFAULT_LINK_PROTOCOL,protocols:oe?[]:B.VALID_LINK_PROTOCOLS}),...Object.values(o.schema.styleSpecs).map(n=>n.implementation.mark.configure({editor:o})),Kt,$t,jt,S.Extension.create({name:"OverrideEscape",addKeyboardShortcuts:()=>({Escape:()=>{var n;return(n=o.getExtension(d.SuggestionMenu))!=null&&n.shown()?!1:(o.blur(),!0)}})}),Xt,Jt.configure({editor:o,domAttributes:e.domAttributes}),zt.configure({editor:o,tabBehavior:e.tabBehavior}),Qt.configure({domAttributes:e.domAttributes}),...Object.values(o.schema.inlineContentSpecs).filter(n=>n.config!=="link"&&n.config!=="text").map(n=>n.implementation.node.configure({editor:o})),...Object.values(o.schema.blockSpecs).flatMap(n=>[..."node"in n.implementation?[n.implementation.node.configure({editor:o,domAttributes:e.domAttributes})]:[]]),Ht(o),Ft(o,e.pasteHandler||(n=>n.defaultPasteHandler())),Bt(o)];return oe=!0,t}function to(o,e){const t=[B.BlockChangeExtension(),B.DropCursorExtension(e),d.FilePanelExtension(e),B.FormattingToolbarExtension(e),B.LinkToolbarExtension(e),B.NodeSelectionKeyboardExtension(),B.PlaceholderExtension(e),Le.ShowSelectionExtension(e),B.SideMenuExtension(e),d.SuggestionMenu(e),...e.trailingBlock!==!1?[B.TrailingNodeExtension()]:[]];return e.collaboration?t.push(Zt(e.collaboration)):t.push(B.HistoryExtension()),"table"in o.schema.blockSpecs&&t.push(B.TableHandlesExtension(e)),e.animations!==!1&&t.push(B.PreviousBlockTypeExtension()),t}class oo{constructor(e,t){b(this,"disabledExtensions",new Set);b(this,"extensions",[]);b(this,"abortMap",new Map);b(this,"extensionFactories",new Map);b(this,"extensionPlugins",new Map);this.editor=e,this.options=t,e.onMount(()=>{for(const n of this.extensions)if(n.mount){const r=new window.AbortController,s=n.mount({dom:e.prosemirrorView.dom,root:e.prosemirrorView.root,signal:r.signal});s&&r.signal.addEventListener("abort",()=>{s()}),this.abortMap.set(n,r)}}),e.onUnmount(()=>{for(const[n,r]of this.abortMap.entries())this.abortMap.delete(n),r.abort()}),this.disabledExtensions=new Set(t.disableExtensions||[]);for(const n of to(this.editor,this.options))this.addExtension(n);for(const n of this.options.extensions??[])this.addExtension(n);for(const n of Object.values(this.editor.schema.blockSpecs))for(const r of n.extensions??[])this.addExtension(r)}registerExtension(e){var s;const t=[].concat(e).filter(Boolean);if(!t.length){console.warn("No extensions found to register",e);return}const n=t.map(i=>this.addExtension(i)).filter(Boolean),r=new Set;for(const i of n)i!=null&&i.tiptapExtensions&&console.warn(`Extension ${i.key} has tiptap extensions, but these cannot be changed after initializing the editor. Please separate the extension into multiple extensions if you want to add them, or re-initialize the editor.`,i),(s=i==null?void 0:i.inputRules)!=null&&s.length&&console.warn(`Extension ${i.key} has input rules, but these cannot be changed after initializing the editor. Please separate the extension into multiple extensions if you want to add them, or re-initialize the editor.`,i),this.getProsemirrorPluginsFromExtension(i).plugins.forEach(a=>{r.add(a)});this.updatePlugins(i=>[...i,...r])}addExtension(e){let t;if(typeof e=="function"?t=e({editor:this.editor}):t=e,!(!t||this.disabledExtensions.has(t.key))){if(typeof e=="function"){const n=t[H.originalFactorySymbol];typeof n=="function"&&this.extensionFactories.set(n,t)}if(this.extensions.push(t),t.blockNoteExtensions)for(const n of t.blockNoteExtensions)this.addExtension(n);return t}}resolveExtensions(e){const t=[];if(typeof e=="function"){const n=this.extensionFactories.get(e);n&&t.push(n)}else if(Array.isArray(e))for(const n of e)t.push(...this.resolveExtensions(n));else if(typeof e=="object"&&"key"in e)t.push(e);else if(typeof e=="string"){const n=this.extensions.find(r=>r.key===e);n&&t.push(n)}return t}unregisterExtension(e){var s;const t=this.resolveExtensions(e);if(!t.length){console.warn("No extensions found to unregister",e);return}let n=!1;const r=new Set;for(const i of t){this.extensions=this.extensions.filter(c=>c!==i),this.extensionFactories.forEach((c,l)=>{c===i&&this.extensionFactories.delete(l)}),(s=this.abortMap.get(i))==null||s.abort(),this.abortMap.delete(i);const a=this.extensionPlugins.get(i);a==null||a.forEach(c=>{r.add(c)}),this.extensionPlugins.delete(i),i.tiptapExtensions&&!n&&(n=!0,console.warn(`Extension ${i.key} has tiptap extensions, but they will not be removed. Please separate the extension into multiple extensions if you want to remove them, or re-initialize the editor.`,e))}this.updatePlugins(i=>i.filter(a=>!r.has(a)))}updatePlugins(e){const t=this.editor.prosemirrorState,n=t.reconfigure({plugins:e(t.plugins.slice())});this.editor.prosemirrorView.updateState(n)}getTiptapExtensions(){var r;const e=eo(this.editor,this.options).filter(s=>!this.disabledExtensions.has(s.name)),t=I.sortByDependencies(this.extensions),n=new Map;for(const s of this.extensions){s.tiptapExtensions&&e.push(...s.tiptapExtensions);const i=t(s.key),{plugins:a,inputRules:c}=this.getProsemirrorPluginsFromExtension(s);a.length&&e.push(S.Extension.create({name:s.key,priority:i,addProseMirrorPlugins:()=>a})),c.length&&(n.has(i)||n.set(i,[]),n.get(i).push(...c))}e.push(S.Extension.create({name:"blocknote-input-rules",addProseMirrorPlugins(){const s=[];return Array.from(n.keys()).sort().reverse().forEach(i=>{s.push(...n.get(i))}),[Y.inputRules({rules:s})]}}));for(const s of((r=this.options._tiptapOptions)==null?void 0:r.extensions)??[])e.push(s);return e}getProsemirrorPluginsFromExtension(e){var r,s,i;const t=[...e.prosemirrorPlugins??[]],n=[];return!((r=e.prosemirrorPlugins)!=null&&r.length)&&!Object.keys(e.keyboardShortcuts||{}).length&&!((s=e.inputRules)!=null&&s.length)?{plugins:t,inputRules:n}:(this.extensionPlugins.set(e,t),(i=e.inputRules)!=null&&i.length&&n.push(...e.inputRules.map(a=>new Y.InputRule(a.find,(c,l,p,f)=>{const h=a.replace({match:l,range:{from:p,to:f},editor:this.editor});if(h){const k=this.editor.getTextCursorPosition();if(this.editor.schema.blockSchema[k.block.type].content!=="inline")return null;const m=u.getBlockInfoFromTransaction(c.tr),g=c.tr.deleteRange(p,f);return d.updateBlockTr(g,m.bnBlock.beforePos,h),g}return null}))),Object.keys(e.keyboardShortcuts||{}).length&&t.push(we.keymap(Object.fromEntries(Object.entries(e.keyboardShortcuts).map(([a,c])=>[a,()=>c({editor:this.editor})])))),{plugins:t,inputRules:n})}getExtensions(){return new Map(this.extensions.map(e=>[e.key,e]))}getExtension(e){if(typeof e=="string"){const t=this.extensions.find(n=>n.key===e);return t||void 0}else if(typeof e=="function"){const t=this.extensionFactories.get(e);return t||void 0}throw new Error(`Invalid extension type: ${typeof e}`)}hasExtension(e){return typeof e=="string"?this.extensions.some(t=>t.key===e):typeof e=="object"&&"key"in e?this.extensions.some(t=>t.key===e.key):typeof e=="function"?this.extensionFactories.has(e):!1}}function ye(o,e){let{$from:t,$to:n}=e;if(t.pos>t.start()&&t.pos<o.content.size){const r=o.textBetween(t.pos,t.pos+1);if(/^[\w\p{P}]$/u.test(r)){const i=o.textBetween(t.start(),t.pos).match(/[\w\p{P}]+$/u);i&&(t=o.resolve(t.pos-i[0].length))}}if(n.pos<n.end()&&n.pos>0){const r=o.textBetween(n.pos-1,n.pos);if(/^[\w\p{P}]$/u.test(r)){const i=o.textBetween(n.pos,n.end()).match(/^[\w\p{P}]+/u);i&&(n=o.resolve(n.pos+i[0].length))}}return{$from:t,$to:n,from:t.pos,to:n.pos}}function no(o){const e=u.getPmSchema(o);if(o.selection.empty||"node"in o.selection)return;const t=o.doc.resolve(u.getNearestBlockPos(o.doc,o.selection.from).posBeforeNode),n=o.doc.resolve(u.getNearestBlockPos(o.doc,o.selection.to).posBeforeNode),r=(l,p)=>{const f=t.posAtIndex(l,p),h=o.doc.resolve(f).nodeAfter;if(!h)throw new Error(`Error getting selection - node not found at position ${f}`);return u.nodeToBlock(h,e)},s=[],i=t.sharedDepth(n.pos),a=t.index(i),c=n.index(i);if(t.depth>i){s.push(u.nodeToBlock(t.nodeAfter,e));for(let l=t.depth;l>i;l--)if(t.node(l).type.isInGroup("childContainer")){const f=t.index(l)+1,h=t.node(l).childCount;for(let k=f;k<h;k++)s.push(r(k,l))}}else s.push(r(a,i));for(let l=a+1;l<=c;l++)s.push(r(l,i));if(s.length===0)throw new Error(`Error getting selection - selection doesn't span any blocks (${o.selection})`);return{blocks:s}}function ro(o,e,t){const n=typeof e=="string"?e:e.id,r=typeof t=="string"?t:t.id,s=u.getPmSchema(o),i=u.getBlockNoteSchema(s);if(n===r)throw new Error(`Attempting to set selection with the same anchor and head blocks (id ${n})`);const a=d.getNodeById(n,o.doc);if(!a)throw new Error(`Block with ID ${n} not found`);const c=d.getNodeById(r,o.doc);if(!c)throw new Error(`Block with ID ${r} not found`);const l=u.getBlockInfo(a),p=u.getBlockInfo(c),f=i.blockSchema[l.blockNoteType],h=i.blockSchema[p.blockNoteType];if(!l.isBlockContainer||f.content==="none")throw new Error(`Attempting to set selection anchor in block without content (id ${n})`);if(!p.isBlockContainer||h.content==="none")throw new Error(`Attempting to set selection anchor in block without content (id ${r})`);let k,m;if(f.content==="table"){const g=D.TableMap.get(l.blockContent.node);k=l.blockContent.beforePos+g.positionAt(0,0,l.blockContent.node)+1+2}else k=l.blockContent.beforePos+1;if(h.content==="table"){const g=D.TableMap.get(p.blockContent.node),C=p.blockContent.beforePos+g.positionAt(g.height-1,g.width-1,p.blockContent.node)+1,y=o.doc.resolve(C).nodeAfter.nodeSize;m=C+y-2}else m=p.blockContent.afterPos-1;o.setSelection(T.TextSelection.create(o.doc,k,m))}function so(o,e=!1){const t=u.getPmSchema(o),n=e?ye(o.doc,o.selection):o.selection;let r=n.$from,s=n.$to;for(;s.parentOffset>=s.parent.nodeSize-2&&s.depth>0;)s=o.doc.resolve(s.pos+1);for(;s.parentOffset===0&&s.depth>0;)s=o.doc.resolve(s.pos-1);for(;r.parentOffset===0&&r.depth>0;)r=o.doc.resolve(r.pos-1);for(;r.parentOffset>=r.parent.nodeSize-2&&r.depth>0;)r=o.doc.resolve(r.pos+1);const i=u.prosemirrorSliceToSlicedBlocks(o.doc.slice(r.pos,s.pos,!0),t);return{_meta:{startPos:r.pos,endPos:s.pos},...i}}function io(o){const{bnBlock:e}=u.getBlockInfoFromTransaction(o),t=u.getPmSchema(o.doc),n=o.doc.resolve(e.beforePos),r=n.nodeBefore,s=o.doc.resolve(e.afterPos).nodeAfter;let i;return n.depth>1&&(i=n.node(),i.type.isInGroup("bnBlock")||(i=n.node(n.depth-1))),{block:u.nodeToBlock(e.node,t),prevBlock:r===null?void 0:u.nodeToBlock(r,t),nextBlock:s===null?void 0:u.nodeToBlock(s,t),parentBlock:i===void 0?void 0:u.nodeToBlock(i,t)}}function Te(o,e,t="start"){const n=typeof e=="string"?e:e.id,r=u.getPmSchema(o.doc),s=u.getBlockNoteSchema(r),i=d.getNodeById(n,o.doc);if(!i)throw new Error(`Block with ID ${n} not found`);const a=u.getBlockInfo(i),c=s.blockSchema[a.blockNoteType].content;if(a.isBlockContainer){const l=a.blockContent;if(c==="none"){o.setSelection(T.NodeSelection.create(o.doc,l.beforePos));return}if(c==="inline")t==="start"?o.setSelection(T.TextSelection.create(o.doc,l.beforePos+1)):o.setSelection(T.TextSelection.create(o.doc,l.afterPos-1));else if(c==="table")t==="start"?o.setSelection(T.TextSelection.create(o.doc,l.beforePos+4)):o.setSelection(T.TextSelection.create(o.doc,l.afterPos-4));else throw new u.UnreachableCaseError(c)}else{const l=t==="start"?a.childContainer.node.firstChild:a.childContainer.node.lastChild;Te(o,l.attrs.id,t)}}class co{constructor(e){this.editor=e}getSelection(){return this.editor.transact(e=>no(e))}getSelectionCutBlocks(e=!1){return this.editor.transact(t=>so(t,e))}setSelection(e,t){return this.editor.transact(n=>ro(n,e,t))}getTextCursorPosition(){return this.editor.transact(e=>io(e))}setTextCursorPosition(e,t="start"){return this.editor.transact(n=>Te(n,e,t))}getSelectionBoundingBox(){if(!this.editor.prosemirrorView)return;const{selection:e}=this.editor.prosemirrorState,{ranges:t}=e,n=Math.min(...t.map(s=>s.$from.pos)),r=Math.max(...t.map(s=>s.$to.pos));if(S.isNodeSelection(e)){const s=this.editor.prosemirrorView.nodeDOM(n);if(s)return s.getBoundingClientRect()}return S.posToDOMRect(this.editor.prosemirrorView,n,r).toJSON()}}class lo{constructor(e){b(this,"activeTransaction",null);b(this,"isInCan",!1);this.editor=e}can(e){try{return this.isInCan=!0,e()}finally{this.isInCan=!1}}exec(e){if(this.activeTransaction)throw new Error("`exec` should not be called within a `transact` call, move the `exec` call outside of the `transact` call");if(this.isInCan)return this.canExec(e);const t=this.prosemirrorState,n=this.prosemirrorView;return e(t,s=>this.prosemirrorView.dispatch(s),n)}canExec(e){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 t=this.prosemirrorState,n=this.prosemirrorView;return e(t,void 0,n)}transact(e){if(this.activeTransaction)return e(this.activeTransaction);try{this.activeTransaction=this.editor._tiptapEditor.state.tr;const t=e(this.activeTransaction),n=this.activeTransaction;return this.activeTransaction=null,n&&(n.docChanged||n.selectionSet||n.scrolledIntoView||n.storedMarksSet||!n.isGeneric)&&this.prosemirrorView.dispatch(n),t}finally{this.activeTransaction=null}}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.editor._tiptapEditor.state}get prosemirrorView(){return this.editor._tiptapEditor.view}isFocused(){var e;return((e=this.prosemirrorView)==null?void 0:e.hasFocus())||!1}focus(){var e;(e=this.prosemirrorView)==null||e.focus()}get isEditable(){if(!this.editor._tiptapEditor){if(!this.editor.headless)throw new Error("no editor, but also not headless?");return!1}return this.editor._tiptapEditor.isEditable===void 0?!0:this.editor._tiptapEditor.isEditable}set isEditable(e){if(!this.editor._tiptapEditor){if(!this.editor.headless)throw new Error("no editor, but also not headless?");return}this.editor._tiptapEditor.options.editable!==e&&this.editor._tiptapEditor.setEditable(e)}undo(){const e=this.editor.getExtension("yUndo");if(e)return this.exec(e.undoCommand);const t=this.editor.getExtension("history");if(t)return this.exec(t.undoCommand);throw new Error("No undo plugin found")}redo(){const e=this.editor.getExtension("yUndo");if(e)return this.exec(e.redoCommand);const t=this.editor.getExtension("history");if(t)return this.exec(t.redoCommand);throw new Error("No redo plugin found")}}function ao(o,e,t,n={updateSelection:!0}){let{from:r,to:s}=typeof e=="number"?{from:e,to:e}:{from:e.from,to:e.to},i=!0,a=!0,c="";if(t.forEach(l=>{l.check(),i&&l.isText&&l.marks.length===0?c+=l.text:i=!1,a=a?l.isBlock:!1}),r===s&&a){const{parent:l}=o.doc.resolve(r);l.isTextblock&&!l.type.spec.code&&!l.childCount&&(r-=1,s+=1)}return i?o.insertText(c,r,s):o.replaceWith(r,s,t),n.updateSelection&&S.selectionToInsertionEnd(o,o.steps.length-1,-1),!0}class uo{constructor(e){this.editor=e}insertInlineContent(e,{updateSelection:t=!1}={}){const n=u.inlineContentToNodes(e,this.editor.pmSchema);this.editor.transact(r=>{ao(r,{from:r.selection.from,to:r.selection.to},n,{updateSelection:t})})}getActiveStyles(){return this.editor.transact(e=>{const t={},n=e.selection.$to.marks();for(const r of n){const s=this.editor.schema.styleSchema[r.type.name];if(!s){r.type.name!=="link"&&!r.type.spec.blocknoteIgnore&&console.warn("mark not found in styleschema",r.type.name);continue}s.propSchema==="boolean"?t[s.type]=!0:t[s.type]=r.attrs.stringValue}return t})}addStyles(e){for(const[t,n]of Object.entries(e)){const r=this.editor.schema.styleSchema[t];if(!r)throw new Error(`style ${t} not found in styleSchema`);if(r.propSchema==="boolean")this.editor._tiptapEditor.commands.setMark(t);else if(r.propSchema==="string")this.editor._tiptapEditor.commands.setMark(t,{stringValue:n});else throw new u.UnreachableCaseError(r.propSchema)}}removeStyles(e){for(const t of Object.keys(e))this.editor._tiptapEditor.commands.unsetMark(t)}toggleStyles(e){for(const[t,n]of Object.entries(e)){const r=this.editor.schema.styleSchema[t];if(!r)throw new Error(`style ${t} not found in styleSchema`);if(r.propSchema==="boolean")this.editor._tiptapEditor.commands.toggleMark(t);else if(r.propSchema==="string")this.editor._tiptapEditor.commands.toggleMark(t,{stringValue:n});else throw new u.UnreachableCaseError(r.propSchema)}}getSelectedText(){return this.editor.transact(e=>e.doc.textBetween(e.selection.from,e.selection.to))}getSelectedLinkUrl(){return this.editor._tiptapEditor.getAttributes("link").href}createLink(e,t){if(e==="")return;const n=this.editor.pmSchema.mark("link",{href:e});this.editor.transact(r=>{const{from:s,to:i}=r.selection;t?r.insertText(t,s,i).addMark(s,s+t.length,n):r.setSelection(He.TextSelection.create(r.doc,i)).addMark(s,i,n)})}}function po(o){return S.findParentNodeClosestToPos(o.state.selection.$from,e=>e.type.name==="tableCell"||e.type.name==="tableHeader")!==void 0}function xe(o,e){var r;const t=e.nodes.hardBreak;let n=w.Fragment.empty;return o.forEach(s=>{s.isTextblock&&s.childCount>0?(n=n.append(s.content),n=n.addToEnd(t.create())):s.isText?n=n.addToEnd(s):s.isBlock&&s.childCount>0&&(n=n.append(xe(s.content,e)),n=n.addToEnd(t.create()))}),((r=n.lastChild)==null?void 0:r.type)===t&&(n=n.cut(0,n.size-1)),n}function fo(o,e){const t=[];return o.forEach((n,r,s)=>{s!==e&&t.push(n)}),w.Fragment.from(t)}function ho(o,e){const t=[];for(let n=0;n<o.childCount;n++)if(o.child(n).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(o.child(n)));t[t.length-1]=s}else{const r=e.nodes.table.createChecked(void 0,o.child(n));t.push(r)}else t.push(o.child(n));return o=w.Fragment.from(t),o}function mo(o,e){let t=w.Fragment.from(o.content);if(t=ho(t,e.state.schema),po(e)){let n=!1;if(t.descendants(r=>{r.type.isInGroup("tableContent")&&(n=!0)}),!n&&!e.state.schema.nodes.tableParagraph.validContent(t))return new w.Slice(xe(t,e.state.schema),0,0)}if(!ko(t,e))return new w.Slice(t,o.openStart,o.openEnd);for(let n=0;n<t.childCount;n++)if(t.child(n).type.spec.group==="blockContent"){const r=[t.child(n)];if(n+1<t.childCount&&t.child(n+1).type.name==="blockGroup"){const i=t.child(n+1).child(0).child(0);(i.type.name==="bulletListItem"||i.type.name==="numberedListItem"||i.type.name==="checkListItem")&&(r.push(t.child(n+1)),t=fo(t,n+1))}const s=e.state.schema.nodes.blockContainer.createChecked(void 0,r);t=t.replaceChild(n,s)}return new w.Slice(t,o.openStart,o.openEnd)}function ko(o,e){var s,i;const t=o.childCount===1,n=((s=o.firstChild)==null?void 0:s.type.spec.content)==="inline*",r=((i=o.firstChild)==null?void 0:i.type.spec.content)==="tableRow+";if(t){if(n)return!1;if(r){const a=u.getBlockInfoFromSelection(e.state);if(a.isBlockContainer)return!(a.blockContent.node.type.spec.content==="tableRow+")}}return!0}const go={enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!1};class K extends z.EventEmitter{constructor(t){var l,p,f,h,k,m,g,C,y,P;super();b(this,"pmSchema");b(this,"_tiptapEditor");b(this,"elementRenderer",null);b(this,"blockCache",new WeakMap);b(this,"dictionary");b(this,"schema");b(this,"blockImplementations");b(this,"inlineContentImplementations");b(this,"styleImplementations");b(this,"uploadFile");b(this,"onUploadStartCallbacks",[]);b(this,"onUploadEndCallbacks",[]);b(this,"resolveFileUrl");b(this,"settings");b(this,"_blockManager");b(this,"_eventManager");b(this,"_exportManager");b(this,"_extensionManager");b(this,"_selectionManager");b(this,"_stateManager");b(this,"_styleManager");b(this,"unregisterExtension",(...t)=>this._extensionManager.unregisterExtension(...t));b(this,"registerExtension",(...t)=>this._extensionManager.registerExtension(...t));b(this,"getExtension",(...t)=>this._extensionManager.getExtension(...t));b(this,"mount",t=>{this._tiptapEditor.mount({mount:t})});b(this,"unmount",()=>{this._tiptapEditor.unmount()});this.options=t,this.dictionary=t.dictionary||Me.en,this.settings={tables:{splitCells:((l=t==null?void 0:t.tables)==null?void 0:l.splitCells)??!1,cellBackgroundColor:((p=t==null?void 0:t.tables)==null?void 0:p.cellBackgroundColor)??!1,cellTextColor:((f=t==null?void 0:t.tables)==null?void 0:f.cellTextColor)??!1,headers:((h=t==null?void 0:t.tables)==null?void 0:h.headers)??!1}};const n={defaultStyles:!0,schema:t.schema||I.BlockNoteSchema.create(),...t,placeholders:{...this.dictionary.placeholders,...t.placeholders}};if(this.schema=n.schema,this.blockImplementations=n.schema.blockSpecs,this.inlineContentImplementations=n.schema.inlineContentSpecs,this.styleImplementations=n.schema.styleSpecs,n.uploadFile){const x=n.uploadFile;this.uploadFile=async(v,M)=>{this.onUploadStartCallbacks.forEach(A=>A.apply(this,[M]));try{return await x(v,M)}finally{this.onUploadEndCallbacks.forEach(A=>A.apply(this,[M]))}}}this.resolveFileUrl=n.resolveFileUrl,this._eventManager=new ct(this),this._extensionManager=new oo(this,n);const r=this._extensionManager.getTiptapExtensions(),s=this._extensionManager.hasExtension("ySync")||this._extensionManager.hasExtension("liveblocksExtension");s&&n.initialContent&&console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider");const i={...go,...n._tiptapOptions,element:null,autofocus:n.autofocus??!1,extensions:r,editorProps:{...(k=n._tiptapOptions)==null?void 0:k.editorProps,attributes:{tabIndex:"0",...(g=(m=n._tiptapOptions)==null?void 0:m.editorProps)==null?void 0:g.attributes,...(C=n.domAttributes)==null?void 0:C.editor,class:d.mergeCSSClasses("bn-editor",n.defaultStyles?"bn-default-styles":"",((P=(y=n.domAttributes)==null?void 0:y.editor)==null?void 0:P.class)||"")},transformPasted:mo}};try{const x=n.initialContent||(s?[{type:"paragraph",id:"initialBlockId"}]:[{type:"paragraph",id:u.UniqueID.options.generateID()}]);if(!Array.isArray(x)||x.length===0)throw new Error("initialContent must be a non-empty array of blocks, received: "+x);const v=S.getSchema(i.extensions),M=x.map(Ee=>u.blockToNode(Ee,v,this.schema.styleSchema).toJSON()),A=S.createDocument({type:"doc",content:[{type:"blockGroup",content:M}]},v,i.parseOptions);this._tiptapEditor=new S.Editor({...i,content:A.toJSON()}),this.pmSchema=this._tiptapEditor.schema}catch(x){throw new Error("Error creating document from blocks passed as `initialContent`",{cause:x})}let a;const c=this.pmSchema.nodes.doc.createAndFill;this.pmSchema.nodes.doc.createAndFill=(...x)=>{if(a)return a;const v=c.apply(this.pmSchema.nodes.doc,x),M=JSON.parse(JSON.stringify(v.toJSON()));return M.content[0].content[0].attrs.id="initialBlockId",a=E.Node.fromJSON(this.pmSchema,M),a},this.pmSchema.cached.blockNoteEditor=this,this._blockManager=new it(this),this._exportManager=new kt(this),this._selectionManager=new co(this),this._stateManager=new lo(this),this._styleManager=new uo(this),this.emit("create")}static create(t){return new K(t??{})}get extensions(){return this._extensionManager.getExtensions()}exec(t){return this._stateManager.exec(t)}canExec(t){return this._stateManager.canExec(t)}transact(t){return this._stateManager.transact(t)}get prosemirrorState(){return this._stateManager.prosemirrorState}get prosemirrorView(){return this._stateManager.prosemirrorView}get domElement(){var t;if(!this.headless)return(t=this.prosemirrorView)==null?void 0:t.dom}isFocused(){var t;return this.headless?!1:((t=this.prosemirrorView)==null?void 0:t.hasFocus())||!1}get headless(){return!this._tiptapEditor.isInitialized}focus(){this.headless||this.prosemirrorView.focus()}blur(){var t;this.headless||(t=this.domElement)==null||t.blur()}onUploadStart(t){return this.onUploadStartCallbacks.push(t),()=>{const n=this.onUploadStartCallbacks.indexOf(t);n>-1&&this.onUploadStartCallbacks.splice(n,1)}}onUploadEnd(t){return this.onUploadEndCallbacks.push(t),()=>{const n=this.onUploadEndCallbacks.indexOf(t);n>-1&&this.onUploadEndCallbacks.splice(n,1)}}get topLevelBlocks(){return this.document}get document(){return this._blockManager.document}getBlock(t){return this._blockManager.getBlock(t)}getPrevBlock(t){return this._blockManager.getPrevBlock(t)}getNextBlock(t){return this._blockManager.getNextBlock(t)}getParentBlock(t){return this._blockManager.getParentBlock(t)}forEachBlock(t,n=!1){this._blockManager.forEachBlock(t,n)}onEditorContentChange(t){this._tiptapEditor.on("update",t)}onEditorSelectionChange(t){this._tiptapEditor.on("selectionUpdate",t)}onBeforeChange(t){return this._extensionManager.getExtension(B.BlockChangeExtension).subscribe(t)}getTextCursorPosition(){return this._selectionManager.getTextCursorPosition()}setTextCursorPosition(t,n="start"){return this._selectionManager.setTextCursorPosition(t,n)}getSelection(){return this._selectionManager.getSelection()}getSelectionCutBlocks(t=!1){return this._selectionManager.getSelectionCutBlocks(t)}setSelection(t,n){return this._selectionManager.setSelection(t,n)}get isEditable(){return this._stateManager.isEditable}set isEditable(t){this._stateManager.isEditable=t}insertBlocks(t,n,r="before"){return this._blockManager.insertBlocks(t,n,r)}updateBlock(t,n){return this._blockManager.updateBlock(t,n)}removeBlocks(t){return this._blockManager.removeBlocks(t)}replaceBlocks(t,n){return this._blockManager.replaceBlocks(t,n)}undo(){return this._stateManager.undo()}redo(){return this._stateManager.redo()}insertInlineContent(t,{updateSelection:n=!1}={}){this._styleManager.insertInlineContent(t,{updateSelection:n})}getActiveStyles(){return this._styleManager.getActiveStyles()}addStyles(t){this._styleManager.addStyles(t)}removeStyles(t){this._styleManager.removeStyles(t)}toggleStyles(t){this._styleManager.toggleStyles(t)}getSelectedText(){return this._styleManager.getSelectedText()}getSelectedLinkUrl(){return this._styleManager.getSelectedLinkUrl()}createLink(t,n){this._styleManager.createLink(t,n)}canNestBlock(){return this._blockManager.canNestBlock()}nestBlock(){this._blockManager.nestBlock()}canUnnestBlock(){return this._blockManager.canUnnestBlock()}unnestBlock(){this._blockManager.unnestBlock()}moveBlocksUp(){return this._blockManager.moveBlocksUp()}moveBlocksDown(){return this._blockManager.moveBlocksDown()}blocksToHTMLLossy(t=this.document){return this._exportManager.blocksToHTMLLossy(t)}blocksToFullHTML(t=this.document){return this._exportManager.blocksToFullHTML(t)}tryParseHTMLToBlocks(t){return this._exportManager.tryParseHTMLToBlocks(t)}blocksToMarkdownLossy(t=this.document){return this._exportManager.blocksToMarkdownLossy(t)}tryParseMarkdownToBlocks(t){return this._exportManager.tryParseMarkdownToBlocks(t)}onChange(t,n){return this._eventManager.onChange(t,n)}onSelectionChange(t,n){return this._eventManager.onSelectionChange(t,n)}onMount(t){this._eventManager.onMount(t)}onUnmount(t){this._eventManager.onUnmount(t)}getSelectionBoundingBox(){return this._selectionManager.getSelectionBoundingBox()}get isEmpty(){const t=this.document;return t.length===0||t.length===1&&t[0].type==="paragraph"&&t[0].content.length===0}pasteHTML(t,n=!1){this._exportManager.pasteHTML(t,n)}pasteText(t){return this._exportManager.pasteText(t)}pasteMarkdown(t){return this._exportManager.pasteMarkdown(t)}}class bo{constructor(e,t,n){this.mappings=t,this.options=n}async resolveFile(e){var n;if(!((n=this.options)!=null&&n.resolveFileUrl))return(await fetch(e)).blob();const t=await this.options.resolveFileUrl(e);return t instanceof Blob?t:(await fetch(t)).blob()}mapStyles(e){return Object.entries(e).map(([n,r])=>this.mappings.styleMapping[n](r,this))}mapInlineContent(e){return this.mappings.inlineContentMapping[e.type](e,this)}transformInlineContent(e){return e.map(t=>this.mapInlineContent(t))}async mapBlock(e,t,n,r){return this.mappings.blockMapping[e.type](e,this,t,n,r)}}function Bo(o){return{createBlockMapping:e=>e,createInlineContentMapping:e=>e,createStyleMapping:e=>e}}function So(o,...e){const t=[...o];for(const n of e)for(const r of n){const s=t.findLastIndex(i=>i.group===r.group);s===-1?t.push(r):t.splice(s+1,0,r)}return t}exports.UniqueID=u.UniqueID;exports.UnreachableCaseError=u.UnreachableCaseError;exports.assertEmpty=u.assertEmpty;exports.blockToNode=u.blockToNode;exports.contentNodeToInlineContent=u.contentNodeToInlineContent;exports.contentNodeToTableContent=u.contentNodeToTableContent;exports.docToBlocks=u.docToBlocks;exports.getBlockCache=u.getBlockCache;exports.getBlockInfo=u.getBlockInfo;exports.getBlockInfoFromResolvedPos=u.getBlockInfoFromResolvedPos;exports.getBlockInfoFromSelection=u.getBlockInfoFromSelection;exports.getBlockInfoFromTransaction=u.getBlockInfoFromTransaction;exports.getBlockInfoWithManualOffset=u.getBlockInfoWithManualOffset;exports.getBlockNoteSchema=u.getBlockNoteSchema;exports.getBlockSchema=u.getBlockSchema;exports.getColspan=u.getColspan;exports.getInlineContentSchema=u.getInlineContentSchema;exports.getNearestBlockPos=u.getNearestBlockPos;exports.getPmSchema=u.getPmSchema;exports.getRowspan=u.getRowspan;exports.getStyleSchema=u.getStyleSchema;exports.inlineContentToNodes=u.inlineContentToNodes;exports.isLinkInlineContent=u.isLinkInlineContent;exports.isPartialLinkInlineContent=u.isPartialLinkInlineContent;exports.isPartialTableCell=u.isPartialTableCell;exports.isStyledTextInlineContent=u.isStyledTextInlineContent;exports.isTableCell=u.isTableCell;exports.mapTableCell=u.mapTableCell;exports.nodeToBlock=u.nodeToBlock;exports.nodeToCustomInlineContent=u.nodeToCustomInlineContent;exports.prosemirrorSliceToSlicedBlocks=u.prosemirrorSliceToSlicedBlocks;exports.tableContentToNodes=u.tableContentToNodes;exports.COLORS_DARK_MODE_DEFAULT=d.COLORS_DARK_MODE_DEFAULT;exports.COLORS_DEFAULT=d.COLORS_DEFAULT;exports.EMPTY_CELL_HEIGHT=d.EMPTY_CELL_HEIGHT;exports.EMPTY_CELL_WIDTH=d.EMPTY_CELL_WIDTH;exports.FILE_AUDIO_ICON_SVG=d.FILE_AUDIO_ICON_SVG;exports.FILE_IMAGE_ICON_SVG=d.FILE_IMAGE_ICON_SVG;exports.FILE_VIDEO_ICON_SVG=d.FILE_VIDEO_ICON_SVG;exports.addDefaultPropsExternalHTML=d.addDefaultPropsExternalHTML;exports.addInlineContentAttributes=d.addInlineContentAttributes;exports.addInlineContentKeyboardShortcuts=d.addInlineContentKeyboardShortcuts;exports.addNodeAndExtensionsToSpec=d.addNodeAndExtensionsToSpec;exports.addStyleAttributes=d.addStyleAttributes;exports.applyNonSelectableBlockFix=d.applyNonSelectableBlockFix;exports.audioParse=d.audioParse;exports.audioRender=d.audioRender;exports.audioToExternalHTML=d.audioToExternalHTML;exports.blockHasType=d.blockHasType;exports.camelToDataKebab=d.camelToDataKebab;exports.captureCellAnchor=d.captureCellAnchor;exports.createAudioBlockConfig=d.createAudioBlockConfig;exports.createAudioBlockSpec=d.createAudioBlockSpec;exports.createBlockConfig=d.createBlockConfig;exports.createBlockSpec=d.createBlockSpec;exports.createBlockSpecFromTiptapNode=d.createBlockSpecFromTiptapNode;exports.createBulletListItemBlockConfig=d.createBulletListItemBlockConfig;exports.createBulletListItemBlockSpec=d.createBulletListItemBlockSpec;exports.createCheckListItemBlockSpec=d.createCheckListItemBlockSpec;exports.createCheckListItemConfig=d.createCheckListItemConfig;exports.createCodeBlockConfig=d.createCodeBlockConfig;exports.createCodeBlockSpec=d.createCodeBlockSpec;exports.createDefaultBlockDOMOutputSpec=d.createDefaultBlockDOMOutputSpec;exports.createDividerBlockConfig=d.createDividerBlockConfig;exports.createDividerBlockSpec=d.createDividerBlockSpec;exports.createFileBlockConfig=d.createFileBlockConfig;exports.createFileBlockSpec=d.createFileBlockSpec;exports.createHeadingBlockConfig=d.createHeadingBlockConfig;exports.createHeadingBlockSpec=d.createHeadingBlockSpec;exports.createImageBlockConfig=d.createImageBlockConfig;exports.createImageBlockSpec=d.createImageBlockSpec;exports.createInlineContentSpecFromTipTapNode=d.createInlineContentSpecFromTipTapNode;exports.createInternalInlineContentSpec=d.createInternalInlineContentSpec;exports.createInternalStyleSpec=d.createInternalStyleSpec;exports.createNumberedListItemBlockConfig=d.createNumberedListItemBlockConfig;exports.createNumberedListItemBlockSpec=d.createNumberedListItemBlockSpec;exports.createParagraphBlockConfig=d.createParagraphBlockConfig;exports.createParagraphBlockSpec=d.createParagraphBlockSpec;exports.createQuoteBlockConfig=d.createQuoteBlockConfig;exports.createQuoteBlockSpec=d.createQuoteBlockSpec;exports.createStyleSpec=d.createStyleSpec;exports.createStyleSpecFromTipTapMark=d.createStyleSpecFromTipTapMark;exports.createTableBlockSpec=d.createTableBlockSpec;exports.createToggleListItemBlockConfig=d.createToggleListItemBlockConfig;exports.createToggleListItemBlockSpec=d.createToggleListItemBlockSpec;exports.createToggleWrapper=d.createToggleWrapper;exports.createVideoBlockConfig=d.createVideoBlockConfig;exports.createVideoBlockSpec=d.createVideoBlockSpec;exports.defaultBlockSpecs=d.defaultBlockSpecs;exports.defaultBlockToHTML=d.defaultBlockToHTML;exports.defaultInlineContentSchema=d.defaultInlineContentSchema;exports.defaultInlineContentSpecs=d.defaultInlineContentSpecs;exports.defaultProps=d.defaultProps;exports.defaultStyleSchema=d.defaultStyleSchema;exports.defaultStyleSpecs=d.defaultStyleSpecs;exports.defaultToggledState=d.defaultToggledState;exports.editorHasBlockWithType=d.editorHasBlockWithType;exports.fileParse=d.fileParse;exports.filenameFromURL=d.filenameFromURL;exports.formatKeyboardShortcut=d.formatKeyboardShortcut;exports.getBackgroundColorAttribute=d.getBackgroundColorAttribute;exports.getBlockFromPos=d.getBlockFromPos;exports.getInlineContentSchemaFromSpecs=d.getInlineContentSchemaFromSpecs;exports.getLanguageId=d.getLanguageId;exports.getNodeById=d.getNodeById;exports.getParseRules=d.getParseRules;exports.getStyleParseRules=d.getStyleParseRules;exports.getStyleSchemaFromSpecs=d.getStyleSchemaFromSpecs;exports.getTextAlignmentAttribute=d.getTextAlignmentAttribute;exports.getTextColorAttribute=d.getTextColorAttribute;exports.imageParse=d.imageParse;exports.imageRender=d.imageRender;exports.imageToExternalHTML=d.imageToExternalHTML;exports.isAppleOS=d.isAppleOS;exports.isNodeBlock=d.isNodeBlock;exports.isSafari=d.isSafari;exports.isTableCellSelection=d.isTableCellSelection;exports.isVideoUrl=d.isVideoUrl;exports.mergeCSSClasses=d.mergeCSSClasses;exports.mergeParagraphs=d.mergeParagraphs;exports.parseAudioElement=d.parseAudioElement;exports.parseDefaultProps=d.parseDefaultProps;exports.propsToAttributes=d.propsToAttributes;exports.stylePropsToAttributes=d.stylePropsToAttributes;exports.tablePropSchema=d.tablePropSchema;exports.trackPosition=d.trackPosition;exports.updateBlock=d.updateBlock;exports.updateBlockCommand=d.updateBlockCommand;exports.updateBlockTr=d.updateBlockTr;exports.videoParse=d.videoParse;exports.wrapInBlockStructure=d.wrapInBlockStructure;exports.blocksToMarkdown=B.blocksToMarkdown;exports.cleanHTMLToMarkdown=B.cleanHTMLToMarkdown;exports.createExternalHTMLExporter=B.createExternalHTMLExporter;exports.getBlocksChangedByTransaction=B.getBlocksChangedByTransaction;exports.BlockNoteSchema=I.BlockNoteSchema;exports.CustomBlockNoteSchema=I.CustomBlockNoteSchema;exports.checkPageBreakBlocksInSchema=I.checkPageBreakBlocksInSchema;exports.createPageBreakBlockConfig=I.createPageBreakBlockConfig;exports.createPageBreakBlockSpec=I.createPageBreakBlockSpec;exports.getPageBreakSlashMenuItems=I.getPageBreakSlashMenuItems;exports.uploadToTmpFilesDotOrg_DEV_ONLY=I.uploadToTmpFilesDotOrg_DEV_ONLY;exports.withPageBreak=I.withPageBreak;exports.EventEmitter=z.EventEmitter;exports.createExtension=H.createExtension;exports.createStore=H.createStore;exports.BlockNoteEditor=K;exports.Exporter=bo;exports.HTMLToBlocks=G;exports.combineByGroup=So;exports.createInlineContentSpec=ze;exports.createInternalHTMLSerializer=le;exports.expandPMRangeToWords=ye;exports.fixColumnList=_;exports.getBlock=he;exports.getInlineContentParseRules=ne;exports.getNextBlock=ke;exports.getParentBlock=ge;exports.getPrevBlock=me;exports.insertBlocks=re;exports.isEmptyColumn=O;exports.mappingFactory=Bo;exports.markdownToBlocks=be;exports.markdownToHTML=q;exports.removeAndInsertBlocks=V;exports.removeEmptyColumns=se;exports.selectedFragmentToHTML=j;
1
+ "use strict";var Ie=Object.defineProperty;var Me=(o,e,t)=>e in o?Ie(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var B=(o,e,t)=>Me(o,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("prosemirror-model"),F=require("prosemirror-transform"),u=require("./blockToNode-CumVjgem.cjs"),a=require("./defaultBlocks-Dg9kQWXm.cjs"),m=require("./TrailingNode-n0WdMPUl.cjs"),I=require("./BlockNoteSchema-CCs_V3lo.cjs"),S=require("@tiptap/core"),G=require("./EventEmitter-CLwfmbqG.cjs"),w=require("@tiptap/pm/model"),we=require("./en-Cl87Uuyf.cjs"),Y=require("@handlewithcare/prosemirror-inputrules"),ve=require("@tiptap/pm/keymap"),H=require("./BlockNoteExtension-BWw0r8Gy.cjs"),Ae=require("@tiptap/extensions/gap-cursor"),Ne=require("@tiptap/extension-link"),Le=require("@tiptap/extension-text"),E=require("prosemirror-state"),D=require("prosemirror-tables"),ne=require("./ShowSelection-BxnbRvy4.cjs"),_e=require("remark-gfm"),De=require("remark-parse"),V=require("remark-rehype"),Fe=require("rehype-stringify"),Oe=require("unified"),He=require("@tiptap/pm/state"),$=o=>o&&typeof o=="object"&&"default"in o?o:{default:o},$e=$(_e),Ve=$(De),Re=$(V),Ue=$(Fe);function re(o,e){const t=[{tag:`[data-inline-content-type="${o.type}"]`,contentElement:n=>{const r=n;return r.matches("[data-editable]")?r:r.querySelector("[data-editable]")||r}}];return e&&t.push({tag:"*",getAttrs(n){if(typeof n=="string")return!1;const r=e==null?void 0:e(n);return r===void 0?!1:r}}),t}function Ge(o,e){var n;const t=S.Node.create({name:o.type,inline:!0,group:"inline",draggable:(n=e.meta)==null?void 0:n.draggable,selectable:o.content==="styled",atom:o.content==="none",content:o.content==="styled"?"inline*":"",addAttributes(){return a.propsToAttributes(o.propSchema)},addKeyboardShortcuts(){return a.addInlineContentKeyboardShortcuts(o)},parseHTML(){return re(o,e.parse)},renderHTML({node:r}){const s=this.options.editor,i=e.render.call({renderType:"dom",props:void 0},u.nodeToCustomInlineContent(r,s.schema.inlineContentSchema,s.schema.styleSchema),()=>{},s);return a.addInlineContentAttributes(i,o.type,r.attrs,o.propSchema)},addNodeView(){return r=>{const{node:s,getPos:i}=r,d=this.options.editor,c=e.render.call({renderType:"nodeView",props:r},u.nodeToCustomInlineContent(s,d.schema.inlineContentSchema,d.schema.styleSchema),l=>{const p=u.inlineContentToNodes([l],d.pmSchema),f=i();f&&d.transact(h=>h.replaceWith(f,f+s.nodeSize,p))},d);return a.addInlineContentAttributes(c,o.type,s.attrs,o.propSchema)}}});return a.createInlineContentSpecFromTipTapNode(t,o.propSchema,{...e,toExternalHTML:e.toExternalHTML,render(r,s,i){const d=e.render(r,s,i);return a.addInlineContentAttributes(d,o.type,r.props,o.propSchema)}})}function se(o,e,t,n="before"){const r=typeof t=="string"?t:t.id,s=u.getPmSchema(o),i=e.map(p=>u.blockToNode(p,s)),d=a.getNodeById(r,o.doc);if(!d)throw new Error(`Block with ID ${r} not found`);let c=d.posBeforeNode;return n==="after"&&(c+=d.node.nodeSize),o.step(new F.ReplaceStep(c,c,new T.Slice(T.Fragment.from(i),0,0))),i.map(p=>u.nodeToBlock(p,s))}function O(o){if(!o||o.type.name!=="column")throw new Error("Invalid columnPos: does not point to column node.");const e=o.firstChild;if(!e)throw new Error("Invalid column: does not have child node.");const t=e.firstChild;if(!t)throw new Error("Invalid blockContainer: does not have child node.");return o.childCount===1&&e.childCount===1&&t.type.name==="paragraph"&&t.content.content.length===0}function ie(o,e){const t=o.doc.resolve(e),n=t.nodeAfter;if(!n||n.type.name!=="columnList")throw new Error("Invalid columnListPos: does not point to columnList node.");for(let r=n.childCount-1;r>=0;r--){const s=o.doc.resolve(t.pos+1).posAtIndex(r),d=o.doc.resolve(s).nodeAfter;if(!d||d.type.name!=="column")throw new Error("Invalid columnPos: does not point to column node.");O(d)&&o.delete(s,s+d.nodeSize)}}function _(o,e){ie(o,e);const n=o.doc.resolve(e).nodeAfter;if(!n||n.type.name!=="columnList")throw new Error("Invalid columnListPos: does not point to columnList node.");if(n.childCount>2)return;if(n.childCount<2)throw new Error("Invalid columnList: contains fewer than two children.");const r=e+1,i=o.doc.resolve(r).nodeAfter,d=e+n.nodeSize-1,l=o.doc.resolve(d).nodeBefore;if(!i||!l)throw new Error("Invalid columnList: does not contain children.");const p=O(i),f=O(l);if(p&&f){o.delete(e,e+n.nodeSize);return}if(p){o.step(new F.ReplaceAroundStep(e,e+n.nodeSize,d-l.nodeSize+1,d-1,T.Slice.empty,0,!1));return}if(f){o.step(new F.ReplaceAroundStep(e,e+n.nodeSize,r+1,r+i.nodeSize-1,T.Slice.empty,0,!1));return}}function R(o,e,t){const n=u.getPmSchema(o),r=t.map(f=>u.blockToNode(f,n)),s=new Set(e.map(f=>typeof f=="string"?f:f.id)),i=[],d=new Set,c=typeof e[0]=="string"?e[0]:e[0].id;let l=0;if(o.doc.descendants((f,h)=>{if(s.size===0)return!1;if(!f.type.isInGroup("bnBlock")||!s.has(f.attrs.id))return!0;if(i.push(u.nodeToBlock(f,n)),s.delete(f.attrs.id),t.length>0&&f.attrs.id===c){const C=o.doc.nodeSize;o.insert(h,r);const y=o.doc.nodeSize;l+=C-y}const g=o.doc.nodeSize,k=o.doc.resolve(h-l);k.node().type.name==="column"?d.add(k.before(-1)):k.node().type.name==="columnList"&&d.add(k.before()),k.node().type.name==="blockGroup"&&k.node(k.depth-1).type.name!=="doc"&&k.node().childCount===1?o.delete(k.before(),k.after()):o.delete(h-l,h-l+f.nodeSize);const b=o.doc.nodeSize;return l+=g-b,!1}),s.size>0){const f=[...s].join(`
2
+ `);throw Error("Blocks with the following IDs could not be found in the editor: "+f)}return d.forEach(f=>_(o,f)),{insertedBlocks:r.map(f=>u.nodeToBlock(f,n)),removedBlocks:i}}function ze(o,e,t,n,r){let s;if(e)if(typeof e=="string")s=u.inlineContentToNodes([e],o.pmSchema,n);else if(Array.isArray(e))s=u.inlineContentToNodes(e,o.pmSchema,n);else if(e.type==="tableContent")s=u.tableContentToNodes(e,o.pmSchema);else throw new u.UnreachableCaseError(e.type);else throw new Error("blockContent is required");const d=((r==null?void 0:r.document)??document).createDocumentFragment();for(const c of s)if(c.type.name!=="text"&&o.schema.inlineContentSchema[c.type.name]){const l=o.schema.inlineContentSpecs[c.type.name].implementation;if(l){const p=u.nodeToCustomInlineContent(c,o.schema.inlineContentSchema,o.schema.styleSchema),f=l.render.call({renderType:"dom",props:void 0},p,()=>{},o);if(f){if(d.appendChild(f.dom),f.contentDOM){const h=t.serializeFragment(c.content,r);f.contentDOM.dataset.editable="",f.contentDOM.appendChild(h)}continue}}}else if(c.type.name==="text"){let l=document.createTextNode(c.textContent);for(const p of c.marks.toReversed())if(p.type.name in o.schema.styleSpecs){const f=o.schema.styleSpecs[p.type.name].implementation.render(p.attrs.stringValue,o);f.contentDOM.appendChild(l),l=f.dom}else{const f=p.type.spec.toDOM(p,!0),h=T.DOMSerializer.renderSpec(document,f);h.contentDOM.appendChild(l),l=h.dom}d.appendChild(l)}else{const l=t.serializeFragment(T.Fragment.from([c]),r);d.appendChild(l)}return d}function qe(o,e,t,n){var f,h,g,k,b;const r=o.pmSchema.nodes.blockContainer,s=e.props||{};for(const[C,y]of Object.entries(o.schema.blockSchema[e.type].propSchema))!(C in s)&&y.default!==void 0&&(s[C]=y.default);const i=e.children||[],c=o.blockImplementations[e.type].implementation.render.call({renderType:"dom",props:void 0},{...e,props:s,children:i},o);if(c.contentDOM&&e.content){const C=ze(o,e.content,t,e.type,n);c.contentDOM.appendChild(C)}if(o.pmSchema.nodes[e.type].isInGroup("bnBlock")){if(e.children&&e.children.length>0){const C=ce(o,e.children,t,n);(f=c.contentDOM)==null||f.append(C)}return c.dom}const p=(g=(h=r.spec)==null?void 0:h.toDOM)==null?void 0:g.call(h,r.create({id:e.id,...s}));return(k=p.contentDOM)==null||k.appendChild(c.dom),e.children&&e.children.length>0&&((b=p.contentDOM)==null||b.appendChild(le(o,e.children,t,n))),p.dom}function ce(o,e,t,n){const s=((n==null?void 0:n.document)??document).createDocumentFragment();for(const i of e){const d=qe(o,i,t,n);s.appendChild(d)}return s}const le=(o,e,t,n)=>{var d;const r=o.pmSchema.nodes.blockGroup,s=r.spec.toDOM(r.create({})),i=ce(o,e,t,n);return(d=s.contentDOM)==null||d.appendChild(i),s.dom},We=o=>(o.querySelectorAll('[data-content-type="numberedListItem"]').forEach(t=>{var r,s;const n=(s=(r=t.closest(".bn-block-outer"))==null?void 0:r.previousElementSibling)==null?void 0:s.querySelector('[data-content-type="numberedListItem"]');if(!n)t.setAttribute("data-index",t.getAttribute("data-start")||"1");else{const i=n.getAttribute("data-index");t.setAttribute("data-index",(parseInt(i||"0")+1).toString())}}),o),je=o=>(o.querySelectorAll('[data-content-type="checkListItem"] input').forEach(t=>{t.disabled=!0}),o),Ke=o=>(o.querySelectorAll('.bn-toggle-wrapper[data-show-children="false"]').forEach(t=>{t.setAttribute("data-show-children","true")}),o),Ye=o=>(o.querySelectorAll('[data-content-type="table"] table').forEach(t=>{t.setAttribute("style",`--default-cell-min-width: ${a.EMPTY_CELL_WIDTH}px;`),t.setAttribute("data-show-children","true")}),o),Je=o=>(o.querySelectorAll('[data-content-type="table"] table').forEach(t=>{var s;const n=document.createElement("div");n.className="tableWrapper";const r=document.createElement("div");r.className="tableWrapper-inner",n.appendChild(r),(s=t.parentElement)==null||s.appendChild(n),n.appendChild(t)}),o),Qe=o=>(o.querySelectorAll(".bn-inline-content:empty").forEach(t=>{const n=document.createElement("span");n.className="ProseMirror-trailingBreak",n.setAttribute("style","display: inline-block;"),t.appendChild(n)}),o),ae=(o,e)=>{const t=T.DOMSerializer.fromSchema(o),n=[We,je,Ke,Ye,Je,Qe];return{serializeBlocks:(r,s)=>{let i=le(e,r,t,s);for(const d of n)i=d(i);return i.outerHTML}}};function Xe(o){return o.transact(e=>{const t=u.getNearestBlockPos(e.doc,e.selection.anchor);if(e.selection instanceof D.CellSelection)return{type:"cell",anchorBlockId:t.node.attrs.id,anchorCellOffset:e.selection.$anchorCell.pos-t.posBeforeNode,headCellOffset:e.selection.$headCell.pos-t.posBeforeNode};if(e.selection instanceof E.NodeSelection)return{type:"node",anchorBlockId:t.node.attrs.id};{const n=u.getNearestBlockPos(e.doc,e.selection.head);return{type:"text",anchorBlockId:t.node.attrs.id,headBlockId:n.node.attrs.id,anchorOffset:e.selection.anchor-t.posBeforeNode,headOffset:e.selection.head-n.posBeforeNode}}})}function Ze(o,e){var r,s;const t=(r=a.getNodeById(e.anchorBlockId,o.doc))==null?void 0:r.posBeforeNode;if(t===void 0)throw new Error(`Could not find block with ID ${e.anchorBlockId} to update selection`);let n;if(e.type==="cell")n=D.CellSelection.create(o.doc,t+e.anchorCellOffset,t+e.headCellOffset);else if(e.type==="node")n=E.NodeSelection.create(o.doc,t+1);else{const i=(s=a.getNodeById(e.headBlockId,o.doc))==null?void 0:s.posBeforeNode;if(i===void 0)throw new Error(`Could not find block with ID ${e.headBlockId} to update selection`);n=E.TextSelection.create(o.doc,t+e.anchorOffset,i+e.headOffset)}o.setSelection(n)}function U(o){return o.map(e=>e.type==="columnList"?e.children.map(t=>U(t.children)).flat():{...e,children:U(e.children)}).flat()}function de(o,e,t){o.transact(n=>{var i;const r=((i=o.getSelection())==null?void 0:i.blocks)||[o.getTextCursorPosition().block],s=Xe(o);o.removeBlocks(r),o.insertBlocks(U(r),e,t),Ze(n,s)})}function ue(o){return!o||o.type!=="columnList"}function pe(o,e,t){let n,r;if(e?e.children.length>0?(n=e.children[e.children.length-1],r="after"):(n=e,r="before"):t&&(n=t,r="before"),!n||!r)return;const s=o.getParentBlock(n);return ue(s)?{referenceBlock:n,placement:r}:pe(o,r==="after"?n:o.getPrevBlock(n),s)}function fe(o,e,t){let n,r;if(e?e.children.length>0?(n=e.children[0],r="before"):(n=e,r="after"):t&&(n=t,r="after"),!n||!r)return;const s=o.getParentBlock(n);return ue(s)?{referenceBlock:n,placement:r}:fe(o,r==="before"?n:o.getNextBlock(n),s)}function et(o){o.transact(()=>{const e=o.getSelection(),t=(e==null?void 0:e.blocks[0])||o.getTextCursorPosition().block,n=pe(o,o.getPrevBlock(t),o.getParentBlock(t));n&&de(o,n.referenceBlock,n.placement)})}function tt(o){o.transact(()=>{const e=o.getSelection(),t=(e==null?void 0:e.blocks[(e==null?void 0:e.blocks.length)-1])||o.getTextCursorPosition().block,n=fe(o,o.getNextBlock(t),o.getParentBlock(t));n&&de(o,n.referenceBlock,n.placement)})}function ot(o,e,t){const{$from:n,$to:r}=o.selection,s=n.blockRange(r,k=>k.childCount>0&&(k.type.name==="blockGroup"||k.type.name==="column"));if(!s)return!1;const i=s.startIndex;if(i===0)return!1;const c=s.parent.child(i-1);if(c.type!==e)return!1;const l=c.lastChild&&c.lastChild.type===t,p=T.Fragment.from(l?e.create():null),f=new T.Slice(T.Fragment.from(e.create(null,T.Fragment.from(t.create(null,p)))),l?3:1,0),h=s.start,g=s.end;return o.step(new F.ReplaceAroundStep(h-(l?3:1),g,h,g,f,1,!0)).scrollIntoView(),!0}function he(o){return o.transact(e=>ot(e,o.pmSchema.nodes.blockContainer,o.pmSchema.nodes.blockGroup))}function nt(o){o._tiptapEditor.commands.liftListItem("blockContainer")}function rt(o){return o.transact(e=>{const{bnBlock:t}=u.getBlockInfoFromTransaction(e);return e.doc.resolve(t.beforePos).nodeBefore!==null})}function st(o){return o.transact(e=>{const{bnBlock:t}=u.getBlockInfoFromTransaction(e);return e.doc.resolve(t.beforePos).depth>1})}function me(o,e){const t=typeof e=="string"?e:e.id,n=u.getPmSchema(o),r=a.getNodeById(t,o);if(r)return u.nodeToBlock(r.node,n)}function ke(o,e){const t=typeof e=="string"?e:e.id,n=a.getNodeById(t,o),r=u.getPmSchema(o);if(!n)return;const i=o.resolve(n.posBeforeNode).nodeBefore;if(i)return u.nodeToBlock(i,r)}function ge(o,e){const t=typeof e=="string"?e:e.id,n=a.getNodeById(t,o),r=u.getPmSchema(o);if(!n)return;const i=o.resolve(n.posBeforeNode+n.node.nodeSize).nodeAfter;if(i)return u.nodeToBlock(i,r)}function be(o,e){const t=typeof e=="string"?e:e.id,n=u.getPmSchema(o),r=a.getNodeById(t,o);if(!r)return;const s=o.resolve(r.posBeforeNode),i=s.node(),d=s.node(-1),c=d.type.name!=="doc"?i.type.name==="blockGroup"?d:i:void 0;if(c)return u.nodeToBlock(c,n)}class it{constructor(e){this.editor=e}get document(){return this.editor.transact(e=>u.docToBlocks(e.doc,this.editor.pmSchema))}getBlock(e){return this.editor.transact(t=>me(t.doc,e))}getPrevBlock(e){return this.editor.transact(t=>ke(t.doc,e))}getNextBlock(e){return this.editor.transact(t=>ge(t.doc,e))}getParentBlock(e){return this.editor.transact(t=>be(t.doc,e))}forEachBlock(e,t=!1){const n=this.document.slice();t&&n.reverse();function r(s){for(const i of s){if(e(i)===!1)return!1;const d=t?i.children.slice().reverse():i.children;if(!r(d))return!1}return!0}r(n)}insertBlocks(e,t,n="before"){return this.editor.transact(r=>se(r,e,t,n))}updateBlock(e,t){return this.editor.transact(n=>a.updateBlock(n,e,t))}removeBlocks(e){return this.editor.transact(t=>R(t,e,[]).removedBlocks)}replaceBlocks(e,t){return this.editor.transact(n=>R(n,e,t))}canNestBlock(){return rt(this.editor)}nestBlock(){he(this.editor)}canUnnestBlock(){return st(this.editor)}unnestBlock(){nt(this.editor)}moveBlocksUp(){return et(this.editor)}moveBlocksDown(){return tt(this.editor)}}class ct extends G.EventEmitter{constructor(e){super(),this.editor=e,e.on("create",()=>{e._tiptapEditor.on("update",({transaction:t,appendedTransactions:n})=>{this.emit("onChange",{editor:e,transaction:t,appendedTransactions:n})}),e._tiptapEditor.on("selectionUpdate",({transaction:t})=>{this.emit("onSelectionChange",{editor:e,transaction:t})}),e._tiptapEditor.on("mount",()=>{this.emit("onMount",{editor:e})}),e._tiptapEditor.on("unmount",()=>{this.emit("onUnmount",{editor:e})})})}onChange(e,t=!0){const n=({transaction:r,appendedTransactions:s})=>{!t&&J(r)||e(this.editor,{getChanges(){return m.getBlocksChangedByTransaction(r,s)}})};return this.on("onChange",n),()=>{this.off("onChange",n)}}onSelectionChange(e,t=!1){const n=r=>{!t&&J(r.transaction)||e(this.editor)};return this.on("onSelectionChange",n),()=>{this.off("onSelectionChange",n)}}onMount(e){return this.on("onMount",e),()=>{this.off("onMount",e)}}onUnmount(e){return this.on("onUnmount",e),()=>{this.off("onUnmount",e)}}}function J(o){return!!o.getMeta("y-sync$")}function lt(o){return Array.prototype.indexOf.call(o.parentElement.childNodes,o)}function at(o){return o.nodeType===3&&!/\S/.test(o.nodeValue||"")}function dt(o){o.querySelectorAll("li > ul, li > ol").forEach(e=>{const t=lt(e),n=e.parentElement,r=Array.from(n.childNodes).slice(t+1);e.remove(),r.forEach(s=>{s.remove()}),n.insertAdjacentElement("afterend",e),r.reverse().forEach(s=>{if(at(s))return;const i=document.createElement("li");i.append(s),e.insertAdjacentElement("afterend",i)}),n.childNodes.length===0&&n.remove()})}function ut(o){o.querySelectorAll("li + ul, li + ol").forEach(e=>{var s,i;const t=e.previousElementSibling,n=document.createElement("div");t.insertAdjacentElement("afterend",n),n.append(t);const r=document.createElement("div");for(r.setAttribute("data-node-type","blockGroup"),n.append(r);((s=n.nextElementSibling)==null?void 0:s.nodeName)==="UL"||((i=n.nextElementSibling)==null?void 0:i.nodeName)==="OL";)r.append(n.nextElementSibling)})}let Q=null;function pt(){return Q||(Q=document.implementation.createHTMLDocument("title"))}function ft(o){if(typeof o=="string"){const e=pt().createElement("div");e.innerHTML=o,o=e}return dt(o),ut(o),o}function ht(o){const e=o.ownerDocument.createTreeWalker(o,128);let t;for(;t=e.nextNode();)if(/^\s*notionvc:/.test(t.nodeValue||""))return!0;return!1}function mt(o){const e=new Set(["PRE","CODE"]),t=o.ownerDocument.createTreeWalker(o,4,{acceptNode(s){let i=s.parentElement;for(;i&&i!==o;){if(e.has(i.tagName))return 2;i=i.parentElement}return 1}}),n=[];let r;for(;r=t.nextNode();)n.push(r);for(const s of n)s.nodeValue&&/[\r\n]/.test(s.nodeValue)&&(s.nodeValue=s.nodeValue.replace(/[ \t\r\n\f]+/g," "))}function kt(o){ht(o)||mt(o)}function z(o,e){const t=ft(o);kt(t);const r=T.DOMParser.fromSchema(e).parse(t,{topNode:e.nodes.blockGroup.create()}),s=[];for(let i=0;i<r.childCount;i++)s.push(u.nodeToBlock(r.child(i),e));return s}function gt(o,e){const t=e.value?e.value:"",n={};e.lang&&(n["data-language"]=e.lang);let r={type:"element",tagName:"code",properties:n,children:[{type:"text",value:t}]};return e.meta&&(r.data={meta:e.meta}),o.patch(e,r),r=o.applyData(e,r),r={type:"element",tagName:"pre",properties:{},children:[r]},o.patch(e,r),r}function bt(o,e){var s;const t=String((e==null?void 0:e.url)||""),n=e!=null&&e.title?String(e.title):void 0;let r={type:"element",tagName:"video",properties:{src:t,"data-name":n,"data-url":t,controls:!0},children:[]};return(s=o.patch)==null||s.call(o,e,r),r=o.applyData?o.applyData(e,r):r,r}function q(o){return Oe.unified().use(Ve.default).use($e.default).use(Re.default,{handlers:{...V.defaultHandlers,image:(t,n)=>{const r=String((n==null?void 0:n.url)||"");return a.isVideoUrl(r)?bt(t,n):V.defaultHandlers.image(t,n)},code:gt,blockquote:(t,n)=>{const r={type:"element",tagName:"blockquote",properties:{},children:t.wrap(t.all(n),!1)};return t.patch(n,r),t.applyData(n,r)}}}).use(Ue.default).processSync(o).value}function Be(o,e){const t=q(o);return z(t,e)}class Bt{constructor(e){this.editor=e}blocksToHTMLLossy(e=this.editor.document){return m.createExternalHTMLExporter(this.editor.pmSchema,this.editor).exportBlocks(e,{})}blocksToFullHTML(e=this.editor.document){return ae(this.editor.pmSchema,this.editor).serializeBlocks(e,{})}tryParseHTMLToBlocks(e){return z(e,this.editor.pmSchema)}blocksToMarkdownLossy(e=this.editor.document){return m.blocksToMarkdown(e,this.editor.pmSchema,this.editor,{})}tryParseMarkdownToBlocks(e){return Be(e,this.editor.pmSchema)}pasteHTML(e,t=!1){var r;let n=e;if(!t){const s=this.tryParseHTMLToBlocks(e);n=this.blocksToFullHTML(s)}n&&((r=this.editor.prosemirrorView)==null||r.pasteHTML(n))}pasteText(e){var t;return(t=this.editor.prosemirrorView)==null?void 0:t.pasteText(e)}pasteMarkdown(e){const t=q(e);return this.pasteHTML(t)}}const W=["vscode-editor-data","blocknote/html","text/markdown","text/html","text/plain","Files"];function St(o,e){if(!o.startsWith(".")||!e.startsWith("."))throw new Error("The strings provided are not valid file extensions.");return o===e}function Ct(o,e){const t=o.split("/"),n=e.split("/");if(t.length!==2)throw new Error(`The string ${o} is not a valid MIME type.`);if(n.length!==2)throw new Error(`The string ${e} is not a valid MIME type.`);return t[1]==="*"||n[1]==="*"?t[0]===n[0]:(t[0]==="*"||n[0]==="*"||t[0]===n[0])&&t[1]===n[1]}function X(o,e,t,n="after"){let r;return Array.isArray(e.content)&&e.content.length===0?r=o.updateBlock(e,t).id:r=o.insertBlocks([t],e,n)[0].id,r}async function Se(o,e){var s;if(!e.uploadFile){console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");return}const t="dataTransfer"in o?o.dataTransfer:o.clipboardData;if(t===null)return;let n=null;for(const i of W)if(t.types.includes(i)){n=i;break}if(n!=="Files")return;const r=t.items;if(r){o.preventDefault();for(let i=0;i<r.length;i++){let d="file";for(const l of Object.values(e.schema.blockSpecs))for(const p of((s=l.implementation.meta)==null?void 0:s.fileBlockAccept)||[]){const f=p.startsWith("."),h=r[i].getAsFile();if(h&&(!f&&h.type&&Ct(r[i].type,p)||f&&St("."+h.name.split(".").pop(),p))){d=l.config.type;break}}const c=r[i].getAsFile();if(c){const l={type:d,props:{name:c.name}};let p;if(o.type==="paste"){const g=e.getTextCursorPosition().block;p=X(e,g,l)}else if(o.type==="drop"){const g={left:o.clientX,top:o.clientY},k=e.prosemirrorView.posAtCoords(g);if(!k)return;p=e.transact(b=>{var x;const C=u.getNearestBlockPos(b.doc,k.pos),y=(x=e.domElement)==null?void 0:x.querySelector(`[data-id="${C.node.attrs.id}"]`),P=y==null?void 0:y.getBoundingClientRect();return X(e,e.getBlock(C.node.attrs.id),l,P&&(P.top+P.bottom)/2>g.top?"before":"after")})}else return;const f=await e.uploadFile(c,p),h=typeof f=="string"?{props:{url:f}}:{...f};e.updateBlock(p,h)}}}}const yt=o=>S.Extension.create({name:"dropFile",addProseMirrorPlugins(){return[new E.Plugin({props:{handleDOMEvents:{drop(e,t){if(!o.isEditable)return;let n=null;for(const r of W)if(t.dataTransfer.types.includes(r)){n=r;break}return n===null?!0:n==="Files"?(Se(t,o),!0):!1}}}})]}}),Et=/(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/,xt=/(_|__|\*|\*\*|~~|==|\+\+)(?!\s)(?:[^\s](?:.{0,62}[^\s])?|\S)(?=\1)/,Tt=/\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/,Pt=/(?:\s|^)`(?!\s)(?:[^\s`](?:[^`]{0,46}[^\s`])?|[^\s`])`([^\w]|$)/,It=/(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/,Mt=/(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/,wt=/\n{2} {0,3}-{2,48}\n{2}/,vt=/(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/,At=/(?:\n|^)(?!\s)\w[^\n]{0,64}\r?\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/,Nt=/(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/,Lt=/^\s*\|(.+\|)+\s*$/m,_t=/^\s*\|(\s*[-:]+[-:]\s*\|)+\s*$/m,Dt=/^\s*\|(.+\|)+\s*$/m,Ft=o=>Et.test(o)||xt.test(o)||Tt.test(o)||Pt.test(o)||It.test(o)||Mt.test(o)||wt.test(o)||vt.test(o)||At.test(o)||Nt.test(o)||Lt.test(o)||_t.test(o)||Dt.test(o);async function Ot(o,e){const{schema:t}=e.state;if(!o.clipboardData)return!1;const n=o.clipboardData.getData("text/plain");if(!n)return!1;if(!t.nodes.codeBlock)return e.pasteText(n),!0;const r=o.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s==null?void 0:s.mode;return i?(e.pasteHTML(`<pre><code class="language-${i}">${n.replace(/\r\n?/g,`
3
+ `)}</code></pre>`),!0):!1}function Ht({event:o,editor:e,prioritizeMarkdownOverHTML:t,plainTextAsMarkdown:n}){var d;if(e.transact(c=>c.selection.$from.parent.type.spec.code&&c.selection.$to.parent.type.spec.code)){const c=(d=o.clipboardData)==null?void 0:d.getData("text/plain");if(c)return e.pasteText(c),!0}let s;for(const c of W)if(o.clipboardData.types.includes(c)){s=c;break}if(!s)return!0;if(s==="vscode-editor-data")return Ot(o,e.prosemirrorView),!0;if(s==="Files")return Se(o,e),!0;const i=o.clipboardData.getData(s);if(s==="blocknote/html")return e.pasteHTML(i,!0),!0;if(s==="text/markdown")return e.pasteMarkdown(i),!0;if(t){const c=o.clipboardData.getData("text/plain");if(Ft(c))return e.pasteMarkdown(c),!0}return s==="text/html"?(e.pasteHTML(i),!0):n?(e.pasteMarkdown(i),!0):(e.pasteText(i),!0)}const $t=(o,e)=>S.Extension.create({name:"pasteFromClipboard",addProseMirrorPlugins(){return[new E.Plugin({props:{handleDOMEvents:{paste(t,n){if(n.preventDefault(),!!o.isEditable)return e({event:n,editor:o,defaultPasteHandler:({prioritizeMarkdownOverHTML:r=!0,plainTextAsMarkdown:s=!0}={})=>Ht({event:n,editor:o,prioritizeMarkdownOverHTML:r,plainTextAsMarkdown:s})})}}}})]}});function Vt(o,e,t){var d;let n=!1;const r=o.state.selection instanceof D.CellSelection;if(!r){const c=o.state.doc.slice(o.state.selection.from,o.state.selection.to,!1).content,l=[];for(let p=0;p<c.childCount;p++)l.push(c.child(p));n=l.find(p=>p.type.isInGroup("bnBlock")||p.type.name==="blockGroup"||p.type.spec.group==="blockContent")===void 0,n&&(e=c)}let s;const i=m.createExternalHTMLExporter(o.state.schema,t);if(r){((d=e.firstChild)==null?void 0:d.type.name)==="table"&&(e=e.firstChild.content);const c=u.contentNodeToTableContent(e,t.schema.inlineContentSchema,t.schema.styleSchema);s=`<table>${i.exportInlineContent(c,{})}</table>`}else if(n){const c=u.contentNodeToInlineContent(e,t.schema.inlineContentSchema,t.schema.styleSchema);s=i.exportInlineContent(c,{})}else{const c=m.fragmentToBlocks(e);s=i.exportBlocks(c,{})}return s}function j(o,e){"node"in o.state.selection&&o.state.selection.node.type.spec.group==="blockContent"&&e.transact(i=>i.setSelection(new E.NodeSelection(i.doc.resolve(o.state.selection.from-1))));const t=o.serializeForClipboard(o.state.selection.content()).dom.innerHTML,n=o.state.selection.content().content,r=Vt(o,n,e),s=m.cleanHTMLToMarkdown(r);return{clipboardHTML:t,externalHTML:r,markdown:s}}const Z=()=>{const o=window.getSelection();if(!o||o.isCollapsed)return!0;let e=o.focusNode;for(;e;){if(e instanceof HTMLElement&&e.getAttribute("contenteditable")==="false")return!0;e=e.parentElement}return!1},ee=(o,e,t)=>{t.preventDefault(),t.clipboardData.clearData();const{clipboardHTML:n,externalHTML:r,markdown:s}=j(e,o);t.clipboardData.setData("blocknote/html",n),t.clipboardData.setData("text/html",r),t.clipboardData.setData("text/plain",s)},Rt=o=>S.Extension.create({name:"copyToClipboard",addProseMirrorPlugins(){return[new E.Plugin({props:{handleDOMEvents:{copy(e,t){return Z()||ee(o,e,t),!0},cut(e,t){return Z()||(ee(o,e,t),e.editable&&e.dispatch(e.state.tr.deleteSelection())),!0},dragstart(e,t){if(!("node"in e.state.selection)||e.state.selection.node.type.spec.group!=="blockContent")return;o.transact(i=>i.setSelection(new E.NodeSelection(i.doc.resolve(e.state.selection.from-1)))),t.preventDefault(),t.dataTransfer.clearData();const{clipboardHTML:n,externalHTML:r,markdown:s}=j(e,o);return t.dataTransfer.setData("blocknote/html",n),t.dataTransfer.setData("text/html",r),t.dataTransfer.setData("text/plain",s),!0}}}})]}}),Ut=S.Extension.create({name:"blockBackgroundColor",addGlobalAttributes(){return[{types:["tableCell","tableHeader"],attributes:{backgroundColor:a.getBackgroundColorAttribute()}}]}}),Gt=S.Node.create({name:"hardBreak",inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,priority:10,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:o}){return["br",S.mergeAttributes(this.options.HTMLAttributes,o)]},renderText(){return`
4
+ `}}),Ce=(o,e)=>{var d;const t=o.resolve(e),n=t.depth-1,r=t.before(n),s=o.resolve(r).nodeAfter;return s?(d=s.type.spec.group)!=null&&d.includes("bnBlock")?u.getBlockInfoFromResolvedPos(o.resolve(r)):Ce(o,r):void 0},L=(o,e)=>{const t=o.resolve(e),n=t.index();if(n===0)return;const r=t.posAtIndex(n-1);return u.getBlockInfoFromResolvedPos(o.resolve(r))},N=(o,e)=>{const t=o.resolve(e),n=t.index();if(n===t.node().childCount-1)return;const r=t.posAtIndex(n+1);return u.getBlockInfoFromResolvedPos(o.resolve(r))},ye=(o,e)=>{for(;e.childContainer;){const t=e.childContainer.node,n=o.resolve(e.childContainer.beforePos+1).posAtIndex(t.childCount-1);e=u.getBlockInfoFromResolvedPos(o.resolve(n))}return e},zt=(o,e)=>o.isBlockContainer&&o.blockContent.node.type.spec.content==="inline*"&&o.blockContent.node.childCount>0&&e.isBlockContainer&&e.blockContent.node.type.spec.content==="inline*",qt=(o,e,t,n)=>{if(!n.isBlockContainer)throw new Error(`Attempted to merge block at position ${n.bnBlock.beforePos} into previous block at position ${t.bnBlock.beforePos}, but next block is not a block container`);if(n.childContainer){const r=o.doc.resolve(n.childContainer.beforePos+1),s=o.doc.resolve(n.childContainer.afterPos-1),i=r.blockRange(s);if(e){const d=o.doc.resolve(n.bnBlock.beforePos);o.tr.lift(i,d.depth)}}if(e){if(!t.isBlockContainer)throw new Error(`Attempted to merge block at position ${n.bnBlock.beforePos} into previous block at position ${t.bnBlock.beforePos}, but previous block is not a block container`);e(o.tr.delete(t.blockContent.afterPos-1,n.blockContent.beforePos+1))}return!0},te=o=>({state:e,dispatch:t})=>{const n=e.doc.resolve(o),r=u.getBlockInfoFromResolvedPos(n),s=L(e.doc,r.bnBlock.beforePos);if(!s)return!1;const i=ye(e.doc,s);return zt(i,r)?qt(e,t,i,r):!1},Wt=S.Extension.create({priority:50,addKeyboardShortcuts(){const o=()=>this.editor.commands.first(({chain:n,commands:r})=>[()=>r.deleteSelection(),()=>r.undoInputRule(),()=>r.command(({state:s})=>{const i=u.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;const d=s.selection.from===i.blockContent.beforePos+1,c=i.blockContent.node.type.name==="paragraph";return d&&!c?r.command(a.updateBlockCommand(i.bnBlock.beforePos,{type:"paragraph",props:{}})):!1}),()=>r.command(({state:s})=>{const i=u.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;const{blockContent:d}=i;return s.selection.from===d.beforePos+1?r.liftListItem("blockContainer"):!1}),()=>r.command(({state:s})=>{const i=u.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;const{bnBlock:d,blockContent:c}=i,l=L(s.doc,i.bnBlock.beforePos);if(!l||!l.isBlockContainer||l.blockContent.node.type.spec.content!=="inline*")return!1;const p=s.selection.from===c.beforePos+1,f=s.selection.empty,h=d.beforePos;return p&&f?n().command(te(h)).scrollIntoView().run():!1}),()=>r.command(({state:s,tr:i,dispatch:d})=>{const c=u.getBlockInfoFromSelection(s);if(!c.isBlockContainer)return!1;const l=L(s.doc,c.bnBlock.beforePos);if(!l||l.isBlockContainer)return!1;if(d){const p=l.bnBlock.afterPos-1,f=i.doc.resolve(p-1);return i.delete(c.bnBlock.beforePos,c.bnBlock.afterPos),i.insert(f.pos,c.bnBlock.node),i.setSelection(E.TextSelection.near(i.doc.resolve(f.pos+1))),!0}return!1}),()=>r.command(({state:s,tr:i,dispatch:d})=>{const c=u.getBlockInfoFromSelection(s);if(!c.isBlockContainer||!(i.selection.from===c.blockContent.beforePos+1))return!1;const p=i.doc.resolve(c.bnBlock.beforePos);if(p.nodeBefore||p.node().type.name!=="column")return!1;const g=i.doc.resolve(c.bnBlock.beforePos),k=i.doc.resolve(g.before()),b=k.before();return d&&(i.delete(c.bnBlock.beforePos,c.bnBlock.afterPos),_(i,b),k.pos===b+1?(i.insert(b,c.bnBlock.node),i.setSelection(E.TextSelection.near(i.doc.resolve(b)))):(i.insert(k.pos-1,c.bnBlock.node),i.setSelection(E.TextSelection.near(i.doc.resolve(k.pos))))),!0}),()=>r.command(({state:s})=>{var c;const i=u.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;if(i.blockContent.node.childCount===0&&i.blockContent.node.type.spec.content==="inline*"){const l=L(s.doc,i.bnBlock.beforePos);if(!l||!l.isBlockContainer)return!1;let p=n();if(i.childContainer&&p.insertContentAt(i.bnBlock.afterPos,(c=i.childContainer)==null?void 0:c.node.content),l.blockContent.node.type.spec.content==="tableRow+"){const b=i.bnBlock.beforePos-1-1-1-1-1;p=p.setTextSelection(b)}else if(l.blockContent.node.type.spec.content==="")p=p.setNodeSelection(l.blockContent.beforePos);else{const f=l.blockContent.afterPos-1;p=p.setTextSelection(f)}return p.deleteRange({from:i.bnBlock.beforePos,to:i.bnBlock.afterPos}).scrollIntoView().run()}return!1}),()=>r.command(({state:s})=>{const i=u.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;const d=s.selection.from===i.blockContent.beforePos+1,c=s.selection.empty,l=L(s.doc,i.bnBlock.beforePos);if(l&&d&&c){const p=ye(s.doc,l);if(!p.isBlockContainer)return!1;if(p.blockContent.node.type.spec.content===""||p.blockContent.node.type.spec.content==="inline*"&&p.blockContent.node.childCount===0)return n().cut({from:i.bnBlock.beforePos,to:i.bnBlock.afterPos},p.bnBlock.afterPos).deleteRange({from:p.bnBlock.beforePos,to:p.bnBlock.afterPos}).run()}return!1})]),e=()=>this.editor.commands.first(({chain:n,commands:r})=>[()=>r.deleteSelection(),()=>r.command(({state:s})=>{var h;const i=u.getBlockInfoFromSelection(s);if(!i.isBlockContainer||!i.childContainer)return!1;const{blockContent:d,childContainer:c}=i,l=s.selection.from===d.afterPos-1,p=s.selection.empty,f=u.getBlockInfoFromResolvedPos(s.doc.resolve(c.beforePos+1));if(!f.isBlockContainer)return!1;if(l&&p){const g=f.blockContent.node,k=g.type.spec.content==="inline*",b=d.node.type.spec.content==="inline*";return n().insertContentAt(f.bnBlock.afterPos,((h=f.childContainer)==null?void 0:h.node.content)||T.Fragment.empty).deleteRange(c.node.childCount===1?{from:c.beforePos,to:c.afterPos}:{from:f.bnBlock.beforePos,to:f.bnBlock.afterPos}).insertContentAt(s.selection.from,k&&b?g.content:null).setTextSelection(s.selection.from).scrollIntoView().run()}return!1}),()=>r.command(({state:s})=>{const i=u.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;const{bnBlock:d,blockContent:c}=i,l=N(s.doc,i.bnBlock.beforePos);if(!l||!l.isBlockContainer)return!1;const p=s.selection.from===c.afterPos-1,f=s.selection.empty,h=d.afterPos;return p&&f?n().command(te(h)).scrollIntoView().run():!1}),()=>r.command(({state:s,tr:i,dispatch:d})=>{const c=u.getBlockInfoFromSelection(s);if(!c.isBlockContainer)return!1;const l=N(s.doc,c.bnBlock.beforePos);if(!l||l.isBlockContainer)return!1;if(d){const p=l.bnBlock.beforePos+1,f=i.doc.resolve(p+1);return i.delete(f.pos,f.pos+f.nodeAfter.nodeSize),_(i,l.bnBlock.beforePos),i.insert(c.bnBlock.afterPos,f.nodeAfter),i.setSelection(E.TextSelection.near(i.doc.resolve(f.pos))),!0}return!1}),()=>r.command(({state:s,tr:i,dispatch:d})=>{const c=u.getBlockInfoFromSelection(s);if(!c.isBlockContainer||!(i.selection.from===c.blockContent.afterPos-1))return!1;const p=i.doc.resolve(c.bnBlock.afterPos);if(p.nodeAfter||p.node().type.name!=="column")return!1;const g=i.doc.resolve(c.bnBlock.afterPos),k=i.doc.resolve(g.after()),b=k.after();if(d){const C=k.pos===b-1?b:k.pos+1,y=u.getBlockInfoFromResolvedPos(i.doc.resolve(C));i.delete(y.bnBlock.beforePos,y.bnBlock.afterPos),_(i,b-k.node().nodeSize),i.insert(g.pos,y.bnBlock.node),i.setSelection(E.TextSelection.near(i.doc.resolve(C)))}return!0}),()=>r.command(({state:s})=>{var p;const i=u.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;const{blockContent:d}=i,c=s.selection.from===d.afterPos-1,l=s.selection.empty;if(c&&l){const f=(C,y)=>{const P=N(C,y);if(P)return P;const x=Ce(C,y);if(x)return f(C,x.bnBlock.beforePos)},h=f(s.doc,i.bnBlock.beforePos);if(!h||!h.isBlockContainer)return!1;const g=h.blockContent.node,k=g.type.spec.content==="inline*",b=d.node.type.spec.content==="inline*";return n().insertContentAt(h.bnBlock.afterPos,((p=h.childContainer)==null?void 0:p.node.content)||T.Fragment.empty).deleteRange({from:h.bnBlock.beforePos,to:h.bnBlock.afterPos}).insertContentAt(s.selection.from,k&&b?g.content:null).setTextSelection(s.selection.from).scrollIntoView().run()}return!1}),()=>r.command(({state:s})=>{const i=u.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;if(i.blockContent.node.childCount===0&&i.blockContent.node.type.spec.content==="inline*"){const c=N(s.doc,i.bnBlock.beforePos);if(!c||!c.isBlockContainer)return!1;let l=n();if(c.blockContent.node.type.spec.content==="tableRow+"){const k=i.bnBlock.afterPos+1+1+1+1+1;l=l.setTextSelection(k)}else c.blockContent.node.type.spec.content===""?l=l.setNodeSelection(c.blockContent.beforePos):l=l.setTextSelection(c.blockContent.beforePos+1);return l.deleteRange({from:i.bnBlock.beforePos,to:i.bnBlock.afterPos}).scrollIntoView().run()}return!1}),()=>r.command(({state:s})=>{const i=u.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;const d=s.selection.from===i.blockContent.afterPos-1,c=s.selection.empty,l=N(s.doc,i.bnBlock.beforePos);if(!l||!l.isBlockContainer)return!1;if(l&&d&&c&&(l.blockContent.node.type.spec.content===""||l.blockContent.node.type.spec.content==="inline*"&&l.blockContent.node.childCount===0)){const f=l.bnBlock.node.lastChild.content;return n().deleteRange({from:l.bnBlock.beforePos,to:l.bnBlock.afterPos}).insertContentAt(i.bnBlock.afterPos,l.bnBlock.node.childCount===2?f:null).run()}return!1})]),t=(n=!1)=>this.editor.commands.first(({commands:r,tr:s})=>[()=>r.command(({state:i})=>{const d=u.getBlockInfoFromSelection(i);if(!d.isBlockContainer)return!1;const{bnBlock:c,blockContent:l}=d,{depth:p}=i.doc.resolve(c.beforePos),f=i.selection.$anchor.parentOffset===0,h=i.selection.anchor===i.selection.head,g=l.node.childCount===0,k=p>1;return f&&h&&g&&k?r.liftListItem("blockContainer"):!1}),()=>r.command(({state:i})=>{var l;const d=u.getBlockInfoFromSelection(i),c=((l=this.options.editor.schema.blockSchema[d.blockNoteType].meta)==null?void 0:l.hardBreakShortcut)??"shift+enter";if(c==="none")return!1;if(c==="shift+enter"&&n||c==="enter"){const p=s.storedMarks||s.selection.$head.marks().filter(f=>this.editor.extensionManager.splittableMarks.includes(f.type.name));return s.insert(s.selection.head,s.doc.type.schema.nodes.hardBreak.create()).ensureMarks(p),!0}return!1}),()=>r.command(({state:i,dispatch:d,tr:c})=>{var b;const l=u.getBlockInfoFromSelection(i);if(!l.isBlockContainer)return!1;const{bnBlock:p,blockContent:f}=l,h=i.selection.$anchor.parentOffset===0,g=i.selection.anchor===i.selection.head,k=f.node.childCount===0;if(h&&g&&k){const C=p.afterPos,y=C+2;if(d){const P=i.schema.nodes.blockContainer.createAndFill(void 0,[i.schema.nodes.paragraph.createAndFill()||void 0,(b=l.childContainer)==null?void 0:b.node].filter(x=>x!==void 0));c.insert(C,P).setSelection(new E.TextSelection(c.doc.resolve(y))).scrollIntoView(),l.childContainer&&c.delete(l.childContainer.beforePos,l.childContainer.afterPos)}return!0}return!1}),()=>r.command(({state:i,chain:d})=>{const c=u.getBlockInfoFromSelection(i);if(!c.isBlockContainer)return!1;const{blockContent:l}=c,p=i.selection.$anchor.parentOffset===0;return l.node.childCount===0?!1:(d().deleteSelection().command(a.splitBlockCommand(i.selection.from,p,p)).run(),!0)})]);return{Backspace:o,Delete:e,Enter:()=>t(),"Shift-Enter":()=>t(!0),Tab:()=>{var n,r;return this.options.tabBehavior!=="prefer-indent"&&((n=this.options.editor.getExtension(m.FormattingToolbarExtension))!=null&&n.store.state||((r=this.options.editor.getExtension(a.FilePanelExtension))==null?void 0:r.store.state)!==void 0)?!1:he(this.options.editor)},"Shift-Tab":()=>{var n,r;return this.options.tabBehavior!=="prefer-indent"&&((n=this.options.editor.getExtension(m.FormattingToolbarExtension))!=null&&n.store.state||((r=this.options.editor.getExtension(a.FilePanelExtension))==null?void 0:r.store.state)!==void 0)?!1:this.editor.commands.liftListItem("blockContainer")},"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()}}}),jt=S.Mark.create({name:"insertion",inclusive:!1,excludes:"deletion modification insertion",addAttributes(){return{id:{default:null,validate:"number"}}},extendMarkSchema(o){return o.name!=="insertion"?{}:{blocknoteIgnore:!0,inclusive:!1,toDOM(e,t){return["ins",{"data-id":String(e.attrs.id),"data-inline":String(t),...!t&&{style:"display: contents"}},0]},parseDOM:[{tag:"ins",getAttrs(e){return e.dataset.id?{id:parseInt(e.dataset.id,10)}:!1}}]}}}),Kt=S.Mark.create({name:"deletion",inclusive:!1,excludes:"insertion modification deletion",addAttributes(){return{id:{default:null,validate:"number"}}},extendMarkSchema(o){return o.name!=="deletion"?{}:{blocknoteIgnore:!0,inclusive:!1,toDOM(e,t){return["del",{"data-id":String(e.attrs.id),"data-inline":String(t),...!t&&{style:"display: contents"}},0]},parseDOM:[{tag:"del",getAttrs(e){return e.dataset.id?{id:parseInt(e.dataset.id,10)}:!1}}]}}}),Yt=S.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(o){return o.name!=="modification"?{}:{blocknoteIgnore:!0,inclusive:!1,toDOM(e,t){return[t?"span":"div",{"data-type":"modification","data-id":String(e.attrs.id),"data-mod-type":e.attrs.type,"data-mod-prev-val":JSON.stringify(e.attrs.previousValue),"data-mod-new-val":JSON.stringify(e.attrs.newValue)},0]},parseDOM:[{tag:"span[data-type='modification']",getAttrs(e){return e.dataset.id?{id:parseInt(e.dataset.id,10),type:e.dataset.modType,previousValue:e.dataset.modPrevVal,newValue:e.dataset.modNewVal}:!1}},{tag:"div[data-type='modification']",getAttrs(e){return e.dataset.id?{id:parseInt(e.dataset.id,10),type:e.dataset.modType,previousValue:e.dataset.modPrevVal}:!1}}]}}}),Jt=S.Extension.create({name:"textAlignment",addGlobalAttributes(){return[{types:["tableCell","tableHeader"],attributes:{textAlignment:{default:"left",parseHTML:o=>o.getAttribute("data-text-alignment"),renderHTML:o=>o.textAlignment==="left"?{}:{"data-text-alignment":o.textAlignment}}}}]}}),Qt=S.Extension.create({name:"blockTextColor",addGlobalAttributes(){return[{types:["table","tableCell","tableHeader"],attributes:{textColor:a.getTextColorAttribute()}}]}}),Xt={blockColor:"data-block-color",blockStyle:"data-block-style",id:"data-id",depth:"data-depth",depthChange:"data-depth-change"},Zt=S.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:o=>{if(typeof o=="string")return!1;const e={};for(const[t,n]of Object.entries(Xt))o.getAttribute(n)&&(e[t]=o.getAttribute(n));return e}},{tag:'div[data-node-type="blockOuter"]',skip:!0}]},renderHTML({HTMLAttributes:o}){var r;const e=document.createElement("div");e.className="bn-block-outer",e.setAttribute("data-node-type","blockOuter");for(const[s,i]of Object.entries(o))s!=="class"&&e.setAttribute(s,i);const t={...((r=this.options.domAttributes)==null?void 0:r.block)||{},...o},n=document.createElement("div");n.className=a.mergeCSSClasses("bn-block",t.class),n.setAttribute("data-node-type",this.name);for(const[s,i]of Object.entries(t))s!=="class"&&n.setAttribute(s,i);return e.appendChild(n),{dom:e,contentDOM:n}}}),eo=S.Node.create({name:"blockGroup",group:"childContainer",content:"blockGroupChild+",marks:"deletion insertion modification",parseHTML(){return[{tag:"div",getAttrs:o=>typeof o=="string"?!1:o.getAttribute("data-node-type")==="blockGroup"?null:!1}]},renderHTML({HTMLAttributes:o}){var n;const e={...((n=this.options.domAttributes)==null?void 0:n.blockGroup)||{},...o},t=document.createElement("div");t.className=a.mergeCSSClasses("bn-block-group",e.class),t.setAttribute("data-node-type","blockGroup");for(const[r,s]of Object.entries(e))r!=="class"&&t.setAttribute(r,s);return{dom:t,contentDOM:t}}}),to=S.Node.create({name:"doc",topNode:!0,content:"blockGroup",marks:"insertion modification deletion"}),oo=H.createExtension(({options:o})=>({key:"collaboration",blockNoteExtensions:[m.ForkYDocExtension(o),m.YCursorExtension(o),m.YSyncExtension(o),m.YUndoExtension(),m.SchemaMigration(o)]}));let oe=!1;function no(o,e){const t=[S.extensions.ClipboardTextSerializer,S.extensions.Commands,S.extensions.Editable,S.extensions.FocusEvents,S.extensions.Tabindex,Ae.Gapcursor,u.UniqueID.configure({types:["blockContainer","columnList","column"],setIdAttribute:e.setIdAttribute}),Gt,Le.Text,jt,Kt,Yt,Ne.Link.extend({inclusive:!1}).configure({defaultProtocol:m.DEFAULT_LINK_PROTOCOL,protocols:oe?[]:m.VALID_LINK_PROTOCOLS}),...Object.values(o.schema.styleSpecs).map(n=>n.implementation.mark.configure({editor:o})),Qt,Ut,Jt,S.Extension.create({name:"OverrideEscape",addKeyboardShortcuts:()=>({Escape:()=>{var n;return(n=o.getExtension(a.SuggestionMenu))!=null&&n.shown()?!1:(o.blur(),!0)}})}),to,Zt.configure({editor:o,domAttributes:e.domAttributes}),Wt.configure({editor:o,tabBehavior:e.tabBehavior}),eo.configure({domAttributes:e.domAttributes}),...Object.values(o.schema.inlineContentSpecs).filter(n=>n.config!=="link"&&n.config!=="text").map(n=>n.implementation.node.configure({editor:o})),...Object.values(o.schema.blockSpecs).flatMap(n=>[..."node"in n.implementation?[n.implementation.node.configure({editor:o,domAttributes:e.domAttributes})]:[]]),Rt(o),$t(o,e.pasteHandler||(n=>n.defaultPasteHandler())),yt(o)];return oe=!0,t}function ro(o,e){const t=[m.BlockChangeExtension(),m.DropCursorExtension(e),a.FilePanelExtension(e),m.FormattingToolbarExtension(e),m.LinkToolbarExtension(e),m.NodeSelectionKeyboardExtension(),m.PlaceholderExtension(e),ne.ShowSelectionExtension(e),m.SideMenuExtension(e),a.SuggestionMenu(e),...e.trailingBlock!==!1?[m.TrailingNodeExtension()]:[]];return e.collaboration?t.push(oo(e.collaboration)):t.push(m.HistoryExtension()),"table"in o.schema.blockSpecs&&t.push(m.TableHandlesExtension(e)),e.animations!==!1&&t.push(m.PreviousBlockTypeExtension()),t}class so{constructor(e,t){B(this,"disabledExtensions",new Set);B(this,"extensions",[]);B(this,"abortMap",new Map);B(this,"extensionFactories",new Map);B(this,"extensionPlugins",new Map);this.editor=e,this.options=t,e.onMount(()=>{for(const n of this.extensions)if(n.mount){const r=new window.AbortController,s=n.mount({dom:e.prosemirrorView.dom,root:e.prosemirrorView.root,signal:r.signal});s&&r.signal.addEventListener("abort",()=>{s()}),this.abortMap.set(n,r)}}),e.onUnmount(()=>{for(const[n,r]of this.abortMap.entries())this.abortMap.delete(n),r.abort()}),this.disabledExtensions=new Set(t.disableExtensions||[]);for(const n of ro(this.editor,this.options))this.addExtension(n);for(const n of this.options.extensions??[])this.addExtension(n);for(const n of Object.values(this.editor.schema.blockSpecs))for(const r of n.extensions??[])this.addExtension(r)}registerExtension(e){var s;const t=[].concat(e).filter(Boolean);if(!t.length){console.warn("No extensions found to register",e);return}const n=t.map(i=>this.addExtension(i)).filter(Boolean),r=new Set;for(const i of n)i!=null&&i.tiptapExtensions&&console.warn(`Extension ${i.key} has tiptap extensions, but these cannot be changed after initializing the editor. Please separate the extension into multiple extensions if you want to add them, or re-initialize the editor.`,i),(s=i==null?void 0:i.inputRules)!=null&&s.length&&console.warn(`Extension ${i.key} has input rules, but these cannot be changed after initializing the editor. Please separate the extension into multiple extensions if you want to add them, or re-initialize the editor.`,i),this.getProsemirrorPluginsFromExtension(i).plugins.forEach(d=>{r.add(d)});this.updatePlugins(i=>[...i,...r])}addExtension(e){let t;if(typeof e=="function"?t=e({editor:this.editor}):t=e,!(!t||this.disabledExtensions.has(t.key))){if(typeof e=="function"){const n=t[H.originalFactorySymbol];typeof n=="function"&&this.extensionFactories.set(n,t)}if(this.extensions.push(t),t.blockNoteExtensions)for(const n of t.blockNoteExtensions)this.addExtension(n);return t}}resolveExtensions(e){const t=[];if(typeof e=="function"){const n=this.extensionFactories.get(e);n&&t.push(n)}else if(Array.isArray(e))for(const n of e)t.push(...this.resolveExtensions(n));else if(typeof e=="object"&&"key"in e)t.push(e);else if(typeof e=="string"){const n=this.extensions.find(r=>r.key===e);n&&t.push(n)}return t}unregisterExtension(e){var s;const t=this.resolveExtensions(e);if(!t.length){console.warn("No extensions found to unregister",e);return}let n=!1;const r=new Set;for(const i of t){this.extensions=this.extensions.filter(c=>c!==i),this.extensionFactories.forEach((c,l)=>{c===i&&this.extensionFactories.delete(l)}),(s=this.abortMap.get(i))==null||s.abort(),this.abortMap.delete(i);const d=this.extensionPlugins.get(i);d==null||d.forEach(c=>{r.add(c)}),this.extensionPlugins.delete(i),i.tiptapExtensions&&!n&&(n=!0,console.warn(`Extension ${i.key} has tiptap extensions, but they will not be removed. Please separate the extension into multiple extensions if you want to remove them, or re-initialize the editor.`,e))}this.updatePlugins(i=>i.filter(d=>!r.has(d)))}updatePlugins(e){const t=this.editor.prosemirrorState,n=t.reconfigure({plugins:e(t.plugins.slice())});this.editor.prosemirrorView.updateState(n)}getTiptapExtensions(){var r;const e=no(this.editor,this.options).filter(s=>!this.disabledExtensions.has(s.name)),t=I.sortByDependencies(this.extensions),n=new Map;for(const s of this.extensions){s.tiptapExtensions&&e.push(...s.tiptapExtensions);const i=t(s.key),{plugins:d,inputRules:c}=this.getProsemirrorPluginsFromExtension(s);d.length&&e.push(S.Extension.create({name:s.key,priority:i,addProseMirrorPlugins:()=>d})),c.length&&(n.has(i)||n.set(i,[]),n.get(i).push(...c))}e.push(S.Extension.create({name:"blocknote-input-rules",addProseMirrorPlugins(){const s=[];return Array.from(n.keys()).sort().reverse().forEach(i=>{s.push(...n.get(i))}),[Y.inputRules({rules:s})]}}));for(const s of((r=this.options._tiptapOptions)==null?void 0:r.extensions)??[])e.push(s);return e}getProsemirrorPluginsFromExtension(e){var r,s,i;const t=[...e.prosemirrorPlugins??[]],n=[];return!((r=e.prosemirrorPlugins)!=null&&r.length)&&!Object.keys(e.keyboardShortcuts||{}).length&&!((s=e.inputRules)!=null&&s.length)?{plugins:t,inputRules:n}:(this.extensionPlugins.set(e,t),(i=e.inputRules)!=null&&i.length&&n.push(...e.inputRules.map(d=>new Y.InputRule(d.find,(c,l,p,f)=>{const h=d.replace({match:l,range:{from:p,to:f},editor:this.editor});if(h){const g=this.editor.getTextCursorPosition();if(this.editor.schema.blockSchema[g.block.type].content!=="inline")return null;const k=u.getBlockInfoFromTransaction(c.tr),b=c.tr.deleteRange(p,f);return a.updateBlockTr(b,k.bnBlock.beforePos,h),b}return null}))),Object.keys(e.keyboardShortcuts||{}).length&&t.push(ve.keymap(Object.fromEntries(Object.entries(e.keyboardShortcuts).map(([d,c])=>[d,()=>c({editor:this.editor})])))),{plugins:t,inputRules:n})}getExtensions(){return new Map(this.extensions.map(e=>[e.key,e]))}getExtension(e){if(typeof e=="string"){const t=this.extensions.find(n=>n.key===e);return t||void 0}else if(typeof e=="function"){const t=this.extensionFactories.get(e);return t||void 0}throw new Error(`Invalid extension type: ${typeof e}`)}hasExtension(e){return typeof e=="string"?this.extensions.some(t=>t.key===e):typeof e=="object"&&"key"in e?this.extensions.some(t=>t.key===e.key):typeof e=="function"?this.extensionFactories.has(e):!1}}function Ee(o,e){let{$from:t,$to:n}=e;if(t.pos>t.start()&&t.pos<o.content.size){const r=o.textBetween(t.pos,t.pos+1);if(/^[\w\p{P}]$/u.test(r)){const i=o.textBetween(t.start(),t.pos).match(/[\w\p{P}]+$/u);i&&(t=o.resolve(t.pos-i[0].length))}}if(n.pos<n.end()&&n.pos>0){const r=o.textBetween(n.pos-1,n.pos);if(/^[\w\p{P}]$/u.test(r)){const i=o.textBetween(n.pos,n.end()).match(/^[\w\p{P}]+/u);i&&(n=o.resolve(n.pos+i[0].length))}}return{$from:t,$to:n,from:t.pos,to:n.pos}}function io(o){const e=u.getPmSchema(o);if(o.selection.empty||"node"in o.selection)return;const t=o.doc.resolve(u.getNearestBlockPos(o.doc,o.selection.from).posBeforeNode),n=o.doc.resolve(u.getNearestBlockPos(o.doc,o.selection.to).posBeforeNode),r=(l,p)=>{const f=t.posAtIndex(l,p),h=o.doc.resolve(f).nodeAfter;if(!h)throw new Error(`Error getting selection - node not found at position ${f}`);return u.nodeToBlock(h,e)},s=[],i=t.sharedDepth(n.pos),d=t.index(i),c=n.index(i);if(t.depth>i){s.push(u.nodeToBlock(t.nodeAfter,e));for(let l=t.depth;l>i;l--)if(t.node(l).type.isInGroup("childContainer")){const f=t.index(l)+1,h=t.node(l).childCount;for(let g=f;g<h;g++)s.push(r(g,l))}}else s.push(r(d,i));for(let l=d+1;l<=c;l++)s.push(r(l,i));if(s.length===0)throw new Error(`Error getting selection - selection doesn't span any blocks (${o.selection})`);return{blocks:s}}function co(o,e,t){const n=typeof e=="string"?e:e.id,r=typeof t=="string"?t:t.id,s=u.getPmSchema(o),i=u.getBlockNoteSchema(s);if(n===r)throw new Error(`Attempting to set selection with the same anchor and head blocks (id ${n})`);const d=a.getNodeById(n,o.doc);if(!d)throw new Error(`Block with ID ${n} not found`);const c=a.getNodeById(r,o.doc);if(!c)throw new Error(`Block with ID ${r} not found`);const l=u.getBlockInfo(d),p=u.getBlockInfo(c),f=i.blockSchema[l.blockNoteType],h=i.blockSchema[p.blockNoteType];if(!l.isBlockContainer||f.content==="none")throw new Error(`Attempting to set selection anchor in block without content (id ${n})`);if(!p.isBlockContainer||h.content==="none")throw new Error(`Attempting to set selection anchor in block without content (id ${r})`);let g,k;if(f.content==="table"){const b=D.TableMap.get(l.blockContent.node);g=l.blockContent.beforePos+b.positionAt(0,0,l.blockContent.node)+1+2}else g=l.blockContent.beforePos+1;if(h.content==="table"){const b=D.TableMap.get(p.blockContent.node),C=p.blockContent.beforePos+b.positionAt(b.height-1,b.width-1,p.blockContent.node)+1,y=o.doc.resolve(C).nodeAfter.nodeSize;k=C+y-2}else k=p.blockContent.afterPos-1;o.setSelection(E.TextSelection.create(o.doc,g,k))}function lo(o,e=!1){const t=u.getPmSchema(o),n=e?Ee(o.doc,o.selection):o.selection;let r=n.$from,s=n.$to;for(;s.parentOffset>=s.parent.nodeSize-2&&s.depth>0;)s=o.doc.resolve(s.pos+1);for(;s.parentOffset===0&&s.depth>0;)s=o.doc.resolve(s.pos-1);for(;r.parentOffset===0&&r.depth>0;)r=o.doc.resolve(r.pos-1);for(;r.parentOffset>=r.parent.nodeSize-2&&r.depth>0;)r=o.doc.resolve(r.pos+1);const i=u.prosemirrorSliceToSlicedBlocks(o.doc.slice(r.pos,s.pos,!0),t);return{_meta:{startPos:r.pos,endPos:s.pos},...i}}function ao(o){const{bnBlock:e}=u.getBlockInfoFromTransaction(o),t=u.getPmSchema(o.doc),n=o.doc.resolve(e.beforePos),r=n.nodeBefore,s=o.doc.resolve(e.afterPos).nodeAfter;let i;return n.depth>1&&(i=n.node(),i.type.isInGroup("bnBlock")||(i=n.node(n.depth-1))),{block:u.nodeToBlock(e.node,t),prevBlock:r===null?void 0:u.nodeToBlock(r,t),nextBlock:s===null?void 0:u.nodeToBlock(s,t),parentBlock:i===void 0?void 0:u.nodeToBlock(i,t)}}function xe(o,e,t="start"){const n=typeof e=="string"?e:e.id,r=u.getPmSchema(o.doc),s=u.getBlockNoteSchema(r),i=a.getNodeById(n,o.doc);if(!i)throw new Error(`Block with ID ${n} not found`);const d=u.getBlockInfo(i),c=s.blockSchema[d.blockNoteType].content;if(d.isBlockContainer){const l=d.blockContent;if(c==="none"){o.setSelection(E.NodeSelection.create(o.doc,l.beforePos));return}if(c==="inline")t==="start"?o.setSelection(E.TextSelection.create(o.doc,l.beforePos+1)):o.setSelection(E.TextSelection.create(o.doc,l.afterPos-1));else if(c==="table")t==="start"?o.setSelection(E.TextSelection.create(o.doc,l.beforePos+4)):o.setSelection(E.TextSelection.create(o.doc,l.afterPos-4));else throw new u.UnreachableCaseError(c)}else{const l=t==="start"?d.childContainer.node.firstChild:d.childContainer.node.lastChild;xe(o,l.attrs.id,t)}}class uo{constructor(e){this.editor=e}getSelection(){return this.editor.transact(e=>io(e))}getSelectionCutBlocks(e=!1){return this.editor.transact(t=>lo(t,e))}setSelection(e,t){return this.editor.transact(n=>co(n,e,t))}getTextCursorPosition(){return this.editor.transact(e=>ao(e))}setTextCursorPosition(e,t="start"){return this.editor.transact(n=>xe(n,e,t))}getSelectionBoundingBox(){if(!this.editor.prosemirrorView)return;const{selection:e}=this.editor.prosemirrorState,{ranges:t}=e,n=Math.min(...t.map(s=>s.$from.pos)),r=Math.max(...t.map(s=>s.$to.pos));if(S.isNodeSelection(e)){const s=this.editor.prosemirrorView.nodeDOM(n);if(s)return s.getBoundingClientRect()}return S.posToDOMRect(this.editor.prosemirrorView,n,r).toJSON()}}class po{constructor(e){B(this,"activeTransaction",null);B(this,"isInCan",!1);this.editor=e}can(e){try{return this.isInCan=!0,e()}finally{this.isInCan=!1}}exec(e){if(this.activeTransaction)throw new Error("`exec` should not be called within a `transact` call, move the `exec` call outside of the `transact` call");if(this.isInCan)return this.canExec(e);const t=this.prosemirrorState,n=this.prosemirrorView;return e(t,s=>this.prosemirrorView.dispatch(s),n)}canExec(e){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 t=this.prosemirrorState,n=this.prosemirrorView;return e(t,void 0,n)}transact(e){if(this.activeTransaction)return e(this.activeTransaction);try{this.activeTransaction=this.editor._tiptapEditor.state.tr;const t=e(this.activeTransaction),n=this.activeTransaction;return this.activeTransaction=null,n&&(n.docChanged||n.selectionSet||n.scrolledIntoView||n.storedMarksSet||!n.isGeneric)&&this.prosemirrorView.dispatch(n),t}finally{this.activeTransaction=null}}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.editor._tiptapEditor.state}get prosemirrorView(){return this.editor._tiptapEditor.view}isFocused(){var e;return((e=this.prosemirrorView)==null?void 0:e.hasFocus())||!1}focus(){var e;(e=this.prosemirrorView)==null||e.focus()}get isEditable(){if(!this.editor._tiptapEditor){if(!this.editor.headless)throw new Error("no editor, but also not headless?");return!1}return this.editor._tiptapEditor.isEditable===void 0?!0:this.editor._tiptapEditor.isEditable}set isEditable(e){if(!this.editor._tiptapEditor){if(!this.editor.headless)throw new Error("no editor, but also not headless?");return}this.editor._tiptapEditor.options.editable!==e&&this.editor._tiptapEditor.setEditable(e)}undo(){const e=this.editor.getExtension("yUndo");if(e)return this.exec(e.undoCommand);const t=this.editor.getExtension("history");if(t)return this.exec(t.undoCommand);throw new Error("No undo plugin found")}redo(){const e=this.editor.getExtension("yUndo");if(e)return this.exec(e.redoCommand);const t=this.editor.getExtension("history");if(t)return this.exec(t.redoCommand);throw new Error("No redo plugin found")}}function fo(o,e,t,n={updateSelection:!0}){let{from:r,to:s}=typeof e=="number"?{from:e,to:e}:{from:e.from,to:e.to},i=!0,d=!0,c="";if(t.forEach(l=>{l.check(),i&&l.isText&&l.marks.length===0?c+=l.text:i=!1,d=d?l.isBlock:!1}),r===s&&d){const{parent:l}=o.doc.resolve(r);l.isTextblock&&!l.type.spec.code&&!l.childCount&&(r-=1,s+=1)}return i?o.insertText(c,r,s):o.replaceWith(r,s,t),n.updateSelection&&S.selectionToInsertionEnd(o,o.steps.length-1,-1),!0}class ho{constructor(e){this.editor=e}insertInlineContent(e,{updateSelection:t=!1}={}){const n=u.inlineContentToNodes(e,this.editor.pmSchema);this.editor.transact(r=>{fo(r,{from:r.selection.from,to:r.selection.to},n,{updateSelection:t})})}getActiveStyles(){return this.editor.transact(e=>{const t={},n=e.selection.$to.marks();for(const r of n){const s=this.editor.schema.styleSchema[r.type.name];if(!s){r.type.name!=="link"&&!r.type.spec.blocknoteIgnore&&console.warn("mark not found in styleschema",r.type.name);continue}s.propSchema==="boolean"?t[s.type]=!0:t[s.type]=r.attrs.stringValue}return t})}addStyles(e){for(const[t,n]of Object.entries(e)){const r=this.editor.schema.styleSchema[t];if(!r)throw new Error(`style ${t} not found in styleSchema`);if(r.propSchema==="boolean")this.editor._tiptapEditor.commands.setMark(t);else if(r.propSchema==="string")this.editor._tiptapEditor.commands.setMark(t,{stringValue:n});else throw new u.UnreachableCaseError(r.propSchema)}}removeStyles(e){for(const t of Object.keys(e))this.editor._tiptapEditor.commands.unsetMark(t)}toggleStyles(e){for(const[t,n]of Object.entries(e)){const r=this.editor.schema.styleSchema[t];if(!r)throw new Error(`style ${t} not found in styleSchema`);if(r.propSchema==="boolean")this.editor._tiptapEditor.commands.toggleMark(t);else if(r.propSchema==="string")this.editor._tiptapEditor.commands.toggleMark(t,{stringValue:n});else throw new u.UnreachableCaseError(r.propSchema)}}getSelectedText(){return this.editor.transact(e=>e.doc.textBetween(e.selection.from,e.selection.to))}getSelectedLinkUrl(){return this.editor._tiptapEditor.getAttributes("link").href}createLink(e,t){if(e==="")return;const n=this.editor.pmSchema.mark("link",{href:e});this.editor.transact(r=>{const{from:s,to:i}=r.selection;t?r.insertText(t,s,i).addMark(s,s+t.length,n):r.setSelection(He.TextSelection.create(r.doc,i)).addMark(s,i,n)})}}function mo(o){return S.findParentNodeClosestToPos(o.state.selection.$from,e=>e.type.name==="tableCell"||e.type.name==="tableHeader")!==void 0}function Te(o,e){var r;const t=e.nodes.hardBreak;let n=w.Fragment.empty;return o.forEach(s=>{s.isTextblock&&s.childCount>0?(n=n.append(s.content),n=n.addToEnd(t.create())):s.isText?n=n.addToEnd(s):s.isBlock&&s.childCount>0&&(n=n.append(Te(s.content,e)),n=n.addToEnd(t.create()))}),((r=n.lastChild)==null?void 0:r.type)===t&&(n=n.cut(0,n.size-1)),n}function ko(o,e){const t=[];return o.forEach((n,r,s)=>{s!==e&&t.push(n)}),w.Fragment.from(t)}function go(o,e){const t=[];for(let n=0;n<o.childCount;n++)if(o.child(n).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(o.child(n)));t[t.length-1]=s}else{const r=e.nodes.table.createChecked(void 0,o.child(n));t.push(r)}else t.push(o.child(n));return o=w.Fragment.from(t),o}function bo(o,e){let t=w.Fragment.from(o.content);if(t=go(t,e.state.schema),mo(e)){let n=!1;if(t.descendants(r=>{r.type.isInGroup("tableContent")&&(n=!0)}),!n&&!e.state.schema.nodes.tableParagraph.validContent(t))return new w.Slice(Te(t,e.state.schema),0,0)}if(!Bo(t,e))return new w.Slice(t,o.openStart,o.openEnd);for(let n=0;n<t.childCount;n++)if(t.child(n).type.spec.group==="blockContent"){const r=[t.child(n)];if(n+1<t.childCount&&t.child(n+1).type.name==="blockGroup"){const i=t.child(n+1).child(0).child(0);(i.type.name==="bulletListItem"||i.type.name==="numberedListItem"||i.type.name==="checkListItem")&&(r.push(t.child(n+1)),t=ko(t,n+1))}const s=e.state.schema.nodes.blockContainer.createChecked(void 0,r);t=t.replaceChild(n,s)}return new w.Slice(t,o.openStart,o.openEnd)}function Bo(o,e){var s,i;const t=o.childCount===1,n=((s=o.firstChild)==null?void 0:s.type.spec.content)==="inline*",r=((i=o.firstChild)==null?void 0:i.type.spec.content)==="tableRow+";if(t){if(n)return!1;if(r){const d=u.getBlockInfoFromSelection(e.state);if(d.isBlockContainer)return!(d.blockContent.node.type.spec.content==="tableRow+")}}return!0}const So={enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!1};class K extends G.EventEmitter{constructor(t){var l,p,f,h,g,k,b,C,y,P;super();B(this,"pmSchema");B(this,"_tiptapEditor");B(this,"elementRenderer",null);B(this,"blockCache",new WeakMap);B(this,"dictionary");B(this,"schema");B(this,"blockImplementations");B(this,"inlineContentImplementations");B(this,"styleImplementations");B(this,"uploadFile");B(this,"onUploadStartCallbacks",[]);B(this,"onUploadEndCallbacks",[]);B(this,"resolveFileUrl");B(this,"settings");B(this,"_blockManager");B(this,"_eventManager");B(this,"_exportManager");B(this,"_extensionManager");B(this,"_selectionManager");B(this,"_stateManager");B(this,"_styleManager");B(this,"unregisterExtension",(...t)=>this._extensionManager.unregisterExtension(...t));B(this,"registerExtension",(...t)=>this._extensionManager.registerExtension(...t));B(this,"getExtension",(...t)=>this._extensionManager.getExtension(...t));B(this,"mount",t=>{this._tiptapEditor.mount({mount:t})});B(this,"unmount",()=>{this._tiptapEditor.unmount()});this.options=t,this.dictionary=t.dictionary||we.en,this.settings={tables:{splitCells:((l=t==null?void 0:t.tables)==null?void 0:l.splitCells)??!1,cellBackgroundColor:((p=t==null?void 0:t.tables)==null?void 0:p.cellBackgroundColor)??!1,cellTextColor:((f=t==null?void 0:t.tables)==null?void 0:f.cellTextColor)??!1,headers:((h=t==null?void 0:t.tables)==null?void 0:h.headers)??!1}};const n={defaultStyles:!0,schema:t.schema||I.BlockNoteSchema.create(),...t,placeholders:{...this.dictionary.placeholders,...t.placeholders}};if(this.schema=n.schema,this.blockImplementations=n.schema.blockSpecs,this.inlineContentImplementations=n.schema.inlineContentSpecs,this.styleImplementations=n.schema.styleSpecs,n.uploadFile){const x=n.uploadFile;this.uploadFile=async(v,M)=>{this.onUploadStartCallbacks.forEach(A=>A.apply(this,[M]));try{return await x(v,M)}finally{this.onUploadEndCallbacks.forEach(A=>A.apply(this,[M]))}}}this.resolveFileUrl=n.resolveFileUrl,this._eventManager=new ct(this),this._extensionManager=new so(this,n);const r=this._extensionManager.getTiptapExtensions(),s=this._extensionManager.hasExtension("ySync")||this._extensionManager.hasExtension("liveblocksExtension");s&&n.initialContent&&console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider");const i={...So,...n._tiptapOptions,element:null,autofocus:n.autofocus??!1,extensions:r,editorProps:{...(g=n._tiptapOptions)==null?void 0:g.editorProps,attributes:{tabIndex:"0",...(b=(k=n._tiptapOptions)==null?void 0:k.editorProps)==null?void 0:b.attributes,...(C=n.domAttributes)==null?void 0:C.editor,class:a.mergeCSSClasses("bn-editor",n.defaultStyles?"bn-default-styles":"",((P=(y=n.domAttributes)==null?void 0:y.editor)==null?void 0:P.class)||"")},transformPasted:bo}};try{const x=n.initialContent||(s?[{type:"paragraph",id:"initialBlockId"}]:[{type:"paragraph",id:u.UniqueID.options.generateID()}]);if(!Array.isArray(x)||x.length===0)throw new Error("initialContent must be a non-empty array of blocks, received: "+x);const v=S.getSchema(i.extensions),M=x.map(Pe=>u.blockToNode(Pe,v,this.schema.styleSchema).toJSON()),A=S.createDocument({type:"doc",content:[{type:"blockGroup",content:M}]},v,i.parseOptions);this._tiptapEditor=new S.Editor({...i,content:A.toJSON()}),this.pmSchema=this._tiptapEditor.schema}catch(x){throw new Error("Error creating document from blocks passed as `initialContent`",{cause:x})}let d;const c=this.pmSchema.nodes.doc.createAndFill;this.pmSchema.nodes.doc.createAndFill=(...x)=>{if(d)return d;const v=c.apply(this.pmSchema.nodes.doc,x),M=JSON.parse(JSON.stringify(v.toJSON()));return M.content[0].content[0].attrs.id="initialBlockId",d=T.Node.fromJSON(this.pmSchema,M),d},this.pmSchema.cached.blockNoteEditor=this,this._blockManager=new it(this),this._exportManager=new Bt(this),this._selectionManager=new uo(this),this._stateManager=new po(this),this._styleManager=new ho(this),this.emit("create")}static create(t){return new K(t??{})}get extensions(){return this._extensionManager.getExtensions()}exec(t){return this._stateManager.exec(t)}canExec(t){return this._stateManager.canExec(t)}transact(t){return this._stateManager.transact(t)}get prosemirrorState(){return this._stateManager.prosemirrorState}get prosemirrorView(){return this._stateManager.prosemirrorView}get domElement(){var t;if(!this.headless)return(t=this.prosemirrorView)==null?void 0:t.dom}isFocused(){var t;return this.headless?!1:((t=this.prosemirrorView)==null?void 0:t.hasFocus())||!1}get headless(){return!this._tiptapEditor.isInitialized}focus(){this.headless||this.prosemirrorView.focus()}blur(){var t;this.headless||(t=this.domElement)==null||t.blur()}onUploadStart(t){return this.onUploadStartCallbacks.push(t),()=>{const n=this.onUploadStartCallbacks.indexOf(t);n>-1&&this.onUploadStartCallbacks.splice(n,1)}}onUploadEnd(t){return this.onUploadEndCallbacks.push(t),()=>{const n=this.onUploadEndCallbacks.indexOf(t);n>-1&&this.onUploadEndCallbacks.splice(n,1)}}get topLevelBlocks(){return this.document}get document(){return this._blockManager.document}getBlock(t){return this._blockManager.getBlock(t)}getPrevBlock(t){return this._blockManager.getPrevBlock(t)}getNextBlock(t){return this._blockManager.getNextBlock(t)}getParentBlock(t){return this._blockManager.getParentBlock(t)}forEachBlock(t,n=!1){this._blockManager.forEachBlock(t,n)}onEditorContentChange(t){this._tiptapEditor.on("update",t)}onEditorSelectionChange(t){this._tiptapEditor.on("selectionUpdate",t)}onBeforeChange(t){return this._extensionManager.getExtension(m.BlockChangeExtension).subscribe(t)}getTextCursorPosition(){return this._selectionManager.getTextCursorPosition()}setTextCursorPosition(t,n="start"){return this._selectionManager.setTextCursorPosition(t,n)}getSelection(){return this._selectionManager.getSelection()}getSelectionCutBlocks(t=!1){return this._selectionManager.getSelectionCutBlocks(t)}setSelection(t,n){return this._selectionManager.setSelection(t,n)}get isEditable(){return this._stateManager.isEditable}set isEditable(t){this._stateManager.isEditable=t}insertBlocks(t,n,r="before"){return this._blockManager.insertBlocks(t,n,r)}updateBlock(t,n){return this._blockManager.updateBlock(t,n)}removeBlocks(t){return this._blockManager.removeBlocks(t)}replaceBlocks(t,n){return this._blockManager.replaceBlocks(t,n)}undo(){return this._stateManager.undo()}redo(){return this._stateManager.redo()}insertInlineContent(t,{updateSelection:n=!1}={}){this._styleManager.insertInlineContent(t,{updateSelection:n})}getActiveStyles(){return this._styleManager.getActiveStyles()}addStyles(t){this._styleManager.addStyles(t)}removeStyles(t){this._styleManager.removeStyles(t)}toggleStyles(t){this._styleManager.toggleStyles(t)}getSelectedText(){return this._styleManager.getSelectedText()}getSelectedLinkUrl(){return this._styleManager.getSelectedLinkUrl()}createLink(t,n){this._styleManager.createLink(t,n)}canNestBlock(){return this._blockManager.canNestBlock()}nestBlock(){this._blockManager.nestBlock()}canUnnestBlock(){return this._blockManager.canUnnestBlock()}unnestBlock(){this._blockManager.unnestBlock()}moveBlocksUp(){return this._blockManager.moveBlocksUp()}moveBlocksDown(){return this._blockManager.moveBlocksDown()}blocksToHTMLLossy(t=this.document){return this._exportManager.blocksToHTMLLossy(t)}blocksToFullHTML(t=this.document){return this._exportManager.blocksToFullHTML(t)}tryParseHTMLToBlocks(t){return this._exportManager.tryParseHTMLToBlocks(t)}blocksToMarkdownLossy(t=this.document){return this._exportManager.blocksToMarkdownLossy(t)}tryParseMarkdownToBlocks(t){return this._exportManager.tryParseMarkdownToBlocks(t)}onChange(t,n){return this._eventManager.onChange(t,n)}onSelectionChange(t,n){return this._eventManager.onSelectionChange(t,n)}onMount(t){this._eventManager.onMount(t)}onUnmount(t){this._eventManager.onUnmount(t)}getSelectionBoundingBox(){return this._selectionManager.getSelectionBoundingBox()}get isEmpty(){const t=this.document;return t.length===0||t.length===1&&t[0].type==="paragraph"&&t[0].content.length===0}pasteHTML(t,n=!1){this._exportManager.pasteHTML(t,n)}pasteText(t){return this._exportManager.pasteText(t)}pasteMarkdown(t){return this._exportManager.pasteMarkdown(t)}}class Co{constructor(e,t,n){this.mappings=t,this.options=n}async resolveFile(e){var n;if(!((n=this.options)!=null&&n.resolveFileUrl))return(await fetch(e)).blob();const t=await this.options.resolveFileUrl(e);return t instanceof Blob?t:(await fetch(t)).blob()}mapStyles(e){return Object.entries(e).map(([n,r])=>this.mappings.styleMapping[n](r,this))}mapInlineContent(e){return this.mappings.inlineContentMapping[e.type](e,this)}transformInlineContent(e){return e.map(t=>this.mapInlineContent(t))}async mapBlock(e,t,n,r){return this.mappings.blockMapping[e.type](e,this,t,n,r)}}function yo(o){return{createBlockMapping:e=>e,createInlineContentMapping:e=>e,createStyleMapping:e=>e}}function Eo(o,...e){const t=[...o];for(const n of e)for(const r of n){const s=t.findLastIndex(i=>i.group===r.group);s===-1?t.push(r):t.splice(s+1,0,r)}return t}exports.UniqueID=u.UniqueID;exports.UnreachableCaseError=u.UnreachableCaseError;exports.assertEmpty=u.assertEmpty;exports.blockToNode=u.blockToNode;exports.contentNodeToInlineContent=u.contentNodeToInlineContent;exports.contentNodeToTableContent=u.contentNodeToTableContent;exports.docToBlocks=u.docToBlocks;exports.getBlockCache=u.getBlockCache;exports.getBlockInfo=u.getBlockInfo;exports.getBlockInfoFromResolvedPos=u.getBlockInfoFromResolvedPos;exports.getBlockInfoFromSelection=u.getBlockInfoFromSelection;exports.getBlockInfoFromTransaction=u.getBlockInfoFromTransaction;exports.getBlockInfoWithManualOffset=u.getBlockInfoWithManualOffset;exports.getBlockNoteSchema=u.getBlockNoteSchema;exports.getBlockSchema=u.getBlockSchema;exports.getColspan=u.getColspan;exports.getInlineContentSchema=u.getInlineContentSchema;exports.getNearestBlockPos=u.getNearestBlockPos;exports.getPmSchema=u.getPmSchema;exports.getRowspan=u.getRowspan;exports.getStyleSchema=u.getStyleSchema;exports.inlineContentToNodes=u.inlineContentToNodes;exports.isLinkInlineContent=u.isLinkInlineContent;exports.isPartialLinkInlineContent=u.isPartialLinkInlineContent;exports.isPartialTableCell=u.isPartialTableCell;exports.isStyledTextInlineContent=u.isStyledTextInlineContent;exports.isTableCell=u.isTableCell;exports.mapTableCell=u.mapTableCell;exports.nodeToBlock=u.nodeToBlock;exports.nodeToCustomInlineContent=u.nodeToCustomInlineContent;exports.prosemirrorSliceToSlicedBlocks=u.prosemirrorSliceToSlicedBlocks;exports.tableContentToNodes=u.tableContentToNodes;exports.COLORS_DARK_MODE_DEFAULT=a.COLORS_DARK_MODE_DEFAULT;exports.COLORS_DEFAULT=a.COLORS_DEFAULT;exports.EMPTY_CELL_HEIGHT=a.EMPTY_CELL_HEIGHT;exports.EMPTY_CELL_WIDTH=a.EMPTY_CELL_WIDTH;exports.FILE_AUDIO_ICON_SVG=a.FILE_AUDIO_ICON_SVG;exports.FILE_IMAGE_ICON_SVG=a.FILE_IMAGE_ICON_SVG;exports.FILE_VIDEO_ICON_SVG=a.FILE_VIDEO_ICON_SVG;exports.FilePanelExtension=a.FilePanelExtension;exports.SuggestionMenu=a.SuggestionMenu;exports.addDefaultPropsExternalHTML=a.addDefaultPropsExternalHTML;exports.addInlineContentAttributes=a.addInlineContentAttributes;exports.addInlineContentKeyboardShortcuts=a.addInlineContentKeyboardShortcuts;exports.addNodeAndExtensionsToSpec=a.addNodeAndExtensionsToSpec;exports.addStyleAttributes=a.addStyleAttributes;exports.applyNonSelectableBlockFix=a.applyNonSelectableBlockFix;exports.audioParse=a.audioParse;exports.audioRender=a.audioRender;exports.audioToExternalHTML=a.audioToExternalHTML;exports.blockHasType=a.blockHasType;exports.camelToDataKebab=a.camelToDataKebab;exports.captureCellAnchor=a.captureCellAnchor;exports.createAudioBlockConfig=a.createAudioBlockConfig;exports.createAudioBlockSpec=a.createAudioBlockSpec;exports.createBlockConfig=a.createBlockConfig;exports.createBlockSpec=a.createBlockSpec;exports.createBlockSpecFromTiptapNode=a.createBlockSpecFromTiptapNode;exports.createBulletListItemBlockConfig=a.createBulletListItemBlockConfig;exports.createBulletListItemBlockSpec=a.createBulletListItemBlockSpec;exports.createCheckListItemBlockSpec=a.createCheckListItemBlockSpec;exports.createCheckListItemConfig=a.createCheckListItemConfig;exports.createCodeBlockConfig=a.createCodeBlockConfig;exports.createCodeBlockSpec=a.createCodeBlockSpec;exports.createDefaultBlockDOMOutputSpec=a.createDefaultBlockDOMOutputSpec;exports.createDividerBlockConfig=a.createDividerBlockConfig;exports.createDividerBlockSpec=a.createDividerBlockSpec;exports.createFileBlockConfig=a.createFileBlockConfig;exports.createFileBlockSpec=a.createFileBlockSpec;exports.createHeadingBlockConfig=a.createHeadingBlockConfig;exports.createHeadingBlockSpec=a.createHeadingBlockSpec;exports.createImageBlockConfig=a.createImageBlockConfig;exports.createImageBlockSpec=a.createImageBlockSpec;exports.createInlineContentSpecFromTipTapNode=a.createInlineContentSpecFromTipTapNode;exports.createInternalInlineContentSpec=a.createInternalInlineContentSpec;exports.createInternalStyleSpec=a.createInternalStyleSpec;exports.createNumberedListItemBlockConfig=a.createNumberedListItemBlockConfig;exports.createNumberedListItemBlockSpec=a.createNumberedListItemBlockSpec;exports.createParagraphBlockConfig=a.createParagraphBlockConfig;exports.createParagraphBlockSpec=a.createParagraphBlockSpec;exports.createQuoteBlockConfig=a.createQuoteBlockConfig;exports.createQuoteBlockSpec=a.createQuoteBlockSpec;exports.createStyleSpec=a.createStyleSpec;exports.createStyleSpecFromTipTapMark=a.createStyleSpecFromTipTapMark;exports.createTableBlockSpec=a.createTableBlockSpec;exports.createToggleListItemBlockConfig=a.createToggleListItemBlockConfig;exports.createToggleListItemBlockSpec=a.createToggleListItemBlockSpec;exports.createToggleWrapper=a.createToggleWrapper;exports.createVideoBlockConfig=a.createVideoBlockConfig;exports.createVideoBlockSpec=a.createVideoBlockSpec;exports.defaultBlockSpecs=a.defaultBlockSpecs;exports.defaultBlockToHTML=a.defaultBlockToHTML;exports.defaultInlineContentSchema=a.defaultInlineContentSchema;exports.defaultInlineContentSpecs=a.defaultInlineContentSpecs;exports.defaultProps=a.defaultProps;exports.defaultStyleSchema=a.defaultStyleSchema;exports.defaultStyleSpecs=a.defaultStyleSpecs;exports.defaultToggledState=a.defaultToggledState;exports.editorHasBlockWithType=a.editorHasBlockWithType;exports.fileParse=a.fileParse;exports.filenameFromURL=a.filenameFromURL;exports.filterSuggestionItems=a.filterSuggestionItems;exports.formatKeyboardShortcut=a.formatKeyboardShortcut;exports.getBackgroundColorAttribute=a.getBackgroundColorAttribute;exports.getBlockFromPos=a.getBlockFromPos;exports.getDefaultSlashMenuItems=a.getDefaultSlashMenuItems;exports.getInlineContentSchemaFromSpecs=a.getInlineContentSchemaFromSpecs;exports.getLanguageId=a.getLanguageId;exports.getNodeById=a.getNodeById;exports.getParseRules=a.getParseRules;exports.getStyleParseRules=a.getStyleParseRules;exports.getStyleSchemaFromSpecs=a.getStyleSchemaFromSpecs;exports.getTextAlignmentAttribute=a.getTextAlignmentAttribute;exports.getTextColorAttribute=a.getTextColorAttribute;exports.imageParse=a.imageParse;exports.imageRender=a.imageRender;exports.imageToExternalHTML=a.imageToExternalHTML;exports.insertOrUpdateBlockForSlashMenu=a.insertOrUpdateBlockForSlashMenu;exports.isAppleOS=a.isAppleOS;exports.isNodeBlock=a.isNodeBlock;exports.isSafari=a.isSafari;exports.isTableCellSelection=a.isTableCellSelection;exports.isVideoUrl=a.isVideoUrl;exports.mergeCSSClasses=a.mergeCSSClasses;exports.mergeParagraphs=a.mergeParagraphs;exports.parseAudioElement=a.parseAudioElement;exports.parseDefaultProps=a.parseDefaultProps;exports.propsToAttributes=a.propsToAttributes;exports.stylePropsToAttributes=a.stylePropsToAttributes;exports.tablePropSchema=a.tablePropSchema;exports.trackPosition=a.trackPosition;exports.updateBlock=a.updateBlock;exports.updateBlockCommand=a.updateBlockCommand;exports.updateBlockTr=a.updateBlockTr;exports.videoParse=a.videoParse;exports.wrapInBlockStructure=a.wrapInBlockStructure;exports.BlockChangeExtension=m.BlockChangeExtension;exports.DEFAULT_LINK_PROTOCOL=m.DEFAULT_LINK_PROTOCOL;exports.DRAG_EXCLUSION_CLASSNAME=m.DRAG_EXCLUSION_CLASSNAME;exports.DropCursorExtension=m.DropCursorExtension;exports.ForkYDocExtension=m.ForkYDocExtension;exports.FormattingToolbarExtension=m.FormattingToolbarExtension;exports.HistoryExtension=m.HistoryExtension;exports.LinkToolbarExtension=m.LinkToolbarExtension;exports.NodeSelectionKeyboardExtension=m.NodeSelectionKeyboardExtension;exports.PlaceholderExtension=m.PlaceholderExtension;exports.PreviousBlockTypeExtension=m.PreviousBlockTypeExtension;exports.SchemaMigration=m.SchemaMigration;exports.SideMenuExtension=m.SideMenuExtension;exports.SideMenuView=m.SideMenuView;exports.TableHandlesExtension=m.TableHandlesExtension;exports.TableHandlesView=m.TableHandlesView;exports.TrailingNodeExtension=m.TrailingNodeExtension;exports.VALID_LINK_PROTOCOLS=m.VALID_LINK_PROTOCOLS;exports.YCursorExtension=m.YCursorExtension;exports.YSyncExtension=m.YSyncExtension;exports.YUndoExtension=m.YUndoExtension;exports.blocksToMarkdown=m.blocksToMarkdown;exports.cleanHTMLToMarkdown=m.cleanHTMLToMarkdown;exports.createExternalHTMLExporter=m.createExternalHTMLExporter;exports.getBlocksChangedByTransaction=m.getBlocksChangedByTransaction;exports.getDefaultEmojiPickerItems=m.getDefaultEmojiPickerItems;exports.sideMenuPluginKey=m.sideMenuPluginKey;exports.tableHandlesPluginKey=m.tableHandlesPluginKey;exports.BlockNoteSchema=I.BlockNoteSchema;exports.CustomBlockNoteSchema=I.CustomBlockNoteSchema;exports.checkPageBreakBlocksInSchema=I.checkPageBreakBlocksInSchema;exports.createPageBreakBlockConfig=I.createPageBreakBlockConfig;exports.createPageBreakBlockSpec=I.createPageBreakBlockSpec;exports.getPageBreakSlashMenuItems=I.getPageBreakSlashMenuItems;exports.uploadToTmpFilesDotOrg_DEV_ONLY=I.uploadToTmpFilesDotOrg_DEV_ONLY;exports.withPageBreak=I.withPageBreak;exports.EventEmitter=G.EventEmitter;exports.createExtension=H.createExtension;exports.createStore=H.createStore;exports.ShowSelectionExtension=ne.ShowSelectionExtension;exports.BlockNoteEditor=K;exports.Exporter=Co;exports.HTMLToBlocks=z;exports.combineByGroup=Eo;exports.createInlineContentSpec=Ge;exports.createInternalHTMLSerializer=ae;exports.expandPMRangeToWords=Ee;exports.fixColumnList=_;exports.getBlock=me;exports.getInlineContentParseRules=re;exports.getNextBlock=ge;exports.getParentBlock=be;exports.getPrevBlock=ke;exports.insertBlocks=se;exports.isEmptyColumn=O;exports.mappingFactory=yo;exports.markdownToBlocks=Be;exports.markdownToHTML=q;exports.removeAndInsertBlocks=R;exports.removeEmptyColumns=ie;exports.selectedFragmentToHTML=j;
5
5
  //# sourceMappingURL=blocknote.cjs.map