@blocknote/xl-pdf-exporter 0.24.2 → 0.25.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/GeistMono-Regular--NrcstcO.cjs +2 -0
- package/dist/GeistMono-Regular--NrcstcO.cjs.map +1 -0
- package/dist/Inter_18pt-Bold-yKiK3cOU.cjs +2 -0
- package/dist/Inter_18pt-Bold-yKiK3cOU.cjs.map +1 -0
- package/dist/Inter_18pt-BoldItalic-TUYlzxLL.cjs +2 -0
- package/dist/Inter_18pt-BoldItalic-TUYlzxLL.cjs.map +1 -0
- package/dist/Inter_18pt-Italic-B-14jOMa.cjs +2 -0
- package/dist/Inter_18pt-Italic-B-14jOMa.cjs.map +1 -0
- package/dist/Inter_18pt-Regular-CCMUw8TC.cjs +2 -0
- package/dist/Inter_18pt-Regular-CCMUw8TC.cjs.map +1 -0
- package/dist/blocknote-xl-pdf-exporter.cjs +3 -0
- package/dist/blocknote-xl-pdf-exporter.cjs.map +1 -0
- package/dist/blocknote-xl-pdf-exporter.js +148 -134
- package/dist/blocknote-xl-pdf-exporter.js.map +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +6 -6
- package/src/pdf/__snapshots__/example.jsx +5 -1
- package/src/pdf/__snapshots__/exampleWithHeaderAndFooter.jsx +5 -1
- package/src/pdf/pdfExporter.tsx +0 -1
- package/src/pdf/util/table/Table.tsx +63 -26
- package/dist/blocknote-xl-pdf-exporter.umd.cjs +0 -3
- package/dist/blocknote-xl-pdf-exporter.umd.cjs.map +0 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";var v=Object.defineProperty;var T=(e,o,t)=>o in e?v(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t;var p=(e,o,t)=>T(e,typeof o!="symbol"?o+"":o,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),r=require("@react-pdf/renderer"),w=require("@blocknote/core"),P=.75,S=r.StyleSheet.create({listItem:{display:"flex",flexDirection:"row",gap:8*P,paddingRight:10},bullet:{fontFamily:""}}),E="•",M=n.jsx(r.Svg,{style:{marginTop:2},height:"12",viewBox:"0 -960 960 960",width:"12",fill:"undefined",children:n.jsx(r.Path,{d:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Z"})}),F=n.jsx(r.Svg,{style:{marginTop:2},height:"12",viewBox:"0 -960 960 960",width:"12",fill:"undefined",children:n.jsx(r.Path,{d:"m424-312 282-282-56-56-226 226-114-114-56 56 170 170ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z"})}),m=({listMarker:e,children:o,style:t})=>n.jsxs(r.View,{style:[S.listItem,t||{}],children:[n.jsx(r.View,{style:S.bullet,children:typeof e=="string"?n.jsx(r.Text,{children:e}):e}),o]}),b=.75,f=r.StyleSheet.create({tableContainer:{},row:{flexDirection:"row",flexWrap:"wrap",display:"flex"},cell:{paddingHorizontal:5*b,paddingTop:3*b,borderLeft:"1px solid #ddd",borderTop:"1px solid #ddd",wordWrap:"break-word",whiteSpace:"pre-wrap"},headerCell:{fontWeight:"bold"},bottomCell:{borderBottom:"1px solid #ddd"},rightCell:{borderRight:"1px solid #ddd"}}),I=e=>{const o=new Array(e.data.headerRows??0).fill(!0),t=new Array(e.data.headerCols??0).fill(!0);return n.jsx(r.View,{style:f.tableContainer,wrap:!1,children:e.data.rows.map((i,s)=>n.jsx(r.View,{style:[f.row,s===e.data.rows.length-1?f.bottomCell:{}],children:i.cells.map((c,l)=>{const a=w.mapTableCell(c),u=o[s],g=t[l];return n.jsx(r.View,{style:[f.cell,u||g?f.headerCell:{},l===i.cells.length-1?f.rightCell:{},e.data.columnWidths[l]?{width:e.data.columnWidths[l]}:{flex:1},{color:a.props.textColor==="default"?void 0:e.transformer.options.colors[a.props.textColor].text,backgroundColor:a.props.backgroundColor==="default"?void 0:e.transformer.options.colors[a.props.backgroundColor].background,textAlign:a.props.textAlignment}],children:e.transformer.transformInlineContent(a.content)},l)})},s))})},d=.75,j=16,_={paragraph:(e,o)=>n.jsx(r.Text,{children:o.transformInlineContent(e.content)}),bulletListItem:(e,o)=>n.jsx(m,{listMarker:E,children:n.jsx(r.Text,{children:o.transformInlineContent(e.content)})}),numberedListItem:(e,o,t,i)=>n.jsx(m,{listMarker:`${i}.`,children:n.jsx(r.Text,{children:o.transformInlineContent(e.content)})}),checkListItem:(e,o)=>n.jsx(m,{listMarker:e.props.checked?F:M,children:n.jsx(r.Text,{children:o.transformInlineContent(e.content)})}),heading:(e,o)=>{const t=e.props.level===1?2:e.props.level===2?1.5:1.17;return n.jsx(r.Text,{style:{fontSize:t*j*d,fontWeight:700},children:o.transformInlineContent(e.content)})},codeBlock:e=>{var i;const t=(((i=e.content[0])==null?void 0:i.text)||"").split(`
|
|
2
|
+
`).map((s,c)=>{var a;const l=((a=s.match(/^\s*/))==null?void 0:a[0].length)||0;return n.jsx(r.Text,{style:{marginLeft:l*9.5*d},children:s.trimStart()||n.jsx(n.Fragment,{children:" "})},`line_${c}`)});return n.jsx(r.View,{wrap:!1,style:{padding:24*d,backgroundColor:"#161616",color:"#ffffff",lineHeight:1.25,fontSize:j*d,fontFamily:"GeistMono"},children:t})},pageBreak:()=>n.jsx(r.View,{break:!0}),audio:(e,o)=>n.jsxs(r.View,{wrap:!1,children:[y(e.props,"Open audio file",n.jsx(r.Svg,{height:14,width:14,viewBox:"0 0 24 24",fill:"currentColor",children:n.jsx(r.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"})})),x(e.props)]}),video:(e,o)=>n.jsxs(r.View,{wrap:!1,children:[y(e.props,"Open video file",n.jsx(r.Svg,{height:14,width:14,viewBox:"0 0 24 24",fill:"currentColor",children:n.jsx(r.Path,{d:"M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z"})})),x(e.props)]}),file:(e,o)=>n.jsxs(r.View,{wrap:!1,children:[y(e.props,"Open file",n.jsx(r.Svg,{height:16,width:16,viewBox:"0 0 24 24",fill:"currentColor",children:n.jsx(r.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"})})),x(e.props)]}),image:async(e,o)=>n.jsxs(r.View,{wrap:!1,children:[n.jsx(r.Image,{src:await o.resolveFile(e.props.url),style:{width:e.props.previewWidth*d}}),x(e.props)]}),table:(e,o)=>n.jsx(I,{data:e.content,transformer:o})};function y(e,o,t,i){return n.jsx(r.Link,{src:e.url,children:n.jsxs(r.View,{style:{display:"flex",gap:8*.75,flexDirection:"row"},children:[t,n.jsx(r.Text,{children:e.name||o})]})})}function x(e,o){if(e.caption)return n.jsx(r.Text,{style:{width:e.previewWidth?e.previewWidth*d:void 0,fontSize:j*.8*d},children:e.caption})}const k={link:(e,o)=>n.jsx(r.Link,{href:e.href,children:e.content.map(t=>o.transformStyledText(t))}),text:(e,o)=>o.transformStyledText(e)},R={bold:e=>e?{fontWeight:"bold"}:{},italic:e=>e?{fontStyle:"italic"}:{},underline:e=>e?{textDecoration:"underline"}:{},strike:e=>e?{textDecoration:"line-through"}:{},backgroundColor:(e,o)=>e?{backgroundColor:o.options.colors[e].background}:{},textColor:(e,o)=>e?{color:o.options.colors[e].text}:{},code:e=>e?{fontFamily:"GeistMono"}:{}},D={blockMapping:_,inlineContentMapping:k,styleMapping:R};async function L(e){return"https://corsproxy.api.blocknotejs.org/corsproxy/?url="+encodeURIComponent(e)}var H={BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};async function B(e,o){if(H.NODE_ENV==="test"){const i=(await Z(e)).toString("base64");return`data:${o};base64,${i}`}else return e.default}async function h(e){return B(e,"font/ttf")}async function Z(e){if(H.NODE_ENV==="test"){const o=require("fs");let t=e.default;return t.startsWith("/@fs/")&&(t=t.substring(4)),o.readFileSync(t)}else{const o=e.default;return await(await fetch(o)).arrayBuffer()}}const V=16,C=.75;class O extends w.Exporter{constructor(t,i,s){const l={...{emojiSource:{format:"png",url:"https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/"},resolveFileUrl:L,colors:w.COLORS_DEFAULT},...s};super(t,i,l);p(this,"fontsRegistered",!1);p(this,"styles",r.StyleSheet.create({page:{paddingTop:35,paddingBottom:65,paddingHorizontal:35,fontFamily:"Inter",fontSize:V*C,lineHeight:1.5},block:{},blockChildren:{},header:{},footer:{position:"absolute"}}));p(this,"options");this.schema=t,this.options=l}transformStyledText(t){const i=this.mapStyles(t.styles),s=Object.assign({},...i);return n.jsx(r.Text,{style:s,children:t.text})}async transformBlocks(t,i=0){const s=[];let c=0;for(const l of t){l.type==="numberedListItem"?c++:c=0;const a=await this.transformBlocks(l.children,i+1),u=await this.mapBlock(l,i,c);if(l.type==="pageBreak"){s.push(u);continue}const g=this.blocknoteDefaultPropsToReactPDFStyle(l.props);s.push(n.jsxs(n.Fragment,{children:[n.jsx(r.View,{style:{paddingVertical:3*C,...this.styles.block,...g},children:u}),a.length>0&&n.jsx(r.View,{style:{marginLeft:V*1.5*C,...this.styles.blockChildren},children:a})]}))}return s}async registerFonts(){if(this.fontsRegistered)return;this.options.emojiSource&&r.Font.registerEmojiSource(this.options.emojiSource);let t=await h(await Promise.resolve().then(()=>require("./Inter_18pt-Regular-CCMUw8TC.cjs")));r.Font.register({family:"Inter",src:t}),t=await h(await Promise.resolve().then(()=>require("./Inter_18pt-Italic-B-14jOMa.cjs"))),r.Font.register({family:"Inter",fontStyle:"italic",src:t}),t=await h(await Promise.resolve().then(()=>require("./Inter_18pt-Bold-yKiK3cOU.cjs"))),r.Font.register({family:"Inter",src:t,fontWeight:"bold"}),t=await h(await Promise.resolve().then(()=>require("./Inter_18pt-BoldItalic-TUYlzxLL.cjs"))),r.Font.register({family:"Inter",fontStyle:"italic",src:t,fontWeight:"bold"}),t=await h(await Promise.resolve().then(()=>require("./GeistMono-Regular--NrcstcO.cjs"))),r.Font.register({family:"GeistMono",src:t}),this.fontsRegistered=!0}async toReactPDFDocument(t,i={}){return await this.registerFonts(),n.jsx(r.Document,{children:n.jsxs(r.Page,{dpi:100,size:"A4",style:this.styles.page,children:[i.header&&n.jsx(r.View,{fixed:!0,style:this.styles.header,children:i.header}),await this.transformBlocks(t),i.footer&&n.jsx(r.View,{fixed:!0,style:[{left:this.styles.page.paddingHorizontal||0,bottom:(this.styles.page.paddingBottom||0)/2,right:this.styles.page.paddingHorizontal||0},this.styles.footer],children:i.footer})]})})}blocknoteDefaultPropsToReactPDFStyle(t){return{textAlign:t.textAlignment,backgroundColor:t.backgroundColor==="default"||!t.backgroundColor?void 0:this.options.colors[t.backgroundColor].background,color:t.textColor==="default"||!t.textColor?void 0:this.options.colors[t.textColor].text,alignItems:t.textAlignment==="right"?"flex-end":t.textAlignment==="center"?"center":void 0}}}exports.PDFExporter=O;exports.pdfDefaultSchemaMappings=D;
|
|
3
|
+
//# sourceMappingURL=blocknote-xl-pdf-exporter.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocknote-xl-pdf-exporter.cjs","sources":["../src/pdf/util/listItem.tsx","../src/pdf/util/table/Table.tsx","../src/pdf/defaultSchema/blocks.tsx","../src/pdf/defaultSchema/inlinecontent.tsx","../src/pdf/defaultSchema/styles.tsx","../src/pdf/defaultSchema/index.ts","../../../shared/api/corsProxy.ts","../../../shared/util/fileUtil.ts","../src/pdf/pdfExporter.tsx"],"sourcesContent":["import { Path, StyleSheet, Svg, Text, View } from \"@react-pdf/renderer\";\nimport { Style } from \"../types.js\";\n\n// https://github.com/diegomura/react-pdf/issues/134\n\nconst PIXELS_PER_POINT = 0.75;\n\nconst styles = StyleSheet.create({\n listItem: {\n display: \"flex\",\n flexDirection: \"row\",\n gap: 8 * PIXELS_PER_POINT,\n paddingRight: 10, // otherwise text overflows, seems like a react-pdf / yoga bug\n },\n bullet: {\n fontFamily: \"\", // TODO: add symbol font\n },\n});\n\nexport const BULLET_MARKER = \"\\u2022\";\n\n// https://fonts.google.com/icons?selected=Material+Symbols+Outlined:check_box_outline_blank:FILL@0;wght@400;GRAD@0;opsz@24&icon.size=24&icon.color=undefined\nexport const CHECK_MARKER_UNCHECKED = (\n <Svg\n style={{ marginTop: 2 }}\n height=\"12\"\n viewBox=\"0 -960 960 960\"\n width=\"12\"\n fill=\"undefined\">\n <Path d=\"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Z\" />\n </Svg>\n);\n\n// https://fonts.google.com/icons?selected=Material+Symbols+Outlined:check_box:FILL@0;wght@400;GRAD@0;opsz@24&icon.size=24&icon.color=undefined\nexport const CHECK_MARKER_CHECKED = (\n <Svg\n style={{ marginTop: 2 }}\n height=\"12\"\n viewBox=\"0 -960 960 960\"\n width=\"12\"\n fill=\"undefined\">\n <Path d=\"m424-312 282-282-56-56-226 226-114-114-56 56 170 170ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z\" />\n </Svg>\n);\n\nexport const ListItem = ({\n listMarker,\n children,\n style,\n}: {\n listMarker: string | React.ReactNode;\n children: React.ReactNode;\n style?: Style;\n}) => {\n return (\n <View style={[styles.listItem, style || {}]}>\n <View style={styles.bullet}>\n {/* <Svg width={2} height={2}>\n <Circle cx=\"1\" cy=\"1\" r=\"2\" fill=\"black\" />\n </Svg> */}\n {typeof listMarker === \"string\" ? (\n <Text>{listMarker}</Text>\n ) : (\n listMarker\n )}\n </View>\n {children}\n </View>\n );\n};\n","import {\n Exporter,\n InlineContentSchema,\n mapTableCell,\n StyleSchema,\n TableContent,\n} from \"@blocknote/core\";\nimport { StyleSheet, View } from \"@react-pdf/renderer\";\nconst PIXELS_PER_POINT = 0.75;\n\n// ( impossible?) to make tables with flex that don't have a fixed / 100% width?\n// we'd need to measure the width of every column manually\nconst styles = StyleSheet.create({\n tableContainer: {\n // width: \"100%\",\n },\n row: {\n flexDirection: \"row\",\n flexWrap: \"wrap\",\n // width: \"100%\",\n // justifyContent: \"space-between\",\n display: \"flex\",\n },\n cell: {\n paddingHorizontal: 5 * PIXELS_PER_POINT,\n paddingTop: 3 * PIXELS_PER_POINT,\n // paddingBottom: 1 * PIXELS_PER_POINT, should be 3px but looks odd, better with no padding Bottom\n borderLeft: \"1px solid #ddd\",\n borderTop: \"1px solid #ddd\",\n wordWrap: \"break-word\",\n whiteSpace: \"pre-wrap\",\n },\n headerCell: {\n fontWeight: \"bold\",\n },\n bottomCell: {\n borderBottom: \"1px solid #ddd\",\n },\n rightCell: {\n borderRight: \"1px solid #ddd\",\n },\n});\n\nexport const Table = (props: {\n data: TableContent<InlineContentSchema>;\n transformer: Exporter<\n any,\n InlineContentSchema,\n StyleSchema,\n any,\n any,\n any,\n any\n >;\n}) => {\n // If headerRows is 1, then the first row is a header row\n const headerRows = new Array(props.data.headerRows ?? 0).fill(true);\n // If headerCols is 1, then the first column is a header column\n const headerCols = new Array(props.data.headerCols ?? 0).fill(true);\n\n return (\n <View style={styles.tableContainer} wrap={false}>\n {props.data.rows.map((row, rowIndex) => (\n <View\n style={[\n styles.row,\n rowIndex === props.data.rows.length - 1 ? styles.bottomCell : {},\n ]}\n key={rowIndex}>\n {row.cells.map((c, colIndex) => {\n const cell = mapTableCell(c);\n\n const isHeaderRow = headerRows[rowIndex];\n const isHeaderCol = headerCols[colIndex];\n\n // TODO we need to support for colspan and rowspan, but at the moment are blocked by react-pdf\n return (\n <View\n style={[\n styles.cell,\n isHeaderRow || isHeaderCol ? styles.headerCell : {},\n colIndex === row.cells.length - 1 ? styles.rightCell : {},\n props.data.columnWidths[colIndex]\n ? { width: props.data.columnWidths[colIndex] }\n : { flex: 1 },\n {\n color:\n cell.props.textColor === \"default\"\n ? undefined\n : props.transformer.options.colors[\n cell.props\n .textColor as keyof typeof props.transformer.options.colors\n ].text,\n backgroundColor:\n cell.props.backgroundColor === \"default\"\n ? undefined\n : props.transformer.options.colors[\n cell.props\n .backgroundColor as keyof typeof props.transformer.options.colors\n ].background,\n textAlign: cell.props.textAlignment,\n },\n ]}\n key={colIndex}>\n {props.transformer.transformInlineContent(cell.content)}\n </View>\n );\n })}\n </View>\n ))}\n </View>\n );\n};\n","import {\n BlockMapping,\n DefaultBlockSchema,\n DefaultProps,\n pageBreakSchema,\n StyledText,\n} from \"@blocknote/core\";\nimport { Image, Link, Path, Svg, Text, View } from \"@react-pdf/renderer\";\nimport {\n BULLET_MARKER,\n CHECK_MARKER_CHECKED,\n CHECK_MARKER_UNCHECKED,\n ListItem,\n} from \"../util/listItem.js\";\nimport { Table } from \"../util/table/Table.js\";\n\nconst PIXELS_PER_POINT = 0.75;\nconst FONT_SIZE = 16;\n\nexport const pdfBlockMappingForDefaultSchema: BlockMapping<\n DefaultBlockSchema & typeof pageBreakSchema.blockSchema,\n any,\n any,\n React.ReactElement<Text>,\n React.ReactElement<Text> | React.ReactElement<Link>\n> = {\n paragraph: (block, exporter) => {\n // const style = blocknoteDefaultPropsToReactPDFStyle(block.props);\n return <Text>{exporter.transformInlineContent(block.content)}</Text>;\n },\n bulletListItem: (block, exporter) => {\n // const style = t(block.props);\n return (\n <ListItem listMarker={BULLET_MARKER}>\n <Text>{exporter.transformInlineContent(block.content)}</Text>\n </ListItem>\n );\n },\n numberedListItem: (block, exporter, _nestingLevel, numberedListIndex) => {\n // const style = blocknoteDefaultPropsToReactPDFStyle(block.props);\n // console.log(\"NUMBERED LIST ITEM\", block.props.textAlignment, style);\n return (\n <ListItem listMarker={`${numberedListIndex}.`}>\n <Text>{exporter.transformInlineContent(block.content)}</Text>\n </ListItem>\n );\n },\n // would be nice to have pdf checkboxes:\n // https://github.com/diegomura/react-pdf/issues/2103\n checkListItem: (block, exporter) => {\n return (\n <ListItem\n listMarker={\n block.props.checked ? CHECK_MARKER_CHECKED : CHECK_MARKER_UNCHECKED\n }>\n <Text>{exporter.transformInlineContent(block.content)}</Text>\n </ListItem>\n );\n },\n heading: (block, exporter) => {\n const fontSizeEM =\n block.props.level === 1 ? 2 : block.props.level === 2 ? 1.5 : 1.17;\n return (\n <Text\n style={{\n fontSize: fontSizeEM * FONT_SIZE * PIXELS_PER_POINT,\n fontWeight: 700,\n }}>\n {exporter.transformInlineContent(block.content)}\n </Text>\n );\n },\n codeBlock: (block) => {\n const textContent = (block.content as StyledText<any>[])[0]?.text || \"\";\n const lines = textContent.split(\"\\n\").map((line, index) => {\n const indent = line.match(/^\\s*/)?.[0].length || 0;\n\n return (\n <Text\n key={`line_${index}`}\n style={{\n marginLeft: indent * 9.5 * PIXELS_PER_POINT,\n }}>\n {line.trimStart() || <> </>}\n </Text>\n );\n });\n\n return (\n <View\n wrap={false}\n style={{\n padding: 24 * PIXELS_PER_POINT,\n backgroundColor: \"#161616\",\n color: \"#ffffff\",\n lineHeight: 1.25,\n fontSize: FONT_SIZE * PIXELS_PER_POINT,\n fontFamily: \"GeistMono\",\n }}>\n {lines}\n </View>\n );\n },\n pageBreak: () => {\n return <View break />;\n },\n audio: (block, exporter) => {\n return (\n <View wrap={false}>\n {file(\n block.props,\n \"Open audio file\",\n <Svg height={14} width={14} viewBox=\"0 0 24 24\" fill=\"currentColor\">\n <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>\n </Svg>,\n exporter\n )}\n {caption(block.props, exporter)}\n </View>\n );\n },\n video: (block, exporter) => {\n return (\n <View wrap={false}>\n {file(\n block.props,\n \"Open video file\",\n <Svg height={14} width={14} viewBox=\"0 0 24 24\" fill=\"currentColor\">\n <Path d=\"M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z\" />\n </Svg>,\n exporter\n )}\n {caption(block.props, exporter)}\n </View>\n );\n },\n file: (block, exporter) => {\n return (\n <View wrap={false}>\n {file(\n block.props,\n \"Open file\",\n <Svg height={16} width={16} viewBox=\"0 0 24 24\" fill=\"currentColor\">\n <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\" />\n </Svg>,\n exporter\n )}\n {caption(block.props, exporter)}\n </View>\n );\n },\n image: async (block, t) => {\n return (\n <View wrap={false}>\n <Image\n src={await t.resolveFile(block.props.url)}\n style={{\n width: block.props.previewWidth * PIXELS_PER_POINT,\n }}\n />\n {caption(block.props, t)}\n </View>\n );\n },\n table: (block, t) => {\n return <Table data={block.content} transformer={t} />;\n },\n};\n\nfunction file(\n props: Partial<DefaultProps & { name: string; url: string }>,\n defaultText: string,\n icon: React.ReactElement<Svg>,\n _exporter: any\n) {\n const PIXELS_PER_POINT = 0.75;\n return (\n <Link src={props.url}>\n <View\n style={{\n display: \"flex\",\n gap: 8 * PIXELS_PER_POINT,\n flexDirection: \"row\",\n }}>\n {icon}\n <Text>{props.name || defaultText}</Text>\n </View>\n </Link>\n );\n}\n\nfunction caption(\n props: Partial<DefaultProps & { caption: string; previewWidth: number }>,\n _exporter: any\n) {\n if (!props.caption) {\n return undefined;\n }\n return (\n <Text\n style={{\n width: props.previewWidth\n ? props.previewWidth * PIXELS_PER_POINT\n : undefined,\n fontSize: FONT_SIZE * 0.8 * PIXELS_PER_POINT,\n }}>\n {props.caption}\n </Text>\n );\n}\n","import {\n DefaultInlineContentSchema,\n InlineContentMapping,\n} from \"@blocknote/core\";\nimport { Link, Text } from \"@react-pdf/renderer\";\n\nexport const pdfInlineContentMappingForDefaultSchema: InlineContentMapping<\n DefaultInlineContentSchema,\n any,\n React.ReactElement<Link> | React.ReactElement<Text>,\n React.ReactElement<Text>\n> = {\n link: (ic, exporter) => {\n return (\n <Link href={ic.href}>\n {ic.content.map((content) => exporter.transformStyledText(content))}\n </Link>\n );\n },\n text: (ic, exporter) => {\n return exporter.transformStyledText(ic);\n },\n};\n","import { DefaultStyleSchema, StyleMapping } from \"@blocknote/core\";\nimport { TextProps } from \"@react-pdf/renderer\";\n\nexport const pdfStyleMappingForDefaultSchema: StyleMapping<\n DefaultStyleSchema,\n TextProps[\"style\"]\n> = {\n bold: (val) => {\n if (!val) {\n return {};\n }\n return {\n fontWeight: \"bold\",\n };\n },\n italic: (val) => {\n if (!val) {\n return {};\n }\n return {\n fontStyle: \"italic\",\n };\n },\n underline: (val) => {\n if (!val) {\n return {};\n }\n return {\n textDecoration: \"underline\", // TODO: could conflict with strike\n };\n },\n strike: (val) => {\n if (!val) {\n return {};\n }\n return {\n textDecoration: \"line-through\",\n };\n },\n backgroundColor: (val, exporter) => {\n if (!val) {\n return {};\n }\n return {\n backgroundColor:\n exporter.options.colors[val as keyof typeof exporter.options.colors]\n .background,\n };\n },\n textColor: (val, exporter) => {\n if (!val) {\n return {};\n }\n return {\n color:\n exporter.options.colors[val as keyof typeof exporter.options.colors]\n .text,\n };\n },\n code: (val) => {\n if (!val) {\n return {};\n }\n return {\n fontFamily: \"GeistMono\",\n };\n },\n};\n","import { pdfBlockMappingForDefaultSchema } from \"./blocks.js\";\nimport { pdfInlineContentMappingForDefaultSchema } from \"./inlinecontent.js\";\nimport { pdfStyleMappingForDefaultSchema } from \"./styles.js\";\n\nexport const pdfDefaultSchemaMappings = {\n blockMapping: pdfBlockMappingForDefaultSchema,\n inlineContentMapping: pdfInlineContentMappingForDefaultSchema,\n styleMapping: pdfStyleMappingForDefaultSchema,\n};\n","export async function corsProxyResolveFileUrl(url: string) {\n return (\n \"https://corsproxy.api.blocknotejs.org/corsproxy/?url=\" +\n encodeURIComponent(url)\n );\n}\n","/**\n *\n * Helper functions so that we can import files both on vitest, browser and node\n * TODO: should find a way to test automatically in all environments\n */\n\nexport async function loadFileDataUrl(\n requireUrl: { default: string },\n mimeType: string\n) {\n if (import.meta.env.NODE_ENV === \"test\") {\n const buffer = await loadFileBuffer(requireUrl);\n const fileBase64 = buffer.toString(\"base64\");\n\n const dataUrl = `data:${mimeType};base64,${fileBase64}`;\n return dataUrl;\n } else {\n // in browser, this is already a data url\n return requireUrl.default as string;\n }\n}\n\nexport async function loadFontDataUrl(requireUrl: { default: string }) {\n return loadFileDataUrl(requireUrl, \"font/ttf\");\n}\n\nexport async function loadFileBuffer(requireUrl: {\n default: string;\n}): Promise<Buffer | ArrayBuffer> {\n if (import.meta.env.NODE_ENV === \"test\") {\n // in vitest, this is the url we need to load with readfilesync\n // eslint-disable-next-line\n const fs = require(\"fs\");\n let url = requireUrl.default;\n\n if (url.startsWith(\"/@fs/\")) {\n url = url.substring(\"/@fs\".length);\n }\n const buffer = fs.readFileSync(url);\n return buffer;\n } else {\n // in browser, this is already a data url\n const dataUrl = requireUrl.default as string;\n // convert to buffer on browser\n const response = await fetch(dataUrl);\n const arrayBuffer = await response.arrayBuffer();\n return arrayBuffer;\n }\n}\n\n/**\n * usage:\n * \n * await loadFontDataUrl(\n await import(\"../fonts/inter/Inter_18pt-Italic.ttf\")\n );\n */\n","import {\n Block,\n BlockNoteSchema,\n BlockSchema,\n COLORS_DEFAULT,\n DefaultProps,\n Exporter,\n ExporterOptions,\n InlineContentSchema,\n StyleSchema,\n StyledText,\n} from \"@blocknote/core\";\nimport {\n Document,\n Font,\n Link,\n Page,\n StyleSheet,\n Text,\n TextProps,\n View,\n} from \"@react-pdf/renderer\";\nimport { corsProxyResolveFileUrl } from \"@shared/api/corsProxy.js\";\nimport { loadFontDataUrl } from \"../../../../shared/util/fileUtil.js\";\n\nimport { Style } from \"./types.js\";\n\nconst FONT_SIZE = 16;\nconst PIXELS_PER_POINT = 0.75;\n\ntype Options = ExporterOptions & {\n /**\n *\n * @default uses the remote emoji source hosted on cloudflare (https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/)\n */\n emojiSource: false | ReturnType<typeof Font.getEmojiSource>;\n};\n\n/**\n * Exports a BlockNote document to a .pdf file using the react-pdf library.\n */\nexport class PDFExporter<\n B extends BlockSchema,\n S extends StyleSchema,\n I extends InlineContentSchema\n> extends Exporter<\n B,\n I,\n S,\n React.ReactElement<Text>,\n React.ReactElement<Link> | React.ReactElement<Text>,\n TextProps[\"style\"],\n React.ReactElement<Text>\n> {\n private fontsRegistered = false;\n\n public styles = StyleSheet.create({\n page: {\n paddingTop: 35,\n paddingBottom: 65,\n paddingHorizontal: 35,\n fontFamily: \"Inter\",\n fontSize: FONT_SIZE * PIXELS_PER_POINT, // pixels\n lineHeight: 1.5,\n },\n block: {},\n blockChildren: {},\n header: {},\n footer: {\n position: \"absolute\",\n },\n });\n\n public readonly options: Options;\n\n public constructor(\n /**\n * The schema of your editor. The mappings are automatically typed checked against this schema.\n */\n protected readonly schema: BlockNoteSchema<B, I, S>,\n /**\n * The mappings that map the BlockNote schema to the react-pdf content.\n *\n * Pass {@link pdfDefaultSchemaMappings} for the default schema.\n */\n mappings: Exporter<\n NoInfer<B>,\n NoInfer<I>,\n NoInfer<S>,\n React.ReactElement<Text>, // RB\n React.ReactElement<Link> | React.ReactElement<Text>, // RI\n TextProps[\"style\"], // RS\n React.ReactElement<Text> // TS\n >[\"mappings\"],\n options?: Partial<Options>\n ) {\n const defaults = {\n emojiSource: {\n format: \"png\",\n url: \"https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/\",\n },\n resolveFileUrl: corsProxyResolveFileUrl,\n colors: COLORS_DEFAULT,\n } satisfies Partial<Options>;\n\n const newOptions = {\n ...defaults,\n ...options,\n };\n super(schema, mappings, newOptions);\n this.options = newOptions;\n }\n\n /**\n * Mostly for internal use, you probably want to use `toBlob` or `toReactPDFDocument` instead.\n */\n public transformStyledText(styledText: StyledText<S>) {\n const stylesArray = this.mapStyles(styledText.styles);\n const styles = Object.assign({}, ...stylesArray);\n return <Text style={styles}>{styledText.text}</Text>;\n }\n\n /**\n * Mostly for internal use, you probably want to use `toBlob` or `toReactPDFDocument` instead.\n */\n public async transformBlocks(\n blocks: Block<B, I, S>[], // Or BlockFromConfig<B[keyof B], I, S>?\n nestingLevel = 0\n ): Promise<React.ReactElement<Text>[]> {\n const ret: React.ReactElement<Text>[] = [];\n let numberedListIndex = 0;\n\n for (const b of blocks) {\n if (b.type === \"numberedListItem\") {\n numberedListIndex++;\n } else {\n numberedListIndex = 0;\n }\n const children = await this.transformBlocks(b.children, nestingLevel + 1);\n const self = await this.mapBlock(\n b as any,\n nestingLevel,\n numberedListIndex\n ); // TODO: any\n\n if (b.type === \"pageBreak\") {\n ret.push(self);\n continue;\n }\n\n const style = this.blocknoteDefaultPropsToReactPDFStyle(b.props as any);\n ret.push(\n <>\n <View\n style={{\n paddingVertical: 3 * PIXELS_PER_POINT,\n ...this.styles.block,\n ...style,\n }}>\n {self}\n </View>\n {children.length > 0 && (\n <View\n style={{\n marginLeft: FONT_SIZE * 1.5 * PIXELS_PER_POINT,\n ...this.styles.blockChildren,\n }}>\n {children}\n </View>\n )}\n </>\n );\n }\n\n return ret;\n }\n\n protected async registerFonts() {\n if (this.fontsRegistered) {\n return;\n }\n\n if (this.options.emojiSource) {\n Font.registerEmojiSource(this.options.emojiSource);\n }\n let font = await loadFontDataUrl(\n await import(\"@shared/assets/fonts/inter/Inter_18pt-Regular.ttf\")\n );\n Font.register({\n family: \"Inter\",\n src: font,\n });\n\n font = await loadFontDataUrl(\n await import(\"@shared/assets/fonts/inter/Inter_18pt-Italic.ttf\")\n );\n Font.register({\n family: \"Inter\",\n fontStyle: \"italic\",\n src: font,\n });\n\n font = await loadFontDataUrl(\n await import(\"@shared/assets/fonts/inter/Inter_18pt-Bold.ttf\")\n );\n Font.register({\n family: \"Inter\",\n src: font,\n fontWeight: \"bold\",\n });\n\n font = await loadFontDataUrl(\n await import(\"@shared/assets/fonts/inter/Inter_18pt-BoldItalic.ttf\")\n );\n Font.register({\n family: \"Inter\",\n fontStyle: \"italic\",\n src: font,\n fontWeight: \"bold\",\n });\n\n font = await loadFontDataUrl(\n await import(\"@shared/assets/fonts/GeistMono-Regular.ttf\")\n );\n Font.register({\n family: \"GeistMono\",\n src: font,\n });\n\n this.fontsRegistered = true;\n }\n\n /**\n * Convert a document (array of Blocks) to a react-pdf Document.\n */\n public async toReactPDFDocument(\n blocks: Block<B, I, S>[],\n options: {\n /**\n * Add a header to every page.\n * The React component passed must be a React-PDF component\n */\n header?: React.ReactElement;\n /**\n * Add a footer to every page.\n * The React component passed must be a React-PDF component\n */\n footer?: React.ReactElement;\n } = {}\n ) {\n await this.registerFonts();\n\n return (\n <Document>\n <Page dpi={100} size=\"A4\" style={this.styles.page}>\n {options.header && (\n <View fixed style={this.styles.header}>\n {options.header}\n </View>\n )}\n {await this.transformBlocks(blocks)}\n {options.footer && (\n <View\n fixed\n style={[\n {\n left: this.styles.page.paddingHorizontal || 0,\n bottom: (this.styles.page.paddingBottom || 0) / 2,\n right: this.styles.page.paddingHorizontal || 0,\n },\n this.styles.footer,\n ]}>\n {options.footer}\n </View>\n )}\n </Page>\n </Document>\n );\n }\n\n protected blocknoteDefaultPropsToReactPDFStyle(\n props: Partial<DefaultProps>\n ): Style {\n return {\n textAlign: props.textAlignment,\n backgroundColor:\n props.backgroundColor === \"default\" || !props.backgroundColor\n ? undefined\n : this.options.colors[\n props.backgroundColor as keyof typeof this.options.colors\n ].background,\n color:\n props.textColor === \"default\" || !props.textColor\n ? undefined\n : this.options.colors[\n props.textColor as keyof typeof this.options.colors\n ].text,\n alignItems:\n props.textAlignment === \"right\"\n ? \"flex-end\"\n : props.textAlignment === \"center\"\n ? \"center\"\n : undefined,\n };\n }\n}\n"],"names":["PIXELS_PER_POINT","styles","StyleSheet","BULLET_MARKER","CHECK_MARKER_UNCHECKED","jsx","Svg","Path","CHECK_MARKER_CHECKED","ListItem","listMarker","children","style","jsxs","View","Text","Table","props","headerRows","headerCols","row","rowIndex","colIndex","cell","mapTableCell","isHeaderRow","isHeaderCol","FONT_SIZE","pdfBlockMappingForDefaultSchema","block","exporter","_nestingLevel","numberedListIndex","fontSizeEM","lines","_a","line","index","indent","Fragment","file","caption","t","Image","defaultText","icon","_exporter","Link","pdfInlineContentMappingForDefaultSchema","ic","content","pdfStyleMappingForDefaultSchema","val","pdfDefaultSchemaMappings","corsProxyResolveFileUrl","url","loadFileDataUrl","requireUrl","mimeType","define_import_meta_env_default","fileBase64","loadFileBuffer","loadFontDataUrl","fs","dataUrl","PDFExporter","Exporter","schema","mappings","options","newOptions","COLORS_DEFAULT","__publicField","styledText","stylesArray","blocks","nestingLevel","ret","b","self","Font","font","Document","Page"],"mappings":"uVAKMA,EAAmB,IAEnBC,EAASC,aAAW,OAAO,CAC/B,SAAU,CACR,QAAS,OACT,cAAe,MACf,IAAK,EAAIF,EACT,aAAc,EAChB,EACA,OAAQ,CACN,WAAY,EACd,CACF,CAAC,EAEYG,EAAgB,IAGhBC,EACXC,EAAA,IAACC,EAAA,IAAA,CACC,MAAO,CAAE,UAAW,CAAE,EACtB,OAAO,KACP,QAAQ,iBACR,MAAM,KACN,KAAK,YACL,SAAAD,EAAAA,IAACE,EAAAA,KAAK,CAAA,EAAE,gJAAiJ,CAAA,CAAA,CAC3J,EAIWC,EACXH,EAAA,IAACC,EAAA,IAAA,CACC,MAAO,CAAE,UAAW,CAAE,EACtB,OAAO,KACP,QAAQ,iBACR,MAAM,KACN,KAAK,YACL,SAAAD,EAAAA,IAACE,EAAAA,KAAK,CAAA,EAAE,oNAAqN,CAAA,CAAA,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,qCACRpD,EACO,CACA,MAAA,CACL,UAAWA,EAAM,cACjB,gBACEA,EAAM,kBAAoB,WAAa,CAACA,EAAM,gBAC1C,OACA,KAAK,QAAQ,OACXA,EAAM,eACR,EAAE,WACR,MACEA,EAAM,YAAc,WAAa,CAACA,EAAM,UACpC,OACA,KAAK,QAAQ,OACXA,EAAM,SACR,EAAE,KACR,WACEA,EAAM,gBAAkB,QACpB,WACAA,EAAM,gBAAkB,SACxB,SACA,MAAA,CAEV,CACF"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { jsx as n, jsxs as
|
|
5
|
-
import { StyleSheet as
|
|
6
|
-
import {
|
|
7
|
-
const N = 0.75,
|
|
1
|
+
var L = Object.defineProperty;
|
|
2
|
+
var P = (t, r, e) => r in t ? L(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e;
|
|
3
|
+
var w = (t, r, e) => P(t, typeof r != "symbol" ? r + "" : r, e);
|
|
4
|
+
import { jsx as n, jsxs as f, Fragment as T } from "react/jsx-runtime";
|
|
5
|
+
import { StyleSheet as v, Svg as m, Path as y, View as s, Text as c, Image as D, Link as k, Font as u, Document as F, Page as B } from "@react-pdf/renderer";
|
|
6
|
+
import { mapTableCell as Z, Exporter as O, COLORS_DEFAULT as A } from "@blocknote/core";
|
|
7
|
+
const N = 0.75, V = v.create({
|
|
8
8
|
listItem: {
|
|
9
9
|
display: "flex",
|
|
10
10
|
flexDirection: "row",
|
|
@@ -26,7 +26,7 @@ const N = 0.75, M = I.create({
|
|
|
26
26
|
fill: "undefined",
|
|
27
27
|
children: /* @__PURE__ */ n(y, { d: "M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Z" })
|
|
28
28
|
}
|
|
29
|
-
),
|
|
29
|
+
), z = /* @__PURE__ */ n(
|
|
30
30
|
m,
|
|
31
31
|
{
|
|
32
32
|
style: { marginTop: 2 },
|
|
@@ -36,14 +36,14 @@ const N = 0.75, M = I.create({
|
|
|
36
36
|
fill: "undefined",
|
|
37
37
|
children: /* @__PURE__ */ n(y, { d: "m424-312 282-282-56-56-226 226-114-114-56 56 170 170ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z" })
|
|
38
38
|
}
|
|
39
|
-
),
|
|
39
|
+
), H = ({
|
|
40
40
|
listMarker: t,
|
|
41
41
|
children: r,
|
|
42
42
|
style: e
|
|
43
|
-
}) => /* @__PURE__ */
|
|
44
|
-
/* @__PURE__ */ n(
|
|
43
|
+
}) => /* @__PURE__ */ f(s, { style: [V.listItem, e || {}], children: [
|
|
44
|
+
/* @__PURE__ */ n(s, { style: V.bullet, children: typeof t == "string" ? /* @__PURE__ */ n(c, { children: t }) : t }),
|
|
45
45
|
r
|
|
46
|
-
] }),
|
|
46
|
+
] }), I = 0.75, p = v.create({
|
|
47
47
|
tableContainer: {
|
|
48
48
|
// width: "100%",
|
|
49
49
|
},
|
|
@@ -55,61 +55,76 @@ const N = 0.75, M = I.create({
|
|
|
55
55
|
display: "flex"
|
|
56
56
|
},
|
|
57
57
|
cell: {
|
|
58
|
-
paddingHorizontal: 5 *
|
|
59
|
-
paddingTop: 3 *
|
|
58
|
+
paddingHorizontal: 5 * I,
|
|
59
|
+
paddingTop: 3 * I,
|
|
60
60
|
// paddingBottom: 1 * PIXELS_PER_POINT, should be 3px but looks odd, better with no padding Bottom
|
|
61
61
|
borderLeft: "1px solid #ddd",
|
|
62
62
|
borderTop: "1px solid #ddd",
|
|
63
63
|
wordWrap: "break-word",
|
|
64
64
|
whiteSpace: "pre-wrap"
|
|
65
65
|
},
|
|
66
|
+
headerCell: {
|
|
67
|
+
fontWeight: "bold"
|
|
68
|
+
},
|
|
66
69
|
bottomCell: {
|
|
67
70
|
borderBottom: "1px solid #ddd"
|
|
68
71
|
},
|
|
69
72
|
rightCell: {
|
|
70
73
|
borderRight: "1px solid #ddd"
|
|
71
74
|
}
|
|
72
|
-
}),
|
|
73
|
-
|
|
74
|
-
{
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
{
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
75
|
+
}), U = (t) => {
|
|
76
|
+
const r = new Array(t.data.headerRows ?? 0).fill(!0), e = new Array(t.data.headerCols ?? 0).fill(!0);
|
|
77
|
+
return /* @__PURE__ */ n(s, { style: p.tableContainer, wrap: !1, children: t.data.rows.map((o, i) => /* @__PURE__ */ n(
|
|
78
|
+
s,
|
|
79
|
+
{
|
|
80
|
+
style: [
|
|
81
|
+
p.row,
|
|
82
|
+
i === t.data.rows.length - 1 ? p.bottomCell : {}
|
|
83
|
+
],
|
|
84
|
+
children: o.cells.map((d, l) => {
|
|
85
|
+
const a = Z(d), C = r[i], b = e[l];
|
|
86
|
+
return /* @__PURE__ */ n(
|
|
87
|
+
s,
|
|
88
|
+
{
|
|
89
|
+
style: [
|
|
90
|
+
p.cell,
|
|
91
|
+
C || b ? p.headerCell : {},
|
|
92
|
+
l === o.cells.length - 1 ? p.rightCell : {},
|
|
93
|
+
t.data.columnWidths[l] ? { width: t.data.columnWidths[l] } : { flex: 1 },
|
|
94
|
+
{
|
|
95
|
+
color: a.props.textColor === "default" ? void 0 : t.transformer.options.colors[a.props.textColor].text,
|
|
96
|
+
backgroundColor: a.props.backgroundColor === "default" ? void 0 : t.transformer.options.colors[a.props.backgroundColor].background,
|
|
97
|
+
textAlign: a.props.textAlignment
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
children: t.transformer.transformInlineContent(a.content)
|
|
101
|
+
},
|
|
102
|
+
l
|
|
103
|
+
);
|
|
104
|
+
})
|
|
105
|
+
},
|
|
106
|
+
i
|
|
107
|
+
)) });
|
|
108
|
+
}, h = 0.75, M = 16, $ = {
|
|
109
|
+
paragraph: (t, r) => /* @__PURE__ */ n(c, { children: r.transformInlineContent(t.content) }),
|
|
110
|
+
bulletListItem: (t, r) => /* @__PURE__ */ n(H, { listMarker: W, children: /* @__PURE__ */ n(c, { children: r.transformInlineContent(t.content) }) }),
|
|
111
|
+
numberedListItem: (t, r, e, o) => /* @__PURE__ */ n(H, { listMarker: `${o}.`, children: /* @__PURE__ */ n(c, { children: r.transformInlineContent(t.content) }) }),
|
|
97
112
|
// would be nice to have pdf checkboxes:
|
|
98
113
|
// https://github.com/diegomura/react-pdf/issues/2103
|
|
99
114
|
checkListItem: (t, r) => /* @__PURE__ */ n(
|
|
100
|
-
|
|
115
|
+
H,
|
|
101
116
|
{
|
|
102
|
-
listMarker: t.props.checked ?
|
|
103
|
-
children: /* @__PURE__ */ n(
|
|
117
|
+
listMarker: t.props.checked ? z : j,
|
|
118
|
+
children: /* @__PURE__ */ n(c, { children: r.transformInlineContent(t.content) })
|
|
104
119
|
}
|
|
105
120
|
),
|
|
106
121
|
heading: (t, r) => {
|
|
107
122
|
const e = t.props.level === 1 ? 2 : t.props.level === 2 ? 1.5 : 1.17;
|
|
108
123
|
return /* @__PURE__ */ n(
|
|
109
|
-
|
|
124
|
+
c,
|
|
110
125
|
{
|
|
111
126
|
style: {
|
|
112
|
-
fontSize: e *
|
|
127
|
+
fontSize: e * M * h,
|
|
113
128
|
fontWeight: 700
|
|
114
129
|
},
|
|
115
130
|
children: r.transformInlineContent(t.content)
|
|
@@ -119,78 +134,78 @@ const N = 0.75, M = I.create({
|
|
|
119
134
|
codeBlock: (t) => {
|
|
120
135
|
var o;
|
|
121
136
|
const e = (((o = t.content[0]) == null ? void 0 : o.text) || "").split(`
|
|
122
|
-
`).map((i,
|
|
123
|
-
var
|
|
124
|
-
const
|
|
137
|
+
`).map((i, d) => {
|
|
138
|
+
var a;
|
|
139
|
+
const l = ((a = i.match(/^\s*/)) == null ? void 0 : a[0].length) || 0;
|
|
125
140
|
return /* @__PURE__ */ n(
|
|
126
|
-
|
|
141
|
+
c,
|
|
127
142
|
{
|
|
128
143
|
style: {
|
|
129
|
-
marginLeft:
|
|
144
|
+
marginLeft: l * 9.5 * h
|
|
130
145
|
},
|
|
131
|
-
children: i.trimStart() || /* @__PURE__ */ n(
|
|
146
|
+
children: i.trimStart() || /* @__PURE__ */ n(T, { children: " " })
|
|
132
147
|
},
|
|
133
|
-
`line_${
|
|
148
|
+
`line_${d}`
|
|
134
149
|
);
|
|
135
150
|
});
|
|
136
151
|
return /* @__PURE__ */ n(
|
|
137
|
-
|
|
152
|
+
s,
|
|
138
153
|
{
|
|
139
154
|
wrap: !1,
|
|
140
155
|
style: {
|
|
141
|
-
padding: 24 *
|
|
156
|
+
padding: 24 * h,
|
|
142
157
|
backgroundColor: "#161616",
|
|
143
158
|
color: "#ffffff",
|
|
144
159
|
lineHeight: 1.25,
|
|
145
|
-
fontSize:
|
|
160
|
+
fontSize: M * h,
|
|
146
161
|
fontFamily: "GeistMono"
|
|
147
162
|
},
|
|
148
163
|
children: e
|
|
149
164
|
}
|
|
150
165
|
);
|
|
151
166
|
},
|
|
152
|
-
pageBreak: () => /* @__PURE__ */ n(
|
|
153
|
-
audio: (t, r) => /* @__PURE__ */
|
|
154
|
-
|
|
167
|
+
pageBreak: () => /* @__PURE__ */ n(s, { break: !0 }),
|
|
168
|
+
audio: (t, r) => /* @__PURE__ */ f(s, { wrap: !1, children: [
|
|
169
|
+
S(
|
|
155
170
|
t.props,
|
|
156
171
|
"Open audio file",
|
|
157
172
|
/* @__PURE__ */ n(m, { height: 14, width: 14, viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ n(y, { 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" }) })
|
|
158
173
|
),
|
|
159
|
-
|
|
174
|
+
x(t.props)
|
|
160
175
|
] }),
|
|
161
|
-
video: (t, r) => /* @__PURE__ */
|
|
162
|
-
|
|
176
|
+
video: (t, r) => /* @__PURE__ */ f(s, { wrap: !1, children: [
|
|
177
|
+
S(
|
|
163
178
|
t.props,
|
|
164
179
|
"Open video file",
|
|
165
180
|
/* @__PURE__ */ n(m, { height: 14, width: 14, viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ n(y, { d: "M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z" }) })
|
|
166
181
|
),
|
|
167
|
-
|
|
182
|
+
x(t.props)
|
|
168
183
|
] }),
|
|
169
|
-
file: (t, r) => /* @__PURE__ */
|
|
170
|
-
|
|
184
|
+
file: (t, r) => /* @__PURE__ */ f(s, { wrap: !1, children: [
|
|
185
|
+
S(
|
|
171
186
|
t.props,
|
|
172
187
|
"Open file",
|
|
173
188
|
/* @__PURE__ */ n(m, { height: 16, width: 16, viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ n(y, { 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" }) })
|
|
174
189
|
),
|
|
175
|
-
|
|
190
|
+
x(t.props)
|
|
176
191
|
] }),
|
|
177
|
-
image: async (t, r) => /* @__PURE__ */
|
|
192
|
+
image: async (t, r) => /* @__PURE__ */ f(s, { wrap: !1, children: [
|
|
178
193
|
/* @__PURE__ */ n(
|
|
179
|
-
|
|
194
|
+
D,
|
|
180
195
|
{
|
|
181
196
|
src: await r.resolveFile(t.props.url),
|
|
182
197
|
style: {
|
|
183
|
-
width: t.props.previewWidth *
|
|
198
|
+
width: t.props.previewWidth * h
|
|
184
199
|
}
|
|
185
200
|
}
|
|
186
201
|
),
|
|
187
|
-
|
|
202
|
+
x(t.props)
|
|
188
203
|
] }),
|
|
189
|
-
table: (t, r) => /* @__PURE__ */ n(
|
|
204
|
+
table: (t, r) => /* @__PURE__ */ n(U, { data: t.content, transformer: r })
|
|
190
205
|
};
|
|
191
|
-
function
|
|
192
|
-
return /* @__PURE__ */ n(
|
|
193
|
-
|
|
206
|
+
function S(t, r, e, o) {
|
|
207
|
+
return /* @__PURE__ */ n(k, { src: t.url, children: /* @__PURE__ */ f(
|
|
208
|
+
s,
|
|
194
209
|
{
|
|
195
210
|
style: {
|
|
196
211
|
display: "flex",
|
|
@@ -199,28 +214,28 @@ function b(t, r, e, o) {
|
|
|
199
214
|
},
|
|
200
215
|
children: [
|
|
201
216
|
e,
|
|
202
|
-
/* @__PURE__ */ n(
|
|
217
|
+
/* @__PURE__ */ n(c, { children: t.name || r })
|
|
203
218
|
]
|
|
204
219
|
}
|
|
205
220
|
) });
|
|
206
221
|
}
|
|
207
|
-
function
|
|
222
|
+
function x(t, r) {
|
|
208
223
|
if (t.caption)
|
|
209
224
|
return /* @__PURE__ */ n(
|
|
210
|
-
|
|
225
|
+
c,
|
|
211
226
|
{
|
|
212
227
|
style: {
|
|
213
|
-
width: t.previewWidth ? t.previewWidth *
|
|
214
|
-
fontSize:
|
|
228
|
+
width: t.previewWidth ? t.previewWidth * h : void 0,
|
|
229
|
+
fontSize: M * 0.8 * h
|
|
215
230
|
},
|
|
216
231
|
children: t.caption
|
|
217
232
|
}
|
|
218
233
|
);
|
|
219
234
|
}
|
|
220
|
-
const
|
|
221
|
-
link: (t, r) => /* @__PURE__ */ n(
|
|
235
|
+
const q = {
|
|
236
|
+
link: (t, r) => /* @__PURE__ */ n(k, { href: t.href, children: t.content.map((e) => r.transformStyledText(e)) }),
|
|
222
237
|
text: (t, r) => r.transformStyledText(t)
|
|
223
|
-
},
|
|
238
|
+
}, K = {
|
|
224
239
|
bold: (t) => t ? {
|
|
225
240
|
fontWeight: "bold"
|
|
226
241
|
} : {},
|
|
@@ -243,27 +258,27 @@ const $ = {
|
|
|
243
258
|
code: (t) => t ? {
|
|
244
259
|
fontFamily: "GeistMono"
|
|
245
260
|
} : {}
|
|
246
|
-
},
|
|
247
|
-
blockMapping:
|
|
248
|
-
inlineContentMapping:
|
|
249
|
-
styleMapping:
|
|
261
|
+
}, rt = {
|
|
262
|
+
blockMapping: $,
|
|
263
|
+
inlineContentMapping: q,
|
|
264
|
+
styleMapping: K
|
|
250
265
|
};
|
|
251
|
-
async function
|
|
266
|
+
async function X(t) {
|
|
252
267
|
return "https://corsproxy.api.blocknotejs.org/corsproxy/?url=" + encodeURIComponent(t);
|
|
253
268
|
}
|
|
254
|
-
var
|
|
255
|
-
async function
|
|
256
|
-
if (
|
|
257
|
-
const o = (await
|
|
269
|
+
var R = { BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 };
|
|
270
|
+
async function G(t, r) {
|
|
271
|
+
if (R.NODE_ENV === "test") {
|
|
272
|
+
const o = (await J(t)).toString("base64");
|
|
258
273
|
return `data:${r};base64,${o}`;
|
|
259
274
|
} else
|
|
260
275
|
return t.default;
|
|
261
276
|
}
|
|
262
277
|
async function g(t) {
|
|
263
|
-
return
|
|
278
|
+
return G(t, "font/ttf");
|
|
264
279
|
}
|
|
265
|
-
async function
|
|
266
|
-
if (
|
|
280
|
+
async function J(t) {
|
|
281
|
+
if (R.NODE_ENV === "test") {
|
|
267
282
|
const r = require("fs");
|
|
268
283
|
let e = t.default;
|
|
269
284
|
return e.startsWith("/@fs/") && (e = e.substring(4)), r.readFileSync(e);
|
|
@@ -272,29 +287,29 @@ async function G(t) {
|
|
|
272
287
|
return await (await fetch(r)).arrayBuffer();
|
|
273
288
|
}
|
|
274
289
|
}
|
|
275
|
-
const _ = 16,
|
|
276
|
-
class
|
|
290
|
+
const _ = 16, E = 0.75;
|
|
291
|
+
class nt extends O {
|
|
277
292
|
constructor(e, o, i) {
|
|
278
|
-
const
|
|
293
|
+
const l = {
|
|
279
294
|
...{
|
|
280
295
|
emojiSource: {
|
|
281
296
|
format: "png",
|
|
282
297
|
url: "https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/"
|
|
283
298
|
},
|
|
284
|
-
resolveFileUrl:
|
|
285
|
-
colors:
|
|
299
|
+
resolveFileUrl: X,
|
|
300
|
+
colors: A
|
|
286
301
|
},
|
|
287
302
|
...i
|
|
288
303
|
};
|
|
289
|
-
super(e, o,
|
|
290
|
-
|
|
291
|
-
|
|
304
|
+
super(e, o, l);
|
|
305
|
+
w(this, "fontsRegistered", !1);
|
|
306
|
+
w(this, "styles", v.create({
|
|
292
307
|
page: {
|
|
293
308
|
paddingTop: 35,
|
|
294
309
|
paddingBottom: 65,
|
|
295
310
|
paddingHorizontal: 35,
|
|
296
311
|
fontFamily: "Inter",
|
|
297
|
-
fontSize: _ *
|
|
312
|
+
fontSize: _ * E,
|
|
298
313
|
// pixels
|
|
299
314
|
lineHeight: 1.5
|
|
300
315
|
},
|
|
@@ -302,59 +317,58 @@ class rt extends Z {
|
|
|
302
317
|
blockChildren: {},
|
|
303
318
|
header: {},
|
|
304
319
|
footer: {
|
|
305
|
-
// @ts-ignore
|
|
306
320
|
position: "absolute"
|
|
307
321
|
}
|
|
308
322
|
}));
|
|
309
|
-
|
|
310
|
-
this.schema = e, this.options =
|
|
323
|
+
w(this, "options");
|
|
324
|
+
this.schema = e, this.options = l;
|
|
311
325
|
}
|
|
312
326
|
/**
|
|
313
327
|
* Mostly for internal use, you probably want to use `toBlob` or `toReactPDFDocument` instead.
|
|
314
328
|
*/
|
|
315
329
|
transformStyledText(e) {
|
|
316
330
|
const o = this.mapStyles(e.styles), i = Object.assign({}, ...o);
|
|
317
|
-
return /* @__PURE__ */ n(
|
|
331
|
+
return /* @__PURE__ */ n(c, { style: i, children: e.text });
|
|
318
332
|
}
|
|
319
333
|
/**
|
|
320
334
|
* Mostly for internal use, you probably want to use `toBlob` or `toReactPDFDocument` instead.
|
|
321
335
|
*/
|
|
322
336
|
async transformBlocks(e, o = 0) {
|
|
323
337
|
const i = [];
|
|
324
|
-
let
|
|
325
|
-
for (const
|
|
326
|
-
|
|
327
|
-
const
|
|
328
|
-
|
|
338
|
+
let d = 0;
|
|
339
|
+
for (const l of e) {
|
|
340
|
+
l.type === "numberedListItem" ? d++ : d = 0;
|
|
341
|
+
const a = await this.transformBlocks(l.children, o + 1), C = await this.mapBlock(
|
|
342
|
+
l,
|
|
329
343
|
o,
|
|
330
|
-
|
|
344
|
+
d
|
|
331
345
|
);
|
|
332
|
-
if (
|
|
333
|
-
i.push(
|
|
346
|
+
if (l.type === "pageBreak") {
|
|
347
|
+
i.push(C);
|
|
334
348
|
continue;
|
|
335
349
|
}
|
|
336
|
-
const
|
|
350
|
+
const b = this.blocknoteDefaultPropsToReactPDFStyle(l.props);
|
|
337
351
|
i.push(
|
|
338
|
-
/* @__PURE__ */
|
|
352
|
+
/* @__PURE__ */ f(T, { children: [
|
|
339
353
|
/* @__PURE__ */ n(
|
|
340
|
-
|
|
354
|
+
s,
|
|
341
355
|
{
|
|
342
356
|
style: {
|
|
343
|
-
paddingVertical: 3 *
|
|
357
|
+
paddingVertical: 3 * E,
|
|
344
358
|
...this.styles.block,
|
|
345
|
-
...
|
|
359
|
+
...b
|
|
346
360
|
},
|
|
347
|
-
children:
|
|
361
|
+
children: C
|
|
348
362
|
}
|
|
349
363
|
),
|
|
350
|
-
|
|
351
|
-
|
|
364
|
+
a.length > 0 && /* @__PURE__ */ n(
|
|
365
|
+
s,
|
|
352
366
|
{
|
|
353
367
|
style: {
|
|
354
|
-
marginLeft: _ * 1.5 *
|
|
368
|
+
marginLeft: _ * 1.5 * E,
|
|
355
369
|
...this.styles.blockChildren
|
|
356
370
|
},
|
|
357
|
-
children:
|
|
371
|
+
children: a
|
|
358
372
|
}
|
|
359
373
|
)
|
|
360
374
|
] })
|
|
@@ -365,35 +379,35 @@ class rt extends Z {
|
|
|
365
379
|
async registerFonts() {
|
|
366
380
|
if (this.fontsRegistered)
|
|
367
381
|
return;
|
|
368
|
-
this.options.emojiSource &&
|
|
382
|
+
this.options.emojiSource && u.registerEmojiSource(this.options.emojiSource);
|
|
369
383
|
let e = await g(
|
|
370
384
|
await import("./Inter_18pt-Regular-byxnNS-8.js")
|
|
371
385
|
);
|
|
372
|
-
|
|
386
|
+
u.register({
|
|
373
387
|
family: "Inter",
|
|
374
388
|
src: e
|
|
375
389
|
}), e = await g(
|
|
376
390
|
await import("./Inter_18pt-Italic-BVnfHlUD.js")
|
|
377
|
-
),
|
|
391
|
+
), u.register({
|
|
378
392
|
family: "Inter",
|
|
379
393
|
fontStyle: "italic",
|
|
380
394
|
src: e
|
|
381
395
|
}), e = await g(
|
|
382
396
|
await import("./Inter_18pt-Bold-BOnnSImi.js")
|
|
383
|
-
),
|
|
397
|
+
), u.register({
|
|
384
398
|
family: "Inter",
|
|
385
399
|
src: e,
|
|
386
400
|
fontWeight: "bold"
|
|
387
401
|
}), e = await g(
|
|
388
402
|
await import("./Inter_18pt-BoldItalic-DPKIpVzB.js")
|
|
389
|
-
),
|
|
403
|
+
), u.register({
|
|
390
404
|
family: "Inter",
|
|
391
405
|
fontStyle: "italic",
|
|
392
406
|
src: e,
|
|
393
407
|
fontWeight: "bold"
|
|
394
408
|
}), e = await g(
|
|
395
409
|
await import("./GeistMono-Regular-D4rKXxwr.js")
|
|
396
|
-
),
|
|
410
|
+
), u.register({
|
|
397
411
|
family: "GeistMono",
|
|
398
412
|
src: e
|
|
399
413
|
}), this.fontsRegistered = !0;
|
|
@@ -402,11 +416,11 @@ class rt extends Z {
|
|
|
402
416
|
* Convert a document (array of Blocks) to a react-pdf Document.
|
|
403
417
|
*/
|
|
404
418
|
async toReactPDFDocument(e, o = {}) {
|
|
405
|
-
return await this.registerFonts(), /* @__PURE__ */ n(F, { children: /* @__PURE__ */
|
|
406
|
-
o.header && /* @__PURE__ */ n(
|
|
419
|
+
return await this.registerFonts(), /* @__PURE__ */ n(F, { children: /* @__PURE__ */ f(B, { dpi: 100, size: "A4", style: this.styles.page, children: [
|
|
420
|
+
o.header && /* @__PURE__ */ n(s, { fixed: !0, style: this.styles.header, children: o.header }),
|
|
407
421
|
await this.transformBlocks(e),
|
|
408
422
|
o.footer && /* @__PURE__ */ n(
|
|
409
|
-
|
|
423
|
+
s,
|
|
410
424
|
{
|
|
411
425
|
fixed: !0,
|
|
412
426
|
style: [
|
|
@@ -432,7 +446,7 @@ class rt extends Z {
|
|
|
432
446
|
}
|
|
433
447
|
}
|
|
434
448
|
export {
|
|
435
|
-
|
|
436
|
-
|
|
449
|
+
nt as PDFExporter,
|
|
450
|
+
rt as pdfDefaultSchemaMappings
|
|
437
451
|
};
|
|
438
452
|
//# sourceMappingURL=blocknote-xl-pdf-exporter.js.map
|