@stll/docx-core 0.24.0 → 0.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/document-DJuN_2kr.js +1200 -0
- package/dist/{document-DT_3cbkQ.d.ts → document-F2xMRFVZ.d.ts} +1296 -177
- package/dist/docx_kernel_bg.wasm +0 -0
- package/dist/index.d.ts +35 -2
- package/dist/index.js +125 -48
- package/dist/model/document.d.ts +3 -2
- package/dist/model/document.js +2 -2
- package/dist/preservedMarkup-G8XjWhs2.d.ts +68 -0
- package/dist/schema/sequenceChildren.d.ts +73 -0
- package/dist/schema/sequenceChildren.js +2 -0
- package/dist/sequenceChildren-DlUb7FZG.js +461 -0
- package/package.json +6 -1
- package/dist/document-CxQxNVrK.js +0 -155
package/dist/docx_kernel_bg.wasm
CHANGED
|
Binary file
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as BlockContent, En as TableCell, F as BreakContent, G as DocumentBody, Ht as Paragraph, In as TextContent, Jt as PositionalTab, Mn as TableRow, Tn as Table, Ut as ParagraphContent, a as DocxPackage, an as RunContent, dn as SectionProperties, g as Style, hr as NumberingDefinitions, i as DocxConformanceClass, in as Run, n as Document, t as DOCX_CONFORMANCE_CLASSES } from "./document-F2xMRFVZ.js";
|
|
2
2
|
import { Buffer } from "node:buffer";
|
|
3
3
|
//#region src/legal-source/types.d.ts
|
|
4
4
|
type LegalDocumentKind = "agreement" | "letter" | "memo" | "checklist" | "pleading" | "other";
|
|
@@ -170,6 +170,39 @@ type SerializeDocumentOptions = {
|
|
|
170
170
|
*/
|
|
171
171
|
declare const serializeDocumentToDocx: (document: Document, options?: SerializeDocumentOptions) => Promise<ArrayBuffer>;
|
|
172
172
|
//#endregion
|
|
173
|
+
//#region src/serialize/xml.d.ts
|
|
174
|
+
/**
|
|
175
|
+
* The one writer for a `CT_OnOff` element: `w:b`, `w:cantSplit`, `w:hideMark`,
|
|
176
|
+
* every element the schema types `CT_OnOff`.
|
|
177
|
+
*
|
|
178
|
+
* A toggle has three states, not two. Absent inherits whatever the style
|
|
179
|
+
* hierarchy resolves to; the bare element is an explicit on; `w:val="0"` is an
|
|
180
|
+
* explicit off, and an explicit off is the only thing that cancels an inherited
|
|
181
|
+
* on. ECMA-376 combines two levels of the hierarchy by XOR rather than by
|
|
182
|
+
* override, so dropping the off does not merely lose a `false`: it flips the
|
|
183
|
+
* resolved value of every toggle the style set above it turns on.
|
|
184
|
+
*
|
|
185
|
+
* Writing the bare element for on and nothing at all for off — the shape a
|
|
186
|
+
* `if (value) parts.push("<w:x/>")` guard produces — is therefore a silent
|
|
187
|
+
* corruption, and it is a shape that reappears at every new toggle site. So
|
|
188
|
+
* there is one writer, `scripts/on-off-element-writer.test.ts` refuses a second
|
|
189
|
+
* one, and a site that spells the element itself does not reach a consumer.
|
|
190
|
+
*
|
|
191
|
+
* `ST_OnOff` spells an on three ways and an off three ways. The readers take
|
|
192
|
+
* all six, and a captured element replays the bytes it arrived as; what folio
|
|
193
|
+
* *writes* is one spelling per polarity, because a package that writes three
|
|
194
|
+
* makes every byte-level comparison argue about which one it is looking at.
|
|
195
|
+
*/
|
|
196
|
+
declare const serializeOnOffElement: (value: boolean | undefined, name: string) => string;
|
|
197
|
+
/**
|
|
198
|
+
* Append a `CT_OnOff` element to a property list, and nothing when it is absent.
|
|
199
|
+
*
|
|
200
|
+
* Most property serializers decide whether to write the enclosing element from
|
|
201
|
+
* `parts.length`, so an absent toggle must not leave an empty string behind:
|
|
202
|
+
* that would turn an unformatted run into a `<w:rPr></w:rPr>`.
|
|
203
|
+
*/
|
|
204
|
+
declare const pushOnOffElement: (parts: string[], value: boolean | undefined, name: string) => void;
|
|
205
|
+
//#endregion
|
|
173
206
|
//#region src/serialize/xmlEscape.d.ts
|
|
174
207
|
/**
|
|
175
208
|
* The one owner of XML character escaping for every part folio writes.
|
|
@@ -274,4 +307,4 @@ declare const validateDocxPackage: (buffer: ArrayBuffer | Uint8Array) => Promise
|
|
|
274
307
|
declare const validateDocumentModel: (document: Document) => ValidateDocumentModelResult;
|
|
275
308
|
declare const assertValidDocumentModel: (document: Document) => void;
|
|
276
309
|
//#endregion
|
|
277
|
-
export { type Autofix, type BlockContent, type BreakContent, type CompiledLegalDocument, DOCX_CONFORMANCE_CLASSES, DOCX_PACKAGE_ISSUE_CODES, type Document, type DocumentBody, type DocxConformanceClass, type DocxPackage, type DocxPackageIssueCode, type LegalDraft, type LegalDraftBlock, type LegalDraftDiagnostic, type LegalSourceCompileOptions, type LegalSourceCompileResult, type LegalSourceDocxCompileResult, type LegalSourceParseResult, type MarkdownContent, type Paragraph, type ParagraphContent, type PositionalTab, type Run, type RunContent, type SectionProperties, type Style, type Table, type TableCell, type TableRow, type TextContent, type ValidateDocumentModelIssue, type ValidateDocumentModelResult, type ValidateDocxPackageResult, assertValidDocumentModel, compileLegalSourceToDocument, compileLegalSourceToDocx, compileMarkdownToContent, escapeXmlAttribute, escapeXmlText, hasIllegalXmlCharacters, parseLegalSource, requiresXmlSpacePreserve, sanitizeExternalUrl, sanitizeXmlCharacters, serializeDocumentToDocx, validateDocumentModel, validateDocxPackage, validateLegalDraft };
|
|
310
|
+
export { type Autofix, type BlockContent, type BreakContent, type CompiledLegalDocument, DOCX_CONFORMANCE_CLASSES, DOCX_PACKAGE_ISSUE_CODES, type Document, type DocumentBody, type DocxConformanceClass, type DocxPackage, type DocxPackageIssueCode, type LegalDraft, type LegalDraftBlock, type LegalDraftDiagnostic, type LegalSourceCompileOptions, type LegalSourceCompileResult, type LegalSourceDocxCompileResult, type LegalSourceParseResult, type MarkdownContent, type Paragraph, type ParagraphContent, type PositionalTab, type Run, type RunContent, type SectionProperties, type Style, type Table, type TableCell, type TableRow, type TextContent, type ValidateDocumentModelIssue, type ValidateDocumentModelResult, type ValidateDocxPackageResult, assertValidDocumentModel, compileLegalSourceToDocument, compileLegalSourceToDocx, compileMarkdownToContent, escapeXmlAttribute, escapeXmlText, hasIllegalXmlCharacters, parseLegalSource, pushOnOffElement, requiresXmlSpacePreserve, sanitizeExternalUrl, sanitizeXmlCharacters, serializeDocumentToDocx, serializeOnOffElement, validateDocumentModel, validateDocxPackage, validateLegalDraft };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { $ as paragraphNumberingSlots, H as headingOutlineLevel, Q as paragraphNumberingReferenceId, X as paragraphNumberingLevel, Z as paragraphNumberingReference, b as statesNoBorder, c as isOoxmlSymbolCharacter, g as borderStyleToken, t as DOCX_CONFORMANCE_CLASSES } from "./document-DJuN_2kr.js";
|
|
2
|
+
import { i as serializeSequenceChildren } from "./sequenceChildren-DlUb7FZG.js";
|
|
3
3
|
import { panic } from "better-result";
|
|
4
|
+
import JSZip from "jszip";
|
|
4
5
|
import { XMLParser, XMLValidator } from "fast-xml-parser";
|
|
5
6
|
import { Marked } from "marked";
|
|
6
7
|
//#region src/serialize/textWhitespace.ts
|
|
@@ -109,6 +110,43 @@ const sanitizeXmlCharacters = (value) => hasIllegalXmlCharacters(value) ? value.
|
|
|
109
110
|
//#endregion
|
|
110
111
|
//#region src/serialize/xml.ts
|
|
111
112
|
const attr = (name, value) => value === void 0 ? "" : ` ${name}="${escapeXmlAttribute(String(value))}"`;
|
|
113
|
+
/**
|
|
114
|
+
* The one writer for a `CT_OnOff` element: `w:b`, `w:cantSplit`, `w:hideMark`,
|
|
115
|
+
* every element the schema types `CT_OnOff`.
|
|
116
|
+
*
|
|
117
|
+
* A toggle has three states, not two. Absent inherits whatever the style
|
|
118
|
+
* hierarchy resolves to; the bare element is an explicit on; `w:val="0"` is an
|
|
119
|
+
* explicit off, and an explicit off is the only thing that cancels an inherited
|
|
120
|
+
* on. ECMA-376 combines two levels of the hierarchy by XOR rather than by
|
|
121
|
+
* override, so dropping the off does not merely lose a `false`: it flips the
|
|
122
|
+
* resolved value of every toggle the style set above it turns on.
|
|
123
|
+
*
|
|
124
|
+
* Writing the bare element for on and nothing at all for off — the shape a
|
|
125
|
+
* `if (value) parts.push("<w:x/>")` guard produces — is therefore a silent
|
|
126
|
+
* corruption, and it is a shape that reappears at every new toggle site. So
|
|
127
|
+
* there is one writer, `scripts/on-off-element-writer.test.ts` refuses a second
|
|
128
|
+
* one, and a site that spells the element itself does not reach a consumer.
|
|
129
|
+
*
|
|
130
|
+
* `ST_OnOff` spells an on three ways and an off three ways. The readers take
|
|
131
|
+
* all six, and a captured element replays the bytes it arrived as; what folio
|
|
132
|
+
* *writes* is one spelling per polarity, because a package that writes three
|
|
133
|
+
* makes every byte-level comparison argue about which one it is looking at.
|
|
134
|
+
*/
|
|
135
|
+
const serializeOnOffElement = (value, name) => {
|
|
136
|
+
if (value === void 0) return "";
|
|
137
|
+
return value ? `<w:${name}/>` : `<w:${name} w:val="0"/>`;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Append a `CT_OnOff` element to a property list, and nothing when it is absent.
|
|
141
|
+
*
|
|
142
|
+
* Most property serializers decide whether to write the enclosing element from
|
|
143
|
+
* `parts.length`, so an absent toggle must not leave an empty string behind:
|
|
144
|
+
* that would turn an unformatted run into a `<w:rPr></w:rPr>`.
|
|
145
|
+
*/
|
|
146
|
+
const pushOnOffElement = (parts, value, name) => {
|
|
147
|
+
const xml = serializeOnOffElement(value, name);
|
|
148
|
+
if (xml) parts.push(xml);
|
|
149
|
+
};
|
|
112
150
|
//#endregion
|
|
113
151
|
//#region src/serialize/docx.ts
|
|
114
152
|
const DEFAULT_FOOTER_REL_ID = "rId10";
|
|
@@ -242,6 +280,8 @@ const serializeBlock = (block) => {
|
|
|
242
280
|
case "table": return serializeTable(block);
|
|
243
281
|
case "blockSdt": return "";
|
|
244
282
|
case "preservedBlock": return block.xml;
|
|
283
|
+
case "bookmarkStart":
|
|
284
|
+
case "bookmarkEnd": return "";
|
|
245
285
|
default: return "";
|
|
246
286
|
}
|
|
247
287
|
};
|
|
@@ -253,10 +293,13 @@ const serializeParagraphProperties = (paragraph) => {
|
|
|
253
293
|
if (!formatting && !paragraph.sectionProperties) return "";
|
|
254
294
|
const parts = [];
|
|
255
295
|
if (formatting?.styleId) parts.push(`<w:pStyle w:val="${escapeXmlAttribute(formatting.styleId)}"/>`);
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
if (formatting?.numPr
|
|
296
|
+
pushOnOffElement(parts, formatting?.keepNext, "keepNext");
|
|
297
|
+
pushOnOffElement(parts, formatting?.keepLines, "keepLines");
|
|
298
|
+
pushOnOffElement(parts, formatting?.pageBreakBefore, "pageBreakBefore");
|
|
299
|
+
if (formatting?.numPr !== void 0) {
|
|
300
|
+
const { numId, ilvl } = paragraphNumberingSlots(formatting.numPr);
|
|
301
|
+
parts.push("<w:numPr>" + (ilvl === void 0 ? "" : `<w:ilvl w:val="${ilvl}"/>`) + (numId === void 0 ? "" : `<w:numId w:val="${numId}"/>`) + "</w:numPr>");
|
|
302
|
+
}
|
|
260
303
|
if (formatting?.spaceBefore !== void 0 || formatting?.spaceAfter !== void 0 || formatting?.lineSpacing !== void 0) parts.push(`<w:spacing${attr("w:before", formatting.spaceBefore)}${attr("w:after", formatting.spaceAfter)}${attr("w:line", formatting.lineSpacing)}${attr("w:lineRule", formatting.lineSpacingRule)}/>`);
|
|
261
304
|
if (formatting?.indentLeft !== void 0 || formatting?.indentRight !== void 0 || formatting?.indentFirstLine !== void 0) parts.push(`<w:ind${attr("w:left", formatting.indentLeft)}${attr("w:right", formatting.indentRight)}${attr(formatting.hangingIndent ? "w:hanging" : "w:firstLine", formatting.indentFirstLine)}/>`);
|
|
262
305
|
if (formatting?.alignment) parts.push(`<w:jc w:val="${formatting.alignment}"/>`);
|
|
@@ -292,26 +335,35 @@ const serializeParagraphContent = (content) => {
|
|
|
292
335
|
const serializeRun = (run) => {
|
|
293
336
|
return `<w:r>${serializeRunProperties(run.formatting)}${run.content.map(serializeRunContent).join("")}</w:r>`;
|
|
294
337
|
};
|
|
338
|
+
/**
|
|
339
|
+
* The run properties a compiled run carries, in the schema's child order.
|
|
340
|
+
*
|
|
341
|
+
* The order comes from the generated list rather than from the order of the
|
|
342
|
+
* statements below: this writer had grown its own, putting `w:highlight`,
|
|
343
|
+
* `w:sz` and `w:szCs` ahead of `w:rFonts`, so a compiled run with both a font
|
|
344
|
+
* and a size came out in a different order from the same run written by
|
|
345
|
+
* folio-core's serializer.
|
|
346
|
+
*/
|
|
295
347
|
const serializeRunProperties = (formatting) => {
|
|
296
348
|
if (!formatting) return "";
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
349
|
+
const { ascii, hAnsi, cs: csFont } = formatting.fontFamily ?? {};
|
|
350
|
+
const parts = serializeSequenceChildren({
|
|
351
|
+
container: "run-properties",
|
|
352
|
+
modelled: [
|
|
353
|
+
["rStyle", formatting.styleId ? `<w:rStyle w:val="${escapeXmlAttribute(formatting.styleId)}"/>` : ""],
|
|
354
|
+
["rFonts", formatting.fontFamily ? `<w:rFonts${attr("w:ascii", ascii)}${attr("w:hAnsi", hAnsi)}${attr("w:cs", csFont)}/>` : ""],
|
|
355
|
+
["b", serializeOnOffElement(formatting.bold, "b")],
|
|
356
|
+
["bCs", serializeOnOffElement(formatting.boldCs, "bCs")],
|
|
357
|
+
["i", serializeOnOffElement(formatting.italic, "i")],
|
|
358
|
+
["iCs", serializeOnOffElement(formatting.italicCs, "iCs")],
|
|
359
|
+
["caps", serializeOnOffElement(formatting.allCaps, "caps")],
|
|
360
|
+
["smallCaps", serializeOnOffElement(formatting.smallCaps, "smallCaps")],
|
|
361
|
+
["sz", formatting.fontSize === void 0 ? "" : `<w:sz w:val="${formatting.fontSize}"/>`],
|
|
362
|
+
["szCs", formatting.fontSizeCs === void 0 ? "" : `<w:szCs w:val="${formatting.fontSizeCs}"/>`],
|
|
363
|
+
["highlight", formatting.highlight ? `<w:highlight w:val="${formatting.highlight}"/>` : ""],
|
|
364
|
+
["cs", serializeOnOffElement(formatting.cs, "cs")]
|
|
365
|
+
]
|
|
366
|
+
});
|
|
315
367
|
return parts.length > 0 ? `<w:rPr>${parts.join("")}</w:rPr>` : "";
|
|
316
368
|
};
|
|
317
369
|
const serializeRunContent = (content) => {
|
|
@@ -320,7 +372,9 @@ const serializeRunContent = (content) => {
|
|
|
320
372
|
case "tab":
|
|
321
373
|
if (!content.positional) return "<w:tab/>";
|
|
322
374
|
return `<w:ptab${attr("w:relativeTo", content.positional.relativeTo)}${attr("w:alignment", content.positional.alignment)}${attr("w:leader", content.positional.leader)}/>`;
|
|
323
|
-
case "break":
|
|
375
|
+
case "break":
|
|
376
|
+
if (content.sourceElement === "cr") return "<w:cr/>";
|
|
377
|
+
return `<w:br${attr("w:type", content.breakType)}/>`;
|
|
324
378
|
case "renderedPageBreak": return "<w:lastRenderedPageBreak/>";
|
|
325
379
|
case "symbol": return `<w:sym w:font="${escapeXmlAttribute(content.font)}" w:char="${escapeXmlAttribute(content.char)}"/>`;
|
|
326
380
|
case "footnoteRef": return `<w:footnoteReference w:id="${content.id}"/>`;
|
|
@@ -375,10 +429,11 @@ const renderCellBorders = (table) => {
|
|
|
375
429
|
};
|
|
376
430
|
const borderEdgeXml = (tag, spec) => {
|
|
377
431
|
if (!spec) return `<${tag} w:val="nil"/>`;
|
|
378
|
-
|
|
432
|
+
const val = borderStyleToken(spec.style);
|
|
433
|
+
if (statesNoBorder(spec.style)) return `<${tag} w:val="${escapeXmlAttribute(val)}"/>`;
|
|
379
434
|
const sz = spec.size ?? 4;
|
|
380
435
|
const color = spec.color?.rgb ?? "CCCCCC";
|
|
381
|
-
return `<${tag} w:val="${escapeXmlAttribute(
|
|
436
|
+
return `<${tag} w:val="${escapeXmlAttribute(val)}" w:sz="${sz}" w:space="0" w:color="${escapeXmlAttribute(color)}"/>`;
|
|
382
437
|
};
|
|
383
438
|
/**
|
|
384
439
|
* The grid this generator gives a table that declares no borders of its own.
|
|
@@ -435,7 +490,7 @@ const serializeStyle = (style) => {
|
|
|
435
490
|
`<w:name w:val="${escapeXmlAttribute(style.name ?? style.styleId)}"/>`,
|
|
436
491
|
style.basedOn ? `<w:basedOn w:val="${escapeXmlAttribute(style.basedOn)}"/>` : "",
|
|
437
492
|
style.next ? `<w:next w:val="${escapeXmlAttribute(style.next)}"/>` : "",
|
|
438
|
-
style.qFormat
|
|
493
|
+
serializeOnOffElement(style.qFormat, "qFormat"),
|
|
439
494
|
pPr ? `<w:pPr>${pPr}</w:pPr>` : "",
|
|
440
495
|
rPr,
|
|
441
496
|
"</w:style>"
|
|
@@ -458,7 +513,7 @@ const serializeNumberingLevel = (level) => [
|
|
|
458
513
|
`<w:lvl w:ilvl="${level.ilvl}">`,
|
|
459
514
|
`<w:start w:val="${level.start ?? 1}"/>`,
|
|
460
515
|
`<w:numFmt w:val="${level.numFmt}"/>`,
|
|
461
|
-
level.isLgl
|
|
516
|
+
serializeOnOffElement(level.isLgl, "isLgl"),
|
|
462
517
|
level.suffix ? `<w:suff w:val="${level.suffix}"/>` : "",
|
|
463
518
|
`<w:lvlText w:val="${escapeXmlAttribute(level.lvlText)}"/>`,
|
|
464
519
|
`<w:lvlJc w:val="${level.lvlJc ?? "left"}"/>`,
|
|
@@ -723,6 +778,7 @@ const validateBlock = (block, path, ctx) => {
|
|
|
723
778
|
return;
|
|
724
779
|
}
|
|
725
780
|
if (block.type === "preservedBlock") return;
|
|
781
|
+
if (block.type === "bookmarkStart" || block.type === "bookmarkEnd") return;
|
|
726
782
|
if (block.content.length === 0) {
|
|
727
783
|
addWarning(ctx, `${path}.content`, "Block content control is empty.");
|
|
728
784
|
return;
|
|
@@ -819,6 +875,10 @@ const validateFieldChild = (child, path, ctx) => {
|
|
|
819
875
|
return;
|
|
820
876
|
}
|
|
821
877
|
if (child.type === "preservedInline") return;
|
|
878
|
+
if (child.type === "inlineWrapper") {
|
|
879
|
+
validateParagraphContent(child, path, ctx);
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
822
882
|
validateHyperlink(child, path, ctx);
|
|
823
883
|
};
|
|
824
884
|
const validateRuns = (runs, path, ctx) => {
|
|
@@ -863,6 +923,10 @@ const validateHyperlinkChild = (child, path, ctx) => {
|
|
|
863
923
|
return;
|
|
864
924
|
}
|
|
865
925
|
if (child.type === "preservedInline") return;
|
|
926
|
+
if (child.type === "inlineWrapper") {
|
|
927
|
+
validateParagraphContent(child, path, ctx);
|
|
928
|
+
return;
|
|
929
|
+
}
|
|
866
930
|
increment(ctx.bookmarkEnds, child.id);
|
|
867
931
|
};
|
|
868
932
|
const validateTrackedRunChange = (change, path, ctx) => {
|
|
@@ -916,11 +980,14 @@ const validateParagraphs = (paragraphs, path, ctx) => {
|
|
|
916
980
|
const validateNumbering = (paragraph, path, ctx) => {
|
|
917
981
|
const numPr = paragraph.formatting?.numPr;
|
|
918
982
|
if (!numPr) return;
|
|
919
|
-
const ilvl = numPr
|
|
920
|
-
if (ilvl
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
983
|
+
const ilvl = paragraphNumberingLevel(numPr);
|
|
984
|
+
if (ilvl !== void 0) {
|
|
985
|
+
if (ilvl < 0) addError(ctx, `${path}.formatting.numPr.ilvl`, "List level must be zero or greater.");
|
|
986
|
+
else if (ilvl > 8) addWarning(ctx, `${path}.formatting.numPr.ilvl`, "List level is outside Word's standard 0-8 range.");
|
|
987
|
+
}
|
|
988
|
+
const referenceId = paragraphNumberingReferenceId(numPr);
|
|
989
|
+
if (referenceId === void 0) return;
|
|
990
|
+
if (!ctx.numberingNums.has(referenceId)) addError(ctx, `${path}.formatting.numPr.numId`, `Numbering definition ${referenceId} is missing.`);
|
|
924
991
|
};
|
|
925
992
|
const validateSectionProperties = (section, path, ctx) => {
|
|
926
993
|
validateHeaderFooterReferences(section.headerReferences ?? [], ctx.headers, `${path}.headerReferences`, "header", ctx);
|
|
@@ -2077,21 +2144,21 @@ const appendBlock = (content, block, options) => {
|
|
|
2077
2144
|
};
|
|
2078
2145
|
const clauseNumbering = (block, profile) => {
|
|
2079
2146
|
if (profile !== "legal") return;
|
|
2080
|
-
return {
|
|
2147
|
+
return paragraphNumberingReference({
|
|
2081
2148
|
numId: LEGAL_NUMBERING_ID,
|
|
2082
2149
|
ilvl: Math.max(0, block.level - 1)
|
|
2083
|
-
};
|
|
2150
|
+
});
|
|
2084
2151
|
};
|
|
2085
2152
|
const listNumbering = (block, profile) => {
|
|
2086
2153
|
if (profile === "none") return;
|
|
2087
|
-
if (profile === "checklist") return {
|
|
2154
|
+
if (profile === "checklist") return paragraphNumberingReference({
|
|
2088
2155
|
numId: CHECKLIST_NUMBERING_ID,
|
|
2089
2156
|
ilvl: 0
|
|
2090
|
-
};
|
|
2091
|
-
return {
|
|
2157
|
+
});
|
|
2158
|
+
return paragraphNumberingReference({
|
|
2092
2159
|
numId: block.ordered ? LEGAL_NUMBERING_ID : BULLET_NUMBERING_ID,
|
|
2093
2160
|
ilvl: block.ordered ? 2 : 0
|
|
2094
|
-
};
|
|
2161
|
+
});
|
|
2095
2162
|
};
|
|
2096
2163
|
const appendParagraphs = (content, paragraphs, styleId) => {
|
|
2097
2164
|
for (const text of paragraphs) content.push(paragraph(text, styleId));
|
|
@@ -2271,7 +2338,10 @@ const createStyleDefinitions = () => ({
|
|
|
2271
2338
|
keepNext: true,
|
|
2272
2339
|
spaceBefore: 360,
|
|
2273
2340
|
spaceAfter: 160,
|
|
2274
|
-
outlineLevel:
|
|
2341
|
+
outlineLevel: {
|
|
2342
|
+
kind: "heading",
|
|
2343
|
+
level: 0
|
|
2344
|
+
}
|
|
2275
2345
|
}
|
|
2276
2346
|
},
|
|
2277
2347
|
{
|
|
@@ -2289,7 +2359,10 @@ const createStyleDefinitions = () => ({
|
|
|
2289
2359
|
keepNext: true,
|
|
2290
2360
|
spaceBefore: 240,
|
|
2291
2361
|
spaceAfter: 120,
|
|
2292
|
-
outlineLevel:
|
|
2362
|
+
outlineLevel: {
|
|
2363
|
+
kind: "heading",
|
|
2364
|
+
level: 1
|
|
2365
|
+
}
|
|
2293
2366
|
}
|
|
2294
2367
|
},
|
|
2295
2368
|
{
|
|
@@ -2304,7 +2377,10 @@ const createStyleDefinitions = () => ({
|
|
|
2304
2377
|
keepNext: true,
|
|
2305
2378
|
spaceBefore: 160,
|
|
2306
2379
|
spaceAfter: 120,
|
|
2307
|
-
outlineLevel:
|
|
2380
|
+
outlineLevel: {
|
|
2381
|
+
kind: "heading",
|
|
2382
|
+
level: 2
|
|
2383
|
+
}
|
|
2308
2384
|
}
|
|
2309
2385
|
},
|
|
2310
2386
|
{
|
|
@@ -2537,10 +2613,10 @@ const para = (runs, styleId) => ({
|
|
|
2537
2613
|
});
|
|
2538
2614
|
const listPara = (runs, rendering) => ({
|
|
2539
2615
|
type: "paragraph",
|
|
2540
|
-
formatting: { numPr: {
|
|
2616
|
+
formatting: { numPr: paragraphNumberingReference({
|
|
2541
2617
|
numId: rendering.numId,
|
|
2542
2618
|
ilvl: rendering.level
|
|
2543
|
-
} },
|
|
2619
|
+
}) },
|
|
2544
2620
|
listRendering: rendering,
|
|
2545
2621
|
content: runs.length > 0 ? runs : [textRun("")]
|
|
2546
2622
|
});
|
|
@@ -2638,9 +2714,10 @@ const MAX_HEADING_LEVEL = 4;
|
|
|
2638
2714
|
const headingParagraph = (runs, depth) => {
|
|
2639
2715
|
const level = Math.min(Math.max(depth, 1), MAX_HEADING_LEVEL);
|
|
2640
2716
|
const paragraph = para(runs, `Heading${level}`);
|
|
2641
|
-
|
|
2717
|
+
const outlineLevel = headingOutlineLevel(level - 1);
|
|
2718
|
+
if (outlineLevel !== void 0) paragraph.formatting = {
|
|
2642
2719
|
...paragraph.formatting,
|
|
2643
|
-
outlineLevel
|
|
2720
|
+
outlineLevel
|
|
2644
2721
|
};
|
|
2645
2722
|
return paragraph;
|
|
2646
2723
|
};
|
|
@@ -2706,4 +2783,4 @@ const compileMarkdownToContent = (markdown) => {
|
|
|
2706
2783
|
};
|
|
2707
2784
|
};
|
|
2708
2785
|
//#endregion
|
|
2709
|
-
export { DOCX_CONFORMANCE_CLASSES, DOCX_PACKAGE_ISSUE_CODES, assertValidDocumentModel, compileLegalSourceToDocument, compileLegalSourceToDocx, compileMarkdownToContent, escapeXmlAttribute, escapeXmlText, hasIllegalXmlCharacters, parseLegalSource, requiresXmlSpacePreserve, sanitizeExternalUrl, sanitizeXmlCharacters, serializeDocumentToDocx, validateDocumentModel, validateDocxPackage, validateLegalDraft };
|
|
2786
|
+
export { DOCX_CONFORMANCE_CLASSES, DOCX_PACKAGE_ISSUE_CODES, assertValidDocumentModel, compileLegalSourceToDocument, compileLegalSourceToDocx, compileMarkdownToContent, escapeXmlAttribute, escapeXmlText, hasIllegalXmlCharacters, parseLegalSource, pushOnOffElement, requiresXmlSpacePreserve, sanitizeExternalUrl, sanitizeXmlCharacters, serializeDocumentToDocx, serializeOnOffElement, validateDocumentModel, validateDocxPackage, validateLegalDraft };
|
package/dist/model/document.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
|
|
1
|
+
import { $ as Field, $n as PRESET_LINE_DASH_VALS, $r as sameEffectiveParagraphNumbering, $t as PropertyChange, A as BlockContent, Ai as knownThemeColor, An as TablePropertyChange, Ar as TableGridChange, At as MoveFromRangeEnd, B as CommentReference, Bi as borderStyleFrom, Bn as TrackedRunContent, Br as NO_PARAGRAPH_NUMBERING, Bt as PROPERTY_REVISION_KINDS, C as MAX_RETAINED_PARSE_WARNINGS_PER_CODE, Ci as ShadingProperties, Cn as SymbolContent, Cr as SpacingExplicit, Ct as InstrTextContent, D as ParseWarningLocation, Di as UnrecognisedThemeColor, Dn as TableCellBlock, Dr as TableCellBorders, Dt as MathEquation, E as ParseWarningCode, Ei as ThemeColorValue, En as TableCell, Er as TableBorders, Et as MarkupRangeMarker, F as BreakContent, Fi as SchemeColorValue, Fn as TextBox, Fr as TableWidthType, Ft as NoBreakHyphenContent, G as DocumentBody, Gi as statesNoBorder, Gn as WrapPolygonPoint, Gr as isNumberingReference, Gt as ParagraphMarkChangeKind, H as DRAWING_RAW_XML_MODES, Hi as isBorderNil, Hn as Watermark, Hr as ParagraphNumberingReference, Ht as Paragraph, I as Column, Ii as THEME_COLORS, In as TextContent, Ir as TextEffect, It as NonVisualDrawingNames, J as DrawingRawXmlMode, Jn as PresetLineDashValue, Jr as paragraphNumberingLevel, Jt as PositionalTab, K as DrawingAnchor, Ki as BORDER_STYLES, Kn as isOoxmlSymbolCharacter, Kr as mergeParagraphNumbering, Kt as ParagraphPropertyChange, L as Comment, Li as ThemeColor, Ln as TextWatermark, Lr as TextFormatting, Lt as NoteNumberRestart, M as BookmarkEnd, Mi as themeColorSlot, Mn as TableRow, Mr as TableMeasurement, Mt as MoveTo, N as BookmarkRangeMarker, Ni as themeColorToken, Nn as TableRowPropertyChange, Nr as TablePropertyExceptionFormatting, Nt as MoveToRangeEnd, O as BIDI_CONTROLS, Oi as isSchemeColorValue, On as TableCellPropertyChange, Or as TableCellFormatting, Ot as MoveBookmarkMarker, P as BookmarkStart, Pi as SchemeColorSlot, Pn as TableStructuralChangeInfo, Pr as TableRowFormatting, Pt as MoveToRangeStart, Q as EndnoteProperties, Qn as presetLineDashToken, Qr as resolveParagraphNumbering, Qt as PreservedXmlContent, R as CommentRangeEnd, Ri as BorderStyleValue, Rn as TrackedChangeInfo, Rr as UnderlineStyle, Rt as NoteReferenceContent, S as ThemeFontScheme, Si as ColorValue, Sn as SoftHyphenContent, Sr as ParagraphFormatting, St as Insertion, T as ParseWarning, Ti as THEME_COLOR_BY_SCHEME_COLOR_VALUE, Tn as Table, Tr as TabStop, Tt as MAX_REVISION_ID, U as Deletion, Ui as isBorderNone, Un as WrapDistanceSlots, Ur as ParagraphNumberingSlots, Ut as ParagraphContent, V as ComplexField, Vi as borderStyleToken, Vn as VerticalAlign, Vr as ParagraphNumberingOverride, Vt as PageOrientation, W as DisplacedByCustomXml, Wi as isBorderStyle, Wn as WrapDistances, Wr as ResolvedParagraphNumbering, Wt as ParagraphMarkChange, X as Endnote, Xn as isPresetLineDashVal, Xr as paragraphNumberingReferenceId, Xt as PreservedBlock, Y as EffectExtentSlots, Yn as UnrecognisedPresetLineDash, Yr as paragraphNumberingReference, Yt as PositionedBookmarkMarker, Z as EndnotePosition, Zn as presetLineDashFrom, Zr as paragraphNumberingSlots, Zt as PreservedInline, _ as StyleDefinitions, _i as TabStopAlignment, _n as ShapeGeometryAdjustment, _r as CellMargins, _t as ImageTransform, a as DocxPackage, ai as headingOutlineLevel, an as RunContent, ar as PreviewShape, at as FootnoteProperties, b as ThemeColorScheme, bi as TextDirectionFlow, bn as ShapeType, br as FloatingTableProperties, bt as InlineSdt, c as EmbeddedFontRef, ci as NUMBER_FORMATS, cn as SdtProperties, cr as CounterFormat, ct as HeaderReference, d as FontTable, di as ParagraphAlignment, dn as SectionProperties, dr as LevelSuffix, dt as ImageCrop, ei as sameStatedParagraphNumbering, en as PropertyChangeInfo, er as PresetLineDashVal, et as FieldCharContent, f as MediaFile, fi as TABLE_ALIGNMENTS, fn as SectionPropertyChange, fr as ListLevel, ft as ImageDocPrLink, g as Style, gi as TEXT_DIRECTION_FLOW_BY_TOKEN, gn as ShapeFill, gr as NumberingInstance, gt as ImageSize, h as RelationshipType, hi as TEXT_DIRECTION_FLOWS, hn as ShapeContent, hr as NumberingDefinitions, ht as ImagePosition, i as DocxConformanceClass, ii as headingLevelOf, in as Run, ir as PreviewDescriptor, it as FootnotePosition, j as BlockSdt, ji as readThemeColor, jn as TablePropertyExceptionChange, jr as TableLook, jt as MoveFromRangeStart, k as BidiControl, ki as isThemeColor, kn as TablePreservedMarkup, kr as TableFormatting, kt as MoveFrom, l as FontCharset, li as NumberFormat, ln as SdtType, lr as LevelLegacy, lt as Hyperlink, m as RelationshipMap, mi as TEXT_DIRECTIONS, mn as Shape, mr as ListRendering, mt as ImagePadding, n as Document, ni as HeadingOutlineLevel, nn as REVIEW_CARRIERS, nr as mintRelationshipId, nt as FooterReference, o as ExhaustiveFields, oi as outlineLevelFromStatedValue, on as RunPropertyChange, or as AbstractNumbering, ot as HeaderFooter, p as Relationship, pi as TAB_STOP_ALIGNMENTS, pn as SectionStart, pr as ListMarkerFormatting, pt as ImageFrameLocks, q as DrawingContent, qi as BorderStyle, qn as normalizeRevisionId, qr as paragraphNumberingFromSlots, qt as PictureWatermark, r as DocumentSettings, ri as OutlineLevel, rn as ReviewCarrier, rr as relationshipIdOf, rt as Footnote, s as DocDefaults, si as outlineLevelStatedValue, sn as SdtEndProperties, sr as COUNTER_FORMATS, st as HeaderFooterType, t as DOCX_CONFORMANCE_CLASSES, ti as BODY_TEXT_OUTLINE_LEVEL, tn as PropertyRevisionKind, tr as RelationshipId, tt as FieldType, u as FontInfo, ui as PARAGRAPH_ALIGNMENTS, un as Section, ur as LevelOverride, ut as Image, v as StyleType, vi as TableAlignment, vn as ShapeOutline, vr as ConditionalFormatStyle, vt as ImageWrap, w as PARSE_WARNING_CODES, wi as SCHEME_COLOR_VALUE_BY_THEME_COLOR, wn as TabContent, wr as TabLeader, wt as LineNumberRestart, x as ThemeFont, xi as BorderSpec, xn as SimpleField, xr as LineSpacingRule, xt as InlineWrapper, y as Theme, yi as TextDirection, yn as ShapeTextBody, yr as EmphasisMark, yt as ImageWrapPolygon, z as CommentRangeStart, zi as UnrecognisedBorderStyle, zn as TrackedRunChange, zr as NO_NUMBERING_NUM_ID, zt as PARAGRAPH_MARK_CHANGE_KINDS } from "../document-F2xMRFVZ.js";
|
|
2
|
+
import { n as PreservedChild, r as PreservedMarkup, t as PreservedAttribute } from "../preservedMarkup-G8XjWhs2.js";
|
|
3
|
+
export { type AbstractNumbering, BIDI_CONTROLS, BODY_TEXT_OUTLINE_LEVEL, BORDER_STYLES, type BidiControl, type BlockContent, type BlockSdt, type BookmarkEnd, type BookmarkRangeMarker, type BookmarkStart, type BorderSpec, type BorderStyle, type BorderStyleValue, type BreakContent, COUNTER_FORMATS, type CellMargins, type ColorValue, type Column, type Comment, type CommentRangeEnd, type CommentRangeStart, type CommentReference, type ComplexField, type ConditionalFormatStyle, type CounterFormat, DOCX_CONFORMANCE_CLASSES, DRAWING_RAW_XML_MODES, type Deletion, type DisplacedByCustomXml, type DocDefaults, Document, type DocumentBody, DocumentSettings, DocxConformanceClass, DocxPackage, type DrawingAnchor, type DrawingContent, type DrawingRawXmlMode, type EffectExtentSlots, type EmbeddedFontRef, type EmphasisMark, type Endnote, type EndnotePosition, type EndnoteProperties, type ExhaustiveFields, type Field, type FieldCharContent, type FieldType, type FloatingTableProperties, type FontCharset, type FontInfo, type FontTable, type FooterReference, type Footnote, type FootnotePosition, type FootnoteProperties, type HeaderFooter, type HeaderFooterType, type HeaderReference, type HeadingOutlineLevel, type Hyperlink, type Image, type ImageCrop, type ImageDocPrLink, type ImageFrameLocks, type ImagePadding, type ImagePosition, type ImageSize, type ImageTransform, type ImageWrap, type ImageWrapPolygon, type InlineSdt, type InlineWrapper, type Insertion, type InstrTextContent, type LevelLegacy, type LevelOverride, type LevelSuffix, type LineNumberRestart, type LineSpacingRule, type ListLevel, type ListMarkerFormatting, type ListRendering, MAX_RETAINED_PARSE_WARNINGS_PER_CODE, MAX_REVISION_ID, type MarkupRangeMarker, type MathEquation, type MediaFile, type MoveBookmarkMarker, type MoveFrom, type MoveFromRangeEnd, type MoveFromRangeStart, type MoveTo, type MoveToRangeEnd, type MoveToRangeStart, NO_NUMBERING_NUM_ID, NO_PARAGRAPH_NUMBERING, NUMBER_FORMATS, type NoBreakHyphenContent, type NonVisualDrawingNames, type NoteNumberRestart, type NoteReferenceContent, type NumberFormat, type NumberingDefinitions, type NumberingInstance, type OutlineLevel, PARAGRAPH_ALIGNMENTS, PARAGRAPH_MARK_CHANGE_KINDS, PARSE_WARNING_CODES, PRESET_LINE_DASH_VALS, PROPERTY_REVISION_KINDS, type PageOrientation, type Paragraph, type ParagraphAlignment, type ParagraphContent, type ParagraphFormatting, type ParagraphMarkChange, type ParagraphMarkChangeKind, type ParagraphNumberingOverride, type ParagraphNumberingReference, type ParagraphNumberingSlots, type ParagraphPropertyChange, type ParseWarning, type ParseWarningCode, type ParseWarningLocation, type PictureWatermark, type PositionalTab, type PositionedBookmarkMarker, type PreservedAttribute, type PreservedBlock, type PreservedChild, type PreservedInline, type PreservedMarkup, type PreservedXmlContent, type PresetLineDashVal, type PresetLineDashValue, type PreviewDescriptor, type PreviewShape, type PropertyChange, type PropertyChangeInfo, type PropertyRevisionKind, REVIEW_CARRIERS, type Relationship, type RelationshipId, type RelationshipMap, type RelationshipType, type ResolvedParagraphNumbering, type ReviewCarrier, type Run, type RunContent, type RunPropertyChange, SCHEME_COLOR_VALUE_BY_THEME_COLOR, type SchemeColorSlot, type SchemeColorValue, type SdtEndProperties, type SdtProperties, type SdtType, type Section, type SectionProperties, type SectionPropertyChange, type SectionStart, type ShadingProperties, type Shape, type ShapeContent, type ShapeFill, type ShapeGeometryAdjustment, type ShapeOutline, type ShapeTextBody, type ShapeType, type SimpleField, type SoftHyphenContent, type SpacingExplicit, type Style, type StyleDefinitions, type StyleType, type SymbolContent, TABLE_ALIGNMENTS, TAB_STOP_ALIGNMENTS, TEXT_DIRECTIONS, TEXT_DIRECTION_FLOWS, TEXT_DIRECTION_FLOW_BY_TOKEN, THEME_COLORS, THEME_COLOR_BY_SCHEME_COLOR_VALUE, type TabContent, type TabLeader, type TabStop, type TabStopAlignment, type Table, type TableAlignment, type TableBorders, type TableCell, type TableCellBlock, type TableCellBorders, type TableCellFormatting, type TableCellPropertyChange, type TableFormatting, type TableGridChange, type TableLook, type TableMeasurement, type TablePreservedMarkup, type TablePropertyChange, type TablePropertyExceptionChange, type TablePropertyExceptionFormatting, type TableRow, type TableRowFormatting, type TableRowPropertyChange, type TableStructuralChangeInfo, type TableWidthType, type TextBox, type TextContent, type TextDirection, type TextDirectionFlow, type TextEffect, type TextFormatting, type TextWatermark, type Theme, type ThemeColor, type ThemeColorScheme, type ThemeColorValue, type ThemeFont, type ThemeFontScheme, type TrackedChangeInfo, type TrackedRunChange, type TrackedRunContent, type UnderlineStyle, type UnrecognisedBorderStyle, type UnrecognisedPresetLineDash, type UnrecognisedThemeColor, type VerticalAlign, type Watermark, type WrapDistanceSlots, type WrapDistances, type WrapPolygonPoint, borderStyleFrom, borderStyleToken, headingLevelOf, headingOutlineLevel, isBorderNil, isBorderNone, isBorderStyle, isNumberingReference, isOoxmlSymbolCharacter, isPresetLineDashVal, isSchemeColorValue, isThemeColor, knownThemeColor, mergeParagraphNumbering, mintRelationshipId, normalizeRevisionId, outlineLevelFromStatedValue, outlineLevelStatedValue, paragraphNumberingFromSlots, paragraphNumberingLevel, paragraphNumberingReference, paragraphNumberingReferenceId, paragraphNumberingSlots, presetLineDashFrom, presetLineDashToken, readThemeColor, relationshipIdOf, resolveParagraphNumbering, sameEffectiveParagraphNumbering, sameStatedParagraphNumbering, statesNoBorder, themeColorSlot, themeColorToken };
|
package/dist/model/document.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as PARAGRAPH_MARK_CHANGE_KINDS, c as
|
|
2
|
-
export { BIDI_CONTROLS, DOCX_CONFORMANCE_CLASSES, DRAWING_RAW_XML_MODES, MAX_RETAINED_PARSE_WARNINGS_PER_CODE, MAX_REVISION_ID, PARAGRAPH_MARK_CHANGE_KINDS, PARSE_WARNING_CODES, REVIEW_CARRIERS, isOoxmlSymbolCharacter, normalizeRevisionId };
|
|
1
|
+
import { $ as paragraphNumberingSlots, A as THEME_COLOR_BY_SCHEME_COLOR_VALUE, B as BODY_TEXT_OUTLINE_LEVEL, C as PARAGRAPH_ALIGNMENTS, D as TEXT_DIRECTION_FLOWS, E as TEXT_DIRECTIONS, F as themeColorSlot, G as NO_NUMBERING_NUM_ID, H as headingOutlineLevel, I as themeColorToken, J as mergeParagraphNumbering, K as NO_PARAGRAPH_NUMBERING, L as THEME_COLORS, M as isThemeColor, N as knownThemeColor, O as TEXT_DIRECTION_FLOW_BY_TOKEN, P as readThemeColor, Q as paragraphNumberingReferenceId, R as mintRelationshipId, S as NUMBER_FORMATS, T as TAB_STOP_ALIGNMENTS, U as outlineLevelFromStatedValue, V as headingLevelOf, W as outlineLevelStatedValue, X as paragraphNumberingLevel, Y as paragraphNumberingFromSlots, Z as paragraphNumberingReference, _ as isBorderNil, a as PARAGRAPH_MARK_CHANGE_KINDS, b as statesNoBorder, c as isOoxmlSymbolCharacter, d as isPresetLineDashVal, et as resolveParagraphNumbering, f as presetLineDashFrom, g as borderStyleToken, h as borderStyleFrom, i as MAX_REVISION_ID, it as PARSE_WARNING_CODES, j as isSchemeColorValue, k as SCHEME_COLOR_VALUE_BY_THEME_COLOR, l as normalizeRevisionId, m as PRESET_LINE_DASH_VALS, n as BIDI_CONTROLS, nt as sameStatedParagraphNumbering, o as PROPERTY_REVISION_KINDS, p as presetLineDashToken, q as isNumberingReference, r as DRAWING_RAW_XML_MODES, rt as MAX_RETAINED_PARSE_WARNINGS_PER_CODE, s as REVIEW_CARRIERS, t as DOCX_CONFORMANCE_CLASSES, tt as sameEffectiveParagraphNumbering, u as COUNTER_FORMATS, v as isBorderNone, w as TABLE_ALIGNMENTS, x as BORDER_STYLES, y as isBorderStyle, z as relationshipIdOf } from "../document-DJuN_2kr.js";
|
|
2
|
+
export { BIDI_CONTROLS, BODY_TEXT_OUTLINE_LEVEL, BORDER_STYLES, COUNTER_FORMATS, DOCX_CONFORMANCE_CLASSES, DRAWING_RAW_XML_MODES, MAX_RETAINED_PARSE_WARNINGS_PER_CODE, MAX_REVISION_ID, NO_NUMBERING_NUM_ID, NO_PARAGRAPH_NUMBERING, NUMBER_FORMATS, PARAGRAPH_ALIGNMENTS, PARAGRAPH_MARK_CHANGE_KINDS, PARSE_WARNING_CODES, PRESET_LINE_DASH_VALS, PROPERTY_REVISION_KINDS, REVIEW_CARRIERS, SCHEME_COLOR_VALUE_BY_THEME_COLOR, TABLE_ALIGNMENTS, TAB_STOP_ALIGNMENTS, TEXT_DIRECTIONS, TEXT_DIRECTION_FLOWS, TEXT_DIRECTION_FLOW_BY_TOKEN, THEME_COLORS, THEME_COLOR_BY_SCHEME_COLOR_VALUE, borderStyleFrom, borderStyleToken, headingLevelOf, headingOutlineLevel, isBorderNil, isBorderNone, isBorderStyle, isNumberingReference, isOoxmlSymbolCharacter, isPresetLineDashVal, isSchemeColorValue, isThemeColor, knownThemeColor, mergeParagraphNumbering, mintRelationshipId, normalizeRevisionId, outlineLevelFromStatedValue, outlineLevelStatedValue, paragraphNumberingFromSlots, paragraphNumberingLevel, paragraphNumberingReference, paragraphNumberingReferenceId, paragraphNumberingSlots, presetLineDashFrom, presetLineDashToken, readThemeColor, relationshipIdOf, resolveParagraphNumbering, sameEffectiveParagraphNumbering, sameStatedParagraphNumbering, statesNoBorder, themeColorSlot, themeColorToken };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
//#region src/model/preservedMarkup.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The ordered verbatim sink: where a container's unmodelled markup goes.
|
|
4
|
+
*
|
|
5
|
+
* A parser that walks a container's children, models the ones it recognises
|
|
6
|
+
* and lets the rest fall off the end of a `switch` loses them silently, and
|
|
7
|
+
* verbatim replay hides the loss until somebody edits the document. The sink
|
|
8
|
+
* is the other branch of that `switch`. It keeps the markup as bytes together
|
|
9
|
+
* with **where it was**, so the serializer puts it back between the same
|
|
10
|
+
* modelled siblings rather than at the end of the container, which is what the
|
|
11
|
+
* schema's ordered content models require.
|
|
12
|
+
*
|
|
13
|
+
* The position is recorded as an ordinal, not a pointer: `index` is how many
|
|
14
|
+
* modelled children the container had read when the markup arrived. That
|
|
15
|
+
* survives the model being edited — inserting a paragraph shifts what comes
|
|
16
|
+
* after it, which is what a reader would expect — and it needs no identity on
|
|
17
|
+
* the modelled children. A property set counts differently, and
|
|
18
|
+
* `containerChildren.ts` says why.
|
|
19
|
+
*
|
|
20
|
+
* One field, `preserved`, carries both halves for every container that has a
|
|
21
|
+
* sink, so a reader never has to know which of two names a given container
|
|
22
|
+
* used.
|
|
23
|
+
*/
|
|
24
|
+
/** Markup the container's model does not hold, and where it sat. */
|
|
25
|
+
type PreservedChild = {
|
|
26
|
+
/**
|
|
27
|
+
* Where the markup goes back. `0` puts it before the first modelled child;
|
|
28
|
+
* the container's modelled count puts it after the last. In a property set
|
|
29
|
+
* it is the schema ordinal, and the two halves merge by it.
|
|
30
|
+
*/
|
|
31
|
+
index: number;
|
|
32
|
+
/** Replayable markup for one child, as `captureVerbatimXml` wrote it. */
|
|
33
|
+
xml: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* A container's unmodelled markup. Absent means the parser read every child
|
|
37
|
+
* the source carried, which is the state a fully modelled container is in; an
|
|
38
|
+
* empty record is never written.
|
|
39
|
+
*/
|
|
40
|
+
type PreservedMarkup = {
|
|
41
|
+
/** Ordered by `index`, then by source order within an index. */
|
|
42
|
+
children?: PreservedChild[];
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* One attribute an element carried that its parser has no field for.
|
|
46
|
+
*
|
|
47
|
+
* The remainder is a sibling of the child sink, not a member of it: an
|
|
48
|
+
* attribute has no position among children to keep, so it rides the element's
|
|
49
|
+
* own model record — `Paragraph.preservedAttributes` and its siblings — and
|
|
50
|
+
* the serializer writes it back into the same start tag.
|
|
51
|
+
*
|
|
52
|
+
* The name is resolved, never the source's spelling. folio reads an attribute
|
|
53
|
+
* by namespace URI plus local name, so a remainder that kept `"w:rsidR"`
|
|
54
|
+
* textually would keep a second copy of the `w:rsidR` a source spelled
|
|
55
|
+
* `altw:rsidR` under a second binding of the same URI. `namespace` is absent
|
|
56
|
+
* for an unprefixed attribute, which has none; a namespace declaration is not
|
|
57
|
+
* an attribute of the element in this sense and is never in the remainder,
|
|
58
|
+
* because the rebuilt part binds its own prefixes.
|
|
59
|
+
*/
|
|
60
|
+
type PreservedAttribute = {
|
|
61
|
+
/** Resolved namespace URI, absent for an unprefixed attribute. */
|
|
62
|
+
namespace?: string;
|
|
63
|
+
/** Local name, without the prefix the source happened to bind. */
|
|
64
|
+
name: string;
|
|
65
|
+
value: string;
|
|
66
|
+
};
|
|
67
|
+
//#endregion
|
|
68
|
+
export { PreservedChild as n, PreservedMarkup as r, PreservedAttribute as t };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { r as PreservedMarkup } from "../preservedMarkup-G8XjWhs2.js";
|
|
2
|
+
//#region src/schema/sequenceChildren.gen.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* GENERATED FILE — do not edit.
|
|
5
|
+
*
|
|
6
|
+
* The containers whose content model declares one order for its children, with
|
|
7
|
+
* the children written in it, derived from the committed schema graph by
|
|
8
|
+
* `scripts/generate-container-children.ts`.
|
|
9
|
+
*
|
|
10
|
+
* It lives in the lower package because two packages write a property set and
|
|
11
|
+
* the dependency runs one way: `@stll/docx-core` compiles a `w:rPr` from a
|
|
12
|
+
* legal source and cannot import `@stll/folio-core`. folio-core's
|
|
13
|
+
* declared-child table spreads this one in, so both write the same order and
|
|
14
|
+
* neither restates it.
|
|
15
|
+
*
|
|
16
|
+
* Regenerate with:
|
|
17
|
+
*
|
|
18
|
+
* bun run generate:container-children
|
|
19
|
+
*/
|
|
20
|
+
declare const SEQUENCE_CHILDREN: {
|
|
21
|
+
readonly "w:numbering": readonly ["numPicBullet", "abstractNum", "num", "numIdMacAtCleanup"];
|
|
22
|
+
readonly "w:abstractNum": readonly ["nsid", "multiLevelType", "tmpl", "name", "styleLink", "numStyleLink", "lvl"];
|
|
23
|
+
readonly "w:lvl": readonly ["start", "numFmt", "lvlRestart", "pStyle", "isLgl", "suff", "lvlText", "lvlPicBulletId", "legacy", "lvlJc", "pPr", "rPr"];
|
|
24
|
+
readonly "w:num": readonly ["abstractNumId", "lvlOverride"];
|
|
25
|
+
readonly "w:lvlOverride": readonly ["startOverride", "lvl"];
|
|
26
|
+
readonly "paragraph-properties": readonly ["pStyle", "keepNext", "keepLines", "pageBreakBefore", "framePr", "widowControl", "numPr", "suppressLineNumbers", "pBdr", "shd", "tabs", "suppressAutoHyphens", "kinsoku", "wordWrap", "overflowPunct", "topLinePunct", "autoSpaceDE", "autoSpaceDN", "bidi", "adjustRightInd", "snapToGrid", "spacing", "ind", "contextualSpacing", "mirrorIndents", "suppressOverlap", "jc", "textDirection", "textAlignment", "textboxTightWrap", "outlineLvl", "divId", "cnfStyle", "rPr", "sectPr", "pPrChange"];
|
|
27
|
+
readonly "table-properties": readonly ["tblStyle", "tblpPr", "tblOverlap", "bidiVisual", "tblStyleRowBandSize", "tblStyleColBandSize", "tblW", "jc", "tblCellSpacing", "tblInd", "tblBorders", "shd", "tblLayout", "tblCellMar", "tblLook", "tblCaption", "tblDescription", "tblPrChange"];
|
|
28
|
+
readonly "table-property-exceptions": readonly ["tblW", "jc", "tblCellSpacing", "tblInd", "tblBorders", "shd", "tblLayout", "tblCellMar", "tblLook", "tblPrExChange"];
|
|
29
|
+
readonly "row-properties": readonly ["cnfStyle", "divId", "gridBefore", "gridAfter", "wBefore", "wAfter", "cantSplit", "trHeight", "tblHeader", "tblCellSpacing", "jc", "hidden", "ins", "del", "trPrChange"];
|
|
30
|
+
readonly "cell-properties": readonly ["cnfStyle", "tcW", "gridSpan", "hMerge", "vMerge", "tcBorders", "shd", "noWrap", "tcMar", "textDirection", "tcFitText", "vAlign", "hideMark", "headers", "cellIns", "cellDel", "cellMerge", "tcPrChange"];
|
|
31
|
+
readonly "run-properties": readonly ["ins", "del", "moveFrom", "moveTo", "rStyle", "rFonts", "b", "bCs", "i", "iCs", "caps", "smallCaps", "strike", "dstrike", "outline", "shadow", "emboss", "imprint", "noProof", "snapToGrid", "vanish", "webHidden", "color", "spacing", "w", "kern", "position", "sz", "szCs", "highlight", "u", "effect", "bdr", "shd", "fitText", "vertAlign", "rtl", "cs", "em", "lang", "eastAsianLayout", "specVanish", "oMath", "rPrChange"];
|
|
32
|
+
readonly "content-control-properties": readonly ["rPr", "alias", "tag", "id", "lock", "placeholder", "temporary", "showingPlcHdr", "dataBinding", "label", "tabIndex", "equation", "comboBox", "date", "docPartObj", "docPartList", "dropDownList", "picture", "richText", "text", "citation", "group", "bibliography"];
|
|
33
|
+
readonly "section-properties": readonly ["headerReference", "footerReference", "footnotePr", "endnotePr", "type", "pgSz", "pgMar", "paperSrc", "pgBorders", "lnNumType", "pgNumType", "cols", "formProt", "vAlign", "noEndnote", "titlePg", "textDirection", "bidi", "rtlGutter", "docGrid", "printerSettings", "sectPrChange"];
|
|
34
|
+
};
|
|
35
|
+
/** A container whose declared children have an order. */
|
|
36
|
+
type SequenceContainer = keyof typeof SEQUENCE_CHILDREN;
|
|
37
|
+
/** Every child the schema declares for `Container`, in declaration order. */
|
|
38
|
+
type SequenceChild<Container extends SequenceContainer> = (typeof SEQUENCE_CHILDREN)[Container][number];
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/schema/sequenceChildren.d.ts
|
|
41
|
+
type SerializeSequenceChildrenOptions<Container extends SequenceContainer> = {
|
|
42
|
+
container: Container;
|
|
43
|
+
/**
|
|
44
|
+
* The modelled children keyed by element name rather than pre-ordered, so
|
|
45
|
+
* the caller cannot state an order of its own.
|
|
46
|
+
*
|
|
47
|
+
* An empty string means the caller wrote nothing for that child.
|
|
48
|
+
*/
|
|
49
|
+
modelled: ReadonlyArray<readonly [name: SequenceChild<Container>, xml: string]>;
|
|
50
|
+
/**
|
|
51
|
+
* The container's unmodelled markup, each capture carrying the schema
|
|
52
|
+
* ordinal it was read at, so it lands between the same two neighbours.
|
|
53
|
+
*
|
|
54
|
+
* A caller that builds a document from scratch has none.
|
|
55
|
+
*/
|
|
56
|
+
preserved?: PreservedMarkup | undefined;
|
|
57
|
+
};
|
|
58
|
+
/** Whether a captured child is exactly one bounded, well-formed XML element. */
|
|
59
|
+
declare const isSafePreservedChildXml: (xml: string) => boolean;
|
|
60
|
+
/** Whether a capture collection stays within its aggregate resource budget. */
|
|
61
|
+
declare const isWithinPreservedMarkupBudget: (children: readonly unknown[]) => boolean;
|
|
62
|
+
/** Reject unsafe captured children before a caller performs any transformation. */
|
|
63
|
+
declare const assertSafePreservedMarkup: (preserved: PreservedMarkup | undefined) => void;
|
|
64
|
+
/**
|
|
65
|
+
* A property set's children, modelled and captured, in schema order.
|
|
66
|
+
*
|
|
67
|
+
* Ties are only possible between a declared child and a capture sharing its
|
|
68
|
+
* slot — an undeclared name takes the place of the last declared child before
|
|
69
|
+
* it. The sort is stable and the modelled child leads.
|
|
70
|
+
*/
|
|
71
|
+
declare const serializeSequenceChildren: <Container extends SequenceContainer>({ container, modelled, preserved }: SerializeSequenceChildrenOptions<Container>) => string[];
|
|
72
|
+
//#endregion
|
|
73
|
+
export { SEQUENCE_CHILDREN, type SequenceChild, type SequenceContainer, assertSafePreservedMarkup, isSafePreservedChildXml, isWithinPreservedMarkupBudget, serializeSequenceChildren };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as SEQUENCE_CHILDREN, i as serializeSequenceChildren, n as isSafePreservedChildXml, r as isWithinPreservedMarkupBudget, t as assertSafePreservedMarkup } from "../sequenceChildren-DlUb7FZG.js";
|
|
2
|
+
export { SEQUENCE_CHILDREN, assertSafePreservedMarkup, isSafePreservedChildXml, isWithinPreservedMarkupBudget, serializeSequenceChildren };
|