oasis-editor 0.0.90 → 0.0.91

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.
@@ -7,8 +7,8 @@
7
7
  * re-export in `src/core/model.ts`.
8
8
  */
9
9
  export type { EditorUnderlineStyle, EditorLigatures, EditorNumberSpacing, EditorNumberForm, EditorTextLanguage, EditorBorderStyle, EditorEmphasisMark, EditorTabStop, EditorParagraphListStyle, EditorImageCrop, EditorImageFillMode, EditorImageFloatingPosition, EditorImageFloatingLayout, EditorImageRunData, EditorWrapPolygonPoint, EditorFieldData, EditorFieldChar, EditorFootnoteReferenceData, EditorEndnoteReferenceData, EditorRevision, EditorRevisionMetadata, EditorStructuralRevision, EditorPropertyRevision, EditorAsset, EditorFootnoteNumberFormat, EditorFootnoteRestart, EditorDocxWidthValue, EditorTableLayout, EditorTableRowHeightRule, } from './types/primitives.js';
10
- export type { EditorTextStyle, EditorParagraphStyle, EditorTableStyle, EditorTableFloatingLayout, EditorTableConditionalFormat, EditorConditionalRowStyle, EditorTableConditionalType, EditorTableConditionalFlags, EditorNamedStyle, } from './types/styles.js';
11
- export type { EditorRunBase, EditorTextRun, EditorTextBoxShape, EditorTextBoxBody, EditorTextBoxData, EditorDropCap, EditorParagraphNode, EditorTableCellStyle, EditorTableCellNode, EditorTableRowStyle, EditorTableRowNode, EditorTableNode, EditorBlockNode, } from './types/nodes.js';
10
+ export type { EditorTextStyle, EditorParagraphStyle, EditorTableStyle, EditorTableFloatingLayout, EditorTableConditionalFormat, EditorConditionalRowStyle, EditorTableConditionalType, EditorTableConditionalFlags, EditorTableCellStyle, EditorNamedStyle, } from './types/styles.js';
11
+ export type { EditorRunBase, EditorTextRun, EditorTextBoxShape, EditorTextBoxBody, EditorTextBoxData, EditorDropCap, EditorParagraphNode, EditorTableCellNode, EditorTableRowStyle, EditorTableRowNode, EditorTableNode, EditorBlockNode, } from './types/nodes.js';
12
12
  export type { RunKind, RunOfKind, RunVisitor } from './runKind.js';
13
13
  export { getRunKind, isInlineObjectRun, visitRun, getRunImage, getRunTextBox, getRunField, getRunFieldChar, getRunFieldInstruction, getRunFootnoteReference, getRunEndnoteReference, getRunSym, } from './runKind.js';
14
14
  export type { EditorFootnote } from './types/documentFootnotes.js';
@@ -86,6 +86,8 @@ export interface EditorDocument {
86
86
  styles?: Record<string, EditorNamedStyle>;
87
87
  settings?: {
88
88
  defaultTabStop?: number;
89
+ /** `w:allowSpaceOfSameStyleInTable`: contextual spacing applies in table cells. */
90
+ allowSpaceOfSameStyleInTable?: boolean;
89
91
  };
90
92
  /**
91
93
  * Out-of-band asset registry. Image runs reference entries here using
@@ -1,5 +1,5 @@
1
- import { EditorBorderStyle, EditorDocxWidthValue, EditorEndnoteReferenceData, EditorFieldChar, EditorFieldData, EditorFootnoteReferenceData, EditorImageFloatingLayout, EditorImageRunData, EditorParagraphListStyle, EditorRevision, EditorPropertyRevision, EditorStructuralRevision, EditorTableRowHeightRule } from './primitives.js';
2
- import { EditorParagraphStyle, EditorTableStyle, EditorTableConditionalFlags, EditorTextStyle } from './styles.js';
1
+ import { EditorDocxWidthValue, EditorEndnoteReferenceData, EditorFieldChar, EditorFieldData, EditorFootnoteReferenceData, EditorImageFloatingLayout, EditorImageRunData, EditorParagraphListStyle, EditorRevision, EditorPropertyRevision, EditorStructuralRevision, EditorTableRowHeightRule } from './primitives.js';
2
+ import { EditorParagraphStyle, EditorTableCellStyle, EditorTableStyle, EditorTableConditionalFlags, EditorTextStyle } from './styles.js';
3
3
 
4
4
  /**
5
5
  * Geometry/appearance of a text box shape (`wps:spPr`). All values are
@@ -153,44 +153,6 @@ export interface EditorParagraphNode {
153
153
  /** Drop cap that body text in this paragraph wraps around, when present. */
154
154
  dropCap?: EditorDropCap;
155
155
  }
