@blocknote/xl-pdf-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 (78) hide show
  1. package/LICENSE +661 -0
  2. package/dist/Inter_18pt-Bold-BOnnSImi.js +5 -0
  3. package/dist/Inter_18pt-Bold-BOnnSImi.js.map +1 -0
  4. package/dist/Inter_18pt-BoldItalic-DPKIpVzB.js +5 -0
  5. package/dist/Inter_18pt-BoldItalic-DPKIpVzB.js.map +1 -0
  6. package/dist/Inter_18pt-Italic-BVnfHlUD.js +5 -0
  7. package/dist/Inter_18pt-Italic-BVnfHlUD.js.map +1 -0
  8. package/dist/Inter_18pt-Regular-byxnNS-8.js +5 -0
  9. package/dist/Inter_18pt-Regular-byxnNS-8.js.map +1 -0
  10. package/dist/blocknote-xl-pdf-exporter.js +2503 -0
  11. package/dist/blocknote-xl-pdf-exporter.js.map +1 -0
  12. package/dist/blocknote-xl-pdf-exporter.umd.cjs +69 -0
  13. package/dist/blocknote-xl-pdf-exporter.umd.cjs.map +1 -0
  14. package/dist/webpack-stats.json +1 -0
  15. package/package.json +88 -0
  16. package/src/index.ts +1 -0
  17. package/src/pdf/__snapshots__/example.jsx +592 -0
  18. package/src/pdf/__snapshots__/exampleWithHeaderAndFooter.jsx +602 -0
  19. package/src/pdf/defaultSchema/blocks.tsx +177 -0
  20. package/src/pdf/defaultSchema/index.ts +9 -0
  21. package/src/pdf/defaultSchema/inlinecontent.tsx +23 -0
  22. package/src/pdf/defaultSchema/styles.tsx +68 -0
  23. package/src/pdf/index.ts +2 -0
  24. package/src/pdf/pdfExporter.test.tsx +208 -0
  25. package/src/pdf/pdfExporter.tsx +297 -0
  26. package/src/pdf/types.ts +3 -0
  27. package/src/pdf/util/listItem.tsx +70 -0
  28. package/src/pdf/util/table/Table.tsx +76 -0
  29. package/src/vite-env.d.ts +11 -0
  30. package/types/src/Exporter.d.ts +26 -0
  31. package/types/src/context/BlockNoteContext.d.ts +59 -0
  32. package/types/src/context/BlockNoteContext.test.d.ts +1 -0
  33. package/types/src/context/ServerBlockNoteEditor.d.ts +137 -0
  34. package/types/src/context/ServerBlockNoteEditor.test.d.ts +1 -0
  35. package/types/src/context/react/ReactServer.test.d.ts +2 -0
  36. package/types/src/docx/blocks.d.ts +433 -0
  37. package/types/src/docx/defaultSchema/blocks.d.ts +4 -0
  38. package/types/src/docx/defaultSchema/index.d.ts +559 -0
  39. package/types/src/docx/defaultSchema/inlinecontent.d.ts +4 -0
  40. package/types/src/docx/defaultSchema/styles.d.ts +4 -0
  41. package/types/src/docx/docxExporter.d.ts +14 -0
  42. package/types/src/docx/docxExporter.test.d.ts +1 -0
  43. package/types/src/docx/imageUtil.d.ts +4 -0
  44. package/types/src/docx/index.d.ts +2 -0
  45. package/types/src/docx/inlinecontent.d.ts +12 -0
  46. package/types/src/docx/styles.d.ts +55 -0
  47. package/types/src/docx/util/Table.d.ts +4 -0
  48. package/types/src/docxExporter.d.ts +255 -0
  49. package/types/src/docxExporter.test.d.ts +1 -0
  50. package/types/src/index.d.ts +1 -0
  51. package/types/src/mapping.d.ts +29 -0
  52. package/types/src/pdf/blocks.d.ts +434 -0
  53. package/types/src/pdf/defaultSchema/blocks.d.ts +4 -0
  54. package/types/src/pdf/defaultSchema/index.d.ts +510 -0
  55. package/types/src/pdf/defaultSchema/inlinecontent.d.ts +4 -0
  56. package/types/src/pdf/defaultSchema/styles.d.ts +3 -0
  57. package/types/src/pdf/index.d.ts +2 -0
  58. package/types/src/pdf/inlinecontent.d.ts +13 -0
  59. package/types/src/pdf/pdfExporter.d.ts +81 -0
  60. package/types/src/pdf/pdfExporter.test.d.ts +1 -0
  61. package/types/src/pdf/styles.d.ts +55 -0
  62. package/types/src/pdf/types.d.ts +2 -0
  63. package/types/src/pdf/util/listItem.d.ts +9 -0
  64. package/types/src/pdf/util/loadFontDataUrl.d.ts +3 -0
  65. package/types/src/pdf/util/table/Table.d.ts +5 -0
  66. package/types/src/pdfExporter.d.ts +256 -0
  67. package/types/src/pdfExporter.test.d.ts +1 -0
  68. package/types/src/react-email/defaultSchema/blocks.d.ts +5 -0
  69. package/types/src/react-email/defaultSchema/index.d.ts +560 -0
  70. package/types/src/react-email/defaultSchema/inlinecontent.d.ts +5 -0
  71. package/types/src/react-email/defaultSchema/styles.d.ts +4 -0
  72. package/types/src/react-email/reactEmailExporter.d.ts +13 -0
  73. package/types/src/react-email/reactEmailExporter.test.d.ts +8 -0
  74. package/types/src/testDocument.d.ts +505 -0
  75. package/types/src/transformer.d.ts +20 -0
  76. package/types/src/util/fileUtil.d.ts +22 -0
  77. package/types/src/util/imageUtil.d.ts +4 -0
  78. package/types/src/yjs/index.d.ts +2 -0
