@blocknote/xl-odt-exporter 0.48.0 → 0.49.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.
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@blocknote/core`),require(`react/jsx-runtime`),require(`@zip.js/zip.js`),require(`react-dom/server`)):typeof define==`function`&&define.amd?define([`exports`,`@blocknote/core`,`react/jsx-runtime`,`@zip.js/zip.js`,`react-dom/server`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e[`blocknote-xl-odt-exporter`]={},e._blocknote_core,e.react_jsx_runtime,e._zip_js_zip_js,e.react_dom_server))})(this,function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var a=Object.defineProperty,o=(e,t)=>()=>(e&&(t=e(e=0)),t),s=(e,t)=>{let n={};for(var r in e)a(n,r,{get:e[r],enumerable:!0});return t||a(n,Symbol.toStringTag,{value:`Module`}),n},c=e=>Array.from({length:e},()=>(0,n.jsx)(`text:tab`,{})),l=(e,t,r=`Standard`,i={},a={},o={})=>{let s={...a},c={...o};t.textAlignment&&t.textAlignment!==`left`&&(s[`fo:text-align`]={left:`start`,center:`center`,right:`end`,justify:`justify`}[t.textAlignment]);let l=t.backgroundColor&&t.backgroundColor!==`default`?e.options.colors[t.backgroundColor]?.background:void 0;return l&&(s[`fo:background-color`]=l),t.textColor&&t.textColor!==`default`&&(c[`fo:color`]=e.options.colors[t.textColor]?.text??t.textColor),!l&&!Object.keys(i).length&&!Object.keys(s).length&&!Object.keys(c).length?r||`Standard`:e.registerStyle(e=>(0,n.jsxs)(`style:style`,{"style:family":`paragraph`,"style:name":e,"style:parent-style-name":r,...i,children:[l&&(0,n.jsx)(`loext:graphic-properties`,{"draw:fill":`solid`,"draw:fill-color":l}),Object.keys(s).length>0&&(0,n.jsx)(`style:paragraph-properties`,{...s}),Object.keys(c).length>0&&(0,n.jsx)(`style:text-properties`,{...c})]}))},u=e=>{let t=new Map;return r=>{let i=`${r.props.backgroundColor}-${r.props.textColor}-${r.props.textAlignment}`;if(t.has(i))return t.get(i);let a=e.registerStyle(t=>(0,n.jsx)(`style:style`,{"style:family":`table-cell`,"style:name":t,children:(0,n.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":r.props.backgroundColor!==`default`&&r.props.backgroundColor?e.options.colors?.[r.props.backgroundColor]?.background:void 0,"fo:color":r.props.textColor!==`default`&&r.props.textColor?e.options.colors[r.props.textColor]?.text:void 0})}));return t.set(i,a),a}},d=(e,t)=>e.registerStyle(e=>(0,n.jsx)(`style:style`,{"style:family":`table`,"style:name":e,children:(0,n.jsx)(`style:table-properties`,{"table:align":`left`,"style:writing-mode":`lr-tb`,"style:width":`${t.width}pt`})})),f=(e,t)=>t<=0?e:(0,n.jsx)(`text:list`,{children:(0,n.jsx)(`text:list-item`,{children:f(e,t-1)})}),p={blockMapping:{paragraph:(e,t,r)=>
|
|
2
|
-
`).map((e,t)=>(0,n.jsxs)(n.Fragment,{children:[t!==0&&(0,n.jsx)(`text:line-break`,{}),e]}))]})
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@blocknote/core`),require(`react/jsx-runtime`),require(`@zip.js/zip.js`),require(`react-dom/server`)):typeof define==`function`&&define.amd?define([`exports`,`@blocknote/core`,`react/jsx-runtime`,`@zip.js/zip.js`,`react-dom/server`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e[`blocknote-xl-odt-exporter`]={},e._blocknote_core,e.react_jsx_runtime,e._zip_js_zip_js,e.react_dom_server))})(this,function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var a=Object.defineProperty,o=(e,t)=>()=>(e&&(t=e(e=0)),t),s=(e,t)=>{let n={};for(var r in e)a(n,r,{get:e[r],enumerable:!0});return t||a(n,Symbol.toStringTag,{value:`Module`}),n},c=e=>Array.from({length:e},()=>(0,n.jsx)(`text:tab`,{})),l=(e,t,r=`Standard`,i={},a={},o={})=>{let s={...a},c={...o};t.textAlignment&&t.textAlignment!==`left`&&(s[`fo:text-align`]={left:`start`,center:`center`,right:`end`,justify:`justify`}[t.textAlignment]);let l=t.backgroundColor&&t.backgroundColor!==`default`?e.options.colors[t.backgroundColor]?.background:void 0;return l&&(s[`fo:background-color`]=l),t.textColor&&t.textColor!==`default`&&(c[`fo:color`]=e.options.colors[t.textColor]?.text??t.textColor),!l&&!Object.keys(i).length&&!Object.keys(s).length&&!Object.keys(c).length?r||`Standard`:e.registerStyle(e=>(0,n.jsxs)(`style:style`,{"style:family":`paragraph`,"style:name":e,"style:parent-style-name":r,...i,children:[l&&(0,n.jsx)(`loext:graphic-properties`,{"draw:fill":`solid`,"draw:fill-color":l}),Object.keys(s).length>0&&(0,n.jsx)(`style:paragraph-properties`,{...s}),Object.keys(c).length>0&&(0,n.jsx)(`style:text-properties`,{...c})]}))},u=e=>{let t=new Map;return r=>{let i=`${r.props.backgroundColor}-${r.props.textColor}-${r.props.textAlignment}`;if(t.has(i))return t.get(i);let a=e.registerStyle(t=>(0,n.jsx)(`style:style`,{"style:family":`table-cell`,"style:name":t,children:(0,n.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":r.props.backgroundColor!==`default`&&r.props.backgroundColor?e.options.colors?.[r.props.backgroundColor]?.background:void 0,"fo:color":r.props.textColor!==`default`&&r.props.textColor?e.options.colors[r.props.textColor]?.text:void 0})}));return t.set(i,a),a}},d=(e,t)=>e.registerStyle(e=>(0,n.jsx)(`style:style`,{"style:family":`table`,"style:name":e,children:(0,n.jsx)(`style:table-properties`,{"table:align":`left`,"style:writing-mode":`lr-tb`,"style:width":`${t.width}pt`})})),f=(e,t)=>t<=0?e:(0,n.jsx)(`text:list`,{children:(0,n.jsx)(`text:list-item`,{children:f(e,t-1)})}),p={blockMapping:{paragraph:(e,t,r)=>(0,n.jsxs)(`text:p`,{"text:style-name":l(t,e.props),children:[c(r),t.transformInlineContent(e.content)]}),heading:(e,t,r)=>{let i=l(t,e.props,`Heading_20_`+e.props.level);return(0,n.jsxs)(`text:h`,{"text:outline-level":`${e.props.level}`,"text:style-name":i,children:[c(r),t.transformInlineContent(e.content)]})},quote:(e,t,r)=>(0,n.jsxs)(`text:p`,{"text:style-name":l(t,e.props,`Standard`,{},{"fo:border-left":`2pt solid #7D797A`,"fo:padding-left":`0.25in`},{"fo:color":`#7D797A`}),children:[c(r),t.transformInlineContent(e.content)]}),toggleListItem:(e,t)=>(0,n.jsxs)(`text:p`,{"text:style-name":`Standard`,children:[`> `,t.transformInlineContent(e.content)]}),bulletListItem:(e,t,r)=>(0,n.jsx)(`text:list`,{"text:style-name":`WWNum1`,children:(0,n.jsx)(`text:list-item`,{children:f((0,n.jsx)(`text:p`,{"text:style-name":l(t,e.props,`Standard`,{"style:list-style-name":`WWNum1`}),children:t.transformInlineContent(e.content)}),r)})}),numberedListItem:(e,t,r,i)=>{let a=l(t,e.props),o=(i||0)>1?`true`:`false`;return(0,n.jsx)(`text:list`,{"text:style-name":`No_20_List`,"text:continue-numbering":o,children:(0,n.jsx)(`text:list-item`,{...o===`false`&&{"text:start-value":e.props.start},children:f((0,n.jsx)(`text:p`,{"text:style-name":a,children:t.transformInlineContent(e.content)}),r)})})},checkListItem:(e,t)=>(0,n.jsxs)(`text:p`,{"text:style-name":`Standard`,children:[e.props.checked?`☒ `:`☐ `,t.transformInlineContent(e.content)]}),pageBreak:async()=>(0,n.jsx)(`text:p`,{"text:style-name":`PageBreak`}),divider:(e,t)=>(0,n.jsx)(`text:p`,{"text:style-name":l(t,e.props,`Standard`,{},{"fo:border-top":`1pt solid #cccccc`,"fo:margin-top":`11pt`,"fo:margin-bottom":`12pt`,"fo:padding-top":`0pt`,"fo:padding-bottom":`0pt`})}),column:(e,t,r,i,a)=>(0,n.jsx)(`table:table-cell`,{"table:style-name":t.registerStyle(e=>(0,n.jsx)(`style:style`,{"style:name":e,"style:family":`table-cell`,children:(0,n.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`})})),children:a}),columnList:(e,t,r,i,a)=>{let o=e,s=t,c=s.registerStyle(e=>(0,n.jsx)(`style:style`,{"style:name":e,"style:family":`table`,children:(0,n.jsx)(`style:table-properties`,{"table:align":`margins`,"style:writing-mode":`lr-tb`})}));return(0,n.jsxs)(`table:table`,{"table:name":e.id,"table:style-name":c,children:[(o.children||[]).map((e,t)=>(0,n.jsx)(`table:table-column`,{"table:style-name":s.registerStyle(t=>(0,n.jsx)(`style:style`,{"style:name":t,"style:family":`table-column`,children:(0,n.jsx)(`style:table-column-properties`,{"style:rel-column-width":`${e.props.width*100}*`})}))},t)),(0,n.jsx)(`table:table-row`,{children:a})]})},image:async(e,t)=>{let{path:r,mimeType:i,...a}=await t.registerPicture(e.props.url),o=l(t,e.props),s=e.props.previewWidth||a.width,c=a.height/a.width*s,u=(0,n.jsxs)(`text:p`,{"text:style-name":e.props.caption?`Caption`:o,children:[(0,n.jsx)(`draw:frame`,{"draw:style-name":`Frame`,"style:rel-height":`scale`,"svg:width":`${s}px`,"svg:height":`${c}px`,"style:rel-width":e.props.caption?`100%`:`${s}px`,...!e.props.caption&&{"text:anchor-type":`as-char`},children:(0,n.jsx)(`draw:image`,{"xlink:type":`simple`,"xlink:show":`embed`,"xlink:actuate":`onLoad`,"xlink:href":r,"draw:mime-type":i})}),(0,n.jsx)(`text:line-break`,{}),(0,n.jsx)(`text:span`,{"text:style-name":`Caption`,children:e.props.caption})]});return e.props.caption?(0,n.jsx)(`text:p`,{"text:style-name":o,children:(0,n.jsx)(`draw:frame`,{"draw:style-name":`Frame`,"style:rel-height":`scale`,"style:rel-width":`${s}px`,"svg:width":`${s}px`,"svg:height":`${c+20}px`,"text:anchor-type":`as-char`,children:(0,n.jsx)(`draw:text-box`,{children:u})})}):u},table:(e,r)=>{let i=(e.content.columnWidths.reduce((e,t)=>(e||0)+(t||120),0)||0)*.75,a=r,o=u(a),s=d(a,{width:i});return(0,n.jsxs)(`table:table`,{"table:name":e.id,"table:style-name":s,children:[e.content.rows[0]?.cells.map((t,r)=>{let i=(e.content.columnWidths[r]||120)*.75;return(0,n.jsx)(`table:table-column`,{"table:style-name":a.registerStyle(e=>(0,n.jsx)(`style:style`,{"style:name":e,"style:family":`table-column`,children:(0,n.jsx)(`style:table-column-properties`,{"style:column-width":`${i}pt`})}))},r)}),e.content.rows.map((e,i)=>(0,n.jsx)(`table:table-row`,{children:e.cells.map((e,a)=>{let s=(0,t.mapTableCell)(e);return(0,n.jsx)(`table:table-cell`,{"table:style-name":o(s),"office:value-type":`string`,"style:text-align-source":`fix`,"style:paragraph-properties-text-align":s.props.textAlignment,children:(0,n.jsx)(`text:p`,{"text:style-name":`Standard`,children:r.transformInlineContent(s.content)})},`${i}-${a}`)})},i))]})},codeBlock:e=>(0,n.jsx)(`text:p`,{"text:style-name":`Codeblock`,children:[...(e.content[0]?.text||``).split(`
|
|
2
|
+
`).map((e,t)=>(0,n.jsxs)(n.Fragment,{children:[t!==0&&(0,n.jsx)(`text:line-break`,{}),e]}))]}),file:async e=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`text:p`,{"style:style-name":`Standard`,children:e.props.url?(0,n.jsx)(`text:a`,{"xlink:type":`simple`,"text:style-name":`Internet_20_link`,"office:target-frame-name":`_top`,"xlink:show":`replace`,"xlink:href":e.props.url,children:(0,n.jsx)(`text:span`,{"text:style-name":`Internet_20_link`,children:`Open file`})}):`Open file`}),e.props.caption&&(0,n.jsx)(`text:p`,{"text:style-name":`Caption`,children:e.props.caption})]}),video:e=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`text:p`,{"style:style-name":`Standard`,children:(0,n.jsx)(`text:a`,{"xlink:type":`simple`,"text:style-name":`Internet_20_link`,"office:target-frame-name":`_top`,"xlink:show":`replace`,"xlink:href":e.props.url,children:(0,n.jsx)(`text:span`,{"text:style-name":`Internet_20_link`,children:`Open video`})})}),e.props.caption&&(0,n.jsx)(`text:p`,{"text:style-name":`Caption`,children:e.props.caption})]}),audio:e=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`text:p`,{"style:style-name":`Standard`,children:(0,n.jsx)(`text:a`,{"xlink:type":`simple`,"text:style-name":`Internet_20_link`,"office:target-frame-name":`_top`,"xlink:show":`replace`,"xlink:href":e.props.url,children:(0,n.jsx)(`text:span`,{"text:style-name":`Internet_20_link`,children:`Open audio`})})}),e.props.caption&&(0,n.jsx)(`text:p`,{"text:style-name":`Caption`,children:e.props.caption})]})},inlineContentMapping:{link:(e,t)=>{let r=e.content.map(e=>t.transformStyledText(e));return(0,n.jsx)(`text:a`,{"xlink:type":`simple`,"text:style-name":`Internet_20_link`,"office:target-frame-name":`_top`,"xlink:show":`replace`,"xlink:href":e.href,children:r})},text:(e,t)=>t.transformStyledText(e)},styleMapping:{bold:e=>e?{"fo:font-weight":`bold`}:{},italic:e=>e?{"fo:font-style":`italic`}:{},underline:e=>e?{"style:text-underline-style":`solid`}:{},strike:e=>e?{"style:text-line-through-style":`solid`}:{},textColor:(e,t)=>{if(!e)return{};let n=t.options.colors[e]?.text;return n?{"fo:color":n}:{}},backgroundColor:(e,t)=>{if(!e)return{};let n=t.options.colors[e]?.background;return n?{"fo:background-color":n}:{}},code:e=>e?{"style:font-name":`Courier New`}:{}}};async function m(e){{let t=e.default;return await(await fetch(t)).arrayBuffer()}}async function h(e){if(typeof window<`u`){let t=await createImageBitmap(e),{width:n,height:r}=t;return t.close(),{width:n,height:r}}else{let t=(await import(`image-meta`)).imageMeta,n=t(new Uint8Array(await e.arrayBuffer()));if(!n.width||!n.height)throw Error(`Image dimensions not found`);return{width:n.width,height:n.height}}}var g=`<?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"
|
|
5
5
|
xmlns:dom="http://www.w3.org/2001/xml-events"
|