oasis-editor 0.0.58 → 0.0.60

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.
@@ -1,158 +1,6 @@
1
- import { EditorEditingZone, EditorLayoutParagraph, EditorParagraphNode, EditorPosition, EditorState } from '../../core/model.js';
2
- import { CanvasUnsupportedReason } from './CanvasTableLayout.js';
3
- import { VerticalRenderMode } from './verticalText.js';
1
+ import { CanvasLayoutSnapshot, BuildCanvasLayoutSnapshotOptions } from './canvasSnapshotTypes.js';
4
2
 
5
- export interface CanvasSnapshotSlot {
6
- offset: number;
7
- left: number;
8
- top: number;
9
- height: number;
10
- }
11
- export interface CanvasSnapshotLine {
12
- startOffset: number;
13
- endOffset: number;
14
- top: number;
15
- height: number;
16
- slots: CanvasSnapshotSlot[];
17
- }
18
- export interface CanvasSnapshotTableCellInfo {
19
- tableId: string;
20
- rowIndex: number;
21
- cellIndex: number;
22
- left: number;
23
- top: number;
24
- width: number;
25
- height: number;
26
- anchorPosition: EditorPosition;
27
- }
28
- export interface CanvasSnapshotParagraph {
29
- paragraph: EditorParagraphNode;
30
- paragraphId: string;
31
- paragraphIndex: number;
32
- zone: EditorEditingZone;
33
- footnoteId?: string;
34
- pageIndex: number;
35
- startOffset: number;
36
- endOffset: number;
37
- textLength: number;
38
- left: number;
39
- top: number;
40
- width: number;
41
- height: number;
42
- lines: CanvasSnapshotLine[];
43
- tableCell?: CanvasSnapshotTableCellInfo;
44
- /** Set when the paragraph is painted with a vertical-text transform. */
45
- verticalMode?: VerticalRenderMode;
46
- }
47
- export interface CanvasSnapshotInlineImage {
48
- paragraphId: string;
49
- paragraphIndex: number;
50
- zone: EditorEditingZone;
51
- footnoteId?: string;
52
- pageIndex: number;
53
- startOffset: number;
54
- endOffset: number;
55
- left: number;
56
- top: number;
57
- width: number;
58
- height: number;
59
- /** Shape rotation in degrees, when rotated. */
60
- rotation?: number;
61
- }
62
- export interface CanvasSnapshotFloatingTextBox {
63
- paragraphId: string;
64
- paragraphIndex: number;
65
- zone: EditorEditingZone;
66
- footnoteId?: string;
67
- pageIndex: number;
68
- startOffset: number;
69
- endOffset: number;
70
- left: number;
71
- top: number;
72
- width: number;
73
- height: number;
74
- /** Shape rotation in degrees, when rotated. */
75
- rotation?: number;
76
- /** True when the object is painted behind the text (`behindDoc`). */
77
- behindDoc?: boolean;
78
- }
79
- export interface CanvasSnapshotFloatingImage {
80
- paragraphId: string;
81
- paragraphIndex: number;
82
- zone: EditorEditingZone;
83
- footnoteId?: string;
84
- pageIndex: number;
85
- startOffset: number;
86
- endOffset: number;
87
- left: number;
88
- top: number;
89
- width: number;
90
- height: number;
91
- /** Shape rotation in degrees, when rotated. */
92
- rotation?: number;
93
- /** True when the object is painted behind the text (`behindDoc`). */
94
- behindDoc?: boolean;
95
- }
96
- export interface CanvasSnapshotInlineTextBox {
97
- paragraphId: string;
98
- paragraphIndex: number;
99
- zone: EditorEditingZone;
100
- footnoteId?: string;
101
- pageIndex: number;
102
- startOffset: number;
103
- endOffset: number;
104
- left: number;
105
- top: number;
106
- width: number;
107
- height: number;
108
- /** Shape rotation in degrees, when rotated. */
109
- rotation?: number;
110
- }
111
- export interface CanvasSnapshotPage {
112
- index: number;
113
- left: number;
114
- top: number;
115
- width: number;
116
- height: number;
117
- bodyTop: number;
118
- bodyBottom: number;
119
- footerTop?: number;
120
- footnoteTop?: number;
121
- footnoteSeparatorTop?: number;
122
- }
123
- export interface CanvasLayoutSnapshot {
124
- surfaceRect: DOMRect;
125
- pages: CanvasSnapshotPage[];
126
- paragraphs: CanvasSnapshotParagraph[];
127
- paragraphsById: Map<string, CanvasSnapshotParagraph[]>;
128
- inlineImages: CanvasSnapshotInlineImage[];
129
- floatingImages: CanvasSnapshotFloatingImage[];
130
- inlineTextBoxes: CanvasSnapshotInlineTextBox[];
131
- floatingTextBoxes: CanvasSnapshotFloatingTextBox[];
132
- unsupportedRegions: Array<{
133
- pageIndex: number;
134
- zone: EditorEditingZone;
135
- footnoteId?: string;
136
- left: number;
137
- top: number;
138
- width: number;
139
- height: number;
140
- reason: CanvasUnsupportedReason;
141
- }>;
142
- }
143
- export interface BuildCanvasLayoutSnapshotOptions {
144
- surface: HTMLElement;
145
- state: EditorState;
146
- measuredBlockHeights?: Record<string, number>;
147
- measuredParagraphLayouts?: Record<string, EditorLayoutParagraph>;
148
- /**
149
- * Visual zoom factor (CSS `transform: scale(z)`) applied to the surface. The
150
- * snapshot is built in "screen-anchored local" space so it is invariant under
151
- * zoom — see the coordinate contract documented on buildCanvasLayoutSnapshot.
152
- * Defaults to 1 (no zoom).
153
- */
154
- zoomFactor?: number;
155
- }
3
+ export type { ResolveTextBoxRenderHeight, CanvasSnapshotSlot, CanvasSnapshotLine, CanvasSnapshotTableCellInfo, CanvasSnapshotParagraph, CanvasSnapshotInlineImage, CanvasSnapshotFloatingTextBox, CanvasSnapshotFloatingImage, CanvasSnapshotInlineTextBox, CanvasSnapshotPage, CanvasLayoutSnapshot, BuildCanvasLayoutSnapshotOptions, } from './canvasSnapshotTypes.js';
156
4
  /**
157
5
  * Coordinate contract ("screen-anchored local" space)
158
6
  * ----------------------------------------------------
@@ -0,0 +1,156 @@
1
+ import { EditorEditingZone, EditorLayoutParagraph, EditorParagraphNode, EditorPosition, EditorState, EditorTextBoxData } from '../../core/model.js';
2
+ import { CanvasUnsupportedReason } from './CanvasTableLayout.js';
3
+ import { VerticalRenderMode } from './verticalText.js';
4
+
5
+ export type ResolveTextBoxRenderHeight = (textBox: EditorTextBoxData) => number;
6
+ export interface CanvasSnapshotSlot {
7
+ offset: number;
8
+ left: number;
9
+ top: number;
10
+ height: number;
11
+ }
12
+ export interface CanvasSnapshotLine {
13
+ startOffset: number;
14
+ endOffset: number;
15
+ top: number;
16
+ height: number;
17
+ slots: CanvasSnapshotSlot[];
18
+ }
19
+ export interface CanvasSnapshotTableCellInfo {
20
+ tableId: string;
21
+ rowIndex: number;
22
+ cellIndex: number;
23
+ left: number;
24
+ top: number;
25
+ width: number;
26
+ height: number;
27
+ anchorPosition: EditorPosition;
28
+ }
29
+ export interface CanvasSnapshotParagraph {
30
+ paragraph: EditorParagraphNode;
31
+ paragraphId: string;
32
+ paragraphIndex: number;
33
+ zone: EditorEditingZone;
34
+ footnoteId?: string;
35
+ pageIndex: number;
36
+ startOffset: number;
37
+ endOffset: number;
38
+ textLength: number;
39
+ left: number;
40
+ top: number;
41
+ width: number;
42
+ height: number;
43
+ lines: CanvasSnapshotLine[];
44
+ tableCell?: CanvasSnapshotTableCellInfo;
45
+ /** Set when the paragraph is painted with a vertical-text transform. */
46
+ verticalMode?: VerticalRenderMode;
47
+ }
48
+ export interface CanvasSnapshotInlineImage {
49
+ paragraphId: string;
50
+ paragraphIndex: number;
51
+ zone: EditorEditingZone;
52
+ footnoteId?: string;
53
+ pageIndex: number;
54
+ startOffset: number;
55
+ endOffset: number;
56
+ left: number;
57
+ top: number;
58
+ width: number;
59
+ height: number;
60
+ /** Shape rotation in degrees, when rotated. */
61
+ rotation?: number;
62
+ }
63
+ export interface CanvasSnapshotFloatingTextBox {
64
+ paragraphId: string;
65
+ paragraphIndex: number;
66
+ zone: EditorEditingZone;
67
+ footnoteId?: string;
68
+ pageIndex: number;
69
+ startOffset: number;
70
+ endOffset: number;
71
+ left: number;
72
+ top: number;
73
+ width: number;
74
+ height: number;
75
+ /** Shape rotation in degrees, when rotated. */
76
+ rotation?: number;
77
+ /** True when the object is painted behind the text (`behindDoc`). */
78
+ behindDoc?: boolean;
79
+ }
80
+ export interface CanvasSnapshotFloatingImage {
81
+ paragraphId: string;
82
+ paragraphIndex: number;
83
+ zone: EditorEditingZone;
84
+ footnoteId?: string;
85
+ pageIndex: number;
86
+ startOffset: number;
87
+ endOffset: number;
88
+ left: number;
89
+ top: number;
90
+ width: number;
91
+ height: number;
92
+ /** Shape rotation in degrees, when rotated. */
93
+ rotation?: number;
94
+ /** True when the object is painted behind the text (`behindDoc`). */
95
+ behindDoc?: boolean;
96
+ }
97
+ export interface CanvasSnapshotInlineTextBox {
98
+ paragraphId: string;
99
+ paragraphIndex: number;
100
+ zone: EditorEditingZone;
101
+ footnoteId?: string;
102
+ pageIndex: number;
103
+ startOffset: number;
104
+ endOffset: number;
105
+ left: number;
106
+ top: number;
107
+ width: number;
108
+ height: number;
109
+ /** Shape rotation in degrees, when rotated. */
110
+ rotation?: number;
111
+ }
112
+ export interface CanvasSnapshotPage {
113
+ index: number;
114
+ left: number;
115
+ top: number;
116
+ width: number;
117
+ height: number;
118
+ bodyTop: number;
119
+ bodyBottom: number;
120
+ footerTop?: number;
121
+ footnoteTop?: number;
122
+ footnoteSeparatorTop?: number;
123
+ }
124
+ export interface CanvasLayoutSnapshot {
125
+ surfaceRect: DOMRect;
126
+ pages: CanvasSnapshotPage[];
127
+ paragraphs: CanvasSnapshotParagraph[];
128
+ paragraphsById: Map<string, CanvasSnapshotParagraph[]>;
129
+ inlineImages: CanvasSnapshotInlineImage[];
130
+ floatingImages: CanvasSnapshotFloatingImage[];
131
+ inlineTextBoxes: CanvasSnapshotInlineTextBox[];
132
+ floatingTextBoxes: CanvasSnapshotFloatingTextBox[];
133
+ unsupportedRegions: Array<{
134
+ pageIndex: number;
135
+ zone: EditorEditingZone;
136
+ footnoteId?: string;
137
+ left: number;
138
+ top: number;
139
+ width: number;
140
+ height: number;
141
+ reason: CanvasUnsupportedReason;
142
+ }>;
143
+ }
144
+ export interface BuildCanvasLayoutSnapshotOptions {
145
+ surface: HTMLElement;
146
+ state: EditorState;
147
+ measuredBlockHeights?: Record<string, number>;
148
+ measuredParagraphLayouts?: Record<string, EditorLayoutParagraph>;
149
+ /**
150
+ * Visual zoom factor (CSS `transform: scale(z)`) applied to the surface. The
151
+ * snapshot is built in "screen-anchored local" space so it is invariant under
152
+ * zoom — see the coordinate contract documented on buildCanvasLayoutSnapshot.
153
+ * Defaults to 1 (no zoom).
154
+ */
155
+ zoomFactor?: number;
156
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oasis-editor",
3
- "version": "0.0.58",
3
+ "version": "0.0.60",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",