paged-react 0.1.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 +173 -0
- package/dist/components/context.d.ts +4 -0
- package/dist/components/context.d.ts.map +1 -0
- package/dist/components/context.js +3 -0
- package/dist/components/context.js.map +1 -0
- package/dist/components/document.d.ts +25 -0
- package/dist/components/document.d.ts.map +1 -0
- package/dist/components/document.js +77 -0
- package/dist/components/document.js.map +1 -0
- package/dist/components/page-break.d.ts +2 -0
- package/dist/components/page-break.d.ts.map +1 -0
- package/dist/components/page-break.js +6 -0
- package/dist/components/page-break.js.map +1 -0
- package/dist/components/watermark.d.ts +7 -0
- package/dist/components/watermark.d.ts.map +1 -0
- package/dist/components/watermark.js +45 -0
- package/dist/components/watermark.js.map +1 -0
- package/dist/core/avoid-break.d.ts +2 -0
- package/dist/core/avoid-break.d.ts.map +1 -0
- package/dist/core/avoid-break.js +30 -0
- package/dist/core/avoid-break.js.map +1 -0
- package/dist/core/computed-style.d.ts +19 -0
- package/dist/core/computed-style.d.ts.map +1 -0
- package/dist/core/computed-style.js +16 -0
- package/dist/core/computed-style.js.map +1 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +2 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/layout-ready.d.ts +2 -0
- package/dist/core/layout-ready.d.ts.map +1 -0
- package/dist/core/layout-ready.js +23 -0
- package/dist/core/layout-ready.js.map +1 -0
- package/dist/core/page-break.d.ts +2 -0
- package/dist/core/page-break.d.ts.map +1 -0
- package/dist/core/page-break.js +25 -0
- package/dist/core/page-break.js.map +1 -0
- package/dist/core/paginate.d.ts +8 -0
- package/dist/core/paginate.d.ts.map +1 -0
- package/dist/core/paginate.js +241 -0
- package/dist/core/paginate.js.map +1 -0
- package/dist/core/text-break.d.ts +5 -0
- package/dist/core/text-break.d.ts.map +1 -0
- package/dist/core/text-break.js +65 -0
- package/dist/core/text-break.js.map +1 -0
- package/dist/core/utils.d.ts +41 -0
- package/dist/core/utils.d.ts.map +1 -0
- package/dist/core/utils.js +90 -0
- package/dist/core/utils.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/page-sizes.d.ts +67 -0
- package/dist/page-sizes.d.ts.map +1 -0
- package/dist/page-sizes.js +19 -0
- package/dist/page-sizes.js.map +1 -0
- package/dist/styles.css +46 -0
- package/dist/types.d.ts +26 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/page-size.d.ts +3 -0
- package/dist/utils/page-size.d.ts.map +1 -0
- package/dist/utils/page-size.js +8 -0
- package/dist/utils/page-size.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { textBreaker } from "./text-break.js";
|
|
2
|
+
import { canBreakElement } from "./avoid-break.js";
|
|
3
|
+
import { createComputedStyleCache } from "./computed-style.js";
|
|
4
|
+
import { waitForLayoutReady } from "./layout-ready.js";
|
|
5
|
+
import { connectedClone, getBoxStyle } from "./utils.js";
|
|
6
|
+
import { cloneChildrenInto, createPage, getDirectSlot, getEffectivePageSize, resolvePageSizeInPixels, } from "./utils.js";
|
|
7
|
+
const EMPTY_BY_PAGINATION_ATTRIBUTE = "data-paged-react-empty-by-pagination";
|
|
8
|
+
export async function paginateDocument(ctx) {
|
|
9
|
+
const { sourceRoot, pagesRoot, signal } = ctx;
|
|
10
|
+
const pages = [];
|
|
11
|
+
if (signal?.aborted)
|
|
12
|
+
return pages;
|
|
13
|
+
pagesRoot.replaceChildren();
|
|
14
|
+
await waitForLayoutReady(sourceRoot);
|
|
15
|
+
if (signal?.aborted)
|
|
16
|
+
return pages;
|
|
17
|
+
const sourceRootClone = connectedClone(sourceRoot);
|
|
18
|
+
const segments = Array.from(sourceRootClone.querySelectorAll(":scope > [data-paged-react-segment-source]"));
|
|
19
|
+
for (const [segmentIndex, segment] of segments.entries()) {
|
|
20
|
+
if (signal?.aborted)
|
|
21
|
+
return pages;
|
|
22
|
+
const segmentPageSize = getEffectivePageSize(segment);
|
|
23
|
+
const segmentPageSizePixels = resolvePageSizeInPixels(segmentPageSize);
|
|
24
|
+
const headerSlot = getDirectSlot(segment, "header");
|
|
25
|
+
const bodySlot = getDirectSlot(segment, "body");
|
|
26
|
+
const footerSlot = getDirectSlot(segment, "footer");
|
|
27
|
+
const headerHeight = headerSlot?.offsetHeight ?? 0;
|
|
28
|
+
const footerHeight = footerSlot?.offsetHeight ?? 0;
|
|
29
|
+
const segBox = getBoxStyle(segment);
|
|
30
|
+
const segmentHeightOffset = segBox.paddingTop + segBox.paddingBottom + segBox.borderBottomWidth + segBox.borderTopWidth;
|
|
31
|
+
const maxBodyHeight = segmentPageSizePixels.height - headerHeight - footerHeight - segmentHeightOffset;
|
|
32
|
+
if (maxBodyHeight <= 0) {
|
|
33
|
+
console.warn(`Page size ${segmentPageSize.width} x ${segmentPageSize.height} is too small to fit header and footer content.`);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const repeatTableHeader = segment.getAttribute("data-paged-react-repeat-table-header") === "true";
|
|
37
|
+
console.time(`Segment ${segmentIndex + 1} pagination`);
|
|
38
|
+
const bodies = bodySegmenter({ body: bodySlot, maxBodyHeight, repeatTableHeader });
|
|
39
|
+
console.timeEnd(`Segment ${segmentIndex + 1} pagination`);
|
|
40
|
+
for (const [bodyIndex, bodySegment] of bodies.entries()) {
|
|
41
|
+
if (signal?.aborted)
|
|
42
|
+
return pages;
|
|
43
|
+
const page = createPage({
|
|
44
|
+
segment,
|
|
45
|
+
pagesRoot,
|
|
46
|
+
pageSize: segmentPageSize,
|
|
47
|
+
bodySlot,
|
|
48
|
+
headerSlot,
|
|
49
|
+
footerSlot,
|
|
50
|
+
pageNumber: segmentIndex + 1,
|
|
51
|
+
});
|
|
52
|
+
page.page.setAttribute("data-paged-react-segment-index", String(segmentIndex));
|
|
53
|
+
page.page.setAttribute("data-paged-react-body-segment-index", String(bodyIndex));
|
|
54
|
+
cloneChildrenInto(page.header, headerSlot);
|
|
55
|
+
cloneChildrenInto(page.footer, footerSlot);
|
|
56
|
+
cloneChildrenInto(page.body, bodySegment);
|
|
57
|
+
pages.push(page.page);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
sourceRootClone.remove();
|
|
61
|
+
return pages;
|
|
62
|
+
}
|
|
63
|
+
function bodySegmenter(ctx) {
|
|
64
|
+
const { body, maxBodyHeight, repeatTableHeader } = ctx;
|
|
65
|
+
const bodySegments = [];
|
|
66
|
+
if (!body)
|
|
67
|
+
return bodySegments;
|
|
68
|
+
const styleCache = createComputedStyleCache();
|
|
69
|
+
while (true) {
|
|
70
|
+
const bodyRect = body.getBoundingClientRect();
|
|
71
|
+
const bodyHeight = bodyRect.height;
|
|
72
|
+
const hasPageBreak = body.querySelector("[data-paged-react-page-break]") !== null;
|
|
73
|
+
if (bodyHeight <= maxBodyHeight && !hasPageBreak) {
|
|
74
|
+
bodySegments.push(body);
|
|
75
|
+
return bodySegments;
|
|
76
|
+
}
|
|
77
|
+
const mutations = [];
|
|
78
|
+
const pageSlice = bodySlice({ body, bodyRect, mutations });
|
|
79
|
+
bodySegments.push(pageSlice.segment);
|
|
80
|
+
if (!mutations.length) {
|
|
81
|
+
return bodySegments;
|
|
82
|
+
}
|
|
83
|
+
for (const mutation of mutations) {
|
|
84
|
+
mutation();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function bodySlice(ctx) {
|
|
88
|
+
const { body, bodyRect, mutations, parent = body, superParentOffset = 0 } = ctx;
|
|
89
|
+
const segment = parent.cloneNode(false);
|
|
90
|
+
const parentStyle = styleCache.get(parent);
|
|
91
|
+
const parentOffset = parentStyle.paddingBottom + parentStyle.borderBottomWidth + parentStyle.marginBottom;
|
|
92
|
+
for (const target of Array.from(parent.childNodes)) {
|
|
93
|
+
if (target instanceof Element) {
|
|
94
|
+
if (target.hasAttribute("data-paged-react-page-break")) {
|
|
95
|
+
mutations.push(() => target.remove());
|
|
96
|
+
return { segment, stopped: true };
|
|
97
|
+
}
|
|
98
|
+
const targetRect = target.getBoundingClientRect();
|
|
99
|
+
const targetStyle = styleCache.get(target);
|
|
100
|
+
const targetBottom = targetRect.bottom +
|
|
101
|
+
targetStyle.marginBottom +
|
|
102
|
+
superParentOffset +
|
|
103
|
+
// We need to consider the parent offset
|
|
104
|
+
parentOffset -
|
|
105
|
+
// to get the relative position
|
|
106
|
+
bodyRect.top;
|
|
107
|
+
const isEmptyShell = target.children.length === 0 &&
|
|
108
|
+
target.textContent !== null &&
|
|
109
|
+
target.textContent.trim() === "";
|
|
110
|
+
if (isEmptyShell) {
|
|
111
|
+
const targetContentHeight = targetRect.height -
|
|
112
|
+
targetStyle.paddingTop -
|
|
113
|
+
targetStyle.paddingBottom -
|
|
114
|
+
targetStyle.borderTopWidth -
|
|
115
|
+
targetStyle.borderBottomWidth;
|
|
116
|
+
if (target.hasAttribute(EMPTY_BY_PAGINATION_ATTRIBUTE) && targetContentHeight <= 0) {
|
|
117
|
+
mutations.push(() => target.remove());
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
segment.appendChild(target.cloneNode(true));
|
|
121
|
+
if (targetBottom <= maxBodyHeight) {
|
|
122
|
+
mutations.push(() => target.remove());
|
|
123
|
+
}
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
const canBreakTarget = canBreakElement(target);
|
|
127
|
+
const hasNestedPageBreak = target.querySelector("[data-paged-react-page-break]") !== null;
|
|
128
|
+
if (targetBottom <= maxBodyHeight && !hasNestedPageBreak) {
|
|
129
|
+
// Keep pagination-created empty shells that still have box height.
|
|
130
|
+
segment.appendChild(target.cloneNode(true));
|
|
131
|
+
// Keep table headers on the current page.
|
|
132
|
+
if (parent instanceof HTMLTableElement && target.tagName === "THEAD")
|
|
133
|
+
continue;
|
|
134
|
+
// Keep the first body row when repeating table headers.
|
|
135
|
+
if (repeatTableHeader &&
|
|
136
|
+
parent instanceof HTMLTableSectionElement &&
|
|
137
|
+
parent.parentElement instanceof HTMLTableElement &&
|
|
138
|
+
!parent.parentElement.tHead &&
|
|
139
|
+
target === parent.rows[0]) {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
mutations.push(() => {
|
|
143
|
+
// Remove the source node after cloning it into the page.
|
|
144
|
+
cleanupPaginationTarget(target, parent, repeatTableHeader);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
else if (canBreakTarget) {
|
|
148
|
+
const childSegment = bodySlice({
|
|
149
|
+
body,
|
|
150
|
+
bodyRect,
|
|
151
|
+
mutations,
|
|
152
|
+
parent: target,
|
|
153
|
+
superParentOffset: parentOffset + superParentOffset,
|
|
154
|
+
});
|
|
155
|
+
if (childSegment.segment.childNodes.length)
|
|
156
|
+
segment.appendChild(childSegment.segment);
|
|
157
|
+
if (childSegment.stopped)
|
|
158
|
+
return { segment, stopped: true };
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
if (segment.childNodes.length)
|
|
162
|
+
return { segment, stopped: true };
|
|
163
|
+
console.error("Paged React: unbreakable element exceeds one page and will be clipped.", target);
|
|
164
|
+
segment.appendChild(target.cloneNode(true));
|
|
165
|
+
mutations.push(() => target.remove());
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (target instanceof Text) {
|
|
169
|
+
const textRange = document.createRange();
|
|
170
|
+
textRange.selectNode(target);
|
|
171
|
+
const textRects = Array.from(textRange.getClientRects());
|
|
172
|
+
// Remove text nodes that no longer render any line boxes.
|
|
173
|
+
if (!textRects.length) {
|
|
174
|
+
mutations.push(() => target.remove());
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
let textTop = Infinity;
|
|
178
|
+
let textBottom = -Infinity;
|
|
179
|
+
for (const rect of textRects) {
|
|
180
|
+
const rectTop = rect.top + parentOffset + superParentOffset - bodyRect.top;
|
|
181
|
+
const rectBottom = rect.bottom + parentOffset + superParentOffset - bodyRect.top;
|
|
182
|
+
if (rectTop < textTop)
|
|
183
|
+
textTop = rectTop;
|
|
184
|
+
if (rectBottom > textBottom)
|
|
185
|
+
textBottom = rectBottom;
|
|
186
|
+
}
|
|
187
|
+
// Keep text that fully fits on the current page.
|
|
188
|
+
if (textBottom <= maxBodyHeight) {
|
|
189
|
+
segment.append(target.data);
|
|
190
|
+
mutations.push(() => target.remove());
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
// Leave text alone if it starts below the current page window.
|
|
194
|
+
if (textTop > maxBodyHeight)
|
|
195
|
+
continue;
|
|
196
|
+
// Split text across the page boundary line by line.
|
|
197
|
+
const lines = textBreaker(target, textRects);
|
|
198
|
+
const remaining = document.createDocumentFragment();
|
|
199
|
+
for (const line of lines) {
|
|
200
|
+
const lineBottom = line.rect.bottom + parentOffset + superParentOffset - bodyRect.top;
|
|
201
|
+
if (lineBottom <= maxBodyHeight) {
|
|
202
|
+
segment.append(line.text);
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
remaining.append(line.text);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
mutations.push(() => target.replaceWith(remaining));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return { segment, stopped: false };
|
|
212
|
+
}
|
|
213
|
+
function cleanupPaginationTarget(target, parent, repeatTableHeader) {
|
|
214
|
+
if (target.tagName === "LI" && parent instanceof HTMLOListElement) {
|
|
215
|
+
if (parent.reversed)
|
|
216
|
+
parent.start -= 1;
|
|
217
|
+
else
|
|
218
|
+
parent.start += 1;
|
|
219
|
+
}
|
|
220
|
+
target.remove();
|
|
221
|
+
if (parent.children.length === 0 &&
|
|
222
|
+
parent.textContent !== null &&
|
|
223
|
+
parent.textContent.trim() === "") {
|
|
224
|
+
parent.setAttribute(EMPTY_BY_PAGINATION_ATTRIBUTE, "");
|
|
225
|
+
}
|
|
226
|
+
if (parent instanceof HTMLTableSectionElement) {
|
|
227
|
+
const table = parent.parentElement;
|
|
228
|
+
if (parent.rows.length === 0)
|
|
229
|
+
parent.remove();
|
|
230
|
+
if (repeatTableHeader &&
|
|
231
|
+
table instanceof HTMLTableElement &&
|
|
232
|
+
!table.tHead &&
|
|
233
|
+
parent.rows.length === 1) {
|
|
234
|
+
parent.remove();
|
|
235
|
+
}
|
|
236
|
+
if (table instanceof HTMLTableElement && !table.tBodies.length)
|
|
237
|
+
table.remove();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
//# sourceMappingURL=paginate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paginate.js","sourceRoot":"","sources":["../../src/core/paginate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AAEpB,MAAM,6BAA6B,GAAG,sCAAsC,CAAC;AAQ7E,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,GAAsB;IAC3D,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IAC9C,MAAM,KAAK,GAAkB,EAAE,CAAC;IAEhC,IAAI,MAAM,EAAE,OAAO;QAAE,OAAO,KAAK,CAAC;IAElC,SAAS,CAAC,eAAe,EAAE,CAAC;IAE5B,MAAM,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAErC,IAAI,MAAM,EAAE,OAAO;QAAE,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AA,wBAAgB,WAAW,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE;;;IA0E/D"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export function textBreaker(textNode, lineRects) {
|
|
2
|
+
const text = textNode.textContent;
|
|
3
|
+
if (!text)
|
|
4
|
+
return [];
|
|
5
|
+
const rectCache = new Map();
|
|
6
|
+
const rectAt = (index) => {
|
|
7
|
+
const cachedRect = rectCache.get(index);
|
|
8
|
+
if (cachedRect) {
|
|
9
|
+
return cachedRect;
|
|
10
|
+
}
|
|
11
|
+
const charRange = document.createRange();
|
|
12
|
+
charRange.setStart(textNode, index);
|
|
13
|
+
charRange.setEnd(textNode, index + 1);
|
|
14
|
+
const rect = charRange.getBoundingClientRect();
|
|
15
|
+
rectCache.set(index, rect);
|
|
16
|
+
return rect;
|
|
17
|
+
};
|
|
18
|
+
const firstIndexOnLine = (lineRect) => {
|
|
19
|
+
const lineMiddle = (lineRect.top + lineRect.bottom) / 2;
|
|
20
|
+
let low = 0;
|
|
21
|
+
let high = text.length - 1;
|
|
22
|
+
let result = text.length;
|
|
23
|
+
while (low <= high) {
|
|
24
|
+
const mid = Math.floor((low + high) / 2);
|
|
25
|
+
const rect = rectAt(mid);
|
|
26
|
+
const rectMiddle = (rect.top + rect.bottom) / 2;
|
|
27
|
+
if (rectMiddle >= lineMiddle) {
|
|
28
|
+
result = mid;
|
|
29
|
+
high = mid - 1;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
low = mid + 1;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
const firstIndexAfterLine = (lineRect, startIndex) => {
|
|
38
|
+
const lineMiddle = (lineRect.top + lineRect.bottom) / 2;
|
|
39
|
+
let low = startIndex;
|
|
40
|
+
let high = text.length - 1;
|
|
41
|
+
let result = text.length;
|
|
42
|
+
while (low <= high) {
|
|
43
|
+
const mid = Math.floor((low + high) / 2);
|
|
44
|
+
const rect = rectAt(mid);
|
|
45
|
+
const rectMiddle = (rect.top + rect.bottom) / 2;
|
|
46
|
+
if (rectMiddle > lineMiddle) {
|
|
47
|
+
result = mid;
|
|
48
|
+
high = mid - 1;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
low = mid + 1;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
};
|
|
56
|
+
return lineRects.map((lineRect) => {
|
|
57
|
+
const start = firstIndexOnLine(lineRect);
|
|
58
|
+
const end = firstIndexAfterLine(lineRect, start);
|
|
59
|
+
return {
|
|
60
|
+
rect: lineRect,
|
|
61
|
+
text: text.slice(start, end),
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=text-break.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-break.js","sourceRoot":"","sources":["../../src/core/text-break.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW,CAAC,QAAc,EAAE,SAAoB;IAC9D,MAAM,IAAI,GAAG,QAAQ,CAAC,WAAW,CAAC;IAClC,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IAErB,MAAM,SAAS,GAAG,IAAI,GAAG,EAAmB,CAAC;IAC7C,MAAM,MAAM,GAAG,CAAC,KAAa,EAAE,EAAE;QAC/B,MAAM,UAAU,GAAG,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAExC,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,MAAM,SAAS,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;QACzC,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACpC,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;QAEtC,MAAM,IAAI,GAAG,SAAS,CAAC,qBAAqB,EAAE,CAA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,IAAI,CAAC,MAAM,CAAC;QAEzB,OAAO,GAAG,IAAI,IAAI,EAAE,CAAC;YACnB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YACzC,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YACzB,MAAM,UAAU,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAEhD,IAAI,UAAU,GAAG,UAAU,EAAE,CAAC;gBAC5B,MAAM,GAAG,GAAG,CAAC;gBACb,IAAI,GAAG,GAAG,GAAG,CAAC,CAAC;YACjB,CAAC;iBAAM,CAAC;gBACN,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;YAChB,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IAEF,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;QAChC,MAAM,KAAK,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QACzC,MAAM,GAAG,GAAG,mBAAmB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAEjD,OAAO;YACL,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC;SAC7B,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export type PageElements = {
|
|
2
|
+
page: HTMLDivElement;
|
|
3
|
+
header: HTMLDivElement;
|
|
4
|
+
body: HTMLDivElement;
|
|
5
|
+
footer: HTMLDivElement;
|
|
6
|
+
};
|
|
7
|
+
export type ResolvedPageSize = {
|
|
8
|
+
width: string;
|
|
9
|
+
height: string;
|
|
10
|
+
};
|
|
11
|
+
/** Returns a direct segment slot without walking into nested child documents. */
|
|
12
|
+
export declare function getDirectSlot(parent: Element, attribute: "header" | "body" | "footer"): HTMLDivElement | null;
|
|
13
|
+
/** Clones all child nodes from a source slot into a target element. */
|
|
14
|
+
export declare function cloneChildrenInto(target: HTMLElement, source: HTMLElement | null): void;
|
|
15
|
+
/** Reads page size attributes from a segment. */
|
|
16
|
+
export declare function getEffectivePageSize(el: HTMLElement): ResolvedPageSize;
|
|
17
|
+
/** Converts a CSS page size value (e.g. mm/in/px) into numeric pixel dimensions. */
|
|
18
|
+
export declare function resolvePageSizeInPixels(pageSize: ResolvedPageSize): {
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
};
|
|
22
|
+
/** Creates the generated page shell used by the pagination engine. */
|
|
23
|
+
export declare function createPage({ pagesRoot, headerSlot, footerSlot, bodySlot, segment, pageSize, pageNumber, }: {
|
|
24
|
+
pagesRoot: HTMLDivElement;
|
|
25
|
+
headerSlot: HTMLDivElement | null;
|
|
26
|
+
footerSlot: HTMLDivElement | null;
|
|
27
|
+
bodySlot: HTMLDivElement | null;
|
|
28
|
+
pageSize: ResolvedPageSize;
|
|
29
|
+
segment: HTMLDivElement;
|
|
30
|
+
pageNumber: number;
|
|
31
|
+
}): PageElements;
|
|
32
|
+
export declare function connectedClone(element: HTMLElement): HTMLElement;
|
|
33
|
+
export declare function getBoxStyle(element: Element): {
|
|
34
|
+
borderBottomWidth: number;
|
|
35
|
+
borderTopWidth: number;
|
|
36
|
+
marginBottom: number;
|
|
37
|
+
marginTop: number;
|
|
38
|
+
paddingBottom: number;
|
|
39
|
+
paddingTop: number;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/core/utils.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,cAAc,CAAC;IACrB,MAAM,EAAE,cAAc,CAAC;IACvB,IAAI,EAAE,cAAc,CAAC;IACrB,MAAM,EAAE,cAAc,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,iFAAiF;AACjF,wBAAgB,aAAa,CAC3B,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,QAAQ,GAAG,MAAM,GAAG,QAAQ,GACtC,cAAc,GAAG,IAAI,CAEvB;AAED,uEAAuE;AACvE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,GAAG,IAAI,CAQvF;AAED,iDAAiD;AACjD,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,WAAW,GAAG,gBAAgB,CAStE;AAED,oFAAoF;AACpF,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,gBAAgB;;;EAmBjE;AAED,sEAAsE;AACtE,wBAAgB,UAAU,CAAC,EACzB,SAAS,EACT,UAAU,EACV,UAAU,EACV,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,UAAU,GACX,EAAE;IACD,SAAS,EAAE,cAAc,CAAC;IAC1B,UAAU,EAAE,cAAc,GAAG,IAAI,CAAC;IAClC,UAAU,EAAE,cAAc,GAAG,IAAI,CAAC;IAClC,QAAQ,EAAE,cAAc,GAAG,IAAI,CAAC;IAChC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,OAAO,EAAE,cAAc,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,YAAY,CAiCf;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,eAOlD;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO;;;;;;;EAU3C"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/** Returns a direct segment slot without walking into nested child documents. */
|
|
2
|
+
export function getDirectSlot(parent, attribute) {
|
|
3
|
+
return parent.querySelector(`:scope > [data-paged-react-${attribute}-source]`);
|
|
4
|
+
}
|
|
5
|
+
/** Clones all child nodes from a source slot into a target element. */
|
|
6
|
+
export function cloneChildrenInto(target, source) {
|
|
7
|
+
if (!source) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
for (const node of Array.from(source.childNodes)) {
|
|
11
|
+
target.appendChild(node.cloneNode(true));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/** Reads page size attributes from a segment. */
|
|
15
|
+
export function getEffectivePageSize(el) {
|
|
16
|
+
const width = el.dataset.pagedReactPageWidth;
|
|
17
|
+
const height = el.dataset.pagedReactPageHeight;
|
|
18
|
+
if (!width || !height) {
|
|
19
|
+
throw new Error("Document.Segment requires a resolved page size.");
|
|
20
|
+
}
|
|
21
|
+
return { width, height };
|
|
22
|
+
}
|
|
23
|
+
/** Converts a CSS page size value (e.g. mm/in/px) into numeric pixel dimensions. */
|
|
24
|
+
export function resolvePageSizeInPixels(pageSize) {
|
|
25
|
+
const probe = document.createElement("div");
|
|
26
|
+
probe.style.position = "absolute";
|
|
27
|
+
probe.style.visibility = "hidden";
|
|
28
|
+
probe.style.pointerEvents = "none";
|
|
29
|
+
probe.style.left = "0";
|
|
30
|
+
probe.style.top = "0";
|
|
31
|
+
probe.style.width = pageSize.width;
|
|
32
|
+
probe.style.height = pageSize.height;
|
|
33
|
+
document.body.appendChild(probe);
|
|
34
|
+
const rect = probe.getBoundingClientRect();
|
|
35
|
+
probe.remove();
|
|
36
|
+
return {
|
|
37
|
+
width: rect.width,
|
|
38
|
+
height: rect.height,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/** Creates the generated page shell used by the pagination engine. */
|
|
42
|
+
export function createPage({ pagesRoot, headerSlot, footerSlot, bodySlot, segment, pageSize, pageNumber, }) {
|
|
43
|
+
const page = segment.cloneNode(false);
|
|
44
|
+
page.removeAttribute("data-paged-react-segment-source");
|
|
45
|
+
page.setAttribute("data-paged-react-page", "");
|
|
46
|
+
page.setAttribute("data-page-number", String(pageNumber));
|
|
47
|
+
page.style.height = pageSize.height;
|
|
48
|
+
page.style.width = pageSize.width;
|
|
49
|
+
let header = document.createElement("div");
|
|
50
|
+
if (headerSlot) {
|
|
51
|
+
header = headerSlot.cloneNode(false);
|
|
52
|
+
}
|
|
53
|
+
header.setAttribute("data-paged-react-page-header", "");
|
|
54
|
+
header.removeAttribute("data-paged-react-header-source");
|
|
55
|
+
let body = document.createElement("div");
|
|
56
|
+
if (bodySlot) {
|
|
57
|
+
body = bodySlot.cloneNode(false);
|
|
58
|
+
}
|
|
59
|
+
body.setAttribute("data-paged-react-page-body", "");
|
|
60
|
+
body.removeAttribute("data-paged-react-body-source");
|
|
61
|
+
let footer = document.createElement("div");
|
|
62
|
+
if (footerSlot) {
|
|
63
|
+
footer = footerSlot.cloneNode(false);
|
|
64
|
+
}
|
|
65
|
+
footer.setAttribute("data-paged-react-page-footer", "");
|
|
66
|
+
footer.removeAttribute("data-paged-react-footer-source");
|
|
67
|
+
page.append(header, body, footer);
|
|
68
|
+
pagesRoot.appendChild(page);
|
|
69
|
+
return { page, header, body, footer };
|
|
70
|
+
}
|
|
71
|
+
export function connectedClone(element) {
|
|
72
|
+
const clone = element.cloneNode(true);
|
|
73
|
+
clone.style.left = "-100000px";
|
|
74
|
+
clone.style.position = "absolute";
|
|
75
|
+
clone.style.top = "0";
|
|
76
|
+
document.body.appendChild(clone);
|
|
77
|
+
return clone;
|
|
78
|
+
}
|
|
79
|
+
export function getBoxStyle(element) {
|
|
80
|
+
const computedStyle = getComputedStyle(element);
|
|
81
|
+
return {
|
|
82
|
+
borderBottomWidth: parseFloat(computedStyle.borderBottomWidth) || 0,
|
|
83
|
+
borderTopWidth: parseFloat(computedStyle.borderTopWidth) || 0,
|
|
84
|
+
marginBottom: parseFloat(computedStyle.marginBottom) || 0,
|
|
85
|
+
marginTop: parseFloat(computedStyle.marginTop) || 0,
|
|
86
|
+
paddingBottom: parseFloat(computedStyle.paddingBottom) || 0,
|
|
87
|
+
paddingTop: parseFloat(comput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C,CAAC;IACjC,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC1C,MAAM,aAAa,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAChD,OAAO;QACL,iBAAiB,EAAE,UAAU,CAAC,aAAa,CAAC,iBAAiB,CAAC,IAAI,CAAC;QACnE,cAAc,EAAE,UAAU,CAAC,aAAa,CAAC,cAAc,CAAC,IAAI,CAAC;QAC7D,YAAY,EAAE,UAAU,CAAC,aAAa,CAAC,YAAY,CAAC,IAAI,CAAC;QACzD,SAAS,EAAE,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC;QACnD,aAAa,EAAE,UAAU,CAAC,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC;QAC3D,UAAU,EAAE,UAAU,CAAC,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC;KACtD,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "./styles.css";
|
|
2
|
+
export { Document, DocumentBody, DocumentFooter, DocumentHeader, DocumentSegment, } from "./components/document.js";
|
|
3
|
+
export { PageBreak } from "./components/page-break.js";
|
|
4
|
+
export { Watermark } from "./components/watermark.js";
|
|
5
|
+
export { pageSizes } from "./page-sizes.js";
|
|
6
|
+
export type { DocumentBodyProps, DocumentFooterProps, DocumentHeaderProps, DocumentProps, DocumentSegmentProps, PageSize, PageSizeName, PageSizeValue, SlotProps, } from "./types.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAEtB,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,cAAc,EACd,eAAe,GAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,YAAY,EACV,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,SAAS,GACV,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import "./styles.css";
|
|
2
|
+
export { Document, DocumentBody, DocumentFooter, DocumentHeader, DocumentSegment, } from "./components/document.js";
|
|
3
|
+
export { PageBreak } from "./components/page-break.js";
|
|
4
|
+
export { Watermark } from "./components/watermark.js";
|
|
5
|
+
export { pageSizes } from "./page-sizes.js";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAEtB,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,cAAc,EACd,eAAe,GAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export declare const pageSizes: {
|
|
2
|
+
readonly A0: {
|
|
3
|
+
readonly width: "841mm";
|
|
4
|
+
readonly height: "1189mm";
|
|
5
|
+
};
|
|
6
|
+
readonly A1: {
|
|
7
|
+
readonly width: "594mm";
|
|
8
|
+
readonly height: "841mm";
|
|
9
|
+
};
|
|
10
|
+
readonly A2: {
|
|
11
|
+
readonly width: "420mm";
|
|
12
|
+
readonly height: "594mm";
|
|
13
|
+
};
|
|
14
|
+
readonly A3: {
|
|
15
|
+
readonly width: "297mm";
|
|
16
|
+
readonly height: "420mm";
|
|
17
|
+
};
|
|
18
|
+
readonly A4: {
|
|
19
|
+
readonly width: "210mm";
|
|
20
|
+
readonly height: "297mm";
|
|
21
|
+
};
|
|
22
|
+
readonly A5: {
|
|
23
|
+
readonly width: "148mm";
|
|
24
|
+
readonly height: "210mm";
|
|
25
|
+
};
|
|
26
|
+
readonly A6: {
|
|
27
|
+
readonly width: "105mm";
|
|
28
|
+
readonly height: "148mm";
|
|
29
|
+
};
|
|
30
|
+
readonly A7: {
|
|
31
|
+
readonly width: "74mm";
|
|
32
|
+
readonly height: "105mm";
|
|
33
|
+
};
|
|
34
|
+
readonly A8: {
|
|
35
|
+
readonly width: "52mm";
|
|
36
|
+
readonly height: "74mm";
|
|
37
|
+
};
|
|
38
|
+
readonly A9: {
|
|
39
|
+
readonly width: "37mm";
|
|
40
|
+
readonly height: "52mm";
|
|
41
|
+
};
|
|
42
|
+
readonly A10: {
|
|
43
|
+
readonly width: "26mm";
|
|
44
|
+
readonly height: "37mm";
|
|
45
|
+
};
|
|
46
|
+
readonly B4: {
|
|
47
|
+
readonly width: "250mm";
|
|
48
|
+
readonly height: "353mm";
|
|
49
|
+
};
|
|
50
|
+
readonly B5: {
|
|
51
|
+
readonly width: "176mm";
|
|
52
|
+
readonly height: "250mm";
|
|
53
|
+
};
|
|
54
|
+
readonly Letter: {
|
|
55
|
+
readonly width: "8.5in";
|
|
56
|
+
readonly height: "11in";
|
|
57
|
+
};
|
|
58
|
+
readonly Legal: {
|
|
59
|
+
readonly width: "8.5in";
|
|
60
|
+
readonly height: "14in";
|
|
61
|
+
};
|
|
62
|
+
readonly Ledger: {
|
|
63
|
+
readonly width: "11in";
|
|
64
|
+
readonly height: "17in";
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=page-sizes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-sizes.d.ts","sourceRoot":"","sources":["../src/page-sizes.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiBkC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const pageSizes = {
|
|
2
|
+
A0: { width: "841mm", height: "1189mm" },
|
|
3
|
+
A1: { width: "594mm", height: "841mm" },
|
|
4
|
+
A2: { width: "420mm", height: "594mm" },
|
|
5
|
+
A3: { width: "297mm", height: "420mm" },
|
|
6
|
+
A4: { width: "210mm", height: "297mm" },
|
|
7
|
+
A5: { width: "148mm", height: "210mm" },
|
|
8
|
+
A6: { width: "105mm", height: "148mm" },
|
|
9
|
+
A7: { width: "74mm", height: "105mm" },
|
|
10
|
+
A8: { width: "52mm", height: "74mm" },
|
|
11
|
+
A9: { width: "37mm", height: "52mm" },
|
|
12
|
+
A10: { width: "26mm", height: "37mm" },
|
|
13
|
+
B4: { width: "250mm", height: "353mm" },
|
|
14
|
+
B5: { width: "176mm", height: "250mm" },
|
|
15
|
+
Letter: { width: "8.5in", height: "11in" },
|
|
16
|
+
Legal: { width: "8.5in", height: "14in" },
|
|
17
|
+
Ledger: { width: "11in", height: "17in" },
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=page-sizes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-sizes.js","sourceRoot":"","sources":["../src/page-sizes.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE;IACxC,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;IACvC,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;IACvC,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;IACvC,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;IACvC,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;IACvC,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;IACvC,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE;IACtC,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;IACrC,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;IACrC,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;IACtC,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;IACvC,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;IACvC,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE;IAC1C,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE;IACzC,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;CACa,CAAC"}
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
[data-paged-react-document] {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
position: relative;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
[data-paged-react-document],
|
|
7
|
+
[data-paged-react-document] *,
|
|
8
|
+
[data-paged-react-document] *::before,
|
|
9
|
+
[data-paged-react-document] *::after {
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
[data-paged-react-root-source] {
|
|
14
|
+
left: -100000px;
|
|
15
|
+
pointer-events: none;
|
|
16
|
+
position: absolute;
|
|
17
|
+
top: 0;
|
|
18
|
+
visibility: hidden;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
[data-paged-react-pages] {
|
|
22
|
+
display: grid;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
[data-paged-react-page] {
|
|
26
|
+
background: #fff;
|
|
27
|
+
box-sizing: border-box;
|
|
28
|
+
display: grid;
|
|
29
|
+
grid-template-rows: auto minmax(0, 1fr) auto;
|
|
30
|
+
overflow: hidden;
|
|
31
|
+
position: relative;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
[data-paged-react-page-body] {
|
|
35
|
+
min-width: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
[data-paged-react-body-source] {
|
|
39
|
+
min-height: 0;
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
[data-paged-react-watermark] {
|
|
44
|
+
position: absolute;
|
|
45
|
+
inset: 0;
|
|
46
|
+
}
|