@stll/docx-core 0.23.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.
Binary file
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { F as BreakContent, Ft as Paragraph, G as DocumentBody, Gt as Run, It as ParagraphContent, Kt as RunContent, Pn as NumberingDefinitions, Vt as PositionalTab, Zt as SectionProperties, a as DocxPackage, dn as Table, fn as TableCell, hn as TableRow, i as DocxConformanceClass, k as BlockContent, m as Style, n as Document, t as DOCX_CONFORMANCE_CLASSES, yn as TextContent } from "./document-o2RiAASq.js";
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";
@@ -148,8 +148,61 @@ type SerializeDocumentOptions = {
148
148
  /** BCP-47 language tag (e.g. "en", "cs", "cs-CZ"); used for footer labels. */
149
149
  language?: string;
150
150
  };
151
+ /**
152
+ * Writes a package from scratch, for a `Document` that was built rather than
153
+ * parsed: today the legal-source compiler's.
154
+ *
155
+ * It writes the subset of OOXML that compiler produces. It has no relationship
156
+ * table, no media, no verbatim capture and no namespace scope, so a **parsed**
157
+ * `Document` handed to it comes back without its drawings, its fields, its
158
+ * tracked changes or its preserved markup — `serializeRunContent` returns `""`
159
+ * for most of `RunContent`. A round trip belongs in `@stll/folio-core`'s
160
+ * `repackDocx`, which rebuilds a package against the one it read.
161
+ *
162
+ * Making that a compile error wants a branded `ConstructedDocument` that only
163
+ * a from-scratch builder can mint. It is not clean today: the two suites that
164
+ * exercise this writer (`serialize/docx.test.ts` and `core`'s
165
+ * `xmlValuePreservation.property.test.ts`) build their `Document` as a literal,
166
+ * so the brand needs a public mint, and a public mint a parsed document can be
167
+ * passed through is decoration rather than a guard. The prerequisite is a
168
+ * from-scratch document builder those suites can call; the brand follows it,
169
+ * not the other way round.
170
+ */
151
171
  declare const serializeDocumentToDocx: (document: Document, options?: SerializeDocumentOptions) => Promise<ArrayBuffer>;
152
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
153
206
  //#region src/serialize/xmlEscape.d.ts
154
207
  /**
155
208
  * The one owner of XML character escaping for every part folio writes.
@@ -254,4 +307,4 @@ declare const validateDocxPackage: (buffer: ArrayBuffer | Uint8Array) => Promise
254
307
  declare const validateDocumentModel: (document: Document) => ValidateDocumentModelResult;
255
308
  declare const assertValidDocumentModel: (document: Document) => void;
256
309
  //#endregion
257
- 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 { s as isOoxmlSymbolCharacter, t as DOCX_CONFORMANCE_CLASSES } from "./document-CKwRw-01.js";
2
- import JSZip from "jszip";
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";
@@ -192,6 +230,26 @@ const documentRelsXml = (hasNumbering) => [
192
230
  "</Relationships>"
193
231
  ].join("");
194
232
  const APP_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Properties xmlns=\"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties\" xmlns:vt=\"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes\"><Application>stella</Application></Properties>";
233
+ /**
234
+ * Writes a package from scratch, for a `Document` that was built rather than
235
+ * parsed: today the legal-source compiler's.
236
+ *
237
+ * It writes the subset of OOXML that compiler produces. It has no relationship
238
+ * table, no media, no verbatim capture and no namespace scope, so a **parsed**
239
+ * `Document` handed to it comes back without its drawings, its fields, its
240
+ * tracked changes or its preserved markup — `serializeRunContent` returns `""`
241
+ * for most of `RunContent`. A round trip belongs in `@stll/folio-core`'s
242
+ * `repackDocx`, which rebuilds a package against the one it read.
243
+ *
244
+ * Making that a compile error wants a branded `ConstructedDocument` that only
245
+ * a from-scratch builder can mint. It is not clean today: the two suites that
246
+ * exercise this writer (`serialize/docx.test.ts` and `core`'s
247
+ * `xmlValuePreservation.property.test.ts`) build their `Document` as a literal,
248
+ * so the brand needs a public mint, and a public mint a parsed document can be
249
+ * passed through is decoration rather than a guard. The prerequisite is a
250
+ * from-scratch document builder those suites can call; the brand follows it,
251
+ * not the other way round.
252
+ */
195
253
  const serializeDocumentToDocx = async (document, options = {}) => {
196
254
  const zip = new JSZip();
197
255
  const hasNumbering = hasNumberingDefinitions(document.package.numbering);
@@ -221,6 +279,9 @@ const serializeBlock = (block) => {
221
279
  case "paragraph": return serializeParagraph(block);
222
280
  case "table": return serializeTable(block);
223
281
  case "blockSdt": return "";
282
+ case "preservedBlock": return block.xml;
283
+ case "bookmarkStart":
284
+ case "bookmarkEnd": return "";
224
285
  default: return "";
225
286
  }
226
287
  };
