@stll/folio-core 0.33.0 → 0.33.2
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/ai-edits/apply.d.ts +15 -0
- package/dist/ai-edits/apply.js +135 -24
- package/dist/ai-edits/headless.d.ts +47 -3
- package/dist/ai-edits/headless.js +53 -3
- package/dist/ai-edits/index.d.ts +1 -1
- package/dist/ai-edits/snapshot.d.ts +19 -1
- package/dist/ai-edits/snapshot.js +25 -3
- package/dist/ai-edits/table-geometry.d.ts +56 -0
- package/dist/ai-edits/table-geometry.js +217 -0
- package/dist/ai-edits/table-row-column-mutations.d.ts +34 -16
- package/dist/ai-edits/table-row-column-mutations.js +12 -4
- package/dist/ai-edits/table-template.d.ts +60 -0
- package/dist/ai-edits/table-template.js +176 -0
- package/dist/ai-edits/types.d.ts +7 -0
- package/dist/compare/__fixtures__/body-sequence.d.ts +86 -4
- package/dist/compare/__fixtures__/body-sequence.js +169 -12
- package/dist/compare/compare.d.ts +15 -8
- package/dist/compare/compare.js +138 -34
- package/dist/compare/plan.d.ts +31 -1
- package/dist/compare/plan.js +277 -28
- package/dist/compare/reproducible-package.d.ts +7 -3
- package/dist/compare/reproducible-package.js +20 -3
- package/dist/compare/types.d.ts +20 -3
- package/dist/compare/types.js +13 -1
- package/dist/compare/verification.d.ts +49 -2
- package/dist/compare/verification.js +115 -1
- package/dist/compat/eigenpal.d.ts +5 -5
- package/dist/compat/eigenpal.js +3 -3
- package/dist/document-operations.d.ts +10 -1
- package/dist/document-operations.js +3 -2
- package/dist/docx/appVersionNormalization.d.ts +49 -0
- package/dist/docx/appVersionNormalization.js +74 -0
- package/dist/docx/blockContentParser.js +3 -2
- package/dist/docx/drawingUtils.js +4 -3
- package/dist/docx/hyperlinkParser.d.ts +9 -1
- package/dist/docx/hyperlinkParser.js +19 -13
- package/dist/docx/paraIdRangeNormalization.d.ts +40 -0
- package/dist/docx/paraIdRangeNormalization.js +64 -0
- package/dist/docx/paragraphParser.js +82 -6
- package/dist/docx/revisionIdNormalization.d.ts +15 -1
- package/dist/docx/revisionIdNormalization.js +22 -4
- package/dist/docx/rezip.d.ts +13 -1
- package/dist/docx/rezip.js +80 -21
- package/dist/docx/runParser.js +9 -8
- package/dist/docx/sdtProperties.js +4 -3
- package/dist/docx/selectiveSave.js +7 -6
- package/dist/docx/serializer/commentSerializer.d.ts +1 -1
- package/dist/docx/serializer/commentSerializer.js +43 -19
- package/dist/docx/serializer/documentSerializer.d.ts +3 -1
- package/dist/docx/serializer/documentSerializer.js +42 -78
- package/dist/docx/serializer/fontTableSerializer.js +8 -5
- package/dist/docx/serializer/headerFooterSerializer.d.ts +4 -1
- package/dist/docx/serializer/headerFooterSerializer.js +34 -29
- package/dist/docx/serializer/noteSerializer.js +34 -30
- package/dist/docx/serializer/numberingSerializer.js +8 -4
- package/dist/docx/serializer/paragraphSerializer.js +45 -21
- package/dist/docx/serializer/partNamespaces.d.ts +78 -0
- package/dist/docx/serializer/partNamespaces.js +324 -0
- package/dist/docx/serializer/runSerializer.js +1 -1
- package/dist/docx/serializer/settingsSerializer.js +8 -2
- package/dist/docx/serializer/stylesSerializer.js +8 -5
- package/dist/docx/serializer/tableSerializer.js +107 -27
- package/dist/docx/serializer/themeSerializer.js +10 -2
- package/dist/docx/server/build.d.ts +1 -1
- package/dist/docx/strictValueEncodings.gen.d.ts +15 -0
- package/dist/docx/strictValueEncodings.gen.js +275 -0
- package/dist/docx/tableParser.d.ts +0 -6
- package/dist/docx/tableParser.js +52 -7
- package/dist/docx/transitionalSpelling.d.ts +23 -0
- package/dist/docx/transitionalSpelling.js +36 -0
- package/dist/docx/universalMeasure.d.ts +20 -0
- package/dist/docx/universalMeasure.js +32 -0
- package/dist/docx/verbatimCapture.d.ts +20 -0
- package/dist/docx/verbatimCapture.js +131 -0
- package/dist/docx/vmlImageParser.js +4 -3
- package/dist/docx/watermarkParser.js +4 -3
- package/dist/docx/xmlParser.d.ts +23 -2
- package/dist/docx/xmlParser.js +43 -11
- package/dist/index.d.ts +5 -5
- package/dist/index.js +3 -3
- package/dist/model.d.ts +3 -3
- package/dist/model.js +2 -2
- package/dist/prosemirror/commands/comments.js +8 -2
- package/dist/prosemirror/containerFinalParagraph.d.ts +47 -0
- package/dist/prosemirror/containerFinalParagraph.js +92 -0
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +8 -1
- package/dist/prosemirror/conversion/fromProseDoc.js +15 -4
- package/dist/prosemirror/conversion/toProseDoc.js +12 -3
- package/dist/prosemirror/extensions/nodes/TableExtension.js +5 -0
- package/dist/prosemirror/schema/marks.d.ts +1 -1
- package/dist/prosemirror/schema/nodes.d.ts +22 -0
- package/dist/server.d.ts +1 -1
- package/dist/types/block-id.d.ts +12 -1
- package/dist/types/block-id.js +17 -1
- package/dist/utils/canonicalJson.d.ts +14 -0
- package/dist/utils/canonicalJson.js +19 -0
- package/dist/utils/formatToStyle.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1,9 +1,17 @@
|
|
|
1
|
+
import { serializePartElement } from "./partNamespaces.js";
|
|
1
2
|
import { escapeXml } from "./xmlUtils.js";
|
|
2
3
|
//#region src/docx/serializer/themeSerializer.ts
|
|
3
|
-
const A_NS = "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
4
4
|
const serializeThemeXml = (theme) => {
|
|
5
5
|
const name = escapeXml(theme.name ?? "Folio Theme");
|
|
6
|
-
|
|
6
|
+
const elements = `${serializeColorScheme(theme.colorScheme)}${serializeFontScheme(theme)}${serializeFormatScheme(theme)}`;
|
|
7
|
+
return "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + serializePartElement({
|
|
8
|
+
partPath: "word/theme/theme1.xml",
|
|
9
|
+
rootName: "a:theme",
|
|
10
|
+
rootAttributes: `name="${name}"`,
|
|
11
|
+
baselinePrefixes: ["a"],
|
|
12
|
+
sourceBindings: void 0,
|
|
13
|
+
body: `<a:themeElements>${elements}</a:themeElements>`
|
|
14
|
+
});
|
|
7
15
|
};
|
|
8
16
|
const serializeColorScheme = (colors) => {
|
|
9
17
|
const values = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { document_d_exports } from "../../types/document.js";
|
|
2
1
|
import { ShadingProperties } from "../../types/colors.js";
|
|
2
|
+
import { document_d_exports } from "../../types/document.js";
|
|
3
3
|
import { Hyperlink, Paragraph, ParagraphContent, Run, Table } from "../../types/content.js";
|
|
4
4
|
import { ParagraphFormatting, TextFormatting } from "../../types/formatting.js";
|
|
5
5
|
//#region src/docx/server/build.d.ts
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { MeasureUnit } from "./universalMeasure.js";
|
|
2
|
+
//#region src/docx/strictValueEncodings.gen.d.ts
|
|
3
|
+
/** The fraction of a percent a Transitional attribute's number counts. */
|
|
4
|
+
type PercentUnit = "fiftiethPercent" | "thousandthPercent" | "wholePercent";
|
|
5
|
+
/** The number a slot's dual-spelling type accepts in place of a Strict string. */
|
|
6
|
+
type SlotEncoding = {
|
|
7
|
+
readonly measure?: MeasureUnit;
|
|
8
|
+
readonly percent?: PercentUnit;
|
|
9
|
+
};
|
|
10
|
+
/** Slots whose Transitional type spells one value two ways. */
|
|
11
|
+
declare const TRANSITIONAL_SLOT_ENCODINGS: ReadonlyMap<string, SlotEncoding>;
|
|
12
|
+
/** Every Strict namespace URI a WordprocessingML part can carry, and its Transitional pair. */
|
|
13
|
+
declare const TRANSITIONAL_NAMESPACE_BY_STRICT_URI: ReadonlyMap<string, string>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { PercentUnit, SlotEncoding, TRANSITIONAL_NAMESPACE_BY_STRICT_URI, TRANSITIONAL_SLOT_ENCODINGS };
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
//#region src/docx/strictValueEncodings.gen.ts
|
|
2
|
+
const MEASURE_UNITS = {
|
|
3
|
+
emu: "emu",
|
|
4
|
+
halfPoints: "halfPoints",
|
|
5
|
+
hundredthPoints: "hundredthPoints",
|
|
6
|
+
twips: "twips"
|
|
7
|
+
};
|
|
8
|
+
const PERCENT_UNITS = {
|
|
9
|
+
fiftiethPercent: "fiftiethPercent",
|
|
10
|
+
thousandthPercent: "thousandthPercent",
|
|
11
|
+
wholePercent: "wholePercent"
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* One slot per line: the slot, a tab, its measure unit, a tab, its percent unit.
|
|
15
|
+
*
|
|
16
|
+
* Text rather than object literals because every package that depends on
|
|
17
|
+
* `@stll/folio-core` pays this file's inference cost, and a few hundred
|
|
18
|
+
* literals breach the repository's compiler-workload budget on their own.
|
|
19
|
+
* The slot is `"<namespace URI> <element local name>"` for element text and
|
|
20
|
+
* `"<namespace URI> <element local name> @<attribute local name>"` for an
|
|
21
|
+
* attribute; an empty column means the type has no spelling of that kind.
|
|
22
|
+
*/
|
|
23
|
+
const SLOT_TABLE = `http://schemas.openxmlformats.org/drawingml/2006/main ahPolar @maxR emu
|
|
24
|
+
http://schemas.openxmlformats.org/drawingml/2006/main ahPolar @minR emu
|
|
25
|
+
http://schemas.openxmlformats.org/drawingml/2006/main ahXY @maxX emu
|
|
26
|
+
http://schemas.openxmlformats.org/drawingml/2006/main ahXY @maxY emu
|
|
27
|
+
http://schemas.openxmlformats.org/drawingml/2006/main ahXY @minX emu
|
|
28
|
+
http://schemas.openxmlformats.org/drawingml/2006/main ahXY @minY emu
|
|
29
|
+
http://schemas.openxmlformats.org/drawingml/2006/main alpha @val thousandthPercent
|
|
30
|
+
http://schemas.openxmlformats.org/drawingml/2006/main alphaBiLevel @thresh thousandthPercent
|
|
31
|
+
http://schemas.openxmlformats.org/drawingml/2006/main alphaMod @val thousandthPercent
|
|
32
|
+
http://schemas.openxmlformats.org/drawingml/2006/main alphaModFix @amt thousandthPercent
|
|
33
|
+
http://schemas.openxmlformats.org/drawingml/2006/main alphaOff @val thousandthPercent
|
|
34
|
+
http://schemas.openxmlformats.org/drawingml/2006/main alphaOutset @rad emu
|
|
35
|
+
http://schemas.openxmlformats.org/drawingml/2006/main alphaRepl @a thousandthPercent
|
|
36
|
+
http://schemas.openxmlformats.org/drawingml/2006/main anchor @x emu
|
|
37
|
+
http://schemas.openxmlformats.org/drawingml/2006/main anchor @y emu
|
|
38
|
+
http://schemas.openxmlformats.org/drawingml/2006/main anchor @z emu
|
|
39
|
+
http://schemas.openxmlformats.org/drawingml/2006/main arcTo @hR emu
|
|
40
|
+
http://schemas.openxmlformats.org/drawingml/2006/main arcTo @wR emu
|
|
41
|
+
http://schemas.openxmlformats.org/drawingml/2006/main biLevel @thresh thousandthPercent
|
|
42
|
+
http://schemas.openxmlformats.org/drawingml/2006/main blue @val thousandthPercent
|
|
43
|
+
http://schemas.openxmlformats.org/drawingml/2006/main blueMod @val thousandthPercent
|
|
44
|
+
http://schemas.openxmlformats.org/drawingml/2006/main blueOff @val thousandthPercent
|
|
45
|
+
http://schemas.openxmlformats.org/drawingml/2006/main bodyPr @bIns emu
|
|
46
|
+
http://schemas.openxmlformats.org/drawingml/2006/main bodyPr @lIns emu
|
|
47
|
+
http://schemas.openxmlformats.org/drawingml/2006/main bodyPr @rIns emu
|
|
48
|
+
http://schemas.openxmlformats.org/drawingml/2006/main bodyPr @tIns emu
|
|
49
|
+
http://schemas.openxmlformats.org/drawingml/2006/main camera @zoom thousandthPercent
|
|
50
|
+
http://schemas.openxmlformats.org/drawingml/2006/main chOff @x emu
|
|
51
|
+
http://schemas.openxmlformats.org/drawingml/2006/main chOff @y emu
|
|
52
|
+
http://schemas.openxmlformats.org/drawingml/2006/main defPPr @defTabSz emu
|
|
53
|
+
http://schemas.openxmlformats.org/drawingml/2006/main defRPr @baseline thousandthPercent
|
|
54
|
+
http://schemas.openxmlformats.org/drawingml/2006/main defRPr @spc hundredthPoints
|
|
55
|
+
http://schemas.openxmlformats.org/drawingml/2006/main ds @d thousandthPercent
|
|
56
|
+
http://schemas.openxmlformats.org/drawingml/2006/main ds @sp thousandthPercent
|
|
57
|
+
http://schemas.openxmlformats.org/drawingml/2006/main endParaRPr @baseline thousandthPercent
|
|
58
|
+
http://schemas.openxmlformats.org/drawingml/2006/main endParaRPr @spc hundredthPoints
|
|
59
|
+
http://schemas.openxmlformats.org/drawingml/2006/main fillRect @b thousandthPercent
|
|
60
|
+
http://schemas.openxmlformats.org/drawingml/2006/main fillRect @l thousandthPercent
|
|
61
|
+
http://schemas.openxmlformats.org/drawingml/2006/main fillRect @r thousandthPercent
|
|
62
|
+
http://schemas.openxmlformats.org/drawingml/2006/main fillRect @t thousandthPercent
|
|
63
|
+
http://schemas.openxmlformats.org/drawingml/2006/main fillToRect @b thousandthPercent
|
|
64
|
+
http://schemas.openxmlformats.org/drawingml/2006/main fillToRect @l thousandthPercent
|
|
65
|
+
http://schemas.openxmlformats.org/drawingml/2006/main fillToRect @r thousandthPercent
|
|
66
|
+
http://schemas.openxmlformats.org/drawingml/2006/main fillToRect @t thousandthPercent
|
|
67
|
+
http://schemas.openxmlformats.org/drawingml/2006/main flatTx @z emu
|
|
68
|
+
http://schemas.openxmlformats.org/drawingml/2006/main green @val thousandthPercent
|
|
69
|
+
http://schemas.openxmlformats.org/drawingml/2006/main greenMod @val thousandthPercent
|
|
70
|
+
http://schemas.openxmlformats.org/drawingml/2006/main greenOff @val thousandthPercent
|
|
71
|
+
http://schemas.openxmlformats.org/drawingml/2006/main gridCol @w emu
|
|
72
|
+
http://schemas.openxmlformats.org/drawingml/2006/main gs @pos thousandthPercent
|
|
73
|
+
http://schemas.openxmlformats.org/drawingml/2006/main hsl @lum thousandthPercent
|
|
74
|
+
http://schemas.openxmlformats.org/drawingml/2006/main hsl @sat thousandthPercent
|
|
75
|
+
http://schemas.openxmlformats.org/drawingml/2006/main hslClr @lum thousandthPercent
|
|
76
|
+
http://schemas.openxmlformats.org/drawingml/2006/main hslClr @sat thousandthPercent
|
|
77
|
+
http://schemas.openxmlformats.org/drawingml/2006/main hueMod @val thousandthPercent
|
|
78
|
+
http://schemas.openxmlformats.org/drawingml/2006/main lum @bright thousandthPercent
|
|
79
|
+
http://schemas.openxmlformats.org/drawingml/2006/main lum @contrast thousandthPercent
|
|
80
|
+
http://schemas.openxmlformats.org/drawingml/2006/main lum @val thousandthPercent
|
|
81
|
+
http://schemas.openxmlformats.org/drawingml/2006/main lumMod @val thousandthPercent
|
|
82
|
+
http://schemas.openxmlformats.org/drawingml/2006/main lumOff @val thousandthPercent
|
|
83
|
+
http://schemas.openxmlformats.org/drawingml/2006/main lvl1pPr @defTabSz emu
|
|
84
|
+
http://schemas.openxmlformats.org/drawingml/2006/main lvl2pPr @defTabSz emu
|
|
85
|
+
http://schemas.openxmlformats.org/drawingml/2006/main lvl3pPr @defTabSz emu
|
|
86
|
+
http://schemas.openxmlformats.org/drawingml/2006/main lvl4pPr @defTabSz emu
|
|
87
|
+
http://schemas.openxmlformats.org/drawingml/2006/main lvl5pPr @defTabSz emu
|
|
88
|
+
http://schemas.openxmlformats.org/drawingml/2006/main lvl6pPr @defTabSz emu
|
|
89
|
+
http://schemas.openxmlformats.org/drawingml/2006/main lvl7pPr @defTabSz emu
|
|
90
|
+
http://schemas.openxmlformats.org/drawingml/2006/main lvl8pPr @defTabSz emu
|
|
91
|
+
http://schemas.openxmlformats.org/drawingml/2006/main lvl9pPr @defTabSz emu
|
|
92
|
+
http://schemas.openxmlformats.org/drawingml/2006/main miter @lim thousandthPercent
|
|
93
|
+
http://schemas.openxmlformats.org/drawingml/2006/main norm @dx emu
|
|
94
|
+
http://schemas.openxmlformats.org/drawingml/2006/main norm @dy emu
|
|
95
|
+
http://schemas.openxmlformats.org/drawingml/2006/main norm @dz emu
|
|
96
|
+
http://schemas.openxmlformats.org/drawingml/2006/main normAutofit @fontScale thousandthPercent
|
|
97
|
+
http://schemas.openxmlformats.org/drawingml/2006/main normAutofit @lnSpcReduction thousandthPercent
|
|
98
|
+
http://schemas.openxmlformats.org/drawingml/2006/main off @x emu
|
|
99
|
+
http://schemas.openxmlformats.org/drawingml/2006/main off @y emu
|
|
100
|
+
http://schemas.openxmlformats.org/drawingml/2006/main outerShdw @sx thousandthPercent
|
|
101
|
+
http://schemas.openxmlformats.org/drawingml/2006/main outerShdw @sy thousandthPercent
|
|
102
|
+
http://schemas.openxmlformats.org/drawingml/2006/main pPr @defTabSz emu
|
|
103
|
+
http://schemas.openxmlformats.org/drawingml/2006/main pos @x emu
|
|
104
|
+
http://schemas.openxmlformats.org/drawingml/2006/main pos @y emu
|
|
105
|
+
http://schemas.openxmlformats.org/drawingml/2006/main pt @x emu
|
|
106
|
+
http://schemas.openxmlformats.org/drawingml/2006/main pt @y emu
|
|
107
|
+
http://schemas.openxmlformats.org/drawingml/2006/main rPr @baseline thousandthPercent
|
|
108
|
+
http://schemas.openxmlformats.org/drawingml/2006/main rPr @spc hundredthPoints
|
|
109
|
+
http://schemas.openxmlformats.org/drawingml/2006/main rect @b emu
|
|
110
|
+
http://schemas.openxmlformats.org/drawingml/2006/main rect @l emu
|
|
111
|
+
http://schemas.openxmlformats.org/drawingml/2006/main rect @r emu
|
|
112
|
+
http://schemas.openxmlformats.org/drawingml/2006/main rect @t emu
|
|
113
|
+
http://schemas.openxmlformats.org/drawingml/2006/main red @val thousandthPercent
|
|
114
|
+
http://schemas.openxmlformats.org/drawingml/2006/main redMod @val thousandthPercent
|
|
115
|
+
http://schemas.openxmlformats.org/drawingml/2006/main redOff @val thousandthPercent
|
|
116
|
+
http://schemas.openxmlformats.org/drawingml/2006/main reflection @endA thousandthPercent
|
|
117
|
+
http://schemas.openxmlformats.org/drawingml/2006/main reflection @endPos thousandthPercent
|
|
118
|
+
http://schemas.openxmlformats.org/drawingml/2006/main reflection @stA thousandthPercent
|
|
119
|
+
http://schemas.openxmlformats.org/drawingml/2006/main reflection @stPos thousandthPercent
|
|
120
|
+
http://schemas.openxmlformats.org/drawingml/2006/main reflection @sx thousandthPercent
|
|
121
|
+
http://schemas.openxmlformats.org/drawingml/2006/main reflection @sy thousandthPercent
|
|
122
|
+
http://schemas.openxmlformats.org/drawingml/2006/main relOff @tx thousandthPercent
|
|
123
|
+
http://schemas.openxmlformats.org/drawingml/2006/main relOff @ty thousandthPercent
|
|
124
|
+
http://schemas.openxmlformats.org/drawingml/2006/main sat @val thousandthPercent
|
|
125
|
+
http://schemas.openxmlformats.org/drawingml/2006/main satMod @val thousandthPercent
|
|
126
|
+
http://schemas.openxmlformats.org/drawingml/2006/main satOff @val thousandthPercent
|
|
127
|
+
http://schemas.openxmlformats.org/drawingml/2006/main scrgbClr @b thousandthPercent
|
|
128
|
+
http://schemas.openxmlformats.org/drawingml/2006/main scrgbClr @g thousandthPercent
|
|
129
|
+
http://schemas.openxmlformats.org/drawingml/2006/main scrgbClr @r thousandthPercent
|
|
130
|
+
http://schemas.openxmlformats.org/drawingml/2006/main shade @val thousandthPercent
|
|
131
|
+
http://schemas.openxmlformats.org/drawingml/2006/main sp3d @z emu
|
|
132
|
+
http://schemas.openxmlformats.org/drawingml/2006/main spcPct @val thousandthPercent
|
|
133
|
+
http://schemas.openxmlformats.org/drawingml/2006/main srcRect @b thousandthPercent
|
|
134
|
+
http://schemas.openxmlformats.org/drawingml/2006/main srcRect @l thousandthPercent
|
|
135
|
+
http://schemas.openxmlformats.org/drawingml/2006/main srcRect @r thousandthPercent
|
|
136
|
+
http://schemas.openxmlformats.org/drawingml/2006/main srcRect @t thousandthPercent
|
|
137
|
+
http://schemas.openxmlformats.org/drawingml/2006/main tab @pos emu
|
|
138
|
+
http://schemas.openxmlformats.org/drawingml/2006/main tcPr @marB emu
|
|
139
|
+
http://schemas.openxmlformats.org/drawingml/2006/main tcPr @marL emu
|
|
140
|
+
http://schemas.openxmlformats.org/drawingml/2006/main tcPr @marR emu
|
|
141
|
+
http://schemas.openxmlformats.org/drawingml/2006/main tcPr @marT emu
|
|
142
|
+
http://schemas.openxmlformats.org/drawingml/2006/main tile @sx thousandthPercent
|
|
143
|
+
http://schemas.openxmlformats.org/drawingml/2006/main tile @sy thousandthPercent
|
|
144
|
+
http://schemas.openxmlformats.org/drawingml/2006/main tile @tx emu
|
|
145
|
+
http://schemas.openxmlformats.org/drawingml/2006/main tile @ty emu
|
|
146
|
+
http://schemas.openxmlformats.org/drawingml/2006/main tileRect @b thousandthPercent
|
|
147
|
+
http://schemas.openxmlformats.org/drawingml/2006/main tileRect @l thousandthPercent
|
|
148
|
+
http://schemas.openxmlformats.org/drawingml/2006/main tileRect @r thousandthPercent
|
|
149
|
+
http://schemas.openxmlformats.org/drawingml/2006/main tileRect @t thousandthPercent
|
|
150
|
+
http://schemas.openxmlformats.org/drawingml/2006/main tint @amt thousandthPercent
|
|
151
|
+
http://schemas.openxmlformats.org/drawingml/2006/main tint @val thousandthPercent
|
|
152
|
+
http://schemas.openxmlformats.org/drawingml/2006/main tr @h emu
|
|
153
|
+
http://schemas.openxmlformats.org/drawingml/2006/main up @dx emu
|
|
154
|
+
http://schemas.openxmlformats.org/drawingml/2006/main up @dy emu
|
|
155
|
+
http://schemas.openxmlformats.org/drawingml/2006/main up @dz emu
|
|
156
|
+
http://schemas.openxmlformats.org/drawingml/2006/main xfrm @sx thousandthPercent
|
|
157
|
+
http://schemas.openxmlformats.org/drawingml/2006/main xfrm @sy thousandthPercent
|
|
158
|
+
http://schemas.openxmlformats.org/drawingml/2006/main xfrm @tx emu
|
|
159
|
+
http://schemas.openxmlformats.org/drawingml/2006/main xfrm @ty emu
|
|
160
|
+
http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing bodyPr @bIns emu
|
|
161
|
+
http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing bodyPr @lIns emu
|
|
162
|
+
http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing bodyPr @rIns emu
|
|
163
|
+
http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing bodyPr @tIns emu
|
|
164
|
+
http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing effectExtent @b emu
|
|
165
|
+
http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing effectExtent @l emu
|
|
166
|
+
http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing effectExtent @r emu
|
|
167
|
+
http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing effectExtent @t emu
|
|
168
|
+
http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing lineTo @x emu
|
|
169
|
+
http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing lineTo @y emu
|
|
170
|
+
http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing simplePos @x emu
|
|
171
|
+
http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing simplePos @y emu
|
|
172
|
+
http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing start @x emu
|
|
173
|
+
http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing start @y emu
|
|
174
|
+
http://schemas.openxmlformats.org/officeDocument/2006/math interSp @val twips
|
|
175
|
+
http://schemas.openxmlformats.org/officeDocument/2006/math intraSp @val twips
|
|
176
|
+
http://schemas.openxmlformats.org/officeDocument/2006/math lMargin @val twips
|
|
177
|
+
http://schemas.openxmlformats.org/officeDocument/2006/math postSp @val twips
|
|
178
|
+
http://schemas.openxmlformats.org/officeDocument/2006/math preSp @val twips
|
|
179
|
+
http://schemas.openxmlformats.org/officeDocument/2006/math rMargin @val twips
|
|
180
|
+
http://schemas.openxmlformats.org/officeDocument/2006/math wrapIndent @val twips
|
|
181
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main bottom @w twips fiftiethPercent
|
|
182
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main col @space twips
|
|
183
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main col @w twips
|
|
184
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main cols @space twips
|
|
185
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main end @w twips fiftiethPercent
|
|
186
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main fitText @val twips
|
|
187
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main framePr @h twips
|
|
188
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main framePr @hSpace twips
|
|
189
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main framePr @vSpace twips
|
|
190
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main framePr @w twips
|
|
191
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main framePr @x twips
|
|
192
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main framePr @y twips
|
|
193
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main gridCol @w twips
|
|
194
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main hps @val halfPoints
|
|
195
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main hpsBaseText @val halfPoints
|
|
196
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main hpsRaise @val halfPoints
|
|
197
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main ind @end twips
|
|
198
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main ind @firstLine twips
|
|
199
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main ind @hanging twips
|
|
200
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main ind @left twips
|
|
201
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main ind @right twips
|
|
202
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main ind @start twips
|
|
203
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main kern @val halfPoints
|
|
204
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main left @w twips fiftiethPercent
|
|
205
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main lnNumType @distance twips
|
|
206
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main object @dxaOrig twips
|
|
207
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main object @dyaOrig twips
|
|
208
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main pgMar @bottom twips
|
|
209
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main pgMar @footer twips
|
|
210
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main pgMar @gutter twips
|
|
211
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main pgMar @header twips
|
|
212
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main pgMar @left twips
|
|
213
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main pgMar @right twips
|
|
214
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main pgMar @top twips
|
|
215
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main pgSz @h twips
|
|
216
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main pgSz @w twips
|
|
217
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main position @val halfPoints
|
|
218
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main right @w twips fiftiethPercent
|
|
219
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main size @val halfPoints
|
|
220
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main spacing @after twips
|
|
221
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main spacing @before twips
|
|
222
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main spacing @line twips
|
|
223
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main spacing @val twips
|
|
224
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main start @w twips fiftiethPercent
|
|
225
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main sz @val halfPoints
|
|
226
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main szCs @val halfPoints
|
|
227
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main tab @pos twips
|
|
228
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main tblCellSpacing @w twips fiftiethPercent
|
|
229
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main tblInd @w twips fiftiethPercent
|
|
230
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main tblW @w twips fiftiethPercent
|
|
231
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main tblpPr @bottomFromText twips
|
|
232
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main tblpPr @leftFromText twips
|
|
233
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main tblpPr @rightFromText twips
|
|
234
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main tblpPr @tblpX twips
|
|
235
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main tblpPr @tblpY twips
|
|
236
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main tblpPr @topFromText twips
|
|
237
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main tcW @w twips fiftiethPercent
|
|
238
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main top @w twips fiftiethPercent
|
|
239
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main trHeight @val twips
|
|
240
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main w @val wholePercent
|
|
241
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main wAfter @w twips fiftiethPercent
|
|
242
|
+
http://schemas.openxmlformats.org/wordprocessingml/2006/main wBefore @w twips fiftiethPercent`;
|
|
243
|
+
const readSlotTable = () => {
|
|
244
|
+
const slots = /* @__PURE__ */ new Map();
|
|
245
|
+
for (const line of SLOT_TABLE.split("\n")) {
|
|
246
|
+
const [slot, measure, percent] = line.split(" ");
|
|
247
|
+
if (slot === void 0) continue;
|
|
248
|
+
const measureUnit = measure === void 0 ? void 0 : MEASURE_UNITS[measure];
|
|
249
|
+
const percentUnit = percent === void 0 ? void 0 : PERCENT_UNITS[percent];
|
|
250
|
+
slots.set(slot, {
|
|
251
|
+
...measureUnit === void 0 ? {} : { measure: measureUnit },
|
|
252
|
+
...percentUnit === void 0 ? {} : { percent: percentUnit }
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
return slots;
|
|
256
|
+
};
|
|
257
|
+
/** Slots whose Transitional type spells one value two ways. */
|
|
258
|
+
const TRANSITIONAL_SLOT_ENCODINGS = readSlotTable();
|
|
259
|
+
/** Every Strict namespace URI a WordprocessingML part can carry, and its Transitional pair. */
|
|
260
|
+
const TRANSITIONAL_NAMESPACE_BY_STRICT_URI = /* @__PURE__ */ new Map([
|
|
261
|
+
["http://purl.oclc.org/ooxml/drawingml/chart", "http://schemas.openxmlformats.org/drawingml/2006/chart"],
|
|
262
|
+
["http://purl.oclc.org/ooxml/drawingml/chartDrawing", "http://schemas.openxmlformats.org/drawingml/2006/chartDrawing"],
|
|
263
|
+
["http://purl.oclc.org/ooxml/drawingml/diagram", "http://schemas.openxmlformats.org/drawingml/2006/diagram"],
|
|
264
|
+
["http://purl.oclc.org/ooxml/drawingml/lockedCanvas", "http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas"],
|
|
265
|
+
["http://purl.oclc.org/ooxml/drawingml/main", "http://schemas.openxmlformats.org/drawingml/2006/main"],
|
|
266
|
+
["http://purl.oclc.org/ooxml/drawingml/picture", "http://schemas.openxmlformats.org/drawingml/2006/picture"],
|
|
267
|
+
["http://purl.oclc.org/ooxml/drawingml/wordprocessingDrawing", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"],
|
|
268
|
+
["http://purl.oclc.org/ooxml/officeDocument/math", "http://schemas.openxmlformats.org/officeDocument/2006/math"],
|
|
269
|
+
["http://purl.oclc.org/ooxml/officeDocument/relationships", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"],
|
|
270
|
+
["http://purl.oclc.org/ooxml/officeDocument/sharedTypes", "http://schemas.openxmlformats.org/officeDocument/2006/sharedTypes"],
|
|
271
|
+
["http://purl.oclc.org/ooxml/schemaLibrary/main", "http://schemas.openxmlformats.org/schemaLibrary/2006/main"],
|
|
272
|
+
["http://purl.oclc.org/ooxml/wordprocessingml/main", "http://schemas.openxmlformats.org/wordprocessingml/2006/main"]
|
|
273
|
+
]);
|
|
274
|
+
//#endregion
|
|
275
|
+
export { TRANSITIONAL_NAMESPACE_BY_STRICT_URI, TRANSITIONAL_SLOT_ENCODINGS };
|
|
@@ -59,12 +59,6 @@ declare function parseTableLook(lookElement: XmlElement | null): document_d_expo
|
|
|
59
59
|
* @returns Parsed floating properties or undefined
|
|
60
60
|
*/
|
|
61
61
|
declare function parseFloatingTableProperties(tblpPrElement: XmlElement | null): document_d_exports.FloatingTableProperties | undefined;
|
|
62
|
-
/**
|
|
63
|
-
* Parse table properties (w:tblPr)
|
|
64
|
-
*
|
|
65
|
-
* @param tblPrElement - The w:tblPr element
|
|
66
|
-
* @returns Parsed table formatting
|
|
67
|
-
*/
|
|
68
62
|
declare function parseTableProperties(tblPrElement: XmlElement | null): document_d_exports.TableFormatting | undefined;
|
|
69
63
|
/**
|
|
70
64
|
* Parse table row properties (w:trPr)
|
package/dist/docx/tableParser.js
CHANGED
|
@@ -3,7 +3,8 @@ import { appendBookmarkMarkerToLastParagraphInBlocks, appendBookmarkMarkerToLast
|
|
|
3
3
|
import { parseParagraph } from "./paragraphParser.js";
|
|
4
4
|
import { enrichParagraphTextBoxes } from "./paragraphTextBoxEnrichment.js";
|
|
5
5
|
import { BorderStyleSchema, FloatingTableXSpecSchema, FloatingTableYSpecSchema, ShadingPatternSchema, TableCellTextDirectionSchema, ThemeColorSlotSchema, narrowEnum } from "./parserEnums.js";
|
|
6
|
-
import {
|
|
6
|
+
import { captureVerbatimXml } from "./verbatimCapture.js";
|
|
7
|
+
import { cloneElement, findChild, findChildByLocalName, findChildren, getAttribute, getChildElements, getLocalName, mergeXmlnsDeclarations, parseBooleanElement, parseNumericAttribute, parseTableMeasurementValue } from "./xmlParser.js";
|
|
7
8
|
import { normalizeRevisionId } from "@stll/docx-core/model";
|
|
8
9
|
//#region src/docx/tableParser.ts
|
|
9
10
|
/**
|
|
@@ -47,8 +48,22 @@ function parseTrackedChangeInfo(node) {
|
|
|
47
48
|
};
|
|
48
49
|
if (date.length > 0) info.date = date;
|
|
49
50
|
if (initials.length > 0) info.initials = initials;
|
|
51
|
+
const utcDate = utcDateAttribute(node);
|
|
52
|
+
if (utcDate) info.utcDate = utcDate;
|
|
50
53
|
return info;
|
|
51
54
|
}
|
|
55
|
+
/** `w16du:dateUtc` under whatever prefix the document bound it to. */
|
|
56
|
+
const utcDateAttribute = (node) => {
|
|
57
|
+
for (const [attribute, value] of Object.entries(node.attributes ?? {})) {
|
|
58
|
+
if (typeof value !== "string" || getLocalName(attribute) !== "dateUtc") continue;
|
|
59
|
+
const trimmed = value.trim();
|
|
60
|
+
if (trimmed.length > 0) return {
|
|
61
|
+
attribute,
|
|
62
|
+
value: trimmed
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
};
|
|
52
67
|
function parsePropertyChangeInfo(node) {
|
|
53
68
|
const base = parseTrackedChangeInfo(node);
|
|
54
69
|
const rsid = (getAttribute(node, "w", "rsid") ?? "").trim();
|
|
@@ -245,6 +260,31 @@ function parseFloatingTableProperties(tblpPrElement) {
|
|
|
245
260
|
* @param tblPrElement - The w:tblPr element
|
|
246
261
|
* @returns Parsed table formatting
|
|
247
262
|
*/
|
|
263
|
+
/**
|
|
264
|
+
* Children of a property element that record a revision rather than a
|
|
265
|
+
* property. They are parsed into records of their own and written back from
|
|
266
|
+
* those, so the capture leaves them out: a capture that kept them would put a
|
|
267
|
+
* resolved revision back into the document after it was accepted.
|
|
268
|
+
*/
|
|
269
|
+
const REVISION_PROPERTY_CHILDREN = /* @__PURE__ */ new Set([
|
|
270
|
+
"tblPrChange",
|
|
271
|
+
"trPrChange",
|
|
272
|
+
"tcPrChange",
|
|
273
|
+
"ins",
|
|
274
|
+
"del",
|
|
275
|
+
"cellIns",
|
|
276
|
+
"cellDel",
|
|
277
|
+
"cellMerge"
|
|
278
|
+
]);
|
|
279
|
+
/**
|
|
280
|
+
* The property element a formatting object was parsed from, kept beside the
|
|
281
|
+
* typed values so a save that did not touch them writes the element back
|
|
282
|
+
* exactly as it arrived.
|
|
283
|
+
*/
|
|
284
|
+
const withSourceXml = (formatting, element) => ({
|
|
285
|
+
...formatting,
|
|
286
|
+
sourceXml: captureVerbatimXml(cloneElement(element, { elements: (element.elements ?? []).filter((child) => !REVISION_PROPERTY_CHILDREN.has(getLocalName(child.name))) }))
|
|
287
|
+
});
|
|
248
288
|
function parseTableProperties(tblPrElement) {
|
|
249
289
|
if (!tblPrElement) return;
|
|
250
290
|
const formatting = {};
|
|
@@ -287,7 +327,7 @@ function parseTableProperties(tblPrElement) {
|
|
|
287
327
|
const bidiVisual = findChild(tblPrElement, "w", "bidiVisual");
|
|
288
328
|
if (bidiVisual) formatting.bidi = parseBooleanElement(bidiVisual);
|
|
289
329
|
if (Object.keys(formatting).length === 0) return;
|
|
290
|
-
return formatting;
|
|
330
|
+
return withSourceXml(formatting, tblPrElement);
|
|
291
331
|
}
|
|
292
332
|
function parseTablePropertyChanges(tblPrElement, currentFormatting) {
|
|
293
333
|
if (!tblPrElement) return;
|
|
@@ -415,7 +455,7 @@ function parseTableRowProperties(trPrElement) {
|
|
|
415
455
|
const conditionalFormat = parseConditionalFormatStyle(findChild(trPrElement, "w", "cnfStyle"));
|
|
416
456
|
if (conditionalFormat) formatting.conditionalFormat = conditionalFormat;
|
|
417
457
|
if (Object.keys(formatting).length === 0) return;
|
|
418
|
-
return formatting;
|
|
458
|
+
return withSourceXml(formatting, trPrElement);
|
|
419
459
|
}
|
|
420
460
|
/**
|
|
421
461
|
* Parse conditional format style (for table style conditional formatting)
|
|
@@ -505,12 +545,12 @@ function parseTableCellProperties(tcPrElement) {
|
|
|
505
545
|
else formatting.vMerge = "continue";
|
|
506
546
|
if (parseBooleanElement(findChild(tcPrElement, "w", "tcFitText"))) formatting.fitText = true;
|
|
507
547
|
if (parseBooleanElement(findChild(tcPrElement, "w", "noWrap"))) formatting.noWrap = true;
|
|
508
|
-
const
|
|
509
|
-
if (
|
|
548
|
+
const hideMarkElement = findChild(tcPrElement, "w", "hideMark");
|
|
549
|
+
if (hideMarkElement) formatting.hideMark = parseBooleanElement(hideMarkElement);
|
|
510
550
|
const conditionalFormat = parseConditionalFormatStyle(findChild(tcPrElement, "w", "cnfStyle"));
|
|
511
551
|
if (conditionalFormat) formatting.conditionalFormat = conditionalFormat;
|
|
512
552
|
if (Object.keys(formatting).length === 0) return;
|
|
513
|
-
return formatting;
|
|
553
|
+
return withSourceXml(formatting, tcPrElement);
|
|
514
554
|
}
|
|
515
555
|
/**
|
|
516
556
|
* Accumulate a table container's own `xmlns:*` onto the inherited in-scope set,
|
|
@@ -731,8 +771,13 @@ function parseTable(tblElement, styles, theme, numbering, rels, media, options)
|
|
|
731
771
|
if (formatting) table.formatting = formatting;
|
|
732
772
|
const tblPropChanges = parseTablePropertyChanges(tblPrElement, formatting);
|
|
733
773
|
if (tblPropChanges !== void 0) table.propertyChanges = tblPropChanges;
|
|
734
|
-
const
|
|
774
|
+
const gridElement = findChild(tblElement, "w", "tblGrid");
|
|
775
|
+
const columnWidths = parseTableGrid(gridElement);
|
|
735
776
|
if (columnWidths) table.columnWidths = columnWidths;
|
|
777
|
+
if (gridElement) table.formatting = {
|
|
778
|
+
...table.formatting,
|
|
779
|
+
gridSourceXml: captureVerbatimXml(gridElement)
|
|
780
|
+
};
|
|
736
781
|
const tableOptions = withContainerXmlns(options, tblElement);
|
|
737
782
|
const rowsWithGridOffsets = /* @__PURE__ */ new Set();
|
|
738
783
|
const parseTableChild = (child) => {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SlotEncoding } from "./strictValueEncodings.gen.js";
|
|
2
|
+
//#region src/docx/transitionalSpelling.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The Transitional URI a Strict one stands for, or the URI unchanged.
|
|
5
|
+
*
|
|
6
|
+
* Also used when a rebuilt part falls back to a binding its source declared:
|
|
7
|
+
* declaring a Strict URI on a Transitional root puts every element under that
|
|
8
|
+
* prefix back into the wrong vocabulary.
|
|
9
|
+
*/
|
|
10
|
+
declare const toTransitionalNamespaceUri: (uri: string) => string;
|
|
11
|
+
/** True for a namespace ECMA-376 Part 4 republished under `purl.oclc.org`. */
|
|
12
|
+
declare const isStrictNamespaceUri: (uri: string) => boolean;
|
|
13
|
+
/** Namespaces ECMA-376 Part 4 republished; nothing else starts with this. */
|
|
14
|
+
declare const STRICT_URI_PREFIX = "http://purl.oclc.org/ooxml/";
|
|
15
|
+
/**
|
|
16
|
+
* How one slot's Transitional type spells its value as a number.
|
|
17
|
+
*
|
|
18
|
+
* `namespaceUri` is the element's, in either conformance class; the lookup
|
|
19
|
+
* translates it. Omit `attributeLocalName` for element text content.
|
|
20
|
+
*/
|
|
21
|
+
declare const transitionalSlotEncoding: (namespaceUri: string | undefined, elementLocalName: string, attributeLocalName?: string) => SlotEncoding | undefined;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { STRICT_URI_PREFIX, isStrictNamespaceUri, toTransitionalNamespaceUri, transitionalSlotEncoding };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { TRANSITIONAL_NAMESPACE_BY_STRICT_URI, TRANSITIONAL_SLOT_ENCODINGS } from "./strictValueEncodings.gen.js";
|
|
2
|
+
//#region src/docx/transitionalSpelling.ts
|
|
3
|
+
/**
|
|
4
|
+
* Reading a Strict-spelled value as the Transitional number it stands for.
|
|
5
|
+
*
|
|
6
|
+
* Two places need it: the verbatim-capture conversion, which rewrites a
|
|
7
|
+
* fragment on its way into a rebuilt part, and the typed projection, which has
|
|
8
|
+
* to reach the same number so the model and the markup do not disagree about a
|
|
9
|
+
* width. Both go through {@link transitionalSlotEncoding} rather than deciding
|
|
10
|
+
* for themselves which attributes carry a unit.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* The Transitional URI a Strict one stands for, or the URI unchanged.
|
|
14
|
+
*
|
|
15
|
+
* Also used when a rebuilt part falls back to a binding its source declared:
|
|
16
|
+
* declaring a Strict URI on a Transitional root puts every element under that
|
|
17
|
+
* prefix back into the wrong vocabulary.
|
|
18
|
+
*/
|
|
19
|
+
const toTransitionalNamespaceUri = (uri) => TRANSITIONAL_NAMESPACE_BY_STRICT_URI.get(uri) ?? uri;
|
|
20
|
+
/** True for a namespace ECMA-376 Part 4 republished under `purl.oclc.org`. */
|
|
21
|
+
const isStrictNamespaceUri = (uri) => TRANSITIONAL_NAMESPACE_BY_STRICT_URI.has(uri);
|
|
22
|
+
/** Namespaces ECMA-376 Part 4 republished; nothing else starts with this. */
|
|
23
|
+
const STRICT_URI_PREFIX = "http://purl.oclc.org/ooxml/";
|
|
24
|
+
/**
|
|
25
|
+
* How one slot's Transitional type spells its value as a number.
|
|
26
|
+
*
|
|
27
|
+
* `namespaceUri` is the element's, in either conformance class; the lookup
|
|
28
|
+
* translates it. Omit `attributeLocalName` for element text content.
|
|
29
|
+
*/
|
|
30
|
+
const transitionalSlotEncoding = (namespaceUri, elementLocalName, attributeLocalName) => {
|
|
31
|
+
if (namespaceUri === void 0) return;
|
|
32
|
+
const slot = `${toTransitionalNamespaceUri(namespaceUri)} ${elementLocalName}`;
|
|
33
|
+
return TRANSITIONAL_SLOT_ENCODINGS.get(attributeLocalName === void 0 ? slot : `${slot} @${attributeLocalName}`);
|
|
34
|
+
};
|
|
35
|
+
//#endregion
|
|
36
|
+
export { STRICT_URI_PREFIX, isStrictNamespaceUri, toTransitionalNamespaceUri, transitionalSlotEncoding };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/docx/universalMeasure.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* ECMA-376's unit-carrying length, and the numbers Transitional counts it in.
|
|
4
|
+
*
|
|
5
|
+
* `ST_UniversalMeasure` spells a length as a decimal with its unit attached
|
|
6
|
+
* (`155.85pt`, `2.54cm`). Strict producers write it wherever the type allows;
|
|
7
|
+
* Transitional attributes are read as plain numbers in a fixed unit, so both
|
|
8
|
+
* the verbatim-capture conversion and the typed projection have to agree on
|
|
9
|
+
* what one of those strings is worth. They share this module so they cannot.
|
|
10
|
+
*/
|
|
11
|
+
/** The unit a Transitional attribute's number is counted in. */
|
|
12
|
+
type MeasureUnit = "emu" | "halfPoints" | "hundredthPoints" | "twips";
|
|
13
|
+
/** Round half away from zero, so a negative offset keeps a positive one's magnitude. */
|
|
14
|
+
declare const roundHalfAwayFromZero: (value: number) => number;
|
|
15
|
+
/** The value of a universal measure in points, or `undefined` if it is not one. */
|
|
16
|
+
declare const universalMeasureInPoints: (value: string) => number | undefined;
|
|
17
|
+
/** A universal measure as the whole number a Transitional attribute of `unit` holds. */
|
|
18
|
+
declare const universalMeasureAs: (value: string, unit: MeasureUnit) => number | undefined;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { MeasureUnit, roundHalfAwayFromZero, universalMeasureAs, universalMeasureInPoints };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/docx/universalMeasure.ts
|
|
2
|
+
/** `-?123.45pt`: the one shape ECMA-376 gives a length that carries its unit. */
|
|
3
|
+
const UNIVERSAL_MEASURE = /^(-?[0-9]+(?:\.[0-9]+)?)(mm|cm|in|pt|pc|pi)$/u;
|
|
4
|
+
const POINTS_PER_UNIT = {
|
|
5
|
+
cm: 72 / 2.54,
|
|
6
|
+
in: 72,
|
|
7
|
+
mm: 72 / 25.4,
|
|
8
|
+
pc: 12,
|
|
9
|
+
pi: 12,
|
|
10
|
+
pt: 1
|
|
11
|
+
};
|
|
12
|
+
const NUMBERS_PER_POINT = {
|
|
13
|
+
emu: 12700,
|
|
14
|
+
halfPoints: 2,
|
|
15
|
+
hundredthPoints: 100,
|
|
16
|
+
twips: 20
|
|
17
|
+
};
|
|
18
|
+
/** Round half away from zero, so a negative offset keeps a positive one's magnitude. */
|
|
19
|
+
const roundHalfAwayFromZero = (value) => value < 0 ? -Math.round(-value) : Math.round(value);
|
|
20
|
+
/** The value of a universal measure in points, or `undefined` if it is not one. */
|
|
21
|
+
const universalMeasureInPoints = (value) => {
|
|
22
|
+
const match = UNIVERSAL_MEASURE.exec(value);
|
|
23
|
+
if (match === null) return;
|
|
24
|
+
return Number(match[1]) * POINTS_PER_UNIT[match[2]];
|
|
25
|
+
};
|
|
26
|
+
/** A universal measure as the whole number a Transitional attribute of `unit` holds. */
|
|
27
|
+
const universalMeasureAs = (value, unit) => {
|
|
28
|
+
const points = universalMeasureInPoints(value);
|
|
29
|
+
return points === void 0 ? void 0 : roundHalfAwayFromZero(points * NUMBERS_PER_POINT[unit]);
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
export { roundHalfAwayFromZero, universalMeasureAs, universalMeasureInPoints };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { XmlElement } from "./xmlParser.js";
|
|
2
|
+
//#region src/docx/verbatimCapture.d.ts
|
|
3
|
+
declare const UntranslatableStrictNamespaceError_base: import("better-result").TaggedErrorClass<"UntranslatableStrictNamespaceError">;
|
|
4
|
+
/** A Strict fragment uses a namespace that has no Transitional counterpart. */
|
|
5
|
+
declare class UntranslatableStrictNamespaceError extends UntranslatableStrictNamespaceError_base<{
|
|
6
|
+
message: string;
|
|
7
|
+
uri: string;
|
|
8
|
+
}> {}
|
|
9
|
+
/**
|
|
10
|
+
* Serialize parsed markup for replay inside a rebuilt Transitional part.
|
|
11
|
+
*
|
|
12
|
+
* Every verbatim capture goes through here — a lint rule keeps
|
|
13
|
+
* {@link elementToXml} out of reach of the parsers — so a replay path added
|
|
14
|
+
* later cannot skip the conversion. Markup that binds no Strict namespace,
|
|
15
|
+
* anywhere in scope or in the fragment itself, is serialized once and returned
|
|
16
|
+
* unchanged.
|
|
17
|
+
*/
|
|
18
|
+
declare const captureVerbatimXml: (element: XmlElement) => string;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { UntranslatableStrictNamespaceError, captureVerbatimXml };
|