@blocknote/core
Version:
A "Notion-style" block-based extensible text editor built on top of Prosemirror and Tiptap.
5 lines (4 loc) • 66.6 kB
JavaScript
"use strict";var Nt=Object.defineProperty;var It=(e,t,n)=>t in e?Nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var P=(e,t,n)=>It(e,typeof t!="symbol"?t+"":t,n);const T=require("prosemirror-tables"),S=require("@tiptap/core"),z=require("prosemirror-state"),$=require("prosemirror-view"),ye=require("prosemirror-transform"),j=require("y-prosemirror"),y=require("./BlockNoteExtension-BWw0r8Gy.cjs"),m=require("./blockToNode-CumVjgem.cjs"),Ht=require("@tiptap/extension-bold"),Dt=require("@tiptap/extension-code"),_t=require("@tiptap/extension-italic"),Ot=require("@tiptap/extension-strike"),Vt=require("@tiptap/extension-underline"),F=require("@tiptap/pm/model"),Rt=require("prosemirror-highlight"),Ft=require("prosemirror-highlight/shiki"),N=require("prosemirror-model"),fe=require("@tiptap/pm/state"),ee=require("@tiptap/pm/view"),q=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},Wt=q(Ht),qt=q(Dt),Ut=q(_t),$t=q(Ot),jt=q(Vt),ve=()=>typeof navigator<"u"&&(/Mac/.test(navigator.platform)||/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent));function B(e,t="Ctrl"){return ve()?e.replace("Mod","⌘"):e.replace("Mod",t)}function V(...e){return[...new Set(e.filter(t=>t).join(" ").split(" "))].join(" ")}const Gt=()=>/^((?!chrome|android).)*safari/i.test(navigator.userAgent);function Se(e,t,n,o){const r=document.createElement("div");r.className=V("bn-block-content",n.class),r.setAttribute("data-content-type",e);for(const[i,s]of Object.entries(n))i!=="class"&&r.setAttribute(i,s);const a=document.createElement(t);a.className=V("bn-inline-content",o.class);for(const[i,s]of Object.entries(o))i!=="class"&&a.setAttribute(i,s);return r.appendChild(a),{dom:r,contentDOM:a}}const te=(e,t)=>{let n=m.blockToNode(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 Ee(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 a=n[r];o.innerHTML+=t+a.innerHTML,a.remove()}}}function W(e){return"data-"+e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function Zt(e){const t=e.split("/");return!t.length||t[t.length-1]===""?e:t[t.length-1]}function zt(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 xe(e){const t={};return Object.entries(e).forEach(([n,o])=>{t[n]={default:o.default,keepOnSplit:!0,parseHTML:r=>{const a=r.getAttribute(W(n));if(a===null)return null;if(o.default===void 0&&o.type==="boolean"||o.default!==void 0&&typeof o.default=="boolean")return a==="true"?!0:a==="false"?!1:null;if(o.default===void 0&&o.type==="number"||o.default!==void 0&&typeof o.default=="number"){const i=parseFloat(a);return!Number.isNaN(i)&&Number.isFinite(i)?i:null}return a},renderHTML:r=>r[n]!==o.default?{[W(n)]:r[n]}:{}}}),t}function Me(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 s=t.getBlock(i);if(s.type!==o)throw new Error("Block type does not match");return s}function Z(e,t,n,o,r=!1,a){const i=document.createElement("div");if(a!==void 0)for(const[s,c]of Object.entries(a))s!=="class"&&i.setAttribute(s,c);i.className=V("bn-block-content",(a==null?void 0:a.class)||""),i.setAttribute("data-content-type",t);for(const[s,c]of Object.entries(n)){const u=o[s].default;c!==u&&i.setAttribute(W(s),c)}return r&&i.setAttribute("data-file-block",""),i.appendChild(e.dom),e.contentDOM&&(e.contentDOM.className=V("bn-inline-content",e.contentDOM.className)),{...e,dom:i}}function we(e,t,n){return{config:{type:e.type,content:e.content,propSchema:t},implementation:{node:e.node,render:te,toExternalHTML:te},extensions:n}}function Le(e,t){e.stopEvent=n=>(n.type==="mousedown"&&setTimeout(()=>{t.view.dom.blur()},10),!0)}function Be(e,t){const n=[{tag:"[data-content-type="+e.type+"]",contentElement:".bn-inline-content"}];return t.parse&&n.push({tag:"*",getAttrs(o){var a;if(typeof o=="string")return!1;const r=(a=t.parse)==null?void 0:a.call(t,o);return r===void 0?!1:r},preserveWhitespace:!0,getContent:e.content==="inline"||e.content==="none"?(o,r)=>{var a;if(t.parseContent)return t.parseContent({el:o,schema:r});if(e.content==="inline"){const s=o.cloneNode(!0);return Ee(s,(a=t.meta)!=null&&a.code?`
`:"<br>"),F.DOMParser.fromSchema(r).parse(s,{topNode:r.nodes.paragraph.create(),preserveWhitespace:!0}).content}return F.Fragment.empty}:void 0}),n}function Kt(e,t,n,o){var a,i,s,c;const r=t.node||S.Node.create({name:e.type,content:e.content==="inline"?"inline*":e.content==="none"?"":e.content,group:"blockContent",selectable:((a=t.meta)==null?void 0:a.selectable)??!0,isolating:((i=t.meta)==null?void 0:i.isolating)??!0,code:((s=t.meta)==null?void 0:s.code)??!1,defining:((c=t.meta)==null?void 0:c.defining)??!0,priority:o,addAttributes(){return xe(e.propSchema)},parseHTML(){return Be(e,t)},renderHTML({HTMLAttributes:l}){var d;const u=document.createElement("div");return Z({dom:u,contentDOM:e.content==="inline"?u:void 0},e.type,{},e.propSchema,((d=t.meta)==null?void 0:d.fileBlockAccept)!==void 0,l)},addNodeView(){return l=>{var f,x;const u=this.options.editor,d=Me(l.getPos,u,this.editor,e.type),p=((f=this.options.domAttributes)==null?void 0:f.blockContent)||{},h=t.render.call({blockContentDOMAttributes:p,props:l,renderType:"nodeView"},d,u);return((x=t.meta)==null?void 0:x.selectable)===!1&&Le(h,this.editor),h}}});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,u){var p;const d=((p=r.options.domAttributes)==null?void 0:p.blockContent)||{};return t.render.call({blockContentDOMAttributes:d,props:void 0,renderType:"dom"},l,u)},toExternalHTML:(l,u)=>{var p,h;const d=((p=r.options.domAttributes)==null?void 0:p.blockContent)||{};return((h=t.toExternalHTML)==null?void 0:h.call({blockContentDOMAttributes:d},l,u))??t.render.call({blockContentDOMAttributes:d,renderType:"dom",props:void 0},l,u)}},extensions:n}}function Xt(e){return e}function E(e,t,n){return(o={})=>{const r=typeof e=="function"?e(o):e,a=typeof t=="function"?t(o):t,i=n?typeof n=="function"?n(o):n:void 0;return{config:r,implementation:{...a,toExternalHTML(s,c){var u,d;const l=(u=a.toExternalHTML)==null?void 0:u.call({blockContentDOMAttributes:this.blockContentDOMAttributes},s,c);if(l!==void 0)return Z(l,s.type,s.props,r.propSchema,((d=a.meta)==null?void 0:d.fileBlockAccept)!==void 0)},render(s,c){var d;const l=a.render.call({blockContentDOMAttributes:this.blockContentDOMAttributes,renderType:this.renderType,props:this.props},s,c);return Z(l,s.type,s.props,r.propSchema,((d=a.meta)==null?void 0:d.fileBlockAccept)!==void 0,this.blockContentDOMAttributes)}},extensions:i}}}function Qt(e,t,n,o){return e.dom.setAttribute("data-inline-content-type",t),Object.entries(n).filter(([r,a])=>{const i=o[r];return a!==i.default}).map(([r,a])=>[W(r),a]).forEach(([r,a])=>e.dom.setAttribute(r,a)),e.contentDOM&&e.contentDOM.setAttribute("data-editable",""),e}function Yt(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 Te(e,t){return{config:e,implementation:t}}function Jt(e,t,n){return Te({type:e.name,propSchema:t,content:e.config.content==="inline*"?"styled":"none"},{...n,node:e})}function Ae(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,n.config]))}function Pe(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 R(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 oe(e,t){return{config:e,implementation:t}}function _(e,t){return oe({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 a=o.pmSchema.mark(e.name,{stringValue:n}),i=F.DOMSerializer.renderSpec(document,r(a,!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 a=o.pmSchema.mark(e.name,{stringValue:n}),i=F.DOMSerializer.renderSpec(document,r(a,!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 Ie(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:"*",consuming:!1,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 re(e,t){const n=S.Mark.create({name:e.type,addAttributes(){return Pe(e.propSchema)},parseHTML(){return Ie(e,t.parse)},renderHTML({mark:o}){const r=(t.toExternalHTML||t.render)(o.attrs.stringValue);return R(r,e.type,o.attrs.stringValue,e.propSchema)},addMarkView(){return({mark:o})=>{const r=t.render(o.attrs.stringValue);return R(r,e.type,o.attrs.stringValue,e.propSchema)}}});return oe(e,{...t,mark:n,render:o=>{const r=t.render(o);return R(r,e.type,o,e.propSchema)},toExternalHTML:o=>{const r=(t.toExternalHTML||t.render)(o);return R(r,e.type,o,e.propSchema)}})}function He(e,t){let n,o;if(t.firstChild.descendants((r,a)=>n?!1:!De(r)||r.attrs.id!==e?!0:(n=r,o=a+1,!1)),!(n===void 0||o===void 0))return{node:n,posBeforeNode:o}}function De(e){return e.type.isInGroup("bnBlock")}const en=(e,t)=>({tr:n,dispatch:o})=>(o&&K(n,e,t),!0);function K(e,t,n,o,r){const a=m.getBlockInfoFromResolvedPos(e.doc.resolve(t));let i=null;a.blockNoteType==="table"&&(i=_e(e));const s=m.getPmSchema(e);if(o!==void 0&&r!==void 0&&o>r)throw new Error("Invalid replaceFromPos or replaceToPos");const c=s.nodes[a.blockNoteType],l=s.nodes[n.type||a.blockNoteType],u=l.isInGroup("bnBlock")?l:s.nodes.blockContainer;if(a.isBlockContainer&&l.isInGroup("blockContent")){const d=o!==void 0&&o>a.blockContent.beforePos&&o<a.blockContent.afterPos?o-a.blockContent.beforePos-1:void 0,p=r!==void 0&&r>a.blockContent.beforePos&&r<a.blockContent.afterPos?r-a.blockContent.beforePos-1:void 0;ge(n,e,a),tn(n,e,c,l,a,d,p)}else if(!a.isBlockContainer&&l.isInGroup("bnBlock"))ge(n,e,a);else{const d=m.nodeToBlock(a.bnBlock.node,s);e.replaceWith(a.bnBlock.beforePos,a.bnBlock.afterPos,m.blockToNode({children:d.children,...n},s));return}e.setNodeMarkup(a.bnBlock.beforePos,u,{...a.bnBlock.node.attrs,...n.props}),i&&on(e,a,i)}function tn(e,t,n,o,r,a,i){const s=m.getPmSchema(t);let c="keep";if(e.content)if(typeof e.content=="string")c=m.inlineContentToNodes([e.content],s,o.name);else if(Array.isArray(e.content))c=m.inlineContentToNodes(e.content,s,o.name);else if(e.content.type==="tableContent")c=m.tableContentToNodes(e.content,s);else throw new m.UnreachableCaseError(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(a!==void 0||i!==void 0){t.setNodeMarkup(r.blockContent.beforePos,o,{...r.blockContent.node.attrs,...e.props});const l=r.blockContent.beforePos+1+(a??0),u=r.blockContent.beforePos+1+(i??r.blockContent.node.content.size),d=t.doc.resolve(r.blockContent.beforePos).depth,p=t.doc.resolve(l).depth,h=t.doc.resolve(u).depth;t.replace(l,u,new N.Slice(N.Fragment.from(c),p-d-1,h-d-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=m.getPmSchema(t);if(e.children!==void 0&&e.children.length>0){const r=e.children.map(a=>m.blockToNode(a,o));if(n.childContainer)t.step(new ye.ReplaceStep(n.childContainer.beforePos+1,n.childContainer.afterPos-1,new N.Slice(N.Fragment.from(r),0,0)));else{if(!n.isBlockContainer)throw new Error("impossible");t.insert(n.blockContent.afterPos,o.nodes.blockGroup.createChecked({},r))}}}function nn(e,t,n,o,r){const a=typeof t=="string"?t:t.id,i=He(a,e.doc);if(!i)throw new Error(`Block with ID ${a} not found`);K(e,i.posBeforeNode,n,o,r);const s=e.doc.resolve(i.posBeforeNode+1).node(),c=m.getPmSchema(e);return m.nodeToBlock(s,c)}function _e(e){const t="selection"in e?e.selection:null;if(!(t instanceof z.TextSelection))return null;const n=e.doc.resolve(t.head);let o=-1,r=-1;for(let w=n.depth;w>=0;w--){const M=n.node(w).type.name;if(o<0&&(M==="tableCell"||M==="tableHeader")&&(o=w),M==="table"){r=w;break}}if(o<0||r<0)return null;const a=n.before(o),i=n.before(r),s=e.doc.nodeAt(i);if(!s||s.type.name!=="table")return null;const c=T.TableMap.get(s),l=a-(i+1),u=c.map.indexOf(l);if(u<0)return null;const d=Math.floor(u/c.width),p=u%c.width,f=a+1+1,x=Math.max(0,t.head-f);return{row:d,col:p,offset:x}}function on(e,t,n){var w;if(t.blockNoteType!=="table")return!1;let o=-1;if(t.isBlockContainer)o=e.mapping.map(t.blockContent.beforePos);else{const M=e.mapping.map(t.bnBlock.beforePos),D=M+(((w=e.doc.nodeAt(M))==null?void 0:w.nodeSize)||0);e.doc.nodesBetween(M,D,(b,L)=>b.type.name==="table"?(o=L,!1):!0)}const r=o>=0?e.doc.nodeAt(o):null;if(!r||r.type.name!=="table")return!1;const a=T.TableMap.get(r),i=Math.max(0,Math.min(n.row,a.height-1)),s=Math.max(0,Math.min(n.col,a.width-1)),c=i*a.width+s,l=a.map[c];if(l==null)return!1;const d=o+1+l+1,p=e.doc.nodeAt(d),h=d+1,f=p?p.content.size:0,x=h+Math.max(0,Math.min(n.offset,f));return"selection"in e&&e.setSelection(z.TextSelection.create(e.doc,x)),!0}const A={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"}},rn={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"}},g={backgroundColor:{default:"default"},textColor:{default:"default"},textAlignment:{default:"left",values:["left","center","right","justify"]}},v=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=g.textAlignment.values.includes(e.style.textAlign)?e.style.textAlign:void 0,t},I=(e,t)=>{e.backgroundColor&&e.backgroundColor!==g.backgroundColor.default&&(t.style.backgroundColor=e.backgroundColor in A?A[e.backgroundColor].background:e.backgroundColor),e.textColor&&e.textColor!==g.textColor.default&&(t.style.color=e.textColor in A?A[e.textColor].text:e.textColor),e.textAlignment&&e.textAlignment!==g.textAlignment.default&&(t.style.textAlign=e.textAlignment)},an=(e="backgroundColor")=>({default:g.backgroundColor.default,parseHTML:t=>t.hasAttribute("data-background-color")?t.getAttribute("data-background-color"):t.style.backgroundColor?t.style.backgroundColor:g.backgroundColor.default,renderHTML:t=>t[e]===g.backgroundColor.default?{}:{"data-background-color":t[e]}}),sn=(e="textColor")=>({default:g.textColor.default,parseHTML:t=>t.hasAttribute("data-text-color")?t.getAttribute("data-text-color"):t.style.color?t.style.color:g.textColor.default,renderHTML:t=>t[e]===g.textColor.default?{}:{"data-text-color":t[e]}}),cn=(e="textAlignment")=>({default:g.textAlignment.default,parseHTML:t=>t.hasAttribute("data-text-alignment")?t.getAttribute("data-text-alignment"):t.style.textAlign?t.style.textAlign:g.textAlignment.default,renderHTML:t=>t[e]===g.textAlignment.default?{}:{"data-text-alignment":t[e]}}),X=(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}},O=y.createExtension(({editor:e})=>{const t=y.createStore(void 0);function n(){t.setState(void 0)}return{key:"filePanel",store:t,mount({signal:o}){const r=e.onChange(n,!1),a=e.onSelectionChange(n,!1);o.addEventListener("abort",()=>{r(),a()})},closeMenu:n,showMenu(o){t.setState(o)}}}),ln=(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 a=document.createElement("p");a.className="bn-add-file-button-text",a.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(a);const i=c=>{c.preventDefault(),c.stopPropagation()},s=()=>{var c;t.isEditable&&((c=t.getExtension(O))==null||c.showMenu(e.id))};return o.addEventListener("mousedown",i,!0),o.addEventListener("click",s,!0),{dom:o,destroy:()=>{o.removeEventListener("mousedown",i,!0),o.removeEventListener("click",s,!0)}}},dn='<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>',un=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=dn,t.appendChild(n);const o=document.createElement("p");return o.className="bn-file-name",o.textContent=e.props.name,t.appendChild(o),{dom:t}},ae=(e,t,n,o)=>{const r=document.createElement("div");if(r.className="bn-file-block-content-wrapper",e.props.url===""){const i=ln(e,t,o);r.appendChild(i.dom);const s=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:()=>{s(),i.destroy()}}}const a={dom:r};if(e.props.showPreview===!1||!n){const i=un(e);r.appendChild(i.dom),a.destroy=()=>{var s;(s=i.destroy)==null||s.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 a},ie=(e,t)=>{const n=document.createElement("figure"),o=document.createElement("figcaption");return o.textContent=t,n.appendChild(e),n.appendChild(o),{dom:n}},Q=(e,t)=>{const n=document.createElement("div"),o=document.createElement("p");return o.textContent=t,n.appendChild(e),n.appendChild(o),{dom:n}},ne=e=>({url:e.src||void 0}),Oe='<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>',Ve=e=>({type:"audio",propSchema:{backgroundColor:g.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0}},content:"none"}),Re=(e={})=>t=>{if(t.tagName==="AUDIO"){if(t.closest("figure"))return;const{backgroundColor:n}=v(t);return{...ne(t),backgroundColor:n}}if(t.tagName==="FIGURE"){const n=X(t,"audio");if(!n)return;const{targetElement:o,caption:r}=n,{backgroundColor:a}=v(t);return{...ne(o),backgroundColor:a,caption:r}}},Fe=(e={})=>(t,n)=>{const o=document.createElement("div");o.innerHTML=e.icon??Oe;const r=document.createElement("audio");return r.className="bn-audio",n.resolveFileUrl?n.resolveFileUrl(t.props.url).then(a=>{r.src=a}):r.src=t.props.url,r.controls=!0,r.contentEditable="false",r.draggable=!1,ae(t,n,{dom:r},o.firstElementChild)},We=(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?ie(o,t.props.caption):Q(o,t.props.caption):{dom:o}},qe=E(Ve,e=>({meta:{fileBlockAccept:["audio/*"]},parse:Re(e),render:Fe(e),toExternalHTML:We(e),runsBefore:["file"]})),he=Symbol.for("blocknote.shikiParser"),J=Symbol.for("blocknote.shikiHighlighterPromise");function pn(e){const t=globalThis;let n,o,r=!1;const a=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[J]=t[J]||e.createHighlighter(),t[J].then(c=>{n=c});const s=se(e,i.language);return!s||s==="text"||s==="none"||s==="plaintext"||s==="txt"?[]:n.getLoadedLanguages().includes(s)?(o||(o=t[he]||Ft.createParser(n),t[he]=o),o(i)):n.loadLanguage(s)};return Rt.createHighlightPlugin({parser:a,languageExtractor:i=>i.attrs.language,nodeTypes:["codeBlock"]})}const Ue=({defaultLanguage:e="text"})=>({type:"codeBlock",propSchema:{language:{default:e}},content:"inline"}),$e=E(Ue,e=>({meta:{code:!0,defining:!0,isolating:!1},parse:t=>{var r,a;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")||((a=n.className.split(" ").find(i=>i.includes("language-")))==null?void 0:a.replace("language-",""))}},parseContent:({el:t,schema:n})=>{const o=F.DOMParser.fromSchema(n),r=t.firstElementChild;return o.parse(r,{preserveWhitespace:"full",topNode:n.nodes.codeBlock.create()}).content},render(t,n){const o=document.createDocumentFragment(),r=document.createElement("pre"),a=document.createElement("code");r.appendChild(a);let i;if(e.supportedLanguages){const s=document.createElement("select");Object.entries(e.supportedLanguages??{}).forEach(([u,{name:d}])=>{const p=document.createElement("option");p.value=u,p.text=d,s.appendChild(p)}),s.value=t.props.language||e.defaultLanguage||"text";const c=u=>{const d=u.target.value;n.updateBlock(t.id,{props:{language:d}})};s.addEventListener("change",c),i=()=>s.removeEventListener("change",c);const l=document.createElement("div");l.contentEditable="false",l.appendChild(s),o.appendChild(l)}return o.appendChild(r),{dom:o,contentDOM:a,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=>[y.createExtension({key:"code-block-highlighter",prosemirrorPlugins:[pn(e)]}),y.createExtension({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:a}=n.selection,i=a.parentOffset===a.parent.nodeSize-2,s=a.parent.textContent.endsWith(`
`);if(i&&s){if(n.delete(a.pos-2,a.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(`
`),!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:se(e,n)??n}.language},content:[]}}}]})]);function se(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 je=()=>({type:"divider",propSchema:{},content:"none"}),Ge=E(je,{meta:{isolating:!1},parse(e){if(e.tagName==="HR")return{}},render(){return{dom:document.createElement("hr")}}},[y.createExtension({key:"divider-block-shortcuts",inputRules:[{find:new RegExp("^---$"),replace(){return{type:"divider",props:{},content:[]}}}]})]),me=e=>({url:e.src||void 0}),Ze=()=>({type:"file",propSchema:{backgroundColor:g.backgroundColor,name:{default:""},url:{default:""},caption:{default:""}},content:"none"}),ze=()=>e=>{if(e.tagName==="EMBED"){if(e.closest("figure"))return;const{backgroundColor:t}=v(e);return{...me(e),backgroundColor:t}}if(e.tagName==="FIGURE"){const t=X(e,"embed");if(!t)return;const{targetElement:n,caption:o}=t,{backgroundColor:r}=v(e);return{...me(n),backgroundColor:r,caption:o}}},Ke=E(Ze,{meta:{fileBlockAccept:["*/*"]},parse:ze(),render(e,t){return ae(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?Q(t,e.props.caption):{dom:t}}}),Xe={set:(e,t)=>window.localStorage.setItem(`toggle-${e.id}`,t?"true":"false"),get:e=>window.localStorage.getItem(`toggle-${e.id}`)==="true"},ce=(e,t,n,o=Xe)=>{if("isToggleable"in e.props&&!e.props.isToggleable)return{dom:n};const r=document.createElement("div"),a=document.createElement("div");a.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 s=f=>f.preventDefault();i.addEventListener("mousedown",s);const c=()=>{var f;a.getAttribute("data-show-children")==="true"?(a.setAttribute("data-show-children","false"),o.set(t.getBlock(e),!1),r.contains(l)&&r.removeChild(l)):(a.setAttribute("data-show-children","true"),o.set(t.getBlock(e),!0),t.isEditable&&((f=t.getBlock(e))==null?void 0:f.children.length)===0&&!r.contains(l)&&r.appendChild(l))};i.addEventListener("click",c),a.appendChild(i),a.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 u=f=>f.preventDefault();l.addEventListener("mousedown",u);const d=()=>{t.transact(()=>{const f=t.updateBlock(e,{children:[{}]});t.setTextCursorPosition(f.children[0].id,"end"),t.focus()})};l.addEventListener("click",d),r.appendChild(a);let p=e.children.length;const h=t.onChange(()=>{var x;const f=((x=t.getBlock(e))==null?void 0:x.children.length)??0;f>p?(a.getAttribute("data-show-children")==="false"&&(a.setAttribute("data-show-children","true"),o.set(t.getBlock(e),!0)),r.contains(l)&&r.removeChild(l)):f===0&&f<p&&(a.getAttribute("data-show-children")==="true"&&(a.setAttribute("data-show-children","false"),o.set(t.getBlock(e),!1)),r.contains(l)&&r.removeChild(l)),p=f});return o.get(e)?(a.setAttribute("data-show-children","true"),t.isEditable&&e.children.length===0&&r.appendChild(l)):a.setAttribute("data-show-children","false"),{dom:r,ignoreMutation:f=>f instanceof MutationRecord&&(f.type==="attributes"&&f.target===a&&f.attributeName==="data-show-children"||f.type==="childList"&&(f.addedNodes[0]===l||f.removedNodes[0]===l)),destroy:()=>{i.removeEventListener("mousedown",s),i.removeEventListener("click",c),l.removeEventListener("mousedown",u),l.removeEventListener("click",d),h==null||h()}}},Qe=[1,2,3,4,5,6],fn=e=>({editor:t})=>{const n=t.getTextCursorPosition();return t.schema.blockSchema[n.block.type].content!=="inline"?!1:(t.updateBlock(n.block,{type:"heading",props:{level:e}}),!0)},Ye=({defaultLevel:e=1,levels:t=Qe,allowToggleHeadings:n=!0}={})=>({type:"heading",propSchema:{...g,level:{default:e,values:t},...n?{isToggleable:{default:!1,optional:!0}}:{}},content:"inline"}),Je=E(Ye,({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{...v(t),level:n}},render(t,n){const o=document.createElement(`h${t.props.level}`);return e?{...ce(t,n,o),contentDOM:o}:{dom:o,contentDOM:o}},toExternalHTML(t){const n=document.createElement(`h${t.props.level}`);return I(t.props,n),{dom:n,contentDOM:n}}}),({levels:e=Qe}={})=>[y.createExtension({key:"heading-shortcuts",keyboardShortcuts:Object.fromEntries(e.map(t=>[`Mod-Alt-${t}`,fn(t)])??[]),inputRules:e.map(t=>({find:new RegExp(`^(#{${t}})\\s$`),replace({match:n}){return{type:"heading",props:{level:n[1].length}}}}))})]),et=(e,t,n,o,r)=>{const{dom:a,destroy:i}=ae(e,t,n,r),s=a;s.style.position="relative",e.props.url&&e.props.showPreview&&(e.props.previewWidth?s.style.width=`${e.props.previewWidth}px`:s.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 u=document.createElement("div");u.style.position="absolute",u.style.height="100%",u.style.width="100%";let d,p=e.props.previewWidth;const h=b=>{var ue,pe;if(!d){!t.isEditable&&o.contains(c)&&o.contains(l)&&(o.removeChild(c),o.removeChild(l));return}let L;const U="touches"in b?b.touches[0].clientX:b.clientX;e.props.textAlignment==="center"?d.handleUsed==="left"?L=d.initialWidth+(d.initialClientX-U)*2:L=d.initialWidth+(U-d.initialClientX)*2:d.handleUsed==="left"?L=d.initialWidth+d.initialClientX-U:L=d.initialWidth+U-d.initialClientX,p=Math.min(Math.max(L,64),((pe=(ue=t.domElement)==null?void 0:ue.firstElementChild)==null?void 0:pe.clientWidth)||Number.MAX_VALUE),s.style.width=`${p}px`},f=b=>{(!b.target||!s.contains(b.target)||!t.isEditable)&&o.contains(c)&&o.contains(l)&&(o.removeChild(c),o.removeChild(l)),d&&(d=void 0,s.contains(u)&&s.removeChild(u),t.updateBlock(e,{props:{previewWidth:p}}))},x=()=>{t.isEditable&&(o.appendChild(c),o.appendChild(l))},w=b=>{b.relatedTarget===c||b.relatedTarget===l||d||t.isEditable&&o.contains(c)&&o.contains(l)&&(o.removeChild(c),o.removeChild(l))},M=b=>{b.preventDefault(),s.contains(u)||s.appendChild(u);const L="touches"in b?b.touches[0].clientX:b.clientX;d={handleUsed:"left",initialWidth:s.clientWidth,initialClientX:L}},D=b=>{b.preventDefault(),s.contains(u)||s.appendChild(u);const L="touches"in b?b.touches[0].clientX:b.clientX;d={handleUsed:"right",initialWidth:s.clientWidth,initialClientX:L}};return window.addEventListener("mousemove",h),window.addEventListener("touchmove",h),window.addEventListener("mouseup",f),window.addEventListener("touchend",f),s.addEventListener("mouseenter",x),s.addEventListener("mouseleave",w),c.addEventListener("mousedown",M),c.addEventListener("touchstart",M),l.addEventListener("mousedown",D),l.addEventListener("touchstart",D),{dom:s,destroy:()=>{i==null||i(),window.removeEventListener("mousemove",h),window.removeEventListener("touchmove",h),window.removeEventListener("mouseup",f),window.removeEventListener("touchend",f),s.removeEventListener("mouseenter",x),s.removeEventListener("mouseleave",w),c.removeEventListener("mousedown",M),c.removeEventListener("touchstart",M),l.removeEventListener("mousedown",D),l.removeEventListener("touchstart",D)}}},be=e=>{const t=e.src||void 0,n=e.width||void 0,o=e.alt||void 0;return{url:t,previewWidth:n,name:o}},tt='<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>',nt=(e={})=>({type:"image",propSchema:{textAlignment:g.textAlignment,backgroundColor:g.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0},previewWidth:{default:void 0,type:"number"}},content:"none"}),ot=(e={})=>t=>{if(t.tagName==="IMG"){if(t.closest("figure"))return;const{backgroundColor:n}=v(t);return{...be(t),backgroundColor:n}}if(t.tagName==="FIGURE"){const n=X(t,"img");if(!n)return;const{targetElement:o,caption:r}=n,{backgroundColor:a}=v(t);return{...be(o),backgroundColor:a,caption:r}}},rt=(e={})=>(t,n)=>{const o=document.createElement("div");o.innerHTML=e.icon??tt;const r=document.createElement("div");r.className="bn-visual-media-wrapper";const a=document.createElement("img");return a.className="bn-visual-media",n.resolveFileUrl?n.resolveFileUrl(t.props.url).then(i=>{a.src=i}):a.src=t.props.url,a.alt=t.props.name||t.props.caption||"BlockNote image",a.contentEditable="false",a.draggable=!1,r.appendChild(a),et(t,n,{dom:r},r,o.firstElementChild)},at=(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?ie(o,t.props.caption):Q(o,t.props.caption):{dom:o}},it=E(nt,e=>({meta:{fileBlockAccept:["image/*"]},parse:ot(e),render:rt(e),toExternalHTML:at(e),runsBefore:["file"]})),gn=(e,t,n)=>({state:o,dispatch:r})=>r?st(o.tr,e,t,n):!0,st=(e,t,n,o)=>{const r=m.getNearestBlockPos(e.doc,t),a=m.getBlockInfo(r);if(!a.isBlockContainer)return!1;const i=m.getPmSchema(e),s=[{type:a.bnBlock.node.type,attrs:o?{...a.bnBlock.node.attrs,id:void 0}:{}},{type:n?a.blockContent.node.type:i.nodes.paragraph,attrs:o?{...a.blockContent.node.attrs}:{}}];return e.split(t,2,s),!0},Y=(e,t)=>{const{blockInfo:n,selectionEmpty:o}=e.transact(i=>({blockInfo:m.getBlockInfoFromTransaction(i),selectionEmpty:i.selection.anchor===i.selection.head}));if(!n.isBlockContainer)return!1;const{bnBlock:r,blockContent:a}=n;return a.node.type.name!==t||!o?!1:a.node.childCount===0?(e.transact(i=>{K(i,r.beforePos,{type:"paragraph",props:{}})}),!0):a.node.childCount>0?e.transact(i=>(i.deleteSelection(),st(i,i.selection.from,!0))):!1};function le(e,t,n){var d,p,h;const o=N.DOMParser.fromSchema(t),r=e,a=document.createElement("div");a.setAttribute("data-node-type","blockGroup");for(const f of Array.from(r.childNodes))a.appendChild(f.cloneNode(!0));let i=o.parse(a,{topNode:t.nodes.blockGroup.create()});((p=(d=i.firstChild)==null?void 0:d.firstChild)==null?void 0:p.type.name)==="checkListItem"&&(i=i.copy(i.content.cut(i.firstChild.firstChild.nodeSize+2)));const s=(h=i.firstChild)==null?void 0:h.firstChild;if(!(s!=null&&s.isTextblock))return N.Fragment.from(i);const c=t.nodes[n].create({},s.content),l=i.content.cut(s.nodeSize+2);if(l.size>0){const f=i.copy(l);return c.content.addToEnd(f)}return c.content}const ct=()=>({type:"bulletListItem",propSchema:{...g},content:"inline"}),lt=E(ct,{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 v(e)},parseContent:({el:e,schema:t})=>le(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 I(e.props,t),t.appendChild(n),{dom:t,contentDOM:n}}},[y.createExtension({key:"bullet-list-item-shortcuts",keyboardShortcuts:{Enter:({editor:e})=>Y(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(m.getBlockInfoFromSelection(e.prosemirrorState).blockNoteType!=="heading")return{type:"bulletListItem",props:{}}}}]})]),dt=()=>({type:"checkListItem",propSchema:{...g,checked:{default:!1,type:"boolean"}},content:"inline"}),ut=E(dt,{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:{...v(e),checked:o.checked}}},parseContent:({el:e,schema:t})=>le(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 I(e.props,t),t.appendChild(n),t.appendChild(o),{dom:t,contentDOM:o}},runsBefore:["bulletListItem"]},[y.createExtension({key:"check-list-item-shortcuts",keyboardShortcuts:{Enter:({editor:e})=>Y(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 pt(e,t,n,o){let r=e.firstChild.attrs.start||1,a=!0;const i=!!e.firstChild.attrs.start,s=m.getBlockInfo({posBeforeNode:t,node:e});if(!s.isBlockContainer)throw new Error("impossible");const c=n.doc.resolve(s.bnBlock.beforePos).nodeBefore,l=c?o.get(c):void 0;return l!==void 0?(r=l+1,a=!1):c&&m.getBlockInfo({posBeforeNode:s.bnBlock.beforePos-c.nodeSize,node:c}).blockNoteType==="numberedListItem"&&(r=pt(c,s.bnBlock.beforePos-c.nodeSize,n,o).index+1,a=!1),o.set(e,r),{index:r,isFirst:a,hasStart:i}}function Ce(e,t){const n=new Map,o=t.decorations.map(e.mapping,e.doc),r=[];e.doc.nodesBetween(0,e.doc.nodeSize-2,(i,s)=>{if(i.type.name==="blockContainer"&&i.firstChild.type.name==="numberedListItem"){const{index:c,isFirst:l,hasStart:u}=pt(i,s,e,n);if(o.find(s,s+i.nodeSize,p=>p.index===c&&p.isFirst===l&&p.hasStart===u).length===0){const p=e.doc.nodeAt(s+1);r.push(ee.Decoration.node(s+1,s+1+p.nodeSize,{"data-index":c.toString()}))}}});const a=r.flatMap(i=>o.find(i.from,i.to));return{decorations:o.remove(a).add(e.doc,r)}}const hn=()=>new fe.Plugin({key:new fe.PluginKey("numbered-list-indexing-decorations"),state:{init(e,t){return Ce(t.tr,{decorations:ee.DecorationSet.empty})},apply(e,t){return!e.docChanged&&!e.selectionSet&&t.decorations?t:Ce(e,t)}},props:{decorations(e){var t;return((t=this.getState(e))==null?void 0:t.decorations)??ee.DecorationSet.empty}}}),ft=()=>({type:"numberedListItem",propSchema:{...g,start:{default:void 0,type:"number"}},content:"inline"}),gt=E(ft,{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=v(e);return e.previousElementSibling||o===1?r:{...r,start:o}}},parseContent:({el:e,schema:t})=>le(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 I(e.props,t),t.appendChild(n),{dom:t,contentDOM:n}}},[y.createExtension({key:"numbered-list-item-shortcuts",inputRules:[{find:new RegExp("^(\\d+)\\.\\s$"),replace({match:e,editor:t}){if(m.getBlockInfoFromSelection(t.prosemirrorState).blockNoteType==="heading")return;const o=parseInt(e[1]);return{type:"numberedListItem",props:{start:o!==1?o:void 0}}}}],keyboardShortcuts:{Enter:({editor:e})=>Y(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)}},prosemirrorPlugins:[hn()]})]),ht=()=>({type:"toggleListItem",propSchema:{...g},content:"inline"}),mt=E(ht,{meta:{isolating:!1},render(e,t){const n=document.createElement("p");return{...ce(e,t,n),contentDOM:n}},toExternalHTML(e){const t=document.createElement("li"),n=document.createElement("p");return I(e.props,t),t.appendChild(n),{dom:t,contentDOM:n}}},[y.createExtension({key:"toggle-list-item-shortcuts",keyboardShortcuts:{Enter:({editor:e})=>Y(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)}}})]),bt=()=>({type:"paragraph",propSchema:g,content:"inline"}),Ct=E(bt,{meta:{isolating:!1},parse:e=>{var t;if(e.tagName==="P"&&(t=e.textContent)!=null&&t.trim())return v(e)},render:()=>{const e=document.createElement("p");return{dom:e,contentDOM:e}},toExternalHTML:e=>{const t=document.createElement("p");return I(e.props,t),{dom:t,contentDOM:t}},runsBefore:["default"]},[y.createExtension({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)}}})]),kt=()=>({type:"quote",propSchema:{backgroundColor:g.backgroundColor,textColor:g.textColor},content:"inline"}),yt=E(kt,{meta:{isolating:!1},parse(e){if(e.tagName==="BLOCKQUOTE"){const{backgroundColor:t,textColor:n}=v(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 I(e.props,t),{dom:t,contentDOM:t}}},[y.createExtension({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:{}}}}]})]),mn=35,de=120,bn=31,Cn=S.Extension.create({name:"BlockNoteTableExtension",addProseMirrorPlugins:()=>[T.columnResizing({cellMinWidth:mn,defaultCellMinWidth:de,View:null}),T.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})=>T.goToNextCell(1)(e,t,n)),"Shift-Tab":()=>this.editor.commands.command(({state:e,dispatch:t,view:n})=>T.goToNextCell(-1)(e,t,n))}},extendNodeSchema(e){const t={name:e.name,options:e.options,storage:e.storage};return{tableRole:S.callOrReturn(S.getExtensionField(e,"tableRole",t))}}}),vt={textColor:g.textColor},kn=S.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)=>St(e,t)}]},renderHTML({HTMLAttributes:e}){return["th",S.mergeAttributes(this.options.HTMLAttributes,e),0]}}),yn=S.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)=>St(e,t)}]},renderHTML({HTMLAttributes:e}){return["td",S.mergeAttributes(this.options.HTMLAttributes,e),0]}}),vn=S.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,a,i;const n=Se(this.name,"table",{...((r=this.options.domAttributes)==null?void 0:r.blockContent)||{},...t},((a=this.options.domAttributes)==null?void 0:a.inlineContent)||{}),o=document.createElement("colgroup");for(const s of e.children[0].children)if(s.attrs.colwidth)for(const l of s.attrs.colwidth){const u=document.createElement("col");l&&(u.style=`width: ${l}px`),o.appendChild(u)}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 T.TableView{constructor(a,i,s){super(a,i),this.node=a,this.cellMinWidth=i,this.blockContentHTMLAttributes=s;const c=document.createElement("div");c.className=V("bn-block-content",s.class),c.setAttribute("data-content-type","table");for(const[p,h]of Object.entries(s))p!=="class"&&c.setAttribute(p,h);const l=this.dom,u=document.createElement("div");u.className="tableWrapper-inner",u.appendChild(l.firstChild),l.appendChild(u),c.appendChild(l);const d=document.createElement("div");d.className="table-widgets-container",d.style.position="relative",l.appendChild(d),this.dom=c}ignoreMutation(a){return!a.target.closest(".tableWrapper-inner")||super.ignoreMutation(a)}}return new n(e,de,{...((o=this.options.domAttributes)==null?void 0:o.blockContent)||{},...t})}}}),Sn=S.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]}}),En=S.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",S.mergeAttributes(this.options.HTMLAttributes,e),0]}});function St(e,t){const o=N.DOMParser.fromSchema(t).parse(e,{topNode:t.nodes.blockGroup.create()}),r=[];return o.content.descendants(a=>{if(a.isInline)return r.push(a),!1}),N.Fragment.fromArray(r)}const Et=()=>we({node:vn,type:"table",content:"table"},vt,[y.createExtension({key:"table-extensions",tiptapExtensions:[Cn,Sn,kn,yn,En]}),y.createExtension({key:"table-keyboard-delete",keyboardShortcuts:{Backspace:({editor:e})=>{if(!(e.prosemirrorState.selection instanceof T.CellSelection))return!1;const t=e.getTextCursorPosition().block,n=t.content;let o=0;for(const a of n.rows)for(const i of a.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)}}})]),ke=e=>{const t=e.src||void 0,n=e.width||void 0;return{url:t,previewWidth:n}},xt='<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.