@portone/docx-editor 0.2.0 → 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 +174 -0
- package/CONTRIBUTING.md +9 -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 +14 -7
- package/dist/docx/commentOnlyChange.js +9 -139
- package/dist/docx/comments/constants.d.ts +3 -4
- package/dist/docx/comments/constants.js +4 -5
- package/dist/docx/comments/grammar.d.ts +86 -0
- package/dist/docx/comments/grammar.js +223 -0
- package/dist/docx/comments/parts.d.ts +52 -0
- package/dist/docx/comments/parts.js +279 -0
- package/dist/docx/comments/people.d.ts +11 -2
- package/dist/docx/comments/people.js +28 -106
- package/dist/docx/comments/policy.d.ts +7 -0
- package/dist/docx/comments/policy.js +43 -0
- package/dist/docx/comments/reading.d.ts +5 -3
- package/dist/docx/comments/reading.js +30 -29
- package/dist/docx/comments/writing.d.ts +19 -7
- package/dist/docx/comments/writing.js +105 -137
- 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 +71 -72
- 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 -81
- 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 +13 -22
- 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 +6 -12
- 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 +75 -99
- 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 +15 -15
- 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 +14 -37
- 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 +9 -7
- package/dist/docx/serializeParagraph.d.ts +2 -1
- package/dist/docx/serializeParagraph.js +25 -14
- package/dist/docx/serializeTable.js +63 -32
- package/dist/docx/session.d.ts +42 -14
- package/dist/docx/session.js +43 -17
- package/dist/docx/storyProjection.d.ts +36 -0
- package/dist/docx/storyProjection.js +23 -0
- package/dist/docx/tableFormatting/editing.js +130 -185
- package/dist/docx/tableFormatting/reading.d.ts +16 -6
- package/dist/docx/tableFormatting/reading.js +40 -20
- package/dist/docx/tableTemplate.js +37 -5
- package/dist/docx/theme.d.ts +0 -6
- package/dist/docx/theme.js +0 -8
- package/dist/download.d.ts +8 -5
- package/dist/download.js +2 -0
- package/dist/editor/clipboard/images.js +17 -3
- package/dist/editor/clipboard/inlineFormatting.d.ts +7 -0
- package/dist/editor/clipboard/inlineFormatting.js +20 -30
- package/dist/editor/commands/breakCommands.js +4 -3
- package/dist/editor/commands/canRunCommand.d.ts +2 -2
- package/dist/editor/commands/canRunCommand.js +1 -1
- package/dist/editor/commands/comments/editing.d.ts +6 -2
- package/dist/editor/commands/comments/editing.js +21 -36
- 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/historyCommands.js +2 -1
- 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 -37
- package/dist/editor/commands/paragraphCommands.js +28 -31
- package/dist/editor/commands/spacingCommands.js +1 -1
- package/dist/editor/commands/tabCommands.js +4 -3
- package/dist/editor/createEditor.d.ts +17 -29
- package/dist/editor/createEditor.js +61 -67
- 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 +166 -33
- package/dist/editor/insertImage.js +4 -3
- 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/documentProtection.d.ts +3 -3
- package/dist/editor/plugins/imagePaste.js +4 -3
- package/dist/editor/plugins/keymap.js +18 -3
- package/dist/editor/plugins/lockedContent.d.ts +4 -4
- package/dist/editor/plugins/lockedContent.js +1 -1
- 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 +49 -10
- 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 +65 -0
- package/dist/ooxml/element.js +68 -0
- package/dist/ooxml/errors.d.ts +3 -2
- package/dist/ooxml/fragment.d.ts +53 -0
- package/dist/ooxml/fragment.js +76 -0
- package/dist/ooxml/image.d.ts +4 -0
- package/dist/ooxml/image.js +3 -5
- package/dist/ooxml/names.d.ts +27 -0
- package/dist/ooxml/names.js +29 -0
- package/dist/ooxml/partSplice.d.ts +67 -0
- package/dist/ooxml/partSplice.js +169 -0
- package/dist/ooxml/precedence.d.ts +31 -0
- package/dist/ooxml/precedence.js +51 -0
- package/dist/ooxml/props.d.ts +112 -0
- package/dist/ooxml/props.js +214 -0
- 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 +52 -0
- package/dist/ooxml/xml.js +64 -5
- package/dist/page/blockKinds.d.ts +103 -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 -1
- package/dist/page/measureBlocks.js +24 -25
- package/dist/page/pageDecorations.d.ts +27 -28
- package/dist/page/pageDecorations.js +70 -151
- package/dist/page/pageLayout.d.ts +10 -62
- package/dist/page/pageLayout.js +60 -53
- package/dist/page/usePageLayout.d.ts +2 -2
- package/dist/page/usePageLayout.js +3 -11
- package/dist/schema/attrRoles.d.ts +42 -0
- package/dist/schema/attrRoles.js +141 -0
- package/dist/schema/displayDerivation.d.ts +82 -0
- package/dist/schema/displayDerivation.js +130 -0
- package/dist/schema/docxSchema.d.ts +9 -0
- package/dist/schema/docxSchema.js +237 -114
- package/dist/schema/editGuard.d.ts +99 -0
- package/dist/schema/editGuard.js +43 -0
- package/dist/schema/guards.d.ts +91 -0
- package/dist/schema/guards.js +108 -0
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/index.js +2 -0
- package/dist/schema/locks.d.ts +17 -77
- package/dist/schema/locks.js +26 -70
- package/dist/schema/preservedGuards.d.ts +50 -0
- package/dist/schema/preservedGuards.js +80 -0
- package/dist/schema/protection.d.ts +17 -4
- package/dist/schema/protection.js +4 -2
- package/dist/schema/sourceEquality.d.ts +19 -0
- package/dist/schema/sourceEquality.js +39 -0
- package/dist/styles/inlineStyle.js +15 -6
- package/dist/table/cellFormatting.d.ts +8 -1
- package/dist/table/cellFormatting.js +10 -17
- package/dist/table/commands.d.ts +2 -2
- 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/index.d.ts +2 -2
- package/dist/table/merge.d.ts +4 -8
- package/dist/table/merge.js +5 -5
- package/package.json +10 -3
- package/dist/docx/comments/contentTypes.d.ts +0 -7
- package/dist/docx/comments/contentTypes.js +0 -38
- package/dist/docx/formatting/effectiveParagraph.d.ts +0 -15
- package/dist/docx/formatting/effectiveParagraph.js +0 -81
- package/dist/docx/propsXml.d.ts +0 -49
- package/dist/docx/propsXml.js +0 -302
- package/dist/docx/uniqueControls.d.ts +0 -14
- package/dist/docx/uniqueControls.js +0 -62
- package/dist/editor/plugins/bookmarkProtection.d.ts +0 -3
- package/dist/editor/plugins/bookmarkProtection.js +0 -28
- package/dist/editor/plugins/commentReservations.d.ts +0 -5
- package/dist/editor/plugins/commentReservations.js +0 -26
- package/dist/editor/plugins/noteProtection.d.ts +0 -3
- package/dist/editor/plugins/noteProtection.js +0 -25
- package/dist/editor/plugins/styledParagraphs.d.ts +0 -15
- package/dist/editor/plugins/styledParagraphs.js +0 -65
- package/dist/page/tableMeasurements.d.ts +0 -10
- package/dist/page/tableMeasurements.js +0 -115
|
@@ -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,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writing one element out as text, and merging the attributes of one.
|
|
3
|
+
*
|
|
4
|
+
* Everything here works on strings, because that is what the writers hold: a fragment the file
|
|
5
|
+
* arrived with is carried around as its original text, and an edit swaps out one element or one
|
|
6
|
+
* attribute of it. Rebuilding a parsed element instead would rewrite markup nobody touched.
|
|
7
|
+
*
|
|
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.
|
|
14
|
+
*/
|
|
15
|
+
import { type KnownPrefix } from "./names";
|
|
16
|
+
/** One attribute as it is written: the whole name, prefix included, and the value before escaping */
|
|
17
|
+
export type XmlAttr = readonly [name: string, value: string];
|
|
18
|
+
/** `a="b" c="d"`. Empty for no attributes, so an opening tag needs no separator of its own */
|
|
19
|
+
export declare function attrsText(attrs: readonly XmlAttr[]): string;
|
|
20
|
+
/**
|
|
21
|
+
* `<name a="b"/>`, or `<name a="b">children</name>` for an element that holds something.
|
|
22
|
+
*
|
|
23
|
+
* Attribute values are escaped here; children are spliced in as they are, being markup already, so
|
|
24
|
+
* a caller writing text as a child escapes it itself. An element handed no child at all closes on
|
|
25
|
+
* its own, which means a caller that wants an empty pair of tags passes the empty text as a child.
|
|
26
|
+
*/
|
|
27
|
+
export declare function elementXml(name: string, attrs: readonly XmlAttr[], children?: readonly string[]): string;
|
|
28
|
+
/**
|
|
29
|
+
* The namespace declaration a fragment carries when the part it is spliced into does not declare
|
|
30
|
+
* the prefix itself.
|
|
31
|
+
*/
|
|
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;
|
|
35
|
+
/**
|
|
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.
|
|
43
|
+
*
|
|
44
|
+
* One already there keeps the slot it sat in and the name it was written under, so an edited
|
|
45
|
+
* element reads as the original did. One that is not there yet goes on the end under the `w`
|
|
46
|
+
* prefix, and one of the same local name under another prefix stands untouched beside it.
|
|
47
|
+
*/
|
|
48
|
+
export declare function withAttr(attrs: readonly XmlAttr[], name: string, value: string | null): XmlAttr[];
|
|
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[];
|
|
57
|
+
/**
|
|
58
|
+
* An opening tag whose attributes are the ones the original wrote.
|
|
59
|
+
*
|
|
60
|
+
* The text is spliced in exactly as it arrived rather than parsed and written again, so the
|
|
61
|
+
* spelling, the order, and the escaping a producer chose all survive being edited.
|
|
62
|
+
*/
|
|
63
|
+
export declare function openTagXml(name: string, rawAttrs: string | null): string;
|
|
64
|
+
/** The same for an element that closes on its own */
|
|
65
|
+
export declare function emptyTagXml(name: string, rawAttrs: string | null): string;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// src/ooxml/element.ts
|
|
2
|
+
import {
|
|
3
|
+
NAMESPACES,
|
|
4
|
+
qualify,
|
|
5
|
+
W_PREFIX,
|
|
6
|
+
wName
|
|
7
|
+
} from "./names.js";
|
|
8
|
+
import { escapeXml, localPart } from "./xml.js";
|
|
9
|
+
function attrsText(attrs) {
|
|
10
|
+
return attrs.map(([name, value]) => `${name}="${escapeXml(value)}"`).join(" ");
|
|
11
|
+
}
|
|
12
|
+
function elementXml(name, attrs, children = []) {
|
|
13
|
+
const text = attrsText(attrs);
|
|
14
|
+
const open = text === "" ? `<${name}` : `<${name} ${text}`;
|
|
15
|
+
if (children.length === 0) return `${open}/>`;
|
|
16
|
+
return `${open}>${children.join("")}</${name}>`;
|
|
17
|
+
}
|
|
18
|
+
function xmlnsAttr(prefix) {
|
|
19
|
+
return [`xmlns:${prefix}`, NAMESPACES[prefix]];
|
|
20
|
+
}
|
|
21
|
+
function localNameUnder(prefix, name) {
|
|
22
|
+
if (!name.includes(":")) return name;
|
|
23
|
+
const local = localPart(name);
|
|
24
|
+
return name === qualify(prefix, local) ? local : null;
|
|
25
|
+
}
|
|
26
|
+
function wLocalName(name) {
|
|
27
|
+
return localNameUnder(W_PREFIX, name);
|
|
28
|
+
}
|
|
29
|
+
function wAttrIndex(attrs, localName) {
|
|
30
|
+
const qualified = attrs.findIndex(([name]) => name === wName(localName));
|
|
31
|
+
if (qualified !== -1) return qualified;
|
|
32
|
+
return attrs.findIndex(([name]) => name === localName);
|
|
33
|
+
}
|
|
34
|
+
function wAttrValue(attrs, localName) {
|
|
35
|
+
const at = wAttrIndex(attrs, localName);
|
|
36
|
+
return at === -1 ? null : attrs[at][1];
|
|
37
|
+
}
|
|
38
|
+
function withAttr(attrs, name, value) {
|
|
39
|
+
if (value === null) return withoutAttrs(attrs, [name]);
|
|
40
|
+
const at = wAttrIndex(attrs, name);
|
|
41
|
+
if (at === -1) return [...attrs, [wName(name), value]];
|
|
42
|
+
return attrs.map(
|
|
43
|
+
(attr, index) => index === at ? [attr[0], value] : attr
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
function withoutAttrs(attrs, localNames, prefix = W_PREFIX) {
|
|
47
|
+
return attrs.filter(([name]) => {
|
|
48
|
+
const local = localNameUnder(prefix, name);
|
|
49
|
+
return local === null || !localNames.includes(local);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function openTagXml(name, rawAttrs) {
|
|
53
|
+
return rawAttrs ? `<${name} ${rawAttrs}>` : `<${name}>`;
|
|
54
|
+
}
|
|
55
|
+
function emptyTagXml(name, rawAttrs) {
|
|
56
|
+
return rawAttrs ? `<${name} ${rawAttrs}/>` : `<${name}/>`;
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
attrsText,
|
|
60
|
+
elementXml,
|
|
61
|
+
emptyTagXml,
|
|
62
|
+
openTagXml,
|
|
63
|
+
wAttrValue,
|
|
64
|
+
wLocalName,
|
|
65
|
+
withAttr,
|
|
66
|
+
withoutAttrs,
|
|
67
|
+
xmlnsAttr
|
|
68
|
+
};
|
package/dist/ooxml/errors.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Why a document could not be opened.
|
|
10
10
|
*
|
|
11
|
+
* - `no-xml-parser`: the runtime has no XML parser to read the package with. The one code here that is about where the call was made rather than about the file
|
|
11
12
|
* - `not-a-docx`: the bytes are not a readable zip container, its entry names are not a package's, or an entry does not hold what it says it does
|
|
12
13
|
* - `too-large`: the package asks to inflate to more than we open
|
|
13
14
|
* - `missing-part`: the package has no main document part to read
|
|
@@ -15,7 +16,7 @@
|
|
|
15
16
|
* - `malformed-xml`: the XML cannot be parsed, declares a DTD, or its markup is inconsistent
|
|
16
17
|
* - `unsupported-content`: the document holds markup we cannot write back out unchanged
|
|
17
18
|
*/
|
|
18
|
-
export type DocxImportErrorCode = "not-a-docx" | "too-large" | "missing-part" | "missing-body" | "malformed-xml" | "unsupported-content";
|
|
19
|
+
export type DocxImportErrorCode = "no-xml-parser" | "not-a-docx" | "too-large" | "missing-part" | "missing-body" | "malformed-xml" | "unsupported-content";
|
|
19
20
|
/** Thrown when we hit a document whose content cannot be kept safely. We refuse to open it instead of losing it silently */
|
|
20
21
|
export declare class DocxImportError extends Error {
|
|
21
22
|
readonly code: DocxImportErrorCode;
|
|
@@ -26,7 +27,7 @@ export declare class DocxImportError extends Error {
|
|
|
26
27
|
*
|
|
27
28
|
* - `missing-numbering-part`: a new list needs a numbering.xml the document does not have
|
|
28
29
|
* - `missing-content-types`: a new image needs a [Content_Types].xml the package does not have
|
|
29
|
-
* - `unsupported-content`: the document holds a node kind we have no way to serialize
|
|
30
|
+
* - `unsupported-content`: the document holds a node kind we have no way to serialize, or a preserved block standing in two places, which has one original XML to write
|
|
30
31
|
* - `lost-original`: a node that only carries its original XML has lost it
|
|
31
32
|
* - `malformed-xml`: an original XML fragment cannot be read well enough to rewrite
|
|
32
33
|
* - `invalid-table`: the table grid is inconsistent, e.g. a vertical merge outliving its rows
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The gate a raw OOXML string passes through on its way from the DOM into a node or mark attr.
|
|
3
|
+
*
|
|
4
|
+
* A preserved fragment goes back out the way it came, spliced into a slot the writer opens and
|
|
5
|
+
* closes around it (`docx/serializeParagraph`), so a fragment that closes that slot itself, opens
|
|
6
|
+
* a sibling beside it, or lays text down beside what it holds writes something the editor never
|
|
7
|
+
* modelled into the exported file. What stands inside the element it carries is that element's own
|
|
8
|
+
* and travels with it. Reading one back is the only place such a string can arrive from outside,
|
|
9
|
+
* so every attr that carries one is read through here and a fragment that does not hold its shape
|
|
10
|
+
* is turned down rather than corrected.
|
|
11
|
+
*
|
|
12
|
+
* A refusal is not an error: `getAttrs` answers `false` with it, which drops the parse rule and
|
|
13
|
+
* leaves ProseMirror to settle the content one level plainer. Demotion, not contamination.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* What a raw XML string has to look like to be let into the attr that carries it.
|
|
17
|
+
*
|
|
18
|
+
* `element` is a whole element: a properties fragment, a drawing, an annotation reference.
|
|
19
|
+
* `attributes` is what stood inside an opening tag, as `attrString` writes it.
|
|
20
|
+
* `openTag` is an opening tag with everything it wrapped cut away, which the writer puts back by
|
|
21
|
+
* appending the closing text `closedBy` names. `head` is what may still stand between the two:
|
|
22
|
+
* the property elements the tag carries ahead of its content, by local name.
|
|
23
|
+
*/
|
|
24
|
+
export type RawXmlShape = {
|
|
25
|
+
kind: "element";
|
|
26
|
+
names: readonly string[] | "any";
|
|
27
|
+
} | {
|
|
28
|
+
kind: "attributes";
|
|
29
|
+
} | {
|
|
30
|
+
kind: "openTag";
|
|
31
|
+
name: string;
|
|
32
|
+
closedBy: string;
|
|
33
|
+
head: readonly string[];
|
|
34
|
+
};
|
|
35
|
+
/** A single element by local name, rejecting an explicitly foreign namespace */
|
|
36
|
+
export declare function ELEMENT(...names: string[]): RawXmlShape;
|
|
37
|
+
/**
|
|
38
|
+
* A single element of any name, in any namespace.
|
|
39
|
+
*
|
|
40
|
+
* What import could not model keeps its own XML (`rawInline`, `rawBlock`), and that is a
|
|
41
|
+
* `m:oMathPara`, a `mc:AlternateContent`, a `w:ins`, a bookmark: naming the ones allowed would
|
|
42
|
+
* turn a document the editor reads today into a demoted one.
|
|
43
|
+
*/
|
|
44
|
+
export declare const ANY_ELEMENT: RawXmlShape;
|
|
45
|
+
/** The attributes of an opening tag, with neither the tag nor anything it held */
|
|
46
|
+
export declare const ATTRIBUTES: RawXmlShape;
|
|
47
|
+
/**
|
|
48
|
+
* The value if it holds the shape, null if there was none, `false` if it does not.
|
|
49
|
+
*
|
|
50
|
+
* The three answers are what `getAttrs` needs: a value to carry, an absent attr, and a rule to
|
|
51
|
+
* give up on.
|
|
52
|
+
*/
|
|
53
|
+
export declare function acceptRawXml(shape: RawXmlShape, value: string | null): string | null | false;
|