@particle-academy/last-word-ui 0.3.0 → 0.4.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 +20 -0
- package/dist/index.cjs +47 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -2
- package/dist/index.d.ts +23 -2
- package/dist/index.js +47 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
10
10
|
|
|
11
11
|
## [Unreleased]
|
|
12
12
|
|
|
13
|
+
## [0.4.0] - 2026-11-03
|
|
14
|
+
|
|
15
|
+
**What you must do: nothing.** A document with one page setup draws exactly as
|
|
16
|
+
before, with no new element and no new `onLayout` key. Under Tailwind, your build
|
|
17
|
+
needs react-fancy's classes as it already does.
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- **A visible notice when a document asks for mixed page layout** (mixed page
|
|
22
|
+
orientation, stage 1). `pageBreak.page`, page keys written straight on a break
|
|
23
|
+
(`pageBreak.orientation`, `.margins`, ...) and a top-level `sections` were silently
|
|
24
|
+
ignored, so a landscape section drew as portrait with nothing said. The document
|
|
25
|
+
still draws, one page setup as before, under a react-fancy `Callout`
|
|
26
|
+
(`data-lw-layout-notice`) in light and dark. `onLayout` gains `notShown`, JSON
|
|
27
|
+
Pointers to what it ignored, present only when there is something to report. New
|
|
28
|
+
exports: `LAYOUT_NOTICE`, `unshownLayout(doc)`. Per-page geometry comes in a later
|
|
29
|
+
release; **consumer action:** none. Those near-miss keys and `sections` do not
|
|
30
|
+
exist: `pageBreak.page` is the form, and `last-word` refuses all of them on write
|
|
31
|
+
until it can honour the first.
|
|
32
|
+
|
|
13
33
|
## [0.3.0] - 2026-11-01
|
|
14
34
|
|
|
15
35
|
**What you must do: probably nothing, but expect page breaks to move.** Calibri
|
package/dist/index.cjs
CHANGED
|
@@ -827,6 +827,40 @@ function numberFootnotes(doc) {
|
|
|
827
827
|
return { marks, notes };
|
|
828
828
|
}
|
|
829
829
|
|
|
830
|
+
// src/layout-notice.ts
|
|
831
|
+
var LAYOUT_NOTICE = "Mixed page orientation isn't shown yet. This document asks for different page settings partway through; every page here uses the document's one page setup.";
|
|
832
|
+
var NEAR_MISS_KEYS = ["size", "orientation", "margins", "header", "footer", "firstHeader", "firstFooter", "evenHeader", "evenFooter", "background", "border"];
|
|
833
|
+
var isObject = (v) => typeof v === "object" && v !== null;
|
|
834
|
+
function unshownLayout(doc) {
|
|
835
|
+
const found = [];
|
|
836
|
+
if (!isObject(doc)) return found;
|
|
837
|
+
if (doc.sections !== void 0) found.push("/sections");
|
|
838
|
+
const stack = [{ blocks: doc.blocks, at: "/blocks" }];
|
|
839
|
+
while (stack.length > 0) {
|
|
840
|
+
const { blocks, at } = stack.pop();
|
|
841
|
+
if (!Array.isArray(blocks)) continue;
|
|
842
|
+
blocks.forEach((block, i) => {
|
|
843
|
+
if (!isObject(block)) return;
|
|
844
|
+
const path = `${at}/${i}`;
|
|
845
|
+
if (block.type === "pageBreak") {
|
|
846
|
+
for (const key of ["page", ...NEAR_MISS_KEYS]) {
|
|
847
|
+
if (block[key] !== void 0) found.push(`${path}/${key}`);
|
|
848
|
+
}
|
|
849
|
+
} else if (block.type === "quote") {
|
|
850
|
+
stack.push({ blocks: block.blocks, at: `${path}/blocks` });
|
|
851
|
+
} else if (block.type === "table" && Array.isArray(block.rows)) {
|
|
852
|
+
block.rows.forEach((row, r) => {
|
|
853
|
+
if (!isObject(row) || !Array.isArray(row.cells)) return;
|
|
854
|
+
row.cells.forEach((cell, c) => {
|
|
855
|
+
if (isObject(cell)) stack.push({ blocks: cell.blocks, at: `${path}/rows/${r}/cells/${c}/blocks` });
|
|
856
|
+
});
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
return found;
|
|
862
|
+
}
|
|
863
|
+
|
|
830
864
|
// src/measure.ts
|
|
831
865
|
var SPLITTABLE = /* @__PURE__ */ new Set(["paragraph", "heading", "list", "quote", "code"]);
|
|
832
866
|
var blockId = (index) => `b${index}`;
|
|
@@ -1326,12 +1360,20 @@ function DocViewer({
|
|
|
1326
1360
|
}, []);
|
|
1327
1361
|
const pageWpx = geometry.width * PX_PER_PT;
|
|
1328
1362
|
const scale = typeof fixedScale === "number" && fixedScale > 0 ? fixedScale : fit === "none" || !width ? 1 : Math.min(maxScale, width / pageWpx);
|
|
1363
|
+
const notShown = react.useMemo(() => unshownLayout(doc), [doc]);
|
|
1329
1364
|
const pageCount = layout?.pages.length ?? 0;
|
|
1330
1365
|
react.useEffect(() => {
|
|
1331
1366
|
if (layout && font !== "pending") {
|
|
1332
|
-
onLayout?.({
|
|
1367
|
+
onLayout?.({
|
|
1368
|
+
pages: layout.pages.length,
|
|
1369
|
+
pageWidth: geometry.width,
|
|
1370
|
+
pageHeight: geometry.height,
|
|
1371
|
+
scale,
|
|
1372
|
+
font,
|
|
1373
|
+
...notShown.length > 0 ? { notShown } : {}
|
|
1374
|
+
});
|
|
1333
1375
|
}
|
|
1334
|
-
}, [layout, geometry, scale, onLayout, font]);
|
|
1376
|
+
}, [layout, geometry, scale, onLayout, font, notShown]);
|
|
1335
1377
|
const typography2 = typography(doc?.defaultFont, ctx.size);
|
|
1336
1378
|
const ready = layout !== null && font !== "pending";
|
|
1337
1379
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -1347,6 +1389,7 @@ function DocViewer({
|
|
|
1347
1389
|
children: [
|
|
1348
1390
|
injectStyles && /* @__PURE__ */ jsxRuntime.jsx("style", { href: "particle-academy-last-word-ui", precedence: "default", children: VIEWER_CSS }),
|
|
1349
1391
|
injectStyles && FONT_CSS && /* @__PURE__ */ jsxRuntime.jsx("style", { href: "particle-academy-last-word-ui-fonts", precedence: "default", children: FONT_CSS }),
|
|
1392
|
+
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 }) }),
|
|
1350
1393
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1351
1394
|
"div",
|
|
1352
1395
|
{
|
|
@@ -1529,6 +1572,7 @@ exports.CARLITO_FACES = CARLITO_FACES;
|
|
|
1529
1572
|
exports.CARLITO_FAMILY = CARLITO_FAMILY;
|
|
1530
1573
|
exports.DocViewer = DocViewer;
|
|
1531
1574
|
exports.FONT_LOAD_TIMEOUT_MS = FONT_LOAD_TIMEOUT_MS;
|
|
1575
|
+
exports.LAYOUT_NOTICE = LAYOUT_NOTICE;
|
|
1532
1576
|
exports.PAGE_BAND_DISTANCE_DEFAULT = PAGE_BAND_DISTANCE_DEFAULT;
|
|
1533
1577
|
exports.PAGE_MARGIN_DEFAULT = PAGE_MARGIN_DEFAULT;
|
|
1534
1578
|
exports.PAGE_SIZES_PT = PAGE_SIZES_PT;
|
|
@@ -1549,5 +1593,6 @@ exports.pageMargins = pageMargins;
|
|
|
1549
1593
|
exports.paginate = paginate;
|
|
1550
1594
|
exports.resolveNow = resolveNow;
|
|
1551
1595
|
exports.substituteFields = substituteFields;
|
|
1596
|
+
exports.unshownLayout = unshownLayout;
|
|
1552
1597
|
//# sourceMappingURL=index.cjs.map
|
|
1553
1598
|
//# sourceMappingURL=index.cjs.map
|