@blocknote/core 0.31.1 → 0.31.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/blocknote.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
`+w.text,m.push(...g.slice(1)),m):(m.push(...g),m)},[]),props:{colspan:u.attrs.colspan,rowspan:u.attrs.rowspan,backgroundColor:u.attrs.backgroundColor,textColor:u.attrs.textColor,textAlignment:u.attrs.textAlignment}})),o.rows.push(d)});for(let a=0;a<r.length;a++)(s=r[a])!=null&&s.every(l=>l)&&(o.headerRows=(o.headerRows??0)+1);for(let a=0;a<((i=r[0])==null?void 0:i.length);a++)r!=null&&r.every(l=>l[a])&&(o.headerCols=(o.headerCols??0)+1);return o}function xe(e,n,t){const o=[];let r;return e.content.forEach(s=>{if(s.type.name==="hardBreak"){if(r)if(ne(r))r.text+=`
|
|
3
3
|
`;else if(it(r))r.content[r.content.length-1].text+=`
|
|
4
4
|
`;else throw new Error("unexpected");else r={type:"text",text:`
|
|
5
|
-
`,styles:{}};return}if(s.type.name!=="link"&&s.type.name!=="text"){if(!n[s.type.name]){console.warn("unrecognized inline content type",s.type.name);return}r&&(o.push(r),r=void 0),o.push(Ue(s,n,t));return}const i={};let a;for(const l of s.marks)if(l.type.name==="link")a=l;else{const c=t[l.type.name];if(!c){if(l.type.spec.blocknoteIgnore)continue;throw new Error(`style ${l.type.name} not found in styleSchema`)}if(c.propSchema==="boolean")i[c.type]=!0;else if(c.propSchema==="string")i[c.type]=l.attrs.stringValue;else throw new K(c.propSchema)}r?ne(r)?a?(o.push(r),r={type:"link",href:a.attrs.href,content:[{type:"text",text:s.textContent,styles:i}]}):JSON.stringify(r.styles)===JSON.stringify(i)?r.text+=s.textContent:(o.push(r),r={type:"text",text:s.textContent,styles:i}):it(r)&&(a?r.href===a.attrs.href?JSON.stringify(r.content[r.content.length-1].styles)===JSON.stringify(i)?r.content[r.content.length-1].text+=s.textContent:r.content.push({type:"text",text:s.textContent,styles:i}):(o.push(r),r={type:"link",href:a.attrs.href,content:[{type:"text",text:s.textContent,styles:i}]}):(o.push(r),r={type:"text",text:s.textContent,styles:i})):a?r={type:"link",href:a.attrs.href,content:[{type:"text",text:s.textContent,styles:i}]}:r={type:"text",text:s.textContent,styles:i}}),r&&o.push(r),o}function Ue(e,n,t){if(e.type.name==="text"||e.type.name==="link")throw new Error("unexpected");const o={},r=n[e.type.name];for(const[a,l]of Object.entries(e.attrs)){if(!r)throw Error("ic node is of an unrecognized type: "+e.type.name);const c=r.propSchema;a in c&&(o[a]=l)}let s;return r.content==="styled"?s=xe(e,n,t):s=void 0,{type:e.type.name,props:o,content:s}}function T(e,n,t=Ge(n),o=Ye(n),r=le(n),s=Je(n)){var g;if(!e.type.isInGroup("bnBlock"))throw Error("Node should be a bnBlock, but is instead: "+e.type.name);const i=s==null?void 0:s.get(e);if(i)return i;const a=je(e,0);let l=a.bnBlock.node.attrs.id;l===null&&(l=Be.options.generateID());const c=t[a.blockNoteType];if(!c)throw Error("Block is of an unrecognized type: "+a.blockNoteType);const d={};for(const[b,w]of Object.entries({...e.attrs,...a.isBlockContainer?a.blockContent.node.attrs:{}})){const C=c.propSchema;b in C&&!(C[b].default===void 0&&w===void 0)&&(d[b]=w)}const u=t[a.blockNoteType],h=[];(g=a.childContainer)==null||g.node.forEach(b=>{h.push(T(b,n,t,o,r,s))});let f;if(u.content==="inline"){if(!a.isBlockContainer)throw new Error("impossible");f=xe(a.blockContent.node,o,r)}else if(u.content==="table"){if(!a.isBlockContainer)throw new Error("impossible");f=Bt(a.blockContent.node,o,r)}else if(u.content==="none")f=void 0;else throw new K(u.content);const m={id:l,type:u.type,props:d,content:f,children:h};return s==null||s.set(e,m),m}function mn(e,n,t=Ge(n),o=Ye(n),r=le(n),s=Je(n)){const i=[];return e.firstChild.descendants(a=>(i.push(T(a,n,t,o,r,s)),!1)),i}function gn(e,n,t=Ge(n),o=Ye(n),r=le(n),s=Je(n)){function i(a,l,c){if(a.type.name!=="blockGroup")throw new Error("unexpected");const d=[];let u,h;return a.forEach((f,m,g)=>{if(f.type.name!=="blockContainer")throw new Error("unexpected");if(f.childCount===0)return;if(f.childCount===0||f.childCount>2)throw new Error("unexpected, blockContainer.childCount: "+f.childCount);const b=g===0,w=g===a.childCount-1;if(f.firstChild.type.name==="blockGroup"){if(!b)throw new Error("unexpected");const R=i(f.firstChild,Math.max(0,l-1),w?Math.max(0,c-1):0);u=R.blockCutAtStart,w&&(h=R.blockCutAtEnd),d.push(...R.blocks);return}const C=T(f,n,t,o,r,s),S=f.childCount>1?f.child(1):void 0;let P=[];if(S){const R=i(S,0,w?Math.max(0,c-1):0);P=R.blocks,w&&(h=R.blockCutAtEnd)}w&&!S&&c>1&&(h=C.id),b&&l>1&&(u=C.id),d.push({...C,children:P})}),{blocks:d,blockCutAtStart:u,blockCutAtEnd:h}}if(e.content.childCount===0)return{blocks:[],blockCutAtStart:void 0,blockCutAtEnd:void 0};if(e.content.childCount!==1)throw new Error("slice must be a single block, did you forget includeParents=true?");return i(e.content.firstChild,Math.max(e.openStart-1,0),Math.max(e.openEnd-1,0))}function lt(e,n,t,o){return e.dom.setAttribute("data-inline-content-type",n),Object.entries(t).filter(([r,s])=>{const i=o[r];return s!==i.default}).map(([r,s])=>[ve(r),s]).forEach(([r,s])=>e.dom.setAttribute(r,s)),e.contentDOM!==void 0&&e.contentDOM.setAttribute("data-editable",""),e}function bn(e){return{Backspace:({editor:n})=>{const t=n.state.selection.$from;return n.state.selection.empty&&t.node().type.name===e.type&&t.parentOffset===0}}}function kn(e,n){return{config:e,implementation:n}}function wn(e,n){return kn({type:e.name,propSchema:n,content:e.config.content==="inline*"?"styled":"none"},{node:e})}function Tt(e){return Object.fromEntries(Object.entries(e).map(([n,t])=>[n,t.config]))}function yn(e){return[{tag:`[data-inline-content-type="${e.type}"]`,contentElement:n=>{const t=n;return t.matches("[data-editable]")?t:t.querySelector("[data-editable]")||t}}]}function Gr(e,n){const t=k.Node.create({name:e.type,inline:!0,group:"inline",selectable:e.content==="styled",atom:e.content==="none",content:e.content==="styled"?"inline*":"",addAttributes(){return me(e.propSchema)},addKeyboardShortcuts(){return bn(e)},parseHTML(){return yn(e)},renderHTML({node:o}){const r=this.options.editor,s=n.render(Ue(o,r.schema.inlineContentSchema,r.schema.styleSchema),()=>{},r);return lt(s,e.type,o.attrs,e.propSchema)},addNodeView(){return({node:o,getPos:r})=>{const s=this.options.editor,i=n.render(Ue(o,s.schema.inlineContentSchema,s.schema.styleSchema),a=>{if(typeof r=="boolean")return;const l=$([a],s.pmSchema);s.transact(c=>c.replaceWith(r(),r()+o.nodeSize,l))},s);return lt(i,e.type,o.attrs,e.propSchema)}}});return wn(t,e.propSchema)}function Cn(e){return e==="boolean"?{}:{stringValue:{default:void 0,keepOnSplit:!0,parseHTML:n=>n.getAttribute("data-value"),renderHTML:n=>n.stringValue!==void 0?{"data-value":n.stringValue}:{}}}}function vn(e,n,t,o){return e.dom.setAttribute("data-style-type",n),o==="string"&&e.dom.setAttribute("data-value",t),e.contentDOM!==void 0&&e.contentDOM.setAttribute("data-editable",""),e}function xt(e,n){return{config:e,implementation:n}}function te(e,n){return xt({type:e.name,propSchema:n},{mark:e})}function Pt(e){return Object.fromEntries(Object.entries(e).map(([n,t])=>[n,t.config]))}function Sn(e){return[{tag:`[data-style-type="${e.type}"]`,contentElement:n=>{const t=n;return t.matches("[data-editable]")?t:t.querySelector("[data-editable]")||t}}]}function Yr(e,n){const t=k.Mark.create({name:e.type,addAttributes(){return Cn(e.propSchema)},parseHTML(){return Sn(e)},renderHTML({mark:o}){let r;if(e.propSchema==="boolean")r=n.render();else if(e.propSchema==="string")r=n.render(o.attrs.stringValue);else throw new K(e.propSchema);return vn(r,e.type,o.attrs.stringValue,e.propSchema)}});return xt(e,{mark:t})}function oe(e){const{height:n,width:t}=Mt(e),o=new Array(n).fill(!1).map(()=>new Array(t).fill(null)),r=(s,i)=>{for(let a=s;a<n;a++)for(let l=i;l<t;l++)if(!o[a][l])return{row:a,col:l};throw new Error("Unable to create occupancy grid for table, no more available cells")};for(let s=0;s<e.content.rows.length;s++)for(let i=0;i<e.content.rows[s].cells.length;i++){const a=_e(e.content.rows[s].cells[i]),l=Ve(a),c=fe(a),{row:d,col:u}=r(s,i);for(let h=d;h<d+l;h++)for(let f=u;f<u+c;f++){if(o[h][f])throw new Error(`Unable to create occupancy grid for table, cell at ${h},${f} is already occupied`);o[h][f]={row:s,col:i,rowspan:l,colspan:c,cell:a}}}return o}function Se(e){const n=new Set;return e.map(t=>({cells:t.map(o=>n.has(o.row+":"+o.col)?!1:(n.add(o.row+":"+o.col),o.cell)).filter(o=>o!==!1)}))}function ae(e,n,t=oe(n)){for(let o=0;o<t.length;o++)for(let r=0;r<t[o].length;r++){const s=t[o][r];if(s.row===e.row&&s.col===e.col)return{row:o,col:r,cell:s.cell}}throw new Error(`Unable to resolve relative table cell indices for table, cell at ${e.row},${e.col} is not occupied`)}function Mt(e){const n=e.content.rows.length;let t=0;return e.content.rows.forEach(o=>{let r=0;o.cells.forEach(s=>{r+=fe(s)}),t=Math.max(t,r)}),{height:n,width:t}}function En(e,n,t=oe(n)){var r;const o=(r=t[e.row])==null?void 0:r[e.col];if(o)return{row:o.row,col:o.col,cell:o.cell}}function ct(e,n){var s;const t=oe(e);if(n<0||n>=t.length)return[];let o=0;for(let i=0;i<n;i++){const a=(s=t[o])==null?void 0:s[0];if(!a)return[];o+=a.rowspan}const r=new Array(t[0].length).fill(!1).map((i,a)=>En({row:o,col:a},e,t)).filter(i=>i!==void 0);return r.filter((i,a)=>r.findIndex(l=>l.row===i.row&&l.col===i.col)===a)}function dt(e,n){var s;const t=oe(e);if(n<0||n>=t[0].length)return[];let o=0;for(let i=0;i<n;i++){const a=(s=t[0])==null?void 0:s[o];if(!a)return[];o+=a.colspan}const r=new Array(t.length).fill(!1).map((i,a)=>En({row:a,col:o},e,t)).filter(i=>i!==void 0);return r.filter((i,a)=>r.findIndex(l=>l.row===i.row&&l.col===i.col)===a)}function Jr(e,n,t,o=oe(e)){const{col:r}=ae({row:0,col:n},e,o),{col:s}=ae({row:0,col:t},e,o);return o.forEach(i=>{const[a]=i.splice(r,1);i.splice(s,0,a)}),Se(o)}function Xr(e,n,t,o=oe(e)){const{row:r}=ae({row:n,col:0},e,o),{row:s}=ae({row:t,col:0},e,o),[i]=o.splice(r,1);return o.splice(s,0,i),Se(o)}function ut(e){return e?he(e)?ut(e.content):typeof e=="string"?e.length===0:Array.isArray(e)?e.every(n=>typeof n=="string"?n.length===0:ne(n)?n.text.length===0:Ct(n)?typeof n.content=="string"?n.content.length===0:n.content.every(t=>t.text.length===0):!1):!1:!0}function Zr(e,n,t=oe(e)){if(n==="columns"){let s=0;for(let i=t[0].length-1;i>=0&&t.every(l=>ut(l[i].cell)&&l[i].colspan===1);i--)s++;for(let i=t.length-1;i>=0;i--){const a=Math.max(t[i].length-s,1);t[i]=t[i].slice(0,a)}return Se(t)}let o=0;for(let s=t.length-1;s>=0&&t[s].every(a=>ut(a.cell)&&a.rowspan===1);s--)o++;const r=Math.min(o,t.length-1);return t.splice(t.length-r,r),Se(t)}function Qr(e,n,t,o=oe(e)){const{width:r,height:s}=Mt(e);if(n==="columns")o.forEach((i,a)=>{if(t>=0)for(let l=0;l<t;l++)i.push({row:a,col:Math.max(...i.map(c=>c.col))+1,rowspan:1,colspan:1,cell:_e("")});else i.splice(r+t,-1*t)});else if(t>0)for(let i=0;i<t;i++){const a=new Array(r).fill(null).map((l,c)=>({row:s+i,col:c,rowspan:1,colspan:1,cell:_e("")}));o.push(a)}else t<0&&o.splice(s+t,-1*t);return Se(o)}function Bn(e,n,t){const o=ct(e,t);if(!o.some(l=>Ve(l.cell)>1))return!0;let s=t,i=t;return o.forEach(l=>{const c=Ve(l.cell);s=Math.max(s,l.row+c-1),i=Math.min(i,l.row)}),n<t?t===s:t===i}function Tn(e,n,t){const o=dt(e,t);if(!o.some(l=>fe(l.cell)>1))return!0;let s=t,i=t;return o.forEach(l=>{const c=fe(l.cell);s=Math.max(s,l.col+c-1),i=Math.min(i,l.col)}),n<t?t===s:t===i}function es(e,n,t){const o=ae(e,t),r=ae(n,t);return o.col===r.col}function Kt(e,n,t,o){const r=[];for(const[i,a]of Object.entries(e.styles||{})){const l=t[i];if(!l)throw new Error(`style ${i} not found in styleSchema`);if(l.propSchema==="boolean")r.push(n.mark(i));else if(l.propSchema==="string")r.push(n.mark(i,{stringValue:a}));else throw new K(l.propSchema)}return!o||!n.nodes[o].spec.code?e.text.split(/(\n)/g).filter(i=>i.length>0).map(i=>i===`
|
|
5
|
+
`,styles:{}};return}if(s.type.name!=="link"&&s.type.name!=="text"){if(!n[s.type.name]){console.warn("unrecognized inline content type",s.type.name);return}r&&(o.push(r),r=void 0),o.push(Ue(s,n,t));return}const i={};let a;for(const l of s.marks)if(l.type.name==="link")a=l;else{const c=t[l.type.name];if(!c){if(l.type.spec.blocknoteIgnore)continue;throw new Error(`style ${l.type.name} not found in styleSchema`)}if(c.propSchema==="boolean")i[c.type]=!0;else if(c.propSchema==="string")i[c.type]=l.attrs.stringValue;else throw new K(c.propSchema)}r?ne(r)?a?(o.push(r),r={type:"link",href:a.attrs.href,content:[{type:"text",text:s.textContent,styles:i}]}):JSON.stringify(r.styles)===JSON.stringify(i)?r.text+=s.textContent:(o.push(r),r={type:"text",text:s.textContent,styles:i}):it(r)&&(a?r.href===a.attrs.href?JSON.stringify(r.content[r.content.length-1].styles)===JSON.stringify(i)?r.content[r.content.length-1].text+=s.textContent:r.content.push({type:"text",text:s.textContent,styles:i}):(o.push(r),r={type:"link",href:a.attrs.href,content:[{type:"text",text:s.textContent,styles:i}]}):(o.push(r),r={type:"text",text:s.textContent,styles:i})):a?r={type:"link",href:a.attrs.href,content:[{type:"text",text:s.textContent,styles:i}]}:r={type:"text",text:s.textContent,styles:i}}),r&&o.push(r),o}function Ue(e,n,t){if(e.type.name==="text"||e.type.name==="link")throw new Error("unexpected");const o={},r=n[e.type.name];for(const[a,l]of Object.entries(e.attrs)){if(!r)throw Error("ic node is of an unrecognized type: "+e.type.name);const c=r.propSchema;a in c&&(o[a]=l)}let s;return r.content==="styled"?s=xe(e,n,t):s=void 0,{type:e.type.name,props:o,content:s}}function T(e,n,t=Ge(n),o=Ye(n),r=le(n),s=Je(n)){var g;if(!e.type.isInGroup("bnBlock"))throw Error("Node should be a bnBlock, but is instead: "+e.type.name);const i=s==null?void 0:s.get(e);if(i)return i;const a=je(e,0);let l=a.bnBlock.node.attrs.id;l===null&&(l=Be.options.generateID());const c=t[a.blockNoteType];if(!c)throw Error("Block is of an unrecognized type: "+a.blockNoteType);const d={};for(const[b,w]of Object.entries({...e.attrs,...a.isBlockContainer?a.blockContent.node.attrs:{}})){const C=c.propSchema;b in C&&!(C[b].default===void 0&&w===void 0)&&(d[b]=w)}const u=t[a.blockNoteType],h=[];(g=a.childContainer)==null||g.node.forEach(b=>{h.push(T(b,n,t,o,r,s))});let f;if(u.content==="inline"){if(!a.isBlockContainer)throw new Error("impossible");f=xe(a.blockContent.node,o,r)}else if(u.content==="table"){if(!a.isBlockContainer)throw new Error("impossible");f=Bt(a.blockContent.node,o,r)}else if(u.content==="none")f=void 0;else throw new K(u.content);const m={id:l,type:u.type,props:d,content:f,children:h};return s==null||s.set(e,m),m}function mn(e,n,t=Ge(n),o=Ye(n),r=le(n),s=Je(n)){const i=[];return e.firstChild.descendants(a=>(i.push(T(a,n,t,o,r,s)),!1)),i}function gn(e,n,t=Ge(n),o=Ye(n),r=le(n),s=Je(n)){function i(a,l,c){if(a.type.name!=="blockGroup")throw new Error("unexpected");const d=[];let u,h;return a.forEach((f,m,g)=>{if(f.type.name!=="blockContainer")throw new Error("unexpected");if(f.childCount===0)return;if(f.childCount===0||f.childCount>2)throw new Error("unexpected, blockContainer.childCount: "+f.childCount);const b=g===0,w=g===a.childCount-1;if(f.firstChild.type.name==="blockGroup"){if(!b)throw new Error("unexpected");const R=i(f.firstChild,Math.max(0,l-1),w?Math.max(0,c-1):0);u=R.blockCutAtStart,w&&(h=R.blockCutAtEnd),d.push(...R.blocks);return}const C=T(f,n,t,o,r,s),S=f.childCount>1?f.child(1):void 0;let P=[];if(S){const R=i(S,0,w?Math.max(0,c-1):0);P=R.blocks,w&&(h=R.blockCutAtEnd)}w&&!S&&c>1&&(h=C.id),b&&l>1&&(u=C.id),d.push({...C,children:P})}),{blocks:d,blockCutAtStart:u,blockCutAtEnd:h}}if(e.content.childCount===0)return{blocks:[],blockCutAtStart:void 0,blockCutAtEnd:void 0};if(e.content.childCount!==1)throw new Error("slice must be a single block, did you forget includeParents=true?");return i(e.content.firstChild,Math.max(e.openStart-1,0),Math.max(e.openEnd-1,0))}function lt(e,n,t,o){return e.dom.setAttribute("data-inline-content-type",n),Object.entries(t).filter(([r,s])=>{const i=o[r];return s!==i.default}).map(([r,s])=>[ve(r),s]).forEach(([r,s])=>e.dom.setAttribute(r,s)),e.contentDOM!==void 0&&e.contentDOM.setAttribute("data-editable",""),e}function bn(e){return{Backspace:({editor:n})=>{const t=n.state.selection.$from;return n.state.selection.empty&&t.node().type.name===e.type&&t.parentOffset===0}}}function kn(e,n){return{config:e,implementation:n}}function wn(e,n){return kn({type:e.name,propSchema:n,content:e.config.content==="inline*"?"styled":"none"},{node:e})}function Tt(e){return Object.fromEntries(Object.entries(e).map(([n,t])=>[n,t.config]))}function yn(e){return[{tag:`[data-inline-content-type="${e.type}"]`,contentElement:n=>{const t=n;return t.matches("[data-editable]")?t:t.querySelector("[data-editable]")||t}}]}function Gr(e,n){const t=k.Node.create({name:e.type,inline:!0,group:"inline",selectable:e.content==="styled",atom:e.content==="none",content:e.content==="styled"?"inline*":"",addAttributes(){return me(e.propSchema)},addKeyboardShortcuts(){return bn(e)},parseHTML(){return yn(e)},renderHTML({node:o}){const r=this.options.editor,s=n.render(Ue(o,r.schema.inlineContentSchema,r.schema.styleSchema),()=>{},r);return lt(s,e.type,o.attrs,e.propSchema)},addNodeView(){return({node:o,getPos:r})=>{const s=this.options.editor,i=n.render(Ue(o,s.schema.inlineContentSchema,s.schema.styleSchema),a=>{if(typeof r=="boolean")return;const l=$([a],s.pmSchema);s.transact(c=>c.replaceWith(r(),r()+o.nodeSize,l))},s);return lt(i,e.type,o.attrs,e.propSchema)}}});return wn(t,e.propSchema)}function Cn(e){return e==="boolean"?{}:{stringValue:{default:void 0,keepOnSplit:!0,parseHTML:n=>n.getAttribute("data-value"),renderHTML:n=>n.stringValue!==void 0?{"data-value":n.stringValue}:{}}}}function vn(e,n,t,o){return e.dom.setAttribute("data-style-type",n),o==="string"&&e.dom.setAttribute("data-value",t),e.contentDOM!==void 0&&e.contentDOM.setAttribute("data-editable",""),e}function xt(e,n){return{config:e,implementation:n}}function te(e,n){return xt({type:e.name,propSchema:n},{mark:e})}function Pt(e){return Object.fromEntries(Object.entries(e).map(([n,t])=>[n,t.config]))}function Sn(e){return[{tag:`[data-style-type="${e.type}"]`,contentElement:n=>{const t=n;return t.matches("[data-editable]")?t:t.querySelector("[data-editable]")||t}}]}function Yr(e,n){const t=k.Mark.create({name:e.type,addAttributes(){return Cn(e.propSchema)},parseHTML(){return Sn(e)},renderHTML({mark:o}){let r;if(e.propSchema==="boolean")r=n.render();else if(e.propSchema==="string")r=n.render(o.attrs.stringValue);else throw new K(e.propSchema);return vn(r,e.type,o.attrs.stringValue,e.propSchema)}});return xt(e,{mark:t})}function oe(e){const{height:n,width:t}=Mt(e),o=new Array(n).fill(!1).map(()=>new Array(t).fill(null)),r=(s,i)=>{for(let a=s;a<n;a++)for(let l=i;l<t;l++)if(!o[a][l])return{row:a,col:l};throw new Error("Unable to create occupancy grid for table, no more available cells")};for(let s=0;s<e.content.rows.length;s++)for(let i=0;i<e.content.rows[s].cells.length;i++){const a=_e(e.content.rows[s].cells[i]),l=Ve(a),c=fe(a),{row:d,col:u}=r(s,i);for(let h=d;h<d+l;h++)for(let f=u;f<u+c;f++){if(o[h][f])throw new Error(`Unable to create occupancy grid for table, cell at ${h},${f} is already occupied`);o[h][f]={row:s,col:i,rowspan:l,colspan:c,cell:a}}}return o}function Se(e){const n=new Set;return e.map(t=>({cells:t.map(o=>n.has(o.row+":"+o.col)?!1:(n.add(o.row+":"+o.col),o.cell)).filter(o=>o!==!1)}))}function ae(e,n,t=oe(n)){for(let o=0;o<t.length;o++)for(let r=0;r<t[o].length;r++){const s=t[o][r];if(s.row===e.row&&s.col===e.col)return{row:o,col:r,cell:s.cell}}throw new Error(`Unable to resolve relative table cell indices for table, cell at ${e.row},${e.col} is not occupied`)}function Mt(e){const n=e.content.rows.length;let t=0;return e.content.rows.forEach(o=>{let r=0;o.cells.forEach(s=>{r+=fe(s)}),t=Math.max(t,r)}),{height:n,width:t}}function En(e,n,t=oe(n)){var r;const o=(r=t[e.row])==null?void 0:r[e.col];if(o)return{row:o.row,col:o.col,cell:o.cell}}function ct(e,n){var s;const t=oe(e);if(n<0||n>=t.length)return[];let o=0;for(let i=0;i<n;i++){const a=(s=t[o])==null?void 0:s[0];if(!a)return[];o+=a.rowspan}const r=new Array(t[0].length).fill(!1).map((i,a)=>En({row:o,col:a},e,t)).filter(i=>i!==void 0);return r.filter((i,a)=>r.findIndex(l=>l.row===i.row&&l.col===i.col)===a)}function dt(e,n){var s;const t=oe(e);if(n<0||n>=t[0].length)return[];let o=0;for(let i=0;i<n;i++){const a=(s=t[0])==null?void 0:s[o];if(!a)return[];o+=a.colspan}const r=new Array(t.length).fill(!1).map((i,a)=>En({row:a,col:o},e,t)).filter(i=>i!==void 0);return r.filter((i,a)=>r.findIndex(l=>l.row===i.row&&l.col===i.col)===a)}function Jr(e,n,t,o=oe(e)){const{col:r}=ae({row:0,col:n},e,o),{col:s}=ae({row:0,col:t},e,o);return o.forEach(i=>{const[a]=i.splice(r,1);i.splice(s,0,a)}),Se(o)}function Xr(e,n,t,o=oe(e)){const{row:r}=ae({row:n,col:0},e,o),{row:s}=ae({row:t,col:0},e,o),[i]=o.splice(r,1);return o.splice(s,0,i),Se(o)}function ut(e){return e?he(e)?ut(e.content):typeof e=="string"?e.length===0:Array.isArray(e)?e.every(n=>typeof n=="string"?n.length===0:ne(n)?n.text.length===0:Ct(n)?typeof n.content=="string"?n.content.length===0:n.content.every(t=>t.text.length===0):!1):!1:!0}function Zr(e,n,t=oe(e)){if(n==="columns"){let s=0;for(let i=t[0].length-1;i>=0&&t.every(l=>ut(l[i].cell)&&l[i].colspan===1);i--)s++;for(let i=t.length-1;i>=0;i--){const a=Math.max(t[i].length-s,1);t[i]=t[i].slice(0,a)}return Se(t)}let o=0;for(let s=t.length-1;s>=0&&t[s].every(a=>ut(a.cell)&&a.rowspan===1);s--)o++;const r=Math.min(o,t.length-1);return t.splice(t.length-r,r),Se(t)}function Qr(e,n,t,o=oe(e)){const{width:r,height:s}=Mt(e);if(n==="columns")o.forEach((i,a)=>{if(t>=0)for(let l=0;l<t;l++)i.push({row:a,col:Math.max(...i.map(c=>c.col))+1,rowspan:1,colspan:1,cell:_e("")});else i.splice(r+t,-1*t)});else if(t>0)for(let i=0;i<t;i++){const a=new Array(r).fill(null).map((l,c)=>({row:s+i,col:c,rowspan:1,colspan:1,cell:_e("")}));o.push(a)}else t<0&&o.splice(s+t,-1*t);return Se(o)}function Bn(e,n,t){const o=ct(e,t);if(!o.some(l=>Ve(l.cell)>1))return!0;let s=t,i=t;return o.forEach(l=>{const c=Ve(l.cell);s=Math.max(s,l.row+c-1),i=Math.min(i,l.row)}),n<t?t===s:t===i}function Tn(e,n,t){const o=dt(e,t);if(!o.some(l=>fe(l.cell)>1))return!0;let s=t,i=t;return o.forEach(l=>{const c=fe(l.cell);s=Math.max(s,l.col+c-1),i=Math.min(i,l.col)}),n<t?t===s:t===i}function es(e,n,t){const o=ae(e,t),r=ae(n,t);return o.col===r.col}function Kt(e,n,t,o){const r=[];for(const[i,a]of Object.entries(e.styles||{})){const l=t[i];if(!l)throw new Error(`style ${i} not found in styleSchema`);if(l.propSchema==="boolean")a&&r.push(n.mark(i));else if(l.propSchema==="string")a&&r.push(n.mark(i,{stringValue:a}));else throw new K(l.propSchema)}return!o||!n.nodes[o].spec.code?e.text.split(/(\n)/g).filter(i=>i.length>0).map(i=>i===`
|
|
6
6
|
`?n.nodes.hardBreak.createChecked():n.text(i,r)):e.text.length>0?[n.text(e.text,r)]:[]}function ts(e,n,t){const o=n.marks.link.create({href:e.href});return pt(e.content,n,t).map(r=>{if(r.type.name==="text")return r.mark([...r.marks,o]);if(r.type.name==="hardBreak")return r;throw new Error("unexpected node type")})}function pt(e,n,t,o){const r=[];if(typeof e=="string")return r.push(...Kt({text:e,styles:{}},n,t,o)),r;for(const s of e)r.push(...Kt(s,n,t,o));return r}function $(e,n,t,o=le(n)){const r=[];for(const s of e)typeof s=="string"?r.push(...pt(s,n,o,t)):Ct(s)?r.push(...ts(s,n,o)):ne(s)?r.push(...pt([s],n,o,t)):r.push(xn(s,n,o));return r}function Pe(e,n,t=le(n)){const o=[],r=new Array(e.headerRows??0).fill(!0),s=new Array(e.headerCols??0).fill(!0),i=e.columnWidths??[];for(let a=0;a<e.rows.length;a++){const l=e.rows[a],c=[],d=r[a];for(let h=0;h<l.cells.length;h++){const f=l.cells[h],m=s[h],g=void 0;let b=null;const w=ae({row:a,col:h},{content:e});let C=i[w.col]?[i[w.col]]:null;if(f)if(typeof f=="string")b=n.text(f);else if(he(f)){f.content&&(b=$(f.content,n,"tableParagraph",t));const P=fe(f);P>1&&(C=new Array(P).fill(!1).map((R,z)=>i[w.col+z]??void 0))}else b=$(f,n,"tableParagraph",t);const S=n.nodes[m||d?"tableHeader":"tableCell"].createChecked({...he(f)?f.props:{},colwidth:C},n.nodes.tableParagraph.createChecked(g,b));c.push(S)}const u=n.nodes.tableRow.createChecked({},c);o.push(u)}return o}function xn(e,n,t){let o,r=e.type;if(r===void 0&&(r="paragraph"),!n.nodes[r])throw new Error(`node type ${r} not found in schema`);if(!e.content)o=n.nodes[r].createChecked(e.props);else if(typeof e.content=="string"){const s=$([e.content],n,r,t);o=n.nodes[r].createChecked(e.props,s)}else if(Array.isArray(e.content)){const s=$(e.content,n,r,t);o=n.nodes[r].createChecked(e.props,s)}else if(e.content.type==="tableContent"){const s=Pe(e.content,n,t);o=n.nodes[r].createChecked(e.props,s)}else throw new K(e.content.type);return o}function re(e,n,t=le(n)){let o=e.id;o===void 0&&(o=Be.options.generateID());const r=[];if(e.children)for(const i of e.children)r.push(re(i,n,t));if(!e.type||n.nodes[e.type].isInGroup("blockContent")){const i=xn(e,n,t),a=r.length>0?n.nodes.blockGroup.createChecked({},r):void 0;return n.nodes.blockContainer.createChecked({id:o,...e.props},a?[i,a]:i)}else{if(n.nodes[e.type].isInGroup("bnBlock"))return n.nodes[e.type].createChecked({id:o,...e.props},r);throw new Error(`block type ${e.type} doesn't match blockContent or bnBlock group`)}}function F(e,n){let t,o;if(n.firstChild.descendants((r,s)=>t?!1:!Fe(r)||r.attrs.id!==e?!0:(t=r,o=s+1,!1)),!(t===void 0||o===void 0))return{node:t,posBeforeNode:o}}function Fe(e){return e.type.isInGroup("bnBlock")}function ns(e,n){return e.id!==n.id||e.type!==n.type||JSON.stringify(e.props)!==JSON.stringify(n.props)||JSON.stringify(e.content)!==JSON.stringify(n.content)}function Pn(e,n=[]){let t={type:"local"};e.getMeta("paste")?t={type:"paste"}:e.getMeta("uiEvent")==="drop"?t={type:"drop"}:e.getMeta("history$")?t={type:e.getMeta("history$").redo?"redo":"undo"}:e.getMeta("y-sync$")&&(e.getMeta("y-sync$").isUndoRedoOperation?t={type:"undo-redo"}:t={type:"yjs-remote"});const o=H(e),r=k.combineTransactionSteps(e.before,[e,...n]),s=k.getChangedRanges(r),i=s.flatMap(u=>k.findChildrenInRange(r.before,u.oldRange,Fe)).map(({node:u})=>T(u,o)),a=s.flatMap(u=>k.findChildrenInRange(r.doc,u.newRange,Fe)).map(({node:u})=>T(u,o)),l=new Map(a.map(u=>[u.id,u])),c=new Map(i.map(u=>[u.id,u])),d=[];for(const[u,h]of l)c.has(u)||d.push({type:"insert",block:h,source:t,prevBlock:void 0});for(const[u,h]of c)l.has(u)||d.push({type:"delete",block:h,source:t,prevBlock:void 0});for(const[u,h]of l)if(c.has(u)){const f=c.get(u);ns(f,h)&&d.push({type:"update",block:h,prevBlock:f,source:t})}return d}function Mn(e,n,t,o="before"){const r=typeof t=="string"?t:t.id,s=H(e),i=n.map(d=>re(d,s)),a=F(r,e.doc);if(!a)throw new Error(`Block with ID ${r} not found`);let l=a.posBeforeNode;return o==="after"&&(l+=a.node.nodeSize),e.step(new pe.ReplaceStep(l,l,new E.Slice(E.Fragment.from(i),0,0))),i.map(d=>T(d,s))}function ht(e,n,t){const o=H(e),r=t.map(d=>re(d,o)),s=new Set(n.map(d=>typeof d=="string"?d:d.id)),i=[],a=typeof n[0]=="string"?n[0]:n[0].id;let l=0;if(e.doc.descendants((d,u)=>{if(s.size===0)return!1;if(!d.type.isInGroup("bnBlock")||!s.has(d.attrs.id))return!0;if(i.push(T(d,o)),s.delete(d.attrs.id),t.length>0&&d.attrs.id===a){const g=e.doc.nodeSize;e.insert(u,r);const b=e.doc.nodeSize;l+=g-b}const h=e.doc.nodeSize,f=e.doc.resolve(u-l);f.node().type.name==="blockGroup"&&f.node(f.depth-1).type.name!=="doc"&&f.node().childCount===1?e.delete(f.before(),f.after()):e.delete(u-l,u-l+d.nodeSize);const m=e.doc.nodeSize;return l+=h-m,!1}),s.size>0){const d=[...s].join(`
|
|
7
7
|
`);throw Error("Blocks with the following IDs could not be found in the editor: "+d)}return{insertedBlocks:r.map(d=>T(d,o)),removedBlocks:i}}const D=(e,n)=>({tr:t,dispatch:o})=>(o&&It(t,e,n),!0);function It(e,n,t,o,r){const s=be(e.doc.resolve(n)),i=H(e);if(o!==void 0&&r!==void 0&&o>r)throw new Error("Invalid replaceFromPos or replaceToPos");const a=i.nodes[s.blockNoteType],l=i.nodes[t.type||s.blockNoteType],c=l.isInGroup("bnBlock")?l:i.nodes.blockContainer;if(s.isBlockContainer&&l.isInGroup("blockContent")){const d=o!==void 0&&o>s.blockContent.beforePos&&o<s.blockContent.afterPos?o-s.blockContent.beforePos-1:void 0,u=r!==void 0&&r>s.blockContent.beforePos&&r<s.blockContent.afterPos?r-s.blockContent.beforePos-1:void 0;qt(t,e,s),os(t,e,a,l,s,d,u)}else if(!s.isBlockContainer&&l.isInGroup("bnBlock"))qt(t,e,s);else{const d=T(s.bnBlock.node,i);e.replaceWith(s.bnBlock.beforePos,s.bnBlock.afterPos,re({children:d.children,...t},i));return}e.setNodeMarkup(s.bnBlock.beforePos,c,{...s.bnBlock.node.attrs,...t.props})}function os(e,n,t,o,r,s,i){const a=H(n);let l="keep";if(e.content)if(typeof e.content=="string")l=$([e.content],a,o.name);else if(Array.isArray(e.content))l=$(e.content,a,o.name);else if(e.content.type==="tableContent")l=Pe(e.content,a);else throw new K(e.content.type);else t.spec.content===""||o.spec.content!==t.spec.content&&(l=[]);if(l==="keep")n.setNodeMarkup(r.blockContent.beforePos,o,{...r.blockContent.node.attrs,...e.props});else if(s!==void 0||i!==void 0){n.setNodeMarkup(r.blockContent.beforePos,o,{...r.blockContent.node.attrs,...e.props});const c=r.blockContent.beforePos+1+(s??0),d=r.blockContent.beforePos+1+(i??r.blockContent.node.content.size),u=n.doc.resolve(r.blockContent.beforePos).depth,h=n.doc.resolve(c).depth,f=n.doc.resolve(d).depth;n.replace(c,d,new E.Slice(E.Fragment.from(l),h-u-1,f-u-1))}else n.replaceWith(r.blockContent.beforePos,r.blockContent.afterPos,o.createChecked({...r.blockContent.node.attrs,...e.props},l))}function qt(e,n,t){const o=H(n);if(e.children!==void 0&&e.children.length>0){const r=e.children.map(s=>re(s,o));if(t.childContainer)n.step(new pe.ReplaceStep(t.childContainer.beforePos+1,t.childContainer.afterPos-1,new E.Slice(E.Fragment.from(r),0,0)));else{if(!t.isBlockContainer)throw new Error("impossible");n.insert(t.blockContent.afterPos,o.nodes.blockGroup.createChecked({},r))}}}function In(e,n,t,o,r){const s=typeof n=="string"?n:n.id,i=F(s,e.doc);if(!i)throw new Error(`Block with ID ${s} not found`);It(e,i.posBeforeNode,t,o,r);const a=e.doc.resolve(i.posBeforeNode+1).node(),l=H(e);return T(a,l)}function Ln(e){const n=Array.from(e.classList).filter(t=>!t.startsWith("bn-"))||[];n.length>0?e.className=n.join(" "):e.removeAttribute("class")}function An(e,n,t,o){let r;if(n)if(typeof n=="string")r=$([n],e.pmSchema);else if(Array.isArray(n))r=$(n,e.pmSchema);else if(n.type==="tableContent")r=Pe(n,e.pmSchema);else throw new K(n.type);else throw new Error("blockContent is required");const s=t.serializeFragment(E.Fragment.from(r),o);return s.nodeType===1&&Ln(s),s}function rs(e,n,t,o,r,s,i){var g,b,w,C,S,P,R,z;const a=(i==null?void 0:i.document)??document,l=n.pmSchema.nodes.blockContainer;let c=t.props;if(!t.props){c={};for(const[x,v]of Object.entries(n.schema.blockSchema[t.type].propSchema))v.default!==void 0&&(c[x]=v.default)}const d=(b=(g=l.spec)==null?void 0:g.toDOM)==null?void 0:b.call(g,l.create({id:t.id,...c})),u=Array.from(d.dom.attributes),h=n.blockImplementations[t.type].implementation.toExternalHTML({...t,props:c},n),f=a.createDocumentFragment();if(h.dom.classList.contains("bn-block-content")){const x=[...u,...Array.from(h.dom.attributes)].filter(v=>v.name.startsWith("data")&&v.name!=="data-content-type"&&v.name!=="data-file-block"&&v.name!=="data-node-view-wrapper"&&v.name!=="data-node-type"&&v.name!=="data-id"&&v.name!=="data-index"&&v.name!=="data-editable");for(const v of x)h.dom.firstChild.setAttribute(v.name,v.value);Ln(h.dom.firstChild),f.append(...Array.from(h.dom.childNodes))}else f.append(h.dom);if(h.contentDOM&&t.content){const x=An(n,t.content,o,i);h.contentDOM.appendChild(x)}let m;if(r.has(t.type)?m="OL":s.has(t.type)&&(m="UL"),m){if(((w=e.lastChild)==null?void 0:w.nodeName)!==m){const v=a.createElement(m);m==="OL"&&(c!=null&&c.start)&&(c==null?void 0:c.start)!==1&&v.setAttribute("start",c.start+""),e.append(v)}const x=a.createElement("li");x.append(f),e.lastChild.appendChild(x)}else e.append(f);if(t.children&&t.children.length>0){const x=a.createDocumentFragment();if(Nn(x,n,t.children,o,r,s,i),((C=e.lastChild)==null?void 0:C.nodeName)==="UL"||((S=e.lastChild)==null?void 0:S.nodeName)==="OL")for(;((P=x.firstChild)==null?void 0:P.nodeName)==="UL"||((R=x.firstChild)==null?void 0:R.nodeName)==="OL";)e.lastChild.lastChild.appendChild(x.firstChild);n.pmSchema.nodes[t.type].isInGroup("blockContent")?e.append(x):(z=h.contentDOM)==null||z.append(x)}}const Nn=(e,n,t,o,r,s,i)=>{for(const a of t)rs(e,n,a,o,r,s,i)},ss=(e,n,t,o,r,s)=>{const a=((s==null?void 0:s.document)??document).createDocumentFragment();return Nn(a,e,n,t,o,r,s),a},Me=(e,n)=>{const t=E.DOMSerializer.fromSchema(e);return{exportBlocks:(o,r)=>{const s=ss(n,o,t,new Set(["numberedListItem"]),new Set(["bulletListItem","checkListItem"]),r),i=document.createElement("div");return i.append(s),i.innerHTML},exportInlineContent:(o,r)=>{const s=An(n,o,t,r),i=document.createElement("div");return i.append(s.cloneNode(!0)),i.innerHTML}}};function is(e,n,t,o,r){let s;if(n)if(typeof n=="string")s=$([n],e.pmSchema,o);else if(Array.isArray(n))s=$(n,e.pmSchema,o);else if(n.type==="tableContent")s=Pe(n,e.pmSchema);else throw new K(n.type);else throw new Error("blockContent is required");return t.serializeFragment(E.Fragment.from(s),r)}function as(e,n,t,o,r){var u,h,f,m,g;const s=e.pmSchema.nodes.blockContainer;let i=n.props;if(!n.props){i={};for(const[b,w]of Object.entries(e.schema.blockSchema[n.type].propSchema))w.default!==void 0&&(i[b]=w.default)}const l=e.blockImplementations[n.type].implementation.toInternalHTML({...n,props:i},e);if(n.type==="numberedListItem"&&l.dom.setAttribute("data-index",o.toString()),l.contentDOM&&n.content){const b=is(e,n.content,t,n.type,r);l.contentDOM.appendChild(b)}if(e.pmSchema.nodes[n.type].isInGroup("bnBlock")){if(n.children&&n.children.length>0){const b=Hn(e,n.children,t,r);(u=l.contentDOM)==null||u.append(b)}return l.dom}const d=(f=(h=s.spec)==null?void 0:h.toDOM)==null?void 0:f.call(h,s.create({id:n.id,...i}));return(m=d.contentDOM)==null||m.appendChild(l.dom),n.children&&n.children.length>0&&((g=d.contentDOM)==null||g.appendChild(Dn(e,n.children,t,r))),d.dom}function Hn(e,n,t,o){const s=((o==null?void 0:o.document)??document).createDocumentFragment();let i=0;for(const a of n){a.type==="numberedListItem"?i++:i=0;const l=as(e,a,t,i,o);s.appendChild(l)}return s}const Dn=(e,n,t,o)=>{var a;const r=e.pmSchema.nodes.blockGroup,s=r.spec.toDOM(r.create({})),i=Hn(e,n,t,o);return(a=s.contentDOM)==null||a.appendChild(i),s.dom},On=(e,n)=>{const t=E.DOMSerializer.fromSchema(e);return{serializeBlocks:(o,r)=>Dn(n,o,t,r).outerHTML}},Ie=(e,n)=>{const t=e.querySelector(n);if(!t)return;const o=e.querySelector("figcaption"),r=(o==null?void 0:o.textContent)??void 0;return{targetElement:t,caption:r}},Rn=(e,n,t,o)=>{const r=document.createElement("div");r.className="bn-add-file-button";const s=document.createElement("div");s.className="bn-add-file-button-icon",o?s.appendChild(o):s.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z"></path></svg>',r.appendChild(s);const i=document.createElement("p");i.className="bn-add-file-button-text",i.innerHTML=t||n.dictionary.file_blocks.file.add_button_text,r.appendChild(i);const a=c=>{c.preventDefault()},l=()=>{n.transact(c=>c.setMeta(n.filePanel.plugins[0],{block:e}))};return r.addEventListener("mousedown",a,!0),r.addEventListener("click",l,!0),{dom:r,destroy:()=>{r.removeEventListener("mousedown",a,!0),r.removeEventListener("click",l,!0)}}},_n='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z"></path></svg>',Vn=e=>{const n=document.createElement("div");n.className="bn-file-name-with-icon";const t=document.createElement("div");t.className="bn-file-icon",t.innerHTML=_n,n.appendChild(t);const o=document.createElement("p");return o.className="bn-file-name",o.textContent=e.props.name,n.appendChild(o),{dom:n}},Xe=(e,n,t,o,r)=>{const s=document.createElement("div");if(s.className="bn-file-block-content-wrapper",e.props.url===""){const a=Rn(e,n,o,r);s.appendChild(a.dom);const l=n.onUploadStart(c=>{if(c===e.id){s.removeChild(a.dom);const d=document.createElement("div");d.className="bn-file-loading-preview",d.textContent="Loading...",s.appendChild(d)}});return{dom:s,destroy:()=>{l(),a.destroy()}}}const i={dom:s};if(e.props.showPreview===!1||!t){const a=Vn(e);s.appendChild(a.dom),i.destroy=()=>{var l;(l=a.destroy)==null||l.call(a)}}else s.appendChild(t.dom);if(e.props.caption){const a=document.createElement("p");a.className="bn-file-caption",a.textContent=e.props.caption,s.appendChild(a)}return i},Ze=(e,n)=>{const t=document.createElement("figure"),o=document.createElement("figcaption");return o.textContent=n,t.appendChild(e),t.appendChild(o),{dom:t}},Le=(e,n)=>{const t=document.createElement("div"),o=document.createElement("p");return o.textContent=n,t.appendChild(e),t.appendChild(o),{dom:t}},jt=e=>({url:e.src||void 0}),Un='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z"></path></svg>',Fn={backgroundColor:I.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0}},$n={type:"audio",propSchema:Fn,content:"none",isFileBlock:!0,fileBlockAccept:["audio/*"]},zn=(e,n)=>{const t=document.createElement("div");t.innerHTML=Un;const o=document.createElement("audio");return o.className="bn-audio",n.resolveFileUrl?n.resolveFileUrl(e.props.url).then(r=>{o.src=r}):o.src=e.props.url,o.controls=!0,o.contentEditable="false",o.draggable=!1,Xe(e,n,{dom:o},n.dictionary.file_blocks.audio.add_button_text,t.firstElementChild)},Wn=e=>{if(e.tagName==="AUDIO")return e.closest("figure")?void 0:jt(e);if(e.tagName==="FIGURE"){const n=Ie(e,"audio");if(!n)return;const{targetElement:t,caption:o}=n;return{...jt(t),caption:o}}},Kn=e=>{if(!e.props.url){const t=document.createElement("p");return t.textContent="Add audio",{dom:t}}let n;return e.props.showPreview?(n=document.createElement("audio"),n.src=e.props.url):(n=document.createElement("a"),n.href=e.props.url,n.textContent=e.props.name||e.props.url),e.props.caption?e.props.showPreview?Ze(n,e.props.caption):Le(n,e.props.caption):{dom:n}},qn=ge($n,{render:zn,parse:Wn,toExternalHTML:Kn}),ft=Symbol.for("blocknote.shikiParser"),Oe=Symbol.for("blocknote.shikiHighlighterPromise"),jn={language:{default:"text"}},ls=G({name:"codeBlock",content:"inline*",group:"blockContent",marks:"insertion deletion modification",code:!0,defining:!0,addOptions(){return{defaultLanguage:"text",indentLineWithTab:!0,supportedLanguages:{}}},addAttributes(){const e=this.options;return{language:{default:e.editor.settings.codeBlock.defaultLanguage,parseHTML:n=>{let t=n,o=null;(t==null?void 0:t.tagName)==="DIV"&&(t==null?void 0:t.dataset.contentType)==="codeBlock"&&(t=t.children[0]),(t==null?void 0:t.tagName)==="PRE"&&(t=t==null?void 0:t.children[0]);const r=t==null?void 0:t.getAttribute("data-language");if(r)o=r.toLowerCase();else{const i=[...(t==null?void 0:t.className.split(" "))||[]].filter(a=>a.startsWith("language-")).map(a=>a.replace("language-",""));i.length>0&&(o=i[0].toLowerCase())}return o?ot(e.editor.settings.codeBlock,o)??o:null},renderHTML:n=>n.language?{class:`language-${n.language}`,"data-language":n.language}:{}}}},parseHTML(){return[{tag:"div[data-content-type="+this.name+"]",contentElement:".bn-inline-content"},{tag:"pre",preserveWhitespace:"full"}]},renderHTML({HTMLAttributes:e}){var r,s;const n=document.createElement("pre"),{dom:t,contentDOM:o}=j(this.name,"code",((r=this.options.domAttributes)==null?void 0:r.blockContent)||{},{...((s=this.options.domAttributes)==null?void 0:s.inlineContent)||{},...e});return t.removeChild(o),t.appendChild(n),n.appendChild(o),{dom:t,contentDOM:o}},addNodeView(){const e=this.options;return({editor:n,node:t,getPos:o,HTMLAttributes:r})=>{var u,h;const s=document.createElement("pre"),i=document.createElement("select"),a=document.createElement("div"),{dom:l,contentDOM:c}=j(this.name,"code",{...((u=this.options.domAttributes)==null?void 0:u.blockContent)||{},...r},((h=this.options.domAttributes)==null?void 0:h.inlineContent)||{}),d=f=>{const m=f.target.value;n.commands.command(({tr:g})=>(g.setNodeAttribute(o(),"language",m),!0))};return Object.entries(e.editor.settings.codeBlock.supportedLanguages).forEach(([f,{name:m}])=>{const g=document.createElement("option");g.value=f,g.text=m,i.appendChild(g)}),a.contentEditable="false",i.value=t.attrs.language||e.editor.settings.codeBlock.defaultLanguage,l.removeChild(c),l.appendChild(a),l.appendChild(s),s.appendChild(c),a.appendChild(i),i.addEventListener("change",d),{dom:l,contentDOM:c,update:f=>f.type===this.type,destroy:()=>{i.removeEventListener("change",d)}}}},addProseMirrorPlugins(){const e=this.options,n=globalThis;let t,o,r=!1;const s=a=>{if(!e.editor.settings.codeBlock.createHighlighter)return process.env.NODE_ENV==="development"&&!r&&(console.log("For syntax highlighting of code blocks, you must provide a `codeBlock.createHighlighter` function"),r=!0),[];if(!t)return n[Oe]=n[Oe]||e.editor.settings.codeBlock.createHighlighter(),n[Oe].then(c=>{t=c});const l=ot(e.editor.settings.codeBlock,a.language);return!l||l==="text"||l==="none"||l==="plaintext"||l==="txt"?[]:t.getLoadedLanguages().includes(l)?(o||(o=n[ft]||Cr.createParser(t),n[ft]=o),o(a)):t.loadLanguage(l)};return[yr.createHighlightPlugin({parser:s,languageExtractor:a=>a.attrs.language,nodeTypes:[this.name]})]},addInputRules(){const e=this.options;return[new k.InputRule({find:/^```(.*?)\s$/,handler:({state:n,range:t,match:o})=>{const r=n.doc.resolve(t.from),s=o[1].trim(),i={language:ot(e.editor.settings.codeBlock,s)??s};if(!r.node(-1).canReplaceWith(r.index(-1),r.indexAfter(-1),this.type))return null;n.tr.delete(t.from,t.to).setBlockType(t.from,t.from,this.type,i).setSelection(y.TextSelection.create(n.tr.doc,t.from))}})]},addKeyboardShortcuts(){return{Delete:({editor:e})=>{const{selection:n}=e.state,{$from:t}=n;if(e.isActive(this.name)&&!t.parent.textContent&&k.isTextSelection(n)){const o=t.pos-t.parentOffset-2;return e.chain().setNodeSelection(o).deleteSelection().run(),!0}return!1},Tab:({editor:e})=>this.options.indentLineWithTab&&e.isActive(this.name)?(e.commands.insertContent(" "),!0):!1,Enter:({editor:e})=>{const{$from:n}=e.state.selection;if(!e.isActive(this.name))return!1;const t=n.parentOffset===n.parent.nodeSize-2,o=n.parent.textContent.endsWith(`
|
|
8
8
|
|