oasis-editor 0.0.88 → 0.0.90

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.
Files changed (39) hide show
  1. package/dist/{OasisEditorApp-Bx4I4GCm.js → OasisEditorApp-2b7y3aGj.js} +1996 -646
  2. package/dist/assets/{importDocxWorker-BcELKms0.js → importDocxWorker-BN5o1geV.js} +1 -1
  3. package/dist/core/commands/table/tableCommandUtils.d.ts +2 -1
  4. package/dist/core/commands/table/tableFloatingCommands.d.ts +5 -0
  5. package/dist/core/commands/table.d.ts +1 -0
  6. package/dist/core/model/index.d.ts +2 -2
  7. package/dist/core/model/types/layout.d.ts +4 -0
  8. package/dist/core/model/types/nodes.d.ts +23 -7
  9. package/dist/core/model/types/primitives.d.ts +19 -0
  10. package/dist/core/model/types/styles.d.ts +63 -6
  11. package/dist/core/model.d.ts +1 -0
  12. package/dist/core/tableStyleResolver.d.ts +20 -0
  13. package/dist/export/docx/tableXml.d.ts +1 -0
  14. package/dist/export/pdf/OasisPdfWriter.d.ts +6 -102
  15. package/dist/export/pdf/draw/drawFragment.d.ts +15 -1
  16. package/dist/export/pdf/draw/drawTextBoxShape.d.ts +1 -0
  17. package/dist/export/pdf/writer/PdfContentStream.d.ts +20 -0
  18. package/dist/export/pdf/writer/PdfDocumentSerializer.d.ts +5 -0
  19. package/dist/export/pdf/writer/PdfFontTable.d.ts +38 -0
  20. package/dist/export/pdf/writer/PdfImageTable.d.ts +12 -0
  21. package/dist/export/pdf/writer/pdfPrimitives.d.ts +20 -0
  22. package/dist/export/pdf/writer/pdfTypes.d.ts +107 -0
  23. package/dist/i18n/locales/en.d.ts +18 -0
  24. package/dist/i18n/locales/pt-BR.d.ts +18 -0
  25. package/dist/import/docx/tableProperties.d.ts +2 -1
  26. package/dist/import/docx/tables.d.ts +1 -1
  27. package/dist/{index-Ds5uOUe8.js → index-DcElQi6c.js} +1946 -1204
  28. package/dist/layoutProjection/floatingObjects.d.ts +15 -1
  29. package/dist/layoutProjection/paginationTrack.d.ts +2 -0
  30. package/dist/layoutProjection/paragraphPagination.d.ts +2 -2
  31. package/dist/oasis-editor.js +50 -50
  32. package/dist/oasis-editor.umd.cjs +4 -4
  33. package/dist/ui/canvas/CanvasLayoutSnapshot.d.ts +1 -1
  34. package/dist/ui/canvas/CanvasTableLayout.d.ts +7 -1
  35. package/dist/ui/canvas/canvasBorders.d.ts +2 -0
  36. package/dist/ui/canvas/canvasSnapshotTypes.d.ts +12 -0
  37. package/dist/ui/components/Dialogs/TablePropertiesDialog.d.ts +22 -1
  38. package/dist/ui/editorUiTypes.d.ts +1 -1
  39. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { EditorBlockNode, EditorDocument, EditorEditingZone, EditorState, EditorTableNode, TableLocation } from '../../model.js';
1
+ import { EditorBlockNode, EditorDocument, EditorEditingZone, EditorState, EditorTableNode, TableLocation, EditorRevisionMetadata } from '../../model.js';
2
2
 
3
3
  export type StylePatchValue<T, K extends keyof T> = T[K] | null;
4
4
  export interface ActiveTableLocation {
@@ -7,6 +7,7 @@ export interface ActiveTableLocation {
7
7
  zone: EditorEditingZone;
8
8
  };
9
9
  }
10
+ export declare function createTableRevisionMetadata(): EditorRevisionMetadata;
10
11
  export declare function patchStyleValue<T extends object, K extends keyof T>(style: T | undefined, key: K, value: StylePatchValue<T, K>): T | undefined;
11
12
  export declare function updateStateSections(state: EditorState, updateBlocks: (blocks: EditorBlockNode[]) => EditorBlockNode[]): EditorState;
12
13
  export declare function updateTablesInBlocks(blocks: EditorBlockNode[], updateTable: (table: EditorTableNode) => EditorTableNode): EditorBlockNode[];
