remark-docx 0.3.28 → 0.3.29
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/lib/chunk-CMqjfN_6.cjs +1 -0
- package/lib/index.cjs +2 -600
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.js +468 -596
- package/lib/index.js.map +1 -1
- package/lib/mdast-util-to-docx.d.ts +2 -2
- package/lib/plugin.d.ts +3 -3
- package/lib/plugins/html/index.cjs +2 -28
- package/lib/plugins/html/index.cjs.map +1 -1
- package/lib/plugins/html/index.d.ts +1 -1
- package/lib/plugins/html/index.js +10 -25
- package/lib/plugins/html/index.js.map +1 -1
- package/lib/plugins/image/index.cjs +2 -129
- package/lib/plugins/image/index.cjs.map +1 -1
- package/lib/plugins/image/index.d.ts +1 -1
- package/lib/plugins/image/index.js +87 -124
- package/lib/plugins/image/index.js.map +1 -1
- package/lib/plugins/latex/index.cjs +2 -123
- package/lib/plugins/latex/index.cjs.map +1 -1
- package/lib/plugins/latex/index.d.ts +1 -7
- package/lib/plugins/latex/index.js +73 -119
- package/lib/plugins/latex/index.js.map +1 -1
- package/lib/plugins/mermaid/index.cjs +2 -77
- package/lib/plugins/mermaid/index.cjs.map +1 -1
- package/lib/plugins/mermaid/index.d.ts +1 -1
- package/lib/plugins/mermaid/index.js +46 -73
- package/lib/plugins/mermaid/index.js.map +1 -1
- package/lib/plugins/shiki/index.cjs +2 -113
- package/lib/plugins/shiki/index.cjs.map +1 -1
- package/lib/plugins/shiki/index.d.ts +2 -2
- package/lib/plugins/shiki/index.js +60 -109
- package/lib/plugins/shiki/index.js.map +1 -1
- package/lib/types.d.ts +3 -3
- package/lib/utils-BBifD5si.js +16 -0
- package/lib/utils-BBifD5si.js.map +1 -0
- package/lib/utils-D_YAYv4R.cjs +2 -0
- package/lib/utils-D_YAYv4R.cjs.map +1 -0
- package/package.json +5 -6
- package/lib/utils-BVB8aSvE.js +0 -25
- package/lib/utils-BVB8aSvE.js.map +0 -1
- package/lib/utils-KFMY7wxz.js +0 -22
- package/lib/utils-KFMY7wxz.js.map +0 -1
package/lib/index.js
CHANGED
|
@@ -1,598 +1,470 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { definitions } from
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
};
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
};
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
// https://docx.js.org/#/usage/hyperlinks?id=styling-hyperlinks
|
|
467
|
-
options.style = HYPERLINK_STYLE_ID;
|
|
468
|
-
}
|
|
469
|
-
if (rtl) {
|
|
470
|
-
options.rightToLeft = true;
|
|
471
|
-
}
|
|
472
|
-
return new TextRun(options);
|
|
473
|
-
};
|
|
474
|
-
const buildEmphasis = ({ children }, ctx) => {
|
|
475
|
-
return ctx.render(children, {
|
|
476
|
-
...ctx,
|
|
477
|
-
style: { ...ctx.style, italic: true },
|
|
478
|
-
});
|
|
479
|
-
};
|
|
480
|
-
const buildStrong = ({ children }, ctx) => {
|
|
481
|
-
return ctx.render(children, {
|
|
482
|
-
...ctx,
|
|
483
|
-
style: { ...ctx.style, bold: true },
|
|
484
|
-
});
|
|
485
|
-
};
|
|
486
|
-
const buildDelete = ({ children }, ctx) => {
|
|
487
|
-
return ctx.render(children, {
|
|
488
|
-
...ctx,
|
|
489
|
-
style: { ...ctx.style, strike: true },
|
|
490
|
-
});
|
|
491
|
-
};
|
|
492
|
-
const buildInlineCode = ({ value }, ctx) => {
|
|
493
|
-
return buildText({ value }, {
|
|
494
|
-
...ctx,
|
|
495
|
-
style: { ...ctx.style, inlineCode: true },
|
|
496
|
-
});
|
|
497
|
-
};
|
|
498
|
-
const buildBreak = () => {
|
|
499
|
-
return new TextRun({ text: "", break: 1 });
|
|
500
|
-
};
|
|
501
|
-
const buildLink = ({ children, url }, ctx) => {
|
|
502
|
-
if (url.startsWith("#")) {
|
|
503
|
-
// TODO support anchor link
|
|
504
|
-
return ctx.render(children);
|
|
505
|
-
}
|
|
506
|
-
return new ExternalHyperlink({
|
|
507
|
-
link: url,
|
|
508
|
-
children: ctx.render(children, {
|
|
509
|
-
...ctx,
|
|
510
|
-
style: { ...ctx.style, link: true },
|
|
511
|
-
}),
|
|
512
|
-
});
|
|
513
|
-
};
|
|
514
|
-
const buildLinkReference = ({ children, identifier }, ctx) => {
|
|
515
|
-
const def = ctx.definition(identifier);
|
|
516
|
-
if (def == null) {
|
|
517
|
-
return ctx.render(children);
|
|
518
|
-
}
|
|
519
|
-
return buildLink({ children, url: def.url }, ctx);
|
|
520
|
-
};
|
|
521
|
-
const buildImage = (node, ctx) => {
|
|
522
|
-
var _a, _b;
|
|
523
|
-
const image = ctx.images.get(node.url);
|
|
524
|
-
if (!image) {
|
|
525
|
-
return null;
|
|
526
|
-
}
|
|
527
|
-
let { width, height } = image;
|
|
528
|
-
const pageWidthInch = ctx.width / 1440;
|
|
529
|
-
const DPI = 96;
|
|
530
|
-
const pageWidthPx = pageWidthInch * DPI;
|
|
531
|
-
if (width > pageWidthPx) {
|
|
532
|
-
const scale = pageWidthPx / width;
|
|
533
|
-
width *= scale;
|
|
534
|
-
height *= scale;
|
|
535
|
-
}
|
|
536
|
-
const altText = node.alt || node.title
|
|
537
|
-
? {
|
|
538
|
-
name: "",
|
|
539
|
-
description: (_a = node.alt) !== null && _a !== void 0 ? _a : undefined,
|
|
540
|
-
title: (_b = node.title) !== null && _b !== void 0 ? _b : undefined,
|
|
541
|
-
}
|
|
542
|
-
: undefined;
|
|
543
|
-
if (image.type === "svg") {
|
|
544
|
-
const { type, data, fallback } = image;
|
|
545
|
-
return new ImageRun({
|
|
546
|
-
type: type,
|
|
547
|
-
data: data,
|
|
548
|
-
transformation: {
|
|
549
|
-
width,
|
|
550
|
-
height,
|
|
551
|
-
},
|
|
552
|
-
// https://github.com/dolanmiu/docx/issues/1162#issuecomment-3228368003
|
|
553
|
-
fallback: { type: "png", data: fallback },
|
|
554
|
-
altText,
|
|
555
|
-
});
|
|
556
|
-
}
|
|
557
|
-
const { type, data } = image;
|
|
558
|
-
return new ImageRun({
|
|
559
|
-
type: type,
|
|
560
|
-
data: data,
|
|
561
|
-
transformation: {
|
|
562
|
-
width,
|
|
563
|
-
height,
|
|
564
|
-
},
|
|
565
|
-
altText,
|
|
566
|
-
});
|
|
567
|
-
};
|
|
568
|
-
const buildImageReference = (node, ctx) => {
|
|
569
|
-
const def = ctx.definition(node.identifier);
|
|
570
|
-
if (def == null) {
|
|
571
|
-
return null;
|
|
572
|
-
}
|
|
573
|
-
return buildImage({ url: def.url, alt: node.alt, title: def.title }, ctx);
|
|
574
|
-
};
|
|
575
|
-
const buildFootnoteDefinition = ({ children, identifier }, ctx) => {
|
|
576
|
-
const contents = ctx.render(children).filter((c) => c instanceof Paragraph);
|
|
577
|
-
ctx.footnote.set(ctx.footnote.id(identifier), contents);
|
|
578
|
-
return null;
|
|
579
|
-
};
|
|
580
|
-
const buildFootnoteReference = ({ identifier }, ctx) => {
|
|
581
|
-
return new FootnoteReferenceRun(ctx.footnote.id(identifier));
|
|
582
|
-
};
|
|
583
|
-
const noop = () => {
|
|
584
|
-
return null;
|
|
585
|
-
};
|
|
586
|
-
const fallbackText = (node, ctx) => {
|
|
587
|
-
warnOnce(`${node.type} node is not supported without plugins, falling back to text.`);
|
|
588
|
-
return buildText({ value: node.value }, ctx);
|
|
589
|
-
};
|
|
590
|
-
|
|
591
|
-
const plugin = function (opts) {
|
|
592
|
-
this.compiler = (node) => {
|
|
593
|
-
return mdastToDocx(node, opts);
|
|
594
|
-
};
|
|
1
|
+
import { n as e } from "./utils-BBifD5si.js";
|
|
2
|
+
import { AlignmentType as t, Document as n, ExternalHyperlink as r, FootnoteReferenceRun as i, HeadingLevel as a, ImageRun as o, LevelFormat as s, Packer as c, PageBreak as l, Paragraph as u, Table as d, TableCell as f, TableRow as p, TextRun as m, sectionMarginDefaults as ee, sectionPageSizeDefaults as te } from "docx";
|
|
3
|
+
import { definitions as h } from "mdast-util-definitions";
|
|
4
|
+
import g from "deepmerge";
|
|
5
|
+
//#region src/mdast-util-to-docx.ts
|
|
6
|
+
var _ = "bullet", v = "ordered", y = "task-complete", b = "task-incomplete", x = "Hyperlink", S = (e) => ({
|
|
7
|
+
hanging: 400,
|
|
8
|
+
left: 400 * (e + 1)
|
|
9
|
+
}), ne = () => {
|
|
10
|
+
let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
|
|
11
|
+
return {
|
|
12
|
+
id: (t) => {
|
|
13
|
+
let n = e.get(t);
|
|
14
|
+
return n ?? e.set(t, n = e.size + 1), n;
|
|
15
|
+
},
|
|
16
|
+
set: (e, n) => {
|
|
17
|
+
t.set(e, n);
|
|
18
|
+
},
|
|
19
|
+
toConfig: () => t.entries().reduce((e, [t, n]) => (e[t] = { children: n }, e), {})
|
|
20
|
+
};
|
|
21
|
+
}, re = () => {
|
|
22
|
+
let e = 1, t = [];
|
|
23
|
+
return {
|
|
24
|
+
createId: () => {
|
|
25
|
+
let n = `${v}-${e++}`;
|
|
26
|
+
return t.push(n), n;
|
|
27
|
+
},
|
|
28
|
+
getIds: () => t
|
|
29
|
+
};
|
|
30
|
+
}, ie = (e, t) => e.reduceRight((e, t) => {
|
|
31
|
+
for (let [n, r] of Object.entries(t)) {
|
|
32
|
+
let t = e[n];
|
|
33
|
+
e[n] = t ? (e, n) => r(e, n) || t(e, n) : r;
|
|
34
|
+
}
|
|
35
|
+
return e;
|
|
36
|
+
}, t), C = (e) => e.map(({ format: e, text: n }, r) => ({
|
|
37
|
+
level: r,
|
|
38
|
+
format: s[e],
|
|
39
|
+
text: n,
|
|
40
|
+
alignment: t.LEFT,
|
|
41
|
+
style: { paragraph: { indent: S(r) } }
|
|
42
|
+
})), w = (e, t) => {
|
|
43
|
+
if (t.quote != null && (e.indent = S(t.quote + 1)), t.list) {
|
|
44
|
+
let { level: n, meta: r } = t.list;
|
|
45
|
+
r.type === "task" ? e.numbering = {
|
|
46
|
+
reference: r.checked ? y : b,
|
|
47
|
+
level: n
|
|
48
|
+
} : r.type === "ordered" ? e.numbering = {
|
|
49
|
+
reference: r.reference,
|
|
50
|
+
level: n
|
|
51
|
+
} : e.numbering = {
|
|
52
|
+
reference: _,
|
|
53
|
+
level: n
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return t.rtl && (e.bidirectional = !0), new u(e);
|
|
57
|
+
}, T = async (t, { plugins: r = [], title: i, subject: a, creator: o, keywords: s, description: l, styles: u, size: d, margin: f, orientation: p, columns: m, spacing: v, direction: x, background: S, thematicBreak: w = "page", orderedListFormat: T } = {}) => {
|
|
58
|
+
let z = h(t), B = re(), V = ne(), H = /* @__PURE__ */ new Map(), me = {
|
|
59
|
+
root: t,
|
|
60
|
+
images: H,
|
|
61
|
+
definition: z
|
|
62
|
+
}, he = ie(await Promise.all(r.map((e) => e(me))), {
|
|
63
|
+
paragraph: ae,
|
|
64
|
+
heading: E,
|
|
65
|
+
thematicBreak: D,
|
|
66
|
+
blockquote: O,
|
|
67
|
+
list: oe,
|
|
68
|
+
listItem: se,
|
|
69
|
+
table: ce,
|
|
70
|
+
tableRow: I,
|
|
71
|
+
tableCell: I,
|
|
72
|
+
html: L,
|
|
73
|
+
code: R,
|
|
74
|
+
definition: I,
|
|
75
|
+
footnoteDefinition: P,
|
|
76
|
+
text: k,
|
|
77
|
+
emphasis: le,
|
|
78
|
+
strong: ue,
|
|
79
|
+
delete: de,
|
|
80
|
+
inlineCode: fe,
|
|
81
|
+
break: pe,
|
|
82
|
+
link: A,
|
|
83
|
+
linkReference: j,
|
|
84
|
+
image: M,
|
|
85
|
+
imageReference: N,
|
|
86
|
+
footnoteReference: F,
|
|
87
|
+
math: L,
|
|
88
|
+
inlineMath: L
|
|
89
|
+
}), U = (t, n) => {
|
|
90
|
+
let r = he[t.type];
|
|
91
|
+
if (!r) return e(`${t.type} node is not supported without plugins.`), null;
|
|
92
|
+
let i = r(t, n);
|
|
93
|
+
return i ? Array.isArray(i) ? i : [i] : null;
|
|
94
|
+
}, { WIDTH: W, HEIGHT: G } = te;
|
|
95
|
+
d && (d.width != null && (W = d.width), d.height != null && (G = d.height));
|
|
96
|
+
let { TOP: K, LEFT: q, BOTTOM: J, RIGHT: Y } = ee;
|
|
97
|
+
f && (f.top != null && (K = f.top), f.left != null && (q = f.left), f.bottom != null && (J = f.bottom), f.right != null && (Y = f.right));
|
|
98
|
+
let ge = {
|
|
99
|
+
render(e, t) {
|
|
100
|
+
let n = [];
|
|
101
|
+
for (let r of e) {
|
|
102
|
+
let e = U(r, t ?? this);
|
|
103
|
+
e && n.push(...e);
|
|
104
|
+
}
|
|
105
|
+
return n;
|
|
106
|
+
},
|
|
107
|
+
width: W - q - Y,
|
|
108
|
+
style: {},
|
|
109
|
+
thematicBreak: w,
|
|
110
|
+
rtl: x === "rtl",
|
|
111
|
+
definition: z,
|
|
112
|
+
images: H,
|
|
113
|
+
footnote: V,
|
|
114
|
+
orderedId: B.createId
|
|
115
|
+
}, X = [[]];
|
|
116
|
+
for (let e of t.children) {
|
|
117
|
+
let t = U(e, ge);
|
|
118
|
+
t && (t.length ? X[X.length - 1].push(...t) : X.push([]));
|
|
119
|
+
}
|
|
120
|
+
let _e = C(T ?? [
|
|
121
|
+
{
|
|
122
|
+
text: "%1.",
|
|
123
|
+
format: "DECIMAL"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
text: "%2.",
|
|
127
|
+
format: "DECIMAL"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
text: "%3.",
|
|
131
|
+
format: "DECIMAL"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
text: "%4.",
|
|
135
|
+
format: "DECIMAL"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
text: "%5.",
|
|
139
|
+
format: "DECIMAL"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
text: "%6.",
|
|
143
|
+
format: "DECIMAL"
|
|
144
|
+
}
|
|
145
|
+
]), ve = {
|
|
146
|
+
column: m ? { count: m } : void 0,
|
|
147
|
+
page: {
|
|
148
|
+
textDirection: x === "vertical" ? "tbRl" : void 0,
|
|
149
|
+
size: {
|
|
150
|
+
width: W,
|
|
151
|
+
height: G,
|
|
152
|
+
orientation: p
|
|
153
|
+
},
|
|
154
|
+
margin: {
|
|
155
|
+
top: K,
|
|
156
|
+
left: q,
|
|
157
|
+
bottom: J,
|
|
158
|
+
right: Y
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}, Z = new n({
|
|
162
|
+
title: i,
|
|
163
|
+
subject: a,
|
|
164
|
+
creator: o,
|
|
165
|
+
keywords: s,
|
|
166
|
+
description: l,
|
|
167
|
+
styles: g({ default: { document: { paragraph: { spacing: v ? { after: v } : void 0 } } } }, u || {}),
|
|
168
|
+
background: S,
|
|
169
|
+
sections: X.filter((e) => e.length).map((e) => ({
|
|
170
|
+
properties: ve,
|
|
171
|
+
children: e
|
|
172
|
+
})),
|
|
173
|
+
footnotes: V.toConfig(),
|
|
174
|
+
numbering: { config: [
|
|
175
|
+
{
|
|
176
|
+
reference: _,
|
|
177
|
+
levels: C([
|
|
178
|
+
{
|
|
179
|
+
text: "●",
|
|
180
|
+
format: "BULLET"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
text: "○",
|
|
184
|
+
format: "BULLET"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
text: "■",
|
|
188
|
+
format: "BULLET"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
text: "●",
|
|
192
|
+
format: "BULLET"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
text: "○",
|
|
196
|
+
format: "BULLET"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
text: "■",
|
|
200
|
+
format: "BULLET"
|
|
201
|
+
}
|
|
202
|
+
])
|
|
203
|
+
},
|
|
204
|
+
...B.getIds().map((e) => ({
|
|
205
|
+
reference: e,
|
|
206
|
+
levels: _e
|
|
207
|
+
})),
|
|
208
|
+
{
|
|
209
|
+
reference: y,
|
|
210
|
+
levels: C([
|
|
211
|
+
{
|
|
212
|
+
text: "☑",
|
|
213
|
+
format: "BULLET"
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
text: "☑",
|
|
217
|
+
format: "BULLET"
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
text: "☑",
|
|
221
|
+
format: "BULLET"
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
text: "☑",
|
|
225
|
+
format: "BULLET"
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
text: "☑",
|
|
229
|
+
format: "BULLET"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
text: "☑",
|
|
233
|
+
format: "BULLET"
|
|
234
|
+
}
|
|
235
|
+
])
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
reference: b,
|
|
239
|
+
levels: C([
|
|
240
|
+
{
|
|
241
|
+
text: "☐",
|
|
242
|
+
format: "BULLET"
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
text: "☐",
|
|
246
|
+
format: "BULLET"
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
text: "☐",
|
|
250
|
+
format: "BULLET"
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
text: "☐",
|
|
254
|
+
format: "BULLET"
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
text: "☐",
|
|
258
|
+
format: "BULLET"
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
text: "☐",
|
|
262
|
+
format: "BULLET"
|
|
263
|
+
}
|
|
264
|
+
])
|
|
265
|
+
}
|
|
266
|
+
] }
|
|
267
|
+
}), Q = "default-bullet-numbering", $ = Z.numbering;
|
|
268
|
+
return $.abstractNumberingMap.delete(Q), $.concreteNumberingMap.delete(Q), c.toArrayBuffer(Z);
|
|
269
|
+
}, ae = ({ children: e }, t) => w({ children: t.render(e) }, t), E = ({ children: e, depth: t }, n) => {
|
|
270
|
+
let r;
|
|
271
|
+
switch (t) {
|
|
272
|
+
case 1:
|
|
273
|
+
r = "TITLE";
|
|
274
|
+
break;
|
|
275
|
+
case 2:
|
|
276
|
+
r = "HEADING_1";
|
|
277
|
+
break;
|
|
278
|
+
case 3:
|
|
279
|
+
r = "HEADING_2";
|
|
280
|
+
break;
|
|
281
|
+
case 4:
|
|
282
|
+
r = "HEADING_3";
|
|
283
|
+
break;
|
|
284
|
+
case 5:
|
|
285
|
+
r = "HEADING_4";
|
|
286
|
+
break;
|
|
287
|
+
case 6:
|
|
288
|
+
r = "HEADING_5";
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
return w({
|
|
292
|
+
heading: a[r],
|
|
293
|
+
outlineLevel: t - 1,
|
|
294
|
+
children: n.render(e)
|
|
295
|
+
}, n);
|
|
296
|
+
}, D = (e, t) => {
|
|
297
|
+
switch (t.thematicBreak) {
|
|
298
|
+
case "page": return new u({ children: [new l()] });
|
|
299
|
+
case "section": return [];
|
|
300
|
+
case "line": return new u({ thematicBreak: !0 });
|
|
301
|
+
}
|
|
302
|
+
}, O = ({ children: e }, t) => t.render(e, {
|
|
303
|
+
...t,
|
|
304
|
+
quote: t.quote == null ? 0 : t.quote + 1
|
|
305
|
+
}), oe = ({ children: e, ordered: t }, n) => {
|
|
306
|
+
let r = n.list, i;
|
|
307
|
+
return i = t ? {
|
|
308
|
+
type: "ordered",
|
|
309
|
+
reference: r && r.meta.type === "ordered" ? r.meta.reference : n.orderedId()
|
|
310
|
+
} : { type: "bullet" }, n.render(e, {
|
|
311
|
+
...n,
|
|
312
|
+
list: {
|
|
313
|
+
level: r ? r.level + 1 : 0,
|
|
314
|
+
meta: i
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
}, se = ({ children: e, checked: t }, n) => {
|
|
318
|
+
let r = n.list;
|
|
319
|
+
return r && t != null && (r = {
|
|
320
|
+
level: r.level,
|
|
321
|
+
meta: {
|
|
322
|
+
type: "task",
|
|
323
|
+
checked: t
|
|
324
|
+
}
|
|
325
|
+
}), n.render(e, {
|
|
326
|
+
...n,
|
|
327
|
+
list: r
|
|
328
|
+
});
|
|
329
|
+
}, ce = ({ children: e, align: n }, r) => {
|
|
330
|
+
let i = n?.map((e) => {
|
|
331
|
+
switch (e) {
|
|
332
|
+
case "left": return "LEFT";
|
|
333
|
+
case "right": return "RIGHT";
|
|
334
|
+
case "center": return "CENTER";
|
|
335
|
+
default: return "LEFT";
|
|
336
|
+
}
|
|
337
|
+
}), a = e[0].children.length, o = r.width / a, s = {
|
|
338
|
+
columnWidths: Array.from({ length: a }).map(() => o),
|
|
339
|
+
rows: e.map((e) => new p({ children: e.children.map((e, n) => new f({
|
|
340
|
+
width: {
|
|
341
|
+
size: o,
|
|
342
|
+
type: "dxa"
|
|
343
|
+
},
|
|
344
|
+
children: [new u({
|
|
345
|
+
alignment: t[i?.[n] ?? "LEFT"],
|
|
346
|
+
children: r.render(e.children, {
|
|
347
|
+
...r,
|
|
348
|
+
rtl: void 0
|
|
349
|
+
})
|
|
350
|
+
})]
|
|
351
|
+
})) }))
|
|
352
|
+
};
|
|
353
|
+
return r.rtl && (s.visuallyRightToLeft = !0), new d(s);
|
|
354
|
+
}, k = ({ value: e }, { style: t, rtl: n }) => {
|
|
355
|
+
let r = {
|
|
356
|
+
text: e,
|
|
357
|
+
bold: t.bold,
|
|
358
|
+
italics: t.italic,
|
|
359
|
+
strike: t.strike
|
|
360
|
+
};
|
|
361
|
+
return t.inlineCode && (r.highlight = "lightGray"), t.link && (r.style = x), n && (r.rightToLeft = !0), new m(r);
|
|
362
|
+
}, le = ({ children: e }, t) => t.render(e, {
|
|
363
|
+
...t,
|
|
364
|
+
style: {
|
|
365
|
+
...t.style,
|
|
366
|
+
italic: !0
|
|
367
|
+
}
|
|
368
|
+
}), ue = ({ children: e }, t) => t.render(e, {
|
|
369
|
+
...t,
|
|
370
|
+
style: {
|
|
371
|
+
...t.style,
|
|
372
|
+
bold: !0
|
|
373
|
+
}
|
|
374
|
+
}), de = ({ children: e }, t) => t.render(e, {
|
|
375
|
+
...t,
|
|
376
|
+
style: {
|
|
377
|
+
...t.style,
|
|
378
|
+
strike: !0
|
|
379
|
+
}
|
|
380
|
+
}), fe = ({ value: e }, t) => k({
|
|
381
|
+
type: "text",
|
|
382
|
+
value: e
|
|
383
|
+
}, {
|
|
384
|
+
...t,
|
|
385
|
+
style: {
|
|
386
|
+
...t.style,
|
|
387
|
+
inlineCode: !0
|
|
388
|
+
}
|
|
389
|
+
}), pe = () => new m({
|
|
390
|
+
text: "",
|
|
391
|
+
break: 1
|
|
392
|
+
}), A = ({ children: e, url: t }, n) => t.startsWith("#") ? n.render(e) : new r({
|
|
393
|
+
link: t,
|
|
394
|
+
children: n.render(e, {
|
|
395
|
+
...n,
|
|
396
|
+
style: {
|
|
397
|
+
...n.style,
|
|
398
|
+
link: !0
|
|
399
|
+
}
|
|
400
|
+
})
|
|
401
|
+
}), j = ({ children: e, identifier: t }, n) => {
|
|
402
|
+
let r = n.definition(t);
|
|
403
|
+
return r == null ? n.render(e) : A({
|
|
404
|
+
type: "link",
|
|
405
|
+
children: e,
|
|
406
|
+
url: r.url
|
|
407
|
+
}, n);
|
|
408
|
+
}, M = (e, t) => {
|
|
409
|
+
let n = t.images.get(e.url);
|
|
410
|
+
if (!n) return null;
|
|
411
|
+
let { width: r, height: i } = n, a = t.width / 1440 * 96;
|
|
412
|
+
if (r > a) {
|
|
413
|
+
let e = a / r;
|
|
414
|
+
r *= e, i *= e;
|
|
415
|
+
}
|
|
416
|
+
let s = e.alt || e.title ? {
|
|
417
|
+
name: "",
|
|
418
|
+
description: e.alt ?? void 0,
|
|
419
|
+
title: e.title ?? void 0
|
|
420
|
+
} : void 0;
|
|
421
|
+
if (n.type === "svg") {
|
|
422
|
+
let { type: e, data: t, fallback: a } = n;
|
|
423
|
+
return new o({
|
|
424
|
+
type: e,
|
|
425
|
+
data: t,
|
|
426
|
+
transformation: {
|
|
427
|
+
width: r,
|
|
428
|
+
height: i
|
|
429
|
+
},
|
|
430
|
+
fallback: {
|
|
431
|
+
type: "png",
|
|
432
|
+
data: a
|
|
433
|
+
},
|
|
434
|
+
altText: s
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
let { type: c, data: l } = n;
|
|
438
|
+
return new o({
|
|
439
|
+
type: c,
|
|
440
|
+
data: l,
|
|
441
|
+
transformation: {
|
|
442
|
+
width: r,
|
|
443
|
+
height: i
|
|
444
|
+
},
|
|
445
|
+
altText: s
|
|
446
|
+
});
|
|
447
|
+
}, N = (e, t) => {
|
|
448
|
+
let n = t.definition(e.identifier);
|
|
449
|
+
return n == null ? null : M({
|
|
450
|
+
type: "image",
|
|
451
|
+
url: n.url,
|
|
452
|
+
alt: e.alt,
|
|
453
|
+
title: n.title
|
|
454
|
+
}, t);
|
|
455
|
+
}, P = ({ children: e, identifier: t }, n) => {
|
|
456
|
+
let r = n.render(e).filter((e) => e instanceof u);
|
|
457
|
+
return n.footnote.set(n.footnote.id(t), r), null;
|
|
458
|
+
}, F = ({ identifier: e }, t) => new i(t.footnote.id(e)), I = () => null, L = (t, n) => (e(`${t.type} node is not supported without plugins, falling back to text.`), k({
|
|
459
|
+
type: "text",
|
|
460
|
+
value: t.value
|
|
461
|
+
}, n)), R = (t, n) => (e(`${t.type} node is not supported without plugins, falling back to text.`), w({ children: t.value.split(/\r?\n/).map((e, t) => new m({
|
|
462
|
+
text: e,
|
|
463
|
+
break: t === 0 ? void 0 : 1
|
|
464
|
+
})) }, n)), z = function(e) {
|
|
465
|
+
this.compiler = (t) => T(t, e);
|
|
595
466
|
};
|
|
467
|
+
//#endregion
|
|
468
|
+
export { z as default };
|
|
596
469
|
|
|
597
|
-
|
|
598
|
-
//# sourceMappingURL=index.js.map
|
|
470
|
+
//# sourceMappingURL=index.js.map
|