@stll/docx-core 0.43.1 → 0.44.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.
@@ -60,6 +60,23 @@ const setDocumentBodyComments = (body, comments) => {
60
60
  body.comments = comments;
61
61
  };
62
62
  /**
63
+ * The sides of `w:spacing` a paragraph's own properties state, as the parser
64
+ * reads them: a side is explicit exactly when the record holds its value.
65
+ *
66
+ * The one rule for the field. The parser marks a record it reads with it, and
67
+ * an operation that states a paragraph's spacing states the field with it, so
68
+ * a paragraph an edit changed has the field the saved file reopens to.
69
+ */
70
+ const paragraphSpacingExplicit = (formatting) => {
71
+ const before = formatting.spaceBefore !== void 0;
72
+ const after = formatting.spaceAfter !== void 0;
73
+ if (!before && !after) return void 0;
74
+ return {
75
+ ...before ? { before: true } : {},
76
+ ...after ? { after: true } : {}
77
+ };
78
+ };
79
+ /**
63
80
  * Finish paragraph formatting at a model boundary.
64
81
  *
65
82
  * The parser represents an empty `w:pPr`, including one whose only state was
@@ -73,20 +90,6 @@ const finalizeParagraphFormatting = (formatting) => {
73
90
  const isCanonicallyEmptyParagraphFormatting = (formatting) => formatting === void 0 || Object.keys(formatting).every((key) => key === "sourceXml");
74
91
  // src/model/parseWarning.ts
75
92
  /**
76
- * What folio normalised to open a document, as data rather than as prose.
77
- *
78
- * Word accepts input the schema does not describe, so folio accepts it too and
79
- * normalises at the parse boundary. Every such decision is recorded here: a
80
- * stable `code`, the part it happened in, the best position that part can
81
- * name, and the value folio declined to read. A host can count them, group
82
- * them, or decide on one; the human-readable string the parser has always
83
- * exposed is derived from this, never written by hand at the call site, so the
84
- * two cannot drift.
85
- *
86
- * It lives beside `Document` because it is part of the parsed document, and a
87
- * `Document` may be produced by anything that builds this model.
88
- */
89
- /**
90
93
  * Every normalisation the parse boundary is allowed to make.
91
94
  *
92
95
  * Adding a member without also giving it a message is a type error: the
@@ -109,10 +112,22 @@ const PARSE_WARNING_CODES = {
109
112
  missingCommentId: "missing-comment-id",
110
113
  /** A later `w:footnote`/`w:endnote` repeating an id an earlier one defines. */
111
114
  duplicateNoteId: "duplicate-note-id",
115
+ /** An automatic note mark outside its matching note story, kept verbatim. */
116
+ misplacedNoteMark: "misplaced-note-mark",
112
117
  /** A comment marker naming a comment `comments.xml` never defines. */
113
118
  danglingCommentReference: "dangling-comment-reference",
114
119
  /** A comment range with no matching start or end, re-anchored as a point. */
115
120
  unbalancedCommentRange: "unbalanced-comment-range",
121
+ /** A comment range boundary with no partner, dropped: the comment's reference anchors it. */
122
+ unpairedCommentRangeBoundary: "unpaired-comment-range-boundary",
123
+ /** A comment reference repeating one its comment already has, dropped. */
124
+ duplicateCommentReference: "duplicate-comment-reference",
125
+ /** A comment's full range after its first, dropped: a comment holds one range. */
126
+ droppedCommentRange: "dropped-comment-range",
127
+ /** A comment range no `w:commentReference` names, given one after its end. */
128
+ missingCommentReference: "missing-comment-reference",
129
+ /** A `comments.xml` paragraph repeating an earlier one's `w14:paraId`, given a minted id. */
130
+ repeatedCommentParagraphId: "repeated-comment-paragraph-id",
116
131
  /** A `w:headerReference` naming a header part the package does not carry. */
117
132
  danglingHeaderReference: "dangling-header-reference",
118
133
  /** A `w:footerReference` naming a footer part the package does not carry. */
