@blocknote/xl-docx-exporter 0.19.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.
Files changed (90) hide show
  1. package/LICENSE +661 -0
  2. package/dist/Inter_18pt-Regular-byxnNS-8.js +5 -0
  3. package/dist/Inter_18pt-Regular-byxnNS-8.js.map +1 -0
  4. package/dist/blocknote-xl-docx-exporter.js +381 -0
  5. package/dist/blocknote-xl-docx-exporter.js.map +1 -0
  6. package/dist/blocknote-xl-docx-exporter.umd.cjs +991 -0
  7. package/dist/blocknote-xl-docx-exporter.umd.cjs.map +1 -0
  8. package/dist/styles-CcdeAskf.js +994 -0
  9. package/dist/styles-CcdeAskf.js.map +1 -0
  10. package/dist/webpack-stats.json +1 -0
  11. package/package.json +80 -0
  12. package/src/docx/__snapshots__/basic/document.xml +685 -0
  13. package/src/docx/__snapshots__/basic/styles.xml +960 -0
  14. package/src/docx/__snapshots__/withCustomOptions/core.xml +14 -0
  15. package/src/docx/__snapshots__/withCustomOptions/document.xml.rels +17 -0
  16. package/src/docx/__snapshots__/withCustomOptions/footer1.xml +8 -0
  17. package/src/docx/__snapshots__/withCustomOptions/header1.xml +8 -0
  18. package/src/docx/defaultSchema/blocks.ts +222 -0
  19. package/src/docx/defaultSchema/index.ts +9 -0
  20. package/src/docx/defaultSchema/inlinecontent.ts +29 -0
  21. package/src/docx/defaultSchema/styles.ts +73 -0
  22. package/src/docx/docxExporter.test.ts +118 -0
  23. package/src/docx/docxExporter.ts +269 -0
  24. package/src/docx/imageUtil.ts +21 -0
  25. package/src/docx/index.ts +2 -0
  26. package/src/docx/template/[Content_Types].xml +22 -0
  27. package/src/docx/template/_rels/.rels +2 -0
  28. package/src/docx/template/docProps/app.xml +35 -0
  29. package/src/docx/template/docProps/core.xml +16 -0
  30. package/src/docx/template/template blocknote.docx +0 -0
  31. package/src/docx/template/word/_rels/document.xml.rels +24 -0
  32. package/src/docx/template/word/document.xml +325 -0
  33. package/src/docx/template/word/fontTable.xml +2 -0
  34. package/src/docx/template/word/media/image1.jpeg +0 -0
  35. package/src/docx/template/word/settings.xml +71 -0
  36. package/src/docx/template/word/styles.xml +990 -0
  37. package/src/docx/template/word/theme/theme1.xml +2 -0
  38. package/src/docx/template/word/webSettings.xml +2 -0
  39. package/src/docx/util/Table.tsx +43 -0
  40. package/src/index.ts +1 -0
  41. package/src/vite-env.d.ts +11 -0
  42. package/types/src/Exporter.d.ts +26 -0
  43. package/types/src/context/BlockNoteContext.d.ts +59 -0
  44. package/types/src/context/BlockNoteContext.test.d.ts +1 -0
  45. package/types/src/context/ServerBlockNoteEditor.d.ts +137 -0
  46. package/types/src/context/ServerBlockNoteEditor.test.d.ts +1 -0
  47. package/types/src/context/react/ReactServer.test.d.ts +2 -0
  48. package/types/src/docx/blocks.d.ts +433 -0
  49. package/types/src/docx/defaultSchema/blocks.d.ts +3 -0
  50. package/types/src/docx/defaultSchema/index.d.ts +559 -0
  51. package/types/src/docx/defaultSchema/inlinecontent.d.ts +3 -0
  52. package/types/src/docx/defaultSchema/styles.d.ts +3 -0
  53. package/types/src/docx/docxExporter.d.ts +53 -0
  54. package/types/src/docx/docxExporter.test.d.ts +1 -0
  55. package/types/src/docx/imageUtil.d.ts +4 -0
  56. package/types/src/docx/index.d.ts +2 -0
  57. package/types/src/docx/inlinecontent.d.ts +12 -0
  58. package/types/src/docx/styles.d.ts +55 -0
  59. package/types/src/docx/util/Table.d.ts +3 -0
  60. package/types/src/docxExporter.d.ts +255 -0
  61. package/types/src/docxExporter.test.d.ts +1 -0
  62. package/types/src/index.d.ts +1 -0
  63. package/types/src/mapping.d.ts +29 -0
  64. package/types/src/pdf/blocks.d.ts +434 -0
  65. package/types/src/pdf/defaultSchema/blocks.d.ts +5 -0
  66. package/types/src/pdf/defaultSchema/index.d.ts +510 -0
  67. package/types/src/pdf/defaultSchema/inlinecontent.d.ts +5 -0
  68. package/types/src/pdf/defaultSchema/styles.d.ts +4 -0
  69. package/types/src/pdf/index.d.ts +2 -0
  70. package/types/src/pdf/inlinecontent.d.ts +13 -0
  71. package/types/src/pdf/pdfExporter.d.ts +35 -0
  72. package/types/src/pdf/pdfExporter.test.d.ts +1 -0
  73. package/types/src/pdf/styles.d.ts +55 -0
  74. package/types/src/pdf/types.d.ts +2 -0
  75. package/types/src/pdf/util/listItem.d.ts +9 -0
  76. package/types/src/pdf/util/loadFontDataUrl.d.ts +3 -0
  77. package/types/src/pdf/util/table/Table.d.ts +6 -0
  78. package/types/src/pdfExporter.d.ts +256 -0
  79. package/types/src/pdfExporter.test.d.ts +1 -0
  80. package/types/src/react-email/defaultSchema/blocks.d.ts +5 -0
  81. package/types/src/react-email/defaultSchema/index.d.ts +560 -0
  82. package/types/src/react-email/defaultSchema/inlinecontent.d.ts +5 -0
  83. package/types/src/react-email/defaultSchema/styles.d.ts +4 -0
  84. package/types/src/react-email/reactEmailExporter.d.ts +13 -0
  85. package/types/src/react-email/reactEmailExporter.test.d.ts +8 -0
  86. package/types/src/testDocument.d.ts +505 -0
  87. package/types/src/transformer.d.ts +20 -0
  88. package/types/src/util/fileUtil.d.ts +22 -0
  89. package/types/src/util/imageUtil.d.ts +4 -0
  90. package/types/src/yjs/index.d.ts +2 -0
