@univerjs-pro/engine-shape 0.25.0 → 1.0.0-alpha.0
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 +1 -1
- package/lib/es/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/types/index.d.ts +3 -2
- package/lib/types/{model → models}/shape-model.d.ts +11 -2
- package/lib/types/render-engine/custom-shape-render-model.d.ts +7 -0
- package/lib/types/render-engine/line-shape-render-model.d.ts +15 -0
- package/lib/types/render-engine/point-to-shape-transform.d.ts +3 -3
- package/lib/types/render-engine/shape-render-model.d.ts +4 -1
- package/lib/types/shape-type.d.ts +22 -0
- package/lib/types/util/shape-name.d.ts +1 -0
- package/lib/umd/index.js +1 -1
- package/package.json +3 -3
- /package/lib/types/{model → models}/group-shape-model.d.ts +0 -0
package/lib/types/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { BasicShapeModel as ShapeModel } from '../src/
|
|
1
|
+
export { BasicShapeModel as ShapeModel } from '../src/models/shape-model';
|
|
2
2
|
export { LineShapeRenderModel } from '../src/render-engine/line-shape-render-model';
|
|
3
3
|
export { BaseShapeRenderModel } from '../src/render-engine/shape-render-model';
|
|
4
4
|
export { BasicShapeEnum, ImageFillModeEnum, ImageSourceTypeEnum, ShapeArrowSizeEnum, ShapeArrowTypeEnum, ShapeFillEnum, ShapeGradientTypeEnum, ShapeLineCapEnum, ShapeLineDashEnum, ShapeLineJoinEnum, ShapeLineTypeEnum, ShapeOperatorEnum, ShapeRenderModeEnum, ShapeSketchTypeEnum, ShapeTypeEnum } from '../src/shape-enum';
|
|
5
|
-
export type { IBasicShapeData, IConnectorLayoutResult, IConnectorRouteLayoutResult, IConnectPointInfo, ICustomShapeTextData, ICxnShapeData, IDrawingRect, IGdContext, IGdContextBase, ILineType, IPathCommand, IPresetShapeConfig, IShapeAdjustItem, IShapeAdjustItemResolved, IShapeContextOptions, IShapeData, IShapeHitTestResult, IShapeJSONData, IShapeLineStyle, IShapeModel, IShapePath, IShapePoint, IShapePointWithAdjName, IShapeRect, IShapeRelation, IShapeRelationItem, IShapeRenderParameters, IShapeText, ShapeAdjustHandleTypeEnum, ShapeHitTestHitTypeEnum, } from '../src/shape-type';
|
|
5
|
+
export type { IBasicShapeData, IConnectorLayoutResult, IConnectorRouteLayoutResult, IConnectPointInfo, ICustomShapeTextData, ICxnShapeData, IDrawingRect, IGdContext, IGdContextBase, ILineType, IPathCommand, IPresetShapeConfig, IShapeAdjustItem, IShapeAdjustItemResolved, IShapeContextOptions, IShapeData, IShapeHitTestResult, IShapeJSONData, IShapeLineStyle, IShapeModel, IShapePath, IShapePoint, IShapePointWithAdjName, IShapeRect, IShapeRelation, IShapeRelationItem, IShapeRenderParameters, IShapeText, IShapeTextRectPadding, ShapeAdjustHandleTypeEnum, ShapeHitTestHitTypeEnum, ShapeTextDirection, } from '../src/shape-type';
|
|
6
6
|
export { AccentBorderCallout1Shape } from '../src/shapes/accent-border-callout1-shape';
|
|
7
7
|
export { AccentBorderCallout2Shape } from '../src/shapes/accent-border-callout2-shape';
|
|
8
8
|
export { AccentBorderCallout3Shape } from '../src/shapes/accent-border-callout3-shape';
|
|
@@ -197,4 +197,5 @@ export { ShapeDefaultConfig } from './shape-default';
|
|
|
197
197
|
export { freeRouteBentConnectorLinePoints } from './util/connector-points-util';
|
|
198
198
|
export type { IBentConnectorResult } from './util/connector-points-util';
|
|
199
199
|
export { ConnectorCoordinateTransform } from './util/connector-transform';
|
|
200
|
+
export { createUniqueShapeName } from './util/shape-name';
|
|
200
201
|
export { isConnectorShape, isCurvedConnectorShape } from './util/shape-util';
|
|
@@ -5,6 +5,7 @@ export declare function deepMerge<T extends Record<string, any>>(target: T, ...s
|
|
|
5
5
|
export declare class BasicShapeModel implements IShapeModel {
|
|
6
6
|
protected _shapeType: ShapeTypeEnum;
|
|
7
7
|
private readonly _id;
|
|
8
|
+
private _name?;
|
|
8
9
|
protected _shapeData: IShapeData;
|
|
9
10
|
/**
|
|
10
11
|
* this property is only used for LineShapeRenderModel to indicate whether to render line points for routing
|
|
@@ -13,12 +14,14 @@ export declare class BasicShapeModel implements IShapeModel {
|
|
|
13
14
|
private _context;
|
|
14
15
|
private _renderModel;
|
|
15
16
|
private _adjustNameMap;
|
|
16
|
-
constructor(shapeType: ShapeTypeEnum, id: string, shapeData?: IShapeData);
|
|
17
|
+
constructor(shapeType: ShapeTypeEnum, id: string, shapeData?: IShapeData, name?: string);
|
|
17
18
|
changeShapeType(shapeType: ShapeTypeEnum, shapeData?: IShapeData): void;
|
|
18
19
|
getShapeType(): ShapeTypeEnum;
|
|
19
20
|
getShapeRelation(): IShapeRelation | undefined;
|
|
20
21
|
getBasicShapeType(): BasicShapeEnum;
|
|
21
22
|
getId(): string;
|
|
23
|
+
getName(): string | undefined;
|
|
24
|
+
setName(name?: string): void;
|
|
22
25
|
/**
|
|
23
26
|
* get shape text data
|
|
24
27
|
* @returns The shape text data
|
|
@@ -68,6 +71,9 @@ export declare class BasicShapeModel implements IShapeModel {
|
|
|
68
71
|
private _getAdjScope;
|
|
69
72
|
private _setAdjustValue;
|
|
70
73
|
clearAdjustValue(): void;
|
|
74
|
+
cloneShapeDataForShapeType(shapeType: ShapeTypeEnum): IShapeData;
|
|
75
|
+
cloneSnapshot(): IShapeJSONData;
|
|
76
|
+
cloneSnapshotForShapeType(shapeType: ShapeTypeEnum): IShapeJSONData;
|
|
71
77
|
/**
|
|
72
78
|
* et adjust value by adj name
|
|
73
79
|
* @param {string} adjName The name of adj point
|
|
@@ -113,8 +119,11 @@ export declare class BasicShapeModel implements IShapeModel {
|
|
|
113
119
|
*/
|
|
114
120
|
buildClipPath(canvasContext: CanvasRenderingContext2D, rect: IShapeRect): IShapeRect | false;
|
|
115
121
|
getDrawingPoints(): IShapePointWithAdjName[];
|
|
116
|
-
calcAdjValue(rect: IShapeRect, point: IShapePoint, adjustInfo: IShapeAdjustItemResolved,
|
|
122
|
+
calcAdjValue(rect: IShapeRect, point: IShapePoint, adjustInfo: IShapeAdjustItemResolved, _isFlipH: boolean, _isFlipV: boolean): number;
|
|
117
123
|
dispose(): void;
|
|
124
|
+
private _getSnapshotAdjustValues;
|
|
125
|
+
private _cloneShapeDataWithSnapshotAdjustValues;
|
|
118
126
|
toJSON(): IShapeJSONData;
|
|
119
127
|
fromJSON(json: IShapeJSONData): void;
|
|
128
|
+
private _createRenderModel;
|
|
120
129
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IPresetShapeConfig } from '../shape-type';
|
|
2
|
+
import { BaseShapeRenderModel } from './shape-render-model';
|
|
3
|
+
export declare class CustomShapeRenderModel extends BaseShapeRenderModel {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly presetShapeConfig: IPresetShapeConfig;
|
|
6
|
+
constructor(name: string, presetShapeConfig: IPresetShapeConfig);
|
|
7
|
+
}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import type { IShapeData, IShapePoint, IShapeRect, IShapeRenderParameters } from '../shape-type';
|
|
2
2
|
import type { BaseShapeContext } from './base-shape-context';
|
|
3
3
|
import { BaseShapeRenderModel } from './shape-render-model';
|
|
4
|
+
/**
|
|
5
|
+
* Interface for storing complete path command information for line shapes
|
|
6
|
+
* Used to preserve bezier curve data when redrawing with arrow adjustments
|
|
7
|
+
*/
|
|
8
|
+
export interface ILinePathCommand {
|
|
9
|
+
command: string;
|
|
10
|
+
points: number[];
|
|
11
|
+
}
|
|
4
12
|
/**
|
|
5
13
|
* Base class for line-type shapes (connectors, lines).
|
|
6
14
|
*
|
|
@@ -13,6 +21,11 @@ import { BaseShapeRenderModel } from './shape-render-model';
|
|
|
13
21
|
*/
|
|
14
22
|
export declare abstract class LineShapeRenderModel extends BaseShapeRenderModel {
|
|
15
23
|
protected _isLineShape: boolean;
|
|
24
|
+
static toRoundedPolylineCommands(commands: ILinePathCommand[], cornerRadius: number): ILinePathCommand[];
|
|
25
|
+
private static _cloneLinePathCommands;
|
|
26
|
+
private static _isLineOnlyPolyline;
|
|
27
|
+
private static _getPolylineCommandPoint;
|
|
28
|
+
private static _getRoundedCorner;
|
|
16
29
|
/**
|
|
17
30
|
* Check if a point is near a line segment.
|
|
18
31
|
*
|
|
@@ -84,8 +97,10 @@ export declare abstract class LineShapeRenderModel extends BaseShapeRenderModel
|
|
|
84
97
|
render(canvasContext: CanvasRenderingContext2D, rect: IShapeRect, shapeContext: BaseShapeContext, shapeData: IShapeData, renderOption: IShapeRenderParameters): void;
|
|
85
98
|
private _scalePoints;
|
|
86
99
|
private _executePathCommand;
|
|
100
|
+
private _drawLinePathCommands;
|
|
87
101
|
private _applyFill;
|
|
88
102
|
private _applyStrokeWithArrows;
|
|
103
|
+
private _getLineCornerRadius;
|
|
89
104
|
/**
|
|
90
105
|
* Extract start and end points with tangent direction points for arrow rendering
|
|
91
106
|
* For bezier curves, uses control points to get correct tangent direction
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { IShapePoint } from '../shape-type';
|
|
2
|
-
interface
|
|
2
|
+
interface IPoint {
|
|
3
3
|
x: number;
|
|
4
4
|
y: number;
|
|
5
5
|
}
|
|
6
|
-
interface
|
|
6
|
+
interface ITransformResult {
|
|
7
7
|
rotation: 0 | 90 | 180 | 270;
|
|
8
8
|
flipH: boolean;
|
|
9
9
|
flipV: boolean;
|
|
10
10
|
restorePoints: IShapePoint[];
|
|
11
11
|
}
|
|
12
|
-
export declare function resolveTransform(points:
|
|
12
|
+
export declare function resolveTransform(points: IPoint[]): ITransformResult;
|
|
13
13
|
export {};
|
|
@@ -23,7 +23,10 @@ export declare abstract class BaseShapeRenderModel {
|
|
|
23
23
|
* @param gdRecord The current gdRecord used to calculate text rect, if the shape has transformed, should use the latest gdRecord
|
|
24
24
|
* @returns {IShapeRect} The text rectangle within the shape
|
|
25
25
|
*/
|
|
26
|
-
getTextRect(rect: IShapeRect, gdRecord: Partial<IGdContext
|
|
26
|
+
getTextRect(rect: IShapeRect, gdRecord: Partial<IGdContext>, shapeData?: IShapeData): IShapeRect;
|
|
27
|
+
private _hasExplicitTextRectPadding;
|
|
28
|
+
private _getPaddedWholeRect;
|
|
29
|
+
private _getTextRectPadding;
|
|
27
30
|
/**
|
|
28
31
|
* 计算所有可填充路径(fill !== 'none')的实际包围盒。
|
|
29
32
|
*
|
|
@@ -104,6 +104,7 @@ export interface IGdContextBase {
|
|
|
104
104
|
lsd32: number;
|
|
105
105
|
}
|
|
106
106
|
export interface IGdContext extends IGdContextBase {
|
|
107
|
+
[key: string]: number | undefined;
|
|
107
108
|
x0?: number;
|
|
108
109
|
x1?: number;
|
|
109
110
|
x2?: number;
|
|
@@ -550,8 +551,16 @@ export interface IShapePath {
|
|
|
550
551
|
/** Parsed path data array (alternative to data string) */
|
|
551
552
|
dataArray?: IPathCommand[];
|
|
552
553
|
}
|
|
554
|
+
export type ShapeTextDirection = 'horz' | 'vert' | 'vert270' | 'wordArtVert' | 'eaVert' | 'mongolianVert' | 'wordArtVertRtl';
|
|
553
555
|
export interface IShapeTextAlign {
|
|
554
556
|
isHorizontal: boolean;
|
|
557
|
+
textDirection?: ShapeTextDirection;
|
|
558
|
+
}
|
|
559
|
+
export interface IShapeTextRectPadding {
|
|
560
|
+
left: number;
|
|
561
|
+
top: number;
|
|
562
|
+
right: number;
|
|
563
|
+
bottom: number;
|
|
555
564
|
}
|
|
556
565
|
export interface IShapeText extends IShapeTextAlign {
|
|
557
566
|
isRichText: false;
|
|
@@ -571,6 +580,7 @@ export interface ICustomShapeTextData extends IShapeTextAlign {
|
|
|
571
580
|
*/
|
|
572
581
|
export interface IBasicShapeData {
|
|
573
582
|
shapeType?: ShapeTypeEnum;
|
|
583
|
+
isTextBox?: boolean;
|
|
574
584
|
fill?: {
|
|
575
585
|
color?: string;
|
|
576
586
|
fillType?: ShapeFillEnum;
|
|
@@ -580,6 +590,7 @@ export interface IBasicShapeData {
|
|
|
580
590
|
gradientStops?: Array<{
|
|
581
591
|
position: number;
|
|
582
592
|
color: string;
|
|
593
|
+
opacity?: number;
|
|
583
594
|
}>;
|
|
584
595
|
/**
|
|
585
596
|
* Image fill source, can be a URL or base64 data URI. When fillType is 'image', this specifies the image to use for filling the shape.
|
|
@@ -630,7 +641,14 @@ export interface IBasicShapeData {
|
|
|
630
641
|
};
|
|
631
642
|
stroke?: IShapeLineStyle;
|
|
632
643
|
adjustValues?: Record<string, number>;
|
|
644
|
+
isCustom?: boolean;
|
|
645
|
+
customGeometry?: IPresetShapeConfig;
|
|
633
646
|
shapeText?: IShapeText | ICustomShapeTextData;
|
|
647
|
+
/**
|
|
648
|
+
* Text box inset used to calculate the editable/rendered text rect.
|
|
649
|
+
* Values use the same drawing units as the shape rect.
|
|
650
|
+
*/
|
|
651
|
+
textRectPadding?: IShapeTextRectPadding;
|
|
634
652
|
}
|
|
635
653
|
export interface ICxnShapeData extends IBasicShapeData {
|
|
636
654
|
points?: Array<{
|
|
@@ -656,6 +674,7 @@ export interface IGroupShapeData {
|
|
|
656
674
|
export type IShapeData = IBasicShapeData | ICxnShapeData;
|
|
657
675
|
export interface IShapeJSONData {
|
|
658
676
|
id: string;
|
|
677
|
+
name?: string;
|
|
659
678
|
shapeData: IShapeData;
|
|
660
679
|
shapeType: ShapeTypeEnum;
|
|
661
680
|
}
|
|
@@ -812,6 +831,7 @@ export interface IShapeLineStyle {
|
|
|
812
831
|
color?: string;
|
|
813
832
|
width?: number;
|
|
814
833
|
opacity?: number;
|
|
834
|
+
cornerRadius?: number;
|
|
815
835
|
dashType?: ShapeLineDashEnum;
|
|
816
836
|
capType?: ShapeLineCapEnum;
|
|
817
837
|
lineJoinType?: ShapeLineJoinEnum;
|
|
@@ -824,6 +844,8 @@ export interface IShapeLineStyle {
|
|
|
824
844
|
export interface IShapeModel {
|
|
825
845
|
getBasicShapeType(): BasicShapeEnum;
|
|
826
846
|
getId(): string;
|
|
847
|
+
getName(): string | undefined;
|
|
848
|
+
setName(name?: string): void;
|
|
827
849
|
dispose(): void;
|
|
828
850
|
getShapeData(): IShapeData;
|
|
829
851
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createUniqueShapeName(shapeType: string, usedNames: Iterable<string | undefined | null>): string;
|