@@ -0,0 +1,5 @@
1
+ import { EditorState, EditorTableFloatingLayout } from '../../model.js';
2
+
3
+ export declare function setSelectedTableFloatingLayout(state: EditorState, floating: EditorTableFloatingLayout | null): EditorState;
4
+ export declare function setActiveTableFloatingLayout(state: EditorState, tableId: string, floating: EditorTableFloatingLayout | null): EditorState;
5
+ export declare function moveActiveFloatingTable(state: EditorState, tableId: string, deltaXPoints: number, deltaYPoints: number): EditorState;
@@ -3,3 +3,4 @@ export * from './table/tableStyleCommands.js';
3
3
  export * from './table/tableRowCommands.js';
4
4
  export * from './table/tableColumnCommands.js';
5
5
  export * from './table/insertTableCommand.js';
6
+ export * from './table/tableFloatingCommands.js';
@@ -6,8 +6,8 @@
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, EditorAsset, EditorFootnoteNumberFormat, EditorFootnoteRestart, EditorDocxWidthValue, EditorTableLayout, EditorTableRowHeightRule, } from './types/primitives.js';
10
- export type { EditorTextStyle, EditorParagraphStyle, EditorTableStyle, EditorTableConditionalFormat, EditorConditionalRowStyle, EditorNamedStyle, } from './types/styles.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, EditorNamedStyle, } from './types/styles.js';
11
11
  export type { EditorRunBase, EditorTextRun, EditorTextBoxShape, EditorTextBoxBody, EditorTextBoxData, EditorDropCap, EditorParagraphNode, EditorTableCellStyle, 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';
@@ -53,6 +53,10 @@ export interface EditorLayoutBlock {
53
53
  paragraphId?: string;
54
54
  globalIndex: number;
55
55
  estimatedHeight: number;
56
+ /** Measured visual height for a zero-flow-height floating table. */
57
+ floatingTableHeight?: number;
58
+ /** Runtime collision displacement for `w:tblOverlap="never"`. */
59
+ floatingTableOffsetY?: number;
56
60
  layout?: EditorLayoutParagraph;
57
61
  tableSegment?: {
58
62
  startRowIndex: number;
@@ -1,5 +1,5 @@
1
- import { EditorBorderStyle, EditorDocxWidthValue, EditorEndnoteReferenceData, EditorFieldChar, EditorFieldData, EditorFootnoteReferenceData, EditorImageFloatingLayout, EditorImageRunData, EditorParagraphListStyle, EditorRevision, EditorTableRowHeightRule } from './primitives.js';
2
- import { EditorParagraphStyle, EditorTableStyle, EditorTextStyle } from './styles.js';
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';
3
3
 
4
4
  /**
5
5
  * Geometry/appearance of a text box shape (`wps:spPr`). All values are
@@ -186,8 +186,10 @@ export interface EditorTableCellStyle {
186
186
  hideMark?: boolean;
187
187
  /** `w:headers/@w:val`: semantic header cell references. */
188
188
  headers?: string;
189
- /** Preservation-only table-cell revision/property XML children. */
190
- revisionXml?: string[];
189
+ /** Structural `cellIns`/`cellDel`/`cellMerge` revision. */
190
+ revision?: EditorStructuralRevision;
191
+ /** Previous cell properties from `w:tcPrChange`. */
192
+ propertyRevision?: EditorPropertyRevision<EditorTableCellStyle>;
191
193
  }
192
194
  export interface EditorTableCellNode {
193
195
  id: string;
@@ -196,8 +198,19 @@ export interface EditorTableCellNode {
196
198
  rowSpan?: number;
197
199
  vMerge?: "restart" | "continue";
198
200
  style?: EditorTableCellStyle;
201
+ conditionalStyle?: EditorTableConditionalFlags;
202
+ /** Exact pre-change cell grid retained while a tracked merge/split is pending. */
203
+ mergeRevisionState?: EditorTableMergeRevisionState;
204
+ }
205
+ export interface EditorTableMergeRevisionState {
206
+ revisionId: string;
207
+ orientation: "horizontal" | "vertical";
208
+ /** Number of cells occupying the changed horizontal range in current markup. */
209
+ currentCellCount: number;
210
+ previousCells: EditorTableCellNode[];
199
211
  }
200
212
  export interface EditorTableRowStyle {
213
+ isHeader?: boolean;
201
214
  height?: number | string;
202
215
  heightRule?: EditorTableRowHeightRule;
203
216
  gridBefore?: number;
@@ -210,14 +223,17 @@ export interface EditorTableRowStyle {
210
223
  hidden?: boolean;
211
224
  /** Row-level cell spacing override (`w:trPr/w:tblCellSpacing`). */
212
225
  cellSpacing?: EditorDocxWidthValue;
213
- /** Preservation-only row revision/property XML children. */
214
- revisionXml?: string[];
226
+ /** Structural row `w:ins`/`w:del` revision. */
227
+ revision?: EditorStructuralRevision;
228
+ /** Previous row properties from `w:trPrChange`. */
229
+ propertyRevision?: EditorPropertyRevision<EditorTableRowStyle>;
215
230
  }
216
231
  export interface EditorTableRowNode {
217
232
  id: string;
218
233
  cells: EditorTableCellNode[];
219
234
  isHeader?: boolean;
220
235
  style?: EditorTableRowStyle;
236
+ conditionalStyle?: EditorTableConditionalFlags;
221
237
  /**
222
238
  * Raw w:tblPrEx XML (per-row table property exceptions), serialized verbatim
223
239
  * before w:trPr. Preserved for DOCX round-trip fidelity only; not editable.
@@ -231,6 +247,6 @@ export interface EditorTableNode {
231
247
  gridCols?: number[];
232
248
  style?: EditorTableStyle;
233
249
  /** Preservation-only `w:tblGridChange` XML. */
234
- tblGridChangeXml?: string;
250
+ gridRevision?: EditorPropertyRevision<number[]>;
235
251
  }
236
252
  export type EditorBlockNode = EditorParagraphNode | EditorTableNode;
@@ -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";
@@ -136,6 +138,23 @@ export interface EditorRevision {
136
138
  author: string;
137
139
  date: number;
138
140
  }
141
+ export interface EditorRevisionMetadata {
142
+ id: string;
143
+ author: string;
144
+ date: number;
145
+ }
146
+ export interface EditorStructuralRevision extends EditorRevisionMetadata {
147
+ type: "insert" | "delete" | "merge";
148
+ previous?: {
149
+ colSpan?: number;
150
+ rowSpan?: number;
151
+ vMerge?: "restart" | "continue";
152
+ };
153
+ }
154
+ export interface EditorPropertyRevision<T> extends EditorRevisionMetadata {
155
+ type: "property" | "grid";
156
+ previous: T;
157
+ }
139
158
  export interface EditorAsset {
140
159
  id: string;
141
160
  url: string;
@@ -1,4 +1,5 @@
1
- import { EditorBorderStyle, EditorDocxWidthValue, EditorLigatures, EditorNumberForm, EditorNumberSpacing, EditorTabStop, EditorTextLanguage, EditorUnderlineStyle } from './primitives.js';
1
+ import { EditorBorderStyle, EditorDocxWidthValue, EditorEmphasisMark, EditorLigatures, EditorNumberForm, EditorNumberSpacing, EditorPropertyRevision, EditorTabStop, EditorTextLanguage, EditorUnderlineStyle } from './primitives.js';
2
+ import { EditorTableCellStyle } from './nodes.js';
2
3
 
3
4
  export interface EditorTextStyle {
4
5
  styleId?: string;
@@ -17,6 +18,26 @@ export interface EditorTextStyle {
17
18
  noProof?: boolean;
18
19
  webHidden?: boolean;
19
20
  specVanish?: boolean;
21
+ /** `w:rtl`: run flows right-to-left. */
22
+ rtl?: boolean;
23
+ /** `w:cs`: run is complex-script text. */
24
+ complexScript?: boolean;
25
+ /** `w:snapToGrid` (run): snap characters to the document grid. Defaults on. */
26
+ snapToGrid?: boolean;
27
+ /** `w:fitText`: compress/expand the run to this target width (in pt). */
28
+ fitText?: number | null;
29
+ /** `w:em`: emphasis mark drawn above (or below for `underDot`) each glyph. */
30
+ emphasisMark?: EditorEmphasisMark | null;
31
+ /** `w:bdr`: border box drawn around the run's text. */
32
+ textBorder?: EditorBorderStyle | null;
33
+ /** `w:outline`: hollow/outlined glyphs. */
34
+ outline?: boolean;
35
+ /** `w:shadow`: drop shadow behind glyphs. */
36
+ shadow?: boolean;
37
+ /** `w:emboss`: raised (embossed) glyphs. */
38
+ emboss?: boolean;
39
+ /** `w:imprint`: engraved glyphs. */
40
+ imprint?: boolean;
20
41
  textEffect?: string | null;
21
42
  characterScale?: number | null;
22
43
  characterSpacing?: number | null;
@@ -73,6 +94,7 @@ export interface EditorParagraphStyle {
73
94
  }
74
95
  /** Row properties from a conditional format's `w:trPr`. */
75
96
  export interface EditorConditionalRowStyle {
97
+ isHeader?: boolean;
76
98
  height?: number | string;
77
99
  heightRule?: "auto" | "exact" | "atLeast";
78
100
  cantSplit?: boolean;
@@ -93,6 +115,32 @@ export interface EditorTableConditionalFormat {
93
115
  paragraphStyle?: EditorParagraphStyle;
94
116
  /** Row properties from the conditional's `w:trPr`. */
95
117
  rowStyle?: EditorConditionalRowStyle;
118
+ /** Full cell properties from conditional `w:tcPr`. */
119
+ cellStyle?: EditorTableCellStyle;
120
+ /** Conditional table properties from `w:tblPr`. */
121
+ tableStyle?: EditorTableStyle;
122
+ }
123
+ export type EditorTableConditionalType = "wholeTable" | "band1Horz" | "band2Horz" | "band1Vert" | "band2Vert" | "firstCol" | "lastCol" | "firstRow" | "lastRow" | "nwCell" | "neCell" | "swCell" | "seCell";
124
+ export type EditorTableConditionalFlags = Partial<Record<EditorTableConditionalType, boolean>>;
125
+ /** Typed `w:tblpPr` positioning for a table whose text wrapping is "around". */
126
+ export interface EditorTableFloatingLayout {
127
+ /** Horizontal positioning reference (`w:horzAnchor`). */
128
+ horizontalAnchor?: "margin" | "page" | "text";
129
+ /** Vertical positioning reference (`w:vertAnchor`). */
130
+ verticalAnchor?: "margin" | "page" | "text";
131
+ /** Explicit horizontal offset in points (`w:tblpX`, originally twips). */
132
+ x?: number;
133
+ /** Explicit vertical offset in points (`w:tblpY`, originally twips). */
134
+ y?: number;
135
+ /** Aligned horizontal position (`w:tblpXSpec`). */
136
+ xAlign?: "left" | "center" | "right" | "inside" | "outside";
137
+ /** Aligned vertical position (`w:tblpYSpec`). */
138
+ yAlign?: "top" | "center" | "bottom" | "inside" | "outside";
139
+ /** Text-wrap distances in points. */
140
+ distanceTop?: number;
141
+ distanceRight?: number;
142
+ distanceBottom?: number;
143
+ distanceLeft?: number;
96
144
  }
97
145
  export interface EditorTableStyle {
98
146
  styleId?: string;
@@ -101,11 +149,19 @@ export interface EditorTableStyle {
101
149
  indentLeft?: EditorDocxWidthValue;
102
150
  layout?: "fixed" | "autofit";
103
151
  cellSpacing?: EditorDocxWidthValue;
152
+ borders?: {
153
+ borderTop?: EditorBorderStyle;
154
+ borderRight?: EditorBorderStyle;
155
+ borderBottom?: EditorBorderStyle;
156
+ borderLeft?: EditorBorderStyle;
157
+ borderInsideH?: EditorBorderStyle;
158
+ borderInsideV?: EditorBorderStyle;
159
+ };
104
160
  pageBreakBefore?: boolean;
105
161
  /** `w:bidiVisual`: visually order table columns right-to-left. */
106
162
  bidiVisual?: boolean;
107
163
  /** `w:tblOverlap/@w:val`: floating-table overlap behavior. */
108
- tblOverlap?: string;
164
+ tblOverlap?: "overlap" | "never";
109
165
  /** `w:tblCellMar`: default margins for cells unless overridden by `w:tcMar`. */
110
166
  defaultCellMargins?: {
111
167
  top?: number;
@@ -115,14 +171,14 @@ export interface EditorTableStyle {
115
171
  start?: number;
116
172
  end?: number;
117
173
  };
118
- /** Raw `w:tblpPr` attributes for floating table round-trip preservation. */
119
- floating?: Record<string, string>;
174
+ /** Typed `w:tblpPr` floating-table position and wrap distances. */
175
+ floating?: EditorTableFloatingLayout;
120
176
  /** Table alt text title, corresponding to Word's table properties Alt Text title. */
121
177
  altTitle?: string;
122
178
  /** Table alt text description, corresponding to Word's table properties Alt Text description. */
123
179
  altDescription?: string;
124
- /** Preservation-only table revision/property XML children. */
125
- revisionXml?: string[];
180
+ /** Previous table properties from `w:tblPrChange`. */
181
+ revision?: EditorPropertyRevision<EditorTableStyle>;
126
182
  /** `w:tblStyleRowBandSize` — rows per horizontal band (default 1). */
127
183
  rowBandSize?: number;
128
184
  /** `w:tblStyleColBandSize` — columns per vertical band (default 1). */
@@ -143,6 +199,7 @@ export interface EditorNamedStyle {
143
199
  id: string;
144
200
  name: string;
145
201
  type: "paragraph" | "character" | "table";
202
+ isDefault?: boolean;
146
203
  basedOn?: string;
147
204
  nextStyle?: string;
148
205
  /** Word quick-style gallery metadata (`w:qFormat`). */
@@ -8,3 +8,4 @@
8
8
  * without any change.
9
9
  */
10
10
  export * from './model/index.js';
11
+ export * from './tableStyleResolver.js';
@@ -0,0 +1,20 @@
1
+ import { EditorNamedStyle, EditorParagraphStyle, EditorTableCellStyle, EditorTableNode, EditorTableRowStyle, EditorTableStyle, EditorTextStyle } from './model.js';
2
+
3
+ export interface ResolvedTableCellFormatting {
4
+ tableStyle: EditorTableStyle;
5
+ rowStyle: EditorTableRowStyle;
6
+ cellStyle: EditorTableCellStyle;
7
+ paragraphStyle?: EditorParagraphStyle;
8
+ textStyle?: EditorTextStyle;
9
+ conditionalKeys: string[];
10
+ }
11
+ export declare function resolveEffectiveTableStyle(table: EditorTableNode, styles?: Record<string, EditorNamedStyle>): EditorTableStyle;
12
+ export declare function resolveTableParagraphInheritance(tableStyle: EditorParagraphStyle | undefined, paragraphStyleId: string | undefined, styles: Record<string, EditorNamedStyle> | undefined): EditorParagraphStyle | undefined;
13
+ export declare function resolveEffectiveTableCellFormatting(options: {
14
+ table: EditorTableNode;
15
+ rowIndex: number;
16
+ cellIndex: number;
17
+ visualColumnIndex: number;
18
+ columnCount: number;
19
+ styles?: Record<string, EditorNamedStyle>;
20
+ }): ResolvedTableCellFormatting;
@@ -1,6 +1,7 @@
1
1
  import { EditorParagraphNode, EditorTableCellNode, EditorTableNode, EditorTableRowStyle } from '../../core/model.js';
2
2
 
3
3
  export type SerializeTableParagraphXml = (paragraph: EditorParagraphNode, cell: EditorTableCellNode) => string;
4
+ export declare function serializeTableCellStyleXml(style: EditorTableCellNode["style"]): string;
4
5
  /**
5
6
  * Serializes the core row style properties into `<w:trPr>` inner XML.
6
7
  * Used for style definitions (styles.xml) as well as per-row serialization.
@@ -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
  }
@@ -1,9 +1,23 @@
1
- import { EditorDocument, EditorLayoutFragment, EditorLayoutLine, EditorParagraphNode, EditorTextStyle } from '../../../core/model.js';
1
+ import { EditorDocument, EditorLayoutFragment, EditorLayoutLine, EditorParagraphNode, EditorTextStyle, EditorPageSettings } from '../../../core/model.js';
2
2
  import { PdfFontRegistry } from '../fonts/PdfFontRegistry.js';
3
3
  import { BlockDrawers } from './blockDrawers.js';
4
4
  import { OasisPdfWriter } from '../OasisPdfWriter.js';
5
5
 
6
+ export declare function drawFloatingImagesForParagraph(options: {
7
+ writer: OasisPdfWriter;
8
+ pageIndex: number;
9
+ lines: EditorLayoutLine[];
10
+ document: EditorDocument;
11
+ pageSettings: EditorPageSettings;
12
+ contentLeft: number;
13
+ contentTop: number;
14
+ contentWidth: number;
15
+ paragraphTop: number;
16
+ layer: "behind" | "front";
17
+ }): Promise<void>;
6
18
  export declare function drawFragmentHighlight(writer: OasisPdfWriter, pageIndex: number, line: EditorLayoutLine, fragment: EditorLayoutFragment, originX: number, originY: number, styles: Required<EditorTextStyle>): void;
7
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;
8
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;
9
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>;
@@ -32,5 +32,6 @@ export declare function drawFloatingTextBoxesForParagraph(options: {
32
32
  contentWidth: number;
33
33
  paragraphTop: number;
34
34
  drawers: BlockDrawers;
35
+ layer?: "behind" | "front";
35
36
  }): Promise<void>;
36
37
  export {};
@@ -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;