@particle-academy/last-word-ui 0.5.0 → 0.7.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/AGENTS.md +76 -0
- package/CHANGELOG.md +85 -0
- package/README.md +35 -10
- package/dist/index.cjs +210 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +80 -4
- package/dist/index.d.ts +80 -4
- package/dist/index.js +206 -44
- package/dist/index.js.map +1 -1
- package/package.json +9 -2
package/dist/index.cjs
CHANGED
|
@@ -53,6 +53,122 @@ function bodyBox(g, headerHeight, footerHeight) {
|
|
|
53
53
|
const bottom = Math.max(g.margins.bottom, footerHeight > 0 ? g.margins.footer + footerHeight : 0);
|
|
54
54
|
return { top, bottom, height: Math.max(1, g.height - top - bottom) };
|
|
55
55
|
}
|
|
56
|
+
var OFFICE_PALETTE = ["#4472C4", "#ED7D31", "#A5A5A5", "#FFC000", "#5B9BD5", "#70AD47", "#264478", "#9E480E"];
|
|
57
|
+
var isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
58
|
+
function pageChartOption(option) {
|
|
59
|
+
const o = isObj(option) ? option : {};
|
|
60
|
+
const hasAxes = o.xAxis !== void 0 || o.yAxis !== void 0;
|
|
61
|
+
const legendShown = isObj(o.legend) && o.legend.show !== false;
|
|
62
|
+
return {
|
|
63
|
+
backgroundColor: "transparent",
|
|
64
|
+
color: OFFICE_PALETTE,
|
|
65
|
+
animation: false,
|
|
66
|
+
...o,
|
|
67
|
+
...hasAxes ? {
|
|
68
|
+
grid: o.grid ?? {
|
|
69
|
+
top: o.title ? 36 : 16,
|
|
70
|
+
right: 16,
|
|
71
|
+
bottom: 8 + (legendShown ? 28 : 0),
|
|
72
|
+
left: 8,
|
|
73
|
+
outerBoundsMode: "same",
|
|
74
|
+
outerBoundsContain: "all"
|
|
75
|
+
}
|
|
76
|
+
} : {}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function chartTitle(block) {
|
|
80
|
+
const title = isObj(block.option) ? block.option.title : void 0;
|
|
81
|
+
if (typeof title === "string") return title;
|
|
82
|
+
if (isObj(title) && typeof title.text === "string") return title.text;
|
|
83
|
+
return typeof block.alt === "string" ? block.alt : "";
|
|
84
|
+
}
|
|
85
|
+
var PENDING = { status: "pending" };
|
|
86
|
+
var MISSING = { status: "missing" };
|
|
87
|
+
var peer = PENDING;
|
|
88
|
+
var loading = null;
|
|
89
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
90
|
+
function loadPeer() {
|
|
91
|
+
if (loading) return;
|
|
92
|
+
loading = import('@particle-academy/fancy-echarts').then((ns) => {
|
|
93
|
+
const mod = ns;
|
|
94
|
+
const EChart = mod.EChart;
|
|
95
|
+
if (typeof EChart !== "function" && typeof EChart !== "object") return MISSING;
|
|
96
|
+
mod.registerAll?.();
|
|
97
|
+
return { status: "ready", EChart };
|
|
98
|
+
}).catch(() => MISSING).then((state) => {
|
|
99
|
+
peer = state;
|
|
100
|
+
listeners.forEach((l) => l());
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function subscribe(listener) {
|
|
104
|
+
listeners.add(listener);
|
|
105
|
+
loadPeer();
|
|
106
|
+
return () => listeners.delete(listener);
|
|
107
|
+
}
|
|
108
|
+
var getSnapshot = () => peer;
|
|
109
|
+
var getServerSnapshot = () => PENDING;
|
|
110
|
+
var warned = false;
|
|
111
|
+
function warnMissing() {
|
|
112
|
+
if (warned) return;
|
|
113
|
+
const env = globalThis.process?.env;
|
|
114
|
+
if (env?.NODE_ENV === "production") return;
|
|
115
|
+
warned = true;
|
|
116
|
+
console.warn(
|
|
117
|
+
"[last-word-ui] This document has charts, but @particle-academy/fancy-echarts is not installed, so they draw as placeholders. Install it (npm i @particle-academy/fancy-echarts echarts) to draw them, or pass DocViewer a renderChart prop."
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
var PAPER_THEME = {};
|
|
121
|
+
function ChartBox({ block, width, height: height2, measuring, renderChart }) {
|
|
122
|
+
const title = chartTitle(block);
|
|
123
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
124
|
+
"div",
|
|
125
|
+
{
|
|
126
|
+
"data-lw-chart": "",
|
|
127
|
+
role: measuring ? void 0 : "img",
|
|
128
|
+
"aria-label": measuring || !title ? void 0 : title,
|
|
129
|
+
style: { width, height: height2, overflow: "hidden" },
|
|
130
|
+
children: measuring ? null : /* @__PURE__ */ jsxRuntime.jsx(ChartContent, { block, width, height: height2, title, renderChart })
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
function ChartContent({ block, width, height: height2, title, renderChart }) {
|
|
135
|
+
const option = react.useMemo(() => pageChartOption(block.option), [block.option]);
|
|
136
|
+
if (renderChart) {
|
|
137
|
+
const custom = renderChart({ block, option, width, height: height2, title });
|
|
138
|
+
if (custom !== void 0) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: custom });
|
|
139
|
+
}
|
|
140
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DefaultChart, { option, width, height: height2, title });
|
|
141
|
+
}
|
|
142
|
+
function DefaultChart({ option, width, height: height2, title }) {
|
|
143
|
+
const state = react.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
144
|
+
if (state.status === "ready") {
|
|
145
|
+
const { EChart } = state;
|
|
146
|
+
return /* @__PURE__ */ jsxRuntime.jsx(EChart, { option, theme: PAPER_THEME, renderer: "svg", autoResize: false, style: { width, height: height2 } });
|
|
147
|
+
}
|
|
148
|
+
if (state.status === "missing") return /* @__PURE__ */ jsxRuntime.jsx(Placeholder, { width, height: height2, title });
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
function Placeholder({ width, height: height2, title }) {
|
|
152
|
+
react.useEffect(warnMissing, []);
|
|
153
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
154
|
+
"div",
|
|
155
|
+
{
|
|
156
|
+
"data-lw-chart-placeholder": "",
|
|
157
|
+
style: {
|
|
158
|
+
width,
|
|
159
|
+
height: height2,
|
|
160
|
+
border: "0.75pt dashed #9CA3AF",
|
|
161
|
+
color: "#6B7280",
|
|
162
|
+
fontSize: "9pt",
|
|
163
|
+
display: "flex",
|
|
164
|
+
alignItems: "center",
|
|
165
|
+
justifyContent: "center",
|
|
166
|
+
boxSizing: "border-box"
|
|
167
|
+
},
|
|
168
|
+
children: title ? `Chart: ${title}` : "Chart"
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
}
|
|
56
172
|
|
|
57
173
|
// src/fields.ts
|
|
58
174
|
var FIELD = /\{(?:(page|pages|section|sectionpages|author|title|filename)|(date|time)(?::([^{}"\\]+))?)\}/g;
|
|
@@ -276,6 +392,49 @@ function safeHref(url) {
|
|
|
276
392
|
return ALLOWED.has(parsed.protocol) ? url : void 0;
|
|
277
393
|
}
|
|
278
394
|
|
|
395
|
+
// src/revisions.ts
|
|
396
|
+
var TRACKED_CHANGES_NOTICE = "This document has tracked changes, which this viewer can't show yet. Accept them first. Deleted text is hidden.";
|
|
397
|
+
var isObject = (v) => typeof v === "object" && v !== null;
|
|
398
|
+
var KEPT_KINDS = /* @__PURE__ */ new Set(["insert", "moveTo", "format"]);
|
|
399
|
+
var KINDS = ["insert", "delete", "moveFrom", "moveTo", "format"];
|
|
400
|
+
function revisionKind(revision) {
|
|
401
|
+
if (typeof revision === "string") return revision;
|
|
402
|
+
if (!isObject(revision)) return null;
|
|
403
|
+
for (const key of ["type", "kind"]) {
|
|
404
|
+
if (typeof revision[key] === "string") return revision[key];
|
|
405
|
+
}
|
|
406
|
+
const named = KINDS.filter((k) => revision[k] !== void 0 && revision[k] !== false);
|
|
407
|
+
return named.length === 1 ? named[0] : null;
|
|
408
|
+
}
|
|
409
|
+
function isDeletedRun(run) {
|
|
410
|
+
if (!isObject(run) || !("revision" in run) || run.revision === void 0) return false;
|
|
411
|
+
const kind = revisionKind(run.revision);
|
|
412
|
+
return kind === null || !KEPT_KINDS.has(kind);
|
|
413
|
+
}
|
|
414
|
+
var escape = (key) => key.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
415
|
+
function revisionPaths(doc) {
|
|
416
|
+
const found = [];
|
|
417
|
+
if (!isObject(doc)) return found;
|
|
418
|
+
const seen = /* @__PURE__ */ new Set();
|
|
419
|
+
const stack = [{ value: doc, at: "" }];
|
|
420
|
+
while (stack.length > 0) {
|
|
421
|
+
const { value, at } = stack.pop();
|
|
422
|
+
if (!isObject(value) || seen.has(value)) continue;
|
|
423
|
+
seen.add(value);
|
|
424
|
+
if (Array.isArray(value)) {
|
|
425
|
+
for (let i = value.length - 1; i >= 0; i--) stack.push({ value: value[i], at: `${at}/${i}` });
|
|
426
|
+
continue;
|
|
427
|
+
}
|
|
428
|
+
if (value.revision !== void 0) found.push(`${at}/revision`);
|
|
429
|
+
const keys = Object.keys(value).filter((k) => k !== "revision" && !(k === "option" && value.type === "chart"));
|
|
430
|
+
for (let i = keys.length - 1; i >= 0; i--) stack.push({ value: value[keys[i]], at: `${at}/${escape(keys[i])}` });
|
|
431
|
+
}
|
|
432
|
+
return found;
|
|
433
|
+
}
|
|
434
|
+
function hasRevisions(doc) {
|
|
435
|
+
return revisionPaths(doc).length > 0;
|
|
436
|
+
}
|
|
437
|
+
|
|
279
438
|
// src/style.ts
|
|
280
439
|
var pt = (n) => `${Math.round(n * 1e3) / 1e3}pt`;
|
|
281
440
|
var px = (n) => `${Math.round(n * 1e3) / 1e3}px`;
|
|
@@ -450,6 +609,7 @@ function WithContext({ value, children }) {
|
|
|
450
609
|
}
|
|
451
610
|
function RunView({ run }) {
|
|
452
611
|
const ctx = react.useContext(RenderCtx);
|
|
612
|
+
if (isDeletedRun(run)) return null;
|
|
453
613
|
const mark = ctx.marks.get(run);
|
|
454
614
|
let text = typeof run.text === "string" ? run.text : "";
|
|
455
615
|
if (ctx.fields) text = substituteFields(text, ctx.fields);
|
|
@@ -493,7 +653,9 @@ function RunView({ run }) {
|
|
|
493
653
|
}
|
|
494
654
|
function Runs({ runs }) {
|
|
495
655
|
const list = Array.isArray(runs) ? runs : [];
|
|
496
|
-
const visible = list.some(
|
|
656
|
+
const visible = list.some(
|
|
657
|
+
(r) => !!r && typeof r === "object" && !isDeletedRun(r) && (typeof r.text === "string" && r.text !== "" || !!r.footnote)
|
|
658
|
+
);
|
|
497
659
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
498
660
|
list.map((run, i) => run && typeof run === "object" ? /* @__PURE__ */ jsxRuntime.jsx(RunView, { run }, i) : null),
|
|
499
661
|
!visible && ZWSP
|
|
@@ -536,7 +698,7 @@ function BlockView({ block }) {
|
|
|
536
698
|
case "image":
|
|
537
699
|
return /* @__PURE__ */ jsxRuntime.jsx(ImageView, { block });
|
|
538
700
|
case "chart":
|
|
539
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
701
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ChartView, { block });
|
|
540
702
|
case "hr":
|
|
541
703
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-lw-kind": "hr", style: { display: "flow-root", paddingBottom: pt(ctx.spaceAfter) }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { height: pt(ctx.size * SINGLE_LINE), display: "flex", alignItems: "flex-end" }, children: /* @__PURE__ */ jsxRuntime.jsx(reactFancy.Separator, { className: "w-full" }) }) });
|
|
542
704
|
case "pageBreak":
|
|
@@ -588,7 +750,7 @@ function ImageView({ block }) {
|
|
|
588
750
|
}
|
|
589
751
|
) });
|
|
590
752
|
}
|
|
591
|
-
function
|
|
753
|
+
function ChartView({ block }) {
|
|
592
754
|
const ctx = react.useContext(RenderCtx);
|
|
593
755
|
const maxPx = ctx.contentWidth * PX_PER_PT;
|
|
594
756
|
const width = Math.min(
|
|
@@ -596,26 +758,7 @@ function ChartPlaceholder({ block }) {
|
|
|
596
758
|
num(block.widthPx, typeof block.width === "number" && block.width > 0 ? maxPx * Math.min(100, block.width) / 100 : maxPx)
|
|
597
759
|
);
|
|
598
760
|
const height2 = num(block.heightPx, width * 0.6);
|
|
599
|
-
|
|
600
|
-
const title = typeof option.title === "string" ? option.title : option.title && typeof option.title.text === "string" ? option.title.text : typeof block.alt === "string" ? block.alt : "";
|
|
601
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-lw-kind": "chart", style: { display: "flow-root", paddingBottom: pt(ctx.spaceAfter) }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
602
|
-
"div",
|
|
603
|
-
{
|
|
604
|
-
"data-lw-chart-placeholder": "",
|
|
605
|
-
style: {
|
|
606
|
-
width,
|
|
607
|
-
height: height2,
|
|
608
|
-
border: "0.75pt dashed #9CA3AF",
|
|
609
|
-
color: "#6B7280",
|
|
610
|
-
fontSize: pt(9),
|
|
611
|
-
display: "flex",
|
|
612
|
-
alignItems: "center",
|
|
613
|
-
justifyContent: "center",
|
|
614
|
-
boxSizing: "border-box"
|
|
615
|
-
},
|
|
616
|
-
children: title ? `Chart: ${title}` : "Chart"
|
|
617
|
-
}
|
|
618
|
-
) });
|
|
761
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-lw-kind": "chart", style: { display: "flow-root", paddingBottom: pt(ctx.spaceAfter) }, children: /* @__PURE__ */ jsxRuntime.jsx(ChartBox, { block, width, height: height2, measuring: ctx.measuring, renderChart: ctx.renderChart }) });
|
|
619
762
|
}
|
|
620
763
|
var DEFAULT_TABLE_BORDER = { style: "single", width: 0.5 };
|
|
621
764
|
var DEFAULT_CELL_PADDING = { top: 3, right: 5.4, bottom: 3, left: 5.4 };
|
|
@@ -800,7 +943,7 @@ function numberFootnotes(doc) {
|
|
|
800
943
|
if (!Array.isArray(list)) return;
|
|
801
944
|
for (const run of list) {
|
|
802
945
|
const fn = run?.footnote;
|
|
803
|
-
if (fn && typeof fn === "object" && Array.isArray(fn.blocks)) {
|
|
946
|
+
if (fn && !isDeletedRun(run) && typeof fn === "object" && Array.isArray(fn.blocks)) {
|
|
804
947
|
const id = notes.length + 1;
|
|
805
948
|
marks.set(run, id);
|
|
806
949
|
notes.push({ id, footnote: fn });
|
|
@@ -841,9 +984,9 @@ function numberFootnotes(doc) {
|
|
|
841
984
|
}
|
|
842
985
|
|
|
843
986
|
// src/stretches.ts
|
|
844
|
-
var
|
|
987
|
+
var isObject2 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
845
988
|
function isPageObject(page) {
|
|
846
|
-
return
|
|
989
|
+
return isObject2(page) || Array.isArray(page) && page.length === 0;
|
|
847
990
|
}
|
|
848
991
|
function mergePage(page, change) {
|
|
849
992
|
const out = { ...page ?? {} };
|
|
@@ -851,7 +994,7 @@ function mergePage(page, change) {
|
|
|
851
994
|
delete out.firstFooter;
|
|
852
995
|
for (const [key, value] of Object.entries(change)) {
|
|
853
996
|
if (value === void 0 || value === null || key === "background") continue;
|
|
854
|
-
if (key === "margins" &&
|
|
997
|
+
if (key === "margins" && isObject2(value) && isObject2(out.margins)) {
|
|
855
998
|
const merged = { ...out.margins };
|
|
856
999
|
for (const [side, v] of Object.entries(value)) {
|
|
857
1000
|
if (v !== void 0 && v !== null) merged[side] = v;
|
|
@@ -873,8 +1016,8 @@ function docStretches(doc) {
|
|
|
873
1016
|
const out = [make(null)];
|
|
874
1017
|
(Array.isArray(doc?.blocks) ? doc.blocks : []).forEach((block, i) => {
|
|
875
1018
|
const b = block;
|
|
876
|
-
if (!
|
|
877
|
-
page = mergePage(page,
|
|
1019
|
+
if (!isObject2(b) || b.type !== "pageBreak" || !isPageObject(b.page)) return;
|
|
1020
|
+
page = mergePage(page, isObject2(b.page) ? b.page : {});
|
|
878
1021
|
out.push(make(i));
|
|
879
1022
|
});
|
|
880
1023
|
return out;
|
|
@@ -924,17 +1067,17 @@ function packInput(stretches, measured) {
|
|
|
924
1067
|
// src/layout-notice.ts
|
|
925
1068
|
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.";
|
|
926
1069
|
var NEAR_MISS_KEYS = ["size", "orientation", "margins", "header", "footer", "firstHeader", "firstFooter", "evenHeader", "evenFooter", "background", "border"];
|
|
927
|
-
var
|
|
1070
|
+
var isObject3 = (v) => typeof v === "object" && v !== null;
|
|
928
1071
|
function unshownLayout(doc) {
|
|
929
1072
|
const found = [];
|
|
930
|
-
if (!
|
|
1073
|
+
if (!isObject3(doc)) return found;
|
|
931
1074
|
if (doc.sections !== void 0) found.push("/sections");
|
|
932
1075
|
const stack = [{ blocks: doc.blocks, at: "/blocks" }];
|
|
933
1076
|
while (stack.length > 0) {
|
|
934
1077
|
const { blocks, at } = stack.pop();
|
|
935
1078
|
if (!Array.isArray(blocks)) continue;
|
|
936
1079
|
blocks.forEach((block, i) => {
|
|
937
|
-
if (!
|
|
1080
|
+
if (!isObject3(block)) return;
|
|
938
1081
|
const path = `${at}/${i}`;
|
|
939
1082
|
if (block.type === "pageBreak") {
|
|
940
1083
|
for (const key of NEAR_MISS_KEYS) {
|
|
@@ -942,15 +1085,15 @@ function unshownLayout(doc) {
|
|
|
942
1085
|
}
|
|
943
1086
|
if (block.page !== void 0) {
|
|
944
1087
|
if (at !== "/blocks" || !isPageObject(block.page)) found.push(`${path}/page`);
|
|
945
|
-
else if (
|
|
1088
|
+
else if (isObject3(block.page) && block.page.background !== void 0) found.push(`${path}/page/background`);
|
|
946
1089
|
}
|
|
947
1090
|
} else if (block.type === "quote") {
|
|
948
1091
|
stack.push({ blocks: block.blocks, at: `${path}/blocks` });
|
|
949
1092
|
} else if (block.type === "table" && Array.isArray(block.rows)) {
|
|
950
1093
|
block.rows.forEach((row, r) => {
|
|
951
|
-
if (!
|
|
1094
|
+
if (!isObject3(row) || !Array.isArray(row.cells)) return;
|
|
952
1095
|
row.cells.forEach((cell, c) => {
|
|
953
|
-
if (
|
|
1096
|
+
if (isObject3(cell)) stack.push({ blocks: cell.blocks, at: `${path}/rows/${r}/cells/${c}/blocks` });
|
|
954
1097
|
});
|
|
955
1098
|
});
|
|
956
1099
|
}
|
|
@@ -1384,6 +1527,7 @@ function DocViewer({
|
|
|
1384
1527
|
now,
|
|
1385
1528
|
onLayout,
|
|
1386
1529
|
injectStyles = true,
|
|
1530
|
+
renderChart,
|
|
1387
1531
|
id,
|
|
1388
1532
|
className,
|
|
1389
1533
|
style
|
|
@@ -1427,9 +1571,10 @@ function DocViewer({
|
|
|
1427
1571
|
marks: numbering.marks,
|
|
1428
1572
|
size: num(doc?.defaultSize, DEFAULT_SIZE),
|
|
1429
1573
|
spaceAfter: DEFAULT_SPACE_AFTER,
|
|
1430
|
-
contentWidth: geometry.contentWidth
|
|
1574
|
+
contentWidth: geometry.contentWidth,
|
|
1575
|
+
...renderChart ? { renderChart } : {}
|
|
1431
1576
|
}),
|
|
1432
|
-
[numbering, doc, geometry]
|
|
1577
|
+
[numbering, doc, geometry, renderChart]
|
|
1433
1578
|
);
|
|
1434
1579
|
const ctxOf = (k) => ({ ...ctx, contentWidth: stretches[k].geometry.contentWidth });
|
|
1435
1580
|
react.useEffect(() => {
|
|
@@ -1476,6 +1621,7 @@ function DocViewer({
|
|
|
1476
1621
|
const pageWpx = Math.max(...stretches.map((s) => s.geometry.width)) * PX_PER_PT;
|
|
1477
1622
|
const scale = typeof fixedScale === "number" && fixedScale > 0 ? fixedScale : fit === "none" || !width ? 1 : Math.min(maxScale, width / pageWpx);
|
|
1478
1623
|
const notShown = react.useMemo(() => unshownLayout(doc), [doc]);
|
|
1624
|
+
const revisions = react.useMemo(() => revisionPaths(doc), [doc]);
|
|
1479
1625
|
const pageCount = layout?.pages.length ?? 0;
|
|
1480
1626
|
react.useEffect(() => {
|
|
1481
1627
|
if (layout && font !== "pending") {
|
|
@@ -1486,10 +1632,11 @@ function DocViewer({
|
|
|
1486
1632
|
...stretches.length > 1 ? { pageSizes: layout.pages.map((p) => ({ width: stretches[p.stretch ?? 0].geometry.width, height: stretches[p.stretch ?? 0].geometry.height })) } : {},
|
|
1487
1633
|
scale,
|
|
1488
1634
|
font,
|
|
1489
|
-
...notShown.length > 0 ? { notShown } : {}
|
|
1635
|
+
...notShown.length > 0 ? { notShown } : {},
|
|
1636
|
+
...revisions.length > 0 ? { revisions } : {}
|
|
1490
1637
|
});
|
|
1491
1638
|
}
|
|
1492
|
-
}, [layout, geometry, stretches, scale, onLayout, font, notShown]);
|
|
1639
|
+
}, [layout, geometry, stretches, scale, onLayout, font, notShown, revisions]);
|
|
1493
1640
|
const typography2 = typography(doc?.defaultFont, ctx.size);
|
|
1494
1641
|
const ready = layout !== null && font !== "pending";
|
|
1495
1642
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -1500,12 +1647,15 @@ function DocViewer({
|
|
|
1500
1647
|
"data-lw-viewer": "",
|
|
1501
1648
|
"data-lw-pages": ready && pageCount || void 0,
|
|
1502
1649
|
"data-lw-font": ready ? font : void 0,
|
|
1650
|
+
"data-lw-tracked-changes": revisions.length > 0 ? "" : void 0,
|
|
1651
|
+
"aria-busy": ready ? void 0 : true,
|
|
1503
1652
|
className,
|
|
1504
1653
|
style: { position: "relative", ...style },
|
|
1505
1654
|
children: [
|
|
1506
1655
|
injectStyles && /* @__PURE__ */ jsxRuntime.jsx("style", { href: "particle-academy-last-word-ui", precedence: "default", children: VIEWER_CSS }),
|
|
1507
1656
|
injectStyles && FONT_CSS && /* @__PURE__ */ jsxRuntime.jsx("style", { href: "particle-academy-last-word-ui-fonts", precedence: "default", children: FONT_CSS }),
|
|
1508
1657
|
notShown.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-lw-layout-notice": "", style: { marginBottom: gap }, children: /* @__PURE__ */ jsxRuntime.jsx(reactFancy.Callout, { color: "amber", children: LAYOUT_NOTICE }) }),
|
|
1658
|
+
revisions.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-lw-tracked-changes-notice": "", "data-lw-revisions": revisions.length, style: { marginBottom: gap }, children: /* @__PURE__ */ jsxRuntime.jsx(reactFancy.Callout, { color: "amber", children: TRACKED_CHANGES_NOTICE }) }),
|
|
1509
1659
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1510
1660
|
"div",
|
|
1511
1661
|
{
|
|
@@ -1529,7 +1679,7 @@ function DocViewer({
|
|
|
1529
1679
|
if (!hasBand(band)) return null;
|
|
1530
1680
|
const n = slot === "even" ? 2 : 1;
|
|
1531
1681
|
const at = k === 0 ? `${kind}:${slot}` : `${k + 1}:${kind}:${slot}`;
|
|
1532
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-lw-measure-band": at, style: stretches.length > 1 ? { width: pt(stretch.geometry.contentWidth) } : void 0, children: /* @__PURE__ */ jsxRuntime.jsx(RenderCtx.Provider, { value: { ...ctxOf(k), fields: { ...docFields, section: k + 1, page: n, pages: n } }, children: /* @__PURE__ */ jsxRuntime.jsx(BandView, { band }) }) }, at);
|
|
1682
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-lw-measure-band": at, style: stretches.length > 1 ? { width: pt(stretch.geometry.contentWidth) } : void 0, children: /* @__PURE__ */ jsxRuntime.jsx(RenderCtx.Provider, { value: { ...ctxOf(k), measuring: true, fields: { ...docFields, section: k + 1, page: n, pages: n } }, children: /* @__PURE__ */ jsxRuntime.jsx(BandView, { band }) }) }, at);
|
|
1533
1683
|
})
|
|
1534
1684
|
)
|
|
1535
1685
|
),
|
|
@@ -1540,19 +1690,31 @@ function DocViewer({
|
|
|
1540
1690
|
{
|
|
1541
1691
|
"data-lw-measure-block": i,
|
|
1542
1692
|
style: { display: "flow-root", ...stretches.length > 1 ? { width: pt(stretches[k].geometry.contentWidth) } : {} },
|
|
1543
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(RenderCtx.Provider, { value: ctxOf(k), children: /* @__PURE__ */ jsxRuntime.jsx(BlockView, { block: b }) })
|
|
1693
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(RenderCtx.Provider, { value: { ...ctxOf(k), measuring: true }, children: /* @__PURE__ */ jsxRuntime.jsx(BlockView, { block: b }) })
|
|
1544
1694
|
},
|
|
1545
1695
|
i
|
|
1546
1696
|
);
|
|
1547
1697
|
}),
|
|
1548
1698
|
numbering.notes.map((n) => {
|
|
1549
1699
|
const k = noteStretch.get(n.id) ?? 0;
|
|
1550
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-lw-measure-footnote": n.id, style: stretches.length > 1 ? { width: pt(stretches[k].geometry.contentWidth) } : void 0, children: /* @__PURE__ */ jsxRuntime.jsx(RenderCtx.Provider, { value: ctxOf(k), children: /* @__PURE__ */ jsxRuntime.jsx(FootnoteView, { id: n.id, footnote: n.footnote }) }) }, n.id);
|
|
1700
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-lw-measure-footnote": n.id, style: stretches.length > 1 ? { width: pt(stretches[k].geometry.contentWidth) } : void 0, children: /* @__PURE__ */ jsxRuntime.jsx(RenderCtx.Provider, { value: { ...ctxOf(k), measuring: true }, children: /* @__PURE__ */ jsxRuntime.jsx(FootnoteView, { id: n.id, footnote: n.footnote }) }) }, n.id);
|
|
1551
1701
|
}),
|
|
1552
1702
|
numbering.notes.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-lw-measure-separator": "", children: /* @__PURE__ */ jsxRuntime.jsx(FootnoteSeparator, { height: pt(FOOTNOTE_SEPARATOR_PT) }) })
|
|
1553
1703
|
] })
|
|
1554
1704
|
}
|
|
1555
1705
|
),
|
|
1706
|
+
!ready && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1707
|
+
"div",
|
|
1708
|
+
{
|
|
1709
|
+
"data-lw-pending": "",
|
|
1710
|
+
style: {
|
|
1711
|
+
width: px(stretches[0].geometry.width * PX_PER_PT * scale),
|
|
1712
|
+
maxWidth: "100%",
|
|
1713
|
+
height: px(stretches[0].geometry.height * PX_PER_PT * scale),
|
|
1714
|
+
margin: "0 auto"
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
),
|
|
1556
1718
|
ready && layout && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-lw-page-stack": "", style: { display: "flex", flexDirection: "column", alignItems: "center", gap }, children: layout.pages.map((p) => {
|
|
1557
1719
|
const k = p.stretch ?? 0;
|
|
1558
1720
|
const inStretch = layout.pages.filter((x) => (x.stretch ?? 0) === k);
|
|
@@ -1714,10 +1876,12 @@ exports.CARLITO_FAMILY = CARLITO_FAMILY;
|
|
|
1714
1876
|
exports.DocViewer = DocViewer;
|
|
1715
1877
|
exports.FONT_LOAD_TIMEOUT_MS = FONT_LOAD_TIMEOUT_MS;
|
|
1716
1878
|
exports.LAYOUT_NOTICE = LAYOUT_NOTICE;
|
|
1879
|
+
exports.OFFICE_PALETTE = OFFICE_PALETTE;
|
|
1717
1880
|
exports.PAGE_BAND_DISTANCE_DEFAULT = PAGE_BAND_DISTANCE_DEFAULT;
|
|
1718
1881
|
exports.PAGE_MARGIN_DEFAULT = PAGE_MARGIN_DEFAULT;
|
|
1719
1882
|
exports.PAGE_SIZES_PT = PAGE_SIZES_PT;
|
|
1720
1883
|
exports.PX_PER_PT = PX_PER_PT;
|
|
1884
|
+
exports.TRACKED_CHANGES_NOTICE = TRACKED_CHANGES_NOTICE;
|
|
1721
1885
|
exports.bandSlot = bandSlot;
|
|
1722
1886
|
exports.blockStretches = blockStretches;
|
|
1723
1887
|
exports.bodyBox = bodyBox;
|
|
@@ -1726,17 +1890,21 @@ exports.docFromReader = docFromReader;
|
|
|
1726
1890
|
exports.docStretches = docStretches;
|
|
1727
1891
|
exports.fontFaceCss = fontFaceCss;
|
|
1728
1892
|
exports.formatDatePicture = formatDatePicture;
|
|
1893
|
+
exports.hasRevisions = hasRevisions;
|
|
1894
|
+
exports.isDeletedRun = isDeletedRun;
|
|
1729
1895
|
exports.numberFootnotes = numberFootnotes;
|
|
1730
1896
|
exports.packInput = packInput;
|
|
1731
1897
|
exports.pageBand = pageBand;
|
|
1732
1898
|
exports.pageBodyBoxes = pageBodyBoxes;
|
|
1733
1899
|
exports.pageCapacity = pageCapacity;
|
|
1900
|
+
exports.pageChartOption = pageChartOption;
|
|
1734
1901
|
exports.pageClass = pageClass;
|
|
1735
1902
|
exports.pageClassIn = pageClassIn;
|
|
1736
1903
|
exports.pageGeometry = pageGeometry;
|
|
1737
1904
|
exports.pageMargins = pageMargins;
|
|
1738
1905
|
exports.paginate = paginate;
|
|
1739
1906
|
exports.resolveNow = resolveNow;
|
|
1907
|
+
exports.revisionPaths = revisionPaths;
|
|
1740
1908
|
exports.substituteFields = substituteFields;
|
|
1741
1909
|
exports.unshownLayout = unshownLayout;
|
|
1742
1910
|
//# sourceMappingURL=index.cjs.map
|