@blocknote/core 0.40.0 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/dist/BlockNoteSchema-COA0fsXW.cjs +11 -0
  2. package/dist/BlockNoteSchema-COA0fsXW.cjs.map +1 -0
  3. package/dist/{BlockNoteSchema-oR047ACf.js → BlockNoteSchema-CYRHak18.js} +681 -581
  4. package/dist/BlockNoteSchema-CYRHak18.js.map +1 -0
  5. package/dist/blocknote.cjs +4 -4
  6. package/dist/blocknote.cjs.map +1 -1
  7. package/dist/blocknote.js +3663 -2817
  8. package/dist/blocknote.js.map +1 -1
  9. package/dist/blocks.cjs +1 -1
  10. package/dist/blocks.js +51 -49
  11. package/dist/en-Cl87Uuyf.cjs +2 -0
  12. package/dist/en-Cl87Uuyf.cjs.map +1 -0
  13. package/dist/{en-Bq3Es3Np.js → en-njEqD7AG.js} +9 -3
  14. package/dist/en-njEqD7AG.js.map +1 -0
  15. package/dist/locales.cjs +1 -1
  16. package/dist/locales.cjs.map +1 -1
  17. package/dist/locales.js +122 -2
  18. package/dist/locales.js.map +1 -1
  19. package/dist/style.css +1 -1
  20. package/dist/tsconfig.tsbuildinfo +1 -1
  21. package/dist/webpack-stats.json +1 -1
  22. package/package.json +4 -3
  23. package/src/api/exporters/html/externalHTMLExporter.ts +1 -1
  24. package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +2 -1
  25. package/src/api/exporters/markdown/markdownExporter.ts +3 -1
  26. package/src/api/exporters/markdown/util/convertVideoToMarkdownRehypePlugin.ts +19 -0
  27. package/src/api/parsers/markdown/parseMarkdown.ts +31 -0
  28. package/src/blocks/Code/block.ts +14 -14
  29. package/src/blocks/Divider/block.ts +49 -0
  30. package/src/blocks/ListItem/BulletListItem/block.ts +9 -1
  31. package/src/blocks/ListItem/CheckListItem/block.ts +1 -0
  32. package/src/blocks/ListItem/NumberedListItem/block.ts +9 -1
  33. package/src/blocks/Table/block.ts +56 -1
  34. package/src/blocks/ToggleWrapper/createToggleWrapper.ts +1 -1
  35. package/src/blocks/defaultBlocks.ts +16 -14
  36. package/src/blocks/index.ts +1 -0
  37. package/src/editor/Block.css +14 -20
  38. package/src/editor/BlockNoteEditor.test.ts +40 -0
  39. package/src/editor/BlockNoteEditor.ts +248 -465
  40. package/src/editor/BlockNoteExtensions.ts +3 -1
  41. package/src/editor/managers/BlockManager.ts +251 -0
  42. package/src/editor/managers/CollaborationManager.ts +212 -0
  43. package/src/editor/managers/EventManager.ts +134 -0
  44. package/src/editor/managers/ExportManager.ts +137 -0
  45. package/src/editor/managers/ExtensionManager.ts +130 -0
  46. package/src/editor/managers/SelectionManager.ts +114 -0
  47. package/src/editor/managers/StateManager.ts +238 -0
  48. package/src/editor/managers/StyleManager.ts +182 -0
  49. package/src/editor/managers/index.ts +11 -0
  50. package/src/extensions/Comments/CommentsPlugin.ts +7 -4
  51. package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +10 -0
  52. package/src/i18n/locales/ar.ts +6 -0
  53. package/src/i18n/locales/de.ts +6 -0
  54. package/src/i18n/locales/en.ts +6 -0
  55. package/src/i18n/locales/es.ts +6 -0
  56. package/src/i18n/locales/fr.ts +6 -0
  57. package/src/i18n/locales/he.ts +6 -0
  58. package/src/i18n/locales/hr.ts +6 -0
  59. package/src/i18n/locales/is.ts +6 -0
  60. package/src/i18n/locales/it.ts +6 -0
  61. package/src/i18n/locales/ja.ts +6 -0
  62. package/src/i18n/locales/ko.ts +6 -0
  63. package/src/i18n/locales/nl.ts +6 -0
  64. package/src/i18n/locales/no.ts +6 -0
  65. package/src/i18n/locales/pl.ts +6 -0
  66. package/src/i18n/locales/pt.ts +6 -0
  67. package/src/i18n/locales/ru.ts +6 -0
  68. package/src/i18n/locales/sk.ts +6 -0
  69. package/src/i18n/locales/uk.ts +6 -0
  70. package/src/i18n/locales/vi.ts +6 -0
  71. package/src/i18n/locales/zh-tw.ts +6 -0
  72. package/src/i18n/locales/zh.ts +6 -0
  73. package/src/schema/blocks/createSpec.ts +1 -0
  74. package/src/util/string.ts +21 -0
  75. package/types/src/api/exporters/markdown/util/convertVideoToMarkdownRehypePlugin.d.ts +2 -0
  76. package/types/src/blocks/Divider/block.d.ts +3 -0
  77. package/types/src/blocks/Heading/block.d.ts +3 -3
  78. package/types/src/blocks/defaultBlocks.d.ts +2 -1
  79. package/types/src/blocks/index.d.ts +1 -0
  80. package/types/src/editor/BlockNoteEditor.d.ts +68 -47
  81. package/types/src/editor/BlockNoteExtensions.d.ts +2 -1
  82. package/types/src/editor/managers/BlockManager.d.ts +114 -0
  83. package/types/src/editor/managers/CollaborationManager.d.ts +115 -0
  84. package/types/src/editor/managers/EventManager.d.ts +58 -0
  85. package/types/src/editor/managers/ExportManager.d.ts +64 -0
  86. package/types/src/editor/managers/ExtensionManager.d.ts +68 -0
  87. package/types/src/editor/managers/SelectionManager.d.ts +54 -0
  88. package/types/src/editor/managers/StateManager.d.ts +115 -0
  89. package/types/src/editor/managers/StyleManager.d.ts +48 -0
  90. package/types/src/editor/managers/index.d.ts +8 -0
  91. package/types/src/extensions/Comments/CommentsPlugin.d.ts +4 -3
  92. package/types/src/i18n/locales/en.d.ts +6 -0
  93. package/types/src/i18n/locales/sk.d.ts +6 -0
  94. package/types/src/util/string.d.ts +1 -0
  95. package/dist/BlockNoteSchema-DmZ6UQfY.cjs +0 -11
  96. package/dist/BlockNoteSchema-DmZ6UQfY.cjs.map +0 -1
  97. package/dist/BlockNoteSchema-oR047ACf.js.map +0 -1
  98. package/dist/en-Bq3Es3Np.js.map +0 -1
  99. package/dist/en-D3B48eJ7.cjs +0 -2
  100. package/dist/en-D3B48eJ7.cjs.map +0 -1
  101. /package/src/api/exporters/markdown/{removeUnderlinesRehypePlugin.ts → util/removeUnderlinesRehypePlugin.ts} +0 -0
  102. /package/types/src/api/exporters/markdown/{removeUnderlinesRehypePlugin.d.ts → util/removeUnderlinesRehypePlugin.d.ts} +0 -0
