@blocknote/core 0.42.0 → 0.42.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocknote.cjs +1 -1
- package/dist/blocknote.cjs.map +1 -1
- package/dist/blocknote.js +1 -16
- package/dist/blocknote.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +1 -1
- package/src/editor/BlockNoteEditor.test.ts +1 -1
- package/src/editor/BlockNoteEditor.ts +1 -27
- package/types/src/editor/BlockNoteEditor.d.ts +0 -4
package/dist/blocknote.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";var Ut=Object.create;var ce=Object.defineProperty;var Rt=Object.getOwnPropertyDescriptor;var Ft=Object.getOwnPropertyNames;var Vt=Object.getPrototypeOf,$t=Object.prototype.hasOwnProperty;var zt=(n,t,e)=>t in n?ce(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var Kt=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ft(t))!$t.call(n,r)&&r!==e&&ce(n,r,{get:()=>t[r],enumerable:!(o=Rt(t,r))||o.enumerable});return n};var Ee=(n,t,e)=>(e=n!=null?Ut(Vt(n)):{},Kt(t||!n||!n.__esModule?ce(e,"default",{value:n,enumerable:!0}):e,n));var u=(n,t,e)=>zt(n,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("prosemirror-model"),W=require("prosemirror-transform"),m=require("./blockToNode-w7H99R6p.cjs"),d=require("./BlockNoteSchema-DjDaA2C3.cjs"),B=require("@tiptap/core"),qt=require("fast-deep-equal"),Gt=require("prosemirror-dropcursor"),jt=require("yjs"),Wt=require("@tiptap/extension-gapcursor"),Yt=require("@tiptap/extension-history"),Xt=require("@tiptap/extension-link"),Jt=require("@tiptap/extension-text"),S=require("prosemirror-state"),N=require("prosemirror-tables"),Qt=require("rehype-parse"),Zt=require("rehype-remark"),eo=require("remark-gfm"),to=require("remark-stringify"),Ve=require("unified"),oo=require("hast-util-from-dom"),no=require("unist-util-visit"),E=require("y-prosemirror"),M=require("prosemirror-view"),ro=require("uuid"),so=require("./en-Cl87Uuyf.cjs"),io=require("remark-parse"),de=require("remark-rehype"),ao=require("rehype-stringify"),Me=require("prosemirror-history"),R=n=>n&&typeof n=="object"&&"default"in n?n:{default:n};function co(n){if(n&&typeof n=="object"&&"default"in n)return n;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(t,e,o.get?o:{enumerable:!0,get:()=>n[e]})}}return t.default=n,Object.freeze(t)}const lo=R(qt),H=co(jt),uo=R(Qt),ho=R(Zt),$e=R(eo),po=R(to),mo=R(io),fo=R(de),go=R(ao);function ze(n,t){const e=[{tag:`[data-inline-content-type="${n.type}"]`,contentElement:o=>{const r=o;return r.matches("[data-editable]")?r:r.querySelector("[data-editable]")||r}}];return t&&e.push({tag:"*",getAttrs(o){if(typeof o=="string")return!1;const r=t==null?void 0:t(o);return r===void 0?!1:r}}),e}function ko(n,t){var o;const e=B.Node.create({name:n.type,inline:!0,group:"inline",draggable:(o=t.meta)==null?void 0:o.draggable,selectable:n.content==="styled",atom:n.content==="none",content:n.content==="styled"?"inline*":"",addAttributes(){return d.propsToAttributes(n.propSchema)},addKeyboardShortcuts(){return d.addInlineContentKeyboardShortcuts(n)},parseHTML(){return ze(n,t.parse)},renderHTML({node:r}){const s=this.options.editor,i=t.render.call({renderType:"dom",props:void 0},m.nodeToCustomInlineContent(r,s.schema.inlineContentSchema,s.schema.styleSchema),()=>{},s);return d.addInlineContentAttributes(i,n.type,r.attrs,n.propSchema)},addNodeView(){return r=>{const{node:s,getPos:i}=r,c=this.options.editor,a=t.render.call({renderType:"nodeView",props:r},m.nodeToCustomInlineContent(s,c.schema.inlineContentSchema,c.schema.styleSchema),l=>{const h=m.inlineContentToNodes([l],c.pmSchema),p=i();p&&c.transact(k=>k.replaceWith(p,p+s.nodeSize,h))},c);return d.addInlineContentAttributes(a,n.type,s.attrs,n.propSchema)}}});return d.createInlineContentSpecFromTipTapNode(e,n.propSchema,{...t,toExternalHTML:t.toExternalHTML,render(r,s,i){const c=t.render(r,s,i);return d.addInlineContentAttributes(c,n.type,r.props,n.propSchema)}})}function Ke(n,t,e,o="before"){const r=typeof e=="string"?e:e.id,s=m.getPmSchema(n),i=t.map(h=>m.blockToNode(h,s)),c=d.getNodeById(r,n.doc);if(!c)throw new Error(`Block with ID ${r} not found`);let a=c.posBeforeNode;return o==="after"&&(a+=c.node.nodeSize),n.step(new W.ReplaceStep(a,a,new T.Slice(T.Fragment.from(i),0,0))),i.map(h=>m.nodeToBlock(h,s))}function te(n){if(!n||n.type.name!=="column")throw new Error("Invalid columnPos: does not point to column node.");const t=n.firstChild;if(!t)throw new Error("Invalid column: does not have child node.");const e=t.firstChild;if(!e)throw new Error("Invalid blockContainer: does not have child node.");return n.childCount===1&&t.childCount===1&&e.type.name==="paragraph"&&e.content.content.length===0}function qe(n,t){const e=n.doc.resolve(t),o=e.nodeAfter;if(!o||o.type.name!=="columnList")throw new Error("Invalid columnListPos: does not point to columnList node.");for(let r=o.childCount-1;r>=0;r--){const s=n.doc.resolve(e.pos+1).posAtIndex(r),c=n.doc.resolve(s).nodeAfter;if(!c||c.type.name!=="column")throw new Error("Invalid columnPos: does not point to column node.");te(c)&&n.delete(s,s+c.nodeSize)}}function oe(n,t){qe(n,t);const o=n.doc.resolve(t).nodeAfter;if(!o||o.type.name!=="columnList")throw new Error("Invalid columnListPos: does not point to columnList node.");if(o.childCount>2)return;if(o.childCount<2)throw new Error("Invalid columnList: contains fewer than two children.");const r=t+1,i=n.doc.resolve(r).nodeAfter,c=t+o.nodeSize-1,l=n.doc.resolve(c).nodeBefore;if(!i||!l)throw new Error("Invalid columnList: does not contain children.");const h=te(i),p=te(l);if(h&&p){n.delete(t,t+o.nodeSize);return}if(h){n.step(new W.ReplaceAroundStep(t,t+o.nodeSize,c-l.nodeSize+1,c-1,T.Slice.empty,0,!1));return}if(p){n.step(new W.ReplaceAroundStep(t,t+o.nodeSize,r+1,r+i.nodeSize-1,T.Slice.empty,0,!1));return}}function ue(n,t,e){const o=m.getPmSchema(n),r=e.map(p=>m.blockToNode(p,o)),s=new Set(t.map(p=>typeof p=="string"?p:p.id)),i=[],c=new Set,a=typeof t[0]=="string"?t[0]:t[0].id;let l=0;if(n.doc.descendants((p,k)=>{if(s.size===0)return!1;if(!p.type.isInGroup("bnBlock")||!s.has(p.attrs.id))return!0;if(i.push(m.nodeToBlock(p,o)),s.delete(p.attrs.id),e.length>0&&p.attrs.id===a){const y=n.doc.nodeSize;n.insert(k,r);const w=n.doc.nodeSize;l+=y-w}const g=n.doc.nodeSize,b=n.doc.resolve(k-l);b.node().type.name==="column"?c.add(b.before(-1)):b.node().type.name==="columnList"&&c.add(b.before()),b.node().type.name==="blockGroup"&&b.node(b.depth-1).type.name!=="doc"&&b.node().childCount===1?n.delete(b.before(),b.after()):n.delete(k-l,k-l+p.nodeSize);const f=n.doc.nodeSize;return l+=g-f,!1}),s.size>0){const p=[...s].join(`
|
|
2
2
|
`);throw Error("Blocks with the following IDs could not be found in the editor: "+p)}return c.forEach(p=>oe(n,p)),{insertedBlocks:r.map(p=>m.nodeToBlock(p,o)),removedBlocks:i}}function Ge(n){const t=Array.from(n.classList).filter(e=>!e.startsWith("bn-"))||[];t.length>0?n.className=t.join(" "):n.removeAttribute("class")}function je(n,t,e,o){var c;let r;if(t)if(typeof t=="string")r=m.inlineContentToNodes([t],n.pmSchema);else if(Array.isArray(t))r=m.inlineContentToNodes(t,n.pmSchema);else if(t.type==="tableContent")r=m.tableContentToNodes(t,n.pmSchema);else throw new m.UnreachableCaseError(t.type);else throw new Error("blockContent is required");const i=((o==null?void 0:o.document)??document).createDocumentFragment();for(const a of r)if(a.type.name!=="text"&&n.schema.inlineContentSchema[a.type.name]){const l=n.schema.inlineContentSpecs[a.type.name].implementation;if(l){const h=m.nodeToCustomInlineContent(a,n.schema.inlineContentSchema,n.schema.styleSchema),p=l.toExternalHTML?l.toExternalHTML(h,n):l.render.call({renderType:"dom",props:void 0},h,()=>{},n);if(p){if(i.appendChild(p.dom),p.contentDOM){const k=e.serializeFragment(a.content,o);p.contentDOM.dataset.editable="",p.contentDOM.appendChild(k)}continue}}}else if(a.type.name==="text"){let l=document.createTextNode(a.textContent);for(const h of a.marks.toReversed())if(h.type.name in n.schema.styleSpecs){const p=(n.schema.styleSpecs[h.type.name].implementation.toExternalHTML??n.schema.styleSpecs[h.type.name].implementation.render)(h.attrs.stringValue,n);p.contentDOM.appendChild(l),l=p.dom}else{const p=h.type.spec.toDOM(h,!0),k=T.DOMSerializer.renderSpec(document,p);k.contentDOM.appendChild(l),l=k.dom}i.appendChild(l)}else{const l=e.serializeFragment(T.Fragment.from([a]),o);i.appendChild(l)}return i.childNodes.length===1&&((c=i.firstChild)==null?void 0:c.nodeType)===1&&Ge(i.firstChild),i}function bo(n,t,e,o,r,s,i){var y,w,C,_,U,K,q,G,j;const c=(i==null?void 0:i.document)??document,a=t.pmSchema.nodes.blockContainer,l=e.props||{};for(const[x,I]of Object.entries(t.schema.blockSchema[e.type].propSchema))!(x in l)&&I.default!==void 0&&(l[x]=I.default);const h=(w=(y=a.spec)==null?void 0:y.toDOM)==null?void 0:w.call(y,a.create({id:e.id,...l})),p=Array.from(h.dom.attributes),k=t.blockImplementations[e.type].implementation,g=((C=k.toExternalHTML)==null?void 0:C.call({},{...e,props:l},t))||k.render.call({},{...e,props:l},t),b=c.createDocumentFragment();if(g.dom.classList.contains("bn-block-content")){const x=[...p,...Array.from(g.dom.attributes)].filter(I=>I.name.startsWith("data")&&I.name!=="data-content-type"&&I.name!=="data-file-block"&&I.name!=="data-node-view-wrapper"&&I.name!=="data-node-type"&&I.name!=="data-id"&&I.name!=="data-editable");for(const I of x)g.dom.firstChild.setAttribute(I.name,I.value);Ge(g.dom.firstChild),b.append(...Array.from(g.dom.childNodes))}else b.append(g.dom);if(g.contentDOM&&e.content){const x=je(t,e.content,o,i);g.contentDOM.appendChild(x)}let f;if(r.has(e.type)?f="OL":s.has(e.type)&&(f="UL"),f){if(((_=n.lastChild)==null?void 0:_.nodeName)!==f){const x=c.createElement(f);f==="OL"&&"start"in l&&l.start&&(l==null?void 0:l.start)!==1&&x.setAttribute("start",l.start+""),n.append(x)}n.lastChild.appendChild(b)}else n.append(b);if(e.children&&e.children.length>0){const x=c.createDocumentFragment();if(We(x,t,e.children,o,r,s,i),((U=n.lastChild)==null?void 0:U.nodeName)==="UL"||((K=n.lastChild)==null?void 0:K.nodeName)==="OL")for(;((q=x.firstChild)==null?void 0:q.nodeName)==="UL"||((G=x.firstChild)==null?void 0:G.nodeName)==="OL";)n.lastChild.lastChild.appendChild(x.firstChild);t.pmSchema.nodes[e.type].isInGroup("blockContent")?n.append(x):(j=g.contentDOM)==null||j.append(x)}}const We=(n,t,e,o,r,s,i)=>{for(const c of e)bo(n,t,c,o,r,s,i)},yo=(n,t,e,o,r,s)=>{const c=((s==null?void 0:s.document)??document).createDocumentFragment();return We(c,n,t,e,o,r,s),c},X=(n,t)=>{const e=T.DOMSerializer.fromSchema(n);return{exportBlocks:(o,r)=>{const s=yo(t,o,e,new Set(["numberedListItem"]),new Set(["bulletListItem","checkListItem","toggleListItem"]),r),i=document.createElement("div");return i.append(s),i.innerHTML},exportInlineContent:(o,r)=>{const s=je(t,o,e,r),i=document.createElement("div");return i.append(s.cloneNode(!0)),i.innerHTML}}};function wo(n,t,e,o,r){let s;if(t)if(typeof t=="string")s=m.inlineContentToNodes([t],n.pmSchema,o);else if(Array.isArray(t))s=m.inlineContentToNodes(t,n.pmSchema,o);else if(t.type==="tableContent")s=m.tableContentToNodes(t,n.pmSchema);else throw new m.UnreachableCaseError(t.type);else throw new Error("blockContent is required");const c=((r==null?void 0:r.document)??document).createDocumentFragment();for(const a of s)if(a.type.name!=="text"&&n.schema.inlineContentSchema[a.type.name]){const l=n.schema.inlineContentSpecs[a.type.name].implementation;if(l){const h=m.nodeToCustomInlineContent(a,n.schema.inlineContentSchema,n.schema.styleSchema),p=l.render.call({renderType:"dom",props:void 0},h,()=>{},n);if(p){if(c.appendChild(p.dom),p.contentDOM){const k=e.serializeFragment(a.content,r);p.contentDOM.dataset.editable="",p.contentDOM.appendChild(k)}continue}}}else if(a.type.name==="text"){let l=document.createTextNode(a.textContent);for(const h of a.marks.toReversed())if(h.type.name in n.schema.styleSpecs){const p=n.schema.styleSpecs[h.type.name].implementation.render(h.attrs.stringValue,n);p.contentDOM.appendChild(l),l=p.dom}else{const p=h.type.spec.toDOM(h,!0),k=T.DOMSerializer.renderSpec(document,p);k.contentDOM.appendChild(l),l=k.dom}c.appendChild(l)}else{const l=e.serializeFragment(T.Fragment.from([a]),r);c.appendChild(l)}return c}function So(n,t,e,o){var p,k,g,b,f;const r=n.pmSchema.nodes.blockContainer,s=t.props||{};for(const[y,w]of Object.entries(n.schema.blockSchema[t.type].propSchema))!(y in s)&&w.default!==void 0&&(s[y]=w.default);const i=t.children||[],a=n.blockImplementations[t.type].implementation.render.call({renderType:"dom",props:void 0},{...t,props:s,children:i},n);if(a.contentDOM&&t.content){const y=wo(n,t.content,e,t.type,o);a.contentDOM.appendChild(y)}if(n.pmSchema.nodes[t.type].isInGroup("bnBlock")){if(t.children&&t.children.length>0){const y=Ye(n,t.children,e,o);(p=a.contentDOM)==null||p.append(y)}return a.dom}const h=(g=(k=r.spec)==null?void 0:k.toDOM)==null?void 0:g.call(k,r.create({id:t.id,...s}));return(b=h.contentDOM)==null||b.appendChild(a.dom),t.children&&t.children.length>0&&((f=h.contentDOM)==null||f.appendChild(Xe(n,t.children,e,o))),h.dom}function Ye(n,t,e,o){const s=((o==null?void 0:o.document)??document).createDocumentFragment();for(const i of t){const c=So(n,i,e,o);s.appendChild(c)}return s}const Xe=(n,t,e,o)=>{var c;const r=n.pmSchema.nodes.blockGroup,s=r.spec.toDOM(r.create({})),i=Ye(n,t,e,o);return(c=s.contentDOM)==null||c.appendChild(i),s.dom},Je=(n,t)=>{const e=T.DOMSerializer.fromSchema(n);return{serializeBlocks:(o,r)=>Xe(t,o,e,r).outerHTML}};function Co(n,t){if(t===0)return;const e=n.resolve(t);for(let o=e.depth;o>0;o--){const r=e.node(o);if(d.isNodeBlock(r))return r.attrs.id}}function Bo(n){return n.getMeta("paste")?{type:"paste"}:n.getMeta("uiEvent")==="drop"?{type:"drop"}:n.getMeta("history$")?{type:n.getMeta("history$").redo?"redo":"undo"}:n.getMeta("y-sync$")?n.getMeta("y-sync$").isUndoRedoOperation?{type:"undo-redo"}:{type:"yjs-remote"}:{type:"local"}}function xe(n){const t="__root__",e={},o={},r=m.getPmSchema(n);return n.descendants((s,i)=>{if(!d.isNodeBlock(s))return!0;const c=Co(n,i),a=c??t;o[a]||(o[a]=[]);const l=m.nodeToBlock(s,r);return e[s.attrs.id]={block:l,parentId:c},o[a].push(s.attrs.id),!0}),{byId:e,childrenByParent:o}}function vo(n,t){const e=new Set;if(!n||!t)return e;const o=new Set(n),r=t.filter(f=>o.has(f)),s=n.filter(f=>r.includes(f));if(s.length<=1||r.length<=1)return e;const i={};for(let f=0;f<s.length;f++)i[s[f]]=f;const c=r.map(f=>i[f]),a=c.length,l=[],h=[],p=new Array(a).fill(-1),k=(f,y)=>{let w=0,C=f.length;for(;w<C;){const _=w+C>>>1;f[_]<y?w=_+1:C=_}return w};for(let f=0;f<a;f++){const y=c[f],w=k(l,y);w>0&&(p[f]=h[w-1]),w===l.length?(l.push(y),h.push(f)):(l[w]=y,h[w]=f)}const g=new Set;let b=h[h.length-1]??-1;for(;b!==-1;)g.add(b),b=p[b];for(let f=0;f<r.length;f++)g.has(f)||e.add(r[f]);return e}function fe(n,t=[]){const e=Bo(n),o=B.combineTransactionSteps(n.before,[n,...t]),r=xe(o.before),s=xe(o.doc),i=[],c=new Set;Object.keys(s.byId).filter(g=>!(g in r.byId)).forEach(g=>{i.push({type:"insert",block:s.byId[g].block,source:e,prevBlock:void 0}),c.add(g)}),Object.keys(r.byId).filter(g=>!(g in s.byId)).forEach(g=>{i.push({type:"delete",block:r.byId[g].block,source:e,prevBlock:void 0}),c.add(g)}),Object.keys(s.byId).filter(g=>g in r.byId).forEach(g=>{var w,C;const b=r.byId[g],f=s.byId[g];b.parentId!==f.parentId?(i.push({type:"move",block:f.block,prevBlock:b.block,source:e,prevParent:b.parentId?(w=r.byId[b.parentId])==null?void 0:w.block:void 0,currentParent:f.parentId?(C=s.byId[f.parentId])==null?void 0:C.block:void 0}),c.add(g)):lo.default({...b.block,children:void 0},{...f.block,children:void 0})||(i.push({type:"update",block:f.block,prevBlock:b.block,source:e}),c.add(g))});const a=r.childrenByParent,l=s.childrenByParent,h="__root__",p=new Set([...Object.keys(a),...Object.keys(l)]),k=new Set;return p.forEach(g=>{const b=vo(a[g],l[g]);b.size!==0&&b.forEach(f=>{var _,U;const y=r.byId[f],w=s.byId[f];!y||!w||y.parentId!==w.parentId||c.has(f)||(y.parentId??h)!==g||k.has(f)||(k.add(f),i.push({type:"move",block:w.block,prevBlock:y.block,source:e,prevParent:y.parentId?(_=r.byId[y.parentId])==null?void 0:_.block:void 0,currentParent:w.parentId?(U=s.byId[w.parentId])==null?void 0:U.block:void 0}),c.add(f))})}),i}const ge=["vscode-editor-data","blocknote/html","text/markdown","text/html","text/plain","Files"];function Po(n,t){if(!n.startsWith(".")||!t.startsWith("."))throw new Error("The strings provided are not valid file extensions.");return n===t}function To(n,t){const e=n.split("/"),o=t.split("/");if(e.length!==2)throw new Error(`The string ${n} is not a valid MIME type.`);if(o.length!==2)throw new Error(`The string ${t} is not a valid MIME type.`);return e[1]==="*"||o[1]==="*"?e[0]===o[0]:(e[0]==="*"||o[0]==="*"||e[0]===o[0])&&e[1]===o[1]}function Ie(n,t,e,o="after"){let r;return Array.isArray(t.content)&&t.content.length===0?r=n.updateBlock(t,e).id:r=n.insertBlocks([e],t,o)[0].id,r}async function Qe(n,t){var s;if(!t.uploadFile){console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");return}const e="dataTransfer"in n?n.dataTransfer:n.clipboardData;if(e===null)return;let o=null;for(const i of ge)if(e.types.includes(i)){o=i;break}if(o!=="Files")return;const r=e.items;if(r){n.preventDefault();for(let i=0;i<r.length;i++){let c="file";for(const l of Object.values(t.schema.blockSpecs))for(const h of((s=l.implementation.meta)==null?void 0:s.fileBlockAccept)||[]){const p=h.startsWith("."),k=r[i].getAsFile();if(k&&(!p&&k.type&&To(r[i].type,h)||p&&Po("."+k.name.split(".").pop(),h))){c=l.config.type;break}}const a=r[i].getAsFile();if(a){const l={type:c,props:{name:a.name}};let h;if(n.type==="paste"){const g=t.getTextCursorPosition().block;h=Ie(t,g,l)}else if(n.type==="drop"){const g={left:n.clientX,top:n.clientY},b=t.prosemirrorView.posAtCoords(g);if(!b)return;h=t.transact(f=>{const y=m.getNearestBlockPos(f.doc,b.pos),w=t.prosemirrorView.dom.querySelector(`[data-id="${y.node.attrs.id}"]`),C=w==null?void 0:w.getBoundingClientRect();return Ie(t,t.getBlock(y.node.attrs.id),l,C&&(C.top+C.bottom)/2>g.top?"before":"after")})}else return;const p=await t.uploadFile(a,h),k=typeof p=="string"?{props:{url:p}}:{...p};t.updateBlock(h,k)}}}}const Eo=n=>B.Extension.create({name:"dropFile",addProseMirrorPlugins(){return[new S.Plugin({props:{handleDOMEvents:{drop(t,e){if(!n.isEditable)return;let o=null;for(const r of ge)if(e.dataTransfer.types.includes(r)){o=r;break}return o===null?!0:o==="Files"?(Qe(e,n),!0):!1}}}})]}}),Mo=/(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/,xo=/(_|__|\*|\*\*|~~|==|\+\+)(?!\s)(?:[^\s](?:.{0,62}[^\s])?|\S)(?=\1)/,Io=/\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/,Do=/(?:\s|^)`(?!\s)(?:[^\s`](?:[^`]{0,46}[^\s`])?|[^\s`])`([^\w]|$)/,Lo=/(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/,No=/(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/,Ao=/\n{2} {0,3}-{2,48}\n{2}/,_o=/(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/,Oo=/(?:\n|^)(?!\s)\w[^\n]{0,64}\r?\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/,Ho=/(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/,Uo=/^\s*\|(.+\|)+\s*$/m,Ro=/^\s*\|(\s*[-:]+[-:]\s*\|)+\s*$/m,Fo=/^\s*\|(.+\|)+\s*$/m,Vo=n=>Mo.test(n)||xo.test(n)||Io.test(n)||Do.test(n)||Lo.test(n)||No.test(n)||Ao.test(n)||_o.test(n)||Oo.test(n)||Ho.test(n)||Uo.test(n)||Ro.test(n)||Fo.test(n);async function $o(n,t){const{schema:e}=t.state;if(!n.clipboardData)return!1;const o=n.clipboardData.getData("text/plain");if(!o)return!1;if(!e.nodes.codeBlock)return t.pasteText(o),!0;const r=n.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s==null?void 0:s.mode;return i?(t.pasteHTML(`<pre><code class="language-${i}">${o.replace(/\r\n?/g,`
|
|
3
3
|
`)}</code></pre>`),!0):!1}function zo({event:n,editor:t,prioritizeMarkdownOverHTML:e,plainTextAsMarkdown:o}){var c;if(t.transact(a=>a.selection.$from.parent.type.spec.code&&a.selection.$to.parent.type.spec.code)){const a=(c=n.clipboardData)==null?void 0:c.getData("text/plain");if(a)return t.pasteText(a),!0}let s;for(const a of ge)if(n.clipboardData.types.includes(a)){s=a;break}if(!s)return!0;if(s==="vscode-editor-data")return $o(n,t.prosemirrorView),!0;if(s==="Files")return Qe(n,t),!0;const i=n.clipboardData.getData(s);if(s==="blocknote/html")return t.pasteHTML(i,!0),!0;if(s==="text/markdown")return t.pasteMarkdown(i),!0;if(e){const a=n.clipboardData.getData("text/plain");if(Vo(a))return t.pasteMarkdown(a),!0}return s==="text/html"?(t.pasteHTML(i),!0):o?(t.pasteMarkdown(i),!0):(t.pasteText(i),!0)}const Ko=(n,t)=>B.Extension.create({name:"pasteFromClipboard",addProseMirrorPlugins(){return[new S.Plugin({props:{handleDOMEvents:{paste(e,o){if(o.preventDefault(),!!n.isEditable)return t({event:o,editor:n,defaultPasteHandler:({prioritizeMarkdownOverHTML:r=!0,plainTextAsMarkdown:s=!0}={})=>zo({event:o,editor:n,prioritizeMarkdownOverHTML:r,plainTextAsMarkdown:s})})}}}})]}});function qo(){const n=t=>{let e=t.children.length;for(let o=0;o<e;o++){const r=t.children[o];if(r.type==="element"&&(n(r),r.tagName==="u"))if(r.children.length>0){t.children.splice(o,1,...r.children);const s=r.children.length-1;e+=s,o+=s}else t.children.splice(o,1),e--,o--}};return n}function Go(){const n=t=>{var e;if(t.children&&"length"in t.children&&t.children.length)for(let o=t.children.length-1;o>=0;o--){const r=t.children[o],s=o+1<t.children.length?t.children[o+1]:void 0;r.type==="element"&&r.tagName==="input"&&((e=r.properties)==null?void 0:e.type)==="checkbox"&&(s==null?void 0:s.type)==="element"&&s.tagName==="p"?(s.tagName="span",s.children.splice(0,0,oo.fromDom(document.createTextNode(" ")))):n(r)}};return n}function jo(){return n=>{no.visit(n,"element",(t,e,o)=>{var r,s,i,c;if(o&&t.tagName==="video"){const a=((r=t.properties)==null?void 0:r.src)||((s=t.properties)==null?void 0:s["data-url"])||"",l=((i=t.properties)==null?void 0:i.title)||((c=t.properties)==null?void 0:c["data-name"])||"";o.children[e]={type:"text",value:``}}})}}function ie(n){return Ve.unified().use(uo.default,{fragment:!0}).use(jo).use(qo).use(Go).use(ho.default).use($e.default).use(po.default,{handlers:{text:e=>e.value}}).processSync(n).value}function Ze(n,t,e,o){const s=X(t,e).exportBlocks(n,o);return ie(s)}function et(n){const t=[];return n.descendants(e=>{var r,s;const o=m.getPmSchema(e);return e.type.name==="blockContainer"&&((r=e.firstChild)==null?void 0:r.type.name)==="blockGroup"?!0:e.type.name==="columnList"&&e.childCount===1?((s=e.firstChild)==null||s.forEach(i=>{t.push(m.nodeToBlock(i,o))}),!1):e.type.isInGroup("bnBlock")?(t.push(m.nodeToBlock(e,o)),!1):!0}),t}function Wo(n,t,e){var c;let o=!1;const r=n.state.selection instanceof N.CellSelection;if(!r){const a=n.state.doc.slice(n.state.selection.from,n.state.selection.to,!1).content,l=[];for(let h=0;h<a.childCount;h++)l.push(a.child(h));o=l.find(h=>h.type.isInGroup("bnBlock")||h.type.name==="blockGroup"||h.type.spec.group==="blockContent")===void 0,o&&(t=a)}let s;const i=X(n.state.schema,e);if(r){((c=t.firstChild)==null?void 0:c.type.name)==="table"&&(t=t.firstChild.content);const a=m.contentNodeToTableContent(t,e.schema.inlineContentSchema,e.schema.styleSchema);s=`<table>${i.exportInlineContent(a,{})}</table>`}else if(o){const a=m.contentNodeToInlineContent(t,e.schema.inlineContentSchema,e.schema.styleSchema);s=i.exportInlineContent(a,{})}else{const a=et(t);s=i.exportBlocks(a,{})}return s}function ke(n,t){"node"in n.state.selection&&n.state.selection.node.type.spec.group==="blockContent"&&t.transact(i=>i.setSelection(new S.NodeSelection(i.doc.resolve(n.state.selection.from-1))));const e=n.serializeForClipboard(n.state.selection.content()).dom.innerHTML,o=n.state.selection.content().content,r=Wo(n,o,t),s=ie(r);return{clipboardHTML:e,externalHTML:r,markdown:s}}const De=()=>{const n=window.getSelection();if(!n||n.isCollapsed)return!0;let t=n.focusNode;for(;t;){if(t instanceof HTMLElement&&t.getAttribute("contenteditable")==="false")return!0;t=t.parentElement}return!1},Le=(n,t,e)=>{e.preventDefault(),e.clipboardData.clearData();const{clipboardHTML:o,externalHTML:r,markdown:s}=ke(t,n);e.clipboardData.setData("blocknote/html",o),e.clipboardData.setData("text/html",r),e.clipboardData.setData("text/plain",s)},Yo=n=>B.Extension.create({name:"copyToClipboard",addProseMirrorPlugins(){return[new S.Plugin({props:{handleDOMEvents:{copy(t,e){return De()||Le(n,t,e),!0},cut(t,e){return De()||(Le(n,t,e),t.editable&&t.dispatch(t.state.tr.deleteSelection())),!0},dragstart(t,e){if(!("node"in t.state.selection)||t.state.selection.node.type.spec.group!=="blockContent")return;n.transact(i=>i.setSelection(new S.NodeSelection(i.doc.resolve(t.state.selection.from-1)))),e.preventDefault(),e.dataTransfer.clearData();const{clipboardHTML:o,externalHTML:r,markdown:s}=ke(t,n);return e.dataTransfer.setData("blocknote/html",o),e.dataTransfer.setData("text/html",r),e.dataTransfer.setData("text/plain",s),!0}}}})]}}),Xo=B.Extension.create({name:"blockBackgroundColor",addGlobalAttributes(){return[{types:["tableCell","tableHeader"],attributes:{backgroundColor:d.getBackgroundColorAttribute()}}]}});class Jo extends d.BlockNoteExtension{constructor(){super();u(this,"beforeChangeCallbacks",[]);this.addProsemirrorPlugin(new S.Plugin({key:new S.PluginKey("blockChange"),filterTransaction:e=>{let o;return this.beforeChangeCallbacks.reduce((r,s)=>r===!1?r:s({getChanges(){return o||(o=fe(e),o)},tr:e})!==!1,!0)}}))}static key(){return"blockChange"}subscribe(e){return this.beforeChangeCallbacks.push(e),()=>{this.beforeChangeCallbacks=this.beforeChangeCallbacks.filter(o=>o!==e)}}}const $=class $ extends d.BlockNoteExtension{constructor(e){super();u(this,"provider");u(this,"recentlyUpdatedCursors");u(this,"renderCursor",(e,o)=>{let r=this.recentlyUpdatedCursors.get(o);if(!r){const s=(this.collaboration.renderCursor??$.defaultCursorRender)(e);this.collaboration.showCursorLabels!=="always"&&(s.addEventListener("mouseenter",()=>{const i=this.recentlyUpdatedCursors.get(o);i.element.setAttribute("data-active",""),i.hideTimeout&&(clearTimeout(i.hideTimeout),this.recentlyUpdatedCursors.set(o,{element:i.element,hideTimeout:void 0}))}),s.addEventListener("mouseleave",()=>{const i=this.recentlyUpdatedCursors.get(o);this.recentlyUpdatedCursors.set(o,{element:i.element,hideTimeout:setTimeout(()=>{i.element.removeAttribute("data-active")},2e3)})})),r={element:s,hideTimeout:void 0},this.recentlyUpdatedCursors.set(o,r)}return r.element});u(this,"updateUser",e=>{this.provider.awareness.setLocalStateField("user",e)});this.collaboration=e,this.provider=e.provider,this.recentlyUpdatedCursors=new Map,this.provider.awareness.setLocalStateField("user",e.user),e.showCursorLabels!=="always"&&this.provider.awareness.on("change",({updated:o})=>{for(const r of o){const s=this.recentlyUpdatedCursors.get(r);s&&(s.element.setAttribute("data-active",""),s.hideTimeout&&clearTimeout(s.hideTimeout),this.recentlyUpdatedCursors.set(r,{element:s.element,hideTimeout:setTimeout(()=>{s.element.removeAttribute("data-active")},2e3)}))}}),this.addProsemirrorPlugin(E.yCursorPlugin(this.provider.awareness,{selectionBuilder:E.defaultSelectionBuilder,cursorBuilder:this.renderCursor}))}static key(){return"yCursorPlugin"}get priority(){return 999}static isDarkColor(e){const o=e.charAt(0)==="#"?e.substring(1,7):e,r=parseInt(o.substring(0,2),16),s=parseInt(o.substring(2,4),16),i=parseInt(o.substring(4,6),16),a=[r/255,s/255,i/255].map(h=>h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4));return .2126*a[0]+.7152*a[1]+.0722*a[2]<=.179}};u($,"defaultCursorRender",e=>{const o=document.createElement("span");o.classList.add("bn-collaboration-cursor__base");const r=document.createElement("span");r.setAttribute("contentedEditable","false"),r.classList.add("bn-collaboration-cursor__caret"),r.setAttribute("style",`background-color: ${e.color}; color: ${$.isDarkColor(e.color)?"white":"black"}`);const s=document.createElement("span");return s.classList.add("bn-collaboration-cursor__label"),s.setAttribute("style",`background-color: ${e.color}; color: ${$.isDarkColor(e.color)?"white":"black"}`),s.insertBefore(document.createTextNode(e.name),null),r.insertBefore(s,null),o.insertBefore(document.createTextNode(""),null),o.insertBefore(r,null),o.insertBefore(document.createTextNode(""),null),o});let Y=$;class ne extends d.BlockNoteExtension{static key(){return"ySyncPlugin"}constructor(t){super(),this.addProsemirrorPlugin(E.ySyncPlugin(t))}get priority(){return 1001}}class re extends d.BlockNoteExtension{static key(){return"yUndoPlugin"}constructor({editor:t}){super(),this.addProsemirrorPlugin(E.yUndoPlugin({trackedOrigins:[t]}))}get priority(){return 1e3}}class tt extends d.BlockNoteExtension{constructor({editor:e,collaboration:o}){super(e);u(this,"editor");u(this,"collaboration");u(this,"forkedState");this.editor=e,this.collaboration=o}static key(){return"ForkYDocPlugin"}findTypeInOtherYdoc(e,o){const r=e.doc;if(e._item===null){const s=Array.from(r.share.keys()).find(i=>r.share.get(i)===e);if(s==null)throw new Error("type does not exist in other ydoc");return o.get(s,e.constructor)}else{const s=e._item,i=o.store.clients.get(s.id.client)??[],c=H.findIndexSS(i,s.id.clock);return i[c].content.type}}get isForkedFromRemote(){return this.forkedState!==void 0}fork(){var s;if(this.isForkedFromRemote)return;const e=(s=this.collaboration)==null?void 0:s.fragment;if(!e)throw new Error("No fragment to fork from");const o=new H.Doc;H.applyUpdate(o,H.encodeStateAsUpdate(e.doc));const r=this.findTypeInOtherYdoc(e,o);this.forkedState={undoStack:E.yUndoPluginKey.getState(this.editor.prosemirrorState).undoManager.undoStack,originalFragment:e,forkedFragment:r},this.editor._tiptapEditor.unregisterPlugin([E.yCursorPluginKey,E.yUndoPluginKey,E.ySyncPluginKey]),this.editor._tiptapEditor.registerPlugin(new ne(r).plugins[0]),this.editor._tiptapEditor.registerPlugin(new re({editor:this.editor}).plugins[0]),this.emit("forked",!0)}merge({keepChanges:e}){if(!this.forkedState)return;this.editor._tiptapEditor.unregisterPlugin(E.ySyncPluginKey),this.editor._tiptapEditor.unregisterPlugin(E.yUndoPluginKey);const{originalFragment:o,forkedFragment:r,undoStack:s}=this.forkedState;if(this.editor.extensions.ySyncPlugin=new ne(o),this.editor.extensions.yCursorPlugin=new Y(this.collaboration),this.editor.extensions.yUndoPlugin=new re({editor:this.editor}),this.editor._tiptapEditor.registerPlugin(this.editor.extensions.ySyncPlugin.plugins[0]),this.editor._tiptapEditor.registerPlugin(this.editor.extensions.yCursorPlugin.plugins[0]),this.editor._tiptapEditor.registerPlugin(this.editor.extensions.yUndoPlugin.plugins[0]),E.yUndoPluginKey.getState(this.editor.prosemirrorState).undoManager.undoStack=s,e){const i=H.encodeStateAsUpdate(r.doc,H.encodeStateVector(o.doc));H.applyUpdate(o.doc,i,this.editor)}this.forkedState=void 0,this.emit("forked",!1)}}const ot=(n,t)=>{t(n),n.forEach(e=>{e instanceof H.XmlElement&&ot(e,t)})},Qo=(n,t)=>{const e=new Map;return n.forEach(o=>{o instanceof H.XmlElement&&ot(o,r=>{if(r.nodeName==="blockContainer"&&r.hasAttribute("id")){const s=r.getAttribute("textColor"),i=r.getAttribute("backgroundColor"),c={textColor:s===d.defaultProps.textColor.default?void 0:s,backgroundColor:i===d.defaultProps.backgroundColor.default?void 0:i};(c.textColor||c.backgroundColor)&&e.set(r.getAttribute("id"),c)}})}),e.size===0?!1:(t.doc.descendants((o,r)=>{if(o.type.name==="blockContainer"&&e.has(o.attrs.id)){const s=t.doc.nodeAt(r+1);if(!s)throw new Error("No element found");t.setNodeMarkup(r+1,void 0,{...s.attrs,...e.get(o.attrs.id)})}}),!0)},Zo=[Qo];class be extends d.BlockNoteExtension{constructor(e){const o=new S.PluginKey(be.key());super();u(this,"migrationDone",!1);this.addProsemirrorPlugin(new S.Plugin({key:o,appendTransaction:(r,s,i)=>{if(this.migrationDone||!r.some(a=>a.getMeta("y-sync$"))||r.every(a=>!a.docChanged)||!e.firstChild)return;const c=i.tr;for(const a of Zo)a(e,c);if(this.migrationDone=!0,!!c.docChanged)return c}}))}static key(){return"schemaMigrationPlugin"}}const se=B.Mark.create({name:"comment",excludes:"",inclusive:!1,keepOnSplit:!0,addAttributes(){return{orphan:{parseHTML:n=>!!n.getAttribute("data-orphan"),renderHTML:n=>n.orphan?{"data-orphan":"true"}:{},default:!1},threadId:{parseHTML:n=>n.getAttribute("data-bn-thread-id"),renderHTML:n=>({"data-bn-thread-id":n.threadId}),default:""}}},renderHTML({HTMLAttributes:n}){return["span",B.mergeAttributes(n,{class:"bn-thread-mark"})]},parseHTML(){return[{tag:"span.bn-thread-mark"}]},extendMarkSchema(n){return n.name==="comment"?{blocknoteIgnore:!0}:{}}});class en extends d.EventEmitter{constructor(e){super();u(this,"userCache",new Map);u(this,"loadingUsers",new Set);this.resolveUsers=e}async loadUsers(e){const o=e.filter(r=>!this.userCache.has(r)&&!this.loadingUsers.has(r));if(o.length!==0){for(const r of o)this.loadingUsers.add(r);try{const r=await this.resolveUsers(o);for(const s of r)this.userCache.set(s.id,s);this.emit("update",this.userCache)}finally{for(const r of o)this.loadingUsers.delete(r)}}}getUser(e){return this.userCache.get(e)}subscribe(e){return this.on("update",e)}}const J=new S.PluginKey("blocknote-comments"),tn="SET_SELECTED_THREAD_ID";function on(n,t){const e=new Map;return n.descendants((o,r)=>{o.marks.forEach(s=>{if(s.type.name===t){const i=s.attrs.threadId;if(!i)return;const c=r,a=c+o.nodeSize,l=e.get(i)??{from:1/0,to:0};e.set(i,{from:Math.min(c,l.from),to:Math.max(a,l.to)})}})}),e}class nt extends d.BlockNoteExtension{constructor(e,o,r,s,i){super();u(this,"userStore");u(this,"pendingComment",!1);u(this,"selectedThreadId");u(this,"threadPositions",new Map);u(this,"updateMarksFromThreads",e=>{this.editor.transact(o=>{o.doc.descendants((r,s)=>{r.marks.forEach(i=>{if(i.type.name===this.markType){const c=i.type,a=i.attrs.threadId,l=e.get(a),h=!!(!l||l.resolved||l.deletedAt);if(h!==i.attrs.orphan){const p=Math.max(s,0),k=Math.min(s+r.nodeSize,o.doc.content.size-1,o.doc.content.size-1);o.removeMark(p,k,i),o.addMark(p,k,c.create({...i.attrs,orphan:h})),h&&this.selectedThreadId===a&&(this.selectedThreadId=void 0,this.emitStateUpdate())}}})})})});if(this.editor=e,this.threadStore=o,this.markType=r,this.resolveUsers=s,this.commentEditorSchema=i,!s)throw new Error("resolveUsers is required for comments");this.userStore=new en(s),this.threadStore.subscribe(this.updateMarksFromThreads),e.onCreate(()=>{this.updateMarksFromThreads(this.threadStore.getThreads()),e.onSelectionChange(()=>{this.pendingComment&&(this.pendingComment=!1,this.emitStateUpdate())})});const c=this;this.addProsemirrorPlugin(new S.Plugin({key:J,state:{init(){return{decorations:M.DecorationSet.empty}},apply(a,l){const h=a.getMeta(J);if(!a.docChanged&&!h)return l;const p=a.docChanged?on(a.doc,c.markType):c.threadPositions;(p.size>0||c.threadPositions.size>0)&&(c.threadPositions=p,c.emitStateUpdate());const k=[];if(c.selectedThreadId){const g=p.get(c.selectedThreadId);g&&k.push(M.Decoration.inline(g.from,g.to,{class:"bn-thread-mark-selected"}))}return{decorations:M.DecorationSet.create(a.doc,k)}}},props:{decorations(a){var l;return((l=J.getState(a))==null?void 0:l.decorations)??M.DecorationSet.empty},handleClick:(a,l,h)=>{var y;if(h.button!==0)return;const p=a.state.doc.nodeAt(l);if(!p){c.selectThread(void 0);return}const k=a.state.schema.marks[r],g=a.state.doc.resolve(l),b=(y=p.marks.filter(w=>w.type.name===r&&w.attrs.orphan!==!0).map(w=>{const C=B.getMarkRange(g,k,w.attrs);return{mark:w,distance:(Math.abs(C.from-l)+Math.abs(C.to-l))/2,length:C.to-C.from}}).sort((w,C)=>w.distance!==C.distance?w.distance-C.distance:w.length-C.length)[0])==null?void 0:y.mark,f=b==null?void 0:b.attrs.threadId;c.selectThread(f)}}}))}static key(){return"comments"}emitStateUpdate(){this.emit("update",{selectedThreadId:this.selectedThreadId,pendingComment:this.pendingComment,threadPositions:this.threadPositions})}onUpdate(e){return this.on("update",e)}selectThread(e){var o,r;if(this.selectedThreadId!==e&&(this.selectedThreadId=e,this.emitStateUpdate(),this.editor.transact(s=>s.setMeta(J,{name:tn})),e)){const s=this.threadPositions.get(e);if(!s)return;(r=(o=this.editor.prosemirrorView)==null?void 0:o.domAtPos(s.from).node)==null||r.scrollIntoView({behavior:"smooth",block:"center"})}}startPendingComment(){this.pendingComment=!0,this.emitStateUpdate()}stopPendingComment(){this.pendingComment=!1,this.emitStateUpdate()}async createThread(e){const o=await this.threadStore.createThread(e);if(this.threadStore.addThreadToDocument){const r=this.editor.prosemirrorView,s=r.state.selection,i=E.ySyncPluginKey.getState(r.state),c={prosemirror:{head:s.head,anchor:s.anchor},yjs:i?E.getRelativeSelection(i.binding,r.state):void 0};await this.threadStore.addThreadToDocument({threadId:o.id,selection:c})}else this.editor._tiptapEditor.commands.setMark(this.markType,{orphan:!1,threadId:o.id})}}class rt{constructor(t,e,o,r){u(this,"state");u(this,"emitUpdate");u(this,"mouseDownHandler",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())});u(this,"dragstartHandler",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())});u(this,"scrollHandler",()=>{var t;if((t=this.state)!=null&&t.show){const e=this.pmView.root.querySelector(`[data-node-type="blockContainer"][data-id="${this.state.block.id}"]`);if(!e)return;this.state.referencePos=e.getBoundingClientRect(),this.emitUpdate()}});u(this,"closeMenu",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())});this.editor=t,this.pluginKey=e,this.pmView=o,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized file panel");r(this.state)},o.dom.addEventListener("mousedown",this.mouseDownHandler),o.dom.addEventListener("dragstart",this.dragstartHandler),o.root.addEventListener("scroll",this.scrollHandler,!0)}update(t,e){var c,a;const o=this.pluginKey.getState(t.state),r=this.pluginKey.getState(e);if(!((c=this.state)!=null&&c.show)&&(o!=null&&o.block)&&this.editor.isEditable){const l=this.pmView.root.querySelector(`[data-node-type="blockContainer"][data-id="${o.block.id}"]`);if(!l)return;this.state={show:!0,referencePos:l.getBoundingClientRect(),block:o.block},this.emitUpdate();return}const s=(o==null?void 0:o.block)&&!(r!=null&&r.block),i=!(o!=null&&o.block)&&(r==null?void 0:r.block);s&&this.state&&!this.state.show&&(this.state.show=!0,this.emitUpdate()),i&&((a=this.state)!=null&&a.show)&&(this.state.show=!1,this.emitUpdate())}destroy(){this.pmView.dom.removeEventListener("mousedown",this.mouseDownHandler),this.pmView.dom.removeEventListener("dragstart",this.dragstartHandler),this.pmView.root.removeEventListener("scroll",this.scrollHandler,!0)}}const le=new S.PluginKey("FilePanelPlugin");class st extends d.BlockNoteExtension{constructor(e){super();u(this,"view");u(this,"closeMenu",()=>{var e;return(e=this.view)==null?void 0:e.closeMenu()});this.addProsemirrorPlugin(new S.Plugin({key:le,view:o=>(this.view=new rt(e,le,o,r=>{this.emit("update",r)}),this.view),props:{handleKeyDown:(o,r)=>{var s;return r.key==="Escape"&&this.shown?((s=this.view)==null||s.closeMenu(),!0):!1}},state:{init:()=>({block:void 0}),apply:(o,r)=>{const s=o.getMeta(le);return s||(!o.getMeta(E.ySyncPluginKey)&&(o.selectionSet||o.docChanged)?{block:void 0}:r)}}}))}static key(){return"filePanel"}get shown(){var e,o;return((o=(e=this.view)==null?void 0:e.state)==null?void 0:o.show)||!1}onUpdate(e){return this.on("update",e)}}class it{constructor(t,e,o){u(this,"state");u(this,"emitUpdate");u(this,"preventHide",!1);u(this,"preventShow",!1);u(this,"shouldShow",({view:t,state:e,from:o,to:r})=>{const{doc:s,selection:i}=e,{empty:c}=i,a=!s.textBetween(o,r).length&&B.isTextSelection(e.selection);if(i.$from.parent.type.spec.code||B.isNodeSelection(i)&&i.node.type.spec.code||c||a)return!1;const l=document.activeElement;return!(!this.isElementWithinEditorWrapper(l)&&t.editable)});u(this,"blurHandler",t=>{var o;if(this.preventHide){this.preventHide=!1;return}const e=this.pmView.dom.parentElement;t&&t.relatedTarget&&(e===t.relatedTarget||e.contains(t.relatedTarget)||t.relatedTarget.matches(".bn-ui-container, .bn-ui-container *"))||(o=this.state)!=null&&o.show&&(this.state.show=!1,this.emitUpdate())});u(this,"isElementWithinEditorWrapper",t=>{if(!t)return!1;const e=this.pmView.dom.parentElement;return e?e.contains(t):!1});u(this,"viewMousedownHandler",t=>{(!this.isElementWithinEditorWrapper(t.target)||t.button===0)&&(this.preventShow=!0)});u(this,"mouseupHandler",()=>{this.preventShow&&(this.preventShow=!1,setTimeout(()=>this.update(this.pmView)))});u(this,"dragHandler",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())});u(this,"scrollHandler",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.referencePos=this.getSelectionBoundingBox(),this.emitUpdate())});u(this,"closeMenu",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())});this.editor=t,this.pmView=e,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized formatting toolbar");o(this.state)},e.dom.addEventListener("mousedown",this.viewMousedownHandler),e.root.addEventListener("mouseup",this.mouseupHandler),e.dom.addEventListener("dragstart",this.dragHandler),e.dom.addEventListener("dragover",this.dragHandler),e.dom.addEventListener("blur",this.blurHandler),e.root.addEventListener("scroll",this.scrollHandler,!0)}update(t,e){var g,b,f;const{state:o,composing:r}=t,{doc:s,selection:i}=o,c=e&&e.doc.eq(s)&&e.selection.eq(i);if(r||c)return;const{ranges:a}=i,l=Math.min(...a.map(y=>y.$from.pos)),h=Math.max(...a.map(y=>y.$to.pos)),p=this.shouldShow({view:t,state:o,from:l,to:h}),k=typeof Range.prototype.getClientRects>"u";if(!this.preventShow&&(p||this.preventHide)&&!k){const y=this.getSelectionBoundingBox();if(y.height===0&&y.width===0){queueMicrotask(()=>{const C={show:!0,referencePos:this.getSelectionBoundingBox()};this.state=C,this.emitUpdate(),t.dispatch(t.state.tr.setSelection(S.TextSelection.create(t.state.doc,t.state.selection.from+1,t.state.selection.to))),t.dispatch(t.state.tr.setSelection(S.TextSelection.create(t.state.doc,t.state.selection.from-1,t.state.selection.to)))});return}const w={show:!0,referencePos:this.getSelectionBoundingBox()};(w.show!==((g=this.state)==null?void 0:g.show)||w.referencePos.toJSON()!==((b=this.state)==null?void 0:b.referencePos.toJSON()))&&(this.state=w,this.emitUpdate());return}if((f=this.state)!=null&&f.show&&!this.preventHide&&(!p||this.preventShow||!this.editor.isEditable)){this.state.show=!1,this.emitUpdate();return}}destroy(){this.pmView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.pmView.root.removeEventListener("mouseup",this.mouseupHandler),this.pmView.dom.removeEventListener("dragstart",this.dragHandler),this.pmView.dom.removeEventListener("dragover",this.dragHandler),this.pmView.dom.removeEventListener("blur",this.blurHandler),this.pmView.root.removeEventListener("scroll",this.scrollHandler,!0)}getSelectionBoundingBox(){const{state:t}=this.pmView,{selection:e}=t,{ranges:o}=e,r=Math.min(...o.map(i=>i.$from.pos)),s=Math.max(...o.map(i=>i.$to.pos));if(B.isNodeSelection(e)){const i=this.pmView.nodeDOM(r);if(i)return i.getBoundingClientRect()}return B.posToDOMRect(this.pmView,r,s)}}const at=new S.PluginKey("FormattingToolbarPlugin");class ct extends d.BlockNoteExtension{constructor(e){super();u(this,"view");u(this,"closeMenu",()=>this.view.closeMenu());this.addProsemirrorPlugin(new S.Plugin({key:at,view:o=>(this.view=new it(e,o,r=>{this.emit("update",r)}),this.view),props:{handleKeyDown:(o,r)=>r.key==="Escape"&&this.shown?(this.view.closeMenu(),!0):!1}}))}static key(){return"formattingToolbar"}get shown(){var e,o;return((o=(e=this.view)==null?void 0:e.state)==null?void 0:o.show)||!1}onUpdate(e){return this.on("update",e)}}const nn=B.Node.create({name:"hardBreak",inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,priority:10,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",B.mergeAttributes(this.options.HTMLAttributes,n)]},renderText(){return`
|
|
4
|
-
`}}),he=(n,t)=>{const e=n.resolve(t),o=e.index();if(o===0)return;const r=e.posAtIndex(o-1);return m.getBlockInfoFromResolvedPos(n.resolve(r))},lt=(n,t)=>{for(;t.childContainer;){const e=t.childContainer.node,o=n.resolve(t.childContainer.beforePos+1).posAtIndex(e.childCount-1);t=m.getBlockInfoFromResolvedPos(n.resolve(o))}return t},rn=(n,t)=>n.isBlockContainer&&n.blockContent.node.type.spec.content==="inline*"&&n.blockContent.node.childCount>0&&t.isBlockContainer&&t.blockContent.node.type.spec.content==="inline*",sn=(n,t,e,o)=>{if(!o.isBlockContainer)throw new Error(`Attempted to merge block at position ${o.bnBlock.beforePos} into previous block at position ${e.bnBlock.beforePos}, but next block is not a block container`);if(o.childContainer){const r=n.doc.resolve(o.childContainer.beforePos+1),s=n.doc.resolve(o.childContainer.afterPos-1),i=r.blockRange(s);if(t){const c=n.doc.resolve(o.bnBlock.beforePos);n.tr.lift(i,c.depth)}}if(t){if(!e.isBlockContainer)throw new Error(`Attempted to merge block at position ${o.bnBlock.beforePos} into previous block at position ${e.bnBlock.beforePos}, but previous block is not a block container`);t(n.tr.delete(e.blockContent.afterPos-1,o.blockContent.beforePos+1))}return!0},Ne=n=>({state:t,dispatch:e})=>{const o=t.doc.resolve(n),r=m.getBlockInfoFromResolvedPos(o),s=he(t.doc,r.bnBlock.beforePos);if(!s)return!1;const i=lt(t.doc,s);return rn(i,r)?sn(t,e,i,r):!1};function an(n,t,e){const{$from:o,$to:r}=n.selection,s=o.blockRange(r,b=>b.childCount>0&&(b.type.name==="blockGroup"||b.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!==t)return!1;const l=a.lastChild&&a.lastChild.type===e,h=T.Fragment.from(l?t.create():null),p=new T.Slice(T.Fragment.from(t.create(null,T.Fragment.from(e.create(null,h)))),l?3:1,0),k=s.start,g=s.end;return n.step(new W.ReplaceAroundStep(k-(l?3:1),g,k,g,p,1,!0)).scrollIntoView(),!0}function dt(n){return n.transact(t=>an(t,n.pmSchema.nodes.blockContainer,n.pmSchema.nodes.blockGroup))}function cn(n){n._tiptapEditor.commands.liftListItem("blockContainer")}function ln(n){return n.transact(t=>{const{bnBlock:e}=m.getBlockInfoFromTransaction(t);return t.doc.resolve(e.beforePos).nodeBefore!==null})}function dn(n){return n.transact(t=>{const{bnBlock:e}=m.getBlockInfoFromTransaction(t);return t.doc.resolve(e.beforePos).depth>1})}const un=B.Extension.create({priority:50,addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({chain:o,commands:r})=>[()=>r.deleteSelection(),()=>r.undoInputRule(),()=>r.command(({state:s})=>{const i=m.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;const c=s.selection.from===i.blockContent.beforePos+1,a=i.blockContent.node.type.name==="paragraph";return c&&!a?r.command(d.updateBlockCommand(i.bnBlock.beforePos,{type:"paragraph",props:{}})):!1}),()=>r.command(({state:s})=>{const i=m.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;const{blockContent:c}=i;return s.selection.from===c.beforePos+1?r.liftListItem("blockContainer"):!1}),()=>r.command(({state:s})=>{const i=m.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;const{bnBlock:c,blockContent:a}=i,l=s.selection.from===a.beforePos+1,h=s.selection.empty,p=c.beforePos;return l&&h?o().command(Ne(p)).scrollIntoView().run():!1}),()=>r.command(({state:s,tr:i,dispatch:c})=>{const a=m.getBlockInfoFromSelection(s);if(!a.isBlockContainer||!(i.selection.from===a.blockContent.beforePos+1))return!1;const h=i.doc.resolve(a.bnBlock.beforePos);if(h.nodeBefore||h.node().type.name!=="column")return!1;const g=i.doc.resolve(a.bnBlock.beforePos),b=i.doc.resolve(g.before()),f=b.before();if(c){const y=i.doc.slice(a.bnBlock.beforePos,a.bnBlock.afterPos).content;i.delete(a.bnBlock.beforePos,a.bnBlock.afterPos),b.index()===0?(oe(i,f),i.insert(f,y),i.setSelection(S.TextSelection.near(i.doc.resolve(f)))):(i.insert(b.pos-1,y),i.setSelection(S.TextSelection.near(i.doc.resolve(b.pos-1))),oe(i,f))}return!0}),()=>r.command(({state:s})=>{const i=m.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;if(i.blockContent.node.childCount===0&&i.blockContent.node.type.spec.content==="inline*"){const a=he(s.doc,i.bnBlock.beforePos);if(!a||!a.isBlockContainer)return!1;let l=o();if(a.blockContent.node.type.spec.content==="tableRow+"){const b=i.bnBlock.beforePos-1-1-1-1-1;l=l.setTextSelection(b)}else if(a.blockContent.node.type.spec.content===""){const h=a.blockContent.afterPos-a.blockContent.node.nodeSize;l=l.setNodeSelection(h)}else{const h=a.blockContent.afterPos-a.blockContent.node.nodeSize;l=l.setTextSelection(h)}return l.deleteRange({from:i.bnBlock.beforePos,to:i.bnBlock.afterPos}).scrollIntoView().run()}return!1}),()=>r.command(({state:s})=>{const i=m.getBlockInfoFromSelection(s);if(!i.isBlockContainer)throw new Error("todo");const c=s.selection.from===i.blockContent.beforePos+1,a=s.selection.empty,l=he(s.doc,i.bnBlock.beforePos);if(l&&c&&a){const h=lt(s.doc,l);if(!h.isBlockContainer)throw new Error("todo");if(h.blockContent.node.type.spec.content===""||h.blockContent.node.type.spec.content==="inline*"&&h.blockContent.node.childCount===0)return o().cut({from:i.bnBlock.beforePos,to:i.bnBlock.afterPos},h.bnBlock.afterPos).deleteRange({from:h.bnBlock.beforePos,to:h.bnBlock.afterPos}).run()}return!1})]),t=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.command(({state:r})=>{const s=m.getBlockInfoFromSelection(r);if(!s.isBlockContainer)return!1;const{bnBlock:i,blockContent:c,childContainer:a}=s,{depth:l}=r.doc.resolve(i.beforePos),h=i.afterPos===r.doc.nodeSize-3,p=r.selection.from===c.afterPos-1,k=r.selection.empty;if(!h&&p&&k&&!(a!==void 0)){let b=l,f=i.afterPos+1,y=r.doc.resolve(f).depth;for(;y<b;)b=y,f+=2,y=r.doc.resolve(f).depth;return o.command(Ne(f-1))}return!1})]),e=(o=!1)=>this.editor.commands.first(({commands:r,tr:s})=>[()=>r.command(({state:i})=>{const c=m.getBlockInfoFromSelection(i);if(!c.isBlockContainer)return!1;const{bnBlock:a,blockContent:l}=c,{depth:h}=i.doc.resolve(a.beforePos),p=i.selection.$anchor.parentOffset===0,k=i.selection.anchor===i.selection.head,g=l.node.childCount===0,b=h>1;return p&&k&&g&&b?r.liftListItem("blockContainer"):!1}),()=>r.command(({state:i})=>{var l;const c=m.getBlockInfoFromSelection(i),a=((l=this.options.editor.schema.blockSchema[c.blockNoteType].meta)==null?void 0:l.hardBreakShortcut)??"shift+enter";if(a==="none")return!1;if(a==="shift+enter"&&o||a==="enter"){const h=s.storedMarks||s.selection.$head.marks().filter(p=>this.editor.extensionManager.splittableMarks.includes(p.type.name));return s.insert(s.selection.head,s.doc.type.schema.nodes.hardBreak.create()).ensureMarks(h),!0}return!1}),()=>r.command(({state:i,dispatch:c})=>{const a=m.getBlockInfoFromSelection(i);if(!a.isBlockContainer)return!1;const{bnBlock:l,blockContent:h}=a,p=i.selection.$anchor.parentOffset===0,k=i.selection.anchor===i.selection.head,g=h.node.childCount===0;if(p&&k&&g){const b=l.afterPos,f=b+2;if(c){const y=i.schema.nodes.blockContainer.createAndFill();i.tr.insert(b,y).scrollIntoView(),i.tr.setSelection(new S.TextSelection(i.doc.resolve(f)))}return!0}return!1}),()=>r.command(({state:i,chain:c})=>{const a=m.getBlockInfoFromSelection(i);if(!a.isBlockContainer)return!1;const{blockContent:l}=a,h=i.selection.$anchor.parentOffset===0;return l.node.childCount===0?!1:(c().deleteSelection().command(d.splitBlockCommand(i.selection.from,h,h)).run(),!0)})]);return{Backspace:n,Delete:t,Enter:()=>e(),"Shift-Enter":()=>e(!0),Tab:()=>{var o,r,s;return this.options.tabBehavior!=="prefer-indent"&&((o=this.options.editor.formattingToolbar)!=null&&o.shown||(r=this.options.editor.linkToolbar)!=null&&r.shown||(s=this.options.editor.filePanel)!=null&&s.shown)?!1:dt(this.options.editor)},"Shift-Tab":()=>{var o,r,s;return this.options.tabBehavior!=="prefer-indent"&&((o=this.options.editor.formattingToolbar)!=null&&o.shown||(r=this.options.editor.linkToolbar)!=null&&r.shown||(s=this.options.editor.filePanel)!=null&&s.shown)?!1:(this.editor.commands.liftListItem("blockContainer"),!0)},"Shift-Mod-ArrowUp":()=>(this.options.editor.moveBlocksUp(),!0),"Shift-Mod-ArrowDown":()=>(this.options.editor.moveBlocksDown(),!0),"Mod-z":()=>this.options.editor.undo(),"Mod-y":()=>this.options.editor.redo(),"Shift-Mod-z":()=>this.options.editor.redo()}}});class hn{constructor(t,e,o){u(this,"state");u(this,"emitUpdate");u(this,"menuUpdateTimer");u(this,"startMenuUpdateTimer");u(this,"stopMenuUpdateTimer");u(this,"mouseHoveredLinkMark");u(this,"mouseHoveredLinkMarkRange");u(this,"keyboardHoveredLinkMark");u(this,"keyboardHoveredLinkMarkRange");u(this,"linkMark");u(this,"linkMarkRange");u(this,"mouseOverHandler",t=>{if(this.mouseHoveredLinkMark=void 0,this.mouseHoveredLinkMarkRange=void 0,this.stopMenuUpdateTimer(),t.target instanceof HTMLAnchorElement&&t.target.nodeName==="A"){const e=t.target,o=this.pmView.posAtDOM(e,0)+1,r=this.pmView.state.doc.resolve(o),s=r.marks();for(const i of s)if(i.type.name===this.pmView.state.schema.mark("link").type.name){this.mouseHoveredLinkMark=i,this.mouseHoveredLinkMarkRange=B.getMarkRange(r,i.type,i.attrs)||void 0;break}}return this.startMenuUpdateTimer(),!1});u(this,"clickHandler",t=>{var o;const e=this.pmView.dom.parentElement;this.linkMark&&t&&t.target&&!(e===t.target||e.contains(t.target))&&(o=this.state)!=null&&o.show&&(this.state.show=!1,this.emitUpdate())});u(this,"scrollHandler",()=>{var t;this.linkMark!==void 0&&(t=this.state)!=null&&t.show&&(this.state.referencePos=B.posToDOMRect(this.pmView,this.linkMarkRange.from,this.linkMarkRange.to),this.emitUpdate())});u(this,"closeMenu",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())});this.editor=t,this.pmView=e,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized link toolbar");o(this.state)},this.startMenuUpdateTimer=()=>{this.menuUpdateTimer=setTimeout(()=>{this.update(this.pmView,void 0,!0)},250)},this.stopMenuUpdateTimer=()=>(this.menuUpdateTimer&&(clearTimeout(this.menuUpdateTimer),this.menuUpdateTimer=void 0),!1),this.pmView.dom.addEventListener("mouseover",this.mouseOverHandler),this.pmView.root.addEventListener("click",this.clickHandler,!0),this.pmView.root.addEventListener("scroll",this.scrollHandler,!0)}editLink(t,e){var o;this.editor.transact(r=>{const s=m.getPmSchema(r);r.insertText(e,this.linkMarkRange.from,this.linkMarkRange.to),r.addMark(this.linkMarkRange.from,this.linkMarkRange.from+e.length,s.mark("link",{href:t}))}),this.pmView.focus(),(o=this.state)!=null&&o.show&&(this.state.show=!1,this.emitUpdate())}deleteLink(){var t;this.editor.transact(e=>e.removeMark(this.linkMarkRange.from,this.linkMarkRange.to,this.linkMark.type).setMeta("preventAutolink",!0)),this.pmView.focus(),(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())}update(t,e,o=!1){var c;const{state:r}=t;if(e&&e.selection.from===r.selection.from&&e.selection.to===r.selection.to||!this.pmView.hasFocus())return;const i=this.linkMark;if(this.linkMark=void 0,this.linkMarkRange=void 0,this.keyboardHoveredLinkMark=void 0,this.keyboardHoveredLinkMarkRange=void 0,this.pmView.state.selection.empty){const a=this.pmView.state.selection.$from.marks();for(const l of a)if(l.type.name===this.pmView.state.schema.mark("link").type.name){this.keyboardHoveredLinkMark=l,this.keyboardHoveredLinkMarkRange=B.getMarkRange(this.pmView.state.selection.$from,l.type,l.attrs)||void 0;break}}if(this.mouseHoveredLinkMark&&o&&(this.linkMark=this.mouseHoveredLinkMark,this.linkMarkRange=this.mouseHoveredLinkMarkRange),this.keyboardHoveredLinkMark&&(this.linkMark=this.keyboardHoveredLinkMark,this.linkMarkRange=this.keyboardHoveredLinkMarkRange),this.linkMark&&this.editor.isEditable){this.state={show:!0,referencePos:B.posToDOMRect(this.pmView,this.linkMarkRange.from,this.linkMarkRange.to),url:this.linkMark.attrs.href,text:this.pmView.state.doc.textBetween(this.linkMarkRange.from,this.linkMarkRange.to)},this.emitUpdate();return}if((c=this.state)!=null&&c.show&&i&&(!this.linkMark||!this.editor.isEditable)){this.state.show=!1,this.emitUpdate();return}}destroy(){this.pmView.dom.removeEventListener("mouseover",this.mouseOverHandler),this.pmView.root.removeEventListener("scroll",this.scrollHandler,!0),this.pmView.root.removeEventListener("click",this.clickHandler,!0)}}const ut=new S.PluginKey("LinkToolbarPlugin");class ht extends d.BlockNoteExtension{constructor(e){super();u(this,"view");u(this,"editLink",(e,o)=>{this.view.editLink(e,o)});u(this,"deleteLink",()=>{this.view.deleteLink()});u(this,"startHideTimer",()=>{this.view.startMenuUpdateTimer()});u(this,"stopHideTimer",()=>{this.view.stopMenuUpdateTimer()});u(this,"closeMenu",()=>this.view.closeMenu());this.addProsemirrorPlugin(new S.Plugin({key:ut,view:o=>(this.view=new hn(e,o,r=>{this.emit("update",r)}),this.view),props:{handleKeyDown:(o,r)=>r.key==="Escape"&&this.shown?(this.view.closeMenu(),!0):!1}}))}static key(){return"linkToolbar"}onUpdate(e){return this.on("update",e)}get shown(){var e,o;return((o=(e=this.view)==null?void 0:e.state)==null?void 0:o.show)||!1}}const pt=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"],mt="https",pn=new S.PluginKey("node-selection-keyboard");class mn extends d.BlockNoteExtension{static key(){return"nodeSelectionKeyboard"}constructor(){super(),this.addProsemirrorPlugin(new S.Plugin({key:pn,props:{handleKeyDown:(t,e)=>{if("node"in t.state.selection){if(e.ctrlKey||e.metaKey)return!1;if(e.key.length===1)return e.preventDefault(),!0;if(e.key==="Enter"&&!e.shiftKey&&!e.altKey&&!e.ctrlKey&&!e.metaKey){const o=t.state.tr;return t.dispatch(o.insert(t.state.tr.selection.$to.after(),t.state.schema.nodes.paragraph.createChecked()).setSelection(new S.TextSelection(o.doc.resolve(t.state.tr.selection.$to.after()+1)))),!0}}return!1}}}))}}const fn=new S.PluginKey("blocknote-placeholder");class gn extends d.BlockNoteExtension{static key(){return"placeholder"}constructor(t,e){super(),this.addProsemirrorPlugin(new S.Plugin({key:fn,view:o=>{const r=`placeholder-selector-${ro.v4()}`;o.dom.classList.add(r);const s=document.createElement("style"),i=t._tiptapEditor.options.injectNonce;i&&s.setAttribute("nonce",i),o.root instanceof window.ShadowRoot?o.root.append(s):o.root.head.appendChild(s);const c=s.sheet,a=(l="")=>`.${r} .bn-block-content${l} .bn-inline-content:has(> .ProseMirror-trailingBreak:only-child):before`;try{const{default:l,emptyDocument:h,...p}=e;for(const[b,f]of Object.entries(p)){const y=`[data-content-type="${b}"]`;c.insertRule(`${a(y)} { content: ${JSON.stringify(f)}; }`)}const k="[data-is-only-empty-block]",g="[data-is-empty-and-focused]";c.insertRule(`${a(k)} { content: ${JSON.stringify(h)}; }`),c.insertRule(`${a(g)} { content: ${JSON.stringify(l)}; }`)}catch(l){console.warn("Failed to insert placeholder CSS rule - this is likely due to the browser not supporting certain CSS pseudo-element selectors (:has, :only-child:, or :before)",l)}return{destroy:()=>{o.root instanceof window.ShadowRoot?o.root.removeChild(s):o.root.head.removeChild(s)}}},props:{decorations:o=>{const{doc:r,selection:s}=o;if(!t.isEditable||!s.empty||s.$from.parent.type.spec.code)return;const i=[];o.doc.content.size===6&&i.push(M.Decoration.node(2,4,{"data-is-only-empty-block":"true"}));const c=s.$anchor,a=c.parent;if(a.content.size===0){const l=c.before();i.push(M.Decoration.node(l,l+a.nodeSize,{"data-is-empty-and-focused":"true"}))}return M.DecorationSet.create(r,i)}}}))}}const Ae=new S.PluginKey("previous-blocks"),kn={index:"index",level:"level",type:"type",depth:"depth","depth-change":"depth-change"};class bn extends d.BlockNoteExtension{static key(){return"previousBlockType"}constructor(){super();let t;this.addProsemirrorPlugin(new S.Plugin({key:Ae,view(e){return{update:async(o,r)=>{var s;((s=this.key)==null?void 0:s.getState(o.state).updatedBlocks.size)>0&&(t=setTimeout(()=>{o.dispatch(o.state.tr.setMeta(Ae,{clearUpdate:!0}))},0))},destroy:()=>{t&&clearTimeout(t)}}},state:{init(){return{prevTransactionOldBlockAttrs:{},currentTransactionOldBlockAttrs:{},updatedBlocks:new Set}},apply(e,o,r,s){if(o.currentTransactionOldBlockAttrs={},o.updatedBlocks.clear(),!e.docChanged||r.doc.eq(s.doc))return o;const i={},c=B.findChildren(r.doc,h=>h.attrs.id),a=new Map(c.map(h=>[h.node.attrs.id,h])),l=B.findChildren(s.doc,h=>h.attrs.id);for(const h of l){const p=a.get(h.node.attrs.id),k=p==null?void 0:p.node.firstChild,g=h.node.firstChild;if(p&&k&&g){const b={index:g.attrs.index,level:g.attrs.level,type:g.type.name,depth:s.doc.resolve(h.pos).depth},f={index:k.attrs.index,level:k.attrs.level,type:k.type.name,depth:r.doc.resolve(p.pos).depth};i[h.node.attrs.id]=f,o.currentTransactionOldBlockAttrs[h.node.attrs.id]=f,JSON.stringify(f)!==JSON.stringify(b)&&(f["depth-change"]=f.depth-b.depth,o.updatedBlocks.add(h.node.attrs.id))}}return o.prevTransactionOldBlockAttrs=i,o}},props:{decorations(e){const o=this.getState(e);if(o.updatedBlocks.size===0)return;const r=[];return e.doc.descendants((s,i)=>{if(!s.attrs.id||!o.updatedBlocks.has(s.attrs.id))return;const c=o.currentTransactionOldBlockAttrs[s.attrs.id],a={};for(const[h,p]of Object.entries(c))a["data-prev-"+kn[h]]=p||"none";const l=M.Decoration.node(i,i+s.nodeSize,{...a});r.push(l)}),M.DecorationSet.create(e.doc,r)}}}))}}const _e=new S.PluginKey("blocknote-show-selection");class yn extends d.BlockNoteExtension{constructor(e){super();u(this,"enabled",!1);this.editor=e,this.addProsemirrorPlugin(new S.Plugin({key:_e,props:{decorations:o=>{const{doc:r,selection:s}=o;if(!this.enabled)return M.DecorationSet.empty;const i=M.Decoration.inline(s.from,s.to,{"data-show-selection":"true"});return M.DecorationSet.create(r,[i])}}}))}static key(){return"showSelection"}setEnabled(e){this.enabled!==e&&(this.enabled=e,this.editor.transact(o=>o.setMeta(_e,{})))}getEnabled(){return this.enabled}}function ft(n,t){var e,o;for(;n&&n.parentElement&&n.parentElement!==t.dom&&((e=n.getAttribute)==null?void 0:e.call(n,"data-node-type"))!=="blockContainer";)n=n.parentElement;if(((o=n.getAttribute)==null?void 0:o.call(n,"data-node-type"))==="blockContainer")return{node:n,id:n.getAttribute("data-id")}}class F extends S.Selection{constructor(e,o){super(e,o);u(this,"nodes");const r=e.node();this.nodes=[],e.doc.nodesBetween(e.pos,o.pos,(s,i,c)=>{if(c!==null&&c.eq(r))return this.nodes.push(s),!1})}static create(e,o,r=o){return new F(e.resolve(o),e.resolve(r))}content(){return new T.Slice(T.Fragment.from(this.nodes),0,0)}eq(e){if(!(e instanceof F)||this.nodes.length!==e.nodes.length||this.from!==e.from||this.to!==e.to)return!1;for(let o=0;o<this.nodes.length;o++)if(!this.nodes[o].eq(e.nodes[o]))return!1;return!0}map(e,o){const r=o.mapResult(this.from),s=o.mapResult(this.to);return s.deleted?S.Selection.near(e.resolve(r.pos)):r.deleted?S.Selection.near(e.resolve(s.pos)):new F(e.resolve(r.pos),e.resolve(s.pos))}toJSON(){return{type:"multiple-node",anchor:this.anchor,head:this.head}}}S.Selection.jsonID("multiple-node",F);let O;function wn(n,t){let e,o;const r=t.resolve(n.from).node().type.spec.group==="blockContent",s=t.resolve(n.to).node().type.spec.group==="blockContent",i=Math.min(n.$anchor.depth,n.$head.depth);if(r&&s){const c=n.$from.start(i-1),a=n.$to.end(i-1);e=t.resolve(c-1).pos,o=t.resolve(a+1).pos}else e=n.from,o=n.to;return{from:e,to:o}}function Oe(n,t,e=t){t===e&&(e+=n.state.doc.resolve(t+1).node().nodeSize);const o=n.domAtPos(t).node.cloneNode(!0),r=n.domAtPos(t).node,s=(p,k)=>Array.prototype.indexOf.call(p.children,k),i=s(r,n.domAtPos(t+1).node.parentElement),c=s(r,n.domAtPos(e-1).node.parentElement);for(let p=r.childElementCount-1;p>=0;p--)(p>c||p<i)&&o.removeChild(o.children[p]);gt(n.root),O=o;const a=O.getElementsByTagName("iframe");for(let p=0;p<a.length;p++){const k=a[p],g=k.parentElement;g&&g.removeChild(k)}const h=n.dom.className.split(" ").filter(p=>p!=="ProseMirror"&&p!=="bn-root"&&p!=="bn-editor").join(" ");O.className=O.className+" bn-drag-preview "+h,n.root instanceof ShadowRoot?n.root.appendChild(O):n.root.body.appendChild(O)}function gt(n){O!==void 0&&(n instanceof ShadowRoot?n.removeChild(O):n.body.removeChild(O),O=void 0)}function Sn(n,t,e){if(!n.dataTransfer||e.headless)return;const o=e.prosemirrorView,r=d.getNodeById(t.id,o.state.doc);if(!r)throw new Error(`Block with ID ${t.id} not found`);const s=r.posBeforeNode;if(s!=null){const i=o.state.selection,c=o.state.doc,{from:a,to:l}=wn(i,c),h=a<=s&&s<l,p=i.$anchor.node()!==i.$head.node()||i instanceof F;h&&p?(o.dispatch(o.state.tr.setSelection(F.create(c,a,l))),Oe(o,a,l)):(o.dispatch(o.state.tr.setSelection(S.NodeSelection.create(o.state.doc,s))),Oe(o,s));const k=o.state.selection.content(),g=e.pmSchema,b=o.serializeForClipboard(k).dom.innerHTML,f=X(g,e),y=et(k.content),w=f.exportBlocks(y,{}),C=ie(w);n.dataTransfer.clearData(),n.dataTransfer.setData("blocknote/html",b),n.dataTransfer.setData("text/html",w),n.dataTransfer.setData("text/plain",C),n.dataTransfer.effectAllowed="move",n.dataTransfer.setDragImage(O,0,0)}}const He=250;function pe(n,t,e=!0){const o=n.root.elementsFromPoint(t.left,t.top);for(const r of o)if(n.dom.contains(r))return e&&r.closest("[data-node-type=columnList]")?pe(n,{left:t.left+50,top:t.top},!1):ft(r,n)}function Cn(n,t){if(!t.dom.firstChild)return;const e=t.dom.firstChild.getBoundingClientRect(),o={left:Math.min(Math.max(e.left+10,n.x),e.right-10),top:n.y},r=pe(t,o);if(!r)return;const s=r.node.getBoundingClientRect();return pe(t,{left:s.right-10,top:n.y},!1)}class kt{constructor(t,e,o){u(this,"state");u(this,"emitUpdate");u(this,"mousePos");u(this,"hoveredBlock");u(this,"menuFrozen",!1);u(this,"isDragOrigin",!1);u(this,"updateState",t=>{this.state=t,this.emitUpdate(this.state)});u(this,"updateStateFromMousePos",()=>{var o,r,s,i,c;if(this.menuFrozen||!this.mousePos)return;const t=this.findClosestEditorElement({clientX:this.mousePos.x,clientY:this.mousePos.y});if((t==null?void 0:t.element)!==this.pmView.dom||t.distance>He){(o=this.state)!=null&&o.show&&(this.state.show=!1,this.updateState(this.state));return}const e=Cn(this.mousePos,this.pmView);if(!e||!this.editor.isEditable){(r=this.state)!=null&&r.show&&(this.state.show=!1,this.updateState(this.state));return}if(!((s=this.state)!=null&&s.show&&((i=this.hoveredBlock)!=null&&i.hasAttribute("data-id"))&&((c=this.hoveredBlock)==null?void 0:c.getAttribute("data-id"))===e.id)&&(this.hoveredBlock=e.node,this.editor.isEditable)){const a=e.node.getBoundingClientRect(),l=e.node.closest("[data-node-type=column]");this.state={show:!0,referencePos:new DOMRect(l?l.firstElementChild.getBoundingClientRect().x:this.pmView.dom.firstChild.getBoundingClientRect().x,a.y,a.width,a.height),block:this.editor.getBlock(this.hoveredBlock.getAttribute("data-id"))},this.updateState(this.state)}});u(this,"onDragStart",t=>{var i;const e=(i=t.dataTransfer)==null?void 0:i.getData("blocknote/html");if(!e||this.pmView.dragging)return;const o=document.createElement("div");o.innerHTML=e;const s=T.DOMParser.fromSchema(this.pmView.state.schema).parse(o,{topNode:this.pmView.state.schema.nodes.blockGroup.create()});this.pmView.dragging={slice:new T.Slice(s.content,0,0),move:!0}});u(this,"findClosestEditorElement",t=>{const e=Array.from(this.pmView.root.querySelectorAll(".bn-editor"));if(e.length===0)return null;let o=e[0],r=Number.MAX_VALUE;return e.forEach(s=>{const i=s.querySelector(".bn-block-group").getBoundingClientRect(),c=t.clientX<i.left?i.left-t.clientX:t.clientX>i.right?t.clientX-i.right:0,a=t.clientY<i.top?i.top-t.clientY:t.clientY>i.bottom?t.clientY-i.bottom:0,l=Math.sqrt(Math.pow(c,2)+Math.pow(a,2));l<r&&(r=l,o=s)}),{element:o,distance:r}});u(this,"onDragOver",t=>{if(t.synthetic)return;const e=this.getDragEventContext(t);if(!e||!e.isDropPoint){this.closeDropCursor();return}e.isDropPoint&&!e.isDropWithinEditorBounds&&this.dispatchSyntheticEvent(t)});u(this,"closeDropCursor",()=>{const t=new Event("dragleave",{bubbles:!1});t.synthetic=!0,this.pmView.dom.dispatchEvent(t)});u(this,"getDragEventContext",t=>{var a;const e=!((a=t.dataTransfer)!=null&&a.types.includes("blocknote/html"))&&!!this.pmView.dragging,o=!!this.isDragOrigin,r=e||o,s=this.findClosestEditorElement(t);if(!s||s.distance>He)return;const i=s.element===this.pmView.dom,c=i&&s.distance===0;if(!(!i&&!r))return{isDropPoint:i,isDropWithinEditorBounds:c,isDragOrigin:r}});u(this,"onDrop",t=>{if(t.synthetic)return;const e=this.getDragEventContext(t);if(!e){this.closeDropCursor();return}const{isDropPoint:o,isDropWithinEditorBounds:r,isDragOrigin:s}=e;if(!r&&o&&this.dispatchSyntheticEvent(t),o){if(this.pmView.dragging)return;this.pmView.dispatch(this.pmView.state.tr.setSelection(S.TextSelection.create(this.pmView.state.tr.doc,this.pmView.state.tr.selection.anchor)));return}else if(s){setTimeout(()=>this.pmView.dispatch(this.pmView.state.tr.deleteSelection()),0);return}});u(this,"onDragEnd",t=>{t.synthetic||(this.pmView.dragging=null)});u(this,"onKeyDown",t=>{var e;(e=this.state)!=null&&e.show&&this.editor.isFocused()&&(this.state.show=!1,this.emitUpdate(this.state))});u(this,"onMouseMove",t=>{var s;if(this.menuFrozen)return;this.mousePos={x:t.clientX,y:t.clientY};const e=this.pmView.dom.getBoundingClientRect(),o=this.mousePos.x>e.left&&this.mousePos.x<e.right&&this.mousePos.y>e.top&&this.mousePos.y<e.bottom,r=this.pmView.dom.parentElement;if(o&&t&&t.target&&!(r===t.target||r.contains(t.target))){(s=this.state)!=null&&s.show&&(this.state.show=!1,this.emitUpdate(this.state));return}this.updateStateFromMousePos()});u(this,"onScroll",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.referencePos=this.hoveredBlock.getBoundingClientRect(),this.emitUpdate(this.state)),this.updateStateFromMousePos()});this.editor=t,this.pmView=e,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized side menu");o(this.state)},this.pmView.root.addEventListener("dragstart",this.onDragStart),this.pmView.root.addEventListener("dragover",this.onDragOver),this.pmView.root.addEventListener("drop",this.onDrop,!0),this.pmView.root.addEventListener("dragend",this.onDragEnd,!0),this.pmView.root.addEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.addEventListener("keydown",this.onKeyDown,!0),e.root.addEventListener("scroll",this.onScroll,!0)}dispatchSyntheticEvent(t){const e=new Event(t.type,t),o=this.pmView.dom.firstChild.getBoundingClientRect();e.clientX=t.clientX,e.clientY=t.clientY,e.clientX=Math.min(Math.max(t.clientX,o.left),o.left+o.width),e.clientY=Math.min(Math.max(t.clientY,o.top),o.top+o.height),e.dataTransfer=t.dataTransfer,e.preventDefault=()=>t.preventDefault(),e.synthetic=!0,this.pmView.dom.dispatchEvent(e)}update(t,e){var r;!e.doc.eq(this.pmView.state.doc)&&((r=this.state)!=null&&r.show)&&this.updateStateFromMousePos()}destroy(){var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate(this.state)),this.pmView.root.removeEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.removeEventListener("dragstart",this.onDragStart),this.pmView.root.removeEventListener("dragover",this.onDragOver),this.pmView.root.removeEventListener("drop",this.onDrop,!0),this.pmView.root.removeEventListener("dragend",this.onDragEnd,!0),this.pmView.root.removeEventListener("keydown",this.onKeyDown,!0),this.pmView.root.removeEventListener("scroll",this.onScroll,!0)}}const bt=new S.PluginKey("SideMenuPlugin");class yt extends d.BlockNoteExtension{constructor(e){super();u(this,"view");u(this,"blockDragStart",(e,o)=>{this.view&&(this.view.isDragOrigin=!0),Sn(e,o,this.editor)});u(this,"blockDragEnd",()=>{gt(this.editor.prosemirrorView.root),this.view&&(this.view.isDragOrigin=!1),this.editor.blur()});u(this,"freezeMenu",()=>{this.view.menuFrozen=!0,this.view.state.show=!0,this.view.emitUpdate(this.view.state)});u(this,"unfreezeMenu",()=>{this.view.menuFrozen=!1,this.view.state.show=!1,this.view.emitUpdate(this.view.state)});this.editor=e,this.addProsemirrorPlugin(new S.Plugin({key:bt,view:o=>(this.view=new kt(e,o,r=>{this.emit("update",r)}),this.view)}))}static key(){return"sideMenu"}onUpdate(e){return this.on("update",e)}}const Q=new Map;function Bn(n){if(Q.has(n))return Q.get(n);const t=new W.Mapping;return n._tiptapEditor.on("transaction",({transaction:e})=>{t.appendMapping(e.mapping)}),n._tiptapEditor.on("destroy",()=>{Q.delete(n)}),Q.set(n,t),t}function wt(n,t,e="left"){const o=E.ySyncPluginKey.getState(n.prosemirrorState);if(!o){const s=Bn(n),i=s.maps.length;return()=>s.slice(i).map(t,e==="left"?-1:1)}const r=E.absolutePositionToRelativePosition(t+(e==="right"?1:-1),o.binding.type,o.binding.mapping);return()=>{const s=E.ySyncPluginKey.getState(n.prosemirrorState),i=E.relativePositionToAbsolutePosition(s.doc,s.binding.type,r,s.binding.mapping);if(i===null)throw new Error("Position not found, cannot track positions");return i+(e==="right"?-1:1)}}const vn=B.findParentNode(n=>n.type.name==="blockContainer");class Pn{constructor(t,e,o){u(this,"state");u(this,"emitUpdate");u(this,"rootEl");u(this,"pluginState");u(this,"handleScroll",()=>{var t,e;if((t=this.state)!=null&&t.show){const o=(e=this.rootEl)==null?void 0:e.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);if(!o)return;this.state.referencePos=o.getBoundingClientRect(),this.emitUpdate(this.pluginState.triggerCharacter)}});u(this,"closeMenu",()=>{this.editor.transact(t=>t.setMeta(z,null))});u(this,"clearQuery",()=>{this.pluginState!==void 0&&this.editor._tiptapEditor.chain().focus().deleteRange({from:this.pluginState.queryStartPos()-(this.pluginState.deleteTriggerCharacter?this.pluginState.triggerCharacter.length:0),to:this.editor.transact(t=>t.selection.from)}).run()});var r;this.editor=t,this.pluginState=void 0,this.emitUpdate=s=>{var i;if(!this.state)throw new Error("Attempting to update uninitialized suggestions menu");e(s,{...this.state,ignoreQueryLength:(i=this.pluginState)==null?void 0:i.ignoreQueryLength})},this.rootEl=o.root,(r=this.rootEl)==null||r.addEventListener("scroll",this.handleScroll,!0)}update(t,e){var l;const o=z.getState(e),r=z.getState(t.state),s=o===void 0&&r!==void 0,i=o!==void 0&&r===void 0;if(!s&&!(o!==void 0&&r!==void 0)&&!i)return;if(this.pluginState=i?o:r,i||!this.editor.isEditable){this.state&&(this.state.show=!1),this.emitUpdate(this.pluginState.triggerCharacter);return}const a=(l=this.rootEl)==null?void 0:l.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);this.editor.isEditable&&a&&(this.state={show:!0,referencePos:a.getBoundingClientRect(),query:this.pluginState.query},this.emitUpdate(this.pluginState.triggerCharacter))}destroy(){var t;(t=this.rootEl)==null||t.removeEventListener("scroll",this.handleScroll,!0)}}const z=new S.PluginKey("SuggestionMenuPlugin");class St extends d.BlockNoteExtension{constructor(e){super();u(this,"view");u(this,"triggerCharacters",[]);u(this,"addTriggerCharacter",e=>{this.triggerCharacters.push(e)});u(this,"removeTriggerCharacter",e=>{this.triggerCharacters=this.triggerCharacters.filter(o=>o!==e)});u(this,"closeMenu",()=>this.view.closeMenu());u(this,"clearQuery",()=>this.view.clearQuery());const o=this.triggerCharacters;this.addProsemirrorPlugin(new S.Plugin({key:z,view:r=>(this.view=new Pn(e,(s,i)=>{this.emit(`update ${s}`,i)},r),this.view),state:{init(){},apply:(r,s,i,c)=>{if(r.selection.$from.parent.type.spec.code)return s;const a=r.getMeta(z);if(typeof a=="object"&&a!==null){s&&this.closeMenu();const h=wt(e,c.selection.from-a.triggerCharacter.length);return{triggerCharacter:a.triggerCharacter,deleteTriggerCharacter:a.deleteTriggerCharacter!==!1,queryStartPos:()=>h()+a.triggerCharacter.length,query:"",decorationId:`id_${Math.floor(Math.random()*4294967295)}`,ignoreQueryLength:a==null?void 0:a.ignoreQueryLength}}if(s===void 0)return s;if(c.selection.from!==c.selection.to||a===null||r.getMeta("focus")||r.getMeta("blur")||r.getMeta("pointer")||s.triggerCharacter!==void 0&&c.selection.from<s.queryStartPos()||!c.selection.$from.sameParent(c.doc.resolve(s.queryStartPos())))return;const l={...s};return l.query=c.doc.textBetween(s.queryStartPos(),c.selection.from),l}},props:{handleTextInput(r,s,i,c){if(s===i){const a=r.state.doc;for(const l of o){const h=l.length>1?a.textBetween(s-l.length,s)+c:c;if(l===h)return r.dispatch(r.state.tr.insertText(c)),r.dispatch(r.state.tr.setMeta(z,{triggerCharacter:h}).scrollIntoView()),!0}}return!1},decorations(r){const s=this.getState(r);if(s===void 0)return null;if(!s.deleteTriggerCharacter){const i=vn(r.selection);if(i)return M.DecorationSet.create(r.doc,[M.Decoration.node(i.pos,i.pos+i.node.nodeSize,{nodeName:"span",class:"bn-suggestion-decorator","data-decoration-id":s.decorationId})])}return M.DecorationSet.create(r.doc,[M.Decoration.inline(s.queryStartPos()-s.triggerCharacter.length,s.queryStartPos(),{nodeName:"span",class:"bn-suggestion-decorator","data-decoration-id":s.decorationId})])}}}))}static key(){return"suggestionMenu"}onUpdate(e,o){return this.triggerCharacters.includes(e)||this.addTriggerCharacter(e),this.on(`update ${e}`,o)}get shown(){var e,o;return((o=(e=this.view)==null?void 0:e.state)==null?void 0:o.show)||!1}}function Tn(n,t){n.suggestionMenus.addTriggerCharacter(t)}const En=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(t,e){return["ins",{"data-id":String(t.attrs.id),"data-inline":String(e),...!e&&{style:"display: contents"}},0]},parseDOM:[{tag:"ins",getAttrs(t){return t.dataset.id?{id:parseInt(t.dataset.id,10)}:!1}}]}}}),Mn=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(t,e){return["del",{"data-id":String(t.attrs.id),"data-inline":String(e),...!e&&{style:"display: contents"}},0]},parseDOM:[{tag:"del",getAttrs(t){return t.dataset.id?{id:parseInt(t.dataset.id,10)}:!1}}]}}}),xn=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(t,e){return[e?"span":"div",{"data-type":"modification","data-id":String(t.attrs.id),"data-mod-type":t.attrs.type,"data-mod-prev-val":JSON.stringify(t.attrs.previousValue),"data-mod-new-val":JSON.stringify(t.attrs.newValue)},0]},parseDOM:[{tag:"span[data-type='modification']",getAttrs(t){return t.dataset.id?{id:parseInt(t.dataset.id,10),type:t.dataset.modType,previousValue:t.dataset.modPrevVal,newValue:t.dataset.modNewVal}:!1}},{tag:"div[data-type='modification']",getAttrs(t){return t.dataset.id?{id:parseInt(t.dataset.id,10),type:t.dataset.modType,previousValue:t.dataset.modPrevVal}:!1}}]}}});let A;function Ue(n){A||(A=document.createElement("div"),A.innerHTML="_",A.style.opacity="0",A.style.height="1px",A.style.width="1px",n instanceof Document?n.body.appendChild(A):n.appendChild(A))}function In(n){A&&(n instanceof Document?n.body.removeChild(A):n.removeChild(A),A=void 0)}function Z(n){return Array.prototype.indexOf.call(n.parentElement.childNodes,n)}function Dn(n){let t=n;for(;t&&t.nodeName!=="TD"&&t.nodeName!=="TH"&&!t.classList.contains("tableWrapper");){if(t.classList.contains("ProseMirror"))return;const e=t.parentNode;if(!e||!(e instanceof Element))return;t=e}return t.nodeName==="TD"||t.nodeName==="TH"?{type:"cell",domNode:t,tbodyNode:t.closest("tbody")}:{type:"wrapper",domNode:t,tbodyNode:t.querySelector("tbody")}}function Ln(n,t){const e=t.querySelectorAll(n);for(let o=0;o<e.length;o++)e[o].style.visibility="hidden"}class Ct{constructor(t,e,o){u(this,"state");u(this,"emitUpdate");u(this,"tableId");u(this,"tablePos");u(this,"tableElement");u(this,"menuFrozen",!1);u(this,"mouseState","up");u(this,"prevWasEditable",null);u(this,"viewMousedownHandler",()=>{this.mouseState="down"});u(this,"mouseUpHandler",t=>{this.mouseState="up",this.mouseMoveHandler(t)});u(this,"mouseMoveHandler",t=>{var l,h,p,k,g,b,f;if(this.menuFrozen||this.mouseState==="selecting"||!(t.target instanceof Element)||!this.pmView.dom.contains(t.target))return;const e=Dn(t.target);if((e==null?void 0:e.type)==="cell"&&this.mouseState==="down"&&!((l=this.state)!=null&&l.draggingState)){this.mouseState="selecting",(h=this.state)!=null&&h.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate());return}if(!e||!this.editor.isEditable){(p=this.state)!=null&&p.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate());return}if(!e.tbodyNode)return;const o=e.tbodyNode.getBoundingClientRect(),r=ft(e.domNode,this.pmView);if(!r)return;this.tableElement=r.node;let s;const i=this.editor.transact(y=>d.getNodeById(r.id,y.doc));if(!i)throw new Error(`Block with ID ${r.id} not found`);const c=m.nodeToBlock(i.node,this.editor.pmSchema,this.editor.schema.blockSchema,this.editor.schema.inlineContentSchema,this.editor.schema.styleSchema);if(d.editorHasBlockWithType(this.editor,"table")&&(this.tablePos=i.posBeforeNode+1,s=c),!s)return;this.tableId=r.id;const a=(k=e.domNode.closest(".tableWrapper"))==null?void 0:k.querySelector(".table-widgets-container");if((e==null?void 0:e.type)==="wrapper"){const y=t.clientY>=o.bottom-1&&t.clientY<o.bottom+20,w=t.clientX>=o.right-1&&t.clientX<o.right+20,C=t.clientX>o.right||t.clientY>o.bottom;this.state={...this.state,show:!0,showAddOrRemoveRowsButton:y,showAddOrRemoveColumnsButton:w,referencePosTable:o,block:s,widgetContainer:a,colIndex:C||(g=this.state)==null?void 0:g.colIndex,rowIndex:C||(b=this.state)==null?void 0:b.rowIndex,referencePosCell:C||(f=this.state)==null?void 0:f.referencePosCell}}else{const y=Z(e.domNode),w=Z(e.domNode.parentElement),C=e.domNode.getBoundingClientRect();if(this.state!==void 0&&this.state.show&&this.tableId===r.id&&this.state.rowIndex===w&&this.state.colIndex===y)return;this.state={show:!0,showAddOrRemoveColumnsButton:y===s.content.rows[0].cells.length-1,showAddOrRemoveRowsButton:w===s.content.rows.length-1,referencePosTable:o,block:s,draggingState:void 0,referencePosCell:C,colIndex:y,rowIndex:w,widgetContainer:a}}return this.emitUpdate(),!1});u(this,"dragOverHandler",t=>{var k;if(((k=this.state)==null?void 0:k.draggingState)===void 0)return;t.preventDefault(),t.dataTransfer.dropEffect="move",Ln(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline",this.pmView.root);const e={left:Math.min(Math.max(t.clientX,this.state.referencePosTable.left+1),this.state.referencePosTable.right-1),top:Math.min(Math.max(t.clientY,this.state.referencePosTable.top+1),this.state.referencePosTable.bottom-1)},o=this.pmView.root.elementsFromPoint(e.left,e.top).filter(g=>g.tagName==="TD"||g.tagName==="TH");if(o.length===0)return;const r=o[0];let s=!1;const i=Z(r.parentElement),c=Z(r),a=this.state.draggingState.draggedCellOrientation==="row"?this.state.rowIndex:this.state.colIndex,h=(this.state.draggingState.draggedCellOrientation==="row"?i:c)!==a;(this.state.rowIndex!==i||this.state.colIndex!==c)&&(this.state.rowIndex=i,this.state.colIndex=c,this.state.referencePosCell=r.getBoundingClientRect(),s=!0);const p=this.state.draggingState.draggedCellOrientation==="row"?e.top:e.left;this.state.draggingState.mousePos!==p&&(this.state.draggingState.mousePos=p,s=!0),s&&this.emitUpdate(),h&&this.editor.transact(g=>g.setMeta(V,!0))});u(this,"dropHandler",t=>{if(this.mouseState="up",this.state===void 0||this.state.draggingState===void 0)return!1;if(this.state.rowIndex===void 0||this.state.colIndex===void 0)throw new Error("Attempted to drop table row or column, but no table block was hovered prior.");t.preventDefault();const{draggingState:e,colIndex:o,rowIndex:r}=this.state,s=this.state.block.content.columnWidths;if(e.draggedCellOrientation==="row"){if(!m.canRowBeDraggedInto(this.state.block,e.originalIndex,r))return!1;const i=m.moveRow(this.state.block,e.originalIndex,r);this.editor.updateBlock(this.state.block,{type:"table",content:{...this.state.block.content,rows:i}})}else{if(!m.canColumnBeDraggedInto(this.state.block,e.originalIndex,o))return!1;const i=m.moveColumn(this.state.block,e.originalIndex,o),[c]=s.splice(e.originalIndex,1);s.splice(o,0,c),this.editor.updateBlock(this.state.block,{type:"table",content:{...this.state.block.content,columnWidths:s,rows:i}})}return this.editor.setTextCursorPosition(this.state.block.id),!0});this.editor=t,this.pmView=e,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized image toolbar");o(this.state)},e.dom.addEventListener("mousemove",this.mouseMoveHandler),e.dom.addEventListener("mousedown",this.viewMousedownHandler),window.addEventListener("mouseup",this.mouseUpHandler),e.root.addEventListener("dragover",this.dragOverHandler),e.root.addEventListener("drop",this.dropHandler)}update(){var r;if(!this.state||!this.state.show)return;if(this.state.block=this.editor.getBlock(this.state.block.id),!this.state.block||this.state.block.type!=="table"||!((r=this.tableElement)!=null&&r.isConnected)){this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate();return}const{height:t,width:e}=m.getDimensionsOfTable(this.state.block);this.state.rowIndex!==void 0&&this.state.colIndex!==void 0&&(this.state.rowIndex>=t&&(this.state.rowIndex=t-1),this.state.colIndex>=e&&(this.state.colIndex=e-1));const o=this.tableElement.querySelector("tbody");if(!o)throw new Error("Table block does not contain a 'tbody' HTML element. This should never happen.");if(this.state.rowIndex!==void 0&&this.state.colIndex!==void 0){const i=o.children[this.state.rowIndex].children[this.state.colIndex];i?this.state.referencePosCell=i.getBoundingClientRect():(this.state.rowIndex=void 0,this.state.colIndex=void 0)}this.state.referencePosTable=o.getBoundingClientRect(),this.emitUpdate()}destroy(){this.pmView.dom.removeEventListener("mousemove",this.mouseMoveHandler),window.removeEventListener("mouseup",this.mouseUpHandler),this.pmView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.pmView.root.removeEventListener("dragover",this.dragOverHandler),this.pmView.root.removeEventListener("drop",this.dropHandler)}}const V=new S.PluginKey("TableHandlesPlugin");class Bt extends d.BlockNoteExtension{constructor(e){super();u(this,"view");u(this,"colDragStart",e=>{if(this.view.state===void 0||this.view.state.colIndex===void 0)throw new Error("Attempted to drag table column, but no table block was hovered prior.");this.view.state.draggingState={draggedCellOrientation:"col",originalIndex:this.view.state.colIndex,mousePos:e.clientX},this.view.emitUpdate(),this.editor.transact(o=>o.setMeta(V,{draggedCellOrientation:this.view.state.draggingState.draggedCellOrientation,originalIndex:this.view.state.colIndex,newIndex:this.view.state.colIndex,tablePos:this.view.tablePos})),!this.editor.headless&&(Ue(this.editor.prosemirrorView.root),e.dataTransfer.setDragImage(A,0,0),e.dataTransfer.effectAllowed="move")});u(this,"rowDragStart",e=>{if(this.view.state===void 0||this.view.state.rowIndex===void 0)throw new Error("Attempted to drag table row, but no table block was hovered prior.");this.view.state.draggingState={draggedCellOrientation:"row",originalIndex:this.view.state.rowIndex,mousePos:e.clientY},this.view.emitUpdate(),this.editor.transact(o=>o.setMeta(V,{draggedCellOrientation:this.view.state.draggingState.draggedCellOrientation,originalIndex:this.view.state.rowIndex,newIndex:this.view.state.rowIndex,tablePos:this.view.tablePos})),!this.editor.headless&&(Ue(this.editor.prosemirrorView.root),e.dataTransfer.setDragImage(A,0,0),e.dataTransfer.effectAllowed="copyMove")});u(this,"dragEnd",()=>{if(this.view.state===void 0)throw new Error("Attempted to drag table row, but no table block was hovered prior.");this.view.state.draggingState=void 0,this.view.emitUpdate(),this.editor.transact(e=>e.setMeta(V,null)),!this.editor.headless&&In(this.editor.prosemirrorView.root)});u(this,"freezeHandles",()=>{this.view.menuFrozen=!0});u(this,"unfreezeHandles",()=>{this.view.menuFrozen=!1});u(this,"getCellsAtRowHandle",(e,o)=>m.getCellsAtRowHandle(e,o));u(this,"getCellsAtColumnHandle",(e,o)=>m.getCellsAtColumnHandle(e,o));u(this,"setCellSelection",(e,o,r=o)=>{const s=this.view;if(!s)throw new Error("Table handles view not initialized");const i=e.doc.resolve(s.tablePos+1),c=e.doc.resolve(i.posAtIndex(o.row)+1),a=e.doc.resolve(c.posAtIndex(o.col)),l=e.doc.resolve(i.posAtIndex(r.row)+1),h=e.doc.resolve(l.posAtIndex(r.col)),p=e.tr;return p.setSelection(new N.CellSelection(a,h)),e.apply(p)});u(this,"addRowOrColumn",(e,o)=>{this.editor.exec((r,s)=>{const i=this.setCellSelection(r,o.orientation==="row"?{row:e,col:0}:{row:0,col:e});return o.orientation==="row"?o.side==="above"?N.addRowBefore(i,s):N.addRowAfter(i,s):o.side==="left"?N.addColumnBefore(i,s):N.addColumnAfter(i,s)})});u(this,"removeRowOrColumn",(e,o)=>o==="row"?this.editor.exec((r,s)=>{const i=this.setCellSelection(r,{row:e,col:0});return N.deleteRow(i,s)}):this.editor.exec((r,s)=>{const i=this.setCellSelection(r,{row:0,col:e});return N.deleteColumn(i,s)}));u(this,"mergeCells",e=>this.editor.exec((o,r)=>{const s=e?this.setCellSelection(o,e.relativeStartCell,e.relativeEndCell):o;return N.mergeCells(s,r)}));u(this,"splitCell",e=>this.editor.exec((o,r)=>{const s=e?this.setCellSelection(o,e):o;return N.splitCell(s,r)}));u(this,"getCellSelection",()=>this.editor.transact(e=>{const o=e.selection;let r=o.$from,s=o.$to;if(d.isTableCellSelection(o)){const{ranges:b}=o;b.forEach(f=>{r=f.$from.min(r??f.$from),s=f.$to.max(s??f.$to)})}else if(r=e.doc.resolve(o.$from.pos-o.$from.parentOffset-1),s=e.doc.resolve(o.$to.pos-o.$to.parentOffset-1),r.pos===0||s.pos===0)return;const i=e.doc.resolve(r.pos-r.parentOffset-1),c=e.doc.resolve(s.pos-s.parentOffset-1),a=e.doc.resolve(i.pos-i.parentOffset-1),l=r.index(i.depth),h=i.index(a.depth),p=s.index(c.depth),k=c.index(a.depth),g=[];for(let b=h;b<=k;b++)for(let f=l;f<=p;f++)g.push({row:b,col:f});return{from:{row:h,col:l},to:{row:k,col:p},cells:g}}));u(this,"getMergeDirection",e=>this.editor.transact(o=>{const r=d.isTableCellSelection(o.selection)?o.selection:void 0;if(!r||!e||r.ranges.length<=1)return;const s=this.getCellSelection();if(s)return m.areInSameColumn(s.from,s.to,e)?"vertical":"horizontal"}));u(this,"cropEmptyRowsOrColumns",(e,o)=>m.cropEmptyRowsOrColumns(e,o));u(this,"addRowsOrColumns",(e,o,r)=>m.addRowsOrColumns(e,o,r));this.editor=e,this.addProsemirrorPlugin(new S.Plugin({key:V,view:o=>(this.view=new Ct(e,o,r=>{this.emit("update",r)}),this.view),props:{decorations:o=>{if(this.view===void 0||this.view.state===void 0||this.view.state.draggingState===void 0||this.view.tablePos===void 0)return;const r=this.view.state.draggingState.draggedCellOrientation==="row"?this.view.state.rowIndex:this.view.state.colIndex;if(r===void 0)return;const s=[],{block:i,draggingState:c}=this.view.state,{originalIndex:a,draggedCellOrientation:l}=c;if(r===a||!i||l==="row"&&!m.canRowBeDraggedInto(i,a,r)||l==="col"&&!m.canColumnBeDraggedInto(i,a,r))return M.DecorationSet.create(o.doc,s);const h=o.doc.resolve(this.view.tablePos+1);return this.view.state.draggingState.draggedCellOrientation==="row"?m.getCellsAtRowHandle(this.view.state.block,r).forEach(({row:k,col:g})=>{const b=o.doc.resolve(h.posAtIndex(k)+1),f=o.doc.resolve(b.posAtIndex(g)+1),y=f.node(),w=f.pos+(r>a?y.nodeSize-2:0);s.push(M.Decoration.widget(w,()=>{const C=document.createElement("div");return C.className="bn-table-drop-cursor",C.style.left="0",C.style.right="0",r>a?C.style.bottom="-2px":C.style.top="-3px",C.style.height="4px",C}))}):m.getCellsAtColumnHandle(this.view.state.block,r).forEach(({row:k,col:g})=>{const b=o.doc.resolve(h.posAtIndex(k)+1),f=o.doc.resolve(b.posAtIndex(g)+1),y=f.node(),w=f.pos+(r>a?y.nodeSize-2:0);s.push(M.Decoration.widget(w,()=>{const C=document.createElement("div");return C.className="bn-table-drop-cursor",C.style.top="0",C.style.bottom="0",r>a?C.style.right="-2px":C.style.left="-3px",C.style.width="4px",C}))}),M.DecorationSet.create(o.doc,s)}}}))}static key(){return"tableHandles"}onUpdate(e){return this.on("update",e)}}const Nn=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}}}}]}}),An=B.Extension.create({name:"blockTextColor",addGlobalAttributes(){return[{types:["table","tableCell","tableHeader"],attributes:{textColor:d.getTextColorAttribute()}}]}}),_n=B.Extension.create({name:"trailingNode",addProseMirrorPlugins(){const n=new S.PluginKey(this.name);return[new S.Plugin({key:n,appendTransaction:(t,e,o)=>{const{doc:r,tr:s,schema:i}=o,c=n.getState(o),a=r.content.size-2,l=i.nodes.blockContainer,h=i.nodes.paragraph;if(c)return s.insert(a,l.create(void 0,h.create()))},state:{init:(t,e)=>{},apply:(t,e)=>{if(!t.docChanged)return e;let o=t.doc.lastChild;if(!o||o.type.name!=="blockGroup")throw new Error("Expected blockGroup");if(o=o.lastChild,!o||o.type.name!=="blockContainer")return!0;const r=o.firstChild;if(!r)throw new Error("Expected blockContent");return o.nodeSize>4||r.type.spec.content!=="inline*"}}})]}}),On={blockColor:"data-block-color",blockStyle:"data-block-style",id:"data-id",depth:"data-depth",depthChange:"data-depth-change"},Hn=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 t={};for(const[e,o]of Object.entries(On))n.getAttribute(o)&&(t[e]=n.getAttribute(o));return t}},{tag:'div[data-node-type="blockOuter"]',skip:!0}]},renderHTML({HTMLAttributes:n}){var r;const t=document.createElement("div");t.className="bn-block-outer",t.setAttribute("data-node-type","blockOuter");for(const[s,i]of Object.entries(n))s!=="class"&&t.setAttribute(s,i);const e={...((r=this.options.domAttributes)==null?void 0:r.block)||{},...n},o=document.createElement("div");o.className=d.mergeCSSClasses("bn-block",e.class),o.setAttribute("data-node-type",this.name);for(const[s,i]of Object.entries(e))s!=="class"&&o.setAttribute(s,i);return t.appendChild(o),{dom:t,contentDOM:o}}}),Un=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 t={...((o=this.options.domAttributes)==null?void 0:o.blockGroup)||{},...n},e=document.createElement("div");e.className=d.mergeCSSClasses("bn-block-group",t.class),e.setAttribute("data-node-type","blockGroup");for(const[r,s]of Object.entries(t))r!=="class"&&e.setAttribute(r,s);return{dom:e,contentDOM:e}}}),Rn=B.Node.create({name:"doc",topNode:!0,content:"blockGroup",marks:"insertion modification deletion"}),vt=n=>{var r;const t={},e=Fn(n);for(const s of e)t[s.name]=s;n.collaboration&&(t.ySyncPlugin=new ne(n.collaboration.fragment),t.yUndoPlugin=new re({editor:n.editor}),(r=n.collaboration.provider)!=null&&r.awareness&&(t.yCursorPlugin=new Y(n.collaboration)),t.forkYDocPlugin=new tt({editor:n.editor,collaboration:n.collaboration}),t.schemaMigrationPlugin=new be(n.collaboration.fragment)),t.formattingToolbar=new ct(n.editor),t.linkToolbar=new ht(n.editor),t.sideMenu=new yt(n.editor),t.suggestionMenus=new St(n.editor),t.filePanel=new st(n.editor),t.placeholder=new gn(n.editor,n.placeholders),(n.animations??!0)&&(t.animations=new bn),n.tableHandles&&(t.tableHandles=new Bt(n.editor)),t.nodeSelectionKeyboard=new mn,t.blockChange=new Jo,t.showSelection=new yn(n.editor),n.comments&&(t.comments=new nt(n.editor,n.comments.threadStore,se.name,n.comments.resolveUsers,n.comments.schema));const o=n.disableExtensions||[];for(const s of o)delete t[s];return t};let Re=!1;const Fn=n=>{const t=[B.extensions.ClipboardTextSerializer,B.extensions.Commands,B.extensions.Editable,B.extensions.FocusEvents,B.extensions.Tabindex,Wt.Gapcursor,B.Extension.create({name:"dropCursor",addProseMirrorPlugins:()=>[n.dropCursor({width:5,color:"#ddeeff",editor:n.editor})]}),m.UniqueID.configure({types:["blockContainer","columnList","column"],setIdAttribute:n.setIdAttribute}),nn,Jt.Text,En,Mn,xn,Xt.Link.extend({inclusive:!1}).configure({defaultProtocol:mt,protocols:Re?[]:pt}),...Object.values(n.styleSpecs).map(e=>e.implementation.mark.configure({editor:n.editor})),An,Xo,Nn,B.Extension.create({name:"OverrideEscape",addKeyboardShortcuts(){return{Escape:()=>n.editor.suggestionMenus.shown?!1:this.editor.commands.blur()}}}),Rn,Hn.configure({editor:n.editor,domAttributes:n.domAttributes}),un.configure({editor:n.editor,tabBehavior:n.tabBehavior}),Un.configure({domAttributes:n.domAttributes}),...Object.values(n.inlineContentSpecs).filter(e=>e.config!=="link"&&e.config!=="text").map(e=>e.implementation.node.configure({editor:n.editor})),...Object.values(n.blockSpecs).flatMap(e=>[..."node"in e.implementation?[e.implementation.node.configure({editor:n.editor,domAttributes:n.domAttributes})]:[]]),Yo(n.editor),Ko(n.editor,n.pasteHandler||(e=>e.defaultPasteHandler())),Eo(n.editor),...n.trailingBlock===void 0||n.trailingBlock?[_n]:[],...n.comments?[se]:[]];return Re=!0,n.collaboration||t.push(Yt.History),t};function Vn(n){return n.transact(t=>{const e=m.getNearestBlockPos(t.doc,t.selection.anchor);if(t.selection instanceof N.CellSelection)return{type:"cell",anchorBlockId:e.node.attrs.id,anchorCellOffset:t.selection.$anchorCell.pos-e.posBeforeNode,headCellOffset:t.selection.$headCell.pos-e.posBeforeNode};if(t.selection instanceof S.NodeSelection)return{type:"node",anchorBlockId:e.node.attrs.id};{const o=m.getNearestBlockPos(t.doc,t.selection.head);return{type:"text",anchorBlockId:e.node.attrs.id,headBlockId:o.node.attrs.id,anchorOffset:t.selection.anchor-e.posBeforeNode,headOffset:t.selection.head-o.posBeforeNode}}})}function $n(n,t){var r,s;const e=(r=d.getNodeById(t.anchorBlockId,n.doc))==null?void 0:r.posBeforeNode;if(e===void 0)throw new Error(`Could not find block with ID ${t.anchorBlockId} to update selection`);let o;if(t.type==="cell")o=N.CellSelection.create(n.doc,e+t.anchorCellOffset,e+t.headCellOffset);else if(t.type==="node")o=S.NodeSelection.create(n.doc,e+1);else{const i=(s=d.getNodeById(t.headBlockId,n.doc))==null?void 0:s.posBeforeNode;if(i===void 0)throw new Error(`Could not find block with ID ${t.headBlockId} to update selection`);o=S.TextSelection.create(n.doc,e+t.anchorOffset,i+t.headOffset)}n.setSelection(o)}function me(n){return n.map(t=>t.type==="columnList"?t.children.map(e=>me(e.children)).flat():{...t,children:me(t.children)}).flat()}function Pt(n,t,e){n.transact(o=>{var i;const r=((i=n.getSelection())==null?void 0:i.blocks)||[n.getTextCursorPosition().block],s=Vn(n);n.removeBlocks(r),n.insertBlocks(me(r),t,e),$n(o,s)})}function Tt(n){return!n||n.type!=="columnList"}function Et(n,t,e){let o,r;if(t?t.children.length>0?(o=t.children[t.children.length-1],r="after"):(o=t,r="before"):e&&(o=e,r="before"),!o||!r)return;const s=n.getParentBlock(o);return Tt(s)?{referenceBlock:o,placement:r}:Et(n,r==="after"?o:n.getPrevBlock(o),s)}function Mt(n,t,e){let o,r;if(t?t.children.length>0?(o=t.children[0],r="before"):(o=t,r="after"):e&&(o=e,r="after"),!o||!r)return;const s=n.getParentBlock(o);return Tt(s)?{referenceBlock:o,placement:r}:Mt(n,r==="before"?o:n.getNextBlock(o),s)}function zn(n){n.transact(()=>{const t=n.getSelection(),e=(t==null?void 0:t.blocks[0])||n.getTextCursorPosition().block,o=Et(n,n.getPrevBlock(e),n.getParentBlock(e));o&&Pt(n,o.referenceBlock,o.placement)})}function Kn(n){n.transact(()=>{const t=n.getSelection(),e=(t==null?void 0:t.blocks[(t==null?void 0:t.blocks.length)-1])||n.getTextCursorPosition().block,o=Mt(n,n.getNextBlock(e),n.getParentBlock(e));o&&Pt(n,o.referenceBlock,o.placement)})}function xt(n,t){const e=typeof t=="string"?t:t.id,o=m.getPmSchema(n),r=d.getNodeById(e,n);if(r)return m.nodeToBlock(r.node,o)}function It(n,t){const e=typeof t=="string"?t:t.id,o=d.getNodeById(e,n),r=m.getPmSchema(n);if(!o)return;const i=n.resolve(o.posBeforeNode).nodeBefore;if(i)return m.nodeToBlock(i,r)}function Dt(n,t){const e=typeof t=="string"?t:t.id,o=d.getNodeById(e,n),r=m.getPmSchema(n);if(!o)return;const i=n.resolve(o.posBeforeNode+o.node.nodeSize).nodeAfter;if(i)return m.nodeToBlock(i,r)}function Lt(n,t){const e=typeof t=="string"?t:t.id,o=m.getPmSchema(n),r=d.getNodeById(e,n);if(!r)return;const s=n.resolve(r.posBeforeNode),i=s.node(),c=s.node(-1),a=c.type.name!=="doc"?i.type.name==="blockGroup"?c:i:void 0;if(a)return m.nodeToBlock(a,o)}class qn{constructor(t){this.editor=t}get document(){return this.editor.transact(t=>m.docToBlocks(t.doc,this.editor.pmSchema))}getBlock(t){return this.editor.transact(e=>xt(e.doc,t))}getPrevBlock(t){return this.editor.transact(e=>It(e.doc,t))}getNextBlock(t){return this.editor.transact(e=>Dt(e.doc,t))}getParentBlock(t){return this.editor.transact(e=>Lt(e.doc,t))}forEachBlock(t,e=!1){const o=this.document.slice();e&&o.reverse();function r(s){for(const i of s){if(t(i)===!1)return!1;const c=e?i.children.slice().reverse():i.children;if(!r(c))return!1}return!0}r(o)}insertBlocks(t,e,o="before"){return this.editor.transact(r=>Ke(r,t,e,o))}updateBlock(t,e){return this.editor.transact(o=>d.updateBlock(o,t,e))}removeBlocks(t){return this.editor.transact(e=>ue(e,t,[]).removedBlocks)}replaceBlocks(t,e){return this.editor.transact(o=>ue(o,t,e))}canNestBlock(){return ln(this.editor)}nestBlock(){dt(this.editor)}canUnnestBlock(){return dn(this.editor)}unnestBlock(){cn(this.editor)}moveBlocksUp(){return zn(this.editor)}moveBlocksDown(){return Kn(this.editor)}}class Gn{constructor(t,e){u(this,"editor");u(this,"options");u(this,"_commentsPlugin");u(this,"_forkYDocPlugin");u(this,"_syncPlugin");u(this,"_undoPlugin");u(this,"_cursorPlugin");this.editor=t,this.options=e}get syncPlugin(){return this._syncPlugin}get undoPlugin(){return this._undoPlugin}get cursorPlugin(){return this._cursorPlugin}get forkYDocPlugin(){return this._forkYDocPlugin}initExtensions(){var e;const t={};if(this._syncPlugin=new ne(this.options.fragment),t.ySyncPlugin=this._syncPlugin,this._undoPlugin=new re({editor:this.editor}),t.yUndoPlugin=this._undoPlugin,(e=this.options.provider)!=null&&e.awareness&&(this._cursorPlugin=new Y(this.options),t.yCursorPlugin=this._cursorPlugin),this._forkYDocPlugin=new tt({editor:this.editor,collaboration:this.options}),t.forkYDocPlugin=this._forkYDocPlugin,this.options.comments){if(!this.options.resolveUsers)throw new Error("resolveUsers is required when using comments");this._commentsPlugin=new nt(this.editor,this.options.comments.threadStore,se.name,this.options.resolveUsers,this.options.comments.schema),t.comments=this._commentsPlugin,t.commentMark=se}return t}updateUserInfo(t){const e=this.cursorPlugin;if(!e)throw new Error("Cannot update collaboration user info when collaboration is disabled.");e.updateUser(t)}getUndoCommand(){return E.undoCommand}getRedoCommand(){return E.redoCommand}shouldAvoidInitialContent(){return!!this.options.provider}getOptions(){return this.options}get comments(){return this._commentsPlugin}get hasComments(){return!!this.options.comments}get resolveUsers(){return this.options.resolveUsers}}class jn extends d.EventEmitter{constructor(t){super(),this.editor=t,t.onCreate(()=>{t._tiptapEditor.on("update",({transaction:e,appendedTransactions:o})=>{this.emit("onChange",t,{getChanges(){return fe(e,o)}})}),t._tiptapEditor.on("selectionUpdate",({transaction:e})=>{this.emit("onSelectionChange",{editor:t,transaction:e})}),t._tiptapEditor.on("mount",()=>{this.emit("onMount",{editor:t})}),t._tiptapEditor.on("unmount",()=>{this.emit("onUnmount",{editor:t})})})}onChange(t){return this.on("onChange",t),()=>{this.off("onChange",t)}}onSelectionChange(t,e=!1){const o=r=>{r.transaction.getMeta("$y-sync")&&!e||t(this.editor)};return this.on("onSelectionChange",o),()=>{this.off("onSelectionChange",o)}}onMount(t){return this.on("onMount",t),()=>{this.off("onMount",t)}}onUnmount(t){return this.on("onUnmount",t),()=>{this.off("onUnmount",t)}}}function Wn(n){return Array.prototype.indexOf.call(n.parentElement.childNodes,n)}function Yn(n){return n.nodeType===3&&!/\S/.test(n.nodeValue||"")}function Xn(n){n.querySelectorAll("li > ul, li > ol").forEach(t=>{const e=Wn(t),o=t.parentElement,r=Array.from(o.childNodes).slice(e+1);t.remove(),r.forEach(s=>{s.remove()}),o.insertAdjacentElement("afterend",t),r.reverse().forEach(s=>{if(Yn(s))return;const i=document.createElement("li");i.append(s),t.insertAdjacentElement("afterend",i)}),o.childNodes.length===0&&o.remove()})}function Jn(n){n.querySelectorAll("li + ul, li + ol").forEach(t=>{var s,i;const e=t.previousElementSibling,o=document.createElement("div");e.insertAdjacentElement("afterend",o),o.append(e);const r=document.createElement("div");for(r.setAttribute("data-node-type","blockGroup"),o.append(r);((s=o.nextElementSibling)==null?void 0:s.nodeName)==="UL"||((i=o.nextElementSibling)==null?void 0:i.nodeName)==="OL";)r.append(o.nextElementSibling)})}let Fe=null;function Qn(){return Fe||(Fe=document.implementation.createHTMLDocument("title"))}function Zn(n){if(typeof n=="string"){const t=Qn().createElement("div");t.innerHTML=n,n=t}return Xn(n),Jn(n),n}function ye(n,t){const e=Zn(n),r=T.DOMParser.fromSchema(t).parse(e,{topNode:t.nodes.blockGroup.create()}),s=[];for(let i=0;i<r.childCount;i++)s.push(m.nodeToBlock(r.child(i),t));return s}function er(n,t){const e=t.value?t.value:"",o={};t.lang&&(o["data-language"]=t.lang);let r={type:"element",tagName:"code",properties:o,children:[{type:"text",value:e}]};return t.meta&&(r.data={meta:t.meta}),n.patch(t,r),r=n.applyData(t,r),r={type:"element",tagName:"pre",properties:{},children:[r]},n.patch(t,r),r}function tr(n,t){var s;const e=String((t==null?void 0:t.url)||""),o=t!=null&&t.title?String(t.title):void 0;let r={type:"element",tagName:"video",properties:{src:e,"data-name":o,"data-url":e,controls:!0},children:[]};return(s=n.patch)==null||s.call(n,t,r),r=n.applyData?n.applyData(t,r):r,r}function we(n){return Ve.unified().use(mo.default).use($e.default).use(fo.default,{handlers:{...de.defaultHandlers,image:(e,o)=>{const r=String((o==null?void 0:o.url)||"");return d.isVideoUrl(r)?tr(e,o):de.defaultHandlers.image(e,o)},code:er}}).use(go.default).processSync(n).value}function Nt(n,t){const e=we(n);return ye(e,t)}class or{constructor(t){this.editor=t}blocksToHTMLLossy(t=this.editor.document){return X(this.editor.pmSchema,this.editor).exportBlocks(t,{})}blocksToFullHTML(t=this.editor.document){return Je(this.editor.pmSchema,this.editor).serializeBlocks(t,{})}tryParseHTMLToBlocks(t){return ye(t,this.editor.pmSchema)}blocksToMarkdownLossy(t=this.editor.document){return Ze(t,this.editor.pmSchema,this.editor,{})}tryParseMarkdownToBlocks(t){return Nt(t,this.editor.pmSchema)}pasteHTML(t,e=!1){var r;let o=t;if(!e){const s=this.tryParseHTMLToBlocks(t);o=this.blocksToFullHTML(s)}o&&((r=this.editor.prosemirrorView)==null||r.pasteHTML(o))}pasteText(t){var e;return(e=this.editor.prosemirrorView)==null?void 0:e.pasteText(t)}pasteMarkdown(t){const e=we(t);return this.pasteHTML(e)}}class nr{constructor(t){this.editor=t}extension(t,e=t.key()){const o=this.editor.extensions[e];if(!o)throw new Error(`Extension ${e} not found`);return o}getExtensions(){return this.editor.extensions}getExtension(t){return this.editor.extensions[t]}hasExtension(t){return t in this.editor.extensions}get formattingToolbar(){return this.editor.extensions.formattingToolbar}get linkToolbar(){return this.editor.extensions.linkToolbar}get sideMenu(){return this.editor.extensions.sideMenu}get suggestionMenus(){return this.editor.extensions.suggestionMenus}get filePanel(){return this.editor.extensions.filePanel}get tableHandles(){return this.editor.extensions.tableHandles}get showSelectionPlugin(){return this.editor.extensions.showSelection}get isCollaborationEnabled(){return this.hasExtension("ySyncPlugin")||this.hasExtension("liveblocksExtension")}}function rr(n){const t=m.getPmSchema(n);if(n.selection.empty||"node"in n.selection)return;const e=n.doc.resolve(m.getNearestBlockPos(n.doc,n.selection.from).posBeforeNode),o=n.doc.resolve(m.getNearestBlockPos(n.doc,n.selection.to).posBeforeNode),r=(l,h)=>{const p=e.posAtIndex(l,h),k=n.doc.resolve(p).nodeAfter;if(!k)throw new Error(`Error getting selection - node not found at position ${p}`);return m.nodeToBlock(k,t)},s=[],i=e.sharedDepth(o.pos),c=e.index(i),a=o.index(i);if(e.depth>i){s.push(m.nodeToBlock(e.nodeAfter,t));for(let l=e.depth;l>i;l--)if(e.node(l).type.isInGroup("childContainer")){const p=e.index(l)+1,k=e.node(l).childCount;for(let g=p;g<k;g++)s.push(r(g,l))}}else s.push(r(c,i));for(let l=c+1;l<=a;l++)s.push(r(l,i));if(s.length===0)throw new Error(`Error getting selection - selection doesn't span any blocks (${n.selection})`);return{blocks:s}}function sr(n,t,e){const o=typeof t=="string"?t:t.id,r=typeof e=="string"?e:e.id,s=m.getPmSchema(n),i=m.getBlockNoteSchema(s);if(o===r)throw new Error(`Attempting to set selection with the same anchor and head blocks (id ${o})`);const c=d.getNodeById(o,n.doc);if(!c)throw new Error(`Block with ID ${o} not found`);const a=d.getNodeById(r,n.doc);if(!a)throw new Error(`Block with ID ${r} not found`);const l=m.getBlockInfo(c),h=m.getBlockInfo(a),p=i.blockSchema[l.blockNoteType],k=i.blockSchema[h.blockNoteType];if(!l.isBlockContainer||p.content==="none")throw new Error(`Attempting to set selection anchor in block without content (id ${o})`);if(!h.isBlockContainer||k.content==="none")throw new Error(`Attempting to set selection anchor in block without content (id ${r})`);let g,b;if(p.content==="table"){const f=N.TableMap.get(l.blockContent.node);g=l.blockContent.beforePos+f.positionAt(0,0,l.blockContent.node)+1+2}else g=l.blockContent.beforePos+1;if(k.content==="table"){const f=N.TableMap.get(h.blockContent.node),y=h.blockContent.beforePos+f.positionAt(f.height-1,f.width-1,h.blockContent.node)+1,w=n.doc.resolve(y).nodeAfter.nodeSize;b=y+w-2}else b=h.blockContent.afterPos-1;n.setSelection(S.TextSelection.create(n.doc,g,b))}function ir(n){const t=m.getPmSchema(n);let e=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(;e.parentOffset===0&&e.depth>0;)e=n.doc.resolve(e.pos-1);for(;e.parentOffset>=e.parent.nodeSize-2&&e.depth>0;)e=n.doc.resolve(e.pos+1);const r=m.prosemirrorSliceToSlicedBlocks(n.doc.slice(e.pos,o.pos,!0),t);return{_meta:{startPos:e.pos,endPos:o.pos},...r}}function ar(n){const{bnBlock:t}=m.getBlockInfoFromTransaction(n),e=m.getPmSchema(n.doc),o=n.doc.resolve(t.beforePos),r=o.nodeBefore,s=n.doc.resolve(t.afterPos).nodeAfter;let i;return o.depth>1&&(i=o.node(),i.type.isInGroup("bnBlock")||(i=o.node(o.depth-1))),{block:m.nodeToBlock(t.node,e),prevBlock:r===null?void 0:m.nodeToBlock(r,e),nextBlock:s===null?void 0:m.nodeToBlock(s,e),parentBlock:i===void 0?void 0:m.nodeToBlock(i,e)}}function At(n,t,e="start"){const o=typeof t=="string"?t:t.id,r=m.getPmSchema(n.doc),s=m.getBlockNoteSchema(r),i=d.getNodeById(o,n.doc);if(!i)throw new Error(`Block with ID ${o} not found`);const c=m.getBlockInfo(i),a=s.blockSchema[c.blockNoteType].content;if(c.isBlockContainer){const l=c.blockContent;if(a==="none"){n.setSelection(S.NodeSelection.create(n.doc,l.beforePos));return}if(a==="inline")e==="start"?n.setSelection(S.TextSelection.create(n.doc,l.beforePos+1)):n.setSelection(S.TextSelection.create(n.doc,l.afterPos-1));else if(a==="table")e==="start"?n.setSelection(S.TextSelection.create(n.doc,l.beforePos+4)):n.setSelection(S.TextSelection.create(n.doc,l.afterPos-4));else throw new m.UnreachableCaseError(a)}else{const l=e==="start"?c.childContainer.node.firstChild:c.childContainer.node.lastChild;At(n,l.attrs.id,e)}}class cr{constructor(t){this.editor=t}getSelection(){return this.editor.transact(t=>rr(t))}getSelectionCutBlocks(){return this.editor.transact(t=>ir(t))}setSelection(t,e){return this.editor.transact(o=>sr(o,t,e))}getTextCursorPosition(){return this.editor.transact(t=>ar(t))}setTextCursorPosition(t,e="start"){return this.editor.transact(o=>At(o,t,e))}getSelectionBoundingBox(){if(!this.editor.prosemirrorView)return;const{selection:t}=this.editor.prosemirrorState,{ranges:e}=t,o=Math.min(...e.map(s=>s.$from.pos)),r=Math.max(...e.map(s=>s.$to.pos));if(B.isNodeSelection(t)){const s=this.editor.prosemirrorView.nodeDOM(o);if(s)return s.getBoundingClientRect()}return B.posToDOMRect(this.editor.prosemirrorView,o,r)}}class lr{constructor(t,e){u(this,"activeTransaction",null);u(this,"isInCan",!1);this.editor=t,this.options=e}can(t){try{return this.isInCan=!0,t()}finally{this.isInCan=!1}}exec(t){if(this.activeTransaction)throw new Error("`exec` should not be called within a `transact` call, move the `exec` call outside of the `transact` call");if(this.isInCan)return this.canExec(t);const e=this.prosemirrorState,o=this.prosemirrorView;return t(e,s=>this.prosemirrorView.dispatch(s),o)}canExec(t){if(this.activeTransaction)throw new Error("`canExec` should not be called within a `transact` call, move the `canExec` call outside of the `transact` call");const e=this.prosemirrorState,o=this.prosemirrorView;return t(e,void 0,o)}transact(t){if(this.activeTransaction)return t(this.activeTransaction);try{this.activeTransaction=this.editor._tiptapEditor.state.tr;const e=t(this.activeTransaction),o=this.activeTransaction;return this.activeTransaction=null,o&&(o.docChanged||o.selectionSet||o.scrolledIntoView||o.storedMarksSet||!o.isGeneric)&&this.prosemirrorView.dispatch(o),e}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 t;return((t=this.prosemirrorView)==null?void 0:t.hasFocus())||!1}focus(){var t;(t=this.prosemirrorView)==null||t.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(t){if(!this.editor._tiptapEditor){if(!this.editor.headless)throw new Error("no editor, but also not headless?");return}this.editor._tiptapEditor.options.editable!==t&&this.editor._tiptapEditor.setEditable(t)}undo(){var t;return this.exec(((t=this.options)==null?void 0:t.undo)??Me.undo)}redo(){var t;return this.exec(((t=this.options)==null?void 0:t.redo)??Me.redo)}}function dr(n,t,e,o={updateSelection:!0}){let{from:r,to:s}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},i=!0,c=!0,a="";if(e.forEach(l=>{l.check(),i&&l.isText&&l.marks.length===0?a+=l.text:i=!1,c=c?l.isBlock:!1}),r===s&&c){const{parent:l}=n.doc.resolve(r);l.isTextblock&&!l.type.spec.code&&!l.childCount&&(r-=1,s+=1)}return i?n.insertText(a,r,s):n.replaceWith(r,s,e),o.updateSelection&&B.selectionToInsertionEnd(n,n.steps.length-1,-1),!0}class ur{constructor(t){this.editor=t}insertInlineContent(t,{updateSelection:e=!1}={}){const o=m.inlineContentToNodes(t,this.editor.pmSchema);this.editor.transact(r=>{dr(r,{from:r.selection.from,to:r.selection.to},o,{updateSelection:e})})}getActiveStyles(){return this.editor.transact(t=>{const e={},o=t.selection.$to.marks();for(const r of o){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"?e[s.type]=!0:e[s.type]=r.attrs.stringValue}return e})}addStyles(t){for(const[e,o]of Object.entries(t)){const r=this.editor.schema.styleSchema[e];if(!r)throw new Error(`style ${e} not found in styleSchema`);if(r.propSchema==="boolean")this.editor._tiptapEditor.commands.setMark(e);else if(r.propSchema==="string")this.editor._tiptapEditor.commands.setMark(e,{stringValue:o});else throw new m.UnreachableCaseError(r.propSchema)}}removeStyles(t){for(const e of Object.keys(t))this.editor._tiptapEditor.commands.unsetMark(e)}toggleStyles(t){for(const[e,o]of Object.entries(t)){const r=this.editor.schema.styleSchema[e];if(!r)throw new Error(`style ${e} not found in styleSchema`);if(r.propSchema==="boolean")this.editor._tiptapEditor.commands.toggleMark(e);else if(r.propSchema==="string")this.editor._tiptapEditor.commands.toggleMark(e,{stringValue:o});else throw new m.UnreachableCaseError(r.propSchema)}}getSelectedText(){return this.editor.transact(t=>t.doc.textBetween(t.selection.from,t.selection.to))}getSelectedLinkUrl(){return this.editor._tiptapEditor.getAttributes("link").href}createLink(t,e){if(t==="")return;const o=this.editor.pmSchema.mark("link",{href:t});this.editor.transact(r=>{const{from:s,to:i}=r.selection;e?r.insertText(e,s,i).addMark(s,s+e.length,o):r.setSelection(S.TextSelection.create(r.doc,i)).addMark(s,i,o)})}}function hr(n,t){const e=[];return n.forEach((o,r,s)=>{s!==t&&e.push(o)}),T.Fragment.from(e)}function pr(n,t){const e=[];for(let o=0;o<n.childCount;o++)if(n.child(o).type.name==="tableRow")if(e.length>0&&e[e.length-1].type.name==="table"){const r=e[e.length-1],s=r.copy(r.content.addToEnd(n.child(o)));e[e.length-1]=s}else{const r=t.nodes.table.createChecked(void 0,n.child(o));e.push(r)}else e.push(n.child(o));return n=T.Fragment.from(e),n}function mr(n,t){let e=T.Fragment.from(n.content);if(e=pr(e,t.state.schema),!fr(e,t))return new T.Slice(e,n.openStart,n.openEnd);for(let o=0;o<e.childCount;o++)if(e.child(o).type.spec.group==="blockContent"){const r=[e.child(o)];if(o+1<e.childCount&&e.child(o+1).type.name==="blockGroup"){const i=e.child(o+1).child(0).child(0);(i.type.name==="bulletListItem"||i.type.name==="numberedListItem"||i.type.name==="checkListItem")&&(r.push(e.child(o+1)),e=hr(e,o+1))}const s=t.state.schema.nodes.blockContainer.createChecked(void 0,r);e=e.replaceChild(o,s)}return new T.Slice(e,n.openStart,n.openEnd)}function fr(n,t){var s,i;const e=n.childCount===1,o=((s=n.firstChild)==null?void 0:s.type.spec.content)==="inline*",r=((i=n.firstChild)==null?void 0:i.type.spec.content)==="tableRow+";if(e){if(o)return!1;if(r){const c=m.getBlockInfoFromSelection(t.state);if(c.isBlockContainer)return!(c.blockContent.node.type.spec.content==="tableRow+")}}return!0}const gr={enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!1};class Se extends d.EventEmitter{constructor(e){var p,k,g,b,f,y,w,C,_,U,K,q,G,j,x,I,Ce,Be,ve;super();u(this,"pmSchema");u(this,"extensions",{});u(this,"_tiptapEditor");u(this,"elementRenderer",null);u(this,"blockCache",new WeakMap);u(this,"dictionary");u(this,"schema");u(this,"blockImplementations");u(this,"inlineContentImplementations");u(this,"styleImplementations");u(this,"uploadFile");u(this,"onUploadStartCallbacks",[]);u(this,"onUploadEndCallbacks",[]);u(this,"resolveFileUrl");u(this,"resolveUsers");u(this,"settings");u(this,"_blockManager");u(this,"_collaborationManager");u(this,"_eventManager");u(this,"_exportManager");u(this,"_extensionManager");u(this,"_selectionManager");u(this,"_stateManager");u(this,"_styleManager");u(this,"mount",e=>{if(this.scheduledDestructionTimeout&&this.prosemirrorView.dom===e){clearTimeout(this.scheduledDestructionTimeout),this.scheduledDestructionTimeout=void 0;return}this._tiptapEditor.mount({mount:e})});u(this,"scheduledDestructionTimeout");u(this,"unmount",()=>{this.scheduledDestructionTimeout=setTimeout(()=>{this._tiptapEditor.unmount(),this.scheduledDestructionTimeout=void 0},1)});this.options=e;const o=e;if(o.onEditorContentChange)throw new Error("onEditorContentChange initialization option is deprecated, use <BlockNoteView onChange={...} />, the useEditorChange(...) hook, or editor.onChange(...)");if(o.onTextCursorPositionChange)throw new Error("onTextCursorPositionChange initialization option is deprecated, use <BlockNoteView onSelectionChange={...} />, the useEditorSelectionChange(...) hook, or editor.onSelectionChange(...)");if(o.onEditorReady)throw new Error("onEditorReady is deprecated. Editor is immediately ready for use after creation.");if(o.editable)throw new Error("editable initialization option is deprecated, use <BlockNoteView editable={true/false} />, or alternatively editor.isEditable = true/false");this.dictionary=e.dictionary||so.en,this.settings={tables:{splitCells:((p=e==null?void 0:e.tables)==null?void 0:p.splitCells)??!1,cellBackgroundColor:((k=e==null?void 0:e.tables)==null?void 0:k.cellBackgroundColor)??!1,cellTextColor:((g=e==null?void 0:e.tables)==null?void 0:g.cellTextColor)??!1,headers:((b=e==null?void 0:e.tables)==null?void 0:b.headers)??!1}};const r={defaultStyles:!0,schema:e.schema||d.BlockNoteSchema.create(),...e,placeholders:{...this.dictionary.placeholders,...e.placeholders}};if(r.collaboration||r.comments){const v={fragment:((f=r.collaboration)==null?void 0:f.fragment)||new H.XmlFragment,user:((y=r.collaboration)==null?void 0:y.user)||{name:"User",color:"#FF0000"},provider:((w=r.collaboration)==null?void 0:w.provider)||null,renderCursor:(C=r.collaboration)==null?void 0:C.renderCursor,showCursorLabels:(_=r.collaboration)==null?void 0:_.showCursorLabels,comments:r.comments,resolveUsers:r.resolveUsers};this._collaborationManager=new Gn(this,v)}else this._collaborationManager=void 0;if(r.comments&&!r.resolveUsers)throw new Error("resolveUsers is required when using comments");this.schema=r.schema,this.blockImplementations=r.schema.blockSpecs,this.inlineContentImplementations=r.schema.inlineContentSpecs,this.styleImplementations=r.schema.styleSpecs,this.extensions={...vt({editor:this,domAttributes:r.domAttributes||{},blockSpecs:this.schema.blockSpecs,styleSpecs:this.schema.styleSpecs,inlineContentSpecs:this.schema.inlineContentSpecs,collaboration:r.collaboration,trailingBlock:r.trailingBlock,disableExtensions:r.disableExtensions,setIdAttribute:r.setIdAttribute,animations:r.animations??!0,tableHandles:d.editorHasBlockWithType(this,"table"),dropCursor:this.options.dropCursor??Gt.dropCursor,placeholders:r.placeholders,tabBehavior:r.tabBehavior,pasteHandler:r.pasteHandler}),...(U=this._collaborationManager)==null?void 0:U.initExtensions()},(((K=r._tiptapOptions)==null?void 0:K.extensions)||[]).forEach(v=>{this.extensions[v.name]=v});for(let v of r.extensions||[]){typeof v=="function"&&(v=v(this));const P=v.key??v.constructor.key();if(!P)throw new Error(`Extension ${v.constructor.name} does not have a key method`);if(this.extensions[P])throw new Error(`Extension ${v.constructor.name} already exists with key ${P}`);this.extensions[P]=v}if(Object.entries(r._extensions||{}).forEach(([v,P])=>{const D=typeof P=="function"?P(this):P;if(!("plugin"in D)){this.extensions[v]=D;return}this.extensions[v]=new class extends d.BlockNoteExtension{static key(){return v}constructor(){super(),this.addProsemirrorPlugin(D.plugin)}get priority(){return D.priority}}}),r.uploadFile){const v=r.uploadFile;this.uploadFile=async(P,L)=>{this.onUploadStartCallbacks.forEach(D=>D.apply(this,[L]));try{return await v(P,L)}finally{this.onUploadEndCallbacks.forEach(D=>D.apply(this,[L]))}}}this.resolveFileUrl=r.resolveFileUrl;const s="ySyncPlugin"in this.extensions||"liveblocksExtension"in this.extensions;s&&r.initialContent&&console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider");const i=Object.fromEntries(Object.values(this.schema.blockSpecs).map(v=>v.extensions).filter(v=>v!==void 0).flat().map(v=>[v.key??v.constructor.key(),v])),c=[...Object.entries({...this.extensions,...i}).map(([v,P])=>{if(P instanceof B.Extension||P instanceof B.Node||P instanceof B.Mark)return P;if(P instanceof d.BlockNoteExtension)return!P.plugins.length&&!P.keyboardShortcuts&&!P.inputRules&&!P.tiptapExtensions?void 0:B.Extension.create({name:v,priority:P.priority,addProseMirrorPlugins:()=>P.plugins,addExtensions:()=>P.tiptapExtensions||[],addInputRules:P.inputRules?()=>P.inputRules.map(L=>new B.InputRule({find:L.find,handler:({range:D,match:ae,state:Pe})=>{const Te=L.replace({match:ae,range:D,editor:this});if(Te){const _t=this.getTextCursorPosition();if(this.schema.blockSchema[_t.block.type].content!=="inline")return;const Ot=m.getBlockInfoFromTransaction(Pe.tr),Ht=Pe.tr.deleteRange(D.from,D.to);d.updateBlockTr(Ht,Ot.bnBlock.beforePos,Te);return}return null}})):void 0,addKeyboardShortcuts:P.keyboardShortcuts?()=>Object.fromEntries(Object.entries(P.keyboardShortcuts).map(([L,D])=>[L,()=>D({editor:this})])):void 0})})].filter(v=>v!==void 0),a={...gr,...r._tiptapOptions,element:null,autofocus:r.autofocus??!1,extensions:c,editorProps:{...(q=r._tiptapOptions)==null?void 0:q.editorProps,attributes:{tabIndex:"0",...(j=(G=r._tiptapOptions)==null?void 0:G.editorProps)==null?void 0:j.attributes,...(x=r.domAttributes)==null?void 0:x.editor,class:d.mergeCSSClasses("bn-editor",r.defaultStyles?"bn-default-styles":"",((Ce=(I=r.domAttributes)==null?void 0:I.editor)==null?void 0:Ce.class)||"")},transformPasted:mr}};try{const v=r.initialContent||(s?[{type:"paragraph",id:"initialBlockId"}]:[{type:"paragraph",id:m.UniqueID.options.generateID()}]);if(!Array.isArray(v)||v.length===0)throw new Error("initialContent must be a non-empty array of blocks, received: "+v);const P=B.getSchema(a.extensions),L=v.map(ae=>m.blockToNode(ae,P,this.schema.styleSchema).toJSON()),D=B.createDocument({type:"doc",content:[{type:"blockGroup",content:L}]},P,a.parseOptions);this._tiptapEditor=new B.Editor({...a,content:D.toJSON()}),this.pmSchema=this._tiptapEditor.schema}catch(v){throw new Error("Error creating document from blocks passed as `initialContent`",{cause:v})}let l;const h=this.pmSchema.nodes.doc.createAndFill;this.pmSchema.nodes.doc.createAndFill=(...v)=>{if(l)return l;const P=h.apply(this.pmSchema.nodes.doc,v),L=JSON.parse(JSON.stringify(P.toJSON()));return L.content[0].content[0].attrs.id="initialBlockId",l=T.Node.fromJSON(this.pmSchema,L),l},this.pmSchema.cached.blockNoteEditor=this,this._blockManager=new qn(this),this._eventManager=new jn(this),this._exportManager=new or(this),this._extensionManager=new nr(this),this._selectionManager=new cr(this),this._stateManager=new lr(this,s?{undo:(Be=this._collaborationManager)==null?void 0:Be.getUndoCommand(),redo:(ve=this._collaborationManager)==null?void 0:ve.getRedoCommand()}:void 0),this._styleManager=new ur(this),this.emit("create")}get formattingToolbar(){return this._extensionManager.formattingToolbar}get linkToolbar(){return this._extensionManager.linkToolbar}get sideMenu(){return this._extensionManager.sideMenu}get suggestionMenus(){return this._extensionManager.suggestionMenus}get filePanel(){return this._extensionManager.filePanel}get tableHandles(){return this._extensionManager.tableHandles}get comments(){var e;return(e=this._collaborationManager)==null?void 0:e.comments}get showSelectionPlugin(){return this._extensionManager.showSelectionPlugin}get forkYDocPlugin(){var e;return(e=this._collaborationManager)==null?void 0:e.forkYDocPlugin}static create(e){return new Se(e??{})}exec(e){return this._stateManager.exec(e)}canExec(e){return this._stateManager.canExec(e)}transact(e){return this._stateManager.transact(e)}extension(e,o=e.key()){return this._extensionManager.extension(e,o)}get prosemirrorState(){return this._stateManager.prosemirrorState}get prosemirrorView(){return this._stateManager.prosemirrorView}get domElement(){var e;return(e=this.prosemirrorView)==null?void 0:e.dom}isFocused(){var e;return((e=this.prosemirrorView)==null?void 0:e.hasFocus())||!1}get headless(){return!this._tiptapEditor.isInitialized}focus(){this.headless||this.prosemirrorView.focus()}blur(){this.headless||this.prosemirrorView.dom.blur()}onUploadStart(e){return this.onUploadStartCallbacks.push(e),()=>{const o=this.onUploadStartCallbacks.indexOf(e);o>-1&&this.onUploadStartCallbacks.splice(o,1)}}onUploadEnd(e){return this.onUploadEndCallbacks.push(e),()=>{const o=this.onUploadEndCallbacks.indexOf(e);o>-1&&this.onUploadEndCallbacks.splice(o,1)}}get topLevelBlocks(){return this.document}get document(){return this._blockManager.document}getBlock(e){return this._blockManager.getBlock(e)}getPrevBlock(e){return this._blockManager.getPrevBlock(e)}getNextBlock(e){return this._blockManager.getNextBlock(e)}getParentBlock(e){return this._blockManager.getParentBlock(e)}forEachBlock(e,o=!1){this._blockManager.forEachBlock(e,o)}onEditorContentChange(e){this._tiptapEditor.on("update",e)}onEditorSelectionChange(e){this._tiptapEditor.on("selectionUpdate",e)}getTextCursorPosition(){return this._selectionManager.getTextCursorPosition()}setTextCursorPosition(e,o="start"){return this._selectionManager.setTextCursorPosition(e,o)}getSelection(){return this._selectionManager.getSelection()}getSelectionCutBlocks(){return this._selectionManager.getSelectionCutBlocks()}setSelection(e,o){return this._selectionManager.setSelection(e,o)}get isEditable(){return this._stateManager.isEditable}set isEditable(e){this._stateManager.isEditable=e}insertBlocks(e,o,r="before"){return this._blockManager.insertBlocks(e,o,r)}updateBlock(e,o){return this._blockManager.updateBlock(e,o)}removeBlocks(e){return this._blockManager.removeBlocks(e)}replaceBlocks(e,o){return this._blockManager.replaceBlocks(e,o)}undo(){return this._stateManager.undo()}redo(){return this._stateManager.redo()}insertInlineContent(e,{updateSelection:o=!1}={}){this._styleManager.insertInlineContent(e,{updateSelection:o})}getActiveStyles(){return this._styleManager.getActiveStyles()}addStyles(e){this._styleManager.addStyles(e)}removeStyles(e){this._styleManager.removeStyles(e)}toggleStyles(e){this._styleManager.toggleStyles(e)}getSelectedText(){return this._styleManager.getSelectedText()}getSelectedLinkUrl(){return this._styleManager.getSelectedLinkUrl()}createLink(e,o){this._styleManager.createLink(e,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(e=this.document){return this._exportManager.blocksToHTMLLossy(e)}blocksToFullHTML(e=this.document){return this._exportManager.blocksToFullHTML(e)}tryParseHTMLToBlocks(e){return this._exportManager.tryParseHTMLToBlocks(e)}blocksToMarkdownLossy(e=this.document){return this._exportManager.blocksToMarkdownLossy(e)}tryParseMarkdownToBlocks(e){return this._exportManager.tryParseMarkdownToBlocks(e)}updateCollaborationUserInfo(e){if(!this._collaborationManager)throw new Error("Cannot update collaboration user info when collaboration is disabled.");this._collaborationManager.updateUserInfo(e)}onChange(e){return this._eventManager.onChange(e)}onSelectionChange(e,o){return this._eventManager.onSelectionChange(e,o)}onCreate(e){return this.on("create",e),()=>{this.off("create",e)}}onMount(e){this._eventManager.onMount(e)}onUnmount(e){this._eventManager.onUnmount(e)}getSelectionBoundingBox(){return this._selectionManager.getSelectionBoundingBox()}get isEmpty(){const e=this.document;return e.length===0||e.length===1&&e[0].type==="paragraph"&&e[0].content.length===0}openSuggestionMenu(e,o){this.prosemirrorView&&(this.focus(),this.transact(r=>{o!=null&&o.deleteTriggerCharacter&&r.insertText(e),r.scrollIntoView().setMeta(this.suggestionMenus.plugins[0],{triggerCharacter:e,deleteTriggerCharacter:(o==null?void 0:o.deleteTriggerCharacter)||!1,ignoreQueryLength:(o==null?void 0:o.ignoreQueryLength)||!1})}))}getForceSelectionVisible(){return this.showSelectionPlugin.getEnabled()}setForceSelectionVisible(e){this.showSelectionPlugin.setEnabled(e)}pasteHTML(e,o=!1){this._exportManager.pasteHTML(e,o)}pasteText(e){return this._exportManager.pasteText(e)}pasteMarkdown(e){return this._exportManager.pasteMarkdown(e)}}class kr{constructor(t,e,o){this.mappings=e,this.options=o}async resolveFile(t){var o;if(!((o=this.options)!=null&&o.resolveFileUrl))return(await fetch(t)).blob();const e=await this.options.resolveFileUrl(t);return e instanceof Blob?e:(await fetch(e)).blob()}mapStyles(t){return Object.entries(t).map(([o,r])=>this.mappings.styleMapping[o](r,this))}mapInlineContent(t){return this.mappings.inlineContentMapping[t.type](t,this)}transformInlineContent(t){return t.map(e=>this.mapInlineContent(e))}async mapBlock(t,e,o,r){return this.mappings.blockMapping[t.type](t,this,e,o,r)}}function br(n){return{createBlockMapping:t=>t,createInlineContentMapping:t=>t,createStyleMapping:t=>t}}let ee;async function yr(){return ee||(ee=(async()=>{const[n,t]=await Promise.all([import("emoji-mart"),import("@emoji-mart/data")]),e="default"in n?n.default:n,o="default"in t?t.default:t;return await e.init({data:o}),{emojiMart:e,emojiData:o}})(),ee)}async function wr(n,t){if(!("text"in n.schema.inlineContentSchema)||n.schema.inlineContentSchema.text!==d.defaultInlineContentSchema.text)return[];const{emojiData:e,emojiMart:o}=await yr();return(t.trim()===""?Object.values(e.emojis):await o.SearchIndex.search(t)).map(s=>({id:s.skins[0].native,onItemClick:()=>n.insertInlineContent(s.skins[0].native+" ")}))}function Sr(n,...t){const e=[...n];for(const o of t)for(const r of o){const s=e.findLastIndex(i=>i.group===r.group);s===-1?e.push(r):e.splice(s+1,0,r)}return e}exports.UniqueID=m.UniqueID;exports.UnreachableCaseError=m.UnreachableCaseError;exports.assertEmpty=m.assertEmpty;exports.blockToNode=m.blockToNode;exports.contentNodeToInlineContent=m.contentNodeToInlineContent;exports.contentNodeToTableContent=m.contentNodeToTableContent;exports.docToBlocks=m.docToBlocks;exports.getBlockCache=m.getBlockCache;exports.getBlockInfo=m.getBlockInfo;exports.getBlockInfoFromResolvedPos=m.getBlockInfoFromResolvedPos;exports.getBlockInfoFromSelection=m.getBlockInfoFromSelection;exports.getBlockInfoFromTransaction=m.getBlockInfoFromTransaction;exports.getBlockInfoWithManualOffset=m.getBlockInfoWithManualOffset;exports.getBlockNoteSchema=m.getBlockNoteSchema;exports.getBlockSchema=m.getBlockSchema;exports.getColspan=m.getColspan;exports.getInlineContentSchema=m.getInlineContentSchema;exports.getNearestBlockPos=m.getNearestBlockPos;exports.getPmSchema=m.getPmSchema;exports.getRowspan=m.getRowspan;exports.getStyleSchema=m.getStyleSchema;exports.inlineContentToNodes=m.inlineContentToNodes;exports.isLinkInlineContent=m.isLinkInlineContent;exports.isPartialLinkInlineContent=m.isPartialLinkInlineContent;exports.isPartialTableCell=m.isPartialTableCell;exports.isStyledTextInlineContent=m.isStyledTextInlineContent;exports.isTableCell=m.isTableCell;exports.mapTableCell=m.mapTableCell;exports.nodeToBlock=m.nodeToBlock;exports.nodeToCustomInlineContent=m.nodeToCustomInlineContent;exports.prosemirrorSliceToSlicedBlocks=m.prosemirrorSliceToSlicedBlocks;exports.tableContentToNodes=m.tableContentToNodes;exports.BlockNoteExtension=d.BlockNoteExtension;exports.BlockNoteSchema=d.BlockNoteSchema;exports.COLORS_DARK_MODE_DEFAULT=d.COLORS_DARK_MODE_DEFAULT;exports.COLORS_DEFAULT=d.COLORS_DEFAULT;exports.CustomBlockNoteSchema=d.CustomBlockNoteSchema;exports.EMPTY_CELL_HEIGHT=d.EMPTY_CELL_HEIGHT;exports.EMPTY_CELL_WIDTH=d.EMPTY_CELL_WIDTH;exports.EventEmitter=d.EventEmitter;exports.FILE_AUDIO_ICON_SVG=d.FILE_AUDIO_ICON_SVG;exports.FILE_IMAGE_ICON_SVG=d.FILE_IMAGE_ICON_SVG;exports.FILE_VIDEO_ICON_SVG=d.FILE_VIDEO_ICON_SVG;exports.addDefaultPropsExternalHTML=d.addDefaultPropsExternalHTML;exports.addInlineContentAttributes=d.addInlineContentAttributes;exports.addInlineContentKeyboardShortcuts=d.addInlineContentKeyboardShortcuts;exports.addNodeAndExtensionsToSpec=d.addNodeAndExtensionsToSpec;exports.addStyleAttributes=d.addStyleAttributes;exports.applyNonSelectableBlockFix=d.applyNonSelectableBlockFix;exports.audioParse=d.audioParse;exports.audioRender=d.audioRender;exports.audioToExternalHTML=d.audioToExternalHTML;exports.blockHasType=d.blockHasType;exports.camelToDataKebab=d.camelToDataKebab;exports.captureCellAnchor=d.captureCellAnchor;exports.checkPageBreakBlocksInSchema=d.checkPageBreakBlocksInSchema;exports.createAudioBlockConfig=d.createAudioBlockConfig;exports.createAudioBlockSpec=d.createAudioBlockSpec;exports.createBlockConfig=d.createBlockConfig;exports.createBlockNoteExtension=d.createBlockNoteExtension;exports.createBlockSpec=d.createBlockSpec;exports.createBlockSpecFromTiptapNode=d.createBlockSpecFromTiptapNode;exports.createBulletListItemBlockConfig=d.createBulletListItemBlockConfig;exports.createBulletListItemBlockSpec=d.createBulletListItemBlockSpec;exports.createCheckListItemBlockSpec=d.createCheckListItemBlockSpec;exports.createCheckListItemConfig=d.createCheckListItemConfig;exports.createCodeBlockConfig=d.createCodeBlockConfig;exports.createCodeBlockSpec=d.createCodeBlockSpec;exports.createDefaultBlockDOMOutputSpec=d.createDefaultBlockDOMOutputSpec;exports.createDividerBlockConfig=d.createDividerBlockConfig;exports.createDividerBlockSpec=d.createDividerBlockSpec;exports.createFileBlockConfig=d.createFileBlockConfig;exports.createFileBlockSpec=d.createFileBlockSpec;exports.createHeadingBlockConfig=d.createHeadingBlockConfig;exports.createHeadingBlockSpec=d.createHeadingBlockSpec;exports.createImageBlockConfig=d.createImageBlockConfig;exports.createImageBlockSpec=d.createImageBlockSpec;exports.createInlineContentSpecFromTipTapNode=d.createInlineContentSpecFromTipTapNode;exports.createInternalInlineContentSpec=d.createInternalInlineContentSpec;exports.createInternalStyleSpec=d.createInternalStyleSpec;exports.createNumberedListItemBlockConfig=d.createNumberedListItemBlockConfig;exports.createNumberedListItemBlockSpec=d.createNumberedListItemBlockSpec;exports.createPageBreakBlockConfig=d.createPageBreakBlockConfig;exports.createPageBreakBlockSpec=d.createPageBreakBlockSpec;exports.createParagraphBlockConfig=d.createParagraphBlockConfig;exports.createParagraphBlockSpec=d.createParagraphBlockSpec;exports.createQuoteBlockConfig=d.createQuoteBlockConfig;exports.createQuoteBlockSpec=d.createQuoteBlockSpec;exports.createStyleSpec=d.createStyleSpec;exports.createStyleSpecFromTipTapMark=d.createStyleSpecFromTipTapMark;exports.createTableBlockSpec=d.createTableBlockSpec;exports.createToggleListItemBlockConfig=d.createToggleListItemBlockConfig;exports.createToggleListItemBlockSpec=d.createToggleListItemBlockSpec;exports.createToggleWrapper=d.createToggleWrapper;exports.createVideoBlockConfig=d.createVideoBlockConfig;exports.createVideoBlockSpec=d.createVideoBlockSpec;exports.defaultBlockSpecs=d.defaultBlockSpecs;exports.defaultBlockToHTML=d.defaultBlockToHTML;exports.defaultInlineContentSchema=d.defaultInlineContentSchema;exports.defaultInlineContentSpecs=d.defaultInlineContentSpecs;exports.defaultProps=d.defaultProps;exports.defaultStyleSchema=d.defaultStyleSchema;exports.defaultStyleSpecs=d.defaultStyleSpecs;exports.defaultToggledState=d.defaultToggledState;exports.editorHasBlockWithType=d.editorHasBlockWithType;exports.fileParse=d.fileParse;exports.filenameFromURL=d.filenameFromURL;exports.filterSuggestionItems=d.filterSuggestionItems;exports.formatKeyboardShortcut=d.formatKeyboardShortcut;exports.getBackgroundColorAttribute=d.getBackgroundColorAttribute;exports.getBlockFromPos=d.getBlockFromPos;exports.getDefaultSlashMenuItems=d.getDefaultSlashMenuItems;exports.getInlineContentSchemaFromSpecs=d.getInlineContentSchemaFromSpecs;exports.getLanguageId=d.getLanguageId;exports.getNodeById=d.getNodeById;exports.getPageBreakSlashMenuItems=d.getPageBreakSlashMenuItems;exports.getParseRules=d.getParseRules;exports.getStyleParseRules=d.getStyleParseRules;exports.getStyleSchemaFromSpecs=d.getStyleSchemaFromSpecs;exports.getTextAlignmentAttribute=d.getTextAlignmentAttribute;exports.getTextColorAttribute=d.getTextColorAttribute;exports.imageParse=d.imageParse;exports.imageRender=d.imageRender;exports.imageToExternalHTML=d.imageToExternalHTML;exports.insertOrUpdateBlock=d.insertOrUpdateBlock;exports.isAppleOS=d.isAppleOS;exports.isNodeBlock=d.isNodeBlock;exports.isSafari=d.isSafari;exports.isTableCellSelection=d.isTableCellSelection;exports.isVideoUrl=d.isVideoUrl;exports.mergeCSSClasses=d.mergeCSSClasses;exports.mergeParagraphs=d.mergeParagraphs;exports.parseAudioElement=d.parseAudioElement;exports.parseDefaultProps=d.parseDefaultProps;exports.propsToAttributes=d.propsToAttributes;exports.stylePropsToAttributes=d.stylePropsToAttributes;exports.tablePropSchema=d.tablePropSchema;exports.updateBlock=d.updateBlock;exports.updateBlockCommand=d.updateBlockCommand;exports.updateBlockTr=d.updateBlockTr;exports.uploadToTmpFilesDotOrg_DEV_ONLY=d.uploadToTmpFilesDotOrg_DEV_ONLY;exports.videoParse=d.videoParse;exports.withPageBreak=d.withPageBreak;exports.wrapInBlockStructure=d.wrapInBlockStructure;exports.BlockNoteEditor=Se;exports.DEFAULT_LINK_PROTOCOL=mt;exports.Exporter=kr;exports.FilePanelProsemirrorPlugin=st;exports.FilePanelView=rt;exports.FormattingToolbarProsemirrorPlugin=ct;exports.FormattingToolbarView=it;exports.HTMLToBlocks=ye;exports.LinkToolbarProsemirrorPlugin=ht;exports.SideMenuProsemirrorPlugin=yt;exports.SideMenuView=kt;exports.SuggestionMenuProseMirrorPlugin=St;exports.TableHandlesProsemirrorPlugin=Bt;exports.TableHandlesView=Ct;exports.VALID_LINK_PROTOCOLS=pt;exports.blocksToMarkdown=Ze;exports.cleanHTMLToMarkdown=ie;exports.combineByGroup=Sr;exports.createExternalHTMLExporter=X;exports.createInlineContentSpec=ko;exports.createInternalHTMLSerializer=Je;exports.createSuggestionMenu=Tn;exports.fixColumnList=oe;exports.formattingToolbarPluginKey=at;exports.getBlock=xt;exports.getBlockNoteExtensions=vt;exports.getBlocksChangedByTransaction=fe;exports.getDefaultEmojiPickerItems=wr;exports.getInlineContentParseRules=ze;exports.getNextBlock=Dt;exports.getParentBlock=Lt;exports.getPrevBlock=It;exports.insertBlocks=Ke;exports.isEmptyColumn=te;exports.linkToolbarPluginKey=ut;exports.mappingFactory=br;exports.markdownToBlocks=Nt;exports.markdownToHTML=we;exports.removeAndInsertBlocks=ue;exports.removeEmptyColumns=qe;exports.selectedFragmentToHTML=ke;exports.sideMenuPluginKey=bt;exports.tableHandlesPluginKey=V;exports.trackPosition=wt;
|
|
4
|
+
`}}),he=(n,t)=>{const e=n.resolve(t),o=e.index();if(o===0)return;const r=e.posAtIndex(o-1);return m.getBlockInfoFromResolvedPos(n.resolve(r))},lt=(n,t)=>{for(;t.childContainer;){const e=t.childContainer.node,o=n.resolve(t.childContainer.beforePos+1).posAtIndex(e.childCount-1);t=m.getBlockInfoFromResolvedPos(n.resolve(o))}return t},rn=(n,t)=>n.isBlockContainer&&n.blockContent.node.type.spec.content==="inline*"&&n.blockContent.node.childCount>0&&t.isBlockContainer&&t.blockContent.node.type.spec.content==="inline*",sn=(n,t,e,o)=>{if(!o.isBlockContainer)throw new Error(`Attempted to merge block at position ${o.bnBlock.beforePos} into previous block at position ${e.bnBlock.beforePos}, but next block is not a block container`);if(o.childContainer){const r=n.doc.resolve(o.childContainer.beforePos+1),s=n.doc.resolve(o.childContainer.afterPos-1),i=r.blockRange(s);if(t){const c=n.doc.resolve(o.bnBlock.beforePos);n.tr.lift(i,c.depth)}}if(t){if(!e.isBlockContainer)throw new Error(`Attempted to merge block at position ${o.bnBlock.beforePos} into previous block at position ${e.bnBlock.beforePos}, but previous block is not a block container`);t(n.tr.delete(e.blockContent.afterPos-1,o.blockContent.beforePos+1))}return!0},Ne=n=>({state:t,dispatch:e})=>{const o=t.doc.resolve(n),r=m.getBlockInfoFromResolvedPos(o),s=he(t.doc,r.bnBlock.beforePos);if(!s)return!1;const i=lt(t.doc,s);return rn(i,r)?sn(t,e,i,r):!1};function an(n,t,e){const{$from:o,$to:r}=n.selection,s=o.blockRange(r,b=>b.childCount>0&&(b.type.name==="blockGroup"||b.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!==t)return!1;const l=a.lastChild&&a.lastChild.type===e,h=T.Fragment.from(l?t.create():null),p=new T.Slice(T.Fragment.from(t.create(null,T.Fragment.from(e.create(null,h)))),l?3:1,0),k=s.start,g=s.end;return n.step(new W.ReplaceAroundStep(k-(l?3:1),g,k,g,p,1,!0)).scrollIntoView(),!0}function dt(n){return n.transact(t=>an(t,n.pmSchema.nodes.blockContainer,n.pmSchema.nodes.blockGroup))}function cn(n){n._tiptapEditor.commands.liftListItem("blockContainer")}function ln(n){return n.transact(t=>{const{bnBlock:e}=m.getBlockInfoFromTransaction(t);return t.doc.resolve(e.beforePos).nodeBefore!==null})}function dn(n){return n.transact(t=>{const{bnBlock:e}=m.getBlockInfoFromTransaction(t);return t.doc.resolve(e.beforePos).depth>1})}const un=B.Extension.create({priority:50,addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({chain:o,commands:r})=>[()=>r.deleteSelection(),()=>r.undoInputRule(),()=>r.command(({state:s})=>{const i=m.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;const c=s.selection.from===i.blockContent.beforePos+1,a=i.blockContent.node.type.name==="paragraph";return c&&!a?r.command(d.updateBlockCommand(i.bnBlock.beforePos,{type:"paragraph",props:{}})):!1}),()=>r.command(({state:s})=>{const i=m.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;const{blockContent:c}=i;return s.selection.from===c.beforePos+1?r.liftListItem("blockContainer"):!1}),()=>r.command(({state:s})=>{const i=m.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;const{bnBlock:c,blockContent:a}=i,l=s.selection.from===a.beforePos+1,h=s.selection.empty,p=c.beforePos;return l&&h?o().command(Ne(p)).scrollIntoView().run():!1}),()=>r.command(({state:s,tr:i,dispatch:c})=>{const a=m.getBlockInfoFromSelection(s);if(!a.isBlockContainer||!(i.selection.from===a.blockContent.beforePos+1))return!1;const h=i.doc.resolve(a.bnBlock.beforePos);if(h.nodeBefore||h.node().type.name!=="column")return!1;const g=i.doc.resolve(a.bnBlock.beforePos),b=i.doc.resolve(g.before()),f=b.before();if(c){const y=i.doc.slice(a.bnBlock.beforePos,a.bnBlock.afterPos).content;i.delete(a.bnBlock.beforePos,a.bnBlock.afterPos),b.index()===0?(oe(i,f),i.insert(f,y),i.setSelection(S.TextSelection.near(i.doc.resolve(f)))):(i.insert(b.pos-1,y),i.setSelection(S.TextSelection.near(i.doc.resolve(b.pos-1))),oe(i,f))}return!0}),()=>r.command(({state:s})=>{const i=m.getBlockInfoFromSelection(s);if(!i.isBlockContainer)return!1;if(i.blockContent.node.childCount===0&&i.blockContent.node.type.spec.content==="inline*"){const a=he(s.doc,i.bnBlock.beforePos);if(!a||!a.isBlockContainer)return!1;let l=o();if(a.blockContent.node.type.spec.content==="tableRow+"){const b=i.bnBlock.beforePos-1-1-1-1-1;l=l.setTextSelection(b)}else if(a.blockContent.node.type.spec.content===""){const h=a.blockContent.afterPos-a.blockContent.node.nodeSize;l=l.setNodeSelection(h)}else{const h=a.blockContent.afterPos-a.blockContent.node.nodeSize;l=l.setTextSelection(h)}return l.deleteRange({from:i.bnBlock.beforePos,to:i.bnBlock.afterPos}).scrollIntoView().run()}return!1}),()=>r.command(({state:s})=>{const i=m.getBlockInfoFromSelection(s);if(!i.isBlockContainer)throw new Error("todo");const c=s.selection.from===i.blockContent.beforePos+1,a=s.selection.empty,l=he(s.doc,i.bnBlock.beforePos);if(l&&c&&a){const h=lt(s.doc,l);if(!h.isBlockContainer)throw new Error("todo");if(h.blockContent.node.type.spec.content===""||h.blockContent.node.type.spec.content==="inline*"&&h.blockContent.node.childCount===0)return o().cut({from:i.bnBlock.beforePos,to:i.bnBlock.afterPos},h.bnBlock.afterPos).deleteRange({from:h.bnBlock.beforePos,to:h.bnBlock.afterPos}).run()}return!1})]),t=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.command(({state:r})=>{const s=m.getBlockInfoFromSelection(r);if(!s.isBlockContainer)return!1;const{bnBlock:i,blockContent:c,childContainer:a}=s,{depth:l}=r.doc.resolve(i.beforePos),h=i.afterPos===r.doc.nodeSize-3,p=r.selection.from===c.afterPos-1,k=r.selection.empty;if(!h&&p&&k&&!(a!==void 0)){let b=l,f=i.afterPos+1,y=r.doc.resolve(f).depth;for(;y<b;)b=y,f+=2,y=r.doc.resolve(f).depth;return o.command(Ne(f-1))}return!1})]),e=(o=!1)=>this.editor.commands.first(({commands:r,tr:s})=>[()=>r.command(({state:i})=>{const c=m.getBlockInfoFromSelection(i);if(!c.isBlockContainer)return!1;const{bnBlock:a,blockContent:l}=c,{depth:h}=i.doc.resolve(a.beforePos),p=i.selection.$anchor.parentOffset===0,k=i.selection.anchor===i.selection.head,g=l.node.childCount===0,b=h>1;return p&&k&&g&&b?r.liftListItem("blockContainer"):!1}),()=>r.command(({state:i})=>{var l;const c=m.getBlockInfoFromSelection(i),a=((l=this.options.editor.schema.blockSchema[c.blockNoteType].meta)==null?void 0:l.hardBreakShortcut)??"shift+enter";if(a==="none")return!1;if(a==="shift+enter"&&o||a==="enter"){const h=s.storedMarks||s.selection.$head.marks().filter(p=>this.editor.extensionManager.splittableMarks.includes(p.type.name));return s.insert(s.selection.head,s.doc.type.schema.nodes.hardBreak.create()).ensureMarks(h),!0}return!1}),()=>r.command(({state:i,dispatch:c})=>{const a=m.getBlockInfoFromSelection(i);if(!a.isBlockContainer)return!1;const{bnBlock:l,blockContent:h}=a,p=i.selection.$anchor.parentOffset===0,k=i.selection.anchor===i.selection.head,g=h.node.childCount===0;if(p&&k&&g){const b=l.afterPos,f=b+2;if(c){const y=i.schema.nodes.blockContainer.createAndFill();i.tr.insert(b,y).scrollIntoView(),i.tr.setSelection(new S.TextSelection(i.doc.resolve(f)))}return!0}return!1}),()=>r.command(({state:i,chain:c})=>{const a=m.getBlockInfoFromSelection(i);if(!a.isBlockContainer)return!1;const{blockContent:l}=a,h=i.selection.$anchor.parentOffset===0;return l.node.childCount===0?!1:(c().deleteSelection().command(d.splitBlockCommand(i.selection.from,h,h)).run(),!0)})]);return{Backspace:n,Delete:t,Enter:()=>e(),"Shift-Enter":()=>e(!0),Tab:()=>{var o,r,s;return this.options.tabBehavior!=="prefer-indent"&&((o=this.options.editor.formattingToolbar)!=null&&o.shown||(r=this.options.editor.linkToolbar)!=null&&r.shown||(s=this.options.editor.filePanel)!=null&&s.shown)?!1:dt(this.options.editor)},"Shift-Tab":()=>{var o,r,s;return this.options.tabBehavior!=="prefer-indent"&&((o=this.options.editor.formattingToolbar)!=null&&o.shown||(r=this.options.editor.linkToolbar)!=null&&r.shown||(s=this.options.editor.filePanel)!=null&&s.shown)?!1:(this.editor.commands.liftListItem("blockContainer"),!0)},"Shift-Mod-ArrowUp":()=>(this.options.editor.moveBlocksUp(),!0),"Shift-Mod-ArrowDown":()=>(this.options.editor.moveBlocksDown(),!0),"Mod-z":()=>this.options.editor.undo(),"Mod-y":()=>this.options.editor.redo(),"Shift-Mod-z":()=>this.options.editor.redo()}}});class hn{constructor(t,e,o){u(this,"state");u(this,"emitUpdate");u(this,"menuUpdateTimer");u(this,"startMenuUpdateTimer");u(this,"stopMenuUpdateTimer");u(this,"mouseHoveredLinkMark");u(this,"mouseHoveredLinkMarkRange");u(this,"keyboardHoveredLinkMark");u(this,"keyboardHoveredLinkMarkRange");u(this,"linkMark");u(this,"linkMarkRange");u(this,"mouseOverHandler",t=>{if(this.mouseHoveredLinkMark=void 0,this.mouseHoveredLinkMarkRange=void 0,this.stopMenuUpdateTimer(),t.target instanceof HTMLAnchorElement&&t.target.nodeName==="A"){const e=t.target,o=this.pmView.posAtDOM(e,0)+1,r=this.pmView.state.doc.resolve(o),s=r.marks();for(const i of s)if(i.type.name===this.pmView.state.schema.mark("link").type.name){this.mouseHoveredLinkMark=i,this.mouseHoveredLinkMarkRange=B.getMarkRange(r,i.type,i.attrs)||void 0;break}}return this.startMenuUpdateTimer(),!1});u(this,"clickHandler",t=>{var o;const e=this.pmView.dom.parentElement;this.linkMark&&t&&t.target&&!(e===t.target||e.contains(t.target))&&(o=this.state)!=null&&o.show&&(this.state.show=!1,this.emitUpdate())});u(this,"scrollHandler",()=>{var t;this.linkMark!==void 0&&(t=this.state)!=null&&t.show&&(this.state.referencePos=B.posToDOMRect(this.pmView,this.linkMarkRange.from,this.linkMarkRange.to),this.emitUpdate())});u(this,"closeMenu",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())});this.editor=t,this.pmView=e,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized link toolbar");o(this.state)},this.startMenuUpdateTimer=()=>{this.menuUpdateTimer=setTimeout(()=>{this.update(this.pmView,void 0,!0)},250)},this.stopMenuUpdateTimer=()=>(this.menuUpdateTimer&&(clearTimeout(this.menuUpdateTimer),this.menuUpdateTimer=void 0),!1),this.pmView.dom.addEventListener("mouseover",this.mouseOverHandler),this.pmView.root.addEventListener("click",this.clickHandler,!0),this.pmView.root.addEventListener("scroll",this.scrollHandler,!0)}editLink(t,e){var o;this.editor.transact(r=>{const s=m.getPmSchema(r);r.insertText(e,this.linkMarkRange.from,this.linkMarkRange.to),r.addMark(this.linkMarkRange.from,this.linkMarkRange.from+e.length,s.mark("link",{href:t}))}),this.pmView.focus(),(o=this.state)!=null&&o.show&&(this.state.show=!1,this.emitUpdate())}deleteLink(){var t;this.editor.transact(e=>e.removeMark(this.linkMarkRange.from,this.linkMarkRange.to,this.linkMark.type).setMeta("preventAutolink",!0)),this.pmView.focus(),(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate())}update(t,e,o=!1){var c;const{state:r}=t;if(e&&e.selection.from===r.selection.from&&e.selection.to===r.selection.to||!this.pmView.hasFocus())return;const i=this.linkMark;if(this.linkMark=void 0,this.linkMarkRange=void 0,this.keyboardHoveredLinkMark=void 0,this.keyboardHoveredLinkMarkRange=void 0,this.pmView.state.selection.empty){const a=this.pmView.state.selection.$from.marks();for(const l of a)if(l.type.name===this.pmView.state.schema.mark("link").type.name){this.keyboardHoveredLinkMark=l,this.keyboardHoveredLinkMarkRange=B.getMarkRange(this.pmView.state.selection.$from,l.type,l.attrs)||void 0;break}}if(this.mouseHoveredLinkMark&&o&&(this.linkMark=this.mouseHoveredLinkMark,this.linkMarkRange=this.mouseHoveredLinkMarkRange),this.keyboardHoveredLinkMark&&(this.linkMark=this.keyboardHoveredLinkMark,this.linkMarkRange=this.keyboardHoveredLinkMarkRange),this.linkMark&&this.editor.isEditable){this.state={show:!0,referencePos:B.posToDOMRect(this.pmView,this.linkMarkRange.from,this.linkMarkRange.to),url:this.linkMark.attrs.href,text:this.pmView.state.doc.textBetween(this.linkMarkRange.from,this.linkMarkRange.to)},this.emitUpdate();return}if((c=this.state)!=null&&c.show&&i&&(!this.linkMark||!this.editor.isEditable)){this.state.show=!1,this.emitUpdate();return}}destroy(){this.pmView.dom.removeEventListener("mouseover",this.mouseOverHandler),this.pmView.root.removeEventListener("scroll",this.scrollHandler,!0),this.pmView.root.removeEventListener("click",this.clickHandler,!0)}}const ut=new S.PluginKey("LinkToolbarPlugin");class ht extends d.BlockNoteExtension{constructor(e){super();u(this,"view");u(this,"editLink",(e,o)=>{this.view.editLink(e,o)});u(this,"deleteLink",()=>{this.view.deleteLink()});u(this,"startHideTimer",()=>{this.view.startMenuUpdateTimer()});u(this,"stopHideTimer",()=>{this.view.stopMenuUpdateTimer()});u(this,"closeMenu",()=>this.view.closeMenu());this.addProsemirrorPlugin(new S.Plugin({key:ut,view:o=>(this.view=new hn(e,o,r=>{this.emit("update",r)}),this.view),props:{handleKeyDown:(o,r)=>r.key==="Escape"&&this.shown?(this.view.closeMenu(),!0):!1}}))}static key(){return"linkToolbar"}onUpdate(e){return this.on("update",e)}get shown(){var e,o;return((o=(e=this.view)==null?void 0:e.state)==null?void 0:o.show)||!1}}const pt=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"],mt="https",pn=new S.PluginKey("node-selection-keyboard");class mn extends d.BlockNoteExtension{static key(){return"nodeSelectionKeyboard"}constructor(){super(),this.addProsemirrorPlugin(new S.Plugin({key:pn,props:{handleKeyDown:(t,e)=>{if("node"in t.state.selection){if(e.ctrlKey||e.metaKey)return!1;if(e.key.length===1)return e.preventDefault(),!0;if(e.key==="Enter"&&!e.shiftKey&&!e.altKey&&!e.ctrlKey&&!e.metaKey){const o=t.state.tr;return t.dispatch(o.insert(t.state.tr.selection.$to.after(),t.state.schema.nodes.paragraph.createChecked()).setSelection(new S.TextSelection(o.doc.resolve(t.state.tr.selection.$to.after()+1)))),!0}}return!1}}}))}}const fn=new S.PluginKey("blocknote-placeholder");class gn extends d.BlockNoteExtension{static key(){return"placeholder"}constructor(t,e){super(),this.addProsemirrorPlugin(new S.Plugin({key:fn,view:o=>{const r=`placeholder-selector-${ro.v4()}`;o.dom.classList.add(r);const s=document.createElement("style"),i=t._tiptapEditor.options.injectNonce;i&&s.setAttribute("nonce",i),o.root instanceof window.ShadowRoot?o.root.append(s):o.root.head.appendChild(s);const c=s.sheet,a=(l="")=>`.${r} .bn-block-content${l} .bn-inline-content:has(> .ProseMirror-trailingBreak:only-child):before`;try{const{default:l,emptyDocument:h,...p}=e;for(const[b,f]of Object.entries(p)){const y=`[data-content-type="${b}"]`;c.insertRule(`${a(y)} { content: ${JSON.stringify(f)}; }`)}const k="[data-is-only-empty-block]",g="[data-is-empty-and-focused]";c.insertRule(`${a(k)} { content: ${JSON.stringify(h)}; }`),c.insertRule(`${a(g)} { content: ${JSON.stringify(l)}; }`)}catch(l){console.warn("Failed to insert placeholder CSS rule - this is likely due to the browser not supporting certain CSS pseudo-element selectors (:has, :only-child:, or :before)",l)}return{destroy:()=>{o.root instanceof window.ShadowRoot?o.root.removeChild(s):o.root.head.removeChild(s)}}},props:{decorations:o=>{const{doc:r,selection:s}=o;if(!t.isEditable||!s.empty||s.$from.parent.type.spec.code)return;const i=[];o.doc.content.size===6&&i.push(M.Decoration.node(2,4,{"data-is-only-empty-block":"true"}));const c=s.$anchor,a=c.parent;if(a.content.size===0){const l=c.before();i.push(M.Decoration.node(l,l+a.nodeSize,{"data-is-empty-and-focused":"true"}))}return M.DecorationSet.create(r,i)}}}))}}const Ae=new S.PluginKey("previous-blocks"),kn={index:"index",level:"level",type:"type",depth:"depth","depth-change":"depth-change"};class bn extends d.BlockNoteExtension{static key(){return"previousBlockType"}constructor(){super();let t;this.addProsemirrorPlugin(new S.Plugin({key:Ae,view(e){return{update:async(o,r)=>{var s;((s=this.key)==null?void 0:s.getState(o.state).updatedBlocks.size)>0&&(t=setTimeout(()=>{o.dispatch(o.state.tr.setMeta(Ae,{clearUpdate:!0}))},0))},destroy:()=>{t&&clearTimeout(t)}}},state:{init(){return{prevTransactionOldBlockAttrs:{},currentTransactionOldBlockAttrs:{},updatedBlocks:new Set}},apply(e,o,r,s){if(o.currentTransactionOldBlockAttrs={},o.updatedBlocks.clear(),!e.docChanged||r.doc.eq(s.doc))return o;const i={},c=B.findChildren(r.doc,h=>h.attrs.id),a=new Map(c.map(h=>[h.node.attrs.id,h])),l=B.findChildren(s.doc,h=>h.attrs.id);for(const h of l){const p=a.get(h.node.attrs.id),k=p==null?void 0:p.node.firstChild,g=h.node.firstChild;if(p&&k&&g){const b={index:g.attrs.index,level:g.attrs.level,type:g.type.name,depth:s.doc.resolve(h.pos).depth},f={index:k.attrs.index,level:k.attrs.level,type:k.type.name,depth:r.doc.resolve(p.pos).depth};i[h.node.attrs.id]=f,o.currentTransactionOldBlockAttrs[h.node.attrs.id]=f,JSON.stringify(f)!==JSON.stringify(b)&&(f["depth-change"]=f.depth-b.depth,o.updatedBlocks.add(h.node.attrs.id))}}return o.prevTransactionOldBlockAttrs=i,o}},props:{decorations(e){const o=this.getState(e);if(o.updatedBlocks.size===0)return;const r=[];return e.doc.descendants((s,i)=>{if(!s.attrs.id||!o.updatedBlocks.has(s.attrs.id))return;const c=o.currentTransactionOldBlockAttrs[s.attrs.id],a={};for(const[h,p]of Object.entries(c))a["data-prev-"+kn[h]]=p||"none";const l=M.Decoration.node(i,i+s.nodeSize,{...a});r.push(l)}),M.DecorationSet.create(e.doc,r)}}}))}}const _e=new S.PluginKey("blocknote-show-selection");class yn extends d.BlockNoteExtension{constructor(e){super();u(this,"enabled",!1);this.editor=e,this.addProsemirrorPlugin(new S.Plugin({key:_e,props:{decorations:o=>{const{doc:r,selection:s}=o;if(!this.enabled)return M.DecorationSet.empty;const i=M.Decoration.inline(s.from,s.to,{"data-show-selection":"true"});return M.DecorationSet.create(r,[i])}}}))}static key(){return"showSelection"}setEnabled(e){this.enabled!==e&&(this.enabled=e,this.editor.transact(o=>o.setMeta(_e,{})))}getEnabled(){return this.enabled}}function ft(n,t){var e,o;for(;n&&n.parentElement&&n.parentElement!==t.dom&&((e=n.getAttribute)==null?void 0:e.call(n,"data-node-type"))!=="blockContainer";)n=n.parentElement;if(((o=n.getAttribute)==null?void 0:o.call(n,"data-node-type"))==="blockContainer")return{node:n,id:n.getAttribute("data-id")}}class F extends S.Selection{constructor(e,o){super(e,o);u(this,"nodes");const r=e.node();this.nodes=[],e.doc.nodesBetween(e.pos,o.pos,(s,i,c)=>{if(c!==null&&c.eq(r))return this.nodes.push(s),!1})}static create(e,o,r=o){return new F(e.resolve(o),e.resolve(r))}content(){return new T.Slice(T.Fragment.from(this.nodes),0,0)}eq(e){if(!(e instanceof F)||this.nodes.length!==e.nodes.length||this.from!==e.from||this.to!==e.to)return!1;for(let o=0;o<this.nodes.length;o++)if(!this.nodes[o].eq(e.nodes[o]))return!1;return!0}map(e,o){const r=o.mapResult(this.from),s=o.mapResult(this.to);return s.deleted?S.Selection.near(e.resolve(r.pos)):r.deleted?S.Selection.near(e.resolve(s.pos)):new F(e.resolve(r.pos),e.resolve(s.pos))}toJSON(){return{type:"multiple-node",anchor:this.anchor,head:this.head}}}S.Selection.jsonID("multiple-node",F);let O;function wn(n,t){let e,o;const r=t.resolve(n.from).node().type.spec.group==="blockContent",s=t.resolve(n.to).node().type.spec.group==="blockContent",i=Math.min(n.$anchor.depth,n.$head.depth);if(r&&s){const c=n.$from.start(i-1),a=n.$to.end(i-1);e=t.resolve(c-1).pos,o=t.resolve(a+1).pos}else e=n.from,o=n.to;return{from:e,to:o}}function Oe(n,t,e=t){t===e&&(e+=n.state.doc.resolve(t+1).node().nodeSize);const o=n.domAtPos(t).node.cloneNode(!0),r=n.domAtPos(t).node,s=(p,k)=>Array.prototype.indexOf.call(p.children,k),i=s(r,n.domAtPos(t+1).node.parentElement),c=s(r,n.domAtPos(e-1).node.parentElement);for(let p=r.childElementCount-1;p>=0;p--)(p>c||p<i)&&o.removeChild(o.children[p]);gt(n.root),O=o;const a=O.getElementsByTagName("iframe");for(let p=0;p<a.length;p++){const k=a[p],g=k.parentElement;g&&g.removeChild(k)}const h=n.dom.className.split(" ").filter(p=>p!=="ProseMirror"&&p!=="bn-root"&&p!=="bn-editor").join(" ");O.className=O.className+" bn-drag-preview "+h,n.root instanceof ShadowRoot?n.root.appendChild(O):n.root.body.appendChild(O)}function gt(n){O!==void 0&&(n instanceof ShadowRoot?n.removeChild(O):n.body.removeChild(O),O=void 0)}function Sn(n,t,e){if(!n.dataTransfer||e.headless)return;const o=e.prosemirrorView,r=d.getNodeById(t.id,o.state.doc);if(!r)throw new Error(`Block with ID ${t.id} not found`);const s=r.posBeforeNode;if(s!=null){const i=o.state.selection,c=o.state.doc,{from:a,to:l}=wn(i,c),h=a<=s&&s<l,p=i.$anchor.node()!==i.$head.node()||i instanceof F;h&&p?(o.dispatch(o.state.tr.setSelection(F.create(c,a,l))),Oe(o,a,l)):(o.dispatch(o.state.tr.setSelection(S.NodeSelection.create(o.state.doc,s))),Oe(o,s));const k=o.state.selection.content(),g=e.pmSchema,b=o.serializeForClipboard(k).dom.innerHTML,f=X(g,e),y=et(k.content),w=f.exportBlocks(y,{}),C=ie(w);n.dataTransfer.clearData(),n.dataTransfer.setData("blocknote/html",b),n.dataTransfer.setData("text/html",w),n.dataTransfer.setData("text/plain",C),n.dataTransfer.effectAllowed="move",n.dataTransfer.setDragImage(O,0,0)}}const He=250;function pe(n,t,e=!0){const o=n.root.elementsFromPoint(t.left,t.top);for(const r of o)if(n.dom.contains(r))return e&&r.closest("[data-node-type=columnList]")?pe(n,{left:t.left+50,top:t.top},!1):ft(r,n)}function Cn(n,t){if(!t.dom.firstChild)return;const e=t.dom.firstChild.getBoundingClientRect(),o={left:Math.min(Math.max(e.left+10,n.x),e.right-10),top:n.y},r=pe(t,o);if(!r)return;const s=r.node.getBoundingClientRect();return pe(t,{left:s.right-10,top:n.y},!1)}class kt{constructor(t,e,o){u(this,"state");u(this,"emitUpdate");u(this,"mousePos");u(this,"hoveredBlock");u(this,"menuFrozen",!1);u(this,"isDragOrigin",!1);u(this,"updateState",t=>{this.state=t,this.emitUpdate(this.state)});u(this,"updateStateFromMousePos",()=>{var o,r,s,i,c;if(this.menuFrozen||!this.mousePos)return;const t=this.findClosestEditorElement({clientX:this.mousePos.x,clientY:this.mousePos.y});if((t==null?void 0:t.element)!==this.pmView.dom||t.distance>He){(o=this.state)!=null&&o.show&&(this.state.show=!1,this.updateState(this.state));return}const e=Cn(this.mousePos,this.pmView);if(!e||!this.editor.isEditable){(r=this.state)!=null&&r.show&&(this.state.show=!1,this.updateState(this.state));return}if(!((s=this.state)!=null&&s.show&&((i=this.hoveredBlock)!=null&&i.hasAttribute("data-id"))&&((c=this.hoveredBlock)==null?void 0:c.getAttribute("data-id"))===e.id)&&(this.hoveredBlock=e.node,this.editor.isEditable)){const a=e.node.getBoundingClientRect(),l=e.node.closest("[data-node-type=column]");this.state={show:!0,referencePos:new DOMRect(l?l.firstElementChild.getBoundingClientRect().x:this.pmView.dom.firstChild.getBoundingClientRect().x,a.y,a.width,a.height),block:this.editor.getBlock(this.hoveredBlock.getAttribute("data-id"))},this.updateState(this.state)}});u(this,"onDragStart",t=>{var i;const e=(i=t.dataTransfer)==null?void 0:i.getData("blocknote/html");if(!e||this.pmView.dragging)return;const o=document.createElement("div");o.innerHTML=e;const s=T.DOMParser.fromSchema(this.pmView.state.schema).parse(o,{topNode:this.pmView.state.schema.nodes.blockGroup.create()});this.pmView.dragging={slice:new T.Slice(s.content,0,0),move:!0}});u(this,"findClosestEditorElement",t=>{const e=Array.from(this.pmView.root.querySelectorAll(".bn-editor"));if(e.length===0)return null;let o=e[0],r=Number.MAX_VALUE;return e.forEach(s=>{const i=s.querySelector(".bn-block-group").getBoundingClientRect(),c=t.clientX<i.left?i.left-t.clientX:t.clientX>i.right?t.clientX-i.right:0,a=t.clientY<i.top?i.top-t.clientY:t.clientY>i.bottom?t.clientY-i.bottom:0,l=Math.sqrt(Math.pow(c,2)+Math.pow(a,2));l<r&&(r=l,o=s)}),{element:o,distance:r}});u(this,"onDragOver",t=>{if(t.synthetic)return;const e=this.getDragEventContext(t);if(!e||!e.isDropPoint){this.closeDropCursor();return}e.isDropPoint&&!e.isDropWithinEditorBounds&&this.dispatchSyntheticEvent(t)});u(this,"closeDropCursor",()=>{const t=new Event("dragleave",{bubbles:!1});t.synthetic=!0,this.pmView.dom.dispatchEvent(t)});u(this,"getDragEventContext",t=>{var a;const e=!((a=t.dataTransfer)!=null&&a.types.includes("blocknote/html"))&&!!this.pmView.dragging,o=!!this.isDragOrigin,r=e||o,s=this.findClosestEditorElement(t);if(!s||s.distance>He)return;const i=s.element===this.pmView.dom,c=i&&s.distance===0;if(!(!i&&!r))return{isDropPoint:i,isDropWithinEditorBounds:c,isDragOrigin:r}});u(this,"onDrop",t=>{if(t.synthetic)return;const e=this.getDragEventContext(t);if(!e){this.closeDropCursor();return}const{isDropPoint:o,isDropWithinEditorBounds:r,isDragOrigin:s}=e;if(!r&&o&&this.dispatchSyntheticEvent(t),o){if(this.pmView.dragging)return;this.pmView.dispatch(this.pmView.state.tr.setSelection(S.TextSelection.create(this.pmView.state.tr.doc,this.pmView.state.tr.selection.anchor)));return}else if(s){setTimeout(()=>this.pmView.dispatch(this.pmView.state.tr.deleteSelection()),0);return}});u(this,"onDragEnd",t=>{t.synthetic||(this.pmView.dragging=null)});u(this,"onKeyDown",t=>{var e;(e=this.state)!=null&&e.show&&this.editor.isFocused()&&(this.state.show=!1,this.emitUpdate(this.state))});u(this,"onMouseMove",t=>{var s;if(this.menuFrozen)return;this.mousePos={x:t.clientX,y:t.clientY};const e=this.pmView.dom.getBoundingClientRect(),o=this.mousePos.x>e.left&&this.mousePos.x<e.right&&this.mousePos.y>e.top&&this.mousePos.y<e.bottom,r=this.pmView.dom.parentElement;if(o&&t&&t.target&&!(r===t.target||r.contains(t.target))){(s=this.state)!=null&&s.show&&(this.state.show=!1,this.emitUpdate(this.state));return}this.updateStateFromMousePos()});u(this,"onScroll",()=>{var t;(t=this.state)!=null&&t.show&&(this.state.referencePos=this.hoveredBlock.getBoundingClientRect(),this.emitUpdate(this.state)),this.updateStateFromMousePos()});this.editor=t,this.pmView=e,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized side menu");o(this.state)},this.pmView.root.addEventListener("dragstart",this.onDragStart),this.pmView.root.addEventListener("dragover",this.onDragOver),this.pmView.root.addEventListener("drop",this.onDrop,!0),this.pmView.root.addEventListener("dragend",this.onDragEnd,!0),this.pmView.root.addEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.addEventListener("keydown",this.onKeyDown,!0),e.root.addEventListener("scroll",this.onScroll,!0)}dispatchSyntheticEvent(t){const e=new Event(t.type,t),o=this.pmView.dom.firstChild.getBoundingClientRect();e.clientX=t.clientX,e.clientY=t.clientY,e.clientX=Math.min(Math.max(t.clientX,o.left),o.left+o.width),e.clientY=Math.min(Math.max(t.clientY,o.top),o.top+o.height),e.dataTransfer=t.dataTransfer,e.preventDefault=()=>t.preventDefault(),e.synthetic=!0,this.pmView.dom.dispatchEvent(e)}update(t,e){var r;!e.doc.eq(this.pmView.state.doc)&&((r=this.state)!=null&&r.show)&&this.updateStateFromMousePos()}destroy(){var t;(t=this.state)!=null&&t.show&&(this.state.show=!1,this.emitUpdate(this.state)),this.pmView.root.removeEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.removeEventListener("dragstart",this.onDragStart),this.pmView.root.removeEventListener("dragover",this.onDragOver),this.pmView.root.removeEventListener("drop",this.onDrop,!0),this.pmView.root.removeEventListener("dragend",this.onDragEnd,!0),this.pmView.root.removeEventListener("keydown",this.onKeyDown,!0),this.pmView.root.removeEventListener("scroll",this.onScroll,!0)}}const bt=new S.PluginKey("SideMenuPlugin");class yt extends d.BlockNoteExtension{constructor(e){super();u(this,"view");u(this,"blockDragStart",(e,o)=>{this.view&&(this.view.isDragOrigin=!0),Sn(e,o,this.editor)});u(this,"blockDragEnd",()=>{gt(this.editor.prosemirrorView.root),this.view&&(this.view.isDragOrigin=!1),this.editor.blur()});u(this,"freezeMenu",()=>{this.view.menuFrozen=!0,this.view.state.show=!0,this.view.emitUpdate(this.view.state)});u(this,"unfreezeMenu",()=>{this.view.menuFrozen=!1,this.view.state.show=!1,this.view.emitUpdate(this.view.state)});this.editor=e,this.addProsemirrorPlugin(new S.Plugin({key:bt,view:o=>(this.view=new kt(e,o,r=>{this.emit("update",r)}),this.view)}))}static key(){return"sideMenu"}onUpdate(e){return this.on("update",e)}}const Q=new Map;function Bn(n){if(Q.has(n))return Q.get(n);const t=new W.Mapping;return n._tiptapEditor.on("transaction",({transaction:e})=>{t.appendMapping(e.mapping)}),n._tiptapEditor.on("destroy",()=>{Q.delete(n)}),Q.set(n,t),t}function wt(n,t,e="left"){const o=E.ySyncPluginKey.getState(n.prosemirrorState);if(!o){const s=Bn(n),i=s.maps.length;return()=>s.slice(i).map(t,e==="left"?-1:1)}const r=E.absolutePositionToRelativePosition(t+(e==="right"?1:-1),o.binding.type,o.binding.mapping);return()=>{const s=E.ySyncPluginKey.getState(n.prosemirrorState),i=E.relativePositionToAbsolutePosition(s.doc,s.binding.type,r,s.binding.mapping);if(i===null)throw new Error("Position not found, cannot track positions");return i+(e==="right"?-1:1)}}const vn=B.findParentNode(n=>n.type.name==="blockContainer");class Pn{constructor(t,e,o){u(this,"state");u(this,"emitUpdate");u(this,"rootEl");u(this,"pluginState");u(this,"handleScroll",()=>{var t,e;if((t=this.state)!=null&&t.show){const o=(e=this.rootEl)==null?void 0:e.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);if(!o)return;this.state.referencePos=o.getBoundingClientRect(),this.emitUpdate(this.pluginState.triggerCharacter)}});u(this,"closeMenu",()=>{this.editor.transact(t=>t.setMeta(z,null))});u(this,"clearQuery",()=>{this.pluginState!==void 0&&this.editor._tiptapEditor.chain().focus().deleteRange({from:this.pluginState.queryStartPos()-(this.pluginState.deleteTriggerCharacter?this.pluginState.triggerCharacter.length:0),to:this.editor.transact(t=>t.selection.from)}).run()});var r;this.editor=t,this.pluginState=void 0,this.emitUpdate=s=>{var i;if(!this.state)throw new Error("Attempting to update uninitialized suggestions menu");e(s,{...this.state,ignoreQueryLength:(i=this.pluginState)==null?void 0:i.ignoreQueryLength})},this.rootEl=o.root,(r=this.rootEl)==null||r.addEventListener("scroll",this.handleScroll,!0)}update(t,e){var l;const o=z.getState(e),r=z.getState(t.state),s=o===void 0&&r!==void 0,i=o!==void 0&&r===void 0;if(!s&&!(o!==void 0&&r!==void 0)&&!i)return;if(this.pluginState=i?o:r,i||!this.editor.isEditable){this.state&&(this.state.show=!1),this.emitUpdate(this.pluginState.triggerCharacter);return}const a=(l=this.rootEl)==null?void 0:l.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);this.editor.isEditable&&a&&(this.state={show:!0,referencePos:a.getBoundingClientRect(),query:this.pluginState.query},this.emitUpdate(this.pluginState.triggerCharacter))}destroy(){var t;(t=this.rootEl)==null||t.removeEventListener("scroll",this.handleScroll,!0)}}const z=new S.PluginKey("SuggestionMenuPlugin");class St extends d.BlockNoteExtension{constructor(e){super();u(this,"view");u(this,"triggerCharacters",[]);u(this,"addTriggerCharacter",e=>{this.triggerCharacters.push(e)});u(this,"removeTriggerCharacter",e=>{this.triggerCharacters=this.triggerCharacters.filter(o=>o!==e)});u(this,"closeMenu",()=>this.view.closeMenu());u(this,"clearQuery",()=>this.view.clearQuery());const o=this.triggerCharacters;this.addProsemirrorPlugin(new S.Plugin({key:z,view:r=>(this.view=new Pn(e,(s,i)=>{this.emit(`update ${s}`,i)},r),this.view),state:{init(){},apply:(r,s,i,c)=>{if(r.selection.$from.parent.type.spec.code)return s;const a=r.getMeta(z);if(typeof a=="object"&&a!==null){s&&this.closeMenu();const h=wt(e,c.selection.from-a.triggerCharacter.length);return{triggerCharacter:a.triggerCharacter,deleteTriggerCharacter:a.deleteTriggerCharacter!==!1,queryStartPos:()=>h()+a.triggerCharacter.length,query:"",decorationId:`id_${Math.floor(Math.random()*4294967295)}`,ignoreQueryLength:a==null?void 0:a.ignoreQueryLength}}if(s===void 0)return s;if(c.selection.from!==c.selection.to||a===null||r.getMeta("focus")||r.getMeta("blur")||r.getMeta("pointer")||s.triggerCharacter!==void 0&&c.selection.from<s.queryStartPos()||!c.selection.$from.sameParent(c.doc.resolve(s.queryStartPos())))return;const l={...s};return l.query=c.doc.textBetween(s.queryStartPos(),c.selection.from),l}},props:{handleTextInput(r,s,i,c){if(s===i){const a=r.state.doc;for(const l of o){const h=l.length>1?a.textBetween(s-l.length,s)+c:c;if(l===h)return r.dispatch(r.state.tr.insertText(c)),r.dispatch(r.state.tr.setMeta(z,{triggerCharacter:h}).scrollIntoView()),!0}}return!1},decorations(r){const s=this.getState(r);if(s===void 0)return null;if(!s.deleteTriggerCharacter){const i=vn(r.selection);if(i)return M.DecorationSet.create(r.doc,[M.Decoration.node(i.pos,i.pos+i.node.nodeSize,{nodeName:"span",class:"bn-suggestion-decorator","data-decoration-id":s.decorationId})])}return M.DecorationSet.create(r.doc,[M.Decoration.inline(s.queryStartPos()-s.triggerCharacter.length,s.queryStartPos(),{nodeName:"span",class:"bn-suggestion-decorator","data-decoration-id":s.decorationId})])}}}))}static key(){return"suggestionMenu"}onUpdate(e,o){return this.triggerCharacters.includes(e)||this.addTriggerCharacter(e),this.on(`update ${e}`,o)}get shown(){var e,o;return((o=(e=this.view)==null?void 0:e.state)==null?void 0:o.show)||!1}}function Tn(n,t){n.suggestionMenus.addTriggerCharacter(t)}const En=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(t,e){return["ins",{"data-id":String(t.attrs.id),"data-inline":String(e),...!e&&{style:"display: contents"}},0]},parseDOM:[{tag:"ins",getAttrs(t){return t.dataset.id?{id:parseInt(t.dataset.id,10)}:!1}}]}}}),Mn=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(t,e){return["del",{"data-id":String(t.attrs.id),"data-inline":String(e),...!e&&{style:"display: contents"}},0]},parseDOM:[{tag:"del",getAttrs(t){return t.dataset.id?{id:parseInt(t.dataset.id,10)}:!1}}]}}}),xn=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(t,e){return[e?"span":"div",{"data-type":"modification","data-id":String(t.attrs.id),"data-mod-type":t.attrs.type,"data-mod-prev-val":JSON.stringify(t.attrs.previousValue),"data-mod-new-val":JSON.stringify(t.attrs.newValue)},0]},parseDOM:[{tag:"span[data-type='modification']",getAttrs(t){return t.dataset.id?{id:parseInt(t.dataset.id,10),type:t.dataset.modType,previousValue:t.dataset.modPrevVal,newValue:t.dataset.modNewVal}:!1}},{tag:"div[data-type='modification']",getAttrs(t){return t.dataset.id?{id:parseInt(t.dataset.id,10),type:t.dataset.modType,previousValue:t.dataset.modPrevVal}:!1}}]}}});let A;function Ue(n){A||(A=document.createElement("div"),A.innerHTML="_",A.style.opacity="0",A.style.height="1px",A.style.width="1px",n instanceof Document?n.body.appendChild(A):n.appendChild(A))}function In(n){A&&(n instanceof Document?n.body.removeChild(A):n.removeChild(A),A=void 0)}function Z(n){return Array.prototype.indexOf.call(n.parentElement.childNodes,n)}function Dn(n){let t=n;for(;t&&t.nodeName!=="TD"&&t.nodeName!=="TH"&&!t.classList.contains("tableWrapper");){if(t.classList.contains("ProseMirror"))return;const e=t.parentNode;if(!e||!(e instanceof Element))return;t=e}return t.nodeName==="TD"||t.nodeName==="TH"?{type:"cell",domNode:t,tbodyNode:t.closest("tbody")}:{type:"wrapper",domNode:t,tbodyNode:t.querySelector("tbody")}}function Ln(n,t){const e=t.querySelectorAll(n);for(let o=0;o<e.length;o++)e[o].style.visibility="hidden"}class Ct{constructor(t,e,o){u(this,"state");u(this,"emitUpdate");u(this,"tableId");u(this,"tablePos");u(this,"tableElement");u(this,"menuFrozen",!1);u(this,"mouseState","up");u(this,"prevWasEditable",null);u(this,"viewMousedownHandler",()=>{this.mouseState="down"});u(this,"mouseUpHandler",t=>{this.mouseState="up",this.mouseMoveHandler(t)});u(this,"mouseMoveHandler",t=>{var l,h,p,k,g,b,f;if(this.menuFrozen||this.mouseState==="selecting"||!(t.target instanceof Element)||!this.pmView.dom.contains(t.target))return;const e=Dn(t.target);if((e==null?void 0:e.type)==="cell"&&this.mouseState==="down"&&!((l=this.state)!=null&&l.draggingState)){this.mouseState="selecting",(h=this.state)!=null&&h.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate());return}if(!e||!this.editor.isEditable){(p=this.state)!=null&&p.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate());return}if(!e.tbodyNode)return;const o=e.tbodyNode.getBoundingClientRect(),r=ft(e.domNode,this.pmView);if(!r)return;this.tableElement=r.node;let s;const i=this.editor.transact(y=>d.getNodeById(r.id,y.doc));if(!i)throw new Error(`Block with ID ${r.id} not found`);const c=m.nodeToBlock(i.node,this.editor.pmSchema,this.editor.schema.blockSchema,this.editor.schema.inlineContentSchema,this.editor.schema.styleSchema);if(d.editorHasBlockWithType(this.editor,"table")&&(this.tablePos=i.posBeforeNode+1,s=c),!s)return;this.tableId=r.id;const a=(k=e.domNode.closest(".tableWrapper"))==null?void 0:k.querySelector(".table-widgets-container");if((e==null?void 0:e.type)==="wrapper"){const y=t.clientY>=o.bottom-1&&t.clientY<o.bottom+20,w=t.clientX>=o.right-1&&t.clientX<o.right+20,C=t.clientX>o.right||t.clientY>o.bottom;this.state={...this.state,show:!0,showAddOrRemoveRowsButton:y,showAddOrRemoveColumnsButton:w,referencePosTable:o,block:s,widgetContainer:a,colIndex:C||(g=this.state)==null?void 0:g.colIndex,rowIndex:C||(b=this.state)==null?void 0:b.rowIndex,referencePosCell:C||(f=this.state)==null?void 0:f.referencePosCell}}else{const y=Z(e.domNode),w=Z(e.domNode.parentElement),C=e.domNode.getBoundingClientRect();if(this.state!==void 0&&this.state.show&&this.tableId===r.id&&this.state.rowIndex===w&&this.state.colIndex===y)return;this.state={show:!0,showAddOrRemoveColumnsButton:y===s.content.rows[0].cells.length-1,showAddOrRemoveRowsButton:w===s.content.rows.length-1,referencePosTable:o,block:s,draggingState:void 0,referencePosCell:C,colIndex:y,rowIndex:w,widgetContainer:a}}return this.emitUpdate(),!1});u(this,"dragOverHandler",t=>{var k;if(((k=this.state)==null?void 0:k.draggingState)===void 0)return;t.preventDefault(),t.dataTransfer.dropEffect="move",Ln(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline",this.pmView.root);const e={left:Math.min(Math.max(t.clientX,this.state.referencePosTable.left+1),this.state.referencePosTable.right-1),top:Math.min(Math.max(t.clientY,this.state.referencePosTable.top+1),this.state.referencePosTable.bottom-1)},o=this.pmView.root.elementsFromPoint(e.left,e.top).filter(g=>g.tagName==="TD"||g.tagName==="TH");if(o.length===0)return;const r=o[0];let s=!1;const i=Z(r.parentElement),c=Z(r),a=this.state.draggingState.draggedCellOrientation==="row"?this.state.rowIndex:this.state.colIndex,h=(this.state.draggingState.draggedCellOrientation==="row"?i:c)!==a;(this.state.rowIndex!==i||this.state.colIndex!==c)&&(this.state.rowIndex=i,this.state.colIndex=c,this.state.referencePosCell=r.getBoundingClientRect(),s=!0);const p=this.state.draggingState.draggedCellOrientation==="row"?e.top:e.left;this.state.draggingState.mousePos!==p&&(this.state.draggingState.mousePos=p,s=!0),s&&this.emitUpdate(),h&&this.editor.transact(g=>g.setMeta(V,!0))});u(this,"dropHandler",t=>{if(this.mouseState="up",this.state===void 0||this.state.draggingState===void 0)return!1;if(this.state.rowIndex===void 0||this.state.colIndex===void 0)throw new Error("Attempted to drop table row or column, but no table block was hovered prior.");t.preventDefault();const{draggingState:e,colIndex:o,rowIndex:r}=this.state,s=this.state.block.content.columnWidths;if(e.draggedCellOrientation==="row"){if(!m.canRowBeDraggedInto(this.state.block,e.originalIndex,r))return!1;const i=m.moveRow(this.state.block,e.originalIndex,r);this.editor.updateBlock(this.state.block,{type:"table",content:{...this.state.block.content,rows:i}})}else{if(!m.canColumnBeDraggedInto(this.state.block,e.originalIndex,o))return!1;const i=m.moveColumn(this.state.block,e.originalIndex,o),[c]=s.splice(e.originalIndex,1);s.splice(o,0,c),this.editor.updateBlock(this.state.block,{type:"table",content:{...this.state.block.content,columnWidths:s,rows:i}})}return this.editor.setTextCursorPosition(this.state.block.id),!0});this.editor=t,this.pmView=e,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized image toolbar");o(this.state)},e.dom.addEventListener("mousemove",this.mouseMoveHandler),e.dom.addEventListener("mousedown",this.viewMousedownHandler),window.addEventListener("mouseup",this.mouseUpHandler),e.root.addEventListener("dragover",this.dragOverHandler),e.root.addEventListener("drop",this.dropHandler)}update(){var r;if(!this.state||!this.state.show)return;if(this.state.block=this.editor.getBlock(this.state.block.id),!this.state.block||this.state.block.type!=="table"||!((r=this.tableElement)!=null&&r.isConnected)){this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate();return}const{height:t,width:e}=m.getDimensionsOfTable(this.state.block);this.state.rowIndex!==void 0&&this.state.colIndex!==void 0&&(this.state.rowIndex>=t&&(this.state.rowIndex=t-1),this.state.colIndex>=e&&(this.state.colIndex=e-1));const o=this.tableElement.querySelector("tbody");if(!o)throw new Error("Table block does not contain a 'tbody' HTML element. This should never happen.");if(this.state.rowIndex!==void 0&&this.state.colIndex!==void 0){const i=o.children[this.state.rowIndex].children[this.state.colIndex];i?this.state.referencePosCell=i.getBoundingClientRect():(this.state.rowIndex=void 0,this.state.colIndex=void 0)}this.state.referencePosTable=o.getBoundingClientRect(),this.emitUpdate()}destroy(){this.pmView.dom.removeEventListener("mousemove",this.mouseMoveHandler),window.removeEventListener("mouseup",this.mouseUpHandler),this.pmView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.pmView.root.removeEventListener("dragover",this.dragOverHandler),this.pmView.root.removeEventListener("drop",this.dropHandler)}}const V=new S.PluginKey("TableHandlesPlugin");class Bt extends d.BlockNoteExtension{constructor(e){super();u(this,"view");u(this,"colDragStart",e=>{if(this.view.state===void 0||this.view.state.colIndex===void 0)throw new Error("Attempted to drag table column, but no table block was hovered prior.");this.view.state.draggingState={draggedCellOrientation:"col",originalIndex:this.view.state.colIndex,mousePos:e.clientX},this.view.emitUpdate(),this.editor.transact(o=>o.setMeta(V,{draggedCellOrientation:this.view.state.draggingState.draggedCellOrientation,originalIndex:this.view.state.colIndex,newIndex:this.view.state.colIndex,tablePos:this.view.tablePos})),!this.editor.headless&&(Ue(this.editor.prosemirrorView.root),e.dataTransfer.setDragImage(A,0,0),e.dataTransfer.effectAllowed="move")});u(this,"rowDragStart",e=>{if(this.view.state===void 0||this.view.state.rowIndex===void 0)throw new Error("Attempted to drag table row, but no table block was hovered prior.");this.view.state.draggingState={draggedCellOrientation:"row",originalIndex:this.view.state.rowIndex,mousePos:e.clientY},this.view.emitUpdate(),this.editor.transact(o=>o.setMeta(V,{draggedCellOrientation:this.view.state.draggingState.draggedCellOrientation,originalIndex:this.view.state.rowIndex,newIndex:this.view.state.rowIndex,tablePos:this.view.tablePos})),!this.editor.headless&&(Ue(this.editor.prosemirrorView.root),e.dataTransfer.setDragImage(A,0,0),e.dataTransfer.effectAllowed="copyMove")});u(this,"dragEnd",()=>{if(this.view.state===void 0)throw new Error("Attempted to drag table row, but no table block was hovered prior.");this.view.state.draggingState=void 0,this.view.emitUpdate(),this.editor.transact(e=>e.setMeta(V,null)),!this.editor.headless&&In(this.editor.prosemirrorView.root)});u(this,"freezeHandles",()=>{this.view.menuFrozen=!0});u(this,"unfreezeHandles",()=>{this.view.menuFrozen=!1});u(this,"getCellsAtRowHandle",(e,o)=>m.getCellsAtRowHandle(e,o));u(this,"getCellsAtColumnHandle",(e,o)=>m.getCellsAtColumnHandle(e,o));u(this,"setCellSelection",(e,o,r=o)=>{const s=this.view;if(!s)throw new Error("Table handles view not initialized");const i=e.doc.resolve(s.tablePos+1),c=e.doc.resolve(i.posAtIndex(o.row)+1),a=e.doc.resolve(c.posAtIndex(o.col)),l=e.doc.resolve(i.posAtIndex(r.row)+1),h=e.doc.resolve(l.posAtIndex(r.col)),p=e.tr;return p.setSelection(new N.CellSelection(a,h)),e.apply(p)});u(this,"addRowOrColumn",(e,o)=>{this.editor.exec((r,s)=>{const i=this.setCellSelection(r,o.orientation==="row"?{row:e,col:0}:{row:0,col:e});return o.orientation==="row"?o.side==="above"?N.addRowBefore(i,s):N.addRowAfter(i,s):o.side==="left"?N.addColumnBefore(i,s):N.addColumnAfter(i,s)})});u(this,"removeRowOrColumn",(e,o)=>o==="row"?this.editor.exec((r,s)=>{const i=this.setCellSelection(r,{row:e,col:0});return N.deleteRow(i,s)}):this.editor.exec((r,s)=>{const i=this.setCellSelection(r,{row:0,col:e});return N.deleteColumn(i,s)}));u(this,"mergeCells",e=>this.editor.exec((o,r)=>{const s=e?this.setCellSelection(o,e.relativeStartCell,e.relativeEndCell):o;return N.mergeCells(s,r)}));u(this,"splitCell",e=>this.editor.exec((o,r)=>{const s=e?this.setCellSelection(o,e):o;return N.splitCell(s,r)}));u(this,"getCellSelection",()=>this.editor.transact(e=>{const o=e.selection;let r=o.$from,s=o.$to;if(d.isTableCellSelection(o)){const{ranges:b}=o;b.forEach(f=>{r=f.$from.min(r??f.$from),s=f.$to.max(s??f.$to)})}else if(r=e.doc.resolve(o.$from.pos-o.$from.parentOffset-1),s=e.doc.resolve(o.$to.pos-o.$to.parentOffset-1),r.pos===0||s.pos===0)return;const i=e.doc.resolve(r.pos-r.parentOffset-1),c=e.doc.resolve(s.pos-s.parentOffset-1),a=e.doc.resolve(i.pos-i.parentOffset-1),l=r.index(i.depth),h=i.index(a.depth),p=s.index(c.depth),k=c.index(a.depth),g=[];for(let b=h;b<=k;b++)for(let f=l;f<=p;f++)g.push({row:b,col:f});return{from:{row:h,col:l},to:{row:k,col:p},cells:g}}));u(this,"getMergeDirection",e=>this.editor.transact(o=>{const r=d.isTableCellSelection(o.selection)?o.selection:void 0;if(!r||!e||r.ranges.length<=1)return;const s=this.getCellSelection();if(s)return m.areInSameColumn(s.from,s.to,e)?"vertical":"horizontal"}));u(this,"cropEmptyRowsOrColumns",(e,o)=>m.cropEmptyRowsOrColumns(e,o));u(this,"addRowsOrColumns",(e,o,r)=>m.addRowsOrColumns(e,o,r));this.editor=e,this.addProsemirrorPlugin(new S.Plugin({key:V,view:o=>(this.view=new Ct(e,o,r=>{this.emit("update",r)}),this.view),props:{decorations:o=>{if(this.view===void 0||this.view.state===void 0||this.view.state.draggingState===void 0||this.view.tablePos===void 0)return;const r=this.view.state.draggingState.draggedCellOrientation==="row"?this.view.state.rowIndex:this.view.state.colIndex;if(r===void 0)return;const s=[],{block:i,draggingState:c}=this.view.state,{originalIndex:a,draggedCellOrientation:l}=c;if(r===a||!i||l==="row"&&!m.canRowBeDraggedInto(i,a,r)||l==="col"&&!m.canColumnBeDraggedInto(i,a,r))return M.DecorationSet.create(o.doc,s);const h=o.doc.resolve(this.view.tablePos+1);return this.view.state.draggingState.draggedCellOrientation==="row"?m.getCellsAtRowHandle(this.view.state.block,r).forEach(({row:k,col:g})=>{const b=o.doc.resolve(h.posAtIndex(k)+1),f=o.doc.resolve(b.posAtIndex(g)+1),y=f.node(),w=f.pos+(r>a?y.nodeSize-2:0);s.push(M.Decoration.widget(w,()=>{const C=document.createElement("div");return C.className="bn-table-drop-cursor",C.style.left="0",C.style.right="0",r>a?C.style.bottom="-2px":C.style.top="-3px",C.style.height="4px",C}))}):m.getCellsAtColumnHandle(this.view.state.block,r).forEach(({row:k,col:g})=>{const b=o.doc.resolve(h.posAtIndex(k)+1),f=o.doc.resolve(b.posAtIndex(g)+1),y=f.node(),w=f.pos+(r>a?y.nodeSize-2:0);s.push(M.Decoration.widget(w,()=>{const C=document.createElement("div");return C.className="bn-table-drop-cursor",C.style.top="0",C.style.bottom="0",r>a?C.style.right="-2px":C.style.left="-3px",C.style.width="4px",C}))}),M.DecorationSet.create(o.doc,s)}}}))}static key(){return"tableHandles"}onUpdate(e){return this.on("update",e)}}const Nn=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}}}}]}}),An=B.Extension.create({name:"blockTextColor",addGlobalAttributes(){return[{types:["table","tableCell","tableHeader"],attributes:{textColor:d.getTextColorAttribute()}}]}}),_n=B.Extension.create({name:"trailingNode",addProseMirrorPlugins(){const n=new S.PluginKey(this.name);return[new S.Plugin({key:n,appendTransaction:(t,e,o)=>{const{doc:r,tr:s,schema:i}=o,c=n.getState(o),a=r.content.size-2,l=i.nodes.blockContainer,h=i.nodes.paragraph;if(c)return s.insert(a,l.create(void 0,h.create()))},state:{init:(t,e)=>{},apply:(t,e)=>{if(!t.docChanged)return e;let o=t.doc.lastChild;if(!o||o.type.name!=="blockGroup")throw new Error("Expected blockGroup");if(o=o.lastChild,!o||o.type.name!=="blockContainer")return!0;const r=o.firstChild;if(!r)throw new Error("Expected blockContent");return o.nodeSize>4||r.type.spec.content!=="inline*"}}})]}}),On={blockColor:"data-block-color",blockStyle:"data-block-style",id:"data-id",depth:"data-depth",depthChange:"data-depth-change"},Hn=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 t={};for(const[e,o]of Object.entries(On))n.getAttribute(o)&&(t[e]=n.getAttribute(o));return t}},{tag:'div[data-node-type="blockOuter"]',skip:!0}]},renderHTML({HTMLAttributes:n}){var r;const t=document.createElement("div");t.className="bn-block-outer",t.setAttribute("data-node-type","blockOuter");for(const[s,i]of Object.entries(n))s!=="class"&&t.setAttribute(s,i);const e={...((r=this.options.domAttributes)==null?void 0:r.block)||{},...n},o=document.createElement("div");o.className=d.mergeCSSClasses("bn-block",e.class),o.setAttribute("data-node-type",this.name);for(const[s,i]of Object.entries(e))s!=="class"&&o.setAttribute(s,i);return t.appendChild(o),{dom:t,contentDOM:o}}}),Un=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 t={...((o=this.options.domAttributes)==null?void 0:o.blockGroup)||{},...n},e=document.createElement("div");e.className=d.mergeCSSClasses("bn-block-group",t.class),e.setAttribute("data-node-type","blockGroup");for(const[r,s]of Object.entries(t))r!=="class"&&e.setAttribute(r,s);return{dom:e,contentDOM:e}}}),Rn=B.Node.create({name:"doc",topNode:!0,content:"blockGroup",marks:"insertion modification deletion"}),vt=n=>{var r;const t={},e=Fn(n);for(const s of e)t[s.name]=s;n.collaboration&&(t.ySyncPlugin=new ne(n.collaboration.fragment),t.yUndoPlugin=new re({editor:n.editor}),(r=n.collaboration.provider)!=null&&r.awareness&&(t.yCursorPlugin=new Y(n.collaboration)),t.forkYDocPlugin=new tt({editor:n.editor,collaboration:n.collaboration}),t.schemaMigrationPlugin=new be(n.collaboration.fragment)),t.formattingToolbar=new ct(n.editor),t.linkToolbar=new ht(n.editor),t.sideMenu=new yt(n.editor),t.suggestionMenus=new St(n.editor),t.filePanel=new st(n.editor),t.placeholder=new gn(n.editor,n.placeholders),(n.animations??!0)&&(t.animations=new bn),n.tableHandles&&(t.tableHandles=new Bt(n.editor)),t.nodeSelectionKeyboard=new mn,t.blockChange=new Jo,t.showSelection=new yn(n.editor),n.comments&&(t.comments=new nt(n.editor,n.comments.threadStore,se.name,n.comments.resolveUsers,n.comments.schema));const o=n.disableExtensions||[];for(const s of o)delete t[s];return t};let Re=!1;const Fn=n=>{const t=[B.extensions.ClipboardTextSerializer,B.extensions.Commands,B.extensions.Editable,B.extensions.FocusEvents,B.extensions.Tabindex,Wt.Gapcursor,B.Extension.create({name:"dropCursor",addProseMirrorPlugins:()=>[n.dropCursor({width:5,color:"#ddeeff",editor:n.editor})]}),m.UniqueID.configure({types:["blockContainer","columnList","column"],setIdAttribute:n.setIdAttribute}),nn,Jt.Text,En,Mn,xn,Xt.Link.extend({inclusive:!1}).configure({defaultProtocol:mt,protocols:Re?[]:pt}),...Object.values(n.styleSpecs).map(e=>e.implementation.mark.configure({editor:n.editor})),An,Xo,Nn,B.Extension.create({name:"OverrideEscape",addKeyboardShortcuts(){return{Escape:()=>n.editor.suggestionMenus.shown?!1:this.editor.commands.blur()}}}),Rn,Hn.configure({editor:n.editor,domAttributes:n.domAttributes}),un.configure({editor:n.editor,tabBehavior:n.tabBehavior}),Un.configure({domAttributes:n.domAttributes}),...Object.values(n.inlineContentSpecs).filter(e=>e.config!=="link"&&e.config!=="text").map(e=>e.implementation.node.configure({editor:n.editor})),...Object.values(n.blockSpecs).flatMap(e=>[..."node"in e.implementation?[e.implementation.node.configure({editor:n.editor,domAttributes:n.domAttributes})]:[]]),Yo(n.editor),Ko(n.editor,n.pasteHandler||(e=>e.defaultPasteHandler())),Eo(n.editor),...n.trailingBlock===void 0||n.trailingBlock?[_n]:[],...n.comments?[se]:[]];return Re=!0,n.collaboration||t.push(Yt.History),t};function Vn(n){return n.transact(t=>{const e=m.getNearestBlockPos(t.doc,t.selection.anchor);if(t.selection instanceof N.CellSelection)return{type:"cell",anchorBlockId:e.node.attrs.id,anchorCellOffset:t.selection.$anchorCell.pos-e.posBeforeNode,headCellOffset:t.selection.$headCell.pos-e.posBeforeNode};if(t.selection instanceof S.NodeSelection)return{type:"node",anchorBlockId:e.node.attrs.id};{const o=m.getNearestBlockPos(t.doc,t.selection.head);return{type:"text",anchorBlockId:e.node.attrs.id,headBlockId:o.node.attrs.id,anchorOffset:t.selection.anchor-e.posBeforeNode,headOffset:t.selection.head-o.posBeforeNode}}})}function $n(n,t){var r,s;const e=(r=d.getNodeById(t.anchorBlockId,n.doc))==null?void 0:r.posBeforeNode;if(e===void 0)throw new Error(`Could not find block with ID ${t.anchorBlockId} to update selection`);let o;if(t.type==="cell")o=N.CellSelection.create(n.doc,e+t.anchorCellOffset,e+t.headCellOffset);else if(t.type==="node")o=S.NodeSelection.create(n.doc,e+1);else{const i=(s=d.getNodeById(t.headBlockId,n.doc))==null?void 0:s.posBeforeNode;if(i===void 0)throw new Error(`Could not find block with ID ${t.headBlockId} to update selection`);o=S.TextSelection.create(n.doc,e+t.anchorOffset,i+t.headOffset)}n.setSelection(o)}function me(n){return n.map(t=>t.type==="columnList"?t.children.map(e=>me(e.children)).flat():{...t,children:me(t.children)}).flat()}function Pt(n,t,e){n.transact(o=>{var i;const r=((i=n.getSelection())==null?void 0:i.blocks)||[n.getTextCursorPosition().block],s=Vn(n);n.removeBlocks(r),n.insertBlocks(me(r),t,e),$n(o,s)})}function Tt(n){return!n||n.type!=="columnList"}function Et(n,t,e){let o,r;if(t?t.children.length>0?(o=t.children[t.children.length-1],r="after"):(o=t,r="before"):e&&(o=e,r="before"),!o||!r)return;const s=n.getParentBlock(o);return Tt(s)?{referenceBlock:o,placement:r}:Et(n,r==="after"?o:n.getPrevBlock(o),s)}function Mt(n,t,e){let o,r;if(t?t.children.length>0?(o=t.children[0],r="before"):(o=t,r="after"):e&&(o=e,r="after"),!o||!r)return;const s=n.getParentBlock(o);return Tt(s)?{referenceBlock:o,placement:r}:Mt(n,r==="before"?o:n.getNextBlock(o),s)}function zn(n){n.transact(()=>{const t=n.getSelection(),e=(t==null?void 0:t.blocks[0])||n.getTextCursorPosition().block,o=Et(n,n.getPrevBlock(e),n.getParentBlock(e));o&&Pt(n,o.referenceBlock,o.placement)})}function Kn(n){n.transact(()=>{const t=n.getSelection(),e=(t==null?void 0:t.blocks[(t==null?void 0:t.blocks.length)-1])||n.getTextCursorPosition().block,o=Mt(n,n.getNextBlock(e),n.getParentBlock(e));o&&Pt(n,o.referenceBlock,o.placement)})}function xt(n,t){const e=typeof t=="string"?t:t.id,o=m.getPmSchema(n),r=d.getNodeById(e,n);if(r)return m.nodeToBlock(r.node,o)}function It(n,t){const e=typeof t=="string"?t:t.id,o=d.getNodeById(e,n),r=m.getPmSchema(n);if(!o)return;const i=n.resolve(o.posBeforeNode).nodeBefore;if(i)return m.nodeToBlock(i,r)}function Dt(n,t){const e=typeof t=="string"?t:t.id,o=d.getNodeById(e,n),r=m.getPmSchema(n);if(!o)return;const i=n.resolve(o.posBeforeNode+o.node.nodeSize).nodeAfter;if(i)return m.nodeToBlock(i,r)}function Lt(n,t){const e=typeof t=="string"?t:t.id,o=m.getPmSchema(n),r=d.getNodeById(e,n);if(!r)return;const s=n.resolve(r.posBeforeNode),i=s.node(),c=s.node(-1),a=c.type.name!=="doc"?i.type.name==="blockGroup"?c:i:void 0;if(a)return m.nodeToBlock(a,o)}class qn{constructor(t){this.editor=t}get document(){return this.editor.transact(t=>m.docToBlocks(t.doc,this.editor.pmSchema))}getBlock(t){return this.editor.transact(e=>xt(e.doc,t))}getPrevBlock(t){return this.editor.transact(e=>It(e.doc,t))}getNextBlock(t){return this.editor.transact(e=>Dt(e.doc,t))}getParentBlock(t){return this.editor.transact(e=>Lt(e.doc,t))}forEachBlock(t,e=!1){const o=this.document.slice();e&&o.reverse();function r(s){for(const i of s){if(t(i)===!1)return!1;const c=e?i.children.slice().reverse():i.children;if(!r(c))return!1}return!0}r(o)}insertBlocks(t,e,o="before"){return this.editor.transact(r=>Ke(r,t,e,o))}updateBlock(t,e){return this.editor.transact(o=>d.updateBlock(o,t,e))}removeBlocks(t){return this.editor.transact(e=>ue(e,t,[]).removedBlocks)}replaceBlocks(t,e){return this.editor.transact(o=>ue(o,t,e))}canNestBlock(){return ln(this.editor)}nestBlock(){dt(this.editor)}canUnnestBlock(){return dn(this.editor)}unnestBlock(){cn(this.editor)}moveBlocksUp(){return zn(this.editor)}moveBlocksDown(){return Kn(this.editor)}}class Gn{constructor(t,e){u(this,"editor");u(this,"options");u(this,"_commentsPlugin");u(this,"_forkYDocPlugin");u(this,"_syncPlugin");u(this,"_undoPlugin");u(this,"_cursorPlugin");this.editor=t,this.options=e}get syncPlugin(){return this._syncPlugin}get undoPlugin(){return this._undoPlugin}get cursorPlugin(){return this._cursorPlugin}get forkYDocPlugin(){return this._forkYDocPlugin}initExtensions(){var e;const t={};if(this._syncPlugin=new ne(this.options.fragment),t.ySyncPlugin=this._syncPlugin,this._undoPlugin=new re({editor:this.editor}),t.yUndoPlugin=this._undoPlugin,(e=this.options.provider)!=null&&e.awareness&&(this._cursorPlugin=new Y(this.options),t.yCursorPlugin=this._cursorPlugin),this._forkYDocPlugin=new tt({editor:this.editor,collaboration:this.options}),t.forkYDocPlugin=this._forkYDocPlugin,this.options.comments){if(!this.options.resolveUsers)throw new Error("resolveUsers is required when using comments");this._commentsPlugin=new nt(this.editor,this.options.comments.threadStore,se.name,this.options.resolveUsers,this.options.comments.schema),t.comments=this._commentsPlugin,t.commentMark=se}return t}updateUserInfo(t){const e=this.cursorPlugin;if(!e)throw new Error("Cannot update collaboration user info when collaboration is disabled.");e.updateUser(t)}getUndoCommand(){return E.undoCommand}getRedoCommand(){return E.redoCommand}shouldAvoidInitialContent(){return!!this.options.provider}getOptions(){return this.options}get comments(){return this._commentsPlugin}get hasComments(){return!!this.options.comments}get resolveUsers(){return this.options.resolveUsers}}class jn extends d.EventEmitter{constructor(t){super(),this.editor=t,t.onCreate(()=>{t._tiptapEditor.on("update",({transaction:e,appendedTransactions:o})=>{this.emit("onChange",t,{getChanges(){return fe(e,o)}})}),t._tiptapEditor.on("selectionUpdate",({transaction:e})=>{this.emit("onSelectionChange",{editor:t,transaction:e})}),t._tiptapEditor.on("mount",()=>{this.emit("onMount",{editor:t})}),t._tiptapEditor.on("unmount",()=>{this.emit("onUnmount",{editor:t})})})}onChange(t){return this.on("onChange",t),()=>{this.off("onChange",t)}}onSelectionChange(t,e=!1){const o=r=>{r.transaction.getMeta("$y-sync")&&!e||t(this.editor)};return this.on("onSelectionChange",o),()=>{this.off("onSelectionChange",o)}}onMount(t){return this.on("onMount",t),()=>{this.off("onMount",t)}}onUnmount(t){return this.on("onUnmount",t),()=>{this.off("onUnmount",t)}}}function Wn(n){return Array.prototype.indexOf.call(n.parentElement.childNodes,n)}function Yn(n){return n.nodeType===3&&!/\S/.test(n.nodeValue||"")}function Xn(n){n.querySelectorAll("li > ul, li > ol").forEach(t=>{const e=Wn(t),o=t.parentElement,r=Array.from(o.childNodes).slice(e+1);t.remove(),r.forEach(s=>{s.remove()}),o.insertAdjacentElement("afterend",t),r.reverse().forEach(s=>{if(Yn(s))return;const i=document.createElement("li");i.append(s),t.insertAdjacentElement("afterend",i)}),o.childNodes.length===0&&o.remove()})}function Jn(n){n.querySelectorAll("li + ul, li + ol").forEach(t=>{var s,i;const e=t.previousElementSibling,o=document.createElement("div");e.insertAdjacentElement("afterend",o),o.append(e);const r=document.createElement("div");for(r.setAttribute("data-node-type","blockGroup"),o.append(r);((s=o.nextElementSibling)==null?void 0:s.nodeName)==="UL"||((i=o.nextElementSibling)==null?void 0:i.nodeName)==="OL";)r.append(o.nextElementSibling)})}let Fe=null;function Qn(){return Fe||(Fe=document.implementation.createHTMLDocument("title"))}function Zn(n){if(typeof n=="string"){const t=Qn().createElement("div");t.innerHTML=n,n=t}return Xn(n),Jn(n),n}function ye(n,t){const e=Zn(n),r=T.DOMParser.fromSchema(t).parse(e,{topNode:t.nodes.blockGroup.create()}),s=[];for(let i=0;i<r.childCount;i++)s.push(m.nodeToBlock(r.child(i),t));return s}function er(n,t){const e=t.value?t.value:"",o={};t.lang&&(o["data-language"]=t.lang);let r={type:"element",tagName:"code",properties:o,children:[{type:"text",value:e}]};return t.meta&&(r.data={meta:t.meta}),n.patch(t,r),r=n.applyData(t,r),r={type:"element",tagName:"pre",properties:{},children:[r]},n.patch(t,r),r}function tr(n,t){var s;const e=String((t==null?void 0:t.url)||""),o=t!=null&&t.title?String(t.title):void 0;let r={type:"element",tagName:"video",properties:{src:e,"data-name":o,"data-url":e,controls:!0},children:[]};return(s=n.patch)==null||s.call(n,t,r),r=n.applyData?n.applyData(t,r):r,r}function we(n){return Ve.unified().use(mo.default).use($e.default).use(fo.default,{handlers:{...de.defaultHandlers,image:(e,o)=>{const r=String((o==null?void 0:o.url)||"");return d.isVideoUrl(r)?tr(e,o):de.defaultHandlers.image(e,o)},code:er}}).use(go.default).processSync(n).value}function Nt(n,t){const e=we(n);return ye(e,t)}class or{constructor(t){this.editor=t}blocksToHTMLLossy(t=this.editor.document){return X(this.editor.pmSchema,this.editor).exportBlocks(t,{})}blocksToFullHTML(t=this.editor.document){return Je(this.editor.pmSchema,this.editor).serializeBlocks(t,{})}tryParseHTMLToBlocks(t){return ye(t,this.editor.pmSchema)}blocksToMarkdownLossy(t=this.editor.document){return Ze(t,this.editor.pmSchema,this.editor,{})}tryParseMarkdownToBlocks(t){return Nt(t,this.editor.pmSchema)}pasteHTML(t,e=!1){var r;let o=t;if(!e){const s=this.tryParseHTMLToBlocks(t);o=this.blocksToFullHTML(s)}o&&((r=this.editor.prosemirrorView)==null||r.pasteHTML(o))}pasteText(t){var e;return(e=this.editor.prosemirrorView)==null?void 0:e.pasteText(t)}pasteMarkdown(t){const e=we(t);return this.pasteHTML(e)}}class nr{constructor(t){this.editor=t}extension(t,e=t.key()){const o=this.editor.extensions[e];if(!o)throw new Error(`Extension ${e} not found`);return o}getExtensions(){return this.editor.extensions}getExtension(t){return this.editor.extensions[t]}hasExtension(t){return t in this.editor.extensions}get formattingToolbar(){return this.editor.extensions.formattingToolbar}get linkToolbar(){return this.editor.extensions.linkToolbar}get sideMenu(){return this.editor.extensions.sideMenu}get suggestionMenus(){return this.editor.extensions.suggestionMenus}get filePanel(){return this.editor.extensions.filePanel}get tableHandles(){return this.editor.extensions.tableHandles}get showSelectionPlugin(){return this.editor.extensions.showSelection}get isCollaborationEnabled(){return this.hasExtension("ySyncPlugin")||this.hasExtension("liveblocksExtension")}}function rr(n){const t=m.getPmSchema(n);if(n.selection.empty||"node"in n.selection)return;const e=n.doc.resolve(m.getNearestBlockPos(n.doc,n.selection.from).posBeforeNode),o=n.doc.resolve(m.getNearestBlockPos(n.doc,n.selection.to).posBeforeNode),r=(l,h)=>{const p=e.posAtIndex(l,h),k=n.doc.resolve(p).nodeAfter;if(!k)throw new Error(`Error getting selection - node not found at position ${p}`);return m.nodeToBlock(k,t)},s=[],i=e.sharedDepth(o.pos),c=e.index(i),a=o.index(i);if(e.depth>i){s.push(m.nodeToBlock(e.nodeAfter,t));for(let l=e.depth;l>i;l--)if(e.node(l).type.isInGroup("childContainer")){const p=e.index(l)+1,k=e.node(l).childCount;for(let g=p;g<k;g++)s.push(r(g,l))}}else s.push(r(c,i));for(let l=c+1;l<=a;l++)s.push(r(l,i));if(s.length===0)throw new Error(`Error getting selection - selection doesn't span any blocks (${n.selection})`);return{blocks:s}}function sr(n,t,e){const o=typeof t=="string"?t:t.id,r=typeof e=="string"?e:e.id,s=m.getPmSchema(n),i=m.getBlockNoteSchema(s);if(o===r)throw new Error(`Attempting to set selection with the same anchor and head blocks (id ${o})`);const c=d.getNodeById(o,n.doc);if(!c)throw new Error(`Block with ID ${o} not found`);const a=d.getNodeById(r,n.doc);if(!a)throw new Error(`Block with ID ${r} not found`);const l=m.getBlockInfo(c),h=m.getBlockInfo(a),p=i.blockSchema[l.blockNoteType],k=i.blockSchema[h.blockNoteType];if(!l.isBlockContainer||p.content==="none")throw new Error(`Attempting to set selection anchor in block without content (id ${o})`);if(!h.isBlockContainer||k.content==="none")throw new Error(`Attempting to set selection anchor in block without content (id ${r})`);let g,b;if(p.content==="table"){const f=N.TableMap.get(l.blockContent.node);g=l.blockContent.beforePos+f.positionAt(0,0,l.blockContent.node)+1+2}else g=l.blockContent.beforePos+1;if(k.content==="table"){const f=N.TableMap.get(h.blockContent.node),y=h.blockContent.beforePos+f.positionAt(f.height-1,f.width-1,h.blockContent.node)+1,w=n.doc.resolve(y).nodeAfter.nodeSize;b=y+w-2}else b=h.blockContent.afterPos-1;n.setSelection(S.TextSelection.create(n.doc,g,b))}function ir(n){const t=m.getPmSchema(n);let e=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(;e.parentOffset===0&&e.depth>0;)e=n.doc.resolve(e.pos-1);for(;e.parentOffset>=e.parent.nodeSize-2&&e.depth>0;)e=n.doc.resolve(e.pos+1);const r=m.prosemirrorSliceToSlicedBlocks(n.doc.slice(e.pos,o.pos,!0),t);return{_meta:{startPos:e.pos,endPos:o.pos},...r}}function ar(n){const{bnBlock:t}=m.getBlockInfoFromTransaction(n),e=m.getPmSchema(n.doc),o=n.doc.resolve(t.beforePos),r=o.nodeBefore,s=n.doc.resolve(t.afterPos).nodeAfter;let i;return o.depth>1&&(i=o.node(),i.type.isInGroup("bnBlock")||(i=o.node(o.depth-1))),{block:m.nodeToBlock(t.node,e),prevBlock:r===null?void 0:m.nodeToBlock(r,e),nextBlock:s===null?void 0:m.nodeToBlock(s,e),parentBlock:i===void 0?void 0:m.nodeToBlock(i,e)}}function At(n,t,e="start"){const o=typeof t=="string"?t:t.id,r=m.getPmSchema(n.doc),s=m.getBlockNoteSchema(r),i=d.getNodeById(o,n.doc);if(!i)throw new Error(`Block with ID ${o} not found`);const c=m.getBlockInfo(i),a=s.blockSchema[c.blockNoteType].content;if(c.isBlockContainer){const l=c.blockContent;if(a==="none"){n.setSelection(S.NodeSelection.create(n.doc,l.beforePos));return}if(a==="inline")e==="start"?n.setSelection(S.TextSelection.create(n.doc,l.beforePos+1)):n.setSelection(S.TextSelection.create(n.doc,l.afterPos-1));else if(a==="table")e==="start"?n.setSelection(S.TextSelection.create(n.doc,l.beforePos+4)):n.setSelection(S.TextSelection.create(n.doc,l.afterPos-4));else throw new m.UnreachableCaseError(a)}else{const l=e==="start"?c.childContainer.node.firstChild:c.childContainer.node.lastChild;At(n,l.attrs.id,e)}}class cr{constructor(t){this.editor=t}getSelection(){return this.editor.transact(t=>rr(t))}getSelectionCutBlocks(){return this.editor.transact(t=>ir(t))}setSelection(t,e){return this.editor.transact(o=>sr(o,t,e))}getTextCursorPosition(){return this.editor.transact(t=>ar(t))}setTextCursorPosition(t,e="start"){return this.editor.transact(o=>At(o,t,e))}getSelectionBoundingBox(){if(!this.editor.prosemirrorView)return;const{selection:t}=this.editor.prosemirrorState,{ranges:e}=t,o=Math.min(...e.map(s=>s.$from.pos)),r=Math.max(...e.map(s=>s.$to.pos));if(B.isNodeSelection(t)){const s=this.editor.prosemirrorView.nodeDOM(o);if(s)return s.getBoundingClientRect()}return B.posToDOMRect(this.editor.prosemirrorView,o,r)}}class lr{constructor(t,e){u(this,"activeTransaction",null);u(this,"isInCan",!1);this.editor=t,this.options=e}can(t){try{return this.isInCan=!0,t()}finally{this.isInCan=!1}}exec(t){if(this.activeTransaction)throw new Error("`exec` should not be called within a `transact` call, move the `exec` call outside of the `transact` call");if(this.isInCan)return this.canExec(t);const e=this.prosemirrorState,o=this.prosemirrorView;return t(e,s=>this.prosemirrorView.dispatch(s),o)}canExec(t){if(this.activeTransaction)throw new Error("`canExec` should not be called within a `transact` call, move the `canExec` call outside of the `transact` call");const e=this.prosemirrorState,o=this.prosemirrorView;return t(e,void 0,o)}transact(t){if(this.activeTransaction)return t(this.activeTransaction);try{this.activeTransaction=this.editor._tiptapEditor.state.tr;const e=t(this.activeTransaction),o=this.activeTransaction;return this.activeTransaction=null,o&&(o.docChanged||o.selectionSet||o.scrolledIntoView||o.storedMarksSet||!o.isGeneric)&&this.prosemirrorView.dispatch(o),e}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 t;return((t=this.prosemirrorView)==null?void 0:t.hasFocus())||!1}focus(){var t;(t=this.prosemirrorView)==null||t.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(t){if(!this.editor._tiptapEditor){if(!this.editor.headless)throw new Error("no editor, but also not headless?");return}this.editor._tiptapEditor.options.editable!==t&&this.editor._tiptapEditor.setEditable(t)}undo(){var t;return this.exec(((t=this.options)==null?void 0:t.undo)??Me.undo)}redo(){var t;return this.exec(((t=this.options)==null?void 0:t.redo)??Me.redo)}}function dr(n,t,e,o={updateSelection:!0}){let{from:r,to:s}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},i=!0,c=!0,a="";if(e.forEach(l=>{l.check(),i&&l.isText&&l.marks.length===0?a+=l.text:i=!1,c=c?l.isBlock:!1}),r===s&&c){const{parent:l}=n.doc.resolve(r);l.isTextblock&&!l.type.spec.code&&!l.childCount&&(r-=1,s+=1)}return i?n.insertText(a,r,s):n.replaceWith(r,s,e),o.updateSelection&&B.selectionToInsertionEnd(n,n.steps.length-1,-1),!0}class ur{constructor(t){this.editor=t}insertInlineContent(t,{updateSelection:e=!1}={}){const o=m.inlineContentToNodes(t,this.editor.pmSchema);this.editor.transact(r=>{dr(r,{from:r.selection.from,to:r.selection.to},o,{updateSelection:e})})}getActiveStyles(){return this.editor.transact(t=>{const e={},o=t.selection.$to.marks();for(const r of o){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"?e[s.type]=!0:e[s.type]=r.attrs.stringValue}return e})}addStyles(t){for(const[e,o]of Object.entries(t)){const r=this.editor.schema.styleSchema[e];if(!r)throw new Error(`style ${e} not found in styleSchema`);if(r.propSchema==="boolean")this.editor._tiptapEditor.commands.setMark(e);else if(r.propSchema==="string")this.editor._tiptapEditor.commands.setMark(e,{stringValue:o});else throw new m.UnreachableCaseError(r.propSchema)}}removeStyles(t){for(const e of Object.keys(t))this.editor._tiptapEditor.commands.unsetMark(e)}toggleStyles(t){for(const[e,o]of Object.entries(t)){const r=this.editor.schema.styleSchema[e];if(!r)throw new Error(`style ${e} not found in styleSchema`);if(r.propSchema==="boolean")this.editor._tiptapEditor.commands.toggleMark(e);else if(r.propSchema==="string")this.editor._tiptapEditor.commands.toggleMark(e,{stringValue:o});else throw new m.UnreachableCaseError(r.propSchema)}}getSelectedText(){return this.editor.transact(t=>t.doc.textBetween(t.selection.from,t.selection.to))}getSelectedLinkUrl(){return this.editor._tiptapEditor.getAttributes("link").href}createLink(t,e){if(t==="")return;const o=this.editor.pmSchema.mark("link",{href:t});this.editor.transact(r=>{const{from:s,to:i}=r.selection;e?r.insertText(e,s,i).addMark(s,s+e.length,o):r.setSelection(S.TextSelection.create(r.doc,i)).addMark(s,i,o)})}}function hr(n,t){const e=[];return n.forEach((o,r,s)=>{s!==t&&e.push(o)}),T.Fragment.from(e)}function pr(n,t){const e=[];for(let o=0;o<n.childCount;o++)if(n.child(o).type.name==="tableRow")if(e.length>0&&e[e.length-1].type.name==="table"){const r=e[e.length-1],s=r.copy(r.content.addToEnd(n.child(o)));e[e.length-1]=s}else{const r=t.nodes.table.createChecked(void 0,n.child(o));e.push(r)}else e.push(n.child(o));return n=T.Fragment.from(e),n}function mr(n,t){let e=T.Fragment.from(n.content);if(e=pr(e,t.state.schema),!fr(e,t))return new T.Slice(e,n.openStart,n.openEnd);for(let o=0;o<e.childCount;o++)if(e.child(o).type.spec.group==="blockContent"){const r=[e.child(o)];if(o+1<e.childCount&&e.child(o+1).type.name==="blockGroup"){const i=e.child(o+1).child(0).child(0);(i.type.name==="bulletListItem"||i.type.name==="numberedListItem"||i.type.name==="checkListItem")&&(r.push(e.child(o+1)),e=hr(e,o+1))}const s=t.state.schema.nodes.blockContainer.createChecked(void 0,r);e=e.replaceChild(o,s)}return new T.Slice(e,n.openStart,n.openEnd)}function fr(n,t){var s,i;const e=n.childCount===1,o=((s=n.firstChild)==null?void 0:s.type.spec.content)==="inline*",r=((i=n.firstChild)==null?void 0:i.type.spec.content)==="tableRow+";if(e){if(o)return!1;if(r){const c=m.getBlockInfoFromSelection(t.state);if(c.isBlockContainer)return!(c.blockContent.node.type.spec.content==="tableRow+")}}return!0}const gr={enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!1};class Se extends d.EventEmitter{constructor(e){var p,k,g,b,f,y,w,C,_,U,K,q,G,j,x,I,Ce,Be,ve;super();u(this,"pmSchema");u(this,"extensions",{});u(this,"_tiptapEditor");u(this,"elementRenderer",null);u(this,"blockCache",new WeakMap);u(this,"dictionary");u(this,"schema");u(this,"blockImplementations");u(this,"inlineContentImplementations");u(this,"styleImplementations");u(this,"uploadFile");u(this,"onUploadStartCallbacks",[]);u(this,"onUploadEndCallbacks",[]);u(this,"resolveFileUrl");u(this,"resolveUsers");u(this,"settings");u(this,"_blockManager");u(this,"_collaborationManager");u(this,"_eventManager");u(this,"_exportManager");u(this,"_extensionManager");u(this,"_selectionManager");u(this,"_stateManager");u(this,"_styleManager");u(this,"mount",e=>{this._tiptapEditor.mount({mount:e})});u(this,"unmount",()=>{this._tiptapEditor.unmount()});this.options=e;const o=e;if(o.onEditorContentChange)throw new Error("onEditorContentChange initialization option is deprecated, use <BlockNoteView onChange={...} />, the useEditorChange(...) hook, or editor.onChange(...)");if(o.onTextCursorPositionChange)throw new Error("onTextCursorPositionChange initialization option is deprecated, use <BlockNoteView onSelectionChange={...} />, the useEditorSelectionChange(...) hook, or editor.onSelectionChange(...)");if(o.onEditorReady)throw new Error("onEditorReady is deprecated. Editor is immediately ready for use after creation.");if(o.editable)throw new Error("editable initialization option is deprecated, use <BlockNoteView editable={true/false} />, or alternatively editor.isEditable = true/false");this.dictionary=e.dictionary||so.en,this.settings={tables:{splitCells:((p=e==null?void 0:e.tables)==null?void 0:p.splitCells)??!1,cellBackgroundColor:((k=e==null?void 0:e.tables)==null?void 0:k.cellBackgroundColor)??!1,cellTextColor:((g=e==null?void 0:e.tables)==null?void 0:g.cellTextColor)??!1,headers:((b=e==null?void 0:e.tables)==null?void 0:b.headers)??!1}};const r={defaultStyles:!0,schema:e.schema||d.BlockNoteSchema.create(),...e,placeholders:{...this.dictionary.placeholders,...e.placeholders}};if(r.collaboration||r.comments){const v={fragment:((f=r.collaboration)==null?void 0:f.fragment)||new H.XmlFragment,user:((y=r.collaboration)==null?void 0:y.user)||{name:"User",color:"#FF0000"},provider:((w=r.collaboration)==null?void 0:w.provider)||null,renderCursor:(C=r.collaboration)==null?void 0:C.renderCursor,showCursorLabels:(_=r.collaboration)==null?void 0:_.showCursorLabels,comments:r.comments,resolveUsers:r.resolveUsers};this._collaborationManager=new Gn(this,v)}else this._collaborationManager=void 0;if(r.comments&&!r.resolveUsers)throw new Error("resolveUsers is required when using comments");this.schema=r.schema,this.blockImplementations=r.schema.blockSpecs,this.inlineContentImplementations=r.schema.inlineContentSpecs,this.styleImplementations=r.schema.styleSpecs,this.extensions={...vt({editor:this,domAttributes:r.domAttributes||{},blockSpecs:this.schema.blockSpecs,styleSpecs:this.schema.styleSpecs,inlineContentSpecs:this.schema.inlineContentSpecs,collaboration:r.collaboration,trailingBlock:r.trailingBlock,disableExtensions:r.disableExtensions,setIdAttribute:r.setIdAttribute,animations:r.animations??!0,tableHandles:d.editorHasBlockWithType(this,"table"),dropCursor:this.options.dropCursor??Gt.dropCursor,placeholders:r.placeholders,tabBehavior:r.tabBehavior,pasteHandler:r.pasteHandler}),...(U=this._collaborationManager)==null?void 0:U.initExtensions()},(((K=r._tiptapOptions)==null?void 0:K.extensions)||[]).forEach(v=>{this.extensions[v.name]=v});for(let v of r.extensions||[]){typeof v=="function"&&(v=v(this));const P=v.key??v.constructor.key();if(!P)throw new Error(`Extension ${v.constructor.name} does not have a key method`);if(this.extensions[P])throw new Error(`Extension ${v.constructor.name} already exists with key ${P}`);this.extensions[P]=v}if(Object.entries(r._extensions||{}).forEach(([v,P])=>{const D=typeof P=="function"?P(this):P;if(!("plugin"in D)){this.extensions[v]=D;return}this.extensions[v]=new class extends d.BlockNoteExtension{static key(){return v}constructor(){super(),this.addProsemirrorPlugin(D.plugin)}get priority(){return D.priority}}}),r.uploadFile){const v=r.uploadFile;this.uploadFile=async(P,L)=>{this.onUploadStartCallbacks.forEach(D=>D.apply(this,[L]));try{return await v(P,L)}finally{this.onUploadEndCallbacks.forEach(D=>D.apply(this,[L]))}}}this.resolveFileUrl=r.resolveFileUrl;const s="ySyncPlugin"in this.extensions||"liveblocksExtension"in this.extensions;s&&r.initialContent&&console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider");const i=Object.fromEntries(Object.values(this.schema.blockSpecs).map(v=>v.extensions).filter(v=>v!==void 0).flat().map(v=>[v.key??v.constructor.key(),v])),c=[...Object.entries({...this.extensions,...i}).map(([v,P])=>{if(P instanceof B.Extension||P instanceof B.Node||P instanceof B.Mark)return P;if(P instanceof d.BlockNoteExtension)return!P.plugins.length&&!P.keyboardShortcuts&&!P.inputRules&&!P.tiptapExtensions?void 0:B.Extension.create({name:v,priority:P.priority,addProseMirrorPlugins:()=>P.plugins,addExtensions:()=>P.tiptapExtensions||[],addInputRules:P.inputRules?()=>P.inputRules.map(L=>new B.InputRule({find:L.find,handler:({range:D,match:ae,state:Pe})=>{const Te=L.replace({match:ae,range:D,editor:this});if(Te){const _t=this.getTextCursorPosition();if(this.schema.blockSchema[_t.block.type].content!=="inline")return;const Ot=m.getBlockInfoFromTransaction(Pe.tr),Ht=Pe.tr.deleteRange(D.from,D.to);d.updateBlockTr(Ht,Ot.bnBlock.beforePos,Te);return}return null}})):void 0,addKeyboardShortcuts:P.keyboardShortcuts?()=>Object.fromEntries(Object.entries(P.keyboardShortcuts).map(([L,D])=>[L,()=>D({editor:this})])):void 0})})].filter(v=>v!==void 0),a={...gr,...r._tiptapOptions,element:null,autofocus:r.autofocus??!1,extensions:c,editorProps:{...(q=r._tiptapOptions)==null?void 0:q.editorProps,attributes:{tabIndex:"0",...(j=(G=r._tiptapOptions)==null?void 0:G.editorProps)==null?void 0:j.attributes,...(x=r.domAttributes)==null?void 0:x.editor,class:d.mergeCSSClasses("bn-editor",r.defaultStyles?"bn-default-styles":"",((Ce=(I=r.domAttributes)==null?void 0:I.editor)==null?void 0:Ce.class)||"")},transformPasted:mr}};try{const v=r.initialContent||(s?[{type:"paragraph",id:"initialBlockId"}]:[{type:"paragraph",id:m.UniqueID.options.generateID()}]);if(!Array.isArray(v)||v.length===0)throw new Error("initialContent must be a non-empty array of blocks, received: "+v);const P=B.getSchema(a.extensions),L=v.map(ae=>m.blockToNode(ae,P,this.schema.styleSchema).toJSON()),D=B.createDocument({type:"doc",content:[{type:"blockGroup",content:L}]},P,a.parseOptions);this._tiptapEditor=new B.Editor({...a,content:D.toJSON()}),this.pmSchema=this._tiptapEditor.schema}catch(v){throw new Error("Error creating document from blocks passed as `initialContent`",{cause:v})}let l;const h=this.pmSchema.nodes.doc.createAndFill;this.pmSchema.nodes.doc.createAndFill=(...v)=>{if(l)return l;const P=h.apply(this.pmSchema.nodes.doc,v),L=JSON.parse(JSON.stringify(P.toJSON()));return L.content[0].content[0].attrs.id="initialBlockId",l=T.Node.fromJSON(this.pmSchema,L),l},this.pmSchema.cached.blockNoteEditor=this,this._blockManager=new qn(this),this._eventManager=new jn(this),this._exportManager=new or(this),this._extensionManager=new nr(this),this._selectionManager=new cr(this),this._stateManager=new lr(this,s?{undo:(Be=this._collaborationManager)==null?void 0:Be.getUndoCommand(),redo:(ve=this._collaborationManager)==null?void 0:ve.getRedoCommand()}:void 0),this._styleManager=new ur(this),this.emit("create")}get formattingToolbar(){return this._extensionManager.formattingToolbar}get linkToolbar(){return this._extensionManager.linkToolbar}get sideMenu(){return this._extensionManager.sideMenu}get suggestionMenus(){return this._extensionManager.suggestionMenus}get filePanel(){return this._extensionManager.filePanel}get tableHandles(){return this._extensionManager.tableHandles}get comments(){var e;return(e=this._collaborationManager)==null?void 0:e.comments}get showSelectionPlugin(){return this._extensionManager.showSelectionPlugin}get forkYDocPlugin(){var e;return(e=this._collaborationManager)==null?void 0:e.forkYDocPlugin}static create(e){return new Se(e??{})}exec(e){return this._stateManager.exec(e)}canExec(e){return this._stateManager.canExec(e)}transact(e){return this._stateManager.transact(e)}extension(e,o=e.key()){return this._extensionManager.extension(e,o)}get prosemirrorState(){return this._stateManager.prosemirrorState}get prosemirrorView(){return this._stateManager.prosemirrorView}get domElement(){var e;return(e=this.prosemirrorView)==null?void 0:e.dom}isFocused(){var e;return((e=this.prosemirrorView)==null?void 0:e.hasFocus())||!1}get headless(){return!this._tiptapEditor.isInitialized}focus(){this.headless||this.prosemirrorView.focus()}blur(){this.headless||this.prosemirrorView.dom.blur()}onUploadStart(e){return this.onUploadStartCallbacks.push(e),()=>{const o=this.onUploadStartCallbacks.indexOf(e);o>-1&&this.onUploadStartCallbacks.splice(o,1)}}onUploadEnd(e){return this.onUploadEndCallbacks.push(e),()=>{const o=this.onUploadEndCallbacks.indexOf(e);o>-1&&this.onUploadEndCallbacks.splice(o,1)}}get topLevelBlocks(){return this.document}get document(){return this._blockManager.document}getBlock(e){return this._blockManager.getBlock(e)}getPrevBlock(e){return this._blockManager.getPrevBlock(e)}getNextBlock(e){return this._blockManager.getNextBlock(e)}getParentBlock(e){return this._blockManager.getParentBlock(e)}forEachBlock(e,o=!1){this._blockManager.forEachBlock(e,o)}onEditorContentChange(e){this._tiptapEditor.on("update",e)}onEditorSelectionChange(e){this._tiptapEditor.on("selectionUpdate",e)}getTextCursorPosition(){return this._selectionManager.getTextCursorPosition()}setTextCursorPosition(e,o="start"){return this._selectionManager.setTextCursorPosition(e,o)}getSelection(){return this._selectionManager.getSelection()}getSelectionCutBlocks(){return this._selectionManager.getSelectionCutBlocks()}setSelection(e,o){return this._selectionManager.setSelection(e,o)}get isEditable(){return this._stateManager.isEditable}set isEditable(e){this._stateManager.isEditable=e}insertBlocks(e,o,r="before"){return this._blockManager.insertBlocks(e,o,r)}updateBlock(e,o){return this._blockManager.updateBlock(e,o)}removeBlocks(e){return this._blockManager.removeBlocks(e)}replaceBlocks(e,o){return this._blockManager.replaceBlocks(e,o)}undo(){return this._stateManager.undo()}redo(){return this._stateManager.redo()}insertInlineContent(e,{updateSelection:o=!1}={}){this._styleManager.insertInlineContent(e,{updateSelection:o})}getActiveStyles(){return this._styleManager.getActiveStyles()}addStyles(e){this._styleManager.addStyles(e)}removeStyles(e){this._styleManager.removeStyles(e)}toggleStyles(e){this._styleManager.toggleStyles(e)}getSelectedText(){return this._styleManager.getSelectedText()}getSelectedLinkUrl(){return this._styleManager.getSelectedLinkUrl()}createLink(e,o){this._styleManager.createLink(e,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(e=this.document){return this._exportManager.blocksToHTMLLossy(e)}blocksToFullHTML(e=this.document){return this._exportManager.blocksToFullHTML(e)}tryParseHTMLToBlocks(e){return this._exportManager.tryParseHTMLToBlocks(e)}blocksToMarkdownLossy(e=this.document){return this._exportManager.blocksToMarkdownLossy(e)}tryParseMarkdownToBlocks(e){return this._exportManager.tryParseMarkdownToBlocks(e)}updateCollaborationUserInfo(e){if(!this._collaborationManager)throw new Error("Cannot update collaboration user info when collaboration is disabled.");this._collaborationManager.updateUserInfo(e)}onChange(e){return this._eventManager.onChange(e)}onSelectionChange(e,o){return this._eventManager.onSelectionChange(e,o)}onCreate(e){return this.on("create",e),()=>{this.off("create",e)}}onMount(e){this._eventManager.onMount(e)}onUnmount(e){this._eventManager.onUnmount(e)}getSelectionBoundingBox(){return this._selectionManager.getSelectionBoundingBox()}get isEmpty(){const e=this.document;return e.length===0||e.length===1&&e[0].type==="paragraph"&&e[0].content.length===0}openSuggestionMenu(e,o){this.prosemirrorView&&(this.focus(),this.transact(r=>{o!=null&&o.deleteTriggerCharacter&&r.insertText(e),r.scrollIntoView().setMeta(this.suggestionMenus.plugins[0],{triggerCharacter:e,deleteTriggerCharacter:(o==null?void 0:o.deleteTriggerCharacter)||!1,ignoreQueryLength:(o==null?void 0:o.ignoreQueryLength)||!1})}))}getForceSelectionVisible(){return this.showSelectionPlugin.getEnabled()}setForceSelectionVisible(e){this.showSelectionPlugin.setEnabled(e)}pasteHTML(e,o=!1){this._exportManager.pasteHTML(e,o)}pasteText(e){return this._exportManager.pasteText(e)}pasteMarkdown(e){return this._exportManager.pasteMarkdown(e)}}class kr{constructor(t,e,o){this.mappings=e,this.options=o}async resolveFile(t){var o;if(!((o=this.options)!=null&&o.resolveFileUrl))return(await fetch(t)).blob();const e=await this.options.resolveFileUrl(t);return e instanceof Blob?e:(await fetch(e)).blob()}mapStyles(t){return Object.entries(t).map(([o,r])=>this.mappings.styleMapping[o](r,this))}mapInlineContent(t){return this.mappings.inlineContentMapping[t.type](t,this)}transformInlineContent(t){return t.map(e=>this.mapInlineContent(e))}async mapBlock(t,e,o,r){return this.mappings.blockMapping[t.type](t,this,e,o,r)}}function br(n){return{createBlockMapping:t=>t,createInlineContentMapping:t=>t,createStyleMapping:t=>t}}let ee;async function yr(){return ee||(ee=(async()=>{const[n,t]=await Promise.all([import("emoji-mart"),import("@emoji-mart/data")]),e="default"in n?n.default:n,o="default"in t?t.default:t;return await e.init({data:o}),{emojiMart:e,emojiData:o}})(),ee)}async function wr(n,t){if(!("text"in n.schema.inlineContentSchema)||n.schema.inlineContentSchema.text!==d.defaultInlineContentSchema.text)return[];const{emojiData:e,emojiMart:o}=await yr();return(t.trim()===""?Object.values(e.emojis):await o.SearchIndex.search(t)).map(s=>({id:s.skins[0].native,onItemClick:()=>n.insertInlineContent(s.skins[0].native+" ")}))}function Sr(n,...t){const e=[...n];for(const o of t)for(const r of o){const s=e.findLastIndex(i=>i.group===r.group);s===-1?e.push(r):e.splice(s+1,0,r)}return e}exports.UniqueID=m.UniqueID;exports.UnreachableCaseError=m.UnreachableCaseError;exports.assertEmpty=m.assertEmpty;exports.blockToNode=m.blockToNode;exports.contentNodeToInlineContent=m.contentNodeToInlineContent;exports.contentNodeToTableContent=m.contentNodeToTableContent;exports.docToBlocks=m.docToBlocks;exports.getBlockCache=m.getBlockCache;exports.getBlockInfo=m.getBlockInfo;exports.getBlockInfoFromResolvedPos=m.getBlockInfoFromResolvedPos;exports.getBlockInfoFromSelection=m.getBlockInfoFromSelection;exports.getBlockInfoFromTransaction=m.getBlockInfoFromTransaction;exports.getBlockInfoWithManualOffset=m.getBlockInfoWithManualOffset;exports.getBlockNoteSchema=m.getBlockNoteSchema;exports.getBlockSchema=m.getBlockSchema;exports.getColspan=m.getColspan;exports.getInlineContentSchema=m.getInlineContentSchema;exports.getNearestBlockPos=m.getNearestBlockPos;exports.getPmSchema=m.getPmSchema;exports.getRowspan=m.getRowspan;exports.getStyleSchema=m.getStyleSchema;exports.inlineContentToNodes=m.inlineContentToNodes;exports.isLinkInlineContent=m.isLinkInlineContent;exports.isPartialLinkInlineContent=m.isPartialLinkInlineContent;exports.isPartialTableCell=m.isPartialTableCell;exports.isStyledTextInlineContent=m.isStyledTextInlineContent;exports.isTableCell=m.isTableCell;exports.mapTableCell=m.mapTableCell;exports.nodeToBlock=m.nodeToBlock;exports.nodeToCustomInlineContent=m.nodeToCustomInlineContent;exports.prosemirrorSliceToSlicedBlocks=m.prosemirrorSliceToSlicedBlocks;exports.tableContentToNodes=m.tableContentToNodes;exports.BlockNoteExtension=d.BlockNoteExtension;exports.BlockNoteSchema=d.BlockNoteSchema;exports.COLORS_DARK_MODE_DEFAULT=d.COLORS_DARK_MODE_DEFAULT;exports.COLORS_DEFAULT=d.COLORS_DEFAULT;exports.CustomBlockNoteSchema=d.CustomBlockNoteSchema;exports.EMPTY_CELL_HEIGHT=d.EMPTY_CELL_HEIGHT;exports.EMPTY_CELL_WIDTH=d.EMPTY_CELL_WIDTH;exports.EventEmitter=d.EventEmitter;exports.FILE_AUDIO_ICON_SVG=d.FILE_AUDIO_ICON_SVG;exports.FILE_IMAGE_ICON_SVG=d.FILE_IMAGE_ICON_SVG;exports.FILE_VIDEO_ICON_SVG=d.FILE_VIDEO_ICON_SVG;exports.addDefaultPropsExternalHTML=d.addDefaultPropsExternalHTML;exports.addInlineContentAttributes=d.addInlineContentAttributes;exports.addInlineContentKeyboardShortcuts=d.addInlineContentKeyboardShortcuts;exports.addNodeAndExtensionsToSpec=d.addNodeAndExtensionsToSpec;exports.addStyleAttributes=d.addStyleAttributes;exports.applyNonSelectableBlockFix=d.applyNonSelectableBlockFix;exports.audioParse=d.audioParse;exports.audioRender=d.audioRender;exports.audioToExternalHTML=d.audioToExternalHTML;exports.blockHasType=d.blockHasType;exports.camelToDataKebab=d.camelToDataKebab;exports.captureCellAnchor=d.captureCellAnchor;exports.checkPageBreakBlocksInSchema=d.checkPageBreakBlocksInSchema;exports.createAudioBlockConfig=d.createAudioBlockConfig;exports.createAudioBlockSpec=d.createAudioBlockSpec;exports.createBlockConfig=d.createBlockConfig;exports.createBlockNoteExtension=d.createBlockNoteExtension;exports.createBlockSpec=d.createBlockSpec;exports.createBlockSpecFromTiptapNode=d.createBlockSpecFromTiptapNode;exports.createBulletListItemBlockConfig=d.createBulletListItemBlockConfig;exports.createBulletListItemBlockSpec=d.createBulletListItemBlockSpec;exports.createCheckListItemBlockSpec=d.createCheckListItemBlockSpec;exports.createCheckListItemConfig=d.createCheckListItemConfig;exports.createCodeBlockConfig=d.createCodeBlockConfig;exports.createCodeBlockSpec=d.createCodeBlockSpec;exports.createDefaultBlockDOMOutputSpec=d.createDefaultBlockDOMOutputSpec;exports.createDividerBlockConfig=d.createDividerBlockConfig;exports.createDividerBlockSpec=d.createDividerBlockSpec;exports.createFileBlockConfig=d.createFileBlockConfig;exports.createFileBlockSpec=d.createFileBlockSpec;exports.createHeadingBlockConfig=d.createHeadingBlockConfig;exports.createHeadingBlockSpec=d.createHeadingBlockSpec;exports.createImageBlockConfig=d.createImageBlockConfig;exports.createImageBlockSpec=d.createImageBlockSpec;exports.createInlineContentSpecFromTipTapNode=d.createInlineContentSpecFromTipTapNode;exports.createInternalInlineContentSpec=d.createInternalInlineContentSpec;exports.createInternalStyleSpec=d.createInternalStyleSpec;exports.createNumberedListItemBlockConfig=d.createNumberedListItemBlockConfig;exports.createNumberedListItemBlockSpec=d.createNumberedListItemBlockSpec;exports.createPageBreakBlockConfig=d.createPageBreakBlockConfig;exports.createPageBreakBlockSpec=d.createPageBreakBlockSpec;exports.createParagraphBlockConfig=d.createParagraphBlockConfig;exports.createParagraphBlockSpec=d.createParagraphBlockSpec;exports.createQuoteBlockConfig=d.createQuoteBlockConfig;exports.createQuoteBlockSpec=d.createQuoteBlockSpec;exports.createStyleSpec=d.createStyleSpec;exports.createStyleSpecFromTipTapMark=d.createStyleSpecFromTipTapMark;exports.createTableBlockSpec=d.createTableBlockSpec;exports.createToggleListItemBlockConfig=d.createToggleListItemBlockConfig;exports.createToggleListItemBlockSpec=d.createToggleListItemBlockSpec;exports.createToggleWrapper=d.createToggleWrapper;exports.createVideoBlockConfig=d.createVideoBlockConfig;exports.createVideoBlockSpec=d.createVideoBlockSpec;exports.defaultBlockSpecs=d.defaultBlockSpecs;exports.defaultBlockToHTML=d.defaultBlockToHTML;exports.defaultInlineContentSchema=d.defaultInlineContentSchema;exports.defaultInlineContentSpecs=d.defaultInlineContentSpecs;exports.defaultProps=d.defaultProps;exports.defaultStyleSchema=d.defaultStyleSchema;exports.defaultStyleSpecs=d.defaultStyleSpecs;exports.defaultToggledState=d.defaultToggledState;exports.editorHasBlockWithType=d.editorHasBlockWithType;exports.fileParse=d.fileParse;exports.filenameFromURL=d.filenameFromURL;exports.filterSuggestionItems=d.filterSuggestionItems;exports.formatKeyboardShortcut=d.formatKeyboardShortcut;exports.getBackgroundColorAttribute=d.getBackgroundColorAttribute;exports.getBlockFromPos=d.getBlockFromPos;exports.getDefaultSlashMenuItems=d.getDefaultSlashMenuItems;exports.getInlineContentSchemaFromSpecs=d.getInlineContentSchemaFromSpecs;exports.getLanguageId=d.getLanguageId;exports.getNodeById=d.getNodeById;exports.getPageBreakSlashMenuItems=d.getPageBreakSlashMenuItems;exports.getParseRules=d.getParseRules;exports.getStyleParseRules=d.getStyleParseRules;exports.getStyleSchemaFromSpecs=d.getStyleSchemaFromSpecs;exports.getTextAlignmentAttribute=d.getTextAlignmentAttribute;exports.getTextColorAttribute=d.getTextColorAttribute;exports.imageParse=d.imageParse;exports.imageRender=d.imageRender;exports.imageToExternalHTML=d.imageToExternalHTML;exports.insertOrUpdateBlock=d.insertOrUpdateBlock;exports.isAppleOS=d.isAppleOS;exports.isNodeBlock=d.isNodeBlock;exports.isSafari=d.isSafari;exports.isTableCellSelection=d.isTableCellSelection;exports.isVideoUrl=d.isVideoUrl;exports.mergeCSSClasses=d.mergeCSSClasses;exports.mergeParagraphs=d.mergeParagraphs;exports.parseAudioElement=d.parseAudioElement;exports.parseDefaultProps=d.parseDefaultProps;exports.propsToAttributes=d.propsToAttributes;exports.stylePropsToAttributes=d.stylePropsToAttributes;exports.tablePropSchema=d.tablePropSchema;exports.updateBlock=d.updateBlock;exports.updateBlockCommand=d.updateBlockCommand;exports.updateBlockTr=d.updateBlockTr;exports.uploadToTmpFilesDotOrg_DEV_ONLY=d.uploadToTmpFilesDotOrg_DEV_ONLY;exports.videoParse=d.videoParse;exports.withPageBreak=d.withPageBreak;exports.wrapInBlockStructure=d.wrapInBlockStructure;exports.BlockNoteEditor=Se;exports.DEFAULT_LINK_PROTOCOL=mt;exports.Exporter=kr;exports.FilePanelProsemirrorPlugin=st;exports.FilePanelView=rt;exports.FormattingToolbarProsemirrorPlugin=ct;exports.FormattingToolbarView=it;exports.HTMLToBlocks=ye;exports.LinkToolbarProsemirrorPlugin=ht;exports.SideMenuProsemirrorPlugin=yt;exports.SideMenuView=kt;exports.SuggestionMenuProseMirrorPlugin=St;exports.TableHandlesProsemirrorPlugin=Bt;exports.TableHandlesView=Ct;exports.VALID_LINK_PROTOCOLS=pt;exports.blocksToMarkdown=Ze;exports.cleanHTMLToMarkdown=ie;exports.combineByGroup=Sr;exports.createExternalHTMLExporter=X;exports.createInlineContentSpec=ko;exports.createInternalHTMLSerializer=Je;exports.createSuggestionMenu=Tn;exports.fixColumnList=oe;exports.formattingToolbarPluginKey=at;exports.getBlock=xt;exports.getBlockNoteExtensions=vt;exports.getBlocksChangedByTransaction=fe;exports.getDefaultEmojiPickerItems=wr;exports.getInlineContentParseRules=ze;exports.getNextBlock=Dt;exports.getParentBlock=Lt;exports.getPrevBlock=It;exports.insertBlocks=Ke;exports.isEmptyColumn=te;exports.linkToolbarPluginKey=ut;exports.mappingFactory=br;exports.markdownToBlocks=Nt;exports.markdownToHTML=we;exports.removeAndInsertBlocks=ue;exports.removeEmptyColumns=qe;exports.selectedFragmentToHTML=ke;exports.sideMenuPluginKey=bt;exports.tableHandlesPluginKey=V;exports.trackPosition=wt;
|
|
5
5
|
//# sourceMappingURL=blocknote.cjs.map
|