@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/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createContext, useMemo, useRef, useState, useEffect, useLayoutEffect, useContext } from 'react';
1
+ import { createContext, useMemo, useRef, useState, useEffect, useLayoutEffect, useContext, useSyncExternalStore } from 'react';
2
2
  import { Callout, Text, Separator, Heading, Table, ImageViewer } from '@particle-academy/react-fancy';
3
3
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
4
4
 
@@ -50,6 +50,122 @@ function bodyBox(g, headerHeight, footerHeight) {
50
50
  const bottom = Math.max(g.margins.bottom, footerHeight > 0 ? g.margins.footer + footerHeight : 0);
51
51
  return { top, bottom, height: Math.max(1, g.height - top - bottom) };
52
52
  }
53
+ var OFFICE_PALETTE = ["#4472C4", "#ED7D31", "#A5A5A5", "#FFC000", "#5B9BD5", "#70AD47", "#264478", "#9E480E"];
54
+ var isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
55
+ function pageChartOption(option) {
56
+ const o = isObj(option) ? option : {};
57
+ const hasAxes = o.xAxis !== void 0 || o.yAxis !== void 0;
58
+ const legendShown = isObj(o.legend) && o.legend.show !== false;
59
+ return {
60
+ backgroundColor: "transparent",
61
+ color: OFFICE_PALETTE,
62
+ animation: false,
63
+ ...o,
64
+ ...hasAxes ? {
65
+ grid: o.grid ?? {
66
+ top: o.title ? 36 : 16,
67
+ right: 16,
68
+ bottom: 8 + (legendShown ? 28 : 0),
69
+ left: 8,
70
+ outerBoundsMode: "same",
71
+ outerBoundsContain: "all"
72
+ }
73
+ } : {}
74
+ };
75
+ }
76
+ function chartTitle(block) {
77
+ const title = isObj(block.option) ? block.option.title : void 0;
78
+ if (typeof title === "string") return title;
79
+ if (isObj(title) && typeof title.text === "string") return title.text;
80
+ return typeof block.alt === "string" ? block.alt : "";
81
+ }
82
+ var PENDING = { status: "pending" };
83
+ var MISSING = { status: "missing" };
84
+ var peer = PENDING;
85
+ var loading = null;
86
+ var listeners = /* @__PURE__ */ new Set();
87
+ function loadPeer() {
88
+ if (loading) return;
89
+ loading = import('@particle-academy/fancy-echarts').then((ns) => {
90
+ const mod = ns;
91
+ const EChart = mod.EChart;
92
+ if (typeof EChart !== "function" && typeof EChart !== "object") return MISSING;
93
+ mod.registerAll?.();
94
+ return { status: "ready", EChart };
95
+ }).catch(() => MISSING).then((state) => {
96
+ peer = state;
97
+ listeners.forEach((l) => l());
98
+ });
99
+ }
100
+ function subscribe(listener) {
101
+ listeners.add(listener);
102
+ loadPeer();
103
+ return () => listeners.delete(listener);
104
+ }
105
+ var getSnapshot = () => peer;
106
+ var getServerSnapshot = () => PENDING;
107
+ var warned = false;
108
+ function warnMissing() {
109
+ if (warned) return;
110
+ const env = globalThis.process?.env;
111
+ if (env?.NODE_ENV === "production") return;
112
+ warned = true;
113
+ console.warn(
114
+ "[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."
115
+ );
116
+ }
117
+ var PAPER_THEME = {};
118
+ function ChartBox({ block, width, height: height2, measuring, renderChart }) {
119
+ const title = chartTitle(block);
120
+ return /* @__PURE__ */ jsx(
121
+ "div",
122
+ {
123
+ "data-lw-chart": "",
124
+ role: measuring ? void 0 : "img",
125
+ "aria-label": measuring || !title ? void 0 : title,
126
+ style: { width, height: height2, overflow: "hidden" },
127
+ children: measuring ? null : /* @__PURE__ */ jsx(ChartContent, { block, width, height: height2, title, renderChart })
128
+ }
129
+ );
130
+ }
131
+ function ChartContent({ block, width, height: height2, title, renderChart }) {
132
+ const option = useMemo(() => pageChartOption(block.option), [block.option]);
133
+ if (renderChart) {
134
+ const custom = renderChart({ block, option, width, height: height2, title });
135
+ if (custom !== void 0) return /* @__PURE__ */ jsx(Fragment, { children: custom });
136
+ }
137
+ return /* @__PURE__ */ jsx(DefaultChart, { option, width, height: height2, title });
138
+ }
139
+ function DefaultChart({ option, width, height: height2, title }) {
140
+ const state = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
141
+ if (state.status === "ready") {
142
+ const { EChart } = state;
143
+ return /* @__PURE__ */ jsx(EChart, { option, theme: PAPER_THEME, renderer: "svg", autoResize: false, style: { width, height: height2 } });
144
+ }
145
+ if (state.status === "missing") return /* @__PURE__ */ jsx(Placeholder, { width, height: height2, title });
146
+ return null;
147
+ }
148
+ function Placeholder({ width, height: height2, title }) {
149
+ useEffect(warnMissing, []);
150
+ return /* @__PURE__ */ jsx(
151
+ "div",
152
+ {
153
+ "data-lw-chart-placeholder": "",
154
+ style: {
155
+ width,
156
+ height: height2,
157
+ border: "0.75pt dashed #9CA3AF",
158
+ color: "#6B7280",
159
+ fontSize: "9pt",
160
+ display: "flex",
161
+ alignItems: "center",
162
+ justifyContent: "center",
163
+ boxSizing: "border-box"
164
+ },
165
+ children: title ? `Chart: ${title}` : "Chart"
166
+ }
167
+ );
168
+ }
53
169
 
