@blocknote/core 0.9.5 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocknote.js +684 -673
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +5 -5
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -2
- package/src/BlockNoteEditor.ts +19 -7
- package/src/api/nodeConversions/nodeConversions.ts +0 -13
- package/src/extensions/Blocks/nodes/Block.module.css +1 -4
- package/src/extensions/Blocks/nodes/BlockContent/ImageBlockContent/ImageBlockContent.ts +30 -0
- package/src/extensions/SideMenu/SideMenuPlugin.ts +11 -0
- package/types/src/BlockNoteEditor.d.ts +2 -1
- package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +1 -0
package/dist/blocknote.umd.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
`?t.nodes.hardBreak.create():t.text(n,e))}function
|
|
1
|
+
(function(m,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("@tiptap/core"),require("@tiptap/extension-bold"),require("@tiptap/extension-code"),require("@tiptap/extension-collaboration"),require("@tiptap/extension-collaboration-cursor"),require("@tiptap/extension-dropcursor"),require("@tiptap/extension-gapcursor"),require("@tiptap/extension-hard-break"),require("@tiptap/extension-history"),require("@tiptap/extension-italic"),require("@tiptap/extension-link"),require("@tiptap/extension-strike"),require("@tiptap/extension-text"),require("@tiptap/extension-underline"),require("prosemirror-model"),require("prosemirror-state"),require("uuid"),require("prosemirror-view"),require("rehype-parse"),require("rehype-remark"),require("rehype-stringify"),require("remark-gfm"),require("remark-parse"),require("remark-rehype"),require("remark-stringify"),require("unified"),require("hast-util-from-dom")):typeof define=="function"&&define.amd?define(["exports","@tiptap/core","@tiptap/extension-bold","@tiptap/extension-code","@tiptap/extension-collaboration","@tiptap/extension-collaboration-cursor","@tiptap/extension-dropcursor","@tiptap/extension-gapcursor","@tiptap/extension-hard-break","@tiptap/extension-history","@tiptap/extension-italic","@tiptap/extension-link","@tiptap/extension-strike","@tiptap/extension-text","@tiptap/extension-underline","prosemirror-model","prosemirror-state","uuid","prosemirror-view","rehype-parse","rehype-remark","rehype-stringify","remark-gfm","remark-parse","remark-rehype","remark-stringify","unified","hast-util-from-dom"],g):(m=typeof globalThis<"u"?globalThis:m||self,g(m.blocknote={},m.core,m.extensionBold,m.extensionCode,m.Collaboration,m.CollaborationCursor,m.extensionDropcursor,m.extensionGapcursor,m.extensionHardBreak,m.extensionHistory,m.extensionItalic,m.extensionLink,m.extensionStrike,m.extensionText,m.extensionUnderline,m.prosemirrorModel,m.prosemirrorState,m.uuid,m.pv,m.rehypeParse,m.rehypeRemark,m.rehypeStringify,m.remarkGfm,m.remarkParse,m.remarkRehype,m.remarkStringify,m.unified,m.hastUtilFromDom))})(this,function(m,g,O,se,ae,le,de,ce,ue,pe,he,me,fe,ge,ke,B,y,be,H,ye,ve,we,Ce,Ee,Z,Se,j,Q){"use strict";var Hn=Object.defineProperty;var Ln=(m,g,O)=>g in m?Hn(m,g,{enumerable:!0,configurable:!0,writable:!0,value:O}):m[g]=O;var u=(m,g,O)=>(Ln(m,typeof g!="symbol"?g+"":g,O),O);const L=o=>o&&typeof o=="object"&&"default"in o?o:{default:o};function Te(o){if(o&&typeof o=="object"&&"default"in o)return o;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const e in o)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(o,e);Object.defineProperty(t,e,n.get?n:{enumerable:!0,get:()=>o[e]})}}return t.default=o,Object.freeze(t)}const Be=L(ae),Me=L(le),xe=Te(H),tt=L(ye),_e=L(ve),et=L(we),nt=L(Ce),Ie=L(Ee),Ae=L(Z),Pe=L(Se),z={bnEditor:"_bnEditor_12je0_3",bnRoot:"_bnRoot_12je0_19",defaultStyles:"_defaultStyles_12je0_34",dragPreview:"_dragPreview_12je0_57","collaboration-cursor__caret":"_collaboration-cursor__caret_12je0_63","collaboration-cursor__label":"_collaboration-cursor__label_12je0_74"};function ot(o){const t=o.attrs.id,e=o.firstChild,n=e.type,i=o.childCount===2?o.lastChild.childCount:0;return{id:t,node:o,contentNode:e,contentType:n,numChildBlocks:i}}function E(o,t){const n=o.nodeSize-2;if(t<=1)for(t=1+1;o.resolve(t).parent.type.name!=="blockContainer"&&t<n;)t++;else if(t>=n)for(t=n-1;o.resolve(t).parent.type.name!=="blockContainer"&&t>1;)t--;o.resolve(t).parent.type.name==="blockGroup"&&t++;const i=o.resolve(t),r=i.depth;let s=i.node(r),l=r;for(;;){if(l<0)throw new Error("Could not find blockContainer node. This can only happen if the underlying BlockNote schema has been edited.");if(s.type.name==="blockContainer")break;l-=1,s=i.node(l)}const{id:a,contentNode:d,contentType:c,numChildBlocks:h}=ot(s),f=i.start(l),p=i.end(l);return{id:a,node:s,contentNode:d,contentType:c,numChildBlocks:h,startPos:f,endPos:p,depth:l}}const _={backgroundColor:{default:"default"},textColor:{default:"default"},textAlignment:{default:"left",values:["left","center","right","justify"]}},He=g.Extension.create({name:"blockBackgroundColor",addGlobalAttributes(){return[{types:["blockContainer"],attributes:{backgroundColor:{default:_.backgroundColor.default,parseHTML:o=>o.hasAttribute("data-background-color")?o.getAttribute("data-background-color"):_.backgroundColor.default,renderHTML:o=>o.backgroundColor!==_.backgroundColor.default&&{"data-background-color":o.backgroundColor}}}}]},addCommands(){return{setBlockBackgroundColor:(o,t)=>({state:e,view:n})=>{const i=E(e.doc,o);return i===void 0?!1:(e.tr.setNodeAttribute(i.startPos-1,"backgroundColor",t),n.focus(),!0)}}}}),Le=g.Mark.create({name:"backgroundColor",addAttributes(){return{color:{default:void 0,parseHTML:o=>o.getAttribute("data-background-color"),renderHTML:o=>({"data-background-color":o.color})}}},parseHTML(){return[{tag:"span",getAttrs:o=>typeof o=="string"?!1:o.hasAttribute("data-background-color")?{color:o.getAttribute("data-background-color")}:!1}]},renderHTML({HTMLAttributes:o}){return["span",o,0]},addCommands(){return{setBackgroundColor:o=>({commands:t})=>o!==_.backgroundColor.default?t.setMark(this.name,{color:o}):t.unsetMark(this.name)}}});function Ne(o,t=JSON.stringify){const e={};return o.filter(n=>{const i=t(n);return Object.prototype.hasOwnProperty.call(e,i)?!1:e[i]=!0})}function De(o){const t=o.filter((n,i)=>o.indexOf(n)!==i);return Ne(t)}const W=g.Extension.create({name:"uniqueID",priority:1e4,addOptions(){return{attributeName:"id",types:[],generateID:()=>{if(typeof window<"u"&&window.__TEST_OPTIONS){const o=window.__TEST_OPTIONS;return o.mockID===void 0?o.mockID=0:o.mockID++,o.mockID.toString()}return be.v4()},filterTransaction:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{[this.options.attributeName]:{default:null,parseHTML:o=>o.getAttribute(`data-${this.options.attributeName}`),renderHTML:o=>({[`data-${this.options.attributeName}`]:o[this.options.attributeName]})}}}]},addProseMirrorPlugins(){let o=null,t=!1;return[new y.Plugin({key:new y.PluginKey("uniqueID"),appendTransaction:(e,n,i)=>{const r=e.some(k=>k.docChanged)&&!n.doc.eq(i.doc),s=this.options.filterTransaction&&e.some(k=>{let w,S;return!(!((S=(w=this.options).filterTransaction)===null||S===void 0)&&S.call(w,k))});if(!r||s)return;const{tr:l}=i,{types:a,attributeName:d,generateID:c}=this.options,h=g.combineTransactionSteps(n.doc,e),{mapping:f}=h;if(g.getChangedRanges(h).forEach(({newRange:k})=>{const w=g.findChildrenInRange(i.doc,k,I=>a.includes(I.type.name)),S=w.map(({node:I})=>I.attrs[d]).filter(I=>I!==null),T=De(S);w.forEach(({node:I,pos:M})=>{let C;const x=(C=l.doc.nodeAt(M))===null||C===void 0?void 0:C.attrs[d];if(x===null){l.setNodeMarkup(M,void 0,{...I.attrs,[d]:c()});return}const{deleted:b}=f.invert().mapResult(M);b&&T.includes(x)&&l.setNodeMarkup(M,void 0,{...I.attrs,[d]:c()})})}),!!l.steps.length)return l},view(e){const n=i=>{let r;o=!((r=e.dom.parentElement)===null||r===void 0)&&r.contains(i.target)?e.dom.parentElement:null};return window.addEventListener("dragstart",n),{destroy(){window.removeEventListener("dragstart",n)}}},props:{handleDOMEvents:{drop:(e,n)=>{let i;return(o!==e.dom.parentElement||((i=n.dataTransfer)===null||i===void 0?void 0:i.effectAllowed)==="copy")&&(o=null,t=!0),!1},paste:()=>(t=!0,!1)},transformPasted:e=>{if(!t)return e;const{types:n,attributeName:i}=this.options,r=s=>{const l=[];return s.forEach(a=>{if(a.isText){l.push(a);return}if(!n.includes(a.type.name)){l.push(a.copy(r(a.content)));return}const d=a.type.create({...a.attrs,[i]:null},r(a.content),a.marks);l.push(d)}),B.Fragment.from(l)};return t=!1,new B.Slice(r(e.content),e.openStart,e.openEnd)}}})]}}),it=()=>/Mac/.test(navigator.platform)||/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent);function Oe(o){return it()?o.replace("Mod","⌘"):o.replace("Mod","Ctrl")}function A(...o){return o.filter(t=>t).join(" ")}class rt extends Error{constructor(t){super(`Unreachable case: ${t}`)}}const st=new Set(["bold","italic","underline","strike","code"]),at=new Set(["textColor","backgroundColor"]);function lt(o,t){const e=[];for(const[n,i]of Object.entries(o.styles))st.has(n)?e.push(t.mark(n)):at.has(n)&&e.push(t.mark(n,{color:i}));return o.text.split(/(\n)/g).filter(n=>n.length>0).map(n=>n===`
|
|
2
|
+
`?t.nodes.hardBreak.create():t.text(n,e))}function Re(o,t){const e=t.marks.link.create({href:o.href});return dt(o.content,t).map(n=>{if(n.type.name==="text")return n.mark([...n.marks,e]);if(n.type.name==="hardBreak")return n;throw new Error("unexpected node type")})}function dt(o,t){const e=[];if(typeof o=="string")return e.push(...lt({type:"text",text:o,styles:{}},t)),e;for(const n of o)e.push(...lt(n,t));return e}function ct(o,t){const e=[];for(const n of o)if(n.type==="link")e.push(...Re(n,t));else if(n.type==="text")e.push(...dt([n],t));else throw new rt(n);return e}function q(o,t){let e=o.id;e===void 0&&(e=W.options.generateID());let n=o.type;n===void 0&&(n="paragraph");let i;if(!o.content)i=t.nodes[n].create(o.props);else if(typeof o.content=="string")i=t.nodes[n].create(o.props,t.text(o.content));else{const l=ct(o.content,t);i=t.nodes[n].create(o.props,l)}const r=[];if(o.children)for(const l of o.children)r.push(q(l,t));const s=t.nodes.blockGroup.create({},r);return t.nodes.blockContainer.create({id:e,...o.props},r.length>0?[i,s]:i)}function ze(o){const t=[];let e;return o.content.forEach(n=>{if(n.type.name==="hardBreak"){e?e.type==="text"?e.text+=`
|
|
3
3
|
`:e.type==="link"&&(e.content[e.content.length-1].text+=`
|
|
4
4
|
`):e={type:"text",text:`
|
|
5
|
-
`,styles:{}};return}const i={};let r;for(const s of n.marks)if(s.type.name==="link")r=s;else if(rt.has(s.type.name))i[s.type.name]=!0;else if(st.has(s.type.name))i[s.type.name]=s.attrs.color;else throw Error("Mark is of an unrecognized type: "+s.type.name);e?e.type==="text"?r?(t.push(e),e={type:"link",href:r.attrs.href,content:[{type:"text",text:n.textContent,styles:i}]}):JSON.stringify(e.styles)===JSON.stringify(i)?e.text+=n.textContent:(t.push(e),e={type:"text",text:n.textContent,styles:i}):e.type==="link"&&(r?e.href===r.attrs.href?JSON.stringify(e.content[e.content.length-1].styles)===JSON.stringify(i)?e.content[e.content.length-1].text+=n.textContent:e.content.push({type:"text",text:n.textContent,styles:i}):(t.push(e),e={type:"link",href:r.attrs.href,content:[{type:"text",text:n.textContent,styles:i}]}):(t.push(e),e={type:"text",text:n.textContent,styles:i})):r?e={type:"link",href:r.attrs.href,content:[{type:"text",text:n.textContent,styles:i}]}:e={type:"text",text:n.textContent,styles:i}}),e&&t.push(e),t}function P(o,t,e){if(o.type.name!=="blockContainer")throw Error("Node must be of type blockContainer, but is of type"+o.type.name+".");const n=e==null?void 0:e.get(o);if(n)return n;const i=nt(o);let r=i.id;r===null&&(r=q.options.generateID());const s={};for(const[c,m]of Object.entries({...o.attrs,...i.contentNode.attrs})){const h=t[i.contentType.name];if(!h)throw Error("Block is of an unrecognized type: "+i.contentType.name);const p=h.propSchema;c in p?s[c]=m:c!=="id"&&!(c in T)&&console.warn("Block has an unrecognized attribute: "+c)}const l=t[i.contentType.name],a=[];for(let c=0;c<i.numChildBlocks;c++)a.push(P(o.lastChild.child(c),t,e));const d={id:r,type:l.node.name,props:s,content:l.node.config.content==="inline*"?Re(i.contentNode):void 0,children:a};return e==null||e.set(o,d),d}const ct=new b.PluginKey("previous-blocks"),ze={index:"index",level:"level",type:"type",depth:"depth","depth-change":"depth-change"},Ve=()=>{let o;return new b.Plugin({key:ct,view(t){return{update:async(e,n)=>{var i;((i=this.key)==null?void 0:i.getState(e.state).updatedBlocks.size)>0&&(o=setTimeout(()=>{e.dispatch(e.state.tr.setMeta(ct,{clearUpdate:!0}))},0))},destroy:()=>{o&&clearTimeout(o)}}},state:{init(){return{prevTransactionOldBlockAttrs:{},currentTransactionOldBlockAttrs:{},updatedBlocks:new Set}},apply(t,e,n,i){if(e.currentTransactionOldBlockAttrs={},e.updatedBlocks.clear(),!t.docChanged||n.doc.eq(i.doc))return e;const r={},s=g.findChildren(n.doc,d=>d.attrs.id),l=new Map(s.map(d=>[d.node.attrs.id,d])),a=g.findChildren(i.doc,d=>d.attrs.id);for(const d of a){const c=l.get(d.node.attrs.id),m=c==null?void 0:c.node.firstChild,h=d.node.firstChild;if(c&&m&&h){const p={index:h.attrs.index,level:h.attrs.level,type:h.type.name,depth:i.doc.resolve(d.pos).depth};let k={index:m.attrs.index,level:m.attrs.level,type:m.type.name,depth:n.doc.resolve(c.pos).depth};r[d.node.attrs.id]=k,t.getMeta("numberedListIndexing")&&(d.node.attrs.id in e.prevTransactionOldBlockAttrs&&(k=e.prevTransactionOldBlockAttrs[d.node.attrs.id]),p.type==="numberedListItem"&&(k.index=p.index)),e.currentTransactionOldBlockAttrs[d.node.attrs.id]=k,JSON.stringify(k)!==JSON.stringify(p)&&(k["depth-change"]=k.depth-p.depth,e.updatedBlocks.add(d.node.attrs.id))}}return e.prevTransactionOldBlockAttrs=r,e}},props:{decorations(t){const e=this.getState(t);if(e.updatedBlocks.size===0)return;const n=[];return t.doc.descendants((i,r)=>{if(!i.attrs.id||!e.updatedBlocks.has(i.attrs.id))return;const s=e.currentTransactionOldBlockAttrs[i.attrs.id],l={};for(const[d,c]of Object.entries(s))l["data-prev-"+ze[d]]=c||"none";const a=I.Decoration.node(r,r+i.nodeSize,{...l});n.push(a)}),I.DecorationSet.create(t.doc,n)}}})},ut="_blockOuter_xo7pf_5",pt="_block_xo7pf_5",ht="_reactNodeViewRenderer_xo7pf_17",mt="_blockContent_xo7pf_22",ft="_blockGroup_xo7pf_42",gt="_wrapper_xo7pf_226",kt="_addImageButton_xo7pf_234",bt="_addImageButtonIcon_xo7pf_250",yt="_addImageButtonText_xo7pf_256",vt="_imageAndCaptionWrapper_xo7pf_260",wt="_imageWrapper_xo7pf_266",Ct="_image_xo7pf_260",Et="_resizeHandle_xo7pf_279",St="_caption_xo7pf_294",Tt="_isEmpty_xo7pf_300",Bt="_inlineContent_xo7pf_300",xt="_isFilter_xo7pf_301",Mt="_hasAnchor_xo7pf_313",y={blockOuter:ut,block:pt,reactNodeViewRenderer:ht,blockContent:mt,blockGroup:ft,wrapper:gt,addImageButton:kt,addImageButtonIcon:bt,addImageButtonText:yt,imageAndCaptionWrapper:vt,imageWrapper:wt,image:Ct,resizeHandle:Et,caption:St,isEmpty:Tt,inlineContent:Bt,isFilter:xt,hasAnchor:Mt},Fe=Object.freeze(Object.defineProperty({__proto__:null,addImageButton:kt,addImageButtonIcon:bt,addImageButtonText:yt,block:pt,blockContent:mt,blockGroup:ft,blockOuter:ut,caption:St,default:y,hasAnchor:Mt,image:Ct,imageAndCaptionWrapper:vt,imageWrapper:wt,inlineContent:Bt,isEmpty:Tt,isFilter:xt,reactNodeViewRenderer:ht,resizeHandle:Et,wrapper:gt},Symbol.toStringTag,{value:"Module"})),Ue={blockColor:"data-block-color",blockStyle:"data-block-style",id:"data-id",depth:"data-depth",depthChange:"data-depth-change"},qe=new b.PluginKey("non-editable-block"),$e=()=>new b.Plugin({key:qe,props:{handleKeyDown:(o,t)=>{"node"in o.state.selection&&t.preventDefault()}}}),We=g.Node.create({name:"blockContainer",group:"blockContainer",content:"blockContent blockGroup?",priority:50,defining:!0,parseHTML(){return[{tag:"div",getAttrs:o=>{if(typeof o=="string")return!1;const t={};for(const[e,n]of Object.entries(Ue))o.getAttribute(n)&&(t[e]=o.getAttribute(n));return o.getAttribute("data-node-type")==="blockContainer"?t:!1}}]},renderHTML({HTMLAttributes:o}){var e;const t=((e=this.options.domAttributes)==null?void 0:e.blockContainer)||{};return["div",g.mergeAttributes(o,{class:y.blockOuter,"data-node-type":"block-outer"}),["div",g.mergeAttributes({...t,class:x(y.block,t.class),"data-node-type":this.name},o),0]]},addCommands(){return{BNCreateBlock:o=>({state:t,dispatch:e})=>{const n=t.schema.nodes.blockContainer.createAndFill();return e&&t.tr.insert(o,n),!0},BNDeleteBlock:o=>({state:t,dispatch:e})=>{const n=v(t.doc,o);if(n===void 0)return!1;const{startPos:i,endPos:r}=n;return e&&t.tr.deleteRange(i,r),!0},BNUpdateBlock:(o,t)=>({state:e,dispatch:n})=>{const i=v(e.doc,o);if(i===void 0)return!1;const{startPos:r,endPos:s,node:l,contentNode:a}=i;if(n){if(t.children!==void 0){const p=[];for(const k of t.children)p.push(F(k,e.schema));l.childCount===2?e.tr.replace(r+a.nodeSize+1,s-1,new S.Slice(S.Fragment.from(p),0,0)):e.tr.insert(r+a.nodeSize,e.schema.nodes.blockGroup.create({},p))}if(t.content!==void 0){let p=[];typeof t.content=="string"?p.push(e.schema.text(t.content)):p=dt(t.content,e.schema),e.tr.replace(r+1,r+a.nodeSize-1,new S.Slice(S.Fragment.from(p),0,0))}const d=a.type.name,c=t.type||d,m=e.schema.nodes[d].spec.content,h=e.schema.nodes[c].spec.content;m==="inline*"&&h===""?e.tr.replaceWith(r,s,e.schema.nodes[c].create({...a.attrs,...t.props})).setSelection(new b.NodeSelection(e.tr.doc.resolve(r))):e.tr.setNodeMarkup(r,t.type===void 0?void 0:e.schema.nodes[t.type],{...a.attrs,...t.props}),e.tr.setNodeMarkup(r-1,void 0,{...l.attrs,...t.props})}return!0},BNMergeBlocks:o=>({state:t,dispatch:e})=>{const n=t.doc.resolve(o+1).node().type.name==="blockContainer",i=t.doc.resolve(o-1).node().type.name==="blockContainer";if(!n||!i)return!1;const r=v(t.doc,o+1),{node:s,contentNode:l,startPos:a,endPos:d,depth:c}=r;if(s.childCount===2){const p=t.doc.resolve(a+l.nodeSize+1),k=t.doc.resolve(d-1),w=p.blockRange(k);e&&t.tr.lift(w,c-1)}let m=o-1,h=v(t.doc,m);for(;h.numChildBlocks>0;)if(m--,h=v(t.doc,m),h===void 0)return!1;return e&&(e(t.tr.deleteRange(a,a+l.nodeSize).replace(m-1,a,new S.Slice(l.content,0,0)).scrollIntoView()),t.tr.setSelection(new b.TextSelection(t.doc.resolve(m-1)))),!0},BNSplitBlock:(o,t)=>({state:e,dispatch:n})=>{const i=v(e.doc,o);if(i===void 0)return!1;const{contentNode:r,contentType:s,startPos:l,endPos:a,depth:d}=i,c=e.doc.cut(l+1,o),m=e.doc.cut(o,a-1),h=e.schema.nodes.blockContainer.createAndFill(),p=a+1,k=p+2;return n&&(e.tr.insert(p,h),e.tr.replace(k,k+1,m.content.size>0?new S.Slice(S.Fragment.from(m),d+2,d+2):void 0),t&&e.tr.setBlockType(k,k,e.schema.node(s).type,r.attrs),e.tr.setSelection(new b.TextSelection(e.doc.resolve(k))),e.tr.replace(l+1,a-1,c.content.size>0?new S.Slice(S.Fragment.from(c),d+2,d+2):void 0)),!0}}},addProseMirrorPlugins(){return[Ve(),$e()]},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.first(({commands:n})=>[()=>n.deleteSelection(),()=>n.undoInputRule(),()=>n.command(({state:i})=>{const{contentType:r}=v(i.doc,i.selection.from),s=i.selection.$anchor.parentOffset===0,l=r.name==="paragraph";return s&&!l?n.BNUpdateBlock(i.selection.from,{type:"paragraph",props:{}}):!1}),()=>n.command(({state:i})=>i.selection.$anchor.parentOffset===0?n.liftListItem("blockContainer"):!1),()=>n.command(({state:i})=>{const{depth:r,startPos:s}=v(i.doc,i.selection.from),l=i.selection.$anchor.parentOffset===0,a=i.selection.anchor===i.selection.head,d=s===2,c=s-1;return!d&&l&&a&&r===2?n.BNMergeBlocks(c):!1})]),Delete:()=>this.editor.commands.first(({commands:n})=>[()=>n.deleteSelection(),()=>n.command(({state:i})=>{const{node:r,contentNode:s,depth:l,endPos:a}=v(i.doc,i.selection.from),d=i.selection.$anchor.parentOffset===s.firstChild.nodeSize,c=i.selection.anchor===i.selection.head,m=r.childCount===2;if(d&&c&&!m){let h=l,p=a+2,k=i.doc.resolve(p).depth;for(;k<h;)h=k,p+=2,k=i.doc.resolve(p).depth;return n.BNMergeBlocks(p-1)}return!1})]),Enter:()=>this.editor.commands.first(({commands:n})=>[()=>n.command(({state:i})=>{const{node:r,depth:s}=v(i.doc,i.selection.from),l=i.selection.$anchor.parentOffset===0,a=i.selection.anchor===i.selection.head,d=r.textContent.length===0,c=s>2;return l&&a&&d&&c?n.liftListItem("blockContainer"):!1}),()=>n.command(({state:i,chain:r})=>{const{node:s,endPos:l}=v(i.doc,i.selection.from),a=i.selection.$anchor.parentOffset===0,d=i.selection.anchor===i.selection.head,c=s.textContent.length===0;if(a&&d&&c){const m=l+1,h=m+2;return r().BNCreateBlock(m).setTextSelection(h).run(),!0}return!1}),()=>n.command(({state:i,chain:r})=>{const{node:s}=v(i.doc,i.selection.from),l=i.selection.$anchor.parentOffset===0;return s.textContent.length===0?!1:(r().deleteSelection().BNSplitBlock(i.selection.from,l).run(),!0)})]),Tab:()=>(this.editor.commands.sinkListItem("blockContainer"),!0),"Shift-Tab":()=>(this.editor.commands.liftListItem("blockContainer"),!0),"Mod-Alt-0":()=>this.editor.commands.BNCreateBlock(this.editor.state.selection.anchor+2)}}}),Ge=g.Node.create({name:"blockGroup",group:"blockGroup",content:"blockContainer+",parseHTML(){return[{tag:"div",getAttrs:o=>typeof o=="string"?!1:o.getAttribute("data-node-type")==="blockGroup"?null:!1}]},renderHTML({HTMLAttributes:o}){var e;const t=((e=this.options.domAttributes)==null?void 0:e.blockGroup)||{};return["div",g.mergeAttributes({...t,class:x(y.blockGroup,t.class),"data-node-type":"blockGroup"},o),0]}}),je=g.Node.create({name:"doc",topNode:!0,content:"blockGroup"}),Ke=o=>{const t=S.DOMSerializer.fromSchema(o);return new S.DOMSerializer({...t.nodes},t.marks)},_t=g.Extension.create({addProseMirrorPlugins(){return[new b.Plugin({props:{clipboardSerializer:Ke(this.editor.schema)}})]}});class U{constructor(){u(this,"callbacks",{})}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),()=>this.off(t,e)}emit(t,...e){const n=this.callbacks[t];n&&n.forEach(i=>i.apply(this,e))}off(t,e){const n=this.callbacks[t];n&&(e?this.callbacks[t]=n.filter(i=>i!==e):delete this.callbacks[t])}removeAllListeners(){this.callbacks={}}}const Xe=g.findParentNode(o=>o.type.name==="blockContainer");class Ye{constructor(t,e,n=()=>{}){u(this,"suggestionsMenuState");u(this,"updateSuggestionsMenu");u(this,"pluginState");u(this,"handleScroll",()=>{var t;if((t=this.suggestionsMenuState)!=null&&t.show){const e=document.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);this.suggestionsMenuState.referencePos=e.getBoundingClientRect(),this.updateSuggestionsMenu()}});this.editor=t,this.pluginKey=e,this.pluginState=G(),this.updateSuggestionsMenu=()=>{if(!this.suggestionsMenuState)throw new Error("Attempting to update uninitialized suggestions menu");n(this.suggestionsMenuState)},document.addEventListener("scroll",this.handleScroll)}update(t,e){const n=this.pluginKey.getState(e),i=this.pluginKey.getState(t.state),r=!n.active&&i.active,s=n.active&&!i.active,l=n.active&&i.active;if(!r&&!l&&!s)return;if(this.pluginState=s?n:i,s||!this.editor.isEditable){this.suggestionsMenuState.show=!1,this.updateSuggestionsMenu();return}const a=document.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);this.editor.isEditable&&(this.suggestionsMenuState={show:!0,referencePos:a.getBoundingClientRect(),filteredItems:this.pluginState.items,keyboardHoveredItemIndex:this.pluginState.keyboardHoveredItemIndex},this.updateSuggestionsMenu())}destroy(){document.removeEventListener("scroll",this.handleScroll)}}function G(){return{active:!1,triggerCharacter:void 0,queryStartPos:void 0,items:[],keyboardHoveredItemIndex:void 0,notFoundCount:0,decorationId:void 0}}const It=(o,t,e,n,i=()=>[],r=()=>{})=>{if(n.length!==1)throw new Error("'char' should be a single character");let s;const l=a=>{a.dispatch(a.state.tr.setMeta(e,{deactivate:!0}))};return{plugin:new b.Plugin({key:e,view:()=>(s=new Ye(o,e,t),s),state:{init(){return G()},apply(a,d,c,m){var p,k,w,E;if(a.getMeta("orderedListIndexing")!==void 0)return d;if((p=a.getMeta(e))!=null&&p.activate)return{active:!0,triggerCharacter:((k=a.getMeta(e))==null?void 0:k.triggerCharacter)||"",queryStartPos:m.selection.from,items:i(""),keyboardHoveredItemIndex:0,notFoundCount:0,decorationId:`id_${Math.floor(Math.random()*4294967295)}`};if(!d.active)return d;const h={...d};if(h.items=i(m.doc.textBetween(d.queryStartPos,m.selection.from)),h.notFoundCount=0,h.items.length===0&&(h.notFoundCount=Math.max(0,d.notFoundCount+(m.selection.from-c.selection.from))),m.selection.from!==m.selection.to||(w=a.getMeta(e))!=null&&w.deactivate||a.getMeta("focus")||a.getMeta("blur")||a.getMeta("pointer")||d.active&&m.selection.from<d.queryStartPos||h.notFoundCount>3)return G();if(((E=a.getMeta(e))==null?void 0:E.selectedItemIndexChanged)!==void 0){let B=a.getMeta(e).selectedItemIndexChanged;B<0?B=d.items.length-1:B>=d.items.length&&(B=0),h.keyboardHoveredItemIndex=B}else c.selection.from!==m.selection.from&&(h.keyboardHoveredItemIndex=0);return h}},props:{handleKeyDown(a,d){const c=this.getState(a.state).active;if(d.key===n&&!c)return a.dispatch(a.state.tr.insertText(n).scrollIntoView().setMeta(e,{activate:!0,triggerCharacter:n})),!0;if(!c)return!1;const{triggerCharacter:m,queryStartPos:h,items:p,keyboardHoveredItemIndex:k}=e.getState(a.state);return d.key==="ArrowUp"?(a.dispatch(a.state.tr.setMeta(e,{selectedItemIndexChanged:k-1})),!0):d.key==="ArrowDown"?(a.dispatch(a.state.tr.setMeta(e,{selectedItemIndexChanged:k+1})),!0):d.key==="Enter"?(p.length===0||(l(a),o._tiptapEditor.chain().focus().deleteRange({from:h-m.length,to:o._tiptapEditor.state.selection.from}).run(),r({item:p[k],editor:o})),!0):d.key==="Escape"?(l(a),!0):!1},decorations(a){const{active:d,decorationId:c,queryStartPos:m,triggerCharacter:h}=this.getState(a);if(!d)return null;if(h===""){const p=Xe(a.selection);if(p)return I.DecorationSet.create(a.doc,[I.Decoration.node(p.pos,p.pos+p.node.nodeSize,{nodeName:"span",class:"suggestion-decorator","data-decoration-id":c})])}return I.DecorationSet.create(a.doc,[I.Decoration.inline(m-h.length,m,{nodeName:"span",class:"suggestion-decorator","data-decoration-id":c})])}}}),itemCallback:a=>{l(o._tiptapEditor.view),o._tiptapEditor.chain().focus().deleteRange({from:s.pluginState.queryStartPos-s.pluginState.triggerCharacter.length,to:o._tiptapEditor.state.selection.from}).run(),r({item:a,editor:o})}}},$=new b.PluginKey("SlashMenuPlugin");class At extends U{constructor(e,n){super();u(this,"plugin");u(this,"itemCallback");const i=It(e,r=>{this.emit("update",r)},$,"/",r=>n.filter(({name:s,aliases:l})=>s.toLowerCase().startsWith(r.toLowerCase())||l&&l.filter(a=>a.toLowerCase().startsWith(r.toLowerCase())).length!==0),({item:r,editor:s})=>r.execute(s));this.plugin=i.plugin,this.itemCallback=i.itemCallback}onUpdate(e){return this.on("update",e)}}const Je=new b.PluginKey("blocknote-placeholder"),Ze=g.Extension.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",isFilterClass:"is-filter",hasAnchorClass:"has-anchor",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new b.Plugin({key:Je,props:{decorations:o=>{const{doc:t,selection:e}=o,n=$.getState(o),i=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,s=[];if(i)return t.descendants((l,a)=>{const d=r>=a&&r<=a+l.nodeSize,c=!l.isLeaf&&!l.childCount;if((d||!this.options.showOnlyCurrent)&&c){const m=[this.options.emptyNodeClass];this.editor.isEmpty&&m.push(this.options.emptyEditorClass),d&&m.push(this.options.hasAnchorClass),(n==null?void 0:n.triggerCharacter)===""&&(n!=null&&n.active)&&m.push(this.options.isFilterClass);const h=I.Decoration.node(a,a+l.nodeSize,{class:m.join(" ")});s.push(h)}return this.options.includeChildren}),I.DecorationSet.create(t,s)}}})]}}),Qe=g.Extension.create({name:"textAlignment",addGlobalAttributes(){return[{types:["paragraph","heading","bulletListItem","numberedListItem"],attributes:{textAlignment:{default:"left",parseHTML:o=>o.getAttribute("data-text-alignment"),renderHTML:o=>o.textAlignment!=="left"&&{"data-text-alignment":o.textAlignment}}}}]},addCommands(){return{setTextAlignment:o=>({state:t})=>{const e=[],n=v(t.doc,t.selection.from);if(n===void 0)return!1;let i=n.startPos;for(;i<t.selection.to;)t.doc.resolve(i).node().type.spec.group==="blockContent"?(e.push(i-1),i+=t.doc.resolve(i).node().nodeSize-1):i+=1;for(const r of e)t.tr.setNodeAttribute(r,"textAlignment",o);return!0}}}}),tn=g.Extension.create({name:"blockTextColor",addGlobalAttributes(){return[{types:["blockContainer"],attributes:{textColor:{default:T.textColor.default,parseHTML:o=>o.hasAttribute("data-text-color")?o.getAttribute("data-text-color"):T.textColor.default,renderHTML:o=>o.textColor!==T.textColor.default&&{"data-text-color":o.textColor}}}}]},addCommands(){return{setBlockTextColor:(o,t)=>({state:e,view:n})=>{const i=v(e.doc,o);return i===void 0?!1:(e.tr.setNodeAttribute(i.startPos-1,"textColor",t),n.focus(),!0)}}}}),en=g.Mark.create({name:"textColor",addAttributes(){return{color:{default:void 0,parseHTML:o=>o.getAttribute("data-text-color"),renderHTML:o=>({"data-text-color":o.color})}}},parseHTML(){return[{tag:"span",getAttrs:o=>typeof o=="string"?!1:o.hasAttribute("data-text-color")?{color:o.getAttribute("data-text-color")}:!1}]},renderHTML({HTMLAttributes:o}){return["span",o,0]},addCommands(){return{setTextColor:o=>({commands:t})=>o!==T.textColor.default?t.setMark(this.name,{color:o}):t.unsetMark(this.name)}}}),nn=g.Extension.create({name:"trailingNode",addProseMirrorPlugins(){const o=new b.PluginKey(this.name);return[new b.Plugin({key:o,appendTransaction:(t,e,n)=>{const{doc:i,tr:r,schema:s}=n,l=o.getState(n),a=i.content.size-2,d=s.nodes.blockContainer,c=s.nodes.paragraph;if(l)return r.insert(a,d.create(void 0,c.create()))},state:{init:(t,e)=>{},apply:(t,e)=>{if(!t.docChanged)return e;let n=t.doc.lastChild;if(!n||n.type.name!=="blockGroup")throw new Error("Expected blockGroup");if(n=n.lastChild,!n||n.type.name!=="blockContainer")throw new Error("Expected blockContainer");const i=n.firstChild;if(!i)throw new Error("Expected blockContent");return n.nodeSize>4||i.type.spec.content!=="inline*"}}})]}}),Pt=o=>{var e;const t=[g.extensions.ClipboardTextSerializer,g.extensions.Commands,g.extensions.Editable,g.extensions.FocusEvents,g.extensions.Tabindex,de.Gapcursor,Ze.configure({emptyNodeClass:y.isEmpty,hasAnchorClass:y.hasAnchor,isFilterClass:y.isFilter,includeChildren:!0,showOnlyCurrent:!1}),q.configure({types:["blockContainer"]}),ce.HardBreak,fe.Text,H.Bold,re.Code,pe.Italic,me.Strike,ge.Underline,he.Link,en,tn,Ne,Pe,Qe,je,We.configure({domAttributes:o.domAttributes}),Ge.configure({domAttributes:o.domAttributes}),...Object.values(o.blockSchema).map(n=>n.node.configure({editor:o.editor,domAttributes:o.domAttributes})),_t,le.Dropcursor.configure({width:5,color:"#ddeeff"}),nn];if(o.collaboration){if(t.push(Te.default.configure({fragment:o.collaboration.fragment})),(e=o.collaboration.provider)!=null&&e.awareness){const n=i=>{const r=document.createElement("span");r.classList.add(O["collaboration-cursor__caret"]),r.setAttribute("style",`border-color: ${i.color}`);const s=document.createElement("span");s.classList.add(O["collaboration-cursor__label"]),s.setAttribute("style",`background-color: ${i.color}`),s.insertBefore(document.createTextNode(i.name),null);const l=document.createTextNode(""),a=document.createTextNode("");return r.insertBefore(l,null),r.insertBefore(s,null),r.insertBefore(a,null),r};t.push(Be.default.configure({user:o.collaboration.user,render:o.collaboration.renderCursor||n,provider:o.collaboration.provider}))}}else t.push(ue.History);return t};function j(o,t){let e,n;if(t.firstChild.descendants((i,r)=>e?!1:i.type.name!=="blockContainer"||i.attrs.id!==o?!0:(e=i,n=r+1,!1)),e===void 0||n===void 0)throw Error("Could not find block in the editor with matching ID.");return{node:e,posBeforeNode:n}}function Nt(o,t,e="before",n){const i=typeof t=="string"?t:t.id,r=[];for(const d of o)r.push(F(d,n.schema));let s=-1;const{node:l,posBeforeNode:a}=j(i,n.state.doc);if(e==="before"&&(s=a),e==="after"&&(s=a+l.nodeSize),e==="nested"){if(l.childCount<2){s=a+l.firstChild.nodeSize+1;const d=n.state.schema.nodes.blockGroup.create({},r);n.view.dispatch(n.state.tr.insert(s,d));return}s=a+l.firstChild.nodeSize+2}n.view.dispatch(n.state.tr.insert(s,r))}function on(o,t,e){const n=typeof o=="string"?o:o.id,{posBeforeNode:i}=j(n,e.state.doc);e.commands.BNUpdateBlock(i+1,t)}function Ht(o,t){const e=new Set(o.map(i=>typeof i=="string"?i:i.id));let n=0;if(t.state.doc.descendants((i,r)=>{if(e.size===0)return!1;if(i.type.name!=="blockContainer"||!e.has(i.attrs.id))return!0;e.delete(i.attrs.id);const s=t.state.doc.nodeSize;t.commands.BNDeleteBlock(r-n+1);const l=t.state.doc.nodeSize;return n+=s-l,!1}),e.size>0){const i=[...e].join(`
|
|
6
|
-
`);throw Error("Blocks with the following IDs could not be found in the editor: "+i)}}function
|
|
7
|
-
`:"",n={};t.lang&&(n["data-language"]=t.lang);let i={type:"element",tagName:"code",properties:n,children:[{type:"text",value:e}]};return t.meta&&(i.data={meta:t.meta}),o.patch(t,i),i=o.applyData(t,i),i={type:"element",tagName:"pre",properties:{},children:[i]},o.patch(t,i),i}async function cn(o,t,e){const n=await W.unified().use(_e.default).use(et.default).use(Ie.default,{handlers:{...J.defaultHandlers,code:dn}}).use(tt.default).process(o);return Dt(n.value,t,e)}function K(o){return"data-"+o.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function Ot(o){const t={};return Object.entries(o.propSchema).forEach(([e,n])=>{t[e]={default:n.default,keepOnSplit:!0,parseHTML:i=>{const r=i.getAttribute(K(e));if(r===null)return null;if(typeof n.default=="boolean")return r==="true"?!0:r==="false"?!1:null;if(typeof n.default=="number"){const s=parseFloat(r);return!Number.isNaN(s)&&Number.isFinite(s)?s:null}return r},renderHTML:i=>i[e]!==n.default?{[K(e)]:i[e]}:{}}}),t}function Rt(o){return[{tag:"div[data-content-type="+o.type+"]"}]}function zt(o,t){const e=document.createElement("div");e.setAttribute("data-content-type",o.type);for(const[i,r]of Object.entries(t))e.setAttribute(i,r);let n;return o.containsInlineContent?(n=document.createElement("div"),e.appendChild(n)):n=void 0,n!==void 0?{dom:e,contentDOM:n}:{dom:e}}function Vt(o){return{node:R({name:o.type,content:o.containsInlineContent?"inline*":"",selectable:!0,addAttributes(){return Ot(o)},parseHTML(){return Rt(o)},renderHTML({HTMLAttributes:e}){return zt(o,e)},addNodeView(){return({HTMLAttributes:e,getPos:n})=>{var p,k;const i=document.createElement("div"),r=((p=this.options.domAttributes)==null?void 0:p.blockContent)||{};for(const[w,E]of Object.entries(r))w!=="class"&&i.setAttribute(w,E);i.className=x(y.blockContent,r.class),i.setAttribute("data-content-type",o.type);for(const[w,E]of Object.entries(e))i.setAttribute(w,E);const s=this.options.editor;if(typeof n=="boolean")throw new Error("Cannot find node position as getPos is a boolean, not a function.");const l=n(),c=s._tiptapEditor.state.doc.resolve(l).node().attrs.id,m=s.getBlock(c);if(m.type!==o.type)throw new Error("Block type does not match");const h=o.render(m,s);if(o.containsInlineContent){const w=h.contentDOM,E=((k=this.options.domAttributes)==null?void 0:k.inlineContent)||{};for(const[B,M]of Object.entries(E))B!=="class"&&w.setAttribute(B,M);w.className=x(w.className,y.inlineContent,E.class)}return i.appendChild(h.dom),"contentDOM"in h?{dom:i,contentDOM:h.contentDOM,destroy:h.destroy}:{dom:i,destroy:h.destroy}}}}),propSchema:o.propSchema}}function R(o){return g.Node.create({...o,group:"blockContent",content:o.content})}const un={...T,level:{default:1,values:[1,2,3]}},pn={node:R({name:"heading",content:"inline*",addAttributes(){return{level:{default:1,parseHTML:o=>o.getAttribute("data-level"),renderHTML:o=>({"data-level":o.level.toString()})}}},addInputRules(){return[...[1,2,3].map(o=>new g.InputRule({find:new RegExp(`^(#{${o}})\\s$`),handler:({state:t,chain:e,range:n})=>{e().BNUpdateBlock(t.selection.from,{type:"heading",props:{level:o}}).deleteRange({from:n.from,to:n.to})}}))]},addKeyboardShortcuts(){return{"Mod-Alt-1":()=>this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor,{type:"heading",props:{level:1}}),"Mod-Alt-2":()=>this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor,{type:"heading",props:{level:2}}),"Mod-Alt-3":()=>this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor,{type:"heading",props:{level:3}})}},parseHTML(){return[{tag:"h1",attrs:{level:1},node:"heading"},{tag:"h2",attrs:{level:2},node:"heading"},{tag:"h3",attrs:{level:3},node:"heading"}]},renderHTML({node:o,HTMLAttributes:t}){var i,r;const e=((i=this.options.domAttributes)==null?void 0:i.blockContent)||{},n=((r=this.options.domAttributes)==null?void 0:r.inlineContent)||{};return["div",g.mergeAttributes(t,{...e,class:x(y.blockContent,e.class),"data-content-type":this.name}),[`h${o.attrs.level}`,{...n,class:x(y.inlineContent,n.class)},0]]}}),propSchema:un},Ft=o=>{const{node:t,contentType:e}=v(o.state.doc,o.state.selection.from),n=o.state.selection.anchor===o.state.selection.head;return!e.name.endsWith("ListItem")||!n?!1:o.commands.first(({state:i,chain:r,commands:s})=>[()=>s.command(()=>t.textContent.length===0?s.BNUpdateBlock(i.selection.from,{type:"paragraph",props:{}}):!1),()=>s.command(()=>t.textContent.length>0?(r().deleteSelection().BNSplitBlock(i.selection.from,!0).run(),!0):!1)])},hn={...T},mn={node:R({name:"bulletListItem",content:"inline*",addInputRules(){return[new g.InputRule({find:new RegExp("^[-+*]\\s$"),handler:({state:o,chain:t,range:e})=>{t().BNUpdateBlock(o.selection.from,{type:"bulletListItem",props:{}}).deleteRange({from:e.from,to:e.to})}})]},addKeyboardShortcuts(){return{Enter:()=>Ft(this.editor),"Mod-Shift-7":()=>this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor,{type:"bulletListItem",props:{}})}},parseHTML(){return[{tag:"li",getAttrs:o=>{if(typeof o=="string")return!1;const t=o.parentElement;return t===null?!1:t.tagName==="UL"?{}:!1},node:"bulletListItem"},{tag:"p",getAttrs:o=>{if(typeof o=="string")return!1;const t=o.parentElement;return t===null?!1:t.getAttribute("data-content-type")==="bulletListItem"?{}:!1},priority:300,node:"bulletListItem"}]},renderHTML({HTMLAttributes:o}){var n,i;const t=((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},e=((i=this.options.domAttributes)==null?void 0:i.inlineContent)||{};return["div",g.mergeAttributes(o,{...t,class:x(y.blockContent,t.class),"data-content-type":this.name}),["p",{...e,class:x(y.inlineContent,e.class)},0]]}}),propSchema:hn},fn=new b.PluginKey("numbered-list-indexing"),gn=()=>new b.Plugin({key:fn,appendTransaction:(o,t,e)=>{const n=e.tr;n.setMeta("numberedListIndexing",!0);let i=!1;return e.doc.descendants((r,s)=>{if(r.type.name==="blockContainer"&&r.firstChild.type.name==="numberedListItem"){let l="1";const a=s===1,d=v(n.doc,s+1);if(d===void 0)return;if(!a){const h=v(n.doc,s-2);if(h===void 0)return;if(!(d.depth!==h.depth)){const k=h.contentNode;if(h.contentType.name==="numberedListItem"){const B=k.attrs.index;l=(parseInt(B)+1).toString()}}}d.contentNode.attrs.index!==l&&(i=!0,n.setNodeMarkup(s+1,void 0,{index:l}))}}),i?n:null}}),kn={...T},bn={node:R({name:"numberedListItem",content:"inline*",addAttributes(){return{index:{default:null,parseHTML:o=>o.getAttribute("data-index"),renderHTML:o=>({"data-index":o.index})}}},addInputRules(){return[new g.InputRule({find:new RegExp("^1\\.\\s$"),handler:({state:o,chain:t,range:e})=>{t().BNUpdateBlock(o.selection.from,{type:"numberedListItem",props:{}}).deleteRange({from:e.from,to:e.to})}})]},addKeyboardShortcuts(){return{Enter:()=>Ft(this.editor),"Mod-Shift-8":()=>this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor,{type:"numberedListItem",props:{}})}},addProseMirrorPlugins(){return[gn()]},parseHTML(){return[{tag:"li",getAttrs:o=>{if(typeof o=="string")return!1;const t=o.parentElement;return t===null?!1:t.tagName==="OL"?{}:!1},node:"numberedListItem"},{tag:"p",getAttrs:o=>{if(typeof o=="string")return!1;const t=o.parentElement;return t===null?!1:t.getAttribute("data-content-type")==="numberedListItem"?{}:!1},priority:300,node:"numberedListItem"}]},renderHTML({HTMLAttributes:o}){var n,i;const t=((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},e=((i=this.options.domAttributes)==null?void 0:i.inlineContent)||{};return["div",g.mergeAttributes(o,{...t,class:x(y.blockContent,t.class),"data-content-type":this.name}),["p",{...e,class:x(y.inlineContent,e.class)},0]]}}),propSchema:kn},yn={...T},vn={node:R({name:"paragraph",content:"inline*",parseHTML(){return[{tag:"p",priority:200,node:"paragraph"}]},renderHTML({HTMLAttributes:o}){var n,i;const t=((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},e=((i=this.options.domAttributes)==null?void 0:i.inlineContent)||{};return["div",g.mergeAttributes({...t,class:x(y.blockContent,t.class),"data-content-type":this.name},o),["p",{...e,class:x(y.inlineContent,e.class)},0]]}}),propSchema:yn};class Ut{constructor(t,e,n){u(this,"imageToolbarState");u(this,"updateImageToolbar");u(this,"prevWasEditable",null);u(this,"shouldShow",t=>"node"in t.selection&&t.selection.node.type.name==="image"&&t.selection.node.attrs.src==="");u(this,"mouseDownHandler",()=>{var t;(t=this.imageToolbarState)!=null&&t.show&&(this.imageToolbarState.show=!1,this.updateImageToolbar())});u(this,"dragstartHandler",()=>{var t;(t=this.imageToolbarState)!=null&&t.show&&(this.imageToolbarState.show=!1,this.updateImageToolbar())});u(this,"blurHandler",t=>{var n;const e=this.pmView.dom.parentElement;t&&t.relatedTarget&&(e===t.relatedTarget||e.contains(t.relatedTarget))||(n=this.imageToolbarState)!=null&&n.show&&(this.imageToolbarState.show=!1,this.updateImageToolbar())});u(this,"scrollHandler",()=>{var t;if((t=this.imageToolbarState)!=null&&t.show){const e=document.querySelector(`[data-node-type="blockContainer"][data-id="${this.imageToolbarState.block.id}"]`);this.imageToolbarState.referencePos=e.getBoundingClientRect(),this.updateImageToolbar()}});this.pluginKey=t,this.pmView=e,this.updateImageToolbar=()=>{if(!this.imageToolbarState)throw new Error("Attempting to update uninitialized image toolbar");n(this.imageToolbarState)},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,r;const n=this.pluginKey.getState(t.state);if(!((i=this.imageToolbarState)!=null&&i.show)&&n.block){const s=document.querySelector(`[data-node-type="blockContainer"][data-id="${n.block.id}"]`);this.imageToolbarState={show:!0,referencePos:s.getBoundingClientRect(),block:n.block},this.updateImageToolbar();return}(!t.state.selection.eq(e.selection)||!t.state.doc.eq(e.doc))&&(r=this.imageToolbarState)!=null&&r.show&&(this.imageToolbarState.show=!1,this.updateImageToolbar())}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)}}const z=new b.PluginKey("ImageToolbarPlugin");class qt extends U{constructor(e){super();u(this,"view");u(this,"plugin");this.plugin=new b.Plugin({key:z,view:n=>(this.view=new Ut(z,n,i=>{this.emit("update",i)}),this.view),state:{init:()=>({block:void 0}),apply:n=>{var r;return{block:(r=n.getMeta(z))==null?void 0:r.block}}}})}onUpdate(e){return this.on("update",e)}}const wn={textAlignment:T.textAlignment,backgroundColor:T.backgroundColor,url:{default:""},caption:{default:""},width:{default:512}},$t=o=>{switch(o){case"left":return"flex-start";case"center":return"center";case"right":return"flex-end";default:return"flex-start"}},Wt=64,Cn=Vt({type:"image",propSchema:wn,containsInlineContent:!1,render:(o,t)=>{const e=document.createElement("div");e.className=y.wrapper,e.style.alignItems=$t(o.props.textAlignment);const n=document.createElement("div");n.className=y.addImageButton,n.style.display=o.props.url===""?"":"none";const i=document.createElement("div");i.className=y.addImageButtonIcon;const r=document.createElement("p");r.className=y.addImageButtonText,r.innerText="Add Image";const s=document.createElement("div");s.className=y.imageAndCaptionWrapper,s.style.display=o.props.url!==""?"":"none";const l=document.createElement("div");l.className=y.imageWrapper,l.style.display=o.props.url!==""?"":"none";const a=document.createElement("img");a.className=y.image,a.src=o.props.url,a.alt="placeholder",a.contentEditable="false",a.draggable=!1,a.style.width=`${Math.min(o.props.width,t.domElement.firstElementChild.clientWidth)}px`;const d=document.createElement("div");d.className=y.resizeHandle,d.style.left="4px";const c=document.createElement("div");c.className=y.resizeHandle,c.style.right="4px";const m=document.createElement("p");m.className=y.caption,m.innerText=o.props.caption,m.style.padding=o.props.caption?"4px":"";const h=()=>{var Y;const C=((Y=t.getSelection())==null?void 0:Y.blocks)||[];[t.getTextCursorPosition().block,...C].find(An=>An.id===o.id)!==void 0?(n.style.outline="4px solid rgb(100, 160, 255)",s.style.outline="4px solid rgb(100, 160, 255)"):(n.style.outline="",s.style.outline="")};t.onEditorContentChange(h),t.onEditorSelectionChange(h);let p;const k=C=>{if(!p)return;let _;$t(o.props.textAlignment)==="center"?p.handleUsed==="left"?_=p.initialWidth+(p.initialClientX-C.clientX)*2:_=p.initialWidth+(C.clientX-p.initialClientX)*2:p.handleUsed==="left"?_=p.initialWidth+p.initialClientX-C.clientX:_=p.initialWidth+C.clientX-p.initialClientX,_<Wt?a.style.width=`${Wt}px`:_>t.domElement.firstElementChild.clientWidth?a.style.width=`${t.domElement.firstElementChild.clientWidth}px`:a.style.width=`${_}px`},w=C=>{p&&((!C.target||!l.contains(C.target))&&l.contains(d)&&l.contains(c)&&(d.style.display="none",c.style.display="none"),p=void 0,t.updateBlock(o,{type:"image",props:{width:parseFloat(a.style.width.slice(0,-2))}}))},E=C=>{C.preventDefault()},B=()=>{t._tiptapEditor.view.dispatch(t._tiptapEditor.state.tr.setMeta(z,{block:o}))},M=C=>{C.preventDefault(),d.style.display="block",c.style.display="block",p={handleUsed:"left",initialWidth:o.props.width,initialClientX:C.clientX}},D=C=>{C.preventDefault(),d.style.display="block",c.style.display="block",p={handleUsed:"right",initialWidth:o.props.width,initialClientX:C.clientX}};return e.appendChild(n),n.appendChild(i),n.appendChild(r),e.appendChild(s),s.appendChild(l),l.appendChild(a),l.appendChild(d),l.appendChild(c),s.appendChild(m),window.addEventListener("mousemove",k),window.addEventListener("mouseup",w),n.addEventListener("mousedown",E),n.addEventListener("click",B),d.addEventListener("mousedown",M),c.addEventListener("mousedown",D),{dom:e,destroy:()=>{window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",w),n.removeEventListener("mousedown",E),n.removeEventListener("click",B),d.removeEventListener("mousedown",M),c.removeEventListener("mousedown",D)}}}}),X={paragraph:vn,heading:pn,bulletListItem:mn,numberedListItem:bn,image:Cn};class Gt{constructor(t,e,n){u(this,"formattingToolbarState");u(this,"updateFormattingToolbar");u(this,"preventHide",!1);u(this,"preventShow",!1);u(this,"prevWasEditable",null);u(this,"shouldShow",({view:t,state:e,from:n,to:i})=>{const{doc:r,selection:s}=e,{empty:l}=s,a=!r.textBetween(n,i).length&&g.isTextSelection(e.selection);return!(!t.hasFocus()||l||a)});u(this,"viewMousedownHandler",()=>{this.preventShow=!0});u(this,"viewMouseupHandler",()=>{this.preventShow=!1,setTimeout(()=>this.update(this.pmView))});u(this,"dragstartHandler",()=>{var t;(t=this.formattingToolbarState)!=null&&t.show&&(this.formattingToolbarState.show=!1,this.updateFormattingToolbar())});u(this,"focusHandler",()=>{setTimeout(()=>this.update(this.pmView))});u(this,"blurHandler",t=>{var n;if(this.preventHide){this.preventHide=!1;return}const e=this.pmView.dom.parentElement;t&&t.relatedTarget&&(e===t.relatedTarget||e.contains(t.relatedTarget))||(n=this.formattingToolbarState)!=null&&n.show&&(this.formattingToolbarState.show=!1,this.updateFormattingToolbar())});u(this,"scrollHandler",()=>{var t;(t=this.formattingToolbarState)!=null&&t.show&&(this.formattingToolbarState.referencePos=this.getSelectionBoundingBox(),this.updateFormattingToolbar())});this.editor=t,this.pmView=e,this.updateFormattingToolbar=()=>{if(!this.formattingToolbarState)throw new Error("Attempting to update uninitialized formatting toolbar");n(this.formattingToolbarState)},e.dom.addEventListener("mousedown",this.viewMousedownHandler),e.dom.addEventListener("mouseup",this.viewMouseupHandler),e.dom.addEventListener("dragstart",this.dragstartHandler),e.dom.addEventListener("focus",this.focusHandler),e.dom.addEventListener("blur",this.blurHandler),document.addEventListener("scroll",this.scrollHandler)}update(t,e){var h,p;const{state:n,composing:i}=t,{doc:r,selection:s}=n,l=e&&e.doc.eq(r)&&e.selection.eq(s);if((this.prevWasEditable===null||this.prevWasEditable===this.editor.isEditable)&&(i||l))return;this.prevWasEditable=this.editor.isEditable;const{ranges:a}=s,d=Math.min(...a.map(k=>k.$from.pos)),c=Math.max(...a.map(k=>k.$to.pos)),m=(h=this.shouldShow)==null?void 0:h.call(this,{view:t,state:n,from:d,to:c});if(this.editor.isEditable&&!this.preventShow&&(m||this.preventHide)){this.formattingToolbarState={show:!0,referencePos:this.getSelectionBoundingBox()},this.updateFormattingToolbar();return}if((p=this.formattingToolbarState)!=null&&p.show&&!this.preventHide&&(!m||this.preventShow||!this.editor.isEditable)){this.formattingToolbarState.show=!1,this.updateFormattingToolbar();return}}destroy(){this.pmView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.pmView.dom.removeEventListener("mouseup",this.viewMouseupHandler),this.pmView.dom.removeEventListener("dragstart",this.dragstartHandler),this.pmView.dom.removeEventListener("focus",this.focusHandler),this.pmView.dom.removeEventListener("blur",this.blurHandler),document.removeEventListener("scroll",this.scrollHandler)}getSelectionBoundingBox(){const{state:t}=this.pmView,{selection:e}=t,{ranges:n}=e,i=Math.min(...n.map(s=>s.$from.pos)),r=Math.max(...n.map(s=>s.$to.pos));if(g.isNodeSelection(e)){const s=this.pmView.nodeDOM(i);if(s)return s.getBoundingClientRect()}return g.posToDOMRect(this.pmView,i,r)}}const jt=new b.PluginKey("FormattingToolbarPlugin");class Kt extends U{constructor(e){super();u(this,"view");u(this,"plugin");this.plugin=new b.Plugin({key:jt,view:n=>(this.view=new Gt(e,n,i=>{this.emit("update",i)}),this.view)})}onUpdate(e){return this.on("update",e)}}class En{constructor(t,e,n){u(this,"hyperlinkToolbarState");u(this,"updateHyperlinkToolbar");u(this,"menuUpdateTimer");u(this,"startMenuUpdateTimer");u(this,"stopMenuUpdateTimer");u(this,"mouseHoveredHyperlinkMark");u(this,"mouseHoveredHyperlinkMarkRange");u(this,"keyboardHoveredHyperlinkMark");u(this,"keyboardHoveredHyperlinkMarkRange");u(this,"hyperlinkMark");u(this,"hyperlinkMarkRange");u(this,"mouseOverHandler",t=>{if(this.mouseHoveredHyperlinkMark=void 0,this.mouseHoveredHyperlinkMarkRange=void 0,this.stopMenuUpdateTimer(),t.target instanceof HTMLAnchorElement&&t.target.nodeName==="A"){const e=t.target,n=this.pmView.posAtDOM(e,0)+1,i=this.pmView.state.doc.resolve(n),r=i.marks();for(const s of r)if(s.type.name===this.pmView.state.schema.mark("link").type.name){this.mouseHoveredHyperlinkMark=s,this.mouseHoveredHyperlinkMarkRange=g.getMarkRange(i,s.type,s.attrs)||void 0;break}}return this.startMenuUpdateTimer(),!1});u(this,"clickHandler",t=>{var n;const e=this.pmView.dom.parentElement;this.hyperlinkMark&&t&&t.target&&!(e===t.target||e.contains(t.target))&&(n=this.hyperlinkToolbarState)!=null&&n.show&&(this.hyperlinkToolbarState.show=!1,this.updateHyperlinkToolbar())});u(this,"scrollHandler",()=>{var t;this.hyperlinkMark!==void 0&&(t=this.hyperlinkToolbarState)!=null&&t.show&&(this.hyperlinkToolbarState.referencePos=g.posToDOMRect(this.pmView,this.hyperlinkMarkRange.from,this.hyperlinkMarkRange.to),this.updateHyperlinkToolbar())});this.editor=t,this.pmView=e,this.updateHyperlinkToolbar=()=>{if(!this.hyperlinkToolbarState)throw new Error("Attempting to update uninitialized hyperlink toolbar");n(this.hyperlinkToolbarState)},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)}editHyperlink(t,e){var i;const n=this.pmView.state.tr.insertText(e,this.hyperlinkMarkRange.from,this.hyperlinkMarkRange.to);n.addMark(this.hyperlinkMarkRange.from,this.hyperlinkMarkRange.from+e.length,this.pmView.state.schema.mark("link",{href:t})),this.pmView.dispatch(n),this.pmView.focus(),(i=this.hyperlinkToolbarState)!=null&&i.show&&(this.hyperlinkToolbarState.show=!1,this.updateHyperlinkToolbar())}deleteHyperlink(){var t;this.pmView.dispatch(this.pmView.state.tr.removeMark(this.hyperlinkMarkRange.from,this.hyperlinkMarkRange.to,this.hyperlinkMark.type).setMeta("preventAutolink",!0)),this.pmView.focus(),(t=this.hyperlinkToolbarState)!=null&&t.show&&(this.hyperlinkToolbarState.show=!1,this.updateHyperlinkToolbar())}update(){var e;if(!this.pmView.hasFocus())return;const t=this.hyperlinkMark;if(this.hyperlinkMark=void 0,this.hyperlinkMarkRange=void 0,this.keyboardHoveredHyperlinkMark=void 0,this.keyboardHoveredHyperlinkMarkRange=void 0,this.pmView.state.selection.empty){const n=this.pmView.state.selection.$from.marks();for(const i of n)if(i.type.name===this.pmView.state.schema.mark("link").type.name){this.keyboardHoveredHyperlinkMark=i,this.keyboardHoveredHyperlinkMarkRange=g.getMarkRange(this.pmView.state.selection.$from,i.type,i.attrs)||void 0;break}}if(this.mouseHoveredHyperlinkMark&&(this.hyperlinkMark=this.mouseHoveredHyperlinkMark,this.hyperlinkMarkRange=this.mouseHoveredHyperlinkMarkRange),this.keyboardHoveredHyperlinkMark&&(this.hyperlinkMark=this.keyboardHoveredHyperlinkMark,this.hyperlinkMarkRange=this.keyboardHoveredHyperlinkMarkRange),this.hyperlinkMark&&this.editor.isEditable){this.hyperlinkToolbarState={show:!0,referencePos:g.posToDOMRect(this.pmView,this.hyperlinkMarkRange.from,this.hyperlinkMarkRange.to),url:this.hyperlinkMark.attrs.href,text:this.pmView.state.doc.textBetween(this.hyperlinkMarkRange.from,this.hyperlinkMarkRange.to)},this.updateHyperlinkToolbar();return}if((e=this.hyperlinkToolbarState)!=null&&e.show&&t&&(!this.hyperlinkMark||!this.editor.isEditable)){this.hyperlinkToolbarState.show=!1,this.updateHyperlinkToolbar();return}}destroy(){this.pmView.dom.removeEventListener("mouseover",this.mouseOverHandler),document.removeEventListener("scroll",this.scrollHandler),document.removeEventListener("click",this.clickHandler,!0)}}const Xt=new b.PluginKey("HyperlinkToolbarPlugin");class Yt extends U{constructor(e){super();u(this,"view");u(this,"plugin");u(this,"editHyperlink",(e,n)=>{this.view.editHyperlink(e,n)});u(this,"deleteHyperlink",()=>{this.view.deleteHyperlink()});u(this,"startHideTimer",()=>{this.view.startMenuUpdateTimer()});u(this,"stopHideTimer",()=>{this.view.stopMenuUpdateTimer()});this.plugin=new b.Plugin({key:Xt,view:n=>(this.view=new En(e,n,i=>{this.emit("update",i)}),this.view)})}onUpdate(e){return this.on("update",e)}}class V extends b.Selection{constructor(e,n){super(e,n);u(this,"nodes");const i=e.node();this.nodes=[],e.doc.nodesBetween(e.pos,n.pos,(r,s,l)=>{if(l!==null&&l.eq(i))return this.nodes.push(r),!1})}static create(e,n,i=n){return new V(e.resolve(n),e.resolve(i))}content(){return new S.Slice(S.Fragment.from(this.nodes),0,0)}eq(e){if(!(e instanceof V)||this.nodes.length!==e.nodes.length||this.from!==e.from||this.to!==e.to)return!1;for(let n=0;n<this.nodes.length;n++)if(!this.nodes[n].eq(e.nodes[n]))return!1;return!0}map(e,n){const i=n.mapResult(this.from),r=n.mapResult(this.to);return r.deleted?b.Selection.near(e.resolve(i.pos)):i.deleted?b.Selection.near(e.resolve(r.pos)):new V(e.resolve(i.pos),e.resolve(r.pos))}toJSON(){return{type:"node",anchor:this.anchor,head:this.head}}}const Sn=xe.__serializeForClipboard;let N;function Jt(o,t){var i;if(!t.dom.isConnected)return;const e=t.posAtCoords(o);if(!e)return;let n=t.domAtPos(e.pos).node;if(n!==t.dom){for(;n&&n.parentNode&&n.parentNode!==t.dom&&!((i=n.hasAttribute)!=null&&i.call(n,"data-id"));)n=n.parentNode;if(n)return{node:n,id:n.getAttribute("data-id")}}}function Tn(o,t){const e=Jt(o,t);if(e&&e.node.nodeType===1){const n=t.docView,i=n.nearestDesc(e.node,!0);return!i||i===n?null:i.posBefore}return null}function Bn(o,t){let e,n;const i=t.resolve(o.from).node().type.spec.group==="blockContent",r=t.resolve(o.to).node().type.spec.group==="blockContent",s=Math.min(o.$anchor.depth,o.$head.depth);if(i&&r){const l=o.$from.start(s-1),a=o.$to.end(s-1);e=t.resolve(l-1).pos,n=t.resolve(a+1).pos}else e=o.from,n=o.to;return{from:e,to:n}}function Zt(o,t,e=t){t===e&&(e+=o.state.doc.resolve(t+1).node().nodeSize);const n=o.domAtPos(t).node.cloneNode(!0),i=o.domAtPos(t).node,r=(c,m)=>Array.prototype.indexOf.call(c.children,m),s=r(i,o.domAtPos(t+1).node.parentElement),l=r(i,o.domAtPos(e-1).node.parentElement);for(let c=i.childElementCount-1;c>=0;c--)(c>l||c<s)&&n.removeChild(n.children[c]);Qt(),N=n;const d=o.dom.className.split(" ").filter(c=>!c.includes("bn")&&!c.includes("ProseMirror")&&!c.includes("editor")).join(" ");N.className=N.className+" "+O.dragPreview+" "+d,document.body.appendChild(N)}function Qt(){N!==void 0&&(document.body.removeChild(N),N=void 0)}function xn(o,t){if(!o.dataTransfer)return;const e=t.dom.getBoundingClientRect(),n={left:e.left+e.width/2,top:o.clientY},i=Tn(n,t);if(i!=null){const r=t.state.selection,s=t.state.doc,{from:l,to:a}=Bn(r,s),d=l<=i&&i<a,c=r.$anchor.node()!==r.$head.node()||r instanceof V;d&&c?(t.dispatch(t.state.tr.setSelection(V.create(s,l,a))),Zt(t,l,a)):(t.dispatch(t.state.tr.setSelection(b.NodeSelection.create(t.state.doc,i))),Zt(t,i));const m=t.state.selection.content(),{dom:h,text:p}=Sn(t,m);o.dataTransfer.clearData(),o.dataTransfer.setData("text/html",h.innerHTML),o.dataTransfer.setData("text/plain",p),o.dataTransfer.effectAllowed="move",o.dataTransfer.setDragImage(N,0,0),t.dragging={slice:m,move:!0}}}class te{constructor(t,e,n){u(this,"sideMenuState");u(this,"horizontalPosAnchoredAtRoot");u(this,"horizontalPosAnchor");u(this,"hoveredBlock");u(this,"isDragging",!1);u(this,"menuFrozen",!1);u(this,"onDragStart",()=>{this.isDragging=!0});u(this,"onDrop",t=>{if(this.editor._tiptapEditor.commands.blur(),t.synthetic||!this.isDragging)return;const e=this.pmView.posAtCoords({left:t.clientX,top:t.clientY});if(this.isDragging=!1,!e||e.inside===-1){const n=new Event("drop",t),i=this.pmView.dom.firstChild.getBoundingClientRect();n.clientX=i.left+i.width/2,n.clientY=t.clientY,n.dataTransfer=t.dataTransfer,n.preventDefault=()=>t.preventDefault(),n.synthetic=!0,this.pmView.dom.dispatchEvent(n)}});u(this,"onDragOver",t=>{if(t.synthetic||!this.isDragging)return;const e=this.pmView.posAtCoords({left:t.clientX,top:t.clientY});if(!e||e.inside===-1){const n=new Event("dragover",t),i=this.pmView.dom.firstChild.getBoundingClientRect();n.clientX=i.left+i.width/2,n.clientY=t.clientY,n.dataTransfer=t.dataTransfer,n.preventDefault=()=>t.preventDefault(),n.synthetic=!0,this.pmView.dom.dispatchEvent(n)}});u(this,"onKeyDown",t=>{var e;(e=this.sideMenuState)!=null&&e.show&&(this.sideMenuState.show=!1,this.updateSideMenu(this.sideMenuState)),this.menuFrozen=!1});u(this,"onMouseMove",t=>{var d,c,m,h,p;if(this.menuFrozen)return;const e=this.pmView.dom.firstChild.getBoundingClientRect(),n=this.pmView.dom.getBoundingClientRect(),i=t.clientX>=n.left&&t.clientX<=n.right&&t.clientY>=n.top&&t.clientY<=n.bottom,r=this.pmView.dom.parentElement;if(i&&t&&t.target&&!(r===t.target||r.contains(t.target))){(d=this.sideMenuState)!=null&&d.show&&(this.sideMenuState.show=!1,this.updateSideMenu(this.sideMenuState));return}this.horizontalPosAnchor=e.x;const s={left:e.left+e.width/2,top:t.clientY},l=Jt(s,this.pmView);if(!l||!this.editor.isEditable){(c=this.sideMenuState)!=null&&c.show&&(this.sideMenuState.show=!1,this.updateSideMenu(this.sideMenuState));return}if((m=this.sideMenuState)!=null&&m.show&&((h=this.hoveredBlock)!=null&&h.hasAttribute("data-id"))&&((p=this.hoveredBlock)==null?void 0:p.getAttribute("data-id"))===l.id)return;this.hoveredBlock=l.node;const a=l.node.firstChild;if(a&&this.editor.isEditable){const k=a.getBoundingClientRect();this.sideMenuState={show:!0,referencePos:new DOMRect(this.horizontalPosAnchoredAtRoot?this.horizontalPosAnchor:k.x,k.y,k.width,k.height),block:this.editor.getBlock(this.hoveredBlock.getAttribute("data-id"))},this.updateSideMenu(this.sideMenuState)}});u(this,"onScroll",()=>{var t;if((t=this.sideMenuState)!=null&&t.show){const n=this.hoveredBlock.firstChild.getBoundingClientRect();this.sideMenuState.referencePos=new DOMRect(this.horizontalPosAnchoredAtRoot?this.horizontalPosAnchor:n.x,n.y,n.width,n.height),this.updateSideMenu(this.sideMenuState)}});this.editor=t,this.pmView=e,this.updateSideMenu=n,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("keydown",this.onKeyDown,!0)}destroy(){var t;(t=this.sideMenuState)!=null&&t.show&&(this.sideMenuState.show=!1,this.updateSideMenu(this.sideMenuState)),document.body.removeEventListener("mousemove",this.onMouseMove),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("keydown",this.onKeyDown,!0)}addBlock(){var l;(l=this.sideMenuState)!=null&&l.show&&(this.sideMenuState.show=!1,this.updateSideMenu(this.sideMenuState)),this.menuFrozen=!0;const e=this.hoveredBlock.firstChild.getBoundingClientRect(),n=this.pmView.posAtCoords({left:e.left+e.width/2,top:e.top+e.height/2});if(!n)return;const i=v(this.editor._tiptapEditor.state.doc,n.pos);if(i===void 0)return;const{contentNode:r,endPos:s}=i;if(r.textContent.length!==0){const a=s+1,d=a+2;this.editor._tiptapEditor.chain().BNCreateBlock(a).BNUpdateBlock(d,{type:"paragraph",props:{}}).setTextSelection(d).run()}else this.editor._tiptapEditor.commands.setTextSelection(s);this.pmView.focus(),this.pmView.dispatch(this.pmView.state.tr.scrollIntoView().setMeta($,{activate:!0,type:"drag"}))}}const ee=new b.PluginKey("SideMenuPlugin");class ne extends U{constructor(e){super();u(this,"sideMenuView");u(this,"plugin");u(this,"addBlock",()=>this.sideMenuView.addBlock());u(this,"blockDragStart",e=>{this.sideMenuView.isDragging=!0,xn(e,this.editor.prosemirrorView)});u(this,"blockDragEnd",()=>Qt());u(this,"freezeMenu",()=>this.sideMenuView.menuFrozen=!0);u(this,"unfreezeMenu",()=>this.sideMenuView.menuFrozen=!1);this.editor=e,this.plugin=new b.Plugin({key:ee,view:n=>(this.sideMenuView=new te(e,n,i=>{this.emit("update",i)}),this.sideMenuView)})}onUpdate(e){return this.on("update",e)}}function L(o,t){const e=o.getTextCursorPosition().block;if(e.content===void 0)throw new Error("Slash Menu open in a block that doesn't contain inline content.");e.content.length===1&&e.content[0].type==="text"&&e.content[0].text==="/"||e.content.length===0?o.updateBlock(e,t):(o.insertBlocks([t],e,"after"),o.setTextCursorPosition(o.getTextCursorPosition().nextBlock))}const oe=(o=X)=>{var e,n,i;const t=[];return"heading"in o&&"level"in o.heading.propSchema&&((e=o.heading.propSchema.level.values)!=null&&e.includes(1)&&t.push({name:"Heading",aliases:["h","heading1","h1"],execute:r=>L(r,{type:"heading",props:{level:1}})}),(n=o.heading.propSchema.level.values)!=null&&n.includes(2)&&t.push({name:"Heading 2",aliases:["h2","heading2","subheading"],execute:r=>L(r,{type:"heading",props:{level:2}})}),(i=o.heading.propSchema.level.values)!=null&&i.includes(3)&&t.push({name:"Heading 3",aliases:["h3","heading3","subheading"],execute:r=>L(r,{type:"heading",props:{level:3}})})),"bulletListItem"in o&&t.push({name:"Bullet List",aliases:["ul","list","bulletlist","bullet list"],execute:r=>L(r,{type:"bulletListItem"})}),"numberedListItem"in o&&t.push({name:"Numbered List",aliases:["li","list","numberedlist","numbered list"],execute:r=>L(r,{type:"numberedListItem"})}),"paragraph"in o&&t.push({name:"Paragraph",aliases:["p"],execute:r=>L(r,{type:"paragraph"})}),"image"in o&&t.push({name:"Image",aliases:["image","imageUpload","upload","img","picture","media","url","drive","dropbox"],execute:r=>{L(r,{type:"image"}),r.setTextCursorPosition(r.getTextCursorPosition().nextBlock,"start"),r._tiptapEditor.view.dispatch(r._tiptapEditor.state.tr.setMeta(z,{block:r.getTextCursorPosition().prevBlock}))}}),t},Mn={enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!1};class _n{constructor(t={}){u(this,"_tiptapEditor");u(this,"blockCache",new WeakMap);u(this,"schema");u(this,"ready",!1);u(this,"sideMenu");u(this,"formattingToolbar");u(this,"slashMenu");u(this,"hyperlinkToolbar");u(this,"imageToolbar");u(this,"uploadFile");var l,a,d,c,m;this.options=t;const e={defaultStyles:!0,blockSchema:t.blockSchema||X,...t};this.sideMenu=new ne(this),this.formattingToolbar=new Kt(this),this.slashMenu=new At(this,e.slashMenuItems||oe(e.blockSchema)),this.hyperlinkToolbar=new Yt(this),this.imageToolbar=new qt(this);const n=Pt({editor:this,domAttributes:e.domAttributes||{},blockSchema:e.blockSchema,collaboration:e.collaboration}),i=g.Extension.create({name:"BlockNoteUIExtension",addProseMirrorPlugins:()=>[this.sideMenu.plugin,this.formattingToolbar.plugin,this.slashMenu.plugin,this.hyperlinkToolbar.plugin,this.imageToolbar.plugin]});n.push(i),this.schema=e.blockSchema,this.uploadFile=e.uploadFile;const r=e.initialContent||(t.collaboration?void 0:[{type:"paragraph",id:q.options.generateID()}]),s={...Mn,...e._tiptapOptions,onBeforeCreate(h){if(!r)return;const p=h.editor.schema,k=p.node("doc",void 0,p.node("blockGroup",void 0,[F({id:"initialBlock",type:"paragraph"},p)]));h.editor.options.content=k.toJSON()},onCreate:()=>{var h;r!==void 0&&this.replaceBlocks(this.topLevelBlocks,r),(h=e.onEditorReady)==null||h.call(e,this),this.ready=!0},onUpdate:()=>{var h;this.ready&&((h=e.onEditorContentChange)==null||h.call(e,this))},onSelectionUpdate:()=>{var h;this.ready&&((h=e.onTextCursorPositionChange)==null||h.call(e,this))},editable:t.editable===void 0?!0:t.editable,extensions:e.enableBlockNoteExtensions===!1?(l=e._tiptapOptions)==null?void 0:l.extensions:[...((a=e._tiptapOptions)==null?void 0:a.extensions)||[],...n],editorProps:{attributes:{...(d=e.domAttributes)==null?void 0:d.editor,class:x(O.bnEditor,O.bnRoot,e.defaultStyles?O.defaultStyles:"",((m=(c=e.domAttributes)==null?void 0:c.editor)==null?void 0:m.class)||"")}}};e.parentElement&&(s.element=e.parentElement),this._tiptapEditor=new g.Editor(s)}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(){const t=[];return this._tiptapEditor.state.doc.firstChild.descendants(e=>(t.push(P(e,this.schema,this.blockCache)),!1)),t}getBlock(t){const e=typeof t=="string"?t:t.id;let n;return this._tiptapEditor.state.doc.firstChild.descendants(i=>typeof n<"u"?!1:i.type.name!=="blockContainer"||i.attrs.id!==e?!0:(n=P(i,this.schema,this.blockCache),!1)),n}forEachBlock(t,e=!1){const n=this.topLevelBlocks.slice();e&&n.reverse();function i(r){for(const s of r){if(!t(s))return!1;const l=e?s.children.slice().reverse():s.children;if(!i(l))return!1}return!0}i(n)}onEditorContentChange(t){this._tiptapEditor.on("update",t)}onEditorSelectionChange(t){this._tiptapEditor.on("selectionUpdate",t)}getTextCursorPosition(){const{node:t,depth:e,startPos:n,endPos:i}=v(this._tiptapEditor.state.doc,this._tiptapEditor.state.selection.from),r=this._tiptapEditor.state.doc.resolve(i).index(e-1),s=this._tiptapEditor.state.doc.resolve(i+1).node().childCount;let l;r>0&&(l=this._tiptapEditor.state.doc.resolve(n-2).node());let a;return r<s-1&&(a=this._tiptapEditor.state.doc.resolve(i+2).node()),{block:P(t,this.schema,this.blockCache),prevBlock:l===void 0?void 0:P(l,this.schema,this.blockCache),nextBlock:a===void 0?void 0:P(a,this.schema,this.blockCache)}}setTextCursorPosition(t,e="start"){const n=typeof t=="string"?t:t.id,{posBeforeNode:i}=j(n,this._tiptapEditor.state.doc),{startPos:r,contentNode:s}=v(this._tiptapEditor.state.doc,i+2);if(s.type.spec.content===""){this._tiptapEditor.commands.setNodeSelection(r);return}e==="start"?this._tiptapEditor.commands.setTextSelection(r+1):this._tiptapEditor.commands.setTextSelection(r+s.nodeSize-1)}getSelection(){if(this._tiptapEditor.state.selection.from===this._tiptapEditor.state.selection.to||"node"in this._tiptapEditor.state.selection)return;const t=[];return this._tiptapEditor.state.doc.descendants((e,n)=>e.type.spec.group!=="blockContent"||n+e.nodeSize<this._tiptapEditor.state.selection.from||n>this._tiptapEditor.state.selection.to?!0:(t.push(P(this._tiptapEditor.state.doc.resolve(n).node(),this.schema,this.blockCache)),!1)),{blocks:t}}get isEditable(){return this._tiptapEditor.isEditable}set isEditable(t){this._tiptapEditor.setEditable(t)}insertBlocks(t,e,n="before"){Nt(t,e,n,this._tiptapEditor)}updateBlock(t,e){on(t,e,this._tiptapEditor)}removeBlocks(t){Ht(t,this._tiptapEditor)}replaceBlocks(t,e){rn(t,e,this._tiptapEditor)}getActiveStyles(){const t={},e=this._tiptapEditor.state.selection.$to.marks(),n=new Set(["bold","italic","underline","strike","code"]),i=new Set(["textColor","backgroundColor"]);for(const r of e)n.has(r.type.name)?t[r.type.name]=!0:i.has(r.type.name)&&(t[r.type.name]=r.attrs.color);return t}addStyles(t){const e=new Set(["bold","italic","underline","strike","code"]),n=new Set(["textColor","backgroundColor"]);this._tiptapEditor.view.focus();for(const[i,r]of Object.entries(t))e.has(i)?this._tiptapEditor.commands.setMark(i):n.has(i)&&this._tiptapEditor.commands.setMark(i,{color:r})}removeStyles(t){this._tiptapEditor.view.focus();for(const e of Object.keys(t))this._tiptapEditor.commands.unsetMark(e)}toggleStyles(t){const e=new Set(["bold","italic","underline","strike","code"]),n=new Set(["textColor","backgroundColor"]);this._tiptapEditor.view.focus();for(const[i,r]of Object.entries(t))e.has(i)?this._tiptapEditor.commands.toggleMark(i):n.has(i)&&this._tiptapEditor.commands.toggleMark(i,{color:r})}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;const{from:n,to:i}=this._tiptapEditor.state.selection;e||(e=this._tiptapEditor.state.doc.textBetween(n,i));const r=this._tiptapEditor.schema.mark("link",{href:t});this._tiptapEditor.view.dispatch(this._tiptapEditor.view.state.tr.insertText(e,n,i).addMark(n,n+e.length,r))}canNestBlock(){const{startPos:t,depth:e}=v(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(){const{depth:t}=v(this._tiptapEditor.state.doc,this._tiptapEditor.state.selection.from);return t>2}unnestBlock(){this._tiptapEditor.commands.liftListItem("blockContainer")}async blocksToHTML(t){return Lt(t,this._tiptapEditor.schema)}async HTMLToBlocks(t){return Dt(t,this.schema,this._tiptapEditor.schema)}async blocksToMarkdown(t){return ln(t,this._tiptapEditor.schema)}async markdownToBlocks(t){return cn(t,this.schema,this._tiptapEditor.schema)}updateCollaborationUserInfo(t){if(!this.options.collaboration)throw new Error("Cannot update collaboration user info when collaboration is disabled.");this._tiptapEditor.commands.updateUser(t)}}const In=async o=>{const t=new FormData;return t.append("file",o),(await(await fetch("https://tmpfiles.org/api/v1/upload",{method:"POST",body:t})).json()).data.url.replace("tmpfiles.org/","tmpfiles.org/dl/")};f.BlockNoteEditor=_n,f.CustomBlockSerializerExtension=_t,f.FormattingToolbarProsemirrorPlugin=Kt,f.FormattingToolbarView=Gt,f.HyperlinkToolbarProsemirrorPlugin=Yt,f.ImageToolbarProsemirrorPlugin=qt,f.ImageToolbarView=Ut,f.SideMenuProsemirrorPlugin=ne,f.SideMenuView=te,f.SlashMenuProsemirrorPlugin=At,f.UnreachableCaseError=it,f.blockStyles=Fe,f.camelToDataKebab=K,f.createBlockSpec=Vt,f.createTipTapBlock=R,f.defaultBlockSchema=X,f.defaultProps=T,f.formatKeyboardShortcut=De,f.formattingToolbarPluginKey=jt,f.getBlockNoteExtensions=Pt,f.getDefaultSlashMenuItems=oe,f.hyperlinkToolbarPluginKey=Xt,f.imageToolbarPluginKey=z,f.isAppleOS=ot,f.mergeCSSClasses=x,f.parse=Rt,f.propsToAttributes=Ot,f.render=zt,f.setupSuggestionsMenu=It,f.sideMenuPluginKey=ee,f.slashMenuPluginKey=$,f.uploadToTmpFilesDotOrg_DEV_ONLY=In,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
|
|
5
|
+
`,styles:{}};return}const i={};let r;for(const s of n.marks)if(s.type.name==="link")r=s;else if(st.has(s.type.name))i[s.type.name]=!0;else if(at.has(s.type.name))i[s.type.name]=s.attrs.color;else throw Error("Mark is of an unrecognized type: "+s.type.name);e?e.type==="text"?r?(t.push(e),e={type:"link",href:r.attrs.href,content:[{type:"text",text:n.textContent,styles:i}]}):JSON.stringify(e.styles)===JSON.stringify(i)?e.text+=n.textContent:(t.push(e),e={type:"text",text:n.textContent,styles:i}):e.type==="link"&&(r?e.href===r.attrs.href?JSON.stringify(e.content[e.content.length-1].styles)===JSON.stringify(i)?e.content[e.content.length-1].text+=n.textContent:e.content.push({type:"text",text:n.textContent,styles:i}):(t.push(e),e={type:"link",href:r.attrs.href,content:[{type:"text",text:n.textContent,styles:i}]}):(t.push(e),e={type:"text",text:n.textContent,styles:i})):r?e={type:"link",href:r.attrs.href,content:[{type:"text",text:n.textContent,styles:i}]}:e={type:"text",text:n.textContent,styles:i}}),e&&t.push(e),t}function N(o,t,e){if(o.type.name!=="blockContainer")throw Error("Node must be of type blockContainer, but is of type"+o.type.name+".");const n=e==null?void 0:e.get(o);if(n)return n;const i=ot(o);let r=i.id;r===null&&(r=W.options.generateID());const s={};for(const[c,h]of Object.entries({...o.attrs,...i.contentNode.attrs})){const f=t[i.contentType.name];if(!f)throw Error("Block is of an unrecognized type: "+i.contentType.name);const p=f.propSchema;c in p&&(s[c]=h)}const l=t[i.contentType.name],a=[];for(let c=0;c<i.numChildBlocks;c++)a.push(N(o.lastChild.child(c),t,e));const d={id:r,type:l.node.name,props:s,content:l.node.config.content==="inline*"?ze(i.contentNode):void 0,children:a};return e==null||e.set(o,d),d}const ut=new y.PluginKey("previous-blocks"),Ve={index:"index",level:"level",type:"type",depth:"depth","depth-change":"depth-change"},Fe=()=>{let o;return new y.Plugin({key:ut,view(t){return{update:async(e,n)=>{var i;((i=this.key)==null?void 0:i.getState(e.state).updatedBlocks.size)>0&&(o=setTimeout(()=>{e.dispatch(e.state.tr.setMeta(ut,{clearUpdate:!0}))},0))},destroy:()=>{o&&clearTimeout(o)}}},state:{init(){return{prevTransactionOldBlockAttrs:{},currentTransactionOldBlockAttrs:{},updatedBlocks:new Set}},apply(t,e,n,i){if(e.currentTransactionOldBlockAttrs={},e.updatedBlocks.clear(),!t.docChanged||n.doc.eq(i.doc))return e;const r={},s=g.findChildren(n.doc,d=>d.attrs.id),l=new Map(s.map(d=>[d.node.attrs.id,d])),a=g.findChildren(i.doc,d=>d.attrs.id);for(const d of a){const c=l.get(d.node.attrs.id),h=c==null?void 0:c.node.firstChild,f=d.node.firstChild;if(c&&h&&f){const p={index:f.attrs.index,level:f.attrs.level,type:f.type.name,depth:i.doc.resolve(d.pos).depth};let k={index:h.attrs.index,level:h.attrs.level,type:h.type.name,depth:n.doc.resolve(c.pos).depth};r[d.node.attrs.id]=k,t.getMeta("numberedListIndexing")&&(d.node.attrs.id in e.prevTransactionOldBlockAttrs&&(k=e.prevTransactionOldBlockAttrs[d.node.attrs.id]),p.type==="numberedListItem"&&(k.index=p.index)),e.currentTransactionOldBlockAttrs[d.node.attrs.id]=k,JSON.stringify(k)!==JSON.stringify(p)&&(k["depth-change"]=k.depth-p.depth,e.updatedBlocks.add(d.node.attrs.id))}}return e.prevTransactionOldBlockAttrs=r,e}},props:{decorations(t){const e=this.getState(t);if(e.updatedBlocks.size===0)return;const n=[];return t.doc.descendants((i,r)=>{if(!i.attrs.id||!e.updatedBlocks.has(i.attrs.id))return;const s=e.currentTransactionOldBlockAttrs[i.attrs.id],l={};for(const[d,c]of Object.entries(s))l["data-prev-"+Ve[d]]=c||"none";const a=H.Decoration.node(r,r+i.nodeSize,{...l});n.push(a)}),H.DecorationSet.create(t.doc,n)}}})},pt="_blockOuter_nstdf_5",ht="_block_nstdf_5",mt="_reactNodeViewRenderer_nstdf_17",ft="_blockContent_nstdf_22",gt="_blockGroup_nstdf_43",kt="_wrapper_nstdf_227",bt="_addImageButton_nstdf_235",yt="_addImageButtonIcon_nstdf_251",vt="_addImageButtonText_nstdf_257",wt="_imageAndCaptionWrapper_nstdf_261",Ct="_imageWrapper_nstdf_267",Et="_image_nstdf_261",St="_resizeHandle_nstdf_280",Tt="_caption_nstdf_291",Bt="_isEmpty_nstdf_297",Mt="_inlineContent_nstdf_297",xt="_isFilter_nstdf_298",_t="_hasAnchor_nstdf_310",v={blockOuter:pt,block:ht,reactNodeViewRenderer:mt,blockContent:ft,blockGroup:gt,wrapper:kt,addImageButton:bt,addImageButtonIcon:yt,addImageButtonText:vt,imageAndCaptionWrapper:wt,imageWrapper:Ct,image:Et,resizeHandle:St,caption:Tt,isEmpty:Bt,inlineContent:Mt,isFilter:xt,hasAnchor:_t},Ue=Object.freeze(Object.defineProperty({__proto__:null,addImageButton:bt,addImageButtonIcon:yt,addImageButtonText:vt,block:ht,blockContent:ft,blockGroup:gt,blockOuter:pt,caption:Tt,default:v,hasAnchor:_t,image:Et,imageAndCaptionWrapper:wt,imageWrapper:Ct,inlineContent:Mt,isEmpty:Bt,isFilter:xt,reactNodeViewRenderer:mt,resizeHandle:St,wrapper:kt},Symbol.toStringTag,{value:"Module"})),qe={blockColor:"data-block-color",blockStyle:"data-block-style",id:"data-id",depth:"data-depth",depthChange:"data-depth-change"},$e=new y.PluginKey("non-editable-block"),We=()=>new y.Plugin({key:$e,props:{handleKeyDown:(o,t)=>{"node"in o.state.selection&&t.preventDefault()}}}),Ge=g.Node.create({name:"blockContainer",group:"blockContainer",content:"blockContent blockGroup?",priority:50,defining:!0,parseHTML(){return[{tag:"div",getAttrs:o=>{if(typeof o=="string")return!1;const t={};for(const[e,n]of Object.entries(qe))o.getAttribute(n)&&(t[e]=o.getAttribute(n));return o.getAttribute("data-node-type")==="blockContainer"?t:!1}}]},renderHTML({HTMLAttributes:o}){var e;const t=((e=this.options.domAttributes)==null?void 0:e.blockContainer)||{};return["div",g.mergeAttributes(o,{class:v.blockOuter,"data-node-type":"block-outer"}),["div",g.mergeAttributes({...t,class:A(v.block,t.class),"data-node-type":this.name},o),0]]},addCommands(){return{BNCreateBlock:o=>({state:t,dispatch:e})=>{const n=t.schema.nodes.blockContainer.createAndFill();return e&&t.tr.insert(o,n),!0},BNDeleteBlock:o=>({state:t,dispatch:e})=>{const n=E(t.doc,o);if(n===void 0)return!1;const{startPos:i,endPos:r}=n;return e&&t.tr.deleteRange(i,r),!0},BNUpdateBlock:(o,t)=>({state:e,dispatch:n})=>{const i=E(e.doc,o);if(i===void 0)return!1;const{startPos:r,endPos:s,node:l,contentNode:a}=i;if(n){if(t.children!==void 0){const p=[];for(const k of t.children)p.push(q(k,e.schema));l.childCount===2?e.tr.replace(r+a.nodeSize+1,s-1,new B.Slice(B.Fragment.from(p),0,0)):e.tr.insert(r+a.nodeSize,e.schema.nodes.blockGroup.create({},p))}if(t.content!==void 0){let p=[];typeof t.content=="string"?p.push(e.schema.text(t.content)):p=ct(t.content,e.schema),e.tr.replace(r+1,r+a.nodeSize-1,new B.Slice(B.Fragment.from(p),0,0))}const d=a.type.name,c=t.type||d,h=e.schema.nodes[d].spec.content,f=e.schema.nodes[c].spec.content;h==="inline*"&&f===""?e.tr.replaceWith(r,s,e.schema.nodes[c].create({...a.attrs,...t.props})).setSelection(new y.NodeSelection(e.tr.doc.resolve(r))):e.tr.setNodeMarkup(r,t.type===void 0?void 0:e.schema.nodes[t.type],{...a.attrs,...t.props}),e.tr.setNodeMarkup(r-1,void 0,{...l.attrs,...t.props})}return!0},BNMergeBlocks:o=>({state:t,dispatch:e})=>{const n=t.doc.resolve(o+1).node().type.name==="blockContainer",i=t.doc.resolve(o-1).node().type.name==="blockContainer";if(!n||!i)return!1;const r=E(t.doc,o+1),{node:s,contentNode:l,startPos:a,endPos:d,depth:c}=r;if(s.childCount===2){const p=t.doc.resolve(a+l.nodeSize+1),k=t.doc.resolve(d-1),w=p.blockRange(k);e&&t.tr.lift(w,c-1)}let h=o-1,f=E(t.doc,h);for(;f.numChildBlocks>0;)if(h--,f=E(t.doc,h),f===void 0)return!1;return e&&(e(t.tr.deleteRange(a,a+l.nodeSize).replace(h-1,a,new B.Slice(l.content,0,0)).scrollIntoView()),t.tr.setSelection(new y.TextSelection(t.doc.resolve(h-1)))),!0},BNSplitBlock:(o,t)=>({state:e,dispatch:n})=>{const i=E(e.doc,o);if(i===void 0)return!1;const{contentNode:r,contentType:s,startPos:l,endPos:a,depth:d}=i,c=e.doc.cut(l+1,o),h=e.doc.cut(o,a-1),f=e.schema.nodes.blockContainer.createAndFill(),p=a+1,k=p+2;return n&&(e.tr.insert(p,f),e.tr.replace(k,k+1,h.content.size>0?new B.Slice(B.Fragment.from(h),d+2,d+2):void 0),t&&e.tr.setBlockType(k,k,e.schema.node(s).type,r.attrs),e.tr.setSelection(new y.TextSelection(e.doc.resolve(k))),e.tr.replace(l+1,a-1,c.content.size>0?new B.Slice(B.Fragment.from(c),d+2,d+2):void 0)),!0}}},addProseMirrorPlugins(){return[Fe(),We()]},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.first(({commands:n})=>[()=>n.deleteSelection(),()=>n.undoInputRule(),()=>n.command(({state:i})=>{const{contentType:r}=E(i.doc,i.selection.from),s=i.selection.$anchor.parentOffset===0,l=r.name==="paragraph";return s&&!l?n.BNUpdateBlock(i.selection.from,{type:"paragraph",props:{}}):!1}),()=>n.command(({state:i})=>i.selection.$anchor.parentOffset===0?n.liftListItem("blockContainer"):!1),()=>n.command(({state:i})=>{const{depth:r,startPos:s}=E(i.doc,i.selection.from),l=i.selection.$anchor.parentOffset===0,a=i.selection.anchor===i.selection.head,d=s===2,c=s-1;return!d&&l&&a&&r===2?n.BNMergeBlocks(c):!1})]),Delete:()=>this.editor.commands.first(({commands:n})=>[()=>n.deleteSelection(),()=>n.command(({state:i})=>{const{node:r,contentNode:s,depth:l,endPos:a}=E(i.doc,i.selection.from),d=i.selection.$anchor.parentOffset===s.firstChild.nodeSize,c=i.selection.anchor===i.selection.head,h=r.childCount===2;if(d&&c&&!h){let f=l,p=a+2,k=i.doc.resolve(p).depth;for(;k<f;)f=k,p+=2,k=i.doc.resolve(p).depth;return n.BNMergeBlocks(p-1)}return!1})]),Enter:()=>this.editor.commands.first(({commands:n})=>[()=>n.command(({state:i})=>{const{node:r,depth:s}=E(i.doc,i.selection.from),l=i.selection.$anchor.parentOffset===0,a=i.selection.anchor===i.selection.head,d=r.textContent.length===0,c=s>2;return l&&a&&d&&c?n.liftListItem("blockContainer"):!1}),()=>n.command(({state:i,chain:r})=>{const{node:s,endPos:l}=E(i.doc,i.selection.from),a=i.selection.$anchor.parentOffset===0,d=i.selection.anchor===i.selection.head,c=s.textContent.length===0;if(a&&d&&c){const h=l+1,f=h+2;return r().BNCreateBlock(h).setTextSelection(f).run(),!0}return!1}),()=>n.command(({state:i,chain:r})=>{const{node:s}=E(i.doc,i.selection.from),l=i.selection.$anchor.parentOffset===0;return s.textContent.length===0?!1:(r().deleteSelection().BNSplitBlock(i.selection.from,l).run(),!0)})]),Tab:()=>(this.editor.commands.sinkListItem("blockContainer"),!0),"Shift-Tab":()=>(this.editor.commands.liftListItem("blockContainer"),!0),"Mod-Alt-0":()=>this.editor.commands.BNCreateBlock(this.editor.state.selection.anchor+2)}}}),je=g.Node.create({name:"blockGroup",group:"blockGroup",content:"blockContainer+",parseHTML(){return[{tag:"div",getAttrs:o=>typeof o=="string"?!1:o.getAttribute("data-node-type")==="blockGroup"?null:!1}]},renderHTML({HTMLAttributes:o}){var e;const t=((e=this.options.domAttributes)==null?void 0:e.blockGroup)||{};return["div",g.mergeAttributes({...t,class:A(v.blockGroup,t.class),"data-node-type":"blockGroup"},o),0]}}),Ke=g.Node.create({name:"doc",topNode:!0,content:"blockGroup"}),Xe=o=>{const t=B.DOMSerializer.fromSchema(o);return new B.DOMSerializer({...t.nodes},t.marks)},It=g.Extension.create({addProseMirrorPlugins(){return[new y.Plugin({props:{clipboardSerializer:Xe(this.editor.schema)}})]}});class ${constructor(){u(this,"callbacks",{})}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),()=>this.off(t,e)}emit(t,...e){const n=this.callbacks[t];n&&n.forEach(i=>i.apply(this,e))}off(t,e){const n=this.callbacks[t];n&&(e?this.callbacks[t]=n.filter(i=>i!==e):delete this.callbacks[t])}removeAllListeners(){this.callbacks={}}}const Ye=g.findParentNode(o=>o.type.name==="blockContainer");class Je{constructor(t,e,n=()=>{}){u(this,"suggestionsMenuState");u(this,"updateSuggestionsMenu");u(this,"pluginState");u(this,"handleScroll",()=>{var t;if((t=this.suggestionsMenuState)!=null&&t.show){const e=document.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);this.suggestionsMenuState.referencePos=e.getBoundingClientRect(),this.updateSuggestionsMenu()}});this.editor=t,this.pluginKey=e,this.pluginState=K(),this.updateSuggestionsMenu=()=>{if(!this.suggestionsMenuState)throw new Error("Attempting to update uninitialized suggestions menu");n(this.suggestionsMenuState)},document.addEventListener("scroll",this.handleScroll)}update(t,e){const n=this.pluginKey.getState(e),i=this.pluginKey.getState(t.state),r=!n.active&&i.active,s=n.active&&!i.active,l=n.active&&i.active;if(!r&&!l&&!s)return;if(this.pluginState=s?n:i,s||!this.editor.isEditable){this.suggestionsMenuState.show=!1,this.updateSuggestionsMenu();return}const a=document.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);this.editor.isEditable&&(this.suggestionsMenuState={show:!0,referencePos:a.getBoundingClientRect(),filteredItems:this.pluginState.items,keyboardHoveredItemIndex:this.pluginState.keyboardHoveredItemIndex},this.updateSuggestionsMenu())}destroy(){document.removeEventListener("scroll",this.handleScroll)}}function K(){return{active:!1,triggerCharacter:void 0,queryStartPos:void 0,items:[],keyboardHoveredItemIndex:void 0,notFoundCount:0,decorationId:void 0}}const At=(o,t,e,n,i=()=>[],r=()=>{})=>{if(n.length!==1)throw new Error("'char' should be a single character");let s;const l=a=>{a.dispatch(a.state.tr.setMeta(e,{deactivate:!0}))};return{plugin:new y.Plugin({key:e,view:()=>(s=new Je(o,e,t),s),state:{init(){return K()},apply(a,d,c,h){var p,k,w,S;if(a.getMeta("orderedListIndexing")!==void 0)return d;if((p=a.getMeta(e))!=null&&p.activate)return{active:!0,triggerCharacter:((k=a.getMeta(e))==null?void 0:k.triggerCharacter)||"",queryStartPos:h.selection.from,items:i(""),keyboardHoveredItemIndex:0,notFoundCount:0,decorationId:`id_${Math.floor(Math.random()*4294967295)}`};if(!d.active)return d;const f={...d};if(f.items=i(h.doc.textBetween(d.queryStartPos,h.selection.from)),f.notFoundCount=0,f.items.length===0&&(f.notFoundCount=Math.max(0,d.notFoundCount+(h.selection.from-c.selection.from))),h.selection.from!==h.selection.to||(w=a.getMeta(e))!=null&&w.deactivate||a.getMeta("focus")||a.getMeta("blur")||a.getMeta("pointer")||d.active&&h.selection.from<d.queryStartPos||f.notFoundCount>3)return K();if(((S=a.getMeta(e))==null?void 0:S.selectedItemIndexChanged)!==void 0){let T=a.getMeta(e).selectedItemIndexChanged;T<0?T=d.items.length-1:T>=d.items.length&&(T=0),f.keyboardHoveredItemIndex=T}else c.selection.from!==h.selection.from&&(f.keyboardHoveredItemIndex=0);return f}},props:{handleKeyDown(a,d){const c=this.getState(a.state).active;if(d.key===n&&!c)return a.dispatch(a.state.tr.insertText(n).scrollIntoView().setMeta(e,{activate:!0,triggerCharacter:n})),!0;if(!c)return!1;const{triggerCharacter:h,queryStartPos:f,items:p,keyboardHoveredItemIndex:k}=e.getState(a.state);return d.key==="ArrowUp"?(a.dispatch(a.state.tr.setMeta(e,{selectedItemIndexChanged:k-1})),!0):d.key==="ArrowDown"?(a.dispatch(a.state.tr.setMeta(e,{selectedItemIndexChanged:k+1})),!0):d.key==="Enter"?(p.length===0||(l(a),o._tiptapEditor.chain().focus().deleteRange({from:f-h.length,to:o._tiptapEditor.state.selection.from}).run(),r({item:p[k],editor:o})),!0):d.key==="Escape"?(l(a),!0):!1},decorations(a){const{active:d,decorationId:c,queryStartPos:h,triggerCharacter:f}=this.getState(a);if(!d)return null;if(f===""){const p=Ye(a.selection);if(p)return H.DecorationSet.create(a.doc,[H.Decoration.node(p.pos,p.pos+p.node.nodeSize,{nodeName:"span",class:"suggestion-decorator","data-decoration-id":c})])}return H.DecorationSet.create(a.doc,[H.Decoration.inline(h-f.length,h,{nodeName:"span",class:"suggestion-decorator","data-decoration-id":c})])}}}),itemCallback:a=>{l(o._tiptapEditor.view),o._tiptapEditor.chain().focus().deleteRange({from:s.pluginState.queryStartPos-s.pluginState.triggerCharacter.length,to:o._tiptapEditor.state.selection.from}).run(),r({item:a,editor:o})}}},G=new y.PluginKey("SlashMenuPlugin");class Pt extends ${constructor(e,n){super();u(this,"plugin");u(this,"itemCallback");const i=At(e,r=>{this.emit("update",r)},G,"/",r=>n.filter(({name:s,aliases:l})=>s.toLowerCase().startsWith(r.toLowerCase())||l&&l.filter(a=>a.toLowerCase().startsWith(r.toLowerCase())).length!==0),({item:r,editor:s})=>r.execute(s));this.plugin=i.plugin,this.itemCallback=i.itemCallback}onUpdate(e){return this.on("update",e)}}const Ze=new y.PluginKey("blocknote-placeholder"),Qe=g.Extension.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",isFilterClass:"is-filter",hasAnchorClass:"has-anchor",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new y.Plugin({key:Ze,props:{decorations:o=>{const{doc:t,selection:e}=o,n=G.getState(o),i=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,s=[];if(i)return t.descendants((l,a)=>{const d=r>=a&&r<=a+l.nodeSize,c=!l.isLeaf&&!l.childCount;if((d||!this.options.showOnlyCurrent)&&c){const h=[this.options.emptyNodeClass];this.editor.isEmpty&&h.push(this.options.emptyEditorClass),d&&h.push(this.options.hasAnchorClass),(n==null?void 0:n.triggerCharacter)===""&&(n!=null&&n.active)&&h.push(this.options.isFilterClass);const f=H.Decoration.node(a,a+l.nodeSize,{class:h.join(" ")});s.push(f)}return this.options.includeChildren}),H.DecorationSet.create(t,s)}}})]}}),tn=g.Extension.create({name:"textAlignment",addGlobalAttributes(){return[{types:["paragraph","heading","bulletListItem","numberedListItem"],attributes:{textAlignment:{default:"left",parseHTML:o=>o.getAttribute("data-text-alignment"),renderHTML:o=>o.textAlignment!=="left"&&{"data-text-alignment":o.textAlignment}}}}]},addCommands(){return{setTextAlignment:o=>({state:t})=>{const e=[],n=E(t.doc,t.selection.from);if(n===void 0)return!1;let i=n.startPos;for(;i<t.selection.to;)t.doc.resolve(i).node().type.spec.group==="blockContent"?(e.push(i-1),i+=t.doc.resolve(i).node().nodeSize-1):i+=1;for(const r of e)t.tr.setNodeAttribute(r,"textAlignment",o);return!0}}}}),en=g.Extension.create({name:"blockTextColor",addGlobalAttributes(){return[{types:["blockContainer"],attributes:{textColor:{default:_.textColor.default,parseHTML:o=>o.hasAttribute("data-text-color")?o.getAttribute("data-text-color"):_.textColor.default,renderHTML:o=>o.textColor!==_.textColor.default&&{"data-text-color":o.textColor}}}}]},addCommands(){return{setBlockTextColor:(o,t)=>({state:e,view:n})=>{const i=E(e.doc,o);return i===void 0?!1:(e.tr.setNodeAttribute(i.startPos-1,"textColor",t),n.focus(),!0)}}}}),nn=g.Mark.create({name:"textColor",addAttributes(){return{color:{default:void 0,parseHTML:o=>o.getAttribute("data-text-color"),renderHTML:o=>({"data-text-color":o.color})}}},parseHTML(){return[{tag:"span",getAttrs:o=>typeof o=="string"?!1:o.hasAttribute("data-text-color")?{color:o.getAttribute("data-text-color")}:!1}]},renderHTML({HTMLAttributes:o}){return["span",o,0]},addCommands(){return{setTextColor:o=>({commands:t})=>o!==_.textColor.default?t.setMark(this.name,{color:o}):t.unsetMark(this.name)}}}),on=g.Extension.create({name:"trailingNode",addProseMirrorPlugins(){const o=new y.PluginKey(this.name);return[new y.Plugin({key:o,appendTransaction:(t,e,n)=>{const{doc:i,tr:r,schema:s}=n,l=o.getState(n),a=i.content.size-2,d=s.nodes.blockContainer,c=s.nodes.paragraph;if(l)return r.insert(a,d.create(void 0,c.create()))},state:{init:(t,e)=>{},apply:(t,e)=>{if(!t.docChanged)return e;let n=t.doc.lastChild;if(!n||n.type.name!=="blockGroup")throw new Error("Expected blockGroup");if(n=n.lastChild,!n||n.type.name!=="blockContainer")throw new Error("Expected blockContainer");const i=n.firstChild;if(!i)throw new Error("Expected blockContent");return n.nodeSize>4||i.type.spec.content!=="inline*"}}})]}}),Ht=o=>{var e;const t=[g.extensions.ClipboardTextSerializer,g.extensions.Commands,g.extensions.Editable,g.extensions.FocusEvents,g.extensions.Tabindex,ce.Gapcursor,Qe.configure({emptyNodeClass:v.isEmpty,hasAnchorClass:v.hasAnchor,isFilterClass:v.isFilter,includeChildren:!0,showOnlyCurrent:!1}),W.configure({types:["blockContainer"]}),ue.HardBreak,ge.Text,O.Bold,se.Code,he.Italic,fe.Strike,ke.Underline,me.Link,nn,en,Le,He,tn,Ke,Ge.configure({domAttributes:o.domAttributes}),je.configure({domAttributes:o.domAttributes}),...Object.values(o.blockSchema).map(n=>n.node.configure({editor:o.editor,domAttributes:o.domAttributes})),It,de.Dropcursor.configure({width:5,color:"#ddeeff"}),on];if(o.collaboration){if(t.push(Be.default.configure({fragment:o.collaboration.fragment})),(e=o.collaboration.provider)!=null&&e.awareness){const n=i=>{const r=document.createElement("span");r.classList.add(z["collaboration-cursor__caret"]),r.setAttribute("style",`border-color: ${i.color}`);const s=document.createElement("span");s.classList.add(z["collaboration-cursor__label"]),s.setAttribute("style",`background-color: ${i.color}`),s.insertBefore(document.createTextNode(i.name),null);const l=document.createTextNode(""),a=document.createTextNode("");return r.insertBefore(l,null),r.insertBefore(s,null),r.insertBefore(a,null),r};t.push(Me.default.configure({user:o.collaboration.user,render:o.collaboration.renderCursor||n,provider:o.collaboration.provider}))}}else t.push(pe.History);return t};function X(o,t){let e,n;if(t.firstChild.descendants((i,r)=>e?!1:i.type.name!=="blockContainer"||i.attrs.id!==o?!0:(e=i,n=r+1,!1)),e===void 0||n===void 0)throw Error("Could not find block in the editor with matching ID.");return{node:e,posBeforeNode:n}}function Lt(o,t,e="before",n){const i=typeof t=="string"?t:t.id,r=[];for(const d of o)r.push(q(d,n.schema));let s=-1;const{node:l,posBeforeNode:a}=X(i,n.state.doc);if(e==="before"&&(s=a),e==="after"&&(s=a+l.nodeSize),e==="nested"){if(l.childCount<2){s=a+l.firstChild.nodeSize+1;const d=n.state.schema.nodes.blockGroup.create({},r);n.view.dispatch(n.state.tr.insert(s,d));return}s=a+l.firstChild.nodeSize+2}n.view.dispatch(n.state.tr.insert(s,r))}function rn(o,t,e){const n=typeof o=="string"?o:o.id,{posBeforeNode:i}=X(n,e.state.doc);e.commands.BNUpdateBlock(i+1,t)}function Nt(o,t){const e=new Set(o.map(i=>typeof i=="string"?i:i.id));let n=0;if(t.state.doc.descendants((i,r)=>{if(e.size===0)return!1;if(i.type.name!=="blockContainer"||!e.has(i.attrs.id))return!0;e.delete(i.attrs.id);const s=t.state.doc.nodeSize;t.commands.BNDeleteBlock(r-n+1);const l=t.state.doc.nodeSize;return n+=s-l,!1}),e.size>0){const i=[...e].join(`
|
|
6
|
+
`);throw Error("Blocks with the following IDs could not be found in the editor: "+i)}}function sn(o,t,e){Lt(t,o[0],"before",e),Nt(o,e)}function an(){const o=t=>{let e=t.children.length;for(let n=0;n<e;n++){const i=t.children[n];if(i.type==="element"&&(o(i),i.tagName==="u"))if(i.children.length>0){t.children.splice(n,1,...i.children);const r=i.children.length-1;e+=r,n+=r}else t.children.splice(n,1),e--,n--}};return o}function ln(o){const t=new Set([...o.orderedListItemBlockTypes,...o.unorderedListItemBlockTypes]),e=n=>{let i=n.children.length,r;for(let s=0;s<i;s++){const a=n.children[s].children[0],d=a.children[0],c=a.children.length===2?a.children[1]:null,h=t.has(d.properties.dataContentType),f=h?o.orderedListItemBlockTypes.has(d.properties.dataContentType)?"ol":"ul":null;if(c!==null&&e(c),r&&r.tagName!==f){n.children.splice(s-r.children.length,r.children.length,r);const p=r.children.length-1;s-=p,i-=p,r=void 0}if(h){r||(r=Q.fromDom(document.createElement(f)));const p=Q.fromDom(document.createElement("li"));p.children.push(d.children[0]),c!==null&&p.children.push(...c.children),r.children.push(p)}else if(c!==null){n.children.splice(s+1,0,...c.children),n.children[s]=d.children[0];const p=c.children.length;s+=p,i+=p}else n.children[s]=d.children[0]}r&&n.children.splice(i-r.children.length,r.children.length,r)};return e}async function Dt(o,t){const e=document.createElement("div"),n=B.DOMSerializer.fromSchema(t);for(const r of o){const s=q(r,t),l=n.serializeNode(s);e.appendChild(l)}return(await j.unified().use(tt.default,{fragment:!0}).use(ln,{orderedListItemBlockTypes:new Set(["numberedListItem"]),unorderedListItemBlockTypes:new Set(["bulletListItem"])}).use(et.default).process(e.innerHTML)).value}async function Ot(o,t,e){const n=document.createElement("div");n.innerHTML=o.trim();const r=B.DOMParser.fromSchema(e).parse(n),s=[];for(let l=0;l<r.firstChild.childCount;l++)s.push(N(r.firstChild.child(l),t));return s}async function dn(o,t){return(await j.unified().use(tt.default,{fragment:!0}).use(an).use(_e.default).use(nt.default).use(Pe.default).process(await Dt(o,t))).value}function cn(o,t){const e=t.value?t.value+`
|
|
7
|
+
`:"",n={};t.lang&&(n["data-language"]=t.lang);let i={type:"element",tagName:"code",properties:n,children:[{type:"text",value:e}]};return t.meta&&(i.data={meta:t.meta}),o.patch(t,i),i=o.applyData(t,i),i={type:"element",tagName:"pre",properties:{},children:[i]},o.patch(t,i),i}async function un(o,t,e){const n=await j.unified().use(Ie.default).use(nt.default).use(Ae.default,{handlers:{...Z.defaultHandlers,code:cn}}).use(et.default).process(o);return Ot(n.value,t,e)}function Y(o){return"data-"+o.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function Rt(o){const t={};return Object.entries(o.propSchema).forEach(([e,n])=>{t[e]={default:n.default,keepOnSplit:!0,parseHTML:i=>{const r=i.getAttribute(Y(e));if(r===null)return null;if(typeof n.default=="boolean")return r==="true"?!0:r==="false"?!1:null;if(typeof n.default=="number"){const s=parseFloat(r);return!Number.isNaN(s)&&Number.isFinite(s)?s:null}return r},renderHTML:i=>i[e]!==n.default?{[Y(e)]:i[e]}:{}}}),t}function zt(o){return[{tag:"div[data-content-type="+o.type+"]"}]}function Vt(o,t){const e=document.createElement("div");e.setAttribute("data-content-type",o.type);for(const[i,r]of Object.entries(t))e.setAttribute(i,r);let n;return o.containsInlineContent?(n=document.createElement("div"),e.appendChild(n)):n=void 0,n!==void 0?{dom:e,contentDOM:n}:{dom:e}}function Ft(o){return{node:V({name:o.type,content:o.containsInlineContent?"inline*":"",selectable:!0,addAttributes(){return Rt(o)},parseHTML(){return zt(o)},renderHTML({HTMLAttributes:e}){return Vt(o,e)},addNodeView(){return({HTMLAttributes:e,getPos:n})=>{var p,k;const i=document.createElement("div"),r=((p=this.options.domAttributes)==null?void 0:p.blockContent)||{};for(const[w,S]of Object.entries(r))w!=="class"&&i.setAttribute(w,S);i.className=A(v.blockContent,r.class),i.setAttribute("data-content-type",o.type);for(const[w,S]of Object.entries(e))i.setAttribute(w,S);const s=this.options.editor;if(typeof n=="boolean")throw new Error("Cannot find node position as getPos is a boolean, not a function.");const l=n(),c=s._tiptapEditor.state.doc.resolve(l).node().attrs.id,h=s.getBlock(c);if(h.type!==o.type)throw new Error("Block type does not match");const f=o.render(h,s);if(o.containsInlineContent){const w=f.contentDOM,S=((k=this.options.domAttributes)==null?void 0:k.inlineContent)||{};for(const[T,I]of Object.entries(S))T!=="class"&&w.setAttribute(T,I);w.className=A(w.className,v.inlineContent,S.class)}return i.appendChild(f.dom),"contentDOM"in f?{dom:i,contentDOM:f.contentDOM,destroy:f.destroy}:{dom:i,destroy:f.destroy}}}}),propSchema:o.propSchema}}function V(o){return g.Node.create({...o,group:"blockContent",content:o.content})}const pn={..._,level:{default:1,values:[1,2,3]}},hn={node:V({name:"heading",content:"inline*",addAttributes(){return{level:{default:1,parseHTML:o=>o.getAttribute("data-level"),renderHTML:o=>({"data-level":o.level.toString()})}}},addInputRules(){return[...[1,2,3].map(o=>new g.InputRule({find:new RegExp(`^(#{${o}})\\s$`),handler:({state:t,chain:e,range:n})=>{e().BNUpdateBlock(t.selection.from,{type:"heading",props:{level:o}}).deleteRange({from:n.from,to:n.to})}}))]},addKeyboardShortcuts(){return{"Mod-Alt-1":()=>this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor,{type:"heading",props:{level:1}}),"Mod-Alt-2":()=>this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor,{type:"heading",props:{level:2}}),"Mod-Alt-3":()=>this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor,{type:"heading",props:{level:3}})}},parseHTML(){return[{tag:"h1",attrs:{level:1},node:"heading"},{tag:"h2",attrs:{level:2},node:"heading"},{tag:"h3",attrs:{level:3},node:"heading"}]},renderHTML({node:o,HTMLAttributes:t}){var i,r;const e=((i=this.options.domAttributes)==null?void 0:i.blockContent)||{},n=((r=this.options.domAttributes)==null?void 0:r.inlineContent)||{};return["div",g.mergeAttributes(t,{...e,class:A(v.blockContent,e.class),"data-content-type":this.name}),[`h${o.attrs.level}`,{...n,class:A(v.inlineContent,n.class)},0]]}}),propSchema:pn},Ut=o=>{const{node:t,contentType:e}=E(o.state.doc,o.state.selection.from),n=o.state.selection.anchor===o.state.selection.head;return!e.name.endsWith("ListItem")||!n?!1:o.commands.first(({state:i,chain:r,commands:s})=>[()=>s.command(()=>t.textContent.length===0?s.BNUpdateBlock(i.selection.from,{type:"paragraph",props:{}}):!1),()=>s.command(()=>t.textContent.length>0?(r().deleteSelection().BNSplitBlock(i.selection.from,!0).run(),!0):!1)])},mn={..._},fn={node:V({name:"bulletListItem",content:"inline*",addInputRules(){return[new g.InputRule({find:new RegExp("^[-+*]\\s$"),handler:({state:o,chain:t,range:e})=>{t().BNUpdateBlock(o.selection.from,{type:"bulletListItem",props:{}}).deleteRange({from:e.from,to:e.to})}})]},addKeyboardShortcuts(){return{Enter:()=>Ut(this.editor),"Mod-Shift-7":()=>this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor,{type:"bulletListItem",props:{}})}},parseHTML(){return[{tag:"li",getAttrs:o=>{if(typeof o=="string")return!1;const t=o.parentElement;return t===null?!1:t.tagName==="UL"?{}:!1},node:"bulletListItem"},{tag:"p",getAttrs:o=>{if(typeof o=="string")return!1;const t=o.parentElement;return t===null?!1:t.getAttribute("data-content-type")==="bulletListItem"?{}:!1},priority:300,node:"bulletListItem"}]},renderHTML({HTMLAttributes:o}){var n,i;const t=((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},e=((i=this.options.domAttributes)==null?void 0:i.inlineContent)||{};return["div",g.mergeAttributes(o,{...t,class:A(v.blockContent,t.class),"data-content-type":this.name}),["p",{...e,class:A(v.inlineContent,e.class)},0]]}}),propSchema:mn},gn=new y.PluginKey("numbered-list-indexing"),kn=()=>new y.Plugin({key:gn,appendTransaction:(o,t,e)=>{const n=e.tr;n.setMeta("numberedListIndexing",!0);let i=!1;return e.doc.descendants((r,s)=>{if(r.type.name==="blockContainer"&&r.firstChild.type.name==="numberedListItem"){let l="1";const a=s===1,d=E(n.doc,s+1);if(d===void 0)return;if(!a){const f=E(n.doc,s-2);if(f===void 0)return;if(!(d.depth!==f.depth)){const k=f.contentNode;if(f.contentType.name==="numberedListItem"){const T=k.attrs.index;l=(parseInt(T)+1).toString()}}}d.contentNode.attrs.index!==l&&(i=!0,n.setNodeMarkup(s+1,void 0,{index:l}))}}),i?n:null}}),bn={..._},yn={node:V({name:"numberedListItem",content:"inline*",addAttributes(){return{index:{default:null,parseHTML:o=>o.getAttribute("data-index"),renderHTML:o=>({"data-index":o.index})}}},addInputRules(){return[new g.InputRule({find:new RegExp("^1\\.\\s$"),handler:({state:o,chain:t,range:e})=>{t().BNUpdateBlock(o.selection.from,{type:"numberedListItem",props:{}}).deleteRange({from:e.from,to:e.to})}})]},addKeyboardShortcuts(){return{Enter:()=>Ut(this.editor),"Mod-Shift-8":()=>this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor,{type:"numberedListItem",props:{}})}},addProseMirrorPlugins(){return[kn()]},parseHTML(){return[{tag:"li",getAttrs:o=>{if(typeof o=="string")return!1;const t=o.parentElement;return t===null?!1:t.tagName==="OL"?{}:!1},node:"numberedListItem"},{tag:"p",getAttrs:o=>{if(typeof o=="string")return!1;const t=o.parentElement;return t===null?!1:t.getAttribute("data-content-type")==="numberedListItem"?{}:!1},priority:300,node:"numberedListItem"}]},renderHTML({HTMLAttributes:o}){var n,i;const t=((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},e=((i=this.options.domAttributes)==null?void 0:i.inlineContent)||{};return["div",g.mergeAttributes(o,{...t,class:A(v.blockContent,t.class),"data-content-type":this.name}),["p",{...e,class:A(v.inlineContent,e.class)},0]]}}),propSchema:bn},vn={..._},wn={node:V({name:"paragraph",content:"inline*",parseHTML(){return[{tag:"p",priority:200,node:"paragraph"}]},renderHTML({HTMLAttributes:o}){var n,i;const t=((n=this.options.domAttributes)==null?void 0:n.blockContent)||{},e=((i=this.options.domAttributes)==null?void 0:i.inlineContent)||{};return["div",g.mergeAttributes({...t,class:A(v.blockContent,t.class),"data-content-type":this.name},o),["p",{...e,class:A(v.inlineContent,e.class)},0]]}}),propSchema:vn};class qt{constructor(t,e,n){u(this,"imageToolbarState");u(this,"updateImageToolbar");u(this,"prevWasEditable",null);u(this,"shouldShow",t=>"node"in t.selection&&t.selection.node.type.name==="image"&&t.selection.node.attrs.src==="");u(this,"mouseDownHandler",()=>{var t;(t=this.imageToolbarState)!=null&&t.show&&(this.imageToolbarState.show=!1,this.updateImageToolbar())});u(this,"dragstartHandler",()=>{var t;(t=this.imageToolbarState)!=null&&t.show&&(this.imageToolbarState.show=!1,this.updateImageToolbar())});u(this,"blurHandler",t=>{var n;const e=this.pmView.dom.parentElement;t&&t.relatedTarget&&(e===t.relatedTarget||e.contains(t.relatedTarget))||(n=this.imageToolbarState)!=null&&n.show&&(this.imageToolbarState.show=!1,this.updateImageToolbar())});u(this,"scrollHandler",()=>{var t;if((t=this.imageToolbarState)!=null&&t.show){const e=document.querySelector(`[data-node-type="blockContainer"][data-id="${this.imageToolbarState.block.id}"]`);this.imageToolbarState.referencePos=e.getBoundingClientRect(),this.updateImageToolbar()}});this.pluginKey=t,this.pmView=e,this.updateImageToolbar=()=>{if(!this.imageToolbarState)throw new Error("Attempting to update uninitialized image toolbar");n(this.imageToolbarState)},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,r;const n=this.pluginKey.getState(t.state);if(!((i=this.imageToolbarState)!=null&&i.show)&&n.block){const s=document.querySelector(`[data-node-type="blockContainer"][data-id="${n.block.id}"]`);this.imageToolbarState={show:!0,referencePos:s.getBoundingClientRect(),block:n.block},this.updateImageToolbar();return}(!t.state.selection.eq(e.selection)||!t.state.doc.eq(e.doc))&&(r=this.imageToolbarState)!=null&&r.show&&(this.imageToolbarState.show=!1,this.updateImageToolbar())}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)}}const F=new y.PluginKey("ImageToolbarPlugin");class $t extends ${constructor(e){super();u(this,"view");u(this,"plugin");this.plugin=new y.Plugin({key:F,view:n=>(this.view=new qt(F,n,i=>{this.emit("update",i)}),this.view),state:{init:()=>({block:void 0}),apply:n=>{var r;return{block:(r=n.getMeta(F))==null?void 0:r.block}}}})}onUpdate(e){return this.on("update",e)}}const Cn={textAlignment:_.textAlignment,backgroundColor:_.backgroundColor,url:{default:""},caption:{default:""},width:{default:512}},Wt=o=>{switch(o){case"left":return"flex-start";case"center":return"center";case"right":return"flex-end";default:return"flex-start"}},Gt=64,En=Ft({type:"image",propSchema:Cn,containsInlineContent:!1,render:(o,t)=>{const e=document.createElement("div");e.className=v.wrapper,e.style.alignItems=Wt(o.props.textAlignment);const n=document.createElement("div");n.className=v.addImageButton,n.style.display=o.props.url===""?"":"none";const i=document.createElement("div");i.className=v.addImageButtonIcon;const r=document.createElement("p");r.className=v.addImageButtonText,r.innerText="Add Image";const s=document.createElement("div");s.className=v.imageAndCaptionWrapper,s.style.display=o.props.url!==""?"":"none";const l=document.createElement("div");l.className=v.imageWrapper,l.style.display=o.props.url!==""?"":"none";const a=document.createElement("img");a.className=v.image,a.src=o.props.url,a.alt="placeholder",a.contentEditable="false",a.draggable=!1,a.style.width=`${Math.min(o.props.width,t.domElement.firstElementChild.clientWidth)}px`;const d=document.createElement("div");d.className=v.resizeHandle,d.style.left="4px";const c=document.createElement("div");c.className=v.resizeHandle,c.style.right="4px";const h=document.createElement("p");h.className=v.caption,h.innerText=o.props.caption,h.style.padding=o.props.caption?"4px":"";const f=()=>{var re;const b=((re=t.getSelection())==null?void 0:re.blocks)||[];[t.getTextCursorPosition().block,...b].find(Pn=>Pn.id===o.id)!==void 0?(n.style.outline="4px solid rgb(100, 160, 255)",s.style.outline="4px solid rgb(100, 160, 255)"):(n.style.outline="",s.style.outline="")};t.onEditorContentChange(f),t.onEditorSelectionChange(f);let p;const k=b=>{if(!p)return;let P;Wt(o.props.textAlignment)==="center"?p.handleUsed==="left"?P=p.initialWidth+(p.initialClientX-b.clientX)*2:P=p.initialWidth+(b.clientX-p.initialClientX)*2:p.handleUsed==="left"?P=p.initialWidth+p.initialClientX-b.clientX:P=p.initialWidth+b.clientX-p.initialClientX,P<Gt?a.style.width=`${Gt}px`:P>t.domElement.firstElementChild.clientWidth?a.style.width=`${t.domElement.firstElementChild.clientWidth}px`:a.style.width=`${P}px`},w=b=>{p&&((!b.target||!l.contains(b.target))&&l.contains(d)&&l.contains(c)&&(d.style.display="none",c.style.display="none"),p=void 0,t.updateBlock(o,{type:"image",props:{width:parseFloat(a.style.width.slice(0,-2))}}))},S=b=>{b.preventDefault()},T=()=>{t._tiptapEditor.view.dispatch(t._tiptapEditor.state.tr.setMeta(F,{block:o}))},I=()=>{t.isEditable?(d.style.display="block",c.style.display="block"):(d.style.display="none",c.style.display="none")},M=b=>{b.relatedTarget===d||b.relatedTarget===c||p||(d.style.display="none",c.style.display="none")},C=b=>{b.preventDefault(),d.style.display="block",c.style.display="block",p={handleUsed:"left",initialWidth:o.props.width,initialClientX:b.clientX}},x=b=>{b.preventDefault(),d.style.display="block",c.style.display="block",p={handleUsed:"right",initialWidth:o.props.width,initialClientX:b.clientX}};return e.appendChild(n),n.appendChild(i),n.appendChild(r),e.appendChild(s),s.appendChild(l),l.appendChild(a),l.appendChild(d),l.appendChild(c),s.appendChild(h),window.addEventListener("mousemove",k),window.addEventListener("mouseup",w),n.addEventListener("mousedown",S),n.addEventListener("click",T),a.addEventListener("mouseenter",I),a.addEventListener("mouseleave",M),d.addEventListener("mousedown",C),c.addEventListener("mousedown",x),{dom:e,destroy:()=>{window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",w),n.removeEventListener("mousedown",S),n.removeEventListener("click",T),d.removeEventListener("mousedown",C),c.removeEventListener("mousedown",x)}}}}),J={paragraph:wn,heading:hn,bulletListItem:fn,numberedListItem:yn,image:En};class jt{constructor(t,e,n){u(this,"formattingToolbarState");u(this,"updateFormattingToolbar");u(this,"preventHide",!1);u(this,"preventShow",!1);u(this,"prevWasEditable",null);u(this,"shouldShow",({view:t,state:e,from:n,to:i})=>{const{doc:r,selection:s}=e,{empty:l}=s,a=!r.textBetween(n,i).length&&g.isTextSelection(e.selection);return!(!t.hasFocus()||l||a)});u(this,"viewMousedownHandler",()=>{this.preventShow=!0});u(this,"viewMouseupHandler",()=>{this.preventShow=!1,setTimeout(()=>this.update(this.pmView))});u(this,"dragstartHandler",()=>{var t;(t=this.formattingToolbarState)!=null&&t.show&&(this.formattingToolbarState.show=!1,this.updateFormattingToolbar())});u(this,"focusHandler",()=>{setTimeout(()=>this.update(this.pmView))});u(this,"blurHandler",t=>{var n;if(this.preventHide){this.preventHide=!1;return}const e=this.pmView.dom.parentElement;t&&t.relatedTarget&&(e===t.relatedTarget||e.contains(t.relatedTarget))||(n=this.formattingToolbarState)!=null&&n.show&&(this.formattingToolbarState.show=!1,this.updateFormattingToolbar())});u(this,"scrollHandler",()=>{var t;(t=this.formattingToolbarState)!=null&&t.show&&(this.formattingToolbarState.referencePos=this.getSelectionBoundingBox(),this.updateFormattingToolbar())});this.editor=t,this.pmView=e,this.updateFormattingToolbar=()=>{if(!this.formattingToolbarState)throw new Error("Attempting to update uninitialized formatting toolbar");n(this.formattingToolbarState)},e.dom.addEventListener("mousedown",this.viewMousedownHandler),e.dom.addEventListener("mouseup",this.viewMouseupHandler),e.dom.addEventListener("dragstart",this.dragstartHandler),e.dom.addEventListener("focus",this.focusHandler),e.dom.addEventListener("blur",this.blurHandler),document.addEventListener("scroll",this.scrollHandler)}update(t,e){var f,p;const{state:n,composing:i}=t,{doc:r,selection:s}=n,l=e&&e.doc.eq(r)&&e.selection.eq(s);if((this.prevWasEditable===null||this.prevWasEditable===this.editor.isEditable)&&(i||l))return;this.prevWasEditable=this.editor.isEditable;const{ranges:a}=s,d=Math.min(...a.map(k=>k.$from.pos)),c=Math.max(...a.map(k=>k.$to.pos)),h=(f=this.shouldShow)==null?void 0:f.call(this,{view:t,state:n,from:d,to:c});if(this.editor.isEditable&&!this.preventShow&&(h||this.preventHide)){this.formattingToolbarState={show:!0,referencePos:this.getSelectionBoundingBox()},this.updateFormattingToolbar();return}if((p=this.formattingToolbarState)!=null&&p.show&&!this.preventHide&&(!h||this.preventShow||!this.editor.isEditable)){this.formattingToolbarState.show=!1,this.updateFormattingToolbar();return}}destroy(){this.pmView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.pmView.dom.removeEventListener("mouseup",this.viewMouseupHandler),this.pmView.dom.removeEventListener("dragstart",this.dragstartHandler),this.pmView.dom.removeEventListener("focus",this.focusHandler),this.pmView.dom.removeEventListener("blur",this.blurHandler),document.removeEventListener("scroll",this.scrollHandler)}getSelectionBoundingBox(){const{state:t}=this.pmView,{selection:e}=t,{ranges:n}=e,i=Math.min(...n.map(s=>s.$from.pos)),r=Math.max(...n.map(s=>s.$to.pos));if(g.isNodeSelection(e)){const s=this.pmView.nodeDOM(i);if(s)return s.getBoundingClientRect()}return g.posToDOMRect(this.pmView,i,r)}}const Kt=new y.PluginKey("FormattingToolbarPlugin");class Xt extends ${constructor(e){super();u(this,"view");u(this,"plugin");this.plugin=new y.Plugin({key:Kt,view:n=>(this.view=new jt(e,n,i=>{this.emit("update",i)}),this.view)})}onUpdate(e){return this.on("update",e)}}class Sn{constructor(t,e,n){u(this,"hyperlinkToolbarState");u(this,"updateHyperlinkToolbar");u(this,"menuUpdateTimer");u(this,"startMenuUpdateTimer");u(this,"stopMenuUpdateTimer");u(this,"mouseHoveredHyperlinkMark");u(this,"mouseHoveredHyperlinkMarkRange");u(this,"keyboardHoveredHyperlinkMark");u(this,"keyboardHoveredHyperlinkMarkRange");u(this,"hyperlinkMark");u(this,"hyperlinkMarkRange");u(this,"mouseOverHandler",t=>{if(this.mouseHoveredHyperlinkMark=void 0,this.mouseHoveredHyperlinkMarkRange=void 0,this.stopMenuUpdateTimer(),t.target instanceof HTMLAnchorElement&&t.target.nodeName==="A"){const e=t.target,n=this.pmView.posAtDOM(e,0)+1,i=this.pmView.state.doc.resolve(n),r=i.marks();for(const s of r)if(s.type.name===this.pmView.state.schema.mark("link").type.name){this.mouseHoveredHyperlinkMark=s,this.mouseHoveredHyperlinkMarkRange=g.getMarkRange(i,s.type,s.attrs)||void 0;break}}return this.startMenuUpdateTimer(),!1});u(this,"clickHandler",t=>{var n;const e=this.pmView.dom.parentElement;this.hyperlinkMark&&t&&t.target&&!(e===t.target||e.contains(t.target))&&(n=this.hyperlinkToolbarState)!=null&&n.show&&(this.hyperlinkToolbarState.show=!1,this.updateHyperlinkToolbar())});u(this,"scrollHandler",()=>{var t;this.hyperlinkMark!==void 0&&(t=this.hyperlinkToolbarState)!=null&&t.show&&(this.hyperlinkToolbarState.referencePos=g.posToDOMRect(this.pmView,this.hyperlinkMarkRange.from,this.hyperlinkMarkRange.to),this.updateHyperlinkToolbar())});this.editor=t,this.pmView=e,this.updateHyperlinkToolbar=()=>{if(!this.hyperlinkToolbarState)throw new Error("Attempting to update uninitialized hyperlink toolbar");n(this.hyperlinkToolbarState)},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)}editHyperlink(t,e){var i;const n=this.pmView.state.tr.insertText(e,this.hyperlinkMarkRange.from,this.hyperlinkMarkRange.to);n.addMark(this.hyperlinkMarkRange.from,this.hyperlinkMarkRange.from+e.length,this.pmView.state.schema.mark("link",{href:t})),this.pmView.dispatch(n),this.pmView.focus(),(i=this.hyperlinkToolbarState)!=null&&i.show&&(this.hyperlinkToolbarState.show=!1,this.updateHyperlinkToolbar())}deleteHyperlink(){var t;this.pmView.dispatch(this.pmView.state.tr.removeMark(this.hyperlinkMarkRange.from,this.hyperlinkMarkRange.to,this.hyperlinkMark.type).setMeta("preventAutolink",!0)),this.pmView.focus(),(t=this.hyperlinkToolbarState)!=null&&t.show&&(this.hyperlinkToolbarState.show=!1,this.updateHyperlinkToolbar())}update(){var e;if(!this.pmView.hasFocus())return;const t=this.hyperlinkMark;if(this.hyperlinkMark=void 0,this.hyperlinkMarkRange=void 0,this.keyboardHoveredHyperlinkMark=void 0,this.keyboardHoveredHyperlinkMarkRange=void 0,this.pmView.state.selection.empty){const n=this.pmView.state.selection.$from.marks();for(const i of n)if(i.type.name===this.pmView.state.schema.mark("link").type.name){this.keyboardHoveredHyperlinkMark=i,this.keyboardHoveredHyperlinkMarkRange=g.getMarkRange(this.pmView.state.selection.$from,i.type,i.attrs)||void 0;break}}if(this.mouseHoveredHyperlinkMark&&(this.hyperlinkMark=this.mouseHoveredHyperlinkMark,this.hyperlinkMarkRange=this.mouseHoveredHyperlinkMarkRange),this.keyboardHoveredHyperlinkMark&&(this.hyperlinkMark=this.keyboardHoveredHyperlinkMark,this.hyperlinkMarkRange=this.keyboardHoveredHyperlinkMarkRange),this.hyperlinkMark&&this.editor.isEditable){this.hyperlinkToolbarState={show:!0,referencePos:g.posToDOMRect(this.pmView,this.hyperlinkMarkRange.from,this.hyperlinkMarkRange.to),url:this.hyperlinkMark.attrs.href,text:this.pmView.state.doc.textBetween(this.hyperlinkMarkRange.from,this.hyperlinkMarkRange.to)},this.updateHyperlinkToolbar();return}if((e=this.hyperlinkToolbarState)!=null&&e.show&&t&&(!this.hyperlinkMark||!this.editor.isEditable)){this.hyperlinkToolbarState.show=!1,this.updateHyperlinkToolbar();return}}destroy(){this.pmView.dom.removeEventListener("mouseover",this.mouseOverHandler),document.removeEventListener("scroll",this.scrollHandler),document.removeEventListener("click",this.clickHandler,!0)}}const Yt=new y.PluginKey("HyperlinkToolbarPlugin");class Jt extends ${constructor(e){super();u(this,"view");u(this,"plugin");u(this,"editHyperlink",(e,n)=>{this.view.editHyperlink(e,n)});u(this,"deleteHyperlink",()=>{this.view.deleteHyperlink()});u(this,"startHideTimer",()=>{this.view.startMenuUpdateTimer()});u(this,"stopHideTimer",()=>{this.view.stopMenuUpdateTimer()});this.plugin=new y.Plugin({key:Yt,view:n=>(this.view=new Sn(e,n,i=>{this.emit("update",i)}),this.view)})}onUpdate(e){return this.on("update",e)}}class U extends y.Selection{constructor(e,n){super(e,n);u(this,"nodes");const i=e.node();this.nodes=[],e.doc.nodesBetween(e.pos,n.pos,(r,s,l)=>{if(l!==null&&l.eq(i))return this.nodes.push(r),!1})}static create(e,n,i=n){return new U(e.resolve(n),e.resolve(i))}content(){return new B.Slice(B.Fragment.from(this.nodes),0,0)}eq(e){if(!(e instanceof U)||this.nodes.length!==e.nodes.length||this.from!==e.from||this.to!==e.to)return!1;for(let n=0;n<this.nodes.length;n++)if(!this.nodes[n].eq(e.nodes[n]))return!1;return!0}map(e,n){const i=n.mapResult(this.from),r=n.mapResult(this.to);return r.deleted?y.Selection.near(e.resolve(i.pos)):i.deleted?y.Selection.near(e.resolve(r.pos)):new U(e.resolve(i.pos),e.resolve(r.pos))}toJSON(){return{type:"node",anchor:this.anchor,head:this.head}}}const Tn=xe.__serializeForClipboard;let D;function Zt(o,t){var i;if(!t.dom.isConnected)return;const e=t.posAtCoords(o);if(!e)return;let n=t.domAtPos(e.pos).node;if(n!==t.dom){for(;n&&n.parentNode&&n.parentNode!==t.dom&&!((i=n.hasAttribute)!=null&&i.call(n,"data-id"));)n=n.parentNode;if(n)return{node:n,id:n.getAttribute("data-id")}}}function Bn(o,t){const e=Zt(o,t);if(e&&e.node.nodeType===1){const n=t.docView,i=n.nearestDesc(e.node,!0);return!i||i===n?null:i.posBefore}return null}function Mn(o,t){let e,n;const i=t.resolve(o.from).node().type.spec.group==="blockContent",r=t.resolve(o.to).node().type.spec.group==="blockContent",s=Math.min(o.$anchor.depth,o.$head.depth);if(i&&r){const l=o.$from.start(s-1),a=o.$to.end(s-1);e=t.resolve(l-1).pos,n=t.resolve(a+1).pos}else e=o.from,n=o.to;return{from:e,to:n}}function Qt(o,t,e=t){t===e&&(e+=o.state.doc.resolve(t+1).node().nodeSize);const n=o.domAtPos(t).node.cloneNode(!0),i=o.domAtPos(t).node,r=(c,h)=>Array.prototype.indexOf.call(c.children,h),s=r(i,o.domAtPos(t+1).node.parentElement),l=r(i,o.domAtPos(e-1).node.parentElement);for(let c=i.childElementCount-1;c>=0;c--)(c>l||c<s)&&n.removeChild(n.children[c]);te(),D=n;const d=o.dom.className.split(" ").filter(c=>!c.includes("bn")&&!c.includes("ProseMirror")&&!c.includes("editor")).join(" ");D.className=D.className+" "+z.dragPreview+" "+d,document.body.appendChild(D)}function te(){D!==void 0&&(document.body.removeChild(D),D=void 0)}function xn(o,t){if(!o.dataTransfer)return;const e=t.dom.getBoundingClientRect(),n={left:e.left+e.width/2,top:o.clientY},i=Bn(n,t);if(i!=null){const r=t.state.selection,s=t.state.doc,{from:l,to:a}=Mn(r,s),d=l<=i&&i<a,c=r.$anchor.node()!==r.$head.node()||r instanceof U;d&&c?(t.dispatch(t.state.tr.setSelection(U.create(s,l,a))),Qt(t,l,a)):(t.dispatch(t.state.tr.setSelection(y.NodeSelection.create(t.state.doc,i))),Qt(t,i));const h=t.state.selection.content(),{dom:f,text:p}=Tn(t,h);o.dataTransfer.clearData(),o.dataTransfer.setData("text/html",f.innerHTML),o.dataTransfer.setData("text/plain",p),o.dataTransfer.effectAllowed="move",o.dataTransfer.setDragImage(D,0,0),t.dragging={slice:h,move:!0}}}class ee{constructor(t,e,n){u(this,"sideMenuState");u(this,"horizontalPosAnchoredAtRoot");u(this,"horizontalPosAnchor");u(this,"hoveredBlock");u(this,"isDragging",!1);u(this,"menuFrozen",!1);u(this,"onDragStart",()=>{this.isDragging=!0});u(this,"onDrop",t=>{if(this.editor._tiptapEditor.commands.blur(),t.synthetic||!this.isDragging)return;const e=this.pmView.posAtCoords({left:t.clientX,top:t.clientY});if(this.isDragging=!1,!e||e.inside===-1){const n=new Event("drop",t),i=this.pmView.dom.firstChild.getBoundingClientRect();n.clientX=i.left+i.width/2,n.clientY=t.clientY,n.dataTransfer=t.dataTransfer,n.preventDefault=()=>t.preventDefault(),n.synthetic=!0,this.pmView.dom.dispatchEvent(n)}});u(this,"onDragOver",t=>{if(t.synthetic||!this.isDragging)return;const e=this.pmView.posAtCoords({left:t.clientX,top:t.clientY});if(!e||e.inside===-1){const n=new Event("dragover",t),i=this.pmView.dom.firstChild.getBoundingClientRect();n.clientX=i.left+i.width/2,n.clientY=t.clientY,n.dataTransfer=t.dataTransfer,n.preventDefault=()=>t.preventDefault(),n.synthetic=!0,this.pmView.dom.dispatchEvent(n)}});u(this,"onKeyDown",t=>{var e;(e=this.sideMenuState)!=null&&e.show&&(this.sideMenuState.show=!1,this.updateSideMenu(this.sideMenuState)),this.menuFrozen=!1});u(this,"onMouseDown",t=>{this.sideMenuState&&!this.sideMenuState.show&&(this.sideMenuState.show=!0,this.updateSideMenu(this.sideMenuState)),this.menuFrozen=!1});u(this,"onMouseMove",t=>{var d,c,h,f,p;if(this.menuFrozen)return;const e=this.pmView.dom.firstChild.getBoundingClientRect(),n=this.pmView.dom.getBoundingClientRect(),i=t.clientX>=n.left&&t.clientX<=n.right&&t.clientY>=n.top&&t.clientY<=n.bottom,r=this.pmView.dom.parentElement;if(i&&t&&t.target&&!(r===t.target||r.contains(t.target))){(d=this.sideMenuState)!=null&&d.show&&(this.sideMenuState.show=!1,this.updateSideMenu(this.sideMenuState));return}this.horizontalPosAnchor=e.x;const s={left:e.left+e.width/2,top:t.clientY},l=Zt(s,this.pmView);if(!l||!this.editor.isEditable){(c=this.sideMenuState)!=null&&c.show&&(this.sideMenuState.show=!1,this.updateSideMenu(this.sideMenuState));return}if((h=this.sideMenuState)!=null&&h.show&&((f=this.hoveredBlock)!=null&&f.hasAttribute("data-id"))&&((p=this.hoveredBlock)==null?void 0:p.getAttribute("data-id"))===l.id)return;this.hoveredBlock=l.node;const a=l.node.firstChild;if(a&&this.editor.isEditable){const k=a.getBoundingClientRect();this.sideMenuState={show:!0,referencePos:new DOMRect(this.horizontalPosAnchoredAtRoot?this.horizontalPosAnchor:k.x,k.y,k.width,k.height),block:this.editor.getBlock(this.hoveredBlock.getAttribute("data-id"))},this.updateSideMenu(this.sideMenuState)}});u(this,"onScroll",()=>{var t;if((t=this.sideMenuState)!=null&&t.show){const n=this.hoveredBlock.firstChild.getBoundingClientRect();this.sideMenuState.referencePos=new DOMRect(this.horizontalPosAnchoredAtRoot?this.horizontalPosAnchor:n.x,n.y,n.width,n.height),this.updateSideMenu(this.sideMenuState)}});this.editor=t,this.pmView=e,this.updateSideMenu=n,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;(t=this.sideMenuState)!=null&&t.show&&(this.sideMenuState.show=!1,this.updateSideMenu(this.sideMenuState)),document.body.removeEventListener("mousemove",this.onMouseMove),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 l;(l=this.sideMenuState)!=null&&l.show&&(this.sideMenuState.show=!1,this.updateSideMenu(this.sideMenuState)),this.menuFrozen=!0;const e=this.hoveredBlock.firstChild.getBoundingClientRect(),n=this.pmView.posAtCoords({left:e.left+e.width/2,top:e.top+e.height/2});if(!n)return;const i=E(this.editor._tiptapEditor.state.doc,n.pos);if(i===void 0)return;const{contentNode:r,endPos:s}=i;if(r.textContent.length!==0){const a=s+1,d=a+2;this.editor._tiptapEditor.chain().BNCreateBlock(a).BNUpdateBlock(d,{type:"paragraph",props:{}}).setTextSelection(d).run()}else this.editor._tiptapEditor.commands.setTextSelection(s);this.pmView.focus(),this.pmView.dispatch(this.pmView.state.tr.scrollIntoView().setMeta(G,{activate:!0,type:"drag"}))}}const ne=new y.PluginKey("SideMenuPlugin");class oe extends ${constructor(e){super();u(this,"sideMenuView");u(this,"plugin");u(this,"addBlock",()=>this.sideMenuView.addBlock());u(this,"blockDragStart",e=>{this.sideMenuView.isDragging=!0,xn(e,this.editor.prosemirrorView)});u(this,"blockDragEnd",()=>te());u(this,"freezeMenu",()=>this.sideMenuView.menuFrozen=!0);u(this,"unfreezeMenu",()=>this.sideMenuView.menuFrozen=!1);this.editor=e,this.plugin=new y.Plugin({key:ne,view:n=>(this.sideMenuView=new ee(e,n,i=>{this.emit("update",i)}),this.sideMenuView)})}onUpdate(e){return this.on("update",e)}}function R(o,t){const e=o.getTextCursorPosition().block;if(e.content===void 0)throw new Error("Slash Menu open in a block that doesn't contain inline content.");e.content.length===1&&e.content[0].type==="text"&&e.content[0].text==="/"||e.content.length===0?o.updateBlock(e,t):(o.insertBlocks([t],e,"after"),o.setTextCursorPosition(o.getTextCursorPosition().nextBlock))}const ie=(o=J)=>{var e,n,i;const t=[];return"heading"in o&&"level"in o.heading.propSchema&&((e=o.heading.propSchema.level.values)!=null&&e.includes(1)&&t.push({name:"Heading",aliases:["h","heading1","h1"],execute:r=>R(r,{type:"heading",props:{level:1}})}),(n=o.heading.propSchema.level.values)!=null&&n.includes(2)&&t.push({name:"Heading 2",aliases:["h2","heading2","subheading"],execute:r=>R(r,{type:"heading",props:{level:2}})}),(i=o.heading.propSchema.level.values)!=null&&i.includes(3)&&t.push({name:"Heading 3",aliases:["h3","heading3","subheading"],execute:r=>R(r,{type:"heading",props:{level:3}})})),"bulletListItem"in o&&t.push({name:"Bullet List",aliases:["ul","list","bulletlist","bullet list"],execute:r=>R(r,{type:"bulletListItem"})}),"numberedListItem"in o&&t.push({name:"Numbered List",aliases:["li","list","numberedlist","numbered list"],execute:r=>R(r,{type:"numberedListItem"})}),"paragraph"in o&&t.push({name:"Paragraph",aliases:["p"],execute:r=>R(r,{type:"paragraph"})}),"image"in o&&t.push({name:"Image",aliases:["image","imageUpload","upload","img","picture","media","url","drive","dropbox"],execute:r=>{R(r,{type:"image"}),r.setTextCursorPosition(r.getTextCursorPosition().nextBlock,"start"),r._tiptapEditor.view.dispatch(r._tiptapEditor.state.tr.setMeta(F,{block:r.getTextCursorPosition().prevBlock}))}}),t},_n={enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!1};class In{constructor(t={}){u(this,"_tiptapEditor");u(this,"blockCache",new WeakMap);u(this,"schema");u(this,"ready",!1);u(this,"sideMenu");u(this,"formattingToolbar");u(this,"slashMenu");u(this,"hyperlinkToolbar");u(this,"imageToolbar");u(this,"uploadFile");var l,a,d,c,h,f,p,k,w,S,T,I;this.options=t;const e={defaultStyles:!0,blockSchema:t.blockSchema||J,...t};this.sideMenu=new oe(this),this.formattingToolbar=new Xt(this),this.slashMenu=new Pt(this,e.slashMenuItems||ie(e.blockSchema)),this.hyperlinkToolbar=new Jt(this),this.imageToolbar=new $t(this);const n=Ht({editor:this,domAttributes:e.domAttributes||{},blockSchema:e.blockSchema,collaboration:e.collaboration}),i=g.Extension.create({name:"BlockNoteUIExtension",addProseMirrorPlugins:()=>[this.sideMenu.plugin,this.formattingToolbar.plugin,this.slashMenu.plugin,this.hyperlinkToolbar.plugin,this.imageToolbar.plugin]});n.push(i),this.schema=e.blockSchema,this.uploadFile=e.uploadFile;const r=e.initialContent||(t.collaboration?void 0:[{type:"paragraph",id:W.options.generateID()}]),s={..._n,...e._tiptapOptions,onBeforeCreate(M){var b,P;if((P=(b=e._tiptapOptions)==null?void 0:b.onBeforeCreate)==null||P.call(b,M),!r)return;const C=M.editor.schema,x=C.node("doc",void 0,C.node("blockGroup",void 0,[q({id:"initialBlock",type:"paragraph"},C)]));M.editor.options.content=x.toJSON()},onCreate:M=>{var C,x,b;(x=(C=e._tiptapOptions)==null?void 0:C.onCreate)==null||x.call(C,M),r!==void 0&&this.replaceBlocks(this.topLevelBlocks,r),(b=e.onEditorReady)==null||b.call(e,this),this.ready=!0},onUpdate:M=>{var C,x,b;(x=(C=e._tiptapOptions)==null?void 0:C.onUpdate)==null||x.call(C,M),this.ready&&((b=e.onEditorContentChange)==null||b.call(e,this))},onSelectionUpdate:M=>{var C,x,b;(x=(C=e._tiptapOptions)==null?void 0:C.onSelectionUpdate)==null||x.call(C,M),this.ready&&((b=e.onTextCursorPositionChange)==null||b.call(e,this))},editable:t.editable!==void 0?t.editable:((l=e._tiptapOptions)==null?void 0:l.editable)!==void 0?(a=e._tiptapOptions)==null?void 0:a.editable:!0,extensions:e.enableBlockNoteExtensions===!1?((d=e._tiptapOptions)==null?void 0:d.extensions)||[]:[...((c=e._tiptapOptions)==null?void 0:c.extensions)||[],...n],editorProps:{...(h=e._tiptapOptions)==null?void 0:h.editorProps,attributes:{...(p=(f=e._tiptapOptions)==null?void 0:f.editorProps)==null?void 0:p.attributes,...(k=e.domAttributes)==null?void 0:k.editor,class:A(z.bnEditor,z.bnRoot,((S=(w=e.domAttributes)==null?void 0:w.editor)==null?void 0:S.class)||"",e.defaultStyles?z.defaultStyles:"",((I=(T=e.domAttributes)==null?void 0:T.editor)==null?void 0:I.class)||"")}}};e.parentElement&&(s.element=e.parentElement),this._tiptapEditor=new g.Editor(s)}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(){const t=[];return this._tiptapEditor.state.doc.firstChild.descendants(e=>(t.push(N(e,this.schema,this.blockCache)),!1)),t}getBlock(t){const e=typeof t=="string"?t:t.id;let n;return this._tiptapEditor.state.doc.firstChild.descendants(i=>typeof n<"u"?!1:i.type.name!=="blockContainer"||i.attrs.id!==e?!0:(n=N(i,this.schema,this.blockCache),!1)),n}forEachBlock(t,e=!1){const n=this.topLevelBlocks.slice();e&&n.reverse();function i(r){for(const s of r){if(!t(s))return!1;const l=e?s.children.slice().reverse():s.children;if(!i(l))return!1}return!0}i(n)}onEditorContentChange(t){this._tiptapEditor.on("update",t)}onEditorSelectionChange(t){this._tiptapEditor.on("selectionUpdate",t)}getTextCursorPosition(){const{node:t,depth:e,startPos:n,endPos:i}=E(this._tiptapEditor.state.doc,this._tiptapEditor.state.selection.from),r=this._tiptapEditor.state.doc.resolve(i).index(e-1),s=this._tiptapEditor.state.doc.resolve(i+1).node().childCount;let l;r>0&&(l=this._tiptapEditor.state.doc.resolve(n-2).node());let a;return r<s-1&&(a=this._tiptapEditor.state.doc.resolve(i+2).node()),{block:N(t,this.schema,this.blockCache),prevBlock:l===void 0?void 0:N(l,this.schema,this.blockCache),nextBlock:a===void 0?void 0:N(a,this.schema,this.blockCache)}}setTextCursorPosition(t,e="start"){const n=typeof t=="string"?t:t.id,{posBeforeNode:i}=X(n,this._tiptapEditor.state.doc),{startPos:r,contentNode:s}=E(this._tiptapEditor.state.doc,i+2);if(s.type.spec.content===""){this._tiptapEditor.commands.setNodeSelection(r);return}e==="start"?this._tiptapEditor.commands.setTextSelection(r+1):this._tiptapEditor.commands.setTextSelection(r+s.nodeSize-1)}getSelection(){if(this._tiptapEditor.state.selection.from===this._tiptapEditor.state.selection.to||"node"in this._tiptapEditor.state.selection)return;const t=[];return this._tiptapEditor.state.doc.descendants((e,n)=>e.type.spec.group!=="blockContent"||n+e.nodeSize<this._tiptapEditor.state.selection.from||n>this._tiptapEditor.state.selection.to?!0:(t.push(N(this._tiptapEditor.state.doc.resolve(n).node(),this.schema,this.blockCache)),!1)),{blocks:t}}get isEditable(){return this._tiptapEditor.isEditable}set isEditable(t){this._tiptapEditor.setEditable(t)}insertBlocks(t,e,n="before"){Lt(t,e,n,this._tiptapEditor)}updateBlock(t,e){rn(t,e,this._tiptapEditor)}removeBlocks(t){Nt(t,this._tiptapEditor)}replaceBlocks(t,e){sn(t,e,this._tiptapEditor)}getActiveStyles(){const t={},e=this._tiptapEditor.state.selection.$to.marks(),n=new Set(["bold","italic","underline","strike","code"]),i=new Set(["textColor","backgroundColor"]);for(const r of e)n.has(r.type.name)?t[r.type.name]=!0:i.has(r.type.name)&&(t[r.type.name]=r.attrs.color);return t}addStyles(t){const e=new Set(["bold","italic","underline","strike","code"]),n=new Set(["textColor","backgroundColor"]);this._tiptapEditor.view.focus();for(const[i,r]of Object.entries(t))e.has(i)?this._tiptapEditor.commands.setMark(i):n.has(i)&&this._tiptapEditor.commands.setMark(i,{color:r})}removeStyles(t){this._tiptapEditor.view.focus();for(const e of Object.keys(t))this._tiptapEditor.commands.unsetMark(e)}toggleStyles(t){const e=new Set(["bold","italic","underline","strike","code"]),n=new Set(["textColor","backgroundColor"]);this._tiptapEditor.view.focus();for(const[i,r]of Object.entries(t))e.has(i)?this._tiptapEditor.commands.toggleMark(i):n.has(i)&&this._tiptapEditor.commands.toggleMark(i,{color:r})}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;const{from:n,to:i}=this._tiptapEditor.state.selection;e||(e=this._tiptapEditor.state.doc.textBetween(n,i));const r=this._tiptapEditor.schema.mark("link",{href:t});this._tiptapEditor.view.dispatch(this._tiptapEditor.view.state.tr.insertText(e,n,i).addMark(n,n+e.length,r))}canNestBlock(){const{startPos:t,depth:e}=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(){const{depth:t}=E(this._tiptapEditor.state.doc,this._tiptapEditor.state.selection.from);return t>2}unnestBlock(){this._tiptapEditor.commands.liftListItem("blockContainer")}async blocksToHTML(t){return Dt(t,this._tiptapEditor.schema)}async HTMLToBlocks(t){return Ot(t,this.schema,this._tiptapEditor.schema)}async blocksToMarkdown(t){return dn(t,this._tiptapEditor.schema)}async markdownToBlocks(t){return un(t,this.schema,this._tiptapEditor.schema)}updateCollaborationUserInfo(t){if(!this.options.collaboration)throw new Error("Cannot update collaboration user info when collaboration is disabled.");this._tiptapEditor.commands.updateUser(t)}}const An=async o=>{const t=new FormData;return t.append("file",o),(await(await fetch("https://tmpfiles.org/api/v1/upload",{method:"POST",body:t})).json()).data.url.replace("tmpfiles.org/","tmpfiles.org/dl/")};m.BlockNoteEditor=In,m.CustomBlockSerializerExtension=It,m.FormattingToolbarProsemirrorPlugin=Xt,m.FormattingToolbarView=jt,m.HyperlinkToolbarProsemirrorPlugin=Jt,m.ImageToolbarProsemirrorPlugin=$t,m.ImageToolbarView=qt,m.SideMenuProsemirrorPlugin=oe,m.SideMenuView=ee,m.SlashMenuProsemirrorPlugin=Pt,m.UnreachableCaseError=rt,m.blockStyles=Ue,m.camelToDataKebab=Y,m.createBlockSpec=Ft,m.createTipTapBlock=V,m.defaultBlockSchema=J,m.defaultProps=_,m.formatKeyboardShortcut=Oe,m.formattingToolbarPluginKey=Kt,m.getBlockNoteExtensions=Ht,m.getDefaultSlashMenuItems=ie,m.hyperlinkToolbarPluginKey=Yt,m.imageToolbarPluginKey=F,m.isAppleOS=it,m.mergeCSSClasses=A,m.parse=zt,m.propsToAttributes=Rt,m.render=Vt,m.setupSuggestionsMenu=At,m.sideMenuPluginKey=ne,m.slashMenuPluginKey=G,m.uploadToTmpFilesDotOrg_DEV_ONLY=An,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
|
|
8
8
|
//# sourceMappingURL=blocknote.umd.cjs.map
|