@blocknote/core 0.44.2 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BlockNoteExtension-BWw0r8Gy.cjs.map +1 -1
- package/dist/BlockNoteExtension-C2X7LW-V.js.map +1 -1
- package/dist/{BlockNoteSchema-BsTi0fNS.js → BlockNoteSchema-BOW16JHv.js} +2 -2
- package/dist/{BlockNoteSchema-BsTi0fNS.js.map → BlockNoteSchema-BOW16JHv.js.map} +1 -1
- package/dist/{BlockNoteSchema-CBNkNhkw.cjs → BlockNoteSchema-CzZbr4Ed.cjs} +2 -2
- package/dist/{BlockNoteSchema-CBNkNhkw.cjs.map → BlockNoteSchema-CzZbr4Ed.cjs.map} +1 -1
- package/dist/{TrailingNode-CG2a-HDA.js → TrailingNode-8cXFaQUm.js} +484 -487
- package/dist/TrailingNode-8cXFaQUm.js.map +1 -0
- package/dist/TrailingNode-DPu6X9ym.cjs +2 -0
- package/dist/TrailingNode-DPu6X9ym.cjs.map +1 -0
- package/dist/{blockToNode-DBNbhwwC.js → blockToNode-BNoNIXU7.js} +2 -2
- package/dist/{blockToNode-DBNbhwwC.js.map → blockToNode-BNoNIXU7.js.map} +1 -1
- package/dist/{blockToNode-w7H99R6p.cjs → blockToNode-CumVjgem.cjs} +2 -2
- package/dist/{blockToNode-w7H99R6p.cjs.map → blockToNode-CumVjgem.cjs.map} +1 -1
- package/dist/blocknote.cjs +4 -4
- package/dist/blocknote.cjs.map +1 -1
- package/dist/blocknote.js +1118 -1077
- package/dist/blocknote.js.map +1 -1
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +2 -2
- package/dist/defaultBlocks-D1cc0lV9.cjs +6 -0
- package/dist/defaultBlocks-D1cc0lV9.cjs.map +1 -0
- package/dist/{defaultBlocks-B63ufZ5N.js → defaultBlocks-DvCGYzqu.js} +168 -206
- package/dist/defaultBlocks-DvCGYzqu.js.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +3 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/webpack-stats.json +1 -1
- package/dist/yjs.cjs +1 -1
- package/dist/yjs.js +1 -1
- package/package.json +15 -15
- package/src/api/blockManipulation/selections/selection.ts +9 -4
- package/src/api/blockManipulation/tables/tables.test.ts +140 -0
- package/src/api/blockManipulation/tables/tables.ts +1 -1
- package/src/api/parsers/markdown/parseMarkdown.ts +11 -0
- package/src/blocks/ListItem/CheckListItem/block.ts +2 -2
- package/src/blocks/ListItem/NumberedListItem/block.ts +5 -1
- package/src/editor/BlockNoteEditor.test.ts +0 -1
- package/src/editor/BlockNoteEditor.ts +9 -39
- package/src/editor/BlockNoteExtension.ts +5 -0
- package/src/editor/managers/EventManager.ts +1 -1
- package/src/editor/managers/ExtensionManager/extensions.ts +2 -12
- package/src/editor/managers/ExtensionManager/index.ts +7 -2
- package/src/editor/managers/SelectionManager.ts +10 -10
- package/src/extensions/BlockChange/BlockChange.ts +2 -2
- package/src/extensions/Collaboration/Collaboration.ts +55 -0
- package/src/extensions/Collaboration/ForkYDoc.ts +4 -9
- package/src/extensions/Collaboration/YCursorPlugin.ts +56 -60
- package/src/extensions/Collaboration/YSync.ts +2 -2
- package/src/extensions/Collaboration/YUndo.ts +2 -2
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +40 -68
- package/src/extensions/TableHandles/TableHandles.ts +9 -5
- package/src/index.ts +2 -1
- package/src/schema/blocks/createSpec.ts +3 -0
- package/src/util/expandToWords.ts +38 -0
- package/types/src/api/blockManipulation/selections/selection.d.ts +1 -1
- package/types/src/editor/BlockNoteEditor.d.ts +5 -34
- package/types/src/editor/BlockNoteExtension.d.ts +4 -0
- package/types/src/editor/managers/SelectionManager.d.ts +4 -4
- package/types/src/extensions/Collaboration/Collaboration.d.ts +76 -0
- package/types/src/extensions/Collaboration/ForkYDoc.d.ts +2 -11
- package/types/src/extensions/Collaboration/YCursorPlugin.d.ts +3 -11
- package/types/src/extensions/Collaboration/YSync.d.ts +2 -4
- package/types/src/extensions/Collaboration/YUndo.d.ts +1 -1
- package/types/src/index.d.ts +2 -1
- package/types/src/util/expandToWords.d.ts +13 -0
- package/dist/TrailingNode-CG2a-HDA.js.map +0 -1
- package/dist/TrailingNode-Du4SNHun.cjs +0 -2
- package/dist/TrailingNode-Du4SNHun.cjs.map +0 -1
- package/dist/defaultBlocks-B63ufZ5N.js.map +0 -1
- package/dist/defaultBlocks-BX6UxQa8.cjs +0 -6
- package/dist/defaultBlocks-BX6UxQa8.cjs.map +0 -1
package/dist/blocknote.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`);throw Error("Blocks with the following IDs could not be found in the editor: "+f)}return l.forEach(f=>D(n,f)),{insertedBlocks:r.map(f=>u.nodeToBlock(f,o)),removedBlocks:s}}function Ue(n,e,t,o,r){let i;if(e)if(typeof e=="string")i=u.inlineContentToNodes([e],n.pmSchema,o);else if(Array.isArray(e))i=u.inlineContentToNodes(e,n.pmSchema,o);else if(e.type==="tableContent")i=u.tableContentToNodes(e,n.pmSchema);else throw new u.UnreachableCaseError(e.type);else throw new Error("blockContent is required");const l=((r==null?void 0:r.document)??document).createDocumentFragment();for(const a of i)if(a.type.name!=="text"&&n.schema.inlineContentSchema[a.type.name]){const d=n.schema.inlineContentSpecs[a.type.name].implementation;if(d){const p=u.nodeToCustomInlineContent(a,n.schema.inlineContentSchema,n.schema.styleSchema),f=d.render.call({renderType:"dom",props:void 0},p,()=>{},n);if(f){if(l.appendChild(f.dom),f.contentDOM){const h=t.serializeFragment(a.content,r);f.contentDOM.dataset.editable="",f.contentDOM.appendChild(h)}continue}}}else if(a.type.name==="text"){let d=document.createTextNode(a.textContent);for(const p of a.marks.toReversed())if(p.type.name in n.schema.styleSpecs){const f=n.schema.styleSpecs[p.type.name].implementation.render(p.attrs.stringValue,n);f.contentDOM.appendChild(d),d=f.dom}else{const f=p.type.spec.toDOM(p,!0),h=x.DOMSerializer.renderSpec(document,f);h.contentDOM.appendChild(d),d=h.dom}l.appendChild(d)}else{const d=t.serializeFragment(x.Fragment.from([a]),r);l.appendChild(d)}return l}function Ve(n,e,t,o){var f,h,g,m,S;const r=n.pmSchema.nodes.blockContainer,i=e.props||{};for(const[C,T]of Object.entries(n.schema.blockSchema[e.type].propSchema))!(C in i)&&T.default!==void 0&&(i[C]=T.default);const s=e.children||[],a=n.blockImplementations[e.type].implementation.render.call({renderType:"dom",props:void 0},{...e,props:i,children:s},n);if(a.contentDOM&&e.content){const C=Ue(n,e.content,t,e.type,o);a.contentDOM.appendChild(C)}if(n.pmSchema.nodes[e.type].isInGroup("bnBlock")){if(e.children&&e.children.length>0){const C=se(n,e.children,t,o);(f=a.contentDOM)==null||f.append(C)}return a.dom}const p=(g=(h=r.spec)==null?void 0:h.toDOM)==null?void 0:g.call(h,r.create({id:e.id,...i}));return(m=p.contentDOM)==null||m.appendChild(a.dom),e.children&&e.children.length>0&&((S=p.contentDOM)==null||S.appendChild(ie(n,e.children,t,o))),p.dom}function se(n,e,t,o){const i=((o==null?void 0:o.document)??document).createDocumentFragment();for(const s of e){const l=Ve(n,s,t,o);i.appendChild(l)}return i}const ie=(n,e,t,o)=>{var l;const r=n.pmSchema.nodes.blockGroup,i=r.spec.toDOM(r.create({})),s=se(n,e,t,o);return(l=i.contentDOM)==null||l.appendChild(s),i.dom},ce=(n,e)=>{const t=x.DOMSerializer.fromSchema(n);return{serializeBlocks:(o,r)=>ie(e,o,t,r).outerHTML}};function Re(n){return n.transact(e=>{const t=u.getNearestBlockPos(e.doc,e.selection.anchor);if(e.selection instanceof A.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 y.NodeSelection)return{type:"node",anchorBlockId:t.node.attrs.id};{const o=u.getNearestBlockPos(e.doc,e.selection.head);return{type:"text",anchorBlockId:t.node.attrs.id,headBlockId:o.node.attrs.id,anchorOffset:e.selection.anchor-t.posBeforeNode,headOffset:e.selection.head-o.posBeforeNode}}})}function Ge(n,e){var r,i;const t=(r=c.getNodeById(e.anchorBlockId,n.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 o;if(e.type==="cell")o=A.CellSelection.create(n.doc,t+e.anchorCellOffset,t+e.headCellOffset);else if(e.type==="node")o=y.NodeSelection.create(n.doc,t+1);else{const s=(i=c.getNodeById(e.headBlockId,n.doc))==null?void 0:i.posBeforeNode;if(s===void 0)throw new Error(`Could not find block with ID ${e.headBlockId} to update selection`);o=y.TextSelection.create(n.doc,t+e.anchorOffset,s+e.headOffset)}n.setSelection(o)}function $(n){return n.map(e=>e.type==="columnList"?e.children.map(t=>$(t.children)).flat():{...e,children:$(e.children)}).flat()}function ae(n,e,t){n.transact(o=>{var s;const r=((s=n.getSelection())==null?void 0:s.blocks)||[n.getTextCursorPosition().block],i=Re(n);n.removeBlocks(r),n.insertBlocks($(r),e,t),Ge(o,i)})}function le(n){return!n||n.type!=="columnList"}function de(n,e,t){let o,r;if(e?e.children.length>0?(o=e.children[e.children.length-1],r="after"):(o=e,r="before"):t&&(o=t,r="before"),!o||!r)return;const i=n.getParentBlock(o);return le(i)?{referenceBlock:o,placement:r}:de(n,r==="after"?o:n.getPrevBlock(o),i)}function ue(n,e,t){let o,r;if(e?e.children.length>0?(o=e.children[0],r="before"):(o=e,r="after"):t&&(o=t,r="after"),!o||!r)return;const i=n.getParentBlock(o);return le(i)?{referenceBlock:o,placement:r}:ue(n,r==="before"?o:n.getNextBlock(o),i)}function ze(n){n.transact(()=>{const e=n.getSelection(),t=(e==null?void 0:e.blocks[0])||n.getTextCursorPosition().block,o=de(n,n.getPrevBlock(t),n.getParentBlock(t));o&&ae(n,o.referenceBlock,o.placement)})}function qe(n){n.transact(()=>{const e=n.getSelection(),t=(e==null?void 0:e.blocks[(e==null?void 0:e.blocks.length)-1])||n.getTextCursorPosition().block,o=ue(n,n.getNextBlock(t),n.getParentBlock(t));o&&ae(n,o.referenceBlock,o.placement)})}function je(n,e,t){const{$from:o,$to:r}=n.selection,i=o.blockRange(r,m=>m.childCount>0&&(m.type.name==="blockGroup"||m.type.name==="column"));if(!i)return!1;const s=i.startIndex;if(s===0)return!1;const a=i.parent.child(s-1);if(a.type!==e)return!1;const d=a.lastChild&&a.lastChild.type===t,p=x.Fragment.from(d?e.create():null),f=new x.Slice(x.Fragment.from(e.create(null,x.Fragment.from(t.create(null,p)))),d?3:1,0),h=i.start,g=i.end;return n.step(new _.ReplaceAroundStep(h-(d?3:1),g,h,g,f,1,!0)).scrollIntoView(),!0}function pe(n){return n.transact(e=>je(e,n.pmSchema.nodes.blockContainer,n.pmSchema.nodes.blockGroup))}function We(n){n._tiptapEditor.commands.liftListItem("blockContainer")}function Ke(n){return n.transact(e=>{const{bnBlock:t}=u.getBlockInfoFromTransaction(e);return e.doc.resolve(t.beforePos).nodeBefore!==null})}function Ye(n){return n.transact(e=>{const{bnBlock:t}=u.getBlockInfoFromTransaction(e);return e.doc.resolve(t.beforePos).depth>1})}function fe(n,e){const t=typeof e=="string"?e:e.id,o=u.getPmSchema(n),r=c.getNodeById(t,n);if(r)return u.nodeToBlock(r.node,o)}function he(n,e){const t=typeof e=="string"?e:e.id,o=c.getNodeById(t,n),r=u.getPmSchema(n);if(!o)return;const s=n.resolve(o.posBeforeNode).nodeBefore;if(s)return u.nodeToBlock(s,r)}function me(n,e){const t=typeof e=="string"?e:e.id,o=c.getNodeById(t,n),r=u.getPmSchema(n);if(!o)return;const s=n.resolve(o.posBeforeNode+o.node.nodeSize).nodeAfter;if(s)return u.nodeToBlock(s,r)}function ke(n,e){const t=typeof e=="string"?e:e.id,o=u.getPmSchema(n),r=c.getNodeById(t,n);if(!r)return;const i=n.resolve(r.posBeforeNode),s=i.node(),l=i.node(-1),a=l.type.name!=="doc"?s.type.name==="blockGroup"?l:s:void 0;if(a)return u.nodeToBlock(a,o)}class Je{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=>fe(t.doc,e))}getPrevBlock(e){return this.editor.transact(t=>he(t.doc,e))}getNextBlock(e){return this.editor.transact(t=>me(t.doc,e))}getParentBlock(e){return this.editor.transact(t=>ke(t.doc,e))}forEachBlock(e,t=!1){const o=this.document.slice();t&&o.reverse();function r(i){for(const s of i){if(e(s)===!1)return!1;const l=t?s.children.slice().reverse():s.children;if(!r(l))return!1}return!0}r(o)}insertBlocks(e,t,o="before"){return this.editor.transact(r=>ne(r,e,t,o))}updateBlock(e,t){return this.editor.transact(o=>c.updateBlock(o,e,t))}removeBlocks(e){return this.editor.transact(t=>H(t,e,[]).removedBlocks)}replaceBlocks(e,t){return this.editor.transact(o=>H(o,e,t))}canNestBlock(){return Ke(this.editor)}nestBlock(){pe(this.editor)}canUnnestBlock(){return Ye(this.editor)}unnestBlock(){We(this.editor)}moveBlocksUp(){return ze(this.editor)}moveBlocksDown(){return qe(this.editor)}}class Qe extends V.EventEmitter{constructor(e){super(),this.editor=e,e.on("create",()=>{e._tiptapEditor.on("update",({transaction:t,appendedTransactions:o})=>{this.emit("onChange",{editor:e,transaction:t,appendedTransactions:o})}),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 o=({transaction:r,appendedTransactions:i})=>{!t&&Y(r)||e(this.editor,{getChanges(){return b.getBlocksChangedByTransaction(r,i)}})};return this.on("onChange",o),()=>{this.off("onChange",o)}}onSelectionChange(e,t=!1){const o=r=>{!t&&Y(r.transaction)||e(this.editor)};return this.on("onSelectionChange",o),()=>{this.off("onSelectionChange",o)}}onMount(e){return this.on("onMount",e),()=>{this.off("onMount",e)}}onUnmount(e){return this.on("onUnmount",e),()=>{this.off("onUnmount",e)}}}function Y(n){return!!n.getMeta("y-sync$")}function Xe(n){return Array.prototype.indexOf.call(n.parentElement.childNodes,n)}function Ze(n){return n.nodeType===3&&!/\S/.test(n.nodeValue||"")}function et(n){n.querySelectorAll("li > ul, li > ol").forEach(e=>{const t=Xe(e),o=e.parentElement,r=Array.from(o.childNodes).slice(t+1);e.remove(),r.forEach(i=>{i.remove()}),o.insertAdjacentElement("afterend",e),r.reverse().forEach(i=>{if(Ze(i))return;const s=document.createElement("li");s.append(i),e.insertAdjacentElement("afterend",s)}),o.childNodes.length===0&&o.remove()})}function tt(n){n.querySelectorAll("li + ul, li + ol").forEach(e=>{var i,s;const t=e.previousElementSibling,o=document.createElement("div");t.insertAdjacentElement("afterend",o),o.append(t);const r=document.createElement("div");for(r.setAttribute("data-node-type","blockGroup"),o.append(r);((i=o.nextElementSibling)==null?void 0:i.nodeName)==="UL"||((s=o.nextElementSibling)==null?void 0:s.nodeName)==="OL";)r.append(o.nextElementSibling)})}let J=null;function ot(){return J||(J=document.implementation.createHTMLDocument("title"))}function nt(n){if(typeof n=="string"){const e=ot().createElement("div");e.innerHTML=n,n=e}return et(n),tt(n),n}function G(n,e){const t=nt(n),r=x.DOMParser.fromSchema(e).parse(t,{topNode:e.nodes.blockGroup.create()}),i=[];for(let s=0;s<r.childCount;s++)i.push(u.nodeToBlock(r.child(s),e));return i}function rt(n,e){const t=e.value?e.value:"",o={};e.lang&&(o["data-language"]=e.lang);let r={type:"element",tagName:"code",properties:o,children:[{type:"text",value:t}]};return e.meta&&(r.data={meta:e.meta}),n.patch(e,r),r=n.applyData(e,r),r={type:"element",tagName:"pre",properties:{},children:[r]},n.patch(e,r),r}function st(n,e){var i;const t=String((e==null?void 0:e.url)||""),o=e!=null&&e.title?String(e.title):void 0;let r={type:"element",tagName:"video",properties:{src:t,"data-name":o,"data-url":t,controls:!0},children:[]};return(i=n.patch)==null||i.call(n,e,r),r=n.applyData?n.applyData(e,r):r,r}function z(n){return _e.unified().use(Fe.default).use(De.default).use(Oe.default,{handlers:{...O.defaultHandlers,image:(t,o)=>{const r=String((o==null?void 0:o.url)||"");return c.isVideoUrl(r)?st(t,o):O.defaultHandlers.image(t,o)},code:rt}}).use(He.default).processSync(n).value}function ge(n,e){const t=z(n);return G(t,e)}class it{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 ce(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 ge(e,this.editor.pmSchema)}pasteHTML(e,t=!1){var r;let o=e;if(!t){const i=this.tryParseHTMLToBlocks(e);o=this.blocksToFullHTML(i)}o&&((r=this.editor.prosemirrorView)==null||r.pasteHTML(o))}pasteText(e){var t;return(t=this.editor.prosemirrorView)==null?void 0:t.pasteText(e)}pasteMarkdown(e){const t=z(e);return this.pasteHTML(t)}}const q=["vscode-editor-data","blocknote/html","text/markdown","text/html","text/plain","Files"];function ct(n,e){if(!n.startsWith(".")||!e.startsWith("."))throw new Error("The strings provided are not valid file extensions.");return n===e}function at(n,e){const t=n.split("/"),o=e.split("/");if(t.length!==2)throw new Error(`The string ${n} is not a valid MIME type.`);if(o.length!==2)throw new Error(`The string ${e} is not a valid MIME type.`);return t[1]==="*"||o[1]==="*"?t[0]===o[0]:(t[0]==="*"||o[0]==="*"||t[0]===o[0])&&t[1]===o[1]}function Q(n,e,t,o="after"){let r;return Array.isArray(e.content)&&e.content.length===0?r=n.updateBlock(e,t).id:r=n.insertBlocks([t],e,o)[0].id,r}async function be(n,e){var i;if(!e.uploadFile){console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");return}const t="dataTransfer"in n?n.dataTransfer:n.clipboardData;if(t===null)return;let o=null;for(const s of q)if(t.types.includes(s)){o=s;break}if(o!=="Files")return;const r=t.items;if(r){n.preventDefault();for(let s=0;s<r.length;s++){let l="file";for(const d of Object.values(e.schema.blockSpecs))for(const p of((i=d.implementation.meta)==null?void 0:i.fileBlockAccept)||[]){const f=p.startsWith("."),h=r[s].getAsFile();if(h&&(!f&&h.type&&at(r[s].type,p)||f&&ct("."+h.name.split(".").pop(),p))){l=d.config.type;break}}const a=r[s].getAsFile();if(a){const d={type:l,props:{name:a.name}};let p;if(n.type==="paste"){const g=e.getTextCursorPosition().block;p=Q(e,g,d)}else if(n.type==="drop"){const g={left:n.clientX,top:n.clientY},m=e.prosemirrorView.posAtCoords(g);if(!m)return;p=e.transact(S=>{var E;const C=u.getNearestBlockPos(S.doc,m.pos),T=(E=e.domElement)==null?void 0:E.querySelector(`[data-id="${C.node.attrs.id}"]`),I=T==null?void 0:T.getBoundingClientRect();return Q(e,e.getBlock(C.node.attrs.id),d,I&&(I.top+I.bottom)/2>g.top?"before":"after")})}else return;const f=await e.uploadFile(a,p),h=typeof f=="string"?{props:{url:f}}:{...f};e.updateBlock(p,h)}}}}const lt=n=>B.Extension.create({name:"dropFile",addProseMirrorPlugins(){return[new y.Plugin({props:{handleDOMEvents:{drop(e,t){if(!n.isEditable)return;let o=null;for(const r of q)if(t.dataTransfer.types.includes(r)){o=r;break}return o===null?!0:o==="Files"?(be(t,n),!0):!1}}}})]}}),dt=/(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/,ut=/(_|__|\*|\*\*|~~|==|\+\+)(?!\s)(?:[^\s](?:.{0,62}[^\s])?|\S)(?=\1)/,pt=/\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/,ft=/(?:\s|^)`(?!\s)(?:[^\s`](?:[^`]{0,46}[^\s`])?|[^\s`])`([^\w]|$)/,ht=/(?:^|\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/,kt=/\n{2} {0,3}-{2,48}\n{2}/,gt=/(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/,bt=/(?:\n|^)(?!\s)\w[^\n]{0,64}\r?\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/,St=/(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/,Bt=/^\s*\|(.+\|)+\s*$/m,Ct=/^\s*\|(\s*[-:]+[-:]\s*\|)+\s*$/m,yt=/^\s*\|(.+\|)+\s*$/m,Tt=n=>dt.test(n)||ut.test(n)||pt.test(n)||ft.test(n)||ht.test(n)||mt.test(n)||kt.test(n)||gt.test(n)||bt.test(n)||St.test(n)||Bt.test(n)||Ct.test(n)||yt.test(n);async function Et(n,e){const{schema:t}=e.state;if(!n.clipboardData)return!1;const o=n.clipboardData.getData("text/plain");if(!o)return!1;if(!t.nodes.codeBlock)return e.pasteText(o),!0;const r=n.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,s=i==null?void 0:i.mode;return s?(e.pasteHTML(`<pre><code class="language-${s}">${o.replace(/\r\n?/g,`
|
|
3
|
-
`)}</code></pre>`),!0):!1}function
|
|
4
|
-
`}}),U=(n,e)=>{const t=n.resolve(e),o=t.index();if(o===0)return;const r=t.posAtIndex(o-1);return u.getBlockInfoFromResolvedPos(n.resolve(r))},Se=(n,e)=>{for(;e.childContainer;){const t=e.childContainer.node,o=n.resolve(e.childContainer.beforePos+1).posAtIndex(t.childCount-1);e=u.getBlockInfoFromResolvedPos(n.resolve(o))}return e},Nt=(n,e)=>n.isBlockContainer&&n.blockContent.node.type.spec.content==="inline*"&&n.blockContent.node.childCount>0&&e.isBlockContainer&&e.blockContent.node.type.spec.content==="inline*",At=(n,e,t,o)=>{if(!o.isBlockContainer)throw new Error(`Attempted to merge block at position ${o.bnBlock.beforePos} into previous block at position ${t.bnBlock.beforePos}, but next block is not a block container`);if(o.childContainer){const r=n.doc.resolve(o.childContainer.beforePos+1),i=n.doc.resolve(o.childContainer.afterPos-1),s=r.blockRange(i);if(e){const l=n.doc.resolve(o.bnBlock.beforePos);n.tr.lift(s,l.depth)}}if(e){if(!t.isBlockContainer)throw new Error(`Attempted to merge block at position ${o.bnBlock.beforePos} into previous block at position ${t.bnBlock.beforePos}, but previous block is not a block container`);e(n.tr.delete(t.blockContent.afterPos-1,o.blockContent.beforePos+1))}return!0},ee=n=>({state:e,dispatch:t})=>{const o=e.doc.resolve(n),r=u.getBlockInfoFromResolvedPos(o),i=U(e.doc,r.bnBlock.beforePos);if(!i)return!1;const s=Se(e.doc,i);return Nt(s,r)?At(e,t,s,r):!1},_t=B.Extension.create({priority:50,addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({chain:o,commands:r})=>[()=>r.deleteSelection(),()=>r.undoInputRule(),()=>r.command(({state:i})=>{const s=u.getBlockInfoFromSelection(i);if(!s.isBlockContainer)return!1;const l=i.selection.from===s.blockContent.beforePos+1,a=s.blockContent.node.type.name==="paragraph";return l&&!a?r.command(c.updateBlockCommand(s.bnBlock.beforePos,{type:"paragraph",props:{}})):!1}),()=>r.command(({state:i})=>{const s=u.getBlockInfoFromSelection(i);if(!s.isBlockContainer)return!1;const{blockContent:l}=s;return i.selection.from===l.beforePos+1?r.liftListItem("blockContainer"):!1}),()=>r.command(({state:i})=>{const s=u.getBlockInfoFromSelection(i);if(!s.isBlockContainer)return!1;const{bnBlock:l,blockContent:a}=s,d=i.selection.from===a.beforePos+1,p=i.selection.empty,f=l.beforePos;return d&&p?o().command(ee(f)).scrollIntoView().run():!1}),()=>r.command(({state:i,tr:s,dispatch:l})=>{const a=u.getBlockInfoFromSelection(i);if(!a.isBlockContainer||!(s.selection.from===a.blockContent.beforePos+1))return!1;const p=s.doc.resolve(a.bnBlock.beforePos);if(p.nodeBefore||p.node().type.name!=="column")return!1;const g=s.doc.resolve(a.bnBlock.beforePos),m=s.doc.resolve(g.before()),S=m.before();if(l){const C=s.doc.slice(a.bnBlock.beforePos,a.bnBlock.afterPos).content;s.delete(a.bnBlock.beforePos,a.bnBlock.afterPos),m.index()===0?(D(s,S),s.insert(S,C),s.setSelection(y.TextSelection.near(s.doc.resolve(S)))):(s.insert(m.pos-1,C),s.setSelection(y.TextSelection.near(s.doc.resolve(m.pos-1))),D(s,S))}return!0}),()=>r.command(({state:i})=>{const s=u.getBlockInfoFromSelection(i);if(!s.isBlockContainer)return!1;if(s.blockContent.node.childCount===0&&s.blockContent.node.type.spec.content==="inline*"){const a=U(i.doc,s.bnBlock.beforePos);if(!a||!a.isBlockContainer)return!1;let d=o();if(a.blockContent.node.type.spec.content==="tableRow+"){const m=s.bnBlock.beforePos-1-1-1-1-1;d=d.setTextSelection(m)}else if(a.blockContent.node.type.spec.content===""){const p=a.blockContent.afterPos-a.blockContent.node.nodeSize;d=d.setNodeSelection(p)}else{const p=a.blockContent.afterPos-a.blockContent.node.nodeSize;d=d.setTextSelection(p)}return d.deleteRange({from:s.bnBlock.beforePos,to:s.bnBlock.afterPos}).scrollIntoView().run()}return!1}),()=>r.command(({state:i})=>{const s=u.getBlockInfoFromSelection(i);if(!s.isBlockContainer)throw new Error("todo");const l=i.selection.from===s.blockContent.beforePos+1,a=i.selection.empty,d=U(i.doc,s.bnBlock.beforePos);if(d&&l&&a){const p=Se(i.doc,d);if(!p.isBlockContainer)throw new Error("todo");if(p.blockContent.node.type.spec.content===""||p.blockContent.node.type.spec.content==="inline*"&&p.blockContent.node.childCount===0)return o().cut({from:s.bnBlock.beforePos,to:s.bnBlock.afterPos},p.bnBlock.afterPos).deleteRange({from:p.bnBlock.beforePos,to:p.bnBlock.afterPos}).run()}return!1})]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.command(({state:r})=>{const i=u.getBlockInfoFromSelection(r);if(!i.isBlockContainer)return!1;const{bnBlock:s,blockContent:l,childContainer:a}=i,{depth:d}=r.doc.resolve(s.beforePos),p=s.afterPos===r.doc.nodeSize-3,f=r.selection.from===l.afterPos-1,h=r.selection.empty;if(!p&&f&&h&&!(a!==void 0)){let m=d,S=s.afterPos+1,C=r.doc.resolve(S).depth;for(;C<m;)m=C,S+=2,C=r.doc.resolve(S).depth;return o.command(ee(S-1))}return!1})]),t=(o=!1)=>this.editor.commands.first(({commands:r,tr:i})=>[()=>r.command(({state:s})=>{const l=u.getBlockInfoFromSelection(s);if(!l.isBlockContainer)return!1;const{bnBlock:a,blockContent:d}=l,{depth:p}=s.doc.resolve(a.beforePos),f=s.selection.$anchor.parentOffset===0,h=s.selection.anchor===s.selection.head,g=d.node.childCount===0,m=p>1;return f&&h&&g&&m?r.liftListItem("blockContainer"):!1}),()=>r.command(({state:s})=>{var d;const l=u.getBlockInfoFromSelection(s),a=((d=this.options.editor.schema.blockSchema[l.blockNoteType].meta)==null?void 0:d.hardBreakShortcut)??"shift+enter";if(a==="none")return!1;if(a==="shift+enter"&&o||a==="enter"){const p=i.storedMarks||i.selection.$head.marks().filter(f=>this.editor.extensionManager.splittableMarks.includes(f.type.name));return i.insert(i.selection.head,i.doc.type.schema.nodes.hardBreak.create()).ensureMarks(p),!0}return!1}),()=>r.command(({state:s,dispatch:l})=>{const a=u.getBlockInfoFromSelection(s);if(!a.isBlockContainer)return!1;const{bnBlock:d,blockContent:p}=a,f=s.selection.$anchor.parentOffset===0,h=s.selection.anchor===s.selection.head,g=p.node.childCount===0;if(f&&h&&g){const m=d.afterPos,S=m+2;if(l){const C=s.schema.nodes.blockContainer.createAndFill();s.tr.insert(m,C).scrollIntoView(),s.tr.setSelection(new y.TextSelection(s.doc.resolve(S)))}return!0}return!1}),()=>r.command(({state:s,chain:l})=>{const a=u.getBlockInfoFromSelection(s);if(!a.isBlockContainer)return!1;const{blockContent:d}=a,p=s.selection.$anchor.parentOffset===0;return d.node.childCount===0?!1:(l().deleteSelection().command(c.splitBlockCommand(s.selection.from,p,p)).run(),!0)})]);return{Backspace:n,Delete:e,Enter:()=>t(),"Shift-Enter":()=>t(!0),Tab:()=>{var o,r;return this.options.tabBehavior!=="prefer-indent"&&((o=this.options.editor.getExtension(b.FormattingToolbarExtension))!=null&&o.store.state||((r=this.options.editor.getExtension(c.FilePanelExtension))==null?void 0:r.store.state)!==void 0)?!1:pe(this.options.editor)},"Shift-Tab":()=>{var o,r;return this.options.tabBehavior!=="prefer-indent"&&((o=this.options.editor.getExtension(b.FormattingToolbarExtension))!=null&&o.store.state||((r=this.options.editor.getExtension(c.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()}}}),Lt=B.Mark.create({name:"insertion",inclusive:!1,excludes:"deletion modification insertion",addAttributes(){return{id:{default:null,validate:"number"}}},extendMarkSchema(n){return n.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}}]}}}),Dt=B.Mark.create({name:"deletion",inclusive:!1,excludes:"insertion modification deletion",addAttributes(){return{id:{default:null,validate:"number"}}},extendMarkSchema(n){return n.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}}]}}}),Ft=B.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(n){return n.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}}]}}}),Ot=B.Extension.create({name:"textAlignment",addGlobalAttributes(){return[{types:["tableCell","tableHeader"],attributes:{textAlignment:{default:"left",parseHTML:n=>n.getAttribute("data-text-alignment"),renderHTML:n=>n.textAlignment==="left"?{}:{"data-text-alignment":n.textAlignment}}}}]}}),Ht=B.Extension.create({name:"blockTextColor",addGlobalAttributes(){return[{types:["table","tableCell","tableHeader"],attributes:{textColor:c.getTextColorAttribute()}}]}}),$t={blockColor:"data-block-color",blockStyle:"data-block-style",id:"data-id",depth:"data-depth",depthChange:"data-depth-change"},Ut=B.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:n=>{if(typeof n=="string")return!1;const e={};for(const[t,o]of Object.entries($t))n.getAttribute(o)&&(e[t]=n.getAttribute(o));return e}},{tag:'div[data-node-type="blockOuter"]',skip:!0}]},renderHTML({HTMLAttributes:n}){var r;const e=document.createElement("div");e.className="bn-block-outer",e.setAttribute("data-node-type","blockOuter");for(const[i,s]of Object.entries(n))i!=="class"&&e.setAttribute(i,s);const t={...((r=this.options.domAttributes)==null?void 0:r.block)||{},...n},o=document.createElement("div");o.className=c.mergeCSSClasses("bn-block",t.class),o.setAttribute("data-node-type",this.name);for(const[i,s]of Object.entries(t))i!=="class"&&o.setAttribute(i,s);return e.appendChild(o),{dom:e,contentDOM:o}}}),Vt=B.Node.create({name:"blockGroup",group:"childContainer",content:"blockGroupChild+",marks:"deletion insertion modification",parseHTML(){return[{tag:"div",getAttrs:n=>typeof n=="string"?!1:n.getAttribute("data-node-type")==="blockGroup"?null:!1}]},renderHTML({HTMLAttributes:n}){var o;const e={...((o=this.options.domAttributes)==null?void 0:o.blockGroup)||{},...n},t=document.createElement("div");t.className=c.mergeCSSClasses("bn-block-group",e.class),t.setAttribute("data-node-type","blockGroup");for(const[r,i]of Object.entries(e))r!=="class"&&t.setAttribute(r,i);return{dom:t,contentDOM:t}}}),Rt=B.Node.create({name:"doc",topNode:!0,content:"blockGroup",marks:"insertion modification deletion"});let te=!1;function Gt(n,e){const t=[B.extensions.ClipboardTextSerializer,B.extensions.Commands,B.extensions.Editable,B.extensions.FocusEvents,B.extensions.Tabindex,Me.Gapcursor,u.UniqueID.configure({types:["blockContainer","columnList","column"],setIdAttribute:e.setIdAttribute}),vt,Ie.Text,Lt,Dt,Ft,Pe.Link.extend({inclusive:!1}).configure({defaultProtocol:b.DEFAULT_LINK_PROTOCOL,protocols:te?[]:b.VALID_LINK_PROTOCOLS}),...Object.values(n.schema.styleSpecs).map(o=>o.implementation.mark.configure({editor:n})),Ht,wt,Ot,B.Extension.create({name:"OverrideEscape",addKeyboardShortcuts:()=>({Escape:()=>{var o;return(o=n.getExtension(c.SuggestionMenu))!=null&&o.shown()?!1:(n.blur(),!0)}})}),Rt,Ut.configure({editor:n,domAttributes:e.domAttributes}),_t.configure({editor:n,tabBehavior:e.tabBehavior}),Vt.configure({domAttributes:e.domAttributes}),...Object.values(n.schema.inlineContentSpecs).filter(o=>o.config!=="link"&&o.config!=="text").map(o=>o.implementation.node.configure({editor:n})),...Object.values(n.schema.blockSpecs).flatMap(o=>[..."node"in o.implementation?[o.implementation.node.configure({editor:n,domAttributes:e.domAttributes})]:[]]),It(n),Mt(n,e.pasteHandler||(o=>o.defaultPasteHandler())),lt(n)];return te=!0,t}function zt(n,e){var o;const t=[b.BlockChangeExtension(),b.DropCursorExtension(e),c.FilePanelExtension(e),b.FormattingToolbarExtension(e),b.LinkToolbarExtension(e),b.NodeSelectionKeyboardExtension(),b.PlaceholderExtension(e),we.ShowSelectionExtension(e),b.SideMenuExtension(e),c.SuggestionMenu(e),...e.trailingBlock!==!1?[b.TrailingNodeExtension()]:[]];return e.collaboration?(t.push(b.ForkYDocExtension(e.collaboration)),(o=e.collaboration.provider)!=null&&o.awareness&&t.push(b.YCursorExtension(e.collaboration)),t.push(b.YSyncExtension(e.collaboration)),t.push(b.YUndoExtension(e.collaboration)),t.push(b.SchemaMigration(e.collaboration))):t.push(b.HistoryExtension()),"table"in n.schema.blockSpecs&&t.push(b.TableHandlesExtension(e)),e.animations!==!1&&t.push(b.PreviousBlockTypeExtension()),t}class qt{constructor(e,t){k(this,"disabledExtensions",new Set);k(this,"extensions",[]);k(this,"abortMap",new Map);k(this,"extensionFactories",new Map);k(this,"extensionPlugins",new Map);this.editor=e,this.options=t,e.onMount(()=>{for(const o of this.extensions)if(o.mount){const r=new window.AbortController,i=o.mount({dom:e.prosemirrorView.dom,root:e.prosemirrorView.root,signal:r.signal});i&&r.signal.addEventListener("abort",()=>{i()}),this.abortMap.set(o,r)}}),e.onUnmount(()=>{for(const[o,r]of this.abortMap.entries())this.abortMap.delete(o),r.abort()}),this.disabledExtensions=new Set(t.disableExtensions||[]);for(const o of zt(this.editor,this.options))this.addExtension(o);for(const o of this.options.extensions??[])this.addExtension(o);for(const o of Object.values(this.editor.schema.blockSpecs))for(const r of o.extensions??[])this.addExtension(r)}registerExtension(e){var i;const t=[].concat(e).filter(Boolean);if(!t.length){console.warn("No extensions found to register",e);return}const o=t.map(s=>this.addExtension(s)).filter(Boolean),r=new Set;for(const s of o)s!=null&&s.tiptapExtensions&&console.warn(`Extension ${s.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.`,s),(i=s==null?void 0:s.inputRules)!=null&&i.length&&console.warn(`Extension ${s.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.`,s),this.getProsemirrorPluginsFromExtension(s).plugins.forEach(l=>{r.add(l)});this.updatePlugins(s=>[...s,...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 o=t[R.originalFactorySymbol];typeof o=="function"&&this.extensionFactories.set(o,t)}return this.extensions.push(t),t}}resolveExtensions(e){const t=[];if(typeof e=="function"){const o=this.extensionFactories.get(e);o&&t.push(o)}else if(Array.isArray(e))for(const o of e)t.push(...this.resolveExtensions(o));else if(typeof e=="object"&&"key"in e)t.push(e);else if(typeof e=="string"){const o=this.extensions.find(r=>r.key===e);o&&t.push(o)}return t}unregisterExtension(e){var i;const t=this.resolveExtensions(e);if(!t.length){console.warn("No extensions found to unregister",e);return}let o=!1;const r=new Set;for(const s of t){this.extensions=this.extensions.filter(a=>a!==s),this.extensionFactories.forEach((a,d)=>{a===s&&this.extensionFactories.delete(d)}),(i=this.abortMap.get(s))==null||i.abort(),this.abortMap.delete(s);const l=this.extensionPlugins.get(s);l==null||l.forEach(a=>{r.add(a)}),this.extensionPlugins.delete(s),s.tiptapExtensions&&!o&&(o=!0,console.warn(`Extension ${s.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(s=>s.filter(l=>!r.has(l)))}updatePlugins(e){const t=this.editor.prosemirrorState,o=t.reconfigure({plugins:e(t.plugins.slice())});this.editor.prosemirrorView.updateState(o)}getTiptapExtensions(){var r;const e=Gt(this.editor,this.options),t=M.sortByDependencies(this.extensions),o=new Map;for(const i of this.extensions){i.tiptapExtensions&&e.push(...i.tiptapExtensions);const s=t(i.key),{plugins:l,inputRules:a}=this.getProsemirrorPluginsFromExtension(i);l.length&&e.push(B.Extension.create({name:i.key,priority:s,addProseMirrorPlugins:()=>l})),a.length&&(o.has(s)||o.set(s,[]),o.get(s).push(...a))}e.push(B.Extension.create({name:"blocknote-input-rules",addProseMirrorPlugins(){const i=[];return Array.from(o.keys()).sort().reverse().forEach(s=>{i.push(...o.get(s))}),[K.inputRules({rules:i})]}}));for(const i of((r=this.options._tiptapOptions)==null?void 0:r.extensions)??[])e.push(i);return e}getProsemirrorPluginsFromExtension(e){var r,i,s;const t=[...e.prosemirrorPlugins??[]],o=[];return!((r=e.prosemirrorPlugins)!=null&&r.length)&&!Object.keys(e.keyboardShortcuts||{}).length&&!((i=e.inputRules)!=null&&i.length)?{plugins:t,inputRules:o}:(this.extensionPlugins.set(e,t),(s=e.inputRules)!=null&&s.length&&o.push(...e.inputRules.map(l=>new K.InputRule(l.find,(a,d,p,f)=>{const h=l.replace({match:d,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 m=u.getBlockInfoFromTransaction(a.tr),S=a.tr.deleteRange(p,f);return c.updateBlockTr(S,m.bnBlock.beforePos,h),S}return null}))),Object.keys(e.keyboardShortcuts||{}).length&&t.push(xe.keymap(Object.fromEntries(Object.entries(e.keyboardShortcuts).map(([l,a])=>[l,()=>a({editor:this.editor})])))),{plugins:t,inputRules:o})}getExtensions(){return new Map(this.extensions.map(e=>[e.key,e]))}getExtension(e){if(typeof e=="string"){const t=this.extensions.find(o=>o.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 jt(n){const e=u.getPmSchema(n);if(n.selection.empty||"node"in n.selection)return;const t=n.doc.resolve(u.getNearestBlockPos(n.doc,n.selection.from).posBeforeNode),o=n.doc.resolve(u.getNearestBlockPos(n.doc,n.selection.to).posBeforeNode),r=(d,p)=>{const f=t.posAtIndex(d,p),h=n.doc.resolve(f).nodeAfter;if(!h)throw new Error(`Error getting selection - node not found at position ${f}`);return u.nodeToBlock(h,e)},i=[],s=t.sharedDepth(o.pos),l=t.index(s),a=o.index(s);if(t.depth>s){i.push(u.nodeToBlock(t.nodeAfter,e));for(let d=t.depth;d>s;d--)if(t.node(d).type.isInGroup("childContainer")){const f=t.index(d)+1,h=t.node(d).childCount;for(let g=f;g<h;g++)i.push(r(g,d))}}else i.push(r(l,s));for(let d=l+1;d<=a;d++)i.push(r(d,s));if(i.length===0)throw new Error(`Error getting selection - selection doesn't span any blocks (${n.selection})`);return{blocks:i}}function Wt(n,e,t){const o=typeof e=="string"?e:e.id,r=typeof t=="string"?t:t.id,i=u.getPmSchema(n),s=u.getBlockNoteSchema(i);if(o===r)throw new Error(`Attempting to set selection with the same anchor and head blocks (id ${o})`);const l=c.getNodeById(o,n.doc);if(!l)throw new Error(`Block with ID ${o} not found`);const a=c.getNodeById(r,n.doc);if(!a)throw new Error(`Block with ID ${r} not found`);const d=u.getBlockInfo(l),p=u.getBlockInfo(a),f=s.blockSchema[d.blockNoteType],h=s.blockSchema[p.blockNoteType];if(!d.isBlockContainer||f.content==="none")throw new Error(`Attempting to set selection anchor in block without content (id ${o})`);if(!p.isBlockContainer||h.content==="none")throw new Error(`Attempting to set selection anchor in block without content (id ${r})`);let g,m;if(f.content==="table"){const S=A.TableMap.get(d.blockContent.node);g=d.blockContent.beforePos+S.positionAt(0,0,d.blockContent.node)+1+2}else g=d.blockContent.beforePos+1;if(h.content==="table"){const S=A.TableMap.get(p.blockContent.node),C=p.blockContent.beforePos+S.positionAt(S.height-1,S.width-1,p.blockContent.node)+1,T=n.doc.resolve(C).nodeAfter.nodeSize;m=C+T-2}else m=p.blockContent.afterPos-1;n.setSelection(y.TextSelection.create(n.doc,g,m))}function Kt(n){const e=u.getPmSchema(n);let t=n.selection.$from,o=n.selection.$to;for(;o.parentOffset>=o.parent.nodeSize-2&&o.depth>0;)o=n.doc.resolve(o.pos+1);for(;o.parentOffset===0&&o.depth>0;)o=n.doc.resolve(o.pos-1);for(;t.parentOffset===0&&t.depth>0;)t=n.doc.resolve(t.pos-1);for(;t.parentOffset>=t.parent.nodeSize-2&&t.depth>0;)t=n.doc.resolve(t.pos+1);const r=u.prosemirrorSliceToSlicedBlocks(n.doc.slice(t.pos,o.pos,!0),e);return{_meta:{startPos:t.pos,endPos:o.pos},...r}}function Yt(n){const{bnBlock:e}=u.getBlockInfoFromTransaction(n),t=u.getPmSchema(n.doc),o=n.doc.resolve(e.beforePos),r=o.nodeBefore,i=n.doc.resolve(e.afterPos).nodeAfter;let s;return o.depth>1&&(s=o.node(),s.type.isInGroup("bnBlock")||(s=o.node(o.depth-1))),{block:u.nodeToBlock(e.node,t),prevBlock:r===null?void 0:u.nodeToBlock(r,t),nextBlock:i===null?void 0:u.nodeToBlock(i,t),parentBlock:s===void 0?void 0:u.nodeToBlock(s,t)}}function Be(n,e,t="start"){const o=typeof e=="string"?e:e.id,r=u.getPmSchema(n.doc),i=u.getBlockNoteSchema(r),s=c.getNodeById(o,n.doc);if(!s)throw new Error(`Block with ID ${o} not found`);const l=u.getBlockInfo(s),a=i.blockSchema[l.blockNoteType].content;if(l.isBlockContainer){const d=l.blockContent;if(a==="none"){n.setSelection(y.NodeSelection.create(n.doc,d.beforePos));return}if(a==="inline")t==="start"?n.setSelection(y.TextSelection.create(n.doc,d.beforePos+1)):n.setSelection(y.TextSelection.create(n.doc,d.afterPos-1));else if(a==="table")t==="start"?n.setSelection(y.TextSelection.create(n.doc,d.beforePos+4)):n.setSelection(y.TextSelection.create(n.doc,d.afterPos-4));else throw new u.UnreachableCaseError(a)}else{const d=t==="start"?l.childContainer.node.firstChild:l.childContainer.node.lastChild;Be(n,d.attrs.id,t)}}class Jt{constructor(e){this.editor=e}getSelection(){return this.editor.transact(e=>jt(e))}getSelectionCutBlocks(){return this.editor.transact(e=>Kt(e))}setSelection(e,t){return this.editor.transact(o=>Wt(o,e,t))}getTextCursorPosition(){return this.editor.transact(e=>Yt(e))}setTextCursorPosition(e,t="start"){return this.editor.transact(o=>Be(o,e,t))}getSelectionBoundingBox(){if(!this.editor.prosemirrorView)return;const{selection:e}=this.editor.prosemirrorState,{ranges:t}=e,o=Math.min(...t.map(i=>i.$from.pos)),r=Math.max(...t.map(i=>i.$to.pos));if(B.isNodeSelection(e)){const i=this.editor.prosemirrorView.nodeDOM(o);if(i)return i.getBoundingClientRect()}return B.posToDOMRect(this.editor.prosemirrorView,o,r).toJSON()}}class Qt{constructor(e){k(this,"activeTransaction",null);k(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,o=this.prosemirrorView;return e(t,i=>this.prosemirrorView.dispatch(i),o)}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,o=this.prosemirrorView;return e(t,void 0,o)}transact(e){if(this.activeTransaction)return e(this.activeTransaction);try{this.activeTransaction=this.editor._tiptapEditor.state.tr;const t=e(this.activeTransaction),o=this.activeTransaction;return this.activeTransaction=null,o&&(o.docChanged||o.selectionSet||o.scrolledIntoView||o.storedMarksSet||!o.isGeneric)&&this.prosemirrorView.dispatch(o),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 Xt(n,e,t,o={updateSelection:!0}){let{from:r,to:i}=typeof e=="number"?{from:e,to:e}:{from:e.from,to:e.to},s=!0,l=!0,a="";if(t.forEach(d=>{d.check(),s&&d.isText&&d.marks.length===0?a+=d.text:s=!1,l=l?d.isBlock:!1}),r===i&&l){const{parent:d}=n.doc.resolve(r);d.isTextblock&&!d.type.spec.code&&!d.childCount&&(r-=1,i+=1)}return s?n.insertText(a,r,i):n.replaceWith(r,i,t),o.updateSelection&&B.selectionToInsertionEnd(n,n.steps.length-1,-1),!0}class Zt{constructor(e){this.editor=e}insertInlineContent(e,{updateSelection:t=!1}={}){const o=u.inlineContentToNodes(e,this.editor.pmSchema);this.editor.transact(r=>{Xt(r,{from:r.selection.from,to:r.selection.to},o,{updateSelection:t})})}getActiveStyles(){return this.editor.transact(e=>{const t={},o=e.selection.$to.marks();for(const r of o){const i=this.editor.schema.styleSchema[r.type.name];if(!i){r.type.name!=="link"&&!r.type.spec.blocknoteIgnore&&console.warn("mark not found in styleschema",r.type.name);continue}i.propSchema==="boolean"?t[i.type]=!0:t[i.type]=r.attrs.stringValue}return t})}addStyles(e){for(const[t,o]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:o});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,o]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:o});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 o=this.editor.pmSchema.mark("link",{href:e});this.editor.transact(r=>{const{from:i,to:s}=r.selection;t?r.insertText(t,i,s).addMark(i,i+t.length,o):r.setSelection(Le.TextSelection.create(r.doc,s)).addMark(i,s,o)})}}function eo(n,e){const t=[];return n.forEach((o,r,i)=>{i!==e&&t.push(o)}),N.Fragment.from(t)}function to(n,e){const t=[];for(let o=0;o<n.childCount;o++)if(n.child(o).type.name==="tableRow")if(t.length>0&&t[t.length-1].type.name==="table"){const r=t[t.length-1],i=r.copy(r.content.addToEnd(n.child(o)));t[t.length-1]=i}else{const r=e.nodes.table.createChecked(void 0,n.child(o));t.push(r)}else t.push(n.child(o));return n=N.Fragment.from(t),n}function oo(n,e){let t=N.Fragment.from(n.content);if(t=to(t,e.state.schema),!no(t,e))return new N.Slice(t,n.openStart,n.openEnd);for(let o=0;o<t.childCount;o++)if(t.child(o).type.spec.group==="blockContent"){const r=[t.child(o)];if(o+1<t.childCount&&t.child(o+1).type.name==="blockGroup"){const s=t.child(o+1).child(0).child(0);(s.type.name==="bulletListItem"||s.type.name==="numberedListItem"||s.type.name==="checkListItem")&&(r.push(t.child(o+1)),t=eo(t,o+1))}const i=e.state.schema.nodes.blockContainer.createChecked(void 0,r);t=t.replaceChild(o,i)}return new N.Slice(t,n.openStart,n.openEnd)}function no(n,e){var i,s;const t=n.childCount===1,o=((i=n.firstChild)==null?void 0:i.type.spec.content)==="inline*",r=((s=n.firstChild)==null?void 0:s.type.spec.content)==="tableRow+";if(t){if(o)return!1;if(r){const l=u.getBlockInfoFromSelection(e.state);if(l.isBlockContainer)return!(l.blockContent.node.type.spec.content==="tableRow+")}}return!0}const ro={enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!1};class W extends V.EventEmitter{constructor(t){var d,p,f,h,g,m,S,C,T,I;super();k(this,"pmSchema");k(this,"_tiptapEditor");k(this,"elementRenderer",null);k(this,"blockCache",new WeakMap);k(this,"dictionary");k(this,"schema");k(this,"blockImplementations");k(this,"inlineContentImplementations");k(this,"styleImplementations");k(this,"uploadFile");k(this,"onUploadStartCallbacks",[]);k(this,"onUploadEndCallbacks",[]);k(this,"resolveFileUrl");k(this,"settings");k(this,"_blockManager");k(this,"_eventManager");k(this,"_exportManager");k(this,"_extensionManager");k(this,"_selectionManager");k(this,"_stateManager");k(this,"_styleManager");k(this,"unregisterExtension",(...t)=>this._extensionManager.unregisterExtension(...t));k(this,"registerExtension",(...t)=>this._extensionManager.registerExtension(...t));k(this,"getExtension",(...t)=>this._extensionManager.getExtension(...t));k(this,"mount",t=>{this._tiptapEditor.mount({mount:t})});k(this,"unmount",()=>{this._tiptapEditor.unmount()});this.options=t,this.dictionary=t.dictionary||Ee.en,this.settings={tables:{splitCells:((d=t==null?void 0:t.tables)==null?void 0:d.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 o={defaultStyles:!0,schema:t.schema||M.BlockNoteSchema.create(),...t,placeholders:{...this.dictionary.placeholders,...t.placeholders}};if(this.schema=o.schema,this.blockImplementations=o.schema.blockSpecs,this.inlineContentImplementations=o.schema.inlineContentSpecs,this.styleImplementations=o.schema.styleSpecs,o.uploadFile){const E=o.uploadFile;this.uploadFile=async(w,P)=>{this.onUploadStartCallbacks.forEach(v=>v.apply(this,[P]));try{return await E(w,P)}finally{this.onUploadEndCallbacks.forEach(v=>v.apply(this,[P]))}}}this.resolveFileUrl=o.resolveFileUrl,this._eventManager=new Qe(this),this._extensionManager=new qt(this,o);const r=this._extensionManager.getTiptapExtensions(),i=this._extensionManager.hasExtension("ySync")||this._extensionManager.hasExtension("liveblocksExtension");i&&o.initialContent&&console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider");const s={...ro,...o._tiptapOptions,element:null,autofocus:o.autofocus??!1,extensions:r,editorProps:{...(g=o._tiptapOptions)==null?void 0:g.editorProps,attributes:{tabIndex:"0",...(S=(m=o._tiptapOptions)==null?void 0:m.editorProps)==null?void 0:S.attributes,...(C=o.domAttributes)==null?void 0:C.editor,class:c.mergeCSSClasses("bn-editor",o.defaultStyles?"bn-default-styles":"",((I=(T=o.domAttributes)==null?void 0:T.editor)==null?void 0:I.class)||"")},transformPasted:oo}};try{const E=o.initialContent||(i?[{type:"paragraph",id:"initialBlockId"}]:[{type:"paragraph",id:u.UniqueID.options.generateID()}]);if(!Array.isArray(E)||E.length===0)throw new Error("initialContent must be a non-empty array of blocks, received: "+E);const w=B.getSchema(s.extensions),P=E.map(Ce=>u.blockToNode(Ce,w,this.schema.styleSchema).toJSON()),v=B.createDocument({type:"doc",content:[{type:"blockGroup",content:P}]},w,s.parseOptions);this._tiptapEditor=new B.Editor({...s,content:v.toJSON()}),this.pmSchema=this._tiptapEditor.schema}catch(E){throw new Error("Error creating document from blocks passed as `initialContent`",{cause:E})}let l;const a=this.pmSchema.nodes.doc.createAndFill;this.pmSchema.nodes.doc.createAndFill=(...E)=>{if(l)return l;const w=a.apply(this.pmSchema.nodes.doc,E),P=JSON.parse(JSON.stringify(w.toJSON()));return P.content[0].content[0].attrs.id="initialBlockId",l=x.Node.fromJSON(this.pmSchema,P),l},this.pmSchema.cached.blockNoteEditor=this,this._blockManager=new Je(this),this._exportManager=new it(this),this._selectionManager=new Jt(this),this._stateManager=new Qt(this),this._styleManager=new Zt(this),this.emit("create")}static create(t){return new W(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 o=this.onUploadStartCallbacks.indexOf(t);o>-1&&this.onUploadStartCallbacks.splice(o,1)}}onUploadEnd(t){return this.onUploadEndCallbacks.push(t),()=>{const o=this.onUploadEndCallbacks.indexOf(t);o>-1&&this.onUploadEndCallbacks.splice(o,1)}}get topLevelBlocks(){return this.document}get document(){return this._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,o=!1){this._blockManager.forEachBlock(t,o)}onEditorContentChange(t){this._tiptapEditor.on("update",t)}onEditorSelectionChange(t){this._tiptapEditor.on("selectionUpdate",t)}onBeforeChange(t){var o;return(o=this._extensionManager.getExtension(b.BlockChangeExtension))==null?void 0:o.subscribe(t)}getTextCursorPosition(){return this._selectionManager.getTextCursorPosition()}setTextCursorPosition(t,o="start"){return this._selectionManager.setTextCursorPosition(t,o)}getSelection(){return this._selectionManager.getSelection()}getSelectionCutBlocks(){return this._selectionManager.getSelectionCutBlocks()}setSelection(t,o){return this._selectionManager.setSelection(t,o)}get isEditable(){return this._stateManager.isEditable}set isEditable(t){this._stateManager.isEditable=t}insertBlocks(t,o,r="before"){return this._blockManager.insertBlocks(t,o,r)}updateBlock(t,o){return this._blockManager.updateBlock(t,o)}removeBlocks(t){return this._blockManager.removeBlocks(t)}replaceBlocks(t,o){return this._blockManager.replaceBlocks(t,o)}undo(){return this._stateManager.undo()}redo(){return this._stateManager.redo()}insertInlineContent(t,{updateSelection:o=!1}={}){this._styleManager.insertInlineContent(t,{updateSelection:o})}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,o){this._styleManager.createLink(t,o)}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,o){return this._eventManager.onChange(t,o)}onSelectionChange(t,o){return this._eventManager.onSelectionChange(t,o)}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,o=!1){this._exportManager.pasteHTML(t,o)}pasteText(t){return this._exportManager.pasteText(t)}pasteMarkdown(t){return this._exportManager.pasteMarkdown(t)}}class so{constructor(e,t,o){this.mappings=t,this.options=o}async resolveFile(e){var o;if(!((o=this.options)!=null&&o.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(([o,r])=>this.mappings.styleMapping[o](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,o,r){return this.mappings.blockMapping[e.type](e,this,t,o,r)}}function io(n){return{createBlockMapping:e=>e,createInlineContentMapping:e=>e,createStyleMapping:e=>e}}function co(n,...e){const t=[...n];for(const o of e)for(const r of o){const i=t.findLastIndex(s=>s.group===r.group);i===-1?t.push(r):t.splice(i+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=c.COLORS_DARK_MODE_DEFAULT;exports.COLORS_DEFAULT=c.COLORS_DEFAULT;exports.EMPTY_CELL_HEIGHT=c.EMPTY_CELL_HEIGHT;exports.EMPTY_CELL_WIDTH=c.EMPTY_CELL_WIDTH;exports.FILE_AUDIO_ICON_SVG=c.FILE_AUDIO_ICON_SVG;exports.FILE_IMAGE_ICON_SVG=c.FILE_IMAGE_ICON_SVG;exports.FILE_VIDEO_ICON_SVG=c.FILE_VIDEO_ICON_SVG;exports.addDefaultPropsExternalHTML=c.addDefaultPropsExternalHTML;exports.addInlineContentAttributes=c.addInlineContentAttributes;exports.addInlineContentKeyboardShortcuts=c.addInlineContentKeyboardShortcuts;exports.addNodeAndExtensionsToSpec=c.addNodeAndExtensionsToSpec;exports.addStyleAttributes=c.addStyleAttributes;exports.applyNonSelectableBlockFix=c.applyNonSelectableBlockFix;exports.audioParse=c.audioParse;exports.audioRender=c.audioRender;exports.audioToExternalHTML=c.audioToExternalHTML;exports.blockHasType=c.blockHasType;exports.camelToDataKebab=c.camelToDataKebab;exports.captureCellAnchor=c.captureCellAnchor;exports.createAudioBlockConfig=c.createAudioBlockConfig;exports.createAudioBlockSpec=c.createAudioBlockSpec;exports.createBlockConfig=c.createBlockConfig;exports.createBlockSpec=c.createBlockSpec;exports.createBlockSpecFromTiptapNode=c.createBlockSpecFromTiptapNode;exports.createBulletListItemBlockConfig=c.createBulletListItemBlockConfig;exports.createBulletListItemBlockSpec=c.createBulletListItemBlockSpec;exports.createCheckListItemBlockSpec=c.createCheckListItemBlockSpec;exports.createCheckListItemConfig=c.createCheckListItemConfig;exports.createCodeBlockConfig=c.createCodeBlockConfig;exports.createCodeBlockSpec=c.createCodeBlockSpec;exports.createDefaultBlockDOMOutputSpec=c.createDefaultBlockDOMOutputSpec;exports.createDividerBlockConfig=c.createDividerBlockConfig;exports.createDividerBlockSpec=c.createDividerBlockSpec;exports.createFileBlockConfig=c.createFileBlockConfig;exports.createFileBlockSpec=c.createFileBlockSpec;exports.createHeadingBlockConfig=c.createHeadingBlockConfig;exports.createHeadingBlockSpec=c.createHeadingBlockSpec;exports.createImageBlockConfig=c.createImageBlockConfig;exports.createImageBlockSpec=c.createImageBlockSpec;exports.createInlineContentSpecFromTipTapNode=c.createInlineContentSpecFromTipTapNode;exports.createInternalInlineContentSpec=c.createInternalInlineContentSpec;exports.createInternalStyleSpec=c.createInternalStyleSpec;exports.createNumberedListItemBlockConfig=c.createNumberedListItemBlockConfig;exports.createNumberedListItemBlockSpec=c.createNumberedListItemBlockSpec;exports.createParagraphBlockConfig=c.createParagraphBlockConfig;exports.createParagraphBlockSpec=c.createParagraphBlockSpec;exports.createQuoteBlockConfig=c.createQuoteBlockConfig;exports.createQuoteBlockSpec=c.createQuoteBlockSpec;exports.createStyleSpec=c.createStyleSpec;exports.createStyleSpecFromTipTapMark=c.createStyleSpecFromTipTapMark;exports.createTableBlockSpec=c.createTableBlockSpec;exports.createToggleListItemBlockConfig=c.createToggleListItemBlockConfig;exports.createToggleListItemBlockSpec=c.createToggleListItemBlockSpec;exports.createToggleWrapper=c.createToggleWrapper;exports.createVideoBlockConfig=c.createVideoBlockConfig;exports.createVideoBlockSpec=c.createVideoBlockSpec;exports.defaultBlockSpecs=c.defaultBlockSpecs;exports.defaultBlockToHTML=c.defaultBlockToHTML;exports.defaultInlineContentSchema=c.defaultInlineContentSchema;exports.defaultInlineContentSpecs=c.defaultInlineContentSpecs;exports.defaultProps=c.defaultProps;exports.defaultStyleSchema=c.defaultStyleSchema;exports.defaultStyleSpecs=c.defaultStyleSpecs;exports.defaultToggledState=c.defaultToggledState;exports.editorHasBlockWithType=c.editorHasBlockWithType;exports.fileParse=c.fileParse;exports.filenameFromURL=c.filenameFromURL;exports.formatKeyboardShortcut=c.formatKeyboardShortcut;exports.getBackgroundColorAttribute=c.getBackgroundColorAttribute;exports.getBlockFromPos=c.getBlockFromPos;exports.getInlineContentSchemaFromSpecs=c.getInlineContentSchemaFromSpecs;exports.getLanguageId=c.getLanguageId;exports.getNodeById=c.getNodeById;exports.getParseRules=c.getParseRules;exports.getStyleParseRules=c.getStyleParseRules;exports.getStyleSchemaFromSpecs=c.getStyleSchemaFromSpecs;exports.getTextAlignmentAttribute=c.getTextAlignmentAttribute;exports.getTextColorAttribute=c.getTextColorAttribute;exports.imageParse=c.imageParse;exports.imageRender=c.imageRender;exports.imageToExternalHTML=c.imageToExternalHTML;exports.isAppleOS=c.isAppleOS;exports.isNodeBlock=c.isNodeBlock;exports.isSafari=c.isSafari;exports.isTableCellSelection=c.isTableCellSelection;exports.isVideoUrl=c.isVideoUrl;exports.mergeCSSClasses=c.mergeCSSClasses;exports.mergeParagraphs=c.mergeParagraphs;exports.parseAudioElement=c.parseAudioElement;exports.parseDefaultProps=c.parseDefaultProps;exports.propsToAttributes=c.propsToAttributes;exports.stylePropsToAttributes=c.stylePropsToAttributes;exports.tablePropSchema=c.tablePropSchema;exports.trackPosition=c.trackPosition;exports.updateBlock=c.updateBlock;exports.updateBlockCommand=c.updateBlockCommand;exports.updateBlockTr=c.updateBlockTr;exports.videoParse=c.videoParse;exports.wrapInBlockStructure=c.wrapInBlockStructure;exports.blocksToMarkdown=b.blocksToMarkdown;exports.cleanHTMLToMarkdown=b.cleanHTMLToMarkdown;exports.createExternalHTMLExporter=b.createExternalHTMLExporter;exports.getBlocksChangedByTransaction=b.getBlocksChangedByTransaction;exports.BlockNoteSchema=M.BlockNoteSchema;exports.CustomBlockNoteSchema=M.CustomBlockNoteSchema;exports.checkPageBreakBlocksInSchema=M.checkPageBreakBlocksInSchema;exports.createPageBreakBlockConfig=M.createPageBreakBlockConfig;exports.createPageBreakBlockSpec=M.createPageBreakBlockSpec;exports.getPageBreakSlashMenuItems=M.getPageBreakSlashMenuItems;exports.uploadToTmpFilesDotOrg_DEV_ONLY=M.uploadToTmpFilesDotOrg_DEV_ONLY;exports.withPageBreak=M.withPageBreak;exports.EventEmitter=V.EventEmitter;exports.createExtension=R.createExtension;exports.createStore=R.createStore;exports.BlockNoteEditor=W;exports.Exporter=so;exports.HTMLToBlocks=G;exports.combineByGroup=co;exports.createInlineContentSpec=$e;exports.createInternalHTMLSerializer=ce;exports.fixColumnList=D;exports.getBlock=fe;exports.getInlineContentParseRules=oe;exports.getNextBlock=me;exports.getParentBlock=ke;exports.getPrevBlock=he;exports.insertBlocks=ne;exports.isEmptyColumn=L;exports.mappingFactory=io;exports.markdownToBlocks=ge;exports.markdownToHTML=z;exports.removeAndInsertBlocks=H;exports.removeEmptyColumns=re;exports.selectedFragmentToHTML=j;
|
|
1
|
+
"use strict";var Te=Object.defineProperty;var Ee=(o,e,t)=>e in o?Te(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var k=(o,e,t)=>Ee(o,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("prosemirror-model"),_=require("prosemirror-transform"),u=require("./blockToNode-CumVjgem.cjs"),c=require("./defaultBlocks-D1cc0lV9.cjs"),b=require("./TrailingNode-DPu6X9ym.cjs"),M=require("./BlockNoteSchema-CzZbr4Ed.cjs"),B=require("@tiptap/core"),R=require("./EventEmitter-CLwfmbqG.cjs"),N=require("@tiptap/pm/model"),xe=require("./en-Cl87Uuyf.cjs"),K=require("@handlewithcare/prosemirror-inputrules"),Me=require("@tiptap/pm/keymap"),F=require("./BlockNoteExtension-BWw0r8Gy.cjs"),Pe=require("@tiptap/extension-gapcursor"),Ie=require("@tiptap/extension-link"),we=require("@tiptap/extension-text"),y=require("prosemirror-state"),A=require("prosemirror-tables"),ve=require("./ShowSelection-BW37oJ6h.cjs"),Ne=require("remark-gfm"),Ae=require("remark-parse"),H=require("remark-rehype"),_e=require("rehype-stringify"),Le=require("unified"),De=require("@tiptap/pm/state"),O=o=>o&&typeof o=="object"&&"default"in o?o:{default:o},Fe=O(Ne),Oe=O(Ae),He=O(H),$e=O(_e);function oe(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 Ue(o,e){var n;const t=B.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 c.propsToAttributes(o.propSchema)},addKeyboardShortcuts(){return c.addInlineContentKeyboardShortcuts(o)},parseHTML(){return oe(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 c.addInlineContentAttributes(i,o.type,r.attrs,o.propSchema)},addNodeView(){return r=>{const{node:s,getPos:i}=r,l=this.options.editor,a=e.render.call({renderType:"nodeView",props:r},u.nodeToCustomInlineContent(s,l.schema.inlineContentSchema,l.schema.styleSchema),d=>{const p=u.inlineContentToNodes([d],l.pmSchema),f=i();f&&l.transact(h=>h.replaceWith(f,f+s.nodeSize,p))},l);return c.addInlineContentAttributes(a,o.type,s.attrs,o.propSchema)}}});return c.createInlineContentSpecFromTipTapNode(t,o.propSchema,{...e,toExternalHTML:e.toExternalHTML,render(r,s,i){const l=e.render(r,s,i);return c.addInlineContentAttributes(l,o.type,r.props,o.propSchema)}})}function ne(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)),l=c.getNodeById(r,o.doc);if(!l)throw new Error(`Block with ID ${r} not found`);let a=l.posBeforeNode;return n==="after"&&(a+=l.node.nodeSize),o.step(new _.ReplaceStep(a,a,new x.Slice(x.Fragment.from(i),0,0))),i.map(p=>u.nodeToBlock(p,s))}function L(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 re(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),l=o.doc.resolve(s).nodeAfter;if(!l||l.type.name!=="column")throw new Error("Invalid columnPos: does not point to column node.");L(l)&&o.delete(s,s+l.nodeSize)}}function D(o,e){re(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,l=e+n.nodeSize-1,d=o.doc.resolve(l).nodeBefore;if(!i||!d)throw new Error("Invalid columnList: does not contain children.");const p=L(i),f=L(d);if(p&&f){o.delete(e,e+n.nodeSize);return}if(p){o.step(new _.ReplaceAroundStep(e,e+n.nodeSize,l-d.nodeSize+1,l-1,x.Slice.empty,0,!1));return}if(f){o.step(new _.ReplaceAroundStep(e,e+n.nodeSize,r+1,r+i.nodeSize-1,x.Slice.empty,0,!1));return}}function $(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=[],l=new Set,a=typeof e[0]=="string"?e[0]:e[0].id;let d=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===a){const C=o.doc.nodeSize;o.insert(h,r);const T=o.doc.nodeSize;d+=C-T}const g=o.doc.nodeSize,m=o.doc.resolve(h-d);m.node().type.name==="column"?l.add(m.before(-1)):m.node().type.name==="columnList"&&l.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-d,h-d+f.nodeSize);const S=o.doc.nodeSize;return d+=g-S,!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 l.forEach(f=>D(o,f)),{insertedBlocks:r.map(f=>u.nodeToBlock(f,n)),removedBlocks:i}}function Ve(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 l=((r==null?void 0:r.document)??document).createDocumentFragment();for(const a of s)if(a.type.name!=="text"&&o.schema.inlineContentSchema[a.type.name]){const d=o.schema.inlineContentSpecs[a.type.name].implementation;if(d){const p=u.nodeToCustomInlineContent(a,o.schema.inlineContentSchema,o.schema.styleSchema),f=d.render.call({renderType:"dom",props:void 0},p,()=>{},o);if(f){if(l.appendChild(f.dom),f.contentDOM){const h=t.serializeFragment(a.content,r);f.contentDOM.dataset.editable="",f.contentDOM.appendChild(h)}continue}}}else if(a.type.name==="text"){let d=document.createTextNode(a.textContent);for(const p of a.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(d),d=f.dom}else{const f=p.type.spec.toDOM(p,!0),h=x.DOMSerializer.renderSpec(document,f);h.contentDOM.appendChild(d),d=h.dom}l.appendChild(d)}else{const d=t.serializeFragment(x.Fragment.from([a]),r);l.appendChild(d)}return l}function Re(o,e,t,n){var f,h,g,m,S;const r=o.pmSchema.nodes.blockContainer,s=e.props||{};for(const[C,T]of Object.entries(o.schema.blockSchema[e.type].propSchema))!(C in s)&&T.default!==void 0&&(s[C]=T.default);const i=e.children||[],a=o.blockImplementations[e.type].implementation.render.call({renderType:"dom",props:void 0},{...e,props:s,children:i},o);if(a.contentDOM&&e.content){const C=Ve(o,e.content,t,e.type,n);a.contentDOM.appendChild(C)}if(o.pmSchema.nodes[e.type].isInGroup("bnBlock")){if(e.children&&e.children.length>0){const C=se(o,e.children,t,n);(f=a.contentDOM)==null||f.append(C)}return a.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(m=p.contentDOM)==null||m.appendChild(a.dom),e.children&&e.children.length>0&&((S=p.contentDOM)==null||S.appendChild(ie(o,e.children,t,n))),p.dom}function se(o,e,t,n){const s=((n==null?void 0:n.document)??document).createDocumentFragment();for(const i of e){const l=Re(o,i,t,n);s.appendChild(l)}return s}const ie=(o,e,t,n)=>{var l;const r=o.pmSchema.nodes.blockGroup,s=r.spec.toDOM(r.create({})),i=se(o,e,t,n);return(l=s.contentDOM)==null||l.appendChild(i),s.dom},ce=(o,e)=>{const t=x.DOMSerializer.fromSchema(o);return{serializeBlocks:(n,r)=>ie(e,n,t,r).outerHTML}};function ze(o){return o.transact(e=>{const t=u.getNearestBlockPos(e.doc,e.selection.anchor);if(e.selection instanceof A.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 y.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 Ge(o,e){var r,s;const t=(r=c.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=A.CellSelection.create(o.doc,t+e.anchorCellOffset,t+e.headCellOffset);else if(e.type==="node")n=y.NodeSelection.create(o.doc,t+1);else{const i=(s=c.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=y.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=ze(o);o.removeBlocks(r),o.insertBlocks(U(r),e,t),Ge(n,s)})}function le(o){return!o||o.type!=="columnList"}function de(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 le(s)?{referenceBlock:n,placement:r}:de(o,r==="after"?n:o.getPrevBlock(n),s)}function ue(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 le(s)?{referenceBlock:n,placement:r}:ue(o,r==="before"?n:o.getNextBlock(n),s)}function qe(o){o.transact(()=>{const e=o.getSelection(),t=(e==null?void 0:e.blocks[0])||o.getTextCursorPosition().block,n=de(o,o.getPrevBlock(t),o.getParentBlock(t));n&&ae(o,n.referenceBlock,n.placement)})}function je(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=ue(o,o.getNextBlock(t),o.getParentBlock(t));n&&ae(o,n.referenceBlock,n.placement)})}function We(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 a=s.parent.child(i-1);if(a.type!==e)return!1;const d=a.lastChild&&a.lastChild.type===t,p=x.Fragment.from(d?e.create():null),f=new x.Slice(x.Fragment.from(e.create(null,x.Fragment.from(t.create(null,p)))),d?3:1,0),h=s.start,g=s.end;return o.step(new _.ReplaceAroundStep(h-(d?3:1),g,h,g,f,1,!0)).scrollIntoView(),!0}function pe(o){return o.transact(e=>We(e,o.pmSchema.nodes.blockContainer,o.pmSchema.nodes.blockGroup))}function Ke(o){o._tiptapEditor.commands.liftListItem("blockContainer")}function Ye(o){return o.transact(e=>{const{bnBlock:t}=u.getBlockInfoFromTransaction(e);return e.doc.resolve(t.beforePos).nodeBefore!==null})}function Je(o){return o.transact(e=>{const{bnBlock:t}=u.getBlockInfoFromTransaction(e);return e.doc.resolve(t.beforePos).depth>1})}function fe(o,e){const t=typeof e=="string"?e:e.id,n=u.getPmSchema(o),r=c.getNodeById(t,o);if(r)return u.nodeToBlock(r.node,n)}function he(o,e){const t=typeof e=="string"?e:e.id,n=c.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 me(o,e){const t=typeof e=="string"?e:e.id,n=c.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 ke(o,e){const t=typeof e=="string"?e:e.id,n=u.getPmSchema(o),r=c.getNodeById(t,o);if(!r)return;const s=o.resolve(r.posBeforeNode),i=s.node(),l=s.node(-1),a=l.type.name!=="doc"?i.type.name==="blockGroup"?l:i:void 0;if(a)return u.nodeToBlock(a,n)}class Qe{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=>fe(t.doc,e))}getPrevBlock(e){return this.editor.transact(t=>he(t.doc,e))}getNextBlock(e){return this.editor.transact(t=>me(t.doc,e))}getParentBlock(e){return this.editor.transact(t=>ke(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 l=t?i.children.slice().reverse():i.children;if(!r(l))return!1}return!0}r(n)}insertBlocks(e,t,n="before"){return this.editor.transact(r=>ne(r,e,t,n))}updateBlock(e,t){return this.editor.transact(n=>c.updateBlock(n,e,t))}removeBlocks(e){return this.editor.transact(t=>$(t,e,[]).removedBlocks)}replaceBlocks(e,t){return this.editor.transact(n=>$(n,e,t))}canNestBlock(){return Ye(this.editor)}nestBlock(){pe(this.editor)}canUnnestBlock(){return Je(this.editor)}unnestBlock(){Ke(this.editor)}moveBlocksUp(){return qe(this.editor)}moveBlocksDown(){return je(this.editor)}}class Xe extends R.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&&Y(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&&Y(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 Y(o){return!!o.getMeta("y-sync$")}function Ze(o){return Array.prototype.indexOf.call(o.parentElement.childNodes,o)}function et(o){return o.nodeType===3&&!/\S/.test(o.nodeValue||"")}function tt(o){o.querySelectorAll("li > ul, li > ol").forEach(e=>{const t=Ze(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(et(s))return;const i=document.createElement("li");i.append(s),e.insertAdjacentElement("afterend",i)}),n.childNodes.length===0&&n.remove()})}function ot(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 J=null;function nt(){return J||(J=document.implementation.createHTMLDocument("title"))}function rt(o){if(typeof o=="string"){const e=nt().createElement("div");e.innerHTML=o,o=e}return tt(o),ot(o),o}function z(o,e){const t=rt(o),r=x.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 st(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 it(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 G(o){return Le.unified().use(Oe.default).use(Fe.default).use(He.default,{handlers:{...H.defaultHandlers,image:(t,n)=>{const r=String((n==null?void 0:n.url)||"");return c.isVideoUrl(r)?it(t,n):H.defaultHandlers.image(t,n)},code:st,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($e.default).processSync(o).value}function ge(o,e){const t=G(o);return z(t,e)}class ct{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 ce(this.editor.pmSchema,this.editor).serializeBlocks(e,{})}tryParseHTMLToBlocks(e){return z(e,this.editor.pmSchema)}blocksToMarkdownLossy(e=this.editor.document){return b.blocksToMarkdown(e,this.editor.pmSchema,this.editor,{})}tryParseMarkdownToBlocks(e){return ge(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=G(e);return this.pasteHTML(t)}}const q=["vscode-editor-data","blocknote/html","text/markdown","text/html","text/plain","Files"];function at(o,e){if(!o.startsWith(".")||!e.startsWith("."))throw new Error("The strings provided are not valid file extensions.");return o===e}function lt(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 Q(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 q)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 l="file";for(const d of Object.values(e.schema.blockSpecs))for(const p of((s=d.implementation.meta)==null?void 0:s.fileBlockAccept)||[]){const f=p.startsWith("."),h=r[i].getAsFile();if(h&&(!f&&h.type&<(r[i].type,p)||f&&at("."+h.name.split(".").pop(),p))){l=d.config.type;break}}const a=r[i].getAsFile();if(a){const d={type:l,props:{name:a.name}};let p;if(o.type==="paste"){const g=e.getTextCursorPosition().block;p=Q(e,g,d)}else if(o.type==="drop"){const g={left:o.clientX,top:o.clientY},m=e.prosemirrorView.posAtCoords(g);if(!m)return;p=e.transact(S=>{var E;const C=u.getNearestBlockPos(S.doc,m.pos),T=(E=e.domElement)==null?void 0:E.querySelector(`[data-id="${C.node.attrs.id}"]`),I=T==null?void 0:T.getBoundingClientRect();return Q(e,e.getBlock(C.node.attrs.id),d,I&&(I.top+I.bottom)/2>g.top?"before":"after")})}else return;const f=await e.uploadFile(a,p),h=typeof f=="string"?{props:{url:f}}:{...f};e.updateBlock(p,h)}}}}const dt=o=>B.Extension.create({name:"dropFile",addProseMirrorPlugins(){return[new y.Plugin({props:{handleDOMEvents:{drop(e,t){if(!o.isEditable)return;let n=null;for(const r of q)if(t.dataTransfer.types.includes(r)){n=r;break}return n===null?!0:n==="Files"?(be(t,o),!0):!1}}}})]}}),ut=/(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/,pt=/(_|__|\*|\*\*|~~|==|\+\+)(?!\s)(?:[^\s](?:.{0,62}[^\s])?|\S)(?=\1)/,ft=/\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/,ht=/(?:\s|^)`(?!\s)(?:[^\s`](?:[^`]{0,46}[^\s`])?|[^\s`])`([^\w]|$)/,mt=/(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/,kt=/(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/,gt=/\n{2} {0,3}-{2,48}\n{2}/,bt=/(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/,St=/(?:\n|^)(?!\s)\w[^\n]{0,64}\r?\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/,Bt=/(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/,Ct=/^\s*\|(.+\|)+\s*$/m,yt=/^\s*\|(\s*[-:]+[-:]\s*\|)+\s*$/m,Tt=/^\s*\|(.+\|)+\s*$/m,Et=o=>ut.test(o)||pt.test(o)||ft.test(o)||ht.test(o)||mt.test(o)||kt.test(o)||gt.test(o)||bt.test(o)||St.test(o)||Bt.test(o)||Ct.test(o)||yt.test(o)||Tt.test(o);async function xt(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 Mt({event:o,editor:e,prioritizeMarkdownOverHTML:t,plainTextAsMarkdown:n}){var l;if(e.transact(a=>a.selection.$from.parent.type.spec.code&&a.selection.$to.parent.type.spec.code)){const a=(l=o.clipboardData)==null?void 0:l.getData("text/plain");if(a)return e.pasteText(a),!0}let s;for(const a of q)if(o.clipboardData.types.includes(a)){s=a;break}if(!s)return!0;if(s==="vscode-editor-data")return xt(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 a=o.clipboardData.getData("text/plain");if(Et(a))return e.pasteMarkdown(a),!0}return s==="text/html"?(e.pasteHTML(i),!0):n?(e.pasteMarkdown(i),!0):(e.pasteText(i),!0)}const Pt=(o,e)=>B.Extension.create({name:"pasteFromClipboard",addProseMirrorPlugins(){return[new y.Plugin({props:{handleDOMEvents:{paste(t,n){if(n.preventDefault(),!!o.isEditable)return e({event:n,editor:o,defaultPasteHandler:({prioritizeMarkdownOverHTML:r=!0,plainTextAsMarkdown:s=!0}={})=>Mt({event:n,editor:o,prioritizeMarkdownOverHTML:r,plainTextAsMarkdown:s})})}}}})]}});function It(o,e,t){var l;let n=!1;const r=o.state.selection instanceof A.CellSelection;if(!r){const a=o.state.doc.slice(o.state.selection.from,o.state.selection.to,!1).content,d=[];for(let p=0;p<a.childCount;p++)d.push(a.child(p));n=d.find(p=>p.type.isInGroup("bnBlock")||p.type.name==="blockGroup"||p.type.spec.group==="blockContent")===void 0,n&&(e=a)}let s;const i=b.createExternalHTMLExporter(o.state.schema,t);if(r){((l=e.firstChild)==null?void 0:l.type.name)==="table"&&(e=e.firstChild.content);const a=u.contentNodeToTableContent(e,t.schema.inlineContentSchema,t.schema.styleSchema);s=`<table>${i.exportInlineContent(a,{})}</table>`}else if(n){const a=u.contentNodeToInlineContent(e,t.schema.inlineContentSchema,t.schema.styleSchema);s=i.exportInlineContent(a,{})}else{const a=b.fragmentToBlocks(e);s=i.exportBlocks(a,{})}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 y.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=It(o,n,e),s=b.cleanHTMLToMarkdown(r);return{clipboardHTML:t,externalHTML:r,markdown:s}}const X=()=>{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},Z=(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)},wt=o=>B.Extension.create({name:"copyToClipboard",addProseMirrorPlugins(){return[new y.Plugin({props:{handleDOMEvents:{copy(e,t){return X()||Z(o,e,t),!0},cut(e,t){return X()||(Z(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 y.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}}}})]}}),vt=B.Extension.create({name:"blockBackgroundColor",addGlobalAttributes(){return[{types:["tableCell","tableHeader"],attributes:{backgroundColor:c.getBackgroundColorAttribute()}}]}}),Nt=B.Node.create({name:"hardBreak",inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,priority:10,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:o}){return["br",B.mergeAttributes(this.options.HTMLAttributes,o)]},renderText(){return`
|
|
4
|
+
`}}),V=(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))},Se=(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},At=(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*",_t=(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 l=o.doc.resolve(n.bnBlock.beforePos);o.tr.lift(i,l.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},ee=o=>({state:e,dispatch:t})=>{const n=e.doc.resolve(o),r=u.getBlockInfoFromResolvedPos(n),s=V(e.doc,r.bnBlock.beforePos);if(!s)return!1;const i=Se(e.doc,s);return At(i,r)?_t(e,t,i,r):!1},Lt=B.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 l=s.selection.from===i.blockContent.beforePos+1,a=i.blockContent.node.type.name==="paragraph";return l&&!a?r.command(c.updateBlockCommand(i.bnBlock.beforePos,{type:"paragraph",props:{}})):!1}),()=>r.command(({state:s})=>{const i=u.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;const{blockContent:l}=i;return s.selection.from===l.beforePos+1?r.liftListItem("blockContainer"):!1}),()=>r.command(({state:s})=>{const i=u.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;const{bnBlock:l,blockContent:a}=i,d=s.selection.from===a.beforePos+1,p=s.selection.empty,f=l.beforePos;return d&&p?n().command(ee(f)).scrollIntoView().run():!1}),()=>r.command(({state:s,tr:i,dispatch:l})=>{const a=u.getBlockInfoFromSelection(s);if(!a.isBlockContainer||!(i.selection.from===a.blockContent.beforePos+1))return!1;const p=i.doc.resolve(a.bnBlock.beforePos);if(p.nodeBefore||p.node().type.name!=="column")return!1;const g=i.doc.resolve(a.bnBlock.beforePos),m=i.doc.resolve(g.before()),S=m.before();if(l){const C=i.doc.slice(a.bnBlock.beforePos,a.bnBlock.afterPos).content;i.delete(a.bnBlock.beforePos,a.bnBlock.afterPos),m.index()===0?(D(i,S),i.insert(S,C),i.setSelection(y.TextSelection.near(i.doc.resolve(S)))):(i.insert(m.pos-1,C),i.setSelection(y.TextSelection.near(i.doc.resolve(m.pos-1))),D(i,S))}return!0}),()=>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 a=V(s.doc,i.bnBlock.beforePos);if(!a||!a.isBlockContainer)return!1;let d=n();if(a.blockContent.node.type.spec.content==="tableRow+"){const m=i.bnBlock.beforePos-1-1-1-1-1;d=d.setTextSelection(m)}else if(a.blockContent.node.type.spec.content===""){const p=a.blockContent.afterPos-a.blockContent.node.nodeSize;d=d.setNodeSelection(p)}else{const p=a.blockContent.afterPos-a.blockContent.node.nodeSize;d=d.setTextSelection(p)}return d.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)throw new Error("todo");const l=s.selection.from===i.blockContent.beforePos+1,a=s.selection.empty,d=V(s.doc,i.bnBlock.beforePos);if(d&&l&&a){const p=Se(s.doc,d);if(!p.isBlockContainer)throw new Error("todo");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(({commands:n})=>[()=>n.deleteSelection(),()=>n.command(({state:r})=>{const s=u.getBlockInfoFromSelection(r);if(!s.isBlockContainer)return!1;const{bnBlock:i,blockContent:l,childContainer:a}=s,{depth:d}=r.doc.resolve(i.beforePos),p=i.afterPos===r.doc.nodeSize-3,f=r.selection.from===l.afterPos-1,h=r.selection.empty;if(!p&&f&&h&&!(a!==void 0)){let m=d,S=i.afterPos+1,C=r.doc.resolve(S).depth;for(;C<m;)m=C,S+=2,C=r.doc.resolve(S).depth;return n.command(ee(S-1))}return!1})]),t=(n=!1)=>this.editor.commands.first(({commands:r,tr:s})=>[()=>r.command(({state:i})=>{const l=u.getBlockInfoFromSelection(i);if(!l.isBlockContainer)return!1;const{bnBlock:a,blockContent:d}=l,{depth:p}=i.doc.resolve(a.beforePos),f=i.selection.$anchor.parentOffset===0,h=i.selection.anchor===i.selection.head,g=d.node.childCount===0,m=p>1;return f&&h&&g&&m?r.liftListItem("blockContainer"):!1}),()=>r.command(({state:i})=>{var d;const l=u.getBlockInfoFromSelection(i),a=((d=this.options.editor.schema.blockSchema[l.blockNoteType].meta)==null?void 0:d.hardBreakShortcut)??"shift+enter";if(a==="none")return!1;if(a==="shift+enter"&&n||a==="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:l})=>{const a=u.getBlockInfoFromSelection(i);if(!a.isBlockContainer)return!1;const{bnBlock:d,blockContent:p}=a,f=i.selection.$anchor.parentOffset===0,h=i.selection.anchor===i.selection.head,g=p.node.childCount===0;if(f&&h&&g){const m=d.afterPos,S=m+2;if(l){const C=i.schema.nodes.blockContainer.createAndFill();i.tr.insert(m,C).scrollIntoView(),i.tr.setSelection(new y.TextSelection(i.doc.resolve(S)))}return!0}return!1}),()=>r.command(({state:i,chain:l})=>{const a=u.getBlockInfoFromSelection(i);if(!a.isBlockContainer)return!1;const{blockContent:d}=a,p=i.selection.$anchor.parentOffset===0;return d.node.childCount===0?!1:(l().deleteSelection().command(c.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(c.FilePanelExtension))==null?void 0:r.store.state)!==void 0)?!1:pe(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(c.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()}}}),Dt=B.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}}]}}}),Ft=B.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}}]}}}),Ot=B.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}}]}}}),Ht=B.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}}}}]}}),$t=B.Extension.create({name:"blockTextColor",addGlobalAttributes(){return[{types:["table","tableCell","tableHeader"],attributes:{textColor:c.getTextColorAttribute()}}]}}),Ut={blockColor:"data-block-color",blockStyle:"data-block-style",id:"data-id",depth:"data-depth",depthChange:"data-depth-change"},Vt=B.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(Ut))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=c.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}}}),Rt=B.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=c.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}}}),zt=B.Node.create({name:"doc",topNode:!0,content:"blockGroup",marks:"insertion modification deletion"}),Gt=F.createExtension(({options:o})=>({key:"collaboration",blockNoteExtensions:[b.ForkYDocExtension(o),b.YCursorExtension(o),b.YSyncExtension(o),b.YUndoExtension(),b.SchemaMigration(o)]}));let te=!1;function qt(o,e){const t=[B.extensions.ClipboardTextSerializer,B.extensions.Commands,B.extensions.Editable,B.extensions.FocusEvents,B.extensions.Tabindex,Pe.Gapcursor,u.UniqueID.configure({types:["blockContainer","columnList","column"],setIdAttribute:e.setIdAttribute}),Nt,we.Text,Dt,Ft,Ot,Ie.Link.extend({inclusive:!1}).configure({defaultProtocol:b.DEFAULT_LINK_PROTOCOL,protocols:te?[]:b.VALID_LINK_PROTOCOLS}),...Object.values(o.schema.styleSpecs).map(n=>n.implementation.mark.configure({editor:o})),$t,vt,Ht,B.Extension.create({name:"OverrideEscape",addKeyboardShortcuts:()=>({Escape:()=>{var n;return(n=o.getExtension(c.SuggestionMenu))!=null&&n.shown()?!1:(o.blur(),!0)}})}),zt,Vt.configure({editor:o,domAttributes:e.domAttributes}),Lt.configure({editor:o,tabBehavior:e.tabBehavior}),Rt.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})]:[]]),wt(o),Pt(o,e.pasteHandler||(n=>n.defaultPasteHandler())),dt(o)];return te=!0,t}function jt(o,e){const t=[b.BlockChangeExtension(),b.DropCursorExtension(e),c.FilePanelExtension(e),b.FormattingToolbarExtension(e),b.LinkToolbarExtension(e),b.NodeSelectionKeyboardExtension(),b.PlaceholderExtension(e),ve.ShowSelectionExtension(e),b.SideMenuExtension(e),c.SuggestionMenu(e),...e.trailingBlock!==!1?[b.TrailingNodeExtension()]:[]];return e.collaboration?t.push(Gt(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 Wt{constructor(e,t){k(this,"disabledExtensions",new Set);k(this,"extensions",[]);k(this,"abortMap",new Map);k(this,"extensionFactories",new Map);k(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 jt(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(l=>{r.add(l)});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[F.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(a=>a!==i),this.extensionFactories.forEach((a,d)=>{a===i&&this.extensionFactories.delete(d)}),(s=this.abortMap.get(i))==null||s.abort(),this.abortMap.delete(i);const l=this.extensionPlugins.get(i);l==null||l.forEach(a=>{r.add(a)}),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(l=>!r.has(l)))}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=qt(this.editor,this.options).filter(s=>!this.disabledExtensions.has(s.name)),t=M.sortByDependencies(this.extensions),n=new Map;for(const s of this.extensions){s.tiptapExtensions&&e.push(...s.tiptapExtensions);const i=t(s.key),{plugins:l,inputRules:a}=this.getProsemirrorPluginsFromExtension(s);l.length&&e.push(B.Extension.create({name:s.key,priority:i,addProseMirrorPlugins:()=>l})),a.length&&(n.has(i)||n.set(i,[]),n.get(i).push(...a))}e.push(B.Extension.create({name:"blocknote-input-rules",addProseMirrorPlugins(){const s=[];return Array.from(n.keys()).sort().reverse().forEach(i=>{s.push(...n.get(i))}),[K.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(l=>new K.InputRule(l.find,(a,d,p,f)=>{const h=l.replace({match:d,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 m=u.getBlockInfoFromTransaction(a.tr),S=a.tr.deleteRange(p,f);return c.updateBlockTr(S,m.bnBlock.beforePos,h),S}return null}))),Object.keys(e.keyboardShortcuts||{}).length&&t.push(Me.keymap(Object.fromEntries(Object.entries(e.keyboardShortcuts).map(([l,a])=>[l,()=>a({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 Be(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 Kt(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=(d,p)=>{const f=t.posAtIndex(d,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),l=t.index(i),a=n.index(i);if(t.depth>i){s.push(u.nodeToBlock(t.nodeAfter,e));for(let d=t.depth;d>i;d--)if(t.node(d).type.isInGroup("childContainer")){const f=t.index(d)+1,h=t.node(d).childCount;for(let g=f;g<h;g++)s.push(r(g,d))}}else s.push(r(l,i));for(let d=l+1;d<=a;d++)s.push(r(d,i));if(s.length===0)throw new Error(`Error getting selection - selection doesn't span any blocks (${o.selection})`);return{blocks:s}}function Yt(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 l=c.getNodeById(n,o.doc);if(!l)throw new Error(`Block with ID ${n} not found`);const a=c.getNodeById(r,o.doc);if(!a)throw new Error(`Block with ID ${r} not found`);const d=u.getBlockInfo(l),p=u.getBlockInfo(a),f=i.blockSchema[d.blockNoteType],h=i.blockSchema[p.blockNoteType];if(!d.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,m;if(f.content==="table"){const S=A.TableMap.get(d.blockContent.node);g=d.blockContent.beforePos+S.positionAt(0,0,d.blockContent.node)+1+2}else g=d.blockContent.beforePos+1;if(h.content==="table"){const S=A.TableMap.get(p.blockContent.node),C=p.blockContent.beforePos+S.positionAt(S.height-1,S.width-1,p.blockContent.node)+1,T=o.doc.resolve(C).nodeAfter.nodeSize;m=C+T-2}else m=p.blockContent.afterPos-1;o.setSelection(y.TextSelection.create(o.doc,g,m))}function Jt(o,e=!1){const t=u.getPmSchema(o),n=e?Be(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 Qt(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 Ce(o,e,t="start"){const n=typeof e=="string"?e:e.id,r=u.getPmSchema(o.doc),s=u.getBlockNoteSchema(r),i=c.getNodeById(n,o.doc);if(!i)throw new Error(`Block with ID ${n} not found`);const l=u.getBlockInfo(i),a=s.blockSchema[l.blockNoteType].content;if(l.isBlockContainer){const d=l.blockContent;if(a==="none"){o.setSelection(y.NodeSelection.create(o.doc,d.beforePos));return}if(a==="inline")t==="start"?o.setSelection(y.TextSelection.create(o.doc,d.beforePos+1)):o.setSelection(y.TextSelection.create(o.doc,d.afterPos-1));else if(a==="table")t==="start"?o.setSelection(y.TextSelection.create(o.doc,d.beforePos+4)):o.setSelection(y.TextSelection.create(o.doc,d.afterPos-4));else throw new u.UnreachableCaseError(a)}else{const d=t==="start"?l.childContainer.node.firstChild:l.childContainer.node.lastChild;Ce(o,d.attrs.id,t)}}class Xt{constructor(e){this.editor=e}getSelection(){return this.editor.transact(e=>Kt(e))}getSelectionCutBlocks(e=!1){return this.editor.transact(t=>Jt(t,e))}setSelection(e,t){return this.editor.transact(n=>Yt(n,e,t))}getTextCursorPosition(){return this.editor.transact(e=>Qt(e))}setTextCursorPosition(e,t="start"){return this.editor.transact(n=>Ce(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(B.isNodeSelection(e)){const s=this.editor.prosemirrorView.nodeDOM(n);if(s)return s.getBoundingClientRect()}return B.posToDOMRect(this.editor.prosemirrorView,n,r).toJSON()}}class Zt{constructor(e){k(this,"activeTransaction",null);k(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 eo(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,l=!0,a="";if(t.forEach(d=>{d.check(),i&&d.isText&&d.marks.length===0?a+=d.text:i=!1,l=l?d.isBlock:!1}),r===s&&l){const{parent:d}=o.doc.resolve(r);d.isTextblock&&!d.type.spec.code&&!d.childCount&&(r-=1,s+=1)}return i?o.insertText(a,r,s):o.replaceWith(r,s,t),n.updateSelection&&B.selectionToInsertionEnd(o,o.steps.length-1,-1),!0}class to{constructor(e){this.editor=e}insertInlineContent(e,{updateSelection:t=!1}={}){const n=u.inlineContentToNodes(e,this.editor.pmSchema);this.editor.transact(r=>{eo(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(De.TextSelection.create(r.doc,i)).addMark(s,i,n)})}}function oo(o,e){const t=[];return o.forEach((n,r,s)=>{s!==e&&t.push(n)}),N.Fragment.from(t)}function no(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=N.Fragment.from(t),o}function ro(o,e){let t=N.Fragment.from(o.content);if(t=no(t,e.state.schema),!so(t,e))return new N.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=oo(t,n+1))}const s=e.state.schema.nodes.blockContainer.createChecked(void 0,r);t=t.replaceChild(n,s)}return new N.Slice(t,o.openStart,o.openEnd)}function so(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 l=u.getBlockInfoFromSelection(e.state);if(l.isBlockContainer)return!(l.blockContent.node.type.spec.content==="tableRow+")}}return!0}const io={enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!1};class W extends R.EventEmitter{constructor(t){var d,p,f,h,g,m,S,C,T,I;super();k(this,"pmSchema");k(this,"_tiptapEditor");k(this,"elementRenderer",null);k(this,"blockCache",new WeakMap);k(this,"dictionary");k(this,"schema");k(this,"blockImplementations");k(this,"inlineContentImplementations");k(this,"styleImplementations");k(this,"uploadFile");k(this,"onUploadStartCallbacks",[]);k(this,"onUploadEndCallbacks",[]);k(this,"resolveFileUrl");k(this,"settings");k(this,"_blockManager");k(this,"_eventManager");k(this,"_exportManager");k(this,"_extensionManager");k(this,"_selectionManager");k(this,"_stateManager");k(this,"_styleManager");k(this,"unregisterExtension",(...t)=>this._extensionManager.unregisterExtension(...t));k(this,"registerExtension",(...t)=>this._extensionManager.registerExtension(...t));k(this,"getExtension",(...t)=>this._extensionManager.getExtension(...t));k(this,"mount",t=>{this._tiptapEditor.mount({mount:t})});k(this,"unmount",()=>{this._tiptapEditor.unmount()});this.options=t,this.dictionary=t.dictionary||xe.en,this.settings={tables:{splitCells:((d=t==null?void 0:t.tables)==null?void 0:d.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||M.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 E=n.uploadFile;this.uploadFile=async(w,P)=>{this.onUploadStartCallbacks.forEach(v=>v.apply(this,[P]));try{return await E(w,P)}finally{this.onUploadEndCallbacks.forEach(v=>v.apply(this,[P]))}}}this.resolveFileUrl=n.resolveFileUrl,this._eventManager=new Xe(this),this._extensionManager=new Wt(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={...io,...n._tiptapOptions,element:null,autofocus:n.autofocus??!1,extensions:r,editorProps:{...(g=n._tiptapOptions)==null?void 0:g.editorProps,attributes:{tabIndex:"0",...(S=(m=n._tiptapOptions)==null?void 0:m.editorProps)==null?void 0:S.attributes,...(C=n.domAttributes)==null?void 0:C.editor,class:c.mergeCSSClasses("bn-editor",n.defaultStyles?"bn-default-styles":"",((I=(T=n.domAttributes)==null?void 0:T.editor)==null?void 0:I.class)||"")},transformPasted:ro}};try{const E=n.initialContent||(s?[{type:"paragraph",id:"initialBlockId"}]:[{type:"paragraph",id:u.UniqueID.options.generateID()}]);if(!Array.isArray(E)||E.length===0)throw new Error("initialContent must be a non-empty array of blocks, received: "+E);const w=B.getSchema(i.extensions),P=E.map(ye=>u.blockToNode(ye,w,this.schema.styleSchema).toJSON()),v=B.createDocument({type:"doc",content:[{type:"blockGroup",content:P}]},w,i.parseOptions);this._tiptapEditor=new B.Editor({...i,content:v.toJSON()}),this.pmSchema=this._tiptapEditor.schema}catch(E){throw new Error("Error creating document from blocks passed as `initialContent`",{cause:E})}let l;const a=this.pmSchema.nodes.doc.createAndFill;this.pmSchema.nodes.doc.createAndFill=(...E)=>{if(l)return l;const w=a.apply(this.pmSchema.nodes.doc,E),P=JSON.parse(JSON.stringify(w.toJSON()));return P.content[0].content[0].attrs.id="initialBlockId",l=x.Node.fromJSON(this.pmSchema,P),l},this.pmSchema.cached.blockNoteEditor=this,this._blockManager=new Qe(this),this._exportManager=new ct(this),this._selectionManager=new Xt(this),this._stateManager=new Zt(this),this._styleManager=new to(this),this.emit("create")}static create(t){return new W(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 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 ao(o){return{createBlockMapping:e=>e,createInlineContentMapping:e=>e,createStyleMapping:e=>e}}function lo(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=c.COLORS_DARK_MODE_DEFAULT;exports.COLORS_DEFAULT=c.COLORS_DEFAULT;exports.EMPTY_CELL_HEIGHT=c.EMPTY_CELL_HEIGHT;exports.EMPTY_CELL_WIDTH=c.EMPTY_CELL_WIDTH;exports.FILE_AUDIO_ICON_SVG=c.FILE_AUDIO_ICON_SVG;exports.FILE_IMAGE_ICON_SVG=c.FILE_IMAGE_ICON_SVG;exports.FILE_VIDEO_ICON_SVG=c.FILE_VIDEO_ICON_SVG;exports.addDefaultPropsExternalHTML=c.addDefaultPropsExternalHTML;exports.addInlineContentAttributes=c.addInlineContentAttributes;exports.addInlineContentKeyboardShortcuts=c.addInlineContentKeyboardShortcuts;exports.addNodeAndExtensionsToSpec=c.addNodeAndExtensionsToSpec;exports.addStyleAttributes=c.addStyleAttributes;exports.applyNonSelectableBlockFix=c.applyNonSelectableBlockFix;exports.audioParse=c.audioParse;exports.audioRender=c.audioRender;exports.audioToExternalHTML=c.audioToExternalHTML;exports.blockHasType=c.blockHasType;exports.camelToDataKebab=c.camelToDataKebab;exports.captureCellAnchor=c.captureCellAnchor;exports.createAudioBlockConfig=c.createAudioBlockConfig;exports.createAudioBlockSpec=c.createAudioBlockSpec;exports.createBlockConfig=c.createBlockConfig;exports.createBlockSpec=c.createBlockSpec;exports.createBlockSpecFromTiptapNode=c.createBlockSpecFromTiptapNode;exports.createBulletListItemBlockConfig=c.createBulletListItemBlockConfig;exports.createBulletListItemBlockSpec=c.createBulletListItemBlockSpec;exports.createCheckListItemBlockSpec=c.createCheckListItemBlockSpec;exports.createCheckListItemConfig=c.createCheckListItemConfig;exports.createCodeBlockConfig=c.createCodeBlockConfig;exports.createCodeBlockSpec=c.createCodeBlockSpec;exports.createDefaultBlockDOMOutputSpec=c.createDefaultBlockDOMOutputSpec;exports.createDividerBlockConfig=c.createDividerBlockConfig;exports.createDividerBlockSpec=c.createDividerBlockSpec;exports.createFileBlockConfig=c.createFileBlockConfig;exports.createFileBlockSpec=c.createFileBlockSpec;exports.createHeadingBlockConfig=c.createHeadingBlockConfig;exports.createHeadingBlockSpec=c.createHeadingBlockSpec;exports.createImageBlockConfig=c.createImageBlockConfig;exports.createImageBlockSpec=c.createImageBlockSpec;exports.createInlineContentSpecFromTipTapNode=c.createInlineContentSpecFromTipTapNode;exports.createInternalInlineContentSpec=c.createInternalInlineContentSpec;exports.createInternalStyleSpec=c.createInternalStyleSpec;exports.createNumberedListItemBlockConfig=c.createNumberedListItemBlockConfig;exports.createNumberedListItemBlockSpec=c.createNumberedListItemBlockSpec;exports.createParagraphBlockConfig=c.createParagraphBlockConfig;exports.createParagraphBlockSpec=c.createParagraphBlockSpec;exports.createQuoteBlockConfig=c.createQuoteBlockConfig;exports.createQuoteBlockSpec=c.createQuoteBlockSpec;exports.createStyleSpec=c.createStyleSpec;exports.createStyleSpecFromTipTapMark=c.createStyleSpecFromTipTapMark;exports.createTableBlockSpec=c.createTableBlockSpec;exports.createToggleListItemBlockConfig=c.createToggleListItemBlockConfig;exports.createToggleListItemBlockSpec=c.createToggleListItemBlockSpec;exports.createToggleWrapper=c.createToggleWrapper;exports.createVideoBlockConfig=c.createVideoBlockConfig;exports.createVideoBlockSpec=c.createVideoBlockSpec;exports.defaultBlockSpecs=c.defaultBlockSpecs;exports.defaultBlockToHTML=c.defaultBlockToHTML;exports.defaultInlineContentSchema=c.defaultInlineContentSchema;exports.defaultInlineContentSpecs=c.defaultInlineContentSpecs;exports.defaultProps=c.defaultProps;exports.defaultStyleSchema=c.defaultStyleSchema;exports.defaultStyleSpecs=c.defaultStyleSpecs;exports.defaultToggledState=c.defaultToggledState;exports.editorHasBlockWithType=c.editorHasBlockWithType;exports.fileParse=c.fileParse;exports.filenameFromURL=c.filenameFromURL;exports.formatKeyboardShortcut=c.formatKeyboardShortcut;exports.getBackgroundColorAttribute=c.getBackgroundColorAttribute;exports.getBlockFromPos=c.getBlockFromPos;exports.getInlineContentSchemaFromSpecs=c.getInlineContentSchemaFromSpecs;exports.getLanguageId=c.getLanguageId;exports.getNodeById=c.getNodeById;exports.getParseRules=c.getParseRules;exports.getStyleParseRules=c.getStyleParseRules;exports.getStyleSchemaFromSpecs=c.getStyleSchemaFromSpecs;exports.getTextAlignmentAttribute=c.getTextAlignmentAttribute;exports.getTextColorAttribute=c.getTextColorAttribute;exports.imageParse=c.imageParse;exports.imageRender=c.imageRender;exports.imageToExternalHTML=c.imageToExternalHTML;exports.isAppleOS=c.isAppleOS;exports.isNodeBlock=c.isNodeBlock;exports.isSafari=c.isSafari;exports.isTableCellSelection=c.isTableCellSelection;exports.isVideoUrl=c.isVideoUrl;exports.mergeCSSClasses=c.mergeCSSClasses;exports.mergeParagraphs=c.mergeParagraphs;exports.parseAudioElement=c.parseAudioElement;exports.parseDefaultProps=c.parseDefaultProps;exports.propsToAttributes=c.propsToAttributes;exports.stylePropsToAttributes=c.stylePropsToAttributes;exports.tablePropSchema=c.tablePropSchema;exports.trackPosition=c.trackPosition;exports.updateBlock=c.updateBlock;exports.updateBlockCommand=c.updateBlockCommand;exports.updateBlockTr=c.updateBlockTr;exports.videoParse=c.videoParse;exports.wrapInBlockStructure=c.wrapInBlockStructure;exports.blocksToMarkdown=b.blocksToMarkdown;exports.cleanHTMLToMarkdown=b.cleanHTMLToMarkdown;exports.createExternalHTMLExporter=b.createExternalHTMLExporter;exports.getBlocksChangedByTransaction=b.getBlocksChangedByTransaction;exports.BlockNoteSchema=M.BlockNoteSchema;exports.CustomBlockNoteSchema=M.CustomBlockNoteSchema;exports.checkPageBreakBlocksInSchema=M.checkPageBreakBlocksInSchema;exports.createPageBreakBlockConfig=M.createPageBreakBlockConfig;exports.createPageBreakBlockSpec=M.createPageBreakBlockSpec;exports.getPageBreakSlashMenuItems=M.getPageBreakSlashMenuItems;exports.uploadToTmpFilesDotOrg_DEV_ONLY=M.uploadToTmpFilesDotOrg_DEV_ONLY;exports.withPageBreak=M.withPageBreak;exports.EventEmitter=R.EventEmitter;exports.createExtension=F.createExtension;exports.createStore=F.createStore;exports.BlockNoteEditor=W;exports.Exporter=co;exports.HTMLToBlocks=z;exports.combineByGroup=lo;exports.createInlineContentSpec=Ue;exports.createInternalHTMLSerializer=ce;exports.expandPMRangeToWords=Be;exports.fixColumnList=D;exports.getBlock=fe;exports.getInlineContentParseRules=oe;exports.getNextBlock=me;exports.getParentBlock=ke;exports.getPrevBlock=he;exports.insertBlocks=ne;exports.isEmptyColumn=L;exports.mappingFactory=ao;exports.markdownToBlocks=ge;exports.markdownToHTML=G;exports.removeAndInsertBlocks=$;exports.removeEmptyColumns=re;exports.selectedFragmentToHTML=j;
|
|
5
5
|
//# sourceMappingURL=blocknote.cjs.map
|