@stll/docx-core 0.43.1 → 0.45.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-CaGfolcU.d.ts → document-BKejiFuk.d.ts} +383 -250
- package/dist/{document-CEMwM5On.js → document-BuoCvTcR.js} +44 -50
- package/dist/docx_kernel_bg.wasm +0 -0
- package/dist/index.d.ts +15 -2
- package/dist/index.js +202 -53
- package/dist/listItems-bPpOKnLB.js +116 -0
- package/dist/model/document.d.ts +16 -3
- package/dist/model/document.js +1 -1
- package/dist/ops/documentOps.d.ts +1183 -111
- package/dist/ops/documentOps.js +34619 -16484
- package/dist/preservedMarkup-BWpGhchw.d.ts +79 -0
- package/dist/projection.js +77 -78
- package/dist/schema/sequenceChildren.d.ts +1 -1
- package/dist/schema/sequenceChildren.js +1 -1
- package/dist/{sequenceChildren-BEcOm3tR.js → sequenceChildren-ESF-Ei5K.js} +1 -1
- package/dist/{streamingXmlParser-GnKxUuw_.js → streamingXmlParser-BqnCIEZd.js} +288 -156
- package/dist/xml/streamingXmlParser.d.ts +74 -12
- package/dist/xml/streamingXmlParser.js +1 -1
- package/dist/xml/xmlNamespaceContext.d.ts +8 -0
- package/dist/xml/xmlNamespaceContext.js +3 -1
- package/dist/zip/archive.d.ts +1 -1
- package/package.json +3 -3
- package/dist/href-ogmJmncc.js +0 -138
- package/dist/preservedMarkup-9L4lbGnE.d.ts +0 -66
|
@@ -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 {
|
|
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 };
|
package/dist/docx_kernel_bg.wasm
CHANGED
|
Binary file
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as finalizeParagraphFormatting, Ct as DocumentBody, Dn as ParagraphContent, E as Style, En as Paragraph, Nn as PositionalTab, St as DocumentBackgroundDrawing, U as setDocumentBodyComments, Un as Run, V as isCanonicallyEmptyParagraphFormatting, Wn as RunContent, Xn as SectionProperties, at as BlockContent, br as TableRow, dr as Table, dt as BreakContent, fr as TableCell, i as Document, o as DocxConformanceClass, r as DOCX_CONFORMANCE_CLASSES, ri as NumberingDefinitions, s as DocxPackage, wr as TextContent, xt as DocumentBackground } from "./document-BKejiFuk.js";
|
|
2
2
|
import { TaggedErrorClass } from "better-result";
|
|
3
3
|
import { Buffer } from "node:buffer";
|
|
4
4
|
type LegalDocumentKind = "agreement" | "letter" | "memo" | "checklist" | "pleading" | "other";
|
|
@@ -128,7 +128,9 @@ type MarkdownContent = {
|
|
|
128
128
|
* Synchronous. The caller places the blocks into a `Document` of its own
|
|
129
129
|
* (page geometry, styles, and presets are the host's decision).
|
|
130
130
|
*/
|
|
131
|
-
export declare const compileMarkdownToContent: (markdown: string
|
|
131
|
+
export declare const compileMarkdownToContent: (markdown: string, options?: {
|
|
132
|
+
editProfile?: "paragraphs" | "table";
|
|
133
|
+
}) => MarkdownContent;
|
|
132
134
|
/**
|
|
133
135
|
* Keep only http(s), mailto, and tel URLs, normalised through the URL parser.
|
|
134
136
|
* Anything else (javascript:, data:, relative paths, malformed input) drops to
|
|
@@ -298,6 +300,17 @@ type ValidateDocumentModelResult = {
|
|
|
298
300
|
issues: ValidateDocumentModelIssue[];
|
|
299
301
|
};
|
|
300
302
|
export declare const validateDocxPackage: (buffer: ArrayBuffer | Uint8Array) => Promise<ValidateDocxPackageResult>;
|
|
303
|
+
/**
|
|
304
|
+
* Every issue {@link validateDocxPackage} would report, not only the first:
|
|
305
|
+
* each part's attribute issues and every package-graph issue. A package the
|
|
306
|
+
* archive, size or root checks reject gives that one issue. Empty when the
|
|
307
|
+
* package is valid.
|
|
308
|
+
*/
|
|
309
|
+
export declare const listDocxPackageIssues: (buffer: ArrayBuffer | Uint8Array) => Promise<string[]>;
|
|
301
310
|
export declare const validateDocumentModel: (document: Document) => ValidateDocumentModelResult;
|
|
302
311
|
export declare const assertValidDocumentModel: (document: Document) => void;
|
|
312
|
+
/** Why a save refuses `author` on a tracked change, if it does. */
|
|
313
|
+
export declare const trackedChangeAuthorIssue: (author: string) => string | undefined;
|
|
314
|
+
/** Why a save refuses `author` on a comment, if it does: an empty one is allowed. */
|
|
315
|
+
export declare const commentAuthorIssue: (author: string) => string | undefined;
|
|
303
316
|
export { type Autofix, type BlockContent, type BreakContent, type CompiledLegalDocument, DOCX_CONFORMANCE_CLASSES, type Document, type DocumentBackground, type DocumentBackgroundDrawing, 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, finalizeParagraphFormatting, isCanonicallyEmptyParagraphFormatting, setDocumentBodyComments };
|