jspdf-md-renderer 3.1.0 → 3.2.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/README.md +34 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +2 -2
- package/dist/index.mjs +587 -470
- package/dist/index.umd.js +2 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,23 +1,90 @@
|
|
|
1
|
-
import { marked as
|
|
2
|
-
import
|
|
1
|
+
import { marked as j } from "marked";
|
|
2
|
+
import O from "jspdf-autotable";
|
|
3
3
|
var u = /* @__PURE__ */ ((t) => (t.Heading = "heading", t.Paragraph = "paragraph", t.List = "list", t.ListItem = "list_item", t.Blockquote = "blockquote", t.Code = "code", t.CodeSpan = "codespan", t.Table = "table", t.Html = "html", t.Hr = "hr", t.Image = "image", t.Link = "link", t.Strong = "strong", t.Em = "em", t.TableHeader = "table_header", t.TableCell = "table_cell", t.Raw = "raw", t.Text = "text", t))(u || {});
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
return
|
|
4
|
+
const A = "__jmr_", G = /(!\[[^\]]*\]\()([^)]+)(\))\s*\{([^}]+)\}/g, q = /(\w+)\s*=\s*(\w+)/g, B = ["left", "center", "right"], U = (t) => {
|
|
5
|
+
const e = [];
|
|
6
|
+
return t.width !== void 0 && e.push(`w=${t.width}`), t.height !== void 0 && e.push(`h=${t.height}`), t.align && e.push(`a=${t.align}`), e.length > 0 ? `#${A}${e.join("&")}` : "";
|
|
7
|
+
}, J = (t) => {
|
|
8
|
+
const e = {};
|
|
9
|
+
let s;
|
|
10
|
+
for (; (s = q.exec(t)) !== null; ) {
|
|
11
|
+
const c = s[1].toLowerCase(), g = s[2];
|
|
12
|
+
switch (c) {
|
|
13
|
+
case "width":
|
|
14
|
+
case "w": {
|
|
15
|
+
const r = parseInt(g, 10);
|
|
16
|
+
!isNaN(r) && r > 0 && (e.width = r);
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
case "height":
|
|
20
|
+
case "h": {
|
|
21
|
+
const r = parseInt(g, 10);
|
|
22
|
+
!isNaN(r) && r > 0 && (e.height = r);
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
case "align": {
|
|
26
|
+
const r = g.toLowerCase();
|
|
27
|
+
B.includes(
|
|
28
|
+
r
|
|
29
|
+
) && (e.align = r);
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return e;
|
|
35
|
+
}, V = (t) => t.replace(
|
|
36
|
+
G,
|
|
37
|
+
(e, s, c, g, r) => {
|
|
38
|
+
const l = J(r), i = U(l);
|
|
39
|
+
return `${s}${c}${i}${g}`;
|
|
40
|
+
}
|
|
41
|
+
), K = (t) => {
|
|
42
|
+
const e = t.indexOf(`#${A}`);
|
|
43
|
+
if (e === -1)
|
|
44
|
+
return { cleanHref: t, attrs: {} };
|
|
45
|
+
const s = t.substring(0, e), c = t.substring(e + 1 + A.length), g = {}, r = c.split("&");
|
|
46
|
+
for (const l of r) {
|
|
47
|
+
const [i, a] = l.split("=");
|
|
48
|
+
switch (i) {
|
|
49
|
+
case "w": {
|
|
50
|
+
const p = parseInt(a, 10);
|
|
51
|
+
!isNaN(p) && p > 0 && (g.width = p);
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
case "h": {
|
|
55
|
+
const p = parseInt(a, 10);
|
|
56
|
+
!isNaN(p) && p > 0 && (g.height = p);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
case "a": {
|
|
60
|
+
B.includes(
|
|
61
|
+
a
|
|
62
|
+
) && (g.align = a);
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return { cleanHref: s, attrs: g };
|
|
68
|
+
}, Q = async (t) => {
|
|
69
|
+
const e = V(t), s = await j.lexer(e, {
|
|
70
|
+
async: !0,
|
|
71
|
+
gfm: !0
|
|
72
|
+
});
|
|
73
|
+
return W(s);
|
|
7
74
|
}, W = (t) => {
|
|
8
|
-
const
|
|
75
|
+
const e = [];
|
|
9
76
|
return t.forEach((s) => {
|
|
10
77
|
try {
|
|
11
|
-
const
|
|
12
|
-
|
|
78
|
+
const c = Z[s.type];
|
|
79
|
+
c ? e.push(c(s)) : e.push({
|
|
13
80
|
type: u.Raw,
|
|
14
81
|
content: s.raw
|
|
15
82
|
});
|
|
16
|
-
} catch (
|
|
17
|
-
console.error("Failed to handle token ==>", s,
|
|
83
|
+
} catch (c) {
|
|
84
|
+
console.error("Failed to handle token ==>", s, c);
|
|
18
85
|
}
|
|
19
|
-
}),
|
|
20
|
-
},
|
|
86
|
+
}), e;
|
|
87
|
+
}, Z = {
|
|
21
88
|
[u.Heading]: (t) => ({
|
|
22
89
|
type: u.Heading,
|
|
23
90
|
depth: t.depth,
|
|
@@ -47,22 +114,28 @@ const j = async (t) => {
|
|
|
47
114
|
}),
|
|
48
115
|
[u.Table]: (t) => ({
|
|
49
116
|
type: u.Table,
|
|
50
|
-
header: t.header.map((
|
|
117
|
+
header: t.header.map((e) => ({
|
|
51
118
|
type: u.TableHeader,
|
|
52
|
-
content:
|
|
119
|
+
content: e.text
|
|
53
120
|
})),
|
|
54
121
|
rows: t.rows.map(
|
|
55
|
-
(
|
|
122
|
+
(e) => e.map((s) => ({
|
|
56
123
|
type: u.TableCell,
|
|
57
124
|
content: s.text
|
|
58
125
|
}))
|
|
59
126
|
)
|
|
60
127
|
}),
|
|
61
|
-
[u.Image]: (t) =>
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
128
|
+
[u.Image]: (t) => {
|
|
129
|
+
const { cleanHref: e, attrs: s } = K(t.href);
|
|
130
|
+
return {
|
|
131
|
+
type: u.Image,
|
|
132
|
+
src: e,
|
|
133
|
+
alt: t.text,
|
|
134
|
+
width: s.width,
|
|
135
|
+
height: s.height,
|
|
136
|
+
align: s.align
|
|
137
|
+
};
|
|
138
|
+
},
|
|
66
139
|
[u.Link]: (t) => ({
|
|
67
140
|
type: u.Link,
|
|
68
141
|
href: t.href,
|
|
@@ -100,14 +173,14 @@ const j = async (t) => {
|
|
|
100
173
|
items: t.tokens ? W(t.tokens) : []
|
|
101
174
|
})
|
|
102
175
|
}, H = class H {
|
|
103
|
-
static initialize(
|
|
104
|
-
this.options_ =
|
|
176
|
+
static initialize(e) {
|
|
177
|
+
this.options_ = e, this.cursor = { x: e.cursor.x, y: e.cursor.y }, this.lastContentY_ = e.cursor.y;
|
|
105
178
|
}
|
|
106
179
|
static getCursor() {
|
|
107
180
|
return this.cursor;
|
|
108
181
|
}
|
|
109
|
-
static setCursor(
|
|
110
|
-
this.cursor =
|
|
182
|
+
static setCursor(e) {
|
|
183
|
+
this.cursor = e;
|
|
111
184
|
}
|
|
112
185
|
static get options() {
|
|
113
186
|
return this.options_;
|
|
@@ -127,8 +200,8 @@ const j = async (t) => {
|
|
|
127
200
|
* @param operation 'set' to assign a new value, 'add' to increment the current value.
|
|
128
201
|
* @default operation = 'set'
|
|
129
202
|
*/
|
|
130
|
-
static updateX(
|
|
131
|
-
s === "set" ? this.cursor.x =
|
|
203
|
+
static updateX(e, s = "set") {
|
|
204
|
+
s === "set" ? this.cursor.x = e : s === "add" && (this.cursor.x += e);
|
|
132
205
|
}
|
|
133
206
|
/**
|
|
134
207
|
* Updates the y pointer of the cursor.
|
|
@@ -136,8 +209,8 @@ const j = async (t) => {
|
|
|
136
209
|
* @param operation 'set' to assign a new value, 'add' to increment the current value.
|
|
137
210
|
* @default operation = 'set'
|
|
138
211
|
*/
|
|
139
|
-
static updateY(
|
|
140
|
-
s === "set" ? this.cursor.y =
|
|
212
|
+
static updateY(e, s = "set") {
|
|
213
|
+
s === "set" ? this.cursor.y = e : s === "add" && (this.cursor.y += e);
|
|
141
214
|
}
|
|
142
215
|
/**
|
|
143
216
|
* Records a Y position as the bottom of rendered content.
|
|
@@ -145,8 +218,8 @@ const j = async (t) => {
|
|
|
145
218
|
* where their actual text content ends, ignoring any trailing margins.
|
|
146
219
|
* @param specificY Optional Y value to record. Defaults to current cursor Y.
|
|
147
220
|
*/
|
|
148
|
-
static recordContentY(
|
|
149
|
-
this.lastContentY_ =
|
|
221
|
+
static recordContentY(e) {
|
|
222
|
+
this.lastContentY_ = e !== void 0 ? e : this.cursor.y;
|
|
150
223
|
}
|
|
151
224
|
/**
|
|
152
225
|
* Gets the last Y position recorded as content bottom.
|
|
@@ -163,74 +236,74 @@ const j = async (t) => {
|
|
|
163
236
|
}
|
|
164
237
|
};
|
|
165
238
|
H.cursor = { x: 0, y: 0 }, H.lastContentY_ = 0, H.inlineLock = !1;
|
|
166
|
-
let
|
|
167
|
-
const
|
|
168
|
-
const
|
|
169
|
-
if (t.setFontSize(
|
|
170
|
-
for (const
|
|
171
|
-
|
|
239
|
+
let n = H;
|
|
240
|
+
const C = (t) => t.getTextDimensions("H").h * n.options.page.defaultLineHeightFactor, Y = (t) => t.getTextDimensions("H").w * n.options.page.defaultLineHeightFactor, M = (t, e, s, c) => {
|
|
241
|
+
const g = 6 - (e?.depth ?? 0) > 0 ? 6 - (e?.depth ?? 0) : 1;
|
|
242
|
+
if (t.setFontSize(n.options.page.defaultFontSize + g), e?.items && e?.items.length > 0)
|
|
243
|
+
for (const r of e?.items ?? [])
|
|
244
|
+
c(r, s, !1);
|
|
172
245
|
else {
|
|
173
|
-
const
|
|
246
|
+
const r = C(t);
|
|
174
247
|
t.text(
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
248
|
+
e?.content ?? "",
|
|
249
|
+
n.X + s,
|
|
250
|
+
n.Y,
|
|
178
251
|
{
|
|
179
252
|
align: "left",
|
|
180
|
-
maxWidth:
|
|
253
|
+
maxWidth: n.options.page.maxContentWidth - s,
|
|
181
254
|
baseline: "top"
|
|
182
255
|
}
|
|
183
|
-
),
|
|
256
|
+
), n.recordContentY(n.Y + r), n.updateY(r, "add");
|
|
184
257
|
}
|
|
185
|
-
t.setFontSize(
|
|
186
|
-
},
|
|
187
|
-
typeof
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
),
|
|
258
|
+
t.setFontSize(n.options.page.defaultFontSize), n.updateX(n.options.page.xpading, "set");
|
|
259
|
+
}, y = (t) => {
|
|
260
|
+
typeof n.options.pageBreakHandler == "function" ? n.options.pageBreakHandler(t) : t.addPage(
|
|
261
|
+
n.options.page?.format,
|
|
262
|
+
n.options.page?.orientation
|
|
263
|
+
), n.updateY(n.options.page.topmargin), n.updateX(n.options.page.xpading);
|
|
191
264
|
};
|
|
192
|
-
class
|
|
265
|
+
class v {
|
|
193
266
|
// Default codespan styling (can be overridden via RenderStore.options.codespan)
|
|
194
267
|
static getCodespanOptions() {
|
|
195
|
-
const
|
|
268
|
+
const e = n.options.codespan ?? {};
|
|
196
269
|
return {
|
|
197
|
-
backgroundColor:
|
|
198
|
-
padding:
|
|
199
|
-
showBackground:
|
|
200
|
-
fontSizeScale:
|
|
270
|
+
backgroundColor: e.backgroundColor ?? "#EEEEEE",
|
|
271
|
+
padding: e.padding ?? 0.5,
|
|
272
|
+
showBackground: e.showBackground !== !1,
|
|
273
|
+
fontSizeScale: e.fontSizeScale ?? 0.9
|
|
201
274
|
};
|
|
202
275
|
}
|
|
203
276
|
/**
|
|
204
277
|
* Apply font style to the jsPDF document.
|
|
205
278
|
*/
|
|
206
|
-
static applyStyle(
|
|
207
|
-
const
|
|
208
|
-
const i =
|
|
209
|
-
return i && i !== "" ? i :
|
|
210
|
-
},
|
|
211
|
-
const i =
|
|
212
|
-
return i && i !== "" ? i :
|
|
279
|
+
static applyStyle(e, s) {
|
|
280
|
+
const c = e.getFont().fontName, g = e.getFontSize(), r = () => {
|
|
281
|
+
const i = n.options.font.bold?.name;
|
|
282
|
+
return i && i !== "" ? i : c;
|
|
283
|
+
}, l = () => {
|
|
284
|
+
const i = n.options.font.regular?.name;
|
|
285
|
+
return i && i !== "" ? i : c;
|
|
213
286
|
};
|
|
214
287
|
switch (s) {
|
|
215
288
|
case "bold":
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
289
|
+
e.setFont(
|
|
290
|
+
r(),
|
|
291
|
+
n.options.font.bold?.style || "bold"
|
|
219
292
|
);
|
|
220
293
|
break;
|
|
221
294
|
case "italic":
|
|
222
|
-
|
|
295
|
+
e.setFont(l(), "italic");
|
|
223
296
|
break;
|
|
224
297
|
case "bolditalic":
|
|
225
|
-
|
|
298
|
+
e.setFont(r(), "bolditalic");
|
|
226
299
|
break;
|
|
227
300
|
case "codespan":
|
|
228
|
-
|
|
229
|
-
|
|
301
|
+
e.setFont("courier", "normal"), e.setFontSize(
|
|
302
|
+
g * this.getCodespanOptions().fontSizeScale
|
|
230
303
|
);
|
|
231
304
|
break;
|
|
232
305
|
default:
|
|
233
|
-
|
|
306
|
+
e.setFont(l(), e.getFont().fontStyle);
|
|
234
307
|
break;
|
|
235
308
|
}
|
|
236
309
|
}
|
|
@@ -239,17 +312,17 @@ class E {
|
|
|
239
312
|
* NOTE: jsPDF's getTextWidth() does NOT include charSpace in its calculation,
|
|
240
313
|
* so we must manually add it: effectiveWidth = getTextWidth(text) + (text.length * charSpace)
|
|
241
314
|
*/
|
|
242
|
-
static measureWordWidth(
|
|
243
|
-
const
|
|
244
|
-
this.applyStyle(
|
|
245
|
-
const
|
|
246
|
-
return
|
|
315
|
+
static measureWordWidth(e, s, c) {
|
|
316
|
+
const g = e.getFont(), r = e.getFontSize();
|
|
317
|
+
this.applyStyle(e, c);
|
|
318
|
+
const l = e.getTextWidth(s), i = e.getCharSpace?.() ?? 0, a = l + s.length * i;
|
|
319
|
+
return e.setFont(g.fontName, g.fontStyle), e.setFontSize(r), a;
|
|
247
320
|
}
|
|
248
321
|
/**
|
|
249
322
|
* Extract style from element type string.
|
|
250
323
|
*/
|
|
251
|
-
static getStyleFromType(
|
|
252
|
-
switch (
|
|
324
|
+
static getStyleFromType(e, s) {
|
|
325
|
+
switch (e) {
|
|
253
326
|
case "strong":
|
|
254
327
|
return s === "italic" ? "bolditalic" : "bold";
|
|
255
328
|
case "em":
|
|
@@ -264,35 +337,35 @@ class E {
|
|
|
264
337
|
* Flatten ParsedElement tree into an array of StyledWordInfo.
|
|
265
338
|
* Handles nested inline elements.
|
|
266
339
|
*/
|
|
267
|
-
static flattenToWords(
|
|
268
|
-
const
|
|
340
|
+
static flattenToWords(e, s, c = "normal", g = !1, r) {
|
|
341
|
+
const l = [];
|
|
269
342
|
for (const i of s) {
|
|
270
|
-
const a = this.getStyleFromType(i.type,
|
|
343
|
+
const a = this.getStyleFromType(i.type, c), p = i.type === "link" || g, h = i.href || r;
|
|
271
344
|
if (i.items && i.items.length > 0) {
|
|
272
345
|
const f = this.flattenToWords(
|
|
273
|
-
|
|
346
|
+
e,
|
|
274
347
|
i.items,
|
|
275
348
|
a,
|
|
276
|
-
|
|
277
|
-
|
|
349
|
+
p,
|
|
350
|
+
h
|
|
278
351
|
);
|
|
279
|
-
|
|
352
|
+
l.push(...f);
|
|
280
353
|
} else {
|
|
281
354
|
const f = i.content || i.text || "";
|
|
282
355
|
if (!f) continue;
|
|
283
356
|
if (a === "codespan") {
|
|
284
357
|
const o = f.trim();
|
|
285
|
-
o &&
|
|
358
|
+
o && l.push({
|
|
286
359
|
text: o,
|
|
287
360
|
width: this.measureWordWidth(
|
|
288
|
-
|
|
361
|
+
e,
|
|
289
362
|
o,
|
|
290
363
|
a
|
|
291
364
|
),
|
|
292
365
|
style: a,
|
|
293
|
-
isLink:
|
|
294
|
-
href:
|
|
295
|
-
linkColor:
|
|
366
|
+
isLink: p,
|
|
367
|
+
href: h,
|
|
368
|
+
linkColor: p ? n.options.link?.linkColor || [
|
|
296
369
|
0,
|
|
297
370
|
0,
|
|
298
371
|
255
|
|
@@ -305,88 +378,88 @@ class E {
|
|
|
305
378
|
continue;
|
|
306
379
|
for (let o = 0; o < d.length; o++) {
|
|
307
380
|
const m = d[o];
|
|
308
|
-
|
|
381
|
+
l.push({
|
|
309
382
|
text: m,
|
|
310
|
-
width: this.measureWordWidth(
|
|
383
|
+
width: this.measureWordWidth(e, m, a),
|
|
311
384
|
style: a,
|
|
312
|
-
isLink:
|
|
313
|
-
href:
|
|
314
|
-
linkColor:
|
|
385
|
+
isLink: p,
|
|
386
|
+
href: h,
|
|
387
|
+
linkColor: p ? n.options.link?.linkColor || [0, 0, 255] : void 0
|
|
315
388
|
});
|
|
316
389
|
}
|
|
317
390
|
}
|
|
318
391
|
}
|
|
319
|
-
return
|
|
392
|
+
return l;
|
|
320
393
|
}
|
|
321
394
|
/**
|
|
322
395
|
* Break a flat list of words into lines that fit within maxWidth.
|
|
323
396
|
* Correctly tracks totalTextWidth (sum of word widths only) for justification.
|
|
324
397
|
*/
|
|
325
|
-
static breakIntoLines(
|
|
326
|
-
const
|
|
327
|
-
let
|
|
328
|
-
const a =
|
|
329
|
-
for (let
|
|
330
|
-
const
|
|
331
|
-
i + f >
|
|
332
|
-
words:
|
|
333
|
-
totalTextWidth:
|
|
398
|
+
static breakIntoLines(e, s, c) {
|
|
399
|
+
const g = [];
|
|
400
|
+
let r = [], l = 0, i = 0;
|
|
401
|
+
const a = e.getTextWidth(" ");
|
|
402
|
+
for (let p = 0; p < s.length; p++) {
|
|
403
|
+
const h = s[p], f = r.length > 0 ? a + h.width : h.width;
|
|
404
|
+
i + f > c && r.length > 0 ? (g.push({
|
|
405
|
+
words: r,
|
|
406
|
+
totalTextWidth: l,
|
|
334
407
|
isLastLine: !1
|
|
335
|
-
}),
|
|
408
|
+
}), r = [h], l = h.width, i = h.width) : (r.push(h), l += h.width, i += f);
|
|
336
409
|
}
|
|
337
|
-
return
|
|
338
|
-
words:
|
|
339
|
-
totalTextWidth:
|
|
410
|
+
return r.length > 0 && g.push({
|
|
411
|
+
words: r,
|
|
412
|
+
totalTextWidth: l,
|
|
340
413
|
isLastLine: !0
|
|
341
|
-
}),
|
|
414
|
+
}), g;
|
|
342
415
|
}
|
|
343
416
|
/**
|
|
344
417
|
* Render a single word with its style applied.
|
|
345
418
|
*/
|
|
346
|
-
static renderWord(
|
|
347
|
-
const
|
|
348
|
-
if (this.applyStyle(
|
|
419
|
+
static renderWord(e, s, c, g) {
|
|
420
|
+
const r = e.getFont(), l = e.getFontSize(), i = e.getTextColor();
|
|
421
|
+
if (this.applyStyle(e, s.style), s.isLink && s.linkColor && e.setTextColor(...s.linkColor), s.style === "codespan") {
|
|
349
422
|
const a = this.getCodespanOptions();
|
|
350
423
|
if (a.showBackground) {
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
s.width +
|
|
356
|
-
|
|
424
|
+
const p = C(e), h = a.padding;
|
|
425
|
+
e.setFillColor(a.backgroundColor), e.rect(
|
|
426
|
+
c - h,
|
|
427
|
+
g - h,
|
|
428
|
+
s.width + h * 2,
|
|
429
|
+
p + h * 2,
|
|
357
430
|
"F"
|
|
358
|
-
),
|
|
431
|
+
), e.setFillColor("#000000");
|
|
359
432
|
}
|
|
360
433
|
}
|
|
361
|
-
if (
|
|
362
|
-
const a =
|
|
363
|
-
|
|
434
|
+
if (e.text(s.text, c, g, { baseline: "top" }), s.isLink && s.href) {
|
|
435
|
+
const a = C(e) / 2;
|
|
436
|
+
e.link(c, g, s.width, a, { url: s.href });
|
|
364
437
|
}
|
|
365
|
-
|
|
438
|
+
e.setFont(r.fontName, r.fontStyle), e.setFontSize(l), e.setTextColor(i);
|
|
366
439
|
}
|
|
367
440
|
/**
|
|
368
441
|
* Render a single line with specified alignment.
|
|
369
442
|
*/
|
|
370
|
-
static renderAlignedLine(
|
|
371
|
-
const { words: i, totalTextWidth: a, isLastLine:
|
|
443
|
+
static renderAlignedLine(e, s, c, g, r, l = "left") {
|
|
444
|
+
const { words: i, totalTextWidth: a, isLastLine: p } = s;
|
|
372
445
|
if (i.length === 0) return;
|
|
373
|
-
const
|
|
374
|
-
let f =
|
|
375
|
-
const o = a + (i.length - 1) *
|
|
376
|
-
switch (
|
|
446
|
+
const h = e.getTextWidth(" ");
|
|
447
|
+
let f = c, d = h;
|
|
448
|
+
const o = a + (i.length - 1) * h;
|
|
449
|
+
switch (l) {
|
|
377
450
|
case "right":
|
|
378
|
-
f =
|
|
451
|
+
f = c + r - o;
|
|
379
452
|
break;
|
|
380
453
|
case "center":
|
|
381
|
-
f =
|
|
454
|
+
f = c + (r - o) / 2;
|
|
382
455
|
break;
|
|
383
456
|
case "justify":
|
|
384
|
-
!
|
|
457
|
+
!p && i.length > 1 && (d = (r - a) / (i.length - 1));
|
|
385
458
|
break;
|
|
386
459
|
}
|
|
387
460
|
let m = f;
|
|
388
461
|
for (let x = 0; x < i.length; x++)
|
|
389
|
-
this.renderWord(
|
|
462
|
+
this.renderWord(e, i[x], m, g), m += i[x].width, x < i.length - 1 && (m += d);
|
|
390
463
|
}
|
|
391
464
|
/**
|
|
392
465
|
* Main entry point: Render a paragraph with mixed inline elements.
|
|
@@ -399,34 +472,34 @@ class E {
|
|
|
399
472
|
* @param maxWidth Maximum width for text wrapping
|
|
400
473
|
* @param alignment Optional alignment override (defaults to RenderStore option)
|
|
401
474
|
*/
|
|
402
|
-
static renderStyledParagraph(
|
|
403
|
-
const i =
|
|
475
|
+
static renderStyledParagraph(e, s, c, g, r, l) {
|
|
476
|
+
const i = l ?? n.options.content?.textAlignment ?? "left", a = this.flattenToWords(e, s);
|
|
404
477
|
if (a.length === 0) return;
|
|
405
|
-
const
|
|
406
|
-
let f =
|
|
407
|
-
for (const o of
|
|
408
|
-
f +
|
|
409
|
-
|
|
478
|
+
const p = this.breakIntoLines(e, a, r), h = C(e) * n.options.page.defaultLineHeightFactor;
|
|
479
|
+
let f = g;
|
|
480
|
+
for (const o of p)
|
|
481
|
+
f + h > n.options.page.maxContentHeight && (y(e), f = n.Y), this.renderAlignedLine(
|
|
482
|
+
e,
|
|
410
483
|
o,
|
|
411
|
-
|
|
484
|
+
c,
|
|
412
485
|
f,
|
|
413
|
-
|
|
486
|
+
r,
|
|
414
487
|
i
|
|
415
|
-
),
|
|
416
|
-
const d =
|
|
488
|
+
), n.recordContentY(f + C(e)), f += h, n.updateY(h, "add");
|
|
489
|
+
const d = p[p.length - 1];
|
|
417
490
|
if (d) {
|
|
418
|
-
const o = d.totalTextWidth + (d.words.length - 1) *
|
|
419
|
-
|
|
491
|
+
const o = d.totalTextWidth + (d.words.length - 1) * e.getTextWidth(" ");
|
|
492
|
+
n.updateX(c + o, "set");
|
|
420
493
|
}
|
|
421
494
|
}
|
|
422
495
|
/**
|
|
423
496
|
* @deprecated Use renderStyledParagraph instead
|
|
424
497
|
*/
|
|
425
|
-
static renderJustifiedParagraph(
|
|
426
|
-
this.renderStyledParagraph(
|
|
498
|
+
static renderJustifiedParagraph(e, s, c, g, r) {
|
|
499
|
+
this.renderStyledParagraph(e, s, c, g, r);
|
|
427
500
|
}
|
|
428
501
|
}
|
|
429
|
-
class
|
|
502
|
+
class I {
|
|
430
503
|
/**
|
|
431
504
|
* Renders text with automatic line wrapping and page breaking.
|
|
432
505
|
* @param doc jsPDF instance
|
|
@@ -436,227 +509,227 @@ class X {
|
|
|
436
509
|
* @param maxWidth Max width for text wrapping
|
|
437
510
|
* @param justify Whether to justify the text
|
|
438
511
|
*/
|
|
439
|
-
static renderText(
|
|
440
|
-
const i =
|
|
441
|
-
let
|
|
512
|
+
static renderText(e, s, c = n.X, g = n.Y, r, l = !1) {
|
|
513
|
+
const i = e.splitTextToSize(s, r), a = C(e), p = a * n.options.page.defaultLineHeightFactor;
|
|
514
|
+
let h = g;
|
|
442
515
|
for (let f = 0; f < i.length; f++) {
|
|
443
516
|
const d = i[f];
|
|
444
|
-
|
|
445
|
-
maxWidth:
|
|
517
|
+
h + p > n.options.page.maxContentHeight && (y(e), h = n.Y), l ? f === i.length - 1 ? e.text(d, c, h, { baseline: "top" }) : e.text(d, c, h, {
|
|
518
|
+
maxWidth: r,
|
|
446
519
|
align: "justify",
|
|
447
520
|
baseline: "top"
|
|
448
|
-
}) :
|
|
521
|
+
}) : e.text(d, c, h, { baseline: "top" }), n.recordContentY(h + a), h += p, n.updateY(p, "add");
|
|
449
522
|
}
|
|
450
|
-
return
|
|
523
|
+
return h;
|
|
451
524
|
}
|
|
452
525
|
}
|
|
453
|
-
const
|
|
454
|
-
|
|
455
|
-
const
|
|
456
|
-
if (
|
|
457
|
-
if (
|
|
458
|
-
(
|
|
459
|
-
|
|
526
|
+
const tt = (t, e, s, c) => {
|
|
527
|
+
n.activateInlineLock(), t.setFontSize(n.options.page.defaultFontSize);
|
|
528
|
+
const g = n.options.page.maxContentWidth - s;
|
|
529
|
+
if (e?.items && e?.items.length > 0)
|
|
530
|
+
if (e.items.some(
|
|
531
|
+
(l) => !["strong", "em", "text", "codespan", "link"].includes(
|
|
532
|
+
l.type
|
|
460
533
|
)
|
|
461
534
|
)) {
|
|
462
|
-
const
|
|
463
|
-
|
|
535
|
+
const l = [], i = () => {
|
|
536
|
+
l.length > 0 && (v.renderStyledParagraph(
|
|
464
537
|
t,
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
),
|
|
538
|
+
l,
|
|
539
|
+
n.X + s,
|
|
540
|
+
n.Y,
|
|
541
|
+
g
|
|
542
|
+
), l.length = 0);
|
|
470
543
|
};
|
|
471
|
-
for (const a of
|
|
544
|
+
for (const a of e.items)
|
|
472
545
|
["strong", "em", "text", "codespan", "link"].includes(
|
|
473
546
|
a.type
|
|
474
|
-
) ?
|
|
547
|
+
) ? l.push(a) : (i(), c(a, s, !1));
|
|
475
548
|
i();
|
|
476
549
|
} else
|
|
477
|
-
|
|
550
|
+
v.renderStyledParagraph(
|
|
478
551
|
t,
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
552
|
+
e.items,
|
|
553
|
+
n.X + s,
|
|
554
|
+
n.Y,
|
|
555
|
+
g
|
|
483
556
|
);
|
|
484
557
|
else {
|
|
485
|
-
const
|
|
486
|
-
|
|
558
|
+
const r = e.content ?? "", l = n.options.content?.textAlignment ?? "left";
|
|
559
|
+
r.trim() && I.renderText(
|
|
487
560
|
t,
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
561
|
+
r,
|
|
562
|
+
n.X + s,
|
|
563
|
+
n.Y,
|
|
564
|
+
g,
|
|
565
|
+
l === "justify"
|
|
493
566
|
);
|
|
494
567
|
}
|
|
495
|
-
|
|
496
|
-
},
|
|
497
|
-
t.setFontSize(
|
|
498
|
-
for (const [
|
|
499
|
-
const
|
|
500
|
-
|
|
501
|
-
|
|
568
|
+
n.updateX(n.options.page.xpading), n.deactivateInlineLock();
|
|
569
|
+
}, et = (t, e, s, c) => {
|
|
570
|
+
t.setFontSize(n.options.page.defaultFontSize);
|
|
571
|
+
for (const [g, r] of e?.items?.entries() ?? []) {
|
|
572
|
+
const l = e.ordered ? (e.start ?? 0) + g : e.start;
|
|
573
|
+
c(
|
|
574
|
+
r,
|
|
502
575
|
s + 1,
|
|
503
576
|
!0,
|
|
504
|
-
|
|
505
|
-
|
|
577
|
+
l,
|
|
578
|
+
e.ordered
|
|
506
579
|
);
|
|
507
580
|
}
|
|
508
|
-
},
|
|
509
|
-
|
|
510
|
-
const
|
|
511
|
-
|
|
512
|
-
const
|
|
513
|
-
if (
|
|
581
|
+
}, nt = (t, e, s, c, g, r) => {
|
|
582
|
+
n.Y + C(t) >= n.options.page.maxContentHeight && y(t);
|
|
583
|
+
const l = n.options, i = s * l.page.indent, a = r ? `${g}. ` : "• ", p = l.page.xpading;
|
|
584
|
+
n.updateX(p, "set"), t.setFont(l.font.regular.name, l.font.regular.style), t.text(a, p + i, n.Y, { baseline: "top" });
|
|
585
|
+
const h = t.getTextWidth(a), f = p + i + h, d = l.page.maxContentWidth - i - h;
|
|
586
|
+
if (e.items && e.items.length > 0) {
|
|
514
587
|
const o = [], m = () => {
|
|
515
|
-
o.length > 0 && (
|
|
588
|
+
o.length > 0 && (v.renderStyledParagraph(
|
|
516
589
|
t,
|
|
517
590
|
o,
|
|
518
591
|
f,
|
|
519
|
-
|
|
592
|
+
n.Y,
|
|
520
593
|
d
|
|
521
|
-
), o.length = 0,
|
|
594
|
+
), o.length = 0, n.updateX(p, "set"));
|
|
522
595
|
};
|
|
523
|
-
for (const x of
|
|
524
|
-
x.type === u.List ? (m(),
|
|
596
|
+
for (const x of e.items)
|
|
597
|
+
x.type === u.List ? (m(), c(
|
|
525
598
|
x,
|
|
526
599
|
s,
|
|
527
600
|
!0,
|
|
528
|
-
|
|
601
|
+
g,
|
|
529
602
|
x.ordered ?? !1
|
|
530
|
-
)) : x.type === u.ListItem ? (m(),
|
|
603
|
+
)) : x.type === u.ListItem ? (m(), c(
|
|
531
604
|
x,
|
|
532
605
|
s,
|
|
533
606
|
!0,
|
|
534
|
-
|
|
535
|
-
|
|
607
|
+
g,
|
|
608
|
+
r
|
|
536
609
|
)) : o.push(x);
|
|
537
610
|
m();
|
|
538
|
-
} else if (
|
|
539
|
-
const o =
|
|
540
|
-
|
|
611
|
+
} else if (e.content) {
|
|
612
|
+
const o = l.content?.textAlignment ?? "left";
|
|
613
|
+
I.renderText(
|
|
541
614
|
t,
|
|
542
|
-
|
|
615
|
+
e.content,
|
|
543
616
|
f,
|
|
544
|
-
|
|
617
|
+
n.Y,
|
|
545
618
|
d,
|
|
546
619
|
o === "justify"
|
|
547
620
|
);
|
|
548
621
|
}
|
|
549
|
-
},
|
|
550
|
-
if (
|
|
551
|
-
for (const a of
|
|
552
|
-
|
|
622
|
+
}, st = (t, e, s, c, g, r, l, i = !0) => {
|
|
623
|
+
if (e?.items && e?.items.length > 0)
|
|
624
|
+
for (const a of e?.items ?? [])
|
|
625
|
+
g(
|
|
553
626
|
a,
|
|
554
627
|
s,
|
|
555
|
-
|
|
556
|
-
l,
|
|
628
|
+
c,
|
|
557
629
|
r,
|
|
630
|
+
l,
|
|
558
631
|
i
|
|
559
632
|
);
|
|
560
633
|
else {
|
|
561
|
-
const a =
|
|
562
|
-
if (!f && !
|
|
563
|
-
if (!f.trim() && !
|
|
634
|
+
const a = n.options, p = s * a.page.indent, h = c ? l ? `${r}. ` : "• " : "", f = e.content || "", d = a.page.xpading;
|
|
635
|
+
if (!f && !h) return;
|
|
636
|
+
if (!f.trim() && !h) {
|
|
564
637
|
const o = (f.match(/\n/g) || []).length;
|
|
565
638
|
if (o > 1) {
|
|
566
|
-
const m = o - 1, x = t.getTextDimensions("A").h * a.page.defaultLineHeightFactor,
|
|
567
|
-
|
|
639
|
+
const m = o - 1, x = t.getTextDimensions("A").h * a.page.defaultLineHeightFactor, F = m * x;
|
|
640
|
+
n.Y + F > a.page.maxContentHeight ? y(t) : (n.updateY(F, "add"), n.recordContentY(n.Y));
|
|
568
641
|
}
|
|
569
642
|
return;
|
|
570
643
|
}
|
|
571
|
-
if (
|
|
572
|
-
const o = t.getTextWidth(
|
|
573
|
-
t.setFont(a.font.regular.name, a.font.regular.style), t.text(
|
|
644
|
+
if (n.updateX(d, "set"), c && h) {
|
|
645
|
+
const o = t.getTextWidth(h), m = a.page.maxContentWidth - p - o;
|
|
646
|
+
t.setFont(a.font.regular.name, a.font.regular.style), t.text(h, d + p, n.Y, {
|
|
574
647
|
baseline: "top"
|
|
575
|
-
}),
|
|
648
|
+
}), I.renderText(
|
|
576
649
|
t,
|
|
577
650
|
f,
|
|
578
|
-
d +
|
|
579
|
-
|
|
651
|
+
d + p + o,
|
|
652
|
+
n.Y,
|
|
580
653
|
m,
|
|
581
654
|
i
|
|
582
655
|
);
|
|
583
656
|
} else {
|
|
584
|
-
const o = a.page.maxContentWidth -
|
|
585
|
-
|
|
657
|
+
const o = a.page.maxContentWidth - p;
|
|
658
|
+
I.renderText(
|
|
586
659
|
t,
|
|
587
660
|
f,
|
|
588
|
-
d +
|
|
589
|
-
|
|
661
|
+
d + p,
|
|
662
|
+
n.Y,
|
|
590
663
|
o,
|
|
591
664
|
i
|
|
592
665
|
);
|
|
593
666
|
}
|
|
594
|
-
|
|
667
|
+
n.updateX(d, "set");
|
|
595
668
|
}
|
|
596
|
-
},
|
|
597
|
-
const
|
|
669
|
+
}, it = (t) => {
|
|
670
|
+
const e = t.internal.pageSize.getWidth();
|
|
598
671
|
t.setLineDashPattern([1, 1], 0), t.setLineWidth(0.1), t.line(
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
), t.setLineWidth(0.1), t.setLineDashPattern([], 0),
|
|
604
|
-
},
|
|
605
|
-
const
|
|
672
|
+
n.options.page.xpading,
|
|
673
|
+
n.Y,
|
|
674
|
+
e - n.options.page.xpading,
|
|
675
|
+
n.Y
|
|
676
|
+
), t.setLineWidth(0.1), t.setLineDashPattern([], 0), n.updateY(C(t), "add");
|
|
677
|
+
}, at = (t, e, s, c) => {
|
|
678
|
+
const g = t.getFont(), r = t.getFontSize();
|
|
606
679
|
t.setFont("courier", "normal");
|
|
607
|
-
const
|
|
608
|
-
t.setFontSize(
|
|
609
|
-
const i = s *
|
|
680
|
+
const l = n.options.page.defaultFontSize * 0.9;
|
|
681
|
+
t.setFontSize(l);
|
|
682
|
+
const i = s * n.options.page.indent, a = n.options.page.maxContentWidth - i - 8, p = t.getLineHeightFactor(), h = l / t.internal.scaleFactor * p, d = (e.code ?? "").replace(/[\r\n\s]+$/, "");
|
|
610
683
|
if (!d) {
|
|
611
|
-
t.setFont(
|
|
684
|
+
t.setFont(g.fontName, g.fontStyle), t.setFontSize(r);
|
|
612
685
|
return;
|
|
613
686
|
}
|
|
614
687
|
const o = t.splitTextToSize(d, a);
|
|
615
688
|
for (; o.length > 0 && o[o.length - 1].trim() === ""; )
|
|
616
689
|
o.pop();
|
|
617
690
|
if (o.length === 0) {
|
|
618
|
-
t.setFont(
|
|
691
|
+
t.setFont(g.fontName, g.fontStyle), t.setFontSize(r);
|
|
619
692
|
return;
|
|
620
693
|
}
|
|
621
|
-
const m = 4, x = "#EEEEEE",
|
|
622
|
-
let
|
|
623
|
-
for (;
|
|
624
|
-
const k =
|
|
625
|
-
let
|
|
626
|
-
if (
|
|
627
|
-
|
|
694
|
+
const m = 4, x = "#EEEEEE", F = "#DDDDDD";
|
|
695
|
+
let b = 0;
|
|
696
|
+
for (; b < o.length; ) {
|
|
697
|
+
const k = n.options.page.maxContentHeight - n.Y, w = o.length - b, T = k - m * 2;
|
|
698
|
+
let S = Math.floor(T / h);
|
|
699
|
+
if (S <= 0) {
|
|
700
|
+
y(t);
|
|
628
701
|
continue;
|
|
629
702
|
}
|
|
630
|
-
|
|
631
|
-
const
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
),
|
|
635
|
-
if (
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
703
|
+
S > w && (S = w);
|
|
704
|
+
const $ = o.slice(
|
|
705
|
+
b,
|
|
706
|
+
b + S
|
|
707
|
+
), X = b === 0, z = b + S >= o.length, N = S * h;
|
|
708
|
+
if (X && n.updateY(m, "add"), t.setFillColor(x), t.setDrawColor(F), t.roundedRect(
|
|
709
|
+
n.X,
|
|
710
|
+
n.Y - m,
|
|
711
|
+
n.options.page.maxContentWidth,
|
|
712
|
+
N + (X ? m : 0) + (z ? m : 0),
|
|
640
713
|
2,
|
|
641
714
|
2,
|
|
642
715
|
"FD"
|
|
643
|
-
),
|
|
644
|
-
const
|
|
716
|
+
), X && e.lang) {
|
|
717
|
+
const E = t.getFontSize();
|
|
645
718
|
t.setFontSize(10), t.setTextColor("#666666"), t.text(
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
719
|
+
e.lang,
|
|
720
|
+
n.X + n.options.page.maxContentWidth - t.getTextWidth(e.lang) - 4,
|
|
721
|
+
n.Y,
|
|
649
722
|
{ baseline: "top" }
|
|
650
|
-
), t.setFontSize(
|
|
723
|
+
), t.setFontSize(E), t.setTextColor("#000000");
|
|
651
724
|
}
|
|
652
|
-
let
|
|
653
|
-
for (const
|
|
654
|
-
t.text(
|
|
655
|
-
|
|
725
|
+
let R = n.Y;
|
|
726
|
+
for (const E of $)
|
|
727
|
+
t.text(E, n.X + 4, R, { baseline: "top" }), R += h;
|
|
728
|
+
n.updateY(N, "add"), n.recordContentY(n.Y + (z ? m : 0)), z && n.updateY(m, "add"), b += S, b < o.length && y(t);
|
|
656
729
|
}
|
|
657
|
-
t.setFont(
|
|
658
|
-
},
|
|
659
|
-
const
|
|
730
|
+
t.setFont(g.fontName, g.fontStyle), t.setFontSize(r);
|
|
731
|
+
}, ot = (t, e, s) => {
|
|
732
|
+
const c = t.getFont().fontName, g = t.getFont().fontStyle, r = t.getFontSize(), l = (a) => {
|
|
660
733
|
switch (a) {
|
|
661
734
|
case "normal":
|
|
662
735
|
return 0;
|
|
@@ -671,52 +744,52 @@ const _ = (t, n, s, g) => {
|
|
|
671
744
|
default:
|
|
672
745
|
return 0;
|
|
673
746
|
}
|
|
674
|
-
}, i = (a,
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
) :
|
|
679
|
-
|
|
747
|
+
}, i = (a, p) => {
|
|
748
|
+
p === "bold" ? t.setFont(
|
|
749
|
+
n.options.font.bold.name && n.options.font.bold.name !== "" ? n.options.font.bold.name : c,
|
|
750
|
+
n.options.font.bold.style || "bold"
|
|
751
|
+
) : p === "italic" ? t.setFont(n.options.font.regular.name, "italic") : p === "bolditalic" ? t.setFont(
|
|
752
|
+
n.options.font.bold.name && n.options.font.bold.name !== "" ? n.options.font.bold.name : c,
|
|
680
753
|
"bolditalic"
|
|
681
|
-
) :
|
|
682
|
-
|
|
683
|
-
|
|
754
|
+
) : p === "codespan" ? (t.setFont("courier", "normal"), t.setFontSize(r * 0.9)) : t.setFont(
|
|
755
|
+
n.options.font.regular.name,
|
|
756
|
+
g
|
|
684
757
|
);
|
|
685
|
-
const
|
|
686
|
-
if (
|
|
758
|
+
const h = n.options.page.maxContentWidth - s - n.X, f = t.splitTextToSize(a, h), d = p === "codespan", o = 1, m = "#EEEEEE";
|
|
759
|
+
if (n.isInlineLockActive)
|
|
687
760
|
for (let x = 0; x < f.length; x++) {
|
|
688
761
|
if (d) {
|
|
689
|
-
const
|
|
762
|
+
const F = t.getTextWidth(f[x]) + Y(t), b = C(t);
|
|
690
763
|
t.setFillColor(m), t.roundedRect(
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
C + o * 2,
|
|
764
|
+
n.X + s - o,
|
|
765
|
+
n.Y - o,
|
|
694
766
|
F + o * 2,
|
|
767
|
+
b + o * 2,
|
|
695
768
|
2,
|
|
696
769
|
2,
|
|
697
770
|
"F"
|
|
698
771
|
), t.setFillColor("#000000");
|
|
699
772
|
}
|
|
700
|
-
t.text(f[x],
|
|
773
|
+
t.text(f[x], n.X + s, n.Y, {
|
|
701
774
|
baseline: "top",
|
|
702
|
-
maxWidth:
|
|
703
|
-
}),
|
|
775
|
+
maxWidth: h
|
|
776
|
+
}), n.updateX(
|
|
704
777
|
t.getTextDimensions(f[x]).w + (d ? o * 2 : 1),
|
|
705
778
|
"add"
|
|
706
|
-
), x < f.length - 1 && (
|
|
707
|
-
|
|
779
|
+
), x < f.length - 1 && (n.updateY(C(t), "add"), n.updateX(
|
|
780
|
+
n.options.page.xpading,
|
|
708
781
|
"set"
|
|
709
782
|
));
|
|
710
783
|
}
|
|
711
784
|
else if (f.length > 1) {
|
|
712
|
-
const x = f[0],
|
|
785
|
+
const x = f[0], F = f?.slice(1)?.join(" ");
|
|
713
786
|
if (d) {
|
|
714
|
-
const
|
|
787
|
+
const w = t.getTextWidth(x) + Y(t), T = C(t);
|
|
715
788
|
t.setFillColor(m), t.roundedRect(
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
789
|
+
n.X + (s >= 2 ? s + 2 : 0) - o,
|
|
790
|
+
n.Y - o,
|
|
791
|
+
w + o * 2,
|
|
792
|
+
T + o * 2,
|
|
720
793
|
2,
|
|
721
794
|
2,
|
|
722
795
|
"F"
|
|
@@ -724,245 +797,285 @@ const _ = (t, n, s, g) => {
|
|
|
724
797
|
}
|
|
725
798
|
t.text(
|
|
726
799
|
x,
|
|
727
|
-
|
|
728
|
-
|
|
800
|
+
n.X + (s >= 2 ? s + 2 * l(p) : 0),
|
|
801
|
+
n.Y,
|
|
729
802
|
{
|
|
730
803
|
baseline: "top",
|
|
731
|
-
maxWidth:
|
|
804
|
+
maxWidth: h
|
|
732
805
|
}
|
|
733
|
-
),
|
|
734
|
-
const
|
|
806
|
+
), n.updateX(n.options.page.xpading + s), n.updateY(C(t), "add");
|
|
807
|
+
const b = n.options.page.maxContentWidth - s - n.options.page.xpading;
|
|
735
808
|
t.splitTextToSize(
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
).forEach((
|
|
809
|
+
F,
|
|
810
|
+
b
|
|
811
|
+
).forEach((w) => {
|
|
739
812
|
if (d) {
|
|
740
|
-
const
|
|
813
|
+
const T = t.getTextWidth(w) + Y(t), S = C(t);
|
|
741
814
|
t.setFillColor(m), t.roundedRect(
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
815
|
+
n.X + Y(t) - o,
|
|
816
|
+
n.Y - o,
|
|
817
|
+
T + o * 2,
|
|
818
|
+
S + o * 2,
|
|
746
819
|
2,
|
|
747
820
|
2,
|
|
748
821
|
"F"
|
|
749
822
|
), t.setFillColor("#000000");
|
|
750
823
|
}
|
|
751
824
|
t.text(
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
825
|
+
w,
|
|
826
|
+
n.X + Y(t),
|
|
827
|
+
n.Y,
|
|
755
828
|
{
|
|
756
829
|
baseline: "top",
|
|
757
|
-
maxWidth:
|
|
830
|
+
maxWidth: b
|
|
758
831
|
}
|
|
759
832
|
);
|
|
760
833
|
});
|
|
761
834
|
} else {
|
|
762
835
|
if (d) {
|
|
763
|
-
const x = t.getTextWidth(a) +
|
|
836
|
+
const x = t.getTextWidth(a) + Y(t), F = C(t);
|
|
764
837
|
t.setFillColor(m), t.roundedRect(
|
|
765
|
-
|
|
766
|
-
|
|
838
|
+
n.X + s - o,
|
|
839
|
+
n.Y - o,
|
|
767
840
|
x + o * 2,
|
|
768
|
-
|
|
841
|
+
F + o * 2,
|
|
769
842
|
2,
|
|
770
843
|
2,
|
|
771
844
|
"F"
|
|
772
845
|
), t.setFillColor("#000000");
|
|
773
846
|
}
|
|
774
|
-
t.text(a,
|
|
847
|
+
t.text(a, n.X + s, n.Y, {
|
|
775
848
|
baseline: "top",
|
|
776
|
-
maxWidth:
|
|
777
|
-
}),
|
|
778
|
-
t.getTextDimensions(a).w + (s >= 2 ? a.split(" ").length + 2 : 2) *
|
|
849
|
+
maxWidth: h
|
|
850
|
+
}), n.updateX(
|
|
851
|
+
t.getTextDimensions(a).w + (s >= 2 ? a.split(" ").length + 2 : 2) * l(p) * 0.5 + (d ? o * 2 : 0),
|
|
779
852
|
"add"
|
|
780
853
|
);
|
|
781
854
|
}
|
|
782
855
|
};
|
|
783
|
-
if (
|
|
784
|
-
for (const a of
|
|
856
|
+
if (e.type === "text" && e.items && e.items.length > 0)
|
|
857
|
+
for (const a of e.items)
|
|
785
858
|
if (a.type === "codespan")
|
|
786
859
|
i(a.content || "", "codespan");
|
|
787
860
|
else if (a.type === "em" || a.type === "strong") {
|
|
788
|
-
const
|
|
861
|
+
const p = a.type === "em" ? "italic" : "bold";
|
|
789
862
|
if (a.items && a.items.length > 0)
|
|
790
|
-
for (const
|
|
791
|
-
|
|
792
|
-
|
|
863
|
+
for (const h of a.items)
|
|
864
|
+
h.type === "strong" && p === "italic" || h.type === "em" && p === "bold" ? i(
|
|
865
|
+
h.content || "",
|
|
793
866
|
"bolditalic"
|
|
794
867
|
) : i(
|
|
795
|
-
|
|
796
|
-
|
|
868
|
+
h.content || "",
|
|
869
|
+
p
|
|
797
870
|
);
|
|
798
871
|
else
|
|
799
|
-
i(a.content || "",
|
|
872
|
+
i(a.content || "", p);
|
|
800
873
|
} else
|
|
801
874
|
i(a.content || "", "normal");
|
|
802
|
-
else
|
|
803
|
-
t.setFont(
|
|
804
|
-
},
|
|
805
|
-
const
|
|
875
|
+
else e.type === "em" ? i(e.content || "", "italic") : e.type === "strong" ? i(e.content || "", "bold") : e.type === "codespan" ? i(e.content || "", "codespan") : i(e.content || "", "normal");
|
|
876
|
+
t.setFont(c, g), t.setFontSize(r);
|
|
877
|
+
}, rt = (t, e, s) => {
|
|
878
|
+
const c = t.getFont().fontName, g = t.getFont().fontStyle, r = t.getFontSize(), l = t.getTextColor(), i = n.options.link?.linkColor || [0, 0, 255];
|
|
806
879
|
t.setTextColor(...i);
|
|
807
|
-
const a =
|
|
808
|
-
if (
|
|
880
|
+
const a = n.options.page.maxContentWidth - s - n.X, p = e.text || e.content || "", h = e.href || "", f = t.splitTextToSize(p, a);
|
|
881
|
+
if (n.isInlineLockActive)
|
|
809
882
|
for (let d = 0; d < f.length; d++) {
|
|
810
|
-
const o = t.getTextDimensions(f[d]).w, m =
|
|
883
|
+
const o = t.getTextDimensions(f[d]).w, m = C(t) / 2;
|
|
811
884
|
t.link(
|
|
812
|
-
|
|
813
|
-
|
|
885
|
+
n.X + s,
|
|
886
|
+
n.Y,
|
|
814
887
|
o,
|
|
815
888
|
m,
|
|
816
|
-
{ url:
|
|
817
|
-
), t.text(f[d],
|
|
889
|
+
{ url: h }
|
|
890
|
+
), t.text(f[d], n.X + s, n.Y, {
|
|
818
891
|
baseline: "top",
|
|
819
892
|
maxWidth: a
|
|
820
|
-
}),
|
|
821
|
-
|
|
893
|
+
}), n.updateX(o + 1, "add"), n.X + o > n.options.page.maxContentWidth - s && (n.updateY(m, "add"), n.updateX(
|
|
894
|
+
n.options.page.xpading + s,
|
|
822
895
|
"set"
|
|
823
|
-
)), d < f.length - 1 && (
|
|
824
|
-
|
|
896
|
+
)), d < f.length - 1 && (n.updateY(m, "add"), n.updateX(
|
|
897
|
+
n.options.page.xpading + s,
|
|
825
898
|
"set"
|
|
826
899
|
));
|
|
827
900
|
}
|
|
828
901
|
else if (f.length > 1) {
|
|
829
|
-
const d = f[0], o = f?.slice(1)?.join(" "), m = t.getTextDimensions(d).w, x =
|
|
902
|
+
const d = f[0], o = f?.slice(1)?.join(" "), m = t.getTextDimensions(d).w, x = C(t) / 2;
|
|
830
903
|
t.link(
|
|
831
|
-
|
|
832
|
-
|
|
904
|
+
n.X + s,
|
|
905
|
+
n.Y,
|
|
833
906
|
m,
|
|
834
907
|
x,
|
|
835
|
-
{ url:
|
|
836
|
-
), t.text(d,
|
|
908
|
+
{ url: h }
|
|
909
|
+
), t.text(d, n.X + s, n.Y, {
|
|
837
910
|
baseline: "top",
|
|
838
911
|
maxWidth: a
|
|
839
|
-
}),
|
|
840
|
-
const
|
|
841
|
-
t.splitTextToSize(o,
|
|
842
|
-
const
|
|
912
|
+
}), n.updateX(n.options.page.xpading + s), n.updateY(x, "add");
|
|
913
|
+
const F = n.options.page.maxContentWidth - s - n.options.page.xpading;
|
|
914
|
+
t.splitTextToSize(o, F).forEach((k) => {
|
|
915
|
+
const w = t.getTextDimensions(k).w;
|
|
843
916
|
t.link(
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
917
|
+
n.X + Y(t),
|
|
918
|
+
n.Y,
|
|
919
|
+
w,
|
|
847
920
|
x,
|
|
848
|
-
{ url:
|
|
921
|
+
{ url: h }
|
|
849
922
|
), t.text(
|
|
850
923
|
k,
|
|
851
|
-
|
|
852
|
-
|
|
924
|
+
n.X + Y(t),
|
|
925
|
+
n.Y,
|
|
853
926
|
{
|
|
854
927
|
baseline: "top",
|
|
855
|
-
maxWidth:
|
|
928
|
+
maxWidth: F
|
|
856
929
|
}
|
|
857
930
|
);
|
|
858
931
|
});
|
|
859
932
|
} else {
|
|
860
|
-
const d = t.getTextDimensions(
|
|
933
|
+
const d = t.getTextDimensions(p).w, o = C(t) / 2;
|
|
861
934
|
t.link(
|
|
862
|
-
|
|
863
|
-
|
|
935
|
+
n.X + s,
|
|
936
|
+
n.Y,
|
|
864
937
|
d,
|
|
865
938
|
o,
|
|
866
|
-
{ url:
|
|
867
|
-
), t.text(
|
|
939
|
+
{ url: h }
|
|
940
|
+
), t.text(p, n.X + s, n.Y, {
|
|
868
941
|
baseline: "top",
|
|
869
942
|
maxWidth: a
|
|
870
|
-
}),
|
|
943
|
+
}), n.updateX(d + 2, "add");
|
|
871
944
|
}
|
|
872
|
-
t.setFont(
|
|
873
|
-
},
|
|
874
|
-
const
|
|
875
|
-
|
|
876
|
-
|
|
945
|
+
t.setFont(c, g), t.setFontSize(r), t.setTextColor(l);
|
|
946
|
+
}, lt = (t, e, s, c) => {
|
|
947
|
+
const g = n.options, r = s + 1, l = n.X + s * g.page.indent, i = n.Y, a = l + g.page.indent / 2, p = i, h = t.internal.getCurrentPageInfo().pageNumber;
|
|
948
|
+
e.items && e.items.length > 0 && e.items.forEach((o) => {
|
|
949
|
+
c(o, r);
|
|
877
950
|
});
|
|
878
|
-
const f =
|
|
951
|
+
const f = n.Y, d = t.internal.getCurrentPageInfo().pageNumber;
|
|
879
952
|
t.setDrawColor(100), t.setLineWidth(1);
|
|
880
|
-
for (let o =
|
|
953
|
+
for (let o = h; o <= d; o++) {
|
|
881
954
|
t.setPage(o);
|
|
882
|
-
const m = o ===
|
|
883
|
-
t.line(a,
|
|
955
|
+
const m = o === h, x = o === d, F = m ? p : g.page.topmargin, b = x ? f : g.page.maxContentHeight;
|
|
956
|
+
t.line(a, F, a, b);
|
|
884
957
|
}
|
|
885
|
-
|
|
886
|
-
},
|
|
887
|
-
if (
|
|
958
|
+
n.recordContentY(), t.setPage(d);
|
|
959
|
+
}, P = 96, ct = (t) => {
|
|
960
|
+
if (t.data) {
|
|
961
|
+
if (t.data.startsWith("data:image/png")) return "PNG";
|
|
962
|
+
if (t.data.startsWith("data:image/jpeg") || t.data.startsWith("data:image/jpg"))
|
|
963
|
+
return "JPEG";
|
|
964
|
+
if (t.data.startsWith("data:image/webp")) return "WEBP";
|
|
965
|
+
if (t.data.startsWith("data:image/gif")) return "GIF";
|
|
966
|
+
}
|
|
967
|
+
return t.src?.split(".").pop()?.toUpperCase() || "JPEG";
|
|
968
|
+
}, L = (t, e = "mm") => {
|
|
969
|
+
switch (e) {
|
|
970
|
+
case "pt":
|
|
971
|
+
return t * 72 / P;
|
|
972
|
+
case "in":
|
|
973
|
+
return t / P;
|
|
974
|
+
case "px":
|
|
975
|
+
return t;
|
|
976
|
+
default:
|
|
977
|
+
return t * 25.4 / P;
|
|
978
|
+
}
|
|
979
|
+
}, gt = (t, e, s) => {
|
|
980
|
+
if (!e.data)
|
|
888
981
|
return;
|
|
889
|
-
const
|
|
890
|
-
let
|
|
891
|
-
const r = g.page.maxContentWidth - s * g.page.indent;
|
|
982
|
+
const c = n.options, g = c.page.unit || "mm", r = s * c.page.indent, l = c.page.maxContentWidth - r, i = n.X + r;
|
|
983
|
+
let a = n.Y;
|
|
892
984
|
try {
|
|
893
|
-
const
|
|
894
|
-
let
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
985
|
+
const p = t.getImageProperties(e.data), h = p.width, f = p.height, d = f > 0 ? h / f : 1;
|
|
986
|
+
let o, m;
|
|
987
|
+
if (e.width && e.height ? (o = L(e.width, g), m = L(e.height, g)) : e.width ? (o = L(e.width, g), m = o / d) : e.height ? (m = L(e.height, g), o = m * d) : (o = L(h, g), m = L(f, g)), o > l) {
|
|
988
|
+
const w = l / o;
|
|
989
|
+
o = l, m = m * w;
|
|
990
|
+
}
|
|
991
|
+
const x = c.page.maxContentHeight - c.page.topmargin;
|
|
992
|
+
if (m > x) {
|
|
993
|
+
const w = x / m;
|
|
994
|
+
m = x, o = o * w;
|
|
995
|
+
}
|
|
996
|
+
a + m > c.page.maxContentHeight && (y(t), a = n.Y);
|
|
997
|
+
const F = e.align || c.image?.defaultAlign || "left";
|
|
998
|
+
let b;
|
|
999
|
+
switch (F) {
|
|
1000
|
+
case "right":
|
|
1001
|
+
b = i + l - o;
|
|
1002
|
+
break;
|
|
1003
|
+
case "center":
|
|
1004
|
+
b = i + (l - o) / 2;
|
|
1005
|
+
break;
|
|
1006
|
+
default:
|
|
1007
|
+
b = i;
|
|
1008
|
+
break;
|
|
1009
|
+
}
|
|
1010
|
+
const k = ct(e);
|
|
1011
|
+
t.addImage(
|
|
1012
|
+
e.data,
|
|
1013
|
+
k,
|
|
1014
|
+
b,
|
|
1015
|
+
a,
|
|
900
1016
|
o,
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
), e.updateY(f, "add"), e.recordContentY();
|
|
906
|
-
} catch (i) {
|
|
907
|
-
console.warn("Failed to render image", i);
|
|
1017
|
+
m
|
|
1018
|
+
), n.updateY(m, "add"), n.recordContentY();
|
|
1019
|
+
} catch (p) {
|
|
1020
|
+
console.warn("Failed to render image", p);
|
|
908
1021
|
}
|
|
909
|
-
},
|
|
910
|
-
if (!
|
|
1022
|
+
}, pt = (t, e, s) => {
|
|
1023
|
+
if (!e.header || !e.rows)
|
|
911
1024
|
return;
|
|
912
|
-
const
|
|
913
|
-
(a) => a.map((
|
|
914
|
-
), i =
|
|
915
|
-
|
|
916
|
-
head:
|
|
917
|
-
body:
|
|
918
|
-
startY:
|
|
919
|
-
margin: { left:
|
|
1025
|
+
const c = n.options, g = c.page.xmargin + s * c.page.indent, r = [e.header.map((a) => a.content || "")], l = e.rows.map(
|
|
1026
|
+
(a) => a.map((p) => p.content || "")
|
|
1027
|
+
), i = c.table || {};
|
|
1028
|
+
O(t, {
|
|
1029
|
+
head: r,
|
|
1030
|
+
body: l,
|
|
1031
|
+
startY: n.Y,
|
|
1032
|
+
margin: { left: g, right: c.page.xmargin },
|
|
920
1033
|
...i,
|
|
921
1034
|
didDrawPage: (a) => {
|
|
922
1035
|
i.didDrawPage && i.didDrawPage(a);
|
|
923
1036
|
},
|
|
924
1037
|
didDrawCell: (a) => {
|
|
925
|
-
i.didDrawCell && i.didDrawCell(a),
|
|
926
|
-
x:
|
|
927
|
-
y: a.cell.y + 2 *
|
|
1038
|
+
i.didDrawCell && i.didDrawCell(a), n.setCursor({
|
|
1039
|
+
x: n.X,
|
|
1040
|
+
y: a.cell.y + 2 * c.page.lineSpace
|
|
928
1041
|
});
|
|
929
1042
|
}
|
|
930
1043
|
});
|
|
931
|
-
},
|
|
932
|
-
for (const
|
|
933
|
-
if (
|
|
1044
|
+
}, _ = async (t) => {
|
|
1045
|
+
for (const e of t) {
|
|
1046
|
+
if (e.type === u.Image && e.src)
|
|
934
1047
|
try {
|
|
935
|
-
if (
|
|
936
|
-
|
|
1048
|
+
if (e.src.startsWith("data:"))
|
|
1049
|
+
e.data = e.src;
|
|
937
1050
|
else {
|
|
938
|
-
const s = await fetch(
|
|
1051
|
+
const s = await fetch(e.src);
|
|
939
1052
|
if (!s.ok)
|
|
940
1053
|
throw new Error(
|
|
941
1054
|
`Failed to fetch image: ${s.statusText}`
|
|
942
1055
|
);
|
|
943
|
-
const
|
|
944
|
-
(
|
|
1056
|
+
const c = await s.blob(), g = await new Promise(
|
|
1057
|
+
(r, l) => {
|
|
945
1058
|
const i = new FileReader();
|
|
946
1059
|
i.onloadend = () => {
|
|
947
|
-
typeof i.result == "string" ?
|
|
1060
|
+
typeof i.result == "string" ? r(i.result) : l(
|
|
948
1061
|
new Error(
|
|
949
1062
|
"Failed to convert image to base64 string"
|
|
950
1063
|
)
|
|
951
1064
|
);
|
|
952
|
-
}, i.onerror =
|
|
1065
|
+
}, i.onerror = l, i.readAsDataURL(c);
|
|
953
1066
|
}
|
|
954
1067
|
);
|
|
955
|
-
|
|
1068
|
+
e.data = g;
|
|
956
1069
|
}
|
|
957
1070
|
} catch (s) {
|
|
958
1071
|
console.warn(
|
|
959
|
-
`[jspdf-md-renderer] Warning: Failed to load image at ${
|
|
1072
|
+
`[jspdf-md-renderer] Warning: Failed to load image at ${e.src}. It will be skipped.`,
|
|
960
1073
|
s
|
|
961
1074
|
);
|
|
962
1075
|
}
|
|
963
|
-
|
|
1076
|
+
e.items && e.items.length > 0 && await _(e.items);
|
|
964
1077
|
}
|
|
965
|
-
},
|
|
1078
|
+
}, D = {
|
|
966
1079
|
page: {
|
|
967
1080
|
indent: 10,
|
|
968
1081
|
maxContentWidth: 190,
|
|
@@ -981,83 +1094,87 @@ const _ = (t, n, s, g) => {
|
|
|
981
1094
|
bold: { name: "helvetica", style: "bold" },
|
|
982
1095
|
regular: { name: "helvetica", style: "normal" },
|
|
983
1096
|
light: { name: "helvetica", style: "light" }
|
|
1097
|
+
},
|
|
1098
|
+
image: {
|
|
1099
|
+
defaultAlign: "left"
|
|
984
1100
|
}
|
|
985
|
-
},
|
|
1101
|
+
}, ht = (t) => {
|
|
986
1102
|
if (!t)
|
|
987
1103
|
throw new Error("RenderOption is required");
|
|
988
|
-
const
|
|
989
|
-
return
|
|
1104
|
+
const e = { ...D.page, ...t.page }, s = { ...D.font, ...t.font }, c = { ...D.image, ...t.image };
|
|
1105
|
+
return e.maxContentWidth || (e.maxContentWidth = 190), e.maxContentHeight || (e.maxContentHeight = 277), {
|
|
990
1106
|
...t,
|
|
991
|
-
page:
|
|
992
|
-
font: s
|
|
1107
|
+
page: e,
|
|
1108
|
+
font: s,
|
|
1109
|
+
image: c
|
|
993
1110
|
};
|
|
994
|
-
},
|
|
995
|
-
const
|
|
996
|
-
|
|
997
|
-
const
|
|
998
|
-
await
|
|
999
|
-
const
|
|
1000
|
-
const d = i *
|
|
1001
|
-
switch (
|
|
1111
|
+
}, ut = async (t, e, s) => {
|
|
1112
|
+
const c = ht(s);
|
|
1113
|
+
n.initialize(c);
|
|
1114
|
+
const g = await Q(e);
|
|
1115
|
+
await _(g);
|
|
1116
|
+
const r = (l, i = 0, a = !1, p = 0, h = !1, f = !0) => {
|
|
1117
|
+
const d = i * c.page.indent;
|
|
1118
|
+
switch (l.type) {
|
|
1002
1119
|
case u.Heading:
|
|
1003
|
-
|
|
1120
|
+
M(t, l, d, r);
|
|
1004
1121
|
break;
|
|
1005
1122
|
case u.Paragraph:
|
|
1006
|
-
|
|
1123
|
+
tt(t, l, d, r);
|
|
1007
1124
|
break;
|
|
1008
1125
|
case u.List:
|
|
1009
|
-
|
|
1126
|
+
et(t, l, i, r);
|
|
1010
1127
|
break;
|
|
1011
1128
|
case u.ListItem:
|
|
1012
|
-
|
|
1129
|
+
nt(
|
|
1013
1130
|
t,
|
|
1014
|
-
r,
|
|
1015
|
-
i,
|
|
1016
1131
|
l,
|
|
1017
|
-
|
|
1018
|
-
|
|
1132
|
+
i,
|
|
1133
|
+
r,
|
|
1134
|
+
p,
|
|
1135
|
+
h
|
|
1019
1136
|
);
|
|
1020
1137
|
break;
|
|
1021
1138
|
case u.Hr:
|
|
1022
|
-
|
|
1139
|
+
it(t);
|
|
1023
1140
|
break;
|
|
1024
1141
|
case u.Code:
|
|
1025
|
-
|
|
1142
|
+
at(t, l, i);
|
|
1026
1143
|
break;
|
|
1027
1144
|
case u.Strong:
|
|
1028
1145
|
case u.Em:
|
|
1029
1146
|
case u.CodeSpan:
|
|
1030
|
-
|
|
1147
|
+
ot(t, l, d);
|
|
1031
1148
|
break;
|
|
1032
1149
|
case u.Link:
|
|
1033
|
-
|
|
1150
|
+
rt(t, l, d);
|
|
1034
1151
|
break;
|
|
1035
1152
|
case u.Blockquote:
|
|
1036
|
-
|
|
1153
|
+
lt(t, l, i, r);
|
|
1037
1154
|
break;
|
|
1038
1155
|
case u.Image:
|
|
1039
|
-
|
|
1156
|
+
gt(t, l, i);
|
|
1040
1157
|
break;
|
|
1041
1158
|
case u.Table:
|
|
1042
|
-
|
|
1159
|
+
pt(t, l, i);
|
|
1043
1160
|
break;
|
|
1044
1161
|
case u.Raw:
|
|
1045
1162
|
case u.Text:
|
|
1046
|
-
|
|
1163
|
+
st(
|
|
1047
1164
|
t,
|
|
1048
|
-
|
|
1165
|
+
l,
|
|
1049
1166
|
i,
|
|
1050
1167
|
a,
|
|
1051
|
-
|
|
1052
|
-
h,
|
|
1168
|
+
r,
|
|
1053
1169
|
p,
|
|
1054
|
-
|
|
1170
|
+
h,
|
|
1171
|
+
c.page.defaultFontSize > 0
|
|
1055
1172
|
// Using validOptions here if needed, or just true for justify
|
|
1056
1173
|
);
|
|
1057
1174
|
break;
|
|
1058
1175
|
default:
|
|
1059
1176
|
console.warn(
|
|
1060
|
-
`Warning: Unsupported element type encountered: ${
|
|
1177
|
+
`Warning: Unsupported element type encountered: ${l.type}.
|
|
1061
1178
|
If you believe this element type should be supported, please create an issue at:
|
|
1062
1179
|
https://github.com/JeelGajera/jspdf-md-renderer/issues
|
|
1063
1180
|
with details of the element and expected behavior. Thanks for helping to improve this library!`
|
|
@@ -1065,11 +1182,11 @@ const _ = (t, n, s, g) => {
|
|
|
1065
1182
|
break;
|
|
1066
1183
|
}
|
|
1067
1184
|
};
|
|
1068
|
-
for (const
|
|
1069
|
-
l
|
|
1070
|
-
|
|
1185
|
+
for (const l of g)
|
|
1186
|
+
r(l);
|
|
1187
|
+
c.endCursorYHandler(n.Y);
|
|
1071
1188
|
};
|
|
1072
1189
|
export {
|
|
1073
|
-
|
|
1074
|
-
|
|
1190
|
+
Q as MdTextParser,
|
|
1191
|
+
ut as MdTextRender
|
|
1075
1192
|
};
|