@beyondwork/docx-react-component 1.0.102 → 1.0.103
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/package.json +1 -1
- package/src/core/commands/formatting-commands.ts +8 -7
- package/src/core/commands/paragraph-layout-commands.ts +11 -10
- package/src/core/commands/section-layout-commands.ts +7 -6
- package/src/core/commands/style-commands.ts +3 -2
- package/src/io/normalize/normalize-text.ts +6 -5
- package/src/io/ooxml/parse-anchor.ts +15 -15
- package/src/io/ooxml/parse-drawing.ts +5 -5
- package/src/io/ooxml/parse-fields.ts +16 -15
- package/src/io/ooxml/parse-font-table.ts +2 -1
- package/src/io/ooxml/parse-footnotes.ts +3 -2
- package/src/io/ooxml/parse-headers-footers.ts +7 -6
- package/src/io/ooxml/parse-main-document.ts +41 -40
- package/src/io/ooxml/parse-numbering.ts +3 -2
- package/src/io/ooxml/parse-object.ts +6 -6
- package/src/io/ooxml/parse-paragraph-formatting.ts +12 -11
- package/src/io/ooxml/parse-picture.ts +16 -16
- package/src/io/ooxml/parse-run-formatting.ts +11 -10
- package/src/io/ooxml/parse-settings.ts +2 -1
- package/src/io/ooxml/parse-shapes.ts +18 -17
- package/src/io/ooxml/parse-styles.ts +16 -16
- package/src/io/ooxml/parse-theme.ts +5 -4
- package/src/model/canonical-document.ts +835 -833
- package/src/runtime/formatting/document-lookup.ts +3 -2
- package/src/runtime/formatting/formatting-context.ts +66 -25
- package/src/runtime/formatting/index.ts +18 -0
- package/src/runtime/formatting/layout-inputs.ts +256 -0
- package/src/runtime/formatting/numbering/geometry.ts +13 -12
- package/src/runtime/formatting/style-cascade.ts +2 -1
- package/src/runtime/formatting/table-style-resolver.ts +8 -7
- package/src/runtime/surface-projection.ts +31 -36
- package/src/session/import/normalize.ts +2 -1
- package/src/session/import/source-package-evidence.ts +612 -1
|
@@ -23,6 +23,7 @@ import type {
|
|
|
23
23
|
TableStyleDefinition,
|
|
24
24
|
TableStyleFormatting,
|
|
25
25
|
TableWidth,
|
|
26
|
+
Mutable,
|
|
26
27
|
} from "../../model/canonical-document.ts";
|
|
27
28
|
import {
|
|
28
29
|
readCellBorders,
|
|
@@ -372,8 +373,8 @@ function resolveStyleLinkReciprocals(
|
|
|
372
373
|
);
|
|
373
374
|
continue;
|
|
374
375
|
}
|
|
375
|
-
if (partner.linkedStyleId === undefined) {
|
|
376
|
-
partner.linkedStyleId = style.styleId;
|
|
376
|
+
if ((partner as Mutable<typeof partner>).linkedStyleId === undefined) {
|
|
377
|
+
(partner as Mutable<typeof partner>).linkedStyleId = style.styleId;
|
|
377
378
|
} else if (partner.linkedStyleId !== style.styleId) {
|
|
378
379
|
diagnostics.push(
|
|
379
380
|
`style ${label} "${style.styleId}" links to "${target}" but partner already links to "${partner.linkedStyleId}"; partner link retained`,
|
|
@@ -439,7 +440,7 @@ function readTableStyleFormatting(styleNode: XmlElementNode): TableStyleFormatti
|
|
|
439
440
|
const cellProperties = findChildElementOptional(styleNode, "tcPr");
|
|
440
441
|
const pPrNode = findChildElementOptional(styleNode, "pPr");
|
|
441
442
|
const rPrNode = findChildElementOptional(styleNode, "rPr");
|
|
442
|
-
const formatting: TableStyleFormatting = {};
|
|
443
|
+
const formatting: Mutable<TableStyleFormatting> = {};
|
|
443
444
|
|
|
444
445
|
const paragraphProperties = readParagraphProperties(pPrNode);
|
|
445
446
|
if (paragraphProperties) formatting.paragraphProperties = paragraphProperties;
|
|
@@ -454,11 +455,11 @@ function readTableStyleFormatting(styleNode: XmlElementNode): TableStyleFormatti
|
|
|
454
455
|
const cellMargins = readTableCellMargins(tableProperties);
|
|
455
456
|
const tblLook = readTableLook(tableProperties);
|
|
456
457
|
|
|
457
|
-
if (width) table.width = width as TableWidth;
|
|
458
|
-
if (alignment) table.alignment = alignment;
|
|
459
|
-
if (borders) table.borders = borders as TableBorders;
|
|
460
|
-
if (cellMargins) table.cellMargins = cellMargins as TableCellMargins;
|
|
461
|
-
if (tblLook) table.tblLook = tblLook as TableLook;
|
|
458
|
+
if (width) (table as Mutable<typeof table>).width = width as TableWidth;
|
|
459
|
+
if (alignment) (table as Mutable<typeof table>).alignment = alignment;
|
|
460
|
+
if (borders) (table as Mutable<typeof table>).borders = borders as TableBorders;
|
|
461
|
+
if (cellMargins) (table as Mutable<typeof table>).cellMargins = cellMargins as TableCellMargins;
|
|
462
|
+
if (tblLook) (table as Mutable<typeof table>).tblLook = tblLook as TableLook;
|
|
462
463
|
|
|
463
464
|
if (Object.keys(table).length > 0) {
|
|
464
465
|
formatting.table = table;
|
|
@@ -471,9 +472,9 @@ function readTableStyleFormatting(styleNode: XmlElementNode): TableStyleFormatti
|
|
|
471
472
|
const heightRule = readRowHeightRule(rowProperties);
|
|
472
473
|
const isHeader = readRowIsHeader(rowProperties);
|
|
473
474
|
|
|
474
|
-
if (height !== undefined) row.height = height;
|
|
475
|
-
if (heightRule) row.heightRule = heightRule;
|
|
476
|
-
if (isHeader !== undefined) row.isHeader = isHeader;
|
|
475
|
+
if (height !== undefined) (row as Mutable<typeof row>).height = height;
|
|
476
|
+
if (heightRule) (row as Mutable<typeof row>).heightRule = heightRule;
|
|
477
|
+
if (isHeader !== undefined) (row as Mutable<typeof row>).isHeader = isHeader;
|
|
477
478
|
|
|
478
479
|
if (Object.keys(row).length > 0) {
|
|
479
480
|
formatting.row = row;
|
|
@@ -487,10 +488,10 @@ function readTableStyleFormatting(styleNode: XmlElementNode): TableStyleFormatti
|
|
|
487
488
|
const shading = readCellShading(cellProperties);
|
|
488
489
|
const verticalAlign = readCellVerticalAlign(cellProperties);
|
|
489
490
|
|
|
490
|
-
if (width) cell.width = width as TableWidth;
|
|
491
|
-
if (borders) cell.borders = borders as TableCellBorders;
|
|
492
|
-
if (shading) cell.shading = shading as CellShading;
|
|
493
|
-
if (verticalAlign) cell.verticalAlign = verticalAlign;
|
|
491
|
+
if (width) (cell as Mutable<typeof cell>).width = width as TableWidth;
|
|
492
|
+
if (borders) (cell as Mutable<typeof cell>).borders = borders as TableCellBorders;
|
|
493
|
+
if (shading) (cell as Mutable<typeof cell>).shading = shading as CellShading;
|
|
494
|
+
if (verticalAlign) (cell as Mutable<typeof cell>).verticalAlign = verticalAlign;
|
|
494
495
|
|
|
495
496
|
if (Object.keys(cell).length > 0) {
|
|
496
497
|
formatting.cell = cell;
|
|
@@ -590,4 +591,3 @@ function findChildElementOptional(
|
|
|
590
591
|
);
|
|
591
592
|
}
|
|
592
593
|
|
|
593
|
-
|
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
ResolvedTheme,
|
|
6
6
|
CanonicalTheme,
|
|
7
7
|
ClrSchemeMapping,
|
|
8
|
+
Mutable,
|
|
8
9
|
} from "../../model/canonical-document.ts";
|
|
9
10
|
import type { XmlElementNode } from "./xml-element.ts";
|
|
10
11
|
import { parseXml } from "./xml-parser.ts";
|
|
@@ -61,7 +62,7 @@ export function parseThemeXml(xml: string): ThemeDefinition {
|
|
|
61
62
|
findChildElementOptional(themeElements, "fontScheme"),
|
|
62
63
|
);
|
|
63
64
|
|
|
64
|
-
const result: ThemeDefinition = {};
|
|
65
|
+
const result: Mutable<ThemeDefinition> = {};
|
|
65
66
|
if (themeName) {
|
|
66
67
|
result.name = themeName;
|
|
67
68
|
}
|
|
@@ -79,7 +80,7 @@ export function parseThemeXml(xml: string): ThemeDefinition {
|
|
|
79
80
|
* Resolve a ThemeDefinition into flattened runtime theme inputs.
|
|
80
81
|
* Maps OOXML theme slot names to CSS-usable color values and font families.
|
|
81
82
|
*/
|
|
82
|
-
export function resolveTheme(theme: ThemeDefinition): ResolvedTheme {
|
|
83
|
+
export function resolveTheme(theme: Mutable<ThemeDefinition>): ResolvedTheme {
|
|
83
84
|
const colors: Record<string, string> = {};
|
|
84
85
|
|
|
85
86
|
if (theme.colorScheme?.colors) {
|
|
@@ -142,7 +143,7 @@ export const DEFAULT_CLR_SCHEME_MAPPING: ClrSchemeMapping = Object.freeze({
|
|
|
142
143
|
* CLAUDE.md §3.
|
|
143
144
|
*/
|
|
144
145
|
export function materializeCanonicalTheme(
|
|
145
|
-
theme: ThemeDefinition
|
|
146
|
+
theme: Mutable<ThemeDefinition>,
|
|
146
147
|
clrMap: ClrSchemeMapping,
|
|
147
148
|
): CanonicalTheme {
|
|
148
149
|
const clrScheme: ThemeColorScheme = theme.colorScheme ?? { name: "", colors: {} };
|
|
@@ -240,7 +241,7 @@ function parseFontScheme(
|
|
|
240
241
|
? extractFontTypeface(minorFontElement)
|
|
241
242
|
: undefined;
|
|
242
243
|
|
|
243
|
-
const result: ThemeFontScheme = { name: schemeName };
|
|
244
|
+
const result: Mutable<ThemeFontScheme> = { name: schemeName };
|
|
244
245
|
if (majorFont) {
|
|
245
246
|
result.majorFont = majorFont;
|
|
246
247
|
}
|