@univerjs/engine-render 0.1.0-beta.2 → 0.1.0-beta.3

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.
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export declare class Break {
17
+ position: number;
18
+ required: boolean;
19
+ constructor(position: number, required?: boolean);
20
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { LineBreaker } from '../linebreaker';
17
+ export declare function tabLineBreakExtension(breaker: LineBreaker): void;
@@ -13,25 +13,29 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- declare class Break {
17
- position: number;
18
- required: boolean;
19
- constructor(position: number, required?: boolean);
16
+ import { Break } from './break';
17
+ import type { ILineBreakRule } from './rule';
18
+ interface ILineBreakExtension {
19
+ (breaker: LineBreaker): void;
20
20
  }
21
21
  export declare class LineBreaker {
22
22
  string: string;
23
- pos: number;
24
- lastPos: number;
25
- curClass: number | null;
26
- nextClass: number | null;
27
- LB8a: boolean;
28
- LB21a: boolean;
29
- LB30a: number;
23
+ private _pos;
24
+ private _lastPos;
25
+ private _curClass;
26
+ private _codePoint;
27
+ private _nextClass;
28
+ private _LB8a;
29
+ private _LB21a;
30
+ private _LB30a;
31
+ private _rule;
30
32
  constructor(string: string);
31
- nextCodePoint(): number;
32
- nextCharClass(): number;
33
- getSimpleBreak(): false | null;
34
- getPairTableBreak(lastClass: number): boolean;
33
+ use(extension: ILineBreakExtension): this;
34
+ addRule(key: string, rule: ILineBreakRule): this;
35
35
  nextBreak(): Break | null;
36
+ private _getNextCodePoint;
37
+ private _nextCharClass;
38
+ private _getSimpleBreak;
39
+ private _getPairTableBreak;
36
40
  }
37
41
  export {};
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export interface ILineBreakRule {
17
+ (codePoint: number, className: number): boolean;
18
+ }
19
+ export declare class Rule {
20
+ private _rules;
21
+ add(key: string, rule: ILineBreakRule): void;
22
+ shouldBreak(codePoint: number, className: number): boolean;
23
+ }
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import type { Nullable } from '@univerjs/core';
17
- import { RxDisposable } from '@univerjs/core';
17
+ import { ILogService, RxDisposable } from '@univerjs/core';
18
18
  import type { Observable } from 'rxjs';
19
19
  import type { IMouseEvent, IPointerEvent } from '../../basics/i-events';
20
20
  import type { INodePosition } from '../../basics/interfaces';
@@ -86,6 +86,7 @@ export interface IEditorInputConfig {
86
86
  rangeList?: TextRange[];
87
87
  }
88
88
  export declare class TextSelectionRenderManager extends RxDisposable implements ITextSelectionRenderManager {
89
+ private readonly _logService;
89
90
  private readonly _onInputBefore$;
90
91
  readonly onInputBefore$: Observable<Nullable<IEditorInputConfig>>;
91
92
  private readonly _onKeydown$;
@@ -122,7 +123,7 @@ export declare class TextSelectionRenderManager extends RxDisposable implements
122
123
  private _docSkeleton;
123
124
  private _scene;
124
125
  private _document;
125
- constructor();
126
+ constructor(_logService: ILogService);
126
127
  __getEditorContainer(): HTMLElement;
127
128
  getViewPort(): Viewport;
128
129
  setSegment(id: string): void;
@@ -154,7 +155,8 @@ export declare class TextSelectionRenderManager extends RxDisposable implements
154
155
  private _removeAllTextRanges;
155
156
  private _deactivateAllTextRanges;
156
157
  private _addTextRange;
157
- private _updateTextRangePosition;
158
+ private _updateTextRangeAnchorPosition;
159
+ private _updateActiveRangeFocusPosition;
158
160
  private _isEmpty;
159
161
  private _getCanvasOffset;
160
162
  private _scrollToSelection;
@@ -70,316 +70,201 @@ export declare class UniverRenderingContext2D implements CanvasRenderingContext2
70
70
  drawFocusIfNeeded(element: Element): void;
71
71
  drawFocusIfNeeded(path: Path2D, element: Element): void;
72
72
  /**
73
-
74
73
  * reset canvas context transform
75
-
76
74
  * @method
77
-
78
75
  */
79
76
  reset(): void;
80
77
  /**
81
-
82
78
  * arc function.
83
-
84
79
  * @method
85
-
86
80
  */
87
81
  arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, counterClockwise?: boolean): void;
88
82
  /**
89
-
90
83
  * arcTo function.
91
-
92
84
  * @method
93
-
94
85
  *
95
-
96
86
  */
97
87
  arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void;
98
88
  /**
99
-
100
89
  * beginPath function.
101
-
102
90
  * @method
103
-
104
91
  */
105
92
  beginPath(): void;
106
93
  /**
107
-
108
94
  * bezierCurveTo function.
109
-
110
95
  * @method
111
-
112
96
  */
113
97
  bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void;
114
98
  /**
115
-
116
99
  * clearRect function.
117
-
118
100
  * @method
119
-
120
101
  */
121
102
  clearRect(x: number, y: number, width: number, height: number): void;
122
103
  /**
123
-
124
104
  * clip function.
125
-
126
105
  * @method
127
-
128
106
  */
129
107
  clip(): void;
130
108
  clip(path: Path2D): void;
131
109
  clip(fillRule?: CanvasFillRule): void;
132
110
  clip(path: Path2D, fillRule?: CanvasFillRule): void;
133
111
  /**
134
-
135
112
  * closePath function.
136
-
137
113
  * @method
138
-
139
114
  */
140
115
  closePath(): void;
141
116
  /**
142
-
143
117
  * createImageData function.
144
-
145
118
  * @method
146
-
147
119
  */
148
120
  createImageData(width: number, height: number, settings?: ImageDataSettings): ImageData;
149
121
  createImageData(imagedata: ImageData): ImageData;
150
122
  /**
151
-
152
123
  * createLinearGradient function.
153
-
154
124
  * @method
155
-
156
125
  */
157
126
  createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient;
158
127
  /**
159
-
160
128
  * createPattern function.
161
-
162
129
  * @method
163
-
164
130
  */
165
131
  createPattern(image: CanvasImageSource, repetition: string | null): CanvasPattern | null;
166
132
  /**
167
-
168
133
  * createRadialGradient function.
169
-
170
134
  * @method
171
-
172
135
  */
173
136
  createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient;
174
137
  /**
175
-
176
138
  * drawImage function.
177
-
178
139
  * @method
179
-
180
140
  */
181
141
  drawImage(image: CanvasImageSource, sx: number, sy: number, sWidth?: number, sHeight?: number, dx?: number, dy?: number, dWidth?: number, dHeight?: number): void;
182
142
  /**
183
-
184
143
  * ellipse function.
185
-
186
144
  * @method
187
-
188
145
  */
189
146
  ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void;
190
147
  /**
191
-
192
148
  * isPointInPath function.
193
-
194
149
  * @method
195
-
196
150
  */
197
151
  isPointInPath(x: number, y: number, fillRule?: CanvasFillRule): boolean;
198
152
  isPointInPath(path: Path2D, x: number, y: number, fillRule?: CanvasFillRule): boolean;
199
153
  /**
200
-
201
154
  * fill function.
202
-
203
155
  * @method
204
-
205
156
  */
206
157
  fill(fillRule?: CanvasFillRule): void;
207
158
  fill(path: Path2D, fillRule?: CanvasFillRule): void;
208
159
  /**
209
-
210
160
  * fillRect function.
211
-
212
161
  * @method
213
-
214
162
  */
215
163
  fillRect(x: number, y: number, width: number, height: number): void;
216
164
  /**
217
-
218
165
  * strokeRect function.
219
-
220
166
  * @method
221
-
222
167
  */
223
168
  strokeRect(x: number, y: number, width: number, height: number): void;
224
169
  /**
225
-
226
170
  * fillText function.
227
-
228
171
  * @method
229
-
230
172
  */
231
173
  fillText(text: string, x: number, y: number, maxWidth?: number): void;
232
174
  /**
233
-
234
175
  * fillText function.
235
-
236
176
  * @method
237
-
238
177
  */
239
178
  fillTextPrecision(text: string, x: number, y: number, maxWidth?: number): void;
240
179
  /**
241
-
242
180
  * measureText function.
243
-
244
181
  * @method
245
-
246
182
  */
247
183
  measureText(text: string): TextMetrics;
248
184
  /**
249
-
250
185
  * getImageData function.
251
-
252
186
  * @method
253
-
254
187
  */
255
188
  getImageData(sx: number, sy: number, sw: number, sh: number): ImageData;
256
189
  /**
257
-
258
190
  * lineTo function.
259
-
260
191
  * @method
261
-
262
192
  */
263
193
  lineTo(x: number, y: number): void;
264
194
  /**
265
-
266
195
  * moveTo function.
267
-
268
196
  * @method
269
-
270
197
  */
271
198
  moveTo(x: number, y: number): void;
272
199
  /**
273
-
274
200
  * rect function.
275
-
276
201
  * @method
277
-
278
202
  */
279
203
  rect(x: number, y: number, width: number, height: number): void;
280
204
  /**
281
-
282
205
  * putImageData function.
283
-
284
206
  * @method
285
-
286
207
  */
287
208
  putImageData(imageData: ImageData, dx: number, dy: number): void;
288
209
  /**
289
-
290
210
  * quadraticCurveTo function.
291
-
292
211
  * @method
293
-
294
212
  */
295
213
  quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
296
214
  /**
297
-
298
215
  * restore function.
299
-
300
216
  * @method
301
-
302
217
  */
303
218
  restore(): void;
304
219
  /**
305
-
306
220
  * rotate function.
307
-
308
221
  * @method
309
-
310
222
  */
311
223
  rotate(angle: number): void;
312
224
  /**
313
-
314
225
  * save function.
315
-
316
226
  * @method
317
-
318
227
  */
319
228
  save(): void;
320
229
  /**
321
-
322
230
  * scale function.
323
-
324
231
  * @method
325
-
326
232
  */
327
233
  scale(x: number, y: number): void;
328
234
  /**
329
-
330
235
  * setLineDash function.
331
-
332
236
  * @method
333
-
334
237
  */
335
238
  setLineDash(segments: number[]): void;
336
239
  /**
337
-
338
240
  * getLineDash function.
339
-
340
241
  * @method
341
-
342
242
  */
343
243
  getLineDash(): number[];
344
244
  /**
345
-
346
245
  * setTransform function.
347
-
348
246
  * @method
349
-
350
247
  */
351
248
  setTransform(transform?: DOMMatrix2DInit): void;
352
249
  setTransform(a: number, b: number, c: number, d: number, e: number, f: number): void;
353
250
  /**
354
-
355
251
  * stroke function.
356
-
357
252
  * @method
358
-
359
253
  */
360
254
  stroke(path2d?: Path2D): void;
361
255
  /**
362
-
363
256
  * strokeText function.
364
-
365
257
  * @method
366
-
367
258
  */
368
259
  strokeText(text: string, x: number, y: number, maxWidth?: number): void;
369
260
  /**
370
-
371
261
  * transform function.
372
-
373
262
  * @method
374
-
375
263
  */
376
264
  transform(a: number, b: number, c: number, d: number, e: number, f: number): void;
377
265
  /**
378
-
379
266
  * translate function.
380
-
381
267
  * @method
382
-
383
268
  */
384
269
  translate(x: number, y: number): void;
385
270
  translateWithPrecision(x: number, y: number): void;
@@ -47,6 +47,7 @@ export declare class Engine extends ThinEngine<Scene> {
47
47
  private _pointerWheelEvent;
48
48
  private _pointerEnterEvent;
49
49
  private _pointerLeaveEvent;
50
+ private _remainCapture;
50
51
  /** previous pointer position */
51
52
  private pointer;
52
53
  private _mouseId;
@@ -63,6 +64,11 @@ export declare class Engine extends ThinEngine<Scene> {
63
64
  clearCanvas(): void;
64
65
  getCanvas(): Canvas;
65
66
  getCanvasElement(): HTMLCanvasElement;
67
+ /**
68
+ * To ensure mouse events remain bound to the host element,
69
+ * preventing the events from becoming ineffective once the mouse leaves the host.
70
+ */
71
+ setRemainCapture(): void;
66
72
  getPixelRatio(): number;
67
73
  setContainer(elem: HTMLElement): void;
68
74
  resize(): void;
@@ -36,6 +36,7 @@ export declare abstract class ThinEngine<T extends IDisposable> extends Disposab
36
36
  hasScene(sceneKey: string): boolean;
37
37
  addScene(sceneInstance: T): T;
38
38
  setActiveScene(sceneKey: string): T | null;
39
+ setRemainCapture(): void;
39
40
  hasActiveScene(): boolean;
40
41
  dispose(): void;
41
42
  remainScene(key: string): T | undefined;