54
170
  // src/fields.ts
55
171
  var FIELD = /\{(?:(page|pages|section|sectionpages|author|title|filename)|(date|time)(?::([^{}"\\]+))?)\}/g;
@@ -273,6 +389,49 @@ function safeHref(url) {
273
389
  return ALLOWED.has(parsed.protocol) ? url : void 0;
274
390
  }
275
391
 
392
+ // src/revisions.ts
393
+ var TRACKED_CHANGES_NOTICE = "This document has tracked changes, which this viewer can't show yet. Accept them first. Deleted text is hidden.";
394
+ var isObject = (v) => typeof v === "object" && v !== null;
395
+ var KEPT_KINDS = /* @__PURE__ */ new Set(["insert", "moveTo", "format"]);
396
+ var KINDS = ["insert", "delete", "moveFrom", "moveTo", "format"];
397
+ function revisionKind(revision) {
398
+ if (typeof revision === "string") return revision;
399
+ if (!isObject(revision)) return null;
400
+ for (const key of ["type", "kind"]) {
401
+ if (typeof revision[key] === "string") return revision[key];
402
+ }
403
+ const named = KINDS.filter((k) => revision[k] !== void 0 && revision[k] !== false);
404
+ return named.length === 1 ? named[0] : null;
405
+ }
406
+ function isDeletedRun(run) {
407
+ if (!isObject(run) || !("revision" in run) || run.revision === void 0) return false;
408
+ const kind = revisionKind(run.revision);
409
+ return kind === null || !KEPT_KINDS.has(kind);
410
+ }
411
+ var escape = (key) => key.replace(/~/g, "~0").replace(/\//g, "~1");
412
+ function revisionPaths(doc) {
413
+ const found = [];
414
+ if (!isObject(doc)) return found;
415
+ const seen = /* @__PURE__ */ new Set();
416
+ const stack = [{ value: doc, at: "" }];
417
+ while (stack.length > 0) {
418
+ const { value, at } = stack.pop();
419
+ if (!isObject(value) || seen.has(value)) continue;
420
+ seen.add(value);
421
+ if (Array.isArray(value)) {
422
+ for (let i = value.length - 1; i >= 0; i--) stack.push({ value: value[i], at: `${at}/${i}` });
423
+ continue;
424
+ }
425
+ if (value.revision !== void 0) found.push(`${at}/revision`);
426
+ const keys = Object.keys(value).filter((k) => k !== "revision" && !(k === "option" && value.type === "chart"));
427
+ for (let i = keys.length - 1; i >= 0; i--) stack.push({ value: value[keys[i]], at: `${at}/${escape(keys[i])}` });
428
+ }
429
+ return found;
430
+ }
431
+ function hasRevisions(doc) {
432
+ return revisionPaths(doc).length > 0;
433
+ }
434
+
276
435
  // src/style.ts
277
436
  var pt = (n) => `${Math.round(n * 1e3) / 1e3}pt`;
278
437
  var px = (n) => `${Math.round(n * 1e3) / 1e3}px`;
@@ -447,6 +606,7 @@ function WithContext({ value, children }) {
447
606
  }
448
607
  function RunView({ run }) {
449
608
  const ctx = useContext(RenderCtx);
609
+ if (isDeletedRun(run)) return null;
450
610
  const mark = ctx.marks.get(run);
451
611
  let text = typeof run.text === "string" ? run.text : "";
452
612
  if (ctx.fields) text = substituteFields(text, ctx.fields);
@@ -490,7 +650,9 @@ function RunView({ run }) {
490
650
  }
491
651
  function Runs({ runs }) {
492
652
  const list = Array.isArray(runs) ? runs : [];
493
- const visible = list.some((r) => typeof r?.text === "string" && r.text !== "" || r?.footnote);
653
+ const visible = list.some(
654
+ (r) => !!r && typeof r === "object" && !isDeletedRun(r) && (typeof r.text === "string" && r.text !== "" || !!r.footnote)
655
+ );
494
656
  return /* @__PURE__ */ jsxs(Fragment, { children: [
495
657
  list.map((run, i) => run && typeof run === "object" ? /* @__PURE__ */ jsx(RunView, { run }, i) : null),
496
658
  !visible && ZWSP
@@ -533,7 +695,7 @@ function BlockView({ block }) {
533
695
  case "image":
534
696
  return /* @__PURE__ */ jsx(ImageView, { block });
535
697
  case "chart":
536
- return /* @__PURE__ */ jsx(ChartPlaceholder, { block });
698
+ return /* @__PURE__ */ jsx(ChartView, { block });
537
699
  case "hr":
538
700
  return /* @__PURE__ */ jsx("div", { "data-lw-kind": "hr", style: { display: "flow-root", paddingBottom: pt(ctx.spaceAfter) }, children: /* @__PURE__ */ jsx("div", { style: { height: pt(ctx.size * SINGLE_LINE), display: "flex", alignItems: "flex-end" }, children: /* @__PURE__ */ jsx(Separator, { className: "w-full" }) }) });
539
701
  case "pageBreak":
@@ -585,7 +747,7 @@ function ImageView({ block }) {
585
747
  }
586
748
  ) });
587
749
  }
588
- function ChartPlaceholder({ block }) {
750
+ function ChartView({ block }) {
589
751
  const ctx = useContext(RenderCtx);
590
752
  const maxPx = ctx.contentWidth * PX_PER_PT;
591
753
  const width = Math.min(
@@ -593,26 +755,7 @@ function ChartPlaceholder({ block }) {
593
755
  num(block.widthPx, typeof block.width === "number" && block.width > 0 ? maxPx * Math.min(100, block.width) / 100 : maxPx)
594
756
  );
595
757
  const height2 = num(block.heightPx, width * 0.6);
596
- const option = block.option ?? {};
597
- const title = typeof option.title === "string" ? option.title : option.title && typeof option.title.text === "string" ? option.title.text : typeof block.alt === "string" ? block.alt : "";
598
- return /* @__PURE__ */ jsx("div", { "data-lw-kind": "chart", style: { display: "flow-root", paddingBottom: pt(ctx.spaceAfter) }, children: /* @__PURE__ */ jsx(
599
- "div",
600
- {
601
- "data-lw-chart-placeholder": "",
602
- style: {
603
- width,
604
- height: height2,
605
- border: "0.75pt dashed #9CA3AF",
606
- color: "#6B7280",
607
- fontSize: pt(9),
608
- display: "flex",
609
- alignItems: "center",
610
- justifyContent: "center",
611
- boxSizing: "border-box"
612
- },
613
- children: title ? `Chart: ${title}` : "Chart"
614
- }
615
- ) });
758
+ return /* @__PURE__ */ jsx("div", { "data-lw-kind": "chart", style: { display: "flow-root", paddingBottom: pt(ctx.spaceAfter) }, children: /* @__PURE__ */ jsx(ChartBox, { block, width, height: height2, measuring: ctx.measuring, renderChart: ctx.renderChart }) });
616
759
  }
617
760
  var DEFAULT_TABLE_BORDER = { style: "single", width: 0.5 };
618
761
  var DEFAULT_CELL_PADDING = { top: 3, right: 5.4, bottom: 3, left: 5.4 };
@@ -797,7 +940,7 @@ function numberFootnotes(doc) {
797
940
  if (!Array.isArray(list)) return;
798
941
  for (const run of list) {
799
942
  const fn = run?.footnote;
800
- if (fn && typeof fn === "object" && Array.isArray(fn.blocks)) {
943
+ if (fn && !isDeletedRun(run) && typeof fn === "object" && Array.isArray(fn.blocks)) {
801
944
  const id = notes.length + 1;
802
945
  marks.set(run, id);
803
946
  notes.push({ id, footnote: fn });
@@ -838,9 +981,9 @@ function numberFootnotes(doc) {
838
981
  }
839
982
 
840
983
  // src/stretches.ts
841
- var isObject = (v) => !!v && typeof v === "object" && !Array.isArray(v);
984
+ var isObject2 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
842
985
  function isPageObject(page) {
843
- return isObject(page) || Array.isArray(page) && page.length === 0;
986
+ return isObject2(page) || Array.isArray(page) && page.length === 0;
844
987
  }
845
988
  function mergePage(page, change) {
846
989
  const out = { ...page ?? {} };
@@ -848,7 +991,7 @@ function mergePage(page, change) {
848
991
  delete out.firstFooter;
849
992
  for (const [key, value] of Object.entries(change)) {
850
993
  if (value === void 0 || value === null || key === "background") continue;
851
- if (key === "margins" && isObject(value) && isObject(out.margins)) {
994
+ if (key === "margins" && isObject2(value) && isObject2(out.margins)) {
852
995
  const merged = { ...out.margins };
853
996
  for (const [side, v] of Object.entries(value)) {
854
997
  if (v !== void 0 && v !== null) merged[side] = v;
@@ -870,8 +1013,8 @@ function docStretches(doc) {
870
1013
  const out = [make(null)];
871
1014
  (Array.isArray(doc?.blocks) ? doc.blocks : []).forEach((block, i) => {
872
1015
  const b = block;
873
- if (!isObject(b) || b.type !== "pageBreak" || !isPageObject(b.page)) return;
874
- page = mergePage(page, isObject(b.page) ? b.page : {});
1016
+ if (!isObject2(b) || b.type !== "pageBreak" || !isPageObject(b.page)) return;
1017
+ page = mergePage(page, isObject2(b.page) ? b.page : {});
875
1018
  out.push(make(i));
876
1019
  });
877
1020
  return out;
@@ -921,17 +1064,17 @@ function packInput(stretches, measured) {
921
1064
  // src/layout-notice.ts
922
1065
  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.";
923
1066
  var NEAR_MISS_KEYS = ["size", "orientation", "margins", "header", "footer", "firstHeader", "firstFooter", "evenHeader", "evenFooter", "background", "border"];
924
- var isObject2 = (v) => typeof v === "object" && v !== null;
1067
+ var isObject3 = (v) => typeof v === "object" && v !== null;
925
1068
  function unshownLayout(doc) {
926
1069
  const found = [];
927
- if (!isObject2(doc)) return found;
1070
+ if (!isObject3(doc)) return found;
928
1071
  if (doc.sections !== void 0) found.push("/sections");
929
1072
  const stack = [{ blocks: doc.blocks, at: "/blocks" }];
930
1073
  while (stack.length > 0) {
931
1074
  const { blocks, at } = stack.pop();
932
1075
  if (!Array.isArray(blocks)) continue;
933
1076
  blocks.forEach((block, i) => {
934
- if (!isObject2(block)) return;
1077
+ if (!isObject3(block)) return;
935
1078
  const path = `${at}/${i}`;
936
1079
  if (block.type === "pageBreak") {
937
1080
  for (const key of NEAR_MISS_KEYS) {
@@ -939,15 +1082,15 @@ function unshownLayout(doc) {
939
1082
  }
940
1083
  if (block.page !== void 0) {
941
1084
  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`);
1085
+ else if (isObject3(block.page) && block.page.background !== void 0) found.push(`${path}/page/background`);
943
1086
  }
944
1087
  } else if (block.type === "quote") {
945
1088
  stack.push({ blocks: block.blocks, at: `${path}/blocks` });
946
1089
  } else if (block.type === "table" && Array.isArray(block.rows)) {
947
1090
  block.rows.forEach((row, r) => {
948
- if (!isObject2(row) || !Array.isArray(row.cells)) return;
1091
+ if (!isObject3(row) || !Array.isArray(row.cells)) return;
949
1092
  row.cells.forEach((cell, c) => {
950
- if (isObject2(cell)) stack.push({ blocks: cell.blocks, at: `${path}/rows/${r}/cells/${c}/blocks` });
1093
+ if (isObject3(cell)) stack.push({ blocks: cell.blocks, at: `${path}/rows/${r}/cells/${c}/blocks` });
951
1094
  });
952
1095
  });
953
1096
  }
@@ -1381,6 +1524,7 @@ function DocViewer({
1381
1524
  now,
1382
1525
  onLayout,
1383
1526
  injectStyles = true,
1527
+ renderChart,
1384
1528
  id,
1385
1529
  className,
1386
1530
  style
@@ -1424,9 +1568,10 @@ function DocViewer({
1424
1568
  marks: numbering.marks,
1425
1569
  size: num(doc?.defaultSize, DEFAULT_SIZE),
1426
1570
  spaceAfter: DEFAULT_SPACE_AFTER,
1427
- contentWidth: geometry.contentWidth
1571
+ contentWidth: geometry.contentWidth,
1572
+ ...renderChart ? { renderChart } : {}
1428
1573
  }),
1429
- [numbering, doc, geometry]
1574
+ [numbering, doc, geometry, renderChart]
1430
1575
  );
1431
1576
  const ctxOf = (k) => ({ ...ctx, contentWidth: stretches[k].geometry.contentWidth });
1432
1577
  useEffect(() => {
@@ -1473,6 +1618,7 @@ function DocViewer({
1473
1618
  const pageWpx = Math.max(...stretches.map((s) => s.geometry.width)) * PX_PER_PT;
1474
1619
  const scale = typeof fixedScale === "number" && fixedScale > 0 ? fixedScale : fit === "none" || !width ? 1 : Math.min(maxScale, width / pageWpx);
1475
1620
  const notShown = useMemo(() => unshownLayout(doc), [doc]);
1621
+ const revisions = useMemo(() => revisionPaths(doc), [doc]);
1476
1622
  const pageCount = layout?.pages.length ?? 0;
1477
1623
  useEffect(() => {
1478
1624
  if (layout && font !== "pending") {
@@ -1483,10 +1629,11 @@ function DocViewer({
1483
1629
  ...stretches.length > 1 ? { pageSizes: layout.pages.map((p) => ({ width: stretches[p.stretch ?? 0].geometry.width, height: stretches[p.stretch ?? 0].geometry.height })) } : {},
1484
1630
  scale,
1485
1631
  font,
1486
- ...notShown.length > 0 ? { notShown } : {}
1632
+ ...notShown.length > 0 ? { notShown } : {},
1633
+ ...revisions.length > 0 ? { revisions } : {}
1487
1634
  });
1488
1635
  }
1489
- }, [layout, geometry, stretches, scale, onLayout, font, notShown]);
1636
+ }, [layout, geometry, stretches, scale, onLayout, font, notShown, revisions]);
1490
1637
  const typography2 = typography(doc?.defaultFont, ctx.size);
1491
1638
  const ready = layout !== null && font !== "pending";
1492
1639
  return /* @__PURE__ */ jsxs(
@@ -1497,12 +1644,15 @@ function DocViewer({
1497
1644
  "data-lw-viewer": "",
1498
1645
  "data-lw-pages": ready && pageCount || void 0,
1499
1646
  "data-lw-font": ready ? font : void 0,
1647
+ "data-lw-tracked-changes": revisions.length > 0 ? "" : void 0,
1648
+ "aria-busy": ready ? void 0 : true,
1500
1649
  className,
1501
1650
  style: { position: "relative", ...style },
1502
1651
  children: [
1503
1652
  injectStyles && /* @__PURE__ */ jsx("style", { href: "particle-academy-last-word-ui", precedence: "default", children: VIEWER_CSS }),
1504
1653
  injectStyles && FONT_CSS && /* @__PURE__ */ jsx("style", { href: "particle-academy-last-word-ui-fonts", precedence: "default", children: FONT_CSS }),
1505
1654
  notShown.length > 0 && /* @__PURE__ */ jsx("div", { "data-lw-layout-notice": "", style: { marginBottom: gap }, children: /* @__PURE__ */ jsx(Callout, { color: "amber", children: LAYOUT_NOTICE }) }),
1655
+ revisions.length > 0 && /* @__PURE__ */ jsx("div", { "data-lw-tracked-changes-notice": "", "data-lw-revisions": revisions.length, style: { marginBottom: gap }, children: /* @__PURE__ */ jsx(Callout, { color: "amber", children: TRACKED_CHANGES_NOTICE }) }),
1506
1656
  /* @__PURE__ */ jsx(
1507
1657
  "div",
1508
1658
  {
@@ -1526,7 +1676,7 @@ function DocViewer({
1526
1676
  if (!hasBand(band)) return null;
1527
1677
  const n = slot === "even" ? 2 : 1;
1528
1678
  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);
1679
+ 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), measuring: true, fields: { ...docFields, section: k + 1, page: n, pages: n } }, children: /* @__PURE__ */ jsx(BandView, { band }) }) }, at);
1530
1680
  })
1531
1681
  )
1532
1682
  ),
@@ -1537,19 +1687,31 @@ function DocViewer({
1537
1687
  {
1538
1688
  "data-lw-measure-block": i,
1539
1689
  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 }) })
1690
+ children: /* @__PURE__ */ jsx(RenderCtx.Provider, { value: { ...ctxOf(k), measuring: true }, children: /* @__PURE__ */ jsx(BlockView, { block: b }) })
1541
1691
  },
1542
1692
  i
1543
1693
  );
1544
1694
  }),
1545
1695
  numbering.notes.map((n) => {
1546
1696
  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);
1697
+ 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), measuring: true }, children: /* @__PURE__ */ jsx(FootnoteView, { id: n.id, footnote: n.footnote }) }) }, n.id);
1548
1698
  }),
1549
1699
  numbering.notes.length > 0 && /* @__PURE__ */ jsx("div", { "data-lw-measure-separator": "", children: /* @__PURE__ */ jsx(FootnoteSeparator, { height: pt(FOOTNOTE_SEPARATOR_PT) }) })
1550
1700
  ] })
1551
1701
  }
1552
1702
  ),
1703
+ !ready && /* @__PURE__ */ jsx(
1704
+ "div",
1705
+ {
1706
+ "data-lw-pending": "",
1707
+ style: {
1708
+ width: px(stretches[0].geometry.width * PX_PER_PT * scale),
1709
+ maxWidth: "100%",
1710
+ height: px(stretches[0].geometry.height * PX_PER_PT * scale),
1711
+ margin: "0 auto"
1712
+ }
1713
+ }
1714
+ ),
1553
1715
  ready && layout && /* @__PURE__ */ jsx("div", { "data-lw-page-stack": "", style: { display: "flex", flexDirection: "column", alignItems: "center", gap }, children: layout.pages.map((p) => {
1554
1716
  const k = p.stretch ?? 0;
1555
1717
  const inStretch = layout.pages.filter((x) => (x.stretch ?? 0) === k);
@@ -1706,6 +1868,6 @@ function docFromReader(output) {
1706
1868
  return value;
1707
1869
  }
1708
1870
 
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 };
1871
+ export { CARLITO_FACES, CARLITO_FAMILY, DocViewer, FONT_LOAD_TIMEOUT_MS, LAYOUT_NOTICE, OFFICE_PALETTE, PAGE_BAND_DISTANCE_DEFAULT, PAGE_MARGIN_DEFAULT, PAGE_SIZES_PT, PX_PER_PT, TRACKED_CHANGES_NOTICE, bandSlot, blockStretches, bodyBox, carlitoFaces, docFromReader, docStretches, fontFaceCss, formatDatePicture, hasRevisions, isDeletedRun, numberFootnotes, packInput, pageBand, pageBodyBoxes, pageCapacity, pageChartOption, pageClass, pageClassIn, pageGeometry, pageMargins, paginate, resolveNow, revisionPaths, substituteFields, unshownLayout };
1710
1872
  //# sourceMappingURL=index.js.map
1711
1873
  //# sourceMappingURL=index.js.map