@portone/docx-editor 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +109 -0
- package/CONTRIBUTING.md +5 -1
- package/dist/DocxEditor.d.ts +6 -0
- package/dist/DocxEditor.js +12 -29
- package/dist/core.d.ts +23 -8
- package/dist/core.js +9 -4
- package/dist/docx/cloning.d.ts +38 -0
- package/dist/docx/cloning.js +74 -0
- package/dist/docx/commentOnlyChange.d.ts +12 -7
- package/dist/docx/commentOnlyChange.js +9 -156
- package/dist/docx/comments/constants.d.ts +0 -1
- package/dist/docx/comments/constants.js +0 -2
- package/dist/docx/comments/grammar.d.ts +10 -4
- package/dist/docx/comments/grammar.js +12 -2
- package/dist/docx/comments/{verifying.d.ts → parts.d.ts} +26 -18
- package/dist/docx/comments/parts.js +279 -0
- package/dist/docx/comments/people.d.ts +11 -2
- package/dist/docx/comments/people.js +16 -92
- package/dist/docx/comments/policy.d.ts +7 -0
- package/dist/docx/comments/policy.js +43 -0
- package/dist/docx/comments/reading.js +8 -10
- package/dist/docx/comments/writing.d.ts +19 -7
- package/dist/docx/comments/writing.js +52 -111
- package/dist/docx/documentSettings.d.ts +7 -0
- package/dist/docx/documentSettings.js +10 -2
- package/dist/docx/exportDocx.d.ts +40 -5
- package/dist/docx/exportDocx.js +69 -71
- package/dist/docx/exportRefs.d.ts +5 -2
- package/dist/docx/exportRefs.js +3 -1
- package/dist/docx/fidelity.d.ts +43 -0
- package/dist/docx/fidelity.js +64 -0
- package/dist/docx/formatting/attrs.d.ts +27 -0
- package/dist/docx/formatting/attrs.js +31 -0
- package/dist/docx/formatting/context.d.ts +31 -0
- package/dist/docx/formatting/context.js +42 -0
- package/dist/docx/formatting/direct.d.ts +6 -5
- package/dist/docx/formatting/direct.js +52 -78
- package/dist/docx/formatting/resolve.d.ts +45 -0
- package/dist/docx/formatting/resolve.js +140 -0
- package/dist/docx/formatting/runProperties.d.ts +93 -0
- package/dist/docx/formatting/runProperties.js +316 -0
- package/dist/docx/formatting/styles.js +3 -3
- package/dist/docx/formatting/tabStops.js +7 -22
- package/dist/docx/formatting.d.ts +4 -1
- package/dist/docx/formatting.js +4 -1
- package/dist/docx/headersFooters.js +6 -13
- package/dist/docx/identities.d.ts +67 -0
- package/dist/docx/identities.js +174 -0
- package/dist/docx/importDocx.d.ts +12 -1
- package/dist/docx/importDocx.js +72 -79
- package/dist/docx/importParagraph.d.ts +1 -1
- package/dist/docx/importParagraph.js +4 -3
- package/dist/docx/importTable.d.ts +1 -1
- package/dist/docx/importTable.js +17 -1
- package/dist/docx/invariants.d.ts +33 -0
- package/dist/docx/invariants.js +256 -0
- package/dist/docx/media.d.ts +6 -4
- package/dist/docx/media.js +6 -37
- package/dist/docx/newLists.d.ts +20 -0
- package/dist/docx/newLists.js +36 -0
- package/dist/docx/notes.js +3 -7
- package/dist/docx/numberingPlanner.d.ts +8 -0
- package/dist/docx/numberingPlanner.js +19 -0
- package/dist/docx/packageParts.d.ts +42 -0
- package/dist/docx/packageParts.js +135 -0
- package/dist/docx/pageGeometry.d.ts +2 -0
- package/dist/docx/pageGeometry.js +18 -9
- package/dist/docx/paraProps.d.ts +10 -22
- package/dist/docx/paraProps.js +47 -76
- package/dist/docx/partPlan.d.ts +36 -0
- package/dist/docx/partPlan.js +59 -0
- package/dist/docx/protectionPolicy.d.ts +127 -0
- package/dist/docx/protectionPolicy.js +169 -0
- package/dist/docx/relationships.d.ts +1 -1
- package/dist/docx/relationships.js +8 -13
- package/dist/docx/runProps.d.ts +9 -22
- package/dist/docx/runProps.js +15 -168
- package/dist/docx/scan.js +20 -52
- package/dist/docx/sdt.js +9 -34
- package/dist/docx/sdtProps.d.ts +8 -1
- package/dist/docx/sdtProps.js +10 -0
- package/dist/docx/serializeBlock.d.ts +2 -0
- package/dist/docx/serializeBlock.js +8 -5
- package/dist/docx/serializeTable.js +32 -15
- package/dist/docx/session.d.ts +42 -14
- package/dist/docx/session.js +43 -17
- package/dist/docx/tableFormatting/editing.js +108 -139
- package/dist/docx/tableFormatting/reading.d.ts +16 -6
- package/dist/docx/tableFormatting/reading.js +40 -20
- package/dist/docx/tableTemplate.js +18 -7
- package/dist/download.d.ts +8 -5
- package/dist/download.js +2 -0
- package/dist/editor/clipboard/inlineFormatting.js +19 -30
- package/dist/editor/commands/comments/editing.d.ts +6 -2
- package/dist/editor/commands/comments/editing.js +19 -31
- package/dist/editor/commands/exportQueries.d.ts +15 -0
- package/dist/editor/commands/exportQueries.js +14 -0
- package/dist/editor/commands/fidelityQueries.d.ts +12 -0
- package/dist/editor/commands/fidelityQueries.js +8 -0
- package/dist/editor/commands/formatting/editing.d.ts +2 -2
- package/dist/editor/commands/formatting/editing.js +26 -108
- package/dist/editor/commands/formatting/propertyCommands.d.ts +21 -0
- package/dist/editor/commands/formatting/propertyCommands.js +103 -0
- package/dist/editor/commands/formatting/shared.d.ts +3 -3
- package/dist/editor/commands/formatting/shared.js +5 -2
- package/dist/editor/commands/indentCommands.js +5 -4
- package/dist/editor/commands/index.d.ts +11 -0
- package/dist/editor/commands/index.js +5 -0
- package/dist/editor/commands/linkCommands.js +5 -6
- package/dist/editor/commands/listCommands.js +8 -10
- package/dist/editor/commands/lockCommands.d.ts +7 -1
- package/dist/editor/commands/lockCommands.js +35 -46
- package/dist/editor/commands/paragraphCommands.js +28 -31
- package/dist/editor/commands/spacingCommands.js +1 -1
- package/dist/editor/createEditor.d.ts +17 -29
- package/dist/editor/createEditor.js +58 -58
- package/dist/editor/documentStyles.d.ts +11 -35
- package/dist/editor/documentStyles.js +9 -52
- package/dist/editor/editorDocument.d.ts +56 -0
- package/dist/editor/editorDocument.js +74 -0
- package/dist/editor/externalClipboard.js +16 -45
- package/dist/editor/insertTable.js +4 -3
- package/dist/editor/paragraphEdits.d.ts +11 -18
- package/dist/editor/paragraphEdits.js +7 -16
- package/dist/editor/plugins/displayDerivation.d.ts +47 -0
- package/dist/editor/plugins/displayDerivation.js +78 -0
- package/dist/editor/plugins/imagePaste.js +4 -3
- package/dist/editor/plugins/keymap.js +18 -3
- package/dist/editor/plugins/numberingDecorations.d.ts +5 -11
- package/dist/editor/plugins/numberingDecorations.js +7 -17
- package/dist/editor/plugins/paragraphDisplay.d.ts +7 -0
- package/dist/editor/plugins/paragraphDisplay.js +51 -0
- package/dist/editor/plugins/tabLayout.js +1 -1
- package/dist/editor/plugins/tableDisplay.d.ts +6 -0
- package/dist/editor/plugins/tableDisplay.js +16 -0
- package/dist/index.d.ts +2 -0
- package/dist/model/format.d.ts +30 -8
- package/dist/model/format.js +35 -22
- package/dist/model/tabStops.d.ts +9 -0
- package/dist/model/tabStops.js +18 -0
- package/dist/numbering/listTemplate.js +24 -7
- package/dist/numbering/parseNumbering.d.ts +14 -1
- package/dist/numbering/parseNumbering.js +35 -22
- package/dist/numbering/writeNumbering.d.ts +3 -4
- package/dist/numbering/writeNumbering.js +14 -25
- package/dist/ooxml/childOrder.d.ts +34 -0
- package/dist/ooxml/childOrder.js +496 -0
- package/dist/ooxml/element.d.ts +24 -11
- package/dist/ooxml/element.js +31 -12
- package/dist/ooxml/errors.d.ts +3 -2
- package/dist/ooxml/image.d.ts +4 -0
- package/dist/ooxml/image.js +2 -5
- package/dist/ooxml/partSplice.d.ts +67 -0
- package/dist/ooxml/partSplice.js +169 -0
- package/dist/ooxml/props.d.ts +112 -0
- package/dist/{docx/propsXml.js → ooxml/props.js} +72 -200
- package/dist/ooxml/simpleTypes.d.ts +103 -0
- package/dist/ooxml/simpleTypes.js +182 -0
- package/dist/ooxml/tabStops.js +8 -27
- package/dist/ooxml/tagScan.d.ts +34 -0
- package/dist/ooxml/tagScan.js +108 -0
- package/dist/ooxml/units.d.ts +25 -13
- package/dist/ooxml/units.js +65 -31
- package/dist/ooxml/xml.d.ts +27 -6
- package/dist/ooxml/xml.js +37 -5
- package/dist/page/blockKinds.d.ts +61 -0
- package/dist/page/blockKinds.js +11 -0
- package/dist/page/kinds/index.d.ts +6 -0
- package/dist/page/kinds/index.js +10 -0
- package/dist/page/kinds/paragraphKind.d.ts +10 -0
- package/dist/page/kinds/paragraphKind.js +71 -0
- package/dist/page/kinds/tableKind.d.ts +10 -0
- package/dist/page/kinds/tableKind.js +178 -0
- package/dist/page/measureBlocks.d.ts +3 -14
- package/dist/page/measureBlocks.js +24 -45
- package/dist/page/pageDecorations.d.ts +27 -44
- package/dist/page/pageDecorations.js +70 -152
- package/dist/page/pageLayout.d.ts +2 -19
- package/dist/page/pageLayout.js +36 -6
- package/dist/page/usePageLayout.d.ts +2 -17
- package/dist/page/usePageLayout.js +3 -39
- package/dist/schema/attrRoles.d.ts +25 -18
- package/dist/schema/attrRoles.js +102 -67
- package/dist/schema/displayDerivation.d.ts +82 -0
- package/dist/schema/displayDerivation.js +130 -0
- package/dist/schema/docxSchema.d.ts +3 -0
- package/dist/schema/docxSchema.js +26 -14
- package/dist/schema/editGuard.d.ts +1 -1
- package/dist/schema/guards.d.ts +37 -14
- package/dist/schema/guards.js +29 -3
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/index.js +2 -0
- package/dist/schema/locks.d.ts +11 -44
- package/dist/schema/locks.js +0 -9
- package/dist/schema/preservedGuards.d.ts +26 -6
- package/dist/schema/preservedGuards.js +31 -1
- package/dist/schema/protection.d.ts +7 -1
- package/dist/schema/protection.js +2 -1
- package/dist/schema/sourceEquality.d.ts +1 -9
- package/dist/schema/sourceEquality.js +1 -27
- package/dist/styles/inlineStyle.js +15 -6
- package/dist/table/cellFormatting.d.ts +8 -1
- package/dist/table/cellFormatting.js +10 -18
- package/dist/table/commands.js +20 -18
- package/dist/table/format.d.ts +3 -0
- package/dist/table/format.js +3 -9
- package/dist/table/gridBorders.d.ts +14 -16
- package/dist/table/gridBorders.js +3 -41
- package/dist/table/merge.d.ts +2 -6
- package/dist/table/merge.js +5 -5
- package/package.json +7 -3
- package/dist/docx/comments/contentTypes.d.ts +0 -7
- package/dist/docx/comments/contentTypes.js +0 -38
- package/dist/docx/comments/verifying.js +0 -206
- package/dist/docx/formatting/effectiveParagraph.d.ts +0 -15
- package/dist/docx/formatting/effectiveParagraph.js +0 -81
- package/dist/docx/propsXml.d.ts +0 -67
- package/dist/docx/uniqueControls.d.ts +0 -14
- package/dist/docx/uniqueControls.js +0 -62
- package/dist/editor/plugins/commentReservations.d.ts +0 -5
- package/dist/editor/plugins/commentReservations.js +0 -26
- package/dist/editor/plugins/styledParagraphs.d.ts +0 -15
- package/dist/editor/plugins/styledParagraphs.js +0 -65
- package/dist/page/tableMeasurements.d.ts +0 -18
- package/dist/page/tableMeasurements.js +0 -119
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Splices the definitions of newly started lists into the original numbering.xml.
|
|
3
3
|
*
|
|
4
|
-
* Not one character of the original is altered; new elements are merely slotted in
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* the definitions go in front of the first number and the numbers go at the very end.
|
|
4
|
+
* Not one character of the original is altered; new elements are merely slotted in.
|
|
5
|
+
* OOXML requires the definitions (`abstractNum`) to come before the numbers (`num`), and
|
|
6
|
+
* `CHILD_ORDER.numbering` is what places each where it belongs among what the part holds.
|
|
8
7
|
*/
|
|
9
8
|
/**
|
|
10
9
|
* numbering.xml with a standard template definition added for every list number.
|
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
// src/numbering/writeNumbering.ts
|
|
2
|
-
import {
|
|
2
|
+
import { splicePart } from "../ooxml/partSplice.js";
|
|
3
3
|
import { wAttr } from "../ooxml/units.js";
|
|
4
4
|
import { elementChildren, parseXml } from "../ooxml/xml.js";
|
|
5
5
|
import { abstractNumXml, listKindOf, numXml } from "./listTemplate.js";
|
|
6
|
-
function openTagAt(xml, name) {
|
|
7
|
-
const match = new RegExp(`<(?:[A-Za-z_][\\w.-]*:)?${name}[\\s/>]`).exec(xml);
|
|
8
|
-
return match ? match.index : null;
|
|
9
|
-
}
|
|
10
|
-
function closeTagAt(xml, name) {
|
|
11
|
-
const matches = Array.from(
|
|
12
|
-
xml.matchAll(new RegExp(`</(?:[A-Za-z_][\\w.-]*:)?${name}\\s*>`, "g"))
|
|
13
|
-
);
|
|
14
|
-
return matches.at(-1)?.index ?? null;
|
|
15
|
-
}
|
|
16
6
|
function maxAbstractNumId(xml) {
|
|
17
7
|
let max = 0;
|
|
18
8
|
for (const child of elementChildren(parseXml(xml).documentElement)) {
|
|
@@ -24,25 +14,24 @@ function maxAbstractNumId(xml) {
|
|
|
24
14
|
}
|
|
25
15
|
function addListDefinitions(xml, numIds) {
|
|
26
16
|
if (numIds.length === 0) return xml;
|
|
27
|
-
const rootEnd = closeTagAt(xml, "numbering");
|
|
28
|
-
if (rootEnd === null) {
|
|
29
|
-
throw new DocxExportError(
|
|
30
|
-
"malformed-xml",
|
|
31
|
-
"no closing tag found in numbering.xml"
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
const numsAt = openTagAt(xml, "numIdMacAtCleanup") ?? rootEnd;
|
|
35
|
-
const definitionsAt = openTagAt(xml, "num") ?? numsAt;
|
|
36
17
|
const firstAbstractNumId = maxAbstractNumId(xml) + 1;
|
|
37
18
|
const additions = [...numIds].sort((a, b) => a - b).map((numId, index) => ({
|
|
38
19
|
numId,
|
|
39
20
|
abstractNumId: firstAbstractNumId + index
|
|
40
21
|
}));
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
22
|
+
return splicePart(xml, {
|
|
23
|
+
root: "numbering",
|
|
24
|
+
insert: [
|
|
25
|
+
...additions.map((added) => ({
|
|
26
|
+
name: "abstractNum",
|
|
27
|
+
xml: abstractNumXml(added.abstractNumId, listKindOf(added.numId))
|
|
28
|
+
})),
|
|
29
|
+
...additions.map((added) => ({
|
|
30
|
+
name: "num",
|
|
31
|
+
xml: numXml(added.numId, added.abstractNumId)
|
|
32
|
+
}))
|
|
33
|
+
]
|
|
34
|
+
});
|
|
46
35
|
}
|
|
47
36
|
export {
|
|
48
37
|
addListDefinitions
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The order the children of one element go in, per parent.
|
|
3
|
+
*
|
|
4
|
+
* A writer that swaps one child of a formatting fragment has to put a child that was not there
|
|
5
|
+
* into the spot the format lays down, and `wml.xsd` is what lays it down. Each entry below names
|
|
6
|
+
* the complex type it mirrors, and `childOrder.test.ts` reads that type out of the committed
|
|
7
|
+
* schema and compares it, so an entry cannot drift from the format it claims to follow.
|
|
8
|
+
*
|
|
9
|
+
* Where the type is a sequence the order is the schema's and nothing else. Where it is a choice
|
|
10
|
+
* the schema fixes no order among the alternatives, so the order here is this package's
|
|
11
|
+
* convention: the schema's own document order. Mutually exclusive alternatives (a content
|
|
12
|
+
* control's type, a cell's markup record) are listed in that same order, since only one of them
|
|
13
|
+
* can ever stand there.
|
|
14
|
+
*
|
|
15
|
+
* A name is the local part alone, as `Props` carries it, which is also how the two children
|
|
16
|
+
* `w:settings` takes from other namespaces (`m:mathPr`, `sl:schemaLibrary`) are spelled here.
|
|
17
|
+
*/
|
|
18
|
+
interface ChildOrder {
|
|
19
|
+
readonly type: string;
|
|
20
|
+
readonly order: readonly string[];
|
|
21
|
+
}
|
|
22
|
+
export declare const CHILD_ORDER: Readonly<Record<string, ChildOrder>>;
|
|
23
|
+
/**
|
|
24
|
+
* The order the children of this parent go in.
|
|
25
|
+
*
|
|
26
|
+
* A nested parent is asked for first (`pPr/rPr` is CT_ParaRPr, which puts a track-change record
|
|
27
|
+
* ahead of what a run's own `w:rPr` holds), so naming the enclosing element is what picks the
|
|
28
|
+
* right one of two entries for the same element name.
|
|
29
|
+
*
|
|
30
|
+
* Throws for a parent no entry covers, because a writer editing an element this registry has
|
|
31
|
+
* never seen would otherwise place its children by nothing at all.
|
|
32
|
+
*/
|
|
33
|
+
export declare function childOrderOf(name: string, parent?: string): readonly string[];
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
// src/ooxml/childOrder.ts
|
|
2
|
+
var CHILD_ORDER = {
|
|
3
|
+
// EG_RPrBase's choice, then rPrChange
|
|
4
|
+
rPr: {
|
|
5
|
+
type: "CT_RPr",
|
|
6
|
+
order: [
|
|
7
|
+
"rStyle",
|
|
8
|
+
"rFonts",
|
|
9
|
+
"b",
|
|
10
|
+
"bCs",
|
|
11
|
+
"i",
|
|
12
|
+
"iCs",
|
|
13
|
+
"caps",
|
|
14
|
+
"smallCaps",
|
|
15
|
+
"strike",
|
|
16
|
+
"dstrike",
|
|
17
|
+
"outline",
|
|
18
|
+
"shadow",
|
|
19
|
+
"emboss",
|
|
20
|
+
"imprint",
|
|
21
|
+
"noProof",
|
|
22
|
+
"snapToGrid",
|
|
23
|
+
"vanish",
|
|
24
|
+
"webHidden",
|
|
25
|
+
"color",
|
|
26
|
+
"spacing",
|
|
27
|
+
"w",
|
|
28
|
+
"kern",
|
|
29
|
+
"position",
|
|
30
|
+
"sz",
|
|
31
|
+
"szCs",
|
|
32
|
+
"highlight",
|
|
33
|
+
"u",
|
|
34
|
+
"effect",
|
|
35
|
+
"bdr",
|
|
36
|
+
"shd",
|
|
37
|
+
"fitText",
|
|
38
|
+
"vertAlign",
|
|
39
|
+
"rtl",
|
|
40
|
+
"cs",
|
|
41
|
+
"em",
|
|
42
|
+
"lang",
|
|
43
|
+
"eastAsianLayout",
|
|
44
|
+
"specVanish",
|
|
45
|
+
"oMath",
|
|
46
|
+
"rPrChange"
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
// the track-change record first, then EG_RPrBase's choice
|
|
50
|
+
"pPr/rPr": {
|
|
51
|
+
type: "CT_ParaRPr",
|
|
52
|
+
order: [
|
|
53
|
+
"ins",
|
|
54
|
+
"del",
|
|
55
|
+
"moveFrom",
|
|
56
|
+
"moveTo",
|
|
57
|
+
"rStyle",
|
|
58
|
+
"rFonts",
|
|
59
|
+
"b",
|
|
60
|
+
"bCs",
|
|
61
|
+
"i",
|
|
62
|
+
"iCs",
|
|
63
|
+
"caps",
|
|
64
|
+
"smallCaps",
|
|
65
|
+
"strike",
|
|
66
|
+
"dstrike",
|
|
67
|
+
"outline",
|
|
68
|
+
"shadow",
|
|
69
|
+
"emboss",
|
|
70
|
+
"imprint",
|
|
71
|
+
"noProof",
|
|
72
|
+
"snapToGrid",
|
|
73
|
+
"vanish",
|
|
74
|
+
"webHidden",
|
|
75
|
+
"color",
|
|
76
|
+
"spacing",
|
|
77
|
+
"w",
|
|
78
|
+
"kern",
|
|
79
|
+
"position",
|
|
80
|
+
"sz",
|
|
81
|
+
"szCs",
|
|
82
|
+
"highlight",
|
|
83
|
+
"u",
|
|
84
|
+
"effect",
|
|
85
|
+
"bdr",
|
|
86
|
+
"shd",
|
|
87
|
+
"fitText",
|
|
88
|
+
"vertAlign",
|
|
89
|
+
"rtl",
|
|
90
|
+
"cs",
|
|
91
|
+
"em",
|
|
92
|
+
"lang",
|
|
93
|
+
"eastAsianLayout",
|
|
94
|
+
"specVanish",
|
|
95
|
+
"oMath",
|
|
96
|
+
"rPrChange"
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
pPr: {
|
|
100
|
+
type: "CT_PPr",
|
|
101
|
+
order: [
|
|
102
|
+
"pStyle",
|
|
103
|
+
"keepNext",
|
|
104
|
+
"keepLines",
|
|
105
|
+
"pageBreakBefore",
|
|
106
|
+
"framePr",
|
|
107
|
+
"widowControl",
|
|
108
|
+
"numPr",
|
|
109
|
+
"suppressLineNumbers",
|
|
110
|
+
"pBdr",
|
|
111
|
+
"shd",
|
|
112
|
+
"tabs",
|
|
113
|
+
"suppressAutoHyphens",
|
|
114
|
+
"kinsoku",
|
|
115
|
+
"wordWrap",
|
|
116
|
+
"overflowPunct",
|
|
117
|
+
"topLinePunct",
|
|
118
|
+
"autoSpaceDE",
|
|
119
|
+
"autoSpaceDN",
|
|
120
|
+
"bidi",
|
|
121
|
+
"adjustRightInd",
|
|
122
|
+
"snapToGrid",
|
|
123
|
+
"spacing",
|
|
124
|
+
"ind",
|
|
125
|
+
"contextualSpacing",
|
|
126
|
+
"mirrorIndents",
|
|
127
|
+
"suppressOverlap",
|
|
128
|
+
"jc",
|
|
129
|
+
"textDirection",
|
|
130
|
+
"textAlignment",
|
|
131
|
+
"textboxTightWrap",
|
|
132
|
+
"outlineLvl",
|
|
133
|
+
"divId",
|
|
134
|
+
"cnfStyle",
|
|
135
|
+
"rPr",
|
|
136
|
+
"sectPr",
|
|
137
|
+
"pPrChange"
|
|
138
|
+
]
|
|
139
|
+
},
|
|
140
|
+
tcPr: {
|
|
141
|
+
type: "CT_TcPr",
|
|
142
|
+
order: [
|
|
143
|
+
"cnfStyle",
|
|
144
|
+
"tcW",
|
|
145
|
+
"gridSpan",
|
|
146
|
+
"hMerge",
|
|
147
|
+
"vMerge",
|
|
148
|
+
"tcBorders",
|
|
149
|
+
"shd",
|
|
150
|
+
"noWrap",
|
|
151
|
+
"tcMar",
|
|
152
|
+
"textDirection",
|
|
153
|
+
"tcFitText",
|
|
154
|
+
"vAlign",
|
|
155
|
+
"hideMark",
|
|
156
|
+
"headers",
|
|
157
|
+
"cellIns",
|
|
158
|
+
"cellDel",
|
|
159
|
+
"cellMerge",
|
|
160
|
+
"tcPrChange"
|
|
161
|
+
]
|
|
162
|
+
},
|
|
163
|
+
// CT_TrPrBase's choice, then the track-change record
|
|
164
|
+
trPr: {
|
|
165
|
+
type: "CT_TrPr",
|
|
166
|
+
order: [
|
|
167
|
+
"cnfStyle",
|
|
168
|
+
"divId",
|
|
169
|
+
"gridBefore",
|
|
170
|
+
"gridAfter",
|
|
171
|
+
"wBefore",
|
|
172
|
+
"wAfter",
|
|
173
|
+
"cantSplit",
|
|
174
|
+
"trHeight",
|
|
175
|
+
"tblHeader",
|
|
176
|
+
"tblCellSpacing",
|
|
177
|
+
"jc",
|
|
178
|
+
"hidden",
|
|
179
|
+
"ins",
|
|
180
|
+
"del",
|
|
181
|
+
"trPrChange"
|
|
182
|
+
]
|
|
183
|
+
},
|
|
184
|
+
tblPr: {
|
|
185
|
+
type: "CT_TblPr",
|
|
186
|
+
order: [
|
|
187
|
+
"tblStyle",
|
|
188
|
+
"tblpPr",
|
|
189
|
+
"tblOverlap",
|
|
190
|
+
"bidiVisual",
|
|
191
|
+
"tblStyleRowBandSize",
|
|
192
|
+
"tblStyleColBandSize",
|
|
193
|
+
"tblW",
|
|
194
|
+
"jc",
|
|
195
|
+
"tblCellSpacing",
|
|
196
|
+
"tblInd",
|
|
197
|
+
"tblBorders",
|
|
198
|
+
"shd",
|
|
199
|
+
"tblLayout",
|
|
200
|
+
"tblCellMar",
|
|
201
|
+
"tblLook",
|
|
202
|
+
"tblCaption",
|
|
203
|
+
"tblDescription",
|
|
204
|
+
"tblPrChange"
|
|
205
|
+
]
|
|
206
|
+
},
|
|
207
|
+
tcBorders: {
|
|
208
|
+
type: "CT_TcBorders",
|
|
209
|
+
order: [
|
|
210
|
+
"top",
|
|
211
|
+
"start",
|
|
212
|
+
"left",
|
|
213
|
+
"bottom",
|
|
214
|
+
"end",
|
|
215
|
+
"right",
|
|
216
|
+
"insideH",
|
|
217
|
+
"insideV",
|
|
218
|
+
"tl2br",
|
|
219
|
+
"tr2bl"
|
|
220
|
+
]
|
|
221
|
+
},
|
|
222
|
+
tblBorders: {
|
|
223
|
+
type: "CT_TblBorders",
|
|
224
|
+
order: [
|
|
225
|
+
"top",
|
|
226
|
+
"start",
|
|
227
|
+
"left",
|
|
228
|
+
"bottom",
|
|
229
|
+
"end",
|
|
230
|
+
"right",
|
|
231
|
+
"insideH",
|
|
232
|
+
"insideV"
|
|
233
|
+
]
|
|
234
|
+
},
|
|
235
|
+
pBdr: {
|
|
236
|
+
type: "CT_PBdr",
|
|
237
|
+
order: ["top", "left", "bottom", "right", "between", "bar"]
|
|
238
|
+
},
|
|
239
|
+
tcMar: {
|
|
240
|
+
type: "CT_TcMar",
|
|
241
|
+
order: ["top", "start", "left", "bottom", "end", "right"]
|
|
242
|
+
},
|
|
243
|
+
tblCellMar: {
|
|
244
|
+
type: "CT_TblCellMar",
|
|
245
|
+
order: ["top", "start", "left", "bottom", "end", "right"]
|
|
246
|
+
},
|
|
247
|
+
// CT_SdtRun lays the same three down
|
|
248
|
+
sdt: {
|
|
249
|
+
type: "CT_SdtBlock",
|
|
250
|
+
order: ["sdtPr", "sdtEndPr", "sdtContent"]
|
|
251
|
+
},
|
|
252
|
+
sdtPr: {
|
|
253
|
+
type: "CT_SdtPr",
|
|
254
|
+
order: [
|
|
255
|
+
"rPr",
|
|
256
|
+
"alias",
|
|
257
|
+
"tag",
|
|
258
|
+
"id",
|
|
259
|
+
"lock",
|
|
260
|
+
"placeholder",
|
|
261
|
+
"temporary",
|
|
262
|
+
"showingPlcHdr",
|
|
263
|
+
"dataBinding",
|
|
264
|
+
"label",
|
|
265
|
+
"tabIndex",
|
|
266
|
+
"equation",
|
|
267
|
+
"comboBox",
|
|
268
|
+
"date",
|
|
269
|
+
"docPartObj",
|
|
270
|
+
"docPartList",
|
|
271
|
+
"dropDownList",
|
|
272
|
+
"picture",
|
|
273
|
+
"richText",
|
|
274
|
+
"text",
|
|
275
|
+
"citation",
|
|
276
|
+
"group",
|
|
277
|
+
"bibliography"
|
|
278
|
+
]
|
|
279
|
+
},
|
|
280
|
+
sectPr: {
|
|
281
|
+
type: "CT_SectPr",
|
|
282
|
+
order: [
|
|
283
|
+
"headerReference",
|
|
284
|
+
"footerReference",
|
|
285
|
+
"footnotePr",
|
|
286
|
+
"endnotePr",
|
|
287
|
+
"type",
|
|
288
|
+
"pgSz",
|
|
289
|
+
"pgMar",
|
|
290
|
+
"paperSrc",
|
|
291
|
+
"pgBorders",
|
|
292
|
+
"lnNumType",
|
|
293
|
+
"pgNumType",
|
|
294
|
+
"cols",
|
|
295
|
+
"formProt",
|
|
296
|
+
"vAlign",
|
|
297
|
+
"noEndnote",
|
|
298
|
+
"titlePg",
|
|
299
|
+
"textDirection",
|
|
300
|
+
"bidi",
|
|
301
|
+
"rtlGutter",
|
|
302
|
+
"docGrid",
|
|
303
|
+
"printerSettings",
|
|
304
|
+
"sectPrChange"
|
|
305
|
+
]
|
|
306
|
+
},
|
|
307
|
+
numPr: {
|
|
308
|
+
type: "CT_NumPr",
|
|
309
|
+
order: ["ilvl", "numId", "numberingChange", "ins"]
|
|
310
|
+
},
|
|
311
|
+
lvl: {
|
|
312
|
+
type: "CT_Lvl",
|
|
313
|
+
order: [
|
|
314
|
+
"start",
|
|
315
|
+
"numFmt",
|
|
316
|
+
"lvlRestart",
|
|
317
|
+
"pStyle",
|
|
318
|
+
"isLgl",
|
|
319
|
+
"suff",
|
|
320
|
+
"lvlText",
|
|
321
|
+
"lvlPicBulletId",
|
|
322
|
+
"legacy",
|
|
323
|
+
"lvlJc",
|
|
324
|
+
"pPr",
|
|
325
|
+
"rPr"
|
|
326
|
+
]
|
|
327
|
+
},
|
|
328
|
+
abstractNum: {
|
|
329
|
+
type: "CT_AbstractNum",
|
|
330
|
+
order: [
|
|
331
|
+
"nsid",
|
|
332
|
+
"multiLevelType",
|
|
333
|
+
"tmpl",
|
|
334
|
+
"name",
|
|
335
|
+
"styleLink",
|
|
336
|
+
"numStyleLink",
|
|
337
|
+
"lvl"
|
|
338
|
+
]
|
|
339
|
+
},
|
|
340
|
+
num: {
|
|
341
|
+
type: "CT_Num",
|
|
342
|
+
order: ["abstractNumId", "lvlOverride"]
|
|
343
|
+
},
|
|
344
|
+
numbering: {
|
|
345
|
+
type: "CT_Numbering",
|
|
346
|
+
order: ["numPicBullet", "abstractNum", "num", "numIdMacAtCleanup"]
|
|
347
|
+
},
|
|
348
|
+
tblStylePr: {
|
|
349
|
+
type: "CT_TblStylePr",
|
|
350
|
+
order: ["pPr", "rPr", "tblPr", "trPr", "tcPr"]
|
|
351
|
+
},
|
|
352
|
+
style: {
|
|
353
|
+
type: "CT_Style",
|
|
354
|
+
order: [
|
|
355
|
+
"name",
|
|
356
|
+
"aliases",
|
|
357
|
+
"basedOn",
|
|
358
|
+
"next",
|
|
359
|
+
"link",
|
|
360
|
+
"autoRedefine",
|
|
361
|
+
"hidden",
|
|
362
|
+
"uiPriority",
|
|
363
|
+
"semiHidden",
|
|
364
|
+
"unhideWhenUsed",
|
|
365
|
+
"qFormat",
|
|
366
|
+
"locked",
|
|
367
|
+
"personal",
|
|
368
|
+
"personalCompose",
|
|
369
|
+
"personalReply",
|
|
370
|
+
"rsid",
|
|
371
|
+
"pPr",
|
|
372
|
+
"rPr",
|
|
373
|
+
"tblPr",
|
|
374
|
+
"trPr",
|
|
375
|
+
"tcPr",
|
|
376
|
+
"tblStylePr"
|
|
377
|
+
]
|
|
378
|
+
},
|
|
379
|
+
settings: {
|
|
380
|
+
type: "CT_Settings",
|
|
381
|
+
order: [
|
|
382
|
+
"writeProtection",
|
|
383
|
+
"view",
|
|
384
|
+
"zoom",
|
|
385
|
+
"removePersonalInformation",
|
|
386
|
+
"removeDateAndTime",
|
|
387
|
+
"doNotDisplayPageBoundaries",
|
|
388
|
+
"displayBackgroundShape",
|
|
389
|
+
"printPostScriptOverText",
|
|
390
|
+
"printFractionalCharacterWidth",
|
|
391
|
+
"printFormsData",
|
|
392
|
+
"embedTrueTypeFonts",
|
|
393
|
+
"embedSystemFonts",
|
|
394
|
+
"saveSubsetFonts",
|
|
395
|
+
"saveFormsData",
|
|
396
|
+
"mirrorMargins",
|
|
397
|
+
"alignBordersAndEdges",
|
|
398
|
+
"bordersDoNotSurroundHeader",
|
|
399
|
+
"bordersDoNotSurroundFooter",
|
|
400
|
+
"gutterAtTop",
|
|
401
|
+
"hideSpellingErrors",
|
|
402
|
+
"hideGrammaticalErrors",
|
|
403
|
+
"activeWritingStyle",
|
|
404
|
+
"proofState",
|
|
405
|
+
"formsDesign",
|
|
406
|
+
"attachedTemplate",
|
|
407
|
+
"linkStyles",
|
|
408
|
+
"stylePaneFormatFilter",
|
|
409
|
+
"stylePaneSortMethod",
|
|
410
|
+
"documentType",
|
|
411
|
+
"mailMerge",
|
|
412
|
+
"revisionView",
|
|
413
|
+
"trackRevisions",
|
|
414
|
+
"doNotTrackMoves",
|
|
415
|
+
"doNotTrackFormatting",
|
|
416
|
+
"documentProtection",
|
|
417
|
+
"autoFormatOverride",
|
|
418
|
+
"styleLockTheme",
|
|
419
|
+
"styleLockQFSet",
|
|
420
|
+
"defaultTabStop",
|
|
421
|
+
"autoHyphenation",
|
|
422
|
+
"consecutiveHyphenLimit",
|
|
423
|
+
"hyphenationZone",
|
|
424
|
+
"doNotHyphenateCaps",
|
|
425
|
+
"showEnvelope",
|
|
426
|
+
"summaryLength",
|
|
427
|
+
"clickAndTypeStyle",
|
|
428
|
+
"defaultTableStyle",
|
|
429
|
+
"evenAndOddHeaders",
|
|
430
|
+
"bookFoldRevPrinting",
|
|
431
|
+
"bookFoldPrinting",
|
|
432
|
+
"bookFoldPrintingSheets",
|
|
433
|
+
"drawingGridHorizontalSpacing",
|
|
434
|
+
"drawingGridVerticalSpacing",
|
|
435
|
+
"displayHorizontalDrawingGridEvery",
|
|
436
|
+
"displayVerticalDrawingGridEvery",
|
|
437
|
+
"doNotUseMarginsForDrawingGridOrigin",
|
|
438
|
+
"drawingGridHorizontalOrigin",
|
|
439
|
+
"drawingGridVerticalOrigin",
|
|
440
|
+
"doNotShadeFormData",
|
|
441
|
+
"noPunctuationKerning",
|
|
442
|
+
"characterSpacingControl",
|
|
443
|
+
"printTwoOnOne",
|
|
444
|
+
"strictFirstAndLastChars",
|
|
445
|
+
"noLineBreaksAfter",
|
|
446
|
+
"noLineBreaksBefore",
|
|
447
|
+
"savePreviewPicture",
|
|
448
|
+
"doNotValidateAgainstSchema",
|
|
449
|
+
"saveInvalidXml",
|
|
450
|
+
"ignoreMixedContent",
|
|
451
|
+
"alwaysShowPlaceholderText",
|
|
452
|
+
"doNotDemarcateInvalidXml",
|
|
453
|
+
"saveXmlDataOnly",
|
|
454
|
+
"useXSLTWhenSaving",
|
|
455
|
+
"saveThroughXslt",
|
|
456
|
+
"showXMLTags",
|
|
457
|
+
"alwaysMergeEmptyNamespace",
|
|
458
|
+
"updateFields",
|
|
459
|
+
"hdrShapeDefaults",
|
|
460
|
+
"footnotePr",
|
|
461
|
+
"endnotePr",
|
|
462
|
+
"compat",
|
|
463
|
+
"docVars",
|
|
464
|
+
"rsids",
|
|
465
|
+
"mathPr",
|
|
466
|
+
"attachedSchema",
|
|
467
|
+
"themeFontLang",
|
|
468
|
+
"clrSchemeMapping",
|
|
469
|
+
"doNotIncludeSubdocsInStats",
|
|
470
|
+
"doNotAutoCompressPictures",
|
|
471
|
+
"forceUpgrade",
|
|
472
|
+
"captions",
|
|
473
|
+
"readModeInkLockDown",
|
|
474
|
+
"smartTagType",
|
|
475
|
+
"schemaLibrary",
|
|
476
|
+
"shapeDefaults",
|
|
477
|
+
"doNotEmbedSmartTags",
|
|
478
|
+
"decimalSymbol",
|
|
479
|
+
"listSeparator"
|
|
480
|
+
]
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
function childOrderOf(name, parent) {
|
|
484
|
+
const nested = parent === void 0 ? void 0 : CHILD_ORDER[`${parent}/${name}`];
|
|
485
|
+
const order = nested ?? CHILD_ORDER[name];
|
|
486
|
+
if (!order) {
|
|
487
|
+
throw new Error(
|
|
488
|
+
`no child order is registered for ${name}; add it to CHILD_ORDER`
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
return order.order;
|
|
492
|
+
}
|
|
493
|
+
export {
|
|
494
|
+
CHILD_ORDER,
|
|
495
|
+
childOrderOf
|
|
496
|
+
};
|
package/dist/ooxml/element.d.ts
CHANGED
|
@@ -5,8 +5,12 @@
|
|
|
5
5
|
* arrived with is carried around as its original text, and an edit swaps out one element or one
|
|
6
6
|
* attribute of it. Rebuilding a parsed element instead would rewrite markup nobody touched.
|
|
7
7
|
*
|
|
8
|
-
* An attribute is
|
|
9
|
-
*
|
|
8
|
+
* An attribute is read and written as the WordprocessingML attribute of a local name: the one
|
|
9
|
+
* spelled under the `w` prefix, which `RESERVED_PREFIXES` pins to that namespace in every fragment,
|
|
10
|
+
* or failing that an unprefixed one, which is what `wAttr` accepted off a parsed fragment too. An
|
|
11
|
+
* attribute another prefix qualifies belongs to some other vocabulary, so it is neither read as the
|
|
12
|
+
* formatting value nor written over when it happens to share the local name (`x:val` beside
|
|
13
|
+
* `w:val`). The two readers below are named for which of those they answer.
|
|
10
14
|
*/
|
|
11
15
|
import { type KnownPrefix } from "./names";
|
|
12
16
|
/** One attribute as it is written: the whole name, prefix included, and the value before escaping */
|
|
@@ -26,16 +30,30 @@ export declare function elementXml(name: string, attrs: readonly XmlAttr[], chil
|
|
|
26
30
|
* the prefix itself.
|
|
27
31
|
*/
|
|
28
32
|
export declare function xmlnsAttr(prefix: KnownPrefix): XmlAttr;
|
|
33
|
+
/** The same for the WordprocessingML vocabulary, which is the one almost everything is written in */
|
|
34
|
+
export declare function wLocalName(name: string): string | null;
|
|
29
35
|
/**
|
|
30
|
-
* The
|
|
36
|
+
* The value of the WordprocessingML attribute of this local name, and null for an element that
|
|
37
|
+
* carries none. An attribute of the same local name under another prefix is not it.
|
|
38
|
+
*/
|
|
39
|
+
export declare function wAttrValue(attrs: readonly XmlAttr[], localName: string): string | null;
|
|
40
|
+
/**
|
|
41
|
+
* The attributes with the WordprocessingML one of this local name written as `value`, or removed
|
|
42
|
+
* when it is null.
|
|
31
43
|
*
|
|
32
44
|
* One already there keeps the slot it sat in and the name it was written under, so an edited
|
|
33
45
|
* element reads as the original did. One that is not there yet goes on the end under the `w`
|
|
34
|
-
* prefix.
|
|
46
|
+
* prefix, and one of the same local name under another prefix stands untouched beside it.
|
|
35
47
|
*/
|
|
36
48
|
export declare function withAttr(attrs: readonly XmlAttr[], name: string, value: string | null): XmlAttr[];
|
|
37
|
-
|
|
38
|
-
|
|
49
|
+
/**
|
|
50
|
+
* The attributes without the ones of these local names, in either spelling.
|
|
51
|
+
*
|
|
52
|
+
* The names are read under the WordprocessingML vocabulary unless another prefix is named, which
|
|
53
|
+
* is what reaches the handful of attributes Word writes beside it: `w14:paraId` is a name under
|
|
54
|
+
* `w14` and no more a `w:` attribute than `x:val` is.
|
|
55
|
+
*/
|
|
56
|
+
export declare function withoutAttrs(attrs: readonly XmlAttr[], localNames: readonly string[], prefix?: KnownPrefix): XmlAttr[];
|
|
39
57
|
/**
|
|
40
58
|
* An opening tag whose attributes are the ones the original wrote.
|
|
41
59
|
*
|
|
@@ -45,8 +63,3 @@ export declare function attrValue(attrs: readonly XmlAttr[], localName: string):
|
|
|
45
63
|
export declare function openTagXml(name: string, rawAttrs: string | null): string;
|
|
46
64
|
/** The same for an element that closes on its own */
|
|
47
65
|
export declare function emptyTagXml(name: string, rawAttrs: string | null): string;
|
|
48
|
-
/**
|
|
49
|
-
* The attributes of a parsed element as pairs, for a caller that still holds the element rather
|
|
50
|
-
* than its text.
|
|
51
|
-
*/
|
|
52
|
-
export declare function attrPairs(el: Element | null): XmlAttr[];
|