@stll/docx-core 0.3.0 → 0.4.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.
|
@@ -152,7 +152,8 @@ type ParagraphFormatting = {
|
|
|
152
152
|
spaceBefore?: number; /** Spacing after in twips (w:spacing/@w:after) */
|
|
153
153
|
spaceAfter?: number; /** Line spacing value (w:spacing/@w:line) */
|
|
154
154
|
lineSpacing?: number; /** Line spacing rule (w:spacing/@w:lineRule) */
|
|
155
|
-
lineSpacingRule?: LineSpacingRule; /**
|
|
155
|
+
lineSpacingRule?: LineSpacingRule; /** Whether the paragraph participates in the section document grid (w:snapToGrid). */
|
|
156
|
+
snapToGrid?: boolean; /** Auto space before (w:spacing/@w:beforeAutospacing) */
|
|
156
157
|
beforeAutospacing?: boolean; /** Auto space after (w:spacing/@w:afterAutospacing) */
|
|
157
158
|
afterAutospacing?: boolean; /** Which spacing sides came from this paragraph's own pPr. */
|
|
158
159
|
spacingExplicit?: SpacingExplicit; /** Left indent in twips (w:ind/@w:left) */
|
|
@@ -532,6 +533,10 @@ type SoftHyphenContent = {
|
|
|
532
533
|
type NoBreakHyphenContent = {
|
|
533
534
|
type: "noBreakHyphen";
|
|
534
535
|
};
|
|
536
|
+
/** Cached pagination boundary emitted by a previous layout pass. */
|
|
537
|
+
type RenderedPageBreakContent = {
|
|
538
|
+
type: "renderedPageBreak";
|
|
539
|
+
};
|
|
535
540
|
/**
|
|
536
541
|
* Drawing/image reference
|
|
537
542
|
*/
|
|
@@ -550,7 +555,7 @@ type ShapeContent = {
|
|
|
550
555
|
/**
|
|
551
556
|
* All possible run content types
|
|
552
557
|
*/
|
|
553
|
-
type RunContent = TextContent | TabContent | BreakContent | SymbolContent | NoteReferenceContent | FieldCharContent | InstrTextContent | SoftHyphenContent | NoBreakHyphenContent | DrawingContent | ShapeContent;
|
|
558
|
+
type RunContent = TextContent | TabContent | BreakContent | SymbolContent | NoteReferenceContent | FieldCharContent | InstrTextContent | SoftHyphenContent | NoBreakHyphenContent | RenderedPageBreakContent | DrawingContent | ShapeContent;
|
|
554
559
|
/**
|
|
555
560
|
* A run is a contiguous region of text with the same formatting
|
|
556
561
|
*/
|
|
@@ -789,8 +794,8 @@ type ShapeTextBody = {
|
|
|
789
794
|
bottom?: number;
|
|
790
795
|
left?: number;
|
|
791
796
|
right?: number;
|
|
792
|
-
}; /**
|
|
793
|
-
content: Paragraph[];
|
|
797
|
+
}; /** Block content inside the shape */
|
|
798
|
+
content: (Paragraph | Table)[];
|
|
794
799
|
};
|
|
795
800
|
/**
|
|
796
801
|
* Shape/drawing object (wps:wsp)
|
|
@@ -819,8 +824,8 @@ type TextBox = {
|
|
|
819
824
|
position?: ImagePosition; /** Wrap settings */
|
|
820
825
|
wrap?: ImageWrap; /** Fill */
|
|
821
826
|
fill?: ShapeFill; /** Outline */
|
|
822
|
-
outline?: ShapeOutline; /** Text content */
|
|
823
|
-
content: Paragraph[]; /** Text fitting behavior */
|
|
827
|
+
outline?: ShapeOutline; /** Text and table content */
|
|
828
|
+
content: (Paragraph | Table)[]; /** Text fitting behavior */
|
|
824
829
|
autoFit?: ShapeTextBody["autoFit"]; /** Internal margins */
|
|
825
830
|
margins?: {
|
|
826
831
|
top?: number;
|
|
@@ -1042,8 +1047,13 @@ type SectionPropertyChange = {
|
|
|
1042
1047
|
* Table structural tracked change metadata (row/cell insert/delete/merge)
|
|
1043
1048
|
*/
|
|
1044
1049
|
type TableStructuralChangeInfo = {
|
|
1045
|
-
type: "tableRowInsertion" | "tableRowDeletion" | "tableCellInsertion" | "tableCellDeletion"
|
|
1050
|
+
type: "tableRowInsertion" | "tableRowDeletion" | "tableCellInsertion" | "tableCellDeletion"; /** Tracked change metadata */
|
|
1046
1051
|
info: TrackedChangeInfo;
|
|
1052
|
+
} | {
|
|
1053
|
+
type: "tableCellMerge"; /** Tracked change metadata */
|
|
1054
|
+
info: TrackedChangeInfo; /** Vertical merge state applied by the revision. */
|
|
1055
|
+
verticalMerge?: "continue" | "rest"; /** Vertical merge state that existed before the revision. */
|
|
1056
|
+
verticalMergeOriginal?: "continue" | "rest";
|
|
1047
1057
|
};
|
|
1048
1058
|
/**
|
|
1049
1059
|
* SDT type (content control type)
|
|
@@ -1116,14 +1126,14 @@ type SdtProperties = {
|
|
|
1116
1126
|
* Inline SDT (content control within a paragraph).
|
|
1117
1127
|
*
|
|
1118
1128
|
* OOXML allows runs, hyperlinks, simple/complex fields, nested SDTs,
|
|
1119
|
-
* tracked insertions/deletions, and math at this level. All of them must survive
|
|
1129
|
+
* tracked insertions/deletions/moves, and math at this level. All of them must survive
|
|
1120
1130
|
* parse → edit → save so docProps-bound fields and reviewed template
|
|
1121
1131
|
* content do not lose their wrapper on round-trip.
|
|
1122
1132
|
*/
|
|
1123
1133
|
type InlineSdt = {
|
|
1124
1134
|
type: "inlineSdt"; /** SDT properties */
|
|
1125
1135
|
properties: SdtProperties; /** Inline content held inside the control */
|
|
1126
|
-
content: (Run | Hyperlink | SimpleField | ComplexField | InlineSdt | Insertion | Deletion | MathEquation)[];
|
|
1136
|
+
content: (Run | Hyperlink | SimpleField | ComplexField | InlineSdt | Insertion | Deletion | MoveFrom | MoveTo | MathEquation)[];
|
|
1127
1137
|
};
|
|
1128
1138
|
/**
|
|
1129
1139
|
* Block-level SDT (content control wrapping paragraphs/tables).
|
|
@@ -1621,6 +1631,11 @@ type MediaFile = {
|
|
|
1621
1631
|
* Extend as more settings.xml fields enter the layout pipeline.
|
|
1622
1632
|
*/
|
|
1623
1633
|
type DocumentSettings = {
|
|
1634
|
+
/**
|
|
1635
|
+
* Application compatibility generation from
|
|
1636
|
+
* `w:compat/w:compatSetting[@w:name="compatibilityMode"]`.
|
|
1637
|
+
*/
|
|
1638
|
+
compatibilityMode?: number;
|
|
1624
1639
|
/**
|
|
1625
1640
|
* `w:defaultTabStop` (§17.6.13) — interval in twips between default
|
|
1626
1641
|
* tab stops applied when a paragraph has no custom `w:tabs`. Word
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ct as RunContent, Gt as TableRow, Ht as TableCell, M as DocumentBody, Ot as SectionProperties, St as Run, Vt as Table, Yt as TextContent, _t as ParagraphContent, a as DocxPackage, b as BlockContent, gt as Paragraph, i as DocxConformanceClass, n as Document, p as Style, t as DOCX_CONFORMANCE_CLASSES, w as BreakContent } from "./document-
|
|
1
|
+
import { Ct as RunContent, Gt as TableRow, Ht as TableCell, M as DocumentBody, Ot as SectionProperties, St as Run, Vt as Table, Yt as TextContent, _t as ParagraphContent, a as DocxPackage, b as BlockContent, gt as Paragraph, i as DocxConformanceClass, n as Document, p as Style, t as DOCX_CONFORMANCE_CLASSES, w as BreakContent } from "./document-CzARzXpt.js";
|
|
2
2
|
|
|
3
3
|
//#region src/legal-source/types.d.ts
|
|
4
4
|
type LegalDocumentKind = "agreement" | "letter" | "memo" | "checklist" | "pleading" | "other";
|
package/dist/index.js
CHANGED
|
@@ -184,6 +184,7 @@ const serializeRunContent = (content) => {
|
|
|
184
184
|
case "text": return `<w:t${content.preserveSpace ? " xml:space=\"preserve\"" : ""}>${escapeXml(content.text)}</w:t>`;
|
|
185
185
|
case "tab": return "<w:tab/>";
|
|
186
186
|
case "break": return `<w:br${attr("w:type", content.breakType)}/>`;
|
|
187
|
+
case "renderedPageBreak": return "<w:lastRenderedPageBreak/>";
|
|
187
188
|
case "symbol": return `<w:sym w:font="${escapeXml(content.font)}" w:char="${escapeXml(content.char)}"/>`;
|
|
188
189
|
case "footnoteRef": return `<w:footnoteReference w:id="${content.id}"/>`;
|
|
189
190
|
case "endnoteRef": return `<w:endnoteReference w:id="${content.id}"/>`;
|
|
@@ -590,7 +591,7 @@ const validateImage = (image, path, ctx, options = {}) => {
|
|
|
590
591
|
const validateShape = (shape, path, ctx) => {
|
|
591
592
|
validateNonNegativeSize(shape.size.width, `${path}.size.width`, ctx);
|
|
592
593
|
validateNonNegativeSize(shape.size.height, `${path}.size.height`, ctx);
|
|
593
|
-
if (shape.textBody)
|
|
594
|
+
if (shape.textBody) validateBlocks(shape.textBody.content, `${path}.textBody.content`, ctx);
|
|
594
595
|
};
|
|
595
596
|
const validateNonNegativeSize = (value, path, ctx) => {
|
|
596
597
|
if (value < 0) {
|
|
@@ -649,7 +650,7 @@ const validateComments = (comments, ctx) => {
|
|
|
649
650
|
const path = `package.document.comments[${index}]`;
|
|
650
651
|
if (seen.has(comment.id)) addError(ctx, `${path}.id`, `Duplicate comment id ${comment.id}.`);
|
|
651
652
|
seen.add(comment.id);
|
|
652
|
-
if (comment.author.trim() === "") addError(ctx, `${path}.author`, "Comment author
|
|
653
|
+
if (comment.author !== "" && comment.author.trim() === "") addError(ctx, `${path}.author`, "Comment author cannot be whitespace-only.");
|
|
653
654
|
if (comment.parentId !== void 0 && !ctx.commentIds.has(comment.parentId)) addError(ctx, `${path}.parentId`, `Parent comment ${comment.parentId} is missing.`);
|
|
654
655
|
validateParagraphs(comment.content, `${path}.content`, ctx);
|
|
655
656
|
}
|
package/dist/model/document.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as ImageTransform, $t as VerticalAlign, A as ComplexField, An as BorderSpec, At as SectionStart, B as FooterReference, Bt as TabContent, C as BookmarkStart, Cn as TableLook, Ct as RunContent, D as CommentRangeEnd, Dn as TextEffect, Dt as Section, E as Comment, En as TableWidthType, Et as SdtType, F as EndnotePosition, Ft as ShapeTextBody, G as HeaderFooterType, Gt as TableRow, H as FootnotePosition, Ht as TableCell, I as EndnoteProperties, It as ShapeType, J as Image, Jt as TextBox, K as HeaderReference, Kt as TableRowPropertyChange, L as Field, Lt as SimpleField, M as DocumentBody, Mn as KnownBorderStyle, Mt as ShapeContent, N as DrawingContent, Nn as ShadingProperties, Nt as ShapeFill, O as CommentRangeStart, On as TextFormatting, Ot as SectionProperties, P as Endnote, Pn as ThemeColorSlot, Pt as ShapeOutline, Q as ImageSize, Qt as TrackedRunChange, R as FieldCharContent, Rt as SoftHyphenContent, S as BookmarkEnd, Sn as TableFormatting, St as Run, T as Column, Tn as TableRowFormatting, Tt as SdtProperties, U as FootnoteProperties, Ut as TableCellPropertyChange, V as Footnote, Vt as Table, W as HeaderFooter, Wt as TablePropertyChange, X as ImagePadding, Xt as TextWatermark, Y as ImageCrop, Yt as TextContent, Z as ImagePosition, Zt as TrackedChangeInfo, _ as ThemeColorScheme, _n as TabStop, _t as ParagraphContent, a as DocxPackage, an as NumberFormat, at as MathEquation, b as BlockContent, bn as TableCellBorders, bt as PictureWatermark, c as FontTable, cn as CellMargins, ct as MoveFromRangeStart, d as RelationshipMap, dn as FloatingTableProperties, dt as MoveToRangeStart, en as Watermark, et as ImageWrap, f as RelationshipType, fn as LineSpacingRule, ft as NoBreakHyphenContent, g as Theme, gn as TabLeader, gt as Paragraph, h as StyleType, hn as SpacingExplicit, ht as PageOrientation, i as DocxConformanceClass, in as ListRendering, it as LineNumberRestart, j as Deletion, jn as ColorValue, jt as Shape, k as CommentReference, kn as UnderlineStyle, kt as SectionPropertyChange, l as MediaFile, ln as ConditionalFormatStyle, lt as MoveTo, m as StyleDefinitions, mn as ParagraphFormatting, mt as NoteReferenceContent, n as Document, nn as LevelSuffix, nt as Insertion, o as DocDefaults, on as NumberingDefinitions, ot as MoveFrom, p as Style, pn as ParagraphAlignment, pt as NoteNumberRestart, q as Hyperlink, qt as TableStructuralChangeInfo, r as DocumentSettings, rn as ListLevel, rt as InstrTextContent, s as FontInfo, sn as NumberingInstance, st as MoveFromRangeEnd, t as DOCX_CONFORMANCE_CLASSES, tn as AbstractNumbering, tt as InlineSdt, u as Relationship, un as EmphasisMark, ut as MoveToRangeEnd, v as ThemeFont, vn as TabStopAlignment, vt as ParagraphMarkChange, w as BreakContent, wn as TableMeasurement, wt as RunPropertyChange, x as BlockSdt, xn as TableCellFormatting, xt as PropertyChangeInfo, y as ThemeFontScheme, yn as TableBorders, yt as ParagraphPropertyChange, z as FieldType, zt as SymbolContent } from "../document-
|
|
1
|
+
import { $ as ImageTransform, $t as VerticalAlign, A as ComplexField, An as BorderSpec, At as SectionStart, B as FooterReference, Bt as TabContent, C as BookmarkStart, Cn as TableLook, Ct as RunContent, D as CommentRangeEnd, Dn as TextEffect, Dt as Section, E as Comment, En as TableWidthType, Et as SdtType, F as EndnotePosition, Ft as ShapeTextBody, G as HeaderFooterType, Gt as TableRow, H as FootnotePosition, Ht as TableCell, I as EndnoteProperties, It as ShapeType, J as Image, Jt as TextBox, K as HeaderReference, Kt as TableRowPropertyChange, L as Field, Lt as SimpleField, M as DocumentBody, Mn as KnownBorderStyle, Mt as ShapeContent, N as DrawingContent, Nn as ShadingProperties, Nt as ShapeFill, O as CommentRangeStart, On as TextFormatting, Ot as SectionProperties, P as Endnote, Pn as ThemeColorSlot, Pt as ShapeOutline, Q as ImageSize, Qt as TrackedRunChange, R as FieldCharContent, Rt as SoftHyphenContent, S as BookmarkEnd, Sn as TableFormatting, St as Run, T as Column, Tn as TableRowFormatting, Tt as SdtProperties, U as FootnoteProperties, Ut as TableCellPropertyChange, V as Footnote, Vt as Table, W as HeaderFooter, Wt as TablePropertyChange, X as ImagePadding, Xt as TextWatermark, Y as ImageCrop, Yt as TextContent, Z as ImagePosition, Zt as TrackedChangeInfo, _ as ThemeColorScheme, _n as TabStop, _t as ParagraphContent, a as DocxPackage, an as NumberFormat, at as MathEquation, b as BlockContent, bn as TableCellBorders, bt as PictureWatermark, c as FontTable, cn as CellMargins, ct as MoveFromRangeStart, d as RelationshipMap, dn as FloatingTableProperties, dt as MoveToRangeStart, en as Watermark, et as ImageWrap, f as RelationshipType, fn as LineSpacingRule, ft as NoBreakHyphenContent, g as Theme, gn as TabLeader, gt as Paragraph, h as StyleType, hn as SpacingExplicit, ht as PageOrientation, i as DocxConformanceClass, in as ListRendering, it as LineNumberRestart, j as Deletion, jn as ColorValue, jt as Shape, k as CommentReference, kn as UnderlineStyle, kt as SectionPropertyChange, l as MediaFile, ln as ConditionalFormatStyle, lt as MoveTo, m as StyleDefinitions, mn as ParagraphFormatting, mt as NoteReferenceContent, n as Document, nn as LevelSuffix, nt as Insertion, o as DocDefaults, on as NumberingDefinitions, ot as MoveFrom, p as Style, pn as ParagraphAlignment, pt as NoteNumberRestart, q as Hyperlink, qt as TableStructuralChangeInfo, r as DocumentSettings, rn as ListLevel, rt as InstrTextContent, s as FontInfo, sn as NumberingInstance, st as MoveFromRangeEnd, t as DOCX_CONFORMANCE_CLASSES, tn as AbstractNumbering, tt as InlineSdt, u as Relationship, un as EmphasisMark, ut as MoveToRangeEnd, v as ThemeFont, vn as TabStopAlignment, vt as ParagraphMarkChange, w as BreakContent, wn as TableMeasurement, wt as RunPropertyChange, x as BlockSdt, xn as TableCellFormatting, xt as PropertyChangeInfo, y as ThemeFontScheme, yn as TableBorders, yt as ParagraphPropertyChange, z as FieldType, zt as SymbolContent } from "../document-CzARzXpt.js";
|
|
2
2
|
export { type AbstractNumbering, type BlockContent, type BlockSdt, type BookmarkEnd, 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, type Deletion, type DocDefaults, Document, type DocumentBody, DocumentSettings, DocxConformanceClass, DocxPackage, type DrawingContent, type EmphasisMark, type Endnote, type EndnotePosition, type EndnoteProperties, 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 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 ListRendering, type MathEquation, type MediaFile, type MoveFrom, type MoveFromRangeEnd, type MoveFromRangeStart, type MoveTo, type MoveToRangeEnd, type MoveToRangeStart, type NoBreakHyphenContent, type NoteNumberRestart, type NoteReferenceContent, type NumberFormat, type NumberingDefinitions, type NumberingInstance, type PageOrientation, type Paragraph, type ParagraphAlignment, type ParagraphContent, type ParagraphFormatting, type ParagraphMarkChange, type ParagraphPropertyChange, type PictureWatermark, type PropertyChangeInfo, type Relationship, type RelationshipMap, type RelationshipType, 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 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 UnderlineStyle, type VerticalAlign, type Watermark };
|
package/package.json
CHANGED