@@ -232,10 +293,13 @@ const serializeParagraphProperties = (paragraph) => {
232
293
  if (!formatting && !paragraph.sectionProperties) return "";
233
294
  const parts = [];
234
295
  if (formatting?.styleId) parts.push(`<w:pStyle w:val="${escapeXmlAttribute(formatting.styleId)}"/>`);
235
- if (formatting?.keepNext) parts.push("<w:keepNext/>");
236
- if (formatting?.keepLines) parts.push("<w:keepLines/>");
237
- if (formatting?.pageBreakBefore) parts.push("<w:pageBreakBefore/>");
238
- if (formatting?.numPr?.numId !== void 0) parts.push(`<w:numPr><w:ilvl w:val="${formatting.numPr.ilvl}"/><w:numId w:val="${formatting.numPr.numId}"/></w: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
+ }
239
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)}/>`);
240
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)}/>`);
241
305
  if (formatting?.alignment) parts.push(`<w:jc w:val="${formatting.alignment}"/>`);
@@ -262,34 +326,44 @@ const serializeParagraphContent = (content) => {
262
326
  case "moveFromRangeEnd":
263
327
  case "moveToRangeStart":
264
328
  case "moveToRangeEnd":
265
- case "bidiWrapper":
266
- case "mathEquation": return "";
329
+ case "inlineWrapper":
330
+ case "mathEquation":
331
+ case "preservedInline": return "";
267
332
  default: return "";
268
333
  }
269
334
  };
270
335
  const serializeRun = (run) => {
271
336
  return `<w:r>${serializeRunProperties(run.formatting)}${run.content.map(serializeRunContent).join("")}</w:r>`;
272
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
+ */
273
347
  const serializeRunProperties = (formatting) => {
274
348
  if (!formatting) return "";
275
- const parts = [];
276
- if (formatting.styleId) parts.push(`<w:rStyle w:val="${escapeXmlAttribute(formatting.styleId)}"/>`);
277
- if (formatting.bold === true) parts.push("<w:b/>");
278
- else if (formatting.bold === false) parts.push("<w:b w:val=\"0\"/>");
279
- if (formatting.boldCs === true) parts.push("<w:bCs/>");
280
- else if (formatting.boldCs === false) parts.push("<w:bCs w:val=\"0\"/>");
281
- if (formatting.italic === true) parts.push("<w:i/>");
282
- else if (formatting.italic === false) parts.push("<w:i w:val=\"0\"/>");
283
- if (formatting.italicCs === true) parts.push("<w:iCs/>");
284
- else if (formatting.italicCs === false) parts.push("<w:iCs w:val=\"0\"/>");
285
- if (formatting.allCaps) parts.push("<w:caps/>");
286
- if (formatting.smallCaps) parts.push("<w:smallCaps/>");
287
- if (formatting.highlight) parts.push(`<w:highlight w:val="${formatting.highlight}"/>`);
288
- if (formatting.fontSize !== void 0) parts.push(`<w:sz w:val="${formatting.fontSize}"/>`);
289
- if (formatting.fontSizeCs !== void 0) parts.push(`<w:szCs w:val="${formatting.fontSizeCs}"/>`);
290
- if (formatting.fontFamily) parts.push(`<w:rFonts${attr("w:ascii", formatting.fontFamily.ascii)}${attr("w:hAnsi", formatting.fontFamily.hAnsi)}${attr("w:cs", formatting.fontFamily.cs)}/>`);
291
- if (formatting.cs === true) parts.push("<w:cs/>");
292
- else if (formatting.cs === false) parts.push("<w:cs w:val=\"0\"/>");
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
+ });
293
367
  return parts.length > 0 ? `<w:rPr>${parts.join("")}</w:rPr>` : "";
294
368
  };
295
369
  const serializeRunContent = (content) => {
@@ -303,6 +377,7 @@ const serializeRunContent = (content) => {
303
377
  case "symbol": return `<w:sym w:font="${escapeXmlAttribute(content.font)}" w:char="${escapeXmlAttribute(content.char)}"/>`;
304
378
  case "footnoteRef": return `<w:footnoteReference w:id="${content.id}"/>`;
305
379
  case "endnoteRef": return `<w:endnoteReference w:id="${content.id}"/>`;
380
+ case "preservedXml": return content.xml;
306
381
  case "fieldChar":
307
382
  case "instrText":
308
383
  case "softHyphen":
@@ -352,10 +427,11 @@ const renderCellBorders = (table) => {
352
427
  };
353
428
  const borderEdgeXml = (tag, spec) => {
354
429
  if (!spec) return `<${tag} w:val="nil"/>`;
355
- if (spec.style === "none" || spec.style === "nil") return `<${tag} w:val="${escapeXmlAttribute(spec.style)}"/>`;
430
+ const val = borderStyleToken(spec.style);
431
+ if (statesNoBorder(spec.style)) return `<${tag} w:val="${escapeXmlAttribute(val)}"/>`;
356
432
  const sz = spec.size ?? 4;
357
433
  const color = spec.color?.rgb ?? "CCCCCC";
358
- return `<${tag} w:val="${escapeXmlAttribute(spec.style)}" w:sz="${sz}" w:space="0" w:color="${escapeXmlAttribute(color)}"/>`;
434
+ return `<${tag} w:val="${escapeXmlAttribute(val)}" w:sz="${sz}" w:space="0" w:color="${escapeXmlAttribute(color)}"/>`;
359
435
  };
360
436
  /**
361
437
  * The grid this generator gives a table that declares no borders of its own.
@@ -412,7 +488,7 @@ const serializeStyle = (style) => {
412
488
  `<w:name w:val="${escapeXmlAttribute(style.name ?? style.styleId)}"/>`,
413
489
  style.basedOn ? `<w:basedOn w:val="${escapeXmlAttribute(style.basedOn)}"/>` : "",
414
490
  style.next ? `<w:next w:val="${escapeXmlAttribute(style.next)}"/>` : "",
415
- style.qFormat ? "<w:qFormat/>" : "",
491
+ serializeOnOffElement(style.qFormat, "qFormat"),
416
492
  pPr ? `<w:pPr>${pPr}</w:pPr>` : "",
417
493
  rPr,
418
494
  "</w:style>"
@@ -435,7 +511,7 @@ const serializeNumberingLevel = (level) => [
435
511
  `<w:lvl w:ilvl="${level.ilvl}">`,
436
512
  `<w:start w:val="${level.start ?? 1}"/>`,
437
513
  `<w:numFmt w:val="${level.numFmt}"/>`,
438
- level.isLgl ? "<w:isLgl/>" : "",
514
+ serializeOnOffElement(level.isLgl, "isLgl"),
439
515
  level.suffix ? `<w:suff w:val="${level.suffix}"/>` : "",
440
516
  `<w:lvlText w:val="${escapeXmlAttribute(level.lvlText)}"/>`,
441
517
  `<w:lvlJc w:val="${level.lvlJc ?? "left"}"/>`,
@@ -699,6 +775,8 @@ const validateBlock = (block, path, ctx) => {
699
775
  validateTable(block, path, ctx);
700
776
  return;
701
777
  }
778
+ if (block.type === "preservedBlock") return;
779
+ if (block.type === "bookmarkStart" || block.type === "bookmarkEnd") return;
702
780
  if (block.content.length === 0) {
703
781
  addWarning(ctx, `${path}.content`, "Block content control is empty.");
704
782
  return;
@@ -779,10 +857,14 @@ const validateParagraphContent = (content, path, ctx) => {
779
857
  increment(ctx.moveToEnds, content.id);
780
858
  return;
781
859
  }
782
- if (content.type === "bidiWrapper") {
860
+ if (content.type === "inlineWrapper") {
783
861
  for (const [index, child] of content.content.entries()) validateParagraphContent(child, `${path}.content[${index}]`, ctx);
784
862
  return;
785
863
  }
864
+ if (content.type === "preservedInline") {
865
+ if (content.xml.trim() === "") addError(ctx, `${path}.xml`, "Preserved inline markup must not be empty.");
866
+ return;
867
+ }
786
868
  if (content.ommlXml.trim() === "") addError(ctx, `${path}.ommlXml`, "Math equation must preserve OMML XML.");
787
869
  };
788
870
  const validateFieldChild = (child, path, ctx) => {
@@ -790,6 +872,11 @@ const validateFieldChild = (child, path, ctx) => {
790
872
  validateRun(child, path, ctx);
791
873
  return;
792
874
  }
875
+ if (child.type === "preservedInline") return;
876
+ if (child.type === "inlineWrapper") {
877
+ validateParagraphContent(child, path, ctx);
878
+ return;
879
+ }
793
880
  validateHyperlink(child, path, ctx);
794
881
  };
795
882
  const validateRuns = (runs, path, ctx) => {
@@ -833,6 +920,11 @@ const validateHyperlinkChild = (child, path, ctx) => {
833
920
  increment(ctx.bookmarkStarts, child.id);
834
921
  return;
835
922
  }
923
+ if (child.type === "preservedInline") return;
924
+ if (child.type === "inlineWrapper") {
925
+ validateParagraphContent(child, path, ctx);
926
+ return;
927
+ }
836
928
  increment(ctx.bookmarkEnds, child.id);
837
929
  };
838
930
  const validateTrackedRunChange = (change, path, ctx) => {
@@ -886,11 +978,14 @@ const validateParagraphs = (paragraphs, path, ctx) => {
886
978
  const validateNumbering = (paragraph, path, ctx) => {
887
979
  const numPr = paragraph.formatting?.numPr;
888
980
  if (!numPr) return;
889
- const ilvl = numPr.ilvl ?? 0;
890
- if (ilvl < 0) addError(ctx, `${path}.formatting.numPr.ilvl`, "List level must be zero or greater.");
891
- else if (ilvl > 8) addWarning(ctx, `${path}.formatting.numPr.ilvl`, "List level is outside Word's standard 0-8 range.");
892
- if (numPr.numId === void 0 || numPr.numId === 0) return;
893
- if (!ctx.numberingNums.has(numPr.numId)) addError(ctx, `${path}.formatting.numPr.numId`, `Numbering definition ${numPr.numId} is missing.`);
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.`);
894
989
  };
