@stll/docx-core 0.24.0 → 0.25.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/dist/document-DJuN_2kr.js +1200 -0
- package/dist/{document-DT_3cbkQ.d.ts → document-tiNJggub.d.ts} +1280 -177
- package/dist/docx_kernel_bg.wasm +0 -0
- package/dist/index.d.ts +35 -2
- package/dist/index.js +122 -47
- 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-tiNJggub.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) => {
|
|
@@ -375,10 +427,11 @@ const renderCellBorders = (table) => {
|
|
|
375
427
|
};
|
|
376
428
|
const borderEdgeXml = (tag, spec) => {
|
|
377
429
|
if (!spec) return `<${tag} w:val="nil"/>`;
|
|
378
|
-
|
|
430
|
+
const val = borderStyleToken(spec.style);
|
|
431
|
+
if (statesNoBorder(spec.style)) return `<${tag} w:val="${escapeXmlAttribute(val)}"/>`;
|
|
379
432
|
const sz = spec.size ?? 4;
|
|
380
433
|
const color = spec.color?.rgb ?? "CCCCCC";
|
|
381
|
-
return `<${tag} w:val="${escapeXmlAttribute(
|
|
434
|
+
return `<${tag} w:val="${escapeXmlAttribute(val)}" w:sz="${sz}" w:space="0" w:color="${escapeXmlAttribute(color)}"/>`;
|
|
382
435
|
};
|
|
383
436
|
/**
|
|
384
437
|
* The grid this generator gives a table that declares no borders of its own.
|
|
@@ -435,7 +488,7 @@ const serializeStyle = (style) => {
|
|
|
435
488
|
`<w:name w:val="${escapeXmlAttribute(style.name ?? style.styleId)}"/>`,
|
|
436
489
|
style.basedOn ? `<w:basedOn w:val="${escapeXmlAttribute(style.basedOn)}"/>` : "",
|
|
437
490
|
style.next ? `<w:next w:val="${escapeXmlAttribute(style.next)}"/>` : "",
|
|
438
|
-
style.qFormat
|
|
491
|
+
serializeOnOffElement(style.qFormat, "qFormat"),
|
|
439
492
|
pPr ? `<w:pPr>${pPr}</w:pPr>` : "",
|
|
440
493
|
rPr,
|
|
441
494
|
"</w:style>"
|
|
@@ -458,7 +511,7 @@ const serializeNumberingLevel = (level) => [
|
|
|
458
511
|
`<w:lvl w:ilvl="${level.ilvl}">`,
|
|
459
512
|
`<w:start w:val="${level.start ?? 1}"/>`,
|
|
460
513
|
`<w:numFmt w:val="${level.numFmt}"/>`,
|
|
461
|
-
level.isLgl
|
|
514
|
+
serializeOnOffElement(level.isLgl, "isLgl"),
|
|
462
515
|
level.suffix ? `<w:suff w:val="${level.suffix}"/>` : "",
|
|
463
516
|
`<w:lvlText w:val="${escapeXmlAttribute(level.lvlText)}"/>`,
|
|
464
517
|
`<w:lvlJc w:val="${level.lvlJc ?? "left"}"/>`,
|
|
@@ -723,6 +776,7 @@ const validateBlock = (block, path, ctx) => {
|
|
|
723
776
|
return;
|
|
724
777
|
}
|
|
725
778
|
if (block.type === "preservedBlock") return;
|
|
779
|
+
if (block.type === "bookmarkStart" || block.type === "bookmarkEnd") return;
|
|
726
780
|
if (block.content.length === 0) {
|
|
727
781
|
addWarning(ctx, `${path}.content`, "Block content control is empty.");
|
|
728
782
|
return;
|
|
@@ -819,6 +873,10 @@ const validateFieldChild = (child, path, ctx) => {
|
|
|
819
873
|
return;
|
|
820
874
|
}
|
|
821
875
|
if (child.type === "preservedInline") return;
|
|
876
|
+
if (child.type === "inlineWrapper") {
|
|
877
|
+
validateParagraphContent(child, path, ctx);
|
|
878
|
+
return;
|
|
879
|
+
}
|
|
822
880
|
validateHyperlink(child, path, ctx);
|
|
823
881
|
};
|
|
824
882
|
const validateRuns = (runs, path, ctx) => {
|
|
@@ -863,6 +921,10 @@ const validateHyperlinkChild = (child, path, ctx) => {
|
|
|
863
921
|
return;
|
|
864
922
|
}
|
|
865
923
|
if (child.type === "preservedInline") return;
|
|
924
|
+
if (child.type === "inlineWrapper") {
|
|
925
|
+
validateParagraphContent(child, path, ctx);
|
|
926
|
+
return;
|
|
927
|
+
}
|
|
866
928
|
increment(ctx.bookmarkEnds, child.id);
|
|
867
929
|
};
|
|
868
930
|
const validateTrackedRunChange = (change, path, ctx) => {
|
|
@@ -916,11 +978,14 @@ const validateParagraphs = (paragraphs, path, ctx) => {
|
|
|
916
978
|
const validateNumbering = (paragraph, path, ctx) => {
|
|
917
979
|
const numPr = paragraph.formatting?.numPr;
|
|
918
980
|
if (!numPr) return;
|
|
919
|
-
const ilvl = numPr
|
|
920
|
-
if (ilvl
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
981
|
+
const ilvl = paragraphNumberingLevel(numPr);
|
|
982
|
+
if (ilvl !== void 0) {
|
|
983
|
+
if (ilvl < 0) addError(ctx, `${path}.formatting.numPr.ilvl`, "List level must be zero or greater.");
|
|
984
|
+
else if (ilvl > 8) addWarning(ctx, `${path}.formatting.numPr.ilvl`, "List level is outside Word's standard 0-8 range.");
|
|
985
|
+
}
|
|
986
|
+
const referenceId = paragraphNumberingReferenceId(numPr);
|
|
987
|
+
if (referenceId === void 0) return;
|
|
988
|
+
if (!ctx.numberingNums.has(referenceId)) addError(ctx, `${path}.formatting.numPr.numId`, `Numbering definition ${referenceId} is missing.`);
|
|
924
989
|
};
|
|
925
990
|
const validateSectionProperties = (section, path, ctx) => {
|
|
926
991
|
validateHeaderFooterReferences(section.headerReferences ?? [], ctx.headers, `${path}.headerReferences`, "header", ctx);
|
|
@@ -2077,21 +2142,21 @@ const appendBlock = (content, block, options) => {
|
|
|
2077
2142
|
};
|
|
2078
2143
|
const clauseNumbering = (block, profile) => {
|
|
2079
2144
|
if (profile !== "legal") return;
|
|
2080
|
-
return {
|
|
2145
|
+
return paragraphNumberingReference({
|
|
2081
2146
|
numId: LEGAL_NUMBERING_ID,
|
|
2082
2147
|
ilvl: Math.max(0, block.level - 1)
|
|
2083
|
-
};
|
|
2148
|
+
});
|
|
2084
2149
|
};
|
|
2085
2150
|
const listNumbering = (block, profile) => {
|
|
2086
2151
|
if (profile === "none") return;
|
|
2087
|
-
if (profile === "checklist") return {
|
|
2152
|
+
if (profile === "checklist") return paragraphNumberingReference({
|
|
2088
2153
|
numId: CHECKLIST_NUMBERING_ID,
|
|
2089
2154
|
ilvl: 0
|
|
2090
|
-
};
|
|
2091
|
-
return {
|
|
2155
|
+
});
|
|
2156
|
+
return paragraphNumberingReference({
|
|
2092
2157
|
numId: block.ordered ? LEGAL_NUMBERING_ID : BULLET_NUMBERING_ID,
|
|
2093
2158
|
ilvl: block.ordered ? 2 : 0
|
|
2094
|
-
};
|
|
2159
|
+
});
|
|
2095
2160
|
};
|
|
2096
2161
|
const appendParagraphs = (content, paragraphs, styleId) => {
|
|
2097
2162
|
for (const text of paragraphs) content.push(paragraph(text, styleId));
|
|
@@ -2271,7 +2336,10 @@ const createStyleDefinitions = () => ({
|
|
|
2271
2336
|
keepNext: true,
|
|
2272
2337
|
spaceBefore: 360,
|
|
2273
2338
|
spaceAfter: 160,
|
|
2274
|
-
outlineLevel:
|
|
2339
|
+
outlineLevel: {
|
|
2340
|
+
kind: "heading",
|
|
2341
|
+
level: 0
|
|
2342
|
+
}
|
|
2275
2343
|
}
|
|
2276
2344
|
},
|
|
2277
2345
|
{
|
|
@@ -2289,7 +2357,10 @@ const createStyleDefinitions = () => ({
|
|
|
2289
2357
|
keepNext: true,
|
|
2290
2358
|
spaceBefore: 240,
|
|
2291
2359
|
spaceAfter: 120,
|
|
2292
|
-
outlineLevel:
|
|
2360
|
+
outlineLevel: {
|
|
2361
|
+
kind: "heading",
|
|
2362
|
+
level: 1
|
|
2363
|
+
}
|
|
2293
2364
|
}
|
|
2294
2365
|
},
|
|
2295
2366
|
{
|
|
@@ -2304,7 +2375,10 @@ const createStyleDefinitions = () => ({
|
|
|
2304
2375
|
keepNext: true,
|
|
2305
2376
|
spaceBefore: 160,
|
|
2306
2377
|
spaceAfter: 120,
|
|
2307
|
-
outlineLevel:
|
|
2378
|
+
outlineLevel: {
|
|
2379
|
+
kind: "heading",
|
|
2380
|
+
level: 2
|
|
2381
|
+
}
|
|
2308
2382
|
}
|
|
2309
2383
|
},
|
|
2310
2384
|
{
|
|
@@ -2537,10 +2611,10 @@ const para = (runs, styleId) => ({
|
|
|
2537
2611
|
});
|
|
2538
2612
|
const listPara = (runs, rendering) => ({
|
|
2539
2613
|
type: "paragraph",
|
|
2540
|
-
formatting: { numPr: {
|
|
2614
|
+
formatting: { numPr: paragraphNumberingReference({
|
|
2541
2615
|
numId: rendering.numId,
|
|
2542
2616
|
ilvl: rendering.level
|
|
2543
|
-
} },
|
|
2617
|
+
}) },
|
|
2544
2618
|
listRendering: rendering,
|
|
2545
2619
|
content: runs.length > 0 ? runs : [textRun("")]
|
|
2546
2620
|
});
|
|
@@ -2638,9 +2712,10 @@ const MAX_HEADING_LEVEL = 4;
|
|
|
2638
2712
|
const headingParagraph = (runs, depth) => {
|
|
2639
2713
|
const level = Math.min(Math.max(depth, 1), MAX_HEADING_LEVEL);
|
|
2640
2714
|
const paragraph = para(runs, `Heading${level}`);
|
|
2641
|
-
|
|
2715
|
+
const outlineLevel = headingOutlineLevel(level - 1);
|
|
2716
|
+
if (outlineLevel !== void 0) paragraph.formatting = {
|
|
2642
2717
|
...paragraph.formatting,
|
|
2643
|
-
outlineLevel
|
|
2718
|
+
outlineLevel
|
|
2644
2719
|
};
|
|
2645
2720
|
return paragraph;
|
|
2646
2721
|
};
|
|
@@ -2706,4 +2781,4 @@ const compileMarkdownToContent = (markdown) => {
|
|
|
2706
2781
|
};
|
|
2707
2782
|
};
|
|
2708
2783
|
//#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 };
|
|
2784
|
+
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-tiNJggub.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 };
|