1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[16153],{1313:function(t,e,i){let n,o;i.d(e,{BM:function(){return tb},G6:function(){return tl},HC:function(){return tm},Rp:function(){return tu},SJ:function(){return tF},Xy:function(){return ej},_v:function(){return tW},eD:function(){return ts},fl:function(){return tJ},kQ:function(){return tg},lG:function(){return th},lw:function(){return eG},lz:function(){return tv},rP:function(){return tw},rn:function(){return tp},tp:function(){return eW},vz:function(){return eY},w2:function(){return tK},xQ:function(){return ta},xg:function(){return tX},yD:function(){return eJ}});var r=i(79284),s=i(89803),a=i(84709),l=i(9391),d=i(11040),c=i(38887),h=i(16300),p=i(15042),u=i(83959),m=i(60626),g=i(11719),f=i(87473),b=i(33476),v=i(94743),y=i(20144),k=i(24054),w=i(42145),E=i(63796),C=i(61303),S=i(37115),x=i(38332),M=i(85756),T=i(86333),L=i(4970),A=i(86217),H=i(36886),B=i(81091),N=i(32133),I=i(50096),P=i(86671),O=i(64056),_=i(95385),U=Object.defineProperty,D=(t,e,i)=>e in t?U(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,V=(t,e,i)=>(D(t,"symbol"!=typeof e?e+"":e,i),i);let R=d.hj.create({name:"uniqueID",priority:1e4,addOptions:()=>({attributeName:"id",types:[],generateID:()=>
1{if("u">typeof window&&window.__TEST_OPTIONS){let t=window.__TEST_OPTIONS;return void 0===t.mockID?t.mockID=0:t.mockID++,t.mockID.toString()}return(0,h.Z)()},filterTransaction:null}),addGlobalAttributes(){return[{types:this.options.types,attributes:{[this.options.attributeName]:{default:null,parseHTML:t=>t.getAttribute(`data-${this.options.attributeName}`),renderHTML:t=>({[`data-${this.options.attributeName}`]:t[this.options.attributeName]})}}}]},addProseMirrorPlugins(){let t=null,e=!1;return[new c.Sy({key:new c.H$("uniqueID"),appendTransaction:(t,e,i)=>{let n=t.some(t=>t.docChanged)&&!e.doc.eq(i.doc),o=this.options.filterTransaction&&t.some(t=>{let e,i;return!(!(null===(i=(e=this.options).filterTransaction)||void 0===i)&&i.call(e,t))});if(!n||o)return;let{tr:r}=i,{types:s,attributeName:a,generateID:l}=this.options,c=(0,d.XP)(e.doc,t),{mapping:h}=c;if((0,d.QC)(c).forEach(({newRange:t})=>{var n;let o=(0,d.b5)(i.doc,t,t=>s.includes(t.type.name)),c=function(t,e=JSON.stringify){let i={};return t.filter(t=>{let n=e(t);return!Object.prototype.hasOwnProperty.call(i,n)&&(i[n]=!0)})}((n=o.map(({node:t})=>t.attrs[a]).filter(t=>null!==t)).filter((t,e)=>n.indexOf(t)!==e));o.forEach(({node:t,pos:n})=>{let o;let s=null===(o=r.doc.nodeAt(n))||void 0===o?void 0:o.attrs[a];if(null===s){let o=e.doc.type.createAndFill().content;if(null===e.doc.content.findDiffStart(o)){let e=JSON.parse(JSON.stringify(i.doc.toJSON()));if(e.content[0].content[0].attrs.id="initialBlockId",JSON.stringify(e.content)===JSON.stringify(o.toJSON())){r.setNodeMarkup(n,void 0,{...t.attrs,[a]:"initialBlockId"});return}}r.setNodeMarkup(n,void 0,{...t.attrs,[a]:l()});return}let{deleted:d}=h.invert().mapResult(n);d&&c.includes(s)&&r.setNodeMarkup(n,void 0,{...t.attrs,[a]:l()})})}),r.steps.length)return r},view(e){let i=i=>{let n;t=!(null===(n=e.dom.parentElement)||void 0===n)&&n.contains(i.target)?e.dom.parentElement:null};return window.addEventListener("dragstart",i),{destroy(){window.removeEventListener("dragstart",i)}}},props:{handleDOMEvents:{drop:(i,n)=>{let o;return(t!==i.dom.parentElement||(null===(o=n.dataTransfer)||void 0===o?void 0:o.effectAllowed)==="copy")&&(t=null,e=!0),!1},paste:()=>(e=!0,!1)},transformPasted:t=>{if(!e)return t;let{types:i,attributeName:n}=this.options,o=t=>{let e=[];return t.forEach(t=>{if(t.isText){e.push(t);return}if(!i.includes(t.type.name)){e.push(t.copy(o(t.content)));return}let r=t.type.create({...t.attrs,[n]:null},o(t.content),t.marks);e.push(r)}),r.HY.from(e)};return e=!1,new r.p2(o(t.content),t.openStart,t.openEnd)}}})]}});function z(t){let e=t.attrs.id,i=t.firstChild,n=i.type,o=2===t.childCount?t.lastChild.childCount:0;return{id:e,node:t,contentNode:i,contentType:n,numChildBlocks:o}}function $(t,e){let i=t.nodeSize-2;if(e<=1)for(e=2;"blockContainer"!==t.resolve(e).parent.type.name&&e<i;)e++;else if(e>=i)for(e=i-1;"blockContainer"!==t.resolve(e).parent.type.name&&e>1;)e--;"blockGroup"===t.resolve(e).parent.type.name&&e++;let n=t.resolve(e),o=n.depth,r=n.node(o),s=o;for(;;){if(s<0)throw Error("Could not find blockContainer node. This can only happen if the underlying BlockNote schema has been edited.");if("blockContainer"===r.type.name)break;s-=1,r=n.node(s)}let{id:a,contentNode:l,contentType:d,numChildBlocks:c}=z(r);return{id:a,node:r,contentNode:l,contentType:d,numChildBlocks:c,startPos:n.start(s),endPos:n.end(s),depth:s}}function j(t){return"link"===t.type}function F(t){return"string"!=typeof t&&"text"===t.type}class q extends Error{constructor(t){super(`Unreachable case: ${t}`)}}function G(t,e,i){let n=[];for(let[o,r]of Object.entries(t.styles)){let t=i[o];if(!t)throw Error(`style ${o} not found in styleSchema`);if("boolean"===t.propSchema)n.push(e.mark(o));else if("string"===t.propSchema)n.push(e.mark(o,{stringValue:r}));else throw new q(t.propSchema)}return t.text.split(/(\n)/g).filter(t=>t.length>0).map(t=>t===` 2`?e.nodes.hardBreak.create():e.text(t,n))}function Y(t,e,i){let n=[];if("string"==typeof t)return n.push(...G({type:"text",text:t,styles:{}},e,i)),n;for(let o of t)n.push(...G(o,e,i));return n}function W(t,e,i){let n=[];for(let o of t)"string"==typeof o?n.push(...Y(o,e,i)):"string"!=typeof o&&"link"===o.type?n.push(...function(t,e,
2i){let n=e.marks.link.create({href:t.href});return Y(t.content,e,i).map(t=>{if("text"===t.type.name)return t.mark([...t.marks,n]);if("hardBreak"===t.type.name)return t;throw Error("unexpected node type")})}(o,e,i)):F(o)?n.push(...Y([o],e,i)):n.push(X(o,e,i));return n}function J(t,e,i){let n=[];for(let o of t.rows){let t=[];for(let n of o.cells){let o;if(n){if("string"==typeof n)o=e.nodes.tableParagraph.create({},e.text(n));else{let t=W(n,e,i);o=e.nodes.tableParagraph.create({},t)}}else o=e.nodes.tableParagraph.create({});let r=e.nodes.tableCell.create({},o);t.push(r)}let r=e.nodes.tableRow.create({},t);n.push(r)}return n}function X(t,e,i){let n,o=t.type;if(void 0===o&&(o="paragraph"),!e.nodes[o])throw Error(`node type ${o} not found in schema`);if(t.content){if("string"==typeof t.content)n=e.nodes[o].create(t.props,e.text(t.content));else if(Array.isArray(t.content)){let r=W(t.content,e,i);n=e.nodes[o].create(t.props,r)}else if("tableContent"===t.content.type){let r=J(t.content,e,i);n=e.nodes[o].create(t.props,r)}else throw new q(t.content.type)}else n=e.nodes[o].create(t.props);return n}function K(t,e,i){let n=t.id;void 0===n&&(n=R.options.generateID());let o=X(t,e,i),r=[];if(t.children)for(let n of t.children)r.push(K(n,e,i));let s=e.nodes.blockGroup.create({},r);return e.nodes.blockContainer.create({id:n,...t.props},r.length>0?[o,s]:o)}function Z(t,e,i){let n;let o=[];return t.content.forEach(t=>{let r;if("hardBreak"===t.type.name){if(n){if(F(n))n.text+=` 3`;else if(j(n))n.content[n.content.length-1].text+=` 4`;else throw Error("unexpected")}else n={type:"text",text:` 5`,styles:{}};return}if("link"!==t.type.name&&"text"!==t.type.name&&e[t.type.name]){n&&(o.push(n),n=void 0),o.push(function(t,e,i){let n;if("text"===t.type.name||"link"===t.type.name)throw Error("unexpected");let o={},r=e[t.type.name];for(let[e,i]of Object.entries(t.attrs)){if(!r)throw Error("ic node is of an unrecognized type: "+t.type.name);e in r.propSchema&&(o[e]=i)}return n="styled"===r.content?Z(t,e,i):void 0,{type:t.type.name,props:o,content:n}}(t,e,i));return}let s={};for(let e of t.marks)if("link"===e.type.name)r=e;else{let t=i[e.type.name];if(!t)throw Error(`style ${e.type.name} not found in styleSchema`);if("boolean"===t.propSchema)s[t.type]=!0;else if("string"===t.propSchema)s[t.type]=e.attrs.stringValue;else throw new q(t.propSchema)}n?F(n)?r?(o.push(n),n={type:"link",href:r.attrs.href,content:[{type:"text",text:t.textContent,styles:s}]}):JSON.stringify(n.styles)===JSON.stringify(s)?n.text+=t.textContent:(o.push(n),n={type:"text",text:t.textContent,styles:s}):j(n)&&(r?n.href===r.attrs.href?JSON.stringify(n.content[n.content.length-1].styles)===JSON.stringify(s)?n.content[n.content.length-1].text+=t.textContent:n.content.push({type:"text",text:t.textContent,styles:s}):(o.push(n),n={type:"link",href:r.attrs.href,content:[{type:"text",text:t.textContent,styles:s}]}):(o.push(n),n={type:"text",text:t.textContent,styles:s})):n=r?{type:"link",href:r.attrs.href,content:[{type:"text",text:t.textContent,styles:s}]}:{type:"text",text:t.textContent,styles:s}}),n&&o.push(n),o}function Q(t,e,i,n,o){let r;if("blockContainer"!==t.type.name)throw Error("Node must be of type blockContainer, but is of type"+t.type.name+".");let s=null==o?void 0:o.get(t);if(s)return s;let a=z(t),l=a.id;null===l&&(l=R.options.generateID());let d={};for(let[i,n]of Object.entries({...t.attrs,...a.contentNode.attrs})){let t=e[a.contentType.name];if(!t)throw Error("Block is of an unrecognized type: "+a.contentType.name);i in t.propSchema&&(d[i]=n)}let c=e[a.contentType.name],h=[];for(let r=0;r<a.numChildBlocks;r++)h.push(Q(t.lastChild.child(r),e,i,n,o));if("inline"===c.content)r=Z(a.contentNode,i,n);else if("table"===c.content)r=function(t,e,i){let n={type:"tableContent",rows:[]};return t.content.forEach(t=>{let o={cells:[]};t.content.forEach(t=>{o.cells.push(Z(t.firstChild,e,i))}),n.rows.push(o)}),n}(a.contentNode,i,n);else if("none"===c.content)r=void 0;else throw new q(c.content);let p={id:l,type:c.type,props:d,content:r,children:h};return null==o||o.set(t,p),p}let tt=(t,e,i,n,o)=>
5{if(!i.nodes[t.type.name])throw Error("Serializer is missing a node type: "+t.type.name);let{dom:s,contentDOM:a}=r.PW.renderSpec(e.document||window.document,i.nodes[t.type.name](t));if(a){if(t.isLeaf)throw RangeError("Content hole not allowed in a leaf node spec");if("blockContainer"===t.type.name){let s=t.childCount>0&&"blockContent"===t.firstChild.type.spec.group?t.firstChild:void 0,l=t.childCount>0&&"blockGroup"===t.lastChild.type.spec.group?t.lastChild:void 0;if(void 0!==s){let r=n.blockImplementations[s.type.name].implementation,l=(o?r.toExternalHTML:r.toInternalHTML)(Q(t,n.schema.blockSchema,n.schema.inlineContentSchema,n.schema.styleSchema,n.blockCache),n);if(void 0!==l.contentDOM){if(t.isLeaf)throw RangeError("Content hole not allowed in a leaf node spec");l.contentDOM.appendChild(i.serializeFragment(s.content,e))}a.appendChild(l.dom)}void 0!==l&&i.serializeFragment(r.HY.from(l),e,a)}else i.serializeFragment(t.content,e,a)}return s},te=(t,e)=>{let i=e.serializeFragment(t),n=document.createElement("div");return n.appendChild(i),n.innerHTML};function ti(t){let e=new Set([...t.orderedListItemBlockTypes,...t.unorderedListItemBlockTypes]),i=n=>{var o;if(1===n.children.length&&(null==(o=n.children[0].properties)?void 0:o.dataNodeType)==="blockGroup"){let t=n.children[0];n.children.pop(),n.children.push(...t.children)}let r=n.children.length,s;for(let o=0;o<r;o++){let a=n.children[o].children[0],l=a.children[0],d=2===a.children.length?a.children[1]:null,c=e.has(l.properties.dataContentType),h=c?t.orderedListItemBlockTypes.has(l.properties.dataContentType)?"ol":"ul":null;if(null!==d&&i(d),s&&s.tagName!==h){n.children.splice(o-s.children.length,s.children.length,s);let t=s.children.length-1;o-=t,r-=t,s=void 0}if(c){s||(s=(0,p.Y)(document.createElement(h)));let t=(0,p.Y)(document.createElement("li"));t.children.push(l.children[0]),null!==d&&t.children.push(...d.children),s.children.push(t)}else if(null!==d){n.children.splice(o+1,0,...d.children),n.children[o]=l.children[0];let t=d.children.length;o+=t,r+=t}else n.children[o]=l.children[0]}s&&n.children.splice(r-s.children.length,s.children.length,s)};return i}let tn=(t,e)=>{let i=r.PW.fromSchema(t);return i.serializeNodeInner=(t,n)=>tt(t,n,i,e,!0),i.exportProseMirrorFragment=t=>(0,l.l)().use(s.Z,{fragment:!0}).use(ti,{orderedListItemBlockTypes:new Set(["numberedListItem"]),unorderedListItemBlockTypes:new Set(["bulletListItem"])}).use(a.Z).processSync(te(t,i)).value,i.exportBlocks=n=>{let o=n.map(i=>K(i,t,e.schema.styleSchema)),s=t.nodes.blockGroup.create(null,o);return i.exportProseMirrorFragment(r.HY.from(s))},i},to=(t,e)=>{let i=r.PW.fromSchema(t);return i.serializeNodeInner=(t,n)=>tt(t,n,i,e,!1),i.serializeProseMirrorFragment=t=>te(t,i),i.serializeBlocks=n=>{let o=n.map(i=>K(i,t,e.schema.styleSchema)),s=t.nodes.blockGroup.create(null,o);return i.serializeProseMirrorFragment(r.HY.from(s))},i},tr=()=>"u">typeof navigator&&(/Mac/.test(navigator.platform)||/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent));function ts(t){return tr()?t.replace("Mod","â"):t.replace("Mod","Ctrl")}function ta(...t){return t.filter(t=>t).join(" ")}let tl=()=>/^((?!chrome|android).)*safari/i.test(navigator.userAgent);function td(t,e,i,n){let o=document.createElement("div");for(let[e,n]of(o.className=ta("bn-block-content",i.class),o.setAttribute("data-content-type",t),Object.entries(i)))"class"!==e&&o.setAttribute(e,n);let r=document.createElement(e);for(let[t,e]of(r.className=ta("bn-inline-content",n.class),Object.entries(n)))"class"!==t&&r.setAttribute(t,e);return o.appendChild(r),{dom:o,contentDOM:r}}let tc=(t,e)=>{let i=K(t,e._tiptapEditor.schema,e.schema.styleSchema).firstChild,n=e._tiptapEditor.schema.nodes[i.type.name].spec.toDOM;if(void 0===n)throw Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");let o=n(i);if("object"!=typeof o||!("dom"in o))throw 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 o},th={backgroundColor:{default:"default"},textColor:{default:"default"},textAlignment:{default:"left",values:["left","center","right","justify"]}},tp=["backgroundColor","textColor"];function tu(t){return"data-"+t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function tm(t){let e={};return Object.entries(t).filter(([t,e])=>
5!tp.includes(t)).forEach(([t,i])=>{e[t]={default:i.default,keepOnSplit:!0,parseHTML:e=>{let n=e.getAttribute(tu(t));if(null===n)return null;if("boolean"==typeof i.default)return"true"===n||"false"!==n&&null;if("number"==typeof i.default){let t=parseFloat(n);return!Number.isNaN(t)&&Number.isFinite(t)?t:null}return n},renderHTML:e=>e[t]!==i.default?{[tu(t)]:e[t]}:{}}}),e}function tg(t,e,i,n){if("boolean"==typeof t)throw Error("Cannot find node position as getPos is a boolean, not a function.");let o=t(),r=i.state.doc.resolve(o).node().attrs.id,s=e.getBlock(r);if(s.type!==n)throw Error("Block type does not match");return s}function tf(t,e,i,n,o){let r=document.createElement("div");if(void 0!==o)for(let[t,e]of Object.entries(o))"class"!==t&&r.setAttribute(t,e);for(let[t,s]of(r.className=ta("bn-block-content",(null==o?void 0:o.class)||""),r.setAttribute("data-content-type",e),Object.entries(i)))tp.includes(t)||s===n[t].default||r.setAttribute(tu(t),s);return r.appendChild(t.dom),void 0!==t.contentDOM&&(t.contentDOM.className=ta("bn-inline-content",t.contentDOM.className),t.contentDOM.setAttribute("data-editable","")),{...t,dom:r}}function tb(t){return d.NB.create(t)}function tv(t,e){return{config:t,implementation:e}}function ty(t,e,i){return tv({type:t.name,content:"inline*"===t.config.content?"inline":"tableRow+"===t.config.content?"table":"none",propSchema:e},{node:t,requiredExtensions:i,toInternalHTML:tc,toExternalHTML:tc})}function tk(t){return Object.fromEntries(Object.entries(t).map(([t,e])=>[t,e.config]))}function tw(t,e){let i=[{tag:"[data-content-type="+t.type+"]",contentElement:"[data-editable]"}];return e&&i.push({tag:"*",getAttrs(t){if("string"==typeof t)return!1;let i=null==e?void 0:e(t);return void 0!==i&&i}}),i}function tE(t){return Object.fromEntries(Object.entries(t).map(([t,e])=>[t,e.config]))}function tC(t,e){return{config:{type:t.name,propSchema:e},implementation:{mark:t}}}function tS(t){return Object.fromEntries(Object.entries(t).map(([t,e])=>[t,e.config]))}let tx=tC(d.vc.create({name:"backgroundColor",addAttributes:()=>({stringValue:{default:void 0,parseHTML:t=>t.getAttribute("data-background-color"),renderHTML:t=>({"data-background-color":t.stringValue})}}),parseHTML:()=>[{tag:"span",getAttrs:t=>"string"!=typeof t&&!!t.hasAttribute("data-background-color")&&{stringValue:t.getAttribute("data-background-color")}}],renderHTML:({HTMLAttributes:t})=>["span",t,0]}),"string"),tM=tC(d.vc.create({name:"textColor",addAttributes:()=>({stringValue:{default:void 0,parseHTML:t=>t.getAttribute("data-text-color"),renderHTML:t=>({"data-text-color":t.stringValue})}}),parseHTML:()=>[{tag:"span",getAttrs:t=>"string"!=typeof t&&!!t.hasAttribute("data-text-color")&&{stringValue:t.getAttribute("data-text-color")}}],renderHTML:({HTMLAttributes:t})=>["span",t,0]}),"string"),tT=t=>{let{contentType:e}=$(t.state.doc,t.state.selection.from);return e.spec.content},tL={...th,level:{default:1,values:[1,2,3]}},tA=ty(tb({name:"heading",content:"inline*",group:"blockContent",addAttributes:()=>({level:{default:1,parseHTML:t=>{let e=parseInt(t.getAttribute("data-level"));if(isFinite(e))return e},renderHTML:t=>({"data-level":t.level.toString()})}}),addInputRules(){return[...[1,2,3].map(t=>new d.VK({find:RegExp(`^(#{${t}})\\s$`),handler:({state:e,chain:i,range:n})=>{"inline*"===tT(this.editor)&&i().BNUpdateBlock(e.selection.from,{type:"heading",props:{level:t}}).deleteRange({from:n.from,to:n.to})}}))]},addKeyboardShortcuts(){return{"Mod-Alt-1":()=>"inline*"!==tT(this.editor)||this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor,{type:"heading",props:{level:1}}),"Mod-Alt-2":()=>"inline*"!==tT(this.editor)||this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor,{type:"heading",props:{level:2}}),"Mod-Alt-3":()=>"inline*"!==tT(this.editor)||this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor,{type:"heading",props:{level:3}})}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",getAttrs:t=>"string"!=typeof t&&{level:t.getAttribute("data-level")}},{tag:"h1",attrs:{level:1},node:"heading"},{tag:"h2",attrs:{level:2},node:"heading"},{tag:"h3",attrs:{level:3},node:"heading"}]},renderHTML({node:t,HTMLAttributes:e}){var i,n;return td(this.name,`h${t.attrs.level}`,{...(null==(i=this.options.domAttributes)?void 0:i.blockContent)||{},...e},(null==(n=this.options.domAttributes)?void 0:n.inlineContent)||{})}}),tL),tH={textAlignment:th.textAlignment,backgroundColor:th.backgroundColor,url:{default:""},caption:{default:""},width:{default:512}},tB=t=>{switch(t){case"left":default:return"flex-start";case"center":return"center";case"right":return"flex-end"}},tN=function(t,e){let i=tb({name:t.type,content:"inline"===t.content?"inline*":"",group:"blockContent",selectable:!0,addAttributes:()=>tm(t.propSchema),parseHTML:()=>tw(t,e.parse),renderHTML(){let t=document.createElement("div");return t.setAttribute("data-tmp-placeholder","true"),{dom:t}},addNodeView(){return({getPos:i})=>{var n;let o=this.options.editor,r=tg(i,o,this.editor,t.type),s=(null==(n=this.options.domAttributes)?void 0:n.blockContent)||{};return tf(e.render(r,o),r.type,r.props,t.propSchema,s)}}});if(i.name!==t.type)throw Error("Node name does not match block type. This is a bug in BlockNote.");return tv(t,{node:i,toInternalHTML:(n,o)=>{var r;let s=(null==(r=i.options.domAttributes)?void 0:r.blockContent)||{};return tf(e.render(n,o),n.type,n.props,t.propSchema,s)},toExternalHTML:(n,o)=>{var r,s;let a=(null==(r=i.options.domAttributes)?void 0:r.blockContent)||{},l=null==(s=e.toExternalHTML)?void 0:s.call(e,n,o);return void 0===l&&(l=e.render(n,o)),tf(l,n.type,n.props,t.propSchema,a)}})}({type:"image",propSchema:tH,content:"none"},{render:(t,e)=>{let i;let n=document.createElement("div");n.className="bn-image-block-content-wrapper",n.style.alignItems=tB(t.props.textAlignment);let o=document.createElement("div");o.className="bn-add-image-button";let r=document.createElement("div");r.className="bn-add-image-button-icon";let s=document.createElement("p");s.className="bn-add-image-button-text",s.innerText="Add Image";let a=document.createElement("div");a.className="bn-image-and-caption-wrapper";let l=document.createElement("div");l.className="bn-image-wrapper";let d=document.createElement("img");d.className="bn-image",d.src=t.props.url,d.alt="placeholder",d.contentEditable="false",d.draggable=!1,d.style.width=`${Math.min(t.props.width,e.domElement.firstElementChild.clientWidth)}px`;let c=document.createElement("div");c.className="bn-image-resize-handle",c.style.left="4px";let h=document.createElement("div");h.className="bn-image-resize-handle",h.style.right="4px";let p=document.createElement("p");p.className="bn-image-caption",p.innerText=t.props.caption,p.style.padding=t.props.caption?"4px":"";let u=()=>{var i;let n=(null==(i=e.getSelection())?void 0:i.blocks)||[];void 0!==[e.getTextCursorPosition().block,...n].find(e=>e.id===t.id)?(o.style.outline="4px solid rgb(100, 160, 255)",a.style.outline="4px solid rgb(100, 160, 255)"):(o.style.outline="",a.style.outline="")};e.onEditorContentChange(u),e.onEditorSelectionChange(u);let m=n=>{let o;if(!i){!e.isEditable&&l.contains(c)&&l.contains(h)&&(l.removeChild(c),l.removeChild(h));return}(o="center"===tB(t.props.textAlignment)?"left"===i.handleUsed?i.initialWidth+(i.initialClientX-n.clientX)*2:i.initialWidth+(n.
5clientX-i.initialClientX)*2:"left"===i.handleUsed?i.initialWidth+i.initialClientX-n.clientX:i.initialWidth+n.clientX-i.initialClientX)<64?d.style.width="64px":o>e.domElement.firstElementChild.clientWidth?d.style.width=`${e.domElement.firstElementChild.clientWidth}px`:d.style.width=`${o}px`},g=n=>{(!n.target||!l.contains(n.target)||!e.isEditable)&&l.contains(c)&&l.contains(h)&&(l.removeChild(c),l.removeChild(h)),i&&(i=void 0,e.updateBlock(t,{type:"image",props:{width:parseFloat(d.style.width.slice(0,-2))}}))},f=t=>{t.preventDefault()},b=()=>{e._tiptapEditor.view.dispatch(e._tiptapEditor.state.tr.setMeta(e.imagePanel.plugin,{block:t}))},v=e=>{e.preventDefault(),l.appendChild(c),l.appendChild(h),i={handleUsed:"left",initialWidth:t.props.width,initialClientX:e.clientX}},y=e=>{e.preventDefault(),l.appendChild(c),l.appendChild(h),i={handleUsed:"right",initialWidth:t.props.width,initialClientX:e.clientX}};return o.appendChild(r),o.appendChild(s),a.appendChild(l),l.appendChild(d),a.appendChild(p),""===t.props.url?n.appendChild(o):n.appendChild(a),window.addEventListener("mousemove",m),window.addEventListener("mouseup",g),o.addEventListener("mousedown",f),o.addEventListener("click",b),d.addEventListener("mouseenter",()=>{e.isEditable&&(l.appendChild(c),l.appendChild(h))}),d.addEventListener("mouseleave",t=>{t.relatedTarget===c||t.relatedTarget===h||i||e.isEditable&&l.contains(c)&&l.contains(h)&&(l.removeChild(c),l.removeChild(h))}),c.addEventListener("mousedown",v),h.addEventListener("mousedown",y),{dom:n,destroy:()=>{window.removeEventListener("mousemove",m),window.removeEventListener("mouseup",g),o.removeEventListener("mousedown",f),o.removeEventListener("click",b),c.removeEventListener("mousedown",v),h.removeEventListener("mousedown",y)}}},toExternalHTML:t=>{if(""===t.props.url){let t=document.createElement("p");return t.innerHTML="Add Image",{dom:t}}let e=document.createElement("figure"),i=document.createElement("img");if(i.src=t.props.url,e.appendChild(i),""!==t.props.caption){let i=document.createElement("figcaption");i.innerHTML=t.props.caption,e.appendChild(i)}return{dom:e}},parse:t=>{if("FIGURE"===t.tagName){let e=t.querySelector("img"),i=t.querySelector("figcaption");return{url:(null==e?void 0:e.getAttribute("src"))||"",caption:(null==i?void 0:i.textContent)||(null==e?void 0:e.getAttribute("alt"))||void 0}}if("IMG"===t.tagName)return{url:t.getAttribute("src")||"",caption:t.getAttribute("alt")||void 0}}}),tI=t=>{let{node:e,contentType:i}=$(t.state.doc,t.state.selection.from),n=t.state.selection.anchor===t.state.selection.head;return("bulletListItem"===i.name||"numberedListItem"===i.name)&&!!n&&t.commands.first(({state:t,chain:i,commands:n})=>[()=>n.command(()=>0===e.textContent.length&&n.BNUpdateBlock(t.selection.from,{type:"paragraph",props:{}})),()=>n.command(()=>e.textContent.length>0&&(i().deleteSelection().BNSplitBlock(t.selection.from,!0).run(),!0))])},tP={...th},tO=ty(tb({name:"bulletListItem",content:"inline*",group:"blockContent",addInputRules(){return[new d.VK({find:RegExp("^[-+*]\\s$"),handler:({state:t,chain:e,range:i})=>{"inline*"===tT(this.editor)&&e().BNUpdateBlock(t.selection.from,{type:"bulletListItem",props:{}}).deleteRange({from:i.from,to:i.to})}})]},addKeyboardShortcuts(){return{Enter:()=>tI(this.editor),"Mod-Shift-8":()=>"inline*"!==tT(this.editor)||this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor,{type:"bulletListItem",props:{}})}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]"},{tag:"li",getAttrs:t=>{if("string"==typeof t)return!1;let e=t.parentElement;return null!==e&&("UL"===e.tagName||"DIV"===e.tagName&&"UL"===e.parentElement.tagName)&&{}},node:"bulletListItem"},{tag:"p",getAttrs:t=>{if("string"==typeof t)return!1;let e=t.parentElement;return null!==e&&"bulletListItem"===e.getAttribute("data-content-type")&&{}},priority:300,node:"bulletListItem"}]},renderHTML({HTMLAttributes:t}){var e,i;return td(this.name,"p",{...(null==(e=this.options.domAttributes)?void 0:e.blockContent)||{},...t},(null==(i=this.options.domAttributes)?void 0:i.inlineContent)||{})}}),tP),t_=new c.H$("numbered-list-indexing"),tU=()=>new c.Sy({key:t_,appendTransaction:(t,e,i)=>{let n=i.tr;n.setMeta("numberedListIndexing",!0);let o=!1;return i.doc.descendants((t,e)=>{if("blockContainer"===t.type.name&&"numberedListItem"===t.firstChild.type.name){let t="1",i=$(n.doc,e+1);if(void 0!==i){if(1!==e){let o=$(n.doc,e-2);if(void 0===o)return;if(!(i.depth!==o.depth)){let e=o.contentNode;"numberedListItem"===o.contentType.name&&(t=(parseInt(e.attrs.index)+1).toString())}}i.contentNode.attrs.index!==t&&(o=!0,n.setNodeMarkup(e+1,void 0,{index:t}))}}}),o?n:null}}),tD={...th},tV=ty(tb({name:"numberedListItem",content:"inline*",group:"blockContent",addAttributes:()=>({index:{default:null,parseHTML:t=>t.getAttribute("data-index"),renderHTML:t=>({"data-index":t.index})}}),addInputRules(){return[new d.VK({find:RegExp("^1\\.\\s$"),handler:({state:t,chain:e,range:i})=>{"inline*"===tT(this.editor)&&e().BNUpdateBlock(t.selection.from,{type:"numberedListItem",props:{}}).deleteRange({from:i.from,to:i.to})}})]},addKeyboardShortcuts(){return{Enter:()=>
5tI(this.editor),"Mod-Shift-7":()=>"inline*"!==tT(this.editor)||this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor,{type:"numberedListItem",props:{}})}},addProseMirrorPlugins:()=>[tU()],parseHTML(){return[{tag:"div[data-content-type="+this.name+"]"},{tag:"li",getAttrs:t=>{if("string"==typeof t)return!1;let e=t.parentElement;return null!==e&&("OL"===e.tagName||"DIV"===e.tagName&&"OL"===e.parentElement.tagName)&&{}},node:"numberedListItem"},{tag:"p",getAttrs:t=>{if("string"==typeof t)return!1;let e=t.parentElement;return null!==e&&"numberedListItem"===e.getAttribute("data-content-type")&&{}},priority:300,node:"numberedListItem"}]},renderHTML({HTMLAttributes:t}){var e,i;return td(this.name,"p",{...(null==(e=this.options.domAttributes)?void 0:e.blockContent)||{},...t},(null==(i=this.options.domAttributes)?void 0:i.inlineContent)||{})}}),tD),tR={...th},tz=ty(tb({name:"paragraph",content:"inline*",group:"blockContent",addKeyboardShortcuts(){return{Enter:()=>tI(this.editor),"Mod-Alt-0":()=>"inline*"!==tT(this.editor)||this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor,{type:"paragraph",props:{}})}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]"},{tag:"p",priority:200,node:"paragraph"}]},renderHTML({HTMLAttributes:t}){var e,i;return td(this.name,"p",{...(null==(e=this.options.domAttributes)?void 0:e.blockContent)||{},...t},(null==(i=this.options.domAttributes)?void 0:i.inlineContent)||{})}}),tR),t$=d.hj.create({name:"BlockNoteTableExtension",addProseMirrorPlugins:()=>[(0,w.VH)({cellMinWidth:100}),(0,w.G3)()],addKeyboardShortcuts(){return{Enter:()=>!!this.editor.state.selection.empty&&"tableParagraph"===this.editor.state.selection.$head.parent.type.name&&(this.editor.commands.setHardBreak(),!0),Backspace:()=>{let t=this.editor.state.selection,e=t.empty,i=0===t.$head.parentOffset,n="tableParagraph"===t.$head.node().type.name;return e&&i&&n}}},extendNodeSchema(t){let e={name:t.name,options:t.options,storage:t.storage};return{tableRole:(0,d.nU)((0,d.Nl)(t,"tableRole",e))}}}),tj={...th},tF={paragraph:tz,heading:tA,bulletListItem:tO,numberedListItem:tV,image:tN,table:ty(tb({name:"table",content:"tableRow+",group:"blockContent",tableRole:"table",isolating:!0,parseHTML:()=>[{tag:"table"}],renderHTML({HTMLAttributes:t}){var e,i;return td(this.name,"table",{...(null==(e=this.options.domAttributes)?void 0:e.blockContent)||{},...t},(null==(i=this.options.domAttributes)?void 0:i.inlineContent)||{})}}),tj,[t$,d.NB.create({name:"tableParagraph",group:"tableContent",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:t}){return["p",(0,d.P1)(this.options.HTMLAttributes,t),0]}}),y.x.extend({content:"tableContent"}),v.p.extend({content:"tableContent"}),k.S])},tq=tk(tF),tG={bold:tC(u.ZP,"boolean"),italic:tC(g.ZP,"boolean"),underline:tC(b.Z,"boolean"),strike:tC(f.ZP,"boolean"),code:tC(m.ZP,"boolean"),textColor:tM,backgroundColor:tx},tY=(tS(tG),{text:{config:"text",implementation:{}},link:{config:"link",implementation:{}}});function tW(t,e){return t in e.schema.blockSchema&&e.schema.blockSchema[t]===tq[t]}function tJ(t,e,i){return e.type===t&&e.type in i.schema.blockSchema&&tW(e.type,i)}function tX(t,e,i){return e in i.schema.blockSchema&&t in i.schema.blockSchema[e].propSchema&&i.schema.blockSchema[e].propSchema[t]===th[t]}function tK(t,e,i){return tX(t,e.type,i)}function tZ(t,e){let i,n;if(e.firstChild.descendants((e,o)=>!i&&("blockContainer"!==e.type.name||e.attrs.id!==t||(i=e,n=o+1,!1))),void 0===i||void 0===n)throw Error("Could not find block in the editor with matching ID.");return{node:i,posBeforeNode:n}}function tQ(t,e,i){let n=e._tiptapEditor,o=n.state.tr,r=new Set(t.map(t=>"string"==typeof t?t:t.id)),s=[],a=0;if(n.state.doc.descendants((t,n)=>{if(0===r.size)return!1;if("blockContainer"!==t.type.name||!r.has(t.attrs.id))return!0;s.push(Q(t,e.schema.blockSchema,e.schema.inlineContentSchema,e.schema.styleSchema,e.blockCache)),r.delete(t.attrs.id),a=(null==i?void 0:i(t,n,o,a))||a;let l=o.doc.nodeSize;o.delete(n-a-1,n-a+t.nodeSize+1);let d=o.doc.nodeSize;return a+=l-d,!1}),r.size>0)throw Error("Blocks with the following IDs could not be found in the editor: "+[...r].join(` 6`));return n.view.dispatch(o),s}function t0(){let t=e=>{let i=e.children.length;for(let n=0;n<i;n++){let o=e.children[n];if("element"===o.type&&(t(o),"u"===o.tagName)){if(o.children.length>0){e.children.splice(n,1,...o.children);let t=o.children.length-1;i+=t,n+=t}else e.children.splice(n,1),i--,n--}}};return t}function t1(t){return(0,l.l)().use(s.Z,{fragment:!0}).use(t0).use(E.Z).use(C.Z).use(S.Z).processSync(t).value}tE(tY);let t2=null;function t3(t){if("string"==typeof t){let e=(t2||(t2=document.implementation.createHTMLDocument("title"))).createElement("div");e.innerHTML=t,t=e}return function(t){t.querySelectorAll("li > ul, li > ol").forEach(t=>{let e=Array.prototype.indexOf.call(t.parentElement.childNodes,t),i=t.parentElement,n=Array.from(i.childNodes).slice(e+1);
6t.remove(),n.forEach(t=>{t.remove()}),i.insertAdjacentElement("afterend",t),n.reverse().forEach(e=>{if(3===e.nodeType&&!/\S/.test(e.nodeValue||""))return;let i=document.createElement("li");i.append(e),t.insertAdjacentElement("afterend",i)}),0===i.childNodes.length&&i.remove()})}(t),function(t){t.querySelectorAll("li + ul, li + ol").forEach(t=>{var e,i;let n=t.previousElementSibling,o=document.createElement("div");n.insertAdjacentElement("afterend",o),o.append(n);let r=document.createElement("div");for(r.setAttribute("data-node-type","blockGroup"),o.append(r);(null==(e=o.nextElementSibling)?void 0:e.nodeName)==="UL"||(null==(i=o.nextElementSibling)?void 0:i.nodeName)==="OL";)r.append(o.nextElementSibling)})}(t),t}async function t4(t,e,i,n,o){let s=t3(t),a=r.aw.fromSchema(o).parse(s,{topNode:o.nodes.blockGroup.create()}),l=[];for(let t=0;t<a.childCount;t++)l.push(Q(a.child(t),e,i,n));return l}function t6(t,e){let i=e.value?e.value+` 7`:"",n={};e.lang&&(n["data-language"]=e.lang);let o={type:"element",tagName:"code",properties:n,children:[{type:"text",value:i}]};return e.meta&&(o.data={meta:e.meta}),t.patch(e,o),o={type:"element",tagName:"pre",properties:{},children:[o=t.applyData(e,o)]},t.patch(e,o),o}class t5{constructor(){V(this,"callbacks",{})}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),()=>this.off(t,e)}emit(t,...e){let i=this.callbacks[t];i&&i.forEach(t=>t.apply(this,e))}off(t,e){let i=this.callbacks[t];i&&(e?this.callbacks[t]=i.filter(t=>t!==e):delete this.callbacks[t])}removeAllListeners(){this.callbacks={}}}class t8{constructor(t,e,i){V(this,"state"),V(this,"emitUpdate"),V(this,"preventHide",!1),V(this,"preventShow",!1),V(this,"prevWasEditable",null),V(this,"shouldShow",({state:t})=>!t.selection.empty),V(this,"viewMousedownHandler",()=>{this.preventShow=!0}),V(this,"viewMouseupHandler",()=>{this.preventShow=!1,setTimeout(()=>this.update(this.pmView))}),V(this,"dragHandler",()=>{var t;null!=(t=this.state)&&t.show&&(this.state.show=!1,this.emitUpdate())}),V(this,"focusHandler",()=>{setTimeout(()=>this.update(this.pmView))}),V(this,"blurHandler",t=>{var e;if(this.preventHide){this.preventHide=!1;return}let i=this.pmView.dom.parentElement;t&&t.relatedTarget&&(i===t.relatedTarget||i.contains(t.relatedTarget))||null!=(e=this.state)&&e.show&&(this.state.show=!1,this.emitUpdate())}),V(this,"scrollHandler",()=>{var t;null!=(t=this.state)&&t.show&&(this.state.referencePos=this.getSelectionBoundingBox(),this.emitUpdate())}),this.editor=t,this.pmView=e,this.emitUpdate=()=>{if(!this.state)throw Error("Attempting to update uninitialized formatting toolbar");i(this.state)},e.dom.addEventListener("mousedown",this.viewMousedownHandler),e.dom.addEventListener("mouseup",this.viewMouseupHandler),e.dom.addEventListener("dragstart",this.dragHandler),e.dom.addEventListener("dragover",this.dragHandler),e.dom.addEventListener("focus",this.focusHandler),e.dom.addEventListener("blur",this.blurHandler),document.addEventListener("scroll",this.scrollHandler)}update(t,e){var i,n;let{state:o,composing:r}=t,{doc:s,selection:a}=o,l=e&&e.doc.eq(s)&&e.selection.eq(a);if((null===this.prevWasEditable||this.prevWasEditable===this.editor.isEditable)&&(r||l))return;this.prevWasEditable=this.editor.isEditable;let{ranges:d}=a,c=Math.min(...d.map(t=>t.$from.pos)),h=Math.max(...d.map(t=>t.$to.pos)),p=null==(i=this.shouldShow)?void 0:i.call(this,{view:t,state:o,from:c,to:h});if(this.editor.isEditable&&!this.preventShow&&(p||this.preventHide)){this.state={show:!0,referencePos:this.getSelectionBoundingBox()},this.emitUpdate();return}if(null!=(n=this.state)&&n.show&&!this.preventHide&&(!p||this.preventShow||!this.editor.isEditable)){this.state.show=!1,this.emitUpdate();return}}destroy(){this.pmView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.pmView.dom.removeEventListener("mouseup",this.viewMouseupHandler),this.pmView.dom.removeEventListener("dragstart",this.dragHandler),this.pmView.dom.removeEventListener("dragover",this.dragHandler),this.pmView.dom.removeEventListener("focus",this.focusHandler),this.pmView.dom.removeEventListener("blur",this.blurHandler),document.removeEventListener("scroll",this.scrollHandler)}getSelectionBoundingBox(){let{state:t}=this.pmView,{selection:e}=t,{ranges:i}=e,n=Math.min(...i.map(t=>t.$from.pos)),o=Math.max(...i.map(t=>t.$to.pos));if((0,d.EG)(e)){let t=this.pmView.nodeDOM(n);if(t)return t.getBoundingClientRect()}return(0,d.pr)(this.pmView,n,o)}}let t7=new c.H$("FormattingToolbarPlugin");class t9 extends t5{constructor(t){super(),V(this,"view"),V(this,"plugin"),this.plugin=new c.Sy({key:t7,view:e=>(this.view=new t8(t,e,t=>
7{this.emit("update",t)}),this.view)})}onUpdate(t){return this.on("update",t)}}class et{constructor(t,e,i){V(this,"state"),V(this,"emitUpdate"),V(this,"menuUpdateTimer"),V(this,"startMenuUpdateTimer"),V(this,"stopMenuUpdateTimer"),V(this,"mouseHoveredLinkMark"),V(this,"mouseHoveredLinkMarkRange"),V(this,"keyboardHoveredLinkMark"),V(this,"keyboardHoveredLinkMarkRange"),V(this,"linkMark"),V(this,"linkMarkRange"),V(this,"mouseOverHandler",t=>{if(this.mouseHoveredLinkMark=void 0,this.mouseHoveredLinkMarkRange=void 0,this.stopMenuUpdateTimer(),t.target instanceof HTMLAnchorElement&&"A"===t.target.nodeName){let e=t.target,i=this.pmView.posAtDOM(e,0)+1,n=this.pmView.state.doc.resolve(i);for(let t of n.marks())if(t.type.name===this.pmView.state.schema.mark("link").type.name){this.mouseHoveredLinkMark=t,this.mouseHoveredLinkMarkRange=(0,d.IH)(n,t.type,t.attrs)||void 0;break}}return this.startMenuUpdateTimer(),!1}),V(this,"clickHandler",t=>{var e;let i=this.pmView.dom.parentElement;this.linkMark&&t&&t.target&&!(i===t.target||i.contains(t.target))&&null!=(e=this.state)&&e.show&&(this.state.show=!1,this.emitUpdate())}),V(this,"scrollHandler",()=>{var t;void 0!==this.linkMark&&null!=(t=this.state)&&t.show&&(this.state.referencePos=(0,d.pr)(this.pmView,this.linkMarkRange.from,this.linkMarkRange.to),this.emitUpdate())}),this.editor=t,this.pmView=e,this.emitUpdate=()=>{if(!this.state)throw Error("Attempting to update uninitialized link toolbar");i(this.state)},this.startMenuUpdateTimer=()=>{this.menuUpdateTimer=setTimeout(()=>{this.update()},250)},this.stopMenuUpdateTimer=()=>(this.menuUpdateTimer&&(clearTimeout(this.menuUpdateTimer),this.menuUpdateTimer=void 0),!1),this.pmView.dom.addEventListener("mouseover",this.mouseOverHandler),document.addEventListener("click",this.clickHandler,!0),document.addEventListener("scroll",this.scrollHandler)}editLink(t,e){var i;let n=this.pmView.state.tr.insertText(e,this.linkMarkRange.from,this.linkMarkRange.to);n.addMark(this.linkMarkRange.from,this.linkMarkRange.from+e.length,this.pmView.state.schema.mark("link",{href:t})),this.pmView.dispatch(n),this.pmView.focus(),null!=(i=this.state)&&i.show&&(this.state.show=!1,this.emitUpdate())}deleteLink(){var t;this.pmView.dispatch(this.pmView.state.tr.removeMark(this.linkMarkRange.from,this.linkMarkRange.to,this.linkMark.type).setMeta("preventAutolink",!0)),this.pmView.focus(),null!=(t=this.state)&&t.show&&(this.state.show=!1,this.emitUpdate())}update(){var t;if(!this.pmView.hasFocus())return;let e=this.linkMark;if(this.linkMark=void 0,this.linkMarkRange=void 0,this.keyboardHoveredLinkMark=void 0,this.keyboardHoveredLinkMarkRange=void 0,this.pmView.state.selection.empty){for(let t of this.pmView.state.selection.$from.marks())if(t.type.name===this.pmView.state.schema.mark("link").type.name){this.keyboardHoveredLinkMark=t,this.keyboardHoveredLinkMarkRange=(0,d.IH)(this.pmView.state.selection.$from,t.type,t.attrs)||void 0;break}}if(this.mouseHoveredLinkMark&&(this.linkMark=this.mouseHoveredLinkMark,this.linkMarkRange=this.mouseHoveredLinkMarkRange),this.keyboardHoveredLinkMark&&(this.linkMark=this.keyboardHoveredLinkMark,this.linkMarkRange=this.keyboardHoveredLinkMarkRange),this.linkMark&&this.editor.isEditable){this.state={show:!0,referencePos:(0,d.pr)(this.pmView,this.linkMarkRange.from,this.linkMarkRange.to),url:this.linkMark.attrs.href,text:this.pmView.state.doc.textBetween(this.linkMarkRange.from,this.linkMarkRange.to)},this.emitUpdate();return}if(null!=(t=this.state)&&t.show&&e&&(!this.linkMark||!this.editor.isEditable)){this.state.show=!1,this.emitUpdate();return}}destroy(){this.pmView.dom.removeEventListener("mouseover",this.mouseOverHandler),document.removeEventListener("scroll",this.scrollHandler),document.removeEventListener("click",this.clickHandler,!0)}}let ee=new c.H$("LinkToolbarPlugin");class ei extends t5{constructor(t){super(),V(this,"view"),V(this,"plugin"),V(this,"editLink",(t,e)=>{this.view.editLink(t,e)}),V(this,"deleteLink",()=>{this.view.deleteLink()}),V(this,"startHideTimer",()=>{this.view.startMenuUpdateTimer()}),V(this,"stopHideTimer",()=>
7{this.view.stopMenuUpdateTimer()}),this.plugin=new c.Sy({key:ee,view:e=>(this.view=new et(t,e,t=>{this.emit("update",t)}),this.view)})}onUpdate(t){return this.on("update",t)}}let en=(0,d.Kk)(t=>"blockContainer"===t.type.name);class eo{constructor(t,e){V(this,"state"),V(this,"emitUpdate"),V(this,"pluginState"),V(this,"handleScroll",()=>{var t;if(null!=(t=this.state)&&t.show){let t=document.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);this.state.referencePos=t.getBoundingClientRect(),this.emitUpdate(this.pluginState.triggerCharacter)}}),V(this,"closeMenu",()=>{this.editor._tiptapEditor.view.dispatch(this.editor._tiptapEditor.view.state.tr.setMeta(er,null))}),V(this,"clearQuery",()=>{void 0!==this.pluginState&&this.editor._tiptapEditor.chain().focus().deleteRange({from:this.pluginState.queryStartPos-(this.pluginState.fromUserInput?this.pluginState.triggerCharacter.length:0),to:this.editor._tiptapEditor.state.selection.from}).run()}),this.editor=t,this.pluginState=void 0,this.emitUpdate=t=>{if(!this.state)throw Error("Attempting to update uninitialized suggestions menu");e(t,this.state)},document.addEventListener("scroll",this.handleScroll)}update(t,e){let i=er.getState(e),n=er.getState(t.state),o=void 0!==i&&void 0===n;if(!(void 0===i&&void 0!==n)&&!(void 0!==i&&void 0!==n)&&!o)return;if(this.pluginState=o?i:n,o||!this.editor.isEditable){this.state.show=!1,this.emitUpdate(this.pluginState.triggerCharacter);return}let r=document.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);this.editor.isEditable&&(this.state={show:!0,referencePos:r.getBoundingClientRect(),query:this.pluginState.query},this.emitUpdate(this.pluginState.triggerCharacter))}destroy(){document.removeEventListener("scroll",this.handleScroll)}}let er=new c.H$("SuggestionMenuPlugin");class es extends t5{constructor(t){super(),V(this,"view"),V(this,"plugin"),V(this,"triggerCharacters",[]),V(this,"addTriggerCharacter",t=>{this.triggerCharacters.push(t)}),V(this,"removeTriggerCharacter",t=>{this.triggerCharacters=this.triggerCharacters.filter(e=>e!==t)}),V(this,"closeMenu",()=>this.view.closeMenu()),V(this,"clearQuery",()=>this.view.clearQuery());let e=this.triggerCharacters;this.plugin=new c.Sy({key:er,view:()=>(this.view=new eo(t,(t,e)=>{this.emit(`update ${t}`,e)}),this.view),state:{init(){},apply(t,e,i,n){if(void 0!==t.getMeta("orderedListIndexing"))return e;let o=t.getMeta(er);if("object"==typeof o&&null!==o&&void 0===e)return{triggerCharacter:o.triggerCharacter,fromUserInput:!1!==o.fromUserInput,queryStartPos:n.selection.from,query:"",decorationId:`id_${Math.floor(4294967295*Math.random())}`};if(void 0===e)return e;if(n.selection.from!==n.selection.to||null===o||t.getMeta("focus")||t.getMeta("blur")||t.getMeta("pointer")||void 0!==e.triggerCharacter&&n.selection.from<e.queryStartPos)return;let r={...e};return r.query=n.doc.textBetween(e.queryStartPos,n.selection.from),r}},props:{handleTextInput(t,i,n,o){let r=this.getState(t.state);return!!e.includes(o)&&void 0===r&&(t.dispatch(t.state.tr.insertText(o).scrollIntoView().setMeta(er,{triggerCharacter:o})),!0)},decorations(t){let e=this.getState(t);if(void 0===e)return null;if(!e.fromUserInput){let i=en(t.selection);if(i)return L.EH.create(t.doc,[L.p.node(i.pos,i.pos+i.node.nodeSize,{nodeName:"span",class:"bn-suggestion-decorator","data-decoration-id":e.decorationId})])}return L.EH.create(t.doc,[L.p.inline(e.queryStartPos-e.triggerCharacter.length,e.queryStartPos,{nodeName:"span",class:"bn-suggestion-decorator","data-decoration-id":e.decorationId})])}}})}onUpdate(t,e){return this.triggerCharacters.includes(t)||this.addTriggerCharacter(t),this.on(`update ${t}`,e)}}class ea extends c.Y1{constructor(t,e){super(t,e),V(this,"nodes");let i=t.node();this.nodes=[],t.doc.nodesBetween(t.pos,e.pos,(t,e,n)=>{if(null!==n&&n.eq(i))return this.nodes.push(t),!1})}static create(t,e,i=e){return new ea(t.resolve(e),t.resolve(i))}content(){return new r.p2(r.HY.from(this.nodes),0,0)}eq(t){if(!(t instanceof ea)||this.nodes.length!==t.nodes.length||this.from!==t.from||this.to!==t.to)return!1;for(let e=0;e<this.nodes.length;e++)if(!this.nodes[e].eq(t.nodes[e]))return!1;return!0}map(t,e){let i=e.mapResult(this.from),n=e.mapResult(this.to);return n.deleted?c.Y1.near(t.resolve(i.pos)):i.deleted?c.Y1.near(t.resolve(n.pos)):new ea(t.resolve(i.pos),t.resolve(n.pos))}toJSON(){return{type:"node",anchor:this.anchor,head:this.head}}}function el(t,e){var i;if(!e.dom.isConnected)return;let n=e.posAtCoords(t);if(!n)return;let o=e.domAtPos(n.pos).node;if(o!==e.dom){for(;o&&o.parentNode&&o.parentNode!==e.dom&&!(null!=(i=o.hasAttribute)&&i.call(o,"data-id"));)o=o.parentNode;if(o)return{node:o,id:o.getAttribute("data-id")}}}
7function ed(t,e,i=e){e===i&&(i+=t.state.doc.resolve(e+1).node().nodeSize);let o=t.domAtPos(e).node.cloneNode(!0),r=t.domAtPos(e).node,s=(t,e)=>Array.prototype.indexOf.call(t.children,e),a=s(r,t.domAtPos(e+1).node.parentElement),l=s(r,t.domAtPos(i-1).node.parentElement);for(let t=r.childElementCount-1;t>=0;t--)(t>l||t<a)&&o.removeChild(o.children[t]);ec(),n=o;let d=t.dom.className.split(" ").filter(t=>"ProseMirror"!==t&&"bn-root"!==t&&"bn-editor"!==t).join(" ");n.className=n.className+" bn-drag-preview "+d,document.body.appendChild(n)}function ec(){void 0!==n&&(document.body.removeChild(n),n=void 0)}class eh{constructor(t,e,i){V(this,"state"),V(this,"emitUpdate"),V(this,"horizontalPosAnchoredAtRoot"),V(this,"horizontalPosAnchor"),V(this,"hoveredBlock"),V(this,"isDragging",!1),V(this,"menuFrozen",!1),V(this,"onDragStart",()=>{this.isDragging=!0}),V(this,"onDrop",t=>{if(this.editor._tiptapEditor.commands.blur(),t.synthetic||!this.isDragging)return;let e=this.pmView.posAtCoords({left:t.clientX,top:t.clientY});if(this.isDragging=!1,!e||-1===e.inside){let e=new Event("drop",t),i=this.pmView.dom.firstChild.getBoundingClientRect();e.clientX=i.left+i.width/2,e.clientY=t.clientY,e.dataTransfer=t.dataTransfer,e.preventDefault=()=>t.preventDefault(),e.synthetic=!0,this.pmView.dom.dispatchEvent(e)}}),V(this,"onDragOver",t=>{if(t.synthetic||!this.isDragging)return;let e=this.pmView.posAtCoords({left:t.clientX,top:t.clientY});if(!e||-1===e.inside){let e=new Event("dragover",t),i=this.pmView.dom.firstChild.getBoundingClientRect();e.clientX=i.left+i.width/2,e.clientY=t.clientY,e.dataTransfer=t.dataTransfer,e.preventDefault=()=>t.preventDefault(),e.synthetic=!0,this.pmView.dom.dispatchEvent(e)}}),V(this,"onKeyDown",t=>{var e;null!=(e=this.state)&&e.show&&(this.state.show=!1,this.emitUpdate(this.state)),this.menuFrozen=!1}),V(this,"onMouseDown",t=>{this.state&&!this.state.show&&(this.state.show=!0,this.emitUpdate(this.state)),this.menuFrozen=!1}),V(this,"onMouseMove",t=>{var e,i,n,o,r;if(this.menuFrozen)return;let s=this.pmView.dom.firstChild.getBoundingClientRect(),a=this.pmView.dom.getBoundingClientRect(),l=t.clientX>=a.left&&t.clientX<=a.right&&t.clientY>=a.top&&t.clientY<=a.bottom,d=this.pmView.dom.parentElement;if(l&&t&&t.target&&!(d===t.target||d.contains(t.target))){null!=(e=this.state)&&e.show&&(this.state.show=!1,this.emitUpdate(this.state));return}this.horizontalPosAnchor=s.x;let c=el({left:s.left+s.width/2,top:t.clientY},this.pmView);if(!c||!this.editor.isEditable){null!=(i=this.state)&&i.show&&(this.state.show=!1,this.emitUpdate(this.state));return}if(null!=(n=this.state)&&n.show&&null!=(o=this.hoveredBlock)&&o.hasAttribute("data-id")&&(null==(r=this.hoveredBlock)?void 0:r.getAttribute("data-id"))===c.id)return;this.hoveredBlock=c.node;let h=c.node.firstChild;if(h&&this.editor.isEditable){let t=h.getBoundingClientRect();this.state={show:!0,referencePos:new DOMRect(this.horizontalPosAnchoredAtRoot?this.horizontalPosAnchor:t.x,t.y,t.width,t.height),block:this.editor.getBlock(this.hoveredBlock.getAttribute("data-id"))},this.emitUpdate(this.state)}}),V(this,"onScroll",()=>{var t;if(null!=(t=this.state)&&t.show){let t=this.hoveredBlock.firstChild.getBoundingClientRect();this.state.referencePos=new DOMRect(this.horizontalPosAnchoredAtRoot?this.horizontalPosAnchor:t.x,t.y,t.width,t.height),this.emitUpdate(this.state)}}),this.editor=t,this.pmView=e,this.emitUpdate=()=>{if(!this.state)throw Error("Attempting to update uninitialized side menu");i(this.state)},this.horizontalPosAnchoredAtRoot=!0,this.horizontalPosAnchor=this.pmView.dom.firstChild.getBoundingClientRect().x,document.body.addEventListener("drop",this.onDrop,!0),document.body.addEventListener("dragover",this.onDragOver),this.pmView.dom.addEventListener("dragstart",this.onDragStart),document.body.addEventListener("mousemove",this.onMouseMove,!0),document.addEventListener("scroll",this.onScroll),document.body.addEventListener("mousedown",this.onMouseDown,!0),document.body.addEventListener("keydown",this.onKeyDown,!0)}destroy(){var t;null!=(t=this.state)&&t.show&&(this.state.show=!1,this.emitUpdate(this.state)),document.body.removeEventListener("mousemove",this.onMouseMove,!0),document.body.removeEventListener("dragover",this.onDragOver),this.pmView.dom.removeEventListener("dragstart",this.onDragStart),document.body.removeEventListener("drop",this.onDrop,!0),document.removeEventListener("scroll",this.onScroll),document.body.removeEventListener("mousedown",this.onMouseDown,!0),document.body.removeEventListener("keydown",this.onKeyDown,!0)}addBlock(){var t;null!=(t=this.state)&&t.show&&(this.state.show=!1,this.emitUpdate(this.state)),this.menuFrozen=!0;let e=this.hoveredBlock.firstChild.getBoundingClientRect(),i=this.pmView.posAtCoords({left:e.left+e.width/2,top:e.top+e.height/2});if(!i)return;let n=$(this.editor._tiptapEditor.state.doc,i.pos);if(void 0===n)return;let{contentNode:o,startPos:r,endPos:s}=n;if("inline*"!==o.type.spec.content||0!==o.textContent.length){let t=s+1;this.editor._tiptapEditor.chain().BNCreateBlock(t).setTextSelection(t+2).run()}else this.editor._tiptapEditor.commands.setTextSelection(r+1);this.pmView.focus(),this.pmView.dispatch(this.pmView.state.tr.scrollIntoView().setMeta(er,{triggerCharacter:"/",fromUserInput:!1}))}}let ep=new c.H$("SideMenuPlugin");class eu extends t5{constructor(t){super(),V(this,"view"),V(this,"plugin"),V(this,"addBlock",()=>this.view.addBlock()),V(this,"blockDragStart",t=>{this.view.isDragging=!0,function(t,e){if(!t.dataTransfer)return;let i=e.prosemirrorView,o=i.dom.getBoundingClientRect(),r=function(t,e){let i=el(t,e);if(i&&1===i.node.nodeType){let t=e.docView,n=t.nearestDesc(i.node,!0);return n&&n!==t?n.posBefore:null}return null}({left:o.left+o.width/2,top:t.clientY},i);if(null!=r){let o=i.state.selection,s=i.state.doc,{from:a,to:l}=function(t,e){let i,n;let o="blockContent"===e.resolve(t.from).node().type.spec.group,r="blockContent"===e.resolve(t.to).node().type.spec.group,s=Math.min(t.$anchor.depth,t.$head.depth);if(o&&r){let o=t.$from.start(s-1),r=t.$to.end(s-1);i=e.resolve(o-1).pos,n=e.resolve(r+1).pos}else i=t.from,n=t.to;return{from:i,to:n}}(o,s),d=a<=r&&r<l,h=o.$anchor.node()!==o.$head.node()||o instanceof ea;d&&h?(i.dispatch(i.state.tr.setSelection(ea.create(s,a,l))),ed(i,a,l)):(i.dispatch(i.state.tr.setSelection(c.qv.create(i.state.doc,r))),ed(i,r));let p=i.state.selection.content(),u=e._tiptapEditor.schema,m=to(u,e).seri
7alizeProseMirrorFragment(p.content),g=tn(u,e).exportProseMirrorFragment(p.content),f=t1(g);t.dataTransfer.clearData(),t.dataTransfer.setData("blocknote/html",m),t.dataTransfer.setData("text/html",g),t.dataTransfer.setData("text/plain",f),t.dataTransfer.effectAllowed="move",t.dataTransfer.setDragImage(n,0,0),i.dragging={slice:p,move:!0}}}(t,this.editor)}),V(this,"blockDragEnd",()=>ec()),V(this,"freezeMenu",()=>this.view.menuFrozen=!0),V(this,"unfreezeMenu",()=>this.view.menuFrozen=!1),this.editor=t,this.plugin=new c.Sy({key:ep,view:e=>(this.view=new eh(t,e,t=>{this.emit("update",t)}),this.view)})}onUpdate(t){return this.on("update",t)}}class em{constructor(t,e,i){V(this,"state"),V(this,"emitUpdate"),V(this,"prevWasEditable",null),V(this,"mouseDownHandler",()=>{var t;null!=(t=this.state)&&t.show&&(this.state.show=!1,this.emitUpdate())}),V(this,"dragstartHandler",()=>{var t;null!=(t=this.state)&&t.show&&(this.state.show=!1,this.emitUpdate())}),V(this,"blurHandler",t=>{var e;let i=this.pmView.dom.parentElement;t&&t.relatedTarget&&(i===t.relatedTarget||i.contains(t.relatedTarget))||null!=(e=this.state)&&e.show&&(this.state.show=!1,this.emitUpdate())}),V(this,"scrollHandler",()=>{var t;if(null!=(t=this.state)&&t.show){let t=document.querySelector(`[data-node-type="blockContainer"][data-id="${this.state.block.id}"]`);this.state.referencePos=t.getBoundingClientRect(),this.emitUpdate()}}),this.pluginKey=t,this.pmView=e,this.emitUpdate=()=>{if(!this.state)throw Error("Attempting to update uninitialized image panel");i(this.state)},e.dom.addEventListener("mousedown",this.mouseDownHandler),e.dom.addEventListener("dragstart",this.dragstartHandler),e.dom.addEventListener("blur",this.blurHandler),document.addEventListener("scroll",this.scrollHandler)}update(t,e){var i,n;let o=this.pluginKey.getState(t.state);if(!(null!=(i=this.state)&&i.show)&&o.block){let t=document.querySelector(`[data-node-type="blockContainer"][data-id="${o.block.id}"]`);this.state={show:!0,referencePos:t.getBoundingClientRect(),block:o.block},this.emitUpdate();return}t.state.selection.eq(e.selection)&&t.state.doc.eq(e.doc)||null==(n=this.state)||!n.show||(this.state.show=!1,this.emitUpdate())}destroy(){this.pmView.dom.removeEventListener("mousedown",this.mouseDownHandler),this.pmView.dom.removeEventListener("dragstart",this.dragstartHandler),this.pmView.dom.removeEventListener("blur",this.blurHandler),document.removeEventListener("scroll",this.scrollHandler)}}let eg=new c.H$("ImagePanelPlugin");class ef extends t5{constructor(t){super(),V(this,"view"),V(this,"plugin"),this.plugin=new c.Sy({key:eg,view:t=>(this.view=new em(eg,t,t=>{this.emit("update",t)}),this.view),state:{init:()=>({block:void 0}),apply:t=>{var e;return{block:null==(e=t.getMeta(eg))?void 0:e.block}}}})}onUpdate(t){return this.on("update",t)}}function eb(){o||((o=document.createElement("div")).innerHTML="_",o.style.opacity="0",o.style.height="1px",o.style.width="1px",document.body.appendChild(o))}function ev(t){return Array.prototype.indexOf.call(t.parentElement.childNodes,t)}class ey{constructor(t,e,i){V(this,"state"),V(this,"emitUpdate"),V(this,"tableId"),V(this,"tablePos"),V(this,"menuFrozen",!1),V(this,"prevWasEditable",null),V(this,"mouseMoveHandler",t=>{var e;let i;if(this.menuFrozen)return;let n=function(t){for(;t&&"TD"!==t.nodeName&&"TH"!==t.nodeName;)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}(t.target);if(!n||!this.editor.isEditable){null!=(e=this.state)&&e.show&&(this.state.show=!1,this.emitUpdate());return}let o=ev(n),r=ev(n.parentElement),s=n.getBoundingClientRect(),a=n.parentElement.parentElement.getBoundingClientRect(),l=el(s,this.pmView);if(!l)throw Error("Found table cell element, but could not find surrounding blockContent element.");if(this.tableId=l.id,void 0===this.state||!this.state.show||this.tableId!==l.id||this.state.rowIndex!==r||this.state.colIndex!==o)return this.editor._tiptapEditor.state.doc.descendants((t,e)=>!("u">typeof i)&&("blockContainer"!==t.type.name||t.attrs.id!==l.id||(i=Q(t,this.editor.schema.blockSchema,this.editor.schema.inlineContentSchema,this.editor.schema.styleSchema,this.editor.blockCache),this.tablePos=e+1,!1))),this.state={show:!0,referencePosCell:s,referencePosTable:a,block:i,colIndex:o,rowIndex:r,draggingState:void 0},this.emitUpdate(),!1}),V(this,"dragOverHandler",t=>{var e;if((null==(e=this.state)?void 0:e.draggingState)===void 0)return;t.preventDefault(),t.dataTransfer.dropEffect="move",function(t){t.forEach(t=>{let e=document.getElementsByClassName(t);for(let t=0;t<e.length;t++)e[t].style.visibility="hidden"})}(["column-resize-handle","prosemirror-dropcursor-block","prosemirror-dropcursor-inline"]);let i={left:Math.min(Math.max(t.clientX,this.state.referencePosTable.left+1),this.state.referencePosTable.right-1),top:Math.min(Math.max(t.clientY,this.state.referencePosTable.top+1),this.state.referencePosTable.bottom-1)},n=document.elementsFromPoint(i.left,i.top).filter(t=>"TD"===t.tagName||"TH"===t.tagName);if(0===n.length)throw Error("Could not find table cell element that the mouse
7cursor is hovering over.");let o=n[0],r=!1,s=ev(o.parentElement),a=ev(o),l="row"===this.state.draggingState.draggedCellOrientation?this.state.rowIndex:this.state.colIndex,d=("row"===this.state.draggingState.draggedCellOrientation?s:a)!==l;(this.state.rowIndex!==s||this.state.colIndex!==a)&&(this.state.rowIndex=s,this.state.colIndex=a,this.state.referencePosCell=o.getBoundingClientRect(),r=!0);let c="row"===this.state.draggingState.draggedCellOrientation?i.top:i.left;this.state.draggingState.mousePos!==c&&(this.state.draggingState.mousePos=c,r=!0),r&&this.emitUpdate(),d&&this.pmView.dispatch(this.pmView.state.tr.setMeta(ek,!0))}),V(this,"dropHandler",t=>{if(void 0===this.state||void 0===this.state.draggingState)return;t.preventDefault();let e=this.state.block.content.rows;if("row"===this.state.draggingState.draggedCellOrientation){let t=e[this.state.draggingState.originalIndex];e.splice(this.state.draggingState.originalIndex,1),e.splice(this.state.rowIndex,0,t)}else{let t=e.map(t=>t.cells[this.state.draggingState.originalIndex]);e.forEach((e,i)=>{e.cells.splice(this.state.draggingState.originalIndex,1),e.cells.splice(this.state.colIndex,0,t[i])})}this.editor.updateBlock(this.state.block,{type:"table",content:{type:"tableContent",rows:e}})}),V(this,"scrollHandler",()=>{var t;if(null!=(t=this.state)&&t.show){let t=document.querySelector(`[data-node-type="blockContainer"][data-id="${this.tableId}"] table`),e=t.querySelector(`tr:nth-child(${this.state.rowIndex+1}) > td:nth-child(${this.state.colIndex+1})`);this.state.referencePosTable=t.getBoundingClientRect(),this.state.referencePosCell=e.getBoundingClientRect(),this.emitUpdate()}}),this.editor=t,this.pmView=e,this.emitUpdate=()=>{if(!this.state)throw Error("Attempting to update uninitialized image toolbar");i(this.state)},e.dom.addEventListener("mousemove",this.mouseMoveHandler),document.addEventListener("dragover",this.dragOverHandler),document.addEventListener("drop",this.dropHandler),document.addEventListener("scroll",this.scrollHandler)}destroy(){this.pmView.dom.removeEventListener("mousedown",this.mouseMoveHandler),document.removeEventListener("dragover",this.dragOverHandler),document.removeEventListener("drop",this.dropHandler),document.removeEventListener("scroll",this.scrollHandler)}}let ek=new c.H$("TableHandlesPlugin");class ew extends t5{constructor(t){super(),V(this,"view"),V(this,"plugin"),V(this,"colDragStart",t=>{if(void 0===this.view.state)throw Error("Attempted to drag table column, but no table block was hovered prior.");this.view.state.draggingState={draggedCellOrientation:"col",originalIndex:this.view.state.colIndex,mousePos:t.clientX},this.view.emitUpdate(),this.editor._tiptapEditor.view.dispatch(this.editor._tiptapEditor.state.tr.setMeta(ek,{draggedCellOrientation:this.view.state.draggingState.draggedCellOrientation,originalIndex:this.view.state.colIndex,newIndex:this.view.state.colIndex,tablePos:this.view.tablePos})),eb(),t.dataTransfer.setDragImage(o,0,0),t.dataTransfer.effectAllowed="move"}),V(this,"rowDragStart",t=>{if(void 0===this.view.state)throw Error("Attempted to drag table row, but no table block was hovered prior.");this.view.state.draggingState={draggedCellOrientation:"row",originalIndex:this.view.state.rowIndex,mousePos:t.clientY},this.view.emitUpdate(),this.editor._tiptapEditor.view.dispatch(this.editor._tiptapEditor.state.tr.setMeta(ek,{draggedCellOrientation:this.view.state.draggingState.draggedCellOrientation,originalIndex:this.view.state.rowIndex,newIndex:this.view.state.rowIndex,tablePos:this.view.tablePos})),eb(),t.dataTransfer.setDragImage(o,0,0),t.dataTransfer.effectAllowed="copyMove"}),V(this,"dragEnd",()=>{if(void 0===this.view.state)throw Error("Attempted to drag table row, but no table block was hovered prior.");this.view.state.draggingState=void 0,this.view.emitUpdate(),this.editor._tiptapEditor.view.dispatch(this.editor._tiptapEditor.state.tr.setMeta(ek,null)),o&&(document.body.removeChild(o),o=void 0)}),V(this,"freezeHandles",()=>{this.view.menuFrozen=!0}),V(this,"unfreezeHandles",()=>{this.view.menuFrozen=!1}),this.editor=t,this.plugin=new c.Sy({key:ek,view:e=>(this.view=new ey(t,e,t=>
7{this.emit("update",t)}),this.view),props:{decorations:t=>{if(void 0===this.view||void 0===this.view.state||void 0===this.view.state.draggingState||void 0===this.view.tablePos)return;let e="row"===this.view.state.draggingState.draggedCellOrientation?this.view.state.rowIndex:this.view.state.colIndex,i=[];if(e===this.view.state.draggingState.originalIndex)return L.EH.create(t.doc,i);let n=t.doc.resolve(this.view.tablePos+1),o=n.node();if("row"===this.view.state.draggingState.draggedCellOrientation){let o=t.doc.resolve(n.posAtIndex(e)+1),r=o.node();for(let n=0;n<r.childCount;n++){let r=t.doc.resolve(o.posAtIndex(n)+1),s=r.node(),a=r.pos+(e>this.view.state.draggingState.originalIndex?s.nodeSize-2:0);i.push(L.p.widget(a,()=>{let t=document.createElement("div");return t.className="bn-table-drop-cursor",t.style.left="0",t.style.right="0",e>this.view.state.draggingState.originalIndex?t.style.bottom="-2px":t.style.top="-3px",t.style.height="4px",t}))}}else for(let r=0;r<o.childCount;r++){let o=t.doc.resolve(n.posAtIndex(r)+1),s=t.doc.resolve(o.posAtIndex(e)+1),a=s.node(),l=s.pos+(e>this.view.state.draggingState.originalIndex?a.nodeSize-2:0);i.push(L.p.widget(l,()=>{let t=document.createElement("div");return t.className="bn-table-drop-cursor",t.style.top="0",t.style.bottom="0",e>this.view.state.draggingState.originalIndex?t.style.right="-2px":t.style.left="-3px",t.style.width="4px",t}))}return L.EH.create(t.doc,i)}}})}onUpdate(t){return this.on("update",t)}}function eE(t,e){let i=t.state.selection.content().content,n=to(t.state.schema,e).serializeProseMirrorFragment(i),o=tn(t.state.schema,e).exportProseMirrorFragment(i),r=t1(o);return{internalHTML:n,externalHTML:o,plainText:r}}let eC=t=>d.hj.create({name:"copyToClipboard",addProseMirrorPlugins:()=>[new c.Sy({props:{handleDOMEvents:{copy(e,i){i.preventDefault(),i.clipboardData.clearData(),"node"in e.state.selection&&"blockContent"===e.state.selection.node.type.spec.group&&e.dispatch(e.state.tr.setSelection(new c.qv(e.state.doc.resolve(e.state.selection.from-1))));let{internalHTML:n,externalHTML:o,plainText:r}=eE(e,t);return i.clipboardData.setData("blocknote/html",n),i.clipboardData.setData("text/html",o),i.clipboardData.setData("text/plain",r),!0},dragstart(e,i){if(!("node"in e.state.selection)||"blockContent"!==e.state.selection.node.type.spec.group)return;e.dispatch(e.state.tr.setSelection(new c.qv(e.state.doc.resolve(e.state.selection.from-1)))),i.preventDefault(),i.dataTransfer.clearData();let{internalHTML:n,externalHTML:o,plainText:r}=eE(e,t);return i.dataTransfer.setData("blocknote/html",n),i.dataTransfer.setData("text/html",o),i.dataTransfer.setData("text/plain",r),!0}}}})]}),eS=["blocknote/html","text/html","text/plain"],ex=t=>d.hj.create({name:"pasteFromClipboard",addProseMirrorPlugins:()=>[new c.Sy({props:{handleDOMEvents:{paste(e,i){i.preventDefault();let n=null;for(let t of eS)if(i.clipboardData.types.includes(t)){n=t;break}if(null!==n){let e=i.clipboardData.getData(n);"text/html"===n&&(e=t3(e.trim()).innerHTML),t._tiptapEditor.view.pasteHTML(e)}return!0}}}})]}),eM=d.hj.create({name:"blockBackgroundColor",addGlobalAttributes:()=>[{types:["blockContainer"],attributes:{backgroundColor:{default:th.backgroundColor.default,parseHTML:t=>t.hasAttribute("data-background-color")?t.getAttribute("data-background-color"):th.backgroundColor.default,renderHTML:t=>t.backgroundColor!==th.backgroundColor.default&&{"data-background-color":t.backgroundColor}}}}]}),eT=new c.H$("blocknote-placeholder"),eL=d.hj.create({name:"placeholder",addOptions:()=>({placeholders:{default:"Enter text or type '/' for commands",heading:"Heading",bulletListItem:"List",numberedListItem:"List"}}),addProseMirrorPlugins(){let t=this.options.placeholders;return[new c.Sy({key:eT,view:()=>{let e=document.createElement("style");document.head.appendChild(e);let i=e.sheet,n=(t="")=>`.bn-block-content${t} .bn-inline-content:has(> .ProseMirror-trailingBreak):before`,o=(t,e=!0)=>{let i=e?"[data-is-empty-and-focused]":"";return"default"===t?n(i):n(i+`[data-content-type="${t}"]`)};for(let[e,n]of Object.entries(t)){let t="default"===e;i.insertRule(`${o(e,t)}{ content: ${JSON.stringify(n)}; }`),t||i.insertRule(`${o(e,!0)}{ content: ${JSON.stringify(n)}; }`)}return{destroy:()=>{document.head.removeChild(e)}}},props:{decorations:t=>{let{doc:e,selection:i}=t;if(!this.editor.isEditable||!i.empty)return;let n=i.$anchor,o=n.parent;if(o.content.size>0)return null;let r=n.before(),s=L.p.node(r,r+o.nodeSize,{"data-is-empty-and-focused":"true"});return L.EH.create(e,[s])}}})]}}),eA=d.hj.create({name:"textAlignment",addGlobalAttributes:()=>[{types:["paragraph","heading","bulletListItem","numberedListItem"],attributes:{textAlignment:{default:"left",parseHTML:t=>t.getAttribute("data-text-alignment"),renderHTML:t=>"left"!==t.textAlignment&&{"data-text-alignment":t.textAlignment}}}}]}),eH=d.hj.create({name:"blockTextColor",addGlobalAttributes:()=>[{types:["blockContainer"],attributes:{textColor:{default:th.textColor.default,parseHTML:t=>t.hasAttribute("data-text-color")?t.getAttribute("data-text-color"):th.textColor.default,renderHTML:t=>t.textColor!==th.textColor.default&&{"data-text-color":t.textColor}}}}]}),eB=d.hj.create({name:"trailingNode",addProseMirrorPlugins(){let t=new c.H$(this.name);return[new c.Sy({key:t,appendTransaction:(e,i,n)=>{let{doc:o,tr:r,schema:s}=n,a=t.getState(n),l=o.content.size-2,d=s.nodes.blockContainer,c=s.nodes.paragraph;if(a)return r.insert(l,d.create(void 0,c.create()))},state:{init:(t,e)=>{},apply:(t,e)=>{if(!t.docChanged)return e;let i=t.doc.lastChild;if(!i||"blockGroup"!==i.type.name)throw Error("Expected blockGroup");
7if(!(i=i.lastChild)||"blockContainer"!==i.type.name)throw Error("Expected blockContainer");let n=i.firstChild;if(!n)throw Error("Expected blockContent");return i.nodeSize>4||"inline*"!==n.type.spec.content}}})]}}),eN=new c.H$("non-editable-block"),eI=()=>new c.Sy({key:eN,props:{handleKeyDown:(t,e)=>{!("node"in t.state.selection)||1!==e.key.length||e.ctrlKey||e.altKey||e.metaKey||e.shiftKey||e.preventDefault()}}}),eP=new c.H$("previous-blocks"),eO={index:"index",level:"level",type:"type",depth:"depth","depth-change":"depth-change"},e_=()=>{let t;return new c.Sy({key:eP,view(e){return{update:async(e,i)=>{var n;(null==(n=this.key)?void 0:n.getState(e.state).updatedBlocks.size)>0&&(t=setTimeout(()=>{e.dispatch(e.state.tr.setMeta(eP,{clearUpdate:!0}))},0))},destroy:()=>{t&&clearTimeout(t)}}},state:{init:()=>({prevTransactionOldBlockAttrs:{},currentTransactionOldBlockAttrs:{},updatedBlocks:new Set}),apply(t,e,i,n){if(e.currentTransactionOldBlockAttrs={},e.updatedBlocks.clear(),!t.docChanged||i.doc.eq(n.doc))return e;let o={},r=new Map((0,d.N2)(i.doc,t=>t.attrs.id).map(t=>[t.node.attrs.id,t]));for(let s of(0,d.N2)(n.doc,t=>t.attrs.id)){let a=r.get(s.node.attrs.id),l=null==a?void 0:a.node.firstChild,d=s.node.firstChild;if(a&&l&&d){let r={index:d.attrs.index,level:d.attrs.level,type:d.type.name,depth:n.doc.resolve(s.pos).depth},c={index:l.attrs.index,level:l.attrs.level,type:l.type.name,depth:i.doc.resolve(a.pos).depth};o[s.node.attrs.id]=c,t.getMeta("numberedListIndexing")&&(s.node.attrs.id in e.prevTransactionOldBlockAttrs&&(c=e.prevTransactionOldBlockAttrs[s.node.attrs.id]),"numberedListItem"===r.type&&(c.index=r.index)),e.currentTransactionOldBlockAttrs[s.node.attrs.id]=c,JSON.stringify(c)!==JSON.stringify(r)&&(c["depth-change"]=c.depth-r.depth,e.updatedBlocks.add(s.node.attrs.id))}}return e.prevTransactionOldBlockAttrs=o,e}},props:{decorations(t){let e=this.getState(t);if(0===e.updatedBlocks.size)return;let i=[];return t.doc.descendants((t,n)=>{if(!t.attrs.id||!e.updatedBlocks.has(t.attrs.id))return;let o=e.currentTransactionOldBlockAttrs[t.attrs.id],r={};for(let[t,e]of Object.entries(o))r["data-prev-"+eO[t]]=e||"none";let s=L.p.node(n,n+t.nodeSize,{...r});i.push(s)}),L.EH.create(t.doc,i)}}})},eU={blockColor:"data-block-color",blockStyle:"data-block-style",id:"data-id",depth:"data-depth",depthChange:"data-depth-change"},eD=d.NB.create({name:"blockContainer",group:"blockContainer",content:"blockContent blockGroup?",priority:50,defining:!0,parseHTML:()=>[{tag:"div",getAttrs:t=>{if("string"==typeof t)return!1;let e={};for(let[i,n]of Object.entries(eU))t.getAttribute(n)&&(e[i]=t.getAttribute(n));return"blockContainer"===t.getAttribute("data-node-type")&&e}}],renderHTML({HTMLAttributes:t}){var e;let i=document.createElement("div");for(let[e,n]of(i.className="bn-block-outer",i.setAttribute("data-node-type","blockOuter"),Object.entries(t)))"class"!==e&&i.setAttribute(e,n);let n={...(null==(e=this.options.domAttributes)?void 0:e.block)||{},...t},o=document.createElement("div");for(let[t,e]of(o.className=ta("bn-block",n.class),o.setAttribute("data-node-type",this.name),Object.entries(n)))"class"!==t&&o.setAttribute(t,e);return i.appendChild(o),{dom:i,contentDOM:o}},addCommands(){return{BNCreateBlock:t=>({state:e,dispatch:i})=>{let n=e.schema.nodes.blockContainer.createAndFill();return i&&e.tr.insert(t,n),!0},BNDeleteBlock:t=>({state:e,dispatch:i})=>{let n=$(e.doc,t);if(void 0===n)return!1;let{startPos:o,endPos:r}=n;return i&&e.tr.deleteRange(o,r),!0},BNUpdateBlock:(t,e)=>({state:i,dispatch:n})=>{let o=$(i.doc,t);if(void 0===o)return!1;let{startPos:s,endPos:a,node:l,contentNode:d}=o;if(n){if(void 0!==e.children){let t=[];for(let n of e.children)t.push(K(n,i.schema,this.options.editor.schema.styleSchema));2===l.childCount?i.tr.replace(s+d.nodeSize+1,a-1,new r.p2(r.HY.from(t),0,0)):i.tr.insert(s+d.nodeSize,i.schema.nodes.blockGroup.create({},t))}let t=d.type.name,n=e.type||t,o="keep";if(e.content){if("string"==typeof e.content)o=[i.schema.text(e.content)];else if(Array.isArray(e.content))o=W(e.content,i.schema,this.options.editor.schema.styleSchema);else if("tableContent"===e.content.type)o=J(e.content,i.schema,this.options.editor.schema.styleSchema);else throw new q(e.content.type)}else{let e=i.schema.nodes[t].spec.content,r=i.schema.nodes[n].spec.content;""===e||r!==e&&(o=[])}
7"keep"===o?i.tr.setNodeMarkup(s,void 0===e.type?void 0:i.schema.nodes[e.type],{...d.attrs,...e.props}):i.tr.replaceWith(s,a,i.schema.nodes[n].create({...d.attrs,...e.props},o)).setSelection(""===i.schema.nodes[n].spec.content?new c.qv(i.tr.doc.resolve(s)):new c.Bs("inline*"===i.schema.nodes[n].spec.content?i.tr.doc.resolve(s):i.tr.doc.resolve(s+4))),i.tr.setNodeMarkup(s-1,void 0,{...l.attrs,...e.props})}return!0},BNMergeBlocks:t=>({state:e,dispatch:i})=>{let n="blockContainer"===e.doc.resolve(t+1).node().type.name,o="blockContainer"===e.doc.resolve(t-1).node().type.name;if(!n||!o)return!1;let{node:s,contentNode:a,startPos:l,endPos:d,depth:h}=$(e.doc,t+1);if(2===s.childCount){let t=e.doc.resolve(l+a.nodeSize+1),n=e.doc.resolve(d-1),o=t.blockRange(n);i&&e.tr.lift(o,h-1)}let p=t-1,u=$(e.doc,p);for(;u.numChildBlocks>0;)if(p--,void 0===(u=$(e.doc,p)))return!1;return i&&(i(e.tr.deleteRange(l,l+a.nodeSize).replace(p-1,l,new r.p2(a.content,0,0)).scrollIntoView()),e.tr.setSelection(new c.Bs(e.doc.resolve(p-1)))),!0},BNSplitBlock:(t,e)=>({state:i,dispatch:n})=>{let o=$(i.doc,t);if(void 0===o)return!1;let{contentNode:s,contentType:a,startPos:l,endPos:d,depth:h}=o,p=i.doc.cut(l+1,t),u=i.doc.cut(t,d-1),m=i.schema.nodes.blockContainer.createAndFill(),g=d+1,f=g+2;return n&&(i.tr.insert(g,m),i.tr.replace(f,f+1,u.content.size>0?new r.p2(r.HY.from(u),h+2,h+2):void 0),e&&i.tr.setBlockType(f,f,i.schema.node(a).type,s.attrs),i.tr.setSelection(new c.Bs(i.doc.resolve(f))),i.tr.replace(l+1,d-1,p.content.size>0?new r.p2(r.HY.from(p),h+2,h+2):void 0)),!0}}},addProseMirrorPlugins:()=>[e_(),eI()],addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.first(({commands:t})=>[()=>t.deleteSelection(),()=>t.undoInputRule(),()=>t.command(({state:e})=>{let{contentType:i,startPos:n}=$(e.doc,e.selection.from),o=e.selection.from===n+1,r="paragraph"===i.name;return!!o&&!r&&t.BNUpdateBlock(e.selection.from,{type:"paragraph",props:{}})}),()=>t.command(({state:e})=>{let{startPos:i}=$(e.doc,e.selection.from);return e.selection.from===i+1&&t.liftListItem("blockContainer")}),()=>t.command(({state:e})=>{let{depth:i,startPos:n}=$(e.doc,e.selection.from),o=e.selection.from===n+1,r=e.selection.empty;return 2!==n&&!!o&&!!r&&2===i&&t.BNMergeBlocks(n-1)})]),Delete:()=>this.editor.commands.first(({commands:t})=>[()=>t.deleteSelection(),()=>t.command(({state:e})=>{let{node:i,depth:n,endPos:o}=$(e.doc,e.selection.from),r=o===e.doc.nodeSize-4,s=e.selection.from===o-1,a=e.selection.empty,l=2===i.childCount;if(!r&&s&&a&&!l){let i=n,r=o+2,s=e.doc.resolve(r).depth;for(;s<i;)i=s,r+=2,s=e.doc.resolve(r).depth;return t.BNMergeBlocks(r-1)}return!1})]),Enter:()=>this.editor.commands.first(({commands:t})=>[()=>t.command(({state:e})=>{let{node:i,depth:n}=$(e.doc,e.selection.from),o=0===e.selection.$anchor.parentOffset,r=e.selection.anchor===e.selection.head,s=0===i.textContent.length;return!!o&&!!r&&!!s&&n>2&&t.liftListItem("blockContainer")}),()=>t.command(({state:t,chain:e})=>{let{node:i,endPos:n}=$(t.doc,t.selection.from),o=0===t.selection.$anchor.parentOffset,r=t.selection.anchor===t.selection.head,s=0===i.textContent.length;if(o&&r&&s){let t=n+1;return e().BNCreateBlock(t).setTextSelection(t+2).run(),!0}return!1}),()=>t.command(({state:t,chain:e})=>{let{node:i}=$(t.doc,t.selection.from),n=0===t.selection.$anchor.parentOffset;return 0!==i.textContent.length&&(e().deleteSelection().BNSplitBlock(t.selection.from,n).run(),!0)})]),Tab:()=>(this.editor.commands.sinkListItem("blockContainer"),!0),"Shift-Tab":()=>(this.editor.commands.liftListItem("blockContainer"),!0)}}}),eV=d.NB.create({name:"blockGroup",group:"blockGroup",content:"blockContainer+",parseHTML:()=>[{tag:"div",getAttrs:t=>"string"!=typeof t&&"blockGroup"===t.getAttribute("data-node-type")&&null}],renderHTML({HTMLAttributes:t}){var e;let i={...(null==(e=this.options.domAttributes)?void 0:e.blockGroup)||{},...t},n=document.createElement("div");for(let[t,e]of(n.className=ta("bn-block-group",i.class),n.setAttribute("data-node-type","blockGroup"),Object.entries(i)))"class"!==t&&n.setAttribute(t,e);return{dom:n,contentDOM:n}}}),eR=d.NB.create({name:"doc",topNode:!0,content:"blockGroup"}),ez=t=>{var e;
7let i=[d.Rw.ClipboardTextSerializer,d.Rw.Commands,d.Rw.Editable,d.Rw.FocusEvents,d.Rw.Tabindex,N.f,eL.configure({...void 0!==t.placeholders?{placeholders:t.placeholders}:{}}),R.configure({types:["blockContainer"]}),I.U,_.x,O.rU,...Object.values(t.styleSpecs).map(t=>t.implementation.mark),eH,eM,eA,eR,eD.configure({editor:t.editor,domAttributes:t.domAttributes}),eV.configure({domAttributes:t.domAttributes}),...Object.values(t.inlineContentSpecs).filter(t=>"link"!==t.config&&"text"!==t.config).map(e=>e.implementation.node.configure({editor:t.editor})),...Object.values(t.blockSpecs).flatMap(e=>[...(e.implementation.requiredExtensions||[]).map(e=>e.configure({editor:t.editor,domAttributes:t.domAttributes})),e.implementation.node.configure({editor:t.editor,domAttributes:t.domAttributes})]),eC(t.editor),ex(t.editor),B.m.configure({width:5,color:"#ddeeff"}),eB];return t.collaboration?(i.push(A.ZP.configure({fragment:t.collaboration.fragment})),null!=(e=t.collaboration.provider)&&e.awareness&&i.push(H.Z.configure({user:t.collaboration.user,render:t.collaboration.renderCursor||(t=>{let e=document.createElement("span");e.classList.add("collaboration-cursor__caret"),e.setAttribute("style",`border-color: ${t.color}`);let i=document.createElement("span");i.classList.add("collaboration-cursor__label"),i.setAttribute("style",`background-color: ${t.color}`),i.insertBefore(document.createTextNode(t.name),null);let n=document.createTextNode("â "),o=document.createTextNode("â ");return e.insertBefore(n,null),e.insertBefore(i,null),e.insertBefore(o,null),e}),provider:t.collaboration.provider}))):i.push(P.A),i};function e$(t,e){let i=r.HY.from(t.content);for(let t=0;t<i.childCount;t++)if("blockContent"===i.child(t).type.spec.group){let n=[i.child(t)];if(t+1<i.childCount&&"blockGroup"===i.child(t+1).type.spec.group){let e=i.child(t+1).child(0).child(0);("bulletListItem"===e.type.name||"numberedListItem"===e.type.name)&&(n.push(i.child(t+1)),i=function(t,e){let i=[];return t.forEach((t,n,o)=>{o!==e&&i.push(t)}),r.HY.from(i)}(i,t+1))}let o=e.state.schema.nodes.blockContainer.create(void 0,n);i=i.replaceChild(t,o)}return new r.p2(i,t.openStart,t.openEnd)}class ej{constructor(t){V(this,"blockSpecs"),V(this,"inlineContentSpecs"),V(this,"styleSpecs"),V(this,"blockSchema"),V(this,"inlineContentSchema"),V(this,"styleSchema"),V(this,"BlockNoteEditor","only for types"),V(this,"Block","only for types"),V(this,"PartialBlock","only for types"),this.blockSpecs=(null==t?void 0:t.blockSpecs)||tF,this.inlineContentSpecs=(null==t?void 0:t.inlineContentSpecs)||tY,this.styleSpecs=(null==t?void 0:t.styleSpecs)||tG,this.blockSchema=tk(this.blockSpecs),this.inlineContentSchema=tE(this.inlineContentSpecs),this.styleSchema=tS(this.styleSpecs)}static create(t){return new ej(t)}}class eF extends d.ML{constructor(t,e){let i,n;super({...t,content:void 0}),V(this,"_state"),V(this,"mount",t=>{t?(this.options.element=t,this.createViewAlternative()):this.destroy()});let o=this.schema,s=o.nodes.doc.createAndFill;o.nodes.doc.createAndFill=(...t)=>{if(i)return i;let e=JSON.parse(JSON.stringify(s.apply(o.nodes.doc,t).toJSON()));return e.content[0].content[0].attrs.id="initialBlockId",i=r.NB.fromJSON(o,e)};try{let i=null==t?void 0:t.content.map(t=>K(t,this.schema,e).toJSON());n=(0,d.OE)({type:"doc",content:[{type:"blockGroup",content:i}]},this.schema,this.options.parseOptions)}catch(e){throw console.error("Error creating document from blocks passed as `initialContent`. Caused by exception: ",e),Error("Error creating document from blocks passed as `initialContent`:\n"+ +JSON.stringify(t.content))}this._state=c.yy.create({doc:n,schema:this.schema})}get state(){return this.view&&(this._state=this.view.state),this._state}createView(){}createViewAlternative(){queueMicrotask(()=>{this.view=new L.tk(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:this.state});let t=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(t),this.createNodeViews()})}}let eq={enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!1};class eG{constructor(t){var e,i,n,o,r,s,a,l;if(V(this,"_tiptapEditor"),V(this,"blockCache",new WeakMap),V(this,"schema"),V(this,"blockImplementations"),V(this,"inlineContentImplementations"),V(this,"styleImplementations"),V(this,"formattingToolbar"),V(this,"linkToolbar"),V(this,"sideMenu"),V(this,"suggestionMenus"),V(this,"imagePanel"),V(this,"tableHandles"),V(this,"uploadFile"),this.options=t,t.onEditorContentChange)throw Error("onEditorContentChange initialization option is deprecated, use <BlockNoteView onChange={...} />, the useEditorChange(...) hook, or editor.onChange(...)");if(t.onTextCursorPositionChange)throw Error("onTextCursorPositionChange initialization option is deprecated, use <BlockNoteView onSelectionChange={...} />, the useEditorSelectionChange(...) hook, or editor.onSelectionChange(...)");if(t.onEditorReady)throw Error("onEditorReady is deprecated. Editor is immediately ready for use after creation.");
7if(t.editable)throw Error("editable initialization option is deprecated, use <BlockNoteView editable={true/false} />, or alternatively editor.isEditable = true/false");let c={defaultStyles:!0,schema:t.schema||ej.create(),...t};this.schema=c.schema,this.blockImplementations=c.schema.blockSpecs,this.inlineContentImplementations=c.schema.inlineContentSpecs,this.styleImplementations=c.schema.styleSpecs,this.formattingToolbar=new t9(this),this.linkToolbar=new ei(this),this.sideMenu=new eu(this),this.suggestionMenus=new es(this),tW("image",this)&&(this.imagePanel=new ef(this)),tW("table",this)&&(this.tableHandles=new ew(this));let h=ez({editor:this,placeholders:c.placeholders,domAttributes:c.domAttributes||{},blockSchema:this.schema.blockSchema,blockSpecs:this.schema.blockSpecs,styleSpecs:this.schema.styleSpecs,inlineContentSpecs:this.schema.inlineContentSpecs,collaboration:c.collaboration}),p=d.hj.create({name:"BlockNoteUIExtension",addProseMirrorPlugins:()=>[this.formattingToolbar.plugin,this.linkToolbar.plugin,this.sideMenu.plugin,this.suggestionMenus.plugin,...this.imagePanel?[this.imagePanel.plugin]:[],...this.tableHandles?[this.tableHandles.plugin]:[]]});h.push(p),this.uploadFile=c.uploadFile,c.collaboration&&c.initialContent&&console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider");let u=c.initialContent||(t.collaboration?[{type:"paragraph",id:"initialBlockId"}]:[{type:"paragraph",id:R.options.generateID()}]);if(!Array.isArray(u)||0===u.length)throw Error("initialContent must be a non-empty array of blocks, received: "+u);let m={...eq,...c._tiptapOptions,content:u,extensions:!1===c.enableBlockNoteExtensions?(null==(e=c._tiptapOptions)?void 0:e.extensions)||[]:[...(null==(i=c._tiptapOptions)?void 0:i.extensions)||[],...h],editorProps:{...null==(n=c._tiptapOptions)?void 0:n.editorProps,attributes:{...null==(r=null==(o=c._tiptapOptions)?void 0:o.editorProps)?void 0:r.attributes,...null==(s=c.domAttributes)?void 0:s.editor,class:ta("bn-editor",c.defaultStyles?"bn-default-styles":"",(null==(l=null==(a=c.domAttributes)?void 0:a.editor)?void 0:l.class)||"")},transformPasted:e$}};this._tiptapEditor=new eF(m,this.schema.styleSchema)}static create(t={}){return new eG(t)}mount(t){this._tiptapEditor.mount(t)}get prosemirrorView(){return this._tiptapEditor.view}get domElement(){return this._tiptapEditor.view.dom}isFocused(){return this._tiptapEditor.view.hasFocus()}focus(){this._tiptapEditor.view.focus()}get topLevelBlocks(){return this.topLevelBlocks}get document(){let t=[];return this._tiptapEditor.state.doc.firstChild.descendants(e=>(t.push(Q(e,this.schema.blockSchema,this.schema.inlineContentSchema,this.schema.styleSchema,this.blockCache)),!1)),t}getBlock(t){let e;let i="string"==typeof t?t:t.id;return this._tiptapEditor.state.doc.firstChild.descendants(t=>!("u">typeof e)&&("blockContainer"!==t.type.name||t.attrs.id!==i||(e=Q(t,this.schema.blockSchema,this.schema.inlineContentSchema,this.schema.styleSchema,this.blockCache),!1))),e}forEachBlock(t,e=!1){let i=this.document.slice();e&&i.reverse(),function i(n){for(let o of n)if(!t(o)||!i(e?o.children.slice().reverse():o.children))return!1;return!0}(i)}onEditorContentChange(t){this._tiptapEditor.on("update",t)}onEditorSelectionChange(t){this._tiptapEditor.on("selectionUpdate",t)}getTextCursorPosition(){let t,e;let{node:i,depth:n,startPos:o,endPos:r}=$(this._tiptapEditor.state.doc,this._tiptapEditor.state.selection.from),s=this._tiptapEditor.state.doc.resolve(r).index(n-1),a=this._tiptapEditor.state.doc.resolve(r+1).node().childCount;return s>0&&(t=this._tiptapEditor.state.doc.resolve(o-2).node()),s<a-1&&(e=this._tiptapEditor.state.doc.resolve(r+2).node()),{block:Q(i,this.schema.blockSchema,this.schema.inlineContentSchema,this.schema.styleSchema,this.blockCache),prevBlock:void 0===t?void 0:Q(t,this.schema.blockSchema,this.schema.inlineContentSchema,this.schema.styleSchema,this.blockCache),nextBlock:void 0===e?void 0:Q(e,this.schema.blockSchema,this.schema.inlineContentSchema,this.schema.styleSchema,this.blockCache)}}setTextCursorPosition(t,e="start"){let{posBeforeNode:i}=tZ("string"==typeof t?t:t.id,this._tiptapEditor.state.doc),{startPos:n,contentNode:o}=$(this._tiptapEditor.state.doc,i+2),r=this.schema.blockSchema[o.type.name].
7content;if("none"===r){this._tiptapEditor.commands.setNodeSelection(n);return}if("inline"===r)"start"===e?this._tiptapEditor.commands.setTextSelection(n+1):this._tiptapEditor.commands.setTextSelection(n+o.nodeSize-1);else if("table"===r)"start"===e?this._tiptapEditor.commands.setTextSelection(n+4):this._tiptapEditor.commands.setTextSelection(n+o.nodeSize-4);else throw new q(r)}getSelection(){if(this._tiptapEditor.state.selection.from===this._tiptapEditor.state.selection.to||"node"in this._tiptapEditor.state.selection)return;let t=[];return this._tiptapEditor.state.doc.descendants((e,i)=>"blockContent"!==e.type.spec.group||i+e.nodeSize<this._tiptapEditor.state.selection.from||i>this._tiptapEditor.state.selection.to||(t.push(Q(this._tiptapEditor.state.doc.resolve(i).node(),this.schema.blockSchema,this.schema.inlineContentSchema,this.schema.styleSchema,this.blockCache)),!1)),{blocks:t}}get isEditable(){return this._tiptapEditor.isEditable}set isEditable(t){this._tiptapEditor.options.editable!==t&&this._tiptapEditor.setEditable(t)}insertBlocks(t,e,i="before"){return function(t,e,i="before",n){let o=n._tiptapEditor,r="string"==typeof e?e:e.id,s=[];for(let e of t)s.push(K(e,o.schema,n.schema.styleSchema));let{node:a,posBeforeNode:l}=tZ(r,o.state.doc);if("before"===i&&o.view.dispatch(o.state.tr.insert(l,s)),"after"===i&&o.view.dispatch(o.state.tr.insert(l+a.nodeSize,s)),"nested"===i&&a.childCount<2){let t=o.state.schema.nodes.blockGroup.create({},s);o.view.dispatch(o.state.tr.insert(l+a.firstChild.nodeSize+1,t))}let d=[];for(let t of s)d.push(Q(t,n.schema.blockSchema,n.schema.inlineContentSchema,n.schema.styleSchema,n.blockCache));return d}(t,e,i,this)}updateBlock(t,e){return function(t,e,i){let n=i._tiptapEditor,{posBeforeNode:o}=tZ("string"==typeof t?t:t.id,n.state.doc);return n.commands.BNUpdateBlock(o+1,e),Q(n.state.doc.resolve(o+1).node(),i.schema.blockSchema,i.schema.inlineContentSchema,i.schema.styleSchema,i.blockCache)}(t,e,this)}removeBlocks(t){return tQ(t,this)}replaceBlocks(t,e){return function(t,e,i){let n=i._tiptapEditor,o=[];for(let t of e)o.push(K(t,n.schema,i.schema.styleSchema));let r="string"==typeof t[0]?t[0]:t[0].id,s=tQ(t,i,(t,e,i,n)=>{if(t.attrs.id===r){let t=i.doc.nodeSize;return i.insert(e,o),n+t-i.doc.nodeSize}return n}),a=[];for(let t of o)a.push(Q(t,i.schema.blockSchema,i.schema.inlineContentSchema,i.schema.styleSchema,i.blockCache));return{insertedBlocks:a,removedBlocks:s}}(t,e,this)}insertInlineContent(t){let e=W(t,this._tiptapEditor.schema,this.schema.styleSchema);!function(t,e,i,n={updateSelection:!0}
7){let o=i._tiptapEditor,r=o.state.tr,{from:s,to:a}="number"==typeof t?{from:t,to:t}:{from:t.from,to:t.to},l=!0,c=!0,h="";if(e.forEach(t=>{t.check(),l&&t.isText&&0===t.marks.length?h+=t.text:l=!1,c=!!c&&t.isBlock}),s===a&&c){let{parent:t}=r.doc.resolve(s);!t.isTextblock||t.type.spec.code||t.childCount||(s-=1,a+=1)}l?r.insertText(h,s,a):r.replaceWith(s,a,e),n.updateSelection&&(0,d.nj)(r,r.steps.length-1,-1),o.view.dispatch(r)}({from:this._tiptapEditor.state.selection.from,to:this._tiptapEditor.state.selection.to},e,this)}getActiveStyles(){let t={};for(let e of this._tiptapEditor.state.selection.$to.marks()){let i=this.schema.styleSchema[e.type.name];if(!i){console.warn("mark not found in styleschema",e.type.name);continue}"boolean"===i.propSchema?t[i.type]=!0:t[i.type]=e.attrs.stringValue}return t}addStyles(t){for(let[e,i]of(this._tiptapEditor.view.focus(),Object.entries(t))){let t=this.schema.styleSchema[e];if(!t)throw Error(`style ${e} not found in styleSchema`);if("boolean"===t.propSchema)this._tiptapEditor.commands.setMark(e);else if("string"===t.propSchema)this._tiptapEditor.commands.setMark(e,{stringValue:i});else throw new q(t.propSchema)}}removeStyles(t){for(let e of(this._tiptapEditor.view.focus(),Object.keys(t)))this._tiptapEditor.commands.unsetMark(e)}toggleStyles(t){for(let[e,i]of(this._tiptapEditor.view.focus(),Object.entries(t))){let t=this.schema.styleSchema[e];if(!t)throw Error(`style ${e} not found in styleSchema`);if("boolean"===t.propSchema)this._tiptapEditor.commands.toggleMark(e);else if("string"===t.propSchema)this._tiptapEditor.commands.toggleMark(e,{stringValue:i});else throw new q(t.propSchema)}}getSelectedText(){return this._tiptapEditor.state.doc.textBetween(this._tiptapEditor.state.selection.from,this._tiptapEditor.state.selection.to)}getSelectedLinkUrl(){return this._tiptapEditor.getAttributes("link").href}createLink(t,e){if(""===t)return;let{from:i,to:n}=this._tiptapEditor.state.selection;e||(e=this._tiptapEditor.state.doc.textBetween(i,n));let o=this._tiptapEditor.schema.mark("link",{href:t});this._tiptapEditor.view.dispatch(this._tiptapEditor.view.state.tr.insertText(e,i,n).addMark(i,i+e.length,o))}canNestBlock(){let{startPos:t,depth:e}=$(this._tiptapEditor.state.doc,this._tiptapEditor.state.selection.from);return this._tiptapEditor.state.doc.resolve(t).index(e-1)>0}nestBlock(){this._tiptapEditor.commands.sinkListItem("blockContainer")}canUnnestBlock(){let{depth:t}=$(this._tiptapEditor.state.doc,this._tiptapEditor.state.selection.from);return t>2}unnestBlock(){this._tiptapEditor.commands.liftListItem("blockContainer")}async blocksToHTMLLossy(t=this.document){return tn(this._tiptapEditor.schema,this).exportBlocks(t)}async tryParseHTMLToBlocks(t){return t4(t,this.schema.blockSchema,this.schema.inlineContentSchema,this.schema.styleSchema,this._tiptapEditor.schema)}async blocksToMarkdownLossy(t=this.document){return t1(tn(this._tiptapEditor.schema,this).exportBlocks(t))}async tryParseMarkdownToBlocks(t){var e,i,n,o;return e=this.schema.blockSchema,i=this.schema.inlineContentSchema,n=this.schema.styleSchema,o=this._tiptapEditor.schema,t4((0,l.l)().use(x.Z).use(C.Z).use(M.Z,{handlers:{...T.q,code:t6}}).use(a.Z).processSync(t).value,e,i,n,o)}updateCollaborationUserInfo(t){if(!this.options.collaboration)throw Error("Cannot update collaboration user info when collaboration is disabled.");this._tiptapEditor.commands.updateUser(t)}onChange(t){let e=()=>{t(this)};return this._tiptapEditor.on("update",e),()=>{this._tiptapEditor.off("update",e)}}onSelectionChange(t){let e=()=>{t(this)};return this._tiptapEditor.on("selectionUpdate",e),()=>{this._tiptapEditor.off("selectionUpdate",e)}}}function eY(t,e){let i=t.getTextCursorPosition().block;if(void 0===i.content)throw Error("Slash Menu open in a block that doesn't contain content.");Array.isArray(i.content)&&(1===i.content.length&&F(i.content[0])&&"text"===i.content[0].type&&"/"===i.content[0].text||0===i.content.length)?t.updateBlock(i,e):(t.insertBlocks([e],i,"after"),t.setTextCursorPosition(t.getTextCursorPosition().nextBlock,"end"));let n=t.getTextCursorPosition().block;return function(t){let e=t.getTextCursorPosition().block,i=t.schema.blockSchema[e.type].content;for(;"none"===i;)e=t.getTextCursorPosition().nextBlock,i=t.schema.blockSchema[e.type].content,t.setTextCursorPosition(e,"end")}(t),n}function eW(t){let e=[];return tW("heading",t)&&e.push({title:"Heading 1",onItemClick:()=>{eY(t,{type:"heading",props:{level:1}})},subtext:"Used for a top-level heading",badge:ts("Mod-Alt-1"),aliases:["h","heading1","h1"],group:"Headings"},{title:"Heading 2",onItemClick:()=>{eY(t,{type:"heading",props:{level:2}})},subtext:"Used for key sections",badge:ts("Mod-Alt-2"),aliases:["h2","heading2","subheading"],group:"Headings"},{title:"Heading 3",onItemClick:()=>{eY(t,{type:"heading",props:{level:3}})},subtext:"Used for subsections and group headings",badge:ts("Mod-Alt-3"),aliases:["h3","heading3","subheading"],group:"Headings"}),tW("numberedListItem",t)&&e.push({title:"Numbered List",onItemClick:()=>{eY(t,{type:"numberedListItem"})}
7,subtext:"Used to display a numbered list",badge:ts("Mod-Shift-7"),aliases:["ol","li","list","numberedlist","numbered list"],group:"Basic blocks"}),tW("bulletListItem",t)&&e.push({title:"Bullet List",onItemClick:()=>{eY(t,{type:"bulletListItem"})},subtext:"Used to display an unordered list",badge:ts("Mod-Shift-8"),aliases:["ul","li","list","bulletlist","bullet list"],group:"Basic blocks"}),tW("paragraph",t)&&e.push({title:"Paragraph",onItemClick:()=>{eY(t,{type:"paragraph"})},subtext:"Used for the body of your document",badge:ts("Mod-Alt-0"),aliases:["p","paragraph"],group:"Basic blocks"}),tW("table",t)&&e.push({title:"Table",onItemClick:()=>{eY(t,{type:"table",content:{type:"tableContent",rows:[{cells:["","",""]},{cells:["","",""]}]}})},subtext:"Used for for tables",aliases:["table"],group:"Advanced",badge:void 0}),tW("image",t)&&e.push({title:"Image",onItemClick:()=>{let e=eY(t,{type:"image"});t.prosemirrorView.dispatch(t._tiptapEditor.state.tr.setMeta(t.imagePanel.plugin,{block:e}))},subtext:"Insert an image",aliases:["image","imageUpload","upload","img","picture","media","url","drive","dropbox"],group:"Media"}),e}function eJ(t,e){return t.filter(({title:t,aliases:i})=>t.toLowerCase().startsWith(e.toLowerCase())||i&&0!==i.filter(t=>t.toLowerCase().startsWith(e.toLowerCase())).length)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.