@beyondwork/docx-react-component 1.0.37 → 1.0.39
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 +41 -31
- package/src/api/public-types.ts +496 -1
- package/src/core/commands/section-layout-commands.ts +58 -0
- package/src/core/commands/table-grid.ts +431 -0
- package/src/core/commands/table-structure-commands.ts +845 -56
- package/src/core/commands/text-commands.ts +122 -2
- package/src/io/docx-session.ts +1 -0
- package/src/io/export/serialize-main-document.ts +2 -11
- package/src/io/export/serialize-numbering.ts +43 -10
- package/src/io/export/serialize-paragraph-formatting.ts +152 -0
- package/src/io/export/serialize-run-formatting.ts +90 -0
- package/src/io/export/serialize-styles.ts +212 -0
- package/src/io/export/serialize-tables.ts +74 -0
- package/src/io/export/table-properties-xml.ts +139 -4
- package/src/io/normalize/normalize-text.ts +15 -0
- package/src/io/ooxml/parse-fields.ts +10 -3
- package/src/io/ooxml/parse-footnotes.ts +60 -0
- package/src/io/ooxml/parse-headers-footers.ts +60 -0
- package/src/io/ooxml/parse-main-document.ts +137 -0
- package/src/io/ooxml/parse-numbering.ts +41 -1
- package/src/io/ooxml/parse-paragraph-formatting.ts +188 -0
- package/src/io/ooxml/parse-run-formatting.ts +129 -0
- package/src/io/ooxml/parse-styles.ts +31 -0
- package/src/io/ooxml/parse-tables.ts +249 -0
- package/src/io/ooxml/xml-attr-helpers.ts +60 -0
- package/src/io/ooxml/xml-element.ts +19 -0
- package/src/model/canonical-document.ts +117 -3
- package/src/runtime/collab/event-types.ts +165 -0
- package/src/runtime/collab/index.ts +22 -0
- package/src/runtime/collab/remote-cursor-awareness.ts +93 -0
- package/src/runtime/collab/runtime-collab-sync.ts +273 -0
- package/src/runtime/document-layout.ts +4 -2
- package/src/runtime/document-navigation.ts +1 -1
- package/src/runtime/document-runtime.ts +248 -18
- package/src/runtime/layout/default-page-format.ts +96 -0
- package/src/runtime/layout/index.ts +47 -0
- package/src/runtime/layout/inert-layout-facet.ts +16 -0
- package/src/runtime/layout/layout-engine-instance.ts +100 -23
- package/src/runtime/layout/layout-invalidation.ts +14 -5
- package/src/runtime/layout/margin-preset-catalog.ts +178 -0
- package/src/runtime/layout/page-format-catalog.ts +233 -0
- package/src/runtime/layout/page-graph.ts +55 -0
- package/src/runtime/layout/paginate-paragraph-lines.ts +128 -0
- package/src/runtime/layout/paginated-layout-engine.ts +484 -37
- package/src/runtime/layout/project-block-fragments.ts +225 -0
- package/src/runtime/layout/public-facet.ts +748 -16
- package/src/runtime/layout/resolve-page-fields.ts +70 -0
- package/src/runtime/layout/resolve-page-previews.ts +185 -0
- package/src/runtime/layout/resolved-formatting-state.ts +30 -26
- package/src/runtime/layout/table-render-plan.ts +249 -0
- package/src/runtime/numbering-prefix.ts +5 -0
- package/src/runtime/paragraph-style-resolver.ts +194 -0
- package/src/runtime/render/block-fragment-projection.ts +35 -0
- package/src/runtime/render/decoration-resolver.ts +189 -0
- package/src/runtime/render/index.ts +57 -0
- package/src/runtime/render/pending-op-delta-reader.ts +129 -0
- package/src/runtime/render/render-frame-types.ts +317 -0
- package/src/runtime/render/render-kernel.ts +759 -0
- package/src/runtime/resolved-numbering-geometry.ts +9 -1
- package/src/runtime/surface-projection.ts +129 -9
- package/src/runtime/table-schema.ts +11 -0
- package/src/runtime/view-state.ts +67 -0
- package/src/runtime/workflow-markup.ts +1 -5
- package/src/runtime/workflow-rail-segments.ts +280 -0
- package/src/ui/WordReviewEditor.tsx +368 -19
- package/src/ui/editor-command-bag.ts +4 -0
- package/src/ui/editor-runtime-boundary.ts +16 -0
- package/src/ui/editor-shell-view.tsx +10 -0
- package/src/ui/editor-surface-controller.tsx +9 -1
- package/src/ui/headless/chrome-registry.ts +310 -15
- package/src/ui/headless/scoped-chrome-policy.ts +49 -1
- package/src/ui/headless/selection-tool-types.ts +10 -0
- package/src/ui-tailwind/chrome/chrome-preset-model.ts +23 -2
- package/src/ui-tailwind/chrome/review-queue-bar.tsx +2 -14
- package/src/ui-tailwind/chrome/role-action-sets.ts +80 -0
- package/src/ui-tailwind/chrome/tw-detach-handle.tsx +147 -0
- package/src/ui-tailwind/chrome/tw-selection-anchor-resolver.ts +160 -0
- package/src/ui-tailwind/chrome/tw-selection-tool-host.tsx +68 -92
- package/src/ui-tailwind/chrome/tw-selection-tool-placement.ts +149 -0
- package/src/ui-tailwind/chrome/tw-selection-tool-structure.tsx +11 -0
- package/src/ui-tailwind/chrome/tw-selection-toolbar.tsx +15 -4
- package/src/ui-tailwind/chrome/tw-table-border-picker.tsx +245 -0
- package/src/ui-tailwind/chrome/tw-table-context-toolbar.tsx +356 -140
- package/src/ui-tailwind/chrome/tw-table-grip-layer.tsx +284 -0
- package/src/ui-tailwind/chrome-overlay/chrome-overlay-projector.ts +94 -0
- package/src/ui-tailwind/chrome-overlay/index.ts +16 -0
- package/src/ui-tailwind/chrome-overlay/tw-chrome-overlay.tsx +96 -0
- package/src/ui-tailwind/chrome-overlay/tw-scope-rail-layer.tsx +178 -0
- package/src/ui-tailwind/editor-surface/fast-text-edit-lane.ts +4 -0
- package/src/ui-tailwind/editor-surface/local-edit-session-state.ts +11 -0
- package/src/ui-tailwind/editor-surface/page-slice-util.ts +15 -0
- package/src/ui-tailwind/editor-surface/perf-probe.ts +7 -1
- package/src/ui-tailwind/editor-surface/pm-command-bridge.ts +40 -4
- package/src/ui-tailwind/editor-surface/pm-decorations.ts +22 -12
- package/src/ui-tailwind/editor-surface/pm-page-break-decorations.ts +389 -0
- package/src/ui-tailwind/editor-surface/pm-schema.ts +40 -2
- package/src/ui-tailwind/editor-surface/pm-state-from-snapshot.ts +144 -62
- package/src/ui-tailwind/editor-surface/remote-cursor-plugin.ts +179 -0
- package/src/ui-tailwind/editor-surface/tw-page-block-view.tsx +559 -0
- package/src/ui-tailwind/editor-surface/tw-prosemirror-surface.tsx +224 -75
- package/src/ui-tailwind/editor-surface/tw-table-bands.css +61 -0
- package/src/ui-tailwind/editor-surface/tw-table-node-view.tsx +19 -0
- package/src/ui-tailwind/index.ts +29 -0
- package/src/ui-tailwind/review/tw-comment-sidebar.tsx +2 -2
- package/src/ui-tailwind/review/tw-rail-card.tsx +150 -0
- package/src/ui-tailwind/review/tw-review-rail-footer.tsx +52 -0
- package/src/ui-tailwind/review/tw-review-rail.tsx +166 -11
- package/src/ui-tailwind/review/tw-workflow-tab.tsx +108 -0
- package/src/ui-tailwind/theme/editor-theme.css +498 -163
- package/src/ui-tailwind/toolbar/tw-role-action-region.tsx +680 -0
- package/src/ui-tailwind/toolbar/tw-scope-posture-menu.tsx +182 -0
- package/src/ui-tailwind/toolbar/tw-shell-header.tsx +162 -0
- package/src/ui-tailwind/toolbar/tw-toolbar.tsx +104 -2
- package/src/ui-tailwind/tw-review-workspace.tsx +234 -21
- package/src/runtime/collab-review-sync.ts +0 -254
- package/src/ui-tailwind/editor-surface/pm-collab-plugins.ts +0 -40
|
@@ -14,16 +14,31 @@ import type {
|
|
|
14
14
|
import { classifyFieldInstruction } from "./parse-fields.ts";
|
|
15
15
|
import {
|
|
16
16
|
readCellBorders,
|
|
17
|
+
readCellCnfStyle,
|
|
18
|
+
readCellFitText,
|
|
19
|
+
readCellMargins,
|
|
20
|
+
readCellNoWrap,
|
|
17
21
|
readCellShading,
|
|
22
|
+
readCellTextDirection,
|
|
18
23
|
readCellVerticalAlign,
|
|
19
24
|
readCellWidth,
|
|
20
25
|
readGridColumns as readSharedGridColumns,
|
|
26
|
+
readRowCantSplit,
|
|
27
|
+
readRowCnfStyle,
|
|
21
28
|
readRowHeight,
|
|
22
29
|
readRowHeightRule,
|
|
30
|
+
readRowHorizontalAlignment,
|
|
23
31
|
readRowIsHeader,
|
|
24
32
|
readTableAlignment,
|
|
33
|
+
readTableBidiVisual,
|
|
25
34
|
readTableBorders,
|
|
35
|
+
readTableCaption,
|
|
26
36
|
readTableCellMargins,
|
|
37
|
+
readTableCellSpacing,
|
|
38
|
+
readTableDescription,
|
|
39
|
+
readTableFloating,
|
|
40
|
+
readTableIndent,
|
|
41
|
+
readTableLayoutMode,
|
|
27
42
|
readTableLook,
|
|
28
43
|
readTableStyleId,
|
|
29
44
|
readTableWidth,
|
|
@@ -672,6 +687,13 @@ function parseSimpleTableElement(tblElement: XmlElementNode): TableNode {
|
|
|
672
687
|
let borders: TableNode["borders"];
|
|
673
688
|
let cellMargins: TableNode["cellMargins"];
|
|
674
689
|
let tblLook: TableNode["tblLook"];
|
|
690
|
+
let indent: TableNode["indent"];
|
|
691
|
+
let layoutMode: TableNode["layoutMode"];
|
|
692
|
+
let cellSpacing: TableNode["cellSpacing"];
|
|
693
|
+
let caption: TableNode["caption"];
|
|
694
|
+
let description: TableNode["description"];
|
|
695
|
+
let bidiVisual: TableNode["bidiVisual"];
|
|
696
|
+
let floating: TableNode["floating"];
|
|
675
697
|
|
|
676
698
|
for (const child of tblElement.children) {
|
|
677
699
|
if (child.type !== "element") continue;
|
|
@@ -685,6 +707,13 @@ function parseSimpleTableElement(tblElement: XmlElementNode): TableNode {
|
|
|
685
707
|
borders = readTableBorders(child);
|
|
686
708
|
cellMargins = readTableCellMargins(child);
|
|
687
709
|
tblLook = readTableLook(child);
|
|
710
|
+
indent = readTableIndent(child);
|
|
711
|
+
layoutMode = readTableLayoutMode(child);
|
|
712
|
+
cellSpacing = readTableCellSpacing(child);
|
|
713
|
+
caption = readTableCaption(child);
|
|
714
|
+
description = readTableDescription(child);
|
|
715
|
+
bidiVisual = readTableBidiVisual(child);
|
|
716
|
+
floating = readTableFloating(child);
|
|
688
717
|
} else if (name === "tblGrid") {
|
|
689
718
|
gridColumns = readGridColumns(child);
|
|
690
719
|
} else if (name === "tr") {
|
|
@@ -703,6 +732,13 @@ function parseSimpleTableElement(tblElement: XmlElementNode): TableNode {
|
|
|
703
732
|
...(borders ? { borders } : {}),
|
|
704
733
|
...(cellMargins ? { cellMargins } : {}),
|
|
705
734
|
...(tblLook ? { tblLook } : {}),
|
|
735
|
+
...(indent ? { indent } : {}),
|
|
736
|
+
...(layoutMode ? { layoutMode } : {}),
|
|
737
|
+
...(cellSpacing ? { cellSpacing } : {}),
|
|
738
|
+
...(caption !== undefined ? { caption } : {}),
|
|
739
|
+
...(description !== undefined ? { description } : {}),
|
|
740
|
+
...(bidiVisual !== undefined ? { bidiVisual } : {}),
|
|
741
|
+
...(floating ? { floating } : {}),
|
|
706
742
|
};
|
|
707
743
|
}
|
|
708
744
|
|
|
@@ -716,6 +752,9 @@ function parseSimpleTableRow(trElement: XmlElementNode): TableRowNode {
|
|
|
716
752
|
let height: TableRowNode["height"];
|
|
717
753
|
let heightRule: TableRowNode["heightRule"];
|
|
718
754
|
let isHeader: TableRowNode["isHeader"];
|
|
755
|
+
let cantSplit: TableRowNode["cantSplit"];
|
|
756
|
+
let horizontalAlignment: TableRowNode["horizontalAlignment"];
|
|
757
|
+
let cnfStyle: TableRowNode["cnfStyle"];
|
|
719
758
|
|
|
720
759
|
for (const child of trElement.children) {
|
|
721
760
|
if (child.type !== "element") continue;
|
|
@@ -726,6 +765,9 @@ function parseSimpleTableRow(trElement: XmlElementNode): TableRowNode {
|
|
|
726
765
|
height = readRowHeight(child);
|
|
727
766
|
heightRule = readRowHeightRule(child);
|
|
728
767
|
isHeader = readRowIsHeader(child);
|
|
768
|
+
cantSplit = readRowCantSplit(child);
|
|
769
|
+
horizontalAlignment = readRowHorizontalAlignment(child);
|
|
770
|
+
cnfStyle = readRowCnfStyle(child);
|
|
729
771
|
} else if (name === "tc") {
|
|
730
772
|
cells.push(parseSimpleTableCell(child));
|
|
731
773
|
}
|
|
@@ -737,6 +779,9 @@ function parseSimpleTableRow(trElement: XmlElementNode): TableRowNode {
|
|
|
737
779
|
...(height !== undefined ? { height } : {}),
|
|
738
780
|
...(heightRule ? { heightRule } : {}),
|
|
739
781
|
...(isHeader !== undefined ? { isHeader } : {}),
|
|
782
|
+
...(cantSplit !== undefined ? { cantSplit } : {}),
|
|
783
|
+
...(horizontalAlignment ? { horizontalAlignment } : {}),
|
|
784
|
+
...(cnfStyle ? { cnfStyle } : {}),
|
|
740
785
|
cells,
|
|
741
786
|
};
|
|
742
787
|
}
|
|
@@ -750,6 +795,11 @@ function parseSimpleTableCell(tcElement: XmlElementNode): TableCellNode {
|
|
|
750
795
|
let borders: TableCellNode["borders"];
|
|
751
796
|
let shading: TableCellNode["shading"];
|
|
752
797
|
let verticalAlign: TableCellNode["verticalAlign"];
|
|
798
|
+
let textDirection: TableCellNode["textDirection"];
|
|
799
|
+
let noWrap: TableCellNode["noWrap"];
|
|
800
|
+
let fitText: TableCellNode["fitText"];
|
|
801
|
+
let margins: TableCellNode["margins"];
|
|
802
|
+
let cnfStyle: TableCellNode["cnfStyle"];
|
|
753
803
|
|
|
754
804
|
for (const child of tcElement.children) {
|
|
755
805
|
if (child.type !== "element") continue;
|
|
@@ -770,6 +820,11 @@ function parseSimpleTableCell(tcElement: XmlElementNode): TableCellNode {
|
|
|
770
820
|
borders = readCellBorders(child);
|
|
771
821
|
shading = readCellShading(child);
|
|
772
822
|
verticalAlign = readCellVerticalAlign(child);
|
|
823
|
+
textDirection = readCellTextDirection(child);
|
|
824
|
+
noWrap = readCellNoWrap(child);
|
|
825
|
+
fitText = readCellFitText(child);
|
|
826
|
+
margins = readCellMargins(child);
|
|
827
|
+
cnfStyle = readCellCnfStyle(child);
|
|
773
828
|
} else if (name === "p") {
|
|
774
829
|
children.push(parseParagraphElement(child));
|
|
775
830
|
}
|
|
@@ -784,6 +839,11 @@ function parseSimpleTableCell(tcElement: XmlElementNode): TableCellNode {
|
|
|
784
839
|
...(borders ? { borders } : {}),
|
|
785
840
|
...(shading ? { shading } : {}),
|
|
786
841
|
...(verticalAlign ? { verticalAlign } : {}),
|
|
842
|
+
...(textDirection ? { textDirection } : {}),
|
|
843
|
+
...(noWrap !== undefined ? { noWrap } : {}),
|
|
844
|
+
...(fitText !== undefined ? { fitText } : {}),
|
|
845
|
+
...(margins ? { margins } : {}),
|
|
846
|
+
...(cnfStyle ? { cnfStyle } : {}),
|
|
787
847
|
children: children.length > 0 ? children : [{ type: "paragraph", children: [] }],
|
|
788
848
|
};
|
|
789
849
|
}
|
|
@@ -16,16 +16,31 @@ import { resolveHighlightColor } from "./highlight-colors.ts";
|
|
|
16
16
|
import { classifyFieldInstruction } from "./parse-fields.ts";
|
|
17
17
|
import {
|
|
18
18
|
readCellBorders,
|
|
19
|
+
readCellCnfStyle,
|
|
20
|
+
readCellFitText,
|
|
21
|
+
readCellMargins,
|
|
22
|
+
readCellNoWrap,
|
|
19
23
|
readCellShading,
|
|
24
|
+
readCellTextDirection,
|
|
20
25
|
readCellVerticalAlign,
|
|
21
26
|
readCellWidth,
|
|
22
27
|
readGridColumns as readSharedGridColumns,
|
|
28
|
+
readRowCantSplit,
|
|
29
|
+
readRowCnfStyle,
|
|
23
30
|
readRowHeight,
|
|
24
31
|
readRowHeightRule,
|
|
32
|
+
readRowHorizontalAlignment,
|
|
25
33
|
readRowIsHeader,
|
|
26
34
|
readTableAlignment,
|
|
35
|
+
readTableBidiVisual,
|
|
27
36
|
readTableBorders,
|
|
37
|
+
readTableCaption,
|
|
28
38
|
readTableCellMargins,
|
|
39
|
+
readTableCellSpacing,
|
|
40
|
+
readTableDescription,
|
|
41
|
+
readTableFloating,
|
|
42
|
+
readTableIndent,
|
|
43
|
+
readTableLayoutMode,
|
|
29
44
|
readTableLook,
|
|
30
45
|
readTableStyleId,
|
|
31
46
|
readTableWidth,
|
|
@@ -927,6 +942,13 @@ function parseSimpleTableElement(tblElement: XmlElementNode): TableNode {
|
|
|
927
942
|
let borders: TableNode["borders"];
|
|
928
943
|
let cellMargins: TableNode["cellMargins"];
|
|
929
944
|
let tblLook: TableNode["tblLook"];
|
|
945
|
+
let indent: TableNode["indent"];
|
|
946
|
+
let layoutMode: TableNode["layoutMode"];
|
|
947
|
+
let cellSpacing: TableNode["cellSpacing"];
|
|
948
|
+
let caption: TableNode["caption"];
|
|
949
|
+
let description: TableNode["description"];
|
|
950
|
+
let bidiVisual: TableNode["bidiVisual"];
|
|
951
|
+
let floating: TableNode["floating"];
|
|
930
952
|
|
|
931
953
|
for (const child of tblElement.children) {
|
|
932
954
|
if (child.type !== "element") continue;
|
|
@@ -940,6 +962,13 @@ function parseSimpleTableElement(tblElement: XmlElementNode): TableNode {
|
|
|
940
962
|
borders = readTableBorders(child);
|
|
941
963
|
cellMargins = readTableCellMargins(child);
|
|
942
964
|
tblLook = readTableLook(child);
|
|
965
|
+
indent = readTableIndent(child);
|
|
966
|
+
layoutMode = readTableLayoutMode(child);
|
|
967
|
+
cellSpacing = readTableCellSpacing(child);
|
|
968
|
+
caption = readTableCaption(child);
|
|
969
|
+
description = readTableDescription(child);
|
|
970
|
+
bidiVisual = readTableBidiVisual(child);
|
|
971
|
+
floating = readTableFloating(child);
|
|
943
972
|
} else if (name === "tblGrid") {
|
|
944
973
|
gridColumns = readGridColumns(child);
|
|
945
974
|
} else if (name === "tr") {
|
|
@@ -958,6 +987,13 @@ function parseSimpleTableElement(tblElement: XmlElementNode): TableNode {
|
|
|
958
987
|
...(borders ? { borders } : {}),
|
|
959
988
|
...(cellMargins ? { cellMargins } : {}),
|
|
960
989
|
...(tblLook ? { tblLook } : {}),
|
|
990
|
+
...(indent ? { indent } : {}),
|
|
991
|
+
...(layoutMode ? { layoutMode } : {}),
|
|
992
|
+
...(cellSpacing ? { cellSpacing } : {}),
|
|
993
|
+
...(caption !== undefined ? { caption } : {}),
|
|
994
|
+
...(description !== undefined ? { description } : {}),
|
|
995
|
+
...(bidiVisual !== undefined ? { bidiVisual } : {}),
|
|
996
|
+
...(floating ? { floating } : {}),
|
|
961
997
|
};
|
|
962
998
|
}
|
|
963
999
|
|
|
@@ -971,6 +1007,9 @@ function parseSimpleTableRow(trElement: XmlElementNode): TableRowNode {
|
|
|
971
1007
|
let height: TableRowNode["height"];
|
|
972
1008
|
let heightRule: TableRowNode["heightRule"];
|
|
973
1009
|
let isHeader: TableRowNode["isHeader"];
|
|
1010
|
+
let cantSplit: TableRowNode["cantSplit"];
|
|
1011
|
+
let horizontalAlignment: TableRowNode["horizontalAlignment"];
|
|
1012
|
+
let cnfStyle: TableRowNode["cnfStyle"];
|
|
974
1013
|
|
|
975
1014
|
for (const child of trElement.children) {
|
|
976
1015
|
if (child.type !== "element") continue;
|
|
@@ -981,6 +1020,9 @@ function parseSimpleTableRow(trElement: XmlElementNode): TableRowNode {
|
|
|
981
1020
|
height = readRowHeight(child);
|
|
982
1021
|
heightRule = readRowHeightRule(child);
|
|
983
1022
|
isHeader = readRowIsHeader(child);
|
|
1023
|
+
cantSplit = readRowCantSplit(child);
|
|
1024
|
+
horizontalAlignment = readRowHorizontalAlignment(child);
|
|
1025
|
+
cnfStyle = readRowCnfStyle(child);
|
|
984
1026
|
} else if (name === "tc") {
|
|
985
1027
|
cells.push(parseSimpleTableCell(child));
|
|
986
1028
|
}
|
|
@@ -992,6 +1034,9 @@ function parseSimpleTableRow(trElement: XmlElementNode): TableRowNode {
|
|
|
992
1034
|
...(height !== undefined ? { height } : {}),
|
|
993
1035
|
...(heightRule ? { heightRule } : {}),
|
|
994
1036
|
...(isHeader !== undefined ? { isHeader } : {}),
|
|
1037
|
+
...(cantSplit !== undefined ? { cantSplit } : {}),
|
|
1038
|
+
...(horizontalAlignment ? { horizontalAlignment } : {}),
|
|
1039
|
+
...(cnfStyle ? { cnfStyle } : {}),
|
|
995
1040
|
cells,
|
|
996
1041
|
};
|
|
997
1042
|
}
|
|
@@ -1005,6 +1050,11 @@ function parseSimpleTableCell(tcElement: XmlElementNode): TableCellNode {
|
|
|
1005
1050
|
let borders: TableCellNode["borders"];
|
|
1006
1051
|
let shading: TableCellNode["shading"];
|
|
1007
1052
|
let verticalAlign: TableCellNode["verticalAlign"];
|
|
1053
|
+
let textDirection: TableCellNode["textDirection"];
|
|
1054
|
+
let noWrap: TableCellNode["noWrap"];
|
|
1055
|
+
let fitText: TableCellNode["fitText"];
|
|
1056
|
+
let margins: TableCellNode["margins"];
|
|
1057
|
+
let cnfStyle: TableCellNode["cnfStyle"];
|
|
1008
1058
|
|
|
1009
1059
|
for (const child of tcElement.children) {
|
|
1010
1060
|
if (child.type !== "element") continue;
|
|
@@ -1025,6 +1075,11 @@ function parseSimpleTableCell(tcElement: XmlElementNode): TableCellNode {
|
|
|
1025
1075
|
borders = readCellBorders(child);
|
|
1026
1076
|
shading = readCellShading(child);
|
|
1027
1077
|
verticalAlign = readCellVerticalAlign(child);
|
|
1078
|
+
textDirection = readCellTextDirection(child);
|
|
1079
|
+
noWrap = readCellNoWrap(child);
|
|
1080
|
+
fitText = readCellFitText(child);
|
|
1081
|
+
margins = readCellMargins(child);
|
|
1082
|
+
cnfStyle = readCellCnfStyle(child);
|
|
1028
1083
|
} else if (name === "p") {
|
|
1029
1084
|
children.push(parseParagraphElement(child));
|
|
1030
1085
|
}
|
|
@@ -1039,6 +1094,11 @@ function parseSimpleTableCell(tcElement: XmlElementNode): TableCellNode {
|
|
|
1039
1094
|
...(borders ? { borders } : {}),
|
|
1040
1095
|
...(shading ? { shading } : {}),
|
|
1041
1096
|
...(verticalAlign ? { verticalAlign } : {}),
|
|
1097
|
+
...(textDirection ? { textDirection } : {}),
|
|
1098
|
+
...(noWrap !== undefined ? { noWrap } : {}),
|
|
1099
|
+
...(fitText !== undefined ? { fitText } : {}),
|
|
1100
|
+
...(margins ? { margins } : {}),
|
|
1101
|
+
...(cnfStyle ? { cnfStyle } : {}),
|
|
1042
1102
|
children: children.length > 0 ? children : [{ type: "paragraph", children: [] }],
|
|
1043
1103
|
};
|
|
1044
1104
|
}
|
|
@@ -10,6 +10,8 @@ import type {
|
|
|
10
10
|
TableBorders,
|
|
11
11
|
TableCellBorders,
|
|
12
12
|
TableCellMargins,
|
|
13
|
+
TableFloatingProperties,
|
|
14
|
+
TableIndent,
|
|
13
15
|
TableLook,
|
|
14
16
|
TableWidth,
|
|
15
17
|
SectionProperties,
|
|
@@ -35,16 +37,31 @@ import { classifyFieldInstruction } from "./parse-fields.ts";
|
|
|
35
37
|
import { resolveHighlightColor } from "./highlight-colors.ts";
|
|
36
38
|
import {
|
|
37
39
|
readCellBorders as readSharedCellBorders,
|
|
40
|
+
readCellCnfStyle as readSharedCellCnfStyle,
|
|
41
|
+
readCellFitText as readSharedCellFitText,
|
|
42
|
+
readCellMargins as readSharedCellMargins,
|
|
43
|
+
readCellNoWrap as readSharedCellNoWrap,
|
|
38
44
|
readCellShading as readSharedCellShading,
|
|
45
|
+
readCellTextDirection as readSharedCellTextDirection,
|
|
39
46
|
readCellVerticalAlign as readSharedCellVerticalAlign,
|
|
40
47
|
readCellWidth as readSharedCellWidth,
|
|
41
48
|
readGridColumns as readSharedGridColumns,
|
|
49
|
+
readRowCantSplit as readSharedRowCantSplit,
|
|
50
|
+
readRowCnfStyle as readSharedRowCnfStyle,
|
|
42
51
|
readRowHeight as readSharedRowHeight,
|
|
43
52
|
readRowHeightRule as readSharedRowHeightRule,
|
|
53
|
+
readRowHorizontalAlignment as readSharedRowHorizontalAlignment,
|
|
44
54
|
readRowIsHeader as readSharedRowIsHeader,
|
|
45
55
|
readTableAlignment as readSharedTableAlignment,
|
|
56
|
+
readTableBidiVisual as readSharedTableBidiVisual,
|
|
46
57
|
readTableBorders as readSharedTableBorders,
|
|
58
|
+
readTableCaption as readSharedTableCaption,
|
|
47
59
|
readTableCellMargins as readSharedTableCellMargins,
|
|
60
|
+
readTableCellSpacing as readSharedTableCellSpacing,
|
|
61
|
+
readTableDescription as readSharedTableDescription,
|
|
62
|
+
readTableFloating as readSharedTableFloating,
|
|
63
|
+
readTableIndent as readSharedTableIndent,
|
|
64
|
+
readTableLayoutMode as readSharedTableLayoutMode,
|
|
48
65
|
readTableLook as readSharedTableLook,
|
|
49
66
|
readTableStyleId as readSharedTableStyleId,
|
|
50
67
|
readTableWidth as readSharedTableWidth,
|
|
@@ -332,6 +349,13 @@ export interface ParsedTableBlockNode {
|
|
|
332
349
|
alignment?: "left" | "center" | "right";
|
|
333
350
|
borders?: TableBorders;
|
|
334
351
|
cellMargins?: TableCellMargins;
|
|
352
|
+
indent?: TableIndent;
|
|
353
|
+
layoutMode?: "fixed" | "autofit";
|
|
354
|
+
cellSpacing?: TableWidth;
|
|
355
|
+
caption?: string;
|
|
356
|
+
description?: string;
|
|
357
|
+
bidiVisual?: boolean;
|
|
358
|
+
floating?: TableFloatingProperties;
|
|
335
359
|
rawXml: string;
|
|
336
360
|
}
|
|
337
361
|
|
|
@@ -346,6 +370,9 @@ export interface ParsedTableRowNode {
|
|
|
346
370
|
height?: number;
|
|
347
371
|
heightRule?: "auto" | "atLeast" | "exact";
|
|
348
372
|
isHeader?: boolean;
|
|
373
|
+
cantSplit?: boolean;
|
|
374
|
+
horizontalAlignment?: "left" | "center" | "right";
|
|
375
|
+
cnfStyle?: string;
|
|
349
376
|
rawXml: string;
|
|
350
377
|
}
|
|
351
378
|
|
|
@@ -359,6 +386,11 @@ export interface ParsedTableCellNode {
|
|
|
359
386
|
borders?: TableCellBorders;
|
|
360
387
|
shading?: CellShading;
|
|
361
388
|
verticalAlign?: "top" | "center" | "bottom";
|
|
389
|
+
textDirection?: "lrTb" | "tbRl" | "btLr";
|
|
390
|
+
noWrap?: boolean;
|
|
391
|
+
fitText?: boolean;
|
|
392
|
+
margins?: TableCellMargins;
|
|
393
|
+
cnfStyle?: string;
|
|
362
394
|
rawXml: string;
|
|
363
395
|
}
|
|
364
396
|
|
|
@@ -857,6 +889,13 @@ function parseTableElement(
|
|
|
857
889
|
let alignment: ParsedTableBlockNode["alignment"];
|
|
858
890
|
let borders: TableBorders | undefined;
|
|
859
891
|
let cellMargins: TableCellMargins | undefined;
|
|
892
|
+
let indent: TableIndent | undefined;
|
|
893
|
+
let layoutMode: ParsedTableBlockNode["layoutMode"];
|
|
894
|
+
let cellSpacing: TableWidth | undefined;
|
|
895
|
+
let caption: string | undefined;
|
|
896
|
+
let description: string | undefined;
|
|
897
|
+
let bidiVisual: boolean | undefined;
|
|
898
|
+
let floating: TableFloatingProperties | undefined;
|
|
860
899
|
const rows: ParsedTableRowNode[] = [];
|
|
861
900
|
|
|
862
901
|
for (const child of node.children) {
|
|
@@ -871,6 +910,13 @@ function parseTableElement(
|
|
|
871
910
|
alignment = readTableAlignment(child);
|
|
872
911
|
borders = readTableBorders(child);
|
|
873
912
|
cellMargins = readTableCellMargins(child);
|
|
913
|
+
indent = readTableIndent(child);
|
|
914
|
+
layoutMode = readTableLayoutMode(child);
|
|
915
|
+
cellSpacing = readTableCellSpacing(child);
|
|
916
|
+
caption = readTableCaption(child);
|
|
917
|
+
description = readTableDescription(child);
|
|
918
|
+
bidiVisual = readTableBidiVisual(child);
|
|
919
|
+
floating = readTableFloating(child);
|
|
874
920
|
break;
|
|
875
921
|
}
|
|
876
922
|
case "tblGrid": {
|
|
@@ -895,6 +941,13 @@ function parseTableElement(
|
|
|
895
941
|
...(alignment ? { alignment } : {}),
|
|
896
942
|
...(borders ? { borders } : {}),
|
|
897
943
|
...(cellMargins ? { cellMargins } : {}),
|
|
944
|
+
...(indent ? { indent } : {}),
|
|
945
|
+
...(layoutMode ? { layoutMode } : {}),
|
|
946
|
+
...(cellSpacing ? { cellSpacing } : {}),
|
|
947
|
+
...(caption !== undefined ? { caption } : {}),
|
|
948
|
+
...(description !== undefined ? { description } : {}),
|
|
949
|
+
...(bidiVisual !== undefined ? { bidiVisual } : {}),
|
|
950
|
+
...(floating ? { floating } : {}),
|
|
898
951
|
rawXml: sourceXml.slice(node.start, node.end),
|
|
899
952
|
};
|
|
900
953
|
}
|
|
@@ -915,6 +968,9 @@ function parseTableRowElement(
|
|
|
915
968
|
let height: number | undefined;
|
|
916
969
|
let heightRule: ParsedTableRowNode["heightRule"];
|
|
917
970
|
let isHeader: boolean | undefined;
|
|
971
|
+
let cantSplit: boolean | undefined;
|
|
972
|
+
let horizontalAlignment: ParsedTableRowNode["horizontalAlignment"];
|
|
973
|
+
let cnfStyle: string | undefined;
|
|
918
974
|
const cells: ParsedTableCellNode[] = [];
|
|
919
975
|
|
|
920
976
|
for (const child of node.children) {
|
|
@@ -930,6 +986,9 @@ function parseTableRowElement(
|
|
|
930
986
|
height = readRowHeight(child);
|
|
931
987
|
heightRule = readRowHeightRule(child);
|
|
932
988
|
isHeader = readRowIsHeader(child);
|
|
989
|
+
cantSplit = readRowCantSplit(child);
|
|
990
|
+
horizontalAlignment = readRowHorizontalAlignment(child);
|
|
991
|
+
cnfStyle = readRowCnfStyle(child);
|
|
933
992
|
break;
|
|
934
993
|
case "tc":
|
|
935
994
|
cells.push(parseTableCellElement(child, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath));
|
|
@@ -947,6 +1006,9 @@ function parseTableRowElement(
|
|
|
947
1006
|
...(height !== undefined ? { height } : {}),
|
|
948
1007
|
...(heightRule ? { heightRule } : {}),
|
|
949
1008
|
...(isHeader !== undefined ? { isHeader } : {}),
|
|
1009
|
+
...(cantSplit !== undefined ? { cantSplit } : {}),
|
|
1010
|
+
...(horizontalAlignment ? { horizontalAlignment } : {}),
|
|
1011
|
+
...(cnfStyle ? { cnfStyle } : {}),
|
|
950
1012
|
cells,
|
|
951
1013
|
rawXml: sourceXml.slice(node.start, node.end),
|
|
952
1014
|
};
|
|
@@ -967,6 +1029,11 @@ function parseTableCellElement(
|
|
|
967
1029
|
let borders: TableCellBorders | undefined;
|
|
968
1030
|
let shading: CellShading | undefined;
|
|
969
1031
|
let verticalAlign: ParsedTableCellNode["verticalAlign"];
|
|
1032
|
+
let textDirection: ParsedTableCellNode["textDirection"];
|
|
1033
|
+
let noWrap: boolean | undefined;
|
|
1034
|
+
let fitText: boolean | undefined;
|
|
1035
|
+
let margins: TableCellMargins | undefined;
|
|
1036
|
+
let cnfStyle: string | undefined;
|
|
970
1037
|
const children: ParsedBlockNode[] = [];
|
|
971
1038
|
|
|
972
1039
|
for (const child of node.children) {
|
|
@@ -981,6 +1048,11 @@ function parseTableCellElement(
|
|
|
981
1048
|
borders = readCellBorders(child);
|
|
982
1049
|
shading = readCellShading(child);
|
|
983
1050
|
verticalAlign = readCellVerticalAlign(child);
|
|
1051
|
+
textDirection = readCellTextDirection(child);
|
|
1052
|
+
noWrap = readCellNoWrap(child);
|
|
1053
|
+
fitText = readCellFitText(child);
|
|
1054
|
+
margins = readCellMargins(child);
|
|
1055
|
+
cnfStyle = readCellCnfStyle(child);
|
|
984
1056
|
break;
|
|
985
1057
|
}
|
|
986
1058
|
default: {
|
|
@@ -1001,6 +1073,11 @@ function parseTableCellElement(
|
|
|
1001
1073
|
...(borders ? { borders } : {}),
|
|
1002
1074
|
...(shading ? { shading } : {}),
|
|
1003
1075
|
...(verticalAlign ? { verticalAlign } : {}),
|
|
1076
|
+
...(textDirection ? { textDirection } : {}),
|
|
1077
|
+
...(noWrap !== undefined ? { noWrap } : {}),
|
|
1078
|
+
...(fitText !== undefined ? { fitText } : {}),
|
|
1079
|
+
...(margins ? { margins } : {}),
|
|
1080
|
+
...(cnfStyle ? { cnfStyle } : {}),
|
|
1004
1081
|
rawXml: sourceXml.slice(node.start, node.end),
|
|
1005
1082
|
};
|
|
1006
1083
|
}
|
|
@@ -1274,6 +1351,66 @@ function readCellVerticalAlign(node: XmlElementNode): ParsedTableCellNode["verti
|
|
|
1274
1351
|
return readSharedCellVerticalAlign(node);
|
|
1275
1352
|
}
|
|
1276
1353
|
|
|
1354
|
+
function readTableIndent(node: XmlElementNode): TableIndent | undefined {
|
|
1355
|
+
return readSharedTableIndent(node);
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
function readTableLayoutMode(node: XmlElementNode): ParsedTableBlockNode["layoutMode"] {
|
|
1359
|
+
return readSharedTableLayoutMode(node);
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
function readTableCellSpacing(node: XmlElementNode): TableWidth | undefined {
|
|
1363
|
+
return readSharedTableCellSpacing(node);
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
function readTableCaption(node: XmlElementNode): string | undefined {
|
|
1367
|
+
return readSharedTableCaption(node);
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
function readTableDescription(node: XmlElementNode): string | undefined {
|
|
1371
|
+
return readSharedTableDescription(node);
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
function readTableBidiVisual(node: XmlElementNode): boolean | undefined {
|
|
1375
|
+
return readSharedTableBidiVisual(node);
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
function readTableFloating(node: XmlElementNode): TableFloatingProperties | undefined {
|
|
1379
|
+
return readSharedTableFloating(node);
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
function readRowCantSplit(node: XmlElementNode): boolean | undefined {
|
|
1383
|
+
return readSharedRowCantSplit(node);
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
function readRowHorizontalAlignment(node: XmlElementNode): ParsedTableRowNode["horizontalAlignment"] {
|
|
1387
|
+
return readSharedRowHorizontalAlignment(node);
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
function readRowCnfStyle(node: XmlElementNode): string | undefined {
|
|
1391
|
+
return readSharedRowCnfStyle(node);
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
function readCellTextDirection(node: XmlElementNode): ParsedTableCellNode["textDirection"] {
|
|
1395
|
+
return readSharedCellTextDirection(node);
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
function readCellNoWrap(node: XmlElementNode): boolean | undefined {
|
|
1399
|
+
return readSharedCellNoWrap(node);
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
function readCellFitText(node: XmlElementNode): boolean | undefined {
|
|
1403
|
+
return readSharedCellFitText(node);
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
function readCellMargins(node: XmlElementNode): TableCellMargins | undefined {
|
|
1407
|
+
return readSharedCellMargins(node);
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
function readCellCnfStyle(node: XmlElementNode): string | undefined {
|
|
1411
|
+
return readSharedCellCnfStyle(node);
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1277
1414
|
/**
|
|
1278
1415
|
* Check if a table's raw XML contains content that cannot safely round-trip
|
|
1279
1416
|
* through the parsed table path yet. This includes:
|
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
ParagraphIndentation,
|
|
9
9
|
TabStop,
|
|
10
10
|
} from "../../model/canonical-document.ts";
|
|
11
|
+
import { readRunProperties } from "./parse-run-formatting.ts";
|
|
11
12
|
|
|
12
13
|
export interface ParsedParagraphNumberingReference {
|
|
13
14
|
paragraphIndex: number;
|
|
@@ -48,9 +49,32 @@ export function parseNumberingXml(xml: string): NumberingCatalog {
|
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
const abstractNumberingId = toCanonicalAbstractNumberingId(rawId);
|
|
52
|
+
const nsidEl = findChildElementOptional(child, "nsid");
|
|
53
|
+
const nsid = nsidEl ? (nsidEl.attributes["w:val"] ?? nsidEl.attributes.val) : undefined;
|
|
54
|
+
const mltEl = findChildElementOptional(child, "multiLevelType");
|
|
55
|
+
const mltRaw = mltEl ? (mltEl.attributes["w:val"] ?? mltEl.attributes.val) : undefined;
|
|
56
|
+
const multiLevelType =
|
|
57
|
+
mltRaw === "singleLevel" || mltRaw === "multilevel" || mltRaw === "hybridMultilevel"
|
|
58
|
+
? mltRaw
|
|
59
|
+
: undefined;
|
|
60
|
+
const tmplEl = findChildElementOptional(child, "tmpl");
|
|
61
|
+
const tplc = tmplEl ? (tmplEl.attributes["w:val"] ?? tmplEl.attributes.val) : undefined;
|
|
62
|
+
const styleLinkEl = findChildElementOptional(child, "styleLink");
|
|
63
|
+
const styleLink = styleLinkEl
|
|
64
|
+
? (styleLinkEl.attributes["w:val"] ?? styleLinkEl.attributes.val)
|
|
65
|
+
: undefined;
|
|
66
|
+
const numStyleLinkEl = findChildElementOptional(child, "numStyleLink");
|
|
67
|
+
const numStyleLink = numStyleLinkEl
|
|
68
|
+
? (numStyleLinkEl.attributes["w:val"] ?? numStyleLinkEl.attributes.val)
|
|
69
|
+
: undefined;
|
|
51
70
|
abstractDefinitions[abstractNumberingId] = {
|
|
52
71
|
abstractNumberingId,
|
|
53
72
|
levels: readLevels(child),
|
|
73
|
+
...(nsid ? { nsid } : {}),
|
|
74
|
+
...(multiLevelType ? { multiLevelType } : {}),
|
|
75
|
+
...(tplc ? { tplc } : {}),
|
|
76
|
+
...(styleLink ? { styleLink } : {}),
|
|
77
|
+
...(numStyleLink ? { numStyleLink } : {}),
|
|
54
78
|
};
|
|
55
79
|
break;
|
|
56
80
|
}
|
|
@@ -219,6 +243,11 @@ function readLevelDefinition(
|
|
|
219
243
|
? "tab"
|
|
220
244
|
: undefined;
|
|
221
245
|
const paragraphGeometry = readLevelParagraphGeometry(levelNode);
|
|
246
|
+
const lvlRestartNode = findChildElementOptional(levelNode, "lvlRestart");
|
|
247
|
+
const rawRestart = lvlRestartNode?.attributes["w:val"] ?? lvlRestartNode?.attributes.val;
|
|
248
|
+
const restartAfterLevel = rawRestart !== undefined ? parseInteger(rawRestart) : undefined;
|
|
249
|
+
const rPrNode = findChildElementOptional(levelNode, "rPr");
|
|
250
|
+
const runProperties = readRunProperties(rPrNode);
|
|
222
251
|
|
|
223
252
|
return {
|
|
224
253
|
level,
|
|
@@ -229,6 +258,8 @@ function readLevelDefinition(
|
|
|
229
258
|
...(isLegalNumbering ? { isLegalNumbering: true } : {}),
|
|
230
259
|
...(suffix ? { suffix } : {}),
|
|
231
260
|
...(paragraphGeometry ? { paragraphGeometry } : {}),
|
|
261
|
+
...(runProperties ? { runProperties } : {}),
|
|
262
|
+
...(restartAfterLevel !== undefined ? { restartAfterLevel } : {}),
|
|
232
263
|
};
|
|
233
264
|
}
|
|
234
265
|
|
|
@@ -263,6 +294,11 @@ function readLevelOverrideDefinition(
|
|
|
263
294
|
? "tab"
|
|
264
295
|
: undefined;
|
|
265
296
|
const paragraphGeometry = readLevelParagraphGeometry(levelNode);
|
|
297
|
+
const lvlRestartNode = findChildElementOptional(levelNode, "lvlRestart");
|
|
298
|
+
const rawRestart = lvlRestartNode?.attributes["w:val"] ?? lvlRestartNode?.attributes.val;
|
|
299
|
+
const restartAfterLevel = rawRestart !== undefined ? parseInteger(rawRestart) : undefined;
|
|
300
|
+
const rPrNode = findChildElementOptional(levelNode, "rPr");
|
|
301
|
+
const runProperties = readRunProperties(rPrNode);
|
|
266
302
|
|
|
267
303
|
const hasExplicitFields =
|
|
268
304
|
startAt !== undefined ||
|
|
@@ -271,7 +307,9 @@ function readLevelOverrideDefinition(
|
|
|
271
307
|
paragraphStyleId !== undefined ||
|
|
272
308
|
isLegalNumbering !== undefined ||
|
|
273
309
|
suffix !== undefined ||
|
|
274
|
-
paragraphGeometry !== undefined
|
|
310
|
+
paragraphGeometry !== undefined ||
|
|
311
|
+
runProperties !== undefined ||
|
|
312
|
+
restartAfterLevel !== undefined;
|
|
275
313
|
|
|
276
314
|
if (!hasExplicitFields) {
|
|
277
315
|
return undefined;
|
|
@@ -286,6 +324,8 @@ function readLevelOverrideDefinition(
|
|
|
286
324
|
...(isLegalNumbering !== undefined ? { isLegalNumbering } : {}),
|
|
287
325
|
...(suffix ? { suffix } : {}),
|
|
288
326
|
...(paragraphGeometry ? { paragraphGeometry } : {}),
|
|
327
|
+
...(runProperties ? { runProperties } : {}),
|
|
328
|
+
...(restartAfterLevel !== undefined ? { restartAfterLevel } : {}),
|
|
289
329
|
};
|
|
290
330
|
}
|
|
291
331
|
|