@@ -0,0 +1,55 @@
1
+ import { StyleSchema, StyledText } from "@blocknote/core";
2
+ import { IRunPropertiesOptions, TextRun } from "docx";
3
+ import { StyleMapping } from "../mapping";
4
+ export declare const docxStyleMappingForDefaultSchema: StyleMapping<import("@blocknote/core").StyleSchemaFromSpecs<{
5
+ bold: {
6
+ config: {
7
+ type: string;
8
+ propSchema: "boolean";
9
+ };
10
+ implementation: import("@blocknote/core").StyleImplementation;
11
+ };
12
+ italic: {
13
+ config: {
14
+ type: string;
15
+ propSchema: "boolean";
16
+ };
17
+ implementation: import("@blocknote/core").StyleImplementation;
18
+ };
19
+ underline: {
20
+ config: {
21
+ type: string;
22
+ propSchema: "boolean";
23
+ };
24
+ implementation: import("@blocknote/core").StyleImplementation;
25
+ };
26
+ strike: {
27
+ config: {
28
+ type: string;
29
+ propSchema: "boolean";
30
+ };
31
+ implementation: import("@blocknote/core").StyleImplementation;
32
+ };
33
+ code: {
34
+ config: {
35
+ type: string;
36
+ propSchema: "boolean";
37
+ };
38
+ implementation: import("@blocknote/core").StyleImplementation;
39
+ };
40
+ textColor: {
41
+ config: {
42
+ type: string;
43
+ propSchema: "string";
44
+ };
45
+ implementation: import("@blocknote/core").StyleImplementation;
46
+ };
47
+ backgroundColor: {
48
+ config: {
49
+ type: string;
50
+ propSchema: "string";
51
+ };
52
+ implementation: import("@blocknote/core").StyleImplementation;
53
+ };
54
+ }>, IRunPropertiesOptions>;
55
+ export declare function createDocxStyledTextTransformer<S extends StyleSchema>(mapping: StyleMapping<S, IRunPropertiesOptions>): (styledText: StyledText<S>) => TextRun;
@@ -0,0 +1,3 @@
1
+ import { Exporter, InlineContentSchema, TableContent } from "@blocknote/core";
2
+ import { Table as DocxTable, ParagraphChild } from "docx";
3
+ export declare const Table: (data: TableContent<InlineContentSchema>, t: Exporter<any, any, any, any, ParagraphChild, any, any>) => DocxTable;
@@ -0,0 +1,255 @@
1
+ import { Block } from "@blocknote/core";
2
+ import { Paragraph, TextRun } from "docx";
3
+ export declare function createDocxExporterForDefaultSchema(): {
4
+ util: {
5
+ blockTransformer: (block: import("@blocknote/core").BlockFromConfig<{
6
+ type: "paragraph";
7
+ content: "inline";
8
+ propSchema: {
9
+ backgroundColor: {
10
+ default: "default";
11
+ };
12
+ textColor: {
13
+ default: "default";
14
+ };
15
+ textAlignment: {
16
+ default: "left";
17
+ values: readonly ["left", "center", "right", "justify"];
18
+ };
19
+ };
20
+ } | {
21
+ type: "heading";
22
+ content: "inline";
23
+ propSchema: {
24
+ level: {
25
+ default: number;
26
+ values: readonly [1, 2, 3];
27
+ };
28
+ backgroundColor: {
29
+ default: "default";
30
+ };
31
+ textColor: {
32
+ default: "default";
33
+ };
34
+ textAlignment: {
35
+ default: "left";
36
+ values: readonly ["left", "center", "right", "justify"];
37
+ };
38
+ };
39
+ } | {
40
+ type: "bulletListItem";
41
+ content: "inline";
42
+ propSchema: {
43
+ backgroundColor: {
44
+ default: "default";
45
+ };
46
+ textColor: {
47
+ default: "default";
48
+ };
49
+ textAlignment: {
50
+ default: "left";
51
+ values: readonly ["left", "center", "right", "justify"];
52
+ };
53
+ };
54
+ } | {
55
+ type: "numberedListItem";
56
+ content: "inline";
57
+ propSchema: {
58
+ backgroundColor: {
59
+ default: "default";
60
+ };
61
+ textColor: {
62
+ default: "default";
63
+ };
64
+ textAlignment: {
65
+ default: "left";
66
+ values: readonly ["left", "center", "right", "justify"];
67
+ };
68
+ };
69
+ } | {
70
+ type: "checkListItem";
71
+ content: "inline";
72
+ propSchema: {
73
+ checked: {
74
+ default: false;
75
+ };
76
+ backgroundColor: {
77
+ default: "default";
78
+ };
79
+ textColor: {
80
+ default: "default";
81
+ };
82
+ textAlignment: {
83
+ default: "left";
84
+ values: readonly ["left", "center", "right", "justify"];
85
+ };
86
+ };
87
+ } | {
88
+ type: "table";
89
+ content: "table";
90
+ propSchema: {
91
+ backgroundColor: {
92
+ default: "default";
93
+ };
94
+ textColor: {
95
+ default: "default";
96
+ };
97
+ textAlignment: {
98
+ default: "left";
99
+ values: readonly ["left", "center", "right", "justify"];
100
+ };
101
+ };
102
+ } | {
103
+ type: "file";
104
+ propSchema: {
105
+ backgroundColor: {
106
+ default: "default";
107
+ };
108
+ name: {
109
+ default: "";
110
+ };
111
+ url: {
112
+ default: "";
113
+ };
114
+ caption: {
115
+ default: "";
116
+ };
117
+ };
118
+ content: "none";
119
+ isFileBlock: true;
120
+ } | {
121
+ type: "image";
122
+ propSchema: {
123
+ textAlignment: {
124
+ default: "left";
125
+ values: readonly ["left", "center", "right", "justify"];
126
+ };
127
+ backgroundColor: {
128
+ default: "default";
129
+ };
130
+ name: {
131
+ default: "";
132
+ };
133
+ url: {
134
+ default: "";
135
+ };
136
+ caption: {
137
+ default: "";
138
+ };
139
+ showPreview: {
140
+ default: true;
141
+ };
142
+ previewWidth: {
143
+ default: number;
144
+ };
145
+ };
146
+ content: "none";
147
+ isFileBlock: true;
148
+ fileBlockAccept: string[];
149
+ } | {
150
+ type: "video";
151
+ propSchema: {
152
+ textAlignment: {
153
+ default: "left";
154
+ values: readonly ["left", "center", "right", "justify"];
155
+ };
156
+ backgroundColor: {
157
+ default: "default";
158
+ };
159
+ name: {
160
+ default: "";
161
+ };
162
+ url: {
163
+ default: "";
164
+ };
165
+ caption: {
166
+ default: "";
167
+ };
168
+ showPreview: {
169
+ default: true;
170
+ };
171
+ previewWidth: {
172
+ default: number;
173
+ };
174
+ };
175
+ content: "none";
176
+ isFileBlock: true;
177
+ fileBlockAccept: string[];
178
+ } | {
179
+ type: "audio";
180
+ propSchema: {
181
+ backgroundColor: {
182
+ default: "default";
183
+ };
184
+ name: {
185
+ default: "";
186
+ };
187
+ url: {
188
+ default: "";
189
+ };
190
+ caption: {
191
+ default: "";
192
+ };
193
+ showPreview: {
194
+ default: true;
195
+ };
196
+ };
197
+ content: "none";
198
+ isFileBlock: true;
199
+ fileBlockAccept: string[];
200
+ }, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>) => Paragraph;
201
+ styledTextTransformer: (styledText: import("@blocknote/core").StyledText<import("@blocknote/core").StyleSchemaFromSpecs<{
202
+ bold: {
203
+ config: {
204
+ type: string;
205
+ propSchema: "boolean";
206
+ };
207
+ implementation: import("@blocknote/core").StyleImplementation;
208
+ };
209
+ italic: {
210
+ config: {
211
+ type: string;
212
+ propSchema: "boolean";
213
+ };
214
+ implementation: import("@blocknote/core").StyleImplementation;
215
+ };
216
+ underline: {
217
+ config: {
218
+ type: string;
219
+ propSchema: "boolean";
220
+ };
221
+ implementation: import("@blocknote/core").StyleImplementation;
222
+ };
223
+ strike: {
224
+ config: {
225
+ type: string;
226
+ propSchema: "boolean";
227
+ };
228
+ implementation: import("@blocknote/core").StyleImplementation;
229
+ };
230
+ code: {
231
+ config: {
232
+ type: string;
233
+ propSchema: "boolean";
234
+ };
235
+ implementation: import("@blocknote/core").StyleImplementation;
236
+ };
237
+ textColor: {
238
+ config: {
239
+ type: string;
240
+ propSchema: "string";
241
+ };
242
+ implementation: import("@blocknote/core").StyleImplementation;
243
+ };
244
+ backgroundColor: {
245
+ config: {
246
+ type: string;
247
+ propSchema: "string";
248
+ };
249
+ implementation: import("@blocknote/core").StyleImplementation;
250
+ };
251
+ }>>) => TextRun;
252
+ inlineContentTransformer: (inlineContent: import("@blocknote/core").StyledText<import("@blocknote/core").StyleSchema> | import("@blocknote/core").Link<import("@blocknote/core").StyleSchema>) => import("docx").ParagraphChild;
253
+ };
254
+ transform: (blocks: Block[]) => Paragraph[];
255
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from "./docx/index.js";
@@ -0,0 +1,29 @@
1
+ import { BlockFromConfigNoChildren, BlockNoteSchema, BlockSchema, InlineContentFromConfig, InlineContentSchema, StyleSchema, Styles } from "@blocknote/core";
2
+ import { Exporter } from "./Exporter.js";
3
+ /**
4
+ * Defines a mapping from all block types with a schema to a result type `R`.
5
+ */
6
+ export type BlockMapping<B extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema, RB, RI> = {
7
+ [K in keyof B]: (block: BlockFromConfigNoChildren<B[K], I, S>, exporter: Exporter<any, any, any, RB, RI, any, any>, nestingLevel: number, numberedListIndex?: number) => RB | Promise<RB>;
8
+ };
9
+ /**
10
+ * Defines a mapping from all inline content types with a schema to a result type R.
11
+ */
12
+ export type InlineContentMapping<I extends InlineContentSchema, S extends StyleSchema, RI, TS> = {
13
+ [K in keyof I]: (inlineContent: InlineContentFromConfig<I[K], S>, exporter: Exporter<any, I, S, any, RI, any, TS>) => RI;
14
+ };
15
+ /**
16
+ * Defines a mapping from all style types with a schema to a result type R.
17
+ */
18
+ export type StyleMapping<S extends StyleSchema, RS> = {
19
+ [K in keyof S]: (style: Styles<S>[K], exporter: Exporter<any, any, any, any, any, RS, any>) => RS;
20
+ };
21
+ /**
22
+ * The mapping factory is a utility function to easily create mappings for
23
+ * a BlockNoteSchema. Using the factory makes it easier to get typescript code completion etc.
24
+ */
25
+ export declare function mappingFactory<B extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(_schema: BlockNoteSchema<B, I, S>): {
26
+ createBlockMapping: <R, RI>(mapping: BlockMapping<B, I, S, R, RI>) => BlockMapping<B, I, S, R, RI>;
27
+ createInlineContentMapping: <R_1, RS>(mapping: InlineContentMapping<I, S, R_1, RS>) => InlineContentMapping<I, S, R_1, RS>;
28
+ createStyleMapping: <R_2>(mapping: StyleMapping<S, R_2>) => StyleMapping<S, R_2>;
29
+ };