@univerjs-pro/engine-shape 1.0.0-alpha.6 → 1.0.0-alpha.8
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/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/facade.js +1 -1
- package/lib/index.js +1 -1
- package/lib/types/facade/f-connector-shape.d.ts +10 -3
- package/lib/types/facade/f-shape-text.d.ts +23 -2
- package/lib/types/facade/f-shape.d.ts +60 -16
- package/lib/types/index.d.ts +3 -5
- package/lib/types/models/shape-model.d.ts +10 -1
- package/lib/types/render-engine/shape-render-model.d.ts +1 -24
- package/lib/types/services/shape-host-adapter.service.d.ts +39 -1
- package/lib/types/shape-type.d.ts +35 -44
- package/lib/types/shapes/oval-callout1-shape.d.ts +1 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +6 -3
- package/lib/types/util/connector-points-util.d.ts +0 -56
- package/lib/types/utils/shape-shadow.util.d.ts +0 -8
|
@@ -16,11 +16,18 @@ import { FShape } from './f-shape';
|
|
|
16
16
|
* @example Doc
|
|
17
17
|
* ```ts
|
|
18
18
|
* const fDocument = univerAPI.getActiveDocument();
|
|
19
|
+
* const paragraph = fDocument.getParagraphs()[0];
|
|
19
20
|
* const fConnectorShape = fDocument.insertShape({
|
|
20
21
|
* shapeType: univerAPI.Enum.ShapeTypeEnum.StraightConnector1,
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
22
|
+
* placement: {
|
|
23
|
+
* wrappingStyle: univerAPI.Enum.DocsShapeWrappingStyle.WRAP_SQUARE,
|
|
24
|
+
* anchor: {
|
|
25
|
+
* paragraphId: paragraph.getId(),
|
|
26
|
+
* segmentId: paragraph.getSegmentId(),
|
|
27
|
+
* },
|
|
28
|
+
* position: { horizontalOffset: 80, verticalOffset: 80 },
|
|
29
|
+
* },
|
|
30
|
+
* transform: { width: 240, height: 120 },
|
|
24
31
|
* });
|
|
25
32
|
* ```
|
|
26
33
|
*
|
|
@@ -20,6 +20,9 @@ export interface IShapeTextImageFillOptions {
|
|
|
20
20
|
/**
|
|
21
21
|
* A live text facade for a Shape in any supported host.
|
|
22
22
|
*
|
|
23
|
+
* Sheet, Doc, Slide, and Board Shapes share this rich-text effect path. Glow and outer shadow support here does not
|
|
24
|
+
* imply that a host's standalone document text UI exposes the same authoring controls.
|
|
25
|
+
*
|
|
23
26
|
* @example Sheet
|
|
24
27
|
* ```ts
|
|
25
28
|
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
@@ -31,9 +34,16 @@ export interface IShapeTextImageFillOptions {
|
|
|
31
34
|
* @example Doc
|
|
32
35
|
* ```ts
|
|
33
36
|
* const fDocument = univerAPI.getActiveDocument();
|
|
37
|
+
* const paragraph = fDocument.getParagraphs()[0];
|
|
34
38
|
* const fShape = fDocument.insertShape({
|
|
35
39
|
* shapeType: univerAPI.Enum.ShapeTypeEnum.Rect,
|
|
36
|
-
*
|
|
40
|
+
* placement: {
|
|
41
|
+
* wrappingStyle: univerAPI.Enum.DocsShapeWrappingStyle.INLINE,
|
|
42
|
+
* anchor: {
|
|
43
|
+
* paragraphId: paragraph.getId(),
|
|
44
|
+
* segmentId: paragraph.getSegmentId(),
|
|
45
|
+
* },
|
|
46
|
+
* },
|
|
37
47
|
* });
|
|
38
48
|
* const fShapeText = fShape?.getText();
|
|
39
49
|
* ```
|
|
@@ -116,7 +126,18 @@ export declare class FShapeText {
|
|
|
116
126
|
* @returns {FShapeText} This Shape text facade for chaining.
|
|
117
127
|
* @example
|
|
118
128
|
* ```ts
|
|
119
|
-
* fShapeText.setTextStyle({
|
|
129
|
+
* fShapeText.setTextStyle({
|
|
130
|
+
* ff: 'Inter',
|
|
131
|
+
* fs: 18,
|
|
132
|
+
* glow: { color: '#f97316', radius: 6 },
|
|
133
|
+
* outerShadow: {
|
|
134
|
+
* color: '#000000',
|
|
135
|
+
* opacity: 0.35,
|
|
136
|
+
* blurRadius: 4,
|
|
137
|
+
* distance: 3,
|
|
138
|
+
* direction: 45,
|
|
139
|
+
* },
|
|
140
|
+
* });
|
|
120
141
|
* ```
|
|
121
142
|
*/
|
|
122
143
|
setTextStyle(style: ITextStyle): this;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { IBasicShapeData, ImageSourceTypeEnum, IPresetShapeConfig, IShapeData, IShapeHostAdapter, IShapeLineStyle,
|
|
1
|
+
import type { IBasicShapeData, ImageSourceTypeEnum, IPresetShapeConfig, IShapeAdjustItemResolved, IShapeData, IShapeHostAdapter, IShapeLineStyle, IShapeRef, IShapeRelationItem, IShapeSnapshot, IShapeTransform, IShapeUpdateInput, ShapeGradientTypeEnum, ShapeHostType, ShapeLineCapEnum, ShapeLineDashEnum, ShapeLineJoinEnum, ShapeTypeEnum } from '@univerjs-pro/engine-shape';
|
|
2
2
|
import type { Injector } from '@univerjs/core';
|
|
3
|
-
import { ShapeLineTypeEnum } from '@univerjs-pro/engine-shape';
|
|
3
|
+
import { IShapeHostAdapterRegistry, ShapeLineTypeEnum } from '@univerjs-pro/engine-shape';
|
|
4
|
+
import { ICommandService } from '@univerjs/core';
|
|
4
5
|
import { FBase } from '@univerjs/core/facade';
|
|
5
6
|
import { FShapeText } from './f-shape-text';
|
|
6
7
|
type ShapeFill = NonNullable<IBasicShapeData['fill']>;
|
|
@@ -40,9 +41,16 @@ export type IShapeImageFillOptions = Pick<ShapeFill, 'imageFillMode' | 'imageOpa
|
|
|
40
41
|
* @example Doc
|
|
41
42
|
* ```ts
|
|
42
43
|
* const fDocument = univerAPI.getActiveDocument();
|
|
44
|
+
* const paragraph = fDocument.getParagraphs()[0];
|
|
43
45
|
* const fShape = fDocument.insertShape({
|
|
44
46
|
* shapeType: univerAPI.Enum.ShapeTypeEnum.Rect,
|
|
45
|
-
*
|
|
47
|
+
* placement: {
|
|
48
|
+
* wrappingStyle: univerAPI.Enum.DocsShapeWrappingStyle.INLINE,
|
|
49
|
+
* anchor: {
|
|
50
|
+
* paragraphId: paragraph.getId(),
|
|
51
|
+
* segmentId: paragraph.getSegmentId(),
|
|
52
|
+
* },
|
|
53
|
+
* },
|
|
46
54
|
* });
|
|
47
55
|
* ```
|
|
48
56
|
*
|
|
@@ -87,7 +95,9 @@ export type IShapeImageFillOptions = Pick<ShapeFill, 'imageFillMode' | 'imageOpa
|
|
|
87
95
|
export declare class FShape extends FBase {
|
|
88
96
|
protected readonly _shapeRef: IShapeRef;
|
|
89
97
|
protected readonly _injector: Injector;
|
|
90
|
-
|
|
98
|
+
protected readonly _shapeHostAdapterRegistry: IShapeHostAdapterRegistry;
|
|
99
|
+
protected readonly _commandService: Pick<ICommandService, 'syncExecuteCommand'>;
|
|
100
|
+
constructor(_shapeRef: IShapeRef, _injector: Injector, _shapeHostAdapterRegistry: IShapeHostAdapterRegistry, _commandService: Pick<ICommandService, 'syncExecuteCommand'>);
|
|
91
101
|
/**
|
|
92
102
|
* Whether this Shape is a Connector preset type.
|
|
93
103
|
* @returns {boolean} Whether this Shape is a Connector preset type.
|
|
@@ -394,17 +404,6 @@ export declare class FShape extends FBase {
|
|
|
394
404
|
* ```
|
|
395
405
|
*/
|
|
396
406
|
getConnectionSites(): IShapeConnectionSite[];
|
|
397
|
-
/**
|
|
398
|
-
* Returns the geometry adjustment handles exposed by this Shape preset.
|
|
399
|
-
* Coordinates are local to the unrotated Shape bounds and `adjName` identifies
|
|
400
|
-
* the corresponding entry in `shapeData.adjustValues`.
|
|
401
|
-
* @returns {IShapePointWithAdjName[]} The geometry adjustment handles exposed by this Shape preset.
|
|
402
|
-
* @example
|
|
403
|
-
* ```ts
|
|
404
|
-
* console.log(fShape.getAdjustPoints());
|
|
405
|
-
* ```
|
|
406
|
-
*/
|
|
407
|
-
getAdjustPoints(): IShapePointWithAdjName[];
|
|
408
407
|
/**
|
|
409
408
|
* Returns the Shape and connection-site index bound to a Connector's start point, or `null` when unbound.
|
|
410
409
|
* @returns {IShapeRelationItem | null} The Shape and connection-site index bound to a Connector's start point, or `null` when unbound.
|
|
@@ -423,6 +422,51 @@ export declare class FShape extends FBase {
|
|
|
423
422
|
* ```
|
|
424
423
|
*/
|
|
425
424
|
getEndConnectInfo(): IShapeRelationItem | null;
|
|
425
|
+
/**
|
|
426
|
+
* Returns complete information for every adjustment handle exposed by this Shape.
|
|
427
|
+
* @returns {IShapeAdjustItemResolved[]} Detached resolved adjustment handles in preset order.
|
|
428
|
+
* @example
|
|
429
|
+
* ```ts
|
|
430
|
+
* fShape.setShapeType(univerAPI.Enum.ShapeTypeEnum.BlockArc);
|
|
431
|
+
*
|
|
432
|
+
* const handle = fShape.getAdjustHandles().find(({ gdRefR }) => gdRefR === 'adj3');
|
|
433
|
+
* console.log(handle?.type); // 'ahPolar'
|
|
434
|
+
* console.log(handle?.gdRefAng, handle?.gdRefR); // 'adj2', 'adj3'
|
|
435
|
+
* console.log(handle?.currentAdjustValues); // { adj2: 0, adj3: 25000 }
|
|
436
|
+
* console.log(handle?.resolvedMinR, handle?.resolvedMaxR); // 0, 50000
|
|
437
|
+
* ```
|
|
438
|
+
*/
|
|
439
|
+
getAdjustHandles(): IShapeAdjustItemResolved[];
|
|
440
|
+
/**
|
|
441
|
+
* Updates only the supplied Shape adjustment values and clamps them to their handle ranges.
|
|
442
|
+
* @param {Record<string, number>} adjustValues Adjustment names and values to update.
|
|
443
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
444
|
+
* @example
|
|
445
|
+
* ```ts
|
|
446
|
+
* fShape
|
|
447
|
+
* .setShapeType(univerAPI.Enum.ShapeTypeEnum.RoundRect)
|
|
448
|
+
* .setAdjustValues({ adj: 75000 });
|
|
449
|
+
*
|
|
450
|
+
* const [handle] = fShape.getAdjustHandles();
|
|
451
|
+
* console.log(handle.currentAdjustValues.adj); // 50000
|
|
452
|
+
* ```
|
|
453
|
+
*/
|
|
454
|
+
setAdjustValues(adjustValues: Record<string, number>): this;
|
|
455
|
+
/**
|
|
456
|
+
* Removes all Shape adjustment overrides and restores preset defaults.
|
|
457
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
458
|
+
* @example
|
|
459
|
+
* ```ts
|
|
460
|
+
* fShape
|
|
461
|
+
* .setShapeType(univerAPI.Enum.ShapeTypeEnum.RoundRect)
|
|
462
|
+
* .setAdjustValues({ adj: 40000 });
|
|
463
|
+
* fShape.resetAdjustValues();
|
|
464
|
+
*
|
|
465
|
+
* const [handle] = fShape.getAdjustHandles();
|
|
466
|
+
* console.log(handle.currentAdjustValues.adj); // 16667
|
|
467
|
+
* ```
|
|
468
|
+
*/
|
|
469
|
+
resetAdjustValues(): this;
|
|
426
470
|
/**
|
|
427
471
|
* Replaces the current fill with a solid color and optional opacity.
|
|
428
472
|
* @param {string} color The new fill color.
|
|
@@ -620,6 +664,6 @@ export declare class FShape extends FBase {
|
|
|
620
664
|
private _patchStroke;
|
|
621
665
|
private _getSnapshot;
|
|
622
666
|
private _getGeometryModel;
|
|
623
|
-
|
|
667
|
+
protected _mutate(operation: string, callback: (adapter: IShapeHostAdapter) => boolean): boolean;
|
|
624
668
|
}
|
|
625
669
|
export {};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
export { BasicShapeModel as ShapeModel } from '../src/models/shape-model';
|
|
2
2
|
export { BaseShapeRenderModel } from '../src/render-engine/shape-render-model';
|
|
3
3
|
export { ImageFillModeEnum, ImageSourceTypeEnum, ShapeArrowSizeEnum, ShapeArrowTypeEnum, ShapeFillEnum, ShapeGradientTypeEnum, ShapeLineCapEnum, ShapeLineDashEnum, ShapeLineJoinEnum, ShapeLineTypeEnum, ShapeOperatorEnum, ShapePresetShadowValEnum, ShapeRenderModeEnum, ShapeSketchTypeEnum, ShapeTypeEnum, } from '../src/shape-enum';
|
|
4
|
-
export type { IBasicShapeData, IConnectorLayoutResult, IConnectPointInfo, ICustomShapeTextData, ICxnShapeData, IDrawingRect, IGdContext, ILineType, IPathCommand, IPresetShapeConfig, IShapeAdjustItemResolved, IShapeData, IShapeJSONData, IShapeLineStyle, IShapePath, IShapePoint, IShapePointWithAdjName, IShapeRect, IShapeRelation, IShapeRelationItem,
|
|
4
|
+
export type { IBasicShapeData, IConnectorLayoutResult, IConnectPointInfo, ICustomShapeTextData, ICxnShapeData, IDrawingRect, IGdContext, ILineType, IPathCommand, IPresetShapeConfig, IShapeAdjustItemResolved, IShapeData, IShapeFormulaBinding, IShapeJSONData, IShapeLineStyle, IShapePath, IShapePoint, IShapePointWithAdjName, IShapeRect, IShapeRelation, IShapeRelationItem, IShapeText, IShapeTextBodyBehavior, IShapeTextBoxOptions, IShapeTextData, IShapeTextDataModel, IShapeTextRectPadding, ShapeTextHorizontalAnchor, } from '../src/shape-type';
|
|
5
5
|
export { ShapeTextAutoFitType, ShapeTextDirection, ShapeTextWrapType } from '../src/shape-type';
|
|
6
|
-
export type { IResolvedShapeShadow } from '../src/utils/shape-shadow.util';
|
|
7
|
-
export { resolveShapeShadow } from '../src/utils/shape-shadow.util';
|
|
8
6
|
export { applyShapeTextBoxOptions, resolveShapeTextBodyBehavior, resolveShapeTextBoxOptions, shouldUseFullShapeTextRectForAutoFit, } from '../src/utils/shape-text-behavior.util';
|
|
9
7
|
export type { IResolvedShapeTextBoxOptions } from '../src/utils/shape-text-behavior.util';
|
|
10
8
|
export { UniverShapePlugin } from './plugin';
|
|
@@ -12,8 +10,8 @@ export { computeConnectorRouteLayout, getBasicShapeRotateBound, routeConnectorLi
|
|
|
12
10
|
export { ConnectorShapeHostAdapter } from './services/connector-shape-host-adapter';
|
|
13
11
|
export { IConnectorShapeHostAdapter } from './services/connector-shape-host-adapter.service';
|
|
14
12
|
export type { IConnectorArrow, IConnectorEndpoint, IConnectorShapeSnapshot, } from './services/connector-shape-host-adapter.service';
|
|
15
|
-
export { IShapeHostAdapterRegistry, isShapeHostType, ShapeHostAdapterRegistry, } from './services/shape-host-adapter.service';
|
|
16
|
-
export type { IShapeCreateInput, IShapeHostAdapter, IShapeRef, IShapeScope, IShapeSnapshot, IShapeTransform, IShapeUpdateInput, ShapeHostType, } from './services/shape-host-adapter.service';
|
|
13
|
+
export { canApplyShapeFormulaLastValue, IShapeHostAdapterRegistry, isShapeHostType, ShapeHostAdapterRegistry, } from './services/shape-host-adapter.service';
|
|
14
|
+
export type { IShapeCreateInput, IShapeFormulaLastValueGuard, IShapeHostAdapter, IShapeHostChange, IShapeHostChangeStream, IShapeRef, IShapeScope, IShapeSnapshot, IShapeTransform, IShapeUpdateInput, ShapeHostType, } from './services/shape-host-adapter.service';
|
|
17
15
|
export { ShapeDefaultConfig } from './shape-default';
|
|
18
16
|
export { resolveShapeDefaultInsertSize } from './shape-default-size';
|
|
19
17
|
export { ConnectorCoordinateTransform } from './util/connector-transform';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { IBoundRectNoAngle } from '@univerjs/engine-render';
|
|
1
2
|
import type { ShapeTypeEnum } from '../shape-enum';
|
|
2
3
|
import type { IGdContext, IPresetShapeConfig, IShapeAdjustItemResolved, IShapeContextOptions, IShapeData, IShapeJSONData, IShapeModel, IShapePoint, IShapePointWithAdjName, IShapeRect, IShapeRelation, IShapeRelationItem, IShapeRenderParameters, IShapeTextData } from '../shape-type';
|
|
3
4
|
import { BasicShapeEnum } from '../shape-enum';
|
|
@@ -68,6 +69,7 @@ export declare class BasicShapeModel implements IShapeModel {
|
|
|
68
69
|
getAdjustInfoByName(adjName: string): IShapeAdjustItemResolved | undefined;
|
|
69
70
|
getAdjustInfo(index: number): IShapeAdjustItemResolved | undefined;
|
|
70
71
|
private _getAdjustIndexByName;
|
|
72
|
+
private _getAdjustNames;
|
|
71
73
|
private _getAdjScope;
|
|
72
74
|
private _setAdjustValue;
|
|
73
75
|
clearAdjustValue(): void;
|
|
@@ -111,6 +113,7 @@ export declare class BasicShapeModel implements IShapeModel {
|
|
|
111
113
|
*/
|
|
112
114
|
isHitLine(pointX: number, pointY: number, width: number, height: number, tolerance?: number): boolean;
|
|
113
115
|
render(canvasContext: CanvasRenderingContext2D, rect: IShapeRect, renderOption: IShapeRenderParameters): void;
|
|
116
|
+
getDrawingEffectBounds(rect: IShapeRect): IBoundRectNoAngle | undefined;
|
|
114
117
|
/**
|
|
115
118
|
* Build the shape outline path on the canvas context and clip.
|
|
116
119
|
* This only builds paths and clips — no fill or stroke is applied.
|
|
@@ -119,7 +122,13 @@ export declare class BasicShapeModel implements IShapeModel {
|
|
|
119
122
|
*/
|
|
120
123
|
buildClipPath(canvasContext: CanvasRenderingContext2D, rect: IShapeRect): IShapeRect | false;
|
|
121
124
|
getDrawingPoints(): IShapePointWithAdjName[];
|
|
122
|
-
|
|
125
|
+
calcAdjValues(rect: IShapeRect, point: IShapePoint, info: IShapeAdjustItemResolved, _isFlipH: boolean, _isFlipV: boolean): Record<string, number>;
|
|
126
|
+
private _getAdjustRefs;
|
|
127
|
+
private _seedAngleAdjustValue;
|
|
128
|
+
private _evaluateAdjustPosition;
|
|
129
|
+
private _calcAdjustDerivative;
|
|
130
|
+
private _solveAdjustDelta;
|
|
131
|
+
private _clamp;
|
|
123
132
|
dispose(): void;
|
|
124
133
|
private _getSnapshotAdjustValues;
|
|
125
134
|
private _cloneShapeDataWithSnapshotAdjustValues;
|
|
@@ -4,7 +4,6 @@ export declare abstract class BaseShapeRenderModel {
|
|
|
4
4
|
protected _isLineShape: boolean;
|
|
5
5
|
abstract readonly name: string;
|
|
6
6
|
abstract readonly presetShapeConfig: IPresetShapeConfig;
|
|
7
|
-
private _inverseCache;
|
|
8
7
|
isLineShape(): boolean;
|
|
9
8
|
getConnectorLinePoints(): IShapeGdContextKeyPoint[];
|
|
10
9
|
/**
|
|
@@ -78,6 +77,7 @@ export declare abstract class BaseShapeRenderModel {
|
|
|
78
77
|
* 而 Canvas ellipse() 使用参数角度:point = (rx·cos(t), ry·sin(t))。
|
|
79
78
|
* 对于非正圆的椭圆,两者不同。OOXML 中 cat2/sat2 公式正是执行此转换来定位
|
|
80
79
|
* moveTo 点和调节手柄,因此传给 Canvas 时必须做同样的转换。
|
|
80
|
+
* 半径必须使用 path 的逻辑坐标值;最终画布的非等比缩放不应再次改变参数角。
|
|
81
81
|
*/
|
|
82
82
|
private _ooxmlAngleToParametric;
|
|
83
83
|
/**
|
|
@@ -151,29 +151,6 @@ export declare abstract class BaseShapeRenderModel {
|
|
|
151
151
|
* Apply coordinate scaling to resolved path points in-place.
|
|
152
152
|
*/
|
|
153
153
|
private _scalePathPoints;
|
|
154
|
-
/**
|
|
155
|
-
* Check if the adjust handle at the given index has an inverse relationship.
|
|
156
|
-
* Uses cache to avoid recalculating.
|
|
157
|
-
* @param index The index of the adjust handle in ahLst
|
|
158
|
-
* @returns true if inverse relationship exists
|
|
159
|
-
*/
|
|
160
|
-
isInverse(index: number): boolean;
|
|
161
|
-
/**
|
|
162
|
-
* Detect if there's an inverse relationship between adj value and position.
|
|
163
|
-
* Analyzes the gd formula chain to find subtract patterns like "r - adj*k" or "b - adj*k".
|
|
164
|
-
* @param adjustInfo The adjust handle info
|
|
165
|
-
* @returns true if inverse relationship is detected
|
|
166
|
-
*/
|
|
167
|
-
private _detectInverseRelationship;
|
|
168
|
-
/**
|
|
169
|
-
* Recursively analyze gd formula to detect inverse relationship.
|
|
170
|
-
* Looking for patterns like: pos = r - f(adj) or pos = b - f(adj)
|
|
171
|
-
*/
|
|
172
|
-
private _analyzeFormulaForInverse;
|
|
173
|
-
/**
|
|
174
|
-
* Check if a gd variable depends on (is derived from) adjName
|
|
175
|
-
*/
|
|
176
|
-
private _dependsOnAdj;
|
|
177
154
|
getGdValue(key: number | IGdContextKey, gdRecord: Partial<IGdContext>): number;
|
|
178
155
|
private _renderAdjustHandles;
|
|
179
156
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IFormulaLastValue } from '@univerjs-pro/engine-formula';
|
|
2
|
+
import type { IAccessor, IDisposable, IMutationInfo } from '@univerjs/core';
|
|
2
3
|
import type { ShapeTypeEnum } from '../shape-enum';
|
|
3
4
|
import type { IShapeData } from '../shape-type';
|
|
5
|
+
import { UniverInstanceType } from '@univerjs/core';
|
|
4
6
|
export type ShapeHostType = UniverInstanceType.UNIVER_SHEET | UniverInstanceType.UNIVER_DOC | UniverInstanceType.UNIVER_SLIDE | UniverInstanceType.UNIVER_BOARD;
|
|
5
7
|
export declare function isShapeHostType(type: UniverInstanceType): type is ShapeHostType;
|
|
6
8
|
export interface IShapeScope {
|
|
@@ -15,6 +17,15 @@ export interface IShapeRef extends IShapeScope {
|
|
|
15
17
|
/** Stable Shape identifier within the host subunit. */
|
|
16
18
|
shapeId: string;
|
|
17
19
|
}
|
|
20
|
+
export interface IShapeHostChange {
|
|
21
|
+
/** Host unit whose persisted Shape projection may have changed. */
|
|
22
|
+
unitId: string;
|
|
23
|
+
}
|
|
24
|
+
export interface IShapeHostChangeStream {
|
|
25
|
+
subscribe(listener: (change: IShapeHostChange) => void): {
|
|
26
|
+
unsubscribe(): void;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
18
29
|
export interface IShapeTransform {
|
|
19
30
|
/** Horizontal position in host coordinates. */
|
|
20
31
|
left: number;
|
|
@@ -79,12 +90,39 @@ export interface IShapeUpdateInput {
|
|
|
79
90
|
/** Canvas selectability to update. Omit to preserve the current value. */
|
|
80
91
|
selectable?: boolean;
|
|
81
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Ephemeral compare-and-set guard carried by a derived Formula last-value mutation.
|
|
95
|
+
*
|
|
96
|
+
* The guard is deliberately excluded from persisted Shape data. It prevents an
|
|
97
|
+
* asynchronous result calculated from an older formula or External Reference
|
|
98
|
+
* binding from overwriting a newer user edit.
|
|
99
|
+
*/
|
|
100
|
+
export interface IShapeFormulaLastValueGuard {
|
|
101
|
+
expectedFormula: string;
|
|
102
|
+
expectedReferenceRevision: number;
|
|
103
|
+
}
|
|
104
|
+
/** Revalidates a Formula Shape result immediately before its Host mutation writes. */
|
|
105
|
+
export declare function canApplyShapeFormulaLastValue(accessor: IAccessor, ref: IShapeRef, currentFormula: string | undefined, guard: IShapeFormulaLastValueGuard | undefined): boolean;
|
|
82
106
|
export interface IShapeHostAdapter {
|
|
83
107
|
readonly hostType: ShapeHostType;
|
|
108
|
+
/** Emits after a Shape mutation has changed this host's persisted Shape data. */
|
|
109
|
+
readonly shapeChanged$?: IShapeHostChangeStream;
|
|
84
110
|
getShape(ref: IShapeRef): IShapeSnapshot | null;
|
|
85
111
|
listShapes(scope: IShapeScope): IShapeSnapshot[];
|
|
112
|
+
/**
|
|
113
|
+
* Lists Shapes from every subunit owned by one host Unit.
|
|
114
|
+
* Core consumers use this optional hook to rebuild runtime projections from persisted snapshots.
|
|
115
|
+
*/
|
|
116
|
+
listShapesInUnit?(unitId: string): IShapeSnapshot[];
|
|
86
117
|
createShape(scope: IShapeScope, input: IShapeCreateInput): IShapeSnapshot | null;
|
|
87
118
|
updateShape(ref: IShapeRef, input: IShapeUpdateInput): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Builds the Host's existing Shape mutation for a successful Formula result.
|
|
121
|
+
*
|
|
122
|
+
* Implementations must include `guard` in the mutation params and validate it
|
|
123
|
+
* in the mutation handler before replacing `formulaBinding.lastValue`.
|
|
124
|
+
*/
|
|
125
|
+
createFormulaLastValueMutation?(ref: IShapeRef, guard: IShapeFormulaLastValueGuard, lastValue: IFormulaLastValue): IMutationInfo | null;
|
|
88
126
|
removeShape(ref: IShapeRef): boolean;
|
|
89
127
|
bringToFront(ref: IShapeRef): boolean;
|
|
90
128
|
bringForward(ref: IShapeRef): boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { IFormulaLastValue } from '@univerjs-pro/engine-formula';
|
|
2
|
+
import type { HorizontalAlign, IDocumentData, IGlowEffect, IShadowEffect, VerticalAlign } from '@univerjs/core';
|
|
3
|
+
import type { BasicShapeEnum, ImageFillModeEnum, ImageSourceTypeEnum, ShapeArrowSizeEnum, ShapeArrowTypeEnum, ShapeFillEnum, ShapeGradientTypeEnum, ShapeLineCapEnum, ShapeLineDashEnum, ShapeLineJoinEnum, ShapeLineTypeEnum, ShapeOperatorEnum, ShapeRenderModeEnum, ShapeSketchTypeEnum, ShapeTypeEnum } from './shape-enum';
|
|
3
4
|
/**
|
|
4
5
|
* GdContext 用来计算 OOXML Shape 的 Geometry Definitions (gd)
|
|
5
6
|
* 包含:
|
|
@@ -575,7 +576,6 @@ export declare enum ShapeTextWrapType {
|
|
|
575
576
|
/** Wrap text inside the shape text box. */
|
|
576
577
|
Square = "square"
|
|
577
578
|
}
|
|
578
|
-
export type ShapeShadowAlignment = 'tl' | 't' | 'tr' | 'l' | 'ctr' | 'r' | 'bl' | 'b' | 'br';
|
|
579
579
|
export declare enum ShapeTextAutoFitType {
|
|
580
580
|
/** Do not automatically adjust overflowing text. */
|
|
581
581
|
NoAutoFit = "noAutoFit",
|
|
@@ -665,35 +665,26 @@ export interface ICustomShapeTextData extends IShapeTextAlign, IShapeTextBodyBeh
|
|
|
665
665
|
dataModel?: IShapeTextDataModel;
|
|
666
666
|
}
|
|
667
667
|
export type IShapeTextData = IShapeText | ICustomShapeTextData;
|
|
668
|
-
/**
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
sy?: number;
|
|
689
|
-
/** Horizontal shadow skew angle in degrees. */
|
|
690
|
-
skewX?: number;
|
|
691
|
-
/** Vertical shadow skew angle in degrees. */
|
|
692
|
-
skewY?: number;
|
|
693
|
-
/** Alignment point used while scaling or skewing the shadow. */
|
|
694
|
-
alignment?: ShapeShadowAlignment;
|
|
695
|
-
/** Whether the shadow rotates together with the shape. */
|
|
696
|
-
rotateWithShape?: boolean;
|
|
668
|
+
/** Formula data persisted by a formula-backed text-box shape. */
|
|
669
|
+
export interface IShapeFormulaBinding {
|
|
670
|
+
/**
|
|
671
|
+
* The complete formula string, including the leading equals sign.
|
|
672
|
+
*
|
|
673
|
+
* Every reference must include its worksheet or table name; unqualified references
|
|
674
|
+
* such as `=A1` are unsupported. For a Shape hosted by a Document, Slide, or Board,
|
|
675
|
+
* every reference must also include the workbook or Base name. Examples:
|
|
676
|
+
* `=Sheet1!A1`, `=Orders[Amount]`, `='[Sales Workbook]Sheet1'!A1`, and
|
|
677
|
+
* `=[Sales Base]!Orders[Amount]`.
|
|
678
|
+
*/
|
|
679
|
+
formula: string;
|
|
680
|
+
/** Whether value changes should be animated. Defaults to true. */
|
|
681
|
+
animationEnabled?: boolean;
|
|
682
|
+
/** Optional display format chosen for this shape. */
|
|
683
|
+
numberFormat?: {
|
|
684
|
+
pattern: string;
|
|
685
|
+
};
|
|
686
|
+
/** Last successful scalar value persisted with the Shape for stale-first reload rendering. */
|
|
687
|
+
lastValue?: IFormulaLastValue;
|
|
697
688
|
}
|
|
698
689
|
/**
|
|
699
690
|
* This interface defines the shape data structure , and this part will save in json
|
|
@@ -763,14 +754,18 @@ export interface IBasicShapeData {
|
|
|
763
754
|
adjustValues?: Record<string, number>;
|
|
764
755
|
isCustom?: boolean;
|
|
765
756
|
customGeometry?: IPresetShapeConfig;
|
|
766
|
-
/**
|
|
767
|
-
outerShadow?:
|
|
757
|
+
/** Outer shadow applied while rendering the shape path. */
|
|
758
|
+
outerShadow?: IShadowEffect;
|
|
759
|
+
/** Glow applied around the rendered shape path. */
|
|
760
|
+
glow?: IGlowEffect;
|
|
768
761
|
shapeText?: IShapeTextData;
|
|
769
762
|
/**
|
|
770
763
|
* Text box inset used to calculate the editable/rendered text rect.
|
|
771
764
|
* Values use the same drawing units as the shape rect.
|
|
772
765
|
*/
|
|
773
766
|
textRectPadding?: IShapeTextRectPadding;
|
|
767
|
+
/** Presence of this field identifies a formula shape. */
|
|
768
|
+
formulaBinding?: IShapeFormulaBinding;
|
|
774
769
|
}
|
|
775
770
|
export interface ICxnShapeData extends IBasicShapeData {
|
|
776
771
|
points?: Array<{
|
|
@@ -817,6 +812,8 @@ export interface IShapeHitTestResult {
|
|
|
817
812
|
hitType: ShapeHitTestHitTypeEnum;
|
|
818
813
|
}
|
|
819
814
|
export interface IPresetShapeConfig {
|
|
815
|
+
/** Arc angles are visual by default; guide-derived presets may already provide Canvas-compatible parametric angles. */
|
|
816
|
+
arcAngleMode?: 'visual' | 'parametric';
|
|
820
817
|
/** Adjustment values for shape parameters, each value typically ranges from 0 to 100000 */
|
|
821
818
|
adjustValues?: Record<string, ShapeOperatorValue>;
|
|
822
819
|
/** Guide definitions - formulas for calculating shape geometry */
|
|
@@ -829,9 +826,9 @@ export interface IPresetShapeConfig {
|
|
|
829
826
|
/** Angle in degrees (cd4 = 90°, cd2 = 180°, 3cd4 = 270°) */
|
|
830
827
|
ang: string | number;
|
|
831
828
|
/** X coordinate */
|
|
832
|
-
x
|
|
829
|
+
x: string | number;
|
|
833
830
|
/** Y coordinate */
|
|
834
|
-
y
|
|
831
|
+
y: string | number;
|
|
835
832
|
}>;
|
|
836
833
|
/** Text rectangle definition */
|
|
837
834
|
rect?: {
|
|
@@ -919,14 +916,8 @@ export interface IShapeAdjustItemResolved extends IShapeAdjustItem {
|
|
|
919
916
|
x: number;
|
|
920
917
|
y: number;
|
|
921
918
|
};
|
|
922
|
-
/** Current
|
|
923
|
-
|
|
924
|
-
/**
|
|
925
|
-
* Indicates inverse relationship between adj value and position.
|
|
926
|
-
* Calculated at runtime by analyzing gd formulas.
|
|
927
|
-
* When true, increasing adj value will decrease the position value.
|
|
928
|
-
*/
|
|
929
|
-
inverse?: boolean;
|
|
919
|
+
/** Current values of all adjustment parameters controlled by this handle. */
|
|
920
|
+
currentAdjustValues: Record<string, number>;
|
|
930
921
|
}
|
|
931
922
|
export interface IShapeRenderParameters {
|
|
932
923
|
renderMode?: ShapeRenderModeEnum;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { IPresetShapeConfig } from '../shape-type';
|
|
2
2
|
import { BaseShapeRenderModel } from '../render-engine/shape-render-model';
|
|
3
|
+
/** Legacy name for Excel's oval callout preset. */
|
|
3
4
|
export declare class OvalCallout1Shape extends BaseShapeRenderModel {
|
|
4
5
|
readonly name: string;
|
|
5
6
|
readonly presetShapeConfig: IPresetShapeConfig;
|