895
990
  const validateSectionProperties = (section, path, ctx) => {
896
991
  validateHeaderFooterReferences(section.headerReferences ?? [], ctx.headers, `${path}.headerReferences`, "header", ctx);
@@ -2047,21 +2142,21 @@ const appendBlock = (content, block, options) => {
2047
2142
  };
2048
2143
  const clauseNumbering = (block, profile) => {
2049
2144
  if (profile !== "legal") return;
2050
- return {
2145
+ return paragraphNumberingReference({
2051
2146
  numId: LEGAL_NUMBERING_ID,
2052
2147
  ilvl: Math.max(0, block.level - 1)
2053
- };
2148
+ });
2054
2149
  };
2055
2150
  const listNumbering = (block, profile) => {
2056
2151
  if (profile === "none") return;
2057
- if (profile === "checklist") return {
2152
+ if (profile === "checklist") return paragraphNumberingReference({
2058
2153
  numId: CHECKLIST_NUMBERING_ID,
2059
2154
  ilvl: 0
2060
- };
2061
- return {
2155
+ });
2156
+ return paragraphNumberingReference({
2062
2157
  numId: block.ordered ? LEGAL_NUMBERING_ID : BULLET_NUMBERING_ID,
2063
2158
  ilvl: block.ordered ? 2 : 0
2064
- };
2159
+ });
2065
2160
  };
2066
2161
  const appendParagraphs = (content, paragraphs, styleId) => {
2067
2162
  for (const text of paragraphs) content.push(paragraph(text, styleId));
@@ -2241,7 +2336,10 @@ const createStyleDefinitions = () => ({
2241
2336
  keepNext: true,
2242
2337
  spaceBefore: 360,
2243
2338
  spaceAfter: 160,
2244
- outlineLevel: 0
2339
+ outlineLevel: {
2340
+ kind: "heading",
2341
+ level: 0
2342
+ }
2245
2343
  }
2246
2344
  },
2247
2345
  {
@@ -2259,7 +2357,10 @@ const createStyleDefinitions = () => ({
2259
2357
  keepNext: true,
2260
2358
  spaceBefore: 240,
2261
2359
  spaceAfter: 120,
2262
- outlineLevel: 1
2360
+ outlineLevel: {
2361
+ kind: "heading",
2362
+ level: 1
2363
+ }
2263
2364
  }
2264
2365
  },
2265
2366
  {
@@ -2274,7 +2375,10 @@ const createStyleDefinitions = () => ({
2274
2375
  keepNext: true,
2275
2376
  spaceBefore: 160,
2276
2377
  spaceAfter: 120,
2277
- outlineLevel: 2
2378
+ outlineLevel: {
2379
+ kind: "heading",
2380
+ level: 2
2381
+ }
2278
2382
  }
2279
2383
  },
2280
2384
  {
@@ -2507,10 +2611,10 @@ const para = (runs, styleId) => ({
2507
2611
  });
2508
2612
  const listPara = (runs, rendering) => ({
2509
2613
  type: "paragraph",
2510
- formatting: { numPr: {
2614
+ formatting: { numPr: paragraphNumberingReference({
2511
2615
  numId: rendering.numId,
2512
2616
  ilvl: rendering.level
2513
- } },
2617
+ }) },
2514
2618
  listRendering: rendering,
2515
2619
  content: runs.length > 0 ? runs : [textRun("")]
2516
2620
  });
@@ -2608,9 +2712,10 @@ const MAX_HEADING_LEVEL = 4;
2608
2712
  const headingParagraph = (runs, depth) => {
2609
2713
  const level = Math.min(Math.max(depth, 1), MAX_HEADING_LEVEL);
2610
2714
  const paragraph = para(runs, `Heading${level}`);
2611
- paragraph.formatting = {
2715
+ const outlineLevel = headingOutlineLevel(level - 1);
2716
+ if (outlineLevel !== void 0) paragraph.formatting = {
2612
2717
  ...paragraph.formatting,
2613
- outlineLevel: level - 1
2718
+ outlineLevel
2614
2719
  };
2615
2720
  return paragraph;
2616
2721
  };
@@ -2676,4 +2781,4 @@ const compileMarkdownToContent = (markdown) => {
2676
2781
  };
2677
2782
  };
2678
2783
  //#endregion
2679
- 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 };
@@ -1,2 +1,3 @@
1
- import { $ as FieldType, $n as TableRowFormatting, $t as SectionStart, A as BlockRangeMarkerCapture, An as ListLevel, At as NoBreakHyphenContent, B as CommentReference, Bn as LineSpacingRule, Bt as PictureWatermark, C as ParseWarning, Cn as TrackedRunContent, Ct as MoveBookmarkMarker, D as BidiControl, Dn as normalizeRevisionId, Dt as MoveTo, E as BIDI_CONTROLS, En as isOoxmlSymbolCharacter, Et as MoveFromRangeStart, F as BreakContent, Fn as NumberingInstance, Ft as Paragraph, G as DocumentBody, Gn as TabStop, Gt as Run, H as DRAWING_RAW_XML_MODES, Hn as ParagraphFormatting, Ht as PropertyChangeInfo, I as Column, In as CellMargins, It as ParagraphContent, J as Endnote, Jn as TableCellBorders, Jt as SdtProperties, K as DrawingContent, Kn as TabStopAlignment, Kt as RunContent, L as Comment, Ln as ConditionalFormatStyle, Lt as ParagraphMarkChange, M as BookmarkEnd, Mn as ListRendering, Mt as NoteReferenceContent, N as BookmarkRangeMarker, Nn as NumberFormat, Nt as PARAGRAPH_MARK_CHANGE_KINDS, O as BidiWrapper, On as AbstractNumbering, Ot as MoveToRangeEnd, P as BookmarkStart, Pn as NumberingDefinitions, Pt as PageOrientation, Q as FieldCharContent, Qn as TableMeasurement, Qt as SectionPropertyChange, R as CommentRangeEnd, Rn as EmphasisMark, Rt as ParagraphMarkChangeKind, S as PARSE_WARNING_CODES, Sn as TrackedRunChange, St as MathEquation, T as ParseWarningLocation, Tn as Watermark, Tt as MoveFromRangeEnd, U as Deletion, Un as SpacingExplicit, Ut as REVIEW_CARRIERS, V as ComplexField, Vn as ParagraphAlignment, Vt as PositionalTab, W as DisplacedByCustomXml, Wn as TabLeader, Wt as ReviewCarrier, X as EndnoteProperties, Xn as TableFormatting, Xt as Section, Y as EndnotePosition, Yn as TableCellFormatting, Yt as SdtType, Z as Field, Zn as TableLook, Zt as SectionProperties, _ as Theme, _n as TableStructuralChangeInfo, _t as Insertion, a as DocxPackage, an as ShapeTextBody, ar as ColorValue, at as HeaderFooterType, b as ThemeFontScheme, bn as TextWatermark, bt as MAX_REVISION_ID, c as FontInfo, cn as SoftHyphenContent, cr as ThemeColorSlot, ct as Image, d as Relationship, dn as Table, dt as ImagePadding, en as Shape, er as TableWidthType, et as FooterReference, f as RelationshipMap, fn as TableCell, ft as ImagePosition, g as StyleType, gn as TableRowPropertyChange, gt as InlineSdt, h as StyleDefinitions, hn as TableRow, ht as ImageWrap, i as DocxConformanceClass, in as ShapeOutline, ir as BorderSpec, it as HeaderFooter, j as BlockSdt, jn as ListMarkerFormatting, jt as NoteNumberRestart, k as BlockContent, kn as LevelSuffix, kt as MoveToRangeStart, l as FontTable, ln as SymbolContent, lt as ImageCrop, m as Style, mn as TablePropertyChange, mt as ImageTransform, n as Document, nn as ShapeFill, nr as TextFormatting, nt as FootnotePosition, o as ExhaustiveFields, on as ShapeType, or as KnownBorderStyle, ot as HeaderReference, p as RelationshipType, pn as TableCellPropertyChange, pt as ImageSize, q as DrawingRawXmlMode, qn as TableBorders, qt as RunPropertyChange, r as DocumentSettings, rn as ShapeGeometryAdjustment, rr as UnderlineStyle, rt as FootnoteProperties, s as DocDefaults, sn as SimpleField, sr as ShadingProperties, st as Hyperlink, t as DOCX_CONFORMANCE_CLASSES, tn as ShapeContent, tr as TextEffect, tt as Footnote, u as MediaFile, un as TabContent, ut as ImageFrameLocks, v as ThemeColorScheme, vn as TextBox, vt as InstrTextContent, w as ParseWarningCode, wn as VerticalAlign, wt as MoveFrom, x as MAX_RETAINED_PARSE_WARNINGS_PER_CODE, xn as TrackedChangeInfo, xt as MarkupRangeMarker, y as ThemeFont, yn as TextContent, yt as LineNumberRestart, z as CommentRangeStart, zn as FloatingTableProperties, zt as ParagraphPropertyChange } from "../document-o2RiAASq.js";
2
- export { type AbstractNumbering, BIDI_CONTROLS, type BidiControl, type BidiWrapper, type BlockContent, type BlockRangeMarkerCapture, type BlockSdt, type BookmarkEnd, type BookmarkRangeMarker, type BookmarkStart, type BorderSpec, type BreakContent, type CellMargins, type ColorValue, type Column, type Comment, type CommentRangeEnd, type CommentRangeStart, type CommentReference, type ComplexField, type ConditionalFormatStyle, DOCX_CONFORMANCE_CLASSES, DRAWING_RAW_XML_MODES, type Deletion, type DisplacedByCustomXml, type DocDefaults, Document, type DocumentBody, DocumentSettings, DocxConformanceClass, DocxPackage, type DrawingContent, type DrawingRawXmlMode, type EmphasisMark, type Endnote, type EndnotePosition, type EndnoteProperties, type ExhaustiveFields, type Field, type FieldCharContent, type FieldType, type FloatingTableProperties, type FontInfo, type FontTable, type FooterReference, type Footnote, type FootnotePosition, type FootnoteProperties, type HeaderFooter, type HeaderFooterType, type HeaderReference, type Hyperlink, type Image, type ImageCrop, type ImageFrameLocks, type ImagePadding, type ImagePosition, type ImageSize, type ImageTransform, type ImageWrap, type InlineSdt, type Insertion, type InstrTextContent, type KnownBorderStyle, 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, type NoBreakHyphenContent, type NoteNumberRestart, type NoteReferenceContent, type NumberFormat, type NumberingDefinitions, type NumberingInstance, PARAGRAPH_MARK_CHANGE_KINDS, PARSE_WARNING_CODES, type PageOrientation, type Paragraph, type ParagraphAlignment, type ParagraphContent, type ParagraphFormatting, type ParagraphMarkChange, type ParagraphMarkChangeKind, type ParagraphPropertyChange, type ParseWarning, type ParseWarningCode, type ParseWarningLocation, type PictureWatermark, type PositionalTab, type PropertyChangeInfo, REVIEW_CARRIERS, type Relationship, type RelationshipMap, type RelationshipType, type ReviewCarrier, type Run, type RunContent, type RunPropertyChange, 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, type TabContent, type TabLeader, type TabStop, type TabStopAlignment, type Table, type TableBorders, type TableCell, type TableCellBorders, type TableCellFormatting, type TableCellPropertyChange, type TableFormatting, type TableLook, type TableMeasurement, type TablePropertyChange, type TableRow, type TableRowFormatting, type TableRowPropertyChange, type TableStructuralChangeInfo, type TableWidthType, type TextBox, type TextContent, type TextEffect, type TextFormatting, type TextWatermark, type Theme, type ThemeColorScheme, type ThemeColorSlot, type ThemeFont, type ThemeFontScheme, type TrackedChangeInfo, type TrackedRunChange, type TrackedRunContent, type UnderlineStyle, type VerticalAlign, type Watermark, isOoxmlSymbolCharacter, normalizeRevisionId };
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 };
@@ -1,2 +1,2 @@
1
- import { a as PARAGRAPH_MARK_CHANGE_KINDS, c as normalizeRevisionId, i as MAX_REVISION_ID, l as MAX_RETAINED_PARSE_WARNINGS_PER_CODE, n as BIDI_CONTROLS, o as REVIEW_CARRIERS, r as DRAWING_RAW_XML_MODES, s as isOoxmlSymbolCharacter, t as DOCX_CONFORMANCE_CLASSES, u as PARSE_WARNING_CODES } from "../document-CKwRw-01.js";
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 };