@paprize/core 0.0.10 → 0.0.12
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 +1 -1
- package/dist/paprize-core.d.ts +26 -8
- package/dist/paprize-core.js +299 -285
- package/dist/paprize-core.js.map +1 -1
- package/dist/paprize-core.umd.cjs +5 -7
- package/dist/paprize-core.umd.cjs.map +1 -1
- package/package.json +3 -3
package/dist/paprize-core.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const fe = "paprize", _e = "pz-temp-container",
|
|
1
|
+
const fe = "paprize", _e = "pz-temp-container", at = "pz-current-element", lt = "pz-current-text", ct = "pz-ignored-element", dt = "pz-ignored-text", Y = "paprize-global-style", z = "pz-page", ve = "pz-section", T = "pz-preview", C = "data-pz-";
|
|
2
2
|
let re = !1;
|
|
3
|
-
const
|
|
3
|
+
const gt = () => {
|
|
4
4
|
re = !0;
|
|
5
|
-
},
|
|
5
|
+
}, q = () => re;
|
|
6
6
|
function se(i) {
|
|
7
7
|
return i.nodeType === Node.ELEMENT_NODE;
|
|
8
8
|
}
|
|
9
9
|
function be(i) {
|
|
10
10
|
return i.nodeType === Node.TEXT_NODE;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function B(i) {
|
|
13
13
|
const e = i.getBoundingClientRect(), t = getComputedStyle(i), n = parseFloat(t.marginTop) || 0, o = parseFloat(t.marginBottom) || 0;
|
|
14
14
|
return e.height + n + o;
|
|
15
15
|
}
|
|
@@ -20,21 +20,21 @@ const ae = {
|
|
|
20
20
|
hyphen: "-",
|
|
21
21
|
keepOnSamePage: !1,
|
|
22
22
|
hyphenationDisabled: !1
|
|
23
|
-
}, le = {
|
|
23
|
+
}, we = `${C}hyphen`, xe = `${C}keep-on-same-page`, Ne = `${C}hyphenation-disabled`, le = {
|
|
24
24
|
hyphen: {
|
|
25
|
-
key:
|
|
25
|
+
key: we,
|
|
26
26
|
reader: (i) => String(i)
|
|
27
27
|
},
|
|
28
28
|
keepOnSamePage: {
|
|
29
|
-
key:
|
|
29
|
+
key: xe,
|
|
30
30
|
reader: (i) => i === "true"
|
|
31
31
|
},
|
|
32
32
|
hyphenationDisabled: {
|
|
33
|
-
key:
|
|
33
|
+
key: Ne,
|
|
34
34
|
reader: (i) => i === "true"
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
function
|
|
37
|
+
function pt(i) {
|
|
38
38
|
const e = {};
|
|
39
39
|
for (const [t, n] of Object.entries(i)) {
|
|
40
40
|
const o = le[t];
|
|
@@ -42,8 +42,8 @@ function ct(i) {
|
|
|
42
42
|
}
|
|
43
43
|
return e;
|
|
44
44
|
}
|
|
45
|
-
const
|
|
46
|
-
function
|
|
45
|
+
const Q = /* @__PURE__ */ new WeakMap();
|
|
46
|
+
function Se(i, e, t, n) {
|
|
47
47
|
if (t == null)
|
|
48
48
|
return;
|
|
49
49
|
const o = e(t);
|
|
@@ -56,30 +56,30 @@ function ce(i) {
|
|
|
56
56
|
return ce(i?.parentNode);
|
|
57
57
|
const e = {};
|
|
58
58
|
for (const o of Object.keys(ae)) {
|
|
59
|
-
const r = o, s = le[r],
|
|
60
|
-
|
|
59
|
+
const r = o, s = le[r], c = i.getAttribute(s.key);
|
|
60
|
+
Se(r, s.reader, c, e);
|
|
61
61
|
}
|
|
62
|
-
const n = { ...i.parentNode ?
|
|
63
|
-
return
|
|
62
|
+
const n = { ...i.parentNode ? Q.get(i.parentNode) : void 0, ...e };
|
|
63
|
+
return Q.set(i, n), n;
|
|
64
64
|
}
|
|
65
65
|
const de = {
|
|
66
66
|
id: "default",
|
|
67
67
|
plugins: [],
|
|
68
68
|
...ae
|
|
69
69
|
};
|
|
70
|
-
function
|
|
70
|
+
function Ce(i, e) {
|
|
71
71
|
const t = ce(i);
|
|
72
72
|
return { ...de, ...e, ...t };
|
|
73
73
|
}
|
|
74
|
-
function
|
|
74
|
+
function Pe(i) {
|
|
75
75
|
return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
|
|
76
76
|
}
|
|
77
|
-
var $ = { exports: {} },
|
|
78
|
-
function
|
|
79
|
-
return
|
|
77
|
+
var $ = { exports: {} }, Ee = $.exports, ee;
|
|
78
|
+
function Te() {
|
|
79
|
+
return ee || (ee = 1, (function(i) {
|
|
80
80
|
(function(e, t) {
|
|
81
81
|
i.exports ? i.exports = t() : e.log = t();
|
|
82
|
-
})(
|
|
82
|
+
})(Ee, function() {
|
|
83
83
|
var e = function() {
|
|
84
84
|
}, t = "undefined", n = typeof window !== t && typeof window.navigator !== t && /Trident\/|MSIE /.test(window.navigator.userAgent), o = [
|
|
85
85
|
"trace",
|
|
@@ -88,7 +88,7 @@ function xe() {
|
|
|
88
88
|
"warn",
|
|
89
89
|
"error"
|
|
90
90
|
], r = {}, s = null;
|
|
91
|
-
function
|
|
91
|
+
function c(l, p) {
|
|
92
92
|
var a = l[p];
|
|
93
93
|
if (typeof a.bind == "function")
|
|
94
94
|
return a.bind(l);
|
|
@@ -100,11 +100,11 @@ function xe() {
|
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
function
|
|
103
|
+
function _() {
|
|
104
104
|
console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
|
|
105
105
|
}
|
|
106
|
-
function
|
|
107
|
-
return l === "debug" && (l = "log"), typeof console === t ? !1 : l === "trace" && n ?
|
|
106
|
+
function w(l) {
|
|
107
|
+
return l === "debug" && (l = "log"), typeof console === t ? !1 : l === "trace" && n ? _ : console[l] !== void 0 ? c(console, l) : console.log !== void 0 ? c(console, "log") : e;
|
|
108
108
|
}
|
|
109
109
|
function f() {
|
|
110
110
|
for (var l = this.getLevel(), p = 0; p < o.length; p++) {
|
|
@@ -114,19 +114,19 @@ function xe() {
|
|
|
114
114
|
if (this.log = this.debug, typeof console === t && l < this.levels.SILENT)
|
|
115
115
|
return "No console available for logging";
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function v(l) {
|
|
118
118
|
return function() {
|
|
119
119
|
typeof console !== t && (f.call(this), this[l].apply(this, arguments));
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
|
-
function
|
|
123
|
-
return
|
|
122
|
+
function M(l, p, a) {
|
|
123
|
+
return w(l) || v.apply(this, arguments);
|
|
124
124
|
}
|
|
125
|
-
function
|
|
126
|
-
var a = this,
|
|
125
|
+
function G(l, p) {
|
|
126
|
+
var a = this, O, W, x, m = "loglevel";
|
|
127
127
|
typeof l == "string" ? m += ":" + l : typeof l == "symbol" && (m = void 0);
|
|
128
|
-
function ue(
|
|
129
|
-
var u = (o[
|
|
128
|
+
function ue(d) {
|
|
129
|
+
var u = (o[d] || "silent").toUpperCase();
|
|
130
130
|
if (!(typeof window === t || !m)) {
|
|
131
131
|
try {
|
|
132
132
|
window.localStorage[m] = u;
|
|
@@ -139,22 +139,22 @@ function xe() {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
function
|
|
143
|
-
var
|
|
142
|
+
function Z() {
|
|
143
|
+
var d;
|
|
144
144
|
if (!(typeof window === t || !m)) {
|
|
145
145
|
try {
|
|
146
|
-
|
|
146
|
+
d = window.localStorage[m];
|
|
147
147
|
} catch {
|
|
148
148
|
}
|
|
149
|
-
if (typeof
|
|
149
|
+
if (typeof d === t)
|
|
150
150
|
try {
|
|
151
|
-
var u = window.document.cookie,
|
|
152
|
-
X !== -1 && (
|
|
153
|
-
u.slice(X +
|
|
151
|
+
var u = window.document.cookie, H = encodeURIComponent(m), X = u.indexOf(H + "=");
|
|
152
|
+
X !== -1 && (d = /^([^;]+)/.exec(
|
|
153
|
+
u.slice(X + H.length + 1)
|
|
154
154
|
)[1]);
|
|
155
155
|
} catch {
|
|
156
156
|
}
|
|
157
|
-
return a.levels[
|
|
157
|
+
return a.levels[d] === void 0 && (d = void 0), d;
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
function he() {
|
|
@@ -169,11 +169,11 @@ function xe() {
|
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
-
function E(
|
|
173
|
-
var u =
|
|
172
|
+
function E(d) {
|
|
173
|
+
var u = d;
|
|
174
174
|
if (typeof u == "string" && a.levels[u.toUpperCase()] !== void 0 && (u = a.levels[u.toUpperCase()]), typeof u == "number" && u >= 0 && u <= a.levels.SILENT)
|
|
175
175
|
return u;
|
|
176
|
-
throw new TypeError("log.setLevel() called with invalid level: " +
|
|
176
|
+
throw new TypeError("log.setLevel() called with invalid level: " + d);
|
|
177
177
|
}
|
|
178
178
|
a.name = l, a.levels = {
|
|
179
179
|
TRACE: 0,
|
|
@@ -182,33 +182,33 @@ function xe() {
|
|
|
182
182
|
WARN: 3,
|
|
183
183
|
ERROR: 4,
|
|
184
184
|
SILENT: 5
|
|
185
|
-
}, a.methodFactory = p ||
|
|
186
|
-
return
|
|
187
|
-
}, a.setLevel = function(
|
|
188
|
-
return
|
|
189
|
-
}, a.setDefaultLevel = function(
|
|
190
|
-
W = E(
|
|
185
|
+
}, a.methodFactory = p || M, a.getLevel = function() {
|
|
186
|
+
return x ?? W ?? O;
|
|
187
|
+
}, a.setLevel = function(d, u) {
|
|
188
|
+
return x = E(d), u !== !1 && ue(x), f.call(a);
|
|
189
|
+
}, a.setDefaultLevel = function(d) {
|
|
190
|
+
W = E(d), Z() || a.setLevel(d, !1);
|
|
191
191
|
}, a.resetLevel = function() {
|
|
192
|
-
|
|
193
|
-
}, a.enableAll = function(
|
|
194
|
-
a.setLevel(a.levels.TRACE,
|
|
195
|
-
}, a.disableAll = function(
|
|
196
|
-
a.setLevel(a.levels.SILENT,
|
|
192
|
+
x = null, he(), f.call(a);
|
|
193
|
+
}, a.enableAll = function(d) {
|
|
194
|
+
a.setLevel(a.levels.TRACE, d);
|
|
195
|
+
}, a.disableAll = function(d) {
|
|
196
|
+
a.setLevel(a.levels.SILENT, d);
|
|
197
197
|
}, a.rebuild = function() {
|
|
198
|
-
if (s !== a && (
|
|
199
|
-
for (var
|
|
200
|
-
r[
|
|
201
|
-
},
|
|
198
|
+
if (s !== a && (O = E(s.getLevel())), f.call(a), s === a)
|
|
199
|
+
for (var d in r)
|
|
200
|
+
r[d].rebuild();
|
|
201
|
+
}, O = E(
|
|
202
202
|
s ? s.getLevel() : "WARN"
|
|
203
203
|
);
|
|
204
|
-
var
|
|
205
|
-
|
|
204
|
+
var K = Z();
|
|
205
|
+
K != null && (x = E(K)), f.call(a);
|
|
206
206
|
}
|
|
207
|
-
s = new
|
|
207
|
+
s = new G(), s.getLogger = function(p) {
|
|
208
208
|
if (typeof p != "symbol" && typeof p != "string" || p === "")
|
|
209
209
|
throw new TypeError("You must supply a name when creating a logger.");
|
|
210
210
|
var a = r[p];
|
|
211
|
-
return a || (a = r[p] = new
|
|
211
|
+
return a || (a = r[p] = new G(
|
|
212
212
|
p,
|
|
213
213
|
s.methodFactory
|
|
214
214
|
)), a;
|
|
@@ -222,28 +222,28 @@ function xe() {
|
|
|
222
222
|
});
|
|
223
223
|
})($)), $.exports;
|
|
224
224
|
}
|
|
225
|
-
var
|
|
226
|
-
const S = /* @__PURE__ */
|
|
225
|
+
var ke = Te();
|
|
226
|
+
const S = /* @__PURE__ */ Pe(ke), g = S.getLogger(fe);
|
|
227
227
|
g.setDefaultLevel("info");
|
|
228
|
-
const
|
|
229
|
-
function
|
|
228
|
+
const U = "\x1B[46mPLUGIN\x1B[0m";
|
|
229
|
+
function y(i, e, ...t) {
|
|
230
230
|
i.sort((n, o) => n.order - o.order).forEach((n) => {
|
|
231
231
|
const o = n[e];
|
|
232
232
|
if (o) {
|
|
233
233
|
g.debug(
|
|
234
|
-
|
|
234
|
+
U,
|
|
235
235
|
`executing plugin ${n.name}:${String(e)} ()`,
|
|
236
236
|
t
|
|
237
237
|
);
|
|
238
238
|
try {
|
|
239
239
|
o(...t), g.debug(
|
|
240
|
-
|
|
240
|
+
U,
|
|
241
241
|
`plugin ${n.name}:${String(e)} executed`,
|
|
242
242
|
t
|
|
243
243
|
);
|
|
244
244
|
} catch (r) {
|
|
245
245
|
g.debug(
|
|
246
|
-
|
|
246
|
+
U,
|
|
247
247
|
`plugin ${n.name}:${String(e)} failed`,
|
|
248
248
|
r
|
|
249
249
|
);
|
|
@@ -251,14 +251,14 @@ function N(i, e, ...t) {
|
|
|
251
251
|
}
|
|
252
252
|
});
|
|
253
253
|
}
|
|
254
|
-
const
|
|
254
|
+
const P = {
|
|
255
255
|
Element: "element",
|
|
256
256
|
Text: "text"
|
|
257
257
|
};
|
|
258
258
|
class F {
|
|
259
259
|
_node;
|
|
260
260
|
config;
|
|
261
|
-
type =
|
|
261
|
+
type = P.Element;
|
|
262
262
|
transaction;
|
|
263
263
|
clonedFrom;
|
|
264
264
|
cloneCount;
|
|
@@ -283,7 +283,7 @@ class F {
|
|
|
283
283
|
this.config,
|
|
284
284
|
this
|
|
285
285
|
);
|
|
286
|
-
return
|
|
286
|
+
return y(
|
|
287
287
|
this.config.plugins,
|
|
288
288
|
"onClone",
|
|
289
289
|
this.config.id,
|
|
@@ -292,7 +292,7 @@ class F {
|
|
|
292
292
|
), n;
|
|
293
293
|
}
|
|
294
294
|
getHeight() {
|
|
295
|
-
return
|
|
295
|
+
return B(this._node);
|
|
296
296
|
}
|
|
297
297
|
remove() {
|
|
298
298
|
this.transaction.addCommitCallback(() => {
|
|
@@ -309,9 +309,9 @@ class F {
|
|
|
309
309
|
return this._node;
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
|
-
class
|
|
312
|
+
class Ae {
|
|
313
313
|
_node;
|
|
314
|
-
type =
|
|
314
|
+
type = P.Text;
|
|
315
315
|
transaction;
|
|
316
316
|
config;
|
|
317
317
|
constructor(e, t, n) {
|
|
@@ -332,15 +332,15 @@ class Ee {
|
|
|
332
332
|
return this._node;
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
|
-
function
|
|
335
|
+
function D(i, e, t) {
|
|
336
336
|
if (be(i))
|
|
337
|
-
return new
|
|
337
|
+
return new Ae(i, e, t);
|
|
338
338
|
if (se(i))
|
|
339
339
|
return new F(i, e, t);
|
|
340
340
|
throw new Error("Unsupported node type");
|
|
341
341
|
}
|
|
342
342
|
const k = "\x1B[106mDOM\x1B[0m";
|
|
343
|
-
class
|
|
343
|
+
class Ie {
|
|
344
344
|
_transaction;
|
|
345
345
|
_treeWalker;
|
|
346
346
|
_config;
|
|
@@ -382,17 +382,17 @@ class Te {
|
|
|
382
382
|
return this._treeWalker.firstChild() ? (g.debug(k, "moving to first child node"), this.setState(), { parentsTraversed: 1 }) : (this.goToNextNode(), { parentsTraversed: 0 });
|
|
383
383
|
}
|
|
384
384
|
setState() {
|
|
385
|
-
this._previousNode = this._currentNode, this._currentNode =
|
|
385
|
+
this._previousNode = this._currentNode, this._currentNode = D(
|
|
386
386
|
this._treeWalker.currentNode,
|
|
387
387
|
this._transaction,
|
|
388
|
-
|
|
388
|
+
Ce(this._treeWalker.currentNode, this._config)
|
|
389
389
|
), g.debug(k, "moved to node", {
|
|
390
390
|
currentNode: this._currentNode,
|
|
391
391
|
previousNode: this._previousNode
|
|
392
392
|
});
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
|
-
class
|
|
395
|
+
class Fe {
|
|
396
396
|
_onRollback;
|
|
397
397
|
_onCommit;
|
|
398
398
|
isActive;
|
|
@@ -421,8 +421,8 @@ class ke {
|
|
|
421
421
|
this.isActive && (this.isActive = !1, this._onCommit.forEach((e) => e()));
|
|
422
422
|
};
|
|
423
423
|
}
|
|
424
|
-
const
|
|
425
|
-
class
|
|
424
|
+
const V = "\x1B[102mPAGE\x1B[0m";
|
|
425
|
+
class L {
|
|
426
426
|
currentPage;
|
|
427
427
|
activeElement;
|
|
428
428
|
currentElement;
|
|
@@ -430,11 +430,11 @@ class I {
|
|
|
430
430
|
pageIsFull;
|
|
431
431
|
pageIndex;
|
|
432
432
|
pageHeight;
|
|
433
|
-
constructor(e, t, n, o, r, s,
|
|
434
|
-
this.currentPage = e, this.activeElement = t, this.currentElement = n, this.parentStack = o, this.pageIsFull = r, this.pageIndex = s, this.pageHeight =
|
|
433
|
+
constructor(e, t, n, o, r, s, c) {
|
|
434
|
+
this.currentPage = e, this.activeElement = t, this.currentElement = n, this.parentStack = o, this.pageIsFull = r, this.pageIndex = s, this.pageHeight = c;
|
|
435
435
|
}
|
|
436
436
|
static create(e, t, n, o) {
|
|
437
|
-
return new
|
|
437
|
+
return new L(
|
|
438
438
|
e,
|
|
439
439
|
null,
|
|
440
440
|
e,
|
|
@@ -444,7 +444,7 @@ class I {
|
|
|
444
444
|
o
|
|
445
445
|
);
|
|
446
446
|
}
|
|
447
|
-
clone = () => new
|
|
447
|
+
clone = () => new L(
|
|
448
448
|
this.currentPage,
|
|
449
449
|
this.activeElement,
|
|
450
450
|
this.currentElement,
|
|
@@ -454,28 +454,28 @@ class I {
|
|
|
454
454
|
this.pageHeight
|
|
455
455
|
);
|
|
456
456
|
}
|
|
457
|
-
class
|
|
457
|
+
class J {
|
|
458
458
|
_pageState;
|
|
459
459
|
_transaction;
|
|
460
460
|
_tempContainer;
|
|
461
461
|
_config;
|
|
462
462
|
constructor(e, t, n, o) {
|
|
463
463
|
this._tempContainer = e, this._config = o, this._transaction = n;
|
|
464
|
-
const r =
|
|
464
|
+
const r = J.createPageHtmlElement(
|
|
465
465
|
t.width
|
|
466
466
|
), s = this.createNewPage(r);
|
|
467
|
-
this._pageState =
|
|
467
|
+
this._pageState = L.create(s, [], 0, t.height), y(this._config.plugins, "onNewPage", o.id, this);
|
|
468
468
|
}
|
|
469
469
|
nextPage() {
|
|
470
470
|
const e = this.createNewPage(
|
|
471
471
|
this._pageState.currentPage.getNode().cloneNode(!1)
|
|
472
|
-
), t =
|
|
472
|
+
), t = L.create(
|
|
473
473
|
e,
|
|
474
474
|
[],
|
|
475
475
|
this._pageState.pageIndex + 1,
|
|
476
476
|
this._pageState.pageHeight
|
|
477
477
|
);
|
|
478
|
-
this.cloneParentStackToNewPage(t), this.cleanupEmptyParent(), this._pageState = t,
|
|
478
|
+
this.cloneParentStackToNewPage(t), this.cleanupEmptyParent(), this._pageState = t, y(
|
|
479
479
|
this._config.plugins,
|
|
480
480
|
"onNewPage",
|
|
481
481
|
this._config.id,
|
|
@@ -498,10 +498,10 @@ class q {
|
|
|
498
498
|
this._transaction.addCommitCallback(t);
|
|
499
499
|
}
|
|
500
500
|
enterElement() {
|
|
501
|
-
if (!this._pageState.activeElement || this._pageState.activeElement.type !==
|
|
501
|
+
if (!this._pageState.activeElement || this._pageState.activeElement.type !== P.Element)
|
|
502
502
|
throw new Error("Invalid state: activeElement is not an Element");
|
|
503
503
|
g.debug(
|
|
504
|
-
|
|
504
|
+
V,
|
|
505
505
|
"entering an element",
|
|
506
506
|
this._pageState.activeElement
|
|
507
507
|
), this._pageState.currentElement = this._pageState.activeElement, this._pageState.parentStack.push(this._pageState.activeElement);
|
|
@@ -509,18 +509,18 @@ class q {
|
|
|
509
509
|
leaveElement() {
|
|
510
510
|
this._pageState.activeElement = null;
|
|
511
511
|
const e = this._pageState.parentStack.pop();
|
|
512
|
-
g.debug(
|
|
512
|
+
g.debug(V, "leaving a parent element", e);
|
|
513
513
|
const t = this._pageState.parentStack.at(-1);
|
|
514
514
|
this._pageState.currentElement = t ?? this._pageState.currentPage;
|
|
515
515
|
}
|
|
516
516
|
static createPageHtmlElement(e) {
|
|
517
517
|
const t = document.createElement("div");
|
|
518
|
-
return t.style.width = `${e}px`, t.style.maxWidth = `${e}px`, t;
|
|
518
|
+
return t.style.width = `${e}px`, t.style.maxWidth = `${e}px`, t.className = z, t;
|
|
519
519
|
}
|
|
520
520
|
createNewPage(e) {
|
|
521
|
-
return this._tempContainer.appendChild(e), this._transaction.isActive && this._transaction.addRollbackCallback(() => {
|
|
521
|
+
return g.debug(V, "creating new page"), this._tempContainer.appendChild(e), this._transaction.isActive && this._transaction.addRollbackCallback(() => {
|
|
522
522
|
this._tempContainer.removeChild(e);
|
|
523
|
-
}),
|
|
523
|
+
}), D(e, this._transaction, this._config);
|
|
524
524
|
}
|
|
525
525
|
startTransaction() {
|
|
526
526
|
this._transaction.start();
|
|
@@ -543,9 +543,9 @@ class q {
|
|
|
543
543
|
return this._pageState.currentElement.appendChild(n), this._pageState.activeElement = n, n;
|
|
544
544
|
}
|
|
545
545
|
addTextNode(e) {
|
|
546
|
-
if (this._pageState.activeElement?.type ===
|
|
546
|
+
if (this._pageState.activeElement?.type === P.Text)
|
|
547
547
|
return this._pageState.activeElement;
|
|
548
|
-
const t = document.createTextNode(e), n =
|
|
548
|
+
const t = document.createTextNode(e), n = D(
|
|
549
549
|
t,
|
|
550
550
|
this._transaction,
|
|
551
551
|
this._config
|
|
@@ -564,7 +564,7 @@ const h = {
|
|
|
564
564
|
SplitChildren: 2
|
|
565
565
|
// The node is too large for the page, and its children must be paginated individually.
|
|
566
566
|
};
|
|
567
|
-
function
|
|
567
|
+
function Le(i, e) {
|
|
568
568
|
const t = te(i, e);
|
|
569
569
|
if (t !== h.None)
|
|
570
570
|
return t;
|
|
@@ -586,31 +586,30 @@ function te(i, e) {
|
|
|
586
586
|
const t = e.appendChild(i, !1);
|
|
587
587
|
return e.isOverFlow() ? (t.remove(), h.None) : h.SplitChildren;
|
|
588
588
|
}
|
|
589
|
-
function
|
|
589
|
+
function Re(i, e) {
|
|
590
590
|
let t = h.FullNodePlaced;
|
|
591
591
|
const n = i.textContent.split(/(\s+)/).filter((s) => s !== "");
|
|
592
592
|
let o, r = 0;
|
|
593
593
|
for (; o || r < n.length; ) {
|
|
594
|
-
const s = o ?? n[r],
|
|
595
|
-
|
|
594
|
+
const s = o ?? n[r], c = Oe(s, e, i.config);
|
|
595
|
+
c.completed || (t = h.None), c.pendingToken ? o = c.pendingToken : (o = void 0, r++);
|
|
596
596
|
}
|
|
597
597
|
return t;
|
|
598
598
|
}
|
|
599
|
-
function
|
|
600
|
-
e.hasEmptySpace() || e.nextPage();
|
|
599
|
+
function Oe(i, e, t) {
|
|
601
600
|
const n = e.addTextNode(""), o = n.textContent;
|
|
602
601
|
if (n.textContent += i, !e.isOverFlow())
|
|
603
602
|
return {
|
|
604
603
|
completed: !0
|
|
605
604
|
};
|
|
606
605
|
n.textContent = o;
|
|
607
|
-
const r =
|
|
606
|
+
const r = He(i, e, t);
|
|
608
607
|
return {
|
|
609
608
|
pendingToken: r.leftovers,
|
|
610
609
|
completed: r.completed
|
|
611
610
|
};
|
|
612
611
|
}
|
|
613
|
-
function
|
|
612
|
+
function He(i, e, t) {
|
|
614
613
|
const { rollback: n, commit: o } = e.startTransaction();
|
|
615
614
|
if (e.nextPage(), e.addTextNode(i), !e.isOverFlow())
|
|
616
615
|
return o(), {
|
|
@@ -620,32 +619,33 @@ function Ie(i, e, t) {
|
|
|
620
619
|
return g.warn("Hyphenation disabled, skipping oversized token:", i), {
|
|
621
620
|
completed: !1
|
|
622
621
|
};
|
|
623
|
-
|
|
622
|
+
e.hasEmptySpace() || e.nextPage();
|
|
623
|
+
const r = $e(i, t.hyphen, e);
|
|
624
624
|
return {
|
|
625
625
|
completed: !0,
|
|
626
626
|
leftovers: r && r.length > 0 ? r : void 0
|
|
627
627
|
};
|
|
628
628
|
}
|
|
629
|
-
function
|
|
629
|
+
function $e(i, e, t) {
|
|
630
630
|
const n = t.addTextNode("");
|
|
631
631
|
let o = "";
|
|
632
632
|
for (let r = 0; r < i.length; r++) {
|
|
633
|
-
const s = i[r],
|
|
634
|
-
if (n.textContent =
|
|
633
|
+
const s = i[r], c = o + s;
|
|
634
|
+
if (n.textContent = c + e, !t.hasEmptySpace())
|
|
635
635
|
return n.textContent = o ? o + e : "", t.markPageAsFull(), i.slice(r);
|
|
636
|
-
o =
|
|
636
|
+
o = c;
|
|
637
637
|
}
|
|
638
638
|
return null;
|
|
639
639
|
}
|
|
640
640
|
const A = "\x1B[103mPAGINATOR\x1B[0m";
|
|
641
|
-
class
|
|
641
|
+
class j {
|
|
642
642
|
_domState;
|
|
643
643
|
_pageManager;
|
|
644
644
|
_transaction;
|
|
645
645
|
_tempContainer;
|
|
646
646
|
_config;
|
|
647
647
|
constructor(e, t, n) {
|
|
648
|
-
this._config = { ...de, ...n }, this._tempContainer =
|
|
648
|
+
this._config = { ...de, ...n }, this._tempContainer = j.createTempContainer(this._config.id), this._transaction = new Fe(), this._domState = new Ie(e, this._transaction, this._config), this._pageManager = new J(
|
|
649
649
|
this._tempContainer,
|
|
650
650
|
t,
|
|
651
651
|
this._transaction,
|
|
@@ -654,13 +654,16 @@ class D {
|
|
|
654
654
|
}
|
|
655
655
|
static createTempContainer(e) {
|
|
656
656
|
const t = document.createElement("div");
|
|
657
|
-
return t.style.display = "flex", t.style.flexDirection = "column", t.style.gap = "20px", t.setAttribute(`${C}-section-id`, e), t.classList.add(_e),
|
|
657
|
+
return t.style.display = "flex", t.style.flexDirection = "column", t.style.gap = "20px", t.setAttribute(`${C}-section-id`, e), t.classList.add(_e), q() || ye(t), document.body.appendChild(t), t;
|
|
658
658
|
}
|
|
659
659
|
static paginate(e, t, n) {
|
|
660
|
-
const o = new
|
|
660
|
+
const o = new j(e, t, n);
|
|
661
661
|
o.processAllNodes();
|
|
662
662
|
const r = Array.from(o._tempContainer.childNodes).filter((s) => se(s)).map((s) => s.innerHTML);
|
|
663
|
-
return
|
|
663
|
+
return q() ? Array.from(o._tempContainer.childNodes).forEach((s) => {
|
|
664
|
+
const c = s;
|
|
665
|
+
c.style.height = `${t.height}px`, c.style.width = `${t.width}px`;
|
|
666
|
+
}) : o._tempContainer.remove(), r;
|
|
664
667
|
}
|
|
665
668
|
processAllNodes() {
|
|
666
669
|
this._domState.goToNextNode();
|
|
@@ -671,7 +674,7 @@ class D {
|
|
|
671
674
|
this._domState.currentNode
|
|
672
675
|
);
|
|
673
676
|
const e = this.processCurrentNode();
|
|
674
|
-
switch (
|
|
677
|
+
switch (y(
|
|
675
678
|
this._config.plugins,
|
|
676
679
|
"afterVisitNode",
|
|
677
680
|
this._config.id,
|
|
@@ -690,7 +693,13 @@ class D {
|
|
|
690
693
|
break;
|
|
691
694
|
}
|
|
692
695
|
} while (this._domState.completed === !1);
|
|
693
|
-
|
|
696
|
+
y(
|
|
697
|
+
this._config.plugins,
|
|
698
|
+
"afterPagination",
|
|
699
|
+
this._config.id,
|
|
700
|
+
this._domState,
|
|
701
|
+
this._pageManager
|
|
702
|
+
), S.debug(A, "pagination completed");
|
|
694
703
|
}
|
|
695
704
|
handleNodeSkipped() {
|
|
696
705
|
S.debug(A, "node skipped - couldn't paginate"), this._domState.goToNextNode();
|
|
@@ -705,34 +714,34 @@ class D {
|
|
|
705
714
|
S.debug(
|
|
706
715
|
A,
|
|
707
716
|
"node partially paginated - splitting children"
|
|
708
|
-
), this._domState.goToFirstChildOrNextNode().parentsTraversed === 1 && this._domState.previousNode?.type ===
|
|
717
|
+
), this._domState.goToFirstChildOrNextNode().parentsTraversed === 1 && this._domState.previousNode?.type === P.Element && this._pageManager.enterElement();
|
|
709
718
|
}
|
|
710
719
|
processCurrentNode() {
|
|
711
720
|
if (!this._domState.currentNode)
|
|
712
721
|
return h.None;
|
|
713
|
-
if (this._domState.currentNode.type ===
|
|
722
|
+
if (this._domState.currentNode.type === P.Element) {
|
|
714
723
|
const e = {};
|
|
715
|
-
return
|
|
724
|
+
return y(
|
|
716
725
|
this._config.plugins,
|
|
717
726
|
"onVisitElement",
|
|
718
727
|
this._config.id,
|
|
719
728
|
this._domState,
|
|
720
729
|
this._pageManager,
|
|
721
730
|
e
|
|
722
|
-
), e.result !== void 0 ? e.result :
|
|
731
|
+
), e.result !== void 0 ? e.result : Le(
|
|
723
732
|
this._domState.currentNode,
|
|
724
733
|
this._pageManager
|
|
725
734
|
);
|
|
726
735
|
} else {
|
|
727
736
|
const e = {};
|
|
728
|
-
return
|
|
737
|
+
return y(
|
|
729
738
|
this._config.plugins,
|
|
730
739
|
"onVisitText",
|
|
731
740
|
this._config.id,
|
|
732
741
|
this._domState,
|
|
733
742
|
this._pageManager,
|
|
734
743
|
e
|
|
735
|
-
), e.result !== void 0 ? e.result :
|
|
744
|
+
), e.result !== void 0 ? e.result : Re(
|
|
736
745
|
this._domState.currentNode,
|
|
737
746
|
this._pageManager
|
|
738
747
|
);
|
|
@@ -756,7 +765,7 @@ class ge {
|
|
|
756
765
|
await r(...t);
|
|
757
766
|
}
|
|
758
767
|
}
|
|
759
|
-
const
|
|
768
|
+
const ut = {
|
|
760
769
|
/** 841mm x 594mm */
|
|
761
770
|
A1: { height: "841mm", width: "594mm" },
|
|
762
771
|
/** 594mm x 420mm */
|
|
@@ -781,7 +790,7 @@ const dt = {
|
|
|
781
790
|
Legal: { height: "11in", width: "8.5in" },
|
|
782
791
|
/** 11in x 17in */
|
|
783
792
|
Tabloid: { height: "11in", width: "17in" }
|
|
784
|
-
},
|
|
793
|
+
}, ze = {
|
|
785
794
|
/** Top, Right, Bottom, Left: 1in */
|
|
786
795
|
Normal: {
|
|
787
796
|
top: "1in",
|
|
@@ -810,24 +819,24 @@ const dt = {
|
|
|
810
819
|
bottom: "0in",
|
|
811
820
|
left: "0in"
|
|
812
821
|
}
|
|
813
|
-
},
|
|
814
|
-
function
|
|
822
|
+
}, Be = "__PAPRIZE_IS_INITIALIZED", ne = "__PAPRIZE_IS_READY", ie = "__PAPRIZE_READ_JSON_DATA_FILE";
|
|
823
|
+
function De(i) {
|
|
815
824
|
const e = i.getBoundingClientRect(), t = getComputedStyle(i), n = parseFloat(t.marginLeft) || 0, o = parseFloat(t.marginRight) || 0;
|
|
816
825
|
return {
|
|
817
|
-
height:
|
|
826
|
+
height: B(i),
|
|
818
827
|
width: e.width + n + o
|
|
819
828
|
};
|
|
820
829
|
}
|
|
821
|
-
function
|
|
822
|
-
const { height: n, width: o } =
|
|
830
|
+
function je(i, e, t) {
|
|
831
|
+
const { height: n, width: o } = De(i), r = e ? B(e) : 0, s = t ? B(t) : 0;
|
|
823
832
|
return { height: n, width: o, sectionHeaderHeight: r, sectionFooterHeight: s };
|
|
824
833
|
}
|
|
825
|
-
function
|
|
834
|
+
function Me(i, e, t) {
|
|
826
835
|
return {
|
|
827
836
|
name: "sectionPageHeight",
|
|
828
837
|
order: 1,
|
|
829
|
-
|
|
830
|
-
|
|
838
|
+
afterPagination: (n, o, r) => {
|
|
839
|
+
t <= 0 || r.hasEmptySpace(t) || r.nextPage();
|
|
831
840
|
},
|
|
832
841
|
onNewPage: (n, o) => {
|
|
833
842
|
const r = o.getPageState();
|
|
@@ -835,20 +844,20 @@ function Be(i, e, t) {
|
|
|
835
844
|
}
|
|
836
845
|
};
|
|
837
846
|
}
|
|
838
|
-
function
|
|
847
|
+
function We(i) {
|
|
839
848
|
return i ? `${i.top} ${i.right} ${i.bottom} ${i.left}` : "0";
|
|
840
849
|
}
|
|
841
|
-
function
|
|
850
|
+
function Ue(i) {
|
|
842
851
|
let e = null;
|
|
843
852
|
return () => (e || (e = i()), e);
|
|
844
853
|
}
|
|
845
|
-
async function
|
|
854
|
+
async function Ve() {
|
|
846
855
|
if (!(ie in window))
|
|
847
856
|
return null;
|
|
848
857
|
const i = await window[ie]?.();
|
|
849
858
|
return i ? JSON.parse(i) : null;
|
|
850
859
|
}
|
|
851
|
-
const
|
|
860
|
+
const qe = `
|
|
852
861
|
html {
|
|
853
862
|
box-sizing: border-box;
|
|
854
863
|
}
|
|
@@ -861,7 +870,6 @@ const Me = `
|
|
|
861
870
|
|
|
862
871
|
:root {
|
|
863
872
|
--paprize-page-background-color: #ffffff;
|
|
864
|
-
--paprize-page-margin-bottom: 10px;
|
|
865
873
|
--paprize-page-box-shadow: rgb(142 138 138) -1px 3px 5px 2px;
|
|
866
874
|
--paprize-section-margin-bottom: 10px;
|
|
867
875
|
--paprize-preview-background-color: rgb(218 220 224);
|
|
@@ -882,9 +890,8 @@ const Me = `
|
|
|
882
890
|
padding: var(--paprize-preview-padding);
|
|
883
891
|
}
|
|
884
892
|
|
|
885
|
-
.${
|
|
893
|
+
.${z} {
|
|
886
894
|
box-shadow: var(--paprize-page-box-shadow);
|
|
887
|
-
margin-bottom: var(--paprize-page-margin-bottom);
|
|
888
895
|
background-color: var(--paprize-page-background-color);
|
|
889
896
|
}
|
|
890
897
|
|
|
@@ -898,37 +905,37 @@ const Me = `
|
|
|
898
905
|
display: none !important;
|
|
899
906
|
}
|
|
900
907
|
}
|
|
901
|
-
`,
|
|
908
|
+
`, Je = {
|
|
902
909
|
display: "flex",
|
|
903
910
|
flexDirection: "column"
|
|
904
|
-
},
|
|
911
|
+
}, Ge = {
|
|
905
912
|
position: "absolute",
|
|
906
913
|
left: "-9999px",
|
|
907
914
|
top: "-9999px",
|
|
908
915
|
visibility: "hidden"
|
|
909
|
-
},
|
|
916
|
+
}, Ze = (i, e) => ({
|
|
910
917
|
display: "flex",
|
|
911
918
|
flexDirection: "column",
|
|
912
919
|
width: i.width,
|
|
913
920
|
height: i.height,
|
|
914
921
|
maxHeight: i.height,
|
|
915
922
|
position: "relative",
|
|
916
|
-
padding:
|
|
923
|
+
padding: We(e),
|
|
917
924
|
zIndex: "1"
|
|
918
|
-
}),
|
|
925
|
+
}), Ke = {
|
|
919
926
|
overflow: "hidden",
|
|
920
927
|
width: "100%",
|
|
921
928
|
height: "100%"
|
|
922
|
-
},
|
|
929
|
+
}, Xe = {
|
|
923
930
|
position: "absolute",
|
|
924
931
|
width: "100%",
|
|
925
932
|
height: "100%",
|
|
926
933
|
left: 0,
|
|
927
934
|
top: 0
|
|
928
|
-
},
|
|
935
|
+
}, Ye = (i) => ({
|
|
929
936
|
page: `section-${i}`
|
|
930
937
|
});
|
|
931
|
-
function
|
|
938
|
+
function Qe(i, e) {
|
|
932
939
|
return `@page section-${i} {
|
|
933
940
|
margin: none;
|
|
934
941
|
size:${e.width} ${e.height};
|
|
@@ -936,37 +943,37 @@ function Xe(i, e) {
|
|
|
936
943
|
height:${e.height};
|
|
937
944
|
}`;
|
|
938
945
|
}
|
|
939
|
-
const
|
|
940
|
-
globalStyle:
|
|
941
|
-
component:
|
|
942
|
-
outOfScreen:
|
|
943
|
-
page:
|
|
944
|
-
overlay:
|
|
945
|
-
pageContent:
|
|
946
|
-
sectionPageMedia:
|
|
947
|
-
section:
|
|
946
|
+
const b = {
|
|
947
|
+
globalStyle: qe,
|
|
948
|
+
component: Je,
|
|
949
|
+
outOfScreen: Ge,
|
|
950
|
+
page: Ze,
|
|
951
|
+
overlay: Xe,
|
|
952
|
+
pageContent: Ke,
|
|
953
|
+
sectionPageMedia: Qe,
|
|
954
|
+
section: Ye
|
|
948
955
|
};
|
|
949
|
-
function
|
|
956
|
+
function I(i) {
|
|
950
957
|
return i?.cloneNode(!0) ?? null;
|
|
951
958
|
}
|
|
952
|
-
function
|
|
959
|
+
function et(i) {
|
|
953
960
|
return {
|
|
954
|
-
sectionHeader:
|
|
955
|
-
sectionFooter:
|
|
956
|
-
pageHeader:
|
|
957
|
-
pageFooter:
|
|
958
|
-
pageContent:
|
|
961
|
+
sectionHeader: I(i.sectionHeader),
|
|
962
|
+
sectionFooter: I(i.sectionFooter),
|
|
963
|
+
pageHeader: I(i.pageHeader),
|
|
964
|
+
pageFooter: I(i.pageFooter),
|
|
965
|
+
pageContent: I(i.pageContent)
|
|
959
966
|
};
|
|
960
967
|
}
|
|
961
|
-
const
|
|
962
|
-
class
|
|
968
|
+
const tt = "data-pz-page-break";
|
|
969
|
+
class nt {
|
|
963
970
|
name = "pageBreak";
|
|
964
971
|
order = 1;
|
|
965
972
|
onVisitElement = (e, t, n, o) => {
|
|
966
|
-
t.currentNode.getNode().getAttribute(
|
|
973
|
+
t.currentNode.getNode().getAttribute(tt) === "true" && (n.markPageAsFull(), o.result = h.FullNodePlaced);
|
|
967
974
|
};
|
|
968
975
|
}
|
|
969
|
-
class
|
|
976
|
+
class it {
|
|
970
977
|
_options = {};
|
|
971
978
|
name = "table";
|
|
972
979
|
order = 1;
|
|
@@ -977,49 +984,52 @@ class et {
|
|
|
977
984
|
if (this._options.includeHeaderOnlyTables)
|
|
978
985
|
return;
|
|
979
986
|
const o = t.getPageState().parentStack.find(
|
|
980
|
-
(
|
|
987
|
+
(v) => this._isTable(v.getNode())
|
|
981
988
|
);
|
|
982
989
|
if (!o || !o.clonedFrom)
|
|
983
990
|
return;
|
|
984
|
-
const r = o.clonedFrom, s = r.getNode(),
|
|
985
|
-
if (!(
|
|
991
|
+
const r = o.clonedFrom, s = r.getNode(), c = s.tHead;
|
|
992
|
+
if (!(c !== null))
|
|
986
993
|
return;
|
|
987
|
-
const
|
|
988
|
-
if (!this._isTableBodyEmpty(
|
|
994
|
+
const w = s.tBodies;
|
|
995
|
+
if (!this._isTableBodyEmpty(w))
|
|
989
996
|
return;
|
|
990
997
|
if (r.remove(), o.getNode().tHead === null) {
|
|
991
|
-
const
|
|
992
|
-
|
|
998
|
+
const v = D(
|
|
999
|
+
c.cloneNode(!0),
|
|
993
1000
|
o.transaction,
|
|
994
1001
|
o.config
|
|
995
1002
|
);
|
|
996
|
-
o.appendChild(
|
|
1003
|
+
o.appendChild(v);
|
|
997
1004
|
}
|
|
998
1005
|
};
|
|
1006
|
+
onVisitElement = (e, t, n, o) => {
|
|
1007
|
+
const r = t.currentNode.getNode();
|
|
1008
|
+
r.tagName === "TR" ? t.currentNode.config.keepOnSamePage = !0 : (r.tagName === "TFOOT" && this._options.cloneFooter || r.tagName === "THEAD" && this._options.cloneHeader) && (o.result = h.FullNodePlaced);
|
|
1009
|
+
};
|
|
999
1010
|
onClone = (e, t, n) => {
|
|
1000
|
-
if (t
|
|
1001
|
-
n.config.keepOnSamePage = !0;
|
|
1011
|
+
if (!this._isTable(t) || !n.clonedFrom)
|
|
1002
1012
|
return;
|
|
1003
|
-
|
|
1004
|
-
if (
|
|
1013
|
+
const o = n.getNode();
|
|
1014
|
+
if (o.tHead || o.tFoot)
|
|
1005
1015
|
return;
|
|
1006
|
-
const
|
|
1007
|
-
if (
|
|
1008
|
-
const
|
|
1009
|
-
|
|
1016
|
+
const r = n.getOriginalNode(), s = r.tHead;
|
|
1017
|
+
if (s && this._options.cloneHeader === !0) {
|
|
1018
|
+
const _ = new F(
|
|
1019
|
+
s.cloneNode(!0),
|
|
1010
1020
|
n.transaction,
|
|
1011
1021
|
n.config
|
|
1012
1022
|
);
|
|
1013
|
-
n.appendChild(
|
|
1023
|
+
n.appendChild(_);
|
|
1014
1024
|
}
|
|
1015
|
-
const
|
|
1016
|
-
if (
|
|
1017
|
-
const
|
|
1018
|
-
|
|
1025
|
+
const c = r.tFoot;
|
|
1026
|
+
if (c && this._options.cloneFooter === !0) {
|
|
1027
|
+
const _ = new F(
|
|
1028
|
+
c.cloneNode(!0),
|
|
1019
1029
|
n.transaction,
|
|
1020
1030
|
n.config
|
|
1021
1031
|
);
|
|
1022
|
-
n.appendChild(
|
|
1032
|
+
n.appendChild(_);
|
|
1023
1033
|
}
|
|
1024
1034
|
};
|
|
1025
1035
|
_isTable(e) {
|
|
@@ -1028,27 +1038,28 @@ class et {
|
|
|
1028
1038
|
_isTableBodyEmpty(e) {
|
|
1029
1039
|
if (e.length === 0) return !0;
|
|
1030
1040
|
const t = e[0];
|
|
1031
|
-
if (t.rows.length
|
|
1041
|
+
if (t.rows.length === 0) return !0;
|
|
1042
|
+
if (t.rows.length > 1) return !1;
|
|
1032
1043
|
const n = t.rows[0];
|
|
1033
|
-
return n.cells.length
|
|
1044
|
+
return n.cells.length === 0 ? !0 : n.cells.length > 1 ? !1 : n.cells[0].textContent?.trim().length === 0;
|
|
1034
1045
|
}
|
|
1035
1046
|
}
|
|
1036
|
-
const
|
|
1037
|
-
new
|
|
1038
|
-
new
|
|
1039
|
-
],
|
|
1047
|
+
const ot = [
|
|
1048
|
+
new nt(),
|
|
1049
|
+
new it()
|
|
1050
|
+
], ht = {
|
|
1040
1051
|
name: "debug",
|
|
1041
1052
|
order: Number.MAX_SAFE_INTEGER,
|
|
1042
1053
|
onNewPage: (i, e) => {
|
|
1043
1054
|
const t = e.getPageState().currentPage.getNode();
|
|
1044
|
-
t.classList.contains(
|
|
1055
|
+
t.classList.contains(z) || t.classList.add(z), t.setAttribute(`${C}-element`, "page"), t.setAttribute(
|
|
1045
1056
|
`${C}-height`,
|
|
1046
1057
|
e.getPageState().pageHeight.toString()
|
|
1047
1058
|
);
|
|
1048
1059
|
}
|
|
1049
|
-
},
|
|
1050
|
-
class
|
|
1051
|
-
name =
|
|
1060
|
+
}, rt = "sectionToc";
|
|
1061
|
+
class mt {
|
|
1062
|
+
name = rt;
|
|
1052
1063
|
order = 1;
|
|
1053
1064
|
_state = /* @__PURE__ */ new Map();
|
|
1054
1065
|
getContentList = () => Array.from(this._state.values()).flat();
|
|
@@ -1121,21 +1132,21 @@ class R {
|
|
|
1121
1132
|
);
|
|
1122
1133
|
}
|
|
1123
1134
|
}
|
|
1124
|
-
function
|
|
1135
|
+
function ft(i, e) {
|
|
1125
1136
|
return `${i}-${e + 1}`;
|
|
1126
1137
|
}
|
|
1127
|
-
function
|
|
1138
|
+
function st(i, e) {
|
|
1128
1139
|
return e === "landscape" ? { height: i.width, width: i.height } : i;
|
|
1129
1140
|
}
|
|
1130
|
-
const
|
|
1131
|
-
class
|
|
1141
|
+
const N = "\x1B[43mREPORT\x1B[0m";
|
|
1142
|
+
class _t {
|
|
1132
1143
|
_sections;
|
|
1133
1144
|
_monitor;
|
|
1134
1145
|
_paginationInProgress;
|
|
1135
1146
|
_pendingPaginateResolvers;
|
|
1136
1147
|
_currentAbortController;
|
|
1137
1148
|
constructor() {
|
|
1138
|
-
this._sections = /* @__PURE__ */ new Map(), this._monitor = new ge(), this._paginationInProgress = !1, this._pendingPaginateResolvers = [], this._currentAbortController = null, window[
|
|
1149
|
+
this._sections = /* @__PURE__ */ new Map(), this._monitor = new ge(), this._paginationInProgress = !1, this._pendingPaginateResolvers = [], this._currentAbortController = null, window[Be] = !0, this._injectStyle(b.globalStyle);
|
|
1139
1150
|
}
|
|
1140
1151
|
/**
|
|
1141
1152
|
* Monitor instance used to subscribe to pagination events.
|
|
@@ -1166,21 +1177,21 @@ class ht {
|
|
|
1166
1177
|
sectionId: e.id,
|
|
1167
1178
|
isPaginated: !1,
|
|
1168
1179
|
isSuspended: !!e.suspense?.length,
|
|
1169
|
-
pages: []
|
|
1170
|
-
};
|
|
1171
|
-
return this._sections.set(e.id, {
|
|
1172
|
-
context: o,
|
|
1180
|
+
pages: [],
|
|
1173
1181
|
options: {
|
|
1174
1182
|
...e,
|
|
1175
|
-
size:
|
|
1183
|
+
size: st(
|
|
1176
1184
|
e.size,
|
|
1177
1185
|
e.orientation ?? "portrait"
|
|
1178
1186
|
)
|
|
1179
1187
|
},
|
|
1180
|
-
components: t
|
|
1188
|
+
components: t
|
|
1189
|
+
};
|
|
1190
|
+
return this._sections.set(e.id, {
|
|
1191
|
+
context: o,
|
|
1181
1192
|
onPaginationCompleted: n
|
|
1182
1193
|
}), this._injectStyle(
|
|
1183
|
-
|
|
1194
|
+
b.sectionPageMedia(e.id, e.size)
|
|
1184
1195
|
), await this._monitor.dispatch("sectionCreated", o), !0;
|
|
1185
1196
|
}
|
|
1186
1197
|
/**
|
|
@@ -1203,7 +1214,7 @@ class ht {
|
|
|
1203
1214
|
sections: [],
|
|
1204
1215
|
suspension: Promise.resolve()
|
|
1205
1216
|
}) : (this._paginationInProgress && this._currentAbortController && (g.debug(
|
|
1206
|
-
|
|
1217
|
+
N,
|
|
1207
1218
|
"Cancelling previous pagination operation."
|
|
1208
1219
|
), this._currentAbortController.abort(
|
|
1209
1220
|
"Cancelled by new paginate call"
|
|
@@ -1228,12 +1239,12 @@ class ht {
|
|
|
1228
1239
|
async getJsonData(e) {
|
|
1229
1240
|
return await this._lazyJsonDataReader().catch(() => e) ?? e ?? null;
|
|
1230
1241
|
}
|
|
1231
|
-
_lazyJsonDataReader =
|
|
1242
|
+
_lazyJsonDataReader = Ue(Ve);
|
|
1232
1243
|
async _executePagination() {
|
|
1233
1244
|
this._paginationInProgress = !0, this._currentAbortController = new AbortController();
|
|
1234
1245
|
const e = this._currentAbortController.signal;
|
|
1235
1246
|
try {
|
|
1236
|
-
if (g.debug(
|
|
1247
|
+
if (g.debug(N, "Schedule paginate."), await document.fonts.ready, e.aborted)
|
|
1237
1248
|
return new Promise((o, r) => {
|
|
1238
1249
|
this._pendingPaginateResolvers.push({ resolve: o, reject: r });
|
|
1239
1250
|
});
|
|
@@ -1241,21 +1252,21 @@ class ht {
|
|
|
1241
1252
|
for (const o of this._sections.values()) {
|
|
1242
1253
|
o.context.isPaginated = !1;
|
|
1243
1254
|
const r = new R();
|
|
1244
|
-
await r.add(o.options.suspense), r.monitor.addEventListener("onChange", (s) => {
|
|
1255
|
+
await r.add(o.context.options.suspense), r.monitor.addEventListener("onChange", (s) => {
|
|
1245
1256
|
g.debug(
|
|
1246
|
-
|
|
1247
|
-
`${s} pending promises in section '${o.
|
|
1257
|
+
N,
|
|
1258
|
+
`${s} pending promises in section '${o.context.sectionId}'.`
|
|
1248
1259
|
);
|
|
1249
1260
|
}), r.then(async () => {
|
|
1250
1261
|
e.aborted || (g.debug(
|
|
1251
|
-
|
|
1252
|
-
`Start paginating section '${o.
|
|
1262
|
+
N,
|
|
1263
|
+
`Start paginating section '${o.context.sectionId}'.`
|
|
1253
1264
|
), o.context.isSuspended = !1, await this._paginateSection(o));
|
|
1254
1265
|
}), t.push(r);
|
|
1255
1266
|
}
|
|
1256
1267
|
const n = new R();
|
|
1257
1268
|
return n.monitor.addEventListener("onChange", async () => {
|
|
1258
|
-
g.debug(
|
|
1269
|
+
g.debug(N, "Report pagination completed."), await this._monitor.dispatch("paginationCycleCompleted", {
|
|
1259
1270
|
sections: [...this._sections.values()].map(
|
|
1260
1271
|
(o) => o.context
|
|
1261
1272
|
)
|
|
@@ -1276,7 +1287,7 @@ class ht {
|
|
|
1276
1287
|
if (this._pendingPaginateResolvers.length === 0)
|
|
1277
1288
|
return;
|
|
1278
1289
|
g.debug(
|
|
1279
|
-
|
|
1290
|
+
N,
|
|
1280
1291
|
`Processing ${this._pendingPaginateResolvers.length} pending paginate calls.`
|
|
1281
1292
|
);
|
|
1282
1293
|
const e = [...this._pendingPaginateResolvers];
|
|
@@ -1287,73 +1298,72 @@ class ht {
|
|
|
1287
1298
|
}
|
|
1288
1299
|
_injectStyle(e) {
|
|
1289
1300
|
let t = document.getElementById(
|
|
1290
|
-
|
|
1301
|
+
Y
|
|
1291
1302
|
);
|
|
1292
|
-
t || (t = document.createElement("style"), t.id =
|
|
1303
|
+
t || (t = document.createElement("style"), t.id = Y, t.textContent = "", document.head.appendChild(t)), t.textContent = (t.textContent + e).replace(/\s+/g, " ").replace(/\s*([:;{}])\s*/g, "$1").trim();
|
|
1293
1304
|
}
|
|
1294
1305
|
async _paginateSection(e) {
|
|
1295
1306
|
const t = document.createElement("div");
|
|
1296
1307
|
Object.assign(
|
|
1297
1308
|
t.style,
|
|
1298
|
-
|
|
1299
|
-
e.options.size,
|
|
1300
|
-
e.options.margin ??
|
|
1309
|
+
b.page(
|
|
1310
|
+
e.context.options.size,
|
|
1311
|
+
e.context.options.margin ?? ze.None
|
|
1301
1312
|
)
|
|
1302
|
-
),
|
|
1303
|
-
const n =
|
|
1313
|
+
), q() || Object.assign(t.style, b.outOfScreen);
|
|
1314
|
+
const n = et(e.context.components);
|
|
1304
1315
|
n.sectionHeader && (Object.assign(
|
|
1305
1316
|
n.sectionHeader.style,
|
|
1306
|
-
|
|
1307
|
-
), t.appendChild(n.sectionHeader)), n.pageHeader && (Object.assign(n.pageHeader.style,
|
|
1317
|
+
b.component
|
|
1318
|
+
), t.appendChild(n.sectionHeader)), n.pageHeader && (Object.assign(n.pageHeader.style, b.component), t.appendChild(n.pageHeader)), Object.assign(n.pageContent.style, b.pageContent), t.appendChild(n.pageContent), n.pageFooter && (Object.assign(n.pageFooter.style, b.component), t.appendChild(n.pageFooter)), n.sectionFooter && (Object.assign(
|
|
1308
1319
|
n.sectionFooter.style,
|
|
1309
|
-
|
|
1320
|
+
b.component
|
|
1310
1321
|
), t.appendChild(n.sectionFooter)), document.body.appendChild(t);
|
|
1311
|
-
const { height: o, width: r, sectionHeaderHeight: s, sectionFooterHeight:
|
|
1322
|
+
const { height: o, width: r, sectionHeaderHeight: s, sectionFooterHeight: c } = je(
|
|
1312
1323
|
n.pageContent,
|
|
1313
1324
|
n.sectionHeader,
|
|
1314
1325
|
n.sectionFooter
|
|
1315
1326
|
);
|
|
1316
1327
|
if (o === 0)
|
|
1317
1328
|
throw g.error(
|
|
1318
|
-
`Pagination failed for section '${e.
|
|
1329
|
+
`Pagination failed for section '${e.context.sectionId}': insufficient space for page content or content is empty. Ensure that the section has content and that the header and footer do not occupy all available space.`
|
|
1319
1330
|
), t.remove(), new Error(
|
|
1320
|
-
`Pagination failed: no available space for content in section '${e.
|
|
1331
|
+
`Pagination failed: no available space for content in section '${e.context.sectionId}'.`
|
|
1321
1332
|
);
|
|
1322
|
-
const
|
|
1333
|
+
const _ = j.paginate(
|
|
1323
1334
|
n.pageContent,
|
|
1324
1335
|
{ height: o, width: r },
|
|
1325
1336
|
{
|
|
1326
|
-
id: e.
|
|
1337
|
+
id: e.context.sectionId,
|
|
1327
1338
|
plugins: [
|
|
1328
|
-
...e.options.plugins ??
|
|
1329
|
-
|
|
1339
|
+
...e.context.options.plugins ?? ot,
|
|
1340
|
+
Me(
|
|
1330
1341
|
o,
|
|
1331
1342
|
s,
|
|
1332
|
-
|
|
1343
|
+
c
|
|
1333
1344
|
)
|
|
1334
1345
|
]
|
|
1335
1346
|
}
|
|
1336
1347
|
);
|
|
1337
1348
|
t.remove();
|
|
1338
|
-
const
|
|
1339
|
-
pageIndex:
|
|
1340
|
-
totalPages:
|
|
1341
|
-
sectionId: e.
|
|
1342
|
-
pageContentHtml:
|
|
1343
|
-
}))
|
|
1344
|
-
await e.onPaginationCompleted(b);
|
|
1345
|
-
for (const _ of b)
|
|
1346
|
-
await this._monitor.dispatch("pageCompleted", _);
|
|
1347
|
-
const f = {
|
|
1349
|
+
const w = _.map((v, M) => ({
|
|
1350
|
+
pageIndex: M,
|
|
1351
|
+
totalPages: _.length,
|
|
1352
|
+
sectionId: e.context.sectionId,
|
|
1353
|
+
pageContentHtml: v
|
|
1354
|
+
})), f = {
|
|
1348
1355
|
...e.context,
|
|
1349
1356
|
isPaginated: !0,
|
|
1350
1357
|
isSuspended: !1,
|
|
1351
|
-
pages:
|
|
1358
|
+
pages: w
|
|
1352
1359
|
};
|
|
1353
|
-
this._sections.set(e.
|
|
1360
|
+
this._sections.set(e.context.sectionId, {
|
|
1354
1361
|
...e,
|
|
1355
1362
|
context: f
|
|
1356
|
-
}), await
|
|
1363
|
+
}), await e.onPaginationCompleted(f);
|
|
1364
|
+
for (const v of w)
|
|
1365
|
+
await this._monitor.dispatch("pageCompleted", v);
|
|
1366
|
+
await this._monitor.dispatch("sectionCompleted", f);
|
|
1357
1367
|
}
|
|
1358
1368
|
}
|
|
1359
1369
|
const oe = [
|
|
@@ -1420,7 +1430,7 @@ const oe = [
|
|
|
1420
1430
|
"veniam",
|
|
1421
1431
|
"voluptate"
|
|
1422
1432
|
];
|
|
1423
|
-
function
|
|
1433
|
+
function vt(i, e) {
|
|
1424
1434
|
if (i <= 0)
|
|
1425
1435
|
return "";
|
|
1426
1436
|
const t = [], n = Math.floor(e * 982451653);
|
|
@@ -1434,45 +1444,49 @@ function mt(i, e) {
|
|
|
1434
1444
|
}
|
|
1435
1445
|
export {
|
|
1436
1446
|
ge as EventDispatcher,
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1447
|
+
nt as PageBreakPlugin,
|
|
1448
|
+
j as Paginator,
|
|
1449
|
+
_t as ReportBuilder,
|
|
1450
|
+
mt as SectionTocPlugin,
|
|
1441
1451
|
h as SplitResult,
|
|
1442
|
-
|
|
1443
|
-
|
|
1452
|
+
it as TablePlugin,
|
|
1453
|
+
st as adjustPageSize,
|
|
1444
1454
|
C as attributePrefix,
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1455
|
+
ft as buildPageId,
|
|
1456
|
+
et as cloneComponents,
|
|
1457
|
+
vt as createLoremIpsumParagraph,
|
|
1458
|
+
at as currentElementClassName,
|
|
1459
|
+
lt as currentTextClassName,
|
|
1460
|
+
ht as debugPlugin,
|
|
1461
|
+
ot as defaultPlugins,
|
|
1462
|
+
gt as enableDebugMode,
|
|
1463
|
+
ce as getNodeLayoutOptionsFromAttribute,
|
|
1464
|
+
B as getVisibleHeight,
|
|
1465
|
+
qe as globalStyle,
|
|
1466
|
+
Y as globalStyleId,
|
|
1467
|
+
ct as ignoredElementClassName,
|
|
1468
|
+
dt as ignoredTextClassName,
|
|
1469
|
+
q as isDebugMode,
|
|
1459
1470
|
se as isElement,
|
|
1460
1471
|
be as isTextNode,
|
|
1461
|
-
|
|
1472
|
+
we as layoutOptionHyphenAttribute,
|
|
1473
|
+
Ne as layoutOptionHyphenationDisabledAttribute,
|
|
1474
|
+
xe as layoutOptionKeepOnSamePageAttribute,
|
|
1475
|
+
pt as layoutOptionsToAttributes,
|
|
1462
1476
|
g as logger,
|
|
1463
1477
|
fe as loggerName,
|
|
1464
1478
|
ye as moveOffscreen,
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1479
|
+
tt as pageBreakAttributeName,
|
|
1480
|
+
z as pageClassName,
|
|
1481
|
+
ze as pageMargin,
|
|
1482
|
+
ut as pageSize,
|
|
1483
|
+
Be as paprize_isInitialized,
|
|
1470
1484
|
ne as paprize_isReady,
|
|
1471
1485
|
ie as paprize_readJsonDataFile,
|
|
1472
1486
|
T as previewClassName,
|
|
1473
|
-
|
|
1487
|
+
b as reportStyles,
|
|
1474
1488
|
ve as sectionClassName,
|
|
1475
|
-
|
|
1489
|
+
rt as sectionTocName,
|
|
1476
1490
|
_e as tempContainerClassName
|
|
1477
1491
|
};
|
|
1478
1492
|
//# sourceMappingURL=paprize-core.js.map
|