156
- export interface EditorTableCellStyle {
157
- shading?: string;
158
- width?: number | string;
159
- borderTop?: EditorBorderStyle;
160
- borderRight?: EditorBorderStyle;
161
- borderBottom?: EditorBorderStyle;
162
- borderLeft?: EditorBorderStyle;
163
- /** Bidi-aware leading/trailing borders (`w:start` / `w:end`). */
164
- borderStart?: EditorBorderStyle;
165
- borderEnd?: EditorBorderStyle;
166
- /** Diagonal cell borders (`w:tl2br` / `w:tr2bl`). */
167
- borderTopLeftToBottomRight?: EditorBorderStyle;
168
- borderTopRightToBottomLeft?: EditorBorderStyle;
169
- padding?: number;
170
- paddingTop?: number;
171
- paddingRight?: number;
172
- paddingBottom?: number;
173
- paddingLeft?: number;
174
- /** Bidi-aware leading/trailing margins (`w:start` / `w:end`). */
175
- paddingStart?: number;
176
- paddingEnd?: number;
177
- verticalAlign?: "top" | "middle" | "bottom";
178
- horizontalAlign?: "left" | "center" | "right" | "justify";
179
- /** `w:tcPr/w:textDirection/@w:val`: cell text flow direction (vertical text). */
180
- textDirection?: "lrTb" | "tbRl" | "btLr" | "lrTbV" | "tbRlV" | null;
181
- /** `w:noWrap`: prevent normal wrapping inside the cell. */
182
- noWrap?: boolean;
183
- /** `w:tcFitText`: request Word-style text fitting within the cell width. */
184
- fitText?: boolean;
185
- /** `w:hideMark`: hide the cell-end marker for layout. */
186
- hideMark?: boolean;
187
- /** `w:headers/@w:val`: semantic header cell references. */
188
- headers?: string;
189
- /** Structural `cellIns`/`cellDel`/`cellMerge` revision. */
190
- revision?: EditorStructuralRevision;
191
- /** Previous cell properties from `w:tcPrChange`. */
192
- propertyRevision?: EditorPropertyRevision<EditorTableCellStyle>;
193
- }
194
156
  export interface EditorTableCellNode {
195
157
  id: string;
196
158
  blocks: EditorParagraphNode[];
@@ -201,6 +163,8 @@ export interface EditorTableCellNode {
201
163
  conditionalStyle?: EditorTableConditionalFlags;
202
164
  /** Exact pre-change cell grid retained while a tracked merge/split is pending. */
203
165
  mergeRevisionState?: EditorTableMergeRevisionState;
166
+ /** Extension attributes (e.g. `w14:paraId`) preserved for round-trip. */
167
+ extAttributes?: Record<string, string>;
204
168
  }
205
169
  export interface EditorTableMergeRevisionState {
206
170
  revisionId: string;
@@ -217,6 +181,8 @@ export interface EditorTableRowStyle {
217
181
  gridAfter?: number;
218
182
  widthBefore?: EditorDocxWidthValue;
219
183
  widthAfter?: EditorDocxWidthValue;
184
+ /** `w:jc` in `w:trPr`: horizontal alignment of the row within the table width. */
185
+ align?: "left" | "center" | "right";
220
186
  /** `w:cantSplit`: keep this row together during pagination. */
221
187
  cantSplit?: boolean;
222
188
  /** `w:hidden`: do not display this row in normal view. */
@@ -235,10 +201,16 @@ export interface EditorTableRowNode {
235
201
  style?: EditorTableRowStyle;
236
202
  conditionalStyle?: EditorTableConditionalFlags;
237
203
  /**
238
- * Raw w:tblPrEx XML (per-row table property exceptions), serialized verbatim
239
- * before w:trPr. Preserved for DOCX round-trip fidelity only; not editable.
204
+ * `w:tblPrEx` per-row table property exceptions. These override the table's
205
+ * own properties (borders, cell margins, cell spacing, indent, width, layout,
206
+ * alignment) for the cells in this row. Applied during cell formatting
207
+ * resolution and re-serialized before `w:trPr` on export.
240
208
  */
241
- tblPrExXml?: string;
209
+ propertyExceptions?: EditorTableStyle;
210
+ /** Raw `<w:tblPrExChange ...>` XML preserved for DOCX round-trip. */
211
+ tblPrExChangeXml?: string;
212
+ /** Extension attributes (e.g. `w14:paraId`, `w15:*`) preserved for round-trip. */
213
+ extAttributes?: Record<string, string>;
242
214
  }
243
215
  export interface EditorTableNode {
244
216
  id: string;
@@ -1,5 +1,4 @@
1
- import { EditorBorderStyle, EditorDocxWidthValue, EditorEmphasisMark, EditorLigatures, EditorNumberForm, EditorNumberSpacing, EditorPropertyRevision, EditorTabStop, EditorTextLanguage, EditorUnderlineStyle } from './primitives.js';
2
- import { EditorTableCellStyle } from './nodes.js';
1
+ import { EditorBorderStyle, EditorDocxWidthValue, EditorEmphasisMark, EditorLigatures, EditorNumberForm, EditorNumberSpacing, EditorPropertyRevision, EditorStructuralRevision, EditorTabStop, EditorTextLanguage, EditorUnderlineStyle } from './primitives.js';
3
2
 
4
3
  export interface EditorTextStyle {
5
4
  styleId?: string;
@@ -100,6 +99,44 @@ export interface EditorConditionalRowStyle {
100
99
  cantSplit?: boolean;
101
100
  hidden?: boolean;
102
101
  }
102
+ export interface EditorTableCellStyle {
103
+ shading?: string;
104
+ width?: number | string;
105
+ borderTop?: EditorBorderStyle;
106
+ borderRight?: EditorBorderStyle;
107
+ borderBottom?: EditorBorderStyle;
108
+ borderLeft?: EditorBorderStyle;
109
+ /** Bidi-aware leading/trailing borders (`w:start` / `w:end`). */
110
+ borderStart?: EditorBorderStyle;
111
+ borderEnd?: EditorBorderStyle;
112
+ /** Diagonal cell borders (`w:tl2br` / `w:tr2bl`). */
113
+ borderTopLeftToBottomRight?: EditorBorderStyle;
114
+ borderTopRightToBottomLeft?: EditorBorderStyle;
115
+ padding?: number;
116
+ paddingTop?: number;
117
+ paddingRight?: number;
118
+ paddingBottom?: number;
119
+ paddingLeft?: number;
120
+ /** Bidi-aware leading/trailing margins (`w:start` / `w:end`). */
121
+ paddingStart?: number;
122
+ paddingEnd?: number;
123
+ verticalAlign?: "top" | "middle" | "bottom";
124
+ horizontalAlign?: "left" | "center" | "right" | "justify";
125
+ /** `w:tcPr/w:textDirection/@w:val`: cell text flow direction (vertical text). */
126
+ textDirection?: "lrTb" | "tbRl" | "btLr" | "lrTbV" | "tbRlV" | null;
127
+ /** `w:noWrap`: prevent normal wrapping inside the cell. */
128
+ noWrap?: boolean;
129
+ /** `w:tcFitText`: request Word-style text fitting within the cell width. */
130
+ fitText?: boolean;
131
+ /** `w:hideMark`: hide the cell-end marker for layout. */
132
+ hideMark?: boolean;
133
+ /** `w:headers/@w:val`: semantic header cell references. */
134
+ headers?: string;
135
+ /** Structural `cellIns`/`cellDel`/`cellMerge` revision. */
136
+ revision?: EditorStructuralRevision;
137
+ /** Previous cell properties from `w:tcPrChange`. */
138
+ propertyRevision?: EditorPropertyRevision<EditorTableCellStyle>;
139
+ }
103
140
  export interface EditorTableConditionalFormat {
104
141
  shading?: string;
105
142
  /** Run formatting (bold/color) from the conditional's `w:rPr`. */
@@ -1,4 +1,5 @@
1
- import { EditorNamedStyle, EditorParagraphStyle, EditorTableCellStyle, EditorTableNode, EditorTableRowStyle, EditorTableStyle, EditorTextStyle } from './model.js';
1
+ import { EditorNamedStyle, EditorParagraphStyle, EditorTableCellStyle, EditorTableStyle, EditorTextStyle } from './model/types/styles.js';
2
+ import { EditorTableNode, EditorTableRowStyle } from './model/types/nodes.js';
2
3
 
3
4
  export interface ResolvedTableCellFormatting {
4
5
  tableStyle: EditorTableStyle;
@@ -4,5 +4,5 @@ import { DocContext, PartDefinition } from './docxTypes.js';
4
4
  export declare function buildContentTypesXml(hasNumbering: boolean, imageExtensions: Iterable<string>, hasSettings: boolean, parts: PartDefinition[], hasFootnotes: boolean, hasEndnotes: boolean, hasStyles: boolean, hasComments: boolean): string;
5
5
  export declare function buildRootRelationshipsXml(): string;
6
6
  export declare function buildDocumentRelationshipsXml(hasNumbering: boolean, hasSettings: boolean, images: DocContext["images"], hyperlinks: DocContext["hyperlinks"], parts: PartDefinition[], hasFootnotes: boolean, hasEndnotes: boolean, hasStyles: boolean, hasComments: boolean): string;
7
- export declare function buildSettingsXml(hasEvenAndOddHeaders: boolean, defaultTabStop?: number, footnoteSettings?: EditorFootnoteSettings, endnoteSettings?: EditorFootnoteSettings): string;
7
+ export declare function buildSettingsXml(hasEvenAndOddHeaders: boolean, defaultTabStop?: number, footnoteSettings?: EditorFootnoteSettings, endnoteSettings?: EditorFootnoteSettings, allowSpaceOfSameStyleInTable?: boolean): string;
8
8
  export declare function buildPartRelationshipsXml(images: DocContext["images"], hyperlinks: DocContext["hyperlinks"]): string;
@@ -2,6 +2,7 @@ import { EditorFootnoteSettings, EditorEndnoteSettings } from '../../core/model.
2
2
 
3
3
  export interface DocxSettings {
4
4
  adjustLineHeightInTable: boolean;
5
+ allowSpaceOfSameStyleInTable?: boolean;
5
6
  defaultTabStop?: number;
6
7
  footnoteSettings?: EditorFootnoteSettings;
7
8
  endnoteSettings?: EditorEndnoteSettings;
@@ -1,5 +1,4 @@
1
1
  import { Element as XmlElement } from '@xmldom/xmldom';
2
- import { EditorNamedStyle, EditorParagraphNode, EditorParagraphStyle, EditorTableConditionalFormat, EditorTextStyle } from '../../core/model.js';
3
2
 
4
3
  export interface TableLook {
5
4
  firstRow: boolean;
@@ -17,32 +16,3 @@ export interface TableLook {
17
16
  * on.
18
17
  */
19
18
  export declare function parseTableLook(tblPr: XmlElement | null): TableLook;
20
- /**
21
- * Returns the table-style conditional-format keys that apply to a cell at the
22
- * given position, ordered low→high precedence (later entries override earlier
23
- * ones). Mirrors Word's resolution order: whole table < bands < first/last col
24
- * < first/last row < corner cells. Banding and first/last row/col are gated by
25
- * `tblLook`; banding parity is computed over the "body" rows/cols that remain
26
- * after excluding the special first/last row/col.
27
- */
28
- export declare function resolveCellConditionalKeys(rowIndex: number, colIndex: number, rowCount: number, colCount: number, look: TableLook, rowBandSize: number, colBandSize: number): string[];
29
- /** Merges resolved conditional formats (low→high precedence) into one. */
30
- export declare function mergeConditionalFormats(keys: string[], conditionals: Record<string, EditorTableConditionalFormat> | undefined): EditorTableConditionalFormat;
31
- /**
32
- * Applies a conditional run text style (bold/color from the table style)
33
- * beneath each run's own style, so explicit run formatting still wins.
34
- */
35
- export declare function applyConditionalTextStyle(paragraphs: EditorParagraphNode[], textStyle: EditorTextStyle | undefined): void;
36
- /**
37
- * Filter a table style's paragraph properties (its `<w:pPr>`) so they sit at the
38
- * correct OOXML precedence for a given cell paragraph.
39
- *
40
- * Per ECMA-376 §17.7.2 the order (low → high) is:
41
- * docDefaults < table style < paragraph style < direct formatting.
42
- * So any property the paragraph's own (named) style explicitly defines must win
43
- * over the table style. We strip those keys from the inherited table-style pPr;
44
- * what remains only fills gaps the paragraph style leaves open. Without this, a
45
- * table style like `TableGrid` (which sets `spacing after="0"`) would wrongly
46
- * override Normal's `after="120"` and collapse cell row height vs Word.
47
- */
48
- export declare function tableStyleParagraphInheritance(tableStylePPr: EditorParagraphStyle | undefined, paragraphStyleId: string | undefined, styles: Record<string, EditorNamedStyle> | undefined): EditorParagraphStyle | undefined;
@@ -8,6 +8,13 @@ export declare function parseTableStyle(tblPr: XmlElement | null, tableStyleId?:
8
8
  export declare function parseTableRowStyle(rowProperties: XmlElement | null): EditorTableRowStyle | undefined;
9
9
  export declare function getTableCellColSpan(cellProperties: XmlElement | null): number;
10
10
  export declare function getTableCellVMerge(cellProperties: XmlElement | null): "restart" | "continue" | undefined;
11
+ /**
12
+ * Legacy horizontal merge marker (`w:hMerge`). Like `w:vMerge`, `restart`
13
+ * begins a merged run and an omitted/`continue` value continues it. Modern Word
14
+ * uses `w:gridSpan` instead; on import we collapse `hMerge` runs into the
15
+ * anchor cell's colspan so both representations render identically.
16
+ */
17
+ export declare function getTableCellHMerge(cellProperties: XmlElement | null): "restart" | "continue" | undefined;
11
18
  export declare function parseTableCellStyle(cellProperties: XmlElement | null, tableDefaultMargins?: EditorTableStyle["defaultCellMargins"]): EditorTableCellStyle | undefined;
12
19
  export declare function isTableHeaderRow(rowNode: XmlElement): boolean;
13
20
  /**
@@ -11,6 +11,11 @@ export declare function parseTextDirection(value: string | null | undefined): Do
11
11
  export declare function getFirstChildByTagNameNS(element: XmlElement | null | undefined, namespace: string, localName: string): XmlElement | null;
12
12
  export declare function getAttributeValue(element: XmlElement | null, localName: string): string | null;
13
13
  export declare function findElementDeep(element: XmlElement, localName: string): XmlElement | null;
14
+ /**
15
+ * Collects non-WORD_NS extension attributes (e.g. `w14:paraId`, `w15:*`) from
16
+ * a table/row/cell element for round-trip preservation.
17
+ */
18
+ export declare function collectExtAttributes(element: XmlElement): Record<string, string> | undefined;
14
19
  export declare function isWordTrue(value: string | null | undefined): boolean;
15
20
  export declare function parseOnOffProperty(parent: XmlElement, localName: string): boolean | undefined;
16
21
  export declare function parseStyleIdProperty(parent: XmlElement | null, localName: "pStyle" | "rStyle"): string | undefined;