@univerjs-pro/engine-shape 0.15.5 → 0.16.0-insiders.20260228-a20b9a7

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/README.md CHANGED
@@ -1,232 +1,82 @@
1
- # EngineShape
2
-
1
+ # @univerjs-pro/engine-shape
3
2
 
4
3
  [![npm version](https://img.shields.io/npm/v/@univerjs-pro/engine-shape)](https://npmjs.org/packages/@univerjs-pro/engine-shape)
5
4
  [![license](https://img.shields.io/npm/l/@univerjs-pro/engine-shape)](https://img.shields.io/npm/l/@univerjs-pro/engine-shape)
6
- ![CSS Included](https://img.shields.io/badge/CSS_Included-blue?logo=CSS3)
7
- ![i18n](https://img.shields.io/badge/zh--CN%20%7C%20en--US-cornflowerblue?label=i18n)
8
5
 
9
- This plugin provide the basic preset shape like excel.
6
+ ## Introduction
7
+
8
+ Engine Shape is the core shape definition and rendering engine for Univer. It provides 180+ preset shapes compatible with Excel/OOXML, covering basic shapes, arrows, flowcharts, callouts, connectors, and more. This package handles shape geometry computation, path rendering, fill/stroke styling, adjust points, connection sites, and connector routing.
10
9
 
10
+ ## Usage
11
11
 
12
12
  ### Installation
13
13
 
14
- Shape Feature provide the ability to rendering basic shape like excel.
14
+ ```shell
15
+ # Using npm
16
+ npm install @univerjs-pro/engine-shape
17
+
18
+ # Using pnpm
19
+ pnpm add @univerjs-pro/engine-shape
20
+ ```
15
21
 
16
- This feature includes the following packages:
22
+ ## Features
17
23
 
18
- - `@univerjs-pro/engine-shape` - Basic shape define and render.
24
+ ### Preset Shapes
19
25
 
20
- ```shell npm2yarn
21
- npm install @univerjs-pro/engine-shape
22
- ```
26
+ The library provides 180+ preset shape types organized into the following categories:
23
27
 
28
+ | Category | Examples |
29
+ |---|---|
30
+ | **Basic Shapes** | Rectangle, RoundRectangle, Ellipse, Diamond, Triangle, Hexagon, Octagon, Star, etc. |
31
+ | **Arrows** | RightArrow, LeftArrow, UpArrow, BentArrow, CurvedArrow, StripedRightArrow, Chevron, etc. |
32
+ | **Flowcharts** | Process, Decision, InputOutput, Document, Terminator, Preparation, ManualInput, etc. |
33
+ | **Callouts** | WedgeRectCallout, WedgeEllipseCallout, CloudCallout, BorderCallout, AccentCallout, etc. |
34
+ | **Stars & Ribbons** | Star4–Star32, Ribbon, EllipseRibbon, VerticalScroll, HorizontalScroll, Wave, etc. |
35
+ | **Math** | MathPlus, MathMinus, MathMultiply, MathDivide, MathEqual, MathNotEqual |
36
+ | **Connectors** | StraightConnector, BentConnector (2–5), CurvedConnector (2–5), Line |
37
+ | **Action Buttons** | Home, Help, Information, Return, BackPrevious, ForwardNext, etc. |
38
+ | **Others** | Cube, Can, Heart, Sun, Moon, SmileyFace, Cloud, Funnel, Gear, etc. |
24
39
 
25
- ### Preset shapes
26
-
27
- This lib provide about 180+ kind of shapes.
28
-
29
- ```typescript
30
- export enum ShapeTypeEnum {
31
- // Basic Shapes
32
- Rectangle = 'rect',
33
- RoundRectangle = 'roundRect',
34
- Ellipse = 'ellipse',
35
- Diamond = 'diamond',
36
- Triangle = 'triangle',
37
- RightTriangle = 'rtTriangle',
38
- Parallelogram = 'parallelogram',
39
- Trapezoid = 'trapezoid',
40
- Hexagon = 'hexagon',
41
- Octagon = 'octagon',
42
- Plus = 'plus',
43
- Star5 = 'star5',
44
- Star6 = 'star6',
45
- Star7 = 'star7',
46
- Star8 = 'star8',
47
- Star10 = 'star10',
48
- Star12 = 'star12',
49
- Star16 = 'star16',
50
- Star24 = 'star24',
51
- Star32 = 'star32',
52
- Round1Rect = 'round1Rect',
53
- Round2SameRect = 'round2SameRect',
54
- Round2DiagRect = 'round2DiagRect',
55
- SnipRectangle1 = 'snip1Rect',
56
- SnipRoundRectangle1 = 'snipRoundRect',
57
- SnipRectangle2Same = 'snip2SameRect',
58
- SnipRectangle2Diagonal = 'snip2DiagRect',
59
- Plaque = 'plaque',
60
- Frame = 'frame',
61
- HalfFrame = 'halfFrame',
62
- Corner = 'corner',
63
- DiagStripe = 'diagStripe',
64
- Chord = 'chord',
65
- Arc = 'arc',
66
- LeftCircularArrow = 'leftCircularArrow',
67
- LeftRightCircularArrow = 'leftRightCircularArrow',
68
- SwooshArrow = 'swooshArrow',
69
- LeftRightRibbon = 'leftRightRibbon',
70
- TextBox = 'textBox',
71
- Circle = 'circle',
72
- Heptagon = 'heptagon',
73
- HomePlate = 'homePlate',
74
-
75
- RightArrow = 'rightArrow',
76
- LeftArrow = 'leftArrow',
77
- UpArrow = 'upArrow',
78
- DownArrow = 'downArrow',
79
- LeftRightArrow = 'leftRightArrow',
80
- UpDownArrow = 'upDownArrow',
81
- QuadArrow = 'quadArrow',
82
- LeftRightUpArrow = 'leftRightUpArrow',
83
- BentArrow = 'bentArrow',
84
- UturnArrow = 'uturnArrow',
85
- LeftUpArrow = 'leftUpArrow',
86
- BentUpArrow = 'bentUpArrow',
87
- CurvedRightArrow = 'curvedRightArrow',
88
- CurvedLeftArrow = 'curvedLeftArrow',
89
- CurvedUpArrow = 'curvedUpArrow',
90
- CurvedDownArrow = 'curvedDownArrow',
91
- StripedRightArrow = 'stripedRightArrow',
92
- NotchedRightArrow = 'notchedRightArrow',
93
- Pentagon = 'pentagon',
94
- Chevron = 'chevron',
95
- RightArrowCallout = 'rightArrowCallout',
96
- DownArrowCallout = 'downArrowCallout',
97
- LeftArrowCallout = 'leftArrowCallout',
98
- UpArrowCallout = 'upArrowCallout',
99
- LeftRightArrowCallout = 'leftRightArrowCallout',
100
- QuadArrowCallout = 'quadArrowCallout',
101
- CircularArrow = 'circularArrow',
102
-
103
- MathPlus = 'mathPlus',
104
- MathMinus = 'mathMinus',
105
- MathMultiply = 'mathMultiply',
106
- MathDivide = 'mathDivide',
107
- MathEqual = 'mathEqual',
108
- MathNotEqual = 'mathNotEqual',
109
-
110
- FlowchartProcess = 'flowChartProcess',
111
- FlowchartAlternateProcess = 'flowChartAlternateProcess',
112
- FlowchartDecision = 'flowChartDecision',
113
- FlowChartInputOutput = 'flowChartInputOutput',
114
- FlowchartPredefinedProcess = 'flowChartPredefinedProcess',
115
- FlowchartInternalStorage = 'flowChartInternalStorage',
116
- FlowchartDocument = 'flowChartDocument',
117
- FlowchartMultiDocument = 'flowChartMultidocument',
118
- FlowchartTerminator = 'flowChartTerminator',
119
- FlowchartPreparation = 'flowChartPreparation',
120
- FlowchartManualInput = 'flowChartManualInput',
121
- FlowchartManualOperation = 'flowChartManualOperation',
122
- FlowchartConnector = 'flowChartConnector',
123
- FlowchartOffPageConnector = 'flowChartOffpageConnector',
124
- FlowchartPunchedCard = 'flowChartPunchedCard',
125
- FlowchartPunchedTape = 'flowChartPunchedTape',
126
- FlowchartSummingJunction = 'flowChartSummingJunction',
127
- FlowchartOr = 'flowChartOr',
128
- FlowchartCollate = 'flowChartCollate',
129
- FlowchartSort = 'flowChartSort',
130
- FlowchartExtract = 'flowChartExtract',
131
- FlowchartMerge = 'flowChartMerge',
132
- FlowchartOnlineStorage = 'flowChartOnlineStorage',
133
- FlowchartDelay = 'flowChartDelay',
134
- FlowchartMagneticTape = 'flowChartMagneticTape',
135
- FlowchartMagneticDisk = 'flowChartMagneticDisk',
136
- FlowchartMagneticDrum = 'flowChartMagneticDrum',
137
- FlowchartDisplay = 'flowChartDisplay',
138
-
139
- WedgeRectCallout = 'wedgeRectCallout',
140
- WedgeRoundRectCallout = 'wedgeRoundRectCallout',
141
- WedgeEllipseCallout = 'wedgeEllipseCallout',
142
- CloudCallout = 'cloudCallout',
143
- BorderCallout1 = 'borderCallout1',
144
- BorderCallout2 = 'borderCallout2',
145
- BorderCallout3 = 'borderCallout3',
146
- AccentCallout1 = 'accentCallout1',
147
- AccentCallout2 = 'accentCallout2',
148
- AccentCallout3 = 'accentCallout3',
149
- Callout1 = 'callout1',
150
- Callout2 = 'callout2',
151
- Callout3 = 'callout3',
152
- AccentBorderCallout1 = 'accentBorderCallout1',
153
- AccentBorderCallout2 = 'accentBorderCallout2',
154
- AccentBorderCallout3 = 'accentBorderCallout3',
155
-
156
-
157
- Ribbon = 'ribbon',
158
- Ribbon2 = 'ribbon2',
159
- EllipseRibbon = 'ellipseRibbon',
160
- EllipseRibbon2 = 'ellipseRibbon2',
161
- VerticalScroll = 'verticalScroll',
162
- HorizontalScroll = 'horizontalScroll',
163
- Wave = 'wave',
164
- DoubleWave = 'doubleWave',
165
-
166
- Cube = 'cube',
167
- Can = 'can',
168
- LightningBolt = 'lightningBolt',
169
- Heart = 'heart',
170
- Sun = 'sun',
171
- Moon = 'moon',
172
- SmileyFace = 'smileyFace',
173
- IrregularSeal1 = 'irregularSeal1',
174
- IrregularSeal2 = 'irregularSeal2',
175
- FoldedCorner = 'folderCorner',
176
- Bevel = 'bevel',
177
- Donut = 'donut',
178
- NoSmoking = 'noSmoking',
179
- BlockArc = 'blockArc',
180
-
181
- Teardrop = 'teardrop',
182
- PieWedge = 'pieWedge',
183
- Pie = 'pie',
184
- Funnel = 'funnel',
185
- Gear6 = 'gear6',
186
- Gear9 = 'gear9',
187
- Decagon = 'decagon',
188
- Dodecagon = 'dodecagon',
189
- CornerTabs = 'cornerTabs',
190
- LeftBrace = 'leftBrace',
191
- RightBrace = 'rightBrace',
192
- LeftBracket = 'leftBracket',
193
- RightBracket = 'rightBracket',
194
- ActionButtonBackPrevious = 'actionButtonBackPrevious',
195
- ActionButtonForwardNext = 'actionButtonForwardNext',
196
- ActionButtonBeginning = 'actionButtonBeginning',
197
- ActionButtonEnd = 'actionButtonEnd',
198
- ActionButtonHome = 'actionButtonHome',
199
- ActionButtonInformation = 'actionButtonInformation',
200
- ActionButtonReturn = 'actionButtonReturn',
201
- ActionButtonMovie = 'actionButtonMovie',
202
- ActionButtonDocument = 'actionButtonDocument',
203
- ActionButtonSound = 'actionButtonSound',
204
- ActionButtonHelp = 'actionButtonHelp',
205
- ActionButtonBlank = 'actionButtonBlank',
206
-
207
- BracePair = 'bracePair',
208
- BracketPair = 'bracketPair',
209
- ChartPlus = 'chartPlus',
210
- ChartStar = 'chartStar',
211
- ChartX = 'chartX',
212
- Cloud = 'cloud',
213
- FlowChartOfflineStorage = 'flowChartOfflineStorage',
214
- LineInv = 'lineInv',
215
- NonIsoscelesTrapezoid = 'nonIsoscelesTrapezoid',
216
- PlaqueTabs = 'plaqueTabs',
217
- SquareTabs = 'squareTabs',
218
- Star4 = 'star4',
219
- UpDownArrowCallout = 'upDownArrowCallout',
220
-
221
- Line = 'line',
222
- StraightConnector1 = 'straightConnector1',
223
- BentConnector2 = 'bentConnector2',
224
- BentConnector3 = 'bentConnector3',
225
- BentConnector4 = 'bentConnector4',
226
- BentConnector5 = 'bentConnector5',
227
- CurvedConnector2 = 'curvedConnector2',
228
- CurvedConnector3 = 'curvedConnector3',
229
- CurvedConnector4 = 'curvedConnector4',
230
- CurvedConnector5 = 'curvedConnector5',
231
- }
232
- ```
40
+ ### Fill & Stroke
41
+
42
+ All shapes support three fill modes:
43
+
44
+ - **No fill** — transparent background.
45
+ - **Solid fill** — a single solid color.
46
+ - **Gradient fill** — linear or radial gradients.
47
+
48
+ Stroke styling is fully configurable, including color, width, dash patterns (solid, dash, dot, etc.), and line join/cap styles.
49
+
50
+ ### Text in Shapes
51
+
52
+ Most shapes support inline text editing via double-click. Rich text formatting is supported within shape text, including font size, color, bold, italic, and alignment.
53
+
54
+ ### Adjust Points
55
+
56
+ Adjust points provide parameterized editing of shape geometry. Each shape may have zero or more adjust points, which fall into the following types:
57
+
58
+ - **XY adjust points** — control position offsets along the X/Y axes.
59
+ - **Angle adjust points** — control angular parameters.
60
+ - **Radius adjust points** — control radial dimensions.
61
+
62
+ Adjust points can be manipulated through the UI (drag handles) or programmatically via API. For example, the `SmileyFace` shape has an adjust point that controls the mouth curvature — dragging it can turn a smile into a frown.
63
+
64
+ ### Connection Sites
65
+
66
+ Connection sites are predefined anchor points on a shape's boundary, used for snapping connectors. When a connector is attached to a connection site, moving the shape automatically updates the connector's path.
67
+
68
+ ### Connectors
69
+
70
+ Three connector line types are supported:
71
+
72
+ - **Straight** — a direct line between two points.
73
+ - **Bent (elbow)** — an orthogonal polyline with right-angle bends.
74
+ - **Curved** — a smooth Bezier curve.
75
+
76
+ All connectors feature:
77
+
78
+ - **Auto-routing** — automatically computes the optimal path around obstacles, similar to Excel.
79
+ - **Shape binding** — attach connector endpoints to connection sites on shapes; moving the shape updates the connector path automatically. Dragging the connector itself detaches it from the bound shape.
80
+ - **Arrow heads** — configurable start and end arrow styles.
81
+ - **Dash styles** — solid, dashed, dotted, and other dash patterns.
82
+ - **Adjust points** — fine-tune the connector path by dragging intermediate control points.