oasis-editor 0.0.89 → 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.
@@ -6,9 +6,9 @@
6
6
  * statements that pointed there continue to work via the barrel
7
7
  * re-export in `src/core/model.ts`.
8
8
  */
9
- export type { EditorUnderlineStyle, EditorLigatures, EditorNumberSpacing, EditorNumberForm, EditorTextLanguage, EditorBorderStyle, 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';
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, 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;
@@ -18,6 +18,8 @@ export interface EditorBorderStyle {
18
18
  type: "solid" | "dashed" | "dotted" | "none";
19
19
  color: string;
20
20
  }
21
+ /** `w:em/@w:val`: the emphasis mark drawn over each glyph of a run. */
22
+ export type EditorEmphasisMark = "dot" | "comma" | "circle" | "underDot" | "none";
21
23
  export interface EditorTabStop {
22
24
  position: number;
23
25
  type: "left" | "center" | "right" | "decimal" | "bar" | "clear";
@@ -1,5 +1,4 @@
1
- import { EditorBorderStyle, EditorDocxWidthValue, 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;
@@ -18,6 +17,26 @@ export interface EditorTextStyle {
18
17
  noProof?: boolean;
19
18
  webHidden?: boolean;
20
19
  specVanish?: boolean;
20
+ /** `w:rtl`: run flows right-to-left. */
21
+ rtl?: boolean;
22
+ /** `w:cs`: run is complex-script text. */
23
+ complexScript?: boolean;
24
+ /** `w:snapToGrid` (run): snap characters to the document grid. Defaults on. */
25
+ snapToGrid?: boolean;
26
+ /** `w:fitText`: compress/expand the run to this target width (in pt). */
27
+ fitText?: number | null;
28
+ /** `w:em`: emphasis mark drawn above (or below for `underDot`) each glyph. */
29
+ emphasisMark?: EditorEmphasisMark | null;
30
+ /** `w:bdr`: border box drawn around the run's text. */
31
+ textBorder?: EditorBorderStyle | null;
32
+ /** `w:outline`: hollow/outlined glyphs. */
33
+ outline?: boolean;
34
+ /** `w:shadow`: drop shadow behind glyphs. */
35
+ shadow?: boolean;
36
+ /** `w:emboss`: raised (embossed) glyphs. */
37
+ emboss?: boolean;
38
+ /** `w:imprint`: engraved glyphs. */
39
+ imprint?: boolean;
21
40
  textEffect?: string | null;
22
41
  characterScale?: number | null;
23
42
  characterSpacing?: number | null;
@@ -80,6 +99,44 @@ export interface EditorConditionalRowStyle {
80
99
  cantSplit?: boolean;
81
100
  hidden?: boolean;
82
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
+ }
83
140
  export interface EditorTableConditionalFormat {
84
141
  shading?: string;
85
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;
@@ -1,102 +1,11 @@
1
- export interface OasisPdfPageSize {
2
- width: number;
3
- height: number;
4
- }
5
- export interface OasisPdfPage {
6
- width: number;
7
- height: number;
8
- commands: string[];
9
- imageResourceNames: Set<string>;
10
- }
11
- export interface OasisPdfRectOptions {
12
- x: number;
13
- y: number;
14
- width: number;
15
- height: number;
16
- fill?: string;
17
- stroke?: string;
18
- lineWidth?: number;
19
- }
20
- export interface OasisPdfLineOptions {
21
- x1: number;
22
- y1: number;
23
- x2: number;
24
- y2: number;
25
- stroke?: string;
26
- lineWidth?: number;
27
- dashArray?: number[];
28
- }
29
- export type OasisPdfPathSegment = {
30
- type: "move";
31
- x: number;
32
- y: number;
33
- } | {
34
- type: "line";
35
- x: number;
36
- y: number;
37
- } | {
38
- type: "cubic";
39
- x1: number;
40
- y1: number;
41
- x2: number;
42
- y2: number;
43
- x: number;
44
- y: number;
45
- } | {
46
- type: "close";
47
- };
48
- export interface OasisPdfPathOptions {
49
- segments: OasisPdfPathSegment[];
50
- fill?: string;
51
- stroke?: string;
52
- lineWidth?: number;
53
- }
54
- export interface OasisPdfTextOptions {
55
- x: number;
56
- y: number;
57
- text: string;
58
- fontSize?: number;
59
- color?: string;
60
- bold?: boolean;
61
- italic?: boolean;
62
- fontResourceName?: string;
63
- characterSpacing?: number;
64
- horizontalScale?: number;
65
- }
66
- export interface OasisPdfImageResource {
67
- resourceName: string;
68
- width: number;
69
- height: number;
70
- data: Uint8Array;
71
- filter: "DCTDecode";
72
- }
73
- export interface OasisPdfImageOptions {
74
- resourceName: string;
75
- x: number;
76
- y: number;
77
- width: number;
78
- height: number;
79
- rotation?: number;
80
- }
81
- export type OasisPdfFontResource = OasisPdfBase14FontResource | OasisPdfUnicodeFontResource;
82
- export interface OasisPdfBase14FontResource {
83
- kind: "base14";
84
- resourceName: string;
85
- baseFont: string;
86
- }
87
- export interface OasisPdfUnicodeFontResource {
88
- kind: "unicode";
89
- resourceName: string;
90
- family: string;
91
- fontData: Uint8Array;
92
- postscriptName?: string;
93
- }
1
+ import { OasisPdfFontResource, OasisPdfImageOptions, OasisPdfImageResource, OasisPdfLineOptions, OasisPdfPageSize, OasisPdfPathOptions, OasisPdfRectOptions, OasisPdfTextOptions } from './writer/pdfTypes.js';
2
+
3
+ export type { OasisPdfPageSize, OasisPdfPage, OasisPdfRectOptions, OasisPdfLineOptions, OasisPdfPathSegment, OasisPdfPathOptions, OasisPdfTextOptions, OasisPdfImageResource, OasisPdfImageOptions, OasisPdfFontResource, OasisPdfBase14FontResource, OasisPdfUnicodeFontResource, } from './writer/pdfTypes.js';
94
4
  export declare class OasisPdfWriter {
95
5
  private readonly pages;
96
- private readonly fontResources;
97
- private readonly unicodeFontStates;
98
- private readonly usedFontResourceNames;
99
- private readonly imageResources;
6
+ private readonly streams;
7
+ private readonly fonts;
8
+ private readonly images;
100
9
  constructor(fontResources?: OasisPdfFontResource[]);
101
10
  registerFontResource(resource: OasisPdfFontResource): void;
102
11
  addPage(size: OasisPdfPageSize): number;
@@ -113,12 +22,7 @@ export declare class OasisPdfWriter {
113
22
  resourceName?: string;
114
23
  }): string;
115
24
  drawImage(pageIndex: number, options: OasisPdfImageOptions): void;
116
- private layoutUnicodeText;
117
- private encodeUnicodeGlyphRun;
118
- private drawUnicodeText;
119
25
  toArrayBuffer(): ArrayBuffer;
120
26
  toBlob(): Blob;
121
27
  private toUint8Array;
122
- private addImageObject;
123
- private addUnicodeFontObjects;
124
28
  }
@@ -17,5 +17,7 @@ export declare function drawFloatingImagesForParagraph(options: {
17
17
  }): Promise<void>;
18
18
  export declare function drawFragmentHighlight(writer: OasisPdfWriter, pageIndex: number, line: EditorLayoutLine, fragment: EditorLayoutFragment, originX: number, originY: number, styles: Required<EditorTextStyle>): void;
19
19
  export declare function drawFragmentShading(writer: OasisPdfWriter, pageIndex: number, line: EditorLayoutLine, fragment: EditorLayoutFragment, originX: number, originY: number, styles: Required<EditorTextStyle>): void;
20
+ export declare function drawFragmentBorder(writer: OasisPdfWriter, pageIndex: number, line: EditorLayoutLine, fragment: EditorLayoutFragment, originX: number, originY: number, styles: Required<EditorTextStyle>): void;
21
+ export declare function drawFragmentEmphasis(writer: OasisPdfWriter, pageIndex: number, line: EditorLayoutLine, fragment: EditorLayoutFragment, originX: number, originY: number, styles: Required<EditorTextStyle>): void;
20
22
  export declare function drawFragmentDecoration(writer: OasisPdfWriter, pageIndex: number, line: EditorLayoutLine, fragment: EditorLayoutFragment, originX: number, originY: number, styles: Required<EditorTextStyle>, kind: "underline" | "strike" | "doubleStrike"): void;
21
23
  export declare function drawFragmentText(writer: OasisPdfWriter, pageIndex: number, paragraph: EditorParagraphNode, line: EditorLayoutLine, fragment: EditorLayoutFragment, document: EditorDocument, originX: number, originY: number, fontRegistry: PdfFontRegistry, drawers: BlockDrawers): Promise<void>;
@@ -0,0 +1,20 @@
1
+ import { OasisPdfImageOptions, OasisPdfLineOptions, OasisPdfPage, OasisPdfPathOptions, OasisPdfRectOptions, OasisPdfTextOptions } from './pdfTypes.js';
2
+ import { PdfFontTable } from './PdfFontTable.js';
3
+ import { PdfImageTable } from './PdfImageTable.js';
4
+
5
+ export declare class PdfContentStream {
6
+ readonly page: OasisPdfPage;
7
+ private readonly fonts;
8
+ private readonly images;
9
+ constructor(page: OasisPdfPage, fonts: PdfFontTable, images: PdfImageTable);
10
+ drawRect(options: OasisPdfRectOptions): void;
11
+ drawLine(options: OasisPdfLineOptions): void;
12
+ drawPath(options: OasisPdfPathOptions): void;
13
+ saveGraphicsState(): void;
14
+ restoreGraphicsState(): void;
15
+ rotateAbout(centerX: number, centerY: number, degrees: number): void;
16
+ clipRect(x: number, y: number, width: number, height: number): void;
17
+ drawText(options: OasisPdfTextOptions): void;
18
+ private emitTextBlock;
19
+ drawImage(options: OasisPdfImageOptions): void;
20
+ }
@@ -0,0 +1,5 @@
1
+ import { OasisPdfPage } from './pdfTypes.js';
2
+ import { PdfFontTable } from './PdfFontTable.js';
3
+ import { PdfImageTable } from './PdfImageTable.js';
4
+
5
+ export declare function serializePdfDocument(pages: OasisPdfPage[], fonts: PdfFontTable, images: PdfImageTable): Uint8Array;
@@ -0,0 +1,38 @@
1
+ import { GlyphInfo, GlyphRun, PdfEmbeddableFont } from '../../../text/fonts/core/types.js';
2
+ import { AddPdfObject, OasisPdfFontResource, OasisPdfTextOptions, OasisPdfUnicodeFontResource } from './pdfTypes.js';
3
+
4
+ interface OasisPdfUnicodeFontState {
5
+ resource: OasisPdfUnicodeFontResource;
6
+ font: PdfEmbeddableFont;
7
+ usedGlyphs: Map<number, GlyphInfo>;
8
+ scale: number;
9
+ layoutCache: Map<string, GlyphRun>;
10
+ }
11
+ export declare class PdfFontTable {
12
+ private readonly fontResources;
13
+ private readonly unicodeFontStates;
14
+ private readonly usedFontResourceNames;
15
+ constructor(fontResources: OasisPdfFontResource[]);
16
+ registerFontResource(resource: OasisPdfFontResource): void;
17
+ /** Resolves the font resource a run uses and marks it as referenced. */
18
+ resolveAndMarkFontName(options: Pick<OasisPdfTextOptions, "bold" | "italic" | "fontResourceName">): string;
19
+ getUnicodeState(resourceName: string): OasisPdfUnicodeFontState | undefined;
20
+ /**
21
+ * Builds the glyph-show operator (`<...> Tj` or `[...] TJ`) for an embedded
22
+ * Unicode run, recording the glyphs used for subsetting. Returns `null` when
23
+ * the run produced no glyphs so the caller can skip emission entirely.
24
+ */
25
+ buildUnicodeShowCommand(state: OasisPdfUnicodeFontState, text: string): string | null;
26
+ /**
27
+ * Emits the font objects (base-14 dictionaries and embedded Unicode font
28
+ * programs) for every referenced resource and returns the `/Font` resource
29
+ * dictionary XML for page objects.
30
+ */
31
+ buildFontObjects(addObject: AddPdfObject): {
32
+ resourceXml: string;
33
+ };
34
+ private layoutUnicodeText;
35
+ private encodeUnicodeGlyphRun;
36
+ private addUnicodeFontObjects;
37
+ }
38
+ export {};
@@ -0,0 +1,12 @@
1
+ import { AddPdfObject, OasisPdfImageResource } from './pdfTypes.js';
2
+
3
+ export declare class PdfImageTable {
4
+ private readonly imageResources;
5
+ registerImageResource(resource: Omit<OasisPdfImageResource, "resourceName"> & {
6
+ resourceName?: string;
7
+ }): string;
8
+ has(resourceName: string): boolean;
9
+ /** Emits each registered image object, keyed by resource name for page maps. */
10
+ buildImageObjects(addObject: AddPdfObject): Map<string, number>;
11
+ private addImageObject;
12
+ }
@@ -0,0 +1,20 @@
1
+ import { OasisPdfFontResource, OasisPdfTextOptions } from './pdfTypes.js';
2
+
3
+ export declare const PDF_HEADER = "%PDF-1.4\n% Oasis PDF\n";
4
+ export declare const DEFAULT_PDF_FONT_RESOURCES: OasisPdfFontResource[];
5
+ export declare function formatNumber(value: number): string;
6
+ export declare function byteLength(value: string): number;
7
+ export declare function bytesToHex(bytes: Uint8Array): string;
8
+ export declare function toHex16(value: number): string;
9
+ export declare function colorCommand(color: string | undefined, operator: "rg" | "RG", fallback: [number, number, number]): string;
10
+ export declare function resolveFontName(options: Pick<OasisPdfTextOptions, "bold" | "italic" | "fontResourceName">): string;
11
+ export declare function fontResourceObjectBody(resource: OasisPdfFontResource): string;
12
+ export declare function sanitizePdfName(value: string | undefined, fallback: string): string;
13
+ export declare function encodePdfHexString(value: string): string;
14
+ export declare function encodePdfUtf16Hex(codePoints: number[]): string;
15
+ export declare function buildToUnicodeCMap(unicode: number[][]): string;
16
+ export declare function streamObjectBody(stream: string, extraDictionary?: string): string;
17
+ export declare function asciiHexStreamObjectBody(bytes: Uint8Array, extraDictionary?: string): string;
18
+ export declare function asciiHexImageStreamObjectBody(bytes: Uint8Array, dictionaryEntries: string[]): string;
19
+ export declare function encodeGlyphHex(glyphId: number): string;
20
+ export declare function textMarkerComment(value: string): string;
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Public value/option types for the PDF writer. These are the interfaces that
3
+ * callers across `src/export/pdf` (and the font registry) depend on; the
4
+ * `OasisPdfWriter` facade re-exports them so existing import paths keep working.
5
+ */
6
+ export interface OasisPdfPageSize {
7
+ width: number;
8
+ height: number;
9
+ }
10
+ export interface OasisPdfPage {
11
+ width: number;
12
+ height: number;
13
+ commands: string[];
14
+ imageResourceNames: Set<string>;
15
+ }
16
+ export interface OasisPdfRectOptions {
17
+ x: number;
18
+ y: number;
19
+ width: number;
20
+ height: number;
21
+ fill?: string;
22
+ stroke?: string;
23
+ lineWidth?: number;
24
+ }
25
+ export interface OasisPdfLineOptions {
26
+ x1: number;
27
+ y1: number;
28
+ x2: number;
29
+ y2: number;
30
+ stroke?: string;
31
+ lineWidth?: number;
32
+ dashArray?: number[];
33
+ }
34
+ export type OasisPdfPathSegment = {
35
+ type: "move";
36
+ x: number;
37
+ y: number;
38
+ } | {
39
+ type: "line";
40
+ x: number;
41
+ y: number;
42
+ } | {
43
+ type: "cubic";
44
+ x1: number;
45
+ y1: number;
46
+ x2: number;
47
+ y2: number;
48
+ x: number;
49
+ y: number;
50
+ } | {
51
+ type: "close";
52
+ };
53
+ export interface OasisPdfPathOptions {
54
+ segments: OasisPdfPathSegment[];
55
+ fill?: string;
56
+ stroke?: string;
57
+ lineWidth?: number;
58
+ }
59
+ export interface OasisPdfTextOptions {
60
+ x: number;
61
+ y: number;
62
+ text: string;
63
+ fontSize?: number;
64
+ color?: string;
65
+ bold?: boolean;
66
+ italic?: boolean;
67
+ fontResourceName?: string;
68
+ characterSpacing?: number;
69
+ horizontalScale?: number;
70
+ /** PDF text render mode (`Tr`): 0 fill (default), 1 stroke, 2 fill+stroke. */
71
+ renderMode?: number;
72
+ }
73
+ export interface OasisPdfImageResource {
74
+ resourceName: string;
75
+ width: number;
76
+ height: number;
77
+ data: Uint8Array;
78
+ filter: "DCTDecode";
79
+ }
80
+ export interface OasisPdfImageOptions {
81
+ resourceName: string;
82
+ x: number;
83
+ y: number;
84
+ width: number;
85
+ height: number;
86
+ rotation?: number;
87
+ }
88
+ export type OasisPdfFontResource = OasisPdfBase14FontResource | OasisPdfUnicodeFontResource;
89
+ export interface OasisPdfBase14FontResource {
90
+ kind: "base14";
91
+ resourceName: string;
92
+ baseFont: string;
93
+ }
94
+ export interface OasisPdfUnicodeFontResource {
95
+ kind: "unicode";
96
+ resourceName: string;
97
+ family: string;
98
+ fontData: Uint8Array;
99
+ postscriptName?: string;
100
+ }
101
+ /** A serialized indirect PDF object: its 1-based id and dictionary/stream body. */
102
+ export interface PdfObject {
103
+ id: number;
104
+ body: string;
105
+ }
106
+ /** Signature of the object-appending closure used during serialization. */
107
+ export type AddPdfObject = (body: string) => number;
@@ -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;