@portone/docx-editor 0.2.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +155 -0
- package/CONTRIBUTING.md +5 -1
- package/dist/DocxEditor.d.ts +6 -0
- package/dist/DocxEditor.js +13 -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 +59 -112
- 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 +88 -74
- 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 +45 -0
- package/dist/docx/formatting/attrs.js +86 -0
- package/dist/docx/formatting/context.d.ts +39 -0
- package/dist/docx/formatting/context.js +60 -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 +51 -0
- package/dist/docx/formatting/resolve.js +160 -0
- package/dist/docx/formatting/runProperties.d.ts +93 -0
- package/dist/docx/formatting/runProperties.js +316 -0
- package/dist/docx/formatting/styles.d.ts +25 -2
- package/dist/docx/formatting/styles.js +87 -6
- 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/hyperlink.d.ts +14 -4
- package/dist/docx/hyperlink.js +4 -1
- 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 +90 -88
- package/dist/docx/importParagraph.d.ts +1 -1
- package/dist/docx/importParagraph.js +4 -3
- package/dist/docx/importTable.d.ts +2 -2
- package/dist/docx/importTable.js +69 -56
- package/dist/docx/invariants.d.ts +33 -0
- package/dist/docx/invariants.js +269 -0
- package/dist/docx/media.d.ts +6 -4
- package/dist/docx/media.js +6 -37
- package/dist/docx/newLists.d.ts +50 -0
- package/dist/docx/newLists.js +59 -0
- package/dist/docx/notes.js +3 -7
- package/dist/docx/numberingPlanner.d.ts +11 -0
- package/dist/docx/numberingPlanner.js +50 -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 +53 -17
- package/dist/docx/tableFormatting/conditions.d.ts +76 -0
- package/dist/docx/tableFormatting/conditions.js +196 -0
- package/dist/docx/tableFormatting/editing.d.ts +7 -3
- package/dist/docx/tableFormatting/editing.js +111 -143
- package/dist/docx/tableFormatting/reading.d.ts +63 -23
- package/dist/docx/tableFormatting/reading.js +132 -38
- package/dist/docx/tableFormatting.d.ts +1 -0
- package/dist/docx/tableFormatting.js +1 -0
- package/dist/docx/tableTemplate.js +30 -19
- 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 +108 -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.d.ts +6 -3
- package/dist/editor/commands/listCommands.js +73 -30
- package/dist/editor/commands/lockCommands.d.ts +7 -1
- package/dist/editor/commands/lockCommands.js +35 -46
- package/dist/editor/commands/paragraphCommands.js +33 -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 +57 -0
- package/dist/editor/editorDocument.js +86 -0
- package/dist/editor/externalClipboard.d.ts +13 -2
- package/dist/editor/externalClipboard.js +76 -75
- package/dist/editor/insertTable.js +4 -3
- package/dist/editor/paragraphEdits.d.ts +27 -19
- package/dist/editor/paragraphEdits.js +18 -19
- package/dist/editor/paragraphPlacement.d.ts +11 -0
- package/dist/editor/paragraphPlacement.js +18 -0
- package/dist/editor/plugins/displayDerivation.d.ts +47 -0
- package/dist/editor/plugins/displayDerivation.js +78 -0
- package/dist/editor/plugins/imagePaste.js +11 -7
- package/dist/editor/plugins/keymap.js +18 -3
- package/dist/editor/plugins/numberingDecorations.d.ts +14 -14
- package/dist/editor/plugins/numberingDecorations.js +50 -19
- package/dist/editor/plugins/paragraphDisplay.d.ts +7 -0
- package/dist/editor/plugins/paragraphDisplay.js +57 -0
- package/dist/editor/plugins/tabLayout.js +1 -1
- package/dist/editor/plugins/tableDisplay.d.ts +6 -0
- package/dist/editor/plugins/tableDisplay.js +30 -0
- package/dist/index.d.ts +2 -0
- package/dist/model/format.d.ts +80 -8
- package/dist/model/format.js +100 -22
- package/dist/model/tabStops.d.ts +9 -0
- package/dist/model/tabStops.js +18 -0
- package/dist/numbering/listRegistry.d.ts +37 -0
- package/dist/numbering/listRegistry.js +112 -0
- package/dist/numbering/listTemplate.d.ts +26 -17
- package/dist/numbering/listTemplate.js +88 -25
- package/dist/numbering/markers.d.ts +15 -6
- package/dist/numbering/markers.js +26 -59
- package/dist/numbering/parseNumbering.d.ts +84 -6
- package/dist/numbering/parseNumbering.js +131 -44
- package/dist/numbering/spellers.d.ts +15 -0
- package/dist/numbering/spellers.js +96 -0
- package/dist/numbering/writeNumbering.d.ts +8 -7
- package/dist/numbering/writeNumbering.js +28 -39
- package/dist/ooxml/childOrder.d.ts +34 -0
- package/dist/ooxml/childOrder.js +496 -0
- package/dist/ooxml/conformance.d.ts +28 -0
- package/dist/ooxml/conformance.js +20 -0
- package/dist/ooxml/element.d.ts +24 -11
- package/dist/ooxml/element.js +31 -12
- package/dist/ooxml/errors.d.ts +6 -5
- package/dist/ooxml/image.d.ts +4 -0
- package/dist/ooxml/image.js +2 -5
- package/dist/ooxml/names.d.ts +9 -0
- package/dist/ooxml/names.js +8 -1
- package/dist/ooxml/partSplice.d.ts +67 -0
- package/dist/ooxml/partSplice.js +176 -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 +35 -15
- package/dist/ooxml/xml.js +43 -11
- package/dist/page/PageGuides.d.ts +1 -1
- package/dist/page/PageGuides.js +0 -13
- 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 -29
- package/dist/page/pageLayout.js +39 -16
- package/dist/page/usePageLayout.d.ts +2 -24
- package/dist/page/usePageLayout.js +5 -48
- package/dist/schema/attrRoles.d.ts +25 -18
- package/dist/schema/attrRoles.js +110 -68
- 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 +58 -17
- 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/classNames.d.ts +13 -2
- package/dist/styles/classNames.js +13 -2
- package/dist/styles/inlineStyle.js +15 -6
- package/dist/styles.css +16 -18
- package/dist/table/cellFormatting.d.ts +8 -1
- package/dist/table/cellFormatting.js +11 -20
- 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 +24 -30
- package/dist/table/gridBorders.js +35 -59
- 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,48 +1,37 @@
|
|
|
1
1
|
// src/numbering/writeNumbering.ts
|
|
2
|
-
import {
|
|
2
|
+
import { splicePart } from "../ooxml/partSplice.js";
|
|
3
|
+
import { ST_DecimalNumber } from "../ooxml/simpleTypes.js";
|
|
3
4
|
import { wAttr } from "../ooxml/units.js";
|
|
4
5
|
import { elementChildren, parseXml } from "../ooxml/xml.js";
|
|
5
|
-
import { abstractNumXml,
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import { abstractNumXml, numberingIdAllocator, numXml } from "./listTemplate.js";
|
|
7
|
+
function abstractNumIds(xml) {
|
|
8
|
+
return elementChildren(parseXml(xml).documentElement).flatMap((child) => {
|
|
9
|
+
if (child.localName !== "abstractNum") return [];
|
|
10
|
+
const id = ST_DecimalNumber.parse(wAttr(child, "abstractNumId"));
|
|
11
|
+
return id === null ? [] : [id];
|
|
12
|
+
});
|
|
9
13
|
}
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
)
|
|
14
|
-
return matches.at(-1)?.index ?? null;
|
|
15
|
-
}
|
|
16
|
-
function maxAbstractNumId(xml) {
|
|
17
|
-
let max = 0;
|
|
18
|
-
for (const child of elementChildren(parseXml(xml).documentElement)) {
|
|
19
|
-
if (child.localName !== "abstractNum") continue;
|
|
20
|
-
const id = Number.parseInt(wAttr(child, "abstractNumId") ?? "", 10);
|
|
21
|
-
if (Number.isFinite(id)) max = Math.max(max, id);
|
|
22
|
-
}
|
|
23
|
-
return max;
|
|
24
|
-
}
|
|
25
|
-
function addListDefinitions(xml, numIds) {
|
|
26
|
-
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
|
-
const firstAbstractNumId = maxAbstractNumId(xml) + 1;
|
|
37
|
-
const additions = [...numIds].sort((a, b) => a - b).map((numId, index) => ({
|
|
14
|
+
function addListDefinitions(xml, lists) {
|
|
15
|
+
if (lists.size === 0) return xml;
|
|
16
|
+
const takeId = numberingIdAllocator(abstractNumIds(xml));
|
|
17
|
+
const additions = [...lists].sort(([left], [right]) => left - right).map(([numId, list]) => ({
|
|
38
18
|
numId,
|
|
39
|
-
|
|
19
|
+
list,
|
|
20
|
+
abstractNumId: takeId()
|
|
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, added.list)
|
|
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
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which conformance class a package is written in, and whether its main part is one this editor
|
|
3
|
+
* can write back into. Both are settled once, when the file is opened.
|
|
4
|
+
*
|
|
5
|
+
* ECMA-376 defines two document conformance classes, Strict (Part 1 §2.1) and Transitional
|
|
6
|
+
* (Part 4 §2.1). They describe the same vocabulary under different names: the main document part's
|
|
7
|
+
* root namespace and the relationship the package reaches it through differ between the two
|
|
8
|
+
* (Part 1 §11.3.10, Part 4 §9.2.10). This editor supports a subset of Transitional. Strict is
|
|
9
|
+
* refused explicitly so that its markup is never read using Transitional assumptions.
|
|
10
|
+
*
|
|
11
|
+
* A namespace prefix is the producer's own choice and carries no meaning of its own, so readers
|
|
12
|
+
* identify markup by namespace URI and local name. The WordprocessingML writer emits `w`
|
|
13
|
+
* (`ooxml/names`), so the main part's root must bind that prefix to the Transitional namespace.
|
|
14
|
+
*/
|
|
15
|
+
/** The WordprocessingML namespace of a Strict main document part (Part 1 §11.3.10) */
|
|
16
|
+
export declare const STRICT_W_NS = "http://purl.oclc.org/ooxml/wordprocessingml/main";
|
|
17
|
+
/** The relationship a Strict package reaches its main document part through (Part 1 §11.3.10) */
|
|
18
|
+
export declare const STRICT_OFFICE_DOCUMENT_REL = "http://purl.oclc.org/ooxml/officeDocument/relationships/officeDocument";
|
|
19
|
+
export type Conformance = "transitional" | "strict";
|
|
20
|
+
/** The class this main part root is written in, null for a root of neither vocabulary */
|
|
21
|
+
export declare function conformanceOf(root: Element): Conformance | null;
|
|
22
|
+
/**
|
|
23
|
+
* Whether the root binds the prefix every writer emits (`w`) to the WordprocessingML namespace.
|
|
24
|
+
*
|
|
25
|
+
* A root has nothing above it to inherit a declaration from, so what it writes itself is the whole
|
|
26
|
+
* answer. A default namespace or another prefix alone does not bind `w`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function bindsWritingPrefix(root: Element): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/ooxml/conformance.ts
|
|
2
|
+
import { W_NS, W_PREFIX } from "./names.js";
|
|
3
|
+
var STRICT_W_NS = "http://purl.oclc.org/ooxml/wordprocessingml/main";
|
|
4
|
+
var STRICT_OFFICE_DOCUMENT_REL = "http://purl.oclc.org/ooxml/officeDocument/relationships/officeDocument";
|
|
5
|
+
function conformanceOf(root) {
|
|
6
|
+
if (root.namespaceURI === W_NS) return "transitional";
|
|
7
|
+
if (root.namespaceURI === STRICT_W_NS) return "strict";
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
function bindsWritingPrefix(root) {
|
|
11
|
+
return Array.from(root.attributes).some(
|
|
12
|
+
(attr) => attr.name === `xmlns:${W_PREFIX}` && attr.value === W_NS
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
STRICT_OFFICE_DOCUMENT_REL,
|
|
17
|
+
STRICT_W_NS,
|
|
18
|
+
bindsWritingPrefix,
|
|
19
|
+
conformanceOf
|
|
20
|
+
};
|