@particle-academy/last-word-ui 0.4.1 → 0.5.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/CHANGELOG.md +13 -0
- package/dist/index.cjs +216 -80
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +87 -25
- package/dist/index.d.ts +87 -25
- package/dist/index.js +213 -81
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -757,8 +757,12 @@ var VARIANT_KEY = {
|
|
|
757
757
|
footer: { first: "firstFooter", even: "evenFooter" }
|
|
758
758
|
};
|
|
759
759
|
function pageClass(index) {
|
|
760
|
-
|
|
761
|
-
|
|
760
|
+
return pageClassIn(index, 0);
|
|
761
|
+
}
|
|
762
|
+
function pageClassIn(index, start) {
|
|
763
|
+
const even = index % 2 === 1;
|
|
764
|
+
if (index === start) return even ? "firstEven" : "first";
|
|
765
|
+
return even ? "even" : "odd";
|
|
762
766
|
}
|
|
763
767
|
var isBandObject = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
764
768
|
function slotBand(page, kind, slot) {
|
|
@@ -768,12 +772,12 @@ function slotBand(page, kind, slot) {
|
|
|
768
772
|
return isBandObject(v) ? v : void 0;
|
|
769
773
|
}
|
|
770
774
|
function bandSlot(page, kind, cls) {
|
|
771
|
-
if (cls === "first" && slotBand(page, kind, "first") !== void 0) return "first";
|
|
772
|
-
if (cls === "even" && slotBand(page, kind, "even") !== void 0) return "even";
|
|
775
|
+
if ((cls === "first" || cls === "firstEven") && slotBand(page, kind, "first") !== void 0) return "first";
|
|
776
|
+
if ((cls === "even" || cls === "firstEven") && slotBand(page, kind, "even") !== void 0) return "even";
|
|
773
777
|
return "default";
|
|
774
778
|
}
|
|
775
|
-
function pageBand(page, kind, index) {
|
|
776
|
-
const band = slotBand(page, kind, bandSlot(page, kind,
|
|
779
|
+
function pageBand(page, kind, index, start = 0) {
|
|
780
|
+
const band = slotBand(page, kind, bandSlot(page, kind, pageClassIn(index, start)));
|
|
777
781
|
return hasBand(band) ? band : null;
|
|
778
782
|
}
|
|
779
783
|
function pageBodyBoxes(g, page, heights) {
|
|
@@ -782,7 +786,7 @@ function pageBodyBoxes(g, page, heights) {
|
|
|
782
786
|
return hasBand(slotBand(page, kind, slot)) ? Math.max(0, heights[kind][slot] || 0) : 0;
|
|
783
787
|
};
|
|
784
788
|
const box = (cls) => bodyBox(g, height2("header", cls), height2("footer", cls));
|
|
785
|
-
return { first: box("first"), even: box("even"), odd: box("odd") };
|
|
789
|
+
return { first: box("first"), even: box("even"), odd: box("odd"), firstEven: box("firstEven") };
|
|
786
790
|
}
|
|
787
791
|
|
|
788
792
|
// src/footnotes.ts
|
|
@@ -833,32 +837,117 @@ function numberFootnotes(doc) {
|
|
|
833
837
|
return { marks, notes };
|
|
834
838
|
}
|
|
835
839
|
|
|
840
|
+
// src/stretches.ts
|
|
841
|
+
var isObject = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
842
|
+
function isPageObject(page) {
|
|
843
|
+
return isObject(page) || Array.isArray(page) && page.length === 0;
|
|
844
|
+
}
|
|
845
|
+
function mergePage(page, change) {
|
|
846
|
+
const out = { ...page ?? {} };
|
|
847
|
+
delete out.firstHeader;
|
|
848
|
+
delete out.firstFooter;
|
|
849
|
+
for (const [key, value] of Object.entries(change)) {
|
|
850
|
+
if (value === void 0 || value === null || key === "background") continue;
|
|
851
|
+
if (key === "margins" && isObject(value) && isObject(out.margins)) {
|
|
852
|
+
const merged = { ...out.margins };
|
|
853
|
+
for (const [side, v] of Object.entries(value)) {
|
|
854
|
+
if (v !== void 0 && v !== null) merged[side] = v;
|
|
855
|
+
}
|
|
856
|
+
out.margins = merged;
|
|
857
|
+
} else {
|
|
858
|
+
out[key] = value;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
return out;
|
|
862
|
+
}
|
|
863
|
+
function docStretches(doc) {
|
|
864
|
+
let page = doc?.page && typeof doc.page === "object" ? doc.page : void 0;
|
|
865
|
+
const make = (breakAt) => ({
|
|
866
|
+
page,
|
|
867
|
+
geometry: pageGeometry({ ...page ? { page } : {}}),
|
|
868
|
+
breakAt
|
|
869
|
+
});
|
|
870
|
+
const out = [make(null)];
|
|
871
|
+
(Array.isArray(doc?.blocks) ? doc.blocks : []).forEach((block, i) => {
|
|
872
|
+
const b = block;
|
|
873
|
+
if (!isObject(b) || b.type !== "pageBreak" || !isPageObject(b.page)) return;
|
|
874
|
+
page = mergePage(page, isObject(b.page) ? b.page : {});
|
|
875
|
+
out.push(make(i));
|
|
876
|
+
});
|
|
877
|
+
return out;
|
|
878
|
+
}
|
|
879
|
+
function blockStretches(stretches, count) {
|
|
880
|
+
const out = [];
|
|
881
|
+
let k = 0;
|
|
882
|
+
for (let i = 0; i < count; i++) {
|
|
883
|
+
while (k + 1 < stretches.length && stretches[k + 1].breakAt <= i) k++;
|
|
884
|
+
out.push(k);
|
|
885
|
+
}
|
|
886
|
+
return out;
|
|
887
|
+
}
|
|
888
|
+
var toPt = (h) => ({
|
|
889
|
+
default: h.default / PX_PER_PT,
|
|
890
|
+
first: h.first / PX_PER_PT,
|
|
891
|
+
even: h.even / PX_PER_PT
|
|
892
|
+
});
|
|
893
|
+
var heightsPt = (h) => ({ header: toPt(h.header), footer: toPt(h.footer) });
|
|
894
|
+
function packInput(stretches, measured) {
|
|
895
|
+
const boxes = stretches.map((s, k) => pageBodyBoxes(s.geometry, s.page, heightsPt(measured.stretchBands[k])));
|
|
896
|
+
const items = measured.items.map((item, i) => {
|
|
897
|
+
const k = stretches.findIndex((s) => s.breakAt === i);
|
|
898
|
+
if (k <= 0) return item;
|
|
899
|
+
const b = boxes[k];
|
|
900
|
+
const stretch = {
|
|
901
|
+
pageHeight: b.odd.height * PX_PER_PT,
|
|
902
|
+
firstPageHeight: b.first.height * PX_PER_PT,
|
|
903
|
+
firstEvenPageHeight: b.firstEven.height * PX_PER_PT,
|
|
904
|
+
evenPageHeight: b.even.height * PX_PER_PT
|
|
905
|
+
};
|
|
906
|
+
return { type: "break", stretch };
|
|
907
|
+
});
|
|
908
|
+
const first = boxes[0];
|
|
909
|
+
return {
|
|
910
|
+
items,
|
|
911
|
+
boxes,
|
|
912
|
+
options: {
|
|
913
|
+
pageHeight: first.odd.height * PX_PER_PT,
|
|
914
|
+
firstPageHeight: first.first.height * PX_PER_PT,
|
|
915
|
+
evenPageHeight: first.even.height * PX_PER_PT,
|
|
916
|
+
footnoteSeparator: measured.footnoteSeparator
|
|
917
|
+
}
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
|
|
836
921
|
// src/layout-notice.ts
|
|
837
|
-
var LAYOUT_NOTICE = "
|
|
922
|
+
var LAYOUT_NOTICE = "Some page settings in this document aren't shown. It sets them somewhere they don't apply: on a page break directly, in a quote or a table cell, or under a sections key.";
|
|
838
923
|
var NEAR_MISS_KEYS = ["size", "orientation", "margins", "header", "footer", "firstHeader", "firstFooter", "evenHeader", "evenFooter", "background", "border"];
|
|
839
|
-
var
|
|
924
|
+
var isObject2 = (v) => typeof v === "object" && v !== null;
|
|
840
925
|
function unshownLayout(doc) {
|
|
841
926
|
const found = [];
|
|
842
|
-
if (!
|
|
927
|
+
if (!isObject2(doc)) return found;
|
|
843
928
|
if (doc.sections !== void 0) found.push("/sections");
|
|
844
929
|
const stack = [{ blocks: doc.blocks, at: "/blocks" }];
|
|
845
930
|
while (stack.length > 0) {
|
|
846
931
|
const { blocks, at } = stack.pop();
|
|
847
932
|
if (!Array.isArray(blocks)) continue;
|
|
848
933
|
blocks.forEach((block, i) => {
|
|
849
|
-
if (!
|
|
934
|
+
if (!isObject2(block)) return;
|
|
850
935
|
const path = `${at}/${i}`;
|
|
851
936
|
if (block.type === "pageBreak") {
|
|
852
|
-
for (const key of
|
|
937
|
+
for (const key of NEAR_MISS_KEYS) {
|
|
853
938
|
if (block[key] !== void 0) found.push(`${path}/${key}`);
|
|
854
939
|
}
|
|
940
|
+
if (block.page !== void 0) {
|
|
941
|
+
if (at !== "/blocks" || !isPageObject(block.page)) found.push(`${path}/page`);
|
|
942
|
+
else if (isObject2(block.page) && block.page.background !== void 0) found.push(`${path}/page/background`);
|
|
943
|
+
}
|
|
855
944
|
} else if (block.type === "quote") {
|
|
856
945
|
stack.push({ blocks: block.blocks, at: `${path}/blocks` });
|
|
857
946
|
} else if (block.type === "table" && Array.isArray(block.rows)) {
|
|
858
947
|
block.rows.forEach((row, r) => {
|
|
859
|
-
if (!
|
|
948
|
+
if (!isObject2(row) || !Array.isArray(row.cells)) return;
|
|
860
949
|
row.cells.forEach((cell, c) => {
|
|
861
|
-
if (
|
|
950
|
+
if (isObject2(cell)) stack.push({ blocks: cell.blocks, at: `${path}/rows/${r}/cells/${c}/blocks` });
|
|
862
951
|
});
|
|
863
952
|
});
|
|
864
953
|
}
|
|
@@ -897,7 +986,7 @@ function lineBreakpoints(el) {
|
|
|
897
986
|
}
|
|
898
987
|
return lines.slice(0, -1).map((l) => l[1]).filter((b) => b > 0 && b < total - 0.5);
|
|
899
988
|
}
|
|
900
|
-
function measure(root, blocks) {
|
|
989
|
+
function measure(root, blocks, stretchCount = 1) {
|
|
901
990
|
const noteHeights = /* @__PURE__ */ new Map();
|
|
902
991
|
root.querySelectorAll("[data-lw-measure-footnote]").forEach((el) => {
|
|
903
992
|
noteHeights.set(Number(el.dataset.lwMeasureFootnote), height(el));
|
|
@@ -941,17 +1030,23 @@ function measure(root, blocks) {
|
|
|
941
1030
|
...notes.length ? { footnotes: notes } : {}
|
|
942
1031
|
};
|
|
943
1032
|
});
|
|
944
|
-
const
|
|
945
|
-
|
|
946
|
-
for (const
|
|
947
|
-
|
|
1033
|
+
const stretchBands = Array.from({ length: Math.max(1, stretchCount) }, (_, k) => {
|
|
1034
|
+
const bands2 = { header: {}, footer: {} };
|
|
1035
|
+
for (const kind of ["header", "footer"]) {
|
|
1036
|
+
for (const slot of BAND_SLOTS) {
|
|
1037
|
+
const at = k === 0 ? `${kind}:${slot}` : `${k + 1}:${kind}:${slot}`;
|
|
1038
|
+
bands2[kind][slot] = height(root.querySelector(`[data-lw-measure-band="${at}"]`));
|
|
1039
|
+
}
|
|
948
1040
|
}
|
|
949
|
-
|
|
1041
|
+
return bands2;
|
|
1042
|
+
});
|
|
1043
|
+
const bands = stretchBands[0];
|
|
950
1044
|
return {
|
|
951
1045
|
items,
|
|
952
1046
|
headerHeight: bands.header.default,
|
|
953
1047
|
footerHeight: bands.footer.default,
|
|
954
1048
|
bands,
|
|
1049
|
+
stretchBands,
|
|
955
1050
|
footnoteSeparator: height(root.querySelector("[data-lw-measure-separator]"))
|
|
956
1051
|
};
|
|
957
1052
|
}
|
|
@@ -959,13 +1054,20 @@ function measure(root, blocks) {
|
|
|
959
1054
|
// src/paginate.ts
|
|
960
1055
|
var EPS = 1e-6;
|
|
961
1056
|
var positive = (v) => typeof v === "number" && Number.isFinite(v) && v > 0;
|
|
962
|
-
function pageCapacity(options, index) {
|
|
1057
|
+
function pageCapacity(options, index, start = 0) {
|
|
963
1058
|
const base = Math.max(1, positive(options.pageHeight) ? options.pageHeight : 1);
|
|
964
|
-
|
|
965
|
-
if (index
|
|
1059
|
+
const even = index % 2 === 1;
|
|
1060
|
+
if (index === start) {
|
|
1061
|
+
const first = even ? options.firstEvenPageHeight : options.firstPageHeight;
|
|
1062
|
+
if (positive(first)) return Math.max(1, first);
|
|
1063
|
+
}
|
|
1064
|
+
if (even) return positive(options.evenPageHeight) ? Math.max(1, options.evenPageHeight) : base;
|
|
966
1065
|
return base;
|
|
967
1066
|
}
|
|
968
|
-
function paginate(items,
|
|
1067
|
+
function paginate(items, initial) {
|
|
1068
|
+
let options = initial;
|
|
1069
|
+
let stretchStart = 0;
|
|
1070
|
+
let stretch = 0;
|
|
969
1071
|
let cap = pageCapacity(options, 0);
|
|
970
1072
|
const sep = Math.max(0, options.footnoteSeparator ?? 0);
|
|
971
1073
|
const pages = [];
|
|
@@ -973,8 +1075,8 @@ function paginate(items, options) {
|
|
|
973
1075
|
let content = 0;
|
|
974
1076
|
let noteHeights = 0;
|
|
975
1077
|
const newPage = () => {
|
|
976
|
-
cap = pageCapacity(options, pages.length);
|
|
977
|
-
page = { index: pages.length, fragments: [], footnotes: [], used: 0, capacity: cap };
|
|
1078
|
+
cap = pageCapacity(options, pages.length, stretchStart);
|
|
1079
|
+
page = { index: pages.length, fragments: [], footnotes: [], used: 0, capacity: cap, ...stretch > 0 ? { stretch } : {} };
|
|
978
1080
|
pages.push(page);
|
|
979
1081
|
content = 0;
|
|
980
1082
|
noteHeights = 0;
|
|
@@ -996,6 +1098,11 @@ function paginate(items, options) {
|
|
|
996
1098
|
newPage();
|
|
997
1099
|
items.forEach((item, index) => {
|
|
998
1100
|
if (item.type === "break") {
|
|
1101
|
+
if (item.stretch) {
|
|
1102
|
+
options = { footnoteSeparator: options.footnoteSeparator, ...item.stretch };
|
|
1103
|
+
stretchStart = pages.length;
|
|
1104
|
+
stretch++;
|
|
1105
|
+
}
|
|
999
1106
|
newPage();
|
|
1000
1107
|
return;
|
|
1001
1108
|
}
|
|
@@ -1044,7 +1151,7 @@ function paginate(items, options) {
|
|
|
1044
1151
|
const chain = keepChainHeight(index);
|
|
1045
1152
|
const next = items[index + 1];
|
|
1046
1153
|
const meaningful = next !== void 0 && next.type !== "break";
|
|
1047
|
-
const nextCap = pageCapacity(options, page.index + 1);
|
|
1154
|
+
const nextCap = pageCapacity(options, page.index + 1, stretchStart);
|
|
1048
1155
|
if (meaningful && chain <= nextCap + EPS && !fits(chain, notesIn(item, 0, height2, true))) newPage();
|
|
1049
1156
|
}
|
|
1050
1157
|
let start = 0;
|
|
@@ -1278,17 +1385,25 @@ function DocViewer({
|
|
|
1278
1385
|
className,
|
|
1279
1386
|
style
|
|
1280
1387
|
}) {
|
|
1281
|
-
const
|
|
1388
|
+
const stretches = useMemo(() => docStretches(doc), [doc]);
|
|
1389
|
+
const geometry = stretches[0].geometry;
|
|
1282
1390
|
const numbering = useMemo(() => numberFootnotes(doc), [doc]);
|
|
1283
1391
|
const blocks = useMemo(() => Array.isArray(doc?.blocks) ? doc.blocks : [], [doc]);
|
|
1284
|
-
const
|
|
1392
|
+
const blockStretch = useMemo(() => blockStretches(stretches, blocks.length), [stretches, blocks]);
|
|
1393
|
+
const noteStretch = useMemo(() => {
|
|
1394
|
+
const out = /* @__PURE__ */ new Map();
|
|
1395
|
+
let id2 = 0;
|
|
1396
|
+
blocks.forEach((block, i) => {
|
|
1397
|
+
for (let n = numberFootnotes({ blocks: [block] }).notes.length; n > 0; n--) out.set(++id2, blockStretch[i]);
|
|
1398
|
+
});
|
|
1399
|
+
return out;
|
|
1400
|
+
}, [blocks, blockStretch]);
|
|
1285
1401
|
const nowKey = now instanceof Date ? now.getTime() : now;
|
|
1286
1402
|
const nowDate = useMemo(() => resolveNow(nowKey === void 0 ? void 0 : typeof nowKey === "number" ? new Date(nowKey) : nowKey), [nowKey]);
|
|
1287
1403
|
const author = doc?.meta && typeof doc.meta === "object" ? doc.meta.author : void 0;
|
|
1288
1404
|
const title = doc?.title;
|
|
1289
1405
|
const docFields = useMemo(
|
|
1290
1406
|
() => ({
|
|
1291
|
-
section: 1,
|
|
1292
1407
|
...typeof author === "string" ? { author } : {},
|
|
1293
1408
|
...typeof title === "string" ? { title } : {},
|
|
1294
1409
|
...typeof filename === "string" ? { filename } : {},
|
|
@@ -1313,6 +1428,7 @@ function DocViewer({
|
|
|
1313
1428
|
}),
|
|
1314
1429
|
[numbering, doc, geometry]
|
|
1315
1430
|
);
|
|
1431
|
+
const ctxOf = (k) => ({ ...ctx, contentWidth: stretches[k].geometry.contentWidth });
|
|
1316
1432
|
useEffect(() => {
|
|
1317
1433
|
const state = initialFontState(faces);
|
|
1318
1434
|
setFont(state);
|
|
@@ -1328,22 +1444,12 @@ function DocViewer({
|
|
|
1328
1444
|
useLayoutEffect(() => {
|
|
1329
1445
|
const el = measureRef.current;
|
|
1330
1446
|
if (!el || font === "pending") return;
|
|
1331
|
-
const m = measure(el, blocks);
|
|
1332
|
-
const
|
|
1333
|
-
|
|
1334
|
-
first: h.first / PX_PER_PT,
|
|
1335
|
-
even: h.even / PX_PER_PT
|
|
1336
|
-
});
|
|
1337
|
-
const boxes = pageBodyBoxes(geometry, page, { header: toPt(m.bands.header), footer: toPt(m.bands.footer) });
|
|
1338
|
-
const pages = paginate(m.items, {
|
|
1339
|
-
pageHeight: boxes.odd.height * PX_PER_PT,
|
|
1340
|
-
firstPageHeight: boxes.first.height * PX_PER_PT,
|
|
1341
|
-
evenPageHeight: boxes.even.height * PX_PER_PT,
|
|
1342
|
-
footnoteSeparator: m.footnoteSeparator
|
|
1343
|
-
});
|
|
1447
|
+
const m = measure(el, blocks, stretches.length);
|
|
1448
|
+
const input = packInput(stretches, m);
|
|
1449
|
+
const pages = paginate(input.items, input.options);
|
|
1344
1450
|
const heights = m.items.map((it) => it.type === "block" ? it.height : 0);
|
|
1345
|
-
setLayout({ pages, boxes, heights });
|
|
1346
|
-
}, [blocks,
|
|
1451
|
+
setLayout({ pages, boxes: input.boxes, heights });
|
|
1452
|
+
}, [blocks, stretches, numbering, fontEpoch, docFields, font]);
|
|
1347
1453
|
useEffect(() => {
|
|
1348
1454
|
const fonts = typeof document !== "undefined" ? document.fonts : void 0;
|
|
1349
1455
|
let live = true;
|
|
@@ -1364,7 +1470,7 @@ function DocViewer({
|
|
|
1364
1470
|
ro.observe(el);
|
|
1365
1471
|
return () => ro.disconnect();
|
|
1366
1472
|
}, []);
|
|
1367
|
-
const pageWpx = geometry.width * PX_PER_PT;
|
|
1473
|
+
const pageWpx = Math.max(...stretches.map((s) => s.geometry.width)) * PX_PER_PT;
|
|
1368
1474
|
const scale = typeof fixedScale === "number" && fixedScale > 0 ? fixedScale : fit === "none" || !width ? 1 : Math.min(maxScale, width / pageWpx);
|
|
1369
1475
|
const notShown = useMemo(() => unshownLayout(doc), [doc]);
|
|
1370
1476
|
const pageCount = layout?.pages.length ?? 0;
|
|
@@ -1374,12 +1480,13 @@ function DocViewer({
|
|
|
1374
1480
|
pages: layout.pages.length,
|
|
1375
1481
|
pageWidth: geometry.width,
|
|
1376
1482
|
pageHeight: geometry.height,
|
|
1483
|
+
...stretches.length > 1 ? { pageSizes: layout.pages.map((p) => ({ width: stretches[p.stretch ?? 0].geometry.width, height: stretches[p.stretch ?? 0].geometry.height })) } : {},
|
|
1377
1484
|
scale,
|
|
1378
1485
|
font,
|
|
1379
1486
|
...notShown.length > 0 ? { notShown } : {}
|
|
1380
1487
|
});
|
|
1381
1488
|
}
|
|
1382
|
-
}, [layout, geometry, scale, onLayout, font, notShown]);
|
|
1489
|
+
}, [layout, geometry, stretches, scale, onLayout, font, notShown]);
|
|
1383
1490
|
const typography2 = typography(doc?.defaultFont, ctx.size);
|
|
1384
1491
|
const ready = layout !== null && font !== "pending";
|
|
1385
1492
|
return /* @__PURE__ */ jsxs(
|
|
@@ -1412,49 +1519,74 @@ function DocViewer({
|
|
|
1412
1519
|
width: pt(geometry.contentWidth)
|
|
1413
1520
|
},
|
|
1414
1521
|
children: /* @__PURE__ */ jsxs(RenderCtx.Provider, { value: ctx, children: [
|
|
1415
|
-
|
|
1416
|
-
(
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1522
|
+
stretches.flatMap(
|
|
1523
|
+
(stretch, k) => ["header", "footer"].flatMap(
|
|
1524
|
+
(kind) => BAND_SLOTS.map((slot) => {
|
|
1525
|
+
const band = slotBand(stretch.page, kind, slot);
|
|
1526
|
+
if (!hasBand(band)) return null;
|
|
1527
|
+
const n = slot === "even" ? 2 : 1;
|
|
1528
|
+
const at = k === 0 ? `${kind}:${slot}` : `${k + 1}:${kind}:${slot}`;
|
|
1529
|
+
return /* @__PURE__ */ jsx("div", { "data-lw-measure-band": at, style: stretches.length > 1 ? { width: pt(stretch.geometry.contentWidth) } : void 0, children: /* @__PURE__ */ jsx(RenderCtx.Provider, { value: { ...ctxOf(k), fields: { ...docFields, section: k + 1, page: n, pages: n } }, children: /* @__PURE__ */ jsx(BandView, { band }) }) }, at);
|
|
1530
|
+
})
|
|
1531
|
+
)
|
|
1422
1532
|
),
|
|
1423
|
-
blocks.map((b, i) =>
|
|
1424
|
-
|
|
1533
|
+
blocks.map((b, i) => {
|
|
1534
|
+
const k = blockStretch[i];
|
|
1535
|
+
return /* @__PURE__ */ jsx(
|
|
1536
|
+
"div",
|
|
1537
|
+
{
|
|
1538
|
+
"data-lw-measure-block": i,
|
|
1539
|
+
style: { display: "flow-root", ...stretches.length > 1 ? { width: pt(stretches[k].geometry.contentWidth) } : {} },
|
|
1540
|
+
children: /* @__PURE__ */ jsx(RenderCtx.Provider, { value: ctxOf(k), children: /* @__PURE__ */ jsx(BlockView, { block: b }) })
|
|
1541
|
+
},
|
|
1542
|
+
i
|
|
1543
|
+
);
|
|
1544
|
+
}),
|
|
1545
|
+
numbering.notes.map((n) => {
|
|
1546
|
+
const k = noteStretch.get(n.id) ?? 0;
|
|
1547
|
+
return /* @__PURE__ */ jsx("div", { "data-lw-measure-footnote": n.id, style: stretches.length > 1 ? { width: pt(stretches[k].geometry.contentWidth) } : void 0, children: /* @__PURE__ */ jsx(RenderCtx.Provider, { value: ctxOf(k), children: /* @__PURE__ */ jsx(FootnoteView, { id: n.id, footnote: n.footnote }) }) }, n.id);
|
|
1548
|
+
}),
|
|
1425
1549
|
numbering.notes.length > 0 && /* @__PURE__ */ jsx("div", { "data-lw-measure-separator": "", children: /* @__PURE__ */ jsx(FootnoteSeparator, { height: pt(FOOTNOTE_SEPARATOR_PT) }) })
|
|
1426
1550
|
] })
|
|
1427
1551
|
}
|
|
1428
1552
|
),
|
|
1429
|
-
ready && layout && /* @__PURE__ */ jsx("div", { "data-lw-page-stack": "", style: { display: "flex", flexDirection: "column", alignItems: "center", gap }, children: layout.pages.map((p) =>
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1553
|
+
ready && layout && /* @__PURE__ */ jsx("div", { "data-lw-page-stack": "", style: { display: "flex", flexDirection: "column", alignItems: "center", gap }, children: layout.pages.map((p) => {
|
|
1554
|
+
const k = p.stretch ?? 0;
|
|
1555
|
+
const inStretch = layout.pages.filter((x) => (x.stretch ?? 0) === k);
|
|
1556
|
+
const start = inStretch[0].index;
|
|
1557
|
+
return /* @__PURE__ */ jsx(
|
|
1558
|
+
PageView,
|
|
1559
|
+
{
|
|
1560
|
+
page: p,
|
|
1561
|
+
pages: layout.pages.length,
|
|
1562
|
+
section: k + 1,
|
|
1563
|
+
sectionPages: inStretch.length,
|
|
1564
|
+
start,
|
|
1565
|
+
stretch: stretches[k],
|
|
1566
|
+
box: layout.boxes[k][pageClassIn(p.index, start)],
|
|
1567
|
+
scale,
|
|
1568
|
+
typography: typography2,
|
|
1569
|
+
ctx: ctxOf(k),
|
|
1570
|
+
docFields,
|
|
1571
|
+
numbering,
|
|
1572
|
+
blocks,
|
|
1573
|
+
heights: layout.heights
|
|
1574
|
+
},
|
|
1575
|
+
p.index
|
|
1576
|
+
);
|
|
1577
|
+
}) })
|
|
1447
1578
|
]
|
|
1448
1579
|
}
|
|
1449
1580
|
);
|
|
1450
1581
|
}
|
|
1451
|
-
function PageView({ page, pages,
|
|
1582
|
+
function PageView({ page, pages, section, sectionPages, start, stretch, box, scale, typography: typography2, ctx, docFields, numbering, blocks, heights }) {
|
|
1452
1583
|
const n = page.index + 1;
|
|
1453
|
-
const g = geometry;
|
|
1454
|
-
const
|
|
1455
|
-
const
|
|
1456
|
-
const
|
|
1457
|
-
const
|
|
1584
|
+
const g = stretch.geometry;
|
|
1585
|
+
const docPage = stretch.page;
|
|
1586
|
+
const bandCtx = { ...ctx, fields: { ...docFields, page: n, pages, section, sectionPages } };
|
|
1587
|
+
const cls = pageClassIn(page.index, start);
|
|
1588
|
+
const header = pageBand(docPage, "header", page.index, start);
|
|
1589
|
+
const footer = pageBand(docPage, "footer", page.index, start);
|
|
1458
1590
|
const variant = (kind) => bandSlot(docPage, kind, cls);
|
|
1459
1591
|
const notes = page.footnotes.map((fid) => numbering.notes.find((x) => x.id === fid)).filter((x) => !!x);
|
|
1460
1592
|
return /* @__PURE__ */ jsx(
|
|
@@ -1574,6 +1706,6 @@ function docFromReader(output) {
|
|
|
1574
1706
|
return value;
|
|
1575
1707
|
}
|
|
1576
1708
|
|
|
1577
|
-
export { CARLITO_FACES, CARLITO_FAMILY, DocViewer, FONT_LOAD_TIMEOUT_MS, LAYOUT_NOTICE, PAGE_BAND_DISTANCE_DEFAULT, PAGE_MARGIN_DEFAULT, PAGE_SIZES_PT, PX_PER_PT, bandSlot, bodyBox, carlitoFaces, docFromReader, fontFaceCss, formatDatePicture, numberFootnotes, pageBand, pageBodyBoxes, pageCapacity, pageClass, pageGeometry, pageMargins, paginate, resolveNow, substituteFields, unshownLayout };
|
|
1709
|
+
export { CARLITO_FACES, CARLITO_FAMILY, DocViewer, FONT_LOAD_TIMEOUT_MS, LAYOUT_NOTICE, PAGE_BAND_DISTANCE_DEFAULT, PAGE_MARGIN_DEFAULT, PAGE_SIZES_PT, PX_PER_PT, bandSlot, blockStretches, bodyBox, carlitoFaces, docFromReader, docStretches, fontFaceCss, formatDatePicture, numberFootnotes, packInput, pageBand, pageBodyBoxes, pageCapacity, pageClass, pageClassIn, pageGeometry, pageMargins, paginate, resolveNow, substituteFields, unshownLayout };
|
|
1578
1710
|
//# sourceMappingURL=index.js.map
|
|
1579
1711
|
//# sourceMappingURL=index.js.map
|