@blocknote/core 0.31.1 → 0.32.0-hackdays.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocknote.cjs +6 -6
- package/dist/blocknote.cjs.map +1 -1
- package/dist/blocknote.js +15 -7
- package/dist/blocknote.js.map +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +1 -1
- package/src/api/nodeConversions/blockToNode.ts +6 -2
- package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +22 -12
- package/types/src/api/blockManipulation/selections/selection.test.d.ts +1 -0
- package/types/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.d.ts +5 -0
- package/types/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.d.ts +1 -0
- package/types/src/extensions/Collaboration/createCollaborationExtensions.d.ts +17 -0
- package/dist/tsconfig.tsbuildinfo +0 -1
package/dist/blocknote.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";var hr=Object.create;var nt=Object.defineProperty;var fr=Object.getOwnPropertyDescriptor;var mr=Object.getOwnPropertyNames;var gr=Object.getPrototypeOf,br=Object.prototype.hasOwnProperty;var kr=(e,n,t)=>n in e?nt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var wr=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of mr(n))!br.call(e,r)&&r!==t&&nt(e,r,{get:()=>n[r],enumerable:!(o=fr(n,r))||o.enumerable});return e};var W=(e,n,t)=>(t=e!=null?hr(gr(e)):{},wr(n||!e||!e.__esModule?nt(t,"default",{value:e,enumerable:!0}):t,e));var p=(e,n,t)=>kr(e,typeof n!="symbol"?n+"":n,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("prosemirror-model"),pe=require("prosemirror-transform"),k=require("@tiptap/core"),y=require("prosemirror-state"),cn=require("uuid"),yr=require("prosemirror-highlight"),Cr=require("prosemirror-highlight/shiki"),vr=require("@tiptap/extension-bold"),Sr=require("@tiptap/extension-code"),Er=require("@tiptap/extension-italic"),Br=require("@tiptap/extension-strike"),Tr=require("@tiptap/extension-underline"),xr=require("@tiptap/extension-table-cell"),Pr=require("@tiptap/extension-table-header"),A=require("prosemirror-tables"),Mr=require("@tiptap/extension-gapcursor"),Ir=require("@tiptap/extension-history"),Lr=require("@tiptap/extension-link"),Ar=require("@tiptap/extension-text"),N=require("y-prosemirror"),M=require("prosemirror-view"),Nr=require("yjs"),Wt=require("prosemirror-history"),Hr=require("prosemirror-dropcursor"),Dr=require("./en-BXVKCwYt.cjs"),Ee=e=>e&&typeof e=="object"&&"default"in e?e:{default:e};function Or(e){if(e&&typeof e=="object"&&"default"in e)return e;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const Rr=Ee(vr),_r=Ee(Sr),Vr=Ee(Er),Ur=Ee(Br),Fr=Ee(Tr),ce=Or(Nr);function $r(e,n=JSON.stringify){const t={};return e.filter(o=>{const r=n(o);return Object.prototype.hasOwnProperty.call(t,r)?!1:t[r]=!0})}function zr(e){const n=e.filter((o,r)=>e.indexOf(o)!==r);return $r(n)}const Be=k.Extension.create({name:"uniqueID",priority:1e4,addOptions(){return{attributeName:"id",types:[],setIdAttribute:!1,generateID:()=>{if(typeof window<"u"&&window.__TEST_OPTIONS){const e=window.__TEST_OPTIONS;return e.mockID===void 0?e.mockID=0:e.mockID++,e.mockID.toString()}return cn.v4()},filterTransaction:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{[this.options.attributeName]:{default:null,parseHTML:e=>e.getAttribute(`data-${this.options.attributeName}`),renderHTML:e=>{const n={[`data-${this.options.attributeName}`]:e[this.options.attributeName]};return this.options.setIdAttribute?{...n,id:e[this.options.attributeName]}:n}}}}]},addProseMirrorPlugins(){let e=null,n=!1;return[new y.Plugin({key:new y.PluginKey("uniqueID"),appendTransaction:(t,o,r)=>{const s=t.some(m=>m.docChanged)&&!o.doc.eq(r.doc),i=this.options.filterTransaction&&t.some(m=>{let g,b;return!(!((b=(g=this.options).filterTransaction)===null||b===void 0)&&b.call(g,m))});if(!s||i)return;const{tr:a}=r,{types:l,attributeName:c,generateID:d}=this.options,u=k.combineTransactionSteps(o.doc,t),{mapping:h}=u;if(k.getChangedRanges(u).forEach(({newRange:m})=>{const g=k.findChildrenInRange(r.doc,m,C=>l.includes(C.type.name)),b=g.map(({node:C})=>C.attrs[c]).filter(C=>C!==null),w=zr(b);g.forEach(({node:C,pos:S})=>{let P;const R=(P=a.doc.nodeAt(S))===null||P===void 0?void 0:P.attrs[c];if(R===null){const v=o.doc.type.createAndFill().content;if(o.doc.content.findDiffStart(v)===null){const se=JSON.parse(JSON.stringify(r.doc.toJSON()));if(se.content[0].content[0].attrs.id="initialBlockId",JSON.stringify(se.content)===JSON.stringify(v.toJSON())){a.setNodeMarkup(S,void 0,{...C.attrs,[c]:"initialBlockId"});return}}a.setNodeMarkup(S,void 0,{...C.attrs,[c]:d()});return}const{deleted:z}=h.invert().mapResult(S);z&&w.includes(R)&&a.setNodeMarkup(S,void 0,{...C.attrs,[c]:d()})})}),!!a.steps.length)return a},view(t){const o=r=>{let s;e=!((s=t.dom.parentElement)===null||s===void 0)&&s.contains(r.target)?t.dom.parentElement:null};return window.addEventListener("dragstart",o),{destroy(){window.removeEventListener("dragstart",o)}}},props:{handleDOMEvents:{drop:(t,o)=>{let r;return e!==t.dom.parentElement||((r=o.dataTransfer)===null||r===void 0?void 0:r.effectAllowed)==="copy"?n=!0:n=!1,e=null,!1},paste:()=>(n=!0,!1)},transformPasted:t=>{if(!n)return t;const{types:o,attributeName:r}=this.options,s=i=>{const a=[];return i.forEach(l=>{if(l.isText){a.push(l);return}if(!o.includes(l.type.name)){a.push(l.copy(s(l.content)));return}const c=l.type.create({...l.attrs,[r]:null},s(l.content),l.marks);a.push(c)}),E.Fragment.from(a)};return n=!1,new E.Slice(s(t.content),t.openStart,t.openEnd)}}})]}});function it(e){return e.type==="link"}function Ct(e){return typeof e!="string"&&e.type==="link"}function ne(e){return typeof e!="string"&&e.type==="text"}function _e(e){var n,t,o,r,s;return qe(e)?{...e}:he(e)?{type:"tableCell",content:[].concat(e.content),props:{backgroundColor:((n=e.props)==null?void 0:n.backgroundColor)??"default",textColor:((t=e.props)==null?void 0:t.textColor)??"default",textAlignment:((o=e.props)==null?void 0:o.textAlignment)??"left",colspan:((r=e.props)==null?void 0:r.colspan)??1,rowspan:((s=e.props)==null?void 0:s.rowspan)??1}}:{type:"tableCell",content:[].concat(e),props:{backgroundColor:"default",textColor:"default",textAlignment:"left",colspan:1,rowspan:1}}}function he(e){return e!=null&&typeof e!="string"&&!Array.isArray(e)&&e.type==="tableCell"}function qe(e){return he(e)&&e.props!==void 0&&e.content!==void 0}function fe(e){return qe(e)?e.props.colspan??1:1}function Ve(e){return qe(e)?e.props.rowspan??1:1}class K extends Error{constructor(n){super(`Unreachable case: ${n}`)}}function Wr(e,n=!0){const{"data-test":t,...o}=e;if(Object.keys(o).length>0&&n)throw new Error("Object must be empty "+JSON.stringify(e))}const dn=()=>typeof navigator<"u"&&(/Mac/.test(navigator.platform)||/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent));function J(e,n="Ctrl"){return dn()?e.replace("Mod","⌘"):e.replace("Mod",n)}function X(...e){return e.filter(n=>n).join(" ")}const Kr=()=>/^((?!chrome|android).)*safari/i.test(navigator.userAgent);function j(e,n,t,o){const r=document.createElement("div");r.className=X("bn-block-content",t.class),r.setAttribute("data-content-type",e);for(const[i,a]of Object.entries(t))i!=="class"&&r.setAttribute(i,a);const s=document.createElement(n);s.className=X("bn-inline-content",o.class);for(const[i,a]of Object.entries(o))i!=="class"&&s.setAttribute(i,a);return r.appendChild(s),{dom:r,contentDOM:s}}const at=(e,n)=>{let t=re(e,n.pmSchema);t.type.name==="blockContainer"&&(t=t.firstChild);const o=n.pmSchema.nodes[t.type.name].spec.toDOM;if(o===void 0)throw new Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");const r=o(t);if(typeof r!="object"||!("dom"in r))throw new Error("Cannot use this block's default HTML serialization as its corresponding TipTap node's `renderHTML` function does not return an object with the `dom` property.");return r};function qr(e){const n=e.querySelectorAll("p");if(n.length>1){const t=n[0];for(let o=1;o<n.length;o++){const r=n[o];t.innerHTML+="<br>"+r.innerHTML,r.remove()}}}const I={backgroundColor:{default:"default"},textColor:{default:"default"},textAlignment:{default:"left",values:["left","center","right","justify"]}},vt=["backgroundColor","textColor"];function ve(e){return"data-"+e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function jr(e){const n=e.split("/");return!n.length||n[n.length-1]===""?e:n[n.length-1]}function me(e){const n={};return Object.entries(e).filter(([t,o])=>!vt.includes(t)).forEach(([t,o])=>{n[t]={default:o.default,keepOnSplit:!0,parseHTML:r=>{const s=r.getAttribute(ve(t));if(s===null)return null;if(o.default===void 0&&o.type==="boolean"||o.default!==void 0&&typeof o.default=="boolean")return s==="true"?!0:s==="false"?!1:null;if(o.default===void 0&&o.type==="number"||o.default!==void 0&&typeof o.default=="number"){const i=parseFloat(s);return!Number.isNaN(i)&&Number.isFinite(i)?i:null}return s},renderHTML:r=>r[t]!==o.default?{[ve(t)]:r[t]}:{}}}),n}function un(e,n,t,o){if(typeof e=="boolean")throw new Error("Cannot find node position as getPos is a boolean, not a function.");const r=e(),i=t.state.doc.resolve(r).node().attrs.id;if(!i)throw new Error("Block doesn't have id");const a=n.getBlock(i);if(a.type!==o)throw new Error("Block type does not match");return a}function Ce(e,n,t,o,r=!1,s){const i=document.createElement("div");if(s!==void 0)for(const[a,l]of Object.entries(s))a!=="class"&&i.setAttribute(a,l);i.className=X("bn-block-content",(s==null?void 0:s.class)||""),i.setAttribute("data-content-type",n);for(const[a,l]of Object.entries(t)){const d=o[a].default;!vt.includes(a)&&l!==d&&i.setAttribute(ve(a),l)}return r&&i.setAttribute("data-file-block",""),i.appendChild(e.dom),e.contentDOM!==void 0&&(e.contentDOM.className=X("bn-inline-content",e.contentDOM.className)),{...e,dom:i}}function G(e){return k.Node.create(e)}function St(e,n){return{config:e,implementation:n}}function Q(e,n,t){return St({type:e.name,content:e.config.content==="inline*"?"inline":e.config.content==="tableRow+"?"table":"none",propSchema:n},{node:e,requiredExtensions:t,toInternalHTML:at,toExternalHTML:at})}function Et(e){return Object.fromEntries(Object.entries(e).map(([n,t])=>[n,t.config]))}function pn(e,n){e.stopEvent=t=>(t.type==="mousedown"&&setTimeout(()=>{n.view.dom.blur()},10),!0)}function hn(e,n){const t=[{tag:"[data-content-type="+e.type+"]",contentElement:".bn-inline-content"}];return n&&t.push({tag:"*",getAttrs(o){if(typeof o=="string")return!1;const r=n==null?void 0:n(o);return r===void 0?!1:r}}),t}function ge(e,n){const t=G({name:e.type,content:e.content==="inline"?"inline*":"",group:"blockContent",selectable:e.isSelectable??!0,isolating:!0,addAttributes(){return me(e.propSchema)},parseHTML(){return hn(e,n.parse)},renderHTML({HTMLAttributes:o}){const r=document.createElement("div");return Ce({dom:r,contentDOM:e.content==="inline"?r:void 0},e.type,{},e.propSchema,e.isFileBlock,o)},addNodeView(){return({getPos:o})=>{var c;const r=this.options.editor,s=un(o,r,this.editor,e.type),i=((c=this.options.domAttributes)==null?void 0:c.blockContent)||{},a=n.render(s,r),l=Ce(a,s.type,s.props,e.propSchema,i);return e.isSelectable===!1&&pn(l,this.editor),l}}});if(t.name!==e.type)throw new Error("Node name does not match block type. This is a bug in BlockNote.");return St(e,{node:t,toInternalHTML:(o,r)=>{var a;const s=((a=t.options.domAttributes)==null?void 0:a.blockContent)||{},i=n.render(o,r);return Ce(i,o.type,o.props,e.propSchema,e.isFileBlock,s)},toExternalHTML:(o,r)=>{var a,l;const s=((a=t.options.domAttributes)==null?void 0:a.blockContent)||{};let i=(l=n.toExternalHTML)==null?void 0:l.call(n,o,r);return i===void 0&&(i=n.render(o,r)),Ce(i,o.type,o.props,e.propSchema,s)}})}function Y(e,n){const t=e.resolve(n);if(t.nodeAfter&&t.nodeAfter.type.isInGroup("bnBlock"))return{posBeforeNode:t.pos,node:t.nodeAfter};let o=t.depth,r=t.node(o);for(;o>0;){if(r.type.isInGroup("bnBlock"))return{posBeforeNode:t.before(o),node:r};o--,r=t.node(o)}const s=[];e.descendants((a,l)=>{a.type.isInGroup("bnBlock")&&s.push(l)}),console.warn(`Position ${n} is not within a blockContainer node.`);const i=e.resolve(s.find(a=>a>=n)||s[s.length-1]);return{posBeforeNode:i.pos,node:i.nodeAfter}}function je(e,n){if(!e.type.isInGroup("bnBlock"))throw new Error(`Attempted to get bnBlock node at position but found node of different type ${e.type.name}`);const t=e,o=n,r=o+t.nodeSize,s={node:t,beforePos:o,afterPos:r};if(t.type.name==="blockContainer"){let i,a;if(t.forEach((l,c)=>{if(l.type.spec.group==="blockContent"){const d=l,u=o+c+1,h=u+l.nodeSize;i={node:d,beforePos:u,afterPos:h}}else if(l.type.name==="blockGroup"){const d=l,u=o+c+1,h=u+l.nodeSize;a={node:d,beforePos:u,afterPos:h}}}),!i)throw new Error(`blockContainer node does not contain a blockContent node in its children: ${t}`);return{isBlockContainer:!0,bnBlock:s,blockContent:i,childContainer:a,blockNoteType:i.node.type.name}}else{if(!s.node.type.isInGroup("childContainer"))throw new Error(`bnBlock node is not in the childContainer group: ${s.node}`);return{isBlockContainer:!1,bnBlock:s,childContainer:s,blockNoteType:s.node.type.name}}}function Z(e){return je(e.node,e.posBeforeNode)}function be(e){if(!e.nodeAfter)throw new Error(`Attempted to get blockContainer node at position ${e.pos} but a node at this position does not exist`);return je(e.nodeAfter,e.pos)}function B(e){const n=Y(e.doc,e.selection.anchor);return Z(n)}function Te(e){const n=Y(e.doc,e.selection.anchor);return Z(n)}function H(e){return"doc"in e?e.doc.type.schema:e.type.schema}function fn(e){return e.cached.blockNoteEditor}function ke(e){return fn(e).schema}function Ge(e){return ke(e).blockSchema}function Ye(e){return ke(e).inlineContentSchema}function le(e){return ke(e).styleSchema}function Je(e){return fn(e).blockCache}function Bt(e,n,t){var s,i;const o={type:"tableContent",columnWidths:[],headerRows:void 0,headerCols:void 0,rows:[]},r=[];e.content.forEach((a,l,c)=>{const d={cells:[]};c===0&&a.content.forEach(u=>{let h=u.attrs.colwidth;h==null&&(h=new Array(u.attrs.colspan??1).fill(void 0)),o.columnWidths.push(...h)}),d.cells=a.content.content.map((u,h)=>(r[c]||(r[c]=[]),r[c][h]=u.type.name==="tableHeader",{type:"tableCell",content:u.content.content.map(m=>xe(m,n,t)).reduce((m,g)=>{if(!m.length)return g;const b=m[m.length-1],w=g[0];return w&&ne(b)&&ne(w)&&JSON.stringify(b.styles)===JSON.stringify(w.styles)?(b.text+=`
|
|
1
|
+
"use strict";var hr=Object.create;var nt=Object.defineProperty;var fr=Object.getOwnPropertyDescriptor;var mr=Object.getOwnPropertyNames;var gr=Object.getPrototypeOf,br=Object.prototype.hasOwnProperty;var kr=(e,n,t)=>n in e?nt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var wr=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of mr(n))!br.call(e,r)&&r!==t&&nt(e,r,{get:()=>n[r],enumerable:!(o=fr(n,r))||o.enumerable});return e};var W=(e,n,t)=>(t=e!=null?hr(gr(e)):{},wr(n||!e||!e.__esModule?nt(t,"default",{value:e,enumerable:!0}):t,e));var p=(e,n,t)=>kr(e,typeof n!="symbol"?n+"":n,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("prosemirror-model"),pe=require("prosemirror-transform"),k=require("@tiptap/core"),y=require("prosemirror-state"),cn=require("uuid"),yr=require("prosemirror-highlight"),Cr=require("prosemirror-highlight/shiki"),vr=require("@tiptap/extension-bold"),Sr=require("@tiptap/extension-code"),Er=require("@tiptap/extension-italic"),Br=require("@tiptap/extension-strike"),Tr=require("@tiptap/extension-underline"),xr=require("@tiptap/extension-table-cell"),Pr=require("@tiptap/extension-table-header"),A=require("prosemirror-tables"),Mr=require("@tiptap/extension-gapcursor"),Ir=require("@tiptap/extension-history"),Lr=require("@tiptap/extension-link"),Ar=require("@tiptap/extension-text"),N=require("y-prosemirror"),M=require("prosemirror-view"),Nr=require("yjs"),Wt=require("prosemirror-history"),Hr=require("prosemirror-dropcursor"),Dr=require("./en-BXVKCwYt.cjs"),Ee=e=>e&&typeof e=="object"&&"default"in e?e:{default:e};function Or(e){if(e&&typeof e=="object"&&"default"in e)return e;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const Rr=Ee(vr),Vr=Ee(Sr),_r=Ee(Er),Ur=Ee(Br),Fr=Ee(Tr),ce=Or(Nr);function $r(e,n=JSON.stringify){const t={};return e.filter(o=>{const r=n(o);return Object.prototype.hasOwnProperty.call(t,r)?!1:t[r]=!0})}function zr(e){const n=e.filter((o,r)=>e.indexOf(o)!==r);return $r(n)}const Be=k.Extension.create({name:"uniqueID",priority:1e4,addOptions(){return{attributeName:"id",types:[],setIdAttribute:!1,generateID:()=>{if(typeof window<"u"&&window.__TEST_OPTIONS){const e=window.__TEST_OPTIONS;return e.mockID===void 0?e.mockID=0:e.mockID++,e.mockID.toString()}return cn.v4()},filterTransaction:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{[this.options.attributeName]:{default:null,parseHTML:e=>e.getAttribute(`data-${this.options.attributeName}`),renderHTML:e=>{const n={[`data-${this.options.attributeName}`]:e[this.options.attributeName]};return this.options.setIdAttribute?{...n,id:e[this.options.attributeName]}:n}}}}]},addProseMirrorPlugins(){let e=null,n=!1;return[new y.Plugin({key:new y.PluginKey("uniqueID"),appendTransaction:(t,o,r)=>{const s=t.some(m=>m.docChanged)&&!o.doc.eq(r.doc),i=this.options.filterTransaction&&t.some(m=>{let g,b;return!(!((b=(g=this.options).filterTransaction)===null||b===void 0)&&b.call(g,m))});if(!s||i)return;const{tr:a}=r,{types:l,attributeName:c,generateID:d}=this.options,u=k.combineTransactionSteps(o.doc,t),{mapping:h}=u;if(k.getChangedRanges(u).forEach(({newRange:m})=>{const g=k.findChildrenInRange(r.doc,m,C=>l.includes(C.type.name)),b=g.map(({node:C})=>C.attrs[c]).filter(C=>C!==null),w=zr(b);g.forEach(({node:C,pos:S})=>{let P;const R=(P=a.doc.nodeAt(S))===null||P===void 0?void 0:P.attrs[c];if(R===null){const v=o.doc.type.createAndFill().content;if(o.doc.content.findDiffStart(v)===null){const se=JSON.parse(JSON.stringify(r.doc.toJSON()));if(se.content[0].content[0].attrs.id="initialBlockId",JSON.stringify(se.content)===JSON.stringify(v.toJSON())){a.setNodeMarkup(S,void 0,{...C.attrs,[c]:"initialBlockId"});return}}a.setNodeMarkup(S,void 0,{...C.attrs,[c]:d()});return}const{deleted:z}=h.invert().mapResult(S);z&&w.includes(R)&&a.setNodeMarkup(S,void 0,{...C.attrs,[c]:d()})})}),!!a.steps.length)return a},view(t){const o=r=>{let s;e=!((s=t.dom.parentElement)===null||s===void 0)&&s.contains(r.target)?t.dom.parentElement:null};return window.addEventListener("dragstart",o),{destroy(){window.removeEventListener("dragstart",o)}}},props:{handleDOMEvents:{drop:(t,o)=>{let r;return e!==t.dom.parentElement||((r=o.dataTransfer)===null||r===void 0?void 0:r.effectAllowed)==="copy"?n=!0:n=!1,e=null,!1},paste:()=>(n=!0,!1)},transformPasted:t=>{if(!n)return t;const{types:o,attributeName:r}=this.options,s=i=>{const a=[];return i.forEach(l=>{if(l.isText){a.push(l);return}if(!o.includes(l.type.name)){a.push(l.copy(s(l.content)));return}const c=l.type.create({...l.attrs,[r]:null},s(l.content),l.marks);a.push(c)}),E.Fragment.from(a)};return n=!1,new E.Slice(s(t.content),t.openStart,t.openEnd)}}})]}});function it(e){return e.type==="link"}function Ct(e){return typeof e!="string"&&e.type==="link"}function ne(e){return typeof e!="string"&&e.type==="text"}function Ve(e){var n,t,o,r,s;return qe(e)?{...e}:he(e)?{type:"tableCell",content:[].concat(e.content),props:{backgroundColor:((n=e.props)==null?void 0:n.backgroundColor)??"default",textColor:((t=e.props)==null?void 0:t.textColor)??"default",textAlignment:((o=e.props)==null?void 0:o.textAlignment)??"left",colspan:((r=e.props)==null?void 0:r.colspan)??1,rowspan:((s=e.props)==null?void 0:s.rowspan)??1}}:{type:"tableCell",content:[].concat(e),props:{backgroundColor:"default",textColor:"default",textAlignment:"left",colspan:1,rowspan:1}}}function he(e){return e!=null&&typeof e!="string"&&!Array.isArray(e)&&e.type==="tableCell"}function qe(e){return he(e)&&e.props!==void 0&&e.content!==void 0}function fe(e){return qe(e)?e.props.colspan??1:1}function _e(e){return qe(e)?e.props.rowspan??1:1}class K extends Error{constructor(n){super(`Unreachable case: ${n}`)}}function Wr(e,n=!0){const{"data-test":t,...o}=e;if(Object.keys(o).length>0&&n)throw new Error("Object must be empty "+JSON.stringify(e))}const dn=()=>typeof navigator<"u"&&(/Mac/.test(navigator.platform)||/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent));function J(e,n="Ctrl"){return dn()?e.replace("Mod","⌘"):e.replace("Mod",n)}function X(...e){return e.filter(n=>n).join(" ")}const Kr=()=>/^((?!chrome|android).)*safari/i.test(navigator.userAgent);function j(e,n,t,o){const r=document.createElement("div");r.className=X("bn-block-content",t.class),r.setAttribute("data-content-type",e);for(const[i,a]of Object.entries(t))i!=="class"&&r.setAttribute(i,a);const s=document.createElement(n);s.className=X("bn-inline-content",o.class);for(const[i,a]of Object.entries(o))i!=="class"&&s.setAttribute(i,a);return r.appendChild(s),{dom:r,contentDOM:s}}const at=(e,n)=>{let t=re(e,n.pmSchema);t.type.name==="blockContainer"&&(t=t.firstChild);const o=n.pmSchema.nodes[t.type.name].spec.toDOM;if(o===void 0)throw new Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");const r=o(t);if(typeof r!="object"||!("dom"in r))throw new Error("Cannot use this block's default HTML serialization as its corresponding TipTap node's `renderHTML` function does not return an object with the `dom` property.");return r};function qr(e){const n=e.querySelectorAll("p");if(n.length>1){const t=n[0];for(let o=1;o<n.length;o++){const r=n[o];t.innerHTML+="<br>"+r.innerHTML,r.remove()}}}const I={backgroundColor:{default:"default"},textColor:{default:"default"},textAlignment:{default:"left",values:["left","center","right","justify"]}},vt=["backgroundColor","textColor"];function ve(e){return"data-"+e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function jr(e){const n=e.split("/");return!n.length||n[n.length-1]===""?e:n[n.length-1]}function me(e){const n={};return Object.entries(e).filter(([t,o])=>!vt.includes(t)).forEach(([t,o])=>{n[t]={default:o.default,keepOnSplit:!0,parseHTML:r=>{const s=r.getAttribute(ve(t));if(s===null)return null;if(o.default===void 0&&o.type==="boolean"||o.default!==void 0&&typeof o.default=="boolean")return s==="true"?!0:s==="false"?!1:null;if(o.default===void 0&&o.type==="number"||o.default!==void 0&&typeof o.default=="number"){const i=parseFloat(s);return!Number.isNaN(i)&&Number.isFinite(i)?i:null}return s},renderHTML:r=>r[t]!==o.default?{[ve(t)]:r[t]}:{}}}),n}function un(e,n,t,o){if(typeof e=="boolean")throw new Error("Cannot find node position as getPos is a boolean, not a function.");const r=e(),i=t.state.doc.resolve(r).node().attrs.id;if(!i)throw new Error("Block doesn't have id");const a=n.getBlock(i);if(a.type!==o)throw new Error("Block type does not match");return a}function Ce(e,n,t,o,r=!1,s){const i=document.createElement("div");if(s!==void 0)for(const[a,l]of Object.entries(s))a!=="class"&&i.setAttribute(a,l);i.className=X("bn-block-content",(s==null?void 0:s.class)||""),i.setAttribute("data-content-type",n);for(const[a,l]of Object.entries(t)){const d=o[a].default;!vt.includes(a)&&l!==d&&i.setAttribute(ve(a),l)}return r&&i.setAttribute("data-file-block",""),i.appendChild(e.dom),e.contentDOM!==void 0&&(e.contentDOM.className=X("bn-inline-content",e.contentDOM.className)),{...e,dom:i}}function G(e){return k.Node.create(e)}function St(e,n){return{config:e,implementation:n}}function Q(e,n,t){return St({type:e.name,content:e.config.content==="inline*"?"inline":e.config.content==="tableRow+"?"table":"none",propSchema:n},{node:e,requiredExtensions:t,toInternalHTML:at,toExternalHTML:at})}function Et(e){return Object.fromEntries(Object.entries(e).map(([n,t])=>[n,t.config]))}function pn(e,n){e.stopEvent=t=>(t.type==="mousedown"&&setTimeout(()=>{n.view.dom.blur()},10),!0)}function hn(e,n){const t=[{tag:"[data-content-type="+e.type+"]",contentElement:".bn-inline-content"}];return n&&t.push({tag:"*",getAttrs(o){if(typeof o=="string")return!1;const r=n==null?void 0:n(o);return r===void 0?!1:r}}),t}function ge(e,n){const t=G({name:e.type,content:e.content==="inline"?"inline*":"",group:"blockContent",selectable:e.isSelectable??!0,isolating:!0,addAttributes(){return me(e.propSchema)},parseHTML(){return hn(e,n.parse)},renderHTML({HTMLAttributes:o}){const r=document.createElement("div");return Ce({dom:r,contentDOM:e.content==="inline"?r:void 0},e.type,{},e.propSchema,e.isFileBlock,o)},addNodeView(){return({getPos:o})=>{var c;const r=this.options.editor,s=un(o,r,this.editor,e.type),i=((c=this.options.domAttributes)==null?void 0:c.blockContent)||{},a=n.render(s,r),l=Ce(a,s.type,s.props,e.propSchema,i);return e.isSelectable===!1&&pn(l,this.editor),l}}});if(t.name!==e.type)throw new Error("Node name does not match block type. This is a bug in BlockNote.");return St(e,{node:t,toInternalHTML:(o,r)=>{var a;const s=((a=t.options.domAttributes)==null?void 0:a.blockContent)||{},i=n.render(o,r);return Ce(i,o.type,o.props,e.propSchema,e.isFileBlock,s)},toExternalHTML:(o,r)=>{var a,l;const s=((a=t.options.domAttributes)==null?void 0:a.blockContent)||{};let i=(l=n.toExternalHTML)==null?void 0:l.call(n,o,r);return i===void 0&&(i=n.render(o,r)),Ce(i,o.type,o.props,e.propSchema,s)}})}function Y(e,n){const t=e.resolve(n);if(t.nodeAfter&&t.nodeAfter.type.isInGroup("bnBlock"))return{posBeforeNode:t.pos,node:t.nodeAfter};let o=t.depth,r=t.node(o);for(;o>0;){if(r.type.isInGroup("bnBlock"))return{posBeforeNode:t.before(o),node:r};o--,r=t.node(o)}const s=[];e.descendants((a,l)=>{a.type.isInGroup("bnBlock")&&s.push(l)}),console.warn(`Position ${n} is not within a blockContainer node.`);const i=e.resolve(s.find(a=>a>=n)||s[s.length-1]);return{posBeforeNode:i.pos,node:i.nodeAfter}}function je(e,n){if(!e.type.isInGroup("bnBlock"))throw new Error(`Attempted to get bnBlock node at position but found node of different type ${e.type.name}`);const t=e,o=n,r=o+t.nodeSize,s={node:t,beforePos:o,afterPos:r};if(t.type.name==="blockContainer"){let i,a;if(t.forEach((l,c)=>{if(l.type.spec.group==="blockContent"){const d=l,u=o+c+1,h=u+l.nodeSize;i={node:d,beforePos:u,afterPos:h}}else if(l.type.name==="blockGroup"){const d=l,u=o+c+1,h=u+l.nodeSize;a={node:d,beforePos:u,afterPos:h}}}),!i)throw new Error(`blockContainer node does not contain a blockContent node in its children: ${t}`);return{isBlockContainer:!0,bnBlock:s,blockContent:i,childContainer:a,blockNoteType:i.node.type.name}}else{if(!s.node.type.isInGroup("childContainer"))throw new Error(`bnBlock node is not in the childContainer group: ${s.node}`);return{isBlockContainer:!1,bnBlock:s,childContainer:s,blockNoteType:s.node.type.name}}}function Z(e){return je(e.node,e.posBeforeNode)}function be(e){if(!e.nodeAfter)throw new Error(`Attempted to get blockContainer node at position ${e.pos} but a node at this position does not exist`);return je(e.nodeAfter,e.pos)}function B(e){const n=Y(e.doc,e.selection.anchor);return Z(n)}function Te(e){const n=Y(e.doc,e.selection.anchor);return Z(n)}function H(e){return"doc"in e?e.doc.type.schema:e.type.schema}function fn(e){return e.cached.blockNoteEditor}function ke(e){return fn(e).schema}function Ge(e){return ke(e).blockSchema}function Ye(e){return ke(e).inlineContentSchema}function le(e){return ke(e).styleSchema}function Je(e){return fn(e).blockCache}function Bt(e,n,t){var s,i;const o={type:"tableContent",columnWidths:[],headerRows:void 0,headerCols:void 0,rows:[]},r=[];e.content.forEach((a,l,c)=>{const d={cells:[]};c===0&&a.content.forEach(u=>{let h=u.attrs.colwidth;h==null&&(h=new Array(u.attrs.colspan??1).fill(void 0)),o.columnWidths.push(...h)}),d.cells=a.content.content.map((u,h)=>(r[c]||(r[c]=[]),r[c][h]=u.type.name==="tableHeader",{type:"tableCell",content:u.content.content.map(m=>xe(m,n,t)).reduce((m,g)=>{if(!m.length)return g;const b=m[m.length-1],w=g[0];return w&&ne(b)&&ne(w)&&JSON.stringify(b.styles)===JSON.stringify(w.styles)?(b.text+=`
|
|
2
2
|
`+w.text,m.push(...g.slice(1)),m):(m.push(...g),m)},[]),props:{colspan:u.attrs.colspan,rowspan:u.attrs.rowspan,backgroundColor:u.attrs.backgroundColor,textColor:u.attrs.textColor,textAlignment:u.attrs.textAlignment}})),o.rows.push(d)});for(let a=0;a<r.length;a++)(s=r[a])!=null&&s.every(l=>l)&&(o.headerRows=(o.headerRows??0)+1);for(let a=0;a<((i=r[0])==null?void 0:i.length);a++)r!=null&&r.every(l=>l[a])&&(o.headerCols=(o.headerCols??0)+1);return o}function xe(e,n,t){const o=[];let r;return e.content.forEach(s=>{if(s.type.name==="hardBreak"){if(r)if(ne(r))r.text+=`
|
|
3
3
|
`;else if(it(r))r.content[r.content.length-1].text+=`
|
|
4
4
|
`;else throw new Error("unexpected");else r={type:"text",text:`
|
|
5
|
-
`,styles:{}};return}if(s.type.name!=="link"&&s.type.name!=="text"){if(!n[s.type.name]){console.warn("unrecognized inline content type",s.type.name);return}r&&(o.push(r),r=void 0),o.push(Ue(s,n,t));return}const i={};let a;for(const l of s.marks)if(l.type.name==="link")a=l;else{const c=t[l.type.name];if(!c){if(l.type.spec.blocknoteIgnore)continue;throw new Error(`style ${l.type.name} not found in styleSchema`)}if(c.propSchema==="boolean")i[c.type]=!0;else if(c.propSchema==="string")i[c.type]=l.attrs.stringValue;else throw new K(c.propSchema)}r?ne(r)?a?(o.push(r),r={type:"link",href:a.attrs.href,content:[{type:"text",text:s.textContent,styles:i}]}):JSON.stringify(r.styles)===JSON.stringify(i)?r.text+=s.textContent:(o.push(r),r={type:"text",text:s.textContent,styles:i}):it(r)&&(a?r.href===a.attrs.href?JSON.stringify(r.content[r.content.length-1].styles)===JSON.stringify(i)?r.content[r.content.length-1].text+=s.textContent:r.content.push({type:"text",text:s.textContent,styles:i}):(o.push(r),r={type:"link",href:a.attrs.href,content:[{type:"text",text:s.textContent,styles:i}]}):(o.push(r),r={type:"text",text:s.textContent,styles:i})):a?r={type:"link",href:a.attrs.href,content:[{type:"text",text:s.textContent,styles:i}]}:r={type:"text",text:s.textContent,styles:i}}),r&&o.push(r),o}function Ue(e,n,t){if(e.type.name==="text"||e.type.name==="link")throw new Error("unexpected");const o={},r=n[e.type.name];for(const[a,l]of Object.entries(e.attrs)){if(!r)throw Error("ic node is of an unrecognized type: "+e.type.name);const c=r.propSchema;a in c&&(o[a]=l)}let s;return r.content==="styled"?s=xe(e,n,t):s=void 0,{type:e.type.name,props:o,content:s}}function T(e,n,t=Ge(n),o=Ye(n),r=le(n),s=Je(n)){var g;if(!e.type.isInGroup("bnBlock"))throw Error("Node should be a bnBlock, but is instead: "+e.type.name);const i=s==null?void 0:s.get(e);if(i)return i;const a=je(e,0);let l=a.bnBlock.node.attrs.id;l===null&&(l=Be.options.generateID());const c=t[a.blockNoteType];if(!c)throw Error("Block is of an unrecognized type: "+a.blockNoteType);const d={};for(const[b,w]of Object.entries({...e.attrs,...a.isBlockContainer?a.blockContent.node.attrs:{}})){const C=c.propSchema;b in C&&!(C[b].default===void 0&&w===void 0)&&(d[b]=w)}const u=t[a.blockNoteType],h=[];(g=a.childContainer)==null||g.node.forEach(b=>{h.push(T(b,n,t,o,r,s))});let f;if(u.content==="inline"){if(!a.isBlockContainer)throw new Error("impossible");f=xe(a.blockContent.node,o,r)}else if(u.content==="table"){if(!a.isBlockContainer)throw new Error("impossible");f=Bt(a.blockContent.node,o,r)}else if(u.content==="none")f=void 0;else throw new K(u.content);const m={id:l,type:u.type,props:d,content:f,children:h};return s==null||s.set(e,m),m}function mn(e,n,t=Ge(n),o=Ye(n),r=le(n),s=Je(n)){const i=[];return e.firstChild.descendants(a=>(i.push(T(a,n,t,o,r,s)),!1)),i}function gn(e,n,t=Ge(n),o=Ye(n),r=le(n),s=Je(n)){function i(a,l,c){if(a.type.name!=="blockGroup")throw new Error("unexpected");const d=[];let u,h;return a.forEach((f,m,g)=>{if(f.type.name!=="blockContainer")throw new Error("unexpected");if(f.childCount===0)return;if(f.childCount===0||f.childCount>2)throw new Error("unexpected, blockContainer.childCount: "+f.childCount);const b=g===0,w=g===a.childCount-1;if(f.firstChild.type.name==="blockGroup"){if(!b)throw new Error("unexpected");const R=i(f.firstChild,Math.max(0,l-1),w?Math.max(0,c-1):0);u=R.blockCutAtStart,w&&(h=R.blockCutAtEnd),d.push(...R.blocks);return}const C=T(f,n,t,o,r,s),S=f.childCount>1?f.child(1):void 0;let P=[];if(S){const R=i(S,0,w?Math.max(0,c-1):0);P=R.blocks,w&&(h=R.blockCutAtEnd)}w&&!S&&c>1&&(h=C.id),b&&l>1&&(u=C.id),d.push({...C,children:P})}),{blocks:d,blockCutAtStart:u,blockCutAtEnd:h}}if(e.content.childCount===0)return{blocks:[],blockCutAtStart:void 0,blockCutAtEnd:void 0};if(e.content.childCount!==1)throw new Error("slice must be a single block, did you forget includeParents=true?");return i(e.content.firstChild,Math.max(e.openStart-1,0),Math.max(e.openEnd-1,0))}function lt(e,n,t,o){return e.dom.setAttribute("data-inline-content-type",n),Object.entries(t).filter(([r,s])=>{const i=o[r];return s!==i.default}).map(([r,s])=>[ve(r),s]).forEach(([r,s])=>e.dom.setAttribute(r,s)),e.contentDOM!==void 0&&e.contentDOM.setAttribute("data-editable",""),e}function bn(e){return{Backspace:({editor:n})=>{const t=n.state.selection.$from;return n.state.selection.empty&&t.node().type.name===e.type&&t.parentOffset===0}}}function kn(e,n){return{config:e,implementation:n}}function wn(e,n){return kn({type:e.name,propSchema:n,content:e.config.content==="inline*"?"styled":"none"},{node:e})}function Tt(e){return Object.fromEntries(Object.entries(e).map(([n,t])=>[n,t.config]))}function yn(e){return[{tag:`[data-inline-content-type="${e.type}"]`,contentElement:n=>{const t=n;return t.matches("[data-editable]")?t:t.querySelector("[data-editable]")||t}}]}function Gr(e,n){const t=k.Node.create({name:e.type,inline:!0,group:"inline",selectable:e.content==="styled",atom:e.content==="none",content:e.content==="styled"?"inline*":"",addAttributes(){return me(e.propSchema)},addKeyboardShortcuts(){return bn(e)},parseHTML(){return yn(e)},renderHTML({node:o}){const r=this.options.editor,s=n.render(Ue(o,r.schema.inlineContentSchema,r.schema.styleSchema),()=>{},r);return lt(s,e.type,o.attrs,e.propSchema)},addNodeView(){return({node:o,getPos:r})=>{const s=this.options.editor,i=n.render(Ue(o,s.schema.inlineContentSchema,s.schema.styleSchema),a=>{if(typeof r=="boolean")return;const l=$([a],s.pmSchema);s.transact(c=>c.replaceWith(r(),r()+o.nodeSize,l))},s);return lt(i,e.type,o.attrs,e.propSchema)}}});return wn(t,e.propSchema)}function Cn(e){return e==="boolean"?{}:{stringValue:{default:void 0,keepOnSplit:!0,parseHTML:n=>n.getAttribute("data-value"),renderHTML:n=>n.stringValue!==void 0?{"data-value":n.stringValue}:{}}}}function vn(e,n,t,o){return e.dom.setAttribute("data-style-type",n),o==="string"&&e.dom.setAttribute("data-value",t),e.contentDOM!==void 0&&e.contentDOM.setAttribute("data-editable",""),e}function xt(e,n){return{config:e,implementation:n}}function te(e,n){return xt({type:e.name,propSchema:n},{mark:e})}function Pt(e){return Object.fromEntries(Object.entries(e).map(([n,t])=>[n,t.config]))}function Sn(e){return[{tag:`[data-style-type="${e.type}"]`,contentElement:n=>{const t=n;return t.matches("[data-editable]")?t:t.querySelector("[data-editable]")||t}}]}function Yr(e,n){const t=k.Mark.create({name:e.type,addAttributes(){return Cn(e.propSchema)},parseHTML(){return Sn(e)},renderHTML({mark:o}){let r;if(e.propSchema==="boolean")r=n.render();else if(e.propSchema==="string")r=n.render(o.attrs.stringValue);else throw new K(e.propSchema);return vn(r,e.type,o.attrs.stringValue,e.propSchema)}});return xt(e,{mark:t})}function oe(e){const{height:n,width:t}=Mt(e),o=new Array(n).fill(!1).map(()=>new Array(t).fill(null)),r=(s,i)=>{for(let a=s;a<n;a++)for(let l=i;l<t;l++)if(!o[a][l])return{row:a,col:l};throw new Error("Unable to create occupancy grid for table, no more available cells")};for(let s=0;s<e.content.rows.length;s++)for(let i=0;i<e.content.rows[s].cells.length;i++){const a=_e(e.content.rows[s].cells[i]),l=Ve(a),c=fe(a),{row:d,col:u}=r(s,i);for(let h=d;h<d+l;h++)for(let f=u;f<u+c;f++){if(o[h][f])throw new Error(`Unable to create occupancy grid for table, cell at ${h},${f} is already occupied`);o[h][f]={row:s,col:i,rowspan:l,colspan:c,cell:a}}}return o}function Se(e){const n=new Set;return e.map(t=>({cells:t.map(o=>n.has(o.row+":"+o.col)?!1:(n.add(o.row+":"+o.col),o.cell)).filter(o=>o!==!1)}))}function ae(e,n,t=oe(n)){for(let o=0;o<t.length;o++)for(let r=0;r<t[o].length;r++){const s=t[o][r];if(s.row===e.row&&s.col===e.col)return{row:o,col:r,cell:s.cell}}throw new Error(`Unable to resolve relative table cell indices for table, cell at ${e.row},${e.col} is not occupied`)}function Mt(e){const n=e.content.rows.length;let t=0;return e.content.rows.forEach(o=>{let r=0;o.cells.forEach(s=>{r+=fe(s)}),t=Math.max(t,r)}),{height:n,width:t}}function En(e,n,t=oe(n)){var r;const o=(r=t[e.row])==null?void 0:r[e.col];if(o)return{row:o.row,col:o.col,cell:o.cell}}function ct(e,n){var s;const t=oe(e);if(n<0||n>=t.length)return[];let o=0;for(let i=0;i<n;i++){const a=(s=t[o])==null?void 0:s[0];if(!a)return[];o+=a.rowspan}const r=new Array(t[0].length).fill(!1).map((i,a)=>En({row:o,col:a},e,t)).filter(i=>i!==void 0);return r.filter((i,a)=>r.findIndex(l=>l.row===i.row&&l.col===i.col)===a)}function dt(e,n){var s;const t=oe(e);if(n<0||n>=t[0].length)return[];let o=0;for(let i=0;i<n;i++){const a=(s=t[0])==null?void 0:s[o];if(!a)return[];o+=a.colspan}const r=new Array(t.length).fill(!1).map((i,a)=>En({row:a,col:o},e,t)).filter(i=>i!==void 0);return r.filter((i,a)=>r.findIndex(l=>l.row===i.row&&l.col===i.col)===a)}function Jr(e,n,t,o=oe(e)){const{col:r}=ae({row:0,col:n},e,o),{col:s}=ae({row:0,col:t},e,o);return o.forEach(i=>{const[a]=i.splice(r,1);i.splice(s,0,a)}),Se(o)}function Xr(e,n,t,o=oe(e)){const{row:r}=ae({row:n,col:0},e,o),{row:s}=ae({row:t,col:0},e,o),[i]=o.splice(r,1);return o.splice(s,0,i),Se(o)}function ut(e){return e?he(e)?ut(e.content):typeof e=="string"?e.length===0:Array.isArray(e)?e.every(n=>typeof n=="string"?n.length===0:ne(n)?n.text.length===0:Ct(n)?typeof n.content=="string"?n.content.length===0:n.content.every(t=>t.text.length===0):!1):!1:!0}function Zr(e,n,t=oe(e)){if(n==="columns"){let s=0;for(let i=t[0].length-1;i>=0&&t.every(l=>ut(l[i].cell)&&l[i].colspan===1);i--)s++;for(let i=t.length-1;i>=0;i--){const a=Math.max(t[i].length-s,1);t[i]=t[i].slice(0,a)}return Se(t)}let o=0;for(let s=t.length-1;s>=0&&t[s].every(a=>ut(a.cell)&&a.rowspan===1);s--)o++;const r=Math.min(o,t.length-1);return t.splice(t.length-r,r),Se(t)}function Qr(e,n,t,o=oe(e)){const{width:r,height:s}=Mt(e);if(n==="columns")o.forEach((i,a)=>{if(t>=0)for(let l=0;l<t;l++)i.push({row:a,col:Math.max(...i.map(c=>c.col))+1,rowspan:1,colspan:1,cell:_e("")});else i.splice(r+t,-1*t)});else if(t>0)for(let i=0;i<t;i++){const a=new Array(r).fill(null).map((l,c)=>({row:s+i,col:c,rowspan:1,colspan:1,cell:_e("")}));o.push(a)}else t<0&&o.splice(s+t,-1*t);return Se(o)}function Bn(e,n,t){const o=ct(e,t);if(!o.some(l=>Ve(l.cell)>1))return!0;let s=t,i=t;return o.forEach(l=>{const c=Ve(l.cell);s=Math.max(s,l.row+c-1),i=Math.min(i,l.row)}),n<t?t===s:t===i}function Tn(e,n,t){const o=dt(e,t);if(!o.some(l=>fe(l.cell)>1))return!0;let s=t,i=t;return o.forEach(l=>{const c=fe(l.cell);s=Math.max(s,l.col+c-1),i=Math.min(i,l.col)}),n<t?t===s:t===i}function es(e,n,t){const o=ae(e,t),r=ae(n,t);return o.col===r.col}function Kt(e,n,t,o){const r=[];for(const[i,a]of Object.entries(e.styles||{})){const l=t[i];if(!l)throw new Error(`style ${i} not found in styleSchema`);if(l.propSchema==="boolean")r.push(n.mark(i));else if(l.propSchema==="string")r.push(n.mark(i,{stringValue:a}));else throw new K(l.propSchema)}return!o||!n.nodes[o].spec.code?e.text.split(/(\n)/g).filter(i=>i.length>0).map(i=>i===`
|
|
5
|
+
`,styles:{}};return}if(s.type.name!=="link"&&s.type.name!=="text"){if(!n[s.type.name]){console.warn("unrecognized inline content type",s.type.name);return}r&&(o.push(r),r=void 0),o.push(Ue(s,n,t));return}const i={};let a;for(const l of s.marks)if(l.type.name==="link")a=l;else{const c=t[l.type.name];if(!c){if(l.type.spec.blocknoteIgnore)continue;throw new Error(`style ${l.type.name} not found in styleSchema`)}if(c.propSchema==="boolean")i[c.type]=!0;else if(c.propSchema==="string")i[c.type]=l.attrs.stringValue;else throw new K(c.propSchema)}r?ne(r)?a?(o.push(r),r={type:"link",href:a.attrs.href,content:[{type:"text",text:s.textContent,styles:i}]}):JSON.stringify(r.styles)===JSON.stringify(i)?r.text+=s.textContent:(o.push(r),r={type:"text",text:s.textContent,styles:i}):it(r)&&(a?r.href===a.attrs.href?JSON.stringify(r.content[r.content.length-1].styles)===JSON.stringify(i)?r.content[r.content.length-1].text+=s.textContent:r.content.push({type:"text",text:s.textContent,styles:i}):(o.push(r),r={type:"link",href:a.attrs.href,content:[{type:"text",text:s.textContent,styles:i}]}):(o.push(r),r={type:"text",text:s.textContent,styles:i})):a?r={type:"link",href:a.attrs.href,content:[{type:"text",text:s.textContent,styles:i}]}:r={type:"text",text:s.textContent,styles:i}}),r&&o.push(r),o}function Ue(e,n,t){if(e.type.name==="text"||e.type.name==="link")throw new Error("unexpected");const o={},r=n[e.type.name];for(const[a,l]of Object.entries(e.attrs)){if(!r)throw Error("ic node is of an unrecognized type: "+e.type.name);const c=r.propSchema;a in c&&(o[a]=l)}let s;return r.content==="styled"?s=xe(e,n,t):s=void 0,{type:e.type.name,props:o,content:s}}function T(e,n,t=Ge(n),o=Ye(n),r=le(n),s=Je(n)){var g;if(!e.type.isInGroup("bnBlock"))throw Error("Node should be a bnBlock, but is instead: "+e.type.name);const i=s==null?void 0:s.get(e);if(i)return i;const a=je(e,0);let l=a.bnBlock.node.attrs.id;l===null&&(l=Be.options.generateID());const c=t[a.blockNoteType];if(!c)throw Error("Block is of an unrecognized type: "+a.blockNoteType);const d={};for(const[b,w]of Object.entries({...e.attrs,...a.isBlockContainer?a.blockContent.node.attrs:{}})){const C=c.propSchema;b in C&&!(C[b].default===void 0&&w===void 0)&&(d[b]=w)}const u=t[a.blockNoteType],h=[];(g=a.childContainer)==null||g.node.forEach(b=>{h.push(T(b,n,t,o,r,s))});let f;if(u.content==="inline"){if(!a.isBlockContainer)throw new Error("impossible");f=xe(a.blockContent.node,o,r)}else if(u.content==="table"){if(!a.isBlockContainer)throw new Error("impossible");f=Bt(a.blockContent.node,o,r)}else if(u.content==="none")f=void 0;else throw new K(u.content);const m={id:l,type:u.type,props:d,content:f,children:h};return s==null||s.set(e,m),m}function mn(e,n,t=Ge(n),o=Ye(n),r=le(n),s=Je(n)){const i=[];return e.firstChild.descendants(a=>(i.push(T(a,n,t,o,r,s)),!1)),i}function gn(e,n,t=Ge(n),o=Ye(n),r=le(n),s=Je(n)){function i(a,l,c){if(a.type.name!=="blockGroup")throw new Error("unexpected");const d=[];let u,h;return a.forEach((f,m,g)=>{if(f.type.name!=="blockContainer")throw new Error("unexpected");if(f.childCount===0)return;if(f.childCount===0||f.childCount>2)throw new Error("unexpected, blockContainer.childCount: "+f.childCount);const b=g===0,w=g===a.childCount-1;if(f.firstChild.type.name==="blockGroup"){if(!b)throw new Error("unexpected");const R=i(f.firstChild,Math.max(0,l-1),w?Math.max(0,c-1):0);u=R.blockCutAtStart,w&&(h=R.blockCutAtEnd),d.push(...R.blocks);return}const C=T(f,n,t,o,r,s),S=f.childCount>1?f.child(1):void 0;let P=[];if(S){const R=i(S,0,w?Math.max(0,c-1):0);P=R.blocks,w&&(h=R.blockCutAtEnd)}w&&!S&&c>1&&(h=C.id),b&&l>1&&(u=C.id),d.push({...C,children:P})}),{blocks:d,blockCutAtStart:u,blockCutAtEnd:h}}if(e.content.childCount===0)return{blocks:[],blockCutAtStart:void 0,blockCutAtEnd:void 0};if(e.content.childCount!==1)throw new Error("slice must be a single block, did you forget includeParents=true?");return i(e.content.firstChild,Math.max(e.openStart-1,0),Math.max(e.openEnd-1,0))}function lt(e,n,t,o){return e.dom.setAttribute("data-inline-content-type",n),Object.entries(t).filter(([r,s])=>{const i=o[r];return s!==i.default}).map(([r,s])=>[ve(r),s]).forEach(([r,s])=>e.dom.setAttribute(r,s)),e.contentDOM!==void 0&&e.contentDOM.setAttribute("data-editable",""),e}function bn(e){return{Backspace:({editor:n})=>{const t=n.state.selection.$from;return n.state.selection.empty&&t.node().type.name===e.type&&t.parentOffset===0}}}function kn(e,n){return{config:e,implementation:n}}function wn(e,n){return kn({type:e.name,propSchema:n,content:e.config.content==="inline*"?"styled":"none"},{node:e})}function Tt(e){return Object.fromEntries(Object.entries(e).map(([n,t])=>[n,t.config]))}function yn(e){return[{tag:`[data-inline-content-type="${e.type}"]`,contentElement:n=>{const t=n;return t.matches("[data-editable]")?t:t.querySelector("[data-editable]")||t}}]}function Gr(e,n){const t=k.Node.create({name:e.type,inline:!0,group:"inline",selectable:e.content==="styled",atom:e.content==="none",content:e.content==="styled"?"inline*":"",addAttributes(){return me(e.propSchema)},addKeyboardShortcuts(){return bn(e)},parseHTML(){return yn(e)},renderHTML({node:o}){const r=this.options.editor,s=n.render(Ue(o,r.schema.inlineContentSchema,r.schema.styleSchema),()=>{},r);return lt(s,e.type,o.attrs,e.propSchema)},addNodeView(){return({node:o,getPos:r})=>{const s=this.options.editor,i=n.render(Ue(o,s.schema.inlineContentSchema,s.schema.styleSchema),a=>{if(typeof r=="boolean")return;const l=$([a],s.pmSchema);s.transact(c=>c.replaceWith(r(),r()+o.nodeSize,l))},s);return lt(i,e.type,o.attrs,e.propSchema)}}});return wn(t,e.propSchema)}function Cn(e){return e==="boolean"?{}:{stringValue:{default:void 0,keepOnSplit:!0,parseHTML:n=>n.getAttribute("data-value"),renderHTML:n=>n.stringValue!==void 0?{"data-value":n.stringValue}:{}}}}function vn(e,n,t,o){return e.dom.setAttribute("data-style-type",n),o==="string"&&e.dom.setAttribute("data-value",t),e.contentDOM!==void 0&&e.contentDOM.setAttribute("data-editable",""),e}function xt(e,n){return{config:e,implementation:n}}function te(e,n){return xt({type:e.name,propSchema:n},{mark:e})}function Pt(e){return Object.fromEntries(Object.entries(e).map(([n,t])=>[n,t.config]))}function Sn(e){return[{tag:`[data-style-type="${e.type}"]`,contentElement:n=>{const t=n;return t.matches("[data-editable]")?t:t.querySelector("[data-editable]")||t}}]}function Yr(e,n){const t=k.Mark.create({name:e.type,addAttributes(){return Cn(e.propSchema)},parseHTML(){return Sn(e)},renderHTML({mark:o}){let r;if(e.propSchema==="boolean")r=n.render();else if(e.propSchema==="string")r=n.render(o.attrs.stringValue);else throw new K(e.propSchema);return vn(r,e.type,o.attrs.stringValue,e.propSchema)}});return xt(e,{mark:t})}function oe(e){const{height:n,width:t}=Mt(e),o=new Array(n).fill(!1).map(()=>new Array(t).fill(null)),r=(s,i)=>{for(let a=s;a<n;a++)for(let l=i;l<t;l++)if(!o[a][l])return{row:a,col:l};throw new Error("Unable to create occupancy grid for table, no more available cells")};for(let s=0;s<e.content.rows.length;s++)for(let i=0;i<e.content.rows[s].cells.length;i++){const a=Ve(e.content.rows[s].cells[i]),l=_e(a),c=fe(a),{row:d,col:u}=r(s,i);for(let h=d;h<d+l;h++)for(let f=u;f<u+c;f++){if(o[h][f])throw new Error(`Unable to create occupancy grid for table, cell at ${h},${f} is already occupied`);o[h][f]={row:s,col:i,rowspan:l,colspan:c,cell:a}}}return o}function Se(e){const n=new Set;return e.map(t=>({cells:t.map(o=>n.has(o.row+":"+o.col)?!1:(n.add(o.row+":"+o.col),o.cell)).filter(o=>o!==!1)}))}function ae(e,n,t=oe(n)){for(let o=0;o<t.length;o++)for(let r=0;r<t[o].length;r++){const s=t[o][r];if(s.row===e.row&&s.col===e.col)return{row:o,col:r,cell:s.cell}}throw new Error(`Unable to resolve relative table cell indices for table, cell at ${e.row},${e.col} is not occupied`)}function Mt(e){const n=e.content.rows.length;let t=0;return e.content.rows.forEach(o=>{let r=0;o.cells.forEach(s=>{r+=fe(s)}),t=Math.max(t,r)}),{height:n,width:t}}function En(e,n,t=oe(n)){var r;const o=(r=t[e.row])==null?void 0:r[e.col];if(o)return{row:o.row,col:o.col,cell:o.cell}}function ct(e,n){var s;const t=oe(e);if(n<0||n>=t.length)return[];let o=0;for(let i=0;i<n;i++){const a=(s=t[o])==null?void 0:s[0];if(!a)return[];o+=a.rowspan}const r=new Array(t[0].length).fill(!1).map((i,a)=>En({row:o,col:a},e,t)).filter(i=>i!==void 0);return r.filter((i,a)=>r.findIndex(l=>l.row===i.row&&l.col===i.col)===a)}function dt(e,n){var s;const t=oe(e);if(n<0||n>=t[0].length)return[];let o=0;for(let i=0;i<n;i++){const a=(s=t[0])==null?void 0:s[o];if(!a)return[];o+=a.colspan}const r=new Array(t.length).fill(!1).map((i,a)=>En({row:a,col:o},e,t)).filter(i=>i!==void 0);return r.filter((i,a)=>r.findIndex(l=>l.row===i.row&&l.col===i.col)===a)}function Jr(e,n,t,o=oe(e)){const{col:r}=ae({row:0,col:n},e,o),{col:s}=ae({row:0,col:t},e,o);return o.forEach(i=>{const[a]=i.splice(r,1);i.splice(s,0,a)}),Se(o)}function Xr(e,n,t,o=oe(e)){const{row:r}=ae({row:n,col:0},e,o),{row:s}=ae({row:t,col:0},e,o),[i]=o.splice(r,1);return o.splice(s,0,i),Se(o)}function ut(e){return e?he(e)?ut(e.content):typeof e=="string"?e.length===0:Array.isArray(e)?e.every(n=>typeof n=="string"?n.length===0:ne(n)?n.text.length===0:Ct(n)?typeof n.content=="string"?n.content.length===0:n.content.every(t=>t.text.length===0):!1):!1:!0}function Zr(e,n,t=oe(e)){if(n==="columns"){let s=0;for(let i=t[0].length-1;i>=0&&t.every(l=>ut(l[i].cell)&&l[i].colspan===1);i--)s++;for(let i=t.length-1;i>=0;i--){const a=Math.max(t[i].length-s,1);t[i]=t[i].slice(0,a)}return Se(t)}let o=0;for(let s=t.length-1;s>=0&&t[s].every(a=>ut(a.cell)&&a.rowspan===1);s--)o++;const r=Math.min(o,t.length-1);return t.splice(t.length-r,r),Se(t)}function Qr(e,n,t,o=oe(e)){const{width:r,height:s}=Mt(e);if(n==="columns")o.forEach((i,a)=>{if(t>=0)for(let l=0;l<t;l++)i.push({row:a,col:Math.max(...i.map(c=>c.col))+1,rowspan:1,colspan:1,cell:Ve("")});else i.splice(r+t,-1*t)});else if(t>0)for(let i=0;i<t;i++){const a=new Array(r).fill(null).map((l,c)=>({row:s+i,col:c,rowspan:1,colspan:1,cell:Ve("")}));o.push(a)}else t<0&&o.splice(s+t,-1*t);return Se(o)}function Bn(e,n,t){const o=ct(e,t);if(!o.some(l=>_e(l.cell)>1))return!0;let s=t,i=t;return o.forEach(l=>{const c=_e(l.cell);s=Math.max(s,l.row+c-1),i=Math.min(i,l.row)}),n<t?t===s:t===i}function Tn(e,n,t){const o=dt(e,t);if(!o.some(l=>fe(l.cell)>1))return!0;let s=t,i=t;return o.forEach(l=>{const c=fe(l.cell);s=Math.max(s,l.col+c-1),i=Math.min(i,l.col)}),n<t?t===s:t===i}function es(e,n,t){const o=ae(e,t),r=ae(n,t);return o.col===r.col}function Kt(e,n,t,o){const r=[];for(const[i,a]of Object.entries(e.styles||{})){const l=t[i];if(!l)throw new Error(`style ${i} not found in styleSchema`);if(l.propSchema==="boolean")a&&r.push(n.mark(i));else if(l.propSchema==="string")a&&r.push(n.mark(i,{stringValue:a}));else throw new K(l.propSchema)}return!o||!n.nodes[o].spec.code?e.text.split(/(\n)/g).filter(i=>i.length>0).map(i=>i===`
|
|
6
6
|
`?n.nodes.hardBreak.createChecked():n.text(i,r)):e.text.length>0?[n.text(e.text,r)]:[]}function ts(e,n,t){const o=n.marks.link.create({href:e.href});return pt(e.content,n,t).map(r=>{if(r.type.name==="text")return r.mark([...r.marks,o]);if(r.type.name==="hardBreak")return r;throw new Error("unexpected node type")})}function pt(e,n,t,o){const r=[];if(typeof e=="string")return r.push(...Kt({text:e,styles:{}},n,t,o)),r;for(const s of e)r.push(...Kt(s,n,t,o));return r}function $(e,n,t,o=le(n)){const r=[];for(const s of e)typeof s=="string"?r.push(...pt(s,n,o,t)):Ct(s)?r.push(...ts(s,n,o)):ne(s)?r.push(...pt([s],n,o,t)):r.push(xn(s,n,o));return r}function Pe(e,n,t=le(n)){const o=[],r=new Array(e.headerRows??0).fill(!0),s=new Array(e.headerCols??0).fill(!0),i=e.columnWidths??[];for(let a=0;a<e.rows.length;a++){const l=e.rows[a],c=[],d=r[a];for(let h=0;h<l.cells.length;h++){const f=l.cells[h],m=s[h],g=void 0;let b=null;const w=ae({row:a,col:h},{content:e});let C=i[w.col]?[i[w.col]]:null;if(f)if(typeof f=="string")b=n.text(f);else if(he(f)){f.content&&(b=$(f.content,n,"tableParagraph",t));const P=fe(f);P>1&&(C=new Array(P).fill(!1).map((R,z)=>i[w.col+z]??void 0))}else b=$(f,n,"tableParagraph",t);const S=n.nodes[m||d?"tableHeader":"tableCell"].createChecked({...he(f)?f.props:{},colwidth:C},n.nodes.tableParagraph.createChecked(g,b));c.push(S)}const u=n.nodes.tableRow.createChecked({},c);o.push(u)}return o}function xn(e,n,t){let o,r=e.type;if(r===void 0&&(r="paragraph"),!n.nodes[r])throw new Error(`node type ${r} not found in schema`);if(!e.content)o=n.nodes[r].createChecked(e.props);else if(typeof e.content=="string"){const s=$([e.content],n,r,t);o=n.nodes[r].createChecked(e.props,s)}else if(Array.isArray(e.content)){const s=$(e.content,n,r,t);o=n.nodes[r].createChecked(e.props,s)}else if(e.content.type==="tableContent"){const s=Pe(e.content,n,t);o=n.nodes[r].createChecked(e.props,s)}else throw new K(e.content.type);return o}function re(e,n,t=le(n)){let o=e.id;o===void 0&&(o=Be.options.generateID());const r=[];if(e.children)for(const i of e.children)r.push(re(i,n,t));if(!e.type||n.nodes[e.type].isInGroup("blockContent")){const i=xn(e,n,t),a=r.length>0?n.nodes.blockGroup.createChecked({},r):void 0;return n.nodes.blockContainer.createChecked({id:o,...e.props},a?[i,a]:i)}else{if(n.nodes[e.type].isInGroup("bnBlock"))return n.nodes[e.type].createChecked({id:o,...e.props},r);throw new Error(`block type ${e.type} doesn't match blockContent or bnBlock group`)}}function F(e,n){let t,o;if(n.firstChild.descendants((r,s)=>t?!1:!Fe(r)||r.attrs.id!==e?!0:(t=r,o=s+1,!1)),!(t===void 0||o===void 0))return{node:t,posBeforeNode:o}}function Fe(e){return e.type.isInGroup("bnBlock")}function ns(e,n){return e.id!==n.id||e.type!==n.type||JSON.stringify(e.props)!==JSON.stringify(n.props)||JSON.stringify(e.content)!==JSON.stringify(n.content)}function Pn(e,n=[]){let t={type:"local"};e.getMeta("paste")?t={type:"paste"}:e.getMeta("uiEvent")==="drop"?t={type:"drop"}:e.getMeta("history$")?t={type:e.getMeta("history$").redo?"redo":"undo"}:e.getMeta("y-sync$")&&(e.getMeta("y-sync$").isUndoRedoOperation?t={type:"undo-redo"}:t={type:"yjs-remote"});const o=H(e),r=k.combineTransactionSteps(e.before,[e,...n]),s=k.getChangedRanges(r),i=s.flatMap(u=>k.findChildrenInRange(r.before,u.oldRange,Fe)).map(({node:u})=>T(u,o)),a=s.flatMap(u=>k.findChildrenInRange(r.doc,u.newRange,Fe)).map(({node:u})=>T(u,o)),l=new Map(a.map(u=>[u.id,u])),c=new Map(i.map(u=>[u.id,u])),d=[];for(const[u,h]of l)c.has(u)||d.push({type:"insert",block:h,source:t,prevBlock:void 0});for(const[u,h]of c)l.has(u)||d.push({type:"delete",block:h,source:t,prevBlock:void 0});for(const[u,h]of l)if(c.has(u)){const f=c.get(u);ns(f,h)&&d.push({type:"update",block:h,prevBlock:f,source:t})}return d}function Mn(e,n,t,o="before"){const r=typeof t=="string"?t:t.id,s=H(e),i=n.map(d=>re(d,s)),a=F(r,e.doc);if(!a)throw new Error(`Block with ID ${r} not found`);let l=a.posBeforeNode;return o==="after"&&(l+=a.node.nodeSize),e.step(new pe.ReplaceStep(l,l,new E.Slice(E.Fragment.from(i),0,0))),i.map(d=>T(d,s))}function ht(e,n,t){const o=H(e),r=t.map(d=>re(d,o)),s=new Set(n.map(d=>typeof d=="string"?d:d.id)),i=[],a=typeof n[0]=="string"?n[0]:n[0].id;let l=0;if(e.doc.descendants((d,u)=>{if(s.size===0)return!1;if(!d.type.isInGroup("bnBlock")||!s.has(d.attrs.id))return!0;if(i.push(T(d,o)),s.delete(d.attrs.id),t.length>0&&d.attrs.id===a){const g=e.doc.nodeSize;e.insert(u,r);const b=e.doc.nodeSize;l+=g-b}const h=e.doc.nodeSize,f=e.doc.resolve(u-l);f.node().type.name==="blockGroup"&&f.node(f.depth-1).type.name!=="doc"&&f.node().childCount===1?e.delete(f.before(),f.after()):e.delete(u-l,u-l+d.nodeSize);const m=e.doc.nodeSize;return l+=h-m,!1}),s.size>0){const d=[...s].join(`
|
|
7
|
-
`);throw Error("Blocks with the following IDs could not be found in the editor: "+d)}return{insertedBlocks:r.map(d=>T(d,o)),removedBlocks:i}}const D=(e,n)=>({tr:t,dispatch:o})=>(o&&It(t,e,n),!0);function It(e,n,t,o,r){const s=be(e.doc.resolve(n)),i=H(e);if(o!==void 0&&r!==void 0&&o>r)throw new Error("Invalid replaceFromPos or replaceToPos");const a=i.nodes[s.blockNoteType],l=i.nodes[t.type||s.blockNoteType],c=l.isInGroup("bnBlock")?l:i.nodes.blockContainer;if(s.isBlockContainer&&l.isInGroup("blockContent")){const d=o!==void 0&&o>s.blockContent.beforePos&&o<s.blockContent.afterPos?o-s.blockContent.beforePos-1:void 0,u=r!==void 0&&r>s.blockContent.beforePos&&r<s.blockContent.afterPos?r-s.blockContent.beforePos-1:void 0;qt(t,e,s),os(t,e,a,l,s,d,u)}else if(!s.isBlockContainer&&l.isInGroup("bnBlock"))qt(t,e,s);else{const d=T(s.bnBlock.node,i);e.replaceWith(s.bnBlock.beforePos,s.bnBlock.afterPos,re({children:d.children,...t},i));return}e.setNodeMarkup(s.bnBlock.beforePos,c,{...s.bnBlock.node.attrs,...t.props})}function os(e,n,t,o,r,s,i){const a=H(n);let l="keep";if(e.content)if(typeof e.content=="string")l=$([e.content],a,o.name);else if(Array.isArray(e.content))l=$(e.content,a,o.name);else if(e.content.type==="tableContent")l=Pe(e.content,a);else throw new K(e.content.type);else t.spec.content===""||o.spec.content!==t.spec.content&&(l=[]);if(l==="keep")n.setNodeMarkup(r.blockContent.beforePos,o,{...r.blockContent.node.attrs,...e.props});else if(s!==void 0||i!==void 0){n.setNodeMarkup(r.blockContent.beforePos,o,{...r.blockContent.node.attrs,...e.props});const c=r.blockContent.beforePos+1+(s??0),d=r.blockContent.beforePos+1+(i??r.blockContent.node.content.size),u=n.doc.resolve(r.blockContent.beforePos).depth,h=n.doc.resolve(c).depth,f=n.doc.resolve(d).depth;n.replace(c,d,new E.Slice(E.Fragment.from(l),h-u-1,f-u-1))}else n.replaceWith(r.blockContent.beforePos,r.blockContent.afterPos,o.createChecked({...r.blockContent.node.attrs,...e.props},l))}function qt(e,n,t){const o=H(n);if(e.children!==void 0&&e.children.length>0){const r=e.children.map(s=>re(s,o));if(t.childContainer)n.step(new pe.ReplaceStep(t.childContainer.beforePos+1,t.childContainer.afterPos-1,new E.Slice(E.Fragment.from(r),0,0)));else{if(!t.isBlockContainer)throw new Error("impossible");n.insert(t.blockContent.afterPos,o.nodes.blockGroup.createChecked({},r))}}}function In(e,n,t,o,r){const s=typeof n=="string"?n:n.id,i=F(s,e.doc);if(!i)throw new Error(`Block with ID ${s} not found`);It(e,i.posBeforeNode,t,o,r);const a=e.doc.resolve(i.posBeforeNode+1).node(),l=H(e);return T(a,l)}function Ln(e){const n=Array.from(e.classList).filter(t=>!t.startsWith("bn-"))||[];n.length>0?e.className=n.join(" "):e.removeAttribute("class")}function An(e,n,t,o){let r;if(n)if(typeof n=="string")r=$([n],e.pmSchema);else if(Array.isArray(n))r=$(n,e.pmSchema);else if(n.type==="tableContent")r=Pe(n,e.pmSchema);else throw new K(n.type);else throw new Error("blockContent is required");const s=t.serializeFragment(E.Fragment.from(r),o);return s.nodeType===1&&Ln(s),s}function rs(e,n,t,o,r,s,i){var g,b,w,C,S,P,R,z;const a=(i==null?void 0:i.document)??document,l=n.pmSchema.nodes.blockContainer;let c=t.props;if(!t.props){c={};for(const[x,v]of Object.entries(n.schema.blockSchema[t.type].propSchema))v.default!==void 0&&(c[x]=v.default)}const d=(b=(g=l.spec)==null?void 0:g.toDOM)==null?void 0:b.call(g,l.create({id:t.id,...c})),u=Array.from(d.dom.attributes),h=n.blockImplementations[t.type].implementation.toExternalHTML({...t,props:c},n),f=a.createDocumentFragment();if(h.dom.classList.contains("bn-block-content")){const x=[...u,...Array.from(h.dom.attributes)].filter(v=>v.name.startsWith("data")&&v.name!=="data-content-type"&&v.name!=="data-file-block"&&v.name!=="data-node-view-wrapper"&&v.name!=="data-node-type"&&v.name!=="data-id"&&v.name!=="data-index"&&v.name!=="data-editable");for(const v of x)h.dom.firstChild.setAttribute(v.name,v.value);Ln(h.dom.firstChild),f.append(...Array.from(h.dom.childNodes))}else f.append(h.dom);if(h.contentDOM&&t.content){const x=An(n,t.content,o,i);h.contentDOM.appendChild(x)}let m;if(r.has(t.type)?m="OL":s.has(t.type)&&(m="UL"),m){if(((w=e.lastChild)==null?void 0:w.nodeName)!==m){const v=a.createElement(m);m==="OL"&&(c!=null&&c.start)&&(c==null?void 0:c.start)!==1&&v.setAttribute("start",c.start+""),e.append(v)}const x=a.createElement("li");x.append(f),e.lastChild.appendChild(x)}else e.append(f);if(t.children&&t.children.length>0){const x=a.createDocumentFragment();if(Nn(x,n,t.children,o,r,s,i),((C=e.lastChild)==null?void 0:C.nodeName)==="UL"||((S=e.lastChild)==null?void 0:S.nodeName)==="OL")for(;((P=x.firstChild)==null?void 0:P.nodeName)==="UL"||((R=x.firstChild)==null?void 0:R.nodeName)==="OL";)e.lastChild.lastChild.appendChild(x.firstChild);n.pmSchema.nodes[t.type].isInGroup("blockContent")?e.append(x):(z=h.contentDOM)==null||z.append(x)}}const Nn=(e,n,t,o,r,s,i)=>{for(const a of t)rs(e,n,a,o,r,s,i)},ss=(e,n,t,o,r,s)=>{const a=((s==null?void 0:s.document)??document).createDocumentFragment();return Nn(a,e,n,t,o,r,s),a},Me=(e,n)=>{const t=E.DOMSerializer.fromSchema(e);return{exportBlocks:(o,r)=>{const s=ss(n,o,t,new Set(["numberedListItem"]),new Set(["bulletListItem","checkListItem"]),r),i=document.createElement("div");return i.append(s),i.innerHTML},exportInlineContent:(o,r)=>{const s=An(n,o,t,r),i=document.createElement("div");return i.append(s.cloneNode(!0)),i.innerHTML}}};function is(e,n,t,o,r){let s;if(n)if(typeof n=="string")s=$([n],e.pmSchema,o);else if(Array.isArray(n))s=$(n,e.pmSchema,o);else if(n.type==="tableContent")s=Pe(n,e.pmSchema);else throw new K(n.type);else throw new Error("blockContent is required");return t.serializeFragment(E.Fragment.from(s),r)}function as(e,n,t,o,r){var u,h,f,m,g;const s=e.pmSchema.nodes.blockContainer;let i=n.props;if(!n.props){i={};for(const[b,w]of Object.entries(e.schema.blockSchema[n.type].propSchema))w.default!==void 0&&(i[b]=w.default)}const l=e.blockImplementations[n.type].implementation.toInternalHTML({...n,props:i},e);if(n.type==="numberedListItem"&&l.dom.setAttribute("data-index",o.toString()),l.contentDOM&&n.content){const b=is(e,n.content,t,n.type,r);l.contentDOM.appendChild(b)}if(e.pmSchema.nodes[n.type].isInGroup("bnBlock")){if(n.children&&n.children.length>0){const b=Hn(e,n.children,t,r);(u=l.contentDOM)==null||u.append(b)}return l.dom}const d=(f=(h=s.spec)==null?void 0:h.toDOM)==null?void 0:f.call(h,s.create({id:n.id,...i}));return(m=d.contentDOM)==null||m.appendChild(l.dom),n.children&&n.children.length>0&&((g=d.contentDOM)==null||g.appendChild(Dn(e,n.children,t,r))),d.dom}function Hn(e,n,t,o){const s=((o==null?void 0:o.document)??document).createDocumentFragment();let i=0;for(const a of n){a.type==="numberedListItem"?i++:i=0;const l=as(e,a,t,i,o);s.appendChild(l)}return s}const Dn=(e,n,t,o)=>{var a;const r=e.pmSchema.nodes.blockGroup,s=r.spec.toDOM(r.create({})),i=Hn(e,n,t,o);return(a=s.contentDOM)==null||a.appendChild(i),s.dom},On=(e,n)=>{const t=E.DOMSerializer.fromSchema(e);return{serializeBlocks:(o,r)=>Dn(n,o,t,r).outerHTML}},Ie=(e,n)=>{const t=e.querySelector(n);if(!t)return;const o=e.querySelector("figcaption"),r=(o==null?void 0:o.textContent)??void 0;return{targetElement:t,caption:r}},Rn=(e,n,t,o)=>{const r=document.createElement("div");r.className="bn-add-file-button";const s=document.createElement("div");s.className="bn-add-file-button-icon",o?s.appendChild(o):s.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z"></path></svg>',r.appendChild(s);const i=document.createElement("p");i.className="bn-add-file-button-text",i.innerHTML=t||n.dictionary.file_blocks.file.add_button_text,r.appendChild(i);const a=c=>{c.preventDefault()},l=()=>{n.transact(c=>c.setMeta(n.filePanel.plugins[0],{block:e}))};return r.addEventListener("mousedown",a,!0),r.addEventListener("click",l,!0),{dom:r,destroy:()=>{r.removeEventListener("mousedown",a,!0),r.removeEventListener("click",l,!0)}}},_n='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z"></path></svg>',Vn=e=>{const n=document.createElement("div");n.className="bn-file-name-with-icon";const t=document.createElement("div");t.className="bn-file-icon",t.innerHTML=_n,n.appendChild(t);const o=document.createElement("p");return o.className="bn-file-name",o.textContent=e.props.name,n.appendChild(o),{dom:n}},Xe=(e,n,t,o,r)=>{const s=document.createElement("div");if(s.className="bn-file-block-content-wrapper",e.props.url===""){const a=Rn(e,n,o,r);s.appendChild(a.dom);const l=n.onUploadStart(c=>{if(c===e.id){s.removeChild(a.dom);const d=document.createElement("div");d.className="bn-file-loading-preview",d.textContent="Loading...",s.appendChild(d)}});return{dom:s,destroy:()=>{l(),a.destroy()}}}const i={dom:s};if(e.props.showPreview===!1||!t){const a=Vn(e);s.appendChild(a.dom),i.destroy=()=>{var l;(l=a.destroy)==null||l.call(a)}}else s.appendChild(t.dom);if(e.props.caption){const a=document.createElement("p");a.className="bn-file-caption",a.textContent=e.props.caption,s.appendChild(a)}return i},Ze=(e,n)=>{const t=document.createElement("figure"),o=document.createElement("figcaption");return o.textContent=n,t.appendChild(e),t.appendChild(o),{dom:t}},Le=(e,n)=>{const t=document.createElement("div"),o=document.createElement("p");return o.textContent=n,t.appendChild(e),t.appendChild(o),{dom:t}},jt=e=>({url:e.src||void 0}),Un='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z"></path></svg>',Fn={backgroundColor:I.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0}},$n={type:"audio",propSchema:Fn,content:"none",isFileBlock:!0,fileBlockAccept:["audio/*"]},zn=(e,n)=>{const t=document.createElement("div");t.innerHTML=Un;const o=document.createElement("audio");return o.className="bn-audio",n.resolveFileUrl?n.resolveFileUrl(e.props.url).then(r=>{o.src=r}):o.src=e.props.url,o.controls=!0,o.contentEditable="false",o.draggable=!1,Xe(e,n,{dom:o},n.dictionary.file_blocks.audio.add_button_text,t.firstElementChild)},Wn=e=>{if(e.tagName==="AUDIO")return e.closest("figure")?void 0:jt(e);if(e.tagName==="FIGURE"){const n=Ie(e,"audio");if(!n)return;const{targetElement:t,caption:o}=n;return{...jt(t),caption:o}}},Kn=e=>{if(!e.props.url){const t=document.createElement("p");return t.textContent="Add audio",{dom:t}}let n;return e.props.showPreview?(n=document.createElement("audio"),n.src=e.props.url):(n=document.createElement("a"),n.href=e.props.url,n.textContent=e.props.name||e.props.url),e.props.caption?e.props.showPreview?Ze(n,e.props.caption):Le(n,e.props.caption):{dom:n}},qn=ge($n,{render:zn,parse:Wn,toExternalHTML:Kn}),ft=Symbol.for("blocknote.shikiParser"),Oe=Symbol.for("blocknote.shikiHighlighterPromise"),jn={language:{default:"text"}},ls=G({name:"codeBlock",content:"inline*",group:"blockContent",marks:"insertion deletion modification",code:!0,defining:!0,addOptions(){return{defaultLanguage:"text",indentLineWithTab:!0,supportedLanguages:{}}},addAttributes(){const e=this.options;return{language:{default:e.editor.settings.codeBlock.defaultLanguage,parseHTML:n=>{let t=n,o=null;(t==null?void 0:t.tagName)==="DIV"&&(t==null?void 0:t.dataset.contentType)==="codeBlock"&&(t=t.children[0]),(t==null?void 0:t.tagName)==="PRE"&&(t=t==null?void 0:t.children[0]);const r=t==null?void 0:t.getAttribute("data-language");if(r)o=r.toLowerCase();else{const i=[...(t==null?void 0:t.className.split(" "))||[]].filter(a=>a.startsWith("language-")).map(a=>a.replace("language-",""));i.length>0&&(o=i[0].toLowerCase())}return o?ot(e.editor.settings.codeBlock,o)??o:null},renderHTML:n=>n.language?{class:`language-${n.language}`,"data-language":n.language}:{}}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"pre",preserveWhitespace:"full"}]},renderHTML({HTMLAttributes:e}){var r,s;const n=document.createElement("pre"),{dom:t,contentDOM:o}=j(this.name,"code",((r=this.options.domAttributes)==null?void 0:r.blockContent)||{},{...((s=this.options.domAttributes)==null?void 0:s.inlineContent)||{},...e});return t.removeChild(o),t.appendChild(n),n.appendChild(o),{dom:t,contentDOM:o}},addNodeView(){const e=this.options;return({editor:n,node:t,getPos:o,HTMLAttributes:r})=>{var u,h;const s=document.createElement("pre"),i=document.createElement("select"),a=document.createElement("div"),{dom:l,contentDOM:c}=j(this.name,"code",{...((u=this.options.domAttributes)==null?void 0:u.blockContent)||{},...r},((h=this.options.domAttributes)==null?void 0:h.inlineContent)||{}),d=f=>{const m=f.target.value;n.commands.command(({tr:g})=>(g.setNodeAttribute(o(),"language",m),!0))};return Object.entries(e.editor.settings.codeBlock.supportedLanguages).forEach(([f,{name:m}])=>{const g=document.createElement("option");g.value=f,g.text=m,i.appendChild(g)}),a.contentEditable="false",i.value=t.attrs.language||e.editor.settings.codeBlock.defaultLanguage,l.removeChild(c),l.appendChild(a),l.appendChild(s),s.appendChild(c),a.appendChild(i),i.addEventListener("change",d),{dom:l,contentDOM:c,update:f=>f.type===this.type,destroy:()=>{i.removeEventListener("change",d)}}}},addProseMirrorPlugins(){const e=this.options,n=globalThis;let t,o,r=!1;const s=a=>{if(!e.editor.settings.codeBlock.createHighlighter)return process.env.NODE_ENV==="development"&&!r&&(console.log("For syntax highlighting of code blocks, you must provide a `codeBlock.createHighlighter` function"),r=!0),[];if(!t)return n[Oe]=n[Oe]||e.editor.settings.codeBlock.createHighlighter(),n[Oe].then(c=>{t=c});const l=ot(e.editor.settings.codeBlock,a.language);return!l||l==="text"||l==="none"||l==="plaintext"||l==="txt"?[]:t.getLoadedLanguages().includes(l)?(o||(o=n[ft]||Cr.createParser(t),n[ft]=o),o(a)):t.loadLanguage(l)};return[yr.createHighlightPlugin({parser:s,languageExtractor:a=>a.attrs.language,nodeTypes:[this.name]})]},addInputRules(){const e=this.options;return[new k.InputRule({find:/^```(.*?)\s$/,handler:({state:n,range:t,match:o})=>{const r=n.doc.resolve(t.from),s=o[1].trim(),i={language:ot(e.editor.settings.codeBlock,s)??s};if(!r.node(-1).canReplaceWith(r.index(-1),r.indexAfter(-1),this.type))return null;n.tr.delete(t.from,t.to).setBlockType(t.from,t.from,this.type,i).setSelection(y.TextSelection.create(n.tr.doc,t.from))}})]},addKeyboardShortcuts(){return{Delete:({editor:e})=>{const{selection:n}=e.state,{$from:t}=n;if(e.isActive(this.name)&&!t.parent.textContent&&k.isTextSelection(n)){const o=t.pos-t.parentOffset-2;return e.chain().setNodeSelection(o).deleteSelection().run(),!0}return!1},Tab:({editor:e})=>this.options.indentLineWithTab&&e.isActive(this.name)?(e.commands.insertContent(" "),!0):!1,Enter:({editor:e})=>{const{$from:n}=e.state.selection;if(!e.isActive(this.name))return!1;const t=n.parentOffset===n.parent.nodeSize-2,o=n.parent.textContent.endsWith(`
|
|
7
|
+
`);throw Error("Blocks with the following IDs could not be found in the editor: "+d)}return{insertedBlocks:r.map(d=>T(d,o)),removedBlocks:i}}const D=(e,n)=>({tr:t,dispatch:o})=>(o&&It(t,e,n),!0);function It(e,n,t,o,r){const s=be(e.doc.resolve(n)),i=H(e);if(o!==void 0&&r!==void 0&&o>r)throw new Error("Invalid replaceFromPos or replaceToPos");const a=i.nodes[s.blockNoteType],l=i.nodes[t.type||s.blockNoteType],c=l.isInGroup("bnBlock")?l:i.nodes.blockContainer;if(s.isBlockContainer&&l.isInGroup("blockContent")){const d=o!==void 0&&o>s.blockContent.beforePos&&o<s.blockContent.afterPos?o-s.blockContent.beforePos-1:void 0,u=r!==void 0&&r>s.blockContent.beforePos&&r<s.blockContent.afterPos?r-s.blockContent.beforePos-1:void 0;qt(t,e,s),os(t,e,a,l,s,d,u)}else if(!s.isBlockContainer&&l.isInGroup("bnBlock"))qt(t,e,s);else{const d=T(s.bnBlock.node,i);e.replaceWith(s.bnBlock.beforePos,s.bnBlock.afterPos,re({children:d.children,...t},i));return}e.setNodeMarkup(s.bnBlock.beforePos,c,{...s.bnBlock.node.attrs,...t.props})}function os(e,n,t,o,r,s,i){const a=H(n);let l="keep";if(e.content)if(typeof e.content=="string")l=$([e.content],a,o.name);else if(Array.isArray(e.content))l=$(e.content,a,o.name);else if(e.content.type==="tableContent")l=Pe(e.content,a);else throw new K(e.content.type);else t.spec.content===""||o.spec.content!==t.spec.content&&(l=[]);if(l==="keep")n.setNodeMarkup(r.blockContent.beforePos,o,{...r.blockContent.node.attrs,...e.props});else if(s!==void 0||i!==void 0){n.setNodeMarkup(r.blockContent.beforePos,o,{...r.blockContent.node.attrs,...e.props});const c=r.blockContent.beforePos+1+(s??0),d=r.blockContent.beforePos+1+(i??r.blockContent.node.content.size),u=n.doc.resolve(r.blockContent.beforePos).depth,h=n.doc.resolve(c).depth,f=n.doc.resolve(d).depth;n.replace(c,d,new E.Slice(E.Fragment.from(l),h-u-1,f-u-1))}else n.replaceWith(r.blockContent.beforePos,r.blockContent.afterPos,o.createChecked({...r.blockContent.node.attrs,...e.props},l))}function qt(e,n,t){const o=H(n);if(e.children!==void 0&&e.children.length>0){const r=e.children.map(s=>re(s,o));if(t.childContainer)n.step(new pe.ReplaceStep(t.childContainer.beforePos+1,t.childContainer.afterPos-1,new E.Slice(E.Fragment.from(r),0,0)));else{if(!t.isBlockContainer)throw new Error("impossible");n.insert(t.blockContent.afterPos,o.nodes.blockGroup.createChecked({},r))}}}function In(e,n,t,o,r){const s=typeof n=="string"?n:n.id,i=F(s,e.doc);if(!i)throw new Error(`Block with ID ${s} not found`);It(e,i.posBeforeNode,t,o,r);const a=e.doc.resolve(i.posBeforeNode+1).node(),l=H(e);return T(a,l)}function Ln(e){const n=Array.from(e.classList).filter(t=>!t.startsWith("bn-"))||[];n.length>0?e.className=n.join(" "):e.removeAttribute("class")}function An(e,n,t,o){let r;if(n)if(typeof n=="string")r=$([n],e.pmSchema);else if(Array.isArray(n))r=$(n,e.pmSchema);else if(n.type==="tableContent")r=Pe(n,e.pmSchema);else throw new K(n.type);else throw new Error("blockContent is required");const s=t.serializeFragment(E.Fragment.from(r),o);return s.nodeType===1&&Ln(s),s}function rs(e,n,t,o,r,s,i){var g,b,w,C,S,P,R,z;const a=(i==null?void 0:i.document)??document,l=n.pmSchema.nodes.blockContainer;let c=t.props;if(!t.props){c={};for(const[x,v]of Object.entries(n.schema.blockSchema[t.type].propSchema))v.default!==void 0&&(c[x]=v.default)}const d=(b=(g=l.spec)==null?void 0:g.toDOM)==null?void 0:b.call(g,l.create({id:t.id,...c})),u=Array.from(d.dom.attributes),h=n.blockImplementations[t.type].implementation.toExternalHTML({...t,props:c},n),f=a.createDocumentFragment();if(h.dom.classList.contains("bn-block-content")){const x=[...u,...Array.from(h.dom.attributes)].filter(v=>v.name.startsWith("data")&&v.name!=="data-content-type"&&v.name!=="data-file-block"&&v.name!=="data-node-view-wrapper"&&v.name!=="data-node-type"&&v.name!=="data-id"&&v.name!=="data-index"&&v.name!=="data-editable");for(const v of x)h.dom.firstChild.setAttribute(v.name,v.value);Ln(h.dom.firstChild),f.append(...Array.from(h.dom.childNodes))}else f.append(h.dom);if(h.contentDOM&&t.content){const x=An(n,t.content,o,i);h.contentDOM.appendChild(x)}let m;if(r.has(t.type)?m="OL":s.has(t.type)&&(m="UL"),m){if(((w=e.lastChild)==null?void 0:w.nodeName)!==m){const v=a.createElement(m);m==="OL"&&(c!=null&&c.start)&&(c==null?void 0:c.start)!==1&&v.setAttribute("start",c.start+""),e.append(v)}const x=a.createElement("li");x.append(f),e.lastChild.appendChild(x)}else e.append(f);if(t.children&&t.children.length>0){const x=a.createDocumentFragment();if(Nn(x,n,t.children,o,r,s,i),((C=e.lastChild)==null?void 0:C.nodeName)==="UL"||((S=e.lastChild)==null?void 0:S.nodeName)==="OL")for(;((P=x.firstChild)==null?void 0:P.nodeName)==="UL"||((R=x.firstChild)==null?void 0:R.nodeName)==="OL";)e.lastChild.lastChild.appendChild(x.firstChild);n.pmSchema.nodes[t.type].isInGroup("blockContent")?e.append(x):(z=h.contentDOM)==null||z.append(x)}}const Nn=(e,n,t,o,r,s,i)=>{for(const a of t)rs(e,n,a,o,r,s,i)},ss=(e,n,t,o,r,s)=>{const a=((s==null?void 0:s.document)??document).createDocumentFragment();return Nn(a,e,n,t,o,r,s),a},Me=(e,n)=>{const t=E.DOMSerializer.fromSchema(e);return{exportBlocks:(o,r)=>{const s=ss(n,o,t,new Set(["numberedListItem"]),new Set(["bulletListItem","checkListItem"]),r),i=document.createElement("div");return i.append(s),i.innerHTML},exportInlineContent:(o,r)=>{const s=An(n,o,t,r),i=document.createElement("div");return i.append(s.cloneNode(!0)),i.innerHTML}}};function is(e,n,t,o,r){let s;if(n)if(typeof n=="string")s=$([n],e.pmSchema,o);else if(Array.isArray(n))s=$(n,e.pmSchema,o);else if(n.type==="tableContent")s=Pe(n,e.pmSchema);else throw new K(n.type);else throw new Error("blockContent is required");return t.serializeFragment(E.Fragment.from(s),r)}function as(e,n,t,o,r){var u,h,f,m,g;const s=e.pmSchema.nodes.blockContainer;let i=n.props;if(!n.props){i={};for(const[b,w]of Object.entries(e.schema.blockSchema[n.type].propSchema))w.default!==void 0&&(i[b]=w.default)}const l=e.blockImplementations[n.type].implementation.toInternalHTML({...n,props:i},e);if(n.type==="numberedListItem"&&l.dom.setAttribute("data-index",o.toString()),l.contentDOM&&n.content){const b=is(e,n.content,t,n.type,r);l.contentDOM.appendChild(b)}if(e.pmSchema.nodes[n.type].isInGroup("bnBlock")){if(n.children&&n.children.length>0){const b=Hn(e,n.children,t,r);(u=l.contentDOM)==null||u.append(b)}return l.dom}const d=(f=(h=s.spec)==null?void 0:h.toDOM)==null?void 0:f.call(h,s.create({id:n.id,...i}));return(m=d.contentDOM)==null||m.appendChild(l.dom),n.children&&n.children.length>0&&((g=d.contentDOM)==null||g.appendChild(Dn(e,n.children,t,r))),d.dom}function Hn(e,n,t,o){const s=((o==null?void 0:o.document)??document).createDocumentFragment();let i=0;for(const a of n){a.type==="numberedListItem"?i++:i=0;const l=as(e,a,t,i,o);s.appendChild(l)}return s}const Dn=(e,n,t,o)=>{var a;const r=e.pmSchema.nodes.blockGroup,s=r.spec.toDOM(r.create({})),i=Hn(e,n,t,o);return(a=s.contentDOM)==null||a.appendChild(i),s.dom},On=(e,n)=>{const t=E.DOMSerializer.fromSchema(e);return{serializeBlocks:(o,r)=>Dn(n,o,t,r).outerHTML}},Ie=(e,n)=>{const t=e.querySelector(n);if(!t)return;const o=e.querySelector("figcaption"),r=(o==null?void 0:o.textContent)??void 0;return{targetElement:t,caption:r}},Rn=(e,n,t,o)=>{const r=document.createElement("div");r.className="bn-add-file-button";const s=document.createElement("div");s.className="bn-add-file-button-icon",o?s.appendChild(o):s.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z"></path></svg>',r.appendChild(s);const i=document.createElement("p");i.className="bn-add-file-button-text",i.innerHTML=t||n.dictionary.file_blocks.file.add_button_text,r.appendChild(i);const a=c=>{c.preventDefault()},l=()=>{n.transact(c=>c.setMeta(n.filePanel.plugins[0],{block:e}))};return r.addEventListener("mousedown",a,!0),r.addEventListener("click",l,!0),{dom:r,destroy:()=>{r.removeEventListener("mousedown",a,!0),r.removeEventListener("click",l,!0)}}},Vn='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z"></path></svg>',_n=e=>{const n=document.createElement("div");n.className="bn-file-name-with-icon";const t=document.createElement("div");t.className="bn-file-icon",t.innerHTML=Vn,n.appendChild(t);const o=document.createElement("p");return o.className="bn-file-name",o.textContent=e.props.name,n.appendChild(o),{dom:n}},Xe=(e,n,t,o,r)=>{const s=document.createElement("div");if(s.className="bn-file-block-content-wrapper",e.props.url===""){const a=Rn(e,n,o,r);s.appendChild(a.dom);const l=n.onUploadStart(c=>{if(c===e.id){s.removeChild(a.dom);const d=document.createElement("div");d.className="bn-file-loading-preview",d.textContent="Loading...",s.appendChild(d)}});return{dom:s,destroy:()=>{l(),a.destroy()}}}const i={dom:s};if(e.props.showPreview===!1||!t){const a=_n(e);s.appendChild(a.dom),i.destroy=()=>{var l;(l=a.destroy)==null||l.call(a)}}else s.appendChild(t.dom);if(e.props.caption){const a=document.createElement("p");a.className="bn-file-caption",a.textContent=e.props.caption,s.appendChild(a)}return i},Ze=(e,n)=>{const t=document.createElement("figure"),o=document.createElement("figcaption");return o.textContent=n,t.appendChild(e),t.appendChild(o),{dom:t}},Le=(e,n)=>{const t=document.createElement("div"),o=document.createElement("p");return o.textContent=n,t.appendChild(e),t.appendChild(o),{dom:t}},jt=e=>({url:e.src||void 0}),Un='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z"></path></svg>',Fn={backgroundColor:I.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0}},$n={type:"audio",propSchema:Fn,content:"none",isFileBlock:!0,fileBlockAccept:["audio/*"]},zn=(e,n)=>{const t=document.createElement("div");t.innerHTML=Un;const o=document.createElement("audio");return o.className="bn-audio",n.resolveFileUrl?n.resolveFileUrl(e.props.url).then(r=>{o.src=r}):o.src=e.props.url,o.controls=!0,o.contentEditable="false",o.draggable=!1,Xe(e,n,{dom:o},n.dictionary.file_blocks.audio.add_button_text,t.firstElementChild)},Wn=e=>{if(e.tagName==="AUDIO")return e.closest("figure")?void 0:jt(e);if(e.tagName==="FIGURE"){const n=Ie(e,"audio");if(!n)return;const{targetElement:t,caption:o}=n;return{...jt(t),caption:o}}},Kn=e=>{if(!e.props.url){const t=document.createElement("p");return t.textContent="Add audio",{dom:t}}let n;return e.props.showPreview?(n=document.createElement("audio"),n.src=e.props.url):(n=document.createElement("a"),n.href=e.props.url,n.textContent=e.props.name||e.props.url),e.props.caption?e.props.showPreview?Ze(n,e.props.caption):Le(n,e.props.caption):{dom:n}},qn=ge($n,{render:zn,parse:Wn,toExternalHTML:Kn}),ft=Symbol.for("blocknote.shikiParser"),Oe=Symbol.for("blocknote.shikiHighlighterPromise"),jn={language:{default:"text"}},ls=G({name:"codeBlock",content:"inline*",group:"blockContent",marks:"insertion deletion modification",code:!0,defining:!0,addOptions(){return{defaultLanguage:"text",indentLineWithTab:!0,supportedLanguages:{}}},addAttributes(){const e=this.options;return{language:{default:e.editor.settings.codeBlock.defaultLanguage,parseHTML:n=>{let t=n,o=null;(t==null?void 0:t.tagName)==="DIV"&&(t==null?void 0:t.dataset.contentType)==="codeBlock"&&(t=t.children[0]),(t==null?void 0:t.tagName)==="PRE"&&(t=t==null?void 0:t.children[0]);const r=t==null?void 0:t.getAttribute("data-language");if(r)o=r.toLowerCase();else{const i=[...(t==null?void 0:t.className.split(" "))||[]].filter(a=>a.startsWith("language-")).map(a=>a.replace("language-",""));i.length>0&&(o=i[0].toLowerCase())}return o?ot(e.editor.settings.codeBlock,o)??o:null},renderHTML:n=>n.language?{class:`language-${n.language}`,"data-language":n.language}:{}}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"pre",preserveWhitespace:"full"}]},renderHTML({HTMLAttributes:e}){var r,s;const n=document.createElement("pre"),{dom:t,contentDOM:o}=j(this.name,"code",((r=this.options.domAttributes)==null?void 0:r.blockContent)||{},{...((s=this.options.domAttributes)==null?void 0:s.inlineContent)||{},...e});return t.removeChild(o),t.appendChild(n),n.appendChild(o),{dom:t,contentDOM:o}},addNodeView(){const e=this.options;return({editor:n,node:t,getPos:o,HTMLAttributes:r})=>{var u,h;const s=document.createElement("pre"),i=document.createElement("select"),a=document.createElement("div"),{dom:l,contentDOM:c}=j(this.name,"code",{...((u=this.options.domAttributes)==null?void 0:u.blockContent)||{},...r},((h=this.options.domAttributes)==null?void 0:h.inlineContent)||{}),d=f=>{const m=f.target.value;n.commands.command(({tr:g})=>(g.setNodeAttribute(o(),"language",m),!0))};return Object.entries(e.editor.settings.codeBlock.supportedLanguages).forEach(([f,{name:m}])=>{const g=document.createElement("option");g.value=f,g.text=m,i.appendChild(g)}),a.contentEditable="false",i.value=t.attrs.language||e.editor.settings.codeBlock.defaultLanguage,l.removeChild(c),l.appendChild(a),l.appendChild(s),s.appendChild(c),a.appendChild(i),i.addEventListener("change",d),{dom:l,contentDOM:c,update:f=>f.type===this.type,destroy:()=>{i.removeEventListener("change",d)}}}},addProseMirrorPlugins(){const e=this.options,n=globalThis;let t,o,r=!1;const s=a=>{if(!e.editor.settings.codeBlock.createHighlighter)return process.env.NODE_ENV==="development"&&!r&&(console.log("For syntax highlighting of code blocks, you must provide a `codeBlock.createHighlighter` function"),r=!0),[];if(!t)return n[Oe]=n[Oe]||e.editor.settings.codeBlock.createHighlighter(),n[Oe].then(c=>{t=c});const l=ot(e.editor.settings.codeBlock,a.language);return!l||l==="text"||l==="none"||l==="plaintext"||l==="txt"?[]:t.getLoadedLanguages().includes(l)?(o||(o=n[ft]||Cr.createParser(t),n[ft]=o),o(a)):t.loadLanguage(l)};return[yr.createHighlightPlugin({parser:s,languageExtractor:a=>a.attrs.language,nodeTypes:[this.name]})]},addInputRules(){const e=this.options;return[new k.InputRule({find:/^```(.*?)\s$/,handler:({state:n,range:t,match:o})=>{const r=n.doc.resolve(t.from),s=o[1].trim(),i={language:ot(e.editor.settings.codeBlock,s)??s};if(!r.node(-1).canReplaceWith(r.index(-1),r.indexAfter(-1),this.type))return null;n.tr.delete(t.from,t.to).setBlockType(t.from,t.from,this.type,i).setSelection(y.TextSelection.create(n.tr.doc,t.from))}})]},addKeyboardShortcuts(){return{Delete:({editor:e})=>{const{selection:n}=e.state,{$from:t}=n;if(e.isActive(this.name)&&!t.parent.textContent&&k.isTextSelection(n)){const o=t.pos-t.parentOffset-2;return e.chain().setNodeSelection(o).deleteSelection().run(),!0}return!1},Tab:({editor:e})=>this.options.indentLineWithTab&&e.isActive(this.name)?(e.commands.insertContent(" "),!0):!1,Enter:({editor:e})=>{const{$from:n}=e.state.selection;if(!e.isActive(this.name))return!1;const t=n.parentOffset===n.parent.nodeSize-2,o=n.parent.textContent.endsWith(`
|
|
8
8
|
|
|
9
9
|
`);return!t||!o?(e.commands.insertContent(`
|
|
10
|
-
`),!0):e.chain().command(({tr:r})=>(r.delete(n.pos-2,n.pos),!0)).exitCode().run()},"Shift-Enter":({editor:e})=>{const{$from:n}=e.state.selection;return e.isActive(this.name)?(e.chain().insertContentAt(n.pos-n.parentOffset+n.parent.nodeSize,{type:"paragraph"}).run(),!0):!1}}}}),Gn=Q(ls,jn);function ot(e,n){var t;return(t=Object.entries(e.supportedLanguages).find(([o,{aliases:r}])=>(r==null?void 0:r.includes(n))||o===n))==null?void 0:t[0]}const cs=k.Mark.create({name:"backgroundColor",addAttributes(){return{stringValue:{default:void 0,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.stringValue})}}},parseHTML(){return[{tag:"span",getAttrs:e=>typeof e=="string"?!1:e.hasAttribute("data-background-color")?{stringValue:e.getAttribute("data-background-color")}:!1}]},renderHTML({HTMLAttributes:e}){return["span",e,0]}}),ds=te(cs,"string"),us=k.Mark.create({name:"textColor",addAttributes(){return{stringValue:{default:void 0,parseHTML:e=>e.getAttribute("data-text-color"),renderHTML:e=>({"data-text-color":e.stringValue})}}},parseHTML(){return[{tag:"span",getAttrs:e=>typeof e=="string"?!1:e.hasAttribute("data-text-color")?{stringValue:e.getAttribute("data-text-color")}:!1}]},renderHTML({HTMLAttributes:e}){return["span",e,0]}}),ps=te(us,"string"),mt=e=>({url:e.src||void 0}),Yn={backgroundColor:I.backgroundColor,name:{default:""},url:{default:""},caption:{default:""}},Jn={type:"file",propSchema:Yn,content:"none",isFileBlock:!0},Xn=(e,n)=>Xe(e,n),Zn=e=>{if(e.tagName==="EMBED")return e.closest("figure")?void 0:mt(e);if(e.tagName==="FIGURE"){const n=Ie(e,"embed");if(!n)return;const{targetElement:t,caption:o}=n;return{...mt(t),caption:o}}},Qn=e=>{if(!e.props.url){const t=document.createElement("p");return t.textContent="Add file",{dom:t}}const n=document.createElement("a");return n.href=e.props.url,n.textContent=e.props.name||e.props.url,e.props.caption?Le(n,e.props.caption):{dom:n}},eo=ge(Jn,{render:Xn,parse:Zn,toExternalHTML:Qn}),to={...I,level:{default:1,values:[1,2,3]}},hs=G({name:"heading",content:"inline*",group:"blockContent",addAttributes(){return me(to)},addInputRules(){return[...[1,2,3].map(e=>new k.InputRule({find:new RegExp(`^(#{${e}})\\s$`),handler:({state:n,chain:t,range:o})=>{const r=B(n);!r.isBlockContainer||r.blockContent.node.type.spec.content!=="inline*"||t().command(D(r.bnBlock.beforePos,{type:"heading",props:{level:e}})).deleteRange({from:o.from,to:o.to}).run()}}))]},addKeyboardShortcuts(){return{"Mod-Alt-1":()=>{const e=B(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(D(e.bnBlock.beforePos,{type:"heading",props:{level:1}}))},"Mod-Alt-2":()=>{const e=B(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(D(e.bnBlock.beforePos,{type:"heading",props:{level:2}}))},"Mod-Alt-3":()=>{const e=B(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(D(e.bnBlock.beforePos,{type:"heading",props:{level:3}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"h1",attrs:{level:1},node:"heading"},{tag:"h2",attrs:{level:2},node:"heading"},{tag:"h3",attrs:{level:3},node:"heading"}]},renderHTML({node:e,HTMLAttributes:n}){var t,o;return j(this.name,`h${e.attrs.level}`,{...((t=this.options.domAttributes)==null?void 0:t.blockContent)||{},...n},((o=this.options.domAttributes)==null?void 0:o.inlineContent)||{})}}),fs=Q(hs,to),Lt=(e,n,t,o,r,s)=>{const{dom:i,destroy:a}=Xe(e,n,t,r,s),l=i;e.props.url&&e.props.showPreview&&(e.props.previewWidth?l.style.width=`${e.props.previewWidth}px`:l.style.width="fit-content");const c=document.createElement("div");c.className="bn-resize-handle",c.style.left="4px";const d=document.createElement("div");d.className="bn-resize-handle",d.style.right="4px";let u,h=e.props.previewWidth;const f=S=>{var z,x;if(!u){!n.isEditable&&o.contains(c)&&o.contains(d)&&(o.removeChild(c),o.removeChild(d));return}let P;e.props.textAlignment==="center"?u.handleUsed==="left"?P=u.initialWidth+(u.initialClientX-S.clientX)*2:P=u.initialWidth+(S.clientX-u.initialClientX)*2:u.handleUsed==="left"?P=u.initialWidth+u.initialClientX-S.clientX:P=u.initialWidth+S.clientX-u.initialClientX,h=Math.min(Math.max(P,64),((x=(z=n.domElement)==null?void 0:z.firstElementChild)==null?void 0:x.clientWidth)||Number.MAX_VALUE),l.style.width=`${h}px`},m=S=>{(!S.target||!l.contains(S.target)||!n.isEditable)&&o.contains(c)&&o.contains(d)&&(o.removeChild(c),o.removeChild(d)),u&&(u=void 0,n.updateBlock(e,{props:{previewWidth:h}}))},g=()=>{n.isEditable&&(o.appendChild(c),o.appendChild(d))},b=S=>{S.relatedTarget===c||S.relatedTarget===d||u||n.isEditable&&o.contains(c)&&o.contains(d)&&(o.removeChild(c),o.removeChild(d))},w=S=>{S.preventDefault(),u={handleUsed:"left",initialWidth:l.clientWidth,initialClientX:S.clientX}},C=S=>{S.preventDefault(),u={handleUsed:"right",initialWidth:l.clientWidth,initialClientX:S.clientX}};return window.addEventListener("mousemove",f),window.addEventListener("mouseup",m),l.addEventListener("mouseenter",g),l.addEventListener("mouseleave",b),c.addEventListener("mousedown",w),d.addEventListener("mousedown",C),{dom:l,destroy:()=>{a==null||a(),window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",m),l.removeEventListener("mouseenter",g),l.removeEventListener("mouseleave",b),c.removeEventListener("mousedown",w),d.removeEventListener("mousedown",C)}}},Gt=e=>{const n=e.src||void 0,t=e.width||void 0;return{url:n,previewWidth:t}},no='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z"></path></svg>',oo={textAlignment:I.textAlignment,backgroundColor:I.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0},previewWidth:{default:void 0,type:"number"}},ro={type:"image",propSchema:oo,content:"none",isFileBlock:!0,fileBlockAccept:["image/*"]},so=(e,n)=>{const t=document.createElement("div");t.innerHTML=no;const o=document.createElement("div");o.className="bn-visual-media-wrapper";const r=document.createElement("img");return r.className="bn-visual-media",n.resolveFileUrl?n.resolveFileUrl(e.props.url).then(s=>{r.src=s}):r.src=e.props.url,r.alt=e.props.name||e.props.caption||"BlockNote image",r.contentEditable="false",r.draggable=!1,o.appendChild(r),Lt(e,n,{dom:o},o,n.dictionary.file_blocks.image.add_button_text,t.firstElementChild)},io=e=>{if(e.tagName==="IMG")return e.closest("figure")?void 0:Gt(e);if(e.tagName==="FIGURE"){const n=Ie(e,"img");if(!n)return;const{targetElement:t,caption:o}=n;return{...Gt(t),caption:o}}},ao=e=>{if(!e.props.url){const t=document.createElement("p");return t.textContent="Add image",{dom:t}}let n;return e.props.showPreview?(n=document.createElement("img"),n.src=e.props.url,n.alt=e.props.name||e.props.caption||"BlockNote image",e.props.previewWidth&&(n.width=e.props.previewWidth)):(n=document.createElement("a"),n.href=e.props.url,n.textContent=e.props.name||e.props.url),e.props.caption?e.props.showPreview?Ze(n,e.props.caption):Le(n,e.props.caption):{dom:n}},lo=ge(ro,{render:so,parse:io,toExternalHTML:ao});function At(e,n,t){var u,h,f;const o=E.DOMParser.fromSchema(n),r=e,s=document.createElement("div");s.setAttribute("data-node-type","blockGroup");for(const m of Array.from(r.childNodes))s.appendChild(m.cloneNode(!0));let i=o.parse(s,{topNode:n.nodes.blockGroup.create()});((h=(u=i.firstChild)==null?void 0:u.firstChild)==null?void 0:h.type.name)==="checkListItem"&&(i=i.copy(i.content.cut(i.firstChild.firstChild.nodeSize+2)));const a=(f=i.firstChild)==null?void 0:f.firstChild;if(!(a!=null&&a.isTextblock))return E.Fragment.from(i);const l=n.nodes[t].create({},a.content),c=i.content.cut(a.nodeSize+2);if(c.size>0){const m=i.copy(c);return l.content.addToEnd(m)}return l.content}const co=(e,n,t)=>({state:o,dispatch:r})=>{const s=Y(o.doc,e),i=Z(s);if(!i.isBlockContainer)throw new Error(`BlockContainer expected when calling splitBlock, position ${e}`);const a=[{type:i.bnBlock.node.type,attrs:t?{...i.bnBlock.node.attrs,id:void 0}:{}},{type:n?i.blockContent.node.type:o.schema.nodes.paragraph,attrs:t?{...i.blockContent.node.attrs}:{}}];return r&&o.tr.split(e,2,a),!0},Nt=e=>{const{blockInfo:n,selectionEmpty:t}=e.transact(s=>({blockInfo:Te(s),selectionEmpty:s.selection.anchor===s.selection.head}));if(!n.isBlockContainer)return!1;const{bnBlock:o,blockContent:r}=n;return!(r.node.type.name==="bulletListItem"||r.node.type.name==="numberedListItem"||r.node.type.name==="checkListItem")||!t?!1:e._tiptapEditor.commands.first(({state:s,chain:i,commands:a})=>[()=>a.command(()=>r.node.childCount===0?a.command(D(o.beforePos,{type:"paragraph",props:{}})):!1),()=>a.command(()=>r.node.childCount>0?(i().deleteSelection().command(co(s.selection.from,!0)).run(),!0):!1)])},ms={...I},gs=G({name:"bulletListItem",content:"inline*",group:"blockContent",priority:90,addInputRules(){return[new k.InputRule({find:new RegExp("^[-+*]\\s$"),handler:({state:e,chain:n,range:t})=>{const o=B(e);!o.isBlockContainer||o.blockContent.node.type.spec.content!=="inline*"||n().command(D(o.bnBlock.beforePos,{type:"bulletListItem",props:{}})).deleteRange({from:t.from,to:t.to})}})]},addKeyboardShortcuts(){return{Enter:()=>Nt(this.options.editor),"Mod-Shift-8":()=>{const e=B(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(D(e.bnBlock.beforePos,{type:"bulletListItem",props:{}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"li",getAttrs:e=>{var t;if(typeof e=="string")return!1;const n=e.parentElement;return n===null?!1:n.tagName==="UL"||n.tagName==="DIV"&&((t=n.parentElement)==null?void 0:t.tagName)==="UL"?{}:!1},getContent:(e,n)=>At(e,n,this.name),node:"bulletListItem"}]},renderHTML({HTMLAttributes:e}){var n,t;return j(this.name,"p",{...((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},...e},((t=this.options.domAttributes)==null?void 0:t.inlineContent)||{})}}),bs=Q(gs,ms),uo={...I,checked:{default:!1}},ks=G({name:"checkListItem",content:"inline*",group:"blockContent",addAttributes(){return me(uo)},addInputRules(){return[new k.InputRule({find:new RegExp("\\[\\s*\\]\\s$"),handler:({state:e,chain:n,range:t})=>{const o=B(e);!o.isBlockContainer||o.blockContent.node.type.spec.content!=="inline*"||n().command(D(o.bnBlock.beforePos,{type:"checkListItem",props:{checked:!1}})).deleteRange({from:t.from,to:t.to})}}),new k.InputRule({find:new RegExp("\\[[Xx]\\]\\s$"),handler:({state:e,chain:n,range:t})=>{const o=B(e);!o.isBlockContainer||o.blockContent.node.type.spec.content!=="inline*"||n().command(D(o.bnBlock.beforePos,{type:"checkListItem",props:{checked:!0}})).deleteRange({from:t.from,to:t.to})}})]},addKeyboardShortcuts(){return{Enter:()=>Nt(this.options.editor),"Mod-Shift-9":()=>{const e=B(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(D(e.bnBlock.beforePos,{type:"checkListItem",props:{}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"input",getAttrs:e=>typeof e=="string"||e.closest("[data-content-type]")||e.closest("li")?!1:e.type==="checkbox"?{checked:e.checked}:!1,node:"checkListItem"},{tag:"li",getAttrs:e=>{var t;if(typeof e=="string")return!1;const n=e.parentElement;if(n===null)return!1;if(n.tagName==="UL"||n.tagName==="DIV"&&((t=n.parentElement)==null?void 0:t.tagName)==="UL"){const o=e.querySelector("input[type=checkbox]")||null;return o===null?!1:{checked:o.checked}}return!1},getContent:(e,n)=>At(e,n,this.name),node:"checkListItem"}]},renderHTML({node:e,HTMLAttributes:n}){var s,i;const t=document.createElement("input");t.type="checkbox",t.checked=e.attrs.checked,e.attrs.checked&&t.setAttribute("checked","");const{dom:o,contentDOM:r}=j(this.name,"p",{...((s=this.options.domAttributes)==null?void 0:s.blockContent)||{},...n},((i=this.options.domAttributes)==null?void 0:i.inlineContent)||{});return o.insertBefore(t,r),{dom:o,contentDOM:r}},addNodeView(){return({node:e,getPos:n,editor:t,HTMLAttributes:o})=>{var d,u;const r=document.createElement("div"),s=document.createElement("div");s.contentEditable="false";const i=document.createElement("input");i.type="checkbox",i.checked=e.attrs.checked,e.attrs.checked&&i.setAttribute("checked","");const a=()=>{if(!t.isEditable){i.checked=!i.checked;return}if(typeof n!="boolean"){const h=Y(t.state.doc,n());if(h.node.type.name!=="blockContainer")throw new Error(`Expected blockContainer node, got ${h.node.type.name}`);this.editor.commands.command(D(h.posBeforeNode,{type:"checkListItem",props:{checked:i.checked}}))}};i.addEventListener("change",a);const{dom:l,contentDOM:c}=j(this.name,"p",{...((d=this.options.domAttributes)==null?void 0:d.blockContent)||{},...o},((u=this.options.domAttributes)==null?void 0:u.inlineContent)||{});if(typeof n!="boolean"){const f="label-"+this.editor.state.doc.resolve(n()).node().attrs.id;i.setAttribute("aria-labelledby",f),c.id=f}return l.removeChild(c),l.appendChild(r),r.appendChild(s),r.appendChild(c),s.appendChild(i),{dom:l,contentDOM:c,destroy:()=>{i.removeEventListener("change",a)}}}}}),ws=Q(ks,uo),ys=new y.PluginKey("numbered-list-indexing"),Cs=()=>new y.Plugin({key:ys,appendTransaction:(e,n,t)=>{const o=t.tr;o.setMeta("numberedListIndexing",!0);let r=!1;return t.doc.descendants((s,i)=>{var a;if(s.type.name==="blockContainer"&&s.firstChild.type.name==="numberedListItem"){let l=`${s.firstChild.attrs.start||1}`;const c=Z({posBeforeNode:i,node:s});if(!c.isBlockContainer)throw new Error("impossible");const d=o.doc.resolve(c.bnBlock.beforePos).nodeBefore;if(d){const m=Z({posBeforeNode:c.bnBlock.beforePos-d.nodeSize,node:d});if(m.blockNoteType==="numberedListItem"){if(!m.isBlockContainer)throw new Error("impossible");const b=m.blockContent.node.attrs.index;l=(parseInt(b)+1).toString()}}const u=c.blockContent.node,h=u.attrs.index,f=((a=d==null?void 0:d.firstChild)==null?void 0:a.type.name)!=="numberedListItem";if(h!==l||u.attrs.start&&!f){r=!0;const{start:m,...g}=u.attrs;o.setNodeMarkup(c.blockContent.beforePos,void 0,{...g,index:l,...typeof m=="number"&&f&&{start:m}})}}}),r?o:null}}),po={...I,start:{default:void 0,type:"number"}},vs=G({name:"numberedListItem",content:"inline*",group:"blockContent",priority:90,addAttributes(){return{...me(po),index:{default:null,parseHTML:e=>e.getAttribute("data-index"),renderHTML:e=>({"data-index":e.index})}}},addInputRules(){return[new k.InputRule({find:new RegExp("^(\\d+)\\.\\s$"),handler:({state:e,chain:n,range:t,match:o})=>{const r=B(e);if(!r.isBlockContainer||r.blockContent.node.type.spec.content!=="inline*"||r.blockNoteType==="numberedListItem")return;const s=parseInt(o[1]);n().command(D(r.bnBlock.beforePos,{type:"numberedListItem",props:s===1&&{}||{start:s}})).deleteRange({from:t.from,to:t.to})}})]},addKeyboardShortcuts(){return{Enter:()=>Nt(this.options.editor),"Mod-Shift-7":()=>{const e=B(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(D(e.bnBlock.beforePos,{type:"numberedListItem",props:{}}))}}},addProseMirrorPlugins(){return[Cs()]},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"li",getAttrs:e=>{var t;if(typeof e=="string")return!1;const n=e.parentElement;if(n===null)return!1;if(n.tagName==="OL"||n.tagName==="DIV"&&((t=n.parentElement)==null?void 0:t.tagName)==="OL"){const o=parseInt(n.getAttribute("start")||"1")||1;return e.previousSibling||o===1?{}:{start:o}}return!1},getContent:(e,n)=>At(e,n,this.name),priority:300,node:"numberedListItem"}]},renderHTML({HTMLAttributes:e}){var n,t;return j(this.name,"p",{...((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},...e},((t=this.options.domAttributes)==null?void 0:t.inlineContent)||{})}}),Ss=Q(vs,po),Es={...I},Bs=G({name:"paragraph",content:"inline*",group:"blockContent",addKeyboardShortcuts(){return{"Mod-Alt-0":()=>{const e=B(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(D(e.bnBlock.beforePos,{type:"paragraph",props:{}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"p",getAttrs:e=>{var n;return typeof e=="string"||!((n=e.textContent)!=null&&n.trim())?!1:{}},node:"paragraph"}]},renderHTML({HTMLAttributes:e}){var n,t;return j(this.name,"p",{...((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},...e},((t=this.options.domAttributes)==null?void 0:t.inlineContent)||{})}}),Ts=Q(Bs,Es),xs={...I},Ps=G({name:"quote",content:"inline*",group:"blockContent",addInputRules(){return[new k.InputRule({find:new RegExp("^>\\s$"),handler:({state:e,chain:n,range:t})=>{const o=B(e);!o.isBlockContainer||o.blockContent.node.type.spec.content!=="inline*"||n().command(D(o.bnBlock.beforePos,{type:"quote",props:{}})).deleteRange({from:t.from,to:t.to})}})]},addKeyboardShortcuts(){return{"Mod-Alt-q":()=>{const e=B(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(D(e.bnBlock.beforePos,{type:"quote"}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"blockquote",node:"quote"}]},renderHTML({HTMLAttributes:e}){var n,t;return j(this.name,"blockquote",{...((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},...e},((t=this.options.domAttributes)==null?void 0:t.inlineContent)||{})}}),Ms=Q(Ps,xs),Is=35,Ht=120,Ls=31,As=k.Extension.create({name:"BlockNoteTableExtension",addProseMirrorPlugins:()=>[A.columnResizing({cellMinWidth:Is,defaultCellMinWidth:Ht,View:null}),A.tableEditing()],addKeyboardShortcuts(){return{Enter:()=>this.editor.state.selection.empty&&this.editor.state.selection.$head.parent.type.name==="tableParagraph"?(this.editor.commands.insertContent({type:"hardBreak"}),!0):!1,Backspace:()=>{const e=this.editor.state.selection,n=e.empty,t=e.$head.parentOffset===0,o=e.$head.node().type.name==="tableParagraph";return n&&t&&o},Tab:()=>this.editor.commands.command(({state:e,dispatch:n,view:t})=>A.goToNextCell(1)(e,n,t)),"Shift-Tab":()=>this.editor.commands.command(({state:e,dispatch:n,view:t})=>A.goToNextCell(-1)(e,n,t))}},extendNodeSchema(e){const n={name:e.name,options:e.options,storage:e.storage};return{tableRole:k.callOrReturn(k.getExtensionField(e,"tableRole",n))}}}),Ns={textColor:I.textColor},Hs=G({name:"table",content:"tableRow+",group:"blockContent",tableRole:"table",marks:"deletion insertion modification",isolating:!0,parseHTML(){return[{tag:"table"}]},renderHTML({HTMLAttributes:e}){var n,t;return j(this.name,"table",{...((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},...e},((t=this.options.domAttributes)==null?void 0:t.inlineContent)||{})},addNodeView(){return({node:e,HTMLAttributes:n})=>{var o;class t extends A.TableView{constructor(s,i,a){super(s,i),this.node=s,this.cellMinWidth=i,this.blockContentHTMLAttributes=a;const l=document.createElement("div");l.className=X("bn-block-content",a.class),l.setAttribute("data-content-type","table");for(const[h,f]of Object.entries(a))h!=="class"&&l.setAttribute(h,f);const c=this.dom,d=document.createElement("div");d.className="tableWrapper-inner",d.appendChild(c.firstChild),c.appendChild(d),l.appendChild(c);const u=document.createElement("div");u.className="table-widgets-container",u.style.position="relative",c.appendChild(u),this.dom=l}ignoreMutation(s){return!s.target.closest(".tableWrapper-inner")||super.ignoreMutation(s)}}return new t(e,Ht,{...((o=this.options.domAttributes)==null?void 0:o.blockContent)||{},...n})}}}),Ds=G({name:"tableParagraph",group:"tableContent",content:"inline*",parseHTML(){return[{tag:"p",getAttrs:e=>{if(typeof e=="string"||!e.textContent||!e.closest("[data-content-type]"))return!1;const n=e.parentElement;return n===null?!1:n.tagName==="TD"||n.tagName==="TH"?{}:!1},node:"tableParagraph"}]},renderHTML({HTMLAttributes:e}){return["p",e,0]}}),Os=k.Node.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)+",tableRole:"row",marks:"deletion insertion modification",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:e}){return["tr",k.mergeAttributes(this.options.HTMLAttributes,e),0]}});function Yt(e,n){const o=E.DOMParser.fromSchema(n).parse(e,{topNode:n.nodes.blockGroup.create()}),r=[];return o.content.descendants(s=>{if(s.isInline)return r.push(s),!1}),E.Fragment.fromArray(r)}const Rs=Q(Hs,Ns,[As,Ds,Pr.TableHeader.extend({content:"tableContent+",parseHTML(){return[{tag:"th",getContent:(e,n)=>Yt(e,n)}]}}),xr.TableCell.extend({content:"tableContent+",parseHTML(){return[{tag:"td",getContent:(e,n)=>Yt(e,n)}]}}),Os]),Jt=e=>{const n=e.src||void 0,t=e.width||void 0;return{url:n,previewWidth:t}},ho='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z"></path></svg>',fo={textAlignment:I.textAlignment,backgroundColor:I.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0},previewWidth:{default:void 0,type:"number"}},mo={type:"video",propSchema:fo,content:"none",isFileBlock:!0,fileBlockAccept:["video/*"]},go=(e,n)=>{const t=document.createElement("div");t.innerHTML=ho;const o=document.createElement("div");o.className="bn-visual-media-wrapper";const r=document.createElement("video");return r.className="bn-visual-media",n.resolveFileUrl?n.resolveFileUrl(e.props.url).then(s=>{r.src=s}):r.src=e.props.url,r.controls=!0,r.contentEditable="false",r.draggable=!1,r.width=e.props.previewWidth,o.appendChild(r),Lt(e,n,{dom:o},o,n.dictionary.file_blocks.video.add_button_text,t.firstElementChild)},bo=e=>{if(e.tagName==="VIDEO")return e.closest("figure")?void 0:Jt(e);if(e.tagName==="FIGURE"){const n=Ie(e,"video");if(!n)return;const{targetElement:t,caption:o}=n;return{...Jt(t),caption:o}}},ko=e=>{if(!e.props.url){const t=document.createElement("p");return t.textContent="Add video",{dom:t}}let n;return e.props.showPreview?(n=document.createElement("video"),n.src=e.props.url,e.props.previewWidth&&(n.width=e.props.previewWidth)):(n=document.createElement("a"),n.href=e.props.url,n.textContent=e.props.name||e.props.url),e.props.caption?e.props.showPreview?Ze(n,e.props.caption):Le(n,e.props.caption):{dom:n}},wo=ge(mo,{render:go,parse:bo,toExternalHTML:ko}),Dt={paragraph:Ts,heading:fs,quote:Ms,codeBlock:Gn,bulletListItem:bs,numberedListItem:Ss,checkListItem:ws,table:Rs,file:eo,image:lo,video:wo,audio:qn},yo=Et(Dt),Ot={bold:te(Rr.default,"boolean"),italic:te(Vr.default,"boolean"),underline:te(Fr.default,"boolean"),strike:te(Ur.default,"boolean"),code:te(_r.default,"boolean"),textColor:ps,backgroundColor:ds},_s=Pt(Ot),Rt={text:{config:"text",implementation:{}},link:{config:"link",implementation:{}}},Co=Tt(Rt);function V(e,n){return e in n.schema.blockSchema&&n.schema.blockSchema[e]===yo[e]}function vo(e,n){return e in n.schema.inlineContentSchema&&n.schema.inlineContentSchema[e]===Co[e]}function So(e,n,t){return n.type===e&&n.type in t.schema.blockSchema&&V(n.type,t)}function Vs(e,n){return e.type in n.schema.blockSchema&&n.schema.blockSchema[e.type].isFileBlock||!1}function Us(e,n){return e.type in n.schema.blockSchema&&n.schema.blockSchema[e.type].isFileBlock&&"showPreview"in n.schema.blockSchema[e.type].propSchema||!1}function Fs(e,n){return n.schema.blockSchema[e.type].isFileBlock&&!e.props.url}function Eo(e,n,t){return n in t.schema.blockSchema&&e in t.schema.blockSchema[n].propSchema&&t.schema.blockSchema[n].propSchema[e]===I[e]}function $s(e,n,t){return Eo(e,n.type,t)}function gt(e){return e instanceof A.CellSelection}const zs=async e=>{const n=new FormData;return n.append("file",e),(await(await fetch("https://tmpfiles.org/api/v1/upload",{method:"POST",body:n})).json()).data.url.replace("tmpfiles.org/","tmpfiles.org/dl/")};function Ws(e){let n=e.getTextCursorPosition().block,t=e.schema.blockSchema[n.type].content;for(;t==="none";){if(n=e.getTextCursorPosition().nextBlock,n===void 0)return;t=e.schema.blockSchema[n.type].content,e.setTextCursorPosition(n,"end")}}function _(e,n){const t=e.getTextCursorPosition().block;if(t.content===void 0)throw new Error("Slash Menu open in a block that doesn't contain content.");let o;return Array.isArray(t.content)&&(t.content.length===1&&ne(t.content[0])&&t.content[0].type==="text"&&t.content[0].text==="/"||t.content.length===0)?(o=e.updateBlock(t,n),e.setTextCursorPosition(o)):(o=e.insertBlocks([n],t,"after")[0],e.setTextCursorPosition(e.getTextCursorPosition().nextBlock)),Ws(e),o}function Ks(e){const n=[];return V("heading",e)&&n.push({onItemClick:()=>{_(e,{type:"heading",props:{level:1}})},badge:J("Mod-Alt-1"),key:"heading",...e.dictionary.slash_menu.heading},{onItemClick:()=>{_(e,{type:"heading",props:{level:2}})},badge:J("Mod-Alt-2"),key:"heading_2",...e.dictionary.slash_menu.heading_2},{onItemClick:()=>{_(e,{type:"heading",props:{level:3}})},badge:J("Mod-Alt-3"),key:"heading_3",...e.dictionary.slash_menu.heading_3}),V("quote",e)&&n.push({onItemClick:()=>{_(e,{type:"quote"})},key:"quote",...e.dictionary.slash_menu.quote}),V("numberedListItem",e)&&n.push({onItemClick:()=>{_(e,{type:"numberedListItem"})},badge:J("Mod-Shift-7"),key:"numbered_list",...e.dictionary.slash_menu.numbered_list}),V("bulletListItem",e)&&n.push({onItemClick:()=>{_(e,{type:"bulletListItem"})},badge:J("Mod-Shift-8"),key:"bullet_list",...e.dictionary.slash_menu.bullet_list}),V("checkListItem",e)&&n.push({onItemClick:()=>{_(e,{type:"checkListItem"})},badge:J("Mod-Shift-9"),key:"check_list",...e.dictionary.slash_menu.check_list}),V("paragraph",e)&&n.push({onItemClick:()=>{_(e,{type:"paragraph"})},badge:J("Mod-Alt-0"),key:"paragraph",...e.dictionary.slash_menu.paragraph}),V("codeBlock",e)&&n.push({onItemClick:()=>{_(e,{type:"codeBlock"})},badge:J("Mod-Alt-c"),key:"code_block",...e.dictionary.slash_menu.code_block}),V("table",e)&&n.push({onItemClick:()=>{_(e,{type:"table",content:{type:"tableContent",rows:[{cells:["","",""]},{cells:["","",""]}]}})},badge:void 0,key:"table",...e.dictionary.slash_menu.table}),V("image",e)&&n.push({onItemClick:()=>{const t=_(e,{type:"image"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:t}))},key:"image",...e.dictionary.slash_menu.image}),V("video",e)&&n.push({onItemClick:()=>{const t=_(e,{type:"video"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:t}))},key:"video",...e.dictionary.slash_menu.video}),V("audio",e)&&n.push({onItemClick:()=>{const t=_(e,{type:"audio"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:t}))},key:"audio",...e.dictionary.slash_menu.audio}),V("file",e)&&n.push({onItemClick:()=>{const t=_(e,{type:"file"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:t}))},key:"file",...e.dictionary.slash_menu.file}),n.push({onItemClick:()=>{e.openSuggestionMenu(":",{deleteTriggerCharacter:!0,ignoreQueryLength:!0})},key:"emoji",...e.dictionary.slash_menu.emoji}),n}function qs(e,n){return e.filter(({title:t,aliases:o})=>t.toLowerCase().includes(n.toLowerCase())||o&&o.filter(r=>r.toLowerCase().includes(n.toLowerCase())).length!==0)}function rt(e){return e&&Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))}class we{constructor(n){p(this,"blockSpecs");p(this,"inlineContentSpecs");p(this,"styleSpecs");p(this,"blockSchema");p(this,"inlineContentSchema");p(this,"styleSchema");p(this,"BlockNoteEditor","only for types");p(this,"Block","only for types");p(this,"PartialBlock","only for types");this.blockSpecs=rt(n==null?void 0:n.blockSpecs)||Dt,this.inlineContentSpecs=rt(n==null?void 0:n.inlineContentSpecs)||Rt,this.styleSpecs=rt(n==null?void 0:n.styleSpecs)||Ot,this.blockSchema=Et(this.blockSpecs),this.inlineContentSchema=Tt(this.inlineContentSpecs),this.styleSchema=Pt(this.styleSpecs)}static create(n){return new we(n)}}const Bo={type:"pageBreak",propSchema:{},content:"none",isFileBlock:!1,isSelectable:!1},To=()=>{const e=document.createElement("div");return e.className="bn-page-break",e.setAttribute("data-page-break",""),{dom:e}},xo=e=>{if(e.tagName==="DIV"&&e.hasAttribute("data-page-break"))return{type:"pageBreak"}},Po=()=>{const e=document.createElement("div");return e.setAttribute("data-page-break",""),{dom:e}},Mo=ge(Bo,{render:To,parse:xo,toExternalHTML:Po}),_t=we.create({blockSpecs:{pageBreak:Mo}}),js=e=>we.create({blockSpecs:{...e.blockSpecs,..._t.blockSpecs},inlineContentSpecs:e.inlineContentSpecs,styleSpecs:e.styleSpecs});function Io(e){return"pageBreak"in e.schema.blockSchema&&e.schema.blockSchema.pageBreak===_t.blockSchema.pageBreak}function Gs(e){const n=[];return Io(e)&&n.push({...e.dictionary.slash_menu.page_break,onItemClick:()=>{_(e,{type:"pageBreak"})},key:"page_break"}),n}function Ys(e){return e.transact(n=>{const t=Y(n.doc,n.selection.anchor);if(n.selection instanceof A.CellSelection)return{type:"cell",anchorBlockId:t.node.attrs.id,anchorCellOffset:n.selection.$anchorCell.pos-t.posBeforeNode,headCellOffset:n.selection.$headCell.pos-t.posBeforeNode};if(n.selection instanceof y.NodeSelection)return{type:"node",anchorBlockId:t.node.attrs.id};{const o=Y(n.doc,n.selection.head);return{type:"text",anchorBlockId:t.node.attrs.id,headBlockId:o.node.attrs.id,anchorOffset:n.selection.anchor-t.posBeforeNode,headOffset:n.selection.head-o.posBeforeNode}}})}function Js(e,n){var r,s;const t=(r=F(n.anchorBlockId,e.doc))==null?void 0:r.posBeforeNode;if(t===void 0)throw new Error(`Could not find block with ID ${n.anchorBlockId} to update selection`);let o;if(n.type==="cell")o=A.CellSelection.create(e.doc,t+n.anchorCellOffset,t+n.headCellOffset);else if(n.type==="node")o=y.NodeSelection.create(e.doc,t+1);else{const i=(s=F(n.headBlockId,e.doc))==null?void 0:s.posBeforeNode;if(i===void 0)throw new Error(`Could not find block with ID ${n.headBlockId} to update selection`);o=y.TextSelection.create(e.doc,t+n.anchorOffset,i+n.headOffset)}e.setSelection(o)}function bt(e){return e.map(n=>n.type==="columnList"?n.children.map(t=>bt(t.children)).flat():{...n,children:bt(n.children)}).flat()}function Lo(e,n,t){e.transact(o=>{var i;const r=((i=e.getSelection())==null?void 0:i.blocks)||[e.getTextCursorPosition().block],s=Ys(e);e.removeBlocks(r),e.insertBlocks(bt(r),n,t),Js(o,s)})}function Ao(e){return!e||e.type!=="columnList"}function No(e,n,t){let o,r;if(n?n.children.length>0?(o=n.children[n.children.length-1],r="after"):(o=n,r="before"):t&&(o=t,r="before"),!o||!r)return;const s=e.getParentBlock(o);return Ao(s)?{referenceBlock:o,placement:r}:No(e,r==="after"?o:e.getPrevBlock(o),s)}function Ho(e,n,t){let o,r;if(n?n.children.length>0?(o=n.children[0],r="before"):(o=n,r="after"):t&&(o=t,r="after"),!o||!r)return;const s=e.getParentBlock(o);return Ao(s)?{referenceBlock:o,placement:r}:Ho(e,r==="before"?o:e.getNextBlock(o),s)}function Xs(e){e.transact(()=>{const n=e.getSelection(),t=(n==null?void 0:n.blocks[0])||e.getTextCursorPosition().block,o=No(e,e.getPrevBlock(t),e.getParentBlock(t));o&&Lo(e,o.referenceBlock,o.placement)})}function Zs(e){e.transact(()=>{const n=e.getSelection(),t=(n==null?void 0:n.blocks[(n==null?void 0:n.blocks.length)-1])||e.getTextCursorPosition().block,o=Ho(e,e.getNextBlock(t),e.getParentBlock(t));o&&Lo(e,o.referenceBlock,o.placement)})}function Qs(e,n){return function(t,o){const{$from:r,$to:s}=t.selection,i=r.blockRange(s,d=>d.childCount>0&&(d.type.name==="blockGroup"||d.type.name==="column"));if(!i)return!1;const a=i.startIndex;if(a===0)return!1;const c=i.parent.child(a-1);if(c.type!==e)return!1;if(o){const d=c.lastChild&&c.lastChild.type===n,u=E.Fragment.from(d?e.create():null),h=new E.Slice(E.Fragment.from(e.create(null,E.Fragment.from(n.create(null,u)))),d?3:1,0),f=i.start,m=i.end;o(t.tr.step(new pe.ReplaceAroundStep(f-(d?3:1),m,f,m,h,1,!0)).scrollIntoView())}return!0}}function Do(e){return e.exec((n,t)=>Qs(n.schema.nodes.blockContainer,n.schema.nodes.blockGroup)(n,t))}function ei(e){e._tiptapEditor.commands.liftListItem("blockContainer")}function ti(e){return e.transact(n=>{const{bnBlock:t}=Te(n);return n.doc.resolve(t.beforePos).nodeBefore!==null})}function ni(e){return e.transact(n=>{const{bnBlock:t}=Te(n);return n.doc.resolve(t.beforePos).depth>1})}function Oo(e,n){const t=typeof n=="string"?n:n.id,o=H(e),r=F(t,e);if(r)return T(r.node,o)}function Ro(e,n){const t=typeof n=="string"?n:n.id,o=F(t,e),r=H(e);if(!o)return;const i=e.resolve(o.posBeforeNode).nodeBefore;if(i)return T(i,r)}function _o(e,n){const t=typeof n=="string"?n:n.id,o=F(t,e),r=H(e);if(!o)return;const i=e.resolve(o.posBeforeNode+o.node.nodeSize).nodeAfter;if(i)return T(i,r)}function Vo(e,n){const t=typeof n=="string"?n:n.id,o=H(e),r=F(t,e);if(!r)return;const s=e.resolve(r.posBeforeNode),i=s.node(),a=s.node(-1),l=a.type.name!=="doc"?i.type.name==="blockGroup"?a:i:void 0;if(l)return T(l,o)}function oi(e,n,t,o={updateSelection:!0}){let{from:r,to:s}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},i=!0,a=!0,l="";if(t.forEach(c=>{c.check(),i&&c.isText&&c.marks.length===0?l+=c.text:i=!1,a=a?c.isBlock:!1}),r===s&&a){const{parent:c}=e.doc.resolve(r);c.isTextblock&&!c.type.spec.code&&!c.childCount&&(r-=1,s+=1)}return i?e.insertText(l,r,s):e.replaceWith(r,s,t),o.updateSelection&&k.selectionToInsertionEnd(e,e.steps.length-1,-1),!0}function ri(e){const n=H(e);if(e.selection.empty||"node"in e.selection)return;const t=e.doc.resolve(Y(e.doc,e.selection.from).posBeforeNode),o=e.doc.resolve(Y(e.doc,e.selection.to).posBeforeNode),r=(c,d)=>{const u=t.posAtIndex(c,d),h=e.doc.resolve(u).nodeAfter;if(!h)throw new Error(`Error getting selection - node not found at position ${u}`);return T(h,n)},s=[],i=t.sharedDepth(o.pos),a=t.index(i),l=o.index(i);if(t.depth>i){s.push(T(t.nodeAfter,n));for(let c=t.depth;c>i;c--)if(t.node(c).type.isInGroup("childContainer")){const u=t.index(c)+1,h=t.node(c).childCount;for(let f=u;f<h;f++)s.push(r(f,c))}}else s.push(r(a,i));for(let c=a+1;c<=l;c++)s.push(r(c,i));if(s.length===0)throw new Error(`Error getting selection - selection doesn't span any blocks (${e.selection})`);return{blocks:s}}function si(e,n,t){const o=typeof n=="string"?n:n.id,r=typeof t=="string"?t:t.id,s=H(e),i=ke(s);if(o===r)throw new Error(`Attempting to set selection with the same anchor and head blocks (id ${o})`);const a=F(o,e.doc);if(!a)throw new Error(`Block with ID ${o} not found`);const l=F(r,e.doc);if(!l)throw new Error(`Block with ID ${r} not found`);const c=Z(a),d=Z(l),u=i.blockSchema[c.blockNoteType],h=i.blockSchema[d.blockNoteType];if(!c.isBlockContainer||u.content==="none")throw new Error(`Attempting to set selection anchor in block without content (id ${o})`);if(!d.isBlockContainer||h.content==="none")throw new Error(`Attempting to set selection anchor in block without content (id ${r})`);let f,m;if(u.content==="table"){const g=A.TableMap.get(c.blockContent.node);f=c.blockContent.beforePos+g.positionAt(0,0,c.blockContent.node)+1+2}else f=c.blockContent.beforePos+1;if(h.content==="table"){const g=A.TableMap.get(d.blockContent.node),b=d.blockContent.beforePos+g.positionAt(g.height-1,g.width-1,d.blockContent.node)+1,w=e.doc.resolve(b).nodeAfter.nodeSize;m=b+w-2}else m=d.blockContent.afterPos-1;e.setSelection(y.TextSelection.create(e.doc,f,m))}function ii(e){const n=H(e);let t=e.selection.$from,o=e.selection.$to;for(;o.parentOffset>=o.parent.nodeSize-2&&o.depth>0;)o=e.doc.resolve(o.pos+1);for(;o.parentOffset===0&&o.depth>0;)o=e.doc.resolve(o.pos-1);for(;t.parentOffset===0&&t.depth>0;)t=e.doc.resolve(t.pos-1);for(;t.parentOffset>=t.parent.nodeSize-2&&t.depth>0;)t=e.doc.resolve(t.pos+1);const r=gn(e.doc.slice(t.pos,o.pos,!0),n);return{_meta:{startPos:t.pos,endPos:o.pos},...r}}function ai(e){const{bnBlock:n}=Te(e),t=H(e.doc),o=e.doc.resolve(n.beforePos),r=o.nodeBefore,s=e.doc.resolve(n.afterPos).nodeAfter;let i;return o.depth>1&&(i=o.node(),i.type.isInGroup("bnBlock")||(i=o.node(o.depth-1))),{block:T(n.node,t),prevBlock:r===null?void 0:T(r,t),nextBlock:s===null?void 0:T(s,t),parentBlock:i===void 0?void 0:T(i,t)}}function Uo(e,n,t="start"){const o=typeof n=="string"?n:n.id,r=H(e.doc),s=ke(r),i=F(o,e.doc);if(!i)throw new Error(`Block with ID ${o} not found`);const a=Z(i),l=s.blockSchema[a.blockNoteType].content;if(a.isBlockContainer){const c=a.blockContent;if(l==="none"){e.setSelection(y.NodeSelection.create(e.doc,c.beforePos));return}if(l==="inline")t==="start"?e.setSelection(y.TextSelection.create(e.doc,c.beforePos+1)):e.setSelection(y.TextSelection.create(e.doc,c.afterPos-1));else if(l==="table")t==="start"?e.setSelection(y.TextSelection.create(e.doc,c.beforePos+4)):e.setSelection(y.TextSelection.create(e.doc,c.afterPos-4));else throw new K(l)}else{const c=t==="start"?a.childContainer.node.firstChild:a.childContainer.node.lastChild;Uo(e,c.attrs.id,t)}}exports.esmDependencies=void 0;async function Qe(){if(exports.esmDependencies)return exports.esmDependencies;const e=await Promise.all([import("rehype-parse"),import("rehype-stringify"),import("unified"),import("hast-util-from-dom"),import("rehype-remark"),import("remark-gfm"),import("remark-stringify"),import("remark-parse"),import("remark-rehype"),import("rehype-format")]);return exports.esmDependencies={rehypeParse:e[0],rehypeStringify:e[1],unified:e[2],hastUtilFromDom:e[3],rehypeRemark:e[4],remarkGfm:e[5],remarkStringify:e[6],remarkParse:e[7],remarkRehype:e[8],rehypeFormat:e[9]},exports.esmDependencies}function li(){const e=n=>{let t=n.children.length;for(let o=0;o<t;o++){const r=n.children[o];if(r.type==="element"&&(e(r),r.tagName==="u"))if(r.children.length>0){n.children.splice(o,1,...r.children);const s=r.children.length-1;t+=s,o+=s}else n.children.splice(o,1),t--,o--}};return e}function ci(){const e=exports.esmDependencies;if(!e)throw new Error("addSpacesToCheckboxes requires ESM dependencies to be initialized");const n=t=>{var o;if(t.children&&"length"in t.children&&t.children.length)for(let r=t.children.length-1;r>=0;r--){const s=t.children[r],i=r+1<t.children.length?t.children[r+1]:void 0;s.type==="element"&&s.tagName==="input"&&((o=s.properties)==null?void 0:o.type)==="checkbox"&&(i==null?void 0:i.type)==="element"&&i.tagName==="p"?(i.tagName="span",i.children.splice(0,0,e.hastUtilFromDom.fromDom(document.createTextNode(" ")))):n(s)}};return n}function et(e){const n=exports.esmDependencies;if(!n)throw new Error("cleanHTMLToMarkdown requires ESM dependencies to be initialized");return n.unified.unified().use(n.rehypeParse.default,{fragment:!0}).use(li).use(ci).use(n.rehypeRemark.default).use(n.remarkGfm.default).use(n.remarkStringify.default,{handlers:{text:o=>o.value}}).processSync(e).value}async function Fo(e,n,t,o){await Qe();const s=Me(n,t).exportBlocks(e,o);return et(s)}function di(e){return Array.prototype.indexOf.call(e.parentElement.childNodes,e)}function ui(e){return e.nodeType===3&&!/\S/.test(e.nodeValue||"")}function pi(e){e.querySelectorAll("li > ul, li > ol").forEach(n=>{const t=di(n),o=n.parentElement,r=Array.from(o.childNodes).slice(t+1);n.remove(),r.forEach(s=>{s.remove()}),o.insertAdjacentElement("afterend",n),r.reverse().forEach(s=>{if(ui(s))return;const i=document.createElement("li");i.append(s),n.insertAdjacentElement("afterend",i)}),o.childNodes.length===0&&o.remove()})}function hi(e){e.querySelectorAll("li + ul, li + ol").forEach(n=>{var s,i;const t=n.previousElementSibling,o=document.createElement("div");t.insertAdjacentElement("afterend",o),o.append(t);const r=document.createElement("div");for(r.setAttribute("data-node-type","blockGroup"),o.append(r);((s=o.nextElementSibling)==null?void 0:s.nodeName)==="UL"||((i=o.nextElementSibling)==null?void 0:i.nodeName)==="OL";)r.append(o.nextElementSibling)})}let Xt=null;function fi(){return Xt||(Xt=document.implementation.createHTMLDocument("title"))}function $o(e){if(typeof e=="string"){const n=fi().createElement("div");n.innerHTML=e,e=n}return pi(e),hi(e),e}async function Vt(e,n){const t=$o(e),r=E.DOMParser.fromSchema(n).parse(t,{topNode:n.nodes.blockGroup.create()}),s=[];for(let i=0;i<r.childCount;i++)s.push(T(r.child(i),n));return s}function mi(e,n){const t=n.value?n.value:"",o={};n.lang&&(o["data-language"]=n.lang);let r={type:"element",tagName:"code",properties:o,children:[{type:"text",value:t}]};return n.meta&&(r.data={meta:n.meta}),e.patch(n,r),r=e.applyData(n,r),r={type:"element",tagName:"pre",properties:{},children:[r]},e.patch(n,r),r}async function Ut(e){const n=await Qe();return n.unified.unified().use(n.remarkParse.default).use(n.remarkGfm.default).use(n.remarkRehype.default,{handlers:{...n.remarkRehype.defaultHandlers,code:mi}}).use(n.rehypeStringify.default).processSync(e).value}async function zo(e,n){const t=await Ut(e);return Vt(t,n)}const Ft=["vscode-editor-data","blocknote/html","text/markdown","text/html","text/plain","Files"];function gi(e,n){if(!e.startsWith(".")||!n.startsWith("."))throw new Error("The strings provided are not valid file extensions.");return e===n}function bi(e,n){const t=e.split("/"),o=n.split("/");if(t.length!==2)throw new Error(`The string ${e} is not a valid MIME type.`);if(o.length!==2)throw new Error(`The string ${n} is not a valid MIME type.`);return t[1]==="*"||o[1]==="*"?t[0]===o[0]:(t[0]==="*"||o[0]==="*"||t[0]===o[0])&&t[1]===o[1]}function Zt(e,n,t){let o;return Array.isArray(n.content)&&n.content.length===0?o=e.updateBlock(n,t).id:o=e.insertBlocks([t],n,"after")[0].id,o}async function Wo(e,n){var i;if(!n.uploadFile){console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");return}const t="dataTransfer"in e?e.dataTransfer:e.clipboardData;if(t===null)return;let o=null;for(const a of Ft)if(t.types.includes(a)){o=a;break}if(o!=="Files")return;const r=t.items;if(!r)return;e.preventDefault();const s=Object.values(n.schema.blockSchema).filter(a=>a.isFileBlock);for(let a=0;a<r.length;a++){let l="file";for(const d of s)for(const u of d.fileBlockAccept||[]){const h=u.startsWith("."),f=r[a].getAsFile();if(f&&(!h&&f.type&&bi(r[a].type,u)||h&&gi("."+f.name.split(".").pop(),u))){l=d.type;break}}const c=r[a].getAsFile();if(c){const d={type:l,props:{name:c.name}};let u;if(e.type==="paste"){const m=n.getTextCursorPosition().block;u=Zt(n,m,d)}else if(e.type==="drop"){const m={left:e.clientX,top:e.clientY},g=(i=n.prosemirrorView)==null?void 0:i.posAtCoords(m);if(!g)return;u=n.transact(b=>{const w=Y(b.doc,g.pos);return Zt(n,n.getBlock(w.node.attrs.id),d)})}else return;const h=await n.uploadFile(c,u),f=typeof h=="string"?{props:{url:h}}:{...h};n.updateBlock(u,f)}}}const ki=e=>k.Extension.create({name:"dropFile",addProseMirrorPlugins(){return[new y.Plugin({props:{handleDOMEvents:{drop(n,t){if(!e.isEditable)return;let o=null;for(const r of Ft)if(t.dataTransfer.types.includes(r)){o=r;break}return o===null?!0:o==="Files"?(Wo(t,e),!0):!1}}}})]}}),wi=/(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/,yi=new RegExp("(?:\\s|^)(_|__|\\*|\\*\\*|~~|==|\\+\\+)(?!\\s).{1,64}(?<!\\s)(?=\\1)"),Ci=/\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/,vi=new RegExp("(?:\\s|^)`(?!\\s)[^`]{1,48}(?<!\\s)`([^\\w]|$)"),Si=/(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/,Ei=/(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/,Bi=/\n{2} {0,3}-{2,48}\n{2}/,Ti=/(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/,xi=/(?:\n|^)(?!\s)\w[^\n]{0,64}\r?\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/,Pi=/(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/,Mi=/^\s*\|(.+\|)+\s*$/m,Ii=/^\s*\|(\s*[-:]+[-:]\s*\|)+\s*$/m,Li=/^\s*\|(.+\|)+\s*$/m,Ai=e=>wi.test(e)||yi.test(e)||Ci.test(e)||vi.test(e)||Si.test(e)||Ei.test(e)||Bi.test(e)||Ti.test(e)||xi.test(e)||Pi.test(e)||Mi.test(e)||Ii.test(e)||Li.test(e);async function Ni(e,n){const{schema:t}=n.state;if(!e.clipboardData)return!1;const o=e.clipboardData.getData("text/plain");if(!o)return!1;if(!t.nodes.codeBlock)return n.pasteText(o),!0;const r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s==null?void 0:s.mode;return i?(n.pasteHTML(`<pre><code class="language-${i}">${o.replace(/\r\n?/g,`
|
|
11
|
-
`)}</code></pre>`),!0):!1}function Hi({event:e,editor:n,prioritizeMarkdownOverHTML:t,plainTextAsMarkdown:o}){var a;if(n.transact(l=>l.selection.$from.parent.type.spec.code&&l.selection.$to.parent.type.spec.code)){const l=(a=e.clipboardData)==null?void 0:a.getData("text/plain");if(l)return n.pasteText(l),!0}let s;for(const l of Ft)if(e.clipboardData.types.includes(l)){s=l;break}if(!s)return!0;if(s==="vscode-editor-data")return Ni(e,n.prosemirrorView),!0;if(s==="Files")return Wo(e,n),!0;const i=e.clipboardData.getData(s);if(s==="blocknote/html")return n.pasteHTML(i,!0),!0;if(s==="text/markdown")return n.pasteMarkdown(i),!0;if(t){const l=e.clipboardData.getData("text/plain");if(Ai(l))return n.pasteMarkdown(l),!0}return s==="text/html"?(n.pasteHTML(i),!0):o?(n.pasteMarkdown(i),!0):(n.pasteText(i),!0)}const Di=(e,n)=>k.Extension.create({name:"pasteFromClipboard",addProseMirrorPlugins(){return[new y.Plugin({props:{handleDOMEvents:{paste(t,o){if(o.preventDefault(),!!e.isEditable)return n({event:o,editor:e,defaultPasteHandler:({prioritizeMarkdownOverHTML:r=!0,plainTextAsMarkdown:s=!0}={})=>Hi({event:o,editor:e,prioritizeMarkdownOverHTML:r,plainTextAsMarkdown:s})})}}}})]}});function Ko(e){const n=[];return e.descendants(t=>{var r,s;const o=H(t);return t.type.name==="blockContainer"&&((r=t.firstChild)==null?void 0:r.type.name)==="blockGroup"?!0:t.type.name==="columnList"&&t.childCount===1?((s=t.firstChild)==null||s.forEach(i=>{n.push(T(i,o))}),!1):t.type.isInGroup("bnBlock")?(n.push(T(t,o)),!1):!0}),n}function Oi(e,n,t){var a;let o=!1;const r=e.state.selection instanceof A.CellSelection;if(!r){const l=e.state.doc.slice(e.state.selection.from,e.state.selection.to,!1).content,c=[];for(let d=0;d<l.childCount;d++)c.push(l.child(d));o=c.find(d=>d.type.isInGroup("bnBlock")||d.type.name==="blockGroup"||d.type.spec.group==="blockContent")===void 0,o&&(n=l)}let s;const i=Me(e.state.schema,t);if(r){((a=n.firstChild)==null?void 0:a.type.name)==="table"&&(n=n.firstChild.content);const l=Bt(n,t.schema.inlineContentSchema,t.schema.styleSchema);s=`<table>${i.exportInlineContent(l,{})}</table>`}else if(o){const l=xe(n,t.schema.inlineContentSchema,t.schema.styleSchema);s=i.exportInlineContent(l,{})}else{const l=Ko(n);s=i.exportBlocks(l,{})}return s}function $t(e,n){"node"in e.state.selection&&e.state.selection.node.type.spec.group==="blockContent"&&n.transact(i=>i.setSelection(new y.NodeSelection(i.doc.resolve(e.state.selection.from-1))));const t=e.serializeForClipboard(e.state.selection.content()).dom.innerHTML,o=e.state.selection.content().content,r=Oi(e,o,n),s=et(r);return{clipboardHTML:t,externalHTML:r,markdown:s}}const Qt=()=>{const e=window.getSelection();if(!e||e.isCollapsed)return!0;let n=e.focusNode;for(;n;){if(n instanceof HTMLElement&&n.getAttribute("contenteditable")==="false")return!0;n=n.parentElement}return!1},en=(e,n,t)=>{t.preventDefault(),t.clipboardData.clearData();const{clipboardHTML:o,externalHTML:r,markdown:s}=$t(n,e);t.clipboardData.setData("blocknote/html",o),t.clipboardData.setData("text/html",r),t.clipboardData.setData("text/plain",s)},Ri=e=>k.Extension.create({name:"copyToClipboard",addProseMirrorPlugins(){return[new y.Plugin({props:{handleDOMEvents:{copy(n,t){return Qt()||en(e,n,t),!0},cut(n,t){return Qt()||(en(e,n,t),n.editable&&n.dispatch(n.state.tr.deleteSelection())),!0},dragstart(n,t){if(!("node"in n.state.selection)||n.state.selection.node.type.spec.group!=="blockContent")return;e.transact(i=>i.setSelection(new y.NodeSelection(i.doc.resolve(n.state.selection.from-1)))),t.preventDefault(),t.dataTransfer.clearData();const{clipboardHTML:o,externalHTML:r,markdown:s}=$t(n,e);return t.dataTransfer.setData("blocknote/html",o),t.dataTransfer.setData("text/html",r),t.dataTransfer.setData("text/plain",s),!0}}}})]}}),_i=k.Extension.create({name:"blockBackgroundColor",addGlobalAttributes(){return[{types:["blockContainer","tableCell","tableHeader"],attributes:{backgroundColor:{default:I.backgroundColor.default,parseHTML:e=>e.hasAttribute("data-background-color")?e.getAttribute("data-background-color"):I.backgroundColor.default,renderHTML:e=>e.backgroundColor===I.backgroundColor.default?{}:{"data-background-color":e.backgroundColor}}}}]}});class tt{constructor(){p(this,"callbacks",{})}on(n,t){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(t),()=>this.off(n,t)}emit(n,...t){const o=this.callbacks[n];o&&o.forEach(r=>r.apply(this,t))}off(n,t){const o=this.callbacks[n];o&&(t?this.callbacks[n]=o.filter(r=>r!==t):delete this.callbacks[n])}removeAllListeners(){this.callbacks={}}}class O extends tt{constructor(...t){super();p(this,"plugins",[])}static key(){throw new Error("You must implement the key method in your extension")}addProsemirrorPlugin(t){this.plugins.push(t)}get priority(){}}const We=class We extends O{constructor(t){super();p(this,"provider");p(this,"recentlyUpdatedCursors");p(this,"renderCursor",(t,o)=>{let r=this.recentlyUpdatedCursors.get(o);if(!r){const s=(this.collaboration.renderCursor??We.defaultCursorRender)(t);this.collaboration.showCursorLabels!=="always"&&(s.addEventListener("mouseenter",()=>{const i=this.recentlyUpdatedCursors.get(o);i.element.setAttribute("data-active",""),i.hideTimeout&&(clearTimeout(i.hideTimeout),this.recentlyUpdatedCursors.set(o,{element:i.element,hideTimeout:void 0}))}),s.addEventListener("mouseleave",()=>{const i=this.recentlyUpdatedCursors.get(o);this.recentlyUpdatedCursors.set(o,{element:i.element,hideTimeout:setTimeout(()=>{i.element.removeAttribute("data-active")},2e3)})})),r={element:s,hideTimeout:void 0},this.recentlyUpdatedCursors.set(o,r)}return r.element});p(this,"updateUser",t=>{this.provider.awareness.setLocalStateField("user",t)});this.collaboration=t,this.provider=t.provider,this.recentlyUpdatedCursors=new Map,this.provider.awareness.setLocalStateField("user",t.user),t.showCursorLabels!=="always"&&this.provider.awareness.on("change",({updated:o})=>{for(const r of o){const s=this.recentlyUpdatedCursors.get(r);s&&(s.element.setAttribute("data-active",""),s.hideTimeout&&clearTimeout(s.hideTimeout),this.recentlyUpdatedCursors.set(r,{element:s.element,hideTimeout:setTimeout(()=>{s.element.removeAttribute("data-active")},2e3)}))}}),this.addProsemirrorPlugin(N.yCursorPlugin(this.provider.awareness,{selectionBuilder:N.defaultSelectionBuilder,cursorBuilder:this.renderCursor}))}static key(){return"yCursorPlugin"}get priority(){return 999}};p(We,"defaultCursorRender",t=>{const o=document.createElement("span");o.classList.add("bn-collaboration-cursor__base");const r=document.createElement("span");r.setAttribute("contentedEditable","false"),r.classList.add("bn-collaboration-cursor__caret"),r.setAttribute("style",`background-color: ${t.color}`);const s=document.createElement("span");return s.classList.add("bn-collaboration-cursor__label"),s.setAttribute("style",`background-color: ${t.color}`),s.insertBefore(document.createTextNode(t.name),null),r.insertBefore(s,null),o.insertBefore(document.createTextNode(""),null),o.insertBefore(r,null),o.insertBefore(document.createTextNode(""),null),o});let $e=We;class kt extends O{static key(){return"ySyncPlugin"}constructor(n){super(),this.addProsemirrorPlugin(N.ySyncPlugin(n))}get priority(){return 1001}}class wt extends O{static key(){return"yUndoPlugin"}constructor(){super(),this.addProsemirrorPlugin(N.yUndoPlugin())}get priority(){return 1e3}}const qo=k.Mark.create({name:"comment",excludes:"",inclusive:!1,keepOnSplit:!0,addAttributes(){return{orphan:{parseHTML:e=>!!e.getAttribute("data-orphan"),renderHTML:e=>e.orphan?{"data-orphan":"true"}:{},default:!1},threadId:{parseHTML:e=>e.getAttribute("data-bn-thread-id"),renderHTML:e=>({"data-bn-thread-id":e.threadId}),default:""}}},renderHTML({HTMLAttributes:e}){return["span",k.mergeAttributes(e,{class:"bn-thread-mark"})]},parseHTML(){return[{tag:"span.bn-thread-mark"}]},extendMarkSchema(e){return e.name==="comment"?{blocknoteIgnore:!0}:{}}});class Vi extends tt{constructor(t){super();p(this,"userCache",new Map);p(this,"loadingUsers",new Set);this.resolveUsers=t}async loadUsers(t){const o=t.filter(r=>!this.userCache.has(r)&&!this.loadingUsers.has(r));if(o.length!==0){for(const r of o)this.loadingUsers.add(r);try{const r=await this.resolveUsers(o);for(const s of r)this.userCache.set(s.id,s);this.emit("update",this.userCache)}finally{for(const r of o)this.loadingUsers.delete(r)}}}getUser(t){return this.userCache.get(t)}subscribe(t){return this.on("update",t)}}const Ae=new y.PluginKey("blocknote-comments"),Ui="SET_SELECTED_THREAD_ID";function Fi(e,n){const t=new Map;return e.descendants((o,r)=>{o.marks.forEach(s=>{if(s.type.name===n){const i=s.attrs.threadId;if(!i)return;const a=r,l=a+o.nodeSize,c=t.get(i)??{from:1/0,to:0};t.set(i,{from:Math.min(a,c.from),to:Math.max(l,c.to)})}})}),t}class $i extends O{constructor(t,o,r){super();p(this,"userStore");p(this,"pendingComment",!1);p(this,"selectedThreadId");p(this,"threadPositions",new Map);p(this,"updateMarksFromThreads",t=>{this.editor.transact(o=>{o.doc.descendants((r,s)=>{r.marks.forEach(i=>{if(i.type.name===this.markType){const a=i.type,l=i.attrs.threadId,c=t.get(l),d=!!(!c||c.resolved||c.deletedAt);if(d!==i.attrs.orphan){const u=Math.max(s,0),h=Math.min(s+r.nodeSize,o.doc.content.size-1,o.doc.content.size-1);o.removeMark(u,h,i),o.addMark(u,h,a.create({...i.attrs,orphan:d})),d&&this.selectedThreadId===l&&(this.selectedThreadId=void 0,this.emitStateUpdate())}}})})})});if(this.editor=t,this.threadStore=o,this.markType=r,!t.resolveUsers)throw new Error("resolveUsers is required for comments");this.userStore=new Vi(t.resolveUsers),this.threadStore.subscribe(this.updateMarksFromThreads),t.onCreate(()=>{this.updateMarksFromThreads(this.threadStore.getThreads()),t.onSelectionChange(()=>{this.pendingComment&&(this.pendingComment=!1,this.emitStateUpdate())})});const s=this;this.addProsemirrorPlugin(new y.Plugin({key:Ae,state:{init(){return{decorations:M.DecorationSet.empty}},apply(i,a){const l=i.getMeta(Ae);if(!i.docChanged&&!l)return a;const c=i.docChanged?Fi(i.doc,s.markType):s.threadPositions;(c.size>0||s.threadPositions.size>0)&&(s.threadPositions=c,s.emitStateUpdate());const d=[];if(s.selectedThreadId){const u=c.get(s.selectedThreadId);u&&d.push(M.Decoration.inline(u.from,u.to,{class:"bn-thread-mark-selected"}))}return{decorations:M.DecorationSet.create(i.doc,d)}}},props:{decorations(i){var a;return((a=Ae.getState(i))==null?void 0:a.decorations)??M.DecorationSet.empty},handleClick:(i,a,l)=>{if(l.button!==0)return;const c=i.state.doc.nodeAt(a);if(!c){s.selectThread(void 0);return}const d=c.marks.find(h=>h.type.name===r&&h.attrs.orphan!==!0),u=d==null?void 0:d.attrs.threadId;s.selectThread(u,!1)}}}))}static key(){return"comments"}emitStateUpdate(){this.emit("update",{selectedThreadId:this.selectedThreadId,pendingComment:this.pendingComment,threadPositions:this.threadPositions})}onUpdate(t){return this.on("update",t)}selectThread(t,o=!0){var r,s;if(this.selectedThreadId!==t&&(this.selectedThreadId=t,this.emitStateUpdate(),this.editor.transact(i=>i.setMeta(Ae,{name:Ui})),t&&o)){const i=this.threadPositions.get(t);if(!i)return;(s=(r=this.editor.prosemirrorView)==null?void 0:r.domAtPos(i.from).node)==null||s.scrollIntoView({behavior:"smooth",block:"center"})}}startPendingComment(){this.pendingComment=!0,this.emitStateUpdate()}stopPendingComment(){this.pendingComment=!1,this.emitStateUpdate()}async createThread(t){const o=await this.threadStore.createThread(t);if(this.threadStore.addThreadToDocument){const r=this.editor.prosemirrorView,s=r.state.selection,i=N.ySyncPluginKey.getState(r.state),a={prosemirror:{head:s.head,anchor:s.anchor},yjs:i?N.getRelativeSelection(i.binding,r.state):void 0};await this.threadStore.addThreadToDocument({threadId:o.id,selection:a})}else this.editor._tiptapEditor.commands.setMark(this.markType,{orphan:!1,threadId:o.id})}}class jo{constructor(n,t,o,r){p(this,"state");p(this,"emitUpdate");p(this,"mouseDownHandler",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())});p(this,"dragstartHandler",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())});p(this,"scrollHandler",()=>{var n;if((n=this.state)!=null&&n.show){const t=this.pmView.root.querySelector(`[data-node-type="blockContainer"][data-id="${this.state.block.id}"]`);if(!t)return;this.state.referencePos=t.getBoundingClientRect(),this.emitUpdate()}});p(this,"closeMenu",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())});this.editor=n,this.pluginKey=t,this.pmView=o,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized file panel");r(this.state)},o.dom.addEventListener("mousedown",this.mouseDownHandler),o.dom.addEventListener("dragstart",this.dragstartHandler),o.root.addEventListener("scroll",this.scrollHandler,!0)}update(n,t){var a,l;const o=this.pluginKey.getState(n.state),r=this.pluginKey.getState(t);if(!((a=this.state)!=null&&a.show)&&(o!=null&&o.block)&&this.editor.isEditable){const c=this.pmView.root.querySelector(`[data-node-type="blockContainer"][data-id="${o.block.id}"]`);if(!c)return;this.state={show:!0,referencePos:c.getBoundingClientRect(),block:o.block},this.emitUpdate();return}const s=(o==null?void 0:o.block)&&!(r!=null&&r.block),i=!(o!=null&&o.block)&&(r==null?void 0:r.block);s&&this.state&&!this.state.show&&(this.state.show=!0,this.emitUpdate()),i&&((l=this.state)!=null&&l.show)&&(this.state.show=!1,this.emitUpdate())}destroy(){this.pmView.dom.removeEventListener("mousedown",this.mouseDownHandler),this.pmView.dom.removeEventListener("dragstart",this.dragstartHandler),this.pmView.root.removeEventListener("scroll",this.scrollHandler,!0)}}const st=new y.PluginKey("FilePanelPlugin");class Go extends O{constructor(t){super();p(this,"view");p(this,"closeMenu",()=>{var t;return(t=this.view)==null?void 0:t.closeMenu()});this.addProsemirrorPlugin(new y.Plugin({key:st,view:o=>(this.view=new jo(t,st,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(st);return s||(!o.getMeta(N.ySyncPluginKey)&&(o.selectionSet||o.docChanged)?{block:void 0}:r)}}}))}static key(){return"filePanel"}get shown(){var t,o;return((o=(t=this.view)==null?void 0:t.state)==null?void 0:o.show)||!1}onUpdate(t){return this.on("update",t)}}class Yo{constructor(n,t,o){p(this,"state");p(this,"emitUpdate");p(this,"preventHide",!1);p(this,"preventShow",!1);p(this,"shouldShow",({view:n,state:t,from:o,to:r})=>{const{doc:s,selection:i}=t,{empty:a}=i,l=!s.textBetween(o,r).length&&k.isTextSelection(t.selection);if(i.$from.parent.type.spec.code||k.isNodeSelection(i)&&i.node.type.spec.code||a||l)return!1;const c=document.activeElement;return!(!this.isElementWithinEditorWrapper(c)&&n.editable)});p(this,"blurHandler",n=>{var o;if(this.preventHide){this.preventHide=!1;return}const t=this.pmView.dom.parentElement;n&&n.relatedTarget&&(t===n.relatedTarget||t.contains(n.relatedTarget)||n.relatedTarget.matches(".bn-ui-container, .bn-ui-container *"))||(o=this.state)!=null&&o.show&&(this.state.show=!1,this.emitUpdate())});p(this,"isElementWithinEditorWrapper",n=>{if(!n)return!1;const t=this.pmView.dom.parentElement;return t?t.contains(n):!1});p(this,"viewMousedownHandler",n=>{this.isElementWithinEditorWrapper(n.target)||(this.preventShow=!0)});p(this,"mouseupHandler",()=>{this.preventShow&&(this.preventShow=!1,setTimeout(()=>this.update(this.pmView)))});p(this,"dragHandler",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())});p(this,"scrollHandler",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.referencePos=this.getSelectionBoundingBox(),this.emitUpdate())});p(this,"closeMenu",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())});this.editor=n,this.pmView=t,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized formatting toolbar");o(this.state)},t.dom.addEventListener("mousedown",this.viewMousedownHandler),t.root.addEventListener("mouseup",this.mouseupHandler),t.dom.addEventListener("dragstart",this.dragHandler),t.dom.addEventListener("dragover",this.dragHandler),t.dom.addEventListener("blur",this.blurHandler),t.root.addEventListener("scroll",this.scrollHandler,!0)}update(n,t){var f,m,g;const{state:o,composing:r}=n,{doc:s,selection:i}=o,a=t&&t.doc.eq(s)&&t.selection.eq(i);if(r||a)return;const{ranges:l}=i,c=Math.min(...l.map(b=>b.$from.pos)),d=Math.max(...l.map(b=>b.$to.pos)),u=this.shouldShow({view:n,state:o,from:c,to:d}),h=typeof Range.prototype.getClientRects>"u";if(!this.preventShow&&(u||this.preventHide)&&!h){const b={show:!0,referencePos:this.getSelectionBoundingBox()};(b.show!==((f=this.state)==null?void 0:f.show)||b.referencePos.toJSON()!==((m=this.state)==null?void 0:m.referencePos.toJSON()))&&(this.state=b,this.emitUpdate());return}if((g=this.state)!=null&&g.show&&!this.preventHide&&(!u||this.preventShow||!this.editor.isEditable)){this.state.show=!1,this.emitUpdate();return}}destroy(){this.pmView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.pmView.root.removeEventListener("mouseup",this.mouseupHandler),this.pmView.dom.removeEventListener("dragstart",this.dragHandler),this.pmView.dom.removeEventListener("dragover",this.dragHandler),this.pmView.dom.removeEventListener("blur",this.blurHandler),this.pmView.root.removeEventListener("scroll",this.scrollHandler,!0)}getSelectionBoundingBox(){const{state:n}=this.pmView,{selection:t}=n,{ranges:o}=t,r=Math.min(...o.map(i=>i.$from.pos)),s=Math.max(...o.map(i=>i.$to.pos));if(k.isNodeSelection(t)){const i=this.pmView.nodeDOM(r);if(i)return i.getBoundingClientRect()}return k.posToDOMRect(this.pmView,r,s)}}const Jo=new y.PluginKey("FormattingToolbarPlugin");class Xo extends O{constructor(t){super();p(this,"view");p(this,"closeMenu",()=>this.view.closeMenu());this.addProsemirrorPlugin(new y.Plugin({key:Jo,view:o=>(this.view=new Yo(t,o,r=>{this.emit("update",r)}),this.view),props:{handleKeyDown:(o,r)=>r.key==="Escape"&&this.shown?(this.view.closeMenu(),!0):!1}}))}static key(){return"formattingToolbar"}get shown(){var t,o;return((o=(t=this.view)==null?void 0:t.state)==null?void 0:o.show)||!1}onUpdate(t){return this.on("update",t)}}const zi=k.Node.create({name:"hardBreak",inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,priority:10,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:e}){return["br",k.mergeAttributes(this.options.HTMLAttributes,e)]},renderText(){return`
|
|
12
|
-
`}}),tn=(e,n)=>{const t=e.resolve(n);if(t.depth<=1)return;const o=t.posAtIndex(t.index(t.depth-1),t.depth-1);return be(e.resolve(o))},Re=(e,n)=>{const t=e.resolve(n),o=t.index();if(o===0)return;const r=t.posAtIndex(o-1);return be(e.resolve(r))},Zo=(e,n)=>{for(;n.childContainer;){const t=n.childContainer.node,o=e.resolve(n.childContainer.beforePos+1).posAtIndex(t.childCount-1);n=be(e.resolve(o))}return n},Wi=(e,n)=>e.isBlockContainer&&e.blockContent.node.type.spec.content==="inline*"&&e.blockContent.node.childCount>0&&n.isBlockContainer&&n.blockContent.node.type.spec.content==="inline*",Ki=(e,n,t,o)=>{if(!o.isBlockContainer)throw new Error(`Attempted to merge block at position ${o.bnBlock.beforePos} into previous block at position ${t.bnBlock.beforePos}, but next block is not a block container`);if(o.childContainer){const r=e.doc.resolve(o.childContainer.beforePos+1),s=e.doc.resolve(o.childContainer.afterPos-1),i=r.blockRange(s);if(n){const a=e.doc.resolve(o.bnBlock.beforePos);e.tr.lift(i,a.depth)}}if(n){if(!t.isBlockContainer)throw new Error(`Attempted to merge block at position ${o.bnBlock.beforePos} into previous block at position ${t.bnBlock.beforePos}, but previous block is not a block container`);n(e.tr.delete(t.blockContent.afterPos-1,o.blockContent.beforePos+1))}return!0},nn=e=>({state:n,dispatch:t})=>{const o=n.doc.resolve(e),r=be(o),s=Re(n.doc,r.bnBlock.beforePos);if(!s)return!1;const i=Zo(n.doc,s);return Wi(i,r)?Ki(n,t,i,r):!1},qi=k.Extension.create({priority:50,addKeyboardShortcuts(){const e=()=>this.editor.commands.first(({chain:o,commands:r})=>[()=>r.deleteSelection(),()=>r.undoInputRule(),()=>r.command(({state:s})=>{const i=B(s);if(!i.isBlockContainer)return!1;const a=s.selection.from===i.blockContent.beforePos+1,l=i.blockContent.node.type.name==="paragraph";return a&&!l?r.command(D(i.bnBlock.beforePos,{type:"paragraph",props:{}})):!1}),()=>r.command(({state:s})=>{const i=B(s);if(!i.isBlockContainer)return!1;const{blockContent:a}=i;return s.selection.from===a.beforePos+1?r.liftListItem("blockContainer"):!1}),()=>r.command(({state:s})=>{const i=B(s);if(!i.isBlockContainer)return!1;const{bnBlock:a,blockContent:l}=i,c=s.selection.from===l.beforePos+1,d=s.selection.empty,u=a.beforePos;return c&&d?o().command(nn(u)).scrollIntoView().run():!1}),()=>r.command(({state:s,dispatch:i})=>{const a=B(s);if(!a.isBlockContainer||!(s.selection.from===a.blockContent.beforePos+1)||Re(s.doc,a.bnBlock.beforePos))return!1;const d=tn(s.doc,a.bnBlock.beforePos);if((d==null?void 0:d.blockNoteType)!=="column")return!1;const u=d,h=tn(s.doc,u.bnBlock.beforePos);if((h==null?void 0:h.blockNoteType)!=="columnList")throw new Error("parent of column is not a column list");const f=u.childContainer.node.childCount===1,m=f&&h.childContainer.node.childCount===2,g=h.childContainer.node.firstChild===u.bnBlock.node;if(i){const b=s.doc.slice(a.bnBlock.beforePos,a.bnBlock.afterPos,!1);if(m)if(g){s.tr.step(new pe.ReplaceAroundStep(h.bnBlock.beforePos,h.bnBlock.afterPos,u.bnBlock.afterPos+1,h.bnBlock.afterPos-2,b,b.size,!1));const w=s.tr.doc.resolve(u.bnBlock.beforePos);s.tr.setSelection(y.TextSelection.between(w,w))}else{s.tr.step(new pe.ReplaceAroundStep(h.bnBlock.beforePos,h.bnBlock.afterPos,h.bnBlock.beforePos+2,u.bnBlock.beforePos-1,b,0,!1));const w=s.tr.doc.resolve(s.tr.mapping.map(u.bnBlock.beforePos-1));s.tr.setSelection(y.TextSelection.between(w,w))}else if(f)if(g){s.tr.delete(u.bnBlock.beforePos,u.bnBlock.afterPos),s.tr.insert(h.bnBlock.beforePos,b.content);const w=s.tr.doc.resolve(h.bnBlock.beforePos);s.tr.setSelection(y.TextSelection.between(w,w))}else s.tr.delete(u.bnBlock.beforePos-1,u.bnBlock.beforePos+1);else{s.tr.delete(a.bnBlock.beforePos,a.bnBlock.afterPos),g?s.tr.insert(h.bnBlock.beforePos-1,b.content):s.tr.insert(u.bnBlock.beforePos-1,b.content);const w=s.tr.doc.resolve(u.bnBlock.beforePos-1);s.tr.setSelection(y.TextSelection.between(w,w))}}return!0}),()=>r.command(({state:s})=>{const i=B(s);if(!i.isBlockContainer)return!1;if(i.blockContent.node.childCount===0&&i.blockContent.node.type.spec.content==="inline*"){const l=Re(s.doc,i.bnBlock.beforePos);if(!l||!l.isBlockContainer)return!1;let c=o();if(l.blockContent.node.type.spec.content==="tableRow+"){const m=i.bnBlock.beforePos-1-1-1-1-1;c=c.setTextSelection(m)}else if(l.blockContent.node.type.spec.content===""){const d=l.blockContent.afterPos-l.blockContent.node.nodeSize;c=c.setNodeSelection(d)}else{const d=l.blockContent.afterPos-l.blockContent.node.nodeSize;c=c.setTextSelection(d)}return c.deleteRange({from:i.bnBlock.beforePos,to:i.bnBlock.afterPos}).scrollIntoView().run()}return!1}),()=>r.command(({state:s})=>{const i=B(s);if(!i.isBlockContainer)throw new Error("todo");const a=s.selection.from===i.blockContent.beforePos+1,l=s.selection.empty,c=Re(s.doc,i.bnBlock.beforePos);if(c&&a&&l){const d=Zo(s.doc,c);if(!d.isBlockContainer)throw new Error("todo");if(d.blockContent.node.type.spec.content===""||d.blockContent.node.type.spec.content==="inline*"&&d.blockContent.node.childCount===0)return o().cut({from:i.bnBlock.beforePos,to:i.bnBlock.afterPos},d.bnBlock.afterPos).deleteRange({from:d.bnBlock.beforePos,to:d.bnBlock.afterPos}).run()}return!1})]),n=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.command(({state:r})=>{const s=B(r);if(!s.isBlockContainer)return!1;const{bnBlock:i,blockContent:a,childContainer:l}=s,{depth:c}=r.doc.resolve(i.beforePos),d=i.afterPos===r.doc.nodeSize-3,u=r.selection.from===a.afterPos-1,h=r.selection.empty;if(!d&&u&&h&&!(l!==void 0)){let m=c,g=i.afterPos+1,b=r.doc.resolve(g).depth;for(;b<m;)m=b,g+=2,b=r.doc.resolve(g).depth;return o.command(nn(g-1))}return!1})]),t=(o=!1)=>this.editor.commands.first(({commands:r})=>[()=>r.command(({state:s})=>{const i=B(s);if(!i.isBlockContainer)return!1;const{bnBlock:a,blockContent:l}=i,{depth:c}=s.doc.resolve(a.beforePos),d=s.selection.$anchor.parentOffset===0,u=s.selection.anchor===s.selection.head,h=l.node.childCount===0,f=c>1;return d&&u&&h&&f?r.liftListItem("blockContainer"):!1}),()=>r.command(({state:s})=>{const i=B(s),a=this.options.editor.schema.blockSchema[i.blockNoteType].hardBreakShortcut??"shift+enter";return a==="none"?!1:a==="shift+enter"&&o||a==="enter"?r.insertContent({type:"hardBreak"}):!1}),()=>r.command(({state:s,dispatch:i})=>{const a=B(s);if(!a.isBlockContainer)return!1;const{bnBlock:l,blockContent:c}=a,d=s.selection.$anchor.parentOffset===0,u=s.selection.anchor===s.selection.head,h=c.node.childCount===0;if(d&&u&&h){const f=l.afterPos,m=f+2;if(i){const g=s.schema.nodes.blockContainer.createAndFill();s.tr.insert(f,g).scrollIntoView(),s.tr.setSelection(new y.TextSelection(s.doc.resolve(m)))}return!0}return!1}),()=>r.command(({state:s,chain:i})=>{const a=B(s);if(!a.isBlockContainer)return!1;const{blockContent:l}=a,c=s.selection.$anchor.parentOffset===0;return l.node.childCount===0?!1:(i().deleteSelection().command(co(s.selection.from,c,c)).run(),!0)})]);return{Backspace:e,Delete:n,Enter:()=>t(),"Shift-Enter":()=>t(!0),Tab:()=>{var o,r,s;return this.options.tabBehavior!=="prefer-indent"&&((o=this.options.editor.formattingToolbar)!=null&&o.shown||(r=this.options.editor.linkToolbar)!=null&&r.shown||(s=this.options.editor.filePanel)!=null&&s.shown)?!1:Do(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 ji{constructor(n,t,o){p(this,"state");p(this,"emitUpdate");p(this,"menuUpdateTimer");p(this,"startMenuUpdateTimer");p(this,"stopMenuUpdateTimer");p(this,"mouseHoveredLinkMark");p(this,"mouseHoveredLinkMarkRange");p(this,"keyboardHoveredLinkMark");p(this,"keyboardHoveredLinkMarkRange");p(this,"linkMark");p(this,"linkMarkRange");p(this,"mouseOverHandler",n=>{if(this.mouseHoveredLinkMark=void 0,this.mouseHoveredLinkMarkRange=void 0,this.stopMenuUpdateTimer(),n.target instanceof HTMLAnchorElement&&n.target.nodeName==="A"){const t=n.target,o=this.pmView.posAtDOM(t,0)+1,r=this.pmView.state.doc.resolve(o),s=r.marks();for(const i of s)if(i.type.name===this.pmView.state.schema.mark("link").type.name){this.mouseHoveredLinkMark=i,this.mouseHoveredLinkMarkRange=k.getMarkRange(r,i.type,i.attrs)||void 0;break}}return this.startMenuUpdateTimer(),!1});p(this,"clickHandler",n=>{var o;const t=this.pmView.dom.parentElement;this.linkMark&&n&&n.target&&!(t===n.target||t.contains(n.target))&&(o=this.state)!=null&&o.show&&(this.state.show=!1,this.emitUpdate())});p(this,"scrollHandler",()=>{var n;this.linkMark!==void 0&&(n=this.state)!=null&&n.show&&(this.state.referencePos=k.posToDOMRect(this.pmView,this.linkMarkRange.from,this.linkMarkRange.to),this.emitUpdate())});p(this,"closeMenu",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())});this.editor=n,this.pmView=t,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized link toolbar");o(this.state)},this.startMenuUpdateTimer=()=>{this.menuUpdateTimer=setTimeout(()=>{this.update(this.pmView,void 0,!0)},250)},this.stopMenuUpdateTimer=()=>(this.menuUpdateTimer&&(clearTimeout(this.menuUpdateTimer),this.menuUpdateTimer=void 0),!1),this.pmView.dom.addEventListener("mouseover",this.mouseOverHandler),this.pmView.root.addEventListener("click",this.clickHandler,!0),this.pmView.root.addEventListener("scroll",this.scrollHandler,!0)}editLink(n,t){var o;this.editor.transact(r=>{const s=H(r);r.insertText(t,this.linkMarkRange.from,this.linkMarkRange.to),r.addMark(this.linkMarkRange.from,this.linkMarkRange.from+t.length,s.mark("link",{href:n}))}),this.pmView.focus(),(o=this.state)!=null&&o.show&&(this.state.show=!1,this.emitUpdate())}deleteLink(){var n;this.editor.transact(t=>t.removeMark(this.linkMarkRange.from,this.linkMarkRange.to,this.linkMark.type).setMeta("preventAutolink",!0)),this.pmView.focus(),(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())}update(n,t,o=!1){var a;const{state:r}=n;if(t&&t.selection.from===r.selection.from&&t.selection.to===r.selection.to||!this.pmView.hasFocus())return;const i=this.linkMark;if(this.linkMark=void 0,this.linkMarkRange=void 0,this.keyboardHoveredLinkMark=void 0,this.keyboardHoveredLinkMarkRange=void 0,this.pmView.state.selection.empty){const l=this.pmView.state.selection.$from.marks();for(const c of l)if(c.type.name===this.pmView.state.schema.mark("link").type.name){this.keyboardHoveredLinkMark=c,this.keyboardHoveredLinkMarkRange=k.getMarkRange(this.pmView.state.selection.$from,c.type,c.attrs)||void 0;break}}if(this.mouseHoveredLinkMark&&o&&(this.linkMark=this.mouseHoveredLinkMark,this.linkMarkRange=this.mouseHoveredLinkMarkRange),this.keyboardHoveredLinkMark&&(this.linkMark=this.keyboardHoveredLinkMark,this.linkMarkRange=this.keyboardHoveredLinkMarkRange),this.linkMark&&this.editor.isEditable){this.state={show:!0,referencePos:k.posToDOMRect(this.pmView,this.linkMarkRange.from,this.linkMarkRange.to),url:this.linkMark.attrs.href,text:this.pmView.state.doc.textBetween(this.linkMarkRange.from,this.linkMarkRange.to)},this.emitUpdate();return}if((a=this.state)!=null&&a.show&&i&&(!this.linkMark||!this.editor.isEditable)){this.state.show=!1,this.emitUpdate();return}}destroy(){this.pmView.dom.removeEventListener("mouseover",this.mouseOverHandler),this.pmView.root.removeEventListener("scroll",this.scrollHandler,!0),this.pmView.root.removeEventListener("click",this.clickHandler,!0)}}const Qo=new y.PluginKey("LinkToolbarPlugin");class er extends O{constructor(t){super();p(this,"view");p(this,"editLink",(t,o)=>{this.view.editLink(t,o)});p(this,"deleteLink",()=>{this.view.deleteLink()});p(this,"startHideTimer",()=>{this.view.startMenuUpdateTimer()});p(this,"stopHideTimer",()=>{this.view.stopMenuUpdateTimer()});p(this,"closeMenu",()=>this.view.closeMenu());this.addProsemirrorPlugin(new y.Plugin({key:Qo,view:o=>(this.view=new ji(t,o,r=>{this.emit("update",r)}),this.view),props:{handleKeyDown:(o,r)=>r.key==="Escape"&&this.shown?(this.view.closeMenu(),!0):!1}}))}static key(){return"linkToolbar"}onUpdate(t){return this.on("update",t)}get shown(){var t,o;return((o=(t=this.view)==null?void 0:t.state)==null?void 0:o.show)||!1}}const tr=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"],nr="https",Gi=new y.PluginKey("node-selection-keyboard");class Yi extends O{static key(){return"nodeSelectionKeyboard"}constructor(){super(),this.addProsemirrorPlugin(new y.Plugin({key:Gi,props:{handleKeyDown:(n,t)=>{if("node"in n.state.selection){if(t.ctrlKey||t.metaKey)return!1;if(t.key.length===1)return t.preventDefault(),!0;if(t.key==="Enter"&&!t.shiftKey&&!t.altKey&&!t.ctrlKey&&!t.metaKey){const o=n.state.tr;return n.dispatch(o.insert(n.state.tr.selection.$to.after(),n.state.schema.nodes.paragraph.createChecked()).setSelection(new y.TextSelection(o.doc.resolve(n.state.tr.selection.$to.after()+1)))),!0}}return!1}}}))}}const Ji=new y.PluginKey("blocknote-placeholder");class Xi extends O{static key(){return"placeholder"}constructor(n,t){super(),this.addProsemirrorPlugin(new y.Plugin({key:Ji,view:o=>{var c,d;const r=`placeholder-selector-${cn.v4()}`;o.dom.classList.add(r);const s=document.createElement("style"),i=n._tiptapEditor.options.injectNonce;i&&s.setAttribute("nonce",i),((c=n.prosemirrorView)==null?void 0:c.root)instanceof ShadowRoot?n.prosemirrorView.root.append(s):(d=n.prosemirrorView)==null||d.root.head.appendChild(s);const a=s.sheet,l=(u="")=>`.${r} .bn-block-content${u} .bn-inline-content:has(> .ProseMirror-trailingBreak:only-child):before`;try{const{default:u,emptyDocument:h,...f}=t;for(const[b,w]of Object.entries(f)){const C=`[data-content-type="${b}"]`;a.insertRule(`${l(C)} { content: ${JSON.stringify(w)}; }`)}const m="[data-is-only-empty-block]",g="[data-is-empty-and-focused]";a.insertRule(`${l(m)} { content: ${JSON.stringify(h)}; }`),a.insertRule(`${l(g)} { content: ${JSON.stringify(u)}; }`)}catch(u){console.warn("Failed to insert placeholder CSS rule - this is likely due to the browser not supporting certain CSS pseudo-element selectors (:has, :only-child:, or :before)",u)}return{destroy:()=>{var u,h;((u=n.prosemirrorView)==null?void 0:u.root)instanceof ShadowRoot?n.prosemirrorView.root.removeChild(s):(h=n.prosemirrorView)==null||h.root.head.removeChild(s)}}},props:{decorations:o=>{const{doc:r,selection:s}=o;if(!n.isEditable||!s.empty||s.$from.parent.type.spec.code)return;const i=[];o.doc.content.size===6&&i.push(M.Decoration.node(2,4,{"data-is-only-empty-block":"true"}));const a=s.$anchor,l=a.parent;if(l.content.size===0){const c=a.before();i.push(M.Decoration.node(c,c+l.nodeSize,{"data-is-empty-and-focused":"true"}))}return M.DecorationSet.create(r,i)}}}))}}const on=new y.PluginKey("previous-blocks"),Zi={index:"index",level:"level",type:"type",depth:"depth","depth-change":"depth-change"};class Qi extends O{static key(){return"previousBlockType"}constructor(){super();let n;this.addProsemirrorPlugin(new y.Plugin({key:on,view(t){return{update:async(o,r)=>{var s;((s=this.key)==null?void 0:s.getState(o.state).updatedBlocks.size)>0&&(n=setTimeout(()=>{o.dispatch(o.state.tr.setMeta(on,{clearUpdate:!0}))},0))},destroy:()=>{n&&clearTimeout(n)}}},state:{init(){return{prevTransactionOldBlockAttrs:{},currentTransactionOldBlockAttrs:{},updatedBlocks:new Set}},apply(t,o,r,s){if(o.currentTransactionOldBlockAttrs={},o.updatedBlocks.clear(),!t.docChanged||r.doc.eq(s.doc))return o;const i={},a=k.findChildren(r.doc,d=>d.attrs.id),l=new Map(a.map(d=>[d.node.attrs.id,d])),c=k.findChildren(s.doc,d=>d.attrs.id);for(const d of c){const u=l.get(d.node.attrs.id),h=u==null?void 0:u.node.firstChild,f=d.node.firstChild;if(u&&h&&f){const m={index:f.attrs.index,level:f.attrs.level,type:f.type.name,depth:s.doc.resolve(d.pos).depth};let g={index:h.attrs.index,level:h.attrs.level,type:h.type.name,depth:r.doc.resolve(u.pos).depth};i[d.node.attrs.id]=g,t.getMeta("numberedListIndexing")&&(d.node.attrs.id in o.prevTransactionOldBlockAttrs&&(g=o.prevTransactionOldBlockAttrs[d.node.attrs.id]),m.type==="numberedListItem"&&(g.index=m.index)),o.currentTransactionOldBlockAttrs[d.node.attrs.id]=g,JSON.stringify(g)!==JSON.stringify(m)&&(g["depth-change"]=g.depth-m.depth,o.updatedBlocks.add(d.node.attrs.id))}}return o.prevTransactionOldBlockAttrs=i,o}},props:{decorations(t){const o=this.getState(t);if(o.updatedBlocks.size===0)return;const r=[];return t.doc.descendants((s,i)=>{if(!s.attrs.id||!o.updatedBlocks.has(s.attrs.id))return;const a=o.currentTransactionOldBlockAttrs[s.attrs.id],l={};for(const[d,u]of Object.entries(a))l["data-prev-"+Zi[d]]=u||"none";const c=M.Decoration.node(i,i+s.nodeSize,{...l});r.push(c)}),M.DecorationSet.create(t.doc,r)}}}))}}const rn=new y.PluginKey("blocknote-show-selection");class ea extends O{constructor(t){super();p(this,"enabled",!1);this.editor=t,this.addProsemirrorPlugin(new y.Plugin({key:rn,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(t){this.enabled!==t&&(this.enabled=t,this.editor.transact(o=>o.setMeta(rn,{})))}getEnabled(){return this.enabled}}function or(e,n){var t,o;for(;e&&e.parentElement&&e.parentElement!==n.dom&&((t=e.getAttribute)==null?void 0:t.call(e,"data-node-type"))!=="blockContainer";)e=e.parentElement;if(((o=e.getAttribute)==null?void 0:o.call(e,"data-node-type"))==="blockContainer")return{node:e,id:e.getAttribute("data-id")}}class ie extends y.Selection{constructor(t,o){super(t,o);p(this,"nodes");const r=t.node();this.nodes=[],t.doc.nodesBetween(t.pos,o.pos,(s,i,a)=>{if(a!==null&&a.eq(r))return this.nodes.push(s),!1})}static create(t,o,r=o){return new ie(t.resolve(o),t.resolve(r))}content(){return new E.Slice(E.Fragment.from(this.nodes),0,0)}eq(t){if(!(t instanceof ie)||this.nodes.length!==t.nodes.length||this.from!==t.from||this.to!==t.to)return!1;for(let o=0;o<this.nodes.length;o++)if(!this.nodes[o].eq(t.nodes[o]))return!1;return!0}map(t,o){const r=o.mapResult(this.from),s=o.mapResult(this.to);return s.deleted?y.Selection.near(t.resolve(r.pos)):r.deleted?y.Selection.near(t.resolve(s.pos)):new ie(t.resolve(r.pos),t.resolve(s.pos))}toJSON(){return{type:"multiple-node",anchor:this.anchor,head:this.head}}}y.Selection.jsonID("multiple-node",ie);let q;function ta(e,n){let t,o;const r=n.resolve(e.from).node().type.spec.group==="blockContent",s=n.resolve(e.to).node().type.spec.group==="blockContent",i=Math.min(e.$anchor.depth,e.$head.depth);if(r&&s){const a=e.$from.start(i-1),l=e.$to.end(i-1);t=n.resolve(a-1).pos,o=n.resolve(l+1).pos}else t=e.from,o=e.to;return{from:t,to:o}}function sn(e,n,t=n){n===t&&(t+=e.state.doc.resolve(n+1).node().nodeSize);const o=e.domAtPos(n).node.cloneNode(!0),r=e.domAtPos(n).node,s=(u,h)=>Array.prototype.indexOf.call(u.children,h),i=s(r,e.domAtPos(n+1).node.parentElement),a=s(r,e.domAtPos(t-1).node.parentElement);for(let u=r.childElementCount-1;u>=0;u--)(u>a||u<i)&&o.removeChild(o.children[u]);rr(e.root),q=o;const l=q.getElementsByTagName("iframe");for(let u=0;u<l.length;u++){const h=l[u],f=h.parentElement;f&&f.removeChild(h)}const d=e.dom.className.split(" ").filter(u=>u!=="ProseMirror"&&u!=="bn-root"&&u!=="bn-editor").join(" ");q.className=q.className+" bn-drag-preview "+d,e.root instanceof ShadowRoot?e.root.appendChild(q):e.root.body.appendChild(q)}function rr(e){q!==void 0&&(e instanceof ShadowRoot?e.removeChild(q):e.body.removeChild(q),q=void 0)}function na(e,n,t){if(!e.dataTransfer)return;const o=t.prosemirrorView;if(!o)return;const r=F(n.id,o.state.doc);if(!r)throw new Error(`Block with ID ${n.id} not found`);const s=r.posBeforeNode;if(s!=null){const i=o.state.selection,a=o.state.doc,{from:l,to:c}=ta(i,a),d=l<=s&&s<c,u=i.$anchor.node()!==i.$head.node()||i instanceof ie;d&&u?(o.dispatch(o.state.tr.setSelection(ie.create(a,l,c))),sn(o,l,c)):(o.dispatch(o.state.tr.setSelection(y.NodeSelection.create(o.state.doc,s))),sn(o,s));const h=o.state.selection.content(),f=t.pmSchema,m=o.serializeForClipboard(h).dom.innerHTML,g=Me(f,t),b=Ko(h.content),w=g.exportBlocks(b,{}),C=et(w);e.dataTransfer.clearData(),e.dataTransfer.setData("blocknote/html",m),e.dataTransfer.setData("text/html",w),e.dataTransfer.setData("text/plain",C),e.dataTransfer.effectAllowed="move",e.dataTransfer.setDragImage(q,0,0)}}const ye=.1;function yt(e,n,t,o=!0){const r=e.root.elementsFromPoint(n.left+(t==="editor"?50:0),n.top);for(const s of r)if(e.dom.contains(s))return o&&s.closest("[data-node-type=columnList]")?yt(e,{left:n.left+50,top:n.top},t,!1):or(s,e)}function oa(e,n,t){if(!n.dom.firstChild)return;const o=n.dom.firstChild.getBoundingClientRect(),r={left:e.x,top:e.y},s=r.left<o.left,i=r.left>o.right;t==="viewport"&&(s&&(r.left=o.left+10),i&&(r.left=o.right-10));let a=yt(n,r,t);if(!i&&a){const l=a.node.getBoundingClientRect();r.left=l.right-10,a=yt(n,r,"viewport",!1)}return a}class sr{constructor(n,t,o,r){p(this,"state");p(this,"emitUpdate");p(this,"mousePos");p(this,"hoveredBlock");p(this,"menuFrozen",!1);p(this,"isDragOrigin",!1);p(this,"updateState",n=>{this.state=n,this.emitUpdate(this.state)});p(this,"updateStateFromMousePos",()=>{var o,r,s,i;if(this.menuFrozen||!this.mousePos)return;const n=oa(this.mousePos,this.pmView,this.sideMenuDetection);if(!n||!this.editor.isEditable){(o=this.state)!=null&&o.show&&(this.state.show=!1,this.updateState(this.state));return}if((r=this.state)!=null&&r.show&&((s=this.hoveredBlock)!=null&&s.hasAttribute("data-id"))&&((i=this.hoveredBlock)==null?void 0:i.getAttribute("data-id"))===n.id)return;this.hoveredBlock=n.node;const t=n.node.firstChild;if(t&&this.editor.isEditable){const a=t.getBoundingClientRect(),l=n.node.closest("[data-node-type=column]");this.updateState({show:!0,referencePos:new DOMRect(l?l.firstElementChild.getBoundingClientRect().x:this.pmView.dom.firstChild.getBoundingClientRect().x,a.y,a.width,a.height),block:this.editor.getBlock(this.hoveredBlock.getAttribute("data-id"))})}});p(this,"onDrop",n=>{var r,s;if(this.pmView.dragging===null)return;this.editor._tiptapEditor.commands.blur();const t=n.target instanceof Node&&((r=n.target instanceof HTMLElement?n.target:n.target.parentElement)==null?void 0:r.closest(".bn-editor"))||null;if(t&&(!this.isDragOrigin&&this.pmView.dom===t?this.pmView.dispatch(this.pmView.state.tr.setSelection(y.TextSelection.create(this.pmView.state.tr.doc,this.pmView.state.tr.selection.to))):this.isDragOrigin&&this.pmView.dom!==t&&setTimeout(()=>this.pmView.dispatch(this.pmView.state.tr.deleteSelection()),0)),this.sideMenuDetection==="editor"||n.synthetic||!((s=n.dataTransfer)!=null&&s.types.includes("blocknote/html")))return;const o=this.pmView.posAtCoords({left:n.clientX,top:n.clientY});if(!o||o.inside===-1){const i=this.createSyntheticEvent(n);this.pmView.dom.dispatchEvent(i)}});p(this,"onDragEnd",()=>{this.pmView.dragging=null});p(this,"onDragStart",n=>{var i;const t=(i=n.dataTransfer)==null?void 0:i.getData("blocknote/html");if(!t)return;if(this.pmView.dragging)throw new Error("New drag was started while an existing drag is ongoing");const o=document.createElement("div");o.innerHTML=t;const s=E.DOMParser.fromSchema(this.pmView.state.schema).parse(o,{topNode:this.pmView.state.schema.nodes.blockGroup.create()});this.pmView.dragging={slice:new E.Slice(s.content,0,0),move:!0}});p(this,"onDragOver",n=>{var o;if(this.sideMenuDetection==="editor"||n.synthetic||!((o=n.dataTransfer)!=null&&o.types.includes("blocknote/html")))return;const t=this.pmView.posAtCoords({left:n.clientX,top:n.clientY});if(!t||t.inside===-1&&this.pmView.dom.firstChild){const r=this.createSyntheticEvent(n);this.pmView.dom.dispatchEvent(r)}});p(this,"onKeyDown",n=>{var t;(t=this.state)!=null&&t.show&&this.editor.isFocused()&&(this.state.show=!1,this.emitUpdate(this.state))});p(this,"onMouseMove",n=>{var s;if(this.menuFrozen)return;this.mousePos={x:n.clientX,y:n.clientY};const t=this.pmView.dom.getBoundingClientRect(),o=this.mousePos.x>t.left&&this.mousePos.x<t.right&&this.mousePos.y>t.top&&this.mousePos.y<t.bottom,r=this.pmView.dom.parentElement;if(o&&n&&n.target&&!(r===n.target||r.contains(n.target))){(s=this.state)!=null&&s.show&&(this.state.show=!1,this.emitUpdate(this.state));return}this.updateStateFromMousePos()});p(this,"onScroll",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.referencePos=this.hoveredBlock.getBoundingClientRect(),this.emitUpdate(this.state))});this.editor=n,this.sideMenuDetection=t,this.pmView=o,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized side menu");r(this.state)},this.pmView.root.addEventListener("dragstart",this.onDragStart),this.pmView.root.addEventListener("dragover",this.onDragOver),this.pmView.root.addEventListener("drop",this.onDrop,!0),this.pmView.root.addEventListener("dragend",this.onDragEnd,!0),Qe(),this.pmView.root.addEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.addEventListener("keydown",this.onKeyDown,!0),o.root.addEventListener("scroll",this.onScroll,!0)}createSyntheticEvent(n){const t=new Event(n.type,n),o=this.pmView.dom.firstChild.getBoundingClientRect();return t.clientX=n.clientX,t.clientY=n.clientY,n.clientX<o.left&&n.clientX>o.left-o.width*ye?t.clientX=o.left+o.width*ye/2:n.clientX>o.right&&n.clientX<o.right+o.width*ye?t.clientX=o.right-o.width*ye/2:(n.clientX<o.left||n.clientX>o.right)&&(t.clientX=o.left+ye*o.width*2),t.clientY=Math.min(Math.max(n.clientY,o.top),o.top+o.height),t.dataTransfer=n.dataTransfer,t.preventDefault=()=>n.preventDefault(),t.synthetic=!0,t}update(n,t){var r;!t.doc.eq(this.pmView.state.doc)&&((r=this.state)!=null&&r.show)&&this.updateStateFromMousePos()}destroy(){var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate(this.state)),this.pmView.root.removeEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.removeEventListener("dragstart",this.onDragStart),this.pmView.root.removeEventListener("dragover",this.onDragOver),this.pmView.root.removeEventListener("drop",this.onDrop,!0),this.pmView.root.removeEventListener("dragend",this.onDragEnd,!0),this.pmView.root.removeEventListener("keydown",this.onKeyDown,!0),this.pmView.root.removeEventListener("scroll",this.onScroll,!0)}}const ir=new y.PluginKey("SideMenuPlugin");class ar extends O{constructor(t,o){super();p(this,"view");p(this,"blockDragStart",(t,o)=>{this.view&&(this.view.isDragOrigin=!0),na(t,o,this.editor)});p(this,"blockDragEnd",()=>{this.editor.prosemirrorView&&rr(this.editor.prosemirrorView.root),this.view&&(this.view.isDragOrigin=!1)});p(this,"freezeMenu",()=>{this.view.menuFrozen=!0,this.view.state.show=!0,this.view.emitUpdate(this.view.state)});p(this,"unfreezeMenu",()=>{this.view.menuFrozen=!1,this.view.state.show=!1,this.view.emitUpdate(this.view.state)});this.editor=t,this.addProsemirrorPlugin(new y.Plugin({key:ir,view:r=>(this.view=new sr(t,o,r,s=>{this.emit("update",s)}),this.view)}))}static key(){return"sideMenu"}onUpdate(t){return this.on("update",t)}}const Ne=new Map;function ra(e){if(Ne.has(e))return Ne.get(e);const n=new pe.Mapping;return e._tiptapEditor.on("transaction",({transaction:t})=>{n.appendMapping(t.mapping)}),e._tiptapEditor.on("destroy",()=>{Ne.delete(e)}),Ne.set(e,n),n}function lr(e,n,t="left"){const o=N.ySyncPluginKey.getState(e._tiptapEditor.state);if(!o){const s=ra(e),i=s.maps.length;return()=>s.slice(i).map(n,t==="left"?-1:1)}const r=N.absolutePositionToRelativePosition(n+(t==="right"?1:0),o.binding.type,o.binding.mapping);return()=>{const s=N.ySyncPluginKey.getState(e._tiptapEditor.state),i=N.relativePositionToAbsolutePosition(s.doc,s.binding.type,r,s.binding.mapping);if(i===null)throw new Error("Position not found, cannot track positions");return i+(t==="right"?-1:0)}}const sa=k.findParentNode(e=>e.type.name==="blockContainer");class ia{constructor(n,t){p(this,"state");p(this,"emitUpdate");p(this,"rootEl");p(this,"pluginState");p(this,"handleScroll",()=>{var n,t;if((n=this.state)!=null&&n.show){const o=(t=this.rootEl)==null?void 0:t.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);if(!o)return;this.state.referencePos=o.getBoundingClientRect(),this.emitUpdate(this.pluginState.triggerCharacter)}});p(this,"closeMenu",()=>{this.editor.transact(n=>n.setMeta(ue,null))});p(this,"clearQuery",()=>{this.pluginState!==void 0&&this.editor._tiptapEditor.chain().focus().deleteRange({from:this.pluginState.queryStartPos()-(this.pluginState.deleteTriggerCharacter?this.pluginState.triggerCharacter.length:0),to:this.editor.transact(n=>n.selection.from)}).run()});var o,r;this.editor=n,this.pluginState=void 0,this.emitUpdate=s=>{var i;if(!this.state)throw new Error("Attempting to update uninitialized suggestions menu");t(s,{...this.state,ignoreQueryLength:(i=this.pluginState)==null?void 0:i.ignoreQueryLength})},this.rootEl=(o=this.editor.prosemirrorView)==null?void 0:o.root,(r=this.rootEl)==null||r.addEventListener("scroll",this.handleScroll,!0)}update(n,t){var c;const o=ue.getState(t),r=ue.getState(n.state),s=o===void 0&&r!==void 0,i=o!==void 0&&r===void 0;if(!s&&!(o!==void 0&&r!==void 0)&&!i)return;if(this.pluginState=i?o:r,i||!this.editor.isEditable){this.state&&(this.state.show=!1),this.emitUpdate(this.pluginState.triggerCharacter);return}const l=(c=this.rootEl)==null?void 0:c.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);this.editor.isEditable&&l&&(this.state={show:!0,referencePos:l.getBoundingClientRect(),query:this.pluginState.query},this.emitUpdate(this.pluginState.triggerCharacter))}destroy(){var n;(n=this.rootEl)==null||n.removeEventListener("scroll",this.handleScroll,!0)}}const ue=new y.PluginKey("SuggestionMenuPlugin");class cr extends O{constructor(t){super();p(this,"view");p(this,"triggerCharacters",[]);p(this,"addTriggerCharacter",t=>{this.triggerCharacters.push(t)});p(this,"removeTriggerCharacter",t=>{this.triggerCharacters=this.triggerCharacters.filter(o=>o!==t)});p(this,"closeMenu",()=>this.view.closeMenu());p(this,"clearQuery",()=>this.view.clearQuery());const o=this.triggerCharacters;this.addProsemirrorPlugin(new y.Plugin({key:ue,view:()=>(this.view=new ia(t,(r,s)=>{this.emit(`update ${r}`,s)}),this.view),state:{init(){},apply:(r,s,i,a)=>{if(r.getMeta("orderedListIndexing")!==void 0||r.selection.$from.parent.type.spec.code)return s;const l=r.getMeta(ue);if(typeof l=="object"&&l!==null){s&&this.closeMenu();const d=lr(t,a.selection.from-l.triggerCharacter.length);return{triggerCharacter:l.triggerCharacter,deleteTriggerCharacter:l.deleteTriggerCharacter!==!1,queryStartPos:()=>d()+l.triggerCharacter.length,query:"",decorationId:`id_${Math.floor(Math.random()*4294967295)}`,ignoreQueryLength:l==null?void 0:l.ignoreQueryLength}}if(s===void 0)return s;if(a.selection.from!==a.selection.to||l===null||r.getMeta("focus")||r.getMeta("blur")||r.getMeta("pointer")||s.triggerCharacter!==void 0&&a.selection.from<s.queryStartPos()||!a.selection.$from.sameParent(a.doc.resolve(s.queryStartPos())))return;const c={...s};return c.query=a.doc.textBetween(s.queryStartPos(),a.selection.from),c}},props:{handleTextInput(r,s,i,a){return o.includes(a)?(r.dispatch(r.state.tr.insertText(a)),r.dispatch(r.state.tr.setMeta(ue,{triggerCharacter:a}).scrollIntoView()),!0):!1},decorations(r){const s=this.getState(r);if(s===void 0)return null;if(!s.deleteTriggerCharacter){const i=sa(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(t,o){return this.triggerCharacters.includes(t)||this.addTriggerCharacter(t),this.on(`update ${t}`,o)}get shown(){var t,o;return((o=(t=this.view)==null?void 0:t.state)==null?void 0:o.show)||!1}}function aa(e,n){e.suggestionMenus.addTriggerCharacter(n)}const la=k.Mark.create({name:"insertion",inclusive:!1,excludes:"deletion modification insertion",addAttributes(){return{id:{default:null,validate:"number"}}},extendMarkSchema(e){return e.name!=="insertion"?{}:{blocknoteIgnore:!0,inclusive:!1,toDOM(n,t){return["ins",{"data-id":String(n.attrs.id),"data-inline":String(t),...!t&&{style:"display: contents"}},0]},parseDOM:[{tag:"ins",getAttrs(n){return n.dataset.id?{id:parseInt(n.dataset.id,10)}:!1}}]}}}),ca=k.Mark.create({name:"deletion",inclusive:!1,excludes:"insertion modification deletion",addAttributes(){return{id:{default:null,validate:"number"}}},extendMarkSchema(e){return e.name!=="deletion"?{}:{blocknoteIgnore:!0,inclusive:!1,toDOM(n,t){return["del",{"data-id":String(n.attrs.id),"data-inline":String(t),...!t&&{style:"display: contents"}},0]},parseDOM:[{tag:"del",getAttrs(n){return n.dataset.id?{id:parseInt(n.dataset.id,10)}:!1}}]}}}),da=k.Mark.create({name:"modification",inclusive:!1,excludes:"deletion insertion",addAttributes(){return{id:{default:null,validate:"number"},type:{validate:"string"},attrName:{default:null,validate:"string|null"},previousValue:{default:null},newValue:{default:null}}},extendMarkSchema(e){return e.name!=="modification"?{}:{blocknoteIgnore:!0,inclusive:!1,toDOM(n,t){return[t?"span":"div",{"data-type":"modification","data-id":String(n.attrs.id),"data-mod-type":n.attrs.type,"data-mod-prev-val":JSON.stringify(n.attrs.previousValue),"data-mod-new-val":JSON.stringify(n.attrs.newValue)},0]},parseDOM:[{tag:"span[data-type='modification']",getAttrs(n){return n.dataset.id?{id:parseInt(n.dataset.id,10),type:n.dataset.modType,previousValue:n.dataset.modPrevVal,newValue:n.dataset.modNewVal}:!1}},{tag:"div[data-type='modification']",getAttrs(n){return n.dataset.id?{id:parseInt(n.dataset.id,10),type:n.dataset.modType,previousValue:n.dataset.modPrevVal}:!1}}]}}});let U;function an(e){U||(U=document.createElement("div"),U.innerHTML="_",U.style.opacity="0",U.style.height="1px",U.style.width="1px",e instanceof Document?e.body.appendChild(U):e.appendChild(U))}function ua(e){U&&(e instanceof Document?e.body.removeChild(U):e.removeChild(U),U=void 0)}function He(e){return Array.prototype.indexOf.call(e.parentElement.childNodes,e)}function pa(e){let n=e;for(;n&&n.nodeName!=="TD"&&n.nodeName!=="TH"&&!n.classList.contains("tableWrapper");){if(n.classList.contains("ProseMirror"))return;const t=n.parentNode;if(!t||!(t instanceof Element))return;n=t}return n.nodeName==="TD"||n.nodeName==="TH"?{type:"cell",domNode:n,tbodyNode:n.closest("tbody")}:{type:"wrapper",domNode:n,tbodyNode:n.querySelector("tbody")}}function ha(e,n){const t=n.querySelectorAll(e);for(let o=0;o<t.length;o++)t[o].style.visibility="hidden"}class dr{constructor(n,t,o){p(this,"state");p(this,"emitUpdate");p(this,"tableId");p(this,"tablePos");p(this,"tableElement");p(this,"menuFrozen",!1);p(this,"mouseState","up");p(this,"prevWasEditable",null);p(this,"viewMousedownHandler",()=>{this.mouseState="down"});p(this,"mouseUpHandler",n=>{this.mouseState="up",this.mouseMoveHandler(n)});p(this,"mouseMoveHandler",n=>{var c,d,u,h,f,m,g;if(this.menuFrozen||this.mouseState==="selecting"||!(n.target instanceof Element)||!this.pmView.dom.contains(n.target))return;const t=pa(n.target);if((t==null?void 0:t.type)==="cell"&&this.mouseState==="down"&&!((c=this.state)!=null&&c.draggingState)){this.mouseState="selecting",(d=this.state)!=null&&d.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate());return}if(!t||!this.editor.isEditable){(u=this.state)!=null&&u.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate());return}if(!t.tbodyNode)return;const o=t.tbodyNode.getBoundingClientRect(),r=or(t.domNode,this.pmView);if(!r)return;this.tableElement=r.node;let s;const i=this.editor.transact(b=>F(r.id,b.doc));if(!i)throw new Error(`Block with ID ${r.id} not found`);const a=T(i.node,this.editor.pmSchema,this.editor.schema.blockSchema,this.editor.schema.inlineContentSchema,this.editor.schema.styleSchema);if(So("table",a,this.editor)&&(this.tablePos=i.posBeforeNode+1,s=a),!s)return;this.tableId=r.id;const l=(h=t.domNode.closest(".tableWrapper"))==null?void 0:h.querySelector(".table-widgets-container");if((t==null?void 0:t.type)==="wrapper"){const b=n.clientY>=o.bottom-1&&n.clientY<o.bottom+20,w=n.clientX>=o.right-1&&n.clientX<o.right+20,C=n.clientX>o.right||n.clientY>o.bottom;this.state={...this.state,show:!0,showAddOrRemoveRowsButton:b,showAddOrRemoveColumnsButton:w,referencePosTable:o,block:s,widgetContainer:l,colIndex:C||(f=this.state)==null?void 0:f.colIndex,rowIndex:C||(m=this.state)==null?void 0:m.rowIndex,referencePosCell:C||(g=this.state)==null?void 0:g.referencePosCell}}else{const b=He(t.domNode),w=He(t.domNode.parentElement),C=t.domNode.getBoundingClientRect();if(this.state!==void 0&&this.state.show&&this.tableId===r.id&&this.state.rowIndex===w&&this.state.colIndex===b)return;this.state={show:!0,showAddOrRemoveColumnsButton:b===s.content.rows[0].cells.length-1,showAddOrRemoveRowsButton:w===s.content.rows.length-1,referencePosTable:o,block:s,draggingState:void 0,referencePosCell:C,colIndex:b,rowIndex:w,widgetContainer:l}}return this.emitUpdate(),!1});p(this,"dragOverHandler",n=>{var h;if(((h=this.state)==null?void 0:h.draggingState)===void 0)return;n.preventDefault(),n.dataTransfer.dropEffect="move",ha(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline",this.pmView.root);const t={left:Math.min(Math.max(n.clientX,this.state.referencePosTable.left+1),this.state.referencePosTable.right-1),top:Math.min(Math.max(n.clientY,this.state.referencePosTable.top+1),this.state.referencePosTable.bottom-1)},o=this.pmView.root.elementsFromPoint(t.left,t.top).filter(f=>f.tagName==="TD"||f.tagName==="TH");if(o.length===0)return;const r=o[0];let s=!1;const i=He(r.parentElement),a=He(r),l=this.state.draggingState.draggedCellOrientation==="row"?this.state.rowIndex:this.state.colIndex,d=(this.state.draggingState.draggedCellOrientation==="row"?i:a)!==l;(this.state.rowIndex!==i||this.state.colIndex!==a)&&(this.state.rowIndex=i,this.state.colIndex=a,this.state.referencePosCell=r.getBoundingClientRect(),s=!0);const u=this.state.draggingState.draggedCellOrientation==="row"?t.top:t.left;this.state.draggingState.mousePos!==u&&(this.state.draggingState.mousePos=u,s=!0),s&&this.emitUpdate(),d&&this.editor.transact(f=>f.setMeta(de,!0))});p(this,"dropHandler",n=>{if(this.mouseState="up",this.state===void 0||this.state.draggingState===void 0)return!1;if(this.state.rowIndex===void 0||this.state.colIndex===void 0)throw new Error("Attempted to drop table row or column, but no table block was hovered prior.");n.preventDefault();const{draggingState:t,colIndex:o,rowIndex:r}=this.state,s=this.state.block.content.columnWidths;if(t.draggedCellOrientation==="row"){if(!Bn(this.state.block,t.originalIndex,r))return!1;const i=Xr(this.state.block,t.originalIndex,r);this.editor.updateBlock(this.state.block,{type:"table",content:{...this.state.block.content,rows:i}})}else{if(!Tn(this.state.block,t.originalIndex,o))return!1;const i=Jr(this.state.block,t.originalIndex,o),[a]=s.splice(t.originalIndex,1);s.splice(o,0,a),this.editor.updateBlock(this.state.block,{type:"table",content:{...this.state.block.content,columnWidths:s,rows:i}})}return this.editor.setTextCursorPosition(this.state.block.id),!0});this.editor=n,this.pmView=t,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized image toolbar");o(this.state)},t.dom.addEventListener("mousemove",this.mouseMoveHandler),t.dom.addEventListener("mousedown",this.viewMousedownHandler),window.addEventListener("mouseup",this.mouseUpHandler),t.root.addEventListener("dragover",this.dragOverHandler),t.root.addEventListener("drop",this.dropHandler)}update(){var r;if(!this.state||!this.state.show)return;if(this.state.block=this.editor.getBlock(this.state.block.id),!this.state.block||this.state.block.type!=="table"||!((r=this.tableElement)!=null&&r.isConnected)){this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate();return}const{height:n,width:t}=Mt(this.state.block);this.state.rowIndex!==void 0&&this.state.colIndex!==void 0&&(this.state.rowIndex>=n&&(this.state.rowIndex=n-1),this.state.colIndex>=t&&(this.state.colIndex=t-1));const o=this.tableElement.querySelector("tbody");if(!o)throw new Error("Table block does not contain a 'tbody' HTML element. This should never happen.");if(this.state.rowIndex!==void 0&&this.state.colIndex!==void 0){const i=o.children[this.state.rowIndex].children[this.state.colIndex];i?this.state.referencePosCell=i.getBoundingClientRect():(this.state.rowIndex=void 0,this.state.colIndex=void 0)}this.state.referencePosTable=o.getBoundingClientRect(),this.emitUpdate()}destroy(){this.pmView.dom.removeEventListener("mousemove",this.mouseMoveHandler),window.removeEventListener("mouseup",this.mouseUpHandler),this.pmView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.pmView.root.removeEventListener("dragover",this.dragOverHandler),this.pmView.root.removeEventListener("drop",this.dropHandler)}}const de=new y.PluginKey("TableHandlesPlugin");class ur extends O{constructor(t){super();p(this,"view");p(this,"colDragStart",t=>{if(this.view.state===void 0||this.view.state.colIndex===void 0)throw new Error("Attempted to drag table column, but no table block was hovered prior.");if(this.view.state.draggingState={draggedCellOrientation:"col",originalIndex:this.view.state.colIndex,mousePos:t.clientX},this.view.emitUpdate(),this.editor.transact(o=>o.setMeta(de,{draggedCellOrientation:this.view.state.draggingState.draggedCellOrientation,originalIndex:this.view.state.colIndex,newIndex:this.view.state.colIndex,tablePos:this.view.tablePos})),!this.editor.prosemirrorView)throw new Error("Editor view not initialized.");an(this.editor.prosemirrorView.root),t.dataTransfer.setDragImage(U,0,0),t.dataTransfer.effectAllowed="move"});p(this,"rowDragStart",t=>{if(this.view.state===void 0||this.view.state.rowIndex===void 0)throw new Error("Attempted to drag table row, but no table block was hovered prior.");if(this.view.state.draggingState={draggedCellOrientation:"row",originalIndex:this.view.state.rowIndex,mousePos:t.clientY},this.view.emitUpdate(),this.editor.transact(o=>o.setMeta(de,{draggedCellOrientation:this.view.state.draggingState.draggedCellOrientation,originalIndex:this.view.state.rowIndex,newIndex:this.view.state.rowIndex,tablePos:this.view.tablePos})),!this.editor.prosemirrorView)throw new Error("Editor view not initialized.");an(this.editor.prosemirrorView.root),t.dataTransfer.setDragImage(U,0,0),t.dataTransfer.effectAllowed="copyMove"});p(this,"dragEnd",()=>{if(this.view.state===void 0)throw new Error("Attempted to drag table row, but no table block was hovered prior.");if(this.view.state.draggingState=void 0,this.view.emitUpdate(),this.editor.transact(t=>t.setMeta(de,null)),!this.editor.prosemirrorView)throw new Error("Editor view not initialized.");ua(this.editor.prosemirrorView.root)});p(this,"freezeHandles",()=>{this.view.menuFrozen=!0});p(this,"unfreezeHandles",()=>{this.view.menuFrozen=!1});p(this,"getCellsAtRowHandle",(t,o)=>ct(t,o));p(this,"getCellsAtColumnHandle",(t,o)=>dt(t,o));p(this,"setCellSelection",(t,o,r=o)=>{const s=this.view;if(!s)throw new Error("Table handles view not initialized");const i=t.doc.resolve(s.tablePos+1),a=t.doc.resolve(i.posAtIndex(o.row)+1),l=t.doc.resolve(a.posAtIndex(o.col)),c=t.doc.resolve(i.posAtIndex(r.row)+1),d=t.doc.resolve(c.posAtIndex(r.col)),u=t.tr;return u.setSelection(new A.CellSelection(l,d)),t.apply(u)});p(this,"addRowOrColumn",(t,o)=>{this.editor.exec((r,s)=>{const i=this.setCellSelection(r,o.orientation==="row"?{row:t,col:0}:{row:0,col:t});return o.orientation==="row"?o.side==="above"?A.addRowBefore(i,s):A.addRowAfter(i,s):o.side==="left"?A.addColumnBefore(i,s):A.addColumnAfter(i,s)})});p(this,"removeRowOrColumn",(t,o)=>o==="row"?this.editor.exec((r,s)=>{const i=this.setCellSelection(r,{row:t,col:0});return A.deleteRow(i,s)}):this.editor.exec((r,s)=>{const i=this.setCellSelection(r,{row:0,col:t});return A.deleteColumn(i,s)}));p(this,"mergeCells",t=>this.editor.exec((o,r)=>{const s=t?this.setCellSelection(o,t.relativeStartCell,t.relativeEndCell):o;return A.mergeCells(s,r)}));p(this,"splitCell",t=>this.editor.exec((o,r)=>{const s=t?this.setCellSelection(o,t):o;return A.splitCell(s,r)}));p(this,"getCellSelection",()=>this.editor.transact(t=>{const o=t.selection;let r=o.$from,s=o.$to;if(gt(o)){const{ranges:m}=o;m.forEach(g=>{r=g.$from.min(r??g.$from),s=g.$to.max(s??g.$to)})}else if(r=t.doc.resolve(o.$from.pos-o.$from.parentOffset-1),s=t.doc.resolve(o.$to.pos-o.$to.parentOffset-1),r.pos===0||s.pos===0)return;const i=t.doc.resolve(r.pos-r.parentOffset-1),a=t.doc.resolve(s.pos-s.parentOffset-1),l=t.doc.resolve(i.pos-i.parentOffset-1),c=r.index(i.depth),d=i.index(l.depth),u=s.index(a.depth),h=a.index(l.depth),f=[];for(let m=d;m<=h;m++)for(let g=c;g<=u;g++)f.push({row:m,col:g});return{from:{row:d,col:c},to:{row:h,col:u},cells:f}}));p(this,"getMergeDirection",t=>this.editor.transact(o=>{const r=gt(o.selection)?o.selection:void 0;if(!r||!t||r.ranges.length<=1)return;const s=this.getCellSelection();if(s)return es(s.from,s.to,t)?"vertical":"horizontal"}));p(this,"cropEmptyRowsOrColumns",(t,o)=>Zr(t,o));p(this,"addRowsOrColumns",(t,o,r)=>Qr(t,o,r));this.editor=t,this.addProsemirrorPlugin(new y.Plugin({key:de,view:o=>(this.view=new dr(t,o,r=>{this.emit("update",r)}),this.view),props:{decorations:o=>{if(this.view===void 0||this.view.state===void 0||this.view.state.draggingState===void 0||this.view.tablePos===void 0)return;const r=this.view.state.draggingState.draggedCellOrientation==="row"?this.view.state.rowIndex:this.view.state.colIndex;if(r===void 0)return;const s=[],{block:i,draggingState:a}=this.view.state,{originalIndex:l,draggedCellOrientation:c}=a;if(r===l||!i||c==="row"&&!Bn(i,l,r)||c==="col"&&!Tn(i,l,r))return M.DecorationSet.create(o.doc,s);const d=o.doc.resolve(this.view.tablePos+1);return this.view.state.draggingState.draggedCellOrientation==="row"?ct(this.view.state.block,r).forEach(({row:h,col:f})=>{const m=o.doc.resolve(d.posAtIndex(h)+1),g=o.doc.resolve(m.posAtIndex(f)+1),b=g.node(),w=g.pos+(r>l?b.nodeSize-2:0);s.push(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>l?C.style.bottom="-2px":C.style.top="-3px",C.style.height="4px",C}))}):dt(this.view.state.block,r).forEach(({row:h,col:f})=>{const m=o.doc.resolve(d.posAtIndex(h)+1),g=o.doc.resolve(m.posAtIndex(f)+1),b=g.node(),w=g.pos+(r>l?b.nodeSize-2:0);s.push(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>l?C.style.right="-2px":C.style.left="-3px",C.style.width="4px",C}))}),M.DecorationSet.create(o.doc,s)}}}))}static key(){return"tableHandles"}onUpdate(t){return this.on("update",t)}}const fa=k.Extension.create({name:"textAlignment",addGlobalAttributes(){return[{types:["paragraph","heading","bulletListItem","numberedListItem","checkListItem","tableCell","tableHeader"],attributes:{textAlignment:{default:"left",parseHTML:e=>e.getAttribute("data-text-alignment"),renderHTML:e=>e.textAlignment==="left"?{}:{"data-text-alignment":e.textAlignment}}}}]}}),ma=k.Extension.create({name:"blockTextColor",addGlobalAttributes(){return[{types:["blockContainer","tableCell","tableHeader"],attributes:{textColor:{default:I.textColor.default,parseHTML:e=>e.hasAttribute("data-text-color")?e.getAttribute("data-text-color"):I.textColor.default,renderHTML:e=>e.textColor===I.textColor.default?{}:{"data-text-color":e.textColor}}}}]}}),ga=k.Extension.create({name:"trailingNode",addProseMirrorPlugins(){const e=new y.PluginKey(this.name);return[new y.Plugin({key:e,appendTransaction:(n,t,o)=>{const{doc:r,tr:s,schema:i}=o,a=e.getState(o),l=r.content.size-2,c=i.nodes.blockContainer,d=i.nodes.paragraph;if(a)return s.insert(l,c.create(void 0,d.create()))},state:{init:(n,t)=>{},apply:(n,t)=>{if(!n.docChanged)return t;let o=n.doc.lastChild;if(!o||o.type.name!=="blockGroup")throw new Error("Expected blockGroup");if(o=o.lastChild,!o||o.type.name!=="blockContainer")return!0;const r=o.firstChild;if(!r)throw new Error("Expected blockContent");return o.nodeSize>4||r.type.spec.content!=="inline*"}}})]}}),ba={blockColor:"data-block-color",blockStyle:"data-block-style",id:"data-id",depth:"data-depth",depthChange:"data-depth-change"},ka=k.Node.create({name:"blockContainer",group:"blockGroupChild bnBlock",content:"blockContent blockGroup?",priority:50,defining:!0,marks:"insertion modification deletion",parseHTML(){return[{tag:"div[data-node-type="+this.name+"]",getAttrs:e=>{if(typeof e=="string")return!1;const n={};for(const[t,o]of Object.entries(ba))e.getAttribute(o)&&(n[t]=e.getAttribute(o));return n}},{tag:'div[data-node-type="blockOuter"]',skip:!0}]},renderHTML({HTMLAttributes:e}){var r;const n=document.createElement("div");n.className="bn-block-outer",n.setAttribute("data-node-type","blockOuter");for(const[s,i]of Object.entries(e))s!=="class"&&n.setAttribute(s,i);const t={...((r=this.options.domAttributes)==null?void 0:r.block)||{},...e},o=document.createElement("div");o.className=X("bn-block",t.class),o.setAttribute("data-node-type",this.name);for(const[s,i]of Object.entries(t))s!=="class"&&o.setAttribute(s,i);return n.appendChild(o),{dom:n,contentDOM:o}}}),wa=k.Node.create({name:"blockGroup",group:"childContainer",content:"blockGroupChild+",marks:"deletion insertion modification",parseHTML(){return[{tag:"div",getAttrs:e=>typeof e=="string"?!1:e.getAttribute("data-node-type")==="blockGroup"?null:!1}]},renderHTML({HTMLAttributes:e}){var o;const n={...((o=this.options.domAttributes)==null?void 0:o.blockGroup)||{},...e},t=document.createElement("div");t.className=X("bn-block-group",n.class),t.setAttribute("data-node-type","blockGroup");for(const[r,s]of Object.entries(n))r!=="class"&&t.setAttribute(r,s);return{dom:t,contentDOM:t}}}),ya=k.Node.create({name:"doc",topNode:!0,content:"blockGroup",marks:"insertion modification deletion"});class Ca extends O{constructor({editor:t,collaboration:o}){super(t);p(this,"editor");p(this,"collaboration");p(this,"forkedState");this.editor=t,this.collaboration=o}static key(){return"ForkYDocPlugin"}findTypeInOtherYdoc(t,o){const r=t.doc;if(t._item===null){const s=Array.from(r.share.keys()).find(i=>r.share.get(i)===t);if(s==null)throw new Error("type does not exist in other ydoc");return o.get(s,t.constructor)}else{const s=t._item,i=o.store.clients.get(s.id.client)??[],a=ce.findIndexSS(i,s.id.clock);return i[a].content.type}}get isForkedFromRemote(){return this.forkedState!==void 0}fork(){if(this.isForkedFromRemote)return;const t=this.collaboration.fragment;if(!t)throw new Error("No fragment to fork from");const o=new ce.Doc;ce.applyUpdate(o,ce.encodeStateAsUpdate(t.doc));const r=this.findTypeInOtherYdoc(t,o);this.forkedState={originalFragment:t,forkedFragment:r},this.editor._tiptapEditor.unregisterPlugin([N.yCursorPluginKey,N.yUndoPluginKey,N.ySyncPluginKey]),this.editor._tiptapEditor.registerPlugin(new kt(r).plugins[0]),this.editor._tiptapEditor.registerPlugin(new wt().plugins[0]),this.emit("forked",!0)}merge({keepChanges:t}){if(!this.forkedState)return;this.editor._tiptapEditor.unregisterPlugin(N.ySyncPluginKey),this.editor._tiptapEditor.unregisterPlugin(N.yUndoPluginKey);const{originalFragment:o,forkedFragment:r}=this.forkedState;if(t){const s=ce.encodeStateAsUpdate(r.doc);ce.applyUpdate(o.doc,s)}this.editor.extensions.ySyncPlugin=new kt(o),this.editor.extensions.yCursorPlugin=new $e(this.collaboration),this.editor.extensions.yUndoPlugin=new wt,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]),this.forkedState=void 0,this.emit("forked",!1)}}const pr=e=>{var r;const n={},t=va(e);for(const s of t)n[s.name]=s;e.collaboration&&(n.ySyncPlugin=new kt(e.collaboration.fragment),n.yUndoPlugin=new wt,(r=e.collaboration.provider)!=null&&r.awareness&&(n.yCursorPlugin=new $e(e.collaboration)),n.forkYDocPlugin=new Ca({editor:e.editor,collaboration:e.collaboration})),n.formattingToolbar=new Xo(e.editor),n.linkToolbar=new er(e.editor),n.sideMenu=new ar(e.editor,e.sideMenuDetection),n.suggestionMenus=new cr(e.editor),n.filePanel=new Go(e.editor),n.placeholder=new Xi(e.editor,e.placeholders),(e.animations??!0)&&(n.animations=new Qi),e.tableHandles&&(n.tableHandles=new ur(e.editor)),n.nodeSelectionKeyboard=new Yi,n.showSelection=new ea(e.editor),e.comments&&(n.comments=new $i(e.editor,e.comments.threadStore,qo.name));const o=e.disableExtensions||[];for(const s of o)delete n[s];return n};let ln=!1;const va=e=>{const n=[k.extensions.ClipboardTextSerializer,k.extensions.Commands,k.extensions.Editable,k.extensions.FocusEvents,k.extensions.Tabindex,Mr.Gapcursor,k.Extension.create({name:"dropCursor",addProseMirrorPlugins:()=>[e.dropCursor({width:5,color:"#ddeeff",editor:e.editor})]}),Be.configure({types:["blockContainer","columnList","column"],setIdAttribute:e.setIdAttribute}),zi,Ar.Text,la,ca,da,Lr.Link.extend({inclusive:!1}).configure({defaultProtocol:nr,protocols:ln?[]:tr}),...Object.values(e.styleSpecs).map(t=>t.implementation.mark.configure({editor:e.editor})),ma,_i,fa,k.Extension.create({name:"OverrideEscape",addKeyboardShortcuts(){return{Escape:()=>e.editor.suggestionMenus.shown?!1:this.editor.commands.blur()}}}),ya,ka.configure({editor:e.editor,domAttributes:e.domAttributes}),qi.configure({editor:e.editor,tabBehavior:e.tabBehavior}),wa.configure({domAttributes:e.domAttributes}),...Object.values(e.inlineContentSpecs).filter(t=>t.config!=="link"&&t.config!=="text").map(t=>t.implementation.node.configure({editor:e.editor})),...Object.values(e.blockSpecs).flatMap(t=>[...(t.implementation.requiredExtensions||[]).map(o=>o.configure({editor:e.editor,domAttributes:e.domAttributes})),t.implementation.node.configure({editor:e.editor,domAttributes:e.domAttributes})]),Ri(e.editor),Di(e.editor,e.pasteHandler||(t=>t.defaultPasteHandler())),ki(e.editor),...e.trailingBlock===void 0||e.trailingBlock?[ga]:[],...e.comments?[qo]:[]];return ln=!0,e.collaboration||n.push(Ir.History),n};function Sa(e,n){const t=[];return e.forEach((o,r,s)=>{s!==n&&t.push(o)}),E.Fragment.from(t)}function Ea(e,n){const t=[];for(let o=0;o<e.childCount;o++)if(e.child(o).type.name==="tableRow")if(t.length>0&&t[t.length-1].type.name==="table"){const r=t[t.length-1],s=r.copy(r.content.addToEnd(e.child(o)));t[t.length-1]=s}else{const r=n.nodes.table.createChecked(void 0,e.child(o));t.push(r)}else t.push(e.child(o));return e=E.Fragment.from(t),e}function Ba(e,n){let t=E.Fragment.from(e.content);if(t=Ea(t,n.state.schema),!Ta(t,n))return new E.Slice(t,e.openStart,e.openEnd);for(let o=0;o<t.childCount;o++)if(t.child(o).type.spec.group==="blockContent"){const r=[t.child(o)];if(o+1<t.childCount&&t.child(o+1).type.name==="blockGroup"){const i=t.child(o+1).child(0).child(0);(i.type.name==="bulletListItem"||i.type.name==="numberedListItem"||i.type.name==="checkListItem")&&(r.push(t.child(o+1)),t=Sa(t,o+1))}const s=n.state.schema.nodes.blockContainer.createChecked(void 0,r);t=t.replaceChild(o,s)}return new E.Slice(t,e.openStart,e.openEnd)}function Ta(e,n){var s,i;const t=e.childCount===1,o=((s=e.firstChild)==null?void 0:s.type.spec.content)==="inline*",r=((i=e.firstChild)==null?void 0:i.type.spec.content)==="tableRow+";if(t){if(o)return!1;if(r){const a=B(n.state);if(a.isBlockContainer)return!(a.blockContent.node.type.spec.content==="tableRow+")}}return!0}const Ke=class Ke extends k.Editor{constructor(t,o){super({...t,content:void 0});p(this,"_state");p(this,"mount",(t,o,r)=>{o?(this.options.element=o,this.createViewAlternative(t,r)):this.destroy()});const r=this.schema;let s;const i=r.nodes.doc.createAndFill;r.nodes.doc.createAndFill=(...l)=>{if(s)return s;const c=i.apply(r.nodes.doc,l),d=JSON.parse(JSON.stringify(c.toJSON()));return d.content[0].content[0].attrs.id="initialBlockId",s=E.Node.fromJSON(r,d),s};let a;try{const l=t==null?void 0:t.content.map(c=>re(c,this.schema,o).toJSON());a=k.createDocument({type:"doc",content:[{type:"blockGroup",content:l}]},this.schema,this.options.parseOptions)}catch(l){throw console.error("Error creating document from blocks passed as `initialContent`. Caused by exception: ",l),new Error("Error creating document from blocks passed as `initialContent`:\n"+ +JSON.stringify(t.content))}this._state=y.EditorState.create({doc:a,schema:this.schema})}get state(){return this.view&&(this._state=this.view.state),this._state}dispatch(t){if(!this.view){this._state=this.state.apply(t),this.emit("transaction",{editor:this,transaction:t});return}if(this.view.isDestroyed)return;if(this.isCapturingTransaction){this.dispatchTransaction(t);return}const{state:o,transactions:r}=this.state.applyTransaction(t),s=!this.state.selection.eq(o.selection);this.emit("beforeTransaction",{editor:this,transaction:t,nextState:o}),this.view.updateState(o),this.emit("transaction",{editor:this,transaction:t}),s&&this.emit("selectionUpdate",{editor:this,transaction:t});const i=t.getMeta("focus"),a=t.getMeta("blur");i&&this.emit("focus",{editor:this,event:i.event,transaction:t}),a&&this.emit("blur",{editor:this,event:a.event,transaction:t}),!(!t.docChanged||t.getMeta("preventUpdate"))&&(this.emit("update",{editor:this,transaction:t}),this.emit("v3-update",{editor:this,transaction:t,appendedTransactions:r.slice(1)}))}forceEnablePlugins(){if(this.view)throw new Error("forcePluginsEnabled called after view has been initialized");this._state=this.state.reconfigure({plugins:this.extensionManager.plugins})}createViewAlternative(t,o){this.contentComponent=o;const r={};this.extensionManager.extensions.forEach(i=>{i.type==="mark"&&i.config.addMarkView&&(r[i.name]=i.config.addMarkView(t))}),this.view=new M.EditorView({mount:this.options.element},{...this.options.editorProps,dispatchTransaction:this.dispatch.bind(this),state:this.state,markViews:r,nodeViews:this.extensionManager.nodeViews});const s=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(s),this.commands.focus(this.options.autofocus||this.options.element.getAttribute("data-bn-autofocus")==="true",{scrollIntoView:!1}),this.emit("create",{editor:this}),this.isInitialized=!0}};p(Ke,"create",(t,o)=>{var s,i;const r=(s=globalThis==null?void 0:globalThis.window)==null?void 0:s.setTimeout;typeof((i=globalThis==null?void 0:globalThis.window)==null?void 0:i.setTimeout)<"u"&&(globalThis.window.setTimeout=()=>0);try{return new Ke(t,o)}finally{r&&(globalThis.window.setTimeout=r)}});let ze=Ke;ze.prototype.createView=function(){this.options.onPaste=this.options.onDrop=void 0};const xa={enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!1};class zt extends tt{constructor(t){var c,d,u,h,f,m,g,b,w,C,S,P,R,z,x;super();p(this,"pmSchema");p(this,"extensions",{});p(this,"headless",!1);p(this,"_tiptapEditor");p(this,"elementRenderer",null);p(this,"blockCache",new WeakMap);p(this,"dictionary");p(this,"schema");p(this,"blockImplementations");p(this,"inlineContentImplementations");p(this,"styleImplementations");p(this,"formattingToolbar");p(this,"linkToolbar");p(this,"sideMenu");p(this,"suggestionMenus");p(this,"filePanel");p(this,"tableHandles");p(this,"comments");p(this,"showSelectionPlugin");p(this,"forkYDocPlugin");p(this,"uploadFile");p(this,"onUploadStartCallbacks",[]);p(this,"onUploadEndCallbacks",[]);p(this,"resolveFileUrl");p(this,"resolveUsers");p(this,"settings");p(this,"activeTransaction",null);p(this,"mount",(t,o)=>{this._tiptapEditor.mount(this,t,o)});this.options=t;const o=t;if(o.onEditorContentChange)throw new Error("onEditorContentChange initialization option is deprecated, use <BlockNoteView onChange={...} />, the useEditorChange(...) hook, or editor.onChange(...)");if(o.onTextCursorPositionChange)throw new Error("onTextCursorPositionChange initialization option is deprecated, use <BlockNoteView onSelectionChange={...} />, the useEditorSelectionChange(...) hook, or editor.onSelectionChange(...)");if(o.onEditorReady)throw new Error("onEditorReady is deprecated. Editor is immediately ready for use after creation.");if(o.editable)throw new Error("editable initialization option is deprecated, use <BlockNoteView editable={true/false} />, or alternatively editor.isEditable = true/false");this.dictionary=t.dictionary||Dr.en,this.settings={tables:{splitCells:((c=t==null?void 0:t.tables)==null?void 0:c.splitCells)??!1,cellBackgroundColor:((d=t==null?void 0:t.tables)==null?void 0:d.cellBackgroundColor)??!1,cellTextColor:((u=t==null?void 0:t.tables)==null?void 0:u.cellTextColor)??!1,headers:((h=t==null?void 0:t.tables)==null?void 0:h.headers)??!1},codeBlock:{indentLineWithTab:((f=t==null?void 0:t.codeBlock)==null?void 0:f.indentLineWithTab)??!0,defaultLanguage:((m=t==null?void 0:t.codeBlock)==null?void 0:m.defaultLanguage)??"text",supportedLanguages:((g=t==null?void 0:t.codeBlock)==null?void 0:g.supportedLanguages)??{},createHighlighter:((b=t==null?void 0:t.codeBlock)==null?void 0:b.createHighlighter)??void 0}};const r={defaultStyles:!0,schema:t.schema||we.create(),_headless:!1,...t,placeholders:{...this.dictionary.placeholders,...t.placeholders}};if(r.comments&&!r.resolveUsers)throw new Error("resolveUsers is required when using comments");this.resolveUsers=r.resolveUsers,this.schema=r.schema,this.blockImplementations=r.schema.blockSpecs,this.inlineContentImplementations=r.schema.inlineContentSpecs,this.styleImplementations=r.schema.styleSpecs,this.extensions=pr({editor:this,domAttributes:r.domAttributes||{},blockSpecs:this.schema.blockSpecs,styleSpecs:this.schema.styleSpecs,inlineContentSpecs:this.schema.inlineContentSpecs,collaboration:r.collaboration,trailingBlock:r.trailingBlock,disableExtensions:r.disableExtensions,setIdAttribute:r.setIdAttribute,animations:r.animations??!0,tableHandles:V("table",this),dropCursor:this.options.dropCursor??Hr.dropCursor,placeholders:r.placeholders,tabBehavior:r.tabBehavior,sideMenuDetection:r.sideMenuDetection||"viewport",comments:r.comments,pasteHandler:r.pasteHandler}),(((w=r._tiptapOptions)==null?void 0:w.extensions)||[]).forEach(v=>{this.extensions[v.name]=v});for(let v of r.extensions||[]){typeof v=="function"&&(v=v(this));const L=v.constructor.key();if(!L)throw new Error(`Extension ${v.constructor.name} does not have a key method`);if(this.extensions[L])throw new Error(`Extension ${v.constructor.name} already exists with key ${L}`);this.extensions[L]=v}if(Object.entries(r._extensions||{}).forEach(([v,L])=>{const ee=typeof L=="function"?L(this):L;if(!("plugin"in ee)){this.extensions[v]=ee;return}this.extensions[v]=new class extends O{static key(){return v}constructor(){super(),this.addProsemirrorPlugin(ee.plugin)}get priority(){return ee.priority}}}),this.formattingToolbar=this.extensions.formattingToolbar,this.linkToolbar=this.extensions.linkToolbar,this.sideMenu=this.extensions.sideMenu,this.suggestionMenus=this.extensions.suggestionMenus,this.filePanel=this.extensions.filePanel,this.tableHandles=this.extensions.tableHandles,this.comments=this.extensions.comments,this.showSelectionPlugin=this.extensions.showSelection,this.forkYDocPlugin=this.extensions.forkYDocPlugin,r.uploadFile){const v=r.uploadFile;this.uploadFile=async(L,se)=>{this.onUploadStartCallbacks.forEach(ee=>ee.apply(this,[se]));try{return await v(L,se)}finally{this.onUploadEndCallbacks.forEach(ee=>ee.apply(this,[se]))}}}this.resolveFileUrl=r.resolveFileUrl,this.headless=r._headless;const s="ySyncPlugin"in this.extensions||"liveblocksExtension"in this.extensions;s&&r.initialContent&&console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider");const i=r.initialContent||(s?[{type:"paragraph",id:"initialBlockId"}]:[{type:"paragraph",id:Be.options.generateID()}]);if(!Array.isArray(i)||i.length===0)throw new Error("initialContent must be a non-empty array of blocks, received: "+i);const a=[...Object.entries(this.extensions).map(([v,L])=>{if(L instanceof k.Extension||L instanceof k.Node||L instanceof k.Mark)return L;if(!(L instanceof O&&!L.plugins.length))return k.Extension.create({name:v,priority:L.priority,addProseMirrorPlugins:()=>L.plugins})})].filter(v=>v!==void 0),l={...xa,...r._tiptapOptions,content:i,extensions:a,editorProps:{...(C=r._tiptapOptions)==null?void 0:C.editorProps,attributes:{tabIndex:"0",...(P=(S=r._tiptapOptions)==null?void 0:S.editorProps)==null?void 0:P.attributes,...(R=r.domAttributes)==null?void 0:R.editor,class:X("bn-editor",r.defaultStyles?"bn-default-styles":"",((x=(z=r.domAttributes)==null?void 0:z.editor)==null?void 0:x.class)||"")},transformPasted:Ba}};this.headless?this.pmSchema=k.getSchema(l.extensions):(this._tiptapEditor=ze.create(l,this.schema.styleSchema),this.pmSchema=this._tiptapEditor.schema),this.pmSchema.cached.blockNoteEditor=this,this.emit("create")}static create(t={}){return new zt(t)}exec(t){if(this.activeTransaction)throw new Error("`exec` should not be called within a `transact` call, move the `exec` call outside of the `transact` call");const o=this._tiptapEditor.state,r=this._tiptapEditor.view;return t(o,i=>this._tiptapEditor.dispatch(i),r)}canExec(t){if(this.activeTransaction)throw new Error("`canExec` should not be called within a `transact` call, move the `canExec` call outside of the `transact` call");const o=this._tiptapEditor.state,r=this._tiptapEditor.view;return t(o,void 0,r)}transact(t){if(this.activeTransaction)return t(this.activeTransaction);try{this.activeTransaction=this._tiptapEditor.state.tr;const o=t(this.activeTransaction),r=this.activeTransaction;return this.activeTransaction=null,r&&(r.docChanged||r.selectionSet||r.scrolledIntoView||r.storedMarksSet||!r.isGeneric)&&this._tiptapEditor.dispatch(r),o}finally{this.activeTransaction=null}}extension(t,o=t.key()){const r=this.extensions[o];if(!r)throw new Error(`Extension ${o} not found`);return r}get prosemirrorState(){if(this.activeTransaction)throw new Error("`prosemirrorState` should not be called within a `transact` call, move the `prosemirrorState` call outside of the `transact` call or use `editor.transact` to read the current editor state");return this._tiptapEditor.state}get prosemirrorView(){return this._tiptapEditor.view}get domElement(){var t;return(t=this.prosemirrorView)==null?void 0:t.dom}isFocused(){var t;return((t=this.prosemirrorView)==null?void 0:t.hasFocus())||!1}focus(){var t;(t=this.prosemirrorView)==null||t.focus()}onUploadStart(t){return this.onUploadStartCallbacks.push(t),()=>{const o=this.onUploadStartCallbacks.indexOf(t);o>-1&&this.onUploadStartCallbacks.splice(o,1)}}onUploadEnd(t){return this.onUploadEndCallbacks.push(t),()=>{const o=this.onUploadEndCallbacks.indexOf(t);o>-1&&this.onUploadEndCallbacks.splice(o,1)}}get topLevelBlocks(){return this.document}get document(){return this.transact(t=>mn(t.doc,this.pmSchema))}getBlock(t){return this.transact(o=>Oo(o.doc,t))}getPrevBlock(t){return this.transact(o=>Ro(o.doc,t))}getNextBlock(t){return this.transact(o=>_o(o.doc,t))}getParentBlock(t){return this.transact(o=>Vo(o.doc,t))}forEachBlock(t,o=!1){const r=this.document.slice();o&&r.reverse();function s(i){for(const a of i){if(t(a)===!1)return!1;const l=o?a.children.slice().reverse():a.children;if(!s(l))return!1}return!0}s(r)}onEditorContentChange(t){this._tiptapEditor.on("update",t)}onEditorSelectionChange(t){this._tiptapEditor.on("selectionUpdate",t)}getTextCursorPosition(){return this.transact(t=>ai(t))}setTextCursorPosition(t,o="start"){return this.transact(r=>Uo(r,t,o))}getSelection(){return this.transact(t=>ri(t))}getSelectionCutBlocks(){return this.transact(t=>ii(t))}setSelection(t,o){return this.transact(r=>si(r,t,o))}get isEditable(){if(!this._tiptapEditor){if(!this.headless)throw new Error("no editor, but also not headless?");return!1}return this._tiptapEditor.isEditable===void 0?!0:this._tiptapEditor.isEditable}set isEditable(t){if(!this._tiptapEditor){if(!this.headless)throw new Error("no editor, but also not headless?");return}this._tiptapEditor.options.editable!==t&&this._tiptapEditor.setEditable(t)}insertBlocks(t,o,r="before"){return this.transact(s=>Mn(s,t,o,r))}updateBlock(t,o){return this.transact(r=>In(r,t,o))}removeBlocks(t){return this.transact(o=>ht(o,t,[]).removedBlocks)}replaceBlocks(t,o){return this.transact(r=>ht(r,t,o))}undo(){return this.options.collaboration?this.exec(N.undoCommand):this.exec(Wt.undo)}redo(){return this.options.collaboration?this.exec(N.redoCommand):this.exec(Wt.redo)}insertInlineContent(t,{updateSelection:o=!1}={}){const r=$(t,this.pmSchema);this.transact(s=>{oi(s,{from:s.selection.from,to:s.selection.to},r,{updateSelection:o})})}getActiveStyles(){return this.transact(t=>{const o={},r=t.selection.$to.marks();for(const s of r){const i=this.schema.styleSchema[s.type.name];if(!i){s.type.name!=="link"&&!s.type.spec.blocknoteIgnore&&console.warn("mark not found in styleschema",s.type.name);continue}i.propSchema==="boolean"?o[i.type]=!0:o[i.type]=s.attrs.stringValue}return o})}addStyles(t){for(const[o,r]of Object.entries(t)){const s=this.schema.styleSchema[o];if(!s)throw new Error(`style ${o} not found in styleSchema`);if(s.propSchema==="boolean")this._tiptapEditor.commands.setMark(o);else if(s.propSchema==="string")this._tiptapEditor.commands.setMark(o,{stringValue:r});else throw new K(s.propSchema)}}removeStyles(t){for(const o of Object.keys(t))this._tiptapEditor.commands.unsetMark(o)}toggleStyles(t){for(const[o,r]of Object.entries(t)){const s=this.schema.styleSchema[o];if(!s)throw new Error(`style ${o} not found in styleSchema`);if(s.propSchema==="boolean")this._tiptapEditor.commands.toggleMark(o);else if(s.propSchema==="string")this._tiptapEditor.commands.toggleMark(o,{stringValue:r});else throw new K(s.propSchema)}}getSelectedText(){return this.transact(t=>t.doc.textBetween(t.selection.from,t.selection.to))}getSelectedLinkUrl(){return this._tiptapEditor.getAttributes("link").href}createLink(t,o){if(t==="")return;const r=this.pmSchema.mark("link",{href:t});this.transact(s=>{const{from:i,to:a}=s.selection;o?s.insertText(o,i,a).addMark(i,i+o.length,r):s.setSelection(y.TextSelection.create(s.doc,a)).addMark(i,a,r)})}canNestBlock(){return ti(this)}nestBlock(){Do(this)}canUnnestBlock(){return ni(this)}unnestBlock(){ei(this)}moveBlocksUp(){return Xs(this)}moveBlocksDown(){return Zs(this)}async blocksToHTMLLossy(t=this.document){return Me(this.pmSchema,this).exportBlocks(t,{})}async blocksToFullHTML(t){return On(this.pmSchema,this).serializeBlocks(t,{})}async tryParseHTMLToBlocks(t){return Vt(t,this.pmSchema)}async blocksToMarkdownLossy(t=this.document){return Fo(t,this.pmSchema,this,{})}async tryParseMarkdownToBlocks(t){return zo(t,this.pmSchema)}updateCollaborationUserInfo(t){if(!this.options.collaboration)throw new Error("Cannot update collaboration user info when collaboration is disabled.");this.extensions.yCursorPlugin.updateUser(t)}onChange(t){if(this.headless)return;const o=({transaction:r,appendedTransactions:s})=>{t(this,{getChanges:()=>Pn(r,s)})};return this._tiptapEditor.on("v3-update",o),()=>{this._tiptapEditor.off("v3-update",o)}}onSelectionChange(t,o){if(this.headless)return;const r=s=>{s.transaction.getMeta(N.ySyncPluginKey)&&!o||t(this)};return this._tiptapEditor.on("selectionUpdate",r),()=>{this._tiptapEditor.off("selectionUpdate",r)}}onCreate(t){return this.on("create",t),()=>{this.off("create",t)}}getSelectionBoundingBox(){if(!this.prosemirrorView)return;const{selection:t}=this.prosemirrorState,{ranges:o}=t,r=Math.min(...o.map(i=>i.$from.pos)),s=Math.max(...o.map(i=>i.$to.pos));if(k.isNodeSelection(t)){const i=this.prosemirrorView.nodeDOM(r);if(i)return i.getBoundingClientRect()}return k.posToDOMRect(this.prosemirrorView,r,s)}get isEmpty(){const t=this.document;return t.length===0||t.length===1&&t[0].type==="paragraph"&&t[0].content.length===0}openSuggestionMenu(t,o){this.prosemirrorView&&(this.focus(),this.transact(r=>{o!=null&&o.deleteTriggerCharacter&&r.insertText(t),r.scrollIntoView().setMeta(this.suggestionMenus.plugins[0],{triggerCharacter:t,deleteTriggerCharacter:(o==null?void 0:o.deleteTriggerCharacter)||!1,ignoreQueryLength:(o==null?void 0:o.ignoreQueryLength)||!1})}))}getForceSelectionVisible(){return this.showSelectionPlugin.getEnabled()}setForceSelectionVisible(t){this.showSelectionPlugin.setEnabled(t)}convertHtmlToBlockNoteHtml(t){return $o(t.trim()).innerHTML}pasteHTML(t,o=!1){var s;let r=t;o||(r=this.convertHtmlToBlockNoteHtml(t)),r&&((s=this.prosemirrorView)==null||s.pasteHTML(r))}pasteText(t){var o;return(o=this.prosemirrorView)==null?void 0:o.pasteText(t)}async pasteMarkdown(t){return this.pasteHTML(await Ut(t))}}const Pa={gray:{text:"#9b9a97",background:"#ebeced"},brown:{text:"#64473a",background:"#e9e5e3"},red:{text:"#e03e3e",background:"#fbe4e4"},orange:{text:"#d9730d",background:"#f6e9d9"},yellow:{text:"#dfab01",background:"#fbf3db"},green:{text:"#4d6461",background:"#ddedea"},blue:{text:"#0b6e99",background:"#ddebf1"},purple:{text:"#6940a5",background:"#eae4f2"},pink:{text:"#ad1a72",background:"#f4dfeb"}},Ma={gray:{text:"#bebdb8",background:"#9b9a97"},brown:{text:"#8e6552",background:"#64473a"},red:{text:"#ec4040",background:"#be3434"},orange:{text:"#e3790d",background:"#b7600a"},yellow:{text:"#dfab01",background:"#b58b00"},green:{text:"#6b8b87",background:"#4d6461"},blue:{text:"#0e87bc",background:"#0b6e99"},purple:{text:"#8552d7",background:"#6940a5"},pink:{text:"#da208f",background:"#ad1a72"}};class Ia{constructor(n,t,o){this.mappings=t,this.options=o}async resolveFile(n){var o;if(!((o=this.options)!=null&&o.resolveFileUrl))return(await fetch(n)).blob();const t=await this.options.resolveFileUrl(n);return t instanceof Blob?t:(await fetch(t)).blob()}mapStyles(n){return Object.entries(n).map(([o,r])=>this.mappings.styleMapping[o](r,this))}mapInlineContent(n){return this.mappings.inlineContentMapping[n.type](n,this)}transformInlineContent(n){return n.map(t=>this.mapInlineContent(t))}async mapBlock(n,t,o){return this.mappings.blockMapping[n.type](n,this,t,o)}}function La(e){return{createBlockMapping:n=>n,createInlineContentMapping:n=>n,createStyleMapping:n=>n}}let De;async function Aa(){return De||(De=(async()=>{const[e,n]=await Promise.all([import("emoji-mart"),import("@emoji-mart/data")]),t="default"in e?e.default:e,o="default"in n?n.default:n;return await t.init({data:o}),{emojiMart:t,emojiData:o}})(),De)}async function Na(e,n){if(!vo("text",e))return[];const{emojiData:t,emojiMart:o}=await Aa();return(n.trim()===""?Object.values(t.emojis):await o.SearchIndex.search(n)).map(s=>({id:s.skins[0].native,onItemClick:()=>e.insertInlineContent(s.skins[0].native+" ")}))}function Ha(e,...n){const t=[...e];for(const o of n)for(const r of o){const s=t.findLastIndex(i=>i.group===r.group);s===-1?t.push(r):t.splice(s+1,0,r)}return t}exports.AudioBlock=qn;exports.BlockNoteEditor=zt;exports.BlockNoteExtension=O;exports.BlockNoteSchema=we;exports.COLORS_DARK_MODE_DEFAULT=Ma;exports.COLORS_DEFAULT=Pa;exports.CodeBlock=Gn;exports.DEFAULT_LINK_PROTOCOL=nr;exports.EMPTY_CELL_HEIGHT=Ls;exports.EMPTY_CELL_WIDTH=Ht;exports.EventEmitter=tt;exports.Exporter=Ia;exports.FILE_AUDIO_ICON_SVG=Un;exports.FILE_ICON_SVG=_n;exports.FILE_IMAGE_ICON_SVG=no;exports.FILE_VIDEO_ICON_SVG=ho;exports.FileBlock=eo;exports.FilePanelProsemirrorPlugin=Go;exports.FilePanelView=jo;exports.FormattingToolbarProsemirrorPlugin=Xo;exports.FormattingToolbarView=Yo;exports.HTMLToBlocks=Vt;exports.ImageBlock=lo;exports.LinkToolbarProsemirrorPlugin=er;exports.PageBreak=Mo;exports.SideMenuProsemirrorPlugin=ar;exports.SideMenuView=sr;exports.SuggestionMenuProseMirrorPlugin=cr;exports.TableHandlesProsemirrorPlugin=ur;exports.TableHandlesView=dr;exports.UniqueID=Be;exports.UnreachableCaseError=K;exports.VALID_LINK_PROTOCOLS=tr;exports.VideoBlock=wo;exports.addInlineContentAttributes=lt;exports.addInlineContentKeyboardShortcuts=bn;exports.addStyleAttributes=vn;exports.applyNonSelectableBlockFix=pn;exports.assertEmpty=Wr;exports.audioBlockConfig=$n;exports.audioParse=Wn;exports.audioPropSchema=Fn;exports.audioRender=zn;exports.audioToExternalHTML=Kn;exports.blockToNode=re;exports.blocksToMarkdown=Fo;exports.camelToDataKebab=ve;exports.checkBlockHasDefaultProp=$s;exports.checkBlockIsDefaultType=So;exports.checkBlockIsFileBlock=Vs;exports.checkBlockIsFileBlockWithPlaceholder=Fs;exports.checkBlockIsFileBlockWithPreview=Us;exports.checkBlockTypeHasDefaultProp=Eo;exports.checkDefaultBlockTypeInSchema=V;exports.checkDefaultInlineContentTypeInSchema=vo;exports.checkPageBreakBlocksInSchema=Io;exports.cleanHTMLToMarkdown=et;exports.combineByGroup=Ha;exports.contentNodeToInlineContent=xe;exports.contentNodeToTableContent=Bt;exports.createAddFileButton=Rn;exports.createBlockSpec=ge;exports.createBlockSpecFromStronglyTypedTiptapNode=Q;exports.createDefaultBlockDOMOutputSpec=j;exports.createExternalHTMLExporter=Me;exports.createFigureWithCaption=Ze;exports.createFileBlockWrapper=Xe;exports.createFileNameWithIcon=Vn;exports.createInlineContentSpec=Gr;exports.createInlineContentSpecFromTipTapNode=wn;exports.createInternalBlockSpec=St;exports.createInternalHTMLSerializer=On;exports.createInternalInlineContentSpec=kn;exports.createInternalStyleSpec=xt;exports.createLinkWithCaption=Le;exports.createResizableFileBlockWrapper=Lt;exports.createStronglyTypedTiptapNode=G;exports.createStyleSpec=Yr;exports.createStyleSpecFromTipTapMark=te;exports.createSuggestionMenu=aa;exports.defaultBlockSchema=yo;exports.defaultBlockSpecs=Dt;exports.defaultBlockToHTML=at;exports.defaultCodeBlockPropSchema=jn;exports.defaultInlineContentSchema=Co;exports.defaultInlineContentSpecs=Rt;exports.defaultProps=I;exports.defaultStyleSchema=_s;exports.defaultStyleSpecs=Ot;exports.docToBlocks=mn;exports.fileBlockConfig=Jn;exports.fileParse=Zn;exports.filePropSchema=Yn;exports.fileRender=Xn;exports.fileToExternalHTML=Qn;exports.filenameFromURL=jr;exports.filterSuggestionItems=qs;exports.formatKeyboardShortcut=J;exports.formattingToolbarPluginKey=Jo;exports.getBlock=Oo;exports.getBlockCache=Je;exports.getBlockFromPos=un;exports.getBlockInfo=Z;exports.getBlockInfoFromResolvedPos=be;exports.getBlockInfoFromSelection=B;exports.getBlockInfoFromTransaction=Te;exports.getBlockInfoWithManualOffset=je;exports.getBlockNoteExtensions=pr;exports.getBlockNoteSchema=ke;exports.getBlockSchema=Ge;exports.getBlockSchemaFromSpecs=Et;exports.getBlocksChangedByTransaction=Pn;exports.getColspan=fe;exports.getDefaultEmojiPickerItems=Na;exports.getDefaultSlashMenuItems=Ks;exports.getInlineContentParseRules=yn;exports.getInlineContentSchema=Ye;exports.getInlineContentSchemaFromSpecs=Tt;exports.getNearestBlockPos=Y;exports.getNextBlock=_o;exports.getNodeById=F;exports.getPageBreakSlashMenuItems=Gs;exports.getParentBlock=Vo;exports.getParseRules=hn;exports.getPmSchema=H;exports.getPrevBlock=Ro;exports.getRowspan=Ve;exports.getStyleParseRules=Sn;exports.getStyleSchema=le;exports.getStyleSchemaFromSpecs=Pt;exports.imageBlockConfig=ro;exports.imageParse=io;exports.imagePropSchema=oo;exports.imageRender=so;exports.imageToExternalHTML=ao;exports.inheritedProps=vt;exports.initializeESMDependencies=Qe;exports.inlineContentToNodes=$;exports.insertBlocks=Mn;exports.insertOrUpdateBlock=_;exports.isAppleOS=dn;exports.isLinkInlineContent=it;exports.isNodeBlock=Fe;exports.isPartialLinkInlineContent=Ct;exports.isPartialTableCell=he;exports.isSafari=Kr;exports.isStyledTextInlineContent=ne;exports.isTableCell=qe;exports.isTableCellSelection=gt;exports.linkToolbarPluginKey=Qo;exports.mapTableCell=_e;exports.mappingFactory=La;exports.markdownToBlocks=zo;exports.markdownToHTML=Ut;exports.mergeCSSClasses=X;exports.mergeParagraphs=qr;exports.nodeToBlock=T;exports.nodeToCustomInlineContent=Ue;exports.pageBreakConfig=Bo;exports.pageBreakParse=xo;exports.pageBreakRender=To;exports.pageBreakSchema=_t;exports.pageBreakToExternalHTML=Po;exports.parseEmbedElement=mt;exports.parseFigureElement=Ie;exports.propsToAttributes=me;exports.prosemirrorSliceToSlicedBlocks=gn;exports.removeAndInsertBlocks=ht;exports.selectedFragmentToHTML=$t;exports.shikiHighlighterPromiseSymbol=Oe;exports.shikiParserSymbol=ft;exports.sideMenuPluginKey=ir;exports.stylePropsToAttributes=Cn;exports.tableContentToNodes=Pe;exports.tableHandlesPluginKey=de;exports.trackPosition=lr;exports.updateBlock=In;exports.updateBlockCommand=D;exports.updateBlockTr=It;exports.uploadToTmpFilesDotOrg_DEV_ONLY=zs;exports.videoBlockConfig=mo;exports.videoParse=bo;exports.videoPropSchema=fo;exports.videoRender=go;exports.videoToExternalHTML=ko;exports.withPageBreak=js;exports.wrapInBlockStructure=Ce;
|
|
10
|
+
`),!0):e.chain().command(({tr:r})=>(r.delete(n.pos-2,n.pos),!0)).exitCode().run()},"Shift-Enter":({editor:e})=>{const{$from:n}=e.state.selection;return e.isActive(this.name)?(e.chain().insertContentAt(n.pos-n.parentOffset+n.parent.nodeSize,{type:"paragraph"}).run(),!0):!1}}}}),Gn=Q(ls,jn);function ot(e,n){var t;return(t=Object.entries(e.supportedLanguages).find(([o,{aliases:r}])=>(r==null?void 0:r.includes(n))||o===n))==null?void 0:t[0]}const cs=k.Mark.create({name:"backgroundColor",addAttributes(){return{stringValue:{default:void 0,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.stringValue})}}},parseHTML(){return[{tag:"span",getAttrs:e=>typeof e=="string"?!1:e.hasAttribute("data-background-color")?{stringValue:e.getAttribute("data-background-color")}:!1}]},renderHTML({HTMLAttributes:e}){return["span",e,0]}}),ds=te(cs,"string"),us=k.Mark.create({name:"textColor",addAttributes(){return{stringValue:{default:void 0,parseHTML:e=>e.getAttribute("data-text-color"),renderHTML:e=>({"data-text-color":e.stringValue})}}},parseHTML(){return[{tag:"span",getAttrs:e=>typeof e=="string"?!1:e.hasAttribute("data-text-color")?{stringValue:e.getAttribute("data-text-color")}:!1}]},renderHTML({HTMLAttributes:e}){return["span",e,0]}}),ps=te(us,"string"),mt=e=>({url:e.src||void 0}),Yn={backgroundColor:I.backgroundColor,name:{default:""},url:{default:""},caption:{default:""}},Jn={type:"file",propSchema:Yn,content:"none",isFileBlock:!0},Xn=(e,n)=>Xe(e,n),Zn=e=>{if(e.tagName==="EMBED")return e.closest("figure")?void 0:mt(e);if(e.tagName==="FIGURE"){const n=Ie(e,"embed");if(!n)return;const{targetElement:t,caption:o}=n;return{...mt(t),caption:o}}},Qn=e=>{if(!e.props.url){const t=document.createElement("p");return t.textContent="Add file",{dom:t}}const n=document.createElement("a");return n.href=e.props.url,n.textContent=e.props.name||e.props.url,e.props.caption?Le(n,e.props.caption):{dom:n}},eo=ge(Jn,{render:Xn,parse:Zn,toExternalHTML:Qn}),to={...I,level:{default:1,values:[1,2,3]}},hs=G({name:"heading",content:"inline*",group:"blockContent",addAttributes(){return me(to)},addInputRules(){return[...[1,2,3].map(e=>new k.InputRule({find:new RegExp(`^(#{${e}})\\s$`),handler:({state:n,chain:t,range:o})=>{const r=B(n);!r.isBlockContainer||r.blockContent.node.type.spec.content!=="inline*"||t().command(D(r.bnBlock.beforePos,{type:"heading",props:{level:e}})).deleteRange({from:o.from,to:o.to}).run()}}))]},addKeyboardShortcuts(){return{"Mod-Alt-1":()=>{const e=B(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(D(e.bnBlock.beforePos,{type:"heading",props:{level:1}}))},"Mod-Alt-2":()=>{const e=B(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(D(e.bnBlock.beforePos,{type:"heading",props:{level:2}}))},"Mod-Alt-3":()=>{const e=B(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(D(e.bnBlock.beforePos,{type:"heading",props:{level:3}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"h1",attrs:{level:1},node:"heading"},{tag:"h2",attrs:{level:2},node:"heading"},{tag:"h3",attrs:{level:3},node:"heading"}]},renderHTML({node:e,HTMLAttributes:n}){var t,o;return j(this.name,`h${e.attrs.level}`,{...((t=this.options.domAttributes)==null?void 0:t.blockContent)||{},...n},((o=this.options.domAttributes)==null?void 0:o.inlineContent)||{})}}),fs=Q(hs,to),Lt=(e,n,t,o,r,s)=>{const{dom:i,destroy:a}=Xe(e,n,t,r,s),l=i;e.props.url&&e.props.showPreview&&(e.props.previewWidth?l.style.width=`${e.props.previewWidth}px`:l.style.width="fit-content");const c=document.createElement("div");c.className="bn-resize-handle",c.style.left="4px";const d=document.createElement("div");d.className="bn-resize-handle",d.style.right="4px";let u,h=e.props.previewWidth;const f=S=>{var z,x;if(!u){!n.isEditable&&o.contains(c)&&o.contains(d)&&(o.removeChild(c),o.removeChild(d));return}let P;e.props.textAlignment==="center"?u.handleUsed==="left"?P=u.initialWidth+(u.initialClientX-S.clientX)*2:P=u.initialWidth+(S.clientX-u.initialClientX)*2:u.handleUsed==="left"?P=u.initialWidth+u.initialClientX-S.clientX:P=u.initialWidth+S.clientX-u.initialClientX,h=Math.min(Math.max(P,64),((x=(z=n.domElement)==null?void 0:z.firstElementChild)==null?void 0:x.clientWidth)||Number.MAX_VALUE),l.style.width=`${h}px`},m=S=>{(!S.target||!l.contains(S.target)||!n.isEditable)&&o.contains(c)&&o.contains(d)&&(o.removeChild(c),o.removeChild(d)),u&&(u=void 0,n.updateBlock(e,{props:{previewWidth:h}}))},g=()=>{n.isEditable&&(o.appendChild(c),o.appendChild(d))},b=S=>{S.relatedTarget===c||S.relatedTarget===d||u||n.isEditable&&o.contains(c)&&o.contains(d)&&(o.removeChild(c),o.removeChild(d))},w=S=>{S.preventDefault(),u={handleUsed:"left",initialWidth:l.clientWidth,initialClientX:S.clientX}},C=S=>{S.preventDefault(),u={handleUsed:"right",initialWidth:l.clientWidth,initialClientX:S.clientX}};return window.addEventListener("mousemove",f),window.addEventListener("mouseup",m),l.addEventListener("mouseenter",g),l.addEventListener("mouseleave",b),c.addEventListener("mousedown",w),d.addEventListener("mousedown",C),{dom:l,destroy:()=>{a==null||a(),window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",m),l.removeEventListener("mouseenter",g),l.removeEventListener("mouseleave",b),c.removeEventListener("mousedown",w),d.removeEventListener("mousedown",C)}}},Gt=e=>{const n=e.src||void 0,t=e.width||void 0;return{url:n,previewWidth:t}},no='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z"></path></svg>',oo={textAlignment:I.textAlignment,backgroundColor:I.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0},previewWidth:{default:void 0,type:"number"}},ro={type:"image",propSchema:oo,content:"none",isFileBlock:!0,fileBlockAccept:["image/*"]},so=(e,n)=>{const t=document.createElement("div");t.innerHTML=no;const o=document.createElement("div");o.className="bn-visual-media-wrapper";const r=document.createElement("img");return r.className="bn-visual-media",n.resolveFileUrl?n.resolveFileUrl(e.props.url).then(s=>{r.src=s}):r.src=e.props.url,r.alt=e.props.name||e.props.caption||"BlockNote image",r.contentEditable="false",r.draggable=!1,o.appendChild(r),Lt(e,n,{dom:o},o,n.dictionary.file_blocks.image.add_button_text,t.firstElementChild)},io=e=>{if(e.tagName==="IMG")return e.closest("figure")?void 0:Gt(e);if(e.tagName==="FIGURE"){const n=Ie(e,"img");if(!n)return;const{targetElement:t,caption:o}=n;return{...Gt(t),caption:o}}},ao=e=>{if(!e.props.url){const t=document.createElement("p");return t.textContent="Add image",{dom:t}}let n;return e.props.showPreview?(n=document.createElement("img"),n.src=e.props.url,n.alt=e.props.name||e.props.caption||"BlockNote image",e.props.previewWidth&&(n.width=e.props.previewWidth)):(n=document.createElement("a"),n.href=e.props.url,n.textContent=e.props.name||e.props.url),e.props.caption?e.props.showPreview?Ze(n,e.props.caption):Le(n,e.props.caption):{dom:n}},lo=ge(ro,{render:so,parse:io,toExternalHTML:ao});function At(e,n,t){var u,h,f;const o=E.DOMParser.fromSchema(n),r=e,s=document.createElement("div");s.setAttribute("data-node-type","blockGroup");for(const m of Array.from(r.childNodes))s.appendChild(m.cloneNode(!0));let i=o.parse(s,{topNode:n.nodes.blockGroup.create()});((h=(u=i.firstChild)==null?void 0:u.firstChild)==null?void 0:h.type.name)==="checkListItem"&&(i=i.copy(i.content.cut(i.firstChild.firstChild.nodeSize+2)));const a=(f=i.firstChild)==null?void 0:f.firstChild;if(!(a!=null&&a.isTextblock))return E.Fragment.from(i);const l=n.nodes[t].create({},a.content),c=i.content.cut(a.nodeSize+2);if(c.size>0){const m=i.copy(c);return l.content.addToEnd(m)}return l.content}const co=(e,n,t)=>({state:o,dispatch:r})=>{const s=Y(o.doc,e),i=Z(s);if(!i.isBlockContainer)throw new Error(`BlockContainer expected when calling splitBlock, position ${e}`);const a=[{type:i.bnBlock.node.type,attrs:t?{...i.bnBlock.node.attrs,id:void 0}:{}},{type:n?i.blockContent.node.type:o.schema.nodes.paragraph,attrs:t?{...i.blockContent.node.attrs}:{}}];return r&&o.tr.split(e,2,a),!0},Nt=e=>{const{blockInfo:n,selectionEmpty:t}=e.transact(s=>({blockInfo:Te(s),selectionEmpty:s.selection.anchor===s.selection.head}));if(!n.isBlockContainer)return!1;const{bnBlock:o,blockContent:r}=n;return!(r.node.type.name==="bulletListItem"||r.node.type.name==="numberedListItem"||r.node.type.name==="checkListItem")||!t?!1:e._tiptapEditor.commands.first(({state:s,chain:i,commands:a})=>[()=>a.command(()=>r.node.childCount===0?a.command(D(o.beforePos,{type:"paragraph",props:{}})):!1),()=>a.command(()=>r.node.childCount>0?(i().deleteSelection().command(co(s.selection.from,!0)).run(),!0):!1)])},ms={...I},gs=G({name:"bulletListItem",content:"inline*",group:"blockContent",priority:90,addInputRules(){return[new k.InputRule({find:new RegExp("^[-+*]\\s$"),handler:({state:e,chain:n,range:t})=>{const o=B(e);!o.isBlockContainer||o.blockContent.node.type.spec.content!=="inline*"||n().command(D(o.bnBlock.beforePos,{type:"bulletListItem",props:{}})).deleteRange({from:t.from,to:t.to})}})]},addKeyboardShortcuts(){return{Enter:()=>Nt(this.options.editor),"Mod-Shift-8":()=>{const e=B(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(D(e.bnBlock.beforePos,{type:"bulletListItem",props:{}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"li",getAttrs:e=>{var t;if(typeof e=="string")return!1;const n=e.parentElement;return n===null?!1:n.tagName==="UL"||n.tagName==="DIV"&&((t=n.parentElement)==null?void 0:t.tagName)==="UL"?{}:!1},getContent:(e,n)=>At(e,n,this.name),node:"bulletListItem"}]},renderHTML({HTMLAttributes:e}){var n,t;return j(this.name,"p",{...((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},...e},((t=this.options.domAttributes)==null?void 0:t.inlineContent)||{})}}),bs=Q(gs,ms),uo={...I,checked:{default:!1}},ks=G({name:"checkListItem",content:"inline*",group:"blockContent",addAttributes(){return me(uo)},addInputRules(){return[new k.InputRule({find:new RegExp("\\[\\s*\\]\\s$"),handler:({state:e,chain:n,range:t})=>{const o=B(e);!o.isBlockContainer||o.blockContent.node.type.spec.content!=="inline*"||n().command(D(o.bnBlock.beforePos,{type:"checkListItem",props:{checked:!1}})).deleteRange({from:t.from,to:t.to})}}),new k.InputRule({find:new RegExp("\\[[Xx]\\]\\s$"),handler:({state:e,chain:n,range:t})=>{const o=B(e);!o.isBlockContainer||o.blockContent.node.type.spec.content!=="inline*"||n().command(D(o.bnBlock.beforePos,{type:"checkListItem",props:{checked:!0}})).deleteRange({from:t.from,to:t.to})}})]},addKeyboardShortcuts(){return{Enter:()=>Nt(this.options.editor),"Mod-Shift-9":()=>{const e=B(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(D(e.bnBlock.beforePos,{type:"checkListItem",props:{}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"input",getAttrs:e=>typeof e=="string"||e.closest("[data-content-type]")||e.closest("li")?!1:e.type==="checkbox"?{checked:e.checked}:!1,node:"checkListItem"},{tag:"li",getAttrs:e=>{var t;if(typeof e=="string")return!1;const n=e.parentElement;if(n===null)return!1;if(n.tagName==="UL"||n.tagName==="DIV"&&((t=n.parentElement)==null?void 0:t.tagName)==="UL"){const o=e.querySelector("input[type=checkbox]")||null;return o===null?!1:{checked:o.checked}}return!1},getContent:(e,n)=>At(e,n,this.name),node:"checkListItem"}]},renderHTML({node:e,HTMLAttributes:n}){var s,i;const t=document.createElement("input");t.type="checkbox",t.checked=e.attrs.checked,e.attrs.checked&&t.setAttribute("checked","");const{dom:o,contentDOM:r}=j(this.name,"p",{...((s=this.options.domAttributes)==null?void 0:s.blockContent)||{},...n},((i=this.options.domAttributes)==null?void 0:i.inlineContent)||{});return o.insertBefore(t,r),{dom:o,contentDOM:r}},addNodeView(){return({node:e,getPos:n,editor:t,HTMLAttributes:o})=>{var d,u;const r=document.createElement("div"),s=document.createElement("div");s.contentEditable="false";const i=document.createElement("input");i.type="checkbox",i.checked=e.attrs.checked,e.attrs.checked&&i.setAttribute("checked","");const a=()=>{if(!t.isEditable){i.checked=!i.checked;return}if(typeof n!="boolean"){const h=Y(t.state.doc,n());if(h.node.type.name!=="blockContainer")throw new Error(`Expected blockContainer node, got ${h.node.type.name}`);this.editor.commands.command(D(h.posBeforeNode,{type:"checkListItem",props:{checked:i.checked}}))}};i.addEventListener("change",a);const{dom:l,contentDOM:c}=j(this.name,"p",{...((d=this.options.domAttributes)==null?void 0:d.blockContent)||{},...o},((u=this.options.domAttributes)==null?void 0:u.inlineContent)||{});if(typeof n!="boolean"){const f="label-"+this.editor.state.doc.resolve(n()).node().attrs.id;i.setAttribute("aria-labelledby",f),c.id=f}return l.removeChild(c),l.appendChild(r),r.appendChild(s),r.appendChild(c),s.appendChild(i),{dom:l,contentDOM:c,destroy:()=>{i.removeEventListener("change",a)}}}}}),ws=Q(ks,uo),ys=new y.PluginKey("numbered-list-indexing"),Cs=()=>new y.Plugin({key:ys,appendTransaction:(e,n,t)=>{const o=t.tr;o.setMeta("numberedListIndexing",!0);let r=!1;return t.doc.descendants((s,i)=>{var a;if(s.type.name==="blockContainer"&&s.firstChild.type.name==="numberedListItem"){let l=`${s.firstChild.attrs.start||1}`;const c=Z({posBeforeNode:i,node:s});if(!c.isBlockContainer)throw new Error("impossible");const d=o.doc.resolve(c.bnBlock.beforePos).nodeBefore;if(d){const m=Z({posBeforeNode:c.bnBlock.beforePos-d.nodeSize,node:d});if(m.blockNoteType==="numberedListItem"){if(!m.isBlockContainer)throw new Error("impossible");const b=m.blockContent.node.attrs.index;l=(parseInt(b)+1).toString()}}const u=c.blockContent.node,h=u.attrs.index,f=((a=d==null?void 0:d.firstChild)==null?void 0:a.type.name)!=="numberedListItem";if(h!==l||u.attrs.start&&!f){r=!0;const{start:m,...g}=u.attrs;o.setNodeMarkup(c.blockContent.beforePos,void 0,{...g,index:l,...typeof m=="number"&&f&&{start:m}})}}}),r?o:null}}),po={...I,start:{default:void 0,type:"number"}},vs=G({name:"numberedListItem",content:"inline*",group:"blockContent",priority:90,addAttributes(){return{...me(po),index:{default:null,parseHTML:e=>e.getAttribute("data-index"),renderHTML:e=>({"data-index":e.index})}}},addInputRules(){return[new k.InputRule({find:new RegExp("^(\\d+)\\.\\s$"),handler:({state:e,chain:n,range:t,match:o})=>{const r=B(e);if(!r.isBlockContainer||r.blockContent.node.type.spec.content!=="inline*"||r.blockNoteType==="numberedListItem")return;const s=parseInt(o[1]);n().command(D(r.bnBlock.beforePos,{type:"numberedListItem",props:s===1&&{}||{start:s}})).deleteRange({from:t.from,to:t.to})}})]},addKeyboardShortcuts(){return{Enter:()=>Nt(this.options.editor),"Mod-Shift-7":()=>{const e=B(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(D(e.bnBlock.beforePos,{type:"numberedListItem",props:{}}))}}},addProseMirrorPlugins(){return[Cs()]},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"li",getAttrs:e=>{var t;if(typeof e=="string")return!1;const n=e.parentElement;if(n===null)return!1;if(n.tagName==="OL"||n.tagName==="DIV"&&((t=n.parentElement)==null?void 0:t.tagName)==="OL"){const o=parseInt(n.getAttribute("start")||"1")||1;return e.previousSibling||o===1?{}:{start:o}}return!1},getContent:(e,n)=>At(e,n,this.name),priority:300,node:"numberedListItem"}]},renderHTML({HTMLAttributes:e}){var n,t;return j(this.name,"p",{...((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},...e},((t=this.options.domAttributes)==null?void 0:t.inlineContent)||{})}}),Ss=Q(vs,po),Es={...I},Bs=G({name:"paragraph",content:"inline*",group:"blockContent",addKeyboardShortcuts(){return{"Mod-Alt-0":()=>{const e=B(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(D(e.bnBlock.beforePos,{type:"paragraph",props:{}}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"p",getAttrs:e=>{var n;return typeof e=="string"||!((n=e.textContent)!=null&&n.trim())?!1:{}},node:"paragraph"}]},renderHTML({HTMLAttributes:e}){var n,t;return j(this.name,"p",{...((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},...e},((t=this.options.domAttributes)==null?void 0:t.inlineContent)||{})}}),Ts=Q(Bs,Es),xs={...I},Ps=G({name:"quote",content:"inline*",group:"blockContent",addInputRules(){return[new k.InputRule({find:new RegExp("^>\\s$"),handler:({state:e,chain:n,range:t})=>{const o=B(e);!o.isBlockContainer||o.blockContent.node.type.spec.content!=="inline*"||n().command(D(o.bnBlock.beforePos,{type:"quote",props:{}})).deleteRange({from:t.from,to:t.to})}})]},addKeyboardShortcuts(){return{"Mod-Alt-q":()=>{const e=B(this.editor.state);return!e.isBlockContainer||e.blockContent.node.type.spec.content!=="inline*"?!0:this.editor.commands.command(D(e.bnBlock.beforePos,{type:"quote"}))}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"blockquote",node:"quote"}]},renderHTML({HTMLAttributes:e}){var n,t;return j(this.name,"blockquote",{...((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},...e},((t=this.options.domAttributes)==null?void 0:t.inlineContent)||{})}}),Ms=Q(Ps,xs),Is=35,Ht=120,Ls=31,As=k.Extension.create({name:"BlockNoteTableExtension",addProseMirrorPlugins:()=>[A.columnResizing({cellMinWidth:Is,defaultCellMinWidth:Ht,View:null}),A.tableEditing()],addKeyboardShortcuts(){return{Enter:()=>this.editor.state.selection.empty&&this.editor.state.selection.$head.parent.type.name==="tableParagraph"?(this.editor.commands.insertContent({type:"hardBreak"}),!0):!1,Backspace:()=>{const e=this.editor.state.selection,n=e.empty,t=e.$head.parentOffset===0,o=e.$head.node().type.name==="tableParagraph";return n&&t&&o},Tab:()=>this.editor.commands.command(({state:e,dispatch:n,view:t})=>A.goToNextCell(1)(e,n,t)),"Shift-Tab":()=>this.editor.commands.command(({state:e,dispatch:n,view:t})=>A.goToNextCell(-1)(e,n,t))}},extendNodeSchema(e){const n={name:e.name,options:e.options,storage:e.storage};return{tableRole:k.callOrReturn(k.getExtensionField(e,"tableRole",n))}}}),Ns={textColor:I.textColor},Hs=G({name:"table",content:"tableRow+",group:"blockContent",tableRole:"table",marks:"deletion insertion modification",isolating:!0,parseHTML(){return[{tag:"table"}]},renderHTML({HTMLAttributes:e}){var n,t;return j(this.name,"table",{...((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},...e},((t=this.options.domAttributes)==null?void 0:t.inlineContent)||{})},addNodeView(){return({node:e,HTMLAttributes:n})=>{var o;class t extends A.TableView{constructor(s,i,a){super(s,i),this.node=s,this.cellMinWidth=i,this.blockContentHTMLAttributes=a;const l=document.createElement("div");l.className=X("bn-block-content",a.class),l.setAttribute("data-content-type","table");for(const[h,f]of Object.entries(a))h!=="class"&&l.setAttribute(h,f);const c=this.dom,d=document.createElement("div");d.className="tableWrapper-inner",d.appendChild(c.firstChild),c.appendChild(d),l.appendChild(c);const u=document.createElement("div");u.className="table-widgets-container",u.style.position="relative",c.appendChild(u),this.dom=l}ignoreMutation(s){return!s.target.closest(".tableWrapper-inner")||super.ignoreMutation(s)}}return new t(e,Ht,{...((o=this.options.domAttributes)==null?void 0:o.blockContent)||{},...n})}}}),Ds=G({name:"tableParagraph",group:"tableContent",content:"inline*",parseHTML(){return[{tag:"p",getAttrs:e=>{if(typeof e=="string"||!e.textContent||!e.closest("[data-content-type]"))return!1;const n=e.parentElement;return n===null?!1:n.tagName==="TD"||n.tagName==="TH"?{}:!1},node:"tableParagraph"}]},renderHTML({HTMLAttributes:e}){return["p",e,0]}}),Os=k.Node.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)+",tableRole:"row",marks:"deletion insertion modification",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:e}){return["tr",k.mergeAttributes(this.options.HTMLAttributes,e),0]}});function Yt(e,n){const o=E.DOMParser.fromSchema(n).parse(e,{topNode:n.nodes.blockGroup.create()}),r=[];return o.content.descendants(s=>{if(s.isInline)return r.push(s),!1}),E.Fragment.fromArray(r)}const Rs=Q(Hs,Ns,[As,Ds,Pr.TableHeader.extend({content:"tableContent+",parseHTML(){return[{tag:"th",getContent:(e,n)=>Yt(e,n)}]}}),xr.TableCell.extend({content:"tableContent+",parseHTML(){return[{tag:"td",getContent:(e,n)=>Yt(e,n)}]}}),Os]),Jt=e=>{const n=e.src||void 0,t=e.width||void 0;return{url:n,previewWidth:t}},ho='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z"></path></svg>',fo={textAlignment:I.textAlignment,backgroundColor:I.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0},previewWidth:{default:void 0,type:"number"}},mo={type:"video",propSchema:fo,content:"none",isFileBlock:!0,fileBlockAccept:["video/*"]},go=(e,n)=>{const t=document.createElement("div");t.innerHTML=ho;const o=document.createElement("div");o.className="bn-visual-media-wrapper";const r=document.createElement("video");return r.className="bn-visual-media",n.resolveFileUrl?n.resolveFileUrl(e.props.url).then(s=>{r.src=s}):r.src=e.props.url,r.controls=!0,r.contentEditable="false",r.draggable=!1,r.width=e.props.previewWidth,o.appendChild(r),Lt(e,n,{dom:o},o,n.dictionary.file_blocks.video.add_button_text,t.firstElementChild)},bo=e=>{if(e.tagName==="VIDEO")return e.closest("figure")?void 0:Jt(e);if(e.tagName==="FIGURE"){const n=Ie(e,"video");if(!n)return;const{targetElement:t,caption:o}=n;return{...Jt(t),caption:o}}},ko=e=>{if(!e.props.url){const t=document.createElement("p");return t.textContent="Add video",{dom:t}}let n;return e.props.showPreview?(n=document.createElement("video"),n.src=e.props.url,e.props.previewWidth&&(n.width=e.props.previewWidth)):(n=document.createElement("a"),n.href=e.props.url,n.textContent=e.props.name||e.props.url),e.props.caption?e.props.showPreview?Ze(n,e.props.caption):Le(n,e.props.caption):{dom:n}},wo=ge(mo,{render:go,parse:bo,toExternalHTML:ko}),Dt={paragraph:Ts,heading:fs,quote:Ms,codeBlock:Gn,bulletListItem:bs,numberedListItem:Ss,checkListItem:ws,table:Rs,file:eo,image:lo,video:wo,audio:qn},yo=Et(Dt),Ot={bold:te(Rr.default,"boolean"),italic:te(_r.default,"boolean"),underline:te(Fr.default,"boolean"),strike:te(Ur.default,"boolean"),code:te(Vr.default,"boolean"),textColor:ps,backgroundColor:ds},Vs=Pt(Ot),Rt={text:{config:"text",implementation:{}},link:{config:"link",implementation:{}}},Co=Tt(Rt);function _(e,n){return e in n.schema.blockSchema&&n.schema.blockSchema[e]===yo[e]}function vo(e,n){return e in n.schema.inlineContentSchema&&n.schema.inlineContentSchema[e]===Co[e]}function So(e,n,t){return n.type===e&&n.type in t.schema.blockSchema&&_(n.type,t)}function _s(e,n){return e.type in n.schema.blockSchema&&n.schema.blockSchema[e.type].isFileBlock||!1}function Us(e,n){return e.type in n.schema.blockSchema&&n.schema.blockSchema[e.type].isFileBlock&&"showPreview"in n.schema.blockSchema[e.type].propSchema||!1}function Fs(e,n){return n.schema.blockSchema[e.type].isFileBlock&&!e.props.url}function Eo(e,n,t){return n in t.schema.blockSchema&&e in t.schema.blockSchema[n].propSchema&&t.schema.blockSchema[n].propSchema[e]===I[e]}function $s(e,n,t){return Eo(e,n.type,t)}function gt(e){return e instanceof A.CellSelection}const zs=async e=>{const n=new FormData;return n.append("file",e),(await(await fetch("https://tmpfiles.org/api/v1/upload",{method:"POST",body:n})).json()).data.url.replace("tmpfiles.org/","tmpfiles.org/dl/")};function Ws(e){let n=e.getTextCursorPosition().block,t=e.schema.blockSchema[n.type].content;for(;t==="none";){if(n=e.getTextCursorPosition().nextBlock,n===void 0)return;t=e.schema.blockSchema[n.type].content,e.setTextCursorPosition(n,"end")}}function V(e,n){const t=e.getTextCursorPosition().block;if(t.content===void 0)throw new Error("Slash Menu open in a block that doesn't contain content.");let o;return Array.isArray(t.content)&&(t.content.length===1&&ne(t.content[0])&&t.content[0].type==="text"&&t.content[0].text==="/"||t.content.length===0)?(o=e.updateBlock(t,n),e.setTextCursorPosition(o)):(o=e.insertBlocks([n],t,"after")[0],e.setTextCursorPosition(e.getTextCursorPosition().nextBlock)),Ws(e),o}function Ks(e){const n=[];return _("heading",e)&&n.push({onItemClick:()=>{V(e,{type:"heading",props:{level:1}})},badge:J("Mod-Alt-1"),key:"heading",...e.dictionary.slash_menu.heading},{onItemClick:()=>{V(e,{type:"heading",props:{level:2}})},badge:J("Mod-Alt-2"),key:"heading_2",...e.dictionary.slash_menu.heading_2},{onItemClick:()=>{V(e,{type:"heading",props:{level:3}})},badge:J("Mod-Alt-3"),key:"heading_3",...e.dictionary.slash_menu.heading_3}),_("quote",e)&&n.push({onItemClick:()=>{V(e,{type:"quote"})},key:"quote",...e.dictionary.slash_menu.quote}),_("numberedListItem",e)&&n.push({onItemClick:()=>{V(e,{type:"numberedListItem"})},badge:J("Mod-Shift-7"),key:"numbered_list",...e.dictionary.slash_menu.numbered_list}),_("bulletListItem",e)&&n.push({onItemClick:()=>{V(e,{type:"bulletListItem"})},badge:J("Mod-Shift-8"),key:"bullet_list",...e.dictionary.slash_menu.bullet_list}),_("checkListItem",e)&&n.push({onItemClick:()=>{V(e,{type:"checkListItem"})},badge:J("Mod-Shift-9"),key:"check_list",...e.dictionary.slash_menu.check_list}),_("paragraph",e)&&n.push({onItemClick:()=>{V(e,{type:"paragraph"})},badge:J("Mod-Alt-0"),key:"paragraph",...e.dictionary.slash_menu.paragraph}),_("codeBlock",e)&&n.push({onItemClick:()=>{V(e,{type:"codeBlock"})},badge:J("Mod-Alt-c"),key:"code_block",...e.dictionary.slash_menu.code_block}),_("table",e)&&n.push({onItemClick:()=>{V(e,{type:"table",content:{type:"tableContent",rows:[{cells:["","",""]},{cells:["","",""]}]}})},badge:void 0,key:"table",...e.dictionary.slash_menu.table}),_("image",e)&&n.push({onItemClick:()=>{const t=V(e,{type:"image"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:t}))},key:"image",...e.dictionary.slash_menu.image}),_("video",e)&&n.push({onItemClick:()=>{const t=V(e,{type:"video"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:t}))},key:"video",...e.dictionary.slash_menu.video}),_("audio",e)&&n.push({onItemClick:()=>{const t=V(e,{type:"audio"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:t}))},key:"audio",...e.dictionary.slash_menu.audio}),_("file",e)&&n.push({onItemClick:()=>{const t=V(e,{type:"file"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:t}))},key:"file",...e.dictionary.slash_menu.file}),n.push({onItemClick:()=>{e.openSuggestionMenu(":",{deleteTriggerCharacter:!0,ignoreQueryLength:!0})},key:"emoji",...e.dictionary.slash_menu.emoji}),n}function qs(e,n){return e.filter(({title:t,aliases:o})=>t.toLowerCase().includes(n.toLowerCase())||o&&o.filter(r=>r.toLowerCase().includes(n.toLowerCase())).length!==0)}function rt(e){return e&&Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))}class we{constructor(n){p(this,"blockSpecs");p(this,"inlineContentSpecs");p(this,"styleSpecs");p(this,"blockSchema");p(this,"inlineContentSchema");p(this,"styleSchema");p(this,"BlockNoteEditor","only for types");p(this,"Block","only for types");p(this,"PartialBlock","only for types");this.blockSpecs=rt(n==null?void 0:n.blockSpecs)||Dt,this.inlineContentSpecs=rt(n==null?void 0:n.inlineContentSpecs)||Rt,this.styleSpecs=rt(n==null?void 0:n.styleSpecs)||Ot,this.blockSchema=Et(this.blockSpecs),this.inlineContentSchema=Tt(this.inlineContentSpecs),this.styleSchema=Pt(this.styleSpecs)}static create(n){return new we(n)}}const Bo={type:"pageBreak",propSchema:{},content:"none",isFileBlock:!1,isSelectable:!1},To=()=>{const e=document.createElement("div");return e.className="bn-page-break",e.setAttribute("data-page-break",""),{dom:e}},xo=e=>{if(e.tagName==="DIV"&&e.hasAttribute("data-page-break"))return{type:"pageBreak"}},Po=()=>{const e=document.createElement("div");return e.setAttribute("data-page-break",""),{dom:e}},Mo=ge(Bo,{render:To,parse:xo,toExternalHTML:Po}),Vt=we.create({blockSpecs:{pageBreak:Mo}}),js=e=>we.create({blockSpecs:{...e.blockSpecs,...Vt.blockSpecs},inlineContentSpecs:e.inlineContentSpecs,styleSpecs:e.styleSpecs});function Io(e){return"pageBreak"in e.schema.blockSchema&&e.schema.blockSchema.pageBreak===Vt.blockSchema.pageBreak}function Gs(e){const n=[];return Io(e)&&n.push({...e.dictionary.slash_menu.page_break,onItemClick:()=>{V(e,{type:"pageBreak"})},key:"page_break"}),n}function Ys(e){return e.transact(n=>{const t=Y(n.doc,n.selection.anchor);if(n.selection instanceof A.CellSelection)return{type:"cell",anchorBlockId:t.node.attrs.id,anchorCellOffset:n.selection.$anchorCell.pos-t.posBeforeNode,headCellOffset:n.selection.$headCell.pos-t.posBeforeNode};if(n.selection instanceof y.NodeSelection)return{type:"node",anchorBlockId:t.node.attrs.id};{const o=Y(n.doc,n.selection.head);return{type:"text",anchorBlockId:t.node.attrs.id,headBlockId:o.node.attrs.id,anchorOffset:n.selection.anchor-t.posBeforeNode,headOffset:n.selection.head-o.posBeforeNode}}})}function Js(e,n){var r,s;const t=(r=F(n.anchorBlockId,e.doc))==null?void 0:r.posBeforeNode;if(t===void 0)throw new Error(`Could not find block with ID ${n.anchorBlockId} to update selection`);let o;if(n.type==="cell")o=A.CellSelection.create(e.doc,t+n.anchorCellOffset,t+n.headCellOffset);else if(n.type==="node")o=y.NodeSelection.create(e.doc,t+1);else{const i=(s=F(n.headBlockId,e.doc))==null?void 0:s.posBeforeNode;if(i===void 0)throw new Error(`Could not find block with ID ${n.headBlockId} to update selection`);o=y.TextSelection.create(e.doc,t+n.anchorOffset,i+n.headOffset)}e.setSelection(o)}function bt(e){return e.map(n=>n.type==="columnList"?n.children.map(t=>bt(t.children)).flat():{...n,children:bt(n.children)}).flat()}function Lo(e,n,t){e.transact(o=>{var i;const r=((i=e.getSelection())==null?void 0:i.blocks)||[e.getTextCursorPosition().block],s=Ys(e);e.removeBlocks(r),e.insertBlocks(bt(r),n,t),Js(o,s)})}function Ao(e){return!e||e.type!=="columnList"}function No(e,n,t){let o,r;if(n?n.children.length>0?(o=n.children[n.children.length-1],r="after"):(o=n,r="before"):t&&(o=t,r="before"),!o||!r)return;const s=e.getParentBlock(o);return Ao(s)?{referenceBlock:o,placement:r}:No(e,r==="after"?o:e.getPrevBlock(o),s)}function Ho(e,n,t){let o,r;if(n?n.children.length>0?(o=n.children[0],r="before"):(o=n,r="after"):t&&(o=t,r="after"),!o||!r)return;const s=e.getParentBlock(o);return Ao(s)?{referenceBlock:o,placement:r}:Ho(e,r==="before"?o:e.getNextBlock(o),s)}function Xs(e){e.transact(()=>{const n=e.getSelection(),t=(n==null?void 0:n.blocks[0])||e.getTextCursorPosition().block,o=No(e,e.getPrevBlock(t),e.getParentBlock(t));o&&Lo(e,o.referenceBlock,o.placement)})}function Zs(e){e.transact(()=>{const n=e.getSelection(),t=(n==null?void 0:n.blocks[(n==null?void 0:n.blocks.length)-1])||e.getTextCursorPosition().block,o=Ho(e,e.getNextBlock(t),e.getParentBlock(t));o&&Lo(e,o.referenceBlock,o.placement)})}function Qs(e,n){return function(t,o){const{$from:r,$to:s}=t.selection,i=r.blockRange(s,d=>d.childCount>0&&(d.type.name==="blockGroup"||d.type.name==="column"));if(!i)return!1;const a=i.startIndex;if(a===0)return!1;const c=i.parent.child(a-1);if(c.type!==e)return!1;if(o){const d=c.lastChild&&c.lastChild.type===n,u=E.Fragment.from(d?e.create():null),h=new E.Slice(E.Fragment.from(e.create(null,E.Fragment.from(n.create(null,u)))),d?3:1,0),f=i.start,m=i.end;o(t.tr.step(new pe.ReplaceAroundStep(f-(d?3:1),m,f,m,h,1,!0)).scrollIntoView())}return!0}}function Do(e){return e.exec((n,t)=>Qs(n.schema.nodes.blockContainer,n.schema.nodes.blockGroup)(n,t))}function ei(e){e._tiptapEditor.commands.liftListItem("blockContainer")}function ti(e){return e.transact(n=>{const{bnBlock:t}=Te(n);return n.doc.resolve(t.beforePos).nodeBefore!==null})}function ni(e){return e.transact(n=>{const{bnBlock:t}=Te(n);return n.doc.resolve(t.beforePos).depth>1})}function Oo(e,n){const t=typeof n=="string"?n:n.id,o=H(e),r=F(t,e);if(r)return T(r.node,o)}function Ro(e,n){const t=typeof n=="string"?n:n.id,o=F(t,e),r=H(e);if(!o)return;const i=e.resolve(o.posBeforeNode).nodeBefore;if(i)return T(i,r)}function Vo(e,n){const t=typeof n=="string"?n:n.id,o=F(t,e),r=H(e);if(!o)return;const i=e.resolve(o.posBeforeNode+o.node.nodeSize).nodeAfter;if(i)return T(i,r)}function _o(e,n){const t=typeof n=="string"?n:n.id,o=H(e),r=F(t,e);if(!r)return;const s=e.resolve(r.posBeforeNode),i=s.node(),a=s.node(-1),l=a.type.name!=="doc"?i.type.name==="blockGroup"?a:i:void 0;if(l)return T(l,o)}function oi(e,n,t,o={updateSelection:!0}){let{from:r,to:s}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},i=!0,a=!0,l="";if(t.forEach(c=>{c.check(),i&&c.isText&&c.marks.length===0?l+=c.text:i=!1,a=a?c.isBlock:!1}),r===s&&a){const{parent:c}=e.doc.resolve(r);c.isTextblock&&!c.type.spec.code&&!c.childCount&&(r-=1,s+=1)}return i?e.insertText(l,r,s):e.replaceWith(r,s,t),o.updateSelection&&k.selectionToInsertionEnd(e,e.steps.length-1,-1),!0}function ri(e){const n=H(e);if(e.selection.empty||"node"in e.selection)return;const t=e.doc.resolve(Y(e.doc,e.selection.from).posBeforeNode),o=e.doc.resolve(Y(e.doc,e.selection.to).posBeforeNode),r=(c,d)=>{const u=t.posAtIndex(c,d),h=e.doc.resolve(u).nodeAfter;if(!h)throw new Error(`Error getting selection - node not found at position ${u}`);return T(h,n)},s=[],i=t.sharedDepth(o.pos),a=t.index(i),l=o.index(i);if(t.depth>i){s.push(T(t.nodeAfter,n));for(let c=t.depth;c>i;c--)if(t.node(c).type.isInGroup("childContainer")){const u=t.index(c)+1,h=t.node(c).childCount;for(let f=u;f<h;f++)s.push(r(f,c))}}else s.push(r(a,i));for(let c=a+1;c<=l;c++)s.push(r(c,i));if(s.length===0)throw new Error(`Error getting selection - selection doesn't span any blocks (${e.selection})`);return{blocks:s}}function si(e,n,t){const o=typeof n=="string"?n:n.id,r=typeof t=="string"?t:t.id,s=H(e),i=ke(s);if(o===r)throw new Error(`Attempting to set selection with the same anchor and head blocks (id ${o})`);const a=F(o,e.doc);if(!a)throw new Error(`Block with ID ${o} not found`);const l=F(r,e.doc);if(!l)throw new Error(`Block with ID ${r} not found`);const c=Z(a),d=Z(l),u=i.blockSchema[c.blockNoteType],h=i.blockSchema[d.blockNoteType];if(!c.isBlockContainer||u.content==="none")throw new Error(`Attempting to set selection anchor in block without content (id ${o})`);if(!d.isBlockContainer||h.content==="none")throw new Error(`Attempting to set selection anchor in block without content (id ${r})`);let f,m;if(u.content==="table"){const g=A.TableMap.get(c.blockContent.node);f=c.blockContent.beforePos+g.positionAt(0,0,c.blockContent.node)+1+2}else f=c.blockContent.beforePos+1;if(h.content==="table"){const g=A.TableMap.get(d.blockContent.node),b=d.blockContent.beforePos+g.positionAt(g.height-1,g.width-1,d.blockContent.node)+1,w=e.doc.resolve(b).nodeAfter.nodeSize;m=b+w-2}else m=d.blockContent.afterPos-1;e.setSelection(y.TextSelection.create(e.doc,f,m))}function ii(e){const n=H(e);let t=e.selection.$from,o=e.selection.$to;for(;o.parentOffset>=o.parent.nodeSize-2&&o.depth>0;)o=e.doc.resolve(o.pos+1);for(;o.parentOffset===0&&o.depth>0;)o=e.doc.resolve(o.pos-1);for(;t.parentOffset===0&&t.depth>0;)t=e.doc.resolve(t.pos-1);for(;t.parentOffset>=t.parent.nodeSize-2&&t.depth>0;)t=e.doc.resolve(t.pos+1);const r=gn(e.doc.slice(t.pos,o.pos,!0),n);return{_meta:{startPos:t.pos,endPos:o.pos},...r}}function ai(e){const{bnBlock:n}=Te(e),t=H(e.doc),o=e.doc.resolve(n.beforePos),r=o.nodeBefore,s=e.doc.resolve(n.afterPos).nodeAfter;let i;return o.depth>1&&(i=o.node(),i.type.isInGroup("bnBlock")||(i=o.node(o.depth-1))),{block:T(n.node,t),prevBlock:r===null?void 0:T(r,t),nextBlock:s===null?void 0:T(s,t),parentBlock:i===void 0?void 0:T(i,t)}}function Uo(e,n,t="start"){const o=typeof n=="string"?n:n.id,r=H(e.doc),s=ke(r),i=F(o,e.doc);if(!i)throw new Error(`Block with ID ${o} not found`);const a=Z(i),l=s.blockSchema[a.blockNoteType].content;if(a.isBlockContainer){const c=a.blockContent;if(l==="none"){e.setSelection(y.NodeSelection.create(e.doc,c.beforePos));return}if(l==="inline")t==="start"?e.setSelection(y.TextSelection.create(e.doc,c.beforePos+1)):e.setSelection(y.TextSelection.create(e.doc,c.afterPos-1));else if(l==="table")t==="start"?e.setSelection(y.TextSelection.create(e.doc,c.beforePos+4)):e.setSelection(y.TextSelection.create(e.doc,c.afterPos-4));else throw new K(l)}else{const c=t==="start"?a.childContainer.node.firstChild:a.childContainer.node.lastChild;Uo(e,c.attrs.id,t)}}exports.esmDependencies=void 0;async function Qe(){if(exports.esmDependencies)return exports.esmDependencies;const e=await Promise.all([import("rehype-parse"),import("rehype-stringify"),import("unified"),import("hast-util-from-dom"),import("rehype-remark"),import("remark-gfm"),import("remark-stringify"),import("remark-parse"),import("remark-rehype"),import("rehype-format")]);return exports.esmDependencies={rehypeParse:e[0],rehypeStringify:e[1],unified:e[2],hastUtilFromDom:e[3],rehypeRemark:e[4],remarkGfm:e[5],remarkStringify:e[6],remarkParse:e[7],remarkRehype:e[8],rehypeFormat:e[9]},exports.esmDependencies}function li(){const e=n=>{let t=n.children.length;for(let o=0;o<t;o++){const r=n.children[o];if(r.type==="element"&&(e(r),r.tagName==="u"))if(r.children.length>0){n.children.splice(o,1,...r.children);const s=r.children.length-1;t+=s,o+=s}else n.children.splice(o,1),t--,o--}};return e}function ci(){const e=exports.esmDependencies;if(!e)throw new Error("addSpacesToCheckboxes requires ESM dependencies to be initialized");const n=t=>{var o;if(t.children&&"length"in t.children&&t.children.length)for(let r=t.children.length-1;r>=0;r--){const s=t.children[r],i=r+1<t.children.length?t.children[r+1]:void 0;s.type==="element"&&s.tagName==="input"&&((o=s.properties)==null?void 0:o.type)==="checkbox"&&(i==null?void 0:i.type)==="element"&&i.tagName==="p"?(i.tagName="span",i.children.splice(0,0,e.hastUtilFromDom.fromDom(document.createTextNode(" ")))):n(s)}};return n}function et(e){const n=exports.esmDependencies;if(!n)throw new Error("cleanHTMLToMarkdown requires ESM dependencies to be initialized");return n.unified.unified().use(n.rehypeParse.default,{fragment:!0}).use(li).use(ci).use(n.rehypeRemark.default).use(n.remarkGfm.default).use(n.remarkStringify.default,{handlers:{text:o=>o.value}}).processSync(e).value}async function Fo(e,n,t,o){await Qe();const s=Me(n,t).exportBlocks(e,o);return et(s)}function di(e){return Array.prototype.indexOf.call(e.parentElement.childNodes,e)}function ui(e){return e.nodeType===3&&!/\S/.test(e.nodeValue||"")}function pi(e){e.querySelectorAll("li > ul, li > ol").forEach(n=>{const t=di(n),o=n.parentElement,r=Array.from(o.childNodes).slice(t+1);n.remove(),r.forEach(s=>{s.remove()}),o.insertAdjacentElement("afterend",n),r.reverse().forEach(s=>{if(ui(s))return;const i=document.createElement("li");i.append(s),n.insertAdjacentElement("afterend",i)}),o.childNodes.length===0&&o.remove()})}function hi(e){e.querySelectorAll("li + ul, li + ol").forEach(n=>{var s,i;const t=n.previousElementSibling,o=document.createElement("div");t.insertAdjacentElement("afterend",o),o.append(t);const r=document.createElement("div");for(r.setAttribute("data-node-type","blockGroup"),o.append(r);((s=o.nextElementSibling)==null?void 0:s.nodeName)==="UL"||((i=o.nextElementSibling)==null?void 0:i.nodeName)==="OL";)r.append(o.nextElementSibling)})}let Xt=null;function fi(){return Xt||(Xt=document.implementation.createHTMLDocument("title"))}function $o(e){if(typeof e=="string"){const n=fi().createElement("div");n.innerHTML=e,e=n}return pi(e),hi(e),e}async function _t(e,n){const t=$o(e),r=E.DOMParser.fromSchema(n).parse(t,{topNode:n.nodes.blockGroup.create()}),s=[];for(let i=0;i<r.childCount;i++)s.push(T(r.child(i),n));return s}function mi(e,n){const t=n.value?n.value:"",o={};n.lang&&(o["data-language"]=n.lang);let r={type:"element",tagName:"code",properties:o,children:[{type:"text",value:t}]};return n.meta&&(r.data={meta:n.meta}),e.patch(n,r),r=e.applyData(n,r),r={type:"element",tagName:"pre",properties:{},children:[r]},e.patch(n,r),r}async function Ut(e){const n=await Qe();return n.unified.unified().use(n.remarkParse.default).use(n.remarkGfm.default).use(n.remarkRehype.default,{handlers:{...n.remarkRehype.defaultHandlers,code:mi}}).use(n.rehypeStringify.default).processSync(e).value}async function zo(e,n){const t=await Ut(e);return _t(t,n)}const Ft=["vscode-editor-data","blocknote/html","text/markdown","text/html","text/plain","Files"];function gi(e,n){if(!e.startsWith(".")||!n.startsWith("."))throw new Error("The strings provided are not valid file extensions.");return e===n}function bi(e,n){const t=e.split("/"),o=n.split("/");if(t.length!==2)throw new Error(`The string ${e} is not a valid MIME type.`);if(o.length!==2)throw new Error(`The string ${n} is not a valid MIME type.`);return t[1]==="*"||o[1]==="*"?t[0]===o[0]:(t[0]==="*"||o[0]==="*"||t[0]===o[0])&&t[1]===o[1]}function Zt(e,n,t){let o;return Array.isArray(n.content)&&n.content.length===0?o=e.updateBlock(n,t).id:o=e.insertBlocks([t],n,"after")[0].id,o}async function Wo(e,n){var i;if(!n.uploadFile){console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");return}const t="dataTransfer"in e?e.dataTransfer:e.clipboardData;if(t===null)return;let o=null;for(const a of Ft)if(t.types.includes(a)){o=a;break}if(o!=="Files")return;const r=t.items;if(!r)return;e.preventDefault();const s=Object.values(n.schema.blockSchema).filter(a=>a.isFileBlock);for(let a=0;a<r.length;a++){let l="file";for(const d of s)for(const u of d.fileBlockAccept||[]){const h=u.startsWith("."),f=r[a].getAsFile();if(f&&(!h&&f.type&&bi(r[a].type,u)||h&&gi("."+f.name.split(".").pop(),u))){l=d.type;break}}const c=r[a].getAsFile();if(c){const d={type:l,props:{name:c.name}};let u;if(e.type==="paste"){const m=n.getTextCursorPosition().block;u=Zt(n,m,d)}else if(e.type==="drop"){const m={left:e.clientX,top:e.clientY},g=(i=n.prosemirrorView)==null?void 0:i.posAtCoords(m);if(!g)return;u=n.transact(b=>{const w=Y(b.doc,g.pos);return Zt(n,n.getBlock(w.node.attrs.id),d)})}else return;const h=await n.uploadFile(c,u),f=typeof h=="string"?{props:{url:h}}:{...h};n.updateBlock(u,f)}}}const ki=e=>k.Extension.create({name:"dropFile",addProseMirrorPlugins(){return[new y.Plugin({props:{handleDOMEvents:{drop(n,t){if(!e.isEditable)return;let o=null;for(const r of Ft)if(t.dataTransfer.types.includes(r)){o=r;break}return o===null?!0:o==="Files"?(Wo(t,e),!0):!1}}}})]}}),wi=/(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/,yi=new RegExp("(?:\\s|^)(_|__|\\*|\\*\\*|~~|==|\\+\\+)(?!\\s).{1,64}(?<!\\s)(?=\\1)"),Ci=/\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/,vi=new RegExp("(?:\\s|^)`(?!\\s)[^`]{1,48}(?<!\\s)`([^\\w]|$)"),Si=/(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/,Ei=/(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/,Bi=/\n{2} {0,3}-{2,48}\n{2}/,Ti=/(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/,xi=/(?:\n|^)(?!\s)\w[^\n]{0,64}\r?\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/,Pi=/(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/,Mi=/^\s*\|(.+\|)+\s*$/m,Ii=/^\s*\|(\s*[-:]+[-:]\s*\|)+\s*$/m,Li=/^\s*\|(.+\|)+\s*$/m,Ai=e=>wi.test(e)||yi.test(e)||Ci.test(e)||vi.test(e)||Si.test(e)||Ei.test(e)||Bi.test(e)||Ti.test(e)||xi.test(e)||Pi.test(e)||Mi.test(e)||Ii.test(e)||Li.test(e);async function Ni(e,n){const{schema:t}=n.state;if(!e.clipboardData)return!1;const o=e.clipboardData.getData("text/plain");if(!o)return!1;if(!t.nodes.codeBlock)return n.pasteText(o),!0;const r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s==null?void 0:s.mode;return i?(n.pasteHTML(`<pre><code class="language-${i}">${o.replace(/\r\n?/g,`
|
|
11
|
+
`)}</code></pre>`),!0):!1}function Hi({event:e,editor:n,prioritizeMarkdownOverHTML:t,plainTextAsMarkdown:o}){var a;if(n.transact(l=>l.selection.$from.parent.type.spec.code&&l.selection.$to.parent.type.spec.code)){const l=(a=e.clipboardData)==null?void 0:a.getData("text/plain");if(l)return n.pasteText(l),!0}let s;for(const l of Ft)if(e.clipboardData.types.includes(l)){s=l;break}if(!s)return!0;if(s==="vscode-editor-data")return Ni(e,n.prosemirrorView),!0;if(s==="Files")return Wo(e,n),!0;const i=e.clipboardData.getData(s);if(s==="blocknote/html")return n.pasteHTML(i,!0),!0;if(s==="text/markdown")return n.pasteMarkdown(i),!0;if(t){const l=e.clipboardData.getData("text/plain");if(Ai(l))return n.pasteMarkdown(l),!0}return s==="text/html"?(n.pasteHTML(i),!0):o?(n.pasteMarkdown(i),!0):(n.pasteText(i),!0)}const Di=(e,n)=>k.Extension.create({name:"pasteFromClipboard",addProseMirrorPlugins(){return[new y.Plugin({props:{handleDOMEvents:{paste(t,o){if(o.preventDefault(),!!e.isEditable)return n({event:o,editor:e,defaultPasteHandler:({prioritizeMarkdownOverHTML:r=!0,plainTextAsMarkdown:s=!0}={})=>Hi({event:o,editor:e,prioritizeMarkdownOverHTML:r,plainTextAsMarkdown:s})})}}}})]}});function Ko(e){const n=[];return e.descendants(t=>{var r,s;const o=H(t);return t.type.name==="blockContainer"&&((r=t.firstChild)==null?void 0:r.type.name)==="blockGroup"?!0:t.type.name==="columnList"&&t.childCount===1?((s=t.firstChild)==null||s.forEach(i=>{n.push(T(i,o))}),!1):t.type.isInGroup("bnBlock")?(n.push(T(t,o)),!1):!0}),n}function Oi(e,n,t){var a;let o=!1;const r=e.state.selection instanceof A.CellSelection;if(!r){const l=e.state.doc.slice(e.state.selection.from,e.state.selection.to,!1).content,c=[];for(let d=0;d<l.childCount;d++)c.push(l.child(d));o=c.find(d=>d.type.isInGroup("bnBlock")||d.type.name==="blockGroup"||d.type.spec.group==="blockContent")===void 0,o&&(n=l)}let s;const i=Me(e.state.schema,t);if(r){((a=n.firstChild)==null?void 0:a.type.name)==="table"&&(n=n.firstChild.content);const l=Bt(n,t.schema.inlineContentSchema,t.schema.styleSchema);s=`<table>${i.exportInlineContent(l,{})}</table>`}else if(o){const l=xe(n,t.schema.inlineContentSchema,t.schema.styleSchema);s=i.exportInlineContent(l,{})}else{const l=Ko(n);s=i.exportBlocks(l,{})}return s}function $t(e,n){"node"in e.state.selection&&e.state.selection.node.type.spec.group==="blockContent"&&n.transact(i=>i.setSelection(new y.NodeSelection(i.doc.resolve(e.state.selection.from-1))));const t=e.serializeForClipboard(e.state.selection.content()).dom.innerHTML,o=e.state.selection.content().content,r=Oi(e,o,n),s=et(r);return{clipboardHTML:t,externalHTML:r,markdown:s}}const Qt=()=>{const e=window.getSelection();if(!e||e.isCollapsed)return!0;let n=e.focusNode;for(;n;){if(n instanceof HTMLElement&&n.getAttribute("contenteditable")==="false")return!0;n=n.parentElement}return!1},en=(e,n,t)=>{t.preventDefault(),t.clipboardData.clearData();const{clipboardHTML:o,externalHTML:r,markdown:s}=$t(n,e);t.clipboardData.setData("blocknote/html",o),t.clipboardData.setData("text/html",r),t.clipboardData.setData("text/plain",s)},Ri=e=>k.Extension.create({name:"copyToClipboard",addProseMirrorPlugins(){return[new y.Plugin({props:{handleDOMEvents:{copy(n,t){return Qt()||en(e,n,t),!0},cut(n,t){return Qt()||(en(e,n,t),n.editable&&n.dispatch(n.state.tr.deleteSelection())),!0},dragstart(n,t){if(!("node"in n.state.selection)||n.state.selection.node.type.spec.group!=="blockContent")return;e.transact(i=>i.setSelection(new y.NodeSelection(i.doc.resolve(n.state.selection.from-1)))),t.preventDefault(),t.dataTransfer.clearData();const{clipboardHTML:o,externalHTML:r,markdown:s}=$t(n,e);return t.dataTransfer.setData("blocknote/html",o),t.dataTransfer.setData("text/html",r),t.dataTransfer.setData("text/plain",s),!0}}}})]}}),Vi=k.Extension.create({name:"blockBackgroundColor",addGlobalAttributes(){return[{types:["blockContainer","tableCell","tableHeader"],attributes:{backgroundColor:{default:I.backgroundColor.default,parseHTML:e=>e.hasAttribute("data-background-color")?e.getAttribute("data-background-color"):I.backgroundColor.default,renderHTML:e=>e.backgroundColor===I.backgroundColor.default?{}:{"data-background-color":e.backgroundColor}}}}]}});class tt{constructor(){p(this,"callbacks",{})}on(n,t){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(t),()=>this.off(n,t)}emit(n,...t){const o=this.callbacks[n];o&&o.forEach(r=>r.apply(this,t))}off(n,t){const o=this.callbacks[n];o&&(t?this.callbacks[n]=o.filter(r=>r!==t):delete this.callbacks[n])}removeAllListeners(){this.callbacks={}}}class O extends tt{constructor(...t){super();p(this,"plugins",[])}static key(){throw new Error("You must implement the key method in your extension")}addProsemirrorPlugin(t){this.plugins.push(t)}get priority(){}}const We=class We extends O{constructor(t){super();p(this,"provider");p(this,"recentlyUpdatedCursors");p(this,"renderCursor",(t,o)=>{let r=this.recentlyUpdatedCursors.get(o);if(!r){const s=(this.collaboration.renderCursor??We.defaultCursorRender)(t);this.collaboration.showCursorLabels!=="always"&&(s.addEventListener("mouseenter",()=>{const i=this.recentlyUpdatedCursors.get(o);i.element.setAttribute("data-active",""),i.hideTimeout&&(clearTimeout(i.hideTimeout),this.recentlyUpdatedCursors.set(o,{element:i.element,hideTimeout:void 0}))}),s.addEventListener("mouseleave",()=>{const i=this.recentlyUpdatedCursors.get(o);this.recentlyUpdatedCursors.set(o,{element:i.element,hideTimeout:setTimeout(()=>{i.element.removeAttribute("data-active")},2e3)})})),r={element:s,hideTimeout:void 0},this.recentlyUpdatedCursors.set(o,r)}return r.element});p(this,"updateUser",t=>{this.provider.awareness.setLocalStateField("user",t)});this.collaboration=t,this.provider=t.provider,this.recentlyUpdatedCursors=new Map,this.provider.awareness.setLocalStateField("user",t.user),t.showCursorLabels!=="always"&&this.provider.awareness.on("change",({updated:o})=>{for(const r of o){const s=this.recentlyUpdatedCursors.get(r);s&&(s.element.setAttribute("data-active",""),s.hideTimeout&&clearTimeout(s.hideTimeout),this.recentlyUpdatedCursors.set(r,{element:s.element,hideTimeout:setTimeout(()=>{s.element.removeAttribute("data-active")},2e3)}))}}),this.addProsemirrorPlugin(N.yCursorPlugin(this.provider.awareness,{selectionBuilder:N.defaultSelectionBuilder,cursorBuilder:this.renderCursor}))}static key(){return"yCursorPlugin"}get priority(){return 999}};p(We,"defaultCursorRender",t=>{const o=document.createElement("span");o.classList.add("bn-collaboration-cursor__base");const r=document.createElement("span");r.setAttribute("contentedEditable","false"),r.classList.add("bn-collaboration-cursor__caret"),r.setAttribute("style",`background-color: ${t.color}`);const s=document.createElement("span");return s.classList.add("bn-collaboration-cursor__label"),s.setAttribute("style",`background-color: ${t.color}`),s.insertBefore(document.createTextNode(t.name),null),r.insertBefore(s,null),o.insertBefore(document.createTextNode(""),null),o.insertBefore(r,null),o.insertBefore(document.createTextNode(""),null),o});let $e=We;class kt extends O{static key(){return"ySyncPlugin"}constructor(n){super(),this.addProsemirrorPlugin(N.ySyncPlugin(n))}get priority(){return 1001}}class wt extends O{static key(){return"yUndoPlugin"}constructor(){super(),this.addProsemirrorPlugin(N.yUndoPlugin())}get priority(){return 1e3}}const qo=k.Mark.create({name:"comment",excludes:"",inclusive:!1,keepOnSplit:!0,addAttributes(){return{orphan:{parseHTML:e=>!!e.getAttribute("data-orphan"),renderHTML:e=>e.orphan?{"data-orphan":"true"}:{},default:!1},threadId:{parseHTML:e=>e.getAttribute("data-bn-thread-id"),renderHTML:e=>({"data-bn-thread-id":e.threadId}),default:""}}},renderHTML({HTMLAttributes:e}){return["span",k.mergeAttributes(e,{class:"bn-thread-mark"})]},parseHTML(){return[{tag:"span.bn-thread-mark"}]},extendMarkSchema(e){return e.name==="comment"?{blocknoteIgnore:!0}:{}}});class _i extends tt{constructor(t){super();p(this,"userCache",new Map);p(this,"loadingUsers",new Set);this.resolveUsers=t}async loadUsers(t){const o=t.filter(r=>!this.userCache.has(r)&&!this.loadingUsers.has(r));if(o.length!==0){for(const r of o)this.loadingUsers.add(r);try{const r=await this.resolveUsers(o);for(const s of r)this.userCache.set(s.id,s);this.emit("update",this.userCache)}finally{for(const r of o)this.loadingUsers.delete(r)}}}getUser(t){return this.userCache.get(t)}subscribe(t){return this.on("update",t)}}const Ae=new y.PluginKey("blocknote-comments"),Ui="SET_SELECTED_THREAD_ID";function Fi(e,n){const t=new Map;return e.descendants((o,r)=>{o.marks.forEach(s=>{if(s.type.name===n){const i=s.attrs.threadId;if(!i)return;const a=r,l=a+o.nodeSize,c=t.get(i)??{from:1/0,to:0};t.set(i,{from:Math.min(a,c.from),to:Math.max(l,c.to)})}})}),t}class $i extends O{constructor(t,o,r){super();p(this,"userStore");p(this,"pendingComment",!1);p(this,"selectedThreadId");p(this,"threadPositions",new Map);p(this,"updateMarksFromThreads",t=>{this.editor.transact(o=>{o.doc.descendants((r,s)=>{r.marks.forEach(i=>{if(i.type.name===this.markType){const a=i.type,l=i.attrs.threadId,c=t.get(l),d=!!(!c||c.resolved||c.deletedAt);if(d!==i.attrs.orphan){const u=Math.max(s,0),h=Math.min(s+r.nodeSize,o.doc.content.size-1,o.doc.content.size-1);o.removeMark(u,h,i),o.addMark(u,h,a.create({...i.attrs,orphan:d})),d&&this.selectedThreadId===l&&(this.selectedThreadId=void 0,this.emitStateUpdate())}}})})})});if(this.editor=t,this.threadStore=o,this.markType=r,!t.resolveUsers)throw new Error("resolveUsers is required for comments");this.userStore=new _i(t.resolveUsers),this.threadStore.subscribe(this.updateMarksFromThreads),t.onCreate(()=>{this.updateMarksFromThreads(this.threadStore.getThreads()),t.onSelectionChange(()=>{this.pendingComment&&(this.pendingComment=!1,this.emitStateUpdate())})});const s=this;this.addProsemirrorPlugin(new y.Plugin({key:Ae,state:{init(){return{decorations:M.DecorationSet.empty}},apply(i,a){const l=i.getMeta(Ae);if(!i.docChanged&&!l)return a;const c=i.docChanged?Fi(i.doc,s.markType):s.threadPositions;(c.size>0||s.threadPositions.size>0)&&(s.threadPositions=c,s.emitStateUpdate());const d=[];if(s.selectedThreadId){const u=c.get(s.selectedThreadId);u&&d.push(M.Decoration.inline(u.from,u.to,{class:"bn-thread-mark-selected"}))}return{decorations:M.DecorationSet.create(i.doc,d)}}},props:{decorations(i){var a;return((a=Ae.getState(i))==null?void 0:a.decorations)??M.DecorationSet.empty},handleClick:(i,a,l)=>{if(l.button!==0)return;const c=i.state.doc.nodeAt(a);if(!c){s.selectThread(void 0);return}const d=c.marks.find(h=>h.type.name===r&&h.attrs.orphan!==!0),u=d==null?void 0:d.attrs.threadId;s.selectThread(u,!1)}}}))}static key(){return"comments"}emitStateUpdate(){this.emit("update",{selectedThreadId:this.selectedThreadId,pendingComment:this.pendingComment,threadPositions:this.threadPositions})}onUpdate(t){return this.on("update",t)}selectThread(t,o=!0){var r,s;if(this.selectedThreadId!==t&&(this.selectedThreadId=t,this.emitStateUpdate(),this.editor.transact(i=>i.setMeta(Ae,{name:Ui})),t&&o)){const i=this.threadPositions.get(t);if(!i)return;(s=(r=this.editor.prosemirrorView)==null?void 0:r.domAtPos(i.from).node)==null||s.scrollIntoView({behavior:"smooth",block:"center"})}}startPendingComment(){this.pendingComment=!0,this.emitStateUpdate()}stopPendingComment(){this.pendingComment=!1,this.emitStateUpdate()}async createThread(t){const o=await this.threadStore.createThread(t);if(this.threadStore.addThreadToDocument){const r=this.editor.prosemirrorView,s=r.state.selection,i=N.ySyncPluginKey.getState(r.state),a={prosemirror:{head:s.head,anchor:s.anchor},yjs:i?N.getRelativeSelection(i.binding,r.state):void 0};await this.threadStore.addThreadToDocument({threadId:o.id,selection:a})}else this.editor._tiptapEditor.commands.setMark(this.markType,{orphan:!1,threadId:o.id})}}class jo{constructor(n,t,o,r){p(this,"state");p(this,"emitUpdate");p(this,"mouseDownHandler",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())});p(this,"dragstartHandler",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())});p(this,"scrollHandler",()=>{var n;if((n=this.state)!=null&&n.show){const t=this.pmView.root.querySelector(`[data-node-type="blockContainer"][data-id="${this.state.block.id}"]`);if(!t)return;this.state.referencePos=t.getBoundingClientRect(),this.emitUpdate()}});p(this,"closeMenu",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())});this.editor=n,this.pluginKey=t,this.pmView=o,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized file panel");r(this.state)},o.dom.addEventListener("mousedown",this.mouseDownHandler),o.dom.addEventListener("dragstart",this.dragstartHandler),o.root.addEventListener("scroll",this.scrollHandler,!0)}update(n,t){var a,l;const o=this.pluginKey.getState(n.state),r=this.pluginKey.getState(t);if(!((a=this.state)!=null&&a.show)&&(o!=null&&o.block)&&this.editor.isEditable){const c=this.pmView.root.querySelector(`[data-node-type="blockContainer"][data-id="${o.block.id}"]`);if(!c)return;this.state={show:!0,referencePos:c.getBoundingClientRect(),block:o.block},this.emitUpdate();return}const s=(o==null?void 0:o.block)&&!(r!=null&&r.block),i=!(o!=null&&o.block)&&(r==null?void 0:r.block);s&&this.state&&!this.state.show&&(this.state.show=!0,this.emitUpdate()),i&&((l=this.state)!=null&&l.show)&&(this.state.show=!1,this.emitUpdate())}destroy(){this.pmView.dom.removeEventListener("mousedown",this.mouseDownHandler),this.pmView.dom.removeEventListener("dragstart",this.dragstartHandler),this.pmView.root.removeEventListener("scroll",this.scrollHandler,!0)}}const st=new y.PluginKey("FilePanelPlugin");class Go extends O{constructor(t){super();p(this,"view");p(this,"closeMenu",()=>{var t;return(t=this.view)==null?void 0:t.closeMenu()});this.addProsemirrorPlugin(new y.Plugin({key:st,view:o=>(this.view=new jo(t,st,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(st);return s||(!o.getMeta(N.ySyncPluginKey)&&(o.selectionSet||o.docChanged)?{block:void 0}:r)}}}))}static key(){return"filePanel"}get shown(){var t,o;return((o=(t=this.view)==null?void 0:t.state)==null?void 0:o.show)||!1}onUpdate(t){return this.on("update",t)}}class Yo{constructor(n,t,o){p(this,"state");p(this,"emitUpdate");p(this,"preventHide",!1);p(this,"preventShow",!1);p(this,"shouldShow",({view:n,state:t,from:o,to:r})=>{const{doc:s,selection:i}=t,{empty:a}=i,l=!s.textBetween(o,r).length&&k.isTextSelection(t.selection);if(i.$from.parent.type.spec.code||k.isNodeSelection(i)&&i.node.type.spec.code||a||l)return!1;const c=document.activeElement;return!(!this.isElementWithinEditorWrapper(c)&&n.editable)});p(this,"blurHandler",n=>{var o;if(this.preventHide){this.preventHide=!1;return}const t=this.pmView.dom.parentElement;n&&n.relatedTarget&&(t===n.relatedTarget||t.contains(n.relatedTarget)||n.relatedTarget.matches(".bn-ui-container, .bn-ui-container *"))||(o=this.state)!=null&&o.show&&(this.state.show=!1,this.emitUpdate())});p(this,"isElementWithinEditorWrapper",n=>{if(!n)return!1;const t=this.pmView.dom.parentElement;return t?t.contains(n):!1});p(this,"viewMousedownHandler",n=>{this.isElementWithinEditorWrapper(n.target)||(this.preventShow=!0)});p(this,"mouseupHandler",()=>{this.preventShow&&(this.preventShow=!1,setTimeout(()=>this.update(this.pmView)))});p(this,"dragHandler",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())});p(this,"scrollHandler",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.referencePos=this.getSelectionBoundingBox(),this.emitUpdate())});p(this,"closeMenu",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())});this.editor=n,this.pmView=t,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized formatting toolbar");o(this.state)},t.dom.addEventListener("mousedown",this.viewMousedownHandler),t.root.addEventListener("mouseup",this.mouseupHandler),t.dom.addEventListener("dragstart",this.dragHandler),t.dom.addEventListener("dragover",this.dragHandler),t.dom.addEventListener("blur",this.blurHandler),t.root.addEventListener("scroll",this.scrollHandler,!0)}update(n,t){var f,m,g;const{state:o,composing:r}=n,{doc:s,selection:i}=o,a=t&&t.doc.eq(s)&&t.selection.eq(i);if(r||a)return;const{ranges:l}=i,c=Math.min(...l.map(b=>b.$from.pos)),d=Math.max(...l.map(b=>b.$to.pos)),u=this.shouldShow({view:n,state:o,from:c,to:d}),h=typeof Range.prototype.getClientRects>"u";if(!this.preventShow&&(u||this.preventHide)&&!h){const b={show:!0,referencePos:this.getSelectionBoundingBox()};(b.show!==((f=this.state)==null?void 0:f.show)||b.referencePos.toJSON()!==((m=this.state)==null?void 0:m.referencePos.toJSON()))&&(this.state=b,this.emitUpdate());return}if((g=this.state)!=null&&g.show&&!this.preventHide&&(!u||this.preventShow||!this.editor.isEditable)){this.state.show=!1,this.emitUpdate();return}}destroy(){this.pmView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.pmView.root.removeEventListener("mouseup",this.mouseupHandler),this.pmView.dom.removeEventListener("dragstart",this.dragHandler),this.pmView.dom.removeEventListener("dragover",this.dragHandler),this.pmView.dom.removeEventListener("blur",this.blurHandler),this.pmView.root.removeEventListener("scroll",this.scrollHandler,!0)}getSelectionBoundingBox(){const{state:n}=this.pmView,{selection:t}=n,{ranges:o}=t,r=Math.min(...o.map(i=>i.$from.pos)),s=Math.max(...o.map(i=>i.$to.pos));if(k.isNodeSelection(t)){const i=this.pmView.nodeDOM(r);if(i)return i.getBoundingClientRect()}return k.posToDOMRect(this.pmView,r,s)}}const Jo=new y.PluginKey("FormattingToolbarPlugin");class Xo extends O{constructor(t){super();p(this,"view");p(this,"closeMenu",()=>this.view.closeMenu());this.addProsemirrorPlugin(new y.Plugin({key:Jo,view:o=>(this.view=new Yo(t,o,r=>{this.emit("update",r)}),this.view),props:{handleKeyDown:(o,r)=>r.key==="Escape"&&this.shown?(this.view.closeMenu(),!0):!1}}))}static key(){return"formattingToolbar"}get shown(){var t,o;return((o=(t=this.view)==null?void 0:t.state)==null?void 0:o.show)||!1}onUpdate(t){return this.on("update",t)}}const zi=k.Node.create({name:"hardBreak",inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,priority:10,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:e}){return["br",k.mergeAttributes(this.options.HTMLAttributes,e)]},renderText(){return`
|
|
12
|
+
`}}),tn=(e,n)=>{const t=e.resolve(n);if(t.depth<=1)return;const o=t.posAtIndex(t.index(t.depth-1),t.depth-1);return be(e.resolve(o))},Re=(e,n)=>{const t=e.resolve(n),o=t.index();if(o===0)return;const r=t.posAtIndex(o-1);return be(e.resolve(r))},Zo=(e,n)=>{for(;n.childContainer;){const t=n.childContainer.node,o=e.resolve(n.childContainer.beforePos+1).posAtIndex(t.childCount-1);n=be(e.resolve(o))}return n},Wi=(e,n)=>e.isBlockContainer&&e.blockContent.node.type.spec.content==="inline*"&&e.blockContent.node.childCount>0&&n.isBlockContainer&&n.blockContent.node.type.spec.content==="inline*",Ki=(e,n,t,o)=>{if(!o.isBlockContainer)throw new Error(`Attempted to merge block at position ${o.bnBlock.beforePos} into previous block at position ${t.bnBlock.beforePos}, but next block is not a block container`);if(o.childContainer){const r=e.doc.resolve(o.childContainer.beforePos+1),s=e.doc.resolve(o.childContainer.afterPos-1),i=r.blockRange(s);if(n){const a=e.doc.resolve(o.bnBlock.beforePos);e.tr.lift(i,a.depth)}}if(n){if(!t.isBlockContainer)throw new Error(`Attempted to merge block at position ${o.bnBlock.beforePos} into previous block at position ${t.bnBlock.beforePos}, but previous block is not a block container`);n(e.tr.delete(t.blockContent.afterPos-1,o.blockContent.beforePos+1))}return!0},nn=e=>({state:n,dispatch:t})=>{const o=n.doc.resolve(e),r=be(o),s=Re(n.doc,r.bnBlock.beforePos);if(!s)return!1;const i=Zo(n.doc,s);return Wi(i,r)?Ki(n,t,i,r):!1},qi=k.Extension.create({priority:50,addKeyboardShortcuts(){const e=()=>this.editor.commands.first(({chain:o,commands:r})=>[()=>r.deleteSelection(),()=>r.undoInputRule(),()=>r.command(({state:s})=>{const i=B(s);if(!i.isBlockContainer)return!1;const a=s.selection.from===i.blockContent.beforePos+1,l=i.blockContent.node.type.name==="paragraph";return a&&!l?r.command(D(i.bnBlock.beforePos,{type:"paragraph",props:{}})):!1}),()=>r.command(({state:s})=>{const i=B(s);if(!i.isBlockContainer)return!1;const{blockContent:a}=i;return s.selection.from===a.beforePos+1?r.liftListItem("blockContainer"):!1}),()=>r.command(({state:s})=>{const i=B(s);if(!i.isBlockContainer)return!1;const{bnBlock:a,blockContent:l}=i,c=s.selection.from===l.beforePos+1,d=s.selection.empty,u=a.beforePos;return c&&d?o().command(nn(u)).scrollIntoView().run():!1}),()=>r.command(({state:s,dispatch:i})=>{const a=B(s);if(!a.isBlockContainer||!(s.selection.from===a.blockContent.beforePos+1)||Re(s.doc,a.bnBlock.beforePos))return!1;const d=tn(s.doc,a.bnBlock.beforePos);if((d==null?void 0:d.blockNoteType)!=="column")return!1;const u=d,h=tn(s.doc,u.bnBlock.beforePos);if((h==null?void 0:h.blockNoteType)!=="columnList")throw new Error("parent of column is not a column list");const f=u.childContainer.node.childCount===1,m=f&&h.childContainer.node.childCount===2,g=h.childContainer.node.firstChild===u.bnBlock.node;if(i){const b=s.doc.slice(a.bnBlock.beforePos,a.bnBlock.afterPos,!1);if(m)if(g){s.tr.step(new pe.ReplaceAroundStep(h.bnBlock.beforePos,h.bnBlock.afterPos,u.bnBlock.afterPos+1,h.bnBlock.afterPos-2,b,b.size,!1));const w=s.tr.doc.resolve(u.bnBlock.beforePos);s.tr.setSelection(y.TextSelection.between(w,w))}else{s.tr.step(new pe.ReplaceAroundStep(h.bnBlock.beforePos,h.bnBlock.afterPos,h.bnBlock.beforePos+2,u.bnBlock.beforePos-1,b,0,!1));const w=s.tr.doc.resolve(s.tr.mapping.map(u.bnBlock.beforePos-1));s.tr.setSelection(y.TextSelection.between(w,w))}else if(f)if(g){s.tr.delete(u.bnBlock.beforePos,u.bnBlock.afterPos),s.tr.insert(h.bnBlock.beforePos,b.content);const w=s.tr.doc.resolve(h.bnBlock.beforePos);s.tr.setSelection(y.TextSelection.between(w,w))}else s.tr.delete(u.bnBlock.beforePos-1,u.bnBlock.beforePos+1);else{s.tr.delete(a.bnBlock.beforePos,a.bnBlock.afterPos),g?s.tr.insert(h.bnBlock.beforePos-1,b.content):s.tr.insert(u.bnBlock.beforePos-1,b.content);const w=s.tr.doc.resolve(u.bnBlock.beforePos-1);s.tr.setSelection(y.TextSelection.between(w,w))}}return!0}),()=>r.command(({state:s})=>{const i=B(s);if(!i.isBlockContainer)return!1;if(i.blockContent.node.childCount===0&&i.blockContent.node.type.spec.content==="inline*"){const l=Re(s.doc,i.bnBlock.beforePos);if(!l||!l.isBlockContainer)return!1;let c=o();if(l.blockContent.node.type.spec.content==="tableRow+"){const m=i.bnBlock.beforePos-1-1-1-1-1;c=c.setTextSelection(m)}else if(l.blockContent.node.type.spec.content===""){const d=l.blockContent.afterPos-l.blockContent.node.nodeSize;c=c.setNodeSelection(d)}else{const d=l.blockContent.afterPos-l.blockContent.node.nodeSize;c=c.setTextSelection(d)}return c.deleteRange({from:i.bnBlock.beforePos,to:i.bnBlock.afterPos}).scrollIntoView().run()}return!1}),()=>r.command(({state:s})=>{const i=B(s);if(!i.isBlockContainer)throw new Error("todo");const a=s.selection.from===i.blockContent.beforePos+1,l=s.selection.empty,c=Re(s.doc,i.bnBlock.beforePos);if(c&&a&&l){const d=Zo(s.doc,c);if(!d.isBlockContainer)throw new Error("todo");if(d.blockContent.node.type.spec.content===""||d.blockContent.node.type.spec.content==="inline*"&&d.blockContent.node.childCount===0)return o().cut({from:i.bnBlock.beforePos,to:i.bnBlock.afterPos},d.bnBlock.afterPos).deleteRange({from:d.bnBlock.beforePos,to:d.bnBlock.afterPos}).run()}return!1})]),n=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.command(({state:r})=>{const s=B(r);if(!s.isBlockContainer)return!1;const{bnBlock:i,blockContent:a,childContainer:l}=s,{depth:c}=r.doc.resolve(i.beforePos),d=i.afterPos===r.doc.nodeSize-3,u=r.selection.from===a.afterPos-1,h=r.selection.empty;if(!d&&u&&h&&!(l!==void 0)){let m=c,g=i.afterPos+1,b=r.doc.resolve(g).depth;for(;b<m;)m=b,g+=2,b=r.doc.resolve(g).depth;return o.command(nn(g-1))}return!1})]),t=(o=!1)=>this.editor.commands.first(({commands:r})=>[()=>r.command(({state:s})=>{const i=B(s);if(!i.isBlockContainer)return!1;const{bnBlock:a,blockContent:l}=i,{depth:c}=s.doc.resolve(a.beforePos),d=s.selection.$anchor.parentOffset===0,u=s.selection.anchor===s.selection.head,h=l.node.childCount===0,f=c>1;return d&&u&&h&&f?r.liftListItem("blockContainer"):!1}),()=>r.command(({state:s})=>{const i=B(s),a=this.options.editor.schema.blockSchema[i.blockNoteType].hardBreakShortcut??"shift+enter";return a==="none"?!1:a==="shift+enter"&&o||a==="enter"?r.insertContent({type:"hardBreak"}):!1}),()=>r.command(({state:s,dispatch:i})=>{const a=B(s);if(!a.isBlockContainer)return!1;const{bnBlock:l,blockContent:c}=a,d=s.selection.$anchor.parentOffset===0,u=s.selection.anchor===s.selection.head,h=c.node.childCount===0;if(d&&u&&h){const f=l.afterPos,m=f+2;if(i){const g=s.schema.nodes.blockContainer.createAndFill();s.tr.insert(f,g).scrollIntoView(),s.tr.setSelection(new y.TextSelection(s.doc.resolve(m)))}return!0}return!1}),()=>r.command(({state:s,chain:i})=>{const a=B(s);if(!a.isBlockContainer)return!1;const{blockContent:l}=a,c=s.selection.$anchor.parentOffset===0;return l.node.childCount===0?!1:(i().deleteSelection().command(co(s.selection.from,c,c)).run(),!0)})]);return{Backspace:e,Delete:n,Enter:()=>t(),"Shift-Enter":()=>t(!0),Tab:()=>{var o,r,s;return this.options.tabBehavior!=="prefer-indent"&&((o=this.options.editor.formattingToolbar)!=null&&o.shown||(r=this.options.editor.linkToolbar)!=null&&r.shown||(s=this.options.editor.filePanel)!=null&&s.shown)?!1:Do(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 ji{constructor(n,t,o){p(this,"state");p(this,"emitUpdate");p(this,"menuUpdateTimer");p(this,"startMenuUpdateTimer");p(this,"stopMenuUpdateTimer");p(this,"mouseHoveredLinkMark");p(this,"mouseHoveredLinkMarkRange");p(this,"keyboardHoveredLinkMark");p(this,"keyboardHoveredLinkMarkRange");p(this,"linkMark");p(this,"linkMarkRange");p(this,"mouseOverHandler",n=>{if(this.mouseHoveredLinkMark=void 0,this.mouseHoveredLinkMarkRange=void 0,this.stopMenuUpdateTimer(),n.target instanceof HTMLAnchorElement&&n.target.nodeName==="A"){const t=n.target,o=this.pmView.posAtDOM(t,0)+1,r=this.pmView.state.doc.resolve(o),s=r.marks();for(const i of s)if(i.type.name===this.pmView.state.schema.mark("link").type.name){this.mouseHoveredLinkMark=i,this.mouseHoveredLinkMarkRange=k.getMarkRange(r,i.type,i.attrs)||void 0;break}}return this.startMenuUpdateTimer(),!1});p(this,"clickHandler",n=>{var o;const t=this.pmView.dom.parentElement;this.linkMark&&n&&n.target&&!(t===n.target||t.contains(n.target))&&(o=this.state)!=null&&o.show&&(this.state.show=!1,this.emitUpdate())});p(this,"scrollHandler",()=>{var n;this.linkMark!==void 0&&(n=this.state)!=null&&n.show&&(this.state.referencePos=k.posToDOMRect(this.pmView,this.linkMarkRange.from,this.linkMarkRange.to),this.emitUpdate())});p(this,"closeMenu",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())});this.editor=n,this.pmView=t,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized link toolbar");o(this.state)},this.startMenuUpdateTimer=()=>{this.menuUpdateTimer=setTimeout(()=>{this.update(this.pmView,void 0,!0)},250)},this.stopMenuUpdateTimer=()=>(this.menuUpdateTimer&&(clearTimeout(this.menuUpdateTimer),this.menuUpdateTimer=void 0),!1),this.pmView.dom.addEventListener("mouseover",this.mouseOverHandler),this.pmView.root.addEventListener("click",this.clickHandler,!0),this.pmView.root.addEventListener("scroll",this.scrollHandler,!0)}editLink(n,t){var o;this.editor.transact(r=>{const s=H(r);r.insertText(t,this.linkMarkRange.from,this.linkMarkRange.to),r.addMark(this.linkMarkRange.from,this.linkMarkRange.from+t.length,s.mark("link",{href:n}))}),this.pmView.focus(),(o=this.state)!=null&&o.show&&(this.state.show=!1,this.emitUpdate())}deleteLink(){var n;this.editor.transact(t=>t.removeMark(this.linkMarkRange.from,this.linkMarkRange.to,this.linkMark.type).setMeta("preventAutolink",!0)),this.pmView.focus(),(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate())}update(n,t,o=!1){var a;const{state:r}=n;if(t&&t.selection.from===r.selection.from&&t.selection.to===r.selection.to||!this.pmView.hasFocus())return;const i=this.linkMark;if(this.linkMark=void 0,this.linkMarkRange=void 0,this.keyboardHoveredLinkMark=void 0,this.keyboardHoveredLinkMarkRange=void 0,this.pmView.state.selection.empty){const l=this.pmView.state.selection.$from.marks();for(const c of l)if(c.type.name===this.pmView.state.schema.mark("link").type.name){this.keyboardHoveredLinkMark=c,this.keyboardHoveredLinkMarkRange=k.getMarkRange(this.pmView.state.selection.$from,c.type,c.attrs)||void 0;break}}if(this.mouseHoveredLinkMark&&o&&(this.linkMark=this.mouseHoveredLinkMark,this.linkMarkRange=this.mouseHoveredLinkMarkRange),this.keyboardHoveredLinkMark&&(this.linkMark=this.keyboardHoveredLinkMark,this.linkMarkRange=this.keyboardHoveredLinkMarkRange),this.linkMark&&this.editor.isEditable){this.state={show:!0,referencePos:k.posToDOMRect(this.pmView,this.linkMarkRange.from,this.linkMarkRange.to),url:this.linkMark.attrs.href,text:this.pmView.state.doc.textBetween(this.linkMarkRange.from,this.linkMarkRange.to)},this.emitUpdate();return}if((a=this.state)!=null&&a.show&&i&&(!this.linkMark||!this.editor.isEditable)){this.state.show=!1,this.emitUpdate();return}}destroy(){this.pmView.dom.removeEventListener("mouseover",this.mouseOverHandler),this.pmView.root.removeEventListener("scroll",this.scrollHandler,!0),this.pmView.root.removeEventListener("click",this.clickHandler,!0)}}const Qo=new y.PluginKey("LinkToolbarPlugin");class er extends O{constructor(t){super();p(this,"view");p(this,"editLink",(t,o)=>{this.view.editLink(t,o)});p(this,"deleteLink",()=>{this.view.deleteLink()});p(this,"startHideTimer",()=>{this.view.startMenuUpdateTimer()});p(this,"stopHideTimer",()=>{this.view.stopMenuUpdateTimer()});p(this,"closeMenu",()=>this.view.closeMenu());this.addProsemirrorPlugin(new y.Plugin({key:Qo,view:o=>(this.view=new ji(t,o,r=>{this.emit("update",r)}),this.view),props:{handleKeyDown:(o,r)=>r.key==="Escape"&&this.shown?(this.view.closeMenu(),!0):!1}}))}static key(){return"linkToolbar"}onUpdate(t){return this.on("update",t)}get shown(){var t,o;return((o=(t=this.view)==null?void 0:t.state)==null?void 0:o.show)||!1}}const tr=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"],nr="https",Gi=new y.PluginKey("node-selection-keyboard");class Yi extends O{static key(){return"nodeSelectionKeyboard"}constructor(){super(),this.addProsemirrorPlugin(new y.Plugin({key:Gi,props:{handleKeyDown:(n,t)=>{if("node"in n.state.selection){if(t.ctrlKey||t.metaKey)return!1;if(t.key.length===1)return t.preventDefault(),!0;if(t.key==="Enter"&&!t.shiftKey&&!t.altKey&&!t.ctrlKey&&!t.metaKey){const o=n.state.tr;return n.dispatch(o.insert(n.state.tr.selection.$to.after(),n.state.schema.nodes.paragraph.createChecked()).setSelection(new y.TextSelection(o.doc.resolve(n.state.tr.selection.$to.after()+1)))),!0}}return!1}}}))}}const Ji=new y.PluginKey("blocknote-placeholder");class Xi extends O{static key(){return"placeholder"}constructor(n,t){super(),this.addProsemirrorPlugin(new y.Plugin({key:Ji,view:o=>{var c,d;const r=`placeholder-selector-${cn.v4()}`;o.dom.classList.add(r);const s=document.createElement("style"),i=n._tiptapEditor.options.injectNonce;i&&s.setAttribute("nonce",i),((c=n.prosemirrorView)==null?void 0:c.root)instanceof ShadowRoot?n.prosemirrorView.root.append(s):(d=n.prosemirrorView)==null||d.root.head.appendChild(s);const a=s.sheet,l=(u="")=>`.${r} .bn-block-content${u} .bn-inline-content:has(> .ProseMirror-trailingBreak:only-child):before`;try{const{default:u,emptyDocument:h,...f}=t;for(const[b,w]of Object.entries(f)){const C=`[data-content-type="${b}"]`;a.insertRule(`${l(C)} { content: ${JSON.stringify(w)}; }`)}const m="[data-is-only-empty-block]",g="[data-is-empty-and-focused]";a.insertRule(`${l(m)} { content: ${JSON.stringify(h)}; }`),a.insertRule(`${l(g)} { content: ${JSON.stringify(u)}; }`)}catch(u){console.warn("Failed to insert placeholder CSS rule - this is likely due to the browser not supporting certain CSS pseudo-element selectors (:has, :only-child:, or :before)",u)}return{destroy:()=>{var u,h;((u=n.prosemirrorView)==null?void 0:u.root)instanceof ShadowRoot?n.prosemirrorView.root.removeChild(s):(h=n.prosemirrorView)==null||h.root.head.removeChild(s)}}},props:{decorations:o=>{const{doc:r,selection:s}=o;if(!n.isEditable||!s.empty||s.$from.parent.type.spec.code)return;const i=[];o.doc.content.size===6&&i.push(M.Decoration.node(2,4,{"data-is-only-empty-block":"true"}));const a=s.$anchor,l=a.parent;if(l.content.size===0){const c=a.before();i.push(M.Decoration.node(c,c+l.nodeSize,{"data-is-empty-and-focused":"true"}))}return M.DecorationSet.create(r,i)}}}))}}const on=new y.PluginKey("previous-blocks"),Zi={index:"index",level:"level",type:"type",depth:"depth","depth-change":"depth-change"};class Qi extends O{static key(){return"previousBlockType"}constructor(){super();let n;this.addProsemirrorPlugin(new y.Plugin({key:on,view(t){return{update:async(o,r)=>{var s;((s=this.key)==null?void 0:s.getState(o.state).updatedBlocks.size)>0&&(n=setTimeout(()=>{o.dispatch(o.state.tr.setMeta(on,{clearUpdate:!0}))},0))},destroy:()=>{n&&clearTimeout(n)}}},state:{init(){return{prevTransactionOldBlockAttrs:{},currentTransactionOldBlockAttrs:{},updatedBlocks:new Set}},apply(t,o,r,s){if(o.currentTransactionOldBlockAttrs={},o.updatedBlocks.clear(),!t.docChanged||r.doc.eq(s.doc))return o;const i={},a=k.findChildren(r.doc,d=>d.attrs.id),l=new Map(a.map(d=>[d.node.attrs.id,d])),c=k.findChildren(s.doc,d=>d.attrs.id);for(const d of c){const u=l.get(d.node.attrs.id),h=u==null?void 0:u.node.firstChild,f=d.node.firstChild;if(u&&h&&f){const m={index:f.attrs.index,level:f.attrs.level,type:f.type.name,depth:s.doc.resolve(d.pos).depth};let g={index:h.attrs.index,level:h.attrs.level,type:h.type.name,depth:r.doc.resolve(u.pos).depth};i[d.node.attrs.id]=g,t.getMeta("numberedListIndexing")&&(d.node.attrs.id in o.prevTransactionOldBlockAttrs&&(g=o.prevTransactionOldBlockAttrs[d.node.attrs.id]),m.type==="numberedListItem"&&(g.index=m.index)),o.currentTransactionOldBlockAttrs[d.node.attrs.id]=g,JSON.stringify(g)!==JSON.stringify(m)&&(g["depth-change"]=g.depth-m.depth,o.updatedBlocks.add(d.node.attrs.id))}}return o.prevTransactionOldBlockAttrs=i,o}},props:{decorations(t){const o=this.getState(t);if(o.updatedBlocks.size===0)return;const r=[];return t.doc.descendants((s,i)=>{if(!s.attrs.id||!o.updatedBlocks.has(s.attrs.id))return;const a=o.currentTransactionOldBlockAttrs[s.attrs.id],l={};for(const[d,u]of Object.entries(a))l["data-prev-"+Zi[d]]=u||"none";const c=M.Decoration.node(i,i+s.nodeSize,{...l});r.push(c)}),M.DecorationSet.create(t.doc,r)}}}))}}const rn=new y.PluginKey("blocknote-show-selection");class ea extends O{constructor(t){super();p(this,"enabled",!1);this.editor=t,this.addProsemirrorPlugin(new y.Plugin({key:rn,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(t){this.enabled!==t&&(this.enabled=t,this.editor.transact(o=>o.setMeta(rn,{})))}getEnabled(){return this.enabled}}function or(e,n){var t,o;for(;e&&e.parentElement&&e.parentElement!==n.dom&&((t=e.getAttribute)==null?void 0:t.call(e,"data-node-type"))!=="blockContainer";)e=e.parentElement;if(((o=e.getAttribute)==null?void 0:o.call(e,"data-node-type"))==="blockContainer")return{node:e,id:e.getAttribute("data-id")}}class ie extends y.Selection{constructor(t,o){super(t,o);p(this,"nodes");const r=t.node();this.nodes=[],t.doc.nodesBetween(t.pos,o.pos,(s,i,a)=>{if(a!==null&&a.eq(r))return this.nodes.push(s),!1})}static create(t,o,r=o){return new ie(t.resolve(o),t.resolve(r))}content(){return new E.Slice(E.Fragment.from(this.nodes),0,0)}eq(t){if(!(t instanceof ie)||this.nodes.length!==t.nodes.length||this.from!==t.from||this.to!==t.to)return!1;for(let o=0;o<this.nodes.length;o++)if(!this.nodes[o].eq(t.nodes[o]))return!1;return!0}map(t,o){const r=o.mapResult(this.from),s=o.mapResult(this.to);return s.deleted?y.Selection.near(t.resolve(r.pos)):r.deleted?y.Selection.near(t.resolve(s.pos)):new ie(t.resolve(r.pos),t.resolve(s.pos))}toJSON(){return{type:"multiple-node",anchor:this.anchor,head:this.head}}}y.Selection.jsonID("multiple-node",ie);let q;function ta(e,n){let t,o;const r=n.resolve(e.from).node().type.spec.group==="blockContent",s=n.resolve(e.to).node().type.spec.group==="blockContent",i=Math.min(e.$anchor.depth,e.$head.depth);if(r&&s){const a=e.$from.start(i-1),l=e.$to.end(i-1);t=n.resolve(a-1).pos,o=n.resolve(l+1).pos}else t=e.from,o=e.to;return{from:t,to:o}}function sn(e,n,t=n){n===t&&(t+=e.state.doc.resolve(n+1).node().nodeSize);const o=e.domAtPos(n).node.cloneNode(!0),r=e.domAtPos(n).node,s=(u,h)=>Array.prototype.indexOf.call(u.children,h),i=s(r,e.domAtPos(n+1).node.parentElement),a=s(r,e.domAtPos(t-1).node.parentElement);for(let u=r.childElementCount-1;u>=0;u--)(u>a||u<i)&&o.removeChild(o.children[u]);rr(e.root),q=o;const l=q.getElementsByTagName("iframe");for(let u=0;u<l.length;u++){const h=l[u],f=h.parentElement;f&&f.removeChild(h)}const d=e.dom.className.split(" ").filter(u=>u!=="ProseMirror"&&u!=="bn-root"&&u!=="bn-editor").join(" ");q.className=q.className+" bn-drag-preview "+d,e.root instanceof ShadowRoot?e.root.appendChild(q):e.root.body.appendChild(q)}function rr(e){q!==void 0&&(e instanceof ShadowRoot?e.removeChild(q):e.body.removeChild(q),q=void 0)}function na(e,n,t){if(!e.dataTransfer)return;const o=t.prosemirrorView;if(!o)return;const r=F(n.id,o.state.doc);if(!r)throw new Error(`Block with ID ${n.id} not found`);const s=r.posBeforeNode;if(s!=null){const i=o.state.selection,a=o.state.doc,{from:l,to:c}=ta(i,a),d=l<=s&&s<c,u=i.$anchor.node()!==i.$head.node()||i instanceof ie;d&&u?(o.dispatch(o.state.tr.setSelection(ie.create(a,l,c))),sn(o,l,c)):(o.dispatch(o.state.tr.setSelection(y.NodeSelection.create(o.state.doc,s))),sn(o,s));const h=o.state.selection.content(),f=t.pmSchema,m=o.serializeForClipboard(h).dom.innerHTML,g=Me(f,t),b=Ko(h.content),w=g.exportBlocks(b,{}),C=et(w);e.dataTransfer.clearData(),e.dataTransfer.setData("blocknote/html",m),e.dataTransfer.setData("text/html",w),e.dataTransfer.setData("text/plain",C),e.dataTransfer.effectAllowed="move",e.dataTransfer.setDragImage(q,0,0)}}const ye=.1;function yt(e,n,t,o=!0){const r=e.root.elementsFromPoint(n.left+(t==="editor"?50:0),n.top);for(const s of r)if(e.dom.contains(s))return o&&s.closest("[data-node-type=columnList]")?yt(e,{left:n.left+50,top:n.top},t,!1):or(s,e)}function oa(e,n,t){if(!n.dom.firstChild)return;const o=n.dom.firstChild.getBoundingClientRect(),r={left:e.x,top:e.y},s=r.left<o.left,i=r.left>o.right;t==="viewport"&&(s&&(r.left=o.left+10),i&&(r.left=o.right-10));let a=yt(n,r,t);if(!i&&a){const l=a.node.getBoundingClientRect();r.left=l.right-10,a=yt(n,r,"viewport",!1)}return a}class sr{constructor(n,t,o,r){p(this,"state");p(this,"emitUpdate");p(this,"mousePos");p(this,"hoveredBlock");p(this,"menuFrozen",!1);p(this,"isDragOrigin",!1);p(this,"updateState",n=>{this.state=n,this.emitUpdate(this.state)});p(this,"updateStateFromMousePos",()=>{var o,r,s,i;if(this.menuFrozen||!this.mousePos)return;const n=oa(this.mousePos,this.pmView,this.sideMenuDetection);if(!n||!this.editor.isEditable){(o=this.state)!=null&&o.show&&(this.state.show=!1,this.updateState(this.state));return}if((r=this.state)!=null&&r.show&&((s=this.hoveredBlock)!=null&&s.hasAttribute("data-id"))&&((i=this.hoveredBlock)==null?void 0:i.getAttribute("data-id"))===n.id)return;this.hoveredBlock=n.node;const t=n.node.firstChild;if(t&&this.editor.isEditable){const a=t.getBoundingClientRect(),l=n.node.closest("[data-node-type=column]");this.updateState({show:!0,referencePos:new DOMRect(l?l.firstElementChild.getBoundingClientRect().x:this.pmView.dom.firstChild.getBoundingClientRect().x,a.y,a.width,a.height),block:this.editor.getBlock(this.hoveredBlock.getAttribute("data-id"))})}});p(this,"onDrop",n=>{var r,s;if(this.pmView.dragging===null)return;this.editor._tiptapEditor.commands.blur();const t=n.target instanceof Node&&((r=n.target instanceof HTMLElement?n.target:n.target.parentElement)==null?void 0:r.closest(".bn-editor"))||null;if(t&&(!this.isDragOrigin&&this.pmView.dom===t?this.pmView.dispatch(this.pmView.state.tr.setSelection(y.TextSelection.create(this.pmView.state.tr.doc,this.pmView.state.tr.selection.to))):this.isDragOrigin&&this.pmView.dom!==t&&setTimeout(()=>this.pmView.dispatch(this.pmView.state.tr.deleteSelection()),0)),this.sideMenuDetection==="editor"||n.synthetic||!((s=n.dataTransfer)!=null&&s.types.includes("blocknote/html")))return;const o=this.pmView.posAtCoords({left:n.clientX,top:n.clientY});if(!o||o.inside===-1){const i=this.createSyntheticEvent(n);this.pmView.dom.dispatchEvent(i)}});p(this,"onDragEnd",()=>{this.pmView.dragging=null});p(this,"onDragStart",n=>{var i;const t=(i=n.dataTransfer)==null?void 0:i.getData("blocknote/html");if(!t)return;if(this.pmView.dragging)throw new Error("New drag was started while an existing drag is ongoing");const o=document.createElement("div");o.innerHTML=t;const s=E.DOMParser.fromSchema(this.pmView.state.schema).parse(o,{topNode:this.pmView.state.schema.nodes.blockGroup.create()});this.pmView.dragging={slice:new E.Slice(s.content,0,0),move:!0}});p(this,"onDragOver",n=>{var o;if(this.sideMenuDetection==="editor"||n.synthetic||!((o=n.dataTransfer)!=null&&o.types.includes("blocknote/html")))return;const t=this.pmView.posAtCoords({left:n.clientX,top:n.clientY});if(!t||t.inside===-1&&this.pmView.dom.firstChild){const r=this.createSyntheticEvent(n);this.pmView.dom.dispatchEvent(r)}});p(this,"onKeyDown",n=>{var t;(t=this.state)!=null&&t.show&&this.editor.isFocused()&&(this.state.show=!1,this.emitUpdate(this.state))});p(this,"onMouseMove",n=>{var s;if(this.menuFrozen)return;this.mousePos={x:n.clientX,y:n.clientY};const t=this.pmView.dom.getBoundingClientRect(),o=this.mousePos.x>t.left&&this.mousePos.x<t.right&&this.mousePos.y>t.top&&this.mousePos.y<t.bottom,r=this.pmView.dom.parentElement;if(o&&n&&n.target&&!(r===n.target||r.contains(n.target))){(s=this.state)!=null&&s.show&&(this.state.show=!1,this.emitUpdate(this.state));return}this.updateStateFromMousePos()});p(this,"onScroll",()=>{var n;(n=this.state)!=null&&n.show&&(this.state.referencePos=this.hoveredBlock.getBoundingClientRect(),this.emitUpdate(this.state))});this.editor=n,this.sideMenuDetection=t,this.pmView=o,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized side menu");r(this.state)},this.pmView.root.addEventListener("dragstart",this.onDragStart),this.pmView.root.addEventListener("dragover",this.onDragOver),this.pmView.root.addEventListener("drop",this.onDrop,!0),this.pmView.root.addEventListener("dragend",this.onDragEnd,!0),Qe(),this.pmView.root.addEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.addEventListener("keydown",this.onKeyDown,!0),o.root.addEventListener("scroll",this.onScroll,!0)}createSyntheticEvent(n){const t=new Event(n.type,n),o=this.pmView.dom.firstChild.getBoundingClientRect();return t.clientX=n.clientX,t.clientY=n.clientY,n.clientX<o.left&&n.clientX>o.left-o.width*ye?t.clientX=o.left+o.width*ye/2:n.clientX>o.right&&n.clientX<o.right+o.width*ye?t.clientX=o.right-o.width*ye/2:(n.clientX<o.left||n.clientX>o.right)&&(t.clientX=o.left+ye*o.width*2),t.clientY=Math.min(Math.max(n.clientY,o.top),o.top+o.height),t.dataTransfer=n.dataTransfer,t.preventDefault=()=>n.preventDefault(),t.synthetic=!0,t}update(n,t){var r;!t.doc.eq(this.pmView.state.doc)&&((r=this.state)!=null&&r.show)&&this.updateStateFromMousePos()}destroy(){var n;(n=this.state)!=null&&n.show&&(this.state.show=!1,this.emitUpdate(this.state)),this.pmView.root.removeEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.removeEventListener("dragstart",this.onDragStart),this.pmView.root.removeEventListener("dragover",this.onDragOver),this.pmView.root.removeEventListener("drop",this.onDrop,!0),this.pmView.root.removeEventListener("dragend",this.onDragEnd,!0),this.pmView.root.removeEventListener("keydown",this.onKeyDown,!0),this.pmView.root.removeEventListener("scroll",this.onScroll,!0)}}const ir=new y.PluginKey("SideMenuPlugin");class ar extends O{constructor(t,o){super();p(this,"view");p(this,"blockDragStart",(t,o)=>{this.view&&(this.view.isDragOrigin=!0),na(t,o,this.editor)});p(this,"blockDragEnd",()=>{this.editor.prosemirrorView&&rr(this.editor.prosemirrorView.root),this.view&&(this.view.isDragOrigin=!1)});p(this,"freezeMenu",()=>{this.view.menuFrozen=!0,this.view.state.show=!0,this.view.emitUpdate(this.view.state)});p(this,"unfreezeMenu",()=>{this.view.menuFrozen=!1,this.view.state.show=!1,this.view.emitUpdate(this.view.state)});this.editor=t,this.addProsemirrorPlugin(new y.Plugin({key:ir,view:r=>(this.view=new sr(t,o,r,s=>{this.emit("update",s)}),this.view)}))}static key(){return"sideMenu"}onUpdate(t){return this.on("update",t)}}const Ne=new Map;function ra(e){if(Ne.has(e))return Ne.get(e);const n=new pe.Mapping;return e._tiptapEditor.on("transaction",({transaction:t})=>{n.appendMapping(t.mapping)}),e._tiptapEditor.on("destroy",()=>{Ne.delete(e)}),Ne.set(e,n),n}function lr(e,n,t="left"){const o=N.ySyncPluginKey.getState(e._tiptapEditor.state);if(!o){const s=ra(e),i=s.maps.length;return()=>s.slice(i).map(n,t==="left"?-1:1)}const r=N.absolutePositionToRelativePosition(n+(t==="right"?1:0),o.binding.type,o.binding.mapping);return()=>{const s=N.ySyncPluginKey.getState(e._tiptapEditor.state),i=N.relativePositionToAbsolutePosition(s.doc,s.binding.type,r,s.binding.mapping);if(i===null)throw new Error("Position not found, cannot track positions");return i+(t==="right"?-1:0)}}const sa=k.findParentNode(e=>e.type.name==="blockContainer");class ia{constructor(n,t){p(this,"state");p(this,"emitUpdate");p(this,"rootEl");p(this,"pluginState");p(this,"handleScroll",()=>{var n,t;if((n=this.state)!=null&&n.show){const o=(t=this.rootEl)==null?void 0:t.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);if(!o)return;this.state.referencePos=o.getBoundingClientRect(),this.emitUpdate(this.pluginState.triggerCharacter)}});p(this,"closeMenu",()=>{this.editor.transact(n=>n.setMeta(ue,null))});p(this,"clearQuery",()=>{this.pluginState!==void 0&&this.editor._tiptapEditor.chain().focus().deleteRange({from:this.pluginState.queryStartPos()-(this.pluginState.deleteTriggerCharacter?this.pluginState.triggerCharacter.length:0),to:this.editor.transact(n=>n.selection.from)}).run()});var o,r;this.editor=n,this.pluginState=void 0,this.emitUpdate=s=>{var i;if(!this.state)throw new Error("Attempting to update uninitialized suggestions menu");t(s,{...this.state,ignoreQueryLength:(i=this.pluginState)==null?void 0:i.ignoreQueryLength})},this.rootEl=(o=this.editor.prosemirrorView)==null?void 0:o.root,(r=this.rootEl)==null||r.addEventListener("scroll",this.handleScroll,!0)}update(n,t){var c;const o=ue.getState(t),r=ue.getState(n.state),s=o===void 0&&r!==void 0,i=o!==void 0&&r===void 0;if(!s&&!(o!==void 0&&r!==void 0)&&!i)return;if(this.pluginState=i?o:r,i||!this.editor.isEditable){this.state&&(this.state.show=!1),this.emitUpdate(this.pluginState.triggerCharacter);return}const l=(c=this.rootEl)==null?void 0:c.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);this.editor.isEditable&&l&&(this.state={show:!0,referencePos:l.getBoundingClientRect(),query:this.pluginState.query},this.emitUpdate(this.pluginState.triggerCharacter))}destroy(){var n;(n=this.rootEl)==null||n.removeEventListener("scroll",this.handleScroll,!0)}}const ue=new y.PluginKey("SuggestionMenuPlugin");class cr extends O{constructor(t){super();p(this,"view");p(this,"triggerCharacters",[]);p(this,"addTriggerCharacter",t=>{this.triggerCharacters.push(t)});p(this,"removeTriggerCharacter",t=>{this.triggerCharacters=this.triggerCharacters.filter(o=>o!==t)});p(this,"closeMenu",()=>this.view.closeMenu());p(this,"clearQuery",()=>this.view.clearQuery());const o=this.triggerCharacters;this.addProsemirrorPlugin(new y.Plugin({key:ue,view:()=>(this.view=new ia(t,(r,s)=>{this.emit(`update ${r}`,s)}),this.view),state:{init(){},apply:(r,s,i,a)=>{if(r.getMeta("orderedListIndexing")!==void 0||r.selection.$from.parent.type.spec.code)return s;const l=r.getMeta(ue);if(typeof l=="object"&&l!==null){s&&this.closeMenu();const d=lr(t,a.selection.from-l.triggerCharacter.length);return{triggerCharacter:l.triggerCharacter,deleteTriggerCharacter:l.deleteTriggerCharacter!==!1,queryStartPos:()=>d()+l.triggerCharacter.length,query:"",decorationId:`id_${Math.floor(Math.random()*4294967295)}`,ignoreQueryLength:l==null?void 0:l.ignoreQueryLength}}if(s===void 0)return s;if(a.selection.from!==a.selection.to||l===null||r.getMeta("focus")||r.getMeta("blur")||r.getMeta("pointer")||s.triggerCharacter!==void 0&&a.selection.from<s.queryStartPos()||!a.selection.$from.sameParent(a.doc.resolve(s.queryStartPos())))return;const c={...s};return c.query=a.doc.textBetween(s.queryStartPos(),a.selection.from),c}},props:{handleTextInput(r,s,i,a){if(s===i){const l=r.state.doc;for(const c of o){const d=c.length>1?l.textBetween(s-c.length,s)+a:a;if(c===d)return r.dispatch(r.state.tr.insertText(a)),r.dispatch(r.state.tr.setMeta(ue,{triggerCharacter:d}).scrollIntoView()),!0}}return!1},decorations(r){const s=this.getState(r);if(s===void 0)return null;if(!s.deleteTriggerCharacter){const i=sa(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(t,o){return this.triggerCharacters.includes(t)||this.addTriggerCharacter(t),this.on(`update ${t}`,o)}get shown(){var t,o;return((o=(t=this.view)==null?void 0:t.state)==null?void 0:o.show)||!1}}function aa(e,n){e.suggestionMenus.addTriggerCharacter(n)}const la=k.Mark.create({name:"insertion",inclusive:!1,excludes:"deletion modification insertion",addAttributes(){return{id:{default:null,validate:"number"}}},extendMarkSchema(e){return e.name!=="insertion"?{}:{blocknoteIgnore:!0,inclusive:!1,toDOM(n,t){return["ins",{"data-id":String(n.attrs.id),"data-inline":String(t),...!t&&{style:"display: contents"}},0]},parseDOM:[{tag:"ins",getAttrs(n){return n.dataset.id?{id:parseInt(n.dataset.id,10)}:!1}}]}}}),ca=k.Mark.create({name:"deletion",inclusive:!1,excludes:"insertion modification deletion",addAttributes(){return{id:{default:null,validate:"number"}}},extendMarkSchema(e){return e.name!=="deletion"?{}:{blocknoteIgnore:!0,inclusive:!1,toDOM(n,t){return["del",{"data-id":String(n.attrs.id),"data-inline":String(t),...!t&&{style:"display: contents"}},0]},parseDOM:[{tag:"del",getAttrs(n){return n.dataset.id?{id:parseInt(n.dataset.id,10)}:!1}}]}}}),da=k.Mark.create({name:"modification",inclusive:!1,excludes:"deletion insertion",addAttributes(){return{id:{default:null,validate:"number"},type:{validate:"string"},attrName:{default:null,validate:"string|null"},previousValue:{default:null},newValue:{default:null}}},extendMarkSchema(e){return e.name!=="modification"?{}:{blocknoteIgnore:!0,inclusive:!1,toDOM(n,t){return[t?"span":"div",{"data-type":"modification","data-id":String(n.attrs.id),"data-mod-type":n.attrs.type,"data-mod-prev-val":JSON.stringify(n.attrs.previousValue),"data-mod-new-val":JSON.stringify(n.attrs.newValue)},0]},parseDOM:[{tag:"span[data-type='modification']",getAttrs(n){return n.dataset.id?{id:parseInt(n.dataset.id,10),type:n.dataset.modType,previousValue:n.dataset.modPrevVal,newValue:n.dataset.modNewVal}:!1}},{tag:"div[data-type='modification']",getAttrs(n){return n.dataset.id?{id:parseInt(n.dataset.id,10),type:n.dataset.modType,previousValue:n.dataset.modPrevVal}:!1}}]}}});let U;function an(e){U||(U=document.createElement("div"),U.innerHTML="_",U.style.opacity="0",U.style.height="1px",U.style.width="1px",e instanceof Document?e.body.appendChild(U):e.appendChild(U))}function ua(e){U&&(e instanceof Document?e.body.removeChild(U):e.removeChild(U),U=void 0)}function He(e){return Array.prototype.indexOf.call(e.parentElement.childNodes,e)}function pa(e){let n=e;for(;n&&n.nodeName!=="TD"&&n.nodeName!=="TH"&&!n.classList.contains("tableWrapper");){if(n.classList.contains("ProseMirror"))return;const t=n.parentNode;if(!t||!(t instanceof Element))return;n=t}return n.nodeName==="TD"||n.nodeName==="TH"?{type:"cell",domNode:n,tbodyNode:n.closest("tbody")}:{type:"wrapper",domNode:n,tbodyNode:n.querySelector("tbody")}}function ha(e,n){const t=n.querySelectorAll(e);for(let o=0;o<t.length;o++)t[o].style.visibility="hidden"}class dr{constructor(n,t,o){p(this,"state");p(this,"emitUpdate");p(this,"tableId");p(this,"tablePos");p(this,"tableElement");p(this,"menuFrozen",!1);p(this,"mouseState","up");p(this,"prevWasEditable",null);p(this,"viewMousedownHandler",()=>{this.mouseState="down"});p(this,"mouseUpHandler",n=>{this.mouseState="up",this.mouseMoveHandler(n)});p(this,"mouseMoveHandler",n=>{var c,d,u,h,f,m,g;if(this.menuFrozen||this.mouseState==="selecting"||!(n.target instanceof Element)||!this.pmView.dom.contains(n.target))return;const t=pa(n.target);if((t==null?void 0:t.type)==="cell"&&this.mouseState==="down"&&!((c=this.state)!=null&&c.draggingState)){this.mouseState="selecting",(d=this.state)!=null&&d.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate());return}if(!t||!this.editor.isEditable){(u=this.state)!=null&&u.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate());return}if(!t.tbodyNode)return;const o=t.tbodyNode.getBoundingClientRect(),r=or(t.domNode,this.pmView);if(!r)return;this.tableElement=r.node;let s;const i=this.editor.transact(b=>F(r.id,b.doc));if(!i)throw new Error(`Block with ID ${r.id} not found`);const a=T(i.node,this.editor.pmSchema,this.editor.schema.blockSchema,this.editor.schema.inlineContentSchema,this.editor.schema.styleSchema);if(So("table",a,this.editor)&&(this.tablePos=i.posBeforeNode+1,s=a),!s)return;this.tableId=r.id;const l=(h=t.domNode.closest(".tableWrapper"))==null?void 0:h.querySelector(".table-widgets-container");if((t==null?void 0:t.type)==="wrapper"){const b=n.clientY>=o.bottom-1&&n.clientY<o.bottom+20,w=n.clientX>=o.right-1&&n.clientX<o.right+20,C=n.clientX>o.right||n.clientY>o.bottom;this.state={...this.state,show:!0,showAddOrRemoveRowsButton:b,showAddOrRemoveColumnsButton:w,referencePosTable:o,block:s,widgetContainer:l,colIndex:C||(f=this.state)==null?void 0:f.colIndex,rowIndex:C||(m=this.state)==null?void 0:m.rowIndex,referencePosCell:C||(g=this.state)==null?void 0:g.referencePosCell}}else{const b=He(t.domNode),w=He(t.domNode.parentElement),C=t.domNode.getBoundingClientRect();if(this.state!==void 0&&this.state.show&&this.tableId===r.id&&this.state.rowIndex===w&&this.state.colIndex===b)return;this.state={show:!0,showAddOrRemoveColumnsButton:b===s.content.rows[0].cells.length-1,showAddOrRemoveRowsButton:w===s.content.rows.length-1,referencePosTable:o,block:s,draggingState:void 0,referencePosCell:C,colIndex:b,rowIndex:w,widgetContainer:l}}return this.emitUpdate(),!1});p(this,"dragOverHandler",n=>{var h;if(((h=this.state)==null?void 0:h.draggingState)===void 0)return;n.preventDefault(),n.dataTransfer.dropEffect="move",ha(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline",this.pmView.root);const t={left:Math.min(Math.max(n.clientX,this.state.referencePosTable.left+1),this.state.referencePosTable.right-1),top:Math.min(Math.max(n.clientY,this.state.referencePosTable.top+1),this.state.referencePosTable.bottom-1)},o=this.pmView.root.elementsFromPoint(t.left,t.top).filter(f=>f.tagName==="TD"||f.tagName==="TH");if(o.length===0)return;const r=o[0];let s=!1;const i=He(r.parentElement),a=He(r),l=this.state.draggingState.draggedCellOrientation==="row"?this.state.rowIndex:this.state.colIndex,d=(this.state.draggingState.draggedCellOrientation==="row"?i:a)!==l;(this.state.rowIndex!==i||this.state.colIndex!==a)&&(this.state.rowIndex=i,this.state.colIndex=a,this.state.referencePosCell=r.getBoundingClientRect(),s=!0);const u=this.state.draggingState.draggedCellOrientation==="row"?t.top:t.left;this.state.draggingState.mousePos!==u&&(this.state.draggingState.mousePos=u,s=!0),s&&this.emitUpdate(),d&&this.editor.transact(f=>f.setMeta(de,!0))});p(this,"dropHandler",n=>{if(this.mouseState="up",this.state===void 0||this.state.draggingState===void 0)return!1;if(this.state.rowIndex===void 0||this.state.colIndex===void 0)throw new Error("Attempted to drop table row or column, but no table block was hovered prior.");n.preventDefault();const{draggingState:t,colIndex:o,rowIndex:r}=this.state,s=this.state.block.content.columnWidths;if(t.draggedCellOrientation==="row"){if(!Bn(this.state.block,t.originalIndex,r))return!1;const i=Xr(this.state.block,t.originalIndex,r);this.editor.updateBlock(this.state.block,{type:"table",content:{...this.state.block.content,rows:i}})}else{if(!Tn(this.state.block,t.originalIndex,o))return!1;const i=Jr(this.state.block,t.originalIndex,o),[a]=s.splice(t.originalIndex,1);s.splice(o,0,a),this.editor.updateBlock(this.state.block,{type:"table",content:{...this.state.block.content,columnWidths:s,rows:i}})}return this.editor.setTextCursorPosition(this.state.block.id),!0});this.editor=n,this.pmView=t,this.emitUpdate=()=>{if(!this.state)throw new Error("Attempting to update uninitialized image toolbar");o(this.state)},t.dom.addEventListener("mousemove",this.mouseMoveHandler),t.dom.addEventListener("mousedown",this.viewMousedownHandler),window.addEventListener("mouseup",this.mouseUpHandler),t.root.addEventListener("dragover",this.dragOverHandler),t.root.addEventListener("drop",this.dropHandler)}update(){var r;if(!this.state||!this.state.show)return;if(this.state.block=this.editor.getBlock(this.state.block.id),!this.state.block||this.state.block.type!=="table"||!((r=this.tableElement)!=null&&r.isConnected)){this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate();return}const{height:n,width:t}=Mt(this.state.block);this.state.rowIndex!==void 0&&this.state.colIndex!==void 0&&(this.state.rowIndex>=n&&(this.state.rowIndex=n-1),this.state.colIndex>=t&&(this.state.colIndex=t-1));const o=this.tableElement.querySelector("tbody");if(!o)throw new Error("Table block does not contain a 'tbody' HTML element. This should never happen.");if(this.state.rowIndex!==void 0&&this.state.colIndex!==void 0){const i=o.children[this.state.rowIndex].children[this.state.colIndex];i?this.state.referencePosCell=i.getBoundingClientRect():(this.state.rowIndex=void 0,this.state.colIndex=void 0)}this.state.referencePosTable=o.getBoundingClientRect(),this.emitUpdate()}destroy(){this.pmView.dom.removeEventListener("mousemove",this.mouseMoveHandler),window.removeEventListener("mouseup",this.mouseUpHandler),this.pmView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.pmView.root.removeEventListener("dragover",this.dragOverHandler),this.pmView.root.removeEventListener("drop",this.dropHandler)}}const de=new y.PluginKey("TableHandlesPlugin");class ur extends O{constructor(t){super();p(this,"view");p(this,"colDragStart",t=>{if(this.view.state===void 0||this.view.state.colIndex===void 0)throw new Error("Attempted to drag table column, but no table block was hovered prior.");if(this.view.state.draggingState={draggedCellOrientation:"col",originalIndex:this.view.state.colIndex,mousePos:t.clientX},this.view.emitUpdate(),this.editor.transact(o=>o.setMeta(de,{draggedCellOrientation:this.view.state.draggingState.draggedCellOrientation,originalIndex:this.view.state.colIndex,newIndex:this.view.state.colIndex,tablePos:this.view.tablePos})),!this.editor.prosemirrorView)throw new Error("Editor view not initialized.");an(this.editor.prosemirrorView.root),t.dataTransfer.setDragImage(U,0,0),t.dataTransfer.effectAllowed="move"});p(this,"rowDragStart",t=>{if(this.view.state===void 0||this.view.state.rowIndex===void 0)throw new Error("Attempted to drag table row, but no table block was hovered prior.");if(this.view.state.draggingState={draggedCellOrientation:"row",originalIndex:this.view.state.rowIndex,mousePos:t.clientY},this.view.emitUpdate(),this.editor.transact(o=>o.setMeta(de,{draggedCellOrientation:this.view.state.draggingState.draggedCellOrientation,originalIndex:this.view.state.rowIndex,newIndex:this.view.state.rowIndex,tablePos:this.view.tablePos})),!this.editor.prosemirrorView)throw new Error("Editor view not initialized.");an(this.editor.prosemirrorView.root),t.dataTransfer.setDragImage(U,0,0),t.dataTransfer.effectAllowed="copyMove"});p(this,"dragEnd",()=>{if(this.view.state===void 0)throw new Error("Attempted to drag table row, but no table block was hovered prior.");if(this.view.state.draggingState=void 0,this.view.emitUpdate(),this.editor.transact(t=>t.setMeta(de,null)),!this.editor.prosemirrorView)throw new Error("Editor view not initialized.");ua(this.editor.prosemirrorView.root)});p(this,"freezeHandles",()=>{this.view.menuFrozen=!0});p(this,"unfreezeHandles",()=>{this.view.menuFrozen=!1});p(this,"getCellsAtRowHandle",(t,o)=>ct(t,o));p(this,"getCellsAtColumnHandle",(t,o)=>dt(t,o));p(this,"setCellSelection",(t,o,r=o)=>{const s=this.view;if(!s)throw new Error("Table handles view not initialized");const i=t.doc.resolve(s.tablePos+1),a=t.doc.resolve(i.posAtIndex(o.row)+1),l=t.doc.resolve(a.posAtIndex(o.col)),c=t.doc.resolve(i.posAtIndex(r.row)+1),d=t.doc.resolve(c.posAtIndex(r.col)),u=t.tr;return u.setSelection(new A.CellSelection(l,d)),t.apply(u)});p(this,"addRowOrColumn",(t,o)=>{this.editor.exec((r,s)=>{const i=this.setCellSelection(r,o.orientation==="row"?{row:t,col:0}:{row:0,col:t});return o.orientation==="row"?o.side==="above"?A.addRowBefore(i,s):A.addRowAfter(i,s):o.side==="left"?A.addColumnBefore(i,s):A.addColumnAfter(i,s)})});p(this,"removeRowOrColumn",(t,o)=>o==="row"?this.editor.exec((r,s)=>{const i=this.setCellSelection(r,{row:t,col:0});return A.deleteRow(i,s)}):this.editor.exec((r,s)=>{const i=this.setCellSelection(r,{row:0,col:t});return A.deleteColumn(i,s)}));p(this,"mergeCells",t=>this.editor.exec((o,r)=>{const s=t?this.setCellSelection(o,t.relativeStartCell,t.relativeEndCell):o;return A.mergeCells(s,r)}));p(this,"splitCell",t=>this.editor.exec((o,r)=>{const s=t?this.setCellSelection(o,t):o;return A.splitCell(s,r)}));p(this,"getCellSelection",()=>this.editor.transact(t=>{const o=t.selection;let r=o.$from,s=o.$to;if(gt(o)){const{ranges:m}=o;m.forEach(g=>{r=g.$from.min(r??g.$from),s=g.$to.max(s??g.$to)})}else if(r=t.doc.resolve(o.$from.pos-o.$from.parentOffset-1),s=t.doc.resolve(o.$to.pos-o.$to.parentOffset-1),r.pos===0||s.pos===0)return;const i=t.doc.resolve(r.pos-r.parentOffset-1),a=t.doc.resolve(s.pos-s.parentOffset-1),l=t.doc.resolve(i.pos-i.parentOffset-1),c=r.index(i.depth),d=i.index(l.depth),u=s.index(a.depth),h=a.index(l.depth),f=[];for(let m=d;m<=h;m++)for(let g=c;g<=u;g++)f.push({row:m,col:g});return{from:{row:d,col:c},to:{row:h,col:u},cells:f}}));p(this,"getMergeDirection",t=>this.editor.transact(o=>{const r=gt(o.selection)?o.selection:void 0;if(!r||!t||r.ranges.length<=1)return;const s=this.getCellSelection();if(s)return es(s.from,s.to,t)?"vertical":"horizontal"}));p(this,"cropEmptyRowsOrColumns",(t,o)=>Zr(t,o));p(this,"addRowsOrColumns",(t,o,r)=>Qr(t,o,r));this.editor=t,this.addProsemirrorPlugin(new y.Plugin({key:de,view:o=>(this.view=new dr(t,o,r=>{this.emit("update",r)}),this.view),props:{decorations:o=>{if(this.view===void 0||this.view.state===void 0||this.view.state.draggingState===void 0||this.view.tablePos===void 0)return;const r=this.view.state.draggingState.draggedCellOrientation==="row"?this.view.state.rowIndex:this.view.state.colIndex;if(r===void 0)return;const s=[],{block:i,draggingState:a}=this.view.state,{originalIndex:l,draggedCellOrientation:c}=a;if(r===l||!i||c==="row"&&!Bn(i,l,r)||c==="col"&&!Tn(i,l,r))return M.DecorationSet.create(o.doc,s);const d=o.doc.resolve(this.view.tablePos+1);return this.view.state.draggingState.draggedCellOrientation==="row"?ct(this.view.state.block,r).forEach(({row:h,col:f})=>{const m=o.doc.resolve(d.posAtIndex(h)+1),g=o.doc.resolve(m.posAtIndex(f)+1),b=g.node(),w=g.pos+(r>l?b.nodeSize-2:0);s.push(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>l?C.style.bottom="-2px":C.style.top="-3px",C.style.height="4px",C}))}):dt(this.view.state.block,r).forEach(({row:h,col:f})=>{const m=o.doc.resolve(d.posAtIndex(h)+1),g=o.doc.resolve(m.posAtIndex(f)+1),b=g.node(),w=g.pos+(r>l?b.nodeSize-2:0);s.push(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>l?C.style.right="-2px":C.style.left="-3px",C.style.width="4px",C}))}),M.DecorationSet.create(o.doc,s)}}}))}static key(){return"tableHandles"}onUpdate(t){return this.on("update",t)}}const fa=k.Extension.create({name:"textAlignment",addGlobalAttributes(){return[{types:["paragraph","heading","bulletListItem","numberedListItem","checkListItem","tableCell","tableHeader"],attributes:{textAlignment:{default:"left",parseHTML:e=>e.getAttribute("data-text-alignment"),renderHTML:e=>e.textAlignment==="left"?{}:{"data-text-alignment":e.textAlignment}}}}]}}),ma=k.Extension.create({name:"blockTextColor",addGlobalAttributes(){return[{types:["blockContainer","tableCell","tableHeader"],attributes:{textColor:{default:I.textColor.default,parseHTML:e=>e.hasAttribute("data-text-color")?e.getAttribute("data-text-color"):I.textColor.default,renderHTML:e=>e.textColor===I.textColor.default?{}:{"data-text-color":e.textColor}}}}]}}),ga=k.Extension.create({name:"trailingNode",addProseMirrorPlugins(){const e=new y.PluginKey(this.name);return[new y.Plugin({key:e,appendTransaction:(n,t,o)=>{const{doc:r,tr:s,schema:i}=o,a=e.getState(o),l=r.content.size-2,c=i.nodes.blockContainer,d=i.nodes.paragraph;if(a)return s.insert(l,c.create(void 0,d.create()))},state:{init:(n,t)=>{},apply:(n,t)=>{if(!n.docChanged)return t;let o=n.doc.lastChild;if(!o||o.type.name!=="blockGroup")throw new Error("Expected blockGroup");if(o=o.lastChild,!o||o.type.name!=="blockContainer")return!0;const r=o.firstChild;if(!r)throw new Error("Expected blockContent");return o.nodeSize>4||r.type.spec.content!=="inline*"}}})]}}),ba={blockColor:"data-block-color",blockStyle:"data-block-style",id:"data-id",depth:"data-depth",depthChange:"data-depth-change"},ka=k.Node.create({name:"blockContainer",group:"blockGroupChild bnBlock",content:"blockContent blockGroup?",priority:50,defining:!0,marks:"insertion modification deletion",parseHTML(){return[{tag:"div[data-node-type="+this.name+"]",getAttrs:e=>{if(typeof e=="string")return!1;const n={};for(const[t,o]of Object.entries(ba))e.getAttribute(o)&&(n[t]=e.getAttribute(o));return n}},{tag:'div[data-node-type="blockOuter"]',skip:!0}]},renderHTML({HTMLAttributes:e}){var r;const n=document.createElement("div");n.className="bn-block-outer",n.setAttribute("data-node-type","blockOuter");for(const[s,i]of Object.entries(e))s!=="class"&&n.setAttribute(s,i);const t={...((r=this.options.domAttributes)==null?void 0:r.block)||{},...e},o=document.createElement("div");o.className=X("bn-block",t.class),o.setAttribute("data-node-type",this.name);for(const[s,i]of Object.entries(t))s!=="class"&&o.setAttribute(s,i);return n.appendChild(o),{dom:n,contentDOM:o}}}),wa=k.Node.create({name:"blockGroup",group:"childContainer",content:"blockGroupChild+",marks:"deletion insertion modification",parseHTML(){return[{tag:"div",getAttrs:e=>typeof e=="string"?!1:e.getAttribute("data-node-type")==="blockGroup"?null:!1}]},renderHTML({HTMLAttributes:e}){var o;const n={...((o=this.options.domAttributes)==null?void 0:o.blockGroup)||{},...e},t=document.createElement("div");t.className=X("bn-block-group",n.class),t.setAttribute("data-node-type","blockGroup");for(const[r,s]of Object.entries(n))r!=="class"&&t.setAttribute(r,s);return{dom:t,contentDOM:t}}}),ya=k.Node.create({name:"doc",topNode:!0,content:"blockGroup",marks:"insertion modification deletion"});class Ca extends O{constructor({editor:t,collaboration:o}){super(t);p(this,"editor");p(this,"collaboration");p(this,"forkedState");this.editor=t,this.collaboration=o}static key(){return"ForkYDocPlugin"}findTypeInOtherYdoc(t,o){const r=t.doc;if(t._item===null){const s=Array.from(r.share.keys()).find(i=>r.share.get(i)===t);if(s==null)throw new Error("type does not exist in other ydoc");return o.get(s,t.constructor)}else{const s=t._item,i=o.store.clients.get(s.id.client)??[],a=ce.findIndexSS(i,s.id.clock);return i[a].content.type}}get isForkedFromRemote(){return this.forkedState!==void 0}fork(){if(this.isForkedFromRemote)return;const t=this.collaboration.fragment;if(!t)throw new Error("No fragment to fork from");const o=new ce.Doc;ce.applyUpdate(o,ce.encodeStateAsUpdate(t.doc));const r=this.findTypeInOtherYdoc(t,o);this.forkedState={originalFragment:t,forkedFragment:r},this.editor._tiptapEditor.unregisterPlugin([N.yCursorPluginKey,N.yUndoPluginKey,N.ySyncPluginKey]),this.editor._tiptapEditor.registerPlugin(new kt(r).plugins[0]),this.editor._tiptapEditor.registerPlugin(new wt().plugins[0]),this.emit("forked",!0)}merge({keepChanges:t}){if(!this.forkedState)return;this.editor._tiptapEditor.unregisterPlugin(N.ySyncPluginKey),this.editor._tiptapEditor.unregisterPlugin(N.yUndoPluginKey);const{originalFragment:o,forkedFragment:r}=this.forkedState;if(t){const s=ce.encodeStateAsUpdate(r.doc);ce.applyUpdate(o.doc,s)}this.editor.extensions.ySyncPlugin=new kt(o),this.editor.extensions.yCursorPlugin=new $e(this.collaboration),this.editor.extensions.yUndoPlugin=new wt,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]),this.forkedState=void 0,this.emit("forked",!1)}}const pr=e=>{var r;const n={},t=va(e);for(const s of t)n[s.name]=s;e.collaboration&&(n.ySyncPlugin=new kt(e.collaboration.fragment),n.yUndoPlugin=new wt,(r=e.collaboration.provider)!=null&&r.awareness&&(n.yCursorPlugin=new $e(e.collaboration)),n.forkYDocPlugin=new Ca({editor:e.editor,collaboration:e.collaboration})),n.formattingToolbar=new Xo(e.editor),n.linkToolbar=new er(e.editor),n.sideMenu=new ar(e.editor,e.sideMenuDetection),n.suggestionMenus=new cr(e.editor),n.filePanel=new Go(e.editor),n.placeholder=new Xi(e.editor,e.placeholders),(e.animations??!0)&&(n.animations=new Qi),e.tableHandles&&(n.tableHandles=new ur(e.editor)),n.nodeSelectionKeyboard=new Yi,n.showSelection=new ea(e.editor),e.comments&&(n.comments=new $i(e.editor,e.comments.threadStore,qo.name));const o=e.disableExtensions||[];for(const s of o)delete n[s];return n};let ln=!1;const va=e=>{const n=[k.extensions.ClipboardTextSerializer,k.extensions.Commands,k.extensions.Editable,k.extensions.FocusEvents,k.extensions.Tabindex,Mr.Gapcursor,k.Extension.create({name:"dropCursor",addProseMirrorPlugins:()=>[e.dropCursor({width:5,color:"#ddeeff",editor:e.editor})]}),Be.configure({types:["blockContainer","columnList","column"],setIdAttribute:e.setIdAttribute}),zi,Ar.Text,la,ca,da,Lr.Link.extend({inclusive:!1}).configure({defaultProtocol:nr,protocols:ln?[]:tr}),...Object.values(e.styleSpecs).map(t=>t.implementation.mark.configure({editor:e.editor})),ma,Vi,fa,k.Extension.create({name:"OverrideEscape",addKeyboardShortcuts(){return{Escape:()=>e.editor.suggestionMenus.shown?!1:this.editor.commands.blur()}}}),ya,ka.configure({editor:e.editor,domAttributes:e.domAttributes}),qi.configure({editor:e.editor,tabBehavior:e.tabBehavior}),wa.configure({domAttributes:e.domAttributes}),...Object.values(e.inlineContentSpecs).filter(t=>t.config!=="link"&&t.config!=="text").map(t=>t.implementation.node.configure({editor:e.editor})),...Object.values(e.blockSpecs).flatMap(t=>[...(t.implementation.requiredExtensions||[]).map(o=>o.configure({editor:e.editor,domAttributes:e.domAttributes})),t.implementation.node.configure({editor:e.editor,domAttributes:e.domAttributes})]),Ri(e.editor),Di(e.editor,e.pasteHandler||(t=>t.defaultPasteHandler())),ki(e.editor),...e.trailingBlock===void 0||e.trailingBlock?[ga]:[],...e.comments?[qo]:[]];return ln=!0,e.collaboration||n.push(Ir.History),n};function Sa(e,n){const t=[];return e.forEach((o,r,s)=>{s!==n&&t.push(o)}),E.Fragment.from(t)}function Ea(e,n){const t=[];for(let o=0;o<e.childCount;o++)if(e.child(o).type.name==="tableRow")if(t.length>0&&t[t.length-1].type.name==="table"){const r=t[t.length-1],s=r.copy(r.content.addToEnd(e.child(o)));t[t.length-1]=s}else{const r=n.nodes.table.createChecked(void 0,e.child(o));t.push(r)}else t.push(e.child(o));return e=E.Fragment.from(t),e}function Ba(e,n){let t=E.Fragment.from(e.content);if(t=Ea(t,n.state.schema),!Ta(t,n))return new E.Slice(t,e.openStart,e.openEnd);for(let o=0;o<t.childCount;o++)if(t.child(o).type.spec.group==="blockContent"){const r=[t.child(o)];if(o+1<t.childCount&&t.child(o+1).type.name==="blockGroup"){const i=t.child(o+1).child(0).child(0);(i.type.name==="bulletListItem"||i.type.name==="numberedListItem"||i.type.name==="checkListItem")&&(r.push(t.child(o+1)),t=Sa(t,o+1))}const s=n.state.schema.nodes.blockContainer.createChecked(void 0,r);t=t.replaceChild(o,s)}return new E.Slice(t,e.openStart,e.openEnd)}function Ta(e,n){var s,i;const t=e.childCount===1,o=((s=e.firstChild)==null?void 0:s.type.spec.content)==="inline*",r=((i=e.firstChild)==null?void 0:i.type.spec.content)==="tableRow+";if(t){if(o)return!1;if(r){const a=B(n.state);if(a.isBlockContainer)return!(a.blockContent.node.type.spec.content==="tableRow+")}}return!0}const Ke=class Ke extends k.Editor{constructor(t,o){super({...t,content:void 0});p(this,"_state");p(this,"mount",(t,o,r)=>{o?(this.options.element=o,this.createViewAlternative(t,r)):this.destroy()});const r=this.schema;let s;const i=r.nodes.doc.createAndFill;r.nodes.doc.createAndFill=(...l)=>{if(s)return s;const c=i.apply(r.nodes.doc,l),d=JSON.parse(JSON.stringify(c.toJSON()));return d.content[0].content[0].attrs.id="initialBlockId",s=E.Node.fromJSON(r,d),s};let a;try{const l=t==null?void 0:t.content.map(c=>re(c,this.schema,o).toJSON());a=k.createDocument({type:"doc",content:[{type:"blockGroup",content:l}]},this.schema,this.options.parseOptions)}catch(l){throw console.error("Error creating document from blocks passed as `initialContent`. Caused by exception: ",l),new Error("Error creating document from blocks passed as `initialContent`:\n"+ +JSON.stringify(t.content))}this._state=y.EditorState.create({doc:a,schema:this.schema})}get state(){return this.view&&(this._state=this.view.state),this._state}dispatch(t){if(!this.view){this._state=this.state.apply(t),this.emit("transaction",{editor:this,transaction:t});return}if(this.view.isDestroyed)return;if(this.isCapturingTransaction){this.dispatchTransaction(t);return}const{state:o,transactions:r}=this.state.applyTransaction(t),s=!this.state.selection.eq(o.selection);this.emit("beforeTransaction",{editor:this,transaction:t,nextState:o}),this.view.updateState(o),this.emit("transaction",{editor:this,transaction:t}),s&&this.emit("selectionUpdate",{editor:this,transaction:t});const i=t.getMeta("focus"),a=t.getMeta("blur");i&&this.emit("focus",{editor:this,event:i.event,transaction:t}),a&&this.emit("blur",{editor:this,event:a.event,transaction:t}),!(!t.docChanged||t.getMeta("preventUpdate"))&&(this.emit("update",{editor:this,transaction:t}),this.emit("v3-update",{editor:this,transaction:t,appendedTransactions:r.slice(1)}))}forceEnablePlugins(){if(this.view)throw new Error("forcePluginsEnabled called after view has been initialized");this._state=this.state.reconfigure({plugins:this.extensionManager.plugins})}createViewAlternative(t,o){this.contentComponent=o;const r={};this.extensionManager.extensions.forEach(i=>{i.type==="mark"&&i.config.addMarkView&&(r[i.name]=i.config.addMarkView(t))}),this.view=new M.EditorView({mount:this.options.element},{...this.options.editorProps,dispatchTransaction:this.dispatch.bind(this),state:this.state,markViews:r,nodeViews:this.extensionManager.nodeViews});const s=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(s),this.commands.focus(this.options.autofocus||this.options.element.getAttribute("data-bn-autofocus")==="true",{scrollIntoView:!1}),this.emit("create",{editor:this}),this.isInitialized=!0}};p(Ke,"create",(t,o)=>{var s,i;const r=(s=globalThis==null?void 0:globalThis.window)==null?void 0:s.setTimeout;typeof((i=globalThis==null?void 0:globalThis.window)==null?void 0:i.setTimeout)<"u"&&(globalThis.window.setTimeout=()=>0);try{return new Ke(t,o)}finally{r&&(globalThis.window.setTimeout=r)}});let ze=Ke;ze.prototype.createView=function(){this.options.onPaste=this.options.onDrop=void 0};const xa={enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!1};class zt extends tt{constructor(t){var c,d,u,h,f,m,g,b,w,C,S,P,R,z,x;super();p(this,"pmSchema");p(this,"extensions",{});p(this,"headless",!1);p(this,"_tiptapEditor");p(this,"elementRenderer",null);p(this,"blockCache",new WeakMap);p(this,"dictionary");p(this,"schema");p(this,"blockImplementations");p(this,"inlineContentImplementations");p(this,"styleImplementations");p(this,"formattingToolbar");p(this,"linkToolbar");p(this,"sideMenu");p(this,"suggestionMenus");p(this,"filePanel");p(this,"tableHandles");p(this,"comments");p(this,"showSelectionPlugin");p(this,"forkYDocPlugin");p(this,"uploadFile");p(this,"onUploadStartCallbacks",[]);p(this,"onUploadEndCallbacks",[]);p(this,"resolveFileUrl");p(this,"resolveUsers");p(this,"settings");p(this,"activeTransaction",null);p(this,"mount",(t,o)=>{this._tiptapEditor.mount(this,t,o)});this.options=t;const o=t;if(o.onEditorContentChange)throw new Error("onEditorContentChange initialization option is deprecated, use <BlockNoteView onChange={...} />, the useEditorChange(...) hook, or editor.onChange(...)");if(o.onTextCursorPositionChange)throw new Error("onTextCursorPositionChange initialization option is deprecated, use <BlockNoteView onSelectionChange={...} />, the useEditorSelectionChange(...) hook, or editor.onSelectionChange(...)");if(o.onEditorReady)throw new Error("onEditorReady is deprecated. Editor is immediately ready for use after creation.");if(o.editable)throw new Error("editable initialization option is deprecated, use <BlockNoteView editable={true/false} />, or alternatively editor.isEditable = true/false");this.dictionary=t.dictionary||Dr.en,this.settings={tables:{splitCells:((c=t==null?void 0:t.tables)==null?void 0:c.splitCells)??!1,cellBackgroundColor:((d=t==null?void 0:t.tables)==null?void 0:d.cellBackgroundColor)??!1,cellTextColor:((u=t==null?void 0:t.tables)==null?void 0:u.cellTextColor)??!1,headers:((h=t==null?void 0:t.tables)==null?void 0:h.headers)??!1},codeBlock:{indentLineWithTab:((f=t==null?void 0:t.codeBlock)==null?void 0:f.indentLineWithTab)??!0,defaultLanguage:((m=t==null?void 0:t.codeBlock)==null?void 0:m.defaultLanguage)??"text",supportedLanguages:((g=t==null?void 0:t.codeBlock)==null?void 0:g.supportedLanguages)??{},createHighlighter:((b=t==null?void 0:t.codeBlock)==null?void 0:b.createHighlighter)??void 0}};const r={defaultStyles:!0,schema:t.schema||we.create(),_headless:!1,...t,placeholders:{...this.dictionary.placeholders,...t.placeholders}};if(r.comments&&!r.resolveUsers)throw new Error("resolveUsers is required when using comments");this.resolveUsers=r.resolveUsers,this.schema=r.schema,this.blockImplementations=r.schema.blockSpecs,this.inlineContentImplementations=r.schema.inlineContentSpecs,this.styleImplementations=r.schema.styleSpecs,this.extensions=pr({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:_("table",this),dropCursor:this.options.dropCursor??Hr.dropCursor,placeholders:r.placeholders,tabBehavior:r.tabBehavior,sideMenuDetection:r.sideMenuDetection||"viewport",comments:r.comments,pasteHandler:r.pasteHandler}),(((w=r._tiptapOptions)==null?void 0:w.extensions)||[]).forEach(v=>{this.extensions[v.name]=v});for(let v of r.extensions||[]){typeof v=="function"&&(v=v(this));const L=v.constructor.key();if(!L)throw new Error(`Extension ${v.constructor.name} does not have a key method`);if(this.extensions[L])throw new Error(`Extension ${v.constructor.name} already exists with key ${L}`);this.extensions[L]=v}if(Object.entries(r._extensions||{}).forEach(([v,L])=>{const ee=typeof L=="function"?L(this):L;if(!("plugin"in ee)){this.extensions[v]=ee;return}this.extensions[v]=new class extends O{static key(){return v}constructor(){super(),this.addProsemirrorPlugin(ee.plugin)}get priority(){return ee.priority}}}),this.formattingToolbar=this.extensions.formattingToolbar,this.linkToolbar=this.extensions.linkToolbar,this.sideMenu=this.extensions.sideMenu,this.suggestionMenus=this.extensions.suggestionMenus,this.filePanel=this.extensions.filePanel,this.tableHandles=this.extensions.tableHandles,this.comments=this.extensions.comments,this.showSelectionPlugin=this.extensions.showSelection,this.forkYDocPlugin=this.extensions.forkYDocPlugin,r.uploadFile){const v=r.uploadFile;this.uploadFile=async(L,se)=>{this.onUploadStartCallbacks.forEach(ee=>ee.apply(this,[se]));try{return await v(L,se)}finally{this.onUploadEndCallbacks.forEach(ee=>ee.apply(this,[se]))}}}this.resolveFileUrl=r.resolveFileUrl,this.headless=r._headless;const s="ySyncPlugin"in this.extensions||"liveblocksExtension"in this.extensions;s&&r.initialContent&&console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider");const i=r.initialContent||(s?[{type:"paragraph",id:"initialBlockId"}]:[{type:"paragraph",id:Be.options.generateID()}]);if(!Array.isArray(i)||i.length===0)throw new Error("initialContent must be a non-empty array of blocks, received: "+i);const a=[...Object.entries(this.extensions).map(([v,L])=>{if(L instanceof k.Extension||L instanceof k.Node||L instanceof k.Mark)return L;if(!(L instanceof O&&!L.plugins.length))return k.Extension.create({name:v,priority:L.priority,addProseMirrorPlugins:()=>L.plugins})})].filter(v=>v!==void 0),l={...xa,...r._tiptapOptions,content:i,extensions:a,editorProps:{...(C=r._tiptapOptions)==null?void 0:C.editorProps,attributes:{tabIndex:"0",...(P=(S=r._tiptapOptions)==null?void 0:S.editorProps)==null?void 0:P.attributes,...(R=r.domAttributes)==null?void 0:R.editor,class:X("bn-editor",r.defaultStyles?"bn-default-styles":"",((x=(z=r.domAttributes)==null?void 0:z.editor)==null?void 0:x.class)||"")},transformPasted:Ba}};this.headless?this.pmSchema=k.getSchema(l.extensions):(this._tiptapEditor=ze.create(l,this.schema.styleSchema),this.pmSchema=this._tiptapEditor.schema),this.pmSchema.cached.blockNoteEditor=this,this.emit("create")}static create(t={}){return new zt(t)}exec(t){if(this.activeTransaction)throw new Error("`exec` should not be called within a `transact` call, move the `exec` call outside of the `transact` call");const o=this._tiptapEditor.state,r=this._tiptapEditor.view;return t(o,i=>this._tiptapEditor.dispatch(i),r)}canExec(t){if(this.activeTransaction)throw new Error("`canExec` should not be called within a `transact` call, move the `canExec` call outside of the `transact` call");const o=this._tiptapEditor.state,r=this._tiptapEditor.view;return t(o,void 0,r)}transact(t){if(this.activeTransaction)return t(this.activeTransaction);try{this.activeTransaction=this._tiptapEditor.state.tr;const o=t(this.activeTransaction),r=this.activeTransaction;return this.activeTransaction=null,r&&(r.docChanged||r.selectionSet||r.scrolledIntoView||r.storedMarksSet||!r.isGeneric)&&this._tiptapEditor.dispatch(r),o}finally{this.activeTransaction=null}}extension(t,o=t.key()){const r=this.extensions[o];if(!r)throw new Error(`Extension ${o} not found`);return r}get prosemirrorState(){if(this.activeTransaction)throw new Error("`prosemirrorState` should not be called within a `transact` call, move the `prosemirrorState` call outside of the `transact` call or use `editor.transact` to read the current editor state");return this._tiptapEditor.state}get prosemirrorView(){return this._tiptapEditor.view}get domElement(){var t;return(t=this.prosemirrorView)==null?void 0:t.dom}isFocused(){var t;return((t=this.prosemirrorView)==null?void 0:t.hasFocus())||!1}focus(){var t;(t=this.prosemirrorView)==null||t.focus()}onUploadStart(t){return this.onUploadStartCallbacks.push(t),()=>{const o=this.onUploadStartCallbacks.indexOf(t);o>-1&&this.onUploadStartCallbacks.splice(o,1)}}onUploadEnd(t){return this.onUploadEndCallbacks.push(t),()=>{const o=this.onUploadEndCallbacks.indexOf(t);o>-1&&this.onUploadEndCallbacks.splice(o,1)}}get topLevelBlocks(){return this.document}get document(){return this.transact(t=>mn(t.doc,this.pmSchema))}getBlock(t){return this.transact(o=>Oo(o.doc,t))}getPrevBlock(t){return this.transact(o=>Ro(o.doc,t))}getNextBlock(t){return this.transact(o=>Vo(o.doc,t))}getParentBlock(t){return this.transact(o=>_o(o.doc,t))}forEachBlock(t,o=!1){const r=this.document.slice();o&&r.reverse();function s(i){for(const a of i){if(t(a)===!1)return!1;const l=o?a.children.slice().reverse():a.children;if(!s(l))return!1}return!0}s(r)}onEditorContentChange(t){this._tiptapEditor.on("update",t)}onEditorSelectionChange(t){this._tiptapEditor.on("selectionUpdate",t)}getTextCursorPosition(){return this.transact(t=>ai(t))}setTextCursorPosition(t,o="start"){return this.transact(r=>Uo(r,t,o))}getSelection(){return this.transact(t=>ri(t))}getSelectionCutBlocks(){return this.transact(t=>ii(t))}setSelection(t,o){return this.transact(r=>si(r,t,o))}get isEditable(){if(!this._tiptapEditor){if(!this.headless)throw new Error("no editor, but also not headless?");return!1}return this._tiptapEditor.isEditable===void 0?!0:this._tiptapEditor.isEditable}set isEditable(t){if(!this._tiptapEditor){if(!this.headless)throw new Error("no editor, but also not headless?");return}this._tiptapEditor.options.editable!==t&&this._tiptapEditor.setEditable(t)}insertBlocks(t,o,r="before"){return this.transact(s=>Mn(s,t,o,r))}updateBlock(t,o){return this.transact(r=>In(r,t,o))}removeBlocks(t){return this.transact(o=>ht(o,t,[]).removedBlocks)}replaceBlocks(t,o){return this.transact(r=>ht(r,t,o))}undo(){return this.options.collaboration?this.exec(N.undoCommand):this.exec(Wt.undo)}redo(){return this.options.collaboration?this.exec(N.redoCommand):this.exec(Wt.redo)}insertInlineContent(t,{updateSelection:o=!1}={}){const r=$(t,this.pmSchema);this.transact(s=>{oi(s,{from:s.selection.from,to:s.selection.to},r,{updateSelection:o})})}getActiveStyles(){return this.transact(t=>{const o={},r=t.selection.$to.marks();for(const s of r){const i=this.schema.styleSchema[s.type.name];if(!i){s.type.name!=="link"&&!s.type.spec.blocknoteIgnore&&console.warn("mark not found in styleschema",s.type.name);continue}i.propSchema==="boolean"?o[i.type]=!0:o[i.type]=s.attrs.stringValue}return o})}addStyles(t){for(const[o,r]of Object.entries(t)){const s=this.schema.styleSchema[o];if(!s)throw new Error(`style ${o} not found in styleSchema`);if(s.propSchema==="boolean")this._tiptapEditor.commands.setMark(o);else if(s.propSchema==="string")this._tiptapEditor.commands.setMark(o,{stringValue:r});else throw new K(s.propSchema)}}removeStyles(t){for(const o of Object.keys(t))this._tiptapEditor.commands.unsetMark(o)}toggleStyles(t){for(const[o,r]of Object.entries(t)){const s=this.schema.styleSchema[o];if(!s)throw new Error(`style ${o} not found in styleSchema`);if(s.propSchema==="boolean")this._tiptapEditor.commands.toggleMark(o);else if(s.propSchema==="string")this._tiptapEditor.commands.toggleMark(o,{stringValue:r});else throw new K(s.propSchema)}}getSelectedText(){return this.transact(t=>t.doc.textBetween(t.selection.from,t.selection.to))}getSelectedLinkUrl(){return this._tiptapEditor.getAttributes("link").href}createLink(t,o){if(t==="")return;const r=this.pmSchema.mark("link",{href:t});this.transact(s=>{const{from:i,to:a}=s.selection;o?s.insertText(o,i,a).addMark(i,i+o.length,r):s.setSelection(y.TextSelection.create(s.doc,a)).addMark(i,a,r)})}canNestBlock(){return ti(this)}nestBlock(){Do(this)}canUnnestBlock(){return ni(this)}unnestBlock(){ei(this)}moveBlocksUp(){return Xs(this)}moveBlocksDown(){return Zs(this)}async blocksToHTMLLossy(t=this.document){return Me(this.pmSchema,this).exportBlocks(t,{})}async blocksToFullHTML(t){return On(this.pmSchema,this).serializeBlocks(t,{})}async tryParseHTMLToBlocks(t){return _t(t,this.pmSchema)}async blocksToMarkdownLossy(t=this.document){return Fo(t,this.pmSchema,this,{})}async tryParseMarkdownToBlocks(t){return zo(t,this.pmSchema)}updateCollaborationUserInfo(t){if(!this.options.collaboration)throw new Error("Cannot update collaboration user info when collaboration is disabled.");this.extensions.yCursorPlugin.updateUser(t)}onChange(t){if(this.headless)return;const o=({transaction:r,appendedTransactions:s})=>{t(this,{getChanges:()=>Pn(r,s)})};return this._tiptapEditor.on("v3-update",o),()=>{this._tiptapEditor.off("v3-update",o)}}onSelectionChange(t,o){if(this.headless)return;const r=s=>{s.transaction.getMeta(N.ySyncPluginKey)&&!o||t(this)};return this._tiptapEditor.on("selectionUpdate",r),()=>{this._tiptapEditor.off("selectionUpdate",r)}}onCreate(t){return this.on("create",t),()=>{this.off("create",t)}}getSelectionBoundingBox(){if(!this.prosemirrorView)return;const{selection:t}=this.prosemirrorState,{ranges:o}=t,r=Math.min(...o.map(i=>i.$from.pos)),s=Math.max(...o.map(i=>i.$to.pos));if(k.isNodeSelection(t)){const i=this.prosemirrorView.nodeDOM(r);if(i)return i.getBoundingClientRect()}return k.posToDOMRect(this.prosemirrorView,r,s)}get isEmpty(){const t=this.document;return t.length===0||t.length===1&&t[0].type==="paragraph"&&t[0].content.length===0}openSuggestionMenu(t,o){this.prosemirrorView&&(this.focus(),this.transact(r=>{o!=null&&o.deleteTriggerCharacter&&r.insertText(t),r.scrollIntoView().setMeta(this.suggestionMenus.plugins[0],{triggerCharacter:t,deleteTriggerCharacter:(o==null?void 0:o.deleteTriggerCharacter)||!1,ignoreQueryLength:(o==null?void 0:o.ignoreQueryLength)||!1})}))}getForceSelectionVisible(){return this.showSelectionPlugin.getEnabled()}setForceSelectionVisible(t){this.showSelectionPlugin.setEnabled(t)}convertHtmlToBlockNoteHtml(t){return $o(t.trim()).innerHTML}pasteHTML(t,o=!1){var s;let r=t;o||(r=this.convertHtmlToBlockNoteHtml(t)),r&&((s=this.prosemirrorView)==null||s.pasteHTML(r))}pasteText(t){var o;return(o=this.prosemirrorView)==null?void 0:o.pasteText(t)}async pasteMarkdown(t){return this.pasteHTML(await Ut(t))}}const Pa={gray:{text:"#9b9a97",background:"#ebeced"},brown:{text:"#64473a",background:"#e9e5e3"},red:{text:"#e03e3e",background:"#fbe4e4"},orange:{text:"#d9730d",background:"#f6e9d9"},yellow:{text:"#dfab01",background:"#fbf3db"},green:{text:"#4d6461",background:"#ddedea"},blue:{text:"#0b6e99",background:"#ddebf1"},purple:{text:"#6940a5",background:"#eae4f2"},pink:{text:"#ad1a72",background:"#f4dfeb"}},Ma={gray:{text:"#bebdb8",background:"#9b9a97"},brown:{text:"#8e6552",background:"#64473a"},red:{text:"#ec4040",background:"#be3434"},orange:{text:"#e3790d",background:"#b7600a"},yellow:{text:"#dfab01",background:"#b58b00"},green:{text:"#6b8b87",background:"#4d6461"},blue:{text:"#0e87bc",background:"#0b6e99"},purple:{text:"#8552d7",background:"#6940a5"},pink:{text:"#da208f",background:"#ad1a72"}};class Ia{constructor(n,t,o){this.mappings=t,this.options=o}async resolveFile(n){var o;if(!((o=this.options)!=null&&o.resolveFileUrl))return(await fetch(n)).blob();const t=await this.options.resolveFileUrl(n);return t instanceof Blob?t:(await fetch(t)).blob()}mapStyles(n){return Object.entries(n).map(([o,r])=>this.mappings.styleMapping[o](r,this))}mapInlineContent(n){return this.mappings.inlineContentMapping[n.type](n,this)}transformInlineContent(n){return n.map(t=>this.mapInlineContent(t))}async mapBlock(n,t,o){return this.mappings.blockMapping[n.type](n,this,t,o)}}function La(e){return{createBlockMapping:n=>n,createInlineContentMapping:n=>n,createStyleMapping:n=>n}}let De;async function Aa(){return De||(De=(async()=>{const[e,n]=await Promise.all([import("emoji-mart"),import("@emoji-mart/data")]),t="default"in e?e.default:e,o="default"in n?n.default:n;return await t.init({data:o}),{emojiMart:t,emojiData:o}})(),De)}async function Na(e,n){if(!vo("text",e))return[];const{emojiData:t,emojiMart:o}=await Aa();return(n.trim()===""?Object.values(t.emojis):await o.SearchIndex.search(n)).map(s=>({id:s.skins[0].native,onItemClick:()=>e.insertInlineContent(s.skins[0].native+" ")}))}function Ha(e,...n){const t=[...e];for(const o of n)for(const r of o){const s=t.findLastIndex(i=>i.group===r.group);s===-1?t.push(r):t.splice(s+1,0,r)}return t}exports.AudioBlock=qn;exports.BlockNoteEditor=zt;exports.BlockNoteExtension=O;exports.BlockNoteSchema=we;exports.COLORS_DARK_MODE_DEFAULT=Ma;exports.COLORS_DEFAULT=Pa;exports.CodeBlock=Gn;exports.DEFAULT_LINK_PROTOCOL=nr;exports.EMPTY_CELL_HEIGHT=Ls;exports.EMPTY_CELL_WIDTH=Ht;exports.EventEmitter=tt;exports.Exporter=Ia;exports.FILE_AUDIO_ICON_SVG=Un;exports.FILE_ICON_SVG=Vn;exports.FILE_IMAGE_ICON_SVG=no;exports.FILE_VIDEO_ICON_SVG=ho;exports.FileBlock=eo;exports.FilePanelProsemirrorPlugin=Go;exports.FilePanelView=jo;exports.FormattingToolbarProsemirrorPlugin=Xo;exports.FormattingToolbarView=Yo;exports.HTMLToBlocks=_t;exports.ImageBlock=lo;exports.LinkToolbarProsemirrorPlugin=er;exports.PageBreak=Mo;exports.SideMenuProsemirrorPlugin=ar;exports.SideMenuView=sr;exports.SuggestionMenuProseMirrorPlugin=cr;exports.TableHandlesProsemirrorPlugin=ur;exports.TableHandlesView=dr;exports.UniqueID=Be;exports.UnreachableCaseError=K;exports.VALID_LINK_PROTOCOLS=tr;exports.VideoBlock=wo;exports.addInlineContentAttributes=lt;exports.addInlineContentKeyboardShortcuts=bn;exports.addStyleAttributes=vn;exports.applyNonSelectableBlockFix=pn;exports.assertEmpty=Wr;exports.audioBlockConfig=$n;exports.audioParse=Wn;exports.audioPropSchema=Fn;exports.audioRender=zn;exports.audioToExternalHTML=Kn;exports.blockToNode=re;exports.blocksToMarkdown=Fo;exports.camelToDataKebab=ve;exports.checkBlockHasDefaultProp=$s;exports.checkBlockIsDefaultType=So;exports.checkBlockIsFileBlock=_s;exports.checkBlockIsFileBlockWithPlaceholder=Fs;exports.checkBlockIsFileBlockWithPreview=Us;exports.checkBlockTypeHasDefaultProp=Eo;exports.checkDefaultBlockTypeInSchema=_;exports.checkDefaultInlineContentTypeInSchema=vo;exports.checkPageBreakBlocksInSchema=Io;exports.cleanHTMLToMarkdown=et;exports.combineByGroup=Ha;exports.contentNodeToInlineContent=xe;exports.contentNodeToTableContent=Bt;exports.createAddFileButton=Rn;exports.createBlockSpec=ge;exports.createBlockSpecFromStronglyTypedTiptapNode=Q;exports.createDefaultBlockDOMOutputSpec=j;exports.createExternalHTMLExporter=Me;exports.createFigureWithCaption=Ze;exports.createFileBlockWrapper=Xe;exports.createFileNameWithIcon=_n;exports.createInlineContentSpec=Gr;exports.createInlineContentSpecFromTipTapNode=wn;exports.createInternalBlockSpec=St;exports.createInternalHTMLSerializer=On;exports.createInternalInlineContentSpec=kn;exports.createInternalStyleSpec=xt;exports.createLinkWithCaption=Le;exports.createResizableFileBlockWrapper=Lt;exports.createStronglyTypedTiptapNode=G;exports.createStyleSpec=Yr;exports.createStyleSpecFromTipTapMark=te;exports.createSuggestionMenu=aa;exports.defaultBlockSchema=yo;exports.defaultBlockSpecs=Dt;exports.defaultBlockToHTML=at;exports.defaultCodeBlockPropSchema=jn;exports.defaultInlineContentSchema=Co;exports.defaultInlineContentSpecs=Rt;exports.defaultProps=I;exports.defaultStyleSchema=Vs;exports.defaultStyleSpecs=Ot;exports.docToBlocks=mn;exports.fileBlockConfig=Jn;exports.fileParse=Zn;exports.filePropSchema=Yn;exports.fileRender=Xn;exports.fileToExternalHTML=Qn;exports.filenameFromURL=jr;exports.filterSuggestionItems=qs;exports.formatKeyboardShortcut=J;exports.formattingToolbarPluginKey=Jo;exports.getBlock=Oo;exports.getBlockCache=Je;exports.getBlockFromPos=un;exports.getBlockInfo=Z;exports.getBlockInfoFromResolvedPos=be;exports.getBlockInfoFromSelection=B;exports.getBlockInfoFromTransaction=Te;exports.getBlockInfoWithManualOffset=je;exports.getBlockNoteExtensions=pr;exports.getBlockNoteSchema=ke;exports.getBlockSchema=Ge;exports.getBlockSchemaFromSpecs=Et;exports.getBlocksChangedByTransaction=Pn;exports.getColspan=fe;exports.getDefaultEmojiPickerItems=Na;exports.getDefaultSlashMenuItems=Ks;exports.getInlineContentParseRules=yn;exports.getInlineContentSchema=Ye;exports.getInlineContentSchemaFromSpecs=Tt;exports.getNearestBlockPos=Y;exports.getNextBlock=Vo;exports.getNodeById=F;exports.getPageBreakSlashMenuItems=Gs;exports.getParentBlock=_o;exports.getParseRules=hn;exports.getPmSchema=H;exports.getPrevBlock=Ro;exports.getRowspan=_e;exports.getStyleParseRules=Sn;exports.getStyleSchema=le;exports.getStyleSchemaFromSpecs=Pt;exports.imageBlockConfig=ro;exports.imageParse=io;exports.imagePropSchema=oo;exports.imageRender=so;exports.imageToExternalHTML=ao;exports.inheritedProps=vt;exports.initializeESMDependencies=Qe;exports.inlineContentToNodes=$;exports.insertBlocks=Mn;exports.insertOrUpdateBlock=V;exports.isAppleOS=dn;exports.isLinkInlineContent=it;exports.isNodeBlock=Fe;exports.isPartialLinkInlineContent=Ct;exports.isPartialTableCell=he;exports.isSafari=Kr;exports.isStyledTextInlineContent=ne;exports.isTableCell=qe;exports.isTableCellSelection=gt;exports.linkToolbarPluginKey=Qo;exports.mapTableCell=Ve;exports.mappingFactory=La;exports.markdownToBlocks=zo;exports.markdownToHTML=Ut;exports.mergeCSSClasses=X;exports.mergeParagraphs=qr;exports.nodeToBlock=T;exports.nodeToCustomInlineContent=Ue;exports.pageBreakConfig=Bo;exports.pageBreakParse=xo;exports.pageBreakRender=To;exports.pageBreakSchema=Vt;exports.pageBreakToExternalHTML=Po;exports.parseEmbedElement=mt;exports.parseFigureElement=Ie;exports.propsToAttributes=me;exports.prosemirrorSliceToSlicedBlocks=gn;exports.removeAndInsertBlocks=ht;exports.selectedFragmentToHTML=$t;exports.shikiHighlighterPromiseSymbol=Oe;exports.shikiParserSymbol=ft;exports.sideMenuPluginKey=ir;exports.stylePropsToAttributes=Cn;exports.tableContentToNodes=Pe;exports.tableHandlesPluginKey=de;exports.trackPosition=lr;exports.updateBlock=In;exports.updateBlockCommand=D;exports.updateBlockTr=It;exports.uploadToTmpFilesDotOrg_DEV_ONLY=zs;exports.videoBlockConfig=mo;exports.videoParse=bo;exports.videoPropSchema=fo;exports.videoRender=go;exports.videoToExternalHTML=ko;exports.withPageBreak=js;exports.wrapInBlockStructure=Ce;
|
|
13
13
|
//# sourceMappingURL=blocknote.cjs.map
|