@@ -0,0 +1,505 @@
1
+ export declare const testDocument: import("@blocknote/core").Block<import("@blocknote/core").BlockSchemaFromSpecs<{
2
+ paragraph: {
3
+ config: {
4
+ type: "paragraph";
5
+ content: "inline";
6
+ propSchema: {
7
+ backgroundColor: {
8
+ default: "default";
9
+ };
10
+ textColor: {
11
+ default: "default";
12
+ };
13
+ textAlignment: {
14
+ default: "left";
15
+ values: readonly ["left", "center", "right", "justify"];
16
+ };
17
+ };
18
+ };
19
+ implementation: import("@blocknote/core").TiptapBlockImplementation<{
20
+ type: "paragraph";
21
+ content: "inline";
22
+ propSchema: {
23
+ backgroundColor: {
24
+ default: "default";
25
+ };
26
+ textColor: {
27
+ default: "default";
28
+ };
29
+ textAlignment: {
30
+ default: "left";
31
+ values: readonly ["left", "center", "right", "justify"];
32
+ };
33
+ };
34
+ }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
35
+ };
36
+ heading: {
37
+ config: {
38
+ type: "heading";
39
+ content: "inline";
40
+ propSchema: {
41
+ level: {
42
+ default: number;
43
+ values: readonly [1, 2, 3];
44
+ };
45
+ backgroundColor: {
46
+ default: "default";
47
+ };
48
+ textColor: {
49
+ default: "default";
50
+ };
51
+ textAlignment: {
52
+ default: "left";
53
+ values: readonly ["left", "center", "right", "justify"];
54
+ };
55
+ };
56
+ };
57
+ implementation: import("@blocknote/core").TiptapBlockImplementation<{
58
+ type: "heading";
59
+ content: "inline";
60
+ propSchema: {
61
+ level: {
62
+ default: number;
63
+ values: readonly [1, 2, 3];
64
+ };
65
+ backgroundColor: {
66
+ default: "default";
67
+ };
68
+ textColor: {
69
+ default: "default";
70
+ };
71
+ textAlignment: {
72
+ default: "left";
73
+ values: readonly ["left", "center", "right", "justify"];
74
+ };
75
+ };
76
+ }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
77
+ };
78
+ codeBlock: {
79
+ config: {
80
+ type: "codeBlock";
81
+ content: "inline";
82
+ propSchema: {
83
+ language: {
84
+ default: string;
85
+ values: string[];
86
+ };
87
+ };
88
+ };
89
+ implementation: import("@blocknote/core").TiptapBlockImplementation<{
90
+ type: "codeBlock";
91
+ content: "inline";
92
+ propSchema: {
93
+ language: {
94
+ default: string;
95
+ values: string[];
96
+ };
97
+ };
98
+ }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
99
+ };
100
+ bulletListItem: {
101
+ config: {
102
+ type: "bulletListItem";
103
+ content: "inline";
104
+ propSchema: {
105
+ backgroundColor: {
106
+ default: "default";
107
+ };
108
+ textColor: {
109
+ default: "default";
110
+ };
111
+ textAlignment: {
112
+ default: "left";
113
+ values: readonly ["left", "center", "right", "justify"];
114
+ };
115
+ };
116
+ };
117
+ implementation: import("@blocknote/core").TiptapBlockImplementation<{
118
+ type: "bulletListItem";
119
+ content: "inline";
120
+ propSchema: {
121
+ backgroundColor: {
122
+ default: "default";
123
+ };
124
+ textColor: {
125
+ default: "default";
126
+ };
127
+ textAlignment: {
128
+ default: "left";
129
+ values: readonly ["left", "center", "right", "justify"];
130
+ };
131
+ };
132
+ }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
133
+ };
134
+ numberedListItem: {
135
+ config: {
136
+ type: "numberedListItem";
137
+ content: "inline";
138
+ propSchema: {
139
+ backgroundColor: {
140
+ default: "default";
141
+ };
142
+ textColor: {
143
+ default: "default";
144
+ };
145
+ textAlignment: {
146
+ default: "left";
147
+ values: readonly ["left", "center", "right", "justify"];
148
+ };
149
+ };
150
+ };
151
+ implementation: import("@blocknote/core").TiptapBlockImplementation<{
152
+ type: "numberedListItem";
153
+ content: "inline";
154
+ propSchema: {
155
+ backgroundColor: {
156
+ default: "default";
157
+ };
158
+ textColor: {
159
+ default: "default";
160
+ };
161
+ textAlignment: {
162
+ default: "left";
163
+ values: readonly ["left", "center", "right", "justify"];
164
+ };
165
+ };
166
+ }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
167
+ };
168
+ checkListItem: {
169
+ config: {
170
+ type: "checkListItem";
171
+ content: "inline";
172
+ propSchema: {
173
+ checked: {
174
+ default: false;
175
+ };
176
+ backgroundColor: {
177
+ default: "default";
178
+ };
179
+ textColor: {
180
+ default: "default";
181
+ };
182
+ textAlignment: {
183
+ default: "left";
184
+ values: readonly ["left", "center", "right", "justify"];
185
+ };
186
+ };
187
+ };
188
+ implementation: import("@blocknote/core").TiptapBlockImplementation<{
189
+ type: "checkListItem";
190
+ content: "inline";
191
+ propSchema: {
192
+ checked: {
193
+ default: false;
194
+ };
195
+ backgroundColor: {
196
+ default: "default";
197
+ };
198
+ textColor: {
199
+ default: "default";
200
+ };
201
+ textAlignment: {
202
+ default: "left";
203
+ values: readonly ["left", "center", "right", "justify"];
204
+ };
205
+ };
206
+ }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
207
+ };
208
+ table: {
209
+ config: {
210
+ type: "table";
211
+ content: "table";
212
+ propSchema: {
213
+ backgroundColor: {
214
+ default: "default";
215
+ };
216
+ textColor: {
217
+ default: "default";
218
+ };
219
+ };
220
+ };
221
+ implementation: import("@blocknote/core").TiptapBlockImplementation<{
222
+ type: "table";
223
+ content: "table";
224
+ propSchema: {
225
+ backgroundColor: {
226
+ default: "default";
227
+ };
228
+ textColor: {
229
+ default: "default";
230
+ };
231
+ };
232
+ }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
233
+ };
234
+ file: {
235
+ config: {
236
+ type: "file";
237
+ propSchema: {
238
+ backgroundColor: {
239
+ default: "default";
240
+ };
241
+ name: {
242
+ default: "";
243
+ };
244
+ url: {
245
+ default: "";
246
+ };
247
+ caption: {
248
+ default: "";
249
+ };
250
+ };
251
+ content: "none";
252
+ isFileBlock: true;
253
+ };
254
+ implementation: import("@blocknote/core").TiptapBlockImplementation<{
255
+ type: "file";
256
+ propSchema: {
257
+ backgroundColor: {
258
+ default: "default";
259
+ };
260
+ name: {
261
+ default: "";
262
+ };
263
+ url: {
264
+ default: "";
265
+ };
266
+ caption: {
267
+ default: "";
268
+ };
269
+ };
270
+ content: "none";
271
+ isFileBlock: true;
272
+ }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
273
+ };
274
+ image: {
275
+ config: {
276
+ type: "image";
277
+ propSchema: {
278
+ textAlignment: {
279
+ default: "left";
280
+ values: readonly ["left", "center", "right", "justify"];
281
+ };
282
+ backgroundColor: {
283
+ default: "default";
284
+ };
285
+ name: {
286
+ default: "";
287
+ };
288
+ url: {
289
+ default: "";
290
+ };
291
+ caption: {
292
+ default: "";
293
+ };
294
+ showPreview: {
295
+ default: true;
296
+ };
297
+ previewWidth: {
298
+ default: number;
299
+ };
300
+ };
301
+ content: "none";
302
+ isFileBlock: true;
303
+ fileBlockAccept: string[];
304
+ };
305
+ implementation: import("@blocknote/core").TiptapBlockImplementation<{
306
+ type: "image";
307
+ propSchema: {
308
+ textAlignment: {
309
+ default: "left";
310
+ values: readonly ["left", "center", "right", "justify"];
311
+ };
312
+ backgroundColor: {
313
+ default: "default";
314
+ };
315
+ name: {
316
+ default: "";
317
+ };
318
+ url: {
319
+ default: "";
320
+ };
321
+ caption: {
322
+ default: "";
323
+ };
324
+ showPreview: {
325
+ default: true;
326
+ };
327
+ previewWidth: {
328
+ default: number;
329
+ };
330
+ };
331
+ content: "none";
332
+ isFileBlock: true;
333
+ fileBlockAccept: string[];
334
+ }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
335
+ };
336
+ video: {
337
+ config: {
338
+ type: "video";
339
+ propSchema: {
340
+ textAlignment: {
341
+ default: "left";
342
+ values: readonly ["left", "center", "right", "justify"];
343
+ };
344
+ backgroundColor: {
345
+ default: "default";
346
+ };
347
+ name: {
348
+ default: "";
349
+ };
350
+ url: {
351
+ default: "";
352
+ };
353
+ caption: {
354
+ default: "";
355
+ };
356
+ showPreview: {
357
+ default: true;
358
+ };
359
+ previewWidth: {
360
+ default: number;
361
+ };
362
+ };
363
+ content: "none";
364
+ isFileBlock: true;
365
+ fileBlockAccept: string[];
366
+ };
367
+ implementation: import("@blocknote/core").TiptapBlockImplementation<{
368
+ type: "video";
369
+ propSchema: {
370
+ textAlignment: {
371
+ default: "left";
372
+ values: readonly ["left", "center", "right", "justify"];
373
+ };
374
+ backgroundColor: {
375
+ default: "default";
376
+ };
377
+ name: {
378
+ default: "";
379
+ };
380
+ url: {
381
+ default: "";
382
+ };
383
+ caption: {
384
+ default: "";
385
+ };
386
+ showPreview: {
387
+ default: true;
388
+ };
389
+ previewWidth: {
390
+ default: number;
391
+ };
392
+ };
393
+ content: "none";
394
+ isFileBlock: true;
395
+ fileBlockAccept: string[];
396
+ }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
397
+ };
398
+ audio: {
399
+ config: {
400
+ type: "audio";
401
+ propSchema: {
402
+ backgroundColor: {
403
+ default: "default";
404
+ };
405
+ name: {
406
+ default: "";
407
+ };
408
+ url: {
409
+ default: "";
410
+ };
411
+ caption: {
412
+ default: "";
413
+ };
414
+ showPreview: {
415
+ default: true;
416
+ };
417
+ };
418
+ content: "none";
419
+ isFileBlock: true;
420
+ fileBlockAccept: string[];
421
+ };
422
+ implementation: import("@blocknote/core").TiptapBlockImplementation<{
423
+ type: "audio";
424
+ propSchema: {
425
+ backgroundColor: {
426
+ default: "default";
427
+ };
428
+ name: {
429
+ default: "";
430
+ };
431
+ url: {
432
+ default: "";
433
+ };
434
+ caption: {
435
+ default: "";
436
+ };
437
+ showPreview: {
438
+ default: true;
439
+ };
440
+ };
441
+ content: "none";
442
+ isFileBlock: true;
443
+ fileBlockAccept: string[];
444
+ }, any, import("@blocknote/core").InlineContentSchema, import("@blocknote/core").StyleSchema>;
445
+ };
446
+ }>, import("@blocknote/core").InlineContentSchemaFromSpecs<{
447
+ text: {
448
+ config: "text";
449
+ implementation: any;
450
+ };
451
+ link: {
452
+ config: "link";
453
+ implementation: any;
454
+ };
455
+ }>, import("@blocknote/core").StyleSchemaFromSpecs<{
456
+ bold: {
457
+ config: {
458
+ type: string;
459
+ propSchema: "boolean";
460
+ };
461
+ implementation: import("@blocknote/core").StyleImplementation;
462
+ };
463
+ italic: {
464
+ config: {
465
+ type: string;
466
+ propSchema: "boolean";
467
+ };
468
+ implementation: import("@blocknote/core").StyleImplementation;
469
+ };
470
+ underline: {
471
+ config: {
472
+ type: string;
473
+ propSchema: "boolean";
474
+ };
475
+ implementation: import("@blocknote/core").StyleImplementation;
476
+ };
477
+ strike: {
478
+ config: {
479
+ type: string;
480
+ propSchema: "boolean";
481
+ };
482
+ implementation: import("@blocknote/core").StyleImplementation;
483
+ };
484
+ code: {
485
+ config: {
486
+ type: string;
487
+ propSchema: "boolean";
488
+ };
489
+ implementation: import("@blocknote/core").StyleImplementation;
490
+ };
491
+ textColor: {
492
+ config: {
493
+ type: string;
494
+ propSchema: "string";
495
+ };
496
+ implementation: import("@blocknote/core").StyleImplementation;
497
+ };
498
+ backgroundColor: {
499
+ config: {
500
+ type: string;
501
+ propSchema: "string";
502
+ };
503
+ implementation: import("@blocknote/core").StyleImplementation;
504
+ };
505
+ }>>[];
@@ -0,0 +1,20 @@
1
+ import { BlockFromConfig, BlockNoteSchema, BlockSchema, InlineContent, InlineContentSchema, StyleSchema, StyledText, Styles } from "@blocknote/core";
2
+ import { BlockMapping, InlineContentMapping, StyleMapping } from "./mapping.js";
3
+ export declare abstract class Transformer<B extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema, RB, RI, RS, TS> {
4
+ readonly mappings: {
5
+ blockMapping: BlockMapping<B, I, S, RB, RI>;
6
+ inlineContentMapping: InlineContentMapping<I, S, RI, TS>;
7
+ styleMapping: StyleMapping<S, RS>;
8
+ };
9
+ constructor(_schema: BlockNoteSchema<B, I, S>, // only used for type inference
10
+ mappings: {
11
+ blockMapping: BlockMapping<B, I, S, RB, RI>;
12
+ inlineContentMapping: InlineContentMapping<I, S, RI, TS>;
13
+ styleMapping: StyleMapping<S, RS>;
14
+ });
15
+ mapStyles(styles: Styles<S>): RS[];
16
+ mapInlineContent(inlineContent: InlineContent<I, S>): RI;
17
+ transformInlineContent(inlineContentArray: InlineContent<I, S>[]): RI[];
18
+ abstract transformStyledText(styledText: StyledText<S>): TS;
19
+ mapBlock(block: BlockFromConfig<B[keyof B], I, S>, nestingLevel: number, numberedListIndex: number): RB;
20
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ *
3
+ * Helper functions so that we can import files both on vitest, browser and node
4
+ * TODO: should find a way to test automatically in all environments
5
+ */
6
+ /// <reference types="node" />
7
+ export declare function loadFileDataUrl(requireUrl: {
8
+ default: string;
9
+ }, mimeType: string): Promise<string>;
10
+ export declare function loadFontDataUrl(requireUrl: {
11
+ default: string;
12
+ }): Promise<string>;
13
+ export declare function loadFileBuffer(requireUrl: {
14
+ default: string;
15
+ }): Promise<Buffer | ArrayBuffer>;
16
+ /**
17
+ * usage:
18
+ *
19
+ * await loadFontDataUrl(
20
+ await import("../fonts/inter/Inter_18pt-Italic.ttf")
21
+ );
22
+ */
@@ -0,0 +1,4 @@
1
+ export declare function getImageDimensions(blob: Blob): Promise<{
2
+ width: number;
3
+ height: number;
4
+ }>;
@@ -0,0 +1,2 @@
1
+ import { yDocToProsemirrorJSON, yXmlFragmentToProsemirrorJSON } from "y-prosemirror";
2
+ export { yDocToProsemirrorJSON, yXmlFragmentToProsemirrorJSON };