@univerjs/engine-render 0.1.12 → 0.1.13
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.
- package/lib/cjs/index.js +2 -2
- package/lib/es/index.js +8801 -7567
- package/lib/types/base-object.d.ts +21 -21
- package/lib/types/basics/const.d.ts +7 -2
- package/lib/types/basics/group-transform.d.ts +16 -0
- package/lib/types/basics/i-document-skeleton-cached.d.ts +5 -4
- package/lib/types/basics/index.d.ts +1 -0
- package/lib/types/basics/interfaces.d.ts +4 -9
- package/lib/types/basics/offset-rotation-axis.d.ts +3 -0
- package/lib/types/basics/tools.d.ts +34 -0
- package/lib/types/basics/transform.d.ts +8 -0
- package/lib/types/basics/transformer-config.d.ts +37 -0
- package/lib/types/basics/vector2.d.ts +44 -2
- package/lib/types/components/component.d.ts +2 -2
- package/lib/types/components/docs/doc-background.d.ts +3 -3
- package/lib/types/components/docs/doc-component.d.ts +4 -4
- package/lib/types/components/docs/document.d.ts +3 -4
- package/lib/types/components/docs/extensions/line.d.ts +1 -1
- package/lib/types/components/docs/layout/doc-skeleton.d.ts +2 -2
- package/lib/types/components/docs/layout/model/glyph.d.ts +1 -1
- package/lib/types/components/docs/text-selection/text-range.d.ts +6 -0
- package/lib/types/components/docs/text-selection/text-selection-render-manager.d.ts +1 -0
- package/lib/types/components/extension.d.ts +7 -2
- package/lib/types/components/sheets/column-header.d.ts +2 -2
- package/lib/types/components/sheets/extensions/background.d.ts +2 -1
- package/lib/types/components/sheets/extensions/font.d.ts +3 -2
- package/lib/types/components/sheets/extensions/marker.d.ts +1 -1
- package/lib/types/components/sheets/extensions/sheet-extension.d.ts +8 -1
- package/lib/types/components/sheets/interfaces.d.ts +47 -0
- package/lib/types/components/sheets/row-header.d.ts +2 -2
- package/lib/types/components/sheets/sheet-component.d.ts +4 -4
- package/lib/types/components/sheets/sheet-skeleton.d.ts +10 -22
- package/lib/types/components/sheets/spreadsheet.d.ts +52 -11
- package/lib/types/custom/custom-object.d.ts +2 -2
- package/lib/types/group.d.ts +22 -2
- package/lib/types/index.d.ts +1 -0
- package/lib/types/layer.d.ts +3 -3
- package/lib/types/scene-viewer.d.ts +3 -3
- package/lib/types/scene.d.ts +9 -5
- package/lib/types/scene.transformer.d.ts +59 -40
- package/lib/types/shape/image.d.ts +54 -0
- package/lib/types/shape/index.d.ts +1 -1
- package/lib/types/shape/regular-polygon.d.ts +4 -1
- package/lib/types/shape/rich-text.d.ts +2 -3
- package/lib/types/shape/shape.d.ts +4 -3
- package/lib/types/thin-engine.d.ts +1 -0
- package/lib/types/thin-scene.d.ts +2 -1
- package/lib/types/viewport.d.ts +134 -16
- package/lib/umd/index.js +2 -2
- package/package.json +5 -5
- package/lib/types/services/object-transform-manager.service.d.ts +0 -41
- package/lib/types/shape/picture.d.ts +0 -24
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IObjectFullState } from '../basics/interfaces';
|
|
2
|
-
import { IPoint } from '../basics/vector2';
|
|
2
|
+
import { IPoint, Vector2 } from '../basics/vector2';
|
|
3
3
|
import { UniverRenderingContext } from '../context';
|
|
4
4
|
import { IShapeProps, Shape } from './shape';
|
|
5
5
|
|
|
@@ -12,6 +12,9 @@ export declare class RegularPolygon extends Shape<IRegularPolygonProps> {
|
|
|
12
12
|
constructor(key?: string, props?: IRegularPolygonProps);
|
|
13
13
|
get pointsGroup(): IPoint[][];
|
|
14
14
|
static drawWith(ctx: UniverRenderingContext, props: IRegularPolygonProps | RegularPolygon): void;
|
|
15
|
+
isHit(coord: Vector2): boolean;
|
|
16
|
+
private _contains;
|
|
17
|
+
private _isOnLine;
|
|
15
18
|
updatePointGroup(pointGroup: IPoint[][]): void;
|
|
16
19
|
resizePolygon(preValue: IObjectFullState): void;
|
|
17
20
|
toJson(): {
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { IDocumentData, IStyleBase, ITransformState, LocaleService } from '@univerjs/core';
|
|
2
2
|
import { BaseObject } from '../base-object';
|
|
3
|
-
import {
|
|
3
|
+
import { IViewportInfo } from '../basics/vector2';
|
|
4
4
|
import { UniverRenderingContext } from '../context';
|
|
5
5
|
|
|
6
6
|
export interface IRichTextProps extends ITransformState, IStyleBase {
|
|
7
7
|
text?: string;
|
|
8
8
|
richText?: IDocumentData;
|
|
9
9
|
zIndex: number;
|
|
10
|
-
isTransformer?: boolean;
|
|
11
10
|
forceRender?: boolean;
|
|
12
11
|
}
|
|
13
12
|
export declare const RICHTEXT_OBJECT_ARRAY: string[];
|
|
@@ -33,7 +32,7 @@ export declare class RichText extends BaseObject {
|
|
|
33
32
|
height: number;
|
|
34
33
|
} | undefined;
|
|
35
34
|
setProps(props?: IRichTextProps): this | undefined;
|
|
36
|
-
render(mainCtx: UniverRenderingContext, bounds?:
|
|
35
|
+
render(mainCtx: UniverRenderingContext, bounds?: IViewportInfo): this;
|
|
37
36
|
toJson(): {
|
|
38
37
|
[x: string]: any;
|
|
39
38
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IScale, Nullable } from '@univerjs/core';
|
|
2
2
|
import { BaseObject } from '../base-object';
|
|
3
3
|
import { IObjectFullState } from '../basics/interfaces';
|
|
4
|
-
import {
|
|
4
|
+
import { IViewportInfo, Vector2 } from '../basics/vector2';
|
|
5
5
|
import { UniverRenderingContext } from '../context';
|
|
6
6
|
|
|
7
7
|
export type LineJoin = 'round' | 'bevel' | 'miter';
|
|
@@ -37,7 +37,7 @@ export interface IShapeProps extends IObjectFullState {
|
|
|
37
37
|
parent?: IScale;
|
|
38
38
|
}
|
|
39
39
|
export declare const SHAPE_OBJECT_ARRAY: string[];
|
|
40
|
-
export declare abstract class Shape<T> extends BaseObject {
|
|
40
|
+
export declare abstract class Shape<T extends IShapeProps> extends BaseObject {
|
|
41
41
|
private _hoverCursor;
|
|
42
42
|
private _moveCursor;
|
|
43
43
|
private _fillRule;
|
|
@@ -98,9 +98,10 @@ export declare abstract class Shape<T> extends BaseObject {
|
|
|
98
98
|
* @param {UniverRenderingContext} ctx SheetContext to render on
|
|
99
99
|
*/
|
|
100
100
|
private static _renderStroke;
|
|
101
|
+
private static _removeShadow;
|
|
101
102
|
private static _setFillStyles;
|
|
102
103
|
private static _setStrokeStyles;
|
|
103
|
-
render(mainCtx: UniverRenderingContext, bounds?:
|
|
104
|
+
render(mainCtx: UniverRenderingContext, bounds?: IViewportInfo): this;
|
|
104
105
|
setProps(props?: T): this | undefined;
|
|
105
106
|
toJson(): {
|
|
106
107
|
[x: string]: any;
|
|
@@ -24,6 +24,7 @@ export declare abstract class ThinEngine<T extends IDisposable> extends Disposab
|
|
|
24
24
|
abstract setRemainCapture(): void;
|
|
25
25
|
hasActiveScene(): boolean;
|
|
26
26
|
dispose(): void;
|
|
27
|
+
getParent(): void;
|
|
27
28
|
remainScene(key: string): T | undefined;
|
|
28
29
|
abstract clearCanvas(): void;
|
|
29
30
|
abstract getCanvas(): Canvas;
|
|
@@ -75,7 +75,8 @@ export declare abstract class ThinScene extends Disposable {
|
|
|
75
75
|
abstract addObjects(objects: BaseObject[], zIndex?: number): void;
|
|
76
76
|
abstract getEngine(): any;
|
|
77
77
|
abstract setObjectBehavior(o: BaseObject): void;
|
|
78
|
-
|
|
78
|
+
attachTransformerTo(o: BaseObject): void;
|
|
79
|
+
detachTransformerFrom(o: BaseObject): void;
|
|
79
80
|
makeDirtyNoParent(state?: boolean): ThinScene;
|
|
80
81
|
makeDirty(state?: boolean): this;
|
|
81
82
|
abstract pick(coord: Vector2): Nullable<BaseObject | ThinScene>;
|
package/lib/types/viewport.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { EventState, IPosition, Nullable, Observable } from '@univerjs/core';
|
|
|
2
2
|
import { BaseObject } from './base-object';
|
|
3
3
|
import { IWheelEvent } from './basics/i-events';
|
|
4
4
|
import { Transform } from './basics/transform';
|
|
5
|
-
import {
|
|
5
|
+
import { IBoundRectNoAngle, IViewportInfo, Vector2 } from './basics/vector2';
|
|
6
6
|
import { UniverRenderingContext } from './context';
|
|
7
7
|
import { BaseScrollBar } from './shape/base-scroll-bar';
|
|
8
8
|
import { ThinScene } from './thin-scene';
|
|
@@ -21,13 +21,24 @@ interface IViewProps extends IViewPosition {
|
|
|
21
21
|
isWheelPreventDefaultX?: boolean;
|
|
22
22
|
isWheelPreventDefaultY?: boolean;
|
|
23
23
|
active?: boolean;
|
|
24
|
+
isRelativeX?: boolean;
|
|
25
|
+
isRelativeY?: boolean;
|
|
26
|
+
allowCache?: boolean;
|
|
27
|
+
bufferEdgeX?: number;
|
|
28
|
+
bufferEdgeY?: number;
|
|
24
29
|
}
|
|
25
30
|
export interface IScrollObserverParam {
|
|
26
31
|
viewport?: Viewport;
|
|
32
|
+
/**
|
|
33
|
+
* scrollX for scrollbar
|
|
34
|
+
*/
|
|
27
35
|
scrollX?: number;
|
|
28
36
|
scrollY?: number;
|
|
29
37
|
x?: number;
|
|
30
38
|
y?: number;
|
|
39
|
+
/**
|
|
40
|
+
* scrollX for viewport
|
|
41
|
+
*/
|
|
31
42
|
actualScrollX?: number;
|
|
32
43
|
actualScrollY?: number;
|
|
33
44
|
limitX?: number;
|
|
@@ -40,25 +51,36 @@ interface IScrollBarPosition {
|
|
|
40
51
|
}
|
|
41
52
|
export declare class Viewport {
|
|
42
53
|
/**
|
|
43
|
-
*
|
|
44
|
-
* use
|
|
45
|
-
*
|
|
54
|
+
* scrollX means scroll x value for scrollbar in viewMain
|
|
55
|
+
* use getBarScroll to get scrolling value(scrollX, scrollY) for scrollbar
|
|
46
56
|
*/
|
|
47
57
|
scrollX: number;
|
|
48
58
|
scrollY: number;
|
|
59
|
+
_preScrollX: number;
|
|
60
|
+
_preScrollY: number;
|
|
49
61
|
/**
|
|
50
62
|
* The actual scroll offset equals the distance from the content area position to the top, and there is a conversion relationship with scrollX and scrollY
|
|
51
|
-
* use
|
|
63
|
+
* use getActualScroll to get scrolling value for spreadsheet.
|
|
52
64
|
*/
|
|
53
|
-
|
|
54
|
-
|
|
65
|
+
viewportScrollX: number;
|
|
66
|
+
viewportScrollY: number;
|
|
67
|
+
preViewportScrollX: number;
|
|
68
|
+
preViewportScrollY: number;
|
|
69
|
+
_deltaViewportScrollX: number;
|
|
70
|
+
_deltaViewportScrollY: number;
|
|
55
71
|
onMouseWheelObserver: Observable<IWheelEvent>;
|
|
56
72
|
onScrollAfterObserver: Observable<IScrollObserverParam>;
|
|
57
73
|
onScrollBeforeObserver: Observable<IScrollObserverParam>;
|
|
58
74
|
onScrollStopObserver: Observable<IScrollObserverParam>;
|
|
59
75
|
onScrollByBarObserver: Observable<IScrollObserverParam>;
|
|
60
|
-
private
|
|
76
|
+
private _viewportKey;
|
|
77
|
+
/**
|
|
78
|
+
* viewport top origin value in logic, scale does not affect it.
|
|
79
|
+
*/
|
|
61
80
|
private _topOrigin;
|
|
81
|
+
/**
|
|
82
|
+
* viewport left origin value in logic, scale does not affect it.
|
|
83
|
+
*/
|
|
62
84
|
private _leftOrigin;
|
|
63
85
|
private _bottomOrigin;
|
|
64
86
|
private _rightOrigin;
|
|
@@ -75,8 +97,6 @@ export declare class Viewport {
|
|
|
75
97
|
private _isWheelPreventDefaultX;
|
|
76
98
|
private _isWheelPreventDefaultY;
|
|
77
99
|
private _scrollStopNum;
|
|
78
|
-
private _preScrollX;
|
|
79
|
-
private _preScrollY;
|
|
80
100
|
private _renderClipState;
|
|
81
101
|
private _active;
|
|
82
102
|
private _paddingStartX;
|
|
@@ -85,12 +105,43 @@ export declare class Viewport {
|
|
|
85
105
|
private _paddingEndY;
|
|
86
106
|
private _isRelativeX;
|
|
87
107
|
private _isRelativeY;
|
|
88
|
-
|
|
89
|
-
|
|
108
|
+
/**
|
|
109
|
+
* viewbound of cache area, cache area is slightly bigger than viewbound.
|
|
110
|
+
*/
|
|
111
|
+
private _cacheBound;
|
|
112
|
+
private _preCacheBound;
|
|
113
|
+
private _preCacheVisibleBound;
|
|
114
|
+
/**
|
|
115
|
+
* bound of visible area
|
|
116
|
+
*/
|
|
117
|
+
private _viewBound;
|
|
118
|
+
private _preViewBound;
|
|
119
|
+
/**
|
|
120
|
+
* Whether the viewport needs to be updated.
|
|
121
|
+
* In future, viewMain dirty would not affect othew viewports.
|
|
122
|
+
*/
|
|
123
|
+
private _isDirty;
|
|
124
|
+
private _cacheCanvas;
|
|
125
|
+
/**
|
|
126
|
+
* The configuration comes from the props.allowCache passed in during viewport initialization.
|
|
127
|
+
* When _allowCache is true, a cacheCanvas will be created.
|
|
128
|
+
*/
|
|
129
|
+
private _allowCache;
|
|
130
|
+
/**
|
|
131
|
+
* Buffer Area size, default is zero
|
|
132
|
+
*/
|
|
133
|
+
bufferEdgeX: number;
|
|
134
|
+
bufferEdgeY: number;
|
|
135
|
+
constructor(viewportKey: string, scene: ThinScene, props?: IViewProps);
|
|
136
|
+
initCacheCanvas(props?: IViewProps): void;
|
|
137
|
+
/**
|
|
138
|
+
* test
|
|
139
|
+
*/
|
|
140
|
+
_testDisplayCache(): void;
|
|
90
141
|
get scene(): ThinScene;
|
|
91
142
|
get width(): Nullable<number>;
|
|
92
143
|
get height(): Nullable<number>;
|
|
93
|
-
get
|
|
144
|
+
get viewportKey(): string;
|
|
94
145
|
get topOrigin(): number;
|
|
95
146
|
get leftOrigin(): number;
|
|
96
147
|
get bottomOrigin(): number;
|
|
@@ -108,16 +159,40 @@ export declare class Viewport {
|
|
|
108
159
|
private set left(value);
|
|
109
160
|
private set bottom(value);
|
|
110
161
|
private set right(value);
|
|
162
|
+
get viewBound(): IBoundRectNoAngle;
|
|
163
|
+
get cacheBound(): IBoundRectNoAngle | null;
|
|
164
|
+
set cacheBound(val: IBoundRectNoAngle | null);
|
|
165
|
+
get preCacheBound(): IBoundRectNoAngle | null;
|
|
166
|
+
set preCacheBound(val: IBoundRectNoAngle | null);
|
|
111
167
|
enable(): void;
|
|
112
168
|
disable(): void;
|
|
169
|
+
/**
|
|
170
|
+
* 物理 canvas 大小改变时调用(调整 window 大小时触发)
|
|
171
|
+
*/
|
|
113
172
|
resetSizeAndScrollBar(): void;
|
|
114
173
|
setScrollBar(instance: BaseScrollBar): void;
|
|
115
174
|
removeScrollBar(): void;
|
|
175
|
+
/**
|
|
176
|
+
* 和 resetSizeAndScrollBar 不同
|
|
177
|
+
* 此方法是调整冻结行列设置时 & 初始化时触发, resize window 时并不会触发
|
|
178
|
+
*
|
|
179
|
+
* 注意参数 position 不一定有 height & width 对于 viewMain 只有 left top bottom right
|
|
180
|
+
* this.width this.height 也有可能是 undefined
|
|
181
|
+
* 因此应通过 _getViewPortSize 获取宽高
|
|
182
|
+
* @param position
|
|
183
|
+
*/
|
|
116
184
|
resize(position: IViewPosition): void;
|
|
117
185
|
setPadding(param: IPosition): void;
|
|
118
186
|
resetPadding(): void;
|
|
119
187
|
/**
|
|
188
|
+
*
|
|
189
|
+
* 改动 scrollbar 的位置,不是 viewport content 滚动
|
|
120
190
|
* scroll to position, absolute
|
|
191
|
+
* 只有 viewMain 才会被调用 scrollTo 其他 viewport 都不会调用此方法
|
|
192
|
+
* 具体在 scroll.controller 中
|
|
193
|
+
*
|
|
194
|
+
* Debug
|
|
195
|
+
* window.scene.getViewports()[0].scrollTo({x: 14.2, y: 1.8}, true)
|
|
121
196
|
* @param pos
|
|
122
197
|
* @returns
|
|
123
198
|
*/
|
|
@@ -155,6 +230,10 @@ export declare class Viewport {
|
|
|
155
230
|
x: number;
|
|
156
231
|
y: number;
|
|
157
232
|
};
|
|
233
|
+
/**
|
|
234
|
+
* get actual scroll value by scrollXY
|
|
235
|
+
* @returns
|
|
236
|
+
*/
|
|
158
237
|
getTransformedScroll(): {
|
|
159
238
|
x: number;
|
|
160
239
|
y: number;
|
|
@@ -162,8 +241,19 @@ export declare class Viewport {
|
|
|
162
241
|
getScrollBar(): Nullable<BaseScrollBar>;
|
|
163
242
|
updateScroll(param: IScrollObserverParam): this;
|
|
164
243
|
getScrollBarTransForm(): Transform;
|
|
244
|
+
shouldIntoRender(): boolean;
|
|
245
|
+
/**
|
|
246
|
+
* engine.renderLoop ---> scene.render ---> layer.render ---> viewport.render
|
|
247
|
+
* that means each layer call all viewports to render
|
|
248
|
+
* @param parentCtx 如果 layer._allowCache true, 那么 parentCtx 是 layer 中的 cacheCtx
|
|
249
|
+
* @param objects
|
|
250
|
+
* @param isMaxLayer
|
|
251
|
+
* @param isLast last viewport would
|
|
252
|
+
*/
|
|
165
253
|
render(parentCtx?: UniverRenderingContext, objects?: BaseObject[], isMaxLayer?: boolean): void;
|
|
166
|
-
|
|
254
|
+
private _makeDefaultViewport;
|
|
255
|
+
private _calcViewportInfo;
|
|
256
|
+
getBounding(): IViewportInfo;
|
|
167
257
|
getRelativeVector(coord: Vector2): Vector2;
|
|
168
258
|
getAbsoluteVector(coord: Vector2): Vector2;
|
|
169
259
|
onMouseWheel(evt: IWheelEvent, state: EventState): void;
|
|
@@ -176,15 +266,43 @@ export declare class Viewport {
|
|
|
176
266
|
isLimitedX: boolean;
|
|
177
267
|
isLimitedY: boolean;
|
|
178
268
|
} | undefined;
|
|
179
|
-
|
|
269
|
+
markDirty(state?: boolean): void;
|
|
270
|
+
get isDirty(): boolean;
|
|
271
|
+
private _isForceDirty;
|
|
272
|
+
markForceDirty(state?: boolean): void;
|
|
273
|
+
resetPrevCacheBounds(): void;
|
|
274
|
+
get isForceDirty(): boolean;
|
|
275
|
+
private _resizeCacheCanvas;
|
|
180
276
|
private _getViewPortSize;
|
|
181
277
|
private _scrollRendered;
|
|
182
278
|
private _triggerScrollStop;
|
|
279
|
+
/**
|
|
280
|
+
* Scroll Viewport
|
|
281
|
+
* Only the 'viewMain' will enter this function, other viewports will not.
|
|
282
|
+
*
|
|
283
|
+
* caller: scroll.controller viewportMain.proscrollTo(config)
|
|
284
|
+
* @param scrollType
|
|
285
|
+
* @param pos viewMain 滚动条的位置
|
|
286
|
+
* @param isTrigger
|
|
287
|
+
*/
|
|
183
288
|
private _scroll;
|
|
184
|
-
|
|
289
|
+
expandBounds(value: {
|
|
290
|
+
top: number;
|
|
291
|
+
left: number;
|
|
292
|
+
bottom: number;
|
|
293
|
+
right: number;
|
|
294
|
+
}): IBoundRectNoAngle;
|
|
295
|
+
updatePrevCacheBounds(viewBound?: IBoundRectNoAngle): void;
|
|
296
|
+
private _calcCacheUpdate;
|
|
185
297
|
private _diffViewBound;
|
|
298
|
+
private _calcDiffCacheBound;
|
|
186
299
|
private _drawScrollbar;
|
|
187
300
|
private _setWithAndHeight;
|
|
188
301
|
private _getBoundScale;
|
|
302
|
+
/**
|
|
303
|
+
* main canvas element resize
|
|
304
|
+
* called by this.scene.getEngine()?.onTransformChangeObservable.add
|
|
305
|
+
*/
|
|
306
|
+
private _mainCanvasResizeHandler;
|
|
189
307
|
}
|
|
190
308
|
export {};
|