@univerjs-pro/engine-shape 1.0.0-alpha.3 → 1.0.0-alpha.4
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 -0
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +1 -0
- package/lib/es/index.js +1 -1
- package/lib/facade.js +1 -0
- package/lib/index.js +1 -1
- package/lib/types/config/config.d.ts +5 -0
- package/lib/types/facade/f-connector-shape.d.ts +257 -0
- package/lib/types/facade/f-enum.d.ts +246 -0
- package/lib/types/facade/f-shape-text.d.ts +281 -0
- package/lib/types/facade/f-shape.d.ts +625 -0
- package/lib/types/facade/index.d.ts +6 -0
- package/lib/types/index.d.ts +15 -3
- package/lib/types/models/shape-model.d.ts +1 -1
- package/lib/types/plugin.d.ts +13 -0
- package/lib/types/services/connector-shape-host-adapter.d.ts +40 -0
- package/lib/types/services/connector-shape-host-adapter.service.d.ts +55 -0
- package/lib/types/services/shape-host-adapter.service.d.ts +103 -0
- package/lib/types/shape-type.d.ts +72 -19
- package/lib/types/utils/connector.util.d.ts +15 -0
- package/lib/types/utils/shape-shadow.util.d.ts +8 -0
- package/lib/types/utils/shape-text-behavior.util.d.ts +10 -2
- package/lib/types/utils/shape-text-converter.d.ts +14 -0
- package/lib/umd/facade.js +1 -0
- package/lib/umd/index.js +1 -1
- package/package.json +15 -2
|
@@ -0,0 +1,625 @@
|
|
|
1
|
+
import type { IBasicShapeData, ImageSourceTypeEnum, IPresetShapeConfig, IShapeData, IShapeHostAdapter, IShapeLineStyle, IShapePointWithAdjName, IShapeRef, IShapeRelationItem, IShapeSnapshot, IShapeTransform, IShapeUpdateInput, ShapeGradientTypeEnum, ShapeHostType, ShapeLineCapEnum, ShapeLineDashEnum, ShapeLineJoinEnum, ShapeTypeEnum } from '@univerjs-pro/engine-shape';
|
|
2
|
+
import type { Injector } from '@univerjs/core';
|
|
3
|
+
import { ShapeLineTypeEnum } from '@univerjs-pro/engine-shape';
|
|
4
|
+
import { FBase } from '@univerjs/core/facade';
|
|
5
|
+
import { FShapeText } from './f-shape-text';
|
|
6
|
+
type ShapeFill = NonNullable<IBasicShapeData['fill']>;
|
|
7
|
+
export interface IShapeGradientStop {
|
|
8
|
+
/** Stop position in the normalized gradient range. */
|
|
9
|
+
position: number;
|
|
10
|
+
/** Stop color. */
|
|
11
|
+
color: string;
|
|
12
|
+
/** Optional stop opacity. */
|
|
13
|
+
opacity?: number;
|
|
14
|
+
}
|
|
15
|
+
/** A connector attachment site in the Shape's local coordinate system. */
|
|
16
|
+
export interface IShapeConnectionSite {
|
|
17
|
+
/** Horizontal position relative to the Shape's top-left corner. */
|
|
18
|
+
x: number;
|
|
19
|
+
/** Vertical position relative to the Shape's top-left corner. */
|
|
20
|
+
y: number;
|
|
21
|
+
/** Stable site index used by Connector endpoint bindings. */
|
|
22
|
+
index: number;
|
|
23
|
+
/** Outward site angle in OOXML angle units (1/60000 degree). */
|
|
24
|
+
ang: number;
|
|
25
|
+
}
|
|
26
|
+
/** Optional image-fill properties accepted by `FShape.setImageFill()`. */
|
|
27
|
+
export type IShapeImageFillOptions = Pick<ShapeFill, 'imageFillMode' | 'imageOpacity' | 'imageRotateWithShape' | 'stretchFillRect' | 'srcRect' | 'imageTile'>;
|
|
28
|
+
/**
|
|
29
|
+
* A live, host-neutral facade handle for a Shape.
|
|
30
|
+
*
|
|
31
|
+
* @example Sheet
|
|
32
|
+
* ```ts
|
|
33
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
34
|
+
* const fWorksheet = fWorkbook.getSheetByName('Sheet1');
|
|
35
|
+
* const fShape = fWorksheet.insertShape({
|
|
36
|
+
* shapeType: univerAPI.Enum.ShapeTypeEnum.Rect,
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @example Doc
|
|
41
|
+
* ```ts
|
|
42
|
+
* const fDocument = univerAPI.getActiveDocument();
|
|
43
|
+
* const fShape = fDocument.insertShape({
|
|
44
|
+
* shapeType: univerAPI.Enum.ShapeTypeEnum.Rect,
|
|
45
|
+
* textRange: { startOffset: 0, endOffset: 0, collapsed: true },
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @example Slide
|
|
50
|
+
* ```ts
|
|
51
|
+
* const fPresentation = univerAPI.getActivePresentation();
|
|
52
|
+
* const fSlide = fPresentation.getSlideByIndex(0);
|
|
53
|
+
* const fShape = fSlide.insertShape({
|
|
54
|
+
* shapeType: univerAPI.Enum.ShapeTypeEnum.Rect,
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @example Board
|
|
59
|
+
* ```ts
|
|
60
|
+
* const fBoard = univerAPI.getActiveBoard();
|
|
61
|
+
* const fShape = fBoard.insertShape({
|
|
62
|
+
* shapeType: univerAPI.Enum.ShapeTypeEnum.Rect,
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* const snapshot = fShape.getSnapshot();
|
|
69
|
+
* console.log(snapshot);
|
|
70
|
+
*
|
|
71
|
+
* fShape
|
|
72
|
+
* .setShapeType(univerAPI.Enum.ShapeTypeEnum.Ellipse)
|
|
73
|
+
* .setSolidFill('#FF0000', 0.5)
|
|
74
|
+
* .setSize(200, 100)
|
|
75
|
+
* .setRotation(45)
|
|
76
|
+
* .setAbsolutePosition(100, 100)
|
|
77
|
+
* .setStroke({
|
|
78
|
+
* color: '#000000',
|
|
79
|
+
* width: 2,
|
|
80
|
+
* lineStrokeType: univerAPI.Enum.ShapeLineTypeEnum.SolidLine,
|
|
81
|
+
* dashType: univerAPI.Enum.ShapeLineDashEnum.Solid,
|
|
82
|
+
* capType: univerAPI.Enum.ShapeLineCapEnum.Round,
|
|
83
|
+
* lineJoinType: univerAPI.Enum.ShapeLineJoinEnum.Round,
|
|
84
|
+
* });
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export declare class FShape extends FBase {
|
|
88
|
+
protected readonly _shapeRef: IShapeRef;
|
|
89
|
+
protected readonly _injector: Injector;
|
|
90
|
+
constructor(_shapeRef: IShapeRef, _injector: Injector);
|
|
91
|
+
/**
|
|
92
|
+
* Whether this Shape is a Connector preset type.
|
|
93
|
+
* @returns {boolean} Whether this Shape is a Connector preset type.
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* console.log(fShape.isConnectorShape());
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
isConnectorShape(): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Returns the stable Shape identifier.
|
|
102
|
+
* @returns {string} The stable Shape identifier.
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* console.log(fShape.getId());
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
getId(): string;
|
|
109
|
+
/**
|
|
110
|
+
* Returns the user-facing Shape name.
|
|
111
|
+
* @returns {string | undefined} The Shape name, or `undefined` when none is configured.
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* console.log(fShape.getName());
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
getName(): string | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* Sets or clears the user-facing Shape name.
|
|
120
|
+
* @param {string | undefined} name The Shape name, or `undefined` to clear it.
|
|
121
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* fShape.setName('Revenue forecast');
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
setName(name?: string): this;
|
|
128
|
+
/**
|
|
129
|
+
* Returns the user-facing Shape description.
|
|
130
|
+
* @returns {string | undefined} The Shape description, or `undefined` when none is configured.
|
|
131
|
+
* @example
|
|
132
|
+
* ```ts
|
|
133
|
+
* console.log(fShape.getDescription());
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
getDescription(): string | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* Sets or clears the user-facing Shape description.
|
|
139
|
+
* @param {string | undefined} description The Shape description, or `undefined` to clear it.
|
|
140
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
141
|
+
* @example
|
|
142
|
+
* ```ts
|
|
143
|
+
* fShape.setDescription('Shows the quarterly revenue forecast.');
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
setDescription(description?: string): this;
|
|
147
|
+
/**
|
|
148
|
+
* Returns the Univer host type that owns this Shape.
|
|
149
|
+
* @returns {ShapeHostType} The Univer host type that owns this Shape.
|
|
150
|
+
* @example
|
|
151
|
+
* ```ts
|
|
152
|
+
* console.log(fShape.getHostType());
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
getHostType(): ShapeHostType;
|
|
156
|
+
/**
|
|
157
|
+
* Returns the current Shape preset type, or `null` when the Shape is unavailable.
|
|
158
|
+
* @returns {ShapeTypeEnum | null} The current Shape preset type, or `null` when the Shape is unavailable.
|
|
159
|
+
* @example
|
|
160
|
+
* ```ts
|
|
161
|
+
* console.log(fShape.getShapeType());
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
getShapeType(): ShapeTypeEnum | null;
|
|
165
|
+
/**
|
|
166
|
+
* Returns a detached copy of the current Shape data.
|
|
167
|
+
* @returns {IShapeData | null} A detached copy of the current Shape data, or `null` when the Shape is unavailable.
|
|
168
|
+
* @example
|
|
169
|
+
* ```ts
|
|
170
|
+
* const shapeData = fShape.getShapeData();
|
|
171
|
+
* console.log(shapeData?.fill, shapeData?.stroke);
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
getShapeData(): IShapeData | null;
|
|
175
|
+
/**
|
|
176
|
+
* Returns a detached snapshot of the Shape and its host identity.
|
|
177
|
+
* @returns {IShapeSnapshot | null} A detached snapshot of the Shape and its host identity, or `null` when the Shape is unavailable.
|
|
178
|
+
* @example
|
|
179
|
+
* ```ts
|
|
180
|
+
* console.log(fShape.getSnapshot());
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
getSnapshot(): IShapeSnapshot | null;
|
|
184
|
+
/**
|
|
185
|
+
* Returns a detached copy of the current Shape transform.
|
|
186
|
+
* @returns {IShapeTransform | null} A detached copy of the current Shape transform, or `null` when the Shape is unavailable.
|
|
187
|
+
* @example
|
|
188
|
+
* ```ts
|
|
189
|
+
* const transform = fShape.getTransform();
|
|
190
|
+
* console.log(transform?.left, transform?.top, transform?.width, transform?.height);
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
getTransform(): IShapeTransform | null;
|
|
194
|
+
/**
|
|
195
|
+
* Returns whether the Shape is visible in its host.
|
|
196
|
+
* @returns {boolean} Whether the Shape is visible.
|
|
197
|
+
* @example
|
|
198
|
+
* ```ts
|
|
199
|
+
* console.log(fShape.isVisible());
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
isVisible(): boolean;
|
|
203
|
+
/**
|
|
204
|
+
* Sets whether the Shape is visible in its host.
|
|
205
|
+
* @param {boolean} visible Whether the Shape should be visible.
|
|
206
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
207
|
+
* @example
|
|
208
|
+
* ```ts
|
|
209
|
+
* fShape.setVisible(false);
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
setVisible(visible: boolean): this;
|
|
213
|
+
/**
|
|
214
|
+
* Returns whether the Shape can be selected from the host canvas.
|
|
215
|
+
* @returns {boolean} Whether the Shape can be selected.
|
|
216
|
+
* @example
|
|
217
|
+
* ```ts
|
|
218
|
+
* console.log(fShape.isSelectable());
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
isSelectable(): boolean;
|
|
222
|
+
/**
|
|
223
|
+
* Sets whether the Shape can be selected from the host canvas.
|
|
224
|
+
* This does not change any host-specific hard-lock state.
|
|
225
|
+
* @param {boolean} selectable Whether the Shape should be selectable.
|
|
226
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
227
|
+
* @example
|
|
228
|
+
* ```ts
|
|
229
|
+
* fShape.setSelectable(false);
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
setSelectable(selectable: boolean): this;
|
|
233
|
+
/**
|
|
234
|
+
* Returns the text facade associated with this Shape.
|
|
235
|
+
* @returns {FShapeText} The text facade associated with this Shape.
|
|
236
|
+
* @example
|
|
237
|
+
* ```ts
|
|
238
|
+
* fShape.getText().setText('Quarterly review');
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
getText(): FShapeText;
|
|
242
|
+
/**
|
|
243
|
+
* Returns whether this Shape uses custom geometry.
|
|
244
|
+
* @returns {boolean} Whether this Shape uses custom geometry.
|
|
245
|
+
* @example
|
|
246
|
+
* ```ts
|
|
247
|
+
* console.log(fShape.isCustomShape());
|
|
248
|
+
* ```
|
|
249
|
+
*/
|
|
250
|
+
isCustomShape(): boolean;
|
|
251
|
+
/**
|
|
252
|
+
* Returns a detached copy of the custom geometry, or `null` when none is configured.
|
|
253
|
+
* @returns {IPresetShapeConfig | null} A detached copy of the custom geometry, or `null` when none is configured.
|
|
254
|
+
* @example
|
|
255
|
+
* ```ts
|
|
256
|
+
* const geometry = fShape.getCustomGeometry();
|
|
257
|
+
* console.log(geometry?.pathLst);
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
getCustomGeometry(): IPresetShapeConfig | null;
|
|
261
|
+
/**
|
|
262
|
+
* Changes the Shape preset type while preserving the remaining Shape data.
|
|
263
|
+
* @param {ShapeTypeEnum} shapeType The new Shape preset type.
|
|
264
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
265
|
+
* @example
|
|
266
|
+
* ```ts
|
|
267
|
+
* fShape.setShapeType(univerAPI.Enum.ShapeTypeEnum.Ellipse);
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
setShapeType(shapeType: ShapeTypeEnum): this;
|
|
271
|
+
/**
|
|
272
|
+
* Replaces the complete Shape data with a detached copy of the supplied value.
|
|
273
|
+
* @param {IShapeData} shapeData The new Shape data.
|
|
274
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
275
|
+
* @example
|
|
276
|
+
* ```ts
|
|
277
|
+
* fShape.setShapeData({
|
|
278
|
+
* shapeType: univerAPI.Enum.ShapeTypeEnum.Rect,
|
|
279
|
+
* fill: { fillType: univerAPI.Enum.ShapeFillEnum.SolidFill, color: '#4f90ff' },
|
|
280
|
+
* });
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
setShapeData(shapeData: IShapeData): this;
|
|
284
|
+
/**
|
|
285
|
+
* Applies a partial Shape transform update.
|
|
286
|
+
*
|
|
287
|
+
* In Docs, width, height, and rotation apply to both inline and floating Shapes. Left and top affect only
|
|
288
|
+
* non-inline Shapes because inline placement is controlled by the document text range. Docs also does not
|
|
289
|
+
* currently support changing flipX or flipY.
|
|
290
|
+
*
|
|
291
|
+
* @param {Partial<IShapeTransform>} transform A partial Shape transform update.
|
|
292
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
293
|
+
* @example
|
|
294
|
+
* ```ts
|
|
295
|
+
* fShape.setTransform({ left: 120, top: 80, rotation: 15 });
|
|
296
|
+
* ```
|
|
297
|
+
*/
|
|
298
|
+
setTransform(transform: Partial<IShapeTransform>): this;
|
|
299
|
+
/**
|
|
300
|
+
* Sets the Shape width and height. Both values must be greater than zero.
|
|
301
|
+
* @param {number} width The new Shape width in host-document units.
|
|
302
|
+
* @param {number} height The new Shape height in host-document units.
|
|
303
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
304
|
+
* @example
|
|
305
|
+
* ```ts
|
|
306
|
+
* fShape.setSize(240, 120);
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
setSize(width: number, height: number): this;
|
|
310
|
+
/**
|
|
311
|
+
* Sets the clockwise Shape rotation in degrees.
|
|
312
|
+
* @param {number} rotation The clockwise Shape rotation in degrees.
|
|
313
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
314
|
+
* @example
|
|
315
|
+
* ```ts
|
|
316
|
+
* fShape.setRotation(30);
|
|
317
|
+
* ```
|
|
318
|
+
*/
|
|
319
|
+
setRotation(rotation: number): this;
|
|
320
|
+
/**
|
|
321
|
+
* Sets the absolute host-document position of the Shape.
|
|
322
|
+
*
|
|
323
|
+
* In Docs, this changes the configured horizontal and vertical offsets only for non-inline Shapes. Inline Shapes
|
|
324
|
+
* remain positioned by their document text range. The horizontal offset is page-relative and the vertical offset
|
|
325
|
+
* is relative to the anchor paragraph.
|
|
326
|
+
*
|
|
327
|
+
* @param {number} left The new Shape left position in host-document units.
|
|
328
|
+
* @param {number} top The new Shape top position in host-document units.
|
|
329
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
330
|
+
* @example
|
|
331
|
+
* ```ts
|
|
332
|
+
* fShape.setAbsolutePosition(160, 96);
|
|
333
|
+
* ```
|
|
334
|
+
*/
|
|
335
|
+
setAbsolutePosition(left: number, top: number): this;
|
|
336
|
+
/**
|
|
337
|
+
* Sets detached custom geometry and marks this Shape as custom.
|
|
338
|
+
* @param {IPresetShapeConfig} customGeometry The new custom geometry.
|
|
339
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
340
|
+
* @example
|
|
341
|
+
* ```ts
|
|
342
|
+
* // Replace the preset geometry with an adjustable right arrow.
|
|
343
|
+
* fShape
|
|
344
|
+
* .setCustomGeometry({
|
|
345
|
+
* adjustValues: {
|
|
346
|
+
* adj1: [univerAPI.Enum.ShapeOperatorEnum.Val, 32000],
|
|
347
|
+
* },
|
|
348
|
+
* gd: {
|
|
349
|
+
* dx: [univerAPI.Enum.ShapeOperatorEnum.MulDiv, 'w', 'adj1', 100000],
|
|
350
|
+
* ix: [univerAPI.Enum.ShapeOperatorEnum.AddSub, 'r', 0, 'dx'],
|
|
351
|
+
* },
|
|
352
|
+
* ahLst: [{
|
|
353
|
+
* type: 'ahXY',
|
|
354
|
+
* gdRefX: 'adj1',
|
|
355
|
+
* minX: 0,
|
|
356
|
+
* maxX: 50000,
|
|
357
|
+
* pos: { x: 'dx', y: 'hd2' },
|
|
358
|
+
* }],
|
|
359
|
+
* cxnLst: [
|
|
360
|
+
* { ang: 0, x: 'r', y: 'hd2' },
|
|
361
|
+
* { ang: 180, x: 0, y: 'hd2' },
|
|
362
|
+
* ],
|
|
363
|
+
* rect: { l: 'dx', t: 0, r: 'ix', b: 'b' },
|
|
364
|
+
* pathLst: [{
|
|
365
|
+
* dataArray: [
|
|
366
|
+
* { command: 'M', points: [0, 0] },
|
|
367
|
+
* { command: 'L', points: ['ix', 0] },
|
|
368
|
+
* { command: 'L', points: ['r', 'hd2'] },
|
|
369
|
+
* { command: 'L', points: ['ix', 'b'] },
|
|
370
|
+
* { command: 'L', points: [0, 'b'] },
|
|
371
|
+
* { command: 'L', points: ['dx', 'hd2'] },
|
|
372
|
+
* { command: 'z', points: [] },
|
|
373
|
+
* ],
|
|
374
|
+
* }],
|
|
375
|
+
* })
|
|
376
|
+
* .setSolidFill('#16a34a', 0.92)
|
|
377
|
+
* .setStroke({
|
|
378
|
+
* lineStrokeType: univerAPI.Enum.ShapeLineTypeEnum.SolidLine,
|
|
379
|
+
* color: '#14532d',
|
|
380
|
+
* width: 3,
|
|
381
|
+
* });
|
|
382
|
+
* ```
|
|
383
|
+
*/
|
|
384
|
+
setCustomGeometry(customGeometry: IPresetShapeConfig): this;
|
|
385
|
+
/**
|
|
386
|
+
* Returns the sites where Connector endpoints can attach to this Shape.
|
|
387
|
+
* Coordinates are local to the unrotated Shape bounds. Shapes without
|
|
388
|
+
* connection-site geometry, including Connector Shapes, return an empty array.
|
|
389
|
+
* @returns {IShapeConnectionSite[]} The sites where Connector endpoints can attach to this Shape.
|
|
390
|
+
* @example
|
|
391
|
+
* ```ts
|
|
392
|
+
* const sites = fShape.getConnectionSites();
|
|
393
|
+
* console.log(sites.map(({ index, x, y }) => ({ index, x, y })));
|
|
394
|
+
* ```
|
|
395
|
+
*/
|
|
396
|
+
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
|
+
/**
|
|
409
|
+
* Returns the Shape and connection-site index bound to a Connector's start point, or `null` when unbound.
|
|
410
|
+
* @returns {IShapeRelationItem | null} The Shape and connection-site index bound to a Connector's start point, or `null` when unbound.
|
|
411
|
+
* @example
|
|
412
|
+
* ```ts
|
|
413
|
+
* console.log(fShape.getStartConnectInfo());
|
|
414
|
+
* ```
|
|
415
|
+
*/
|
|
416
|
+
getStartConnectInfo(): IShapeRelationItem | null;
|
|
417
|
+
/**
|
|
418
|
+
* Returns the Shape and connection-site index bound to a Connector's end point, or `null` when unbound.
|
|
419
|
+
* @returns {IShapeRelationItem | null} The Shape and connection-site index bound to a Connector's end point, or `null` when unbound.
|
|
420
|
+
* @example
|
|
421
|
+
* ```ts
|
|
422
|
+
* console.log(fShape.getEndConnectInfo());
|
|
423
|
+
* ```
|
|
424
|
+
*/
|
|
425
|
+
getEndConnectInfo(): IShapeRelationItem | null;
|
|
426
|
+
/**
|
|
427
|
+
* Replaces the current fill with a solid color and optional opacity.
|
|
428
|
+
* @param {string} color The new fill color.
|
|
429
|
+
* @param {number} [opacity] The new fill opacity, ranging from 0 (completely transparent) to 1 (completely opaque).
|
|
430
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
431
|
+
* @example
|
|
432
|
+
* ```ts
|
|
433
|
+
* fShape.setSolidFill('#4f90ff', 0.85);
|
|
434
|
+
* ```
|
|
435
|
+
*/
|
|
436
|
+
setSolidFill(color: string, opacity?: number): this;
|
|
437
|
+
/**
|
|
438
|
+
* Replaces the current fill with a gradient containing at least two color stops.
|
|
439
|
+
* @param {ShapeGradientTypeEnum} gradientType The new gradient type.
|
|
440
|
+
* @param {IShapeGradientStop[]} colorStops An array of at least two gradient stops.
|
|
441
|
+
* @param {number} [gradientAngle] The new gradient angle in degrees, used only for linear gradients.
|
|
442
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
443
|
+
* @example
|
|
444
|
+
* ```ts
|
|
445
|
+
* fShape.setGradientFill(univerAPI.Enum.ShapeGradientTypeEnum.Linear, [
|
|
446
|
+
* { position: 0, color: '#2563eb' },
|
|
447
|
+
* { position: 1, color: '#a855f7' },
|
|
448
|
+
* ], 45);
|
|
449
|
+
* ```
|
|
450
|
+
*/
|
|
451
|
+
setGradientFill(gradientType: ShapeGradientTypeEnum, colorStops: IShapeGradientStop[], gradientAngle?: number): this;
|
|
452
|
+
/**
|
|
453
|
+
* Replaces the current fill with an image source and optional image-fill settings.
|
|
454
|
+
* @param {string} source The image source, which can be a URL or base64 data URI.
|
|
455
|
+
* @param {ImageSourceTypeEnum} [imageSourceType] The type of the image source, either URL or base64.
|
|
456
|
+
* @param {IShapeImageFillOptions} [options] Optional image-fill settings, including fill mode, opacity, and rotation behavior.
|
|
457
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
458
|
+
* @example
|
|
459
|
+
* ```ts
|
|
460
|
+
* fShape.setImageFill(
|
|
461
|
+
* 'https://github.com/dream-num.png',
|
|
462
|
+
* univerAPI.Enum.ShapeImageSourceTypeEnum.URL,
|
|
463
|
+
* { imageOpacity: 0.9 }
|
|
464
|
+
* );
|
|
465
|
+
* ```
|
|
466
|
+
*/
|
|
467
|
+
setImageFill(source: string, imageSourceType?: ImageSourceTypeEnum, options?: IShapeImageFillOptions): this;
|
|
468
|
+
/**
|
|
469
|
+
* Removes the visible fill from this Shape.
|
|
470
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
471
|
+
* @example
|
|
472
|
+
* ```ts
|
|
473
|
+
* fShape.setNoneFill();
|
|
474
|
+
* ```
|
|
475
|
+
*/
|
|
476
|
+
setNoneFill(): this;
|
|
477
|
+
/**
|
|
478
|
+
* Replaces the complete Shape stroke configuration.
|
|
479
|
+
* @param {IShapeLineStyle} stroke The new Shape stroke configuration.
|
|
480
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
481
|
+
* @example
|
|
482
|
+
* ```ts
|
|
483
|
+
* fShape.setStroke({
|
|
484
|
+
* color: '#1e3a8a',
|
|
485
|
+
* width: 2,
|
|
486
|
+
* lineStrokeType: univerAPI.Enum.ShapeLineTypeEnum.SolidLine,
|
|
487
|
+
* dashType: univerAPI.Enum.ShapeLineDashEnum.Dash,
|
|
488
|
+
* });
|
|
489
|
+
* ```
|
|
490
|
+
*/
|
|
491
|
+
setStroke(stroke: IShapeLineStyle): this;
|
|
492
|
+
/**
|
|
493
|
+
* Sets the stroke color while preserving other stroke properties.
|
|
494
|
+
* @param {string} color The new stroke color.
|
|
495
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
496
|
+
* @example
|
|
497
|
+
* ```ts
|
|
498
|
+
* fShape.setStrokeColor('#1e3a8a');
|
|
499
|
+
* ```
|
|
500
|
+
*/
|
|
501
|
+
setStrokeColor(color: string): this;
|
|
502
|
+
/**
|
|
503
|
+
* Sets the stroke width while preserving other stroke properties.
|
|
504
|
+
* @param {number} width The new stroke width in host-document units.
|
|
505
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
506
|
+
* @example
|
|
507
|
+
* ```ts
|
|
508
|
+
* fShape.setStrokeWidth(3);
|
|
509
|
+
* ```
|
|
510
|
+
*/
|
|
511
|
+
setStrokeWidth(width: number): this;
|
|
512
|
+
/**
|
|
513
|
+
* Sets the stroke opacity while preserving other stroke properties.
|
|
514
|
+
* @param {number} opacity The new stroke opacity, ranging from 0 (completely transparent) to 1 (completely opaque).
|
|
515
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
516
|
+
* @example
|
|
517
|
+
* ```ts
|
|
518
|
+
* fShape.setStrokeOpacity(0.6);
|
|
519
|
+
* ```
|
|
520
|
+
*/
|
|
521
|
+
setStrokeOpacity(opacity: number): this;
|
|
522
|
+
/**
|
|
523
|
+
* Sets the stroke dash preset.
|
|
524
|
+
* @param {ShapeLineDashEnum} lineDashType The new stroke dash preset.
|
|
525
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
526
|
+
* @example
|
|
527
|
+
* ```ts
|
|
528
|
+
* fShape.setStrokeLineDashType(univerAPI.Enum.ShapeLineDashEnum.DashDot);
|
|
529
|
+
* ```
|
|
530
|
+
*/
|
|
531
|
+
setStrokeLineDashType(lineDashType: ShapeLineDashEnum): this;
|
|
532
|
+
/**
|
|
533
|
+
* Sets the stroke line-join preset.
|
|
534
|
+
* @param {ShapeLineJoinEnum} lineJoinType The new stroke line-join preset.
|
|
535
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
536
|
+
* @example
|
|
537
|
+
* ```ts
|
|
538
|
+
* fShape.setStrokeLineJoinType(univerAPI.Enum.ShapeLineJoinEnum.Round);
|
|
539
|
+
* ```
|
|
540
|
+
*/
|
|
541
|
+
setStrokeLineJoinType(lineJoinType: ShapeLineJoinEnum): this;
|
|
542
|
+
/**
|
|
543
|
+
* Sets the stroke line-cap preset.
|
|
544
|
+
* @param {ShapeLineCapEnum} lineCapType The new stroke line-cap preset.
|
|
545
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
546
|
+
* @example
|
|
547
|
+
* ```ts
|
|
548
|
+
* fShape.setStrokeLineCapType(univerAPI.Enum.ShapeLineCapEnum.Round);
|
|
549
|
+
* ```
|
|
550
|
+
*/
|
|
551
|
+
setStrokeLineCapType(lineCapType: ShapeLineCapEnum): this;
|
|
552
|
+
/**
|
|
553
|
+
* Sets the stroke line type.
|
|
554
|
+
* @param {ShapeLineTypeEnum} lineType The new stroke line type.
|
|
555
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
556
|
+
* @example
|
|
557
|
+
* ```ts
|
|
558
|
+
* fShape.setStrokeLineType(univerAPI.Enum.ShapeLineTypeEnum.SolidLine);
|
|
559
|
+
* ```
|
|
560
|
+
*/
|
|
561
|
+
setStrokeLineType(lineType: ShapeLineTypeEnum): this;
|
|
562
|
+
/**
|
|
563
|
+
* Applies a partial Shape update through the registered host adapter.
|
|
564
|
+
* @param {IShapeUpdateInput} input A partial Shape update.
|
|
565
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
566
|
+
* @example
|
|
567
|
+
* ```ts
|
|
568
|
+
* fShape.update({ transform: { left: 240, top: 120, rotation: 20 } });
|
|
569
|
+
* ```
|
|
570
|
+
*/
|
|
571
|
+
update(input: IShapeUpdateInput): this;
|
|
572
|
+
/**
|
|
573
|
+
* Removes the Shape and returns whether the host mutation succeeded.
|
|
574
|
+
* @returns {boolean} Whether the shape was successfully removed from its host.
|
|
575
|
+
* @example
|
|
576
|
+
* ```ts
|
|
577
|
+
* const removed = fShape.remove();
|
|
578
|
+
* console.log(removed);
|
|
579
|
+
* ```
|
|
580
|
+
*/
|
|
581
|
+
remove(): boolean;
|
|
582
|
+
/**
|
|
583
|
+
* Moves the Shape to the front of its host drawing order.
|
|
584
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
585
|
+
* @example
|
|
586
|
+
* ```ts
|
|
587
|
+
* fShape.bringToFront();
|
|
588
|
+
* ```
|
|
589
|
+
*/
|
|
590
|
+
bringToFront(): this;
|
|
591
|
+
/**
|
|
592
|
+
* Moves the Shape forward by one position in its host drawing order.
|
|
593
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
594
|
+
* @example
|
|
595
|
+
* ```ts
|
|
596
|
+
* fShape.bringForward();
|
|
597
|
+
* ```
|
|
598
|
+
*/
|
|
599
|
+
bringForward(): this;
|
|
600
|
+
/**
|
|
601
|
+
* Moves the Shape backward by one position in its host drawing order.
|
|
602
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
603
|
+
* @example
|
|
604
|
+
* ```ts
|
|
605
|
+
* fShape.sendBackward();
|
|
606
|
+
* ```
|
|
607
|
+
*/
|
|
608
|
+
sendBackward(): this;
|
|
609
|
+
/**
|
|
610
|
+
* Moves the Shape to the back of its host drawing order.
|
|
611
|
+
* @returns {FShape} This Shape facade for chaining.
|
|
612
|
+
* @example
|
|
613
|
+
* ```ts
|
|
614
|
+
* fShape.sendToBack();
|
|
615
|
+
* ```
|
|
616
|
+
*/
|
|
617
|
+
sendToBack(): this;
|
|
618
|
+
protected _getAdapter(): IShapeHostAdapter | null;
|
|
619
|
+
private _patchShapeData;
|
|
620
|
+
private _patchStroke;
|
|
621
|
+
private _getSnapshot;
|
|
622
|
+
private _getGeometryModel;
|
|
623
|
+
private _mutate;
|
|
624
|
+
}
|
|
625
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import './f-enum';
|
|
2
|
+
export { FConnectorShape } from './f-connector-shape';
|
|
3
|
+
export { FShape } from './f-shape';
|
|
4
|
+
export type { IShapeConnectionSite, IShapeGradientStop, IShapeImageFillOptions } from './f-shape';
|
|
5
|
+
export { FShapeText } from './f-shape-text';
|
|
6
|
+
export type { IShapeTextImageFillOptions } from './f-shape-text';
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
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, IShapeShadowEffect, IShapeText, IShapeTextBodyBehavior, IShapeTextData, IShapeTextDataModel,
|
|
5
|
-
export { ShapeTextAutoFitType } from '../src/shape-type';
|
|
6
|
-
export {
|
|
4
|
+
export type { IBasicShapeData, IConnectorLayoutResult, IConnectPointInfo, ICustomShapeTextData, ICxnShapeData, IDrawingRect, IGdContext, ILineType, IPathCommand, IPresetShapeConfig, IShapeAdjustItemResolved, IShapeData, IShapeJSONData, IShapeLineStyle, IShapePath, IShapePoint, IShapePointWithAdjName, IShapeRect, IShapeRelation, IShapeRelationItem, IShapeShadowEffect, IShapeText, IShapeTextBodyBehavior, IShapeTextBoxOptions, IShapeTextData, IShapeTextDataModel, IShapeTextRectPadding, ShapeShadowAlignment, ShapeTextHorizontalAnchor, } from '../src/shape-type';
|
|
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
|
+
export { applyShapeTextBoxOptions, resolveShapeTextBodyBehavior, resolveShapeTextBoxOptions, shouldUseFullShapeTextRectForAutoFit, } from '../src/utils/shape-text-behavior.util';
|
|
9
|
+
export type { IResolvedShapeTextBoxOptions } from '../src/utils/shape-text-behavior.util';
|
|
10
|
+
export { UniverShapePlugin } from './plugin';
|
|
7
11
|
export { computeConnectorRouteLayout, getBasicShapeRotateBound, routeConnectorLineShape, } from './render-engine/connector-points-util';
|
|
12
|
+
export { ConnectorShapeHostAdapter } from './services/connector-shape-host-adapter';
|
|
13
|
+
export { IConnectorShapeHostAdapter } from './services/connector-shape-host-adapter.service';
|
|
14
|
+
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';
|
|
8
17
|
export { ShapeDefaultConfig } from './shape-default';
|
|
9
18
|
export { resolveShapeDefaultInsertSize } from './shape-default-size';
|
|
10
19
|
export { ConnectorCoordinateTransform } from './util/connector-transform';
|
|
11
20
|
export { createUniqueShapeName } from './util/shape-name';
|
|
12
21
|
export { isConnectorShape, isCurvedConnectorShape, } from './util/shape-util';
|
|
22
|
+
export { buildConnectorEndpointUpdate, buildConnectorRoutePointsUpdate, createFreeConnectorPointInfo, resolveConnectorRoutePoints, resolveShapeConnectionPoint, } from './utils/connector.util';
|
|
23
|
+
export { applyDocumentToShapeText, applyRichTextToShapeText, applyShapeTextAlignment, applyShapeTextStyle, applyTextToShapeText, normalizeShapeTextData, shapeTextToRichTextValue, } from './utils/shape-text-converter';
|
|
24
|
+
export type { IShapeTextAlignmentOptions } from './utils/shape-text-converter';
|
|
@@ -26,7 +26,7 @@ export declare class BasicShapeModel implements IShapeModel {
|
|
|
26
26
|
* get shape text data
|
|
27
27
|
* @returns The shape text data
|
|
28
28
|
*/
|
|
29
|
-
getShapeTextData(): IShapeTextData
|
|
29
|
+
getShapeTextData(): IShapeTextData;
|
|
30
30
|
/**
|
|
31
31
|
* set shape text data
|
|
32
32
|
* @param shapeText The shape text data
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IUniverEngineShapeConfig } from './config/config';
|
|
2
|
+
import { IConfigService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
|
|
3
|
+
export declare class UniverShapePlugin extends Plugin {
|
|
4
|
+
private readonly _config;
|
|
5
|
+
protected readonly _injector: Injector;
|
|
6
|
+
private readonly _configService;
|
|
7
|
+
static type: UniverInstanceType;
|
|
8
|
+
static pluginName: string;
|
|
9
|
+
static packageName: string;
|
|
10
|
+
static version: string;
|
|
11
|
+
constructor(_config: Partial<IUniverEngineShapeConfig> | undefined, _injector: Injector, _configService: IConfigService);
|
|
12
|
+
onStarting(): void;
|
|
13
|
+
}
|