@blocknote/core 0.44.2 → 0.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BlockNoteExtension-BWw0r8Gy.cjs.map +1 -1
- package/dist/BlockNoteExtension-C2X7LW-V.js.map +1 -1
- package/dist/{BlockNoteSchema-BsTi0fNS.js → BlockNoteSchema-DsMVJZv4.js} +2 -2
- package/dist/{BlockNoteSchema-BsTi0fNS.js.map → BlockNoteSchema-DsMVJZv4.js.map} +1 -1
- package/dist/{BlockNoteSchema-CBNkNhkw.cjs → BlockNoteSchema-qt4Czo0-.cjs} +2 -2
- package/dist/{BlockNoteSchema-CBNkNhkw.cjs.map → BlockNoteSchema-qt4Czo0-.cjs.map} +1 -1
- package/dist/ShowSelection-B0ch3unP.js +51 -0
- package/dist/ShowSelection-B0ch3unP.js.map +1 -0
- package/dist/ShowSelection-BxnbRvy4.cjs +2 -0
- package/dist/ShowSelection-BxnbRvy4.cjs.map +1 -0
- package/dist/{TrailingNode-CG2a-HDA.js → TrailingNode-C-Kyrtf1.js} +715 -709
- package/dist/TrailingNode-C-Kyrtf1.js.map +1 -0
- package/dist/TrailingNode-W7GJVng5.cjs +2 -0
- package/dist/TrailingNode-W7GJVng5.cjs.map +1 -0
- package/dist/{blockToNode-DBNbhwwC.js → blockToNode-BNoNIXU7.js} +2 -2
- package/dist/{blockToNode-DBNbhwwC.js.map → blockToNode-BNoNIXU7.js.map} +1 -1
- package/dist/{blockToNode-w7H99R6p.cjs → blockToNode-CumVjgem.cjs} +2 -2
- package/dist/{blockToNode-w7H99R6p.cjs.map → blockToNode-CumVjgem.cjs.map} +1 -1
- package/dist/blocknote.cjs +4 -4
- package/dist/blocknote.cjs.map +1 -1
- package/dist/blocknote.js +1118 -1077
- package/dist/blocknote.js.map +1 -1
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +2 -2
- package/dist/comments.cjs +1 -1
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js +3 -3
- package/dist/comments.js.map +1 -1
- package/dist/{defaultBlocks-B63ufZ5N.js → defaultBlocks-CXOCngjC.js} +273 -312
- package/dist/defaultBlocks-CXOCngjC.js.map +1 -0
- package/dist/defaultBlocks-IsUGVZIq.cjs +6 -0
- package/dist/defaultBlocks-IsUGVZIq.cjs.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +4 -4
- package/dist/style.css +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/webpack-stats.json +1 -1
- package/dist/yjs.cjs +1 -1
- package/dist/yjs.js +1 -1
- package/package.json +18 -18
- package/src/api/blockManipulation/selections/selection.ts +9 -4
- package/src/api/blockManipulation/tables/tables.test.ts +140 -0
- package/src/api/blockManipulation/tables/tables.ts +1 -1
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +17 -0
- package/src/api/parsers/markdown/parseMarkdown.ts +11 -0
- package/src/blocks/ListItem/BulletListItem/block.ts +1 -1
- package/src/blocks/ListItem/CheckListItem/block.ts +6 -4
- package/src/blocks/ListItem/NumberedListItem/block.ts +6 -2
- package/src/comments/extension.ts +6 -2
- package/src/editor/Block.css +1 -1
- package/src/editor/BlockNoteEditor.test.ts +0 -1
- package/src/editor/BlockNoteEditor.ts +9 -39
- package/src/editor/BlockNoteExtension.ts +5 -0
- package/src/editor/managers/EventManager.ts +1 -1
- package/src/editor/managers/ExtensionManager/extensions.ts +3 -13
- package/src/editor/managers/ExtensionManager/index.ts +7 -2
- package/src/editor/managers/SelectionManager.ts +10 -10
- package/src/extensions/BlockChange/BlockChange.ts +2 -2
- package/src/extensions/Collaboration/Collaboration.ts +55 -0
- package/src/extensions/Collaboration/ForkYDoc.ts +4 -9
- package/src/extensions/Collaboration/YCursorPlugin.ts +56 -60
- package/src/extensions/Collaboration/YSync.ts +2 -2
- package/src/extensions/Collaboration/YUndo.ts +2 -2
- package/src/extensions/LinkToolbar/LinkToolbar.ts +1 -1
- package/src/extensions/ShowSelection/ShowSelection.ts +14 -4
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +40 -68
- package/src/extensions/TableHandles/TableHandles.ts +9 -5
- package/src/index.ts +2 -1
- package/src/schema/blocks/createSpec.ts +3 -0
- package/src/util/expandToWords.ts +38 -0
- package/types/src/api/blockManipulation/selections/selection.d.ts +1 -1
- package/types/src/editor/BlockNoteEditor.d.ts +5 -34
- package/types/src/editor/BlockNoteExtension.d.ts +4 -0
- package/types/src/editor/managers/SelectionManager.d.ts +4 -4
- package/types/src/extensions/Collaboration/Collaboration.d.ts +76 -0
- package/types/src/extensions/Collaboration/ForkYDoc.d.ts +2 -11
- package/types/src/extensions/Collaboration/YCursorPlugin.d.ts +3 -11
- package/types/src/extensions/Collaboration/YSync.d.ts +2 -4
- package/types/src/extensions/Collaboration/YUndo.d.ts +1 -1
- package/types/src/extensions/ShowSelection/ShowSelection.d.ts +10 -4
- package/types/src/index.d.ts +2 -1
- package/types/src/util/expandToWords.d.ts +13 -0
- package/dist/ShowSelection-BW37oJ6h.cjs +0 -2
- package/dist/ShowSelection-BW37oJ6h.cjs.map +0 -1
- package/dist/ShowSelection-Dz-NEase.js +0 -43
- package/dist/ShowSelection-Dz-NEase.js.map +0 -1
- package/dist/TrailingNode-CG2a-HDA.js.map +0 -1
- package/dist/TrailingNode-Du4SNHun.cjs +0 -2
- package/dist/TrailingNode-Du4SNHun.cjs.map +0 -1
- package/dist/defaultBlocks-B63ufZ5N.js.map +0 -1
- package/dist/defaultBlocks-BX6UxQa8.cjs +0 -6
- package/dist/defaultBlocks-BX6UxQa8.cjs.map +0 -1
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
`+w.text,g.push(...C.slice(1)),g):(g.push(...C),g)},[]),props:{colspan:f.attrs.colspan,rowspan:f.attrs.rowspan,backgroundColor:f.attrs.backgroundColor,textColor:f.attrs.textColor,textAlignment:f.attrs.textAlignment}})),n.rows.push(h)});for(let i=0;i<e.length;i++)(s=e[i])!=null&&s.every(c=>c)&&(n.headerRows=(n.headerRows??0)+1);for(let i=0;i<((l=e[0])==null?void 0:l.length);i++)e!=null&&e.every(c=>c[i])&&(n.headerCols=(n.headerCols??0)+1);return n}function q(t,o,r){const n=[];let e;return t.content.forEach(s=>{if(s.type.name==="hardBreak"){if(e)if(x(e))e.text+=`
|
|
3
3
|
`;else if(L(e))e.content[e.content.length-1].text+=`
|
|
4
4
|
`;else throw new Error("unexpected");else e={type:"text",text:`
|
|
5
|
-
`,styles:{}};return}if(s.type.name!=="link"&&s.type.name!=="text"){if(!o[s.type.name]){console.warn("unrecognized inline content type",s.type.name);return}e&&(n.push(e),e=void 0),n.push(lt(s,o,r));return}const l={};let i;for(const c of s.marks)if(c.type.name==="link")i=c;else{const a=r[c.type.name];if(!a){if(c.type.spec.blocknoteIgnore)continue;throw new Error(`style ${c.type.name} not found in styleSchema`)}if(a.propSchema==="boolean")l[a.type]=!0;else if(a.propSchema==="string")l[a.type]=c.attrs.stringValue;else throw new A(a.propSchema)}e?x(e)?i?(n.push(e),e={type:"link",href:i.attrs.href,content:[{type:"text",text:s.textContent,styles:l}]}):JSON.stringify(e.styles)===JSON.stringify(l)?e.text+=s.textContent:(n.push(e),e={type:"text",text:s.textContent,styles:l}):L(e)&&(i?e.href===i.attrs.href?JSON.stringify(e.content[e.content.length-1].styles)===JSON.stringify(l)?e.content[e.content.length-1].text+=s.textContent:e.content.push({type:"text",text:s.textContent,styles:l}):(n.push(e),e={type:"link",href:i.attrs.href,content:[{type:"text",text:s.textContent,styles:l}]}):(n.push(e),e={type:"text",text:s.textContent,styles:l})):i?e={type:"link",href:i.attrs.href,content:[{type:"text",text:s.textContent,styles:l}]}:e={type:"text",text:s.textContent,styles:l}}),e&&n.push(e),n}function lt(t,o,r){if(t.type.name==="text"||t.type.name==="link")throw new Error("unexpected");const n={},e=o[t.type.name];for(const[i,c]of Object.entries(t.attrs)){if(!e)throw Error("ic node is of an unrecognized type: "+t.type.name);const a=e.propSchema;i in a&&(n[i]=c)}let s;return e.content==="styled"?s=q(t,o,r):s=void 0,{type:t.type.name,props:n,content:s}}function F(t,o,r=J(o),n=_(o),e=N(o),s=H(o)){var C;if(!t.type.isInGroup("bnBlock"))throw Error("Node should be a bnBlock, but is instead: "+t.type.name);const l=s==null?void 0:s.get(t);if(l)return l;const i=M(t,0);let c=i.bnBlock.node.attrs.id;c===null&&(c=U.options.generateID());const a=r[i.blockNoteType];if(!a)throw Error("Block is of an unrecognized type: "+i.blockNoteType);const h={};for(const[d,w]of Object.entries({...t.attrs,...i.isBlockContainer?i.blockContent.node.attrs:{}})){const y=a.propSchema;d in y&&!(y[d].default===void 0&&w===void 0)&&(h[d]=w)}const f=r[i.blockNoteType],p=[];(C=i.childContainer)==null||C.node.forEach(d=>{p.push(F(d,o,r,n,e,s))});let u;if(f.content==="inline"){if(!i.isBlockContainer)throw new Error("impossible");u=q(i.blockContent.node,n,e)}else if(f.content==="table"){if(!i.isBlockContainer)throw new Error("impossible");u=st(i.blockContent.node,n,e)}else if(f.content==="none")u=void 0;else throw new A(f.content);const g={id:c,type:f.type,props:h,content:u,children:p};return s==null||s.set(t,g),g}function kt(t,o=ot(t),r=J(o),n=_(o),e=N(o),s=H(o)){const l=[];return t.firstChild&&t.firstChild.descendants(i=>(l.push(F(i,o,r,n,e,s)),!1)),l}function bt(t,o,r=J(o),n=_(o),e=N(o),s=H(o)){function l(i,c,a){if(i.type.name!=="blockGroup")throw new Error("unexpected");const h=[];let f,p;return i.forEach((u,g,C)=>{if(u.type.name!=="blockContainer")throw new Error("unexpected");if(u.childCount===0)return;if(u.childCount===0||u.childCount>2)throw new Error("unexpected, blockContainer.childCount: "+u.childCount);const d=C===0,w=C===i.childCount-1;if(u.firstChild.type.name==="blockGroup"){if(!d)throw new Error("unexpected");const k=l(u.firstChild,Math.max(0,c-1),w?Math.max(0,a-1):0);f=k.blockCutAtStart,w&&(p=k.blockCutAtEnd),h.push(...k.blocks);return}const y=F(u,o,r,n,e,s),m=u.childCount>1?u.child(1):void 0;let b=[];if(m){const k=l(m,0,w?Math.max(0,a-1):0);b=k.blocks,w&&(p=k.blockCutAtEnd)}w&&!m&&a>1&&(p=y.id),d&&c>1&&(f=y.id),h.push({...y,children:b})}),{blocks:h,blockCutAtStart:f,blockCutAtEnd:p}}if(t.content.childCount===0)return{blocks:[],blockCutAtStart:void 0,blockCutAtEnd:void 0};if(t.content.childCount!==1)throw new Error("slice must be a single block, did you forget includeParents=true?");return l(t.content.firstChild,Math.max(t.openStart-1,0),Math.max(t.openEnd-1,0))}function B(t){const{height:o,width:r}=Q(t),n=new Array(o).fill(!1).map(()=>new Array(r).fill(null)),e=(s,l)=>{for(let i=s;i<o;i++)for(let c=l;c<r;c++)if(!n[i][c])return{row:i,col:c};throw new Error("Unable to create occupancy grid for table, no more available cells")};for(let s=0;s<t.content.rows.length;s++)for(let l=0;l<t.content.rows[s].cells.length;l++){const i=R(t.content.rows[s].cells[l]),c=P(i),a=v(i),{row:h,col:f}=e(s,l);for(let p=h;p<h+c;p++)for(let u=f;u<f+a;u++){if(n[p][u])throw new Error(`Unable to create occupancy grid for table, cell at ${p},${u} is already occupied`);n[p][u]={row:s,col:l,rowspan:c,colspan:a,cell:i}}}return n}function T(t){const o=new Set;return t.map(r=>({cells:r.map(n=>o.has(n.row+":"+n.col)?!1:(o.add(n.row+":"+n.col),n.cell)).filter(n=>n!==!1)}))}function E(t,o,r=B(o)){for(let n=0;n<r.length;n++)for(let e=0;e<r[n].length;e++){const s=r[n][e];if(s.row===t.row&&s.col===t.col)return{row:n,col:e,cell:s.cell}}throw new Error(`Unable to resolve relative table cell indices for table, cell at ${t.row},${t.col} is not occupied`)}function Q(t){const o=t.content.rows.length;let r=0;return t.content.rows.forEach(n=>{let e=0;n.cells.forEach(s=>{e+=v(s)}),r=Math.max(r,e)}),{height:o,width:r}}function it(t,o,r=B(o)){var e;const n=(e=r[t.row])==null?void 0:e[t.col];if(n)return{row:n.row,col:n.col,cell:n.cell}}function ct(t,o){var s;const r=B(t);if(o<0||o>=r.length)return[];let n=0;for(let l=0;l<o;l++){const i=(s=r[n])==null?void 0:s[0];if(!i)return[];n+=i.rowspan}const e=new Array(r[0].length).fill(!1).map((l,i)=>it({row:n,col:i},t,r)).filter(l=>l!==void 0);return e.filter((l,i)=>e.findIndex(c=>c.row===l.row&&c.col===l.col)===i)}function at(t,o){var s;const r=B(t);if(o<0||o>=r[0].length)return[];let n=0;for(let l=0;l<o;l++){const i=(s=r[0])==null?void 0:s[n];if(!i)return[];n+=i.colspan}const e=new Array(r.length).fill(!1).map((l,i)=>it({row:i,col:n},t,r)).filter(l=>l!==void 0);return e.filter((l,i)=>e.findIndex(c=>c.row===l.row&&c.col===l.col)===i)}function Bt(t,o,r,n=B(t)){const{col:e}=E({row:0,col:o},t,n),{col:s}=E({row:0,col:r},t,n);return n.forEach(l=>{const[i]=l.splice(e,1);l.splice(s,0,i)}),T(n)}function xt(t,o,r,n=B(t)){const{row:e}=E({row:o,col:0},t,n),{row:s}=E({row:r,col:0},t,n),[l]=n.splice(e,1);return n.splice(s,0,l),T(n)}function W(t){return t?I(t)?W(t.content):typeof t=="string"?t.length===0:Array.isArray(t)?t.every(o=>typeof o=="string"?o.length===0:x(o)?o.text.length===0:z(o)?typeof o.content=="string"?o.content.length===0:o.content.every(r=>r.text.length===0):!1):!1:!0}function Et(t,o,r=B(t)){if(o==="columns"){let s=0;for(let l=r[0].length-1;l>=0&&r.every(c=>W(c[l].cell)&&c[l].colspan===1);l--)s++;for(let l=r.length-1;l>=0;l--){const i=Math.max(r[l].length-s,1);r[l]=r[l].slice(0,i)}return T(r)}let n=0;for(let s=r.length-1;s>=0&&r[s].every(i=>W(i.cell)&&i.rowspan===1);s--)n++;const e=Math.min(n,r.length-1);return r.splice(r.length-e,e),T(r)}function Nt(t,o,r,n=B(t)){const{width:e,height:s}=Q(t);if(o==="columns")n.forEach((l,i)=>{if(r>=0)for(let c=0;c<r;c++)l.push({row:i,col:Math.max(...l.map(a=>a.col))+1,rowspan:1,colspan:1,cell:R("")});else l.splice(e+r,-1*r)});else if(r>0)for(let l=0;l<r;l++){const i=new Array(e).fill(null).map((c,a)=>({row:s+l,col:a,rowspan:1,colspan:1,cell:R("")}));n.push(i)}else r<0&&n.splice(s+r,-1*r);return T(n)}function It(t,o,r){const n=ct(t,r);if(!n.some(c=>P(c.cell)>1))return!0;let s=r,l=r;return n.forEach(c=>{const a=P(c.cell);s=Math.max(s,c.row+a-1),l=Math.min(l,c.row)}),o<r?r===s:r===l}function vt(t,o,r){const n=at(t,r);if(!n.some(c=>v(c.cell)>1))return!0;let s=r,l=r;return n.forEach(c=>{const a=v(c.cell);s=Math.max(s,c.col+a-1),l=Math.min(l,c.col)}),o<r?r===s:r===l}function Tt(t,o,r){const n=E(t,r),e=E(o,r);return n.col===e.col}function nt(t,o,r,n){const e=[];for(const[l,i]of Object.entries(t.styles||{})){const c=r[l];if(!c)throw new Error(`style ${l} not found in styleSchema`);if(c.propSchema==="boolean")i&&e.push(o.mark(l));else if(c.propSchema==="string")i&&e.push(o.mark(l,{stringValue:i}));else throw new A(c.propSchema)}return!n||!o.nodes[n].spec.code?t.text.split(/(\n)/g).filter(l=>l.length>0).map(l=>l===`
|
|
5
|
+
`,styles:{}};return}if(s.type.name!=="link"&&s.type.name!=="text"){if(!o[s.type.name]){console.warn("unrecognized inline content type",s.type.name);return}e&&(n.push(e),e=void 0),n.push(lt(s,o,r));return}const l={};let i;for(const c of s.marks)if(c.type.name==="link")i=c;else{const a=r[c.type.name];if(!a){if(c.type.spec.blocknoteIgnore)continue;throw new Error(`style ${c.type.name} not found in styleSchema`)}if(a.propSchema==="boolean")l[a.type]=!0;else if(a.propSchema==="string")l[a.type]=c.attrs.stringValue;else throw new A(a.propSchema)}e?x(e)?i?(n.push(e),e={type:"link",href:i.attrs.href,content:[{type:"text",text:s.textContent,styles:l}]}):JSON.stringify(e.styles)===JSON.stringify(l)?e.text+=s.textContent:(n.push(e),e={type:"text",text:s.textContent,styles:l}):L(e)&&(i?e.href===i.attrs.href?JSON.stringify(e.content[e.content.length-1].styles)===JSON.stringify(l)?e.content[e.content.length-1].text+=s.textContent:e.content.push({type:"text",text:s.textContent,styles:l}):(n.push(e),e={type:"link",href:i.attrs.href,content:[{type:"text",text:s.textContent,styles:l}]}):(n.push(e),e={type:"text",text:s.textContent,styles:l})):i?e={type:"link",href:i.attrs.href,content:[{type:"text",text:s.textContent,styles:l}]}:e={type:"text",text:s.textContent,styles:l}}),e&&n.push(e),n}function lt(t,o,r){if(t.type.name==="text"||t.type.name==="link")throw new Error("unexpected");const n={},e=o[t.type.name];for(const[i,c]of Object.entries(t.attrs)){if(!e)throw Error("ic node is of an unrecognized type: "+t.type.name);const a=e.propSchema;i in a&&(n[i]=c)}let s;return e.content==="styled"?s=q(t,o,r):s=void 0,{type:t.type.name,props:n,content:s}}function F(t,o,r=J(o),n=_(o),e=N(o),s=H(o)){var C;if(!t.type.isInGroup("bnBlock"))throw Error("Node should be a bnBlock, but is instead: "+t.type.name);const l=s==null?void 0:s.get(t);if(l)return l;const i=M(t,0);let c=i.bnBlock.node.attrs.id;c===null&&(c=U.options.generateID());const a=r[i.blockNoteType];if(!a)throw Error("Block is of an unrecognized type: "+i.blockNoteType);const h={};for(const[d,w]of Object.entries({...t.attrs,...i.isBlockContainer?i.blockContent.node.attrs:{}})){const y=a.propSchema;d in y&&!(y[d].default===void 0&&w===void 0)&&(h[d]=w)}const f=r[i.blockNoteType],p=[];(C=i.childContainer)==null||C.node.forEach(d=>{p.push(F(d,o,r,n,e,s))});let u;if(f.content==="inline"){if(!i.isBlockContainer)throw new Error("impossible");u=q(i.blockContent.node,n,e)}else if(f.content==="table"){if(!i.isBlockContainer)throw new Error("impossible");u=st(i.blockContent.node,n,e)}else if(f.content==="none")u=void 0;else throw new A(f.content);const g={id:c,type:f.type,props:h,content:u,children:p};return s==null||s.set(t,g),g}function kt(t,o=ot(t),r=J(o),n=_(o),e=N(o),s=H(o)){const l=[];return t.firstChild&&t.firstChild.descendants(i=>(l.push(F(i,o,r,n,e,s)),!1)),l}function bt(t,o,r=J(o),n=_(o),e=N(o),s=H(o)){function l(i,c,a){if(i.type.name!=="blockGroup")throw new Error("unexpected");const h=[];let f,p;return i.forEach((u,g,C)=>{if(u.type.name!=="blockContainer")throw new Error("unexpected");if(u.childCount===0)return;if(u.childCount===0||u.childCount>2)throw new Error("unexpected, blockContainer.childCount: "+u.childCount);const d=C===0,w=C===i.childCount-1;if(u.firstChild.type.name==="blockGroup"){if(!d)throw new Error("unexpected");const k=l(u.firstChild,Math.max(0,c-1),w?Math.max(0,a-1):0);f=k.blockCutAtStart,w&&(p=k.blockCutAtEnd),h.push(...k.blocks);return}const y=F(u,o,r,n,e,s),m=u.childCount>1?u.child(1):void 0;let b=[];if(m){const k=l(m,0,w?Math.max(0,a-1):0);b=k.blocks,w&&(p=k.blockCutAtEnd)}w&&!m&&a>1&&(p=y.id),d&&c>1&&(f=y.id),h.push({...y,children:b})}),{blocks:h,blockCutAtStart:f,blockCutAtEnd:p}}if(t.content.childCount===0)return{blocks:[],blockCutAtStart:void 0,blockCutAtEnd:void 0};if(t.content.childCount!==1)throw new Error("slice must be a single block, did you forget includeParents=true?");return l(t.content.firstChild,Math.max(t.openStart-1,0),Math.max(t.openEnd-1,0))}function B(t){const{height:o,width:r}=Q(t),n=new Array(o).fill(!1).map(()=>new Array(r).fill(null)),e=(s,l)=>{for(let i=s;i<o;i++)for(let c=l;c<r;c++)if(!n[i][c])return{row:i,col:c};throw new Error("Unable to create occupancy grid for table, no more available cells")};for(let s=0;s<t.content.rows.length;s++)for(let l=0;l<t.content.rows[s].cells.length;l++){const i=R(t.content.rows[s].cells[l]),c=P(i),a=v(i),{row:h,col:f}=e(s,l);for(let p=h;p<h+c;p++)for(let u=f;u<f+a;u++){if(n[p][u])throw new Error(`Unable to create occupancy grid for table, cell at ${p},${u} is already occupied`);n[p][u]={row:s,col:l,rowspan:c,colspan:a,cell:i}}}return n}function T(t){const o=new Set;return t.map(r=>({cells:r.map(n=>o.has(n.row+":"+n.col)?!1:(o.add(n.row+":"+n.col),n.cell)).filter(n=>n!==!1)}))}function E(t,o,r=B(o)){for(let n=0;n<r.length;n++)for(let e=0;e<r[n].length;e++){const s=r[n][e];if(s&&s.row===t.row&&s.col===t.col)return{row:n,col:e,cell:s.cell}}throw new Error(`Unable to resolve relative table cell indices for table, cell at ${t.row},${t.col} is not occupied`)}function Q(t){const o=t.content.rows.length;let r=0;return t.content.rows.forEach(n=>{let e=0;n.cells.forEach(s=>{e+=v(s)}),r=Math.max(r,e)}),{height:o,width:r}}function it(t,o,r=B(o)){var e;const n=(e=r[t.row])==null?void 0:e[t.col];if(n)return{row:n.row,col:n.col,cell:n.cell}}function ct(t,o){var s;const r=B(t);if(o<0||o>=r.length)return[];let n=0;for(let l=0;l<o;l++){const i=(s=r[n])==null?void 0:s[0];if(!i)return[];n+=i.rowspan}const e=new Array(r[0].length).fill(!1).map((l,i)=>it({row:n,col:i},t,r)).filter(l=>l!==void 0);return e.filter((l,i)=>e.findIndex(c=>c.row===l.row&&c.col===l.col)===i)}function at(t,o){var s;const r=B(t);if(o<0||o>=r[0].length)return[];let n=0;for(let l=0;l<o;l++){const i=(s=r[0])==null?void 0:s[n];if(!i)return[];n+=i.colspan}const e=new Array(r.length).fill(!1).map((l,i)=>it({row:i,col:n},t,r)).filter(l=>l!==void 0);return e.filter((l,i)=>e.findIndex(c=>c.row===l.row&&c.col===l.col)===i)}function Bt(t,o,r,n=B(t)){const{col:e}=E({row:0,col:o},t,n),{col:s}=E({row:0,col:r},t,n);return n.forEach(l=>{const[i]=l.splice(e,1);l.splice(s,0,i)}),T(n)}function xt(t,o,r,n=B(t)){const{row:e}=E({row:o,col:0},t,n),{row:s}=E({row:r,col:0},t,n),[l]=n.splice(e,1);return n.splice(s,0,l),T(n)}function W(t){return t?I(t)?W(t.content):typeof t=="string"?t.length===0:Array.isArray(t)?t.every(o=>typeof o=="string"?o.length===0:x(o)?o.text.length===0:z(o)?typeof o.content=="string"?o.content.length===0:o.content.every(r=>r.text.length===0):!1):!1:!0}function Et(t,o,r=B(t)){if(o==="columns"){let s=0;for(let l=r[0].length-1;l>=0&&r.every(c=>W(c[l].cell)&&c[l].colspan===1);l--)s++;for(let l=r.length-1;l>=0;l--){const i=Math.max(r[l].length-s,1);r[l]=r[l].slice(0,i)}return T(r)}let n=0;for(let s=r.length-1;s>=0&&r[s].every(i=>W(i.cell)&&i.rowspan===1);s--)n++;const e=Math.min(n,r.length-1);return r.splice(r.length-e,e),T(r)}function Nt(t,o,r,n=B(t)){const{width:e,height:s}=Q(t);if(o==="columns")n.forEach((l,i)=>{if(r>=0)for(let c=0;c<r;c++)l.push({row:i,col:Math.max(...l.map(a=>a.col))+1,rowspan:1,colspan:1,cell:R("")});else l.splice(e+r,-1*r)});else if(r>0)for(let l=0;l<r;l++){const i=new Array(e).fill(null).map((c,a)=>({row:s+l,col:a,rowspan:1,colspan:1,cell:R("")}));n.push(i)}else r<0&&n.splice(s+r,-1*r);return T(n)}function It(t,o,r){const n=ct(t,r);if(!n.some(c=>P(c.cell)>1))return!0;let s=r,l=r;return n.forEach(c=>{const a=P(c.cell);s=Math.max(s,c.row+a-1),l=Math.min(l,c.row)}),o<r?r===s:r===l}function vt(t,o,r){const n=at(t,r);if(!n.some(c=>v(c.cell)>1))return!0;let s=r,l=r;return n.forEach(c=>{const a=v(c.cell);s=Math.max(s,c.col+a-1),l=Math.min(l,c.col)}),o<r?r===s:r===l}function Tt(t,o,r){const n=E(t,r),e=E(o,r);return n.col===e.col}function nt(t,o,r,n){const e=[];for(const[l,i]of Object.entries(t.styles||{})){const c=r[l];if(!c)throw new Error(`style ${l} not found in styleSchema`);if(c.propSchema==="boolean")i&&e.push(o.mark(l));else if(c.propSchema==="string")i&&e.push(o.mark(l,{stringValue:i}));else throw new A(c.propSchema)}return!n||!o.nodes[n].spec.code?t.text.split(/(\n)/g).filter(l=>l.length>0).map(l=>l===`
|
|
6
6
|
`?o.nodes.hardBreak.createChecked():o.text(l,e)):t.text.length>0?[o.text(t.text,e)]:[]}function St(t,o,r){const n=o.marks.link.create({href:t.href});return j(t.content,o,r).map(e=>{if(e.type.name==="text")return e.mark([...e.marks,n]);if(e.type.name==="hardBreak")return e;throw new Error("unexpected node type")})}function j(t,o,r,n){const e=[];if(typeof t=="string")return e.push(...nt({text:t,styles:{}},o,r,n)),e;for(const s of t)e.push(...nt(s,o,r,n));return e}function S(t,o,r,n=N(o)){const e=[];for(const s of t)typeof s=="string"?e.push(...j(s,o,n,r)):z(s)?e.push(...St(s,o,n)):x(s)?e.push(...j([s],o,n,r)):e.push(ut(s,o,n));return e}function ft(t,o,r=N(o)){const n=[],e=new Array(t.headerRows??0).fill(!0),s=new Array(t.headerCols??0).fill(!0),l=t.columnWidths??[];for(let i=0;i<t.rows.length;i++){const c=t.rows[i],a=[],h=e[i];for(let p=0;p<c.cells.length;p++){const u=c.cells[p],g=s[p],C=void 0;let d=null;const w=E({row:i,col:p},{content:t});let y=l[w.col]?[l[w.col]]:null;if(u)if(typeof u=="string")d=o.text(u);else if(I(u)){u.content&&(d=S(u.content,o,"tableParagraph",r));const b=v(u);b>1&&(y=new Array(b).fill(!1).map((k,X)=>l[w.col+X]??void 0))}else d=S(u,o,"tableParagraph",r);const m=o.nodes[g||h?"tableHeader":"tableCell"].createChecked({...I(u)?u.props:{},colwidth:y},o.nodes.tableParagraph.createChecked(C,d));a.push(m)}const f=o.nodes.tableRow.createChecked({},a);n.push(f)}return n}function ut(t,o,r){let n,e=t.type;if(e===void 0&&(e="paragraph"),!o.nodes[e])throw new Error(`node type ${e} not found in schema`);if(!t.content)n=o.nodes[e].createChecked(t.props);else if(typeof t.content=="string"){const s=S([t.content],o,e,r);n=o.nodes[e].createChecked(t.props,s)}else if(Array.isArray(t.content)){const s=S(t.content,o,e,r);n=o.nodes[e].createChecked(t.props,s)}else if(t.content.type==="tableContent"){const s=ft(t.content,o,r);n=o.nodes[e].createChecked(t.props,s)}else throw new A(t.content.type);return n}function pt(t,o,r=N(o)){let n=t.id;n===void 0&&(n=U.options.generateID());const e=[];if(t.children)for(const l of t.children)e.push(pt(l,o,r));if(!t.type||o.nodes[t.type].isInGroup("blockContent")){const l=ut(t,o,r),i=e.length>0?o.nodes.blockGroup.createChecked({},e):void 0;return o.nodes.blockContainer.createChecked({id:n,...t.props},i?[l,i]:l)}else{if(o.nodes[t.type].isInGroup("bnBlock"))return o.nodes[t.type].createChecked({id:n,...t.props},e);throw new Error(`block type ${t.type} doesn't match blockContent or bnBlock group`)}}exports.UniqueID=U;exports.UnreachableCaseError=A;exports.addRowsOrColumns=Nt;exports.areInSameColumn=Tt;exports.assertEmpty=wt;exports.blockToNode=pt;exports.canColumnBeDraggedInto=vt;exports.canRowBeDraggedInto=It;exports.contentNodeToInlineContent=q;exports.contentNodeToTableContent=st;exports.cropEmptyRowsOrColumns=Et;exports.docToBlocks=kt;exports.getBlockCache=H;exports.getBlockInfo=K;exports.getBlockInfoFromResolvedPos=yt;exports.getBlockInfoFromSelection=Ct;exports.getBlockInfoFromTransaction=mt;exports.getBlockInfoWithManualOffset=M;exports.getBlockNoteSchema=$;exports.getBlockSchema=J;exports.getCellsAtColumnHandle=at;exports.getCellsAtRowHandle=ct;exports.getColspan=v;exports.getDimensionsOfTable=Q;exports.getInlineContentSchema=_;exports.getNearestBlockPos=V;exports.getPmSchema=ot;exports.getRowspan=P;exports.getStyleSchema=N;exports.inlineContentToNodes=S;exports.isLinkInlineContent=L;exports.isPartialLinkInlineContent=z;exports.isPartialTableCell=I;exports.isStyledTextInlineContent=x;exports.isTableCell=D;exports.mapTableCell=R;exports.moveColumn=Bt;exports.moveRow=xt;exports.nodeToBlock=F;exports.nodeToCustomInlineContent=lt;exports.prosemirrorSliceToSlicedBlocks=bt;exports.tableContentToNodes=ft;
|
|
7
|
-
//# sourceMappingURL=blockToNode-
|
|
7
|
+
//# sourceMappingURL=blockToNode-CumVjgem.cjs.map
|