@blocknote/xl-odt-exporter 0.40.0 → 0.41.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/blocknote-xl-odt-exporter.js +28 -12
- package/dist/blocknote-xl-odt-exporter.js.map +1 -1
- package/dist/blocknote-xl-odt-exporter.umd.cjs +1 -1
- package/dist/blocknote-xl-odt-exporter.umd.cjs.map +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +3 -3
- package/src/odt/__snapshots__/basic/content.xml +4 -0
- package/src/odt/__snapshots__/withCustomOptions/content.xml +4 -0
- package/src/odt/defaultSchema/blocks.tsx +18 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(D,A){typeof exports=="object"&&typeof module<"u"?A(exports,require("react/jsx-runtime"),require("@blocknote/core"),require("@zip.js/zip.js"),require("react-dom/server")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@blocknote/core","@zip.js/zip.js","react-dom/server"],A):(D=typeof globalThis<"u"?globalThis:D||self,A(D["blocknote-xl-odt-exporter"]={},D.jsxRuntime,D.core,D.zip_js,D.server))})(this,function(D,A,t,s,N){"use strict";var z=Object.defineProperty;var S=(D,A,t)=>A in D?z(D,A,{enumerable:!0,configurable:!0,writable:!0,value:t}):D[A]=t;var o=(D,A,t)=>S(D,typeof A!="symbol"?A+"":A,t);const J=B=>Array.from({length:B},()=>A.jsx("text:tab",{})),G=(B,Q,g="Standard",E={},w={},C={})=>{const M={...w},I={...C};if(Q.textAlignment&&Q.textAlignment!=="left"){const Y={left:"start",center:"center",right:"end",justify:"justify"};M["fo:text-align"]=Y[Q.textAlignment]}const F=Q.backgroundColor&&Q.backgroundColor!=="default"?B.options.colors[Q.backgroundColor].background:void 0;if(F&&(M["fo:background-color"]=F),Q.textColor&&Q.textColor!=="default"){const Y=B.options.colors[Q.textColor].text;I["fo:color"]=Y}return!F&&!Object.keys(E).length&&!Object.keys(M).length&&!Object.keys(I).length?g||"Standard":B.registerStyle(Y=>A.jsxs("style:style",{"style:family":"paragraph","style:name":Y,"style:parent-style-name":g,...E,children:[F&&A.jsx("loext:graphic-properties",{"draw:fill":"solid","draw:fill-color":F}),Object.keys(M).length>0&&A.jsx("style:paragraph-properties",{...M}),Object.keys(I).length>0&&A.jsx("style:text-properties",{...I})]}))},a=B=>{const Q=new Map;return g=>{const E=`${g.props.backgroundColor}-${g.props.textColor}-${g.props.textAlignment}`;if(Q.has(E))return Q.get(E);const w=B.registerStyle(C=>A.jsx("style:style",{"style:family":"table-cell","style:name":C,children:A.jsx("style:table-cell-properties",{"fo:border":"0.5pt solid #000000","style:writing-mode":"lr-tb","fo:padding-top":"0in","fo:padding-left":"0.075in","fo:padding-bottom":"0in","fo:padding-right":"0.075in","fo:background-color":g.props.backgroundColor!=="default"&&g.props.backgroundColor?B.options.colors[g.props.backgroundColor].background:void 0,"fo:color":g.props.textColor!=="default"&&g.props.textColor?B.options.colors[g.props.textColor].text:void 0})}));return Q.set(E,w),w}},y=(B,Q)=>B.registerStyle(E=>A.jsx("style:style",{"style:family":"table","style:name":E,children:A.jsx("style:table-properties",{"table:align":"left","style:writing-mode":"lr-tb","style:width":`${Q.width}pt`})})),H=(B,Q)=>Q<=0?B:A.jsx("text:list",{children:A.jsx("text:list-item",{children:H(B,Q-1)})}),h={blockMapping:{paragraph:(B,Q,g)=>{const E=G(Q,B.props);return A.jsxs("text:p",{"text:style-name":E,children:[J(g),Q.transformInlineContent(B.content)]})},heading:(B,Q,g)=>{const w=G(Q,B.props,"Heading_20_"+B.props.level);return A.jsxs("text:h",{"text:outline-level":`${B.props.level}`,"text:style-name":w,children:[J(g),Q.transformInlineContent(B.content)]})},quote:(B,Q,g)=>{const w=G(Q,B.props,"Standard",{},{"fo:border-left":"2pt solid #7D797A","fo:padding-left":"0.25in"},{"fo:color":"#7D797A"});return A.jsxs("text:p",{"text:style-name":w,children:[J(g),Q.transformInlineContent(B.content)]})},toggleListItem:(B,Q)=>A.jsxs("text:p",{"text:style-name":"Standard",children:["> ",Q.transformInlineContent(B.content)]}),bulletListItem:(B,Q,g)=>{const E=G(Q,B.props,"Standard",{"style:list-style-name":"WWNum1"});return A.jsx("text:list",{"text:style-name":"WWNum1",children:A.jsx("text:list-item",{children:H(A.jsx("text:p",{"text:style-name":E,children:Q.transformInlineContent(B.content)}),g)})})},numberedListItem:(B,Q,g,E)=>{const w=G(Q,B.props),C=(E||0)>1?"true":"false";return A.jsx("text:list",{"text:style-name":"No_20_List","text:continue-numbering":C,children:A.jsx("text:list-item",{...C==="false"&&{"text:start-value":B.props.start},children:H(A.jsx("text:p",{"text:style-name":w,children:Q.transformInlineContent(B.content)}),g)})})},checkListItem:(B,Q)=>A.jsxs("text:p",{"text:style-name":"Standard",children:[B.props.checked?"☒ ":"☐ ",Q.transformInlineContent(B.content)]}),pageBreak:async()=>A.jsx("text:p",{"text:style-name":"PageBreak"}),column:(B,Q,g,E,w)=>{const M=Q.registerStyle(I=>A.jsx("style:style",{"style:name":I,"style:family":"table-cell",children:A.jsx("style:table-cell-properties",{"style:writing-mode":"lr-tb","fo:border":"none","fo:padding-top":"0in","fo:padding-left":"0.075in","fo:padding-bottom":"0in","fo:padding-right":"0.075in"})}));return A.jsx("table:table-cell",{"table:style-name":M,children:w})},columnList:(B,Q,g,E,w)=>{const C=B,M=Q,I=M.registerStyle(F=>A.jsx("style:style",{"style:name":F,"style:family":"table",children:A.jsx("style:table-properties",{"table:align":"margins","style:writing-mode":"lr-tb"})}));return A.jsxs("table:table",{"table:name":B.id,"table:style-name":I,children:[(C.children||[]).map((F,Y)=>{const l=M.registerStyle(c=>A.jsx("style:style",{"style:name":c,"style:family":"table-column",children:A.jsx("style:table-column-properties",{"style:rel-column-width":`${F.props.width*100}*`})}));return A.jsx("table:table-column",{"table:style-name":l},Y)}),A.jsx("table:table-row",{children:w})]})},image:async(B,Q)=>{const g=Q,{path:E,mimeType:w,...C}=await g.registerPicture(B.props.url),M=G(Q,B.props),I=B.props.previewWidth||C.width,F=C.height/C.width*I,Y=20,l=A.jsxs("text:p",{"text:style-name":B.props.caption?"Caption":M,children:[A.jsx("draw:frame",{"draw:style-name":"Frame","style:rel-height":"scale","svg:width":`${I}px`,"svg:height":`${F}px`,"style:rel-width":B.props.caption?"100%":`${I}px`,...!B.props.caption&&{"text:anchor-type":"as-char"},children:A.jsx("draw:image",{"xlink:type":"simple","xlink:show":"embed","xlink:actuate":"onLoad","xlink:href":E,"draw:mime-type":w})}),A.jsx("text:line-break",{}),A.jsx("text:span",{"text:style-name":"Caption",children:B.props.caption})]});return B.props.caption?A.jsx("text:p",{"text:style-name":M,children:A.jsx("draw:frame",{"draw:style-name":"Frame","style:rel-height":"scale","style:rel-width":`${I}px`,"svg:width":`${I}px`,"svg:height":`${F+Y}px`,"text:anchor-type":"as-char",children:A.jsx("draw:text-box",{children:l})})}):l},table:(B,Q)=>{var F;const w=(B.content.columnWidths.reduce((Y,l)=>(Y||0)+(l||120),0)||0)*.75,C=Q,M=a(C),I=y(C,{width:w});return A.jsxs("table:table",{"table:name":B.id,"table:style-name":I,children:[(F=B.content.rows[0])==null?void 0:F.cells.map((Y,l)=>{const i=(B.content.columnWidths[l]||120)*.75,U=C.registerStyle(n=>A.jsx("style:style",{"style:name":n,"style:family":"table-column",children:A.jsx("style:table-column-properties",{"style:column-width":`${i}pt`})}));return A.jsx("table:table-column",{"table:style-name":U},l)}),B.content.rows.map((Y,l)=>A.jsx("table:table-row",{children:Y.cells.map((c,i)=>{const U=t.mapTableCell(c);return A.jsx("table:table-cell",{"table:style-name":M(U),"office:value-type":"string","style:text-align-source":"fix","style:paragraph-properties-text-align":U.props.textAlignment,children:A.jsx("text:p",{"text:style-name":"Standard",children:Q.transformInlineContent(U.content)})},`${l}-${i}`)})},l))]})},codeBlock:B=>{var g;const Q=((g=B.content[0])==null?void 0:g.text)||"";return A.jsxs("text:p",{"text:style-name":"Codeblock",children:[...Q.split(`
|
|
1
|
+
(function(D,A){typeof exports=="object"&&typeof module<"u"?A(exports,require("react/jsx-runtime"),require("@blocknote/core"),require("@zip.js/zip.js"),require("react-dom/server")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@blocknote/core","@zip.js/zip.js","react-dom/server"],A):(D=typeof globalThis<"u"?globalThis:D||self,A(D["blocknote-xl-odt-exporter"]={},D.jsxRuntime,D.core,D.zip_js,D.server))})(this,function(D,A,t,s,N){"use strict";var z=Object.defineProperty;var S=(D,A,t)=>A in D?z(D,A,{enumerable:!0,configurable:!0,writable:!0,value:t}):D[A]=t;var o=(D,A,t)=>S(D,typeof A!="symbol"?A+"":A,t);const J=B=>Array.from({length:B},()=>A.jsx("text:tab",{})),G=(B,Q,g="Standard",E={},w={},C={})=>{const M={...w},I={...C};if(Q.textAlignment&&Q.textAlignment!=="left"){const Y={left:"start",center:"center",right:"end",justify:"justify"};M["fo:text-align"]=Y[Q.textAlignment]}const F=Q.backgroundColor&&Q.backgroundColor!=="default"?B.options.colors[Q.backgroundColor].background:void 0;if(F&&(M["fo:background-color"]=F),Q.textColor&&Q.textColor!=="default"){const Y=B.options.colors[Q.textColor].text;I["fo:color"]=Y}return!F&&!Object.keys(E).length&&!Object.keys(M).length&&!Object.keys(I).length?g||"Standard":B.registerStyle(Y=>A.jsxs("style:style",{"style:family":"paragraph","style:name":Y,"style:parent-style-name":g,...E,children:[F&&A.jsx("loext:graphic-properties",{"draw:fill":"solid","draw:fill-color":F}),Object.keys(M).length>0&&A.jsx("style:paragraph-properties",{...M}),Object.keys(I).length>0&&A.jsx("style:text-properties",{...I})]}))},a=B=>{const Q=new Map;return g=>{const E=`${g.props.backgroundColor}-${g.props.textColor}-${g.props.textAlignment}`;if(Q.has(E))return Q.get(E);const w=B.registerStyle(C=>A.jsx("style:style",{"style:family":"table-cell","style:name":C,children:A.jsx("style:table-cell-properties",{"fo:border":"0.5pt solid #000000","style:writing-mode":"lr-tb","fo:padding-top":"0in","fo:padding-left":"0.075in","fo:padding-bottom":"0in","fo:padding-right":"0.075in","fo:background-color":g.props.backgroundColor!=="default"&&g.props.backgroundColor?B.options.colors[g.props.backgroundColor].background:void 0,"fo:color":g.props.textColor!=="default"&&g.props.textColor?B.options.colors[g.props.textColor].text:void 0})}));return Q.set(E,w),w}},y=(B,Q)=>B.registerStyle(E=>A.jsx("style:style",{"style:family":"table","style:name":E,children:A.jsx("style:table-properties",{"table:align":"left","style:writing-mode":"lr-tb","style:width":`${Q.width}pt`})})),H=(B,Q)=>Q<=0?B:A.jsx("text:list",{children:A.jsx("text:list-item",{children:H(B,Q-1)})}),h={blockMapping:{paragraph:(B,Q,g)=>{const E=G(Q,B.props);return A.jsxs("text:p",{"text:style-name":E,children:[J(g),Q.transformInlineContent(B.content)]})},heading:(B,Q,g)=>{const w=G(Q,B.props,"Heading_20_"+B.props.level);return A.jsxs("text:h",{"text:outline-level":`${B.props.level}`,"text:style-name":w,children:[J(g),Q.transformInlineContent(B.content)]})},quote:(B,Q,g)=>{const w=G(Q,B.props,"Standard",{},{"fo:border-left":"2pt solid #7D797A","fo:padding-left":"0.25in"},{"fo:color":"#7D797A"});return A.jsxs("text:p",{"text:style-name":w,children:[J(g),Q.transformInlineContent(B.content)]})},toggleListItem:(B,Q)=>A.jsxs("text:p",{"text:style-name":"Standard",children:["> ",Q.transformInlineContent(B.content)]}),bulletListItem:(B,Q,g)=>{const E=G(Q,B.props,"Standard",{"style:list-style-name":"WWNum1"});return A.jsx("text:list",{"text:style-name":"WWNum1",children:A.jsx("text:list-item",{children:H(A.jsx("text:p",{"text:style-name":E,children:Q.transformInlineContent(B.content)}),g)})})},numberedListItem:(B,Q,g,E)=>{const w=G(Q,B.props),C=(E||0)>1?"true":"false";return A.jsx("text:list",{"text:style-name":"No_20_List","text:continue-numbering":C,children:A.jsx("text:list-item",{...C==="false"&&{"text:start-value":B.props.start},children:H(A.jsx("text:p",{"text:style-name":w,children:Q.transformInlineContent(B.content)}),g)})})},checkListItem:(B,Q)=>A.jsxs("text:p",{"text:style-name":"Standard",children:[B.props.checked?"☒ ":"☐ ",Q.transformInlineContent(B.content)]}),pageBreak:async()=>A.jsx("text:p",{"text:style-name":"PageBreak"}),divider:(B,Q)=>{const g=G(Q,B.props,"Standard",{},{"fo:border-top":"1pt solid #cccccc","fo:margin-top":"11pt","fo:margin-bottom":"12pt","fo:padding-top":"0pt","fo:padding-bottom":"0pt"});return A.jsx("text:p",{"text:style-name":g})},column:(B,Q,g,E,w)=>{const M=Q.registerStyle(I=>A.jsx("style:style",{"style:name":I,"style:family":"table-cell",children:A.jsx("style:table-cell-properties",{"style:writing-mode":"lr-tb","fo:border":"none","fo:padding-top":"0in","fo:padding-left":"0.075in","fo:padding-bottom":"0in","fo:padding-right":"0.075in"})}));return A.jsx("table:table-cell",{"table:style-name":M,children:w})},columnList:(B,Q,g,E,w)=>{const C=B,M=Q,I=M.registerStyle(F=>A.jsx("style:style",{"style:name":F,"style:family":"table",children:A.jsx("style:table-properties",{"table:align":"margins","style:writing-mode":"lr-tb"})}));return A.jsxs("table:table",{"table:name":B.id,"table:style-name":I,children:[(C.children||[]).map((F,Y)=>{const l=M.registerStyle(c=>A.jsx("style:style",{"style:name":c,"style:family":"table-column",children:A.jsx("style:table-column-properties",{"style:rel-column-width":`${F.props.width*100}*`})}));return A.jsx("table:table-column",{"table:style-name":l},Y)}),A.jsx("table:table-row",{children:w})]})},image:async(B,Q)=>{const g=Q,{path:E,mimeType:w,...C}=await g.registerPicture(B.props.url),M=G(Q,B.props),I=B.props.previewWidth||C.width,F=C.height/C.width*I,Y=20,l=A.jsxs("text:p",{"text:style-name":B.props.caption?"Caption":M,children:[A.jsx("draw:frame",{"draw:style-name":"Frame","style:rel-height":"scale","svg:width":`${I}px`,"svg:height":`${F}px`,"style:rel-width":B.props.caption?"100%":`${I}px`,...!B.props.caption&&{"text:anchor-type":"as-char"},children:A.jsx("draw:image",{"xlink:type":"simple","xlink:show":"embed","xlink:actuate":"onLoad","xlink:href":E,"draw:mime-type":w})}),A.jsx("text:line-break",{}),A.jsx("text:span",{"text:style-name":"Caption",children:B.props.caption})]});return B.props.caption?A.jsx("text:p",{"text:style-name":M,children:A.jsx("draw:frame",{"draw:style-name":"Frame","style:rel-height":"scale","style:rel-width":`${I}px`,"svg:width":`${I}px`,"svg:height":`${F+Y}px`,"text:anchor-type":"as-char",children:A.jsx("draw:text-box",{children:l})})}):l},table:(B,Q)=>{var F;const w=(B.content.columnWidths.reduce((Y,l)=>(Y||0)+(l||120),0)||0)*.75,C=Q,M=a(C),I=y(C,{width:w});return A.jsxs("table:table",{"table:name":B.id,"table:style-name":I,children:[(F=B.content.rows[0])==null?void 0:F.cells.map((Y,l)=>{const i=(B.content.columnWidths[l]||120)*.75,U=C.registerStyle(n=>A.jsx("style:style",{"style:name":n,"style:family":"table-column",children:A.jsx("style:table-column-properties",{"style:column-width":`${i}pt`})}));return A.jsx("table:table-column",{"table:style-name":U},l)}),B.content.rows.map((Y,l)=>A.jsx("table:table-row",{children:Y.cells.map((c,i)=>{const U=t.mapTableCell(c);return A.jsx("table:table-cell",{"table:style-name":M(U),"office:value-type":"string","style:text-align-source":"fix","style:paragraph-properties-text-align":U.props.textAlignment,children:A.jsx("text:p",{"text:style-name":"Standard",children:Q.transformInlineContent(U.content)})},`${l}-${i}`)})},l))]})},codeBlock:B=>{var g;const Q=((g=B.content[0])==null?void 0:g.text)||"";return A.jsxs("text:p",{"text:style-name":"Codeblock",children:[...Q.split(`
|
|
2
2
|
`).map((E,w)=>A.jsxs(A.Fragment,{children:[w!==0&&A.jsx("text:line-break",{}),E]}))]})},file:async B=>A.jsxs(A.Fragment,{children:[A.jsx("text:p",{"style:style-name":"Standard",children:B.props.url?A.jsx("text:a",{"xlink:type":"simple","text:style-name":"Internet_20_link","office:target-frame-name":"_top","xlink:show":"replace","xlink:href":B.props.url,children:A.jsx("text:span",{"text:style-name":"Internet_20_link",children:"Open file"})}):"Open file"}),B.props.caption&&A.jsx("text:p",{"text:style-name":"Caption",children:B.props.caption})]}),video:B=>A.jsxs(A.Fragment,{children:[A.jsx("text:p",{"style:style-name":"Standard",children:A.jsx("text:a",{"xlink:type":"simple","text:style-name":"Internet_20_link","office:target-frame-name":"_top","xlink:show":"replace","xlink:href":B.props.url,children:A.jsx("text:span",{"text:style-name":"Internet_20_link",children:"Open video"})})}),B.props.caption&&A.jsx("text:p",{"text:style-name":"Caption",children:B.props.caption})]}),audio:B=>A.jsxs(A.Fragment,{children:[A.jsx("text:p",{"style:style-name":"Standard",children:A.jsx("text:a",{"xlink:type":"simple","text:style-name":"Internet_20_link","office:target-frame-name":"_top","xlink:show":"replace","xlink:href":B.props.url,children:A.jsx("text:span",{"text:style-name":"Internet_20_link",children:"Open audio"})})}),B.props.caption&&A.jsx("text:p",{"text:style-name":"Caption",children:B.props.caption})]})},inlineContentMapping:{link:(B,Q)=>{const g=B.content.map(E=>Q.transformStyledText(E));return A.jsx("text:a",{"xlink:type":"simple","text:style-name":"Internet_20_link","office:target-frame-name":"_top","xlink:show":"replace","xlink:href":B.href,children:g})},text:(B,Q)=>Q.transformStyledText(B)},styleMapping:{bold:B=>B?{"fo:font-weight":"bold"}:{},italic:B=>B?{"fo:font-style":"italic"}:{},underline:B=>B?{"style:text-underline-style":"solid"}:{},strike:B=>B?{"style:text-line-through-style":"solid"}:{},textColor:(B,Q)=>B?{"fo:color":Q.options.colors[B].text}:{},backgroundColor:(B,Q)=>B?{"fo:background-color":Q.options.colors[B].background}:{},code:B=>B?{"style:font-name":"Courier New"}:{}}};async function m(B){{const Q=B.default;return await(await fetch(Q)).arrayBuffer()}}async function W(B){if(typeof window<"u"){const Q=await createImageBitmap(B),{width:g,height:E}=Q;return Q.close(),{width:g,height:E}}else{const Q=(await import("image-meta")).imageMeta,g=new Uint8Array(await B.arrayBuffer()),E=Q(g);if(!E.width||!E.height)throw new Error("Image dimensions not found");return{width:E.width,height:E.height}}}const j=`<?xml version="1.0" encoding="UTF-8"?>
|
|
3
3
|
<office:document-styles xmlns:css3t="http://www.w3.org/TR/css3-text/"
|
|
4
4
|
xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:xhtml="http://www.w3.org/1999/xhtml"
|