@@ -125,6 +140,8 @@ const PARSE_WARNING_CODES = {
125
140
  unnumberedStyle: "unnumbered-style",
126
141
  /** A tracked move range with no matching start or end. */
127
142
  unbalancedMoveRange: "unbalanced-move-range",
143
+ /** A tracked move range after the first of its id, dropped: a move holds one range. */
144
+ droppedMoveRange: "dropped-move-range",
128
145
  /** A `w:type` outside `ST_HdrFtr`, read as the enumeration's default. */
129
146
  headerFooterTypeOutsideEnum: "header-footer-type-outside-enum",
130
147
  /** A value outside `ST_OnOff`'s six spellings. */
@@ -420,6 +437,9 @@ const outlineLevelStatedValue = (outlineLevel) => {
420
437
  * cascade still has a tier left to ask.
421
438
  */
422
439
  const headingLevelOf = (outlineLevel) => outlineLevel?.kind === "heading" ? outlineLevel.level : void 0;
440
+ // src/model/preservedMarkup.ts
441
+ /** Locate captured markup among the children still present. */
442
+ const preservedChildGap = (child, childCount) => Math.min(Math.max(child.index, 0), childCount);
423
443
  // src/model/relationshipId.ts
424
444
  /**
425
445
  * Whether a string names a relationship. The refinement is a type predicate
@@ -510,23 +530,6 @@ const SCHEME_COLOR_VALUES = [
510
530
  "lt2"
511
531
  ];
512
532
  // src/model/themeColor.ts
513
- /**
514
- * The one mapping between a WordprocessingML theme reference and a theme slot.
515
- *
516
- * `w:themeColor` names a colour in `ST_ThemeColor`'s spelling; a theme part
517
- * declares its slots in DrawingML's. Three kinds of member, per ECMA-376
518
- * §17.18.97:
519
- *
520
- * direct `dark1`, `hyperlink`, `accent3` name a slot outright
521
- * mapped `background1`, `text1`, … name a `w:clrSchemeMapping` key,
522
- * which `settings.xml` points at a
523
- * slot (§17.15.1.20)
524
- * cancel `none` states that no theme colour
525
- * applies, overriding an inherited
526
- * one
527
- *
528
- * Every consumer reads the same map, so the DrawingML spelling appears once.
529
- */
530
533
  const slot = (value) => ({
531
534
  kind: "slot",
532
535
  slot: value
@@ -1153,24 +1156,6 @@ const PRESET_LINE_DASH_VALS = [
1153
1156
  "sysDashDotDot"
1154
1157
  ];
1155
1158
  // src/model/presetLineDash.ts
1156
- /**
1157
- * The one place an `a:ln/a:prstDash` `@val` is decided.
1158
- *
1159
- * `ST_PresetLineDashVal` is DrawingML's own dash vocabulary. Three of its
1160
- * spellings (`solid`, `dash`, `dot`) also occur in CSS `border-style` and in
1161
- * `text-decoration-style`, where they name different patterns, so an outline
1162
- * dash is kept in its own type and resolved against its own table rather than
1163
- * matched by string against whatever vocabulary a consumer happens to hold.
1164
- *
1165
- * A `@val` outside the enumeration is kept as {@link UnrecognisedPresetLineDash}
1166
- * and written back exactly as it was read, the way an undeclared `ST_Border`
1167
- * `w:val` is.
1168
- *
1169
- * `a:custDash` is not this attribute and is not modelled: an outline that
1170
- * carries one keeps it through `ShapeOutline.rawXml`, which the serializer
1171
- * replays verbatim, so the custom stop list survives a save without the dash
1172
- * field pretending to describe it.
1173
- */
1174
1159
  const DECLARED = new Set(PRESET_LINE_DASH_VALS);
1175
1160
  /** Whether the schema declares this token. */
1176
1161
  const isPresetLineDashVal = (value) => DECLARED.has(value);
@@ -1354,6 +1339,15 @@ function normalizeRevisionId(id) {
1354
1339
  }
1355
1340
  const INSERTION_SEAM_POLICIES = { MERGE_PLAIN_RUNS: "merge-plain-runs" };
1356
1341
  /**
1342
+ * Whether an insertion marked as what its paragraph stands for had resolution
1343
+ * joins of its own: without, its zero depths only carry the marker, and it
1344
+ * resolves as an insertion with no joins.
1345
+ */
1346
+ const HELD_PARAGRAPH_JOINS = {
1347
+ OWN: "own-joins",
1348
+ NONE: "no-joins"
1349
+ };
1350
+ /**
1357
1351
  * Which Unicode bidirectional control a `w:bdo`/`w:dir` wrapper is.
1358
1352
  *
1359
1353
  * `w:dir` is an embedding: the run of text inside it is laid out in the given
@@ -1427,4 +1421,4 @@ const COMMENT_PART_RELATIONSHIPS = {
1427
1421
  target: "commentsExtended.xml"
1428
1422
  }
1429
1423
  };
1430
- export { outlineLevelStatedValue as $, BORDER_STYLES as A, isSchemeColorValue as B, PRESET_LINE_DASH_VALS as C, lockedControlViolation as Ct, isBorderNone as D, isBorderNil as E, getSingularRunPropertyChange as Et, TEXT_DIRECTIONS as F, themeColorToken as G, knownThemeColor as H, TEXT_DIRECTION_FLOWS as I, relationshipIdOf as J, THEME_COLORS as K, TEXT_DIRECTION_FLOW_BY_TOKEN as L, PARAGRAPH_ALIGNMENTS as M, TABLE_ALIGNMENTS as N, isBorderStyle as O, TAB_STOP_ALIGNMENTS as P, outlineLevelFromStatedValue as Q, SCHEME_COLOR_VALUE_BY_THEME_COLOR as R, presetLineDashToken as S, lockedControlMessage as St, borderStyleToken as T, locksControl as Tt, readThemeColor as U, isThemeColor as V, themeColorSlot as W, headingLevelOf as X, BODY_TEXT_OUTLINE_LEVEL as Y, headingOutlineLevel as Z, numberingLevelHasMarkerSlot as _, isCanonicallyEmptyParagraphFormatting as _t, DRAWING_RAW_XML_MODES as a, paragraphNumberingFromSlots as at, isPresetLineDashVal as b, contentControlLockAllows as bt, PARAGRAPH_MARK_CHANGE_KINDS as c, paragraphNumberingReferenceId as ct, isNoteReferenceId as d, sameEffectiveParagraphNumbering as dt, isNumberingLevel as et, isOoxmlSymbolCharacter as f, sameStatedParagraphNumbering as ft, numberingLevelEntries as g, finalizeParagraphFormatting as gt, numberingInstanceResolves as h, PARSE_WARNING_CODES as ht, BIDI_CONTROLS as i, mergeParagraphNumbering as it, NUMBER_FORMATS as j, statesNoBorder as k, PROPERTY_REVISION_KINDS as l, paragraphNumberingSlots as lt, levelShowsMarker as m, MAX_RETAINED_PARSE_WARNINGS_PER_CODE as mt, DEFAULT_TAB_STOP_TWIPS as n, NO_PARAGRAPH_NUMBERING as nt, INSERTION_SEAM_POLICIES as o, paragraphNumberingLevel as ot, normalizeRevisionId as p, IMPORTED_ID_COLLISION_KINDS as pt, mintRelationshipId as q, DOCX_CONFORMANCE_CLASSES as r, isNumberingReference as rt, MAX_REVISION_ID as s, paragraphNumberingReference as st, COMMENT_PART_RELATIONSHIPS as t, NO_NUMBERING_NUM_ID as tt, REVIEW_CARRIERS as u, resolveParagraphNumbering as ut, resolveNumberingLevel as v, setDocumentBodyComments as vt, borderStyleFrom as w, locksContent as wt, presetLineDashFrom as x, firstLockedControlViolation as xt, COUNTER_FORMATS as y, CONTENT_CONTROL_LOCK as yt, THEME_COLOR_BY_SCHEME_COLOR_VALUE as z };
1424
+ export { headingOutlineLevel as $, statesNoBorder as A, THEME_COLOR_BY_SCHEME_COLOR_VALUE as B, presetLineDashToken as C, contentControlLockAllows as Ct, isBorderNil as D, locksContent as Dt, borderStyleToken as E, lockedControlViolation as Et, TAB_STOP_ALIGNMENTS as F, themeColorSlot as G, isThemeColor as H, TEXT_DIRECTIONS as I, mintRelationshipId as J, themeColorToken as K, TEXT_DIRECTION_FLOWS as L, NUMBER_FORMATS as M, PARAGRAPH_ALIGNMENTS as N, isBorderNone as O, locksControl as Ot, TABLE_ALIGNMENTS as P, headingLevelOf as Q, TEXT_DIRECTION_FLOW_BY_TOKEN as R, presetLineDashFrom as S, CONTENT_CONTROL_LOCK as St, borderStyleFrom as T, lockedControlMessage as Tt, knownThemeColor as U, isSchemeColorValue as V, readThemeColor as W, preservedChildGap as X, relationshipIdOf as Y, BODY_TEXT_OUTLINE_LEVEL as Z, numberingLevelEntries as _, PARSE_WARNING_CODES as _t, DRAWING_RAW_XML_MODES as a, isNumberingReference as at, COUNTER_FORMATS as b, paragraphSpacingExplicit as bt, MAX_REVISION_ID as c, paragraphNumberingLevel as ct, REVIEW_CARRIERS as d, paragraphNumberingSlots as dt, outlineLevelFromStatedValue as et, isNoteReferenceId as f, resolveParagraphNumbering as ft, numberingInstanceResolves as g, MAX_RETAINED_PARSE_WARNINGS_PER_CODE as gt, levelShowsMarker as h, IMPORTED_ID_COLLISION_KINDS as ht, BIDI_CONTROLS as i, NO_PARAGRAPH_NUMBERING as it, BORDER_STYLES as j, isBorderStyle as k, getSingularRunPropertyChange as kt, PARAGRAPH_MARK_CHANGE_KINDS as l, paragraphNumberingReference as lt, normalizeRevisionId as m, sameStatedParagraphNumbering as mt, DEFAULT_TAB_STOP_TWIPS as n, isNumberingLevel as nt, HELD_PARAGRAPH_JOINS as o, mergeParagraphNumbering as ot, isOoxmlSymbolCharacter as p, sameEffectiveParagraphNumbering as pt, THEME_COLORS as q, DOCX_CONFORMANCE_CLASSES as r, NO_NUMBERING_NUM_ID as rt, INSERTION_SEAM_POLICIES as s, paragraphNumberingFromSlots as st, COMMENT_PART_RELATIONSHIPS as t, outlineLevelStatedValue as tt, PROPERTY_REVISION_KINDS as u, paragraphNumberingReferenceId as ut, numberingLevelHasMarkerSlot as v, finalizeParagraphFormatting as vt, PRESET_LINE_DASH_VALS as w, firstLockedControlViolation as wt, isPresetLineDashVal as x, setDocumentBodyComments as xt, resolveNumberingLevel as y, isCanonicallyEmptyParagraphFormatting as yt, SCHEME_COLOR_VALUE_BY_THEME_COLOR as z };