@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,6 +1,9 @@
|
|
|
1
1
|
import { BorderStyleTypes, HorizontalAlign, ISelectionCellWithCoord, ObjectMatrix, VerticalAlign, WrapStrategy } from '@univerjs/core';
|
|
2
2
|
import { BORDER_TYPE } from '../../basics/const';
|
|
3
3
|
import { DocumentSkeleton } from '../docs/layout/doc-skeleton';
|
|
4
|
+
import { Canvas } from '../../canvas';
|
|
5
|
+
import { UniverRenderingContext } from '../../context';
|
|
6
|
+
import { ISheetFontRenderExtension } from './extensions';
|
|
4
7
|
|
|
5
8
|
export interface BorderCache {
|
|
6
9
|
[key: string]: BorderCacheItem | {};
|
|
@@ -34,4 +37,48 @@ export declare enum ShowGridlinesState {
|
|
|
34
37
|
OFF = 0,
|
|
35
38
|
ON = 1
|
|
36
39
|
}
|
|
40
|
+
export declare enum SHEET_VIEWPORT_KEY {
|
|
41
|
+
VIEW_MAIN = "viewMain",
|
|
42
|
+
VIEW_MAIN_LEFT_TOP = "viewMainLeftTop",
|
|
43
|
+
VIEW_MAIN_TOP = "viewMainTop",
|
|
44
|
+
VIEW_MAIN_LEFT = "viewMainLeft",
|
|
45
|
+
VIEW_ROW_TOP = "viewRowTop",
|
|
46
|
+
VIEW_ROW_BOTTOM = "viewRowBottom",
|
|
47
|
+
VIEW_COLUMN_LEFT = "viewColumnLeft",
|
|
48
|
+
VIEW_COLUMN_RIGHT = "viewColumnRight",
|
|
49
|
+
VIEW_LEFT_TOP = "viewLeftTop"
|
|
50
|
+
}
|
|
51
|
+
export interface IPaintForRefresh {
|
|
52
|
+
cacheCanvas: Canvas;
|
|
53
|
+
cacheCtx: UniverRenderingContext;
|
|
54
|
+
mainCtx: UniverRenderingContext;
|
|
55
|
+
topOrigin: number;
|
|
56
|
+
leftOrigin: number;
|
|
57
|
+
bufferEdgeX: number;
|
|
58
|
+
bufferEdgeY: number;
|
|
59
|
+
}
|
|
60
|
+
export interface IPaintForScrolling {
|
|
61
|
+
cacheCanvas: Canvas;
|
|
62
|
+
cacheCtx: UniverRenderingContext;
|
|
63
|
+
mainCtx: UniverRenderingContext;
|
|
64
|
+
topOrigin: number;
|
|
65
|
+
leftOrigin: number;
|
|
66
|
+
bufferEdgeX: number;
|
|
67
|
+
bufferEdgeY: number;
|
|
68
|
+
rowHeaderWidth: number;
|
|
69
|
+
columnHeaderHeight: number;
|
|
70
|
+
scaleX: number;
|
|
71
|
+
scaleY: number;
|
|
72
|
+
}
|
|
73
|
+
export type ISheetRenderExtension = ISheetFontRenderExtension & ISheetBackgroundRenderExtension & ISheetBorderRenderExtension;
|
|
74
|
+
export interface ISheetBackgroundRenderExtension {
|
|
75
|
+
backgroundRenderExtension?: {
|
|
76
|
+
isSkip?: boolean;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export interface ISheetBorderRenderExtension {
|
|
80
|
+
borderRenderExtension?: {
|
|
81
|
+
isSkip?: boolean;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
37
84
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Nullable } from '@univerjs/core';
|
|
2
|
-
import {
|
|
2
|
+
import { IViewportInfo, Vector2 } from '../../basics/vector2';
|
|
3
3
|
import { UniverRenderingContext } from '../../context';
|
|
4
4
|
import { RowHeaderLayout } from './extensions/row-header-layout';
|
|
5
5
|
import { SpreadsheetHeader } from './sheet-component';
|
|
@@ -22,7 +22,7 @@ export declare class SpreadsheetRowHeader extends SpreadsheetHeader {
|
|
|
22
22
|
private _rowHeaderLayoutExtension;
|
|
23
23
|
constructor(oKey: string, spreadsheetSkeleton?: SpreadsheetSkeleton);
|
|
24
24
|
get rowHeaderLayoutExtension(): RowHeaderLayout;
|
|
25
|
-
draw(ctx: UniverRenderingContext, bounds?:
|
|
25
|
+
draw(ctx: UniverRenderingContext, bounds?: IViewportInfo): void;
|
|
26
26
|
isHit(coord: Vector2): boolean;
|
|
27
27
|
private _initialDefaultExtension;
|
|
28
28
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IRange, Nullable } from '@univerjs/core';
|
|
2
|
-
import {
|
|
2
|
+
import { IViewportInfo, Vector2 } from '../../basics/vector2';
|
|
3
3
|
import { UniverRenderingContext } from '../../context';
|
|
4
4
|
import { RenderComponent } from '../component';
|
|
5
5
|
import { SHEET_EXTENSION_TYPE } from './extensions/sheet-extension';
|
|
@@ -10,7 +10,7 @@ export declare abstract class SheetComponent extends RenderComponent<Spreadsheet
|
|
|
10
10
|
constructor(oKey: string, _skeleton?: SpreadsheetSkeleton | undefined);
|
|
11
11
|
getSkeleton(): SpreadsheetSkeleton | undefined;
|
|
12
12
|
updateSkeleton(spreadsheetSkeleton: SpreadsheetSkeleton): void;
|
|
13
|
-
render(mainCtx: UniverRenderingContext, bounds?:
|
|
13
|
+
render(mainCtx: UniverRenderingContext, bounds?: IViewportInfo): this | undefined;
|
|
14
14
|
getParentScale(): {
|
|
15
15
|
scaleX: number;
|
|
16
16
|
scaleY: number;
|
|
@@ -32,12 +32,12 @@ export declare abstract class SheetComponent extends RenderComponent<Spreadsheet
|
|
|
32
32
|
endRow: number;
|
|
33
33
|
endColumn: number;
|
|
34
34
|
}>;
|
|
35
|
-
protected abstract _draw(ctx: UniverRenderingContext, bounds?:
|
|
35
|
+
protected abstract _draw(ctx: UniverRenderingContext, bounds?: IViewportInfo): void;
|
|
36
36
|
/**
|
|
37
37
|
* TODO: DR-Univer, fix as unknown as
|
|
38
38
|
*/
|
|
39
39
|
dispose(): void;
|
|
40
40
|
}
|
|
41
41
|
export declare abstract class SpreadsheetHeader extends SheetComponent {
|
|
42
|
-
protected _draw(ctx: UniverRenderingContext, bounds?:
|
|
42
|
+
protected _draw(ctx: UniverRenderingContext, bounds?: IViewportInfo): void;
|
|
43
43
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BooleanNumber, DocumentDataModel, HorizontalAlign, IContextService, LocaleService, ObjectMatrix, VerticalAlign, WrapStrategy, ICellData, IPaddingData, IRange, ISelectionCellWithCoord, ITextRotation, IWorksheetData, Nullable, Styles, Worksheet } from '@univerjs/core';
|
|
2
|
-
import { IBoundRectNoAngle,
|
|
2
|
+
import { IBoundRectNoAngle, IViewportInfo } from '../../basics/vector2';
|
|
3
3
|
import { DocumentSkeleton } from '../docs/layout/doc-skeleton';
|
|
4
4
|
import { Skeleton } from '../skeleton';
|
|
5
5
|
import { IStylesCache } from './interfaces';
|
|
@@ -50,6 +50,9 @@ export declare class SpreadsheetSkeleton extends Skeleton {
|
|
|
50
50
|
private _columnTotalWidth;
|
|
51
51
|
private _rowHeaderWidth;
|
|
52
52
|
private _columnHeaderHeight;
|
|
53
|
+
/**
|
|
54
|
+
* skeletonData(row col range) of visible area
|
|
55
|
+
*/
|
|
53
56
|
private _rowColumnSegment;
|
|
54
57
|
private _dataMergeCache;
|
|
55
58
|
private _overflowCache;
|
|
@@ -101,30 +104,20 @@ export declare class SpreadsheetSkeleton extends Skeleton {
|
|
|
101
104
|
setOverflowCache(value: ObjectMatrix<IRange>): void;
|
|
102
105
|
setMarginLeft(left: number): void;
|
|
103
106
|
setMarginTop(top: number): void;
|
|
104
|
-
calculateSegment(bounds?:
|
|
105
|
-
calculateWithoutClearingCache(bounds?:
|
|
106
|
-
calculate(bounds?:
|
|
107
|
+
calculateSegment(bounds?: IViewportInfo): true | undefined;
|
|
108
|
+
calculateWithoutClearingCache(bounds?: IViewportInfo): this | undefined;
|
|
109
|
+
calculate(bounds?: IViewportInfo): this;
|
|
107
110
|
calculateAutoHeightInRange(ranges: Nullable<IRange[]>): IRowAutoHeightInfo[];
|
|
108
111
|
private _calculateRowAutoHeight;
|
|
109
112
|
private _updateLayout;
|
|
110
113
|
private _dynamicallyUpdateRowHeaderWidth;
|
|
111
|
-
getRowColumnSegment(bounds?:
|
|
112
|
-
startRow: number;
|
|
113
|
-
endRow: number;
|
|
114
|
-
startColumn: number;
|
|
115
|
-
endColumn: number;
|
|
116
|
-
};
|
|
114
|
+
getRowColumnSegment(bounds?: IViewportInfo): IRange;
|
|
117
115
|
/**
|
|
118
116
|
* @deprecated should never expose a property that is provided by another module!
|
|
119
117
|
* @returns
|
|
120
118
|
*/
|
|
121
119
|
getWorksheetConfig(): IWorksheetData;
|
|
122
|
-
getRowColumnSegmentByViewBound(bound?: IBoundRectNoAngle):
|
|
123
|
-
startRow: number;
|
|
124
|
-
endRow: number;
|
|
125
|
-
startColumn: number;
|
|
126
|
-
endColumn: number;
|
|
127
|
-
};
|
|
120
|
+
getRowColumnSegmentByViewBound(bound?: IBoundRectNoAngle): IRange;
|
|
128
121
|
getMergeBounding(startRow: number, startColumn: number, endRow: number, endColumn: number): {
|
|
129
122
|
startRow: number;
|
|
130
123
|
startColumn: number;
|
|
@@ -284,12 +277,7 @@ export declare class SpreadsheetSkeleton extends Skeleton {
|
|
|
284
277
|
* @param viewBound The range of the visible area of the canvas
|
|
285
278
|
* @returns The range cell index of the canvas visible area
|
|
286
279
|
*/
|
|
287
|
-
protected _getBounding(rowHeightAccumulation: number[], columnWidthAccumulation: number[], viewBound?: IBoundRectNoAngle):
|
|
288
|
-
startRow: number;
|
|
289
|
-
endRow: number;
|
|
290
|
-
startColumn: number;
|
|
291
|
-
endColumn: number;
|
|
292
|
-
};
|
|
280
|
+
protected _getBounding(rowHeightAccumulation: number[], columnWidthAccumulation: number[], viewBound?: IBoundRectNoAngle): IRange;
|
|
293
281
|
private _generateRowMatrixCache;
|
|
294
282
|
private _generateColumnMatrixCache;
|
|
295
283
|
private _getOverflowBound;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IBoundRectNoAngle, IViewportInfo, Vector2 } from '../../basics/vector2';
|
|
2
|
+
import { Canvas } from '../../canvas';
|
|
2
3
|
import { UniverRenderingContext } from '../../context';
|
|
3
4
|
import { Documents } from '../docs/document';
|
|
4
5
|
import { Background } from './extensions/background';
|
|
@@ -6,15 +7,15 @@ import { Border } from './extensions/border';
|
|
|
6
7
|
import { Font } from './extensions/font';
|
|
7
8
|
import { SheetComponent } from './sheet-component';
|
|
8
9
|
import { SpreadsheetSkeleton } from './sheet-skeleton';
|
|
10
|
+
import { IPaintForRefresh, IPaintForScrolling, SHEET_VIEWPORT_KEY } from './interfaces';
|
|
9
11
|
|
|
10
12
|
export declare class Spreadsheet extends SheetComponent {
|
|
11
13
|
private _allowCache;
|
|
12
14
|
private _backgroundExtension;
|
|
13
15
|
private _borderExtension;
|
|
14
16
|
private _fontExtension;
|
|
15
|
-
private _cacheCanvas;
|
|
16
17
|
private _refreshIncrementalState;
|
|
17
|
-
private
|
|
18
|
+
private _dirtyBounds;
|
|
18
19
|
private _forceDisableGridlines;
|
|
19
20
|
private _documents;
|
|
20
21
|
isPrinting: boolean;
|
|
@@ -29,7 +30,14 @@ export declare class Spreadsheet extends SheetComponent {
|
|
|
29
30
|
* TODO: DR-Univer, fix as unknown as
|
|
30
31
|
*/
|
|
31
32
|
dispose(): void;
|
|
32
|
-
|
|
33
|
+
/**
|
|
34
|
+
* draw by viewport
|
|
35
|
+
* cacheBound ---> viewBound
|
|
36
|
+
* diffCacheBounds ---> diffRange
|
|
37
|
+
* @param ctx
|
|
38
|
+
* @param viewportInfo
|
|
39
|
+
*/
|
|
40
|
+
draw(ctx: UniverRenderingContext, viewportInfo: IViewportInfo): void;
|
|
33
41
|
isHit(coord: Vector2): boolean;
|
|
34
42
|
getNoMergeCellPositionByIndex(rowIndex: number, columnIndex: number): {
|
|
35
43
|
startY: number;
|
|
@@ -41,6 +49,11 @@ export declare class Spreadsheet extends SheetComponent {
|
|
|
41
49
|
x: number;
|
|
42
50
|
y: number;
|
|
43
51
|
};
|
|
52
|
+
isForceDirty(): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* canvas resize & zoom would call forceDirty
|
|
55
|
+
* @param state
|
|
56
|
+
*/
|
|
44
57
|
makeForceDirty(state?: boolean): void;
|
|
45
58
|
setForceDisableGridlines(disabled: boolean): void;
|
|
46
59
|
getSelectionBounding(startRow: number, startColumn: number, endRow: number, endColumn: number): {
|
|
@@ -49,20 +62,48 @@ export declare class Spreadsheet extends SheetComponent {
|
|
|
49
62
|
endRow: number;
|
|
50
63
|
endColumn: number;
|
|
51
64
|
} | undefined;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
65
|
+
/**
|
|
66
|
+
* @param state
|
|
67
|
+
*/
|
|
68
|
+
makeDirty(state?: boolean): this;
|
|
69
|
+
setDirtyArea(dirtyBounds: IBoundRectNoAngle[]): void;
|
|
70
|
+
renderByViewport(mainCtx: UniverRenderingContext, viewportInfo: IViewportInfo, spreadsheetSkeleton: SpreadsheetSkeleton): void;
|
|
71
|
+
paintNewAreaForScrolling(viewportInfo: IViewportInfo, param: IPaintForScrolling): void;
|
|
72
|
+
/**
|
|
73
|
+
* Redraw the entire viewport.
|
|
74
|
+
*/
|
|
75
|
+
refreshCacheCanvas(viewportInfo: IViewportInfo, param: IPaintForRefresh): void;
|
|
76
|
+
render(mainCtx: UniverRenderingContext, viewportInfo: IViewportInfo): this | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* applyCache from cache canvas
|
|
79
|
+
* @param cacheCanvas Source Image
|
|
80
|
+
* @param ctx MainCtx
|
|
81
|
+
* @param sx
|
|
82
|
+
* @param sy
|
|
83
|
+
* @param sw
|
|
84
|
+
* @param sh
|
|
85
|
+
* @param dx
|
|
86
|
+
* @param dy
|
|
87
|
+
* @param dw
|
|
88
|
+
* @param dh
|
|
89
|
+
*/
|
|
90
|
+
protected _applyCache(cacheCanvas: Canvas, ctx: UniverRenderingContext, sx?: number, sy?: number, sw?: number, sh?: number, dx?: number, dy?: number, dw?: number, dh?: number): void;
|
|
91
|
+
protected _draw(ctx: UniverRenderingContext, bounds?: IViewportInfo): void;
|
|
56
92
|
private _getAncestorSize;
|
|
57
93
|
private _getAncestorParent;
|
|
58
94
|
private _initialDefaultExtension;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
95
|
+
/**
|
|
96
|
+
* draw gridlines
|
|
97
|
+
* @param ctx
|
|
98
|
+
*/
|
|
62
99
|
private _drawAuxiliary;
|
|
63
100
|
/**
|
|
64
101
|
* Clear the guide lines within a range in the table, to make room for merged cells and overflow.
|
|
65
102
|
*/
|
|
66
103
|
private _clearRectangle;
|
|
67
104
|
private _clearBackground;
|
|
105
|
+
sheetContentViewport(): SHEET_VIEWPORT_KEY[];
|
|
106
|
+
sheetHeaderViewport(): SHEET_VIEWPORT_KEY[];
|
|
107
|
+
testShowRuler(cacheCtx: UniverRenderingContext, viewportInfo: IViewportInfo): void;
|
|
108
|
+
testGetRandomLightColor(): string;
|
|
68
109
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseObject } from '../base-object';
|
|
2
|
-
import {
|
|
2
|
+
import { IViewportInfo, Vector2 } from '../basics/vector2';
|
|
3
3
|
import { UniverRenderingContext } from '../context';
|
|
4
4
|
|
|
5
5
|
export declare class CustomObject extends BaseObject {
|
|
@@ -9,6 +9,6 @@ export declare class CustomObject extends BaseObject {
|
|
|
9
9
|
toJson(): {
|
|
10
10
|
[x: string]: any;
|
|
11
11
|
};
|
|
12
|
-
render(mainCtx: UniverRenderingContext, bounds?:
|
|
12
|
+
render(mainCtx: UniverRenderingContext, bounds?: IViewportInfo): this;
|
|
13
13
|
isHit(coord: Vector2): boolean;
|
|
14
14
|
}
|
package/lib/types/group.d.ts
CHANGED
|
@@ -1,19 +1,39 @@
|
|
|
1
1
|
import { BaseObject } from './base-object';
|
|
2
2
|
import { CURSOR_TYPE, RENDER_CLASS_TYPE } from './basics/const';
|
|
3
|
-
import {
|
|
3
|
+
import { IViewportInfo, Vector2 } from './basics/vector2';
|
|
4
4
|
import { UniverRenderingContext } from './context';
|
|
5
5
|
|
|
6
6
|
export declare class Group extends BaseObject {
|
|
7
7
|
private _objects;
|
|
8
|
+
private _selfSizeMode;
|
|
8
9
|
constructor(key?: string, ...objects: BaseObject[]);
|
|
9
10
|
get classType(): RENDER_CLASS_TYPE;
|
|
10
11
|
set cursor(val: CURSOR_TYPE);
|
|
12
|
+
getState(): import('@univerjs/core').ITransformState | {
|
|
13
|
+
left: number;
|
|
14
|
+
top: number;
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
angle: number;
|
|
18
|
+
scaleX: number;
|
|
19
|
+
scaleY: number;
|
|
20
|
+
};
|
|
21
|
+
get width(): number;
|
|
22
|
+
get height(): number;
|
|
23
|
+
set width(val: number);
|
|
24
|
+
set height(val: number);
|
|
25
|
+
get maxZIndex(): number;
|
|
26
|
+
openSelfSizeMode(): void;
|
|
27
|
+
closeSelfSizeMode(): void;
|
|
28
|
+
reCalculateObjects(): void;
|
|
11
29
|
addObjects(...objects: BaseObject[]): void;
|
|
12
30
|
addObject(o: BaseObject | string): void;
|
|
13
31
|
removeObject(object: BaseObject | string): void;
|
|
32
|
+
removeSelfObjectAndTransform(oKey: string, width?: number, height?: number, isTransform?: boolean): void;
|
|
33
|
+
private _transformObject;
|
|
14
34
|
getObjectsByOrder(): BaseObject[];
|
|
15
35
|
getObjects(): BaseObject[];
|
|
16
|
-
render(ctx: UniverRenderingContext, bounds?:
|
|
36
|
+
render(ctx: UniverRenderingContext, bounds?: IViewportInfo): void;
|
|
17
37
|
resize(width?: number | string, height?: number | string): this;
|
|
18
38
|
scale(scaleX?: number, scaleY?: number): this;
|
|
19
39
|
skew(skewX?: number, skewY?: number): this;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -42,3 +42,4 @@ export type { IPageRenderConfig } from './components/docs/document';
|
|
|
42
42
|
export { DocumentSkeleton } from './components/docs/layout/doc-skeleton';
|
|
43
43
|
export { ThinEngine } from './thin-engine';
|
|
44
44
|
export { getCharSpaceApply, getNumberUnitValue } from './components/docs/layout/tools';
|
|
45
|
+
export { type IChangeObserverConfig } from './scene.transformer';
|
package/lib/types/layer.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Disposable } from '@univerjs/core';
|
|
2
2
|
import { BaseObject } from './base-object';
|
|
3
3
|
import { UniverRenderingContext } from './context';
|
|
4
|
-
import {
|
|
4
|
+
import { Scene } from './scene';
|
|
5
5
|
|
|
6
6
|
export declare class Layer extends Disposable {
|
|
7
7
|
private _scene;
|
|
@@ -11,8 +11,8 @@ export declare class Layer extends Disposable {
|
|
|
11
11
|
private _cacheCanvas;
|
|
12
12
|
protected _dirty: boolean;
|
|
13
13
|
private _debounceDirtyFunc;
|
|
14
|
-
constructor(_scene:
|
|
15
|
-
get scene():
|
|
14
|
+
constructor(_scene: Scene, objects?: BaseObject[], _zIndex?: number, _allowCache?: boolean);
|
|
15
|
+
get scene(): Scene;
|
|
16
16
|
get zIndex(): number;
|
|
17
17
|
enableCache(): void;
|
|
18
18
|
disableCache(): void;
|
|
@@ -2,7 +2,7 @@ import { Nullable } from '@univerjs/core';
|
|
|
2
2
|
import { BaseObject } from './base-object';
|
|
3
3
|
import { RENDER_CLASS_TYPE } from './basics/const';
|
|
4
4
|
import { IObjectFullState } from './basics/interfaces';
|
|
5
|
-
import {
|
|
5
|
+
import { IViewportInfo, Vector2 } from './basics/vector2';
|
|
6
6
|
import { UniverRenderingContext } from './context';
|
|
7
7
|
import { ThinScene } from './thin-scene';
|
|
8
8
|
|
|
@@ -12,7 +12,7 @@ export declare class SceneViewer extends BaseObject {
|
|
|
12
12
|
private _allowSelectedClipElement;
|
|
13
13
|
constructor(key?: string, props?: IObjectFullState);
|
|
14
14
|
get classType(): RENDER_CLASS_TYPE;
|
|
15
|
-
render(mainCtx: UniverRenderingContext, bounds?:
|
|
15
|
+
render(mainCtx: UniverRenderingContext, bounds?: IViewportInfo): this;
|
|
16
16
|
getSubScenes(): Map<string, ThinScene>;
|
|
17
17
|
getActiveSubScene(): Nullable<ThinScene>;
|
|
18
18
|
getSubScene(sceneKey: string): ThinScene | undefined;
|
|
@@ -22,7 +22,7 @@ export declare class SceneViewer extends BaseObject {
|
|
|
22
22
|
enableSelectedClipElement(): void;
|
|
23
23
|
disableSelectedClipElement(): void;
|
|
24
24
|
allowSelectedClipElement(): boolean;
|
|
25
|
-
pick(coord: Vector2): Nullable<
|
|
25
|
+
pick(coord: Vector2): Nullable<BaseObject | ThinScene>;
|
|
26
26
|
dispose(): void;
|
|
27
27
|
private _initialProps;
|
|
28
28
|
}
|
package/lib/types/scene.d.ts
CHANGED
|
@@ -6,11 +6,12 @@ import { ISceneTransformState } from './basics/interfaces';
|
|
|
6
6
|
import { Vector2 } from './basics/vector2';
|
|
7
7
|
import { UniverRenderingContext } from './context';
|
|
8
8
|
import { Layer } from './layer';
|
|
9
|
-
import {
|
|
9
|
+
import { Transformer } from './scene.transformer';
|
|
10
10
|
import { SceneViewer } from './scene-viewer';
|
|
11
11
|
import { ThinEngine } from './thin-engine';
|
|
12
12
|
import { ThinScene } from './thin-scene';
|
|
13
13
|
import { Viewport } from './viewport';
|
|
14
|
+
import { ITransformerConfig } from './basics/transformer-config';
|
|
14
15
|
|
|
15
16
|
export declare class Scene extends ThinScene {
|
|
16
17
|
private _parent;
|
|
@@ -26,12 +27,13 @@ export declare class Scene extends ThinScene {
|
|
|
26
27
|
* when you resize them. Instead it changes `scaleX` and `scaleY` properties.
|
|
27
28
|
*/
|
|
28
29
|
private _transformer;
|
|
29
|
-
private _transformerOpenState;
|
|
30
30
|
/** @hidden */
|
|
31
31
|
private _inputManager;
|
|
32
32
|
constructor(sceneKey: string, _parent: ThinEngine<Scene> | SceneViewer, state?: ISceneTransformState);
|
|
33
33
|
get ancestorScaleX(): number;
|
|
34
34
|
get ancestorScaleY(): number;
|
|
35
|
+
get ancestorLeft(): number;
|
|
36
|
+
get ancestorTop(): number;
|
|
35
37
|
set cursor(val: CURSOR_TYPE);
|
|
36
38
|
attachControl(hasDown?: boolean, hasUp?: boolean, hasMove?: boolean, hasWheel?: boolean): this | undefined;
|
|
37
39
|
detachControl(): this;
|
|
@@ -69,6 +71,7 @@ export declare class Scene extends ThinScene {
|
|
|
69
71
|
getAllObjectsByOrder(isDesc?: boolean): BaseObject[];
|
|
70
72
|
getAllObjectsByOrderForPick(isDesc?: boolean): BaseObject[];
|
|
71
73
|
getObject(oKey: string): BaseObject | undefined;
|
|
74
|
+
getObjectIncludeInGroup(oKey: string): BaseObject | undefined;
|
|
72
75
|
fuzzyMathObjects(oKey: string): BaseObject[];
|
|
73
76
|
addViewport(...viewport: Viewport[]): this;
|
|
74
77
|
removeViewport(key: string): Viewport | undefined;
|
|
@@ -76,9 +79,10 @@ export declare class Scene extends ThinScene {
|
|
|
76
79
|
getViewport(key: string): Viewport | undefined;
|
|
77
80
|
render(parentCtx?: UniverRenderingContext): void;
|
|
78
81
|
requestRender(parentCtx?: UniverRenderingContext): Promise<unknown>;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
attachTransformerTo(o: BaseObject): void;
|
|
83
|
+
detachTransformerFrom(o: BaseObject): void;
|
|
84
|
+
initTransformer(config?: ITransformerConfig): void;
|
|
85
|
+
getTransformerByCreate(): Transformer;
|
|
82
86
|
getTransformer(): Nullable<Transformer>;
|
|
83
87
|
getActiveViewportByRelativeCoord(coord: Vector2): Viewport | undefined;
|
|
84
88
|
getActiveViewportByCoord(coord: Vector2): Viewport | undefined;
|
|
@@ -2,49 +2,21 @@ import { Nullable, Disposable, Observable } from '@univerjs/core';
|
|
|
2
2
|
import { BaseObject } from './base-object';
|
|
3
3
|
import { IMouseEvent, IPointerEvent } from './basics/i-events';
|
|
4
4
|
import { Group } from './group';
|
|
5
|
-
import {
|
|
5
|
+
import { Scene } from './scene';
|
|
6
|
+
import { ITransformerConfig } from './basics/transformer-config';
|
|
6
7
|
|
|
7
8
|
declare enum MoveObserverType {
|
|
8
9
|
MOVE_START = 0,
|
|
9
10
|
MOVING = 1,
|
|
10
11
|
MOVE_END = 2
|
|
11
12
|
}
|
|
12
|
-
interface IChangeObserverConfig {
|
|
13
|
+
export interface IChangeObserverConfig {
|
|
13
14
|
objects: Map<string, BaseObject>;
|
|
14
15
|
moveX?: number;
|
|
15
16
|
moveY?: number;
|
|
17
|
+
angle?: number;
|
|
16
18
|
type: MoveObserverType;
|
|
17
19
|
}
|
|
18
|
-
export interface ITransformerConfig {
|
|
19
|
-
hoverEnabled?: boolean;
|
|
20
|
-
hoverEnterFunc?: Nullable<(e: IPointerEvent | IMouseEvent) => void>;
|
|
21
|
-
hoverLeaveFunc?: Nullable<(e: IPointerEvent | IMouseEvent) => void>;
|
|
22
|
-
rotateEnabled?: boolean;
|
|
23
|
-
rotationSnaps?: number[];
|
|
24
|
-
rotationSnapTolerance?: number;
|
|
25
|
-
rotateAnchorOffset?: number;
|
|
26
|
-
rotateSize?: number;
|
|
27
|
-
rotateCornerRadius?: number;
|
|
28
|
-
borderEnabled?: boolean;
|
|
29
|
-
borderStroke?: string;
|
|
30
|
-
borderStrokeWidth?: number;
|
|
31
|
-
borderDash?: number[];
|
|
32
|
-
borderSpacing: number;
|
|
33
|
-
resizeEnabled?: boolean;
|
|
34
|
-
enabledAnchors?: number[];
|
|
35
|
-
anchorFill?: string;
|
|
36
|
-
anchorStroke?: string;
|
|
37
|
-
anchorStrokeWidth?: number;
|
|
38
|
-
anchorSize?: number;
|
|
39
|
-
anchorCornerRadius?: number;
|
|
40
|
-
keepRatio?: boolean;
|
|
41
|
-
centeredScaling?: boolean;
|
|
42
|
-
flipEnabled?: boolean;
|
|
43
|
-
ignoreStroke?: boolean;
|
|
44
|
-
boundBoxFunc?: Nullable<(oldBox: BaseObject, newBox: BaseObject) => BaseObject>;
|
|
45
|
-
useSingleNodeRotation?: boolean;
|
|
46
|
-
shouldOverdrawWholeArea?: boolean;
|
|
47
|
-
}
|
|
48
20
|
/**
|
|
49
21
|
* Transformer constructor. Transformer is a special type of group that allow you transform
|
|
50
22
|
* primitives and shapes. Transforming tool is not changing `width` and `height` properties of nodes
|
|
@@ -52,6 +24,7 @@ export interface ITransformerConfig {
|
|
|
52
24
|
*/
|
|
53
25
|
export declare class Transformer extends Disposable implements ITransformerConfig {
|
|
54
26
|
private _scene;
|
|
27
|
+
isCropper: boolean;
|
|
55
28
|
hoverEnabled: boolean;
|
|
56
29
|
hoverEnterFunc: Nullable<(e: IPointerEvent | IMouseEvent) => void>;
|
|
57
30
|
hoverLeaveFunc: Nullable<(e: IPointerEvent | IMouseEvent) => void>;
|
|
@@ -74,6 +47,8 @@ export declare class Transformer extends Disposable implements ITransformerConfi
|
|
|
74
47
|
anchorCornerRadius: number;
|
|
75
48
|
keepRatio: boolean;
|
|
76
49
|
centeredScaling: boolean;
|
|
50
|
+
zeroLeft: number;
|
|
51
|
+
zeroTop: number;
|
|
77
52
|
/**
|
|
78
53
|
* leftTop centerTop rightTop
|
|
79
54
|
* leftMiddle rightMiddle
|
|
@@ -88,10 +63,11 @@ export declare class Transformer extends Disposable implements ITransformerConfi
|
|
|
88
63
|
onChangeStartObservable: Observable<IChangeObserverConfig>;
|
|
89
64
|
onChangingObservable: Observable<IChangeObserverConfig>;
|
|
90
65
|
onChangeEndObservable: Observable<IChangeObserverConfig>;
|
|
91
|
-
onClearControlObservable: Observable<
|
|
66
|
+
onClearControlObservable: Observable<boolean>;
|
|
92
67
|
onCreateControlObservable: Observable<Group>;
|
|
93
68
|
private _startOffsetX;
|
|
94
69
|
private _startOffsetY;
|
|
70
|
+
private _startStateMap;
|
|
95
71
|
private _viewportScrollX;
|
|
96
72
|
private _viewportScrollY;
|
|
97
73
|
private _moveObserver;
|
|
@@ -99,30 +75,73 @@ export declare class Transformer extends Disposable implements ITransformerConfi
|
|
|
99
75
|
private _cancelFocusObserver;
|
|
100
76
|
private _transformerControlMap;
|
|
101
77
|
private _selectedObjectMap;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
78
|
+
private _observerObjectMap;
|
|
79
|
+
private _copperControl;
|
|
80
|
+
private _copperSelectedObject;
|
|
81
|
+
private _moveBufferSkip;
|
|
82
|
+
private _debounceClearFunc;
|
|
83
|
+
constructor(_scene: Scene, config?: ITransformerConfig);
|
|
84
|
+
changeNotification(): this;
|
|
85
|
+
getSelectedObjectMap(): Map<string, BaseObject>;
|
|
86
|
+
resetProps(config?: ITransformerConfig): void;
|
|
87
|
+
getScene(): Scene;
|
|
88
|
+
clearControls(changeSelf?: boolean): void;
|
|
89
|
+
updateControl(): void;
|
|
90
|
+
debounceRefreshControls(): void;
|
|
91
|
+
clearSelectedObjects(): void;
|
|
92
|
+
refreshControls(): this;
|
|
93
|
+
createControlForCopper(applyObject: BaseObject): void;
|
|
94
|
+
clearCopperControl(): void;
|
|
95
|
+
setSelectedControl(applyObject: BaseObject): void;
|
|
96
|
+
private _getConfig;
|
|
97
|
+
attachTo(applyObject: BaseObject): BaseObject;
|
|
98
|
+
detachFrom(applyObject: BaseObject): BaseObject;
|
|
106
99
|
dispose(): void;
|
|
107
100
|
private _initialProps;
|
|
108
|
-
private
|
|
101
|
+
private _checkMoveBoundary;
|
|
102
|
+
private _moving;
|
|
103
|
+
private _moveBufferBlocker;
|
|
109
104
|
private _anchorMoving;
|
|
105
|
+
private _moveFunc;
|
|
106
|
+
private _getMovePoint;
|
|
107
|
+
/**
|
|
108
|
+
*
|
|
109
|
+
*/
|
|
110
|
+
private _applyRotationForResult;
|
|
111
|
+
private _updateCloseKeepRatioState;
|
|
112
|
+
private _getLimitedSize;
|
|
113
|
+
private _resizeLeftTop;
|
|
114
|
+
private _resizeRightBottom;
|
|
115
|
+
private _resizeLeftBottom;
|
|
116
|
+
private _resizeRightTop;
|
|
117
|
+
private _fixMoveLtRb;
|
|
118
|
+
private _fixMoveLbRt;
|
|
110
119
|
private _attachEventToAnchor;
|
|
120
|
+
private _recoverySizeBoundary;
|
|
111
121
|
private _attachEventToRotate;
|
|
122
|
+
private _rotateMoving;
|
|
112
123
|
private _getOutlinePosition;
|
|
113
124
|
private _getRotateAnchorCursor;
|
|
125
|
+
private _getCopperAnchorPosition;
|
|
114
126
|
private _getRotateAnchorPosition;
|
|
115
127
|
private _createResizeAnchor;
|
|
128
|
+
private _createCopperResizeAnchor;
|
|
129
|
+
private _getNorthEastPoints;
|
|
130
|
+
private _getNorthWestPoints;
|
|
131
|
+
private _getSouthEastPoints;
|
|
132
|
+
private _getSouthWestPoints;
|
|
116
133
|
private _checkTransformerType;
|
|
117
134
|
private _updateControlIterator;
|
|
118
135
|
private _updateControl;
|
|
119
136
|
private _hideControl;
|
|
120
137
|
private _attachHover;
|
|
121
|
-
private
|
|
138
|
+
private _clearControls;
|
|
139
|
+
private _clearControlMap;
|
|
122
140
|
private _createControl;
|
|
123
141
|
private _getTopScene;
|
|
124
|
-
private _moving;
|
|
125
142
|
private _updateActiveObjectList;
|
|
143
|
+
private _findGroupObject;
|
|
126
144
|
private _addCancelObserver;
|
|
145
|
+
private _smoothAccuracy;
|
|
127
146
|
}
|
|
128
147
|
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ISrcRect, Nullable, PresetGeometryType } from '@univerjs/core';
|
|
2
|
+
import { UniverRenderingContext } from '../context';
|
|
3
|
+
import { IObjectFullState, IViewportInfo, RENDER_CLASS_TYPE } from '../basics';
|
|
4
|
+
import { IShapeProps, Shape } from './shape';
|
|
5
|
+
|
|
6
|
+
export interface IImageProps extends IShapeProps {
|
|
7
|
+
image?: HTMLImageElement;
|
|
8
|
+
url?: string;
|
|
9
|
+
success?: () => void;
|
|
10
|
+
fail?: () => void;
|
|
11
|
+
/**
|
|
12
|
+
* 20.1.8.55 srcRect (Source Rectangle)
|
|
13
|
+
*/
|
|
14
|
+
srcRect?: Nullable<ISrcRect>;
|
|
15
|
+
/**
|
|
16
|
+
* 20.1.9.18 prstGeom (Preset geometry)
|
|
17
|
+
*/
|
|
18
|
+
prstGeom?: Nullable<PresetGeometryType>;
|
|
19
|
+
}
|
|
20
|
+
export declare class Image extends Shape<IImageProps> {
|
|
21
|
+
protected _props: IImageProps;
|
|
22
|
+
protected _native: Nullable<HTMLImageElement>;
|
|
23
|
+
private _renderByCropper;
|
|
24
|
+
private _transformCalculateSrcRect;
|
|
25
|
+
constructor(id: string, config: IImageProps);
|
|
26
|
+
get srcRect(): Nullable<ISrcRect>;
|
|
27
|
+
get prstGeom(): Nullable<PresetGeometryType>;
|
|
28
|
+
get classType(): RENDER_CLASS_TYPE;
|
|
29
|
+
transformByStateCloseCropper(option: IObjectFullState): void;
|
|
30
|
+
changeSource(url: string): void;
|
|
31
|
+
resetSize(): void;
|
|
32
|
+
setPrstGeom(prstGeom?: Nullable<PresetGeometryType>): void;
|
|
33
|
+
setSrcRect(srcRect?: Nullable<ISrcRect>): void;
|
|
34
|
+
getProps(): IImageProps;
|
|
35
|
+
getNative(): Nullable<HTMLImageElement>;
|
|
36
|
+
getNativeSize(): {
|
|
37
|
+
width: number;
|
|
38
|
+
height: number;
|
|
39
|
+
};
|
|
40
|
+
closeRenderByCropper(): void;
|
|
41
|
+
openRenderByCropper(): void;
|
|
42
|
+
calculateTransformWithSrcRect(): {
|
|
43
|
+
left: number;
|
|
44
|
+
top: number;
|
|
45
|
+
width: number;
|
|
46
|
+
height: number;
|
|
47
|
+
angle: number;
|
|
48
|
+
};
|
|
49
|
+
private _transformBySrcRect;
|
|
50
|
+
render(mainCtx: UniverRenderingContext, bounds?: IViewportInfo): this;
|
|
51
|
+
protected _draw(ctx: UniverRenderingContext): void;
|
|
52
|
+
private _init;
|
|
53
|
+
private _updateSrcRectByTransform;
|
|
54
|
+
}
|
|
@@ -17,7 +17,7 @@ export * from './circle';
|
|
|
17
17
|
export * from './control';
|
|
18
18
|
export * from './drawing';
|
|
19
19
|
export * from './path';
|
|
20
|
-
export * from './
|
|
20
|
+
export * from './image';
|
|
21
21
|
export * from './rect';
|
|
22
22
|
export * from './regular-polygon';
|
|
23
23
|
export * from './rich-text';
|