@@ -0,0 +1,11 @@
1
+ "use strict";var vn=Object.defineProperty;var Sn=(e,t,n)=>t in e?vn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var B=(e,t,n)=>Sn(e,typeof t!="symbol"?t+"":t,n);const I=require("prosemirror-tables"),En=require("@tiptap/extension-bold"),Bn=require("@tiptap/extension-code"),xn=require("@tiptap/extension-italic"),Tn=require("@tiptap/extension-strike"),Mn=require("@tiptap/extension-underline"),E=require("@tiptap/core"),x=require("prosemirror-model"),W=require("prosemirror-state"),Ln=require("uuid"),Nn=require("prosemirror-highlight"),An=require("prosemirror-highlight/shiki"),In=require("prosemirror-transform"),Ce=require("prosemirror-view"),ee=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},Pn=ee(En),On=ee(Bn),Dn=ee(xn),Hn=ee(Tn),_n=ee(Mn);function Rn(e,t=JSON.stringify){const n={};return e.filter(o=>{const r=t(o);return Object.prototype.hasOwnProperty.call(n,r)?!1:n[r]=!0})}function Vn(e){const t=e.filter((o,r)=>e.indexOf(o)!==r);return Rn(t)}const Be=E.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 Ln.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 t={[`data-${this.options.attributeName}`]:e[this.options.attributeName]};return this.options.setIdAttribute?{...t,id:e[this.options.attributeName]}:t}}}}]},addProseMirrorPlugins(){let e=null,t=!1;return[new W.Plugin({key:new W.PluginKey("uniqueID"),appendTransaction:(n,o,r)=>{const s=n.some(h=>h.docChanged)&&!o.doc.eq(r.doc),i=this.options.filterTransaction&&n.some(h=>{var k,g;return!((g=(k=this.options).filterTransaction)!=null&&g.call(k,h))});if(!s||i)return;const{tr:a}=r,{types:c,attributeName:l,generateID:d}=this.options,u=E.combineTransactionSteps(o.doc,n),{mapping:p}=u;if(E.getChangedRanges(u).forEach(({newRange:h})=>{const k=E.findChildrenInRange(r.doc,h,y=>c.includes(y.type.name)),g=k.map(({node:y})=>y.attrs[l]).filter(y=>y!==null),b=Vn(g);k.forEach(({node:y,pos:m})=>{var X;const v=(X=a.doc.nodeAt(m))==null?void 0:X.attrs[l];if(v===null){const J=o.doc.type.createAndFill().content;if(o.doc.content.findDiffStart(J)===null){const je=JSON.parse(JSON.stringify(r.doc.toJSON()));if(je.content[0].content[0].attrs.id="initialBlockId",JSON.stringify(je.content)===JSON.stringify(J.toJSON())){a.setNodeMarkup(m,void 0,{...y.attrs,[l]:"initialBlockId"});return}}a.setNodeMarkup(m,void 0,{...y.attrs,[l]:d()});return}const{deleted:L}=p.invert().mapResult(m);L&&b.includes(v)&&a.setNodeMarkup(m,void 0,{...y.attrs,[l]:d()})})}),!!a.steps.length)return a.setMeta("uniqueID",!0),a},view(n){const o=r=>{let s;e=!((s=n.dom.parentElement)===null||s===void 0)&&s.contains(r.target)?n.dom.parentElement:null};return window.addEventListener("dragstart",o),{destroy(){window.removeEventListener("dragstart",o)}}},props:{handleDOMEvents:{drop:(n,o)=>{let r;return e!==n.dom.parentElement||((r=o.dataTransfer)===null||r===void 0?void 0:r.effectAllowed)==="copy"?t=!0:t=!1,e=null,!1},paste:()=>(t=!0,!1)},transformPasted:n=>{if(!t)return n;const{types:o,attributeName:r}=this.options,s=i=>{const a=[];return i.forEach(c=>{if(c.isText){a.push(c);return}if(!o.includes(c.type.name)){a.push(c.copy(s(c.content)));return}const l=c.type.create({...c.attrs,[r]:null},s(c.content),c.marks);a.push(l)}),x.Fragment.from(a)};return t=!1,new x.Slice(s(n.content),n.openStart,n.openEnd)}}})]}});function ye(e){return e.type==="link"}function xe(e){return typeof e!="string"&&e.type==="link"}function O(e){return typeof e!="string"&&e.type==="text"}function ne(e){var t,n,o,r,s;return se(e)?{...e}:$(e)?{type:"tableCell",content:[].concat(e.content),props:{backgroundColor:((t=e.props)==null?void 0:t.backgroundColor)??"default",textColor:((n=e.props)==null?void 0:n.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 $(e){return e!=null&&typeof e!="string"&&!Array.isArray(e)&&e.type==="tableCell"}function se(e){return $(e)&&e.props!==void 0&&e.content!==void 0}function j(e){return se(e)?e.props.colspan??1:1}function oe(e){return se(e)?e.props.rowspan??1:1}class z extends Error{constructor(t){super(`Unreachable case: ${t}`)}}function Fn(e,t=!0){const{"data-test":n,...o}=e;if(Object.keys(o).length>0&&t)throw new Error("Object must be empty "+JSON.stringify(e))}const Qe=()=>typeof navigator<"u"&&(/Mac/.test(navigator.platform)||/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent));function A(e,t="Ctrl"){return Qe()?e.replace("Mod","⌘"):e.replace("Mod",t)}function U(...e){return[...new Set(e.filter(t=>t).join(" ").split(" "))].join(" ")}const Wn=()=>/^((?!chrome|android).)*safari/i.test(navigator.userAgent);function et(e,t,n,o){const r=document.createElement("div");r.className=U("bn-block-content",n.class),r.setAttribute("data-content-type",e);for(const[i,a]of Object.entries(n))i!=="class"&&r.setAttribute(i,a);const s=document.createElement(t);s.className=U("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 we=(e,t)=>{let n=te(e,t.pmSchema);n.type.name==="blockContainer"&&(n=n.firstChild);const o=t.pmSchema.nodes[n.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(n);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 tt(e,t="<br>"){const n=e.querySelectorAll("p");if(n.length>1){const o=n[0];for(let r=1;r<n.length;r++){const s=n[r];o.innerHTML+=t+s.innerHTML,s.remove()}}}function Y(e){return"data-"+e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function $n(e){const t=e.split("/");return!t.length||t[t.length-1]===""?e:t[t.length-1]}function jn(e){var n;const t=["mp4","webm","ogg","mov","mkv","flv","avi","wmv","m4v"];try{const r=((n=new URL(e).pathname.split(".").pop())==null?void 0:n.toLowerCase())||"";return t.includes(r)}catch{return!1}}function nt(e){const t={};return Object.entries(e).forEach(([n,o])=>{t[n]={default:o.default,keepOnSplit:!0,parseHTML:r=>{const s=r.getAttribute(Y(n));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[n]!==o.default?{[Y(n)]:r[n]}:{}}}),t}function ot(e,t,n,o){const r=e();if(r===void 0)throw new Error("Cannot find node position");const i=n.state.doc.resolve(r).node().attrs.id;if(!i)throw new Error("Block doesn't have id");const a=t.getBlock(i);if(a.type!==o)throw new Error("Block type does not match");return a}function re(e,t,n,o,r=!1,s){const i=document.createElement("div");if(s!==void 0)for(const[a,c]of Object.entries(s))a!=="class"&&i.setAttribute(a,c);i.className=U("bn-block-content",(s==null?void 0:s.class)||""),i.setAttribute("data-content-type",t);for(const[a,c]of Object.entries(n)){const d=o[a].default;c!==d&&i.setAttribute(Y(a),c)}return r&&i.setAttribute("data-file-block",""),i.appendChild(e.dom),e.contentDOM&&(e.contentDOM.className=U("bn-inline-content",e.contentDOM.className)),{...e,dom:i}}function rt(e,t,n){return{config:{type:e.type,content:e.content,propSchema:t},implementation:{node:e.node,render:we,toExternalHTML:we},extensions:n}}function st(e,t){e.stopEvent=n=>(n.type==="mousedown"&&setTimeout(()=>{t.view.dom.blur()},10),!0)}function it(e,t){const n=[{tag:"[data-content-type="+e.type+"]",contentElement:".bn-inline-content"}];return t.parse&&n.push({tag:"*",getAttrs(o){var s;if(typeof o=="string")return!1;const r=(s=t.parse)==null?void 0:s.call(t,o);return r===void 0?!1:r},getContent:e.content==="inline"||e.content==="none"?(o,r)=>{var s;if(t.parseContent)return t.parseContent({el:o,schema:r});if(e.content==="inline"){const a=o.cloneNode(!0);return tt(a,(s=t.meta)!=null&&s.code?`
2
+ `:"<br>"),x.DOMParser.fromSchema(r).parse(a,{topNode:r.nodes.paragraph.create()}).content}return x.Fragment.empty}:void 0}),n}function at(e,t,n,o){var s,i,a,c;const r=t.node||E.Node.create({name:e.type,content:e.content==="inline"?"inline*":e.content==="none"?"":e.content,group:"blockContent",selectable:((s=t.meta)==null?void 0:s.selectable)??!0,isolating:((i=t.meta)==null?void 0:i.isolating)??!0,code:((a=t.meta)==null?void 0:a.code)??!1,defining:((c=t.meta)==null?void 0:c.defining)??!0,priority:o,addAttributes(){return nt(e.propSchema)},parseHTML(){return it(e,t)},renderHTML({HTMLAttributes:l}){var u;const d=document.createElement("div");return re({dom:d,contentDOM:e.content==="inline"?d:void 0},e.type,{},e.propSchema,((u=t.meta)==null?void 0:u.fileBlockAccept)!==void 0,l)},addNodeView(){return l=>{var h,k;const d=this.options.editor,u=ot(l.getPos,d,this.editor,e.type),p=((h=this.options.domAttributes)==null?void 0:h.blockContent)||{},f=t.render.call({blockContentDOMAttributes:p,props:l,renderType:"nodeView"},u,d);return((k=t.meta)==null?void 0:k.selectable)===!1&&st(f,this.editor),f}}});if(r.name!==e.type)throw new Error("Node name does not match block type. This is a bug in BlockNote.");return{config:e,implementation:{...t,node:r,render(l,d){var p;const u=((p=r.options.domAttributes)==null?void 0:p.blockContent)||{};return t.render.call({blockContentDOMAttributes:u,props:void 0,renderType:"dom"},l,d)},toExternalHTML:(l,d)=>{var p,f;const u=((p=r.options.domAttributes)==null?void 0:p.blockContent)||{};return((f=t.toExternalHTML)==null?void 0:f.call({blockContentDOMAttributes:u},l,d))??t.render.call({blockContentDOMAttributes:u,renderType:"dom",props:void 0},l,d)}},extensions:n}}function Un(e){return e}function M(e,t,n){return(o={})=>{const r=typeof e=="function"?e(o):e,s=typeof t=="function"?t(o):t,i=n?typeof n=="function"?n(o):n:void 0;return{config:r,implementation:{...s,toExternalHTML(a,c){var d,u;const l=(d=s.toExternalHTML)==null?void 0:d.call({blockContentDOMAttributes:this.blockContentDOMAttributes},a,c);if(l!==void 0)return re(l,a.type,a.props,r.propSchema,((u=s.meta)==null?void 0:u.fileBlockAccept)!==void 0)},render(a,c){var u;const l=s.render.call({blockContentDOMAttributes:this.blockContentDOMAttributes,renderType:this.renderType,props:this.props},a,c);return re(l,a.type,a.props,r.propSchema,((u=s.meta)==null?void 0:u.fileBlockAccept)!==void 0,this.blockContentDOMAttributes)}},extensions:i}}}function ie(e,t){const n=e.resolve(t);if(n.nodeAfter&&n.nodeAfter.type.isInGroup("bnBlock"))return{posBeforeNode:n.pos,node:n.nodeAfter};let o=n.depth,r=n.node(o);for(;o>0;){if(r.type.isInGroup("bnBlock"))return{posBeforeNode:n.before(o),node:r};o--,r=n.node(o)}const s=[];e.descendants((a,c)=>{a.type.isInGroup("bnBlock")&&s.push(c)}),console.warn(`Position ${t} is not within a blockContainer node.`);const i=e.resolve(s.find(a=>a>=t)||s[s.length-1]);return{posBeforeNode:i.pos,node:i.nodeAfter}}function ae(e,t){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 n=e,o=t,r=o+n.nodeSize,s={node:n,beforePos:o,afterPos:r};if(n.type.name==="blockContainer"){let i,a;if(n.forEach((c,l)=>{if(c.type.spec.group==="blockContent"){const d=c,u=o+l+1,p=u+c.nodeSize;i={node:d,beforePos:u,afterPos:p}}else if(c.type.name==="blockGroup"){const d=c,u=o+l+1,p=u+c.nodeSize;a={node:d,beforePos:u,afterPos:p}}}),!i)throw new Error(`blockContainer node does not contain a blockContent node in its children: ${n}`);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 q(e){return ae(e.node,e.posBeforeNode)}function ct(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 ae(e.nodeAfter,e.pos)}function Te(e){const t=ie(e.doc,e.selection.anchor);return q(t)}function lt(e){const t=ie(e.doc,e.selection.anchor);return q(t)}function G(e){return"doc"in e?e.doc.type.schema:e.type.schema}function ut(e){return e.cached.blockNoteEditor}function ce(e){return ut(e).schema}function le(e){return ce(e).blockSchema}function ue(e){return ce(e).inlineContentSchema}function V(e){return ce(e).styleSchema}function de(e){return ut(e).blockCache}function dt(e,t,n){var s,i;const o={type:"tableContent",columnWidths:[],headerRows:void 0,headerCols:void 0,rows:[]},r=[];e.content.forEach((a,c,l)=>{const d={cells:[]};l===0&&a.content.forEach(u=>{let p=u.attrs.colwidth;p==null&&(p=new Array(u.attrs.colspan??1).fill(void 0)),o.columnWidths.push(...p)}),d.cells=a.content.content.map((u,p)=>(r[l]||(r[l]=[]),r[l][p]=u.type.name==="tableHeader",{type:"tableCell",content:u.content.content.map(h=>pe(h,t,n)).reduce((h,k)=>{if(!h.length)return k;const g=h[h.length-1],b=k[0];return b&&O(g)&&O(b)&&JSON.stringify(g.styles)===JSON.stringify(b.styles)?(g.text+=`
3
+ `+b.text,h.push(...k.slice(1)),h):(h.push(...k),h)},[]),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(c=>c)&&(o.headerRows=(o.headerRows??0)+1);for(let a=0;a<((i=r[0])==null?void 0:i.length);a++)r!=null&&r.every(c=>c[a])&&(o.headerCols=(o.headerCols??0)+1);return o}function pe(e,t,n){const o=[];let r;return e.content.forEach(s=>{if(s.type.name==="hardBreak"){if(r)if(O(r))r.text+=`
4
+ `;else if(ye(r))r.content[r.content.length-1].text+=`
5
+ `;else throw new Error("unexpected");else r={type:"text",text:`
6
+ `,styles:{}};return}if(s.type.name!=="link"&&s.type.name!=="text"){if(!t[s.type.name]){console.warn("unrecognized inline content type",s.type.name);return}r&&(o.push(r),r=void 0),o.push(pt(s,t,n));return}const i={};let a;for(const c of s.marks)if(c.type.name==="link")a=c;else{const l=n[c.type.name];if(!l){if(c.type.spec.blocknoteIgnore)continue;throw new Error(`style ${c.type.name} not found in styleSchema`)}if(l.propSchema==="boolean")i[l.type]=!0;else if(l.propSchema==="string")i[l.type]=c.attrs.stringValue;else throw new z(l.propSchema)}r?O(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}):ye(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 pt(e,t,n){if(e.type.name==="text"||e.type.name==="link")throw new Error("unexpected");const o={},r=t[e.type.name];for(const[a,c]of Object.entries(e.attrs)){if(!r)throw Error("ic node is of an unrecognized type: "+e.type.name);const l=r.propSchema;a in l&&(o[a]=c)}let s;return r.content==="styled"?s=pe(e,t,n):s=void 0,{type:e.type.name,props:o,content:s}}function Z(e,t,n=le(t),o=ue(t),r=V(t),s=de(t)){var k;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=ae(e,0);let c=a.bnBlock.node.attrs.id;c===null&&(c=Be.options.generateID());const l=n[a.blockNoteType];if(!l)throw Error("Block is of an unrecognized type: "+a.blockNoteType);const d={};for(const[g,b]of Object.entries({...e.attrs,...a.isBlockContainer?a.blockContent.node.attrs:{}})){const y=l.propSchema;g in y&&!(y[g].default===void 0&&b===void 0)&&(d[g]=b)}const u=n[a.blockNoteType],p=[];(k=a.childContainer)==null||k.node.forEach(g=>{p.push(Z(g,t,n,o,r,s))});let f;if(u.content==="inline"){if(!a.isBlockContainer)throw new Error("impossible");f=pe(a.blockContent.node,o,r)}else if(u.content==="table"){if(!a.isBlockContainer)throw new Error("impossible");f=dt(a.blockContent.node,o,r)}else if(u.content==="none")f=void 0;else throw new z(u.content);const h={id:c,type:u.type,props:d,content:f,children:p};return s==null||s.set(e,h),h}function qn(e,t,n=le(t),o=ue(t),r=V(t),s=de(t)){const i=[];return e.firstChild.descendants(a=>(i.push(Z(a,t,n,o,r,s)),!1)),i}function zn(e,t,n=le(t),o=ue(t),r=V(t),s=de(t)){function i(a,c,l){if(a.type.name!=="blockGroup")throw new Error("unexpected");const d=[];let u,p;return a.forEach((f,h,k)=>{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 g=k===0,b=k===a.childCount-1;if(f.firstChild.type.name==="blockGroup"){if(!g)throw new Error("unexpected");const L=i(f.firstChild,Math.max(0,c-1),b?Math.max(0,l-1):0);u=L.blockCutAtStart,b&&(p=L.blockCutAtEnd),d.push(...L.blocks);return}const y=Z(f,t,n,o,r,s),m=f.childCount>1?f.child(1):void 0;let v=[];if(m){const L=i(m,0,b?Math.max(0,l-1):0);v=L.blocks,b&&(p=L.blockCutAtEnd)}b&&!m&&l>1&&(p=y.id),g&&c>1&&(u=y.id),d.push({...y,children:v})}),{blocks:d,blockCutAtStart:u,blockCutAtEnd:p}}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 Gn(e,t,n,o){return e.dom.setAttribute("data-inline-content-type",t),Object.entries(n).filter(([r,s])=>{const i=o[r];return s!==i.default}).map(([r,s])=>[Y(r),s]).forEach(([r,s])=>e.dom.setAttribute(r,s)),e.contentDOM&&e.contentDOM.setAttribute("data-editable",""),e}function Zn(e){return{Backspace:({editor:t})=>{const n=t.state.selection.$from;return t.state.selection.empty&&n.node().type.name===e.type&&n.parentOffset===0}}}function ft(e,t){return{config:e,implementation:t}}function Xn(e,t,n){return ft({type:e.name,propSchema:t,content:e.config.content==="inline*"?"styled":"none"},{...n,node:e})}function Me(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,n.config]))}function ht(e){return e==="boolean"?{}:{stringValue:{default:void 0,keepOnSplit:!0,parseHTML:t=>t.getAttribute("data-value"),renderHTML:t=>t.stringValue!==void 0?{"data-value":t.stringValue}:{}}}}function K(e,t,n,o){return e.dom.setAttribute("data-style-type",t),o==="string"&&e.dom.setAttribute("data-value",n),e.contentDOM&&e.contentDOM.setAttribute("data-editable",""),e}function Le(e,t){return{config:e,implementation:t}}function F(e,t){return Le({type:e.name,propSchema:t},{mark:e,render(n,o){const r=o.pmSchema.marks[e.name].spec.toDOM;if(r===void 0)throw new Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");const s=o.pmSchema.mark(e.name,{stringValue:n}),i=x.DOMSerializer.renderSpec(document,r(s,!0));if(typeof i!="object"||!("dom"in i))throw new Error("Cannot use this block's default HTML serialization as its corresponding TipTap mark's `renderHTML` function does not return an object with the `dom` property.");return i},toExternalHTML(n,o){const r=o.pmSchema.marks[e.name].spec.toDOM;if(r===void 0)throw new Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");const s=o.pmSchema.mark(e.name,{stringValue:n}),i=x.DOMSerializer.renderSpec(document,r(s,!0));if(typeof i!="object"||!("dom"in i))throw new Error("Cannot use this block's default HTML serialization as its corresponding TipTap mark's `renderHTML` function does not return an object with the `dom` property.");return i}})}function Ne(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,n.config]))}function gt(e,t){const n=[{tag:`[data-style-type="${e.type}"]`,contentElement:o=>{const r=o;return r.matches("[data-editable]")?r:r.querySelector("[data-editable]")||r}}];return t&&n.push({tag:"*",getAttrs(o){if(typeof o=="string")return!1;const r=t==null?void 0:t(o);return r===void 0?!1:{stringValue:r}}}),n}function Ae(e,t){const n=E.Mark.create({name:e.type,addAttributes(){return ht(e.propSchema)},parseHTML(){return gt(e,t.parse)},renderHTML({mark:o}){const r=(t.toExternalHTML||t.render)(o.attrs.stringValue);return K(r,e.type,o.attrs.stringValue,e.propSchema)},addMarkView(){return({mark:o})=>{const r=t.render(o.attrs.stringValue);return K(r,e.type,o.attrs.stringValue,e.propSchema)}}});return Le(e,{mark:n,render:o=>{const r=t.render(o);return K(r,e.type,o,e.propSchema)},toExternalHTML:o=>{const r=(t.toExternalHTML||t.render)(o);return K(r,e.type,o,e.propSchema)}})}function Jn(e){const t=Yn(e);let{roots:n,nonRoots:o}=Ue(t);const r=[];for(;n.size;){r.push(n);const s=new Set;for(const i of n){const a=e.get(i);if(a)for(const c of a){const l=t.get(c);if(l===void 0)continue;const d=l-1;t.set(c,d),d===0&&s.add(c)}}n=s}if(o=Ue(t).nonRoots,o.size)throw new Error(`Cycle(s) detected; toposort only works on acyclic graphs. Cyclic nodes: ${Array.from(o).join(", ")}`);return r}function Kn(e){const t=Qn(e);return Jn(t)}function Yn(e){const t=new Map;for(const[n,o]of e.entries()){t.has(n)||t.set(n,0);for(const r of o){const s=t.get(r)??0;t.set(r,s+1)}}return t}function Ue(e){const t=new Set,n=new Set;for(const[o,r]of e.entries())r===0?t.add(o):n.add(o);return{roots:t,nonRoots:n}}function Qn(e){const t=new Map;for(const[n,o]of e.entries()){t.has(n)||t.set(n,new Set);for(const r of o)t.has(r)||t.set(r,new Set),t.get(r).add(n)}return t}function eo(){return new Map}function qe(e){return e&&Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}class mt{constructor(t){B(this,"BlockNoteEditor","only for types");B(this,"Block","only for types");B(this,"PartialBlock","only for types");B(this,"inlineContentSpecs");B(this,"styleSpecs");B(this,"blockSpecs");B(this,"blockSchema");B(this,"inlineContentSchema");B(this,"styleSchema");this.opts=t;const{blockSpecs:n,inlineContentSpecs:o,styleSpecs:r,blockSchema:s,inlineContentSchema:i,styleSchema:a}=this.init();this.blockSpecs=n,this.styleSpecs=r,this.styleSchema=a,this.inlineContentSpecs=o,this.blockSchema=s,this.inlineContentSchema=i}init(){const t=eo(),n=new Set;t.set("default",n);for(const[a,c]of Object.entries(this.opts.blockSpecs))c.implementation.runsBefore?t.set(a,new Set(c.implementation.runsBefore)):n.add(a);const o=Kn(t),r=o.findIndex(a=>a.has("default")),s=a=>91+(o.findIndex(l=>l.has(a))+r)*10,i=Object.fromEntries(Object.entries(this.opts.blockSpecs).map(([a,c])=>[a,at(c.config,c.implementation,c.extensions,s(a))]));return{blockSpecs:i,blockSchema:Object.fromEntries(Object.entries(i).map(([a,c])=>[a,c.config])),inlineContentSpecs:qe(this.opts.inlineContentSpecs),styleSpecs:qe(this.opts.styleSpecs),inlineContentSchema:Me(this.opts.inlineContentSpecs),styleSchema:Ne(this.opts.styleSpecs)}}extend(t){Object.assign(this.opts.blockSpecs,t.blockSpecs),Object.assign(this.opts.inlineContentSpecs,t.inlineContentSpecs),Object.assign(this.opts.styleSpecs,t.styleSpecs);const{blockSpecs:n,inlineContentSpecs:o,styleSpecs:r,blockSchema:s,inlineContentSchema:i,styleSchema:a}=this.init();return this.blockSpecs=n,this.styleSpecs=r,this.styleSchema=a,this.inlineContentSpecs=o,this.blockSchema=s,this.inlineContentSchema=i,this}}function D(e){const{height:t,width:n}=Ie(e),o=new Array(t).fill(!1).map(()=>new Array(n).fill(null)),r=(s,i)=>{for(let a=s;a<t;a++)for(let c=i;c<n;c++)if(!o[a][c])return{row:a,col:c};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=ne(e.content.rows[s].cells[i]),c=oe(a),l=j(a),{row:d,col:u}=r(s,i);for(let p=d;p<d+c;p++)for(let f=u;f<u+l;f++){if(o[p][f])throw new Error(`Unable to create occupancy grid for table, cell at ${p},${f} is already occupied`);o[p][f]={row:s,col:i,rowspan:c,colspan:l,cell:a}}}return o}function Q(e){const t=new Set;return e.map(n=>({cells:n.map(o=>t.has(o.row+":"+o.col)?!1:(t.add(o.row+":"+o.col),o.cell)).filter(o=>o!==!1)}))}function _(e,t,n=D(t)){for(let o=0;o<n.length;o++)for(let r=0;r<n[o].length;r++){const s=n[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 Ie(e){const t=e.content.rows.length;let n=0;return e.content.rows.forEach(o=>{let r=0;o.cells.forEach(s=>{r+=j(s)}),n=Math.max(n,r)}),{height:t,width:n}}function bt(e,t,n=D(t)){var r;const o=(r=n[e.row])==null?void 0:r[e.col];if(o)return{row:o.row,col:o.col,cell:o.cell}}function kt(e,t){var s;const n=D(e);if(t<0||t>=n.length)return[];let o=0;for(let i=0;i<t;i++){const a=(s=n[o])==null?void 0:s[0];if(!a)return[];o+=a.rowspan}const r=new Array(n[0].length).fill(!1).map((i,a)=>bt({row:o,col:a},e,n)).filter(i=>i!==void 0);return r.filter((i,a)=>r.findIndex(c=>c.row===i.row&&c.col===i.col)===a)}function Ct(e,t){var s;const n=D(e);if(t<0||t>=n[0].length)return[];let o=0;for(let i=0;i<t;i++){const a=(s=n[0])==null?void 0:s[o];if(!a)return[];o+=a.colspan}const r=new Array(n.length).fill(!1).map((i,a)=>bt({row:a,col:o},e,n)).filter(i=>i!==void 0);return r.filter((i,a)=>r.findIndex(c=>c.row===i.row&&c.col===i.col)===a)}function to(e,t,n,o=D(e)){const{col:r}=_({row:0,col:t},e,o),{col:s}=_({row:0,col:n},e,o);return o.forEach(i=>{const[a]=i.splice(r,1);i.splice(s,0,a)}),Q(o)}function no(e,t,n,o=D(e)){const{row:r}=_({row:t,col:0},e,o),{row:s}=_({row:n,col:0},e,o),[i]=o.splice(r,1);return o.splice(s,0,i),Q(o)}function ve(e){return e?$(e)?ve(e.content):typeof e=="string"?e.length===0:Array.isArray(e)?e.every(t=>typeof t=="string"?t.length===0:O(t)?t.text.length===0:xe(t)?typeof t.content=="string"?t.content.length===0:t.content.every(n=>n.text.length===0):!1):!1:!0}function oo(e,t,n=D(e)){if(t==="columns"){let s=0;for(let i=n[0].length-1;i>=0&&n.every(c=>ve(c[i].cell)&&c[i].colspan===1);i--)s++;for(let i=n.length-1;i>=0;i--){const a=Math.max(n[i].length-s,1);n[i]=n[i].slice(0,a)}return Q(n)}let o=0;for(let s=n.length-1;s>=0&&n[s].every(a=>ve(a.cell)&&a.rowspan===1);s--)o++;const r=Math.min(o,n.length-1);return n.splice(n.length-r,r),Q(n)}function ro(e,t,n,o=D(e)){const{width:r,height:s}=Ie(e);if(t==="columns")o.forEach((i,a)=>{if(n>=0)for(let c=0;c<n;c++)i.push({row:a,col:Math.max(...i.map(l=>l.col))+1,rowspan:1,colspan:1,cell:ne("")});else i.splice(r+n,-1*n)});else if(n>0)for(let i=0;i<n;i++){const a=new Array(r).fill(null).map((c,l)=>({row:s+i,col:l,rowspan:1,colspan:1,cell:ne("")}));o.push(a)}else n<0&&o.splice(s+n,-1*n);return Q(o)}function so(e,t,n){const o=kt(e,n);if(!o.some(c=>oe(c.cell)>1))return!0;let s=n,i=n;return o.forEach(c=>{const l=oe(c.cell);s=Math.max(s,c.row+l-1),i=Math.min(i,c.row)}),t<n?n===s:n===i}function io(e,t,n){const o=Ct(e,n);if(!o.some(c=>j(c.cell)>1))return!0;let s=n,i=n;return o.forEach(c=>{const l=j(c.cell);s=Math.max(s,c.col+l-1),i=Math.min(i,c.col)}),t<n?n===s:n===i}function ao(e,t,n){const o=_(e,n),r=_(t,n);return o.col===r.col}function ze(e,t,n,o){const r=[];for(const[i,a]of Object.entries(e.styles||{})){const c=n[i];if(!c)throw new Error(`style ${i} not found in styleSchema`);if(c.propSchema==="boolean")a&&r.push(t.mark(i));else if(c.propSchema==="string")a&&r.push(t.mark(i,{stringValue:a}));else throw new z(c.propSchema)}return!o||!t.nodes[o].spec.code?e.text.split(/(\n)/g).filter(i=>i.length>0).map(i=>i===`
7
+ `?t.nodes.hardBreak.createChecked():t.text(i,r)):e.text.length>0?[t.text(e.text,r)]:[]}function co(e,t,n){const o=t.marks.link.create({href:e.href});return Se(e.content,t,n).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 Se(e,t,n,o){const r=[];if(typeof e=="string")return r.push(...ze({text:e,styles:{}},t,n,o)),r;for(const s of e)r.push(...ze(s,t,n,o));return r}function R(e,t,n,o=V(t)){const r=[];for(const s of e)typeof s=="string"?r.push(...Se(s,t,o,n)):xe(s)?r.push(...co(s,t,o)):O(s)?r.push(...Se([s],t,o,n)):r.push(yt(s,t,o));return r}function Pe(e,t,n=V(t)){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 c=e.rows[a],l=[],d=r[a];for(let p=0;p<c.cells.length;p++){const f=c.cells[p],h=s[p],k=void 0;let g=null;const b=_({row:a,col:p},{content:e});let y=i[b.col]?[i[b.col]]:null;if(f)if(typeof f=="string")g=t.text(f);else if($(f)){f.content&&(g=R(f.content,t,"tableParagraph",n));const v=j(f);v>1&&(y=new Array(v).fill(!1).map((L,be)=>i[b.col+be]??void 0))}else g=R(f,t,"tableParagraph",n);const m=t.nodes[h||d?"tableHeader":"tableCell"].createChecked({...$(f)?f.props:{},colwidth:y},t.nodes.tableParagraph.createChecked(k,g));l.push(m)}const u=t.nodes.tableRow.createChecked({},l);o.push(u)}return o}function yt(e,t,n){let o,r=e.type;if(r===void 0&&(r="paragraph"),!t.nodes[r])throw new Error(`node type ${r} not found in schema`);if(!e.content)o=t.nodes[r].createChecked(e.props);else if(typeof e.content=="string"){const s=R([e.content],t,r,n);o=t.nodes[r].createChecked(e.props,s)}else if(Array.isArray(e.content)){const s=R(e.content,t,r,n);o=t.nodes[r].createChecked(e.props,s)}else if(e.content.type==="tableContent"){const s=Pe(e.content,t,n);o=t.nodes[r].createChecked(e.props,s)}else throw new z(e.content.type);return o}function te(e,t,n=V(t)){let o=e.id;o===void 0&&(o=Be.options.generateID());const r=[];if(e.children)for(const i of e.children)r.push(te(i,t,n));if(!e.type||t.nodes[e.type].isInGroup("blockContent")){const i=yt(e,t,n),a=r.length>0?t.nodes.blockGroup.createChecked({},r):void 0;return t.nodes.blockContainer.createChecked({id:o,...e.props},a?[i,a]:i)}else{if(t.nodes[e.type].isInGroup("bnBlock"))return t.nodes[e.type].createChecked({id:o,...e.props},r);throw new Error(`block type ${e.type} doesn't match blockContent or bnBlock group`)}}function wt(e,t){let n,o;if(t.firstChild.descendants((r,s)=>n?!1:!vt(r)||r.attrs.id!==e?!0:(n=r,o=s+1,!1)),!(n===void 0||o===void 0))return{node:n,posBeforeNode:o}}function vt(e){return e.type.isInGroup("bnBlock")}const lo=(e,t)=>({tr:n,dispatch:o})=>(o&&fe(n,e,t),!0);function fe(e,t,n,o,r){const s=ct(e.doc.resolve(t));let i=null;s.blockNoteType==="table"&&(i=St(e));const a=G(e);if(o!==void 0&&r!==void 0&&o>r)throw new Error("Invalid replaceFromPos or replaceToPos");const c=a.nodes[s.blockNoteType],l=a.nodes[n.type||s.blockNoteType],d=l.isInGroup("bnBlock")?l:a.nodes.blockContainer;if(s.isBlockContainer&&l.isInGroup("blockContent")){const u=o!==void 0&&o>s.blockContent.beforePos&&o<s.blockContent.afterPos?o-s.blockContent.beforePos-1:void 0,p=r!==void 0&&r>s.blockContent.beforePos&&r<s.blockContent.afterPos?r-s.blockContent.beforePos-1:void 0;Ge(n,e,s),uo(n,e,c,l,s,u,p)}else if(!s.isBlockContainer&&l.isInGroup("bnBlock"))Ge(n,e,s);else{const u=Z(s.bnBlock.node,a);e.replaceWith(s.bnBlock.beforePos,s.bnBlock.afterPos,te({children:u.children,...n},a));return}e.setNodeMarkup(s.bnBlock.beforePos,d,{...s.bnBlock.node.attrs,...n.props}),i&&fo(e,s,i)}function uo(e,t,n,o,r,s,i){const a=G(t);let c="keep";if(e.content)if(typeof e.content=="string")c=R([e.content],a,o.name);else if(Array.isArray(e.content))c=R(e.content,a,o.name);else if(e.content.type==="tableContent")c=Pe(e.content,a);else throw new z(e.content.type);else n.spec.content===""||o.spec.content!==n.spec.content&&(c=[]);if(c==="keep")t.setNodeMarkup(r.blockContent.beforePos,o,{...r.blockContent.node.attrs,...e.props});else if(s!==void 0||i!==void 0){t.setNodeMarkup(r.blockContent.beforePos,o,{...r.blockContent.node.attrs,...e.props});const l=r.blockContent.beforePos+1+(s??0),d=r.blockContent.beforePos+1+(i??r.blockContent.node.content.size),u=t.doc.resolve(r.blockContent.beforePos).depth,p=t.doc.resolve(l).depth,f=t.doc.resolve(d).depth;t.replace(l,d,new x.Slice(x.Fragment.from(c),p-u-1,f-u-1))}else t.replaceWith(r.blockContent.beforePos,r.blockContent.afterPos,o.createChecked({...r.blockContent.node.attrs,...e.props},c))}function Ge(e,t,n){const o=G(t);if(e.children!==void 0&&e.children.length>0){const r=e.children.map(s=>te(s,o));if(n.childContainer)t.step(new In.ReplaceStep(n.childContainer.beforePos+1,n.childContainer.afterPos-1,new x.Slice(x.Fragment.from(r),0,0)));else{if(!n.isBlockContainer)throw new Error("impossible");t.insert(n.blockContent.afterPos,o.nodes.blockGroup.createChecked({},r))}}}function po(e,t,n,o,r){const s=typeof t=="string"?t:t.id,i=wt(s,e.doc);if(!i)throw new Error(`Block with ID ${s} not found`);fe(e,i.posBeforeNode,n,o,r);const a=e.doc.resolve(i.posBeforeNode+1).node(),c=G(e);return Z(a,c)}function St(e){const t="selection"in e?e.selection:null;if(!(t instanceof W.TextSelection))return null;const n=e.doc.resolve(t.head);let o=-1,r=-1;for(let g=n.depth;g>=0;g--){const b=n.node(g).type.name;if(o<0&&(b==="tableCell"||b==="tableHeader")&&(o=g),b==="table"){r=g;break}}if(o<0||r<0)return null;const s=n.before(o),i=n.before(r),a=e.doc.nodeAt(i);if(!a||a.type.name!=="table")return null;const c=I.TableMap.get(a),l=s-(i+1),d=c.map.indexOf(l);if(d<0)return null;const u=Math.floor(d/c.width),p=d%c.width,h=s+1+1,k=Math.max(0,t.head-h);return{row:u,col:p,offset:k}}function fo(e,t,n){var g;if(t.blockNoteType!=="table")return!1;let o=-1;if(t.isBlockContainer)o=e.mapping.map(t.blockContent.beforePos);else{const b=e.mapping.map(t.bnBlock.beforePos),y=b+(((g=e.doc.nodeAt(b))==null?void 0:g.nodeSize)||0);e.doc.nodesBetween(b,y,(m,v)=>m.type.name==="table"?(o=v,!1):!0)}const r=o>=0?e.doc.nodeAt(o):null;if(!r||r.type.name!=="table")return!1;const s=I.TableMap.get(r),i=Math.max(0,Math.min(n.row,s.height-1)),a=Math.max(0,Math.min(n.col,s.width-1)),c=i*s.width+a,l=s.map[c];if(l==null)return!1;const u=o+1+l+1,p=e.doc.nodeAt(u),f=u+1,h=p?p.content.size:0,k=f+Math.max(0,Math.min(n.offset,h));return"selection"in e&&e.setSelection(W.TextSelection.create(e.doc,k)),!0}const P={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"}},ho={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"}},C={backgroundColor:{default:"default"},textColor:{default:"default"},textAlignment:{default:"left",values:["left","center","right","justify"]}},T=e=>{const t={};return e.hasAttribute("data-background-color")?t.backgroundColor=e.getAttribute("data-background-color"):e.style.backgroundColor&&(t.backgroundColor=e.style.backgroundColor),e.hasAttribute("data-text-color")?t.textColor=e.getAttribute("data-text-color"):e.style.color&&(t.textColor=e.style.color),t.textAlignment=C.textAlignment.values.includes(e.style.textAlign)?e.style.textAlign:void 0,t},H=(e,t)=>{e.backgroundColor&&e.backgroundColor!==C.backgroundColor.default&&(t.style.backgroundColor=e.backgroundColor in P?P[e.backgroundColor].background:e.backgroundColor),e.textColor&&e.textColor!==C.textColor.default&&(t.style.color=e.textColor in P?P[e.textColor].text:e.textColor),e.textAlignment&&e.textAlignment!==C.textAlignment.default&&(t.style.textAlign=e.textAlignment)},go=(e="backgroundColor")=>({default:C.backgroundColor.default,parseHTML:t=>t.hasAttribute("data-background-color")?t.getAttribute("data-background-color"):t.style.backgroundColor?t.style.backgroundColor:C.backgroundColor.default,renderHTML:t=>t[e]===C.backgroundColor.default?{}:{"data-background-color":t[e]}}),mo=(e="textColor")=>({default:C.textColor.default,parseHTML:t=>t.hasAttribute("data-text-color")?t.getAttribute("data-text-color"):t.style.color?t.style.color:C.textColor.default,renderHTML:t=>t[e]===C.textColor.default?{}:{"data-text-color":t[e]}}),bo=(e="textAlignment")=>({default:C.textAlignment.default,parseHTML:t=>t.hasAttribute("data-text-alignment")?t.getAttribute("data-text-alignment"):t.style.textAlign?t.style.textAlign:C.textAlignment.default,renderHTML:t=>t[e]===C.textAlignment.default?{}:{"data-text-alignment":t[e]}}),he=(e,t)=>{const n=e.querySelector(t);if(!n)return;const o=e.querySelector("figcaption"),r=(o==null?void 0:o.textContent)??void 0;return{targetElement:n,caption:r}},ko=(e,t,n)=>{const o=document.createElement("div");o.className="bn-add-file-button";const r=document.createElement("div");r.className="bn-add-file-button-icon",n?r.appendChild(n):r.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>',o.appendChild(r);const s=document.createElement("p");s.className="bn-add-file-button-text",s.innerHTML=e.type in t.dictionary.file_blocks.add_button_text?t.dictionary.file_blocks.add_button_text[e.type]:t.dictionary.file_blocks.add_button_text.file,o.appendChild(s);const i=c=>{c.preventDefault()},a=()=>{t.transact(c=>c.setMeta(t.filePanel.plugins[0],{block:e}))};return o.addEventListener("mousedown",i,!0),o.addEventListener("click",a,!0),{dom:o,destroy:()=>{o.removeEventListener("mousedown",i,!0),o.removeEventListener("click",a,!0)}}},Co='<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>',yo=e=>{const t=document.createElement("div");t.className="bn-file-name-with-icon";const n=document.createElement("div");n.className="bn-file-icon",n.innerHTML=Co,t.appendChild(n);const o=document.createElement("p");return o.className="bn-file-name",o.textContent=e.props.name,t.appendChild(o),{dom:t}},Oe=(e,t,n,o)=>{const r=document.createElement("div");if(r.className="bn-file-block-content-wrapper",e.props.url===""){const i=ko(e,t,o);r.appendChild(i.dom);const a=t.onUploadStart(c=>{if(c===e.id){r.removeChild(i.dom);const l=document.createElement("div");l.className="bn-file-loading-preview",l.textContent="Loading...",r.appendChild(l)}});return{dom:r,destroy:()=>{a(),i.destroy()}}}const s={dom:r};if(e.props.showPreview===!1||!n){const i=yo(e);r.appendChild(i.dom),s.destroy=()=>{var a;(a=i.destroy)==null||a.call(i)}}else r.appendChild(n.dom);if(e.props.caption){const i=document.createElement("p");i.className="bn-file-caption",i.textContent=e.props.caption,r.appendChild(i)}return s},De=(e,t)=>{const n=document.createElement("figure"),o=document.createElement("figcaption");return o.textContent=t,n.appendChild(e),n.appendChild(o),{dom:n}},ge=(e,t)=>{const n=document.createElement("div"),o=document.createElement("p");return o.textContent=t,n.appendChild(e),n.appendChild(o),{dom:n}},Ee=e=>({url:e.src||void 0}),Et='<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>',Bt=e=>({type:"audio",propSchema:{backgroundColor:C.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0}},content:"none"}),xt=(e={})=>t=>{if(t.tagName==="AUDIO"){if(t.closest("figure"))return;const{backgroundColor:n}=T(t);return{...Ee(t),backgroundColor:n}}if(t.tagName==="FIGURE"){const n=he(t,"audio");if(!n)return;const{targetElement:o,caption:r}=n,{backgroundColor:s}=T(t);return{...Ee(o),backgroundColor:s,caption:r}}},Tt=(e={})=>(t,n)=>{const o=document.createElement("div");o.innerHTML=e.icon??Et;const r=document.createElement("audio");return r.className="bn-audio",n.resolveFileUrl?n.resolveFileUrl(t.props.url).then(s=>{r.src=s}):r.src=t.props.url,r.controls=!0,r.contentEditable="false",r.draggable=!1,Oe(t,n,{dom:r},o.firstElementChild)},Mt=(e={})=>(t,n)=>{if(!t.props.url){const r=document.createElement("p");return r.textContent="Add audio",{dom:r}}let o;return t.props.showPreview?(o=document.createElement("audio"),o.src=t.props.url):(o=document.createElement("a"),o.href=t.props.url,o.textContent=t.props.name||t.props.url),t.props.caption?t.props.showPreview?De(o,t.props.caption):ge(o,t.props.caption):{dom:o}},Lt=M(Bt,e=>({meta:{fileBlockAccept:["audio/*"]},parse:xt(e),render:Tt(e),toExternalHTML:Mt(e),runsBefore:["file"]}));class Nt{constructor(){B(this,"callbacks",{})}on(t,n){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(n),()=>this.off(t,n)}emit(t,...n){const o=this.callbacks[t];o&&o.forEach(r=>r.apply(this,n))}off(t,n){const o=this.callbacks[t];o&&(n?this.callbacks[t]=o.filter(r=>r!==n):delete this.callbacks[t])}removeAllListeners(){this.callbacks={}}}class At extends Nt{constructor(...n){super();B(this,"plugins",[]);B(this,"inputRules");B(this,"keyboardShortcuts");B(this,"tiptapExtensions")}static key(){throw new Error("You must implement the key method in your extension")}addProsemirrorPlugin(n){this.plugins.push(n)}get priority(){}}function N(e){const t=Object.create(At.prototype);return t.key=e.key,t.inputRules=e.inputRules,t.keyboardShortcuts=e.keyboardShortcuts,t.plugins=e.plugins??[],t.tiptapExtensions=e.tiptapExtensions,t}const Ze=Symbol.for("blocknote.shikiParser"),ke=Symbol.for("blocknote.shikiHighlighterPromise");function wo(e){const t=globalThis;let n,o,r=!1;const s=i=>{if(!e.createHighlighter)return process.env.NODE_ENV==="development"&&!r&&(console.log("For syntax highlighting of code blocks, you must provide a `createCodeBlockSpec({ createHighlighter: () => ... })` function"),r=!0),[];if(!n)return t[ke]=t[ke]||e.createHighlighter(),t[ke].then(c=>{n=c});const a=He(e,i.language);return!a||a==="text"||a==="none"||a==="plaintext"||a==="txt"?[]:n.getLoadedLanguages().includes(a)?(o||(o=t[Ze]||An.createParser(n),t[Ze]=o),o(i)):n.loadLanguage(a)};return Nn.createHighlightPlugin({parser:s,languageExtractor:i=>i.attrs.language,nodeTypes:["codeBlock"]})}const It=({defaultLanguage:e="text"})=>({type:"codeBlock",propSchema:{language:{default:e}},content:"inline"}),Pt=M(It,e=>({meta:{code:!0,defining:!0,isolating:!1},parse:t=>{var r,s;if(t.tagName!=="PRE"||t.childElementCount!==1||((r=t.firstElementChild)==null?void 0:r.tagName)!=="CODE")return;const n=t.firstElementChild;return{language:n.getAttribute("data-language")||((s=n.className.split(" ").find(i=>i.includes("language-")))==null?void 0:s.replace("language-",""))}},parseContent:({el:t,schema:n})=>{const o=x.DOMParser.fromSchema(n),r=t.firstElementChild;return o.parse(r,{topNode:n.nodes.codeBlock.create()}).content},render(t,n){const o=document.createDocumentFragment(),r=document.createElement("pre"),s=document.createElement("code");r.appendChild(s);let i;if(e.supportedLanguages){const a=document.createElement("select");Object.entries(e.supportedLanguages??{}).forEach(([d,{name:u}])=>{const p=document.createElement("option");p.value=d,p.text=u,a.appendChild(p)}),a.value=t.props.language||e.defaultLanguage||"text";const c=d=>{const u=d.target.value;n.updateBlock(t.id,{props:{language:u}})};a.addEventListener("change",c),i=()=>a.removeEventListener("change",c);const l=document.createElement("div");l.contentEditable="false",l.appendChild(a),o.appendChild(l)}return o.appendChild(r),{dom:o,contentDOM:s,destroy:()=>{i==null||i()}}},toExternalHTML(t){const n=document.createElement("pre"),o=document.createElement("code");return o.className=`language-${t.props.language}`,o.dataset.language=t.props.language,n.appendChild(o),{dom:n,contentDOM:o}}}),e=>[N({key:"code-block-highlighter",plugins:[wo(e)]}),N({key:"code-block-keyboard-shortcuts",keyboardShortcuts:{Delete:({editor:t})=>t.transact(n=>{const{block:o}=t.getTextCursorPosition();if(o.type!=="codeBlock")return!1;const{$from:r}=n.selection;return r.parent.textContent?!1:(t.removeBlocks([o]),!0)}),Tab:({editor:t})=>e.indentLineWithTab===!1?!1:t.transact(n=>{const{block:o}=t.getTextCursorPosition();return o.type==="codeBlock"?(n.insertText(" "),!0):!1}),Enter:({editor:t})=>t.transact(n=>{const{block:o,nextBlock:r}=t.getTextCursorPosition();if(o.type!=="codeBlock")return!1;const{$from:s}=n.selection,i=s.parentOffset===s.parent.nodeSize-2,a=s.parent.textContent.endsWith(`
8
+
9
+ `);if(i&&a){if(n.delete(s.pos-2,s.pos),r)return t.setTextCursorPosition(r,"start"),!0;const[c]=t.insertBlocks([{type:"paragraph"}],o,"after");return t.setTextCursorPosition(c,"start"),!0}return n.insertText(`
10
+ `),!0}),"Shift-Enter":({editor:t})=>t.transact(()=>{const{block:n}=t.getTextCursorPosition();if(n.type!=="codeBlock")return!1;const[o]=t.insertBlocks([{type:"paragraph"}],n,"after");return t.setTextCursorPosition(o,"start"),!0})},inputRules:[{find:/^```(.*?)\s$/,replace:({match:t})=>{const n=t[1].trim();return{type:"codeBlock",props:{language:{language:He(e,n)??n}.language},content:[]}}}]})]);function He(e,t){var n;return(n=Object.entries(e.supportedLanguages??{}).find(([o,{aliases:r}])=>(r==null?void 0:r.includes(t))||o===t))==null?void 0:n[0]}const Ot=()=>({type:"divider",propSchema:{},content:"none"}),Dt=M(Ot,{meta:{isolating:!1},parse(e){if(e.tagName==="HR")return{}},render(){return{dom:document.createElement("hr")}}},[N({key:"divider-block-shortcuts",inputRules:[{find:new RegExp("^---$"),replace(){return{type:"divider",props:{},content:[]}}}]})]),Xe=e=>({url:e.src||void 0}),Ht=()=>({type:"file",propSchema:{backgroundColor:C.backgroundColor,name:{default:""},url:{default:""},caption:{default:""}},content:"none"}),_t=()=>e=>{if(e.tagName==="EMBED"){if(e.closest("figure"))return;const{backgroundColor:t}=T(e);return{...Xe(e),backgroundColor:t}}if(e.tagName==="FIGURE"){const t=he(e,"embed");if(!t)return;const{targetElement:n,caption:o}=t,{backgroundColor:r}=T(e);return{...Xe(n),backgroundColor:r,caption:o}}},Rt=M(Ht,{meta:{fileBlockAccept:["*/*"]},parse:_t(),render(e,t){return Oe(e,t)},toExternalHTML(e){if(!e.props.url){const n=document.createElement("p");return n.textContent="Add file",{dom:n}}const t=document.createElement("a");return t.href=e.props.url,t.textContent=e.props.name||e.props.url,e.props.caption?ge(t,e.props.caption):{dom:t}}}),Vt={set:(e,t)=>window.localStorage.setItem(`toggle-${e.id}`,t?"true":"false"),get:e=>window.localStorage.getItem(`toggle-${e.id}`)==="true"},_e=(e,t,n,o=Vt)=>{if("isToggleable"in e.props&&!e.props.isToggleable)return{dom:n};const r=document.createElement("div"),s=document.createElement("div");s.className="bn-toggle-wrapper";const i=document.createElement("button");i.className="bn-toggle-button",i.type="button",i.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="CURRENTCOLOR"><path d="M320-200v-560l440 280-440 280Z"/></svg>';const a=h=>h.preventDefault();i.addEventListener("mousedown",a);const c=()=>{var h;s.getAttribute("data-show-children")==="true"?(s.setAttribute("data-show-children","false"),o.set(t.getBlock(e),!1),r.contains(l)&&r.removeChild(l)):(s.setAttribute("data-show-children","true"),o.set(t.getBlock(e),!0),((h=t.getBlock(e))==null?void 0:h.children.length)===0&&!r.contains(l)&&r.appendChild(l))};i.addEventListener("click",c),s.appendChild(i),s.appendChild(n);const l=document.createElement("button");l.className="bn-toggle-add-block-button",l.type="button",l.textContent=t.dictionary.toggle_blocks.add_block_button;const d=h=>h.preventDefault();l.addEventListener("mousedown",d);const u=()=>{t.transact(()=>{const h=t.updateBlock(e,{children:[{}]});t.setTextCursorPosition(h.children[0].id,"end"),t.focus()})};l.addEventListener("click",u),r.appendChild(s);let p=e.children.length;const f=t.onChange(()=>{var k;const h=((k=t.getBlock(e))==null?void 0:k.children.length)??0;h>p?(s.getAttribute("data-show-children")==="false"&&(s.setAttribute("data-show-children","true"),o.set(t.getBlock(e),!0)),r.contains(l)&&r.removeChild(l)):h===0&&h<p&&(s.getAttribute("data-show-children")==="true"&&(s.setAttribute("data-show-children","false"),o.set(t.getBlock(e),!1)),r.contains(l)&&r.removeChild(l)),p=h});return o.get(e)?(s.setAttribute("data-show-children","true"),e.children.length===0&&r.appendChild(l)):s.setAttribute("data-show-children","false"),{dom:r,ignoreMutation:h=>h instanceof MutationRecord&&(h.type==="attributes"&&h.target===s&&h.attributeName==="data-show-children"||h.type==="childList"&&(h.addedNodes[0]===l||h.removedNodes[0]===l)),destroy:()=>{i.removeEventListener("mousedown",a),i.removeEventListener("click",c),l.removeEventListener("mousedown",d),l.removeEventListener("click",u),f==null||f()}}},Ft=[1,2,3,4,5,6],Wt=({defaultLevel:e=1,levels:t=Ft,allowToggleHeadings:n=!0}={})=>({type:"heading",propSchema:{...C,level:{default:e,values:t},...n?{isToggleable:{default:!1,optional:!0}}:{}},content:"inline"}),$t=M(Wt,({allowToggleHeadings:e=!0}={})=>({meta:{isolating:!1},parse(t){let n;switch(t.tagName){case"H1":n=1;break;case"H2":n=2;break;case"H3":n=3;break;case"H4":n=4;break;case"H5":n=5;break;case"H6":n=6;break;default:return}return{...T(t),level:n}},render(t,n){const o=document.createElement(`h${t.props.level}`);return e?{..._e(t,n,o),contentDOM:o}:{dom:o,contentDOM:o}},toExternalHTML(t){const n=document.createElement(`h${t.props.level}`);return H(t.props,n),{dom:n,contentDOM:n}}}),({levels:e=Ft}={})=>[N({key:"heading-shortcuts",keyboardShortcuts:Object.fromEntries(e.map(t=>[`Mod-Alt-${t}`,({editor:n})=>{const o=n.getTextCursorPosition();return n.schema.blockSchema[o.block.type].content!=="inline"?!1:(n.updateBlock(o.block,{type:"heading",props:{level:t}}),!0)}])??[]),inputRules:e.map(t=>({find:new RegExp(`^(#{${t}})\\s$`),replace({match:n}){return{type:"heading",props:{level:n[1].length}}}}))})]),jt=(e,t,n,o,r)=>{const{dom:s,destroy:i}=Oe(e,t,n,r),a=s;a.style.position="relative",e.props.url&&e.props.showPreview&&(e.props.previewWidth?a.style.width=`${e.props.previewWidth}px`:a.style.width="fit-content");const c=document.createElement("div");c.className="bn-resize-handle",c.style.left="4px";const l=document.createElement("div");l.className="bn-resize-handle",l.style.right="4px";const d=document.createElement("div");d.style.position="absolute",d.style.height="100%",d.style.width="100%";let u,p=e.props.previewWidth;const f=m=>{var X,J;if(!u){!t.isEditable&&o.contains(c)&&o.contains(l)&&(o.removeChild(c),o.removeChild(l));return}let v;const L="touches"in m?m.touches[0].clientX:m.clientX;e.props.textAlignment==="center"?u.handleUsed==="left"?v=u.initialWidth+(u.initialClientX-L)*2:v=u.initialWidth+(L-u.initialClientX)*2:u.handleUsed==="left"?v=u.initialWidth+u.initialClientX-L:v=u.initialWidth+L-u.initialClientX,p=Math.min(Math.max(v,64),((J=(X=t.domElement)==null?void 0:X.firstElementChild)==null?void 0:J.clientWidth)||Number.MAX_VALUE),a.style.width=`${p}px`},h=m=>{(!m.target||!a.contains(m.target)||!t.isEditable)&&o.contains(c)&&o.contains(l)&&(o.removeChild(c),o.removeChild(l)),u&&(u=void 0,a.contains(d)&&a.removeChild(d),t.updateBlock(e,{props:{previewWidth:p}}))},k=()=>{t.isEditable&&(o.appendChild(c),o.appendChild(l))},g=m=>{m.relatedTarget===c||m.relatedTarget===l||u||t.isEditable&&o.contains(c)&&o.contains(l)&&(o.removeChild(c),o.removeChild(l))},b=m=>{m.preventDefault(),a.contains(d)||a.appendChild(d);const v="touches"in m?m.touches[0].clientX:m.clientX;u={handleUsed:"left",initialWidth:a.clientWidth,initialClientX:v}},y=m=>{m.preventDefault(),a.contains(d)||a.appendChild(d);const v="touches"in m?m.touches[0].clientX:m.clientX;u={handleUsed:"right",initialWidth:a.clientWidth,initialClientX:v}};return window.addEventListener("mousemove",f),window.addEventListener("touchmove",f),window.addEventListener("mouseup",h),window.addEventListener("touchend",h),a.addEventListener("mouseenter",k),a.addEventListener("mouseleave",g),c.addEventListener("mousedown",b),c.addEventListener("touchstart",b),l.addEventListener("mousedown",y),l.addEventListener("touchstart",y),{dom:a,destroy:()=>{i==null||i(),window.removeEventListener("mousemove",f),window.removeEventListener("touchmove",f),window.removeEventListener("mouseup",h),window.removeEventListener("touchend",h),a.removeEventListener("mouseenter",k),a.removeEventListener("mouseleave",g),c.removeEventListener("mousedown",b),c.removeEventListener("touchstart",b),l.removeEventListener("mousedown",y),l.removeEventListener("touchstart",y)}}},Je=e=>{const t=e.src||void 0,n=e.width||void 0,o=e.alt||void 0;return{url:t,previewWidth:n,name:o}},Ut='<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>',qt=(e={})=>({type:"image",propSchema:{textAlignment:C.textAlignment,backgroundColor:C.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0},previewWidth:{default:void 0,type:"number"}},content:"none"}),zt=(e={})=>t=>{if(t.tagName==="IMG"){if(t.closest("figure"))return;const{backgroundColor:n}=T(t);return{...Je(t),backgroundColor:n}}if(t.tagName==="FIGURE"){const n=he(t,"img");if(!n)return;const{targetElement:o,caption:r}=n,{backgroundColor:s}=T(t);return{...Je(o),backgroundColor:s,caption:r}}},Gt=(e={})=>(t,n)=>{const o=document.createElement("div");o.innerHTML=e.icon??Ut;const r=document.createElement("div");r.className="bn-visual-media-wrapper";const s=document.createElement("img");return s.className="bn-visual-media",n.resolveFileUrl?n.resolveFileUrl(t.props.url).then(i=>{s.src=i}):s.src=t.props.url,s.alt=t.props.name||t.props.caption||"BlockNote image",s.contentEditable="false",s.draggable=!1,r.appendChild(s),jt(t,n,{dom:r},r,o.firstElementChild)},Zt=(e={})=>(t,n)=>{if(!t.props.url){const r=document.createElement("p");return r.textContent="Add image",{dom:r}}let o;return t.props.showPreview?(o=document.createElement("img"),o.src=t.props.url,o.alt=t.props.name||t.props.caption||"BlockNote image",t.props.previewWidth&&(o.width=t.props.previewWidth)):(o=document.createElement("a"),o.href=t.props.url,o.textContent=t.props.name||t.props.url),t.props.caption?t.props.showPreview?De(o,t.props.caption):ge(o,t.props.caption):{dom:o}},Xt=M(qt,e=>({meta:{fileBlockAccept:["image/*"]},parse:zt(e),render:Gt(e),toExternalHTML:Zt(e),runsBefore:["file"]})),vo=(e,t,n)=>({state:o,dispatch:r})=>r?Jt(o.tr,e,t,n):!0,Jt=(e,t,n,o)=>{const r=ie(e.doc,t),s=q(r);if(!s.isBlockContainer)return!1;const i=G(e),a=[{type:s.bnBlock.node.type,attrs:o?{...s.bnBlock.node.attrs,id:void 0}:{}},{type:n?s.blockContent.node.type:i.nodes.paragraph,attrs:o?{...s.blockContent.node.attrs}:{}}];return e.split(t,2,a),!0},me=(e,t)=>{const{blockInfo:n,selectionEmpty:o}=e.transact(i=>({blockInfo:lt(i),selectionEmpty:i.selection.anchor===i.selection.head}));if(!n.isBlockContainer)return!1;const{bnBlock:r,blockContent:s}=n;return s.node.type.name!==t||!o?!1:s.node.childCount===0?(e.transact(i=>{fe(i,r.beforePos,{type:"paragraph",props:{}})}),!0):s.node.childCount>0?e.transact(i=>(i.deleteSelection(),Jt(i,i.selection.from,!0))):!1};function Re(e,t,n){var u,p,f;const o=x.DOMParser.fromSchema(t),r=e,s=document.createElement("div");s.setAttribute("data-node-type","blockGroup");for(const h of Array.from(r.childNodes))s.appendChild(h.cloneNode(!0));let i=o.parse(s,{topNode:t.nodes.blockGroup.create()});((p=(u=i.firstChild)==null?void 0:u.firstChild)==null?void 0:p.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 x.Fragment.from(i);const c=t.nodes[n].create({},a.content),l=i.content.cut(a.nodeSize+2);if(l.size>0){const h=i.copy(l);return c.content.addToEnd(h)}return c.content}const Kt=()=>({type:"bulletListItem",propSchema:{...C},content:"inline"}),Yt=M(Kt,{meta:{isolating:!1},parse(e){var n;if(e.tagName!=="LI")return;const t=e.parentElement;if(t!==null&&(t.tagName==="UL"||t.tagName==="DIV"&&((n=t.parentElement)==null?void 0:n.tagName)==="UL"))return T(e)},parseContent:({el:e,schema:t})=>Re(e,t,"bulletListItem"),render(){const e=document.createElement("p");return{dom:e,contentDOM:e}},toExternalHTML(e){const t=document.createElement("li"),n=document.createElement("p");return H(e.props,t),t.appendChild(n),{dom:t,contentDOM:n}}},[N({key:"bullet-list-item-shortcuts",keyboardShortcuts:{Enter:({editor:e})=>me(e,"bulletListItem"),"Mod-Shift-8":({editor:e})=>{const t=e.getTextCursorPosition();return e.schema.blockSchema[t.block.type].content!=="inline"?!1:(e.updateBlock(t.block,{type:"bulletListItem",props:{}}),!0)}},inputRules:[{find:new RegExp("^[-+*]\\s$"),replace({editor:e}){if(Te(e.prosemirrorState).blockNoteType!=="heading")return{type:"bulletListItem",props:{}}}}]})]),Qt=()=>({type:"checkListItem",propSchema:{...C,checked:{default:!1,type:"boolean"}},content:"inline"}),en=M(Qt,{meta:{isolating:!1},parse(e){var n;if(e.tagName==="input")return e.closest("[data-content-type]")||e.closest("li")?void 0:e.type==="checkbox"?{checked:e.checked}:void 0;if(e.tagName!=="LI")return;const t=e.parentElement;if(t!==null&&(t.tagName==="UL"||t.tagName==="DIV"&&((n=t.parentElement)==null?void 0:n.tagName)==="UL")){const o=e.querySelector("input[type=checkbox]")||null;return o===null?void 0:{...T(e),checked:o.checked}}},parseContent:({el:e,schema:t})=>Re(e,t,"checkListItem"),render(e,t){const n=document.createDocumentFragment(),o=document.createElement("input");o.type="checkbox",o.checked=e.props.checked,e.props.checked&&o.setAttribute("checked",""),o.addEventListener("change",()=>{t.updateBlock(e,{props:{checked:!e.props.checked}})});const r=document.createElement("p");return n.appendChild(o),n.appendChild(r),{dom:n,contentDOM:r}},toExternalHTML(e){const t=document.createElement("li"),n=document.createElement("input");n.type="checkbox",n.checked=e.props.checked,e.props.checked&&n.setAttribute("checked","");const o=document.createElement("p");return H(e.props,t),t.appendChild(n),t.appendChild(o),{dom:t,contentDOM:o}},runsBefore:["bulletListItem"]},[N({key:"check-list-item-shortcuts",keyboardShortcuts:{Enter:({editor:e})=>me(e,"checkListItem"),"Mod-Shift-9":({editor:e})=>{const t=e.getTextCursorPosition();return e.schema.blockSchema[t.block.type].content!=="inline"?!1:(e.updateBlock(t.block,{type:"checkListItem",props:{}}),!0)}},inputRules:[{find:new RegExp("\\[\\s*\\]\\s$"),replace(){return{type:"checkListItem",props:{checked:!1},content:[]}}},{find:new RegExp("\\[[Xx]\\]\\s$"),replace(){return{type:"checkListItem",props:{checked:!0}}}}]})]);function tn(e,t,n,o){let r=e.firstChild.attrs.start||1,s=!0;const i=!!e.firstChild.attrs.start,a=q({posBeforeNode:t,node:e});if(!a.isBlockContainer)throw new Error("impossible");const c=n.doc.resolve(a.bnBlock.beforePos).nodeBefore,l=c?o.get(c):void 0;return l!==void 0?(r=l+1,s=!1):c&&q({posBeforeNode:a.bnBlock.beforePos-c.nodeSize,node:c}).blockNoteType==="numberedListItem"&&(r=tn(c,a.bnBlock.beforePos-c.nodeSize,n,o).index+1,s=!1),o.set(e,r),{index:r,isFirst:s,hasStart:i}}function Ke(e,t){const n=new Map,o=t.decorations.map(e.mapping,e.doc),r=[];e.doc.nodesBetween(0,e.doc.nodeSize-2,(i,a)=>{if(i.type.name==="blockContainer"&&i.firstChild.type.name==="numberedListItem"){const{index:c,isFirst:l,hasStart:d}=tn(i,a,e,n);o.find(a,a+i.nodeSize,p=>p.index===c&&p.isFirst===l&&p.hasStart===d).length===0&&r.push(Ce.Decoration.node(a+1,a+i.nodeSize-1,{"data-index":c.toString()}))}});const s=r.flatMap(i=>o.find(i.from,i.to));return{decorations:o.remove(s).add(e.doc,r)}}const So=()=>new W.Plugin({key:new W.PluginKey("numbered-list-indexing-decorations"),state:{init(e,t){return Ke(t.tr,{decorations:Ce.DecorationSet.empty})},apply(e,t){return!e.docChanged&&!e.selectionSet&&t.decorations?t:Ke(e,t)}},props:{decorations(e){var t;return((t=this.getState(e))==null?void 0:t.decorations)??Ce.DecorationSet.empty}}}),nn=()=>({type:"numberedListItem",propSchema:{...C,start:{default:void 0,type:"number"}},content:"inline"}),on=M(nn,{meta:{isolating:!1},parse(e){var n;if(e.tagName!=="LI")return;const t=e.parentElement;if(t!==null&&(t.tagName==="OL"||t.tagName==="DIV"&&((n=t.parentElement)==null?void 0:n.tagName)==="OL")){const o=parseInt(t.getAttribute("start")||"1"),r=T(e);return e.previousElementSibling||o===1?r:{...r,start:o}}},parseContent:({el:e,schema:t})=>Re(e,t,"numberedListItem"),render(){const e=document.createElement("p");return{dom:e,contentDOM:e}},toExternalHTML(e){const t=document.createElement("li"),n=document.createElement("p");return H(e.props,t),t.appendChild(n),{dom:t,contentDOM:n}}},[N({key:"numbered-list-item-shortcuts",inputRules:[{find:new RegExp("^(\\d+)\\.\\s$"),replace({match:e,editor:t}){if(Te(t.prosemirrorState).blockNoteType==="heading")return;const o=parseInt(e[1]);return{type:"numberedListItem",props:{start:o!==1?o:void 0}}}}],keyboardShortcuts:{Enter:({editor:e})=>me(e,"numberedListItem"),"Mod-Shift-7":({editor:e})=>{const t=e.getTextCursorPosition();return e.schema.blockSchema[t.block.type].content!=="inline"?!1:(e.updateBlock(t.block,{type:"numberedListItem",props:{}}),!0)}},plugins:[So()]})]),rn=()=>({type:"toggleListItem",propSchema:{...C},content:"inline"}),sn=M(rn,{meta:{isolating:!1},render(e,t){const n=document.createElement("p");return{..._e(e,t,n),contentDOM:n}},toExternalHTML(e){const t=document.createElement("li"),n=document.createElement("p");return H(e.props,t),t.appendChild(n),{dom:t,contentDOM:n}}},[N({key:"toggle-list-item-shortcuts",keyboardShortcuts:{Enter:({editor:e})=>me(e,"toggleListItem"),"Mod-Shift-6":({editor:e})=>{const t=e.getTextCursorPosition();return e.schema.blockSchema[t.block.type].content!=="inline"?!1:(e.updateBlock(t.block,{type:"toggleListItem",props:{}}),!0)}}})]),an=()=>({type:"pageBreak",propSchema:{},content:"none"}),cn=M(an,{parse(e){if(e.tagName==="DIV"&&e.hasAttribute("data-page-break"))return{}},render(){const e=document.createElement("div");return e.setAttribute("data-page-break",""),{dom:e}},toExternalHTML(){const e=document.createElement("div");return e.setAttribute("data-page-break",""),{dom:e}}}),Eo=e=>e.extend({blockSpecs:{pageBreak:cn()}}),ln=()=>({type:"paragraph",propSchema:C,content:"inline"}),un=M(ln,{meta:{isolating:!1},parse:e=>{var t;if(e.tagName==="P"&&(t=e.textContent)!=null&&t.trim())return T(e)},render:()=>{const e=document.createElement("p");return{dom:e,contentDOM:e}},toExternalHTML:e=>{const t=document.createElement("p");return H(e.props,t),{dom:t,contentDOM:t}},runsBefore:["default"]},[N({key:"paragraph-shortcuts",keyboardShortcuts:{"Mod-Alt-0":({editor:e})=>{const t=e.getTextCursorPosition();return e.schema.blockSchema[t.block.type].content!=="inline"?!1:(e.updateBlock(t.block,{type:"paragraph",props:{}}),!0)}}})]),dn=()=>({type:"quote",propSchema:{backgroundColor:C.backgroundColor,textColor:C.textColor},content:"inline"}),pn=M(dn,{meta:{isolating:!1},parse(e){if(e.tagName==="BLOCKQUOTE"){const{backgroundColor:t,textColor:n}=T(e);return{backgroundColor:t,textColor:n}}},render(){const e=document.createElement("blockquote");return{dom:e,contentDOM:e}},toExternalHTML(e){const t=document.createElement("blockquote");return H(e.props,t),{dom:t,contentDOM:t}}},[N({key:"quote-block-shortcuts",keyboardShortcuts:{"Mod-Alt-q":({editor:e})=>{const t=e.getTextCursorPosition();return e.schema.blockSchema[t.block.type].content!=="inline"?!1:(e.updateBlock(t.block,{type:"quote",props:{}}),!0)}},inputRules:[{find:new RegExp("^>\\s$"),replace(){return{type:"quote",props:{}}}}]})]),Bo=35,Ve=120,xo=31,To=E.Extension.create({name:"BlockNoteTableExtension",addProseMirrorPlugins:()=>[I.columnResizing({cellMinWidth:Bo,defaultCellMinWidth:Ve,View:null}),I.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,t=e.empty,n=e.$head.parentOffset===0,o=e.$head.node().type.name==="tableParagraph";return t&&n&&o},Tab:()=>this.editor.commands.command(({state:e,dispatch:t,view:n})=>I.goToNextCell(1)(e,t,n)),"Shift-Tab":()=>this.editor.commands.command(({state:e,dispatch:t,view:n})=>I.goToNextCell(-1)(e,t,n))}},extendNodeSchema(e){const t={name:e.name,options:e.options,storage:e.storage};return{tableRole:E.callOrReturn(E.getExtensionField(e,"tableRole",t))}}}),fn={textColor:C.textColor},Mo=E.Node.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"tableContent+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(o=>parseInt(o,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th",getContent:(e,t)=>hn(e,t)}]},renderHTML({HTMLAttributes:e}){return["th",E.mergeAttributes(this.options.HTMLAttributes,e),0]}}),Lo=E.Node.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"tableContent+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(o=>parseInt(o,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td",getContent:(e,t)=>hn(e,t)}]},renderHTML({HTMLAttributes:e}){return["td",E.mergeAttributes(this.options.HTMLAttributes,e),0]}}),No=E.Node.create({name:"table",content:"tableRow+",group:"blockContent",tableRole:"table",marks:"deletion insertion modification",isolating:!0,parseHTML(){return[{tag:"table"}]},renderHTML({node:e,HTMLAttributes:t}){var r,s,i;const n=et(this.name,"table",{...((r=this.options.domAttributes)==null?void 0:r.blockContent)||{},...t},((s=this.options.domAttributes)==null?void 0:s.inlineContent)||{}),o=document.createElement("colgroup");for(const a of e.children[0].children)if(a.attrs.colwidth)for(const l of a.attrs.colwidth){const d=document.createElement("col");l&&(d.style=`width: ${l}px`),o.appendChild(d)}else o.appendChild(document.createElement("col"));return(i=n.dom.firstChild)==null||i.appendChild(o),n},addNodeView(){return({node:e,HTMLAttributes:t})=>{var o;class n extends I.TableView{constructor(s,i,a){super(s,i),this.node=s,this.cellMinWidth=i,this.blockContentHTMLAttributes=a;const c=document.createElement("div");c.className=U("bn-block-content",a.class),c.setAttribute("data-content-type","table");for(const[p,f]of Object.entries(a))p!=="class"&&c.setAttribute(p,f);const l=this.dom,d=document.createElement("div");d.className="tableWrapper-inner",d.appendChild(l.firstChild),l.appendChild(d),c.appendChild(l);const u=document.createElement("div");u.className="table-widgets-container",u.style.position="relative",l.appendChild(u),this.dom=c}ignoreMutation(s){return!s.target.closest(".tableWrapper-inner")||super.ignoreMutation(s)}}return new n(e,Ve,{...((o=this.options.domAttributes)==null?void 0:o.blockContent)||{},...t})}}}),Ao=E.Node.create({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 t=e.parentElement;return t===null?!1:t.tagName==="TD"||t.tagName==="TH"?{}:!1},node:"tableParagraph"}]},renderHTML({HTMLAttributes:e}){return["p",e,0]}}),Io=E.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",E.mergeAttributes(this.options.HTMLAttributes,e),0]}});function hn(e,t){const o=x.DOMParser.fromSchema(t).parse(e,{topNode:t.nodes.blockGroup.create()}),r=[];return o.content.descendants(s=>{if(s.isInline)return r.push(s),!1}),x.Fragment.fromArray(r)}const gn=()=>rt({node:No,type:"table",content:"table"},fn,[N({key:"table-extensions",tiptapExtensions:[To,Ao,Mo,Lo,Io]}),N({key:"table-keyboard-delete",keyboardShortcuts:{Backspace:({editor:e})=>{if(!(e.prosemirrorState.selection instanceof I.CellSelection))return!1;const t=e.getTextCursorPosition().block,n=t.content;let o=0;for(const s of n.rows)for(const i of s.cells){if("type"in i&&i.content.length>0||!("type"in i)&&i.length>0)return!1;o++}let r=0;return e.prosemirrorState.selection.forEachCell(()=>{r++}),r<o?!1:(e.transact(()=>{(e.getPrevBlock(t)||e.getNextBlock(t))&&e.setTextCursorPosition(t),e.removeBlocks([t])}),!0)}}})]),Ye=e=>{const t=e.src||void 0,n=e.width||void 0;return{url:t,previewWidth:n}},mn='<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>',bn=e=>({type:"video",propSchema:{textAlignment:C.textAlignment,backgroundColor:C.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0},previewWidth:{default:void 0,type:"number"}},content:"none"}),kn=e=>t=>{if(t.tagName==="VIDEO"){if(t.closest("figure"))return;const{backgroundColor:n}=T(t);return{...Ye(t),backgroundColor:n}}if(t.tagName==="FIGURE"){const n=he(t,"video");if(!n)return;const{targetElement:o,caption:r}=n,{backgroundColor:s}=T(t);return{...Ye(o),backgroundColor:s,caption:r}}},Cn=M(bn,e=>({meta:{fileBlockAccept:["video/*"]},parse:kn(),render(t,n){const o=document.createElement("div");o.innerHTML=e.icon??mn;const r=document.createElement("div");r.className="bn-visual-media-wrapper";const s=document.createElement("video");return s.className="bn-visual-media",n.resolveFileUrl?n.resolveFileUrl(t.props.url).then(i=>{s.src=i}):s.src=t.props.url,s.controls=!0,s.contentEditable="false",s.draggable=!1,s.width=t.props.previewWidth,r.appendChild(s),jt(t,n,{dom:r},r,o.firstElementChild)},toExternalHTML(t){if(!t.props.url){const o=document.createElement("p");return o.textContent="Add video",{dom:o}}let n;return t.props.showPreview?(n=document.createElement("video"),n.src=t.props.url,t.props.previewWidth&&(n.width=t.props.previewWidth)):(n=document.createElement("a"),n.href=t.props.url,n.textContent=t.props.name||t.props.url),t.props.caption?t.props.showPreview?De(n,t.props.caption):ge(n,t.props.caption):{dom:n}},runsBefore:["file"]})),Po=async e=>{const t=new FormData;return t.append("file",e),(await(await fetch("https://tmpfiles.org/api/v1/upload",{method:"POST",body:t})).json()).data.url.replace("tmpfiles.org/","tmpfiles.org/dl/")};function S(e,t,n){if(!(t in e.schema.blockSpecs))return!1;if(!n)return!0;for(const[o,r]of Object.entries(n)){if(!(o in e.schema.blockSpecs[t].config.propSchema))return!1;if(typeof r=="string"){if(e.schema.blockSpecs[t].config.propSchema[o].default&&typeof e.schema.blockSpecs[t].config.propSchema[o].default!==r||e.schema.blockSpecs[t].config.propSchema[o].type&&e.schema.blockSpecs[t].config.propSchema[o].type!==r)return!1}else{if(e.schema.blockSpecs[t].config.propSchema[o].default!==r.default||e.schema.blockSpecs[t].config.propSchema[o].default===void 0&&r.default===void 0&&e.schema.blockSpecs[t].config.propSchema[o].type!==r.type||typeof e.schema.blockSpecs[t].config.propSchema[o].values!=typeof r.values)return!1;if(typeof e.schema.blockSpecs[t].config.propSchema[o].values=="object"&&typeof r.values=="object"){if(e.schema.blockSpecs[t].config.propSchema[o].values.length!==r.values.length)return!1;for(let s=0;s<e.schema.blockSpecs[t].config.propSchema[o].values.length;s++)if(e.schema.blockSpecs[t].config.propSchema[o].values[s]!==r.values[s])return!1}}}return!0}function Oo(e,t,n,o){return S(t,n,o)&&e.type===n}function Do(e){return e instanceof I.CellSelection}function Ho(e){let t=e.getTextCursorPosition().block,n=e.schema.blockSchema[t.type].content;for(;n==="none";){if(t=e.getTextCursorPosition().nextBlock,t===void 0)return;n=e.schema.blockSchema[t.type].content,e.setTextCursorPosition(t,"end")}}function w(e,t){const n=e.getTextCursorPosition().block;if(n.content===void 0)throw new Error("Slash Menu open in a block that doesn't contain content.");let o;return Array.isArray(n.content)&&(n.content.length===1&&O(n.content[0])&&n.content[0].type==="text"&&n.content[0].text==="/"||n.content.length===0)?(o=e.updateBlock(n,t),e.setTextCursorPosition(o)):(o=e.insertBlocks([t],n,"after")[0],e.setTextCursorPosition(e.getTextCursorPosition().nextBlock)),Ho(e),o}function _o(e){const t=[];return S(e,"heading",{level:"number"})&&t.push({onItemClick:()=>{w(e,{type:"heading",props:{level:1}})},badge:A("Mod-Alt-1"),key:"heading",...e.dictionary.slash_menu.heading},{onItemClick:()=>{w(e,{type:"heading",props:{level:2}})},badge:A("Mod-Alt-2"),key:"heading_2",...e.dictionary.slash_menu.heading_2},{onItemClick:()=>{w(e,{type:"heading",props:{level:3}})},badge:A("Mod-Alt-3"),key:"heading_3",...e.dictionary.slash_menu.heading_3}),S(e,"quote")&&t.push({onItemClick:()=>{w(e,{type:"quote"})},key:"quote",...e.dictionary.slash_menu.quote}),S(e,"toggleListItem")&&t.push({onItemClick:()=>{w(e,{type:"toggleListItem"})},badge:A("Mod-Shift-6"),key:"toggle_list",...e.dictionary.slash_menu.toggle_list}),S(e,"numberedListItem")&&t.push({onItemClick:()=>{w(e,{type:"numberedListItem"})},badge:A("Mod-Shift-7"),key:"numbered_list",...e.dictionary.slash_menu.numbered_list}),S(e,"bulletListItem")&&t.push({onItemClick:()=>{w(e,{type:"bulletListItem"})},badge:A("Mod-Shift-8"),key:"bullet_list",...e.dictionary.slash_menu.bullet_list}),S(e,"checkListItem")&&t.push({onItemClick:()=>{w(e,{type:"checkListItem"})},badge:A("Mod-Shift-9"),key:"check_list",...e.dictionary.slash_menu.check_list}),S(e,"paragraph")&&t.push({onItemClick:()=>{w(e,{type:"paragraph"})},badge:A("Mod-Alt-0"),key:"paragraph",...e.dictionary.slash_menu.paragraph}),S(e,"codeBlock")&&t.push({onItemClick:()=>{w(e,{type:"codeBlock"})},badge:A("Mod-Alt-c"),key:"code_block",...e.dictionary.slash_menu.code_block}),S(e,"divider")&&t.push({onItemClick:()=>{w(e,{type:"divider"})},key:"divider",...e.dictionary.slash_menu.divider}),S(e,"table")&&t.push({onItemClick:()=>{w(e,{type:"table",content:{type:"tableContent",rows:[{cells:["","",""]},{cells:["","",""]}]}})},badge:void 0,key:"table",...e.dictionary.slash_menu.table}),S(e,"image",{url:"string"})&&t.push({onItemClick:()=>{const n=w(e,{type:"image"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:n}))},key:"image",...e.dictionary.slash_menu.image}),S(e,"video",{url:"string"})&&t.push({onItemClick:()=>{const n=w(e,{type:"video"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:n}))},key:"video",...e.dictionary.slash_menu.video}),S(e,"audio",{url:"string"})&&t.push({onItemClick:()=>{const n=w(e,{type:"audio"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:n}))},key:"audio",...e.dictionary.slash_menu.audio}),S(e,"file",{url:"string"})&&t.push({onItemClick:()=>{const n=w(e,{type:"file"});e.transact(o=>o.setMeta(e.filePanel.plugins[0],{block:n}))},key:"file",...e.dictionary.slash_menu.file}),S(e,"heading",{level:"number",isToggleable:"boolean"})&&t.push({onItemClick:()=>{w(e,{type:"heading",props:{level:1,isToggleable:!0}})},key:"toggle_heading",...e.dictionary.slash_menu.toggle_heading},{onItemClick:()=>{w(e,{type:"heading",props:{level:2,isToggleable:!0}})},key:"toggle_heading_2",...e.dictionary.slash_menu.toggle_heading_2},{onItemClick:()=>{w(e,{type:"heading",props:{level:3,isToggleable:!0}})},key:"toggle_heading_3",...e.dictionary.slash_menu.toggle_heading_3}),S(e,"heading",{level:"number"})&&(e.schema.blockSchema.heading.propSchema.level.values||[]).filter(n=>n>3).forEach(n=>{t.push({onItemClick:()=>{w(e,{type:"heading",props:{level:n}})},key:`heading_${n}`,...e.dictionary.slash_menu[`heading_${n}`]})}),t.push({onItemClick:()=>{e.openSuggestionMenu(":",{deleteTriggerCharacter:!0,ignoreQueryLength:!0})},key:"emoji",...e.dictionary.slash_menu.emoji}),t}function Ro(e,t){return e.filter(({title:n,aliases:o})=>n.toLowerCase().includes(t.toLowerCase())||o&&o.filter(r=>r.toLowerCase().includes(t.toLowerCase())).length!==0)}function yn(e){return"pageBreak"in e.schema.blockSchema}function Vo(e){const t=[];return yn(e)&&t.push({...e.dictionary.slash_menu.page_break,onItemClick:()=>{w(e,{type:"pageBreak"})},key:"page_break"}),t}const wn={audio:Lt(),bulletListItem:Yt(),checkListItem:en(),codeBlock:Pt(),divider:Dt(),file:Rt(),heading:$t(),image:Xt(),numberedListItem:on(),paragraph:un(),quote:pn(),table:gn(),toggleListItem:sn(),video:Cn()},Fo=Ae({type:"textColor",propSchema:"string"},{render:()=>{const e=document.createElement("span");return{dom:e,contentDOM:e}},toExternalHTML:e=>{const t=document.createElement("span");return e!==C.textColor.default&&(t.style.color=e in P?P[e].text:e),{dom:t,contentDOM:t}},parse:e=>{if(e.tagName==="SPAN"&&e.style.color)return e.style.color}}),Wo=Ae({type:"backgroundColor",propSchema:"string"},{render:()=>{const e=document.createElement("span");return{dom:e,contentDOM:e}},toExternalHTML:e=>{const t=document.createElement("span");return e!==C.backgroundColor.default&&(t.style.backgroundColor=e in P?P[e].background:e),{dom:t,contentDOM:t}},parse:e=>{if(e.tagName==="SPAN"&&e.style.backgroundColor)return e.style.backgroundColor}}),Fe={bold:F(Pn.default,"boolean"),italic:F(Dn.default,"boolean"),underline:F(_n.default,"boolean"),strike:F(Hn.default,"boolean"),code:F(On.default,"boolean"),textColor:Fo,backgroundColor:Wo},$o=Ne(Fe),We={text:{config:"text",implementation:{}},link:{config:"link",implementation:{}}},jo=Me(We);class $e extends mt{static create(t){return new $e({blockSpecs:(t==null?void 0:t.blockSpecs)??wn,inlineContentSpecs:(t==null?void 0:t.inlineContentSpecs)??We,styleSpecs:(t==null?void 0:t.styleSpecs)??Fe})}}exports.BlockNoteExtension=At;exports.BlockNoteSchema=$e;exports.COLORS_DARK_MODE_DEFAULT=ho;exports.COLORS_DEFAULT=P;exports.CustomBlockNoteSchema=mt;exports.EMPTY_CELL_HEIGHT=xo;exports.EMPTY_CELL_WIDTH=Ve;exports.EventEmitter=Nt;exports.FILE_AUDIO_ICON_SVG=Et;exports.FILE_IMAGE_ICON_SVG=Ut;exports.FILE_VIDEO_ICON_SVG=mn;exports.UniqueID=Be;exports.UnreachableCaseError=z;exports.addDefaultPropsExternalHTML=H;exports.addInlineContentAttributes=Gn;exports.addInlineContentKeyboardShortcuts=Zn;exports.addNodeAndExtensionsToSpec=at;exports.addRowsOrColumns=ro;exports.addStyleAttributes=K;exports.applyNonSelectableBlockFix=st;exports.areInSameColumn=ao;exports.assertEmpty=Fn;exports.audioParse=xt;exports.audioRender=Tt;exports.audioToExternalHTML=Mt;exports.blockHasType=Oo;exports.blockToNode=te;exports.camelToDataKebab=Y;exports.canColumnBeDraggedInto=io;exports.canRowBeDraggedInto=so;exports.captureCellAnchor=St;exports.checkPageBreakBlocksInSchema=yn;exports.contentNodeToInlineContent=pe;exports.contentNodeToTableContent=dt;exports.createAudioBlockConfig=Bt;exports.createAudioBlockSpec=Lt;exports.createBlockConfig=Un;exports.createBlockNoteExtension=N;exports.createBlockSpec=M;exports.createBlockSpecFromTiptapNode=rt;exports.createBulletListItemBlockConfig=Kt;exports.createBulletListItemBlockSpec=Yt;exports.createCheckListItemBlockSpec=en;exports.createCheckListItemConfig=Qt;exports.createCodeBlockConfig=It;exports.createCodeBlockSpec=Pt;exports.createDefaultBlockDOMOutputSpec=et;exports.createDividerBlockConfig=Ot;exports.createDividerBlockSpec=Dt;exports.createFileBlockConfig=Ht;exports.createFileBlockSpec=Rt;exports.createHeadingBlockConfig=Wt;exports.createHeadingBlockSpec=$t;exports.createImageBlockConfig=qt;exports.createImageBlockSpec=Xt;exports.createInlineContentSpecFromTipTapNode=Xn;exports.createInternalInlineContentSpec=ft;exports.createInternalStyleSpec=Le;exports.createNumberedListItemBlockConfig=nn;exports.createNumberedListItemBlockSpec=on;exports.createPageBreakBlockConfig=an;exports.createPageBreakBlockSpec=cn;exports.createParagraphBlockConfig=ln;exports.createParagraphBlockSpec=un;exports.createQuoteBlockConfig=dn;exports.createQuoteBlockSpec=pn;exports.createStyleSpec=Ae;exports.createStyleSpecFromTipTapMark=F;exports.createTableBlockSpec=gn;exports.createToggleListItemBlockConfig=rn;exports.createToggleListItemBlockSpec=sn;exports.createToggleWrapper=_e;exports.createVideoBlockConfig=bn;exports.createVideoBlockSpec=Cn;exports.cropEmptyRowsOrColumns=oo;exports.defaultBlockSpecs=wn;exports.defaultBlockToHTML=we;exports.defaultInlineContentSchema=jo;exports.defaultInlineContentSpecs=We;exports.defaultProps=C;exports.defaultStyleSchema=$o;exports.defaultStyleSpecs=Fe;exports.defaultToggledState=Vt;exports.docToBlocks=qn;exports.editorHasBlockWithType=S;exports.fileParse=_t;exports.filenameFromURL=$n;exports.filterSuggestionItems=Ro;exports.formatKeyboardShortcut=A;exports.getBackgroundColorAttribute=go;exports.getBlockCache=de;exports.getBlockFromPos=ot;exports.getBlockInfo=q;exports.getBlockInfoFromResolvedPos=ct;exports.getBlockInfoFromSelection=Te;exports.getBlockInfoFromTransaction=lt;exports.getBlockInfoWithManualOffset=ae;exports.getBlockNoteSchema=ce;exports.getBlockSchema=le;exports.getCellsAtColumnHandle=Ct;exports.getCellsAtRowHandle=kt;exports.getColspan=j;exports.getDefaultSlashMenuItems=_o;exports.getDimensionsOfTable=Ie;exports.getInlineContentSchema=ue;exports.getInlineContentSchemaFromSpecs=Me;exports.getLanguageId=He;exports.getNearestBlockPos=ie;exports.getNodeById=wt;exports.getPageBreakSlashMenuItems=Vo;exports.getParseRules=it;exports.getPmSchema=G;exports.getRowspan=oe;exports.getStyleParseRules=gt;exports.getStyleSchema=V;exports.getStyleSchemaFromSpecs=Ne;exports.getTextAlignmentAttribute=bo;exports.getTextColorAttribute=mo;exports.imageParse=zt;exports.imageRender=Gt;exports.imageToExternalHTML=Zt;exports.inlineContentToNodes=R;exports.insertOrUpdateBlock=w;exports.isAppleOS=Qe;exports.isLinkInlineContent=ye;exports.isNodeBlock=vt;exports.isPartialLinkInlineContent=xe;exports.isPartialTableCell=$;exports.isSafari=Wn;exports.isStyledTextInlineContent=O;exports.isTableCell=se;exports.isTableCellSelection=Do;exports.isVideoUrl=jn;exports.mapTableCell=ne;exports.mergeCSSClasses=U;exports.mergeParagraphs=tt;exports.moveColumn=to;exports.moveRow=no;exports.nodeToBlock=Z;exports.nodeToCustomInlineContent=pt;exports.parseAudioElement=Ee;exports.parseDefaultProps=T;exports.propsToAttributes=nt;exports.prosemirrorSliceToSlicedBlocks=zn;exports.splitBlockCommand=vo;exports.stylePropsToAttributes=ht;exports.tableContentToNodes=Pe;exports.tablePropSchema=fn;exports.updateBlock=po;exports.updateBlockCommand=lo;exports.updateBlockTr=fe;exports.uploadToTmpFilesDotOrg_DEV_ONLY=Po;exports.videoParse=kn;exports.withPageBreak=Eo;exports.wrapInBlockStructure=re;
11
+ //# sourceMappingURL=BlockNoteSchema-COA0fsXW.cjs.map