@plait/draw 0.59.0 → 0.60.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.
@@ -71,8 +71,18 @@ var UMLSymbols;
71
71
  UMLSymbols["actor"] = "actor";
72
72
  UMLSymbols["useCase"] = "useCase";
73
73
  UMLSymbols["container"] = "container";
74
+ UMLSymbols["note"] = "note";
75
+ UMLSymbols["simpleClass"] = "simpleClass";
76
+ UMLSymbols["activityClass"] = "activityClass";
77
+ UMLSymbols["branchMerge"] = "branchMerge";
78
+ UMLSymbols["port"] = "port";
74
79
  UMLSymbols["package"] = "package";
75
80
  UMLSymbols["combinedFragment"] = "combinedFragment";
81
+ UMLSymbols["class"] = "class";
82
+ UMLSymbols["interface"] = "interface";
83
+ UMLSymbols["object"] = "object";
84
+ UMLSymbols["activation"] = "activation";
85
+ UMLSymbols["deletion"] = "deletion";
76
86
  })(UMLSymbols || (UMLSymbols = {}));
77
87
  var MultipleTextGeometryCommonTextKeys;
78
88
  (function (MultipleTextGeometryCommonTextKeys) {
@@ -201,6 +211,22 @@ const DefaultPackageProperty = {
201
211
  }
202
212
  ]
203
213
  };
214
+ const DefaultActivationProperty = {
215
+ width: 18,
216
+ height: 80
217
+ };
218
+ const DefaultObjectProperty = {
219
+ width: 120,
220
+ height: 60
221
+ };
222
+ const DefaultDeletionProperty = {
223
+ width: 40,
224
+ height: 40
225
+ };
226
+ const DefaultPortProperty = {
227
+ width: 20,
228
+ height: 20
229
+ };
204
230
  const DefaultCombinedFragmentProperty = {
205
231
  width: 400,
206
232
  height: 280,
@@ -217,6 +243,32 @@ const DefaultCombinedFragmentProperty = {
217
243
  }
218
244
  ]
219
245
  };
246
+ const DefaultClassProperty = {
247
+ width: 230,
248
+ height: 180,
249
+ texts: [
250
+ { text: 'Class', align: Alignment.center },
251
+ {
252
+ text: '+ attribute1:type defaultValue\n+ attribute2:type\n- attribute3:type',
253
+ align: Alignment.left
254
+ },
255
+ {
256
+ text: '+ operation1(params):returnType\n- operation2(params)\n- operation3()',
257
+ align: Alignment.left
258
+ }
259
+ ]
260
+ };
261
+ const DefaultInterfaceProperty = {
262
+ width: 230,
263
+ height: 140,
264
+ texts: [
265
+ { text: '<<interface>>\nInterface', align: Alignment.center },
266
+ {
267
+ text: '+ operation1(params):returnType\n- operation2(params)\n- operation3()',
268
+ align: Alignment.left
269
+ }
270
+ ]
271
+ };
220
272
  const DefaultSwimlaneVerticalProperty = {
221
273
  width: 450,
222
274
  height: 500
@@ -263,8 +315,18 @@ const DefaultUMLPropertyMap = {
263
315
  [UMLSymbols.actor]: DefaultActorProperty,
264
316
  [UMLSymbols.useCase]: DefaultDocumentProperty,
265
317
  [UMLSymbols.container]: DefaultContainerProperty,
318
+ [UMLSymbols.note]: DefaultObjectProperty,
266
319
  [UMLSymbols.package]: DefaultPackageProperty,
267
- [UMLSymbols.combinedFragment]: DefaultCombinedFragmentProperty
320
+ [UMLSymbols.combinedFragment]: DefaultCombinedFragmentProperty,
321
+ [UMLSymbols.class]: DefaultClassProperty,
322
+ [UMLSymbols.interface]: DefaultInterfaceProperty,
323
+ [UMLSymbols.activation]: DefaultActivationProperty,
324
+ [UMLSymbols.object]: DefaultObjectProperty,
325
+ [UMLSymbols.deletion]: DefaultDeletionProperty,
326
+ [UMLSymbols.activityClass]: DefaultObjectProperty,
327
+ [UMLSymbols.simpleClass]: DefaultObjectProperty,
328
+ [UMLSymbols.port]: DefaultPortProperty,
329
+ [UMLSymbols.branchMerge]: DefaultDeletionProperty
268
330
  };
269
331
  const MultipleTextGeometryTextKeys = {
270
332
  [UMLSymbols.package]: Object.keys(MultipleTextGeometryCommonTextKeys),
@@ -277,7 +339,14 @@ const DefaultSwimlanePropertyMap = {
277
339
  const LINE_HIT_GEOMETRY_BUFFER = 10;
278
340
  const LINE_SNAPPING_BUFFER = 6;
279
341
  const LINE_SNAPPING_CONNECTOR_BUFFER = 8;
280
- const GEOMETRY_WITHOUT_TEXT = [FlowchartSymbols.or, FlowchartSymbols.summingJunction];
342
+ const GEOMETRY_WITHOUT_TEXT = [
343
+ FlowchartSymbols.or,
344
+ FlowchartSymbols.summingJunction,
345
+ UMLSymbols.activation,
346
+ UMLSymbols.deletion,
347
+ UMLSymbols.port,
348
+ UMLSymbols.branchMerge
349
+ ];
281
350
  const GEOMETRY_WITH_MULTIPLE_TEXT = [UMLSymbols.package, UMLSymbols.combinedFragment];
282
351
 
283
352
  const getGeometryPointers = () => {
@@ -749,7 +818,7 @@ const getMultipleTextGeometryTextKeys = (shape) => {
749
818
  };
750
819
  const createMultipleTextGeometryElement = (shape, points, options = {}) => {
751
820
  const id = idCreator();
752
- const drawShapeTexts = buildDefaultTextsByShape(shape, id);
821
+ const drawShapeTexts = buildDefaultTextsByShape(shape);
753
822
  return {
754
823
  id,
755
824
  type: 'geometry',
@@ -761,7 +830,7 @@ const createMultipleTextGeometryElement = (shape, points, options = {}) => {
761
830
  ...options
762
831
  };
763
832
  };
764
- const buildDefaultTextsByShape = (shape, elementId) => {
833
+ const buildDefaultTextsByShape = (shape) => {
765
834
  const memorizedLatest = getMemorizedLatestByPointer(shape);
766
835
  const textProperties = { ...memorizedLatest.textProperties };
767
836
  const alignment = textProperties?.align;
@@ -1796,6 +1865,89 @@ function drawMask(board, element, id) {
1796
1865
  return { mask, maskTargetFillRect };
1797
1866
  }
1798
1867
 
1868
+ const createUMLClassOrInterfaceGeometryElement = (board, shape, points) => {
1869
+ const memorizedLatest = getMemorizedLatestByPointer(shape);
1870
+ const element = {
1871
+ id: idCreator(),
1872
+ type: 'table',
1873
+ angle: 0,
1874
+ opacity: 1,
1875
+ points,
1876
+ strokeWidth: DefaultBasicShapeProperty.strokeWidth,
1877
+ ...memorizedLatest.geometryProperties
1878
+ };
1879
+ let rows;
1880
+ let columns;
1881
+ if (shape === UMLSymbols.class) {
1882
+ rows = [
1883
+ {
1884
+ id: idCreator(),
1885
+ height: 30
1886
+ },
1887
+ {
1888
+ id: idCreator()
1889
+ },
1890
+ {
1891
+ id: idCreator()
1892
+ }
1893
+ ];
1894
+ columns = [
1895
+ {
1896
+ id: idCreator()
1897
+ }
1898
+ ];
1899
+ }
1900
+ else {
1901
+ rows = [
1902
+ {
1903
+ id: idCreator(),
1904
+ height: 50
1905
+ },
1906
+ {
1907
+ id: idCreator()
1908
+ }
1909
+ ];
1910
+ columns = [
1911
+ {
1912
+ id: idCreator()
1913
+ }
1914
+ ];
1915
+ }
1916
+ return {
1917
+ ...element,
1918
+ shape,
1919
+ rows,
1920
+ columns,
1921
+ cells: buildTableCellsForGeometry(board, rows, columns, shape)
1922
+ };
1923
+ };
1924
+ const buildTableCellsForGeometry = (board, rows, columns, shape) => {
1925
+ const memorizedLatest = getMemorizedLatestByPointer(shape);
1926
+ const cellCount = rows.length * columns.length;
1927
+ const defaultTexts = getDefaultGeometryProperty(shape)?.texts || [];
1928
+ const testHeights = defaultTexts.map((textItem) => {
1929
+ return getTextShapeProperty(board, textItem.text || DefaultTextProperty.text, memorizedLatest.textProperties['font-size']).height;
1930
+ });
1931
+ return new Array(cellCount).fill('').map((item, index) => {
1932
+ const rowIndex = Math.floor(index / columns.length);
1933
+ const columnIndex = index % columns.length;
1934
+ return {
1935
+ id: idCreator(),
1936
+ rowId: rows[rowIndex].id,
1937
+ columnId: columns[columnIndex].id,
1938
+ textHeight: testHeights[index],
1939
+ text: {
1940
+ children: [
1941
+ {
1942
+ text: defaultTexts[index].text
1943
+ }
1944
+ ],
1945
+ align: defaultTexts[index].align
1946
+ }
1947
+ };
1948
+ });
1949
+ };
1950
+
1799
1951
  const createGeometryElement = (shape, points, text, options = {}, textProperties = {}) => {
1800
1952
  if (GEOMETRY_WITHOUT_TEXT.includes(shape)) {
1801
1953
  return createGeometryElementWithoutText(shape, points, options);
@@ -1981,6 +2133,9 @@ const createTextElement = (board, points, text = DefaultTextProperty.text, textH
1981
2133
  const createDefaultGeometry = (board, points, shape) => {
1982
2134
  const memorizedLatest = getMemorizedLatestByPointer(shape);
1983
2135
  const textHeight = getTextShapeProperty(board, DefaultTextProperty.text, memorizedLatest.textProperties['font-size']).height;
2136
+ if (PlaitDrawElement.isUMLClassOrInterface({ shape })) {
2137
+ return createUMLClassOrInterfaceGeometryElement(board, shape, points);
2138
+ }
1984
2139
  if (isMultipleTextShape(shape)) {
1985
2140
  return createMultipleTextGeometryElement(shape, points, {
1986
2141
  strokeWidth: DefaultBasicShapeProperty.strokeWidth,
@@ -1996,12 +2151,14 @@ const createDefaultGeometry = (board, points, shape) => {
1996
2151
  };
1997
2152
  const editText = (board, element, text) => {
1998
2153
  const textManage = text ? getTextManage(`${element.id}-${text.key}`) : getFirstTextManage(element);
1999
- textManage.edit(() => {
2000
- // delay to avoid blinking
2001
- setTimeout(() => {
2002
- rerenderGeometryActive(board, element);
2003
- }, 200);
2004
- });
2154
+ if (textManage) {
2155
+ textManage.edit(() => {
2156
+ // delay to avoid blinking
2157
+ setTimeout(() => {
2158
+ rerenderGeometryActive(board, element);
2159
+ }, 200);
2160
+ });
2161
+ }
2005
2162
  rerenderGeometryActive(board, element);
2006
2163
  };
2007
2164
  const rerenderGeometryActive = (board, element) => {
@@ -2389,9 +2546,7 @@ const addSwimlaneRow = (board, swimlane, index) => {
2389
2546
  const newRows = [...swimlane.rows];
2390
2547
  const newRowId = idCreator();
2391
2548
  newRows.splice(index, 0, { id: newRowId });
2392
- let newCells = createNewRowCells(swimlane, newRowId);
2393
- newCells.shift();
2394
- newCells = [...swimlane.cells, ...newCells];
2549
+ const newCells = [...swimlane.cells, ...createNewSwimlaneCells(swimlane, newRowId, 'column')];
2395
2550
  const lastCellPoints = getCellWithPoints(board, swimlane, swimlane.cells[swimlane.cells.length - 1].id).points;
2396
2551
  const lastRowHeight = RectangleClient.getRectangleByPoints(lastCellPoints).height;
2397
2552
  const newPoints = [swimlane.points[0], [swimlane.points[1][0], swimlane.points[1][1] + lastRowHeight]];
@@ -2403,9 +2558,7 @@ const addSwimlaneColumn = (board, swimlane, index) => {
2403
2558
  const newColumns = [...swimlane.columns];
2404
2559
  const newColumnId = idCreator();
2405
2560
  newColumns.splice(index, 0, { id: newColumnId });
2406
- let newCells = createNewColumnCells(swimlane, newColumnId);
2407
- newCells.shift();
2408
- newCells = [...swimlane.cells, ...newCells];
2561
+ const newCells = [...swimlane.cells, ...createNewSwimlaneCells(swimlane, newColumnId, 'row')];
2409
2562
  const lastCellPoints = getCellWithPoints(board, swimlane, swimlane.cells[swimlane.cells.length - 1].id).points;
2410
2563
  const lastColumnWidth = RectangleClient.getRectangleByPoints(lastCellPoints).width;
2411
2564
  const newPoints = [swimlane.points[0], [swimlane.points[1][0] + lastColumnWidth, swimlane.points[1][1]]];
@@ -2425,7 +2578,8 @@ const removeSwimlaneRow = (board, swimlane, index) => {
2425
2578
  const newCells = swimlane.cells.filter(item => item.rowId !== removeRow.id);
2426
2579
  let removeRowHeight = removeRow.height;
2427
2580
  if (!removeRowHeight) {
2428
- const cellPoints = getCellWithPoints(board, swimlane, swimlane.cells[index].id).points;
2581
+ const rowCell = swimlane.cells.find(item => item.rowId === removeRow.id);
2582
+ const cellPoints = getCellWithPoints(board, swimlane, rowCell.id).points;
2429
2583
  removeRowHeight = RectangleClient.getRectangleByPoints(cellPoints).height;
2430
2584
  }
2431
2585
  const newPoints = [swimlane.points[0], [swimlane.points[1][0], swimlane.points[1][1] - removeRowHeight]];
@@ -2446,7 +2600,8 @@ const removeSwimlaneColumn = (board, swimlane, index) => {
2446
2600
  const newCells = swimlane.cells.filter(item => item.columnId !== removeColumn.id);
2447
2601
  let removeColumnWidth = removeColumn.width;
2448
2602
  if (!removeColumnWidth) {
2449
- const cellPoints = getCellWithPoints(board, swimlane, swimlane.cells[index].id).points;
2603
+ const columnCell = swimlane.cells.find(item => item.columnId === removeColumn.id);
2604
+ const cellPoints = getCellWithPoints(board, swimlane, columnCell.id).points;
2450
2605
  removeColumnWidth = RectangleClient.getRectangleByPoints(cellPoints).width;
2451
2606
  }
2452
2607
  const newPoints = [swimlane.points[0], [swimlane.points[1][0] - removeColumnWidth, swimlane.points[1][1]]];
@@ -2454,19 +2609,23 @@ const removeSwimlaneColumn = (board, swimlane, index) => {
2454
2609
  }
2455
2610
  }
2456
2611
  };
2457
- const createNewColumnCells = (swimlane, newColumnId) => {
2458
- return swimlane.rows.map(row => ({
2612
+ const createNewSwimlaneCells = (swimlane, newId, type) => {
2613
+ const cells = swimlane[`${type}s`].map(item => ({
2459
2614
  id: idCreator(),
2460
- rowId: row.id,
2461
- columnId: newColumnId
2462
- }));
2463
- };
2464
- const createNewRowCells = (swimlane, newRowId) => {
2465
- return swimlane.columns.map(column => ({
2466
- id: idCreator(),
2467
- rowId: newRowId,
2468
- columnId: column.id
2615
+ rowId: type === 'row' ? item.id : newId,
2616
+ columnId: type === 'row' ? newId : item.id
2469
2617
  }));
2618
+ cells.shift();
2619
+ cells[0] = {
2620
+ ...cells[0],
2621
+ text: {
2622
+ children: [{ text: 'Lane' }],
2623
+ align: Alignment.center,
2624
+ direction: type === 'row' ? undefined : 'vertical'
2625
+ },
2626
+ textHeight: 20
2627
+ };
2628
+ return cells;
2470
2629
  };
2471
2630
  const updateSwimlane = (board, swimlane, newColumns, newRows, newCells, newPoints) => {
2472
2631
  const path = PlaitBoard.findPath(board, swimlane);
@@ -4781,6 +4940,7 @@ const TableEngine = {
4781
4940
  const cellBottomBorder = drawLine$1(rs, [x, y + height], [x + width, y + height], roughOptions);
4782
4941
  g.append(cellRightBorder, cellBottomBorder);
4783
4942
  });
4943
+ setStrokeLinecap(g, 'round');
4784
4944
  return g;
4785
4945
  },
4786
4946
  isInsidePoint(rectangle, point) {
@@ -5098,6 +5258,130 @@ const CombinedFragmentEngine = {
5098
5258
  }
5099
5259
  };
5100
5260
 
5261
+ const DeletionEngine = {
5262
+ draw(board, rectangle, options) {
5263
+ const rs = PlaitBoard.getRoughSVG(board);
5264
+ const shape = rs.path(`M${rectangle.x} ${rectangle.y} L${rectangle.x + rectangle.width} ${rectangle.y + rectangle.height}
5265
+ M${rectangle.x + rectangle.width} ${rectangle.y} L${rectangle.x} ${rectangle.y + rectangle.height}
5266
+ `, { ...options, fillStyle: 'solid', strokeWidth: 4 });
5267
+ return shape;
5268
+ },
5269
+ isInsidePoint(rectangle, point) {
5270
+ const rangeRectangle = RectangleClient.getRectangleByPoints([point, point]);
5271
+ return RectangleClient.isHit(rectangle, rangeRectangle);
5272
+ },
5273
+ getCornerPoints(rectangle) {
5274
+ return RectangleClient.getCornerPoints(rectangle);
5275
+ },
5276
+ getNearestPoint(rectangle, point) {
5277
+ return getNearestPointBetweenPointAndSegments(point, RectangleEngine.getCornerPoints(rectangle));
5278
+ },
5279
+ getEdgeByConnectionPoint(rectangle, pointOfRectangle) {
5280
+ const corners = RectangleEngine.getCornerPoints(rectangle);
5281
+ const point = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
5282
+ return getPolygonEdgeByConnectionPoint(corners, point);
5283
+ },
5284
+ getConnectorPoints(rectangle) {
5285
+ return RectangleClient.getEdgeCenterPoints(rectangle);
5286
+ }
5287
+ };
5288
+
5289
+ const ActiveClassEngine = {
5290
+ draw(board, rectangle, options) {
5291
+ const rs = PlaitBoard.getRoughSVG(board);
5292
+ const shape = rs.path(`M${rectangle.x} ${rectangle.y} H${rectangle.x + rectangle.width} V${rectangle.y + rectangle.height} H${rectangle.x} Z M${rectangle.x + rectangle.width * 0.125} ${rectangle.y} L${rectangle.x + rectangle.width * 0.125} ${rectangle.y +
5293
+ rectangle.height} M${rectangle.x + rectangle.width - rectangle.width * 0.125} ${rectangle.y} L${rectangle.x +
5294
+ rectangle.width -
5295
+ rectangle.width * 0.125} ${rectangle.y + rectangle.height}`, { ...options, fillStyle: 'solid' });
5296
+ setStrokeLinecap(shape, 'round');
5297
+ return shape;
5298
+ },
5299
+ isInsidePoint(rectangle, point) {
5300
+ const rangeRectangle = RectangleClient.getRectangleByPoints([point, point]);
5301
+ return RectangleClient.isHit(rectangle, rangeRectangle);
5302
+ },
5303
+ getCornerPoints(rectangle) {
5304
+ return RectangleClient.getCornerPoints(rectangle);
5305
+ },
5306
+ getNearestPoint(rectangle, point) {
5307
+ return getNearestPointBetweenPointAndSegments(point, RectangleEngine.getCornerPoints(rectangle));
5308
+ },
5309
+ getEdgeByConnectionPoint(rectangle, pointOfRectangle) {
5310
+ const corners = RectangleEngine.getCornerPoints(rectangle);
5311
+ const point = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
5312
+ return getPolygonEdgeByConnectionPoint(corners, point);
5313
+ },
5314
+ getConnectorPoints(rectangle) {
5315
+ return RectangleClient.getEdgeCenterPoints(rectangle);
5316
+ },
5317
+ getTextRectangle: (element) => {
5318
+ const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
5319
+ const strokeWidth = getStrokeWidthByElement(element);
5320
+ const height = element.textHeight;
5321
+ const width = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2 - elementRectangle.width * 0.125 * 2;
5322
+ return {
5323
+ height,
5324
+ width: width > 0 ? width : 0,
5325
+ x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth + elementRectangle.width * 0.125,
5326
+ y: elementRectangle.y + (elementRectangle.height - height) / 2
5327
+ };
5328
+ }
5329
+ };
5330
+
5331
+ const NoteEngine = {
5332
+ draw(board, rectangle, options) {
5333
+ const rs = PlaitBoard.getRoughSVG(board);
5334
+ const shape = rs.path(`M${rectangle.x} ${rectangle.y}
5335
+ h${rectangle.width - 16}
5336
+ v16
5337
+ h16
5338
+ v${rectangle.height - 16}
5339
+ h${-rectangle.width}
5340
+ Z
5341
+ M${rectangle.x + rectangle.width - 16} ${rectangle.y}
5342
+ A16 16, 0,0,1, ${rectangle.x + rectangle.width} ${rectangle.y + 16}
5343
+ `, { ...options, fillStyle: 'solid' });
5344
+ setStrokeLinecap(shape, 'round');
5345
+ return shape;
5346
+ },
5347
+ isInsidePoint(rectangle, point) {
5348
+ const rangeRectangle = RectangleClient.getRectangleByPoints([point, point]);
5349
+ return RectangleClient.isHit(rectangle, rangeRectangle);
5350
+ },
5351
+ getCornerPoints(rectangle) {
5352
+ return RectangleClient.getCornerPoints(rectangle);
5353
+ },
5354
+ getNearestPoint(rectangle, point) {
5355
+ const nearestPoint = getNearestPointBetweenPointAndSegments(point, RectangleEngine.getCornerPoints(rectangle));
5356
+ if (nearestPoint[0] > rectangle.x + rectangle.width - 16 && nearestPoint[1] < rectangle.y + 16) {
5357
+ return getNearestPointBetweenPointAndEllipse(point, [rectangle.x + rectangle.width - 16, rectangle.y + 16], 16, 16);
5358
+ }
5359
+ return nearestPoint;
5360
+ },
5361
+ getTangentVectorByConnectionPoint(rectangle, pointOfRectangle) {
5362
+ const connectionPoint = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
5363
+ const centerPoint = [rectangle.x + (rectangle.width * 3) / 4, rectangle.y + rectangle.height / 2];
5364
+ const point = [connectionPoint[0] - centerPoint[0], -(connectionPoint[1] - centerPoint[1])];
5365
+ const slope = getEllipseTangentSlope(point[0], point[1], 16, 16);
5366
+ return getVectorFromPointAndSlope(point[0], point[1], slope);
5367
+ },
5368
+ getConnectorPoints(rectangle) {
5369
+ return RectangleClient.getEdgeCenterPoints(rectangle);
5370
+ },
5371
+ getTextRectangle: (element) => {
5372
+ const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
5373
+ const strokeWidth = getStrokeWidthByElement(element);
5374
+ const height = element.textHeight;
5375
+ const width = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth - 15;
5376
+ return {
5377
+ height,
5378
+ width: width > 0 ? width : 0,
5379
+ x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
5380
+ y: elementRectangle.y + (elementRectangle.height - height) / 2
5381
+ };
5382
+ }
5383
+ };
5384
+
5101
5385
  const ShapeEngineMap = {
5102
5386
  [BasicShapes.rectangle]: RectangleEngine,
5103
5387
  [BasicShapes.diamond]: DiamondEngine,
@@ -5150,8 +5434,18 @@ const ShapeEngineMap = {
5150
5434
  [UMLSymbols.actor]: ActorEngine,
5151
5435
  [UMLSymbols.useCase]: EllipseEngine,
5152
5436
  [UMLSymbols.container]: ContainerEngine,
5437
+ [UMLSymbols.note]: NoteEngine,
5153
5438
  [UMLSymbols.package]: PackageEngine,
5154
- [UMLSymbols.combinedFragment]: CombinedFragmentEngine
5439
+ [UMLSymbols.combinedFragment]: CombinedFragmentEngine,
5440
+ [UMLSymbols.class]: TableEngine,
5441
+ [UMLSymbols.interface]: TableEngine,
5442
+ [UMLSymbols.activation]: RectangleEngine,
5443
+ [UMLSymbols.object]: RectangleEngine,
5444
+ [UMLSymbols.deletion]: DeletionEngine,
5445
+ [UMLSymbols.activityClass]: ActiveClassEngine,
5446
+ [UMLSymbols.simpleClass]: RectangleEngine,
5447
+ [UMLSymbols.port]: RectangleEngine,
5448
+ [UMLSymbols.branchMerge]: DiamondEngine
5155
5449
  };
5156
5450
  const getEngine = (shape) => {
5157
5451
  return ShapeEngineMap[shape];
@@ -5405,7 +5699,7 @@ const PlaitDrawElement = {
5405
5699
  return Object.keys(SwimlaneSymbols).includes(value.shape) && value.shape === SwimlaneSymbols.swimlaneHorizontal;
5406
5700
  },
5407
5701
  isUMLClassOrInterface: (value) => {
5408
- return false;
5702
+ return Object.keys(UMLSymbols).includes(value.shape) && [UMLSymbols.class, UMLSymbols.interface].includes(value.shape);
5409
5703
  }
5410
5704
  };
5411
5705
 
@@ -5877,6 +6171,21 @@ const withDrawHotkey = (board) => {
5877
6171
  return board;
5878
6172
  };
5879
6173
 
6174
+ class TableGenerator extends Generator {
6175
+ canDraw(element, data) {
6176
+ return true;
6177
+ }
6178
+ draw(element, data) {
6179
+ const rectangle = RectangleClient.getRectangleByPoints(element.points);
6180
+ return getEngine(TableSymbols.table).draw(this.board, rectangle, {
6181
+ strokeWidth: 2,
6182
+ stroke: getDrawDefaultStrokeColor(this.board.theme.themeColorMode),
6183
+ }, {
6184
+ element: element
6185
+ });
6186
+ }
6187
+ }
6188
+
5880
6189
  const isGeometryDndMode = (board) => {
5881
6190
  const geometryPointers = getGeometryPointers();
5882
6191
  const isGeometryPointer = PlaitBoard.isInPointer(board, geometryPointers);
@@ -5889,6 +6198,14 @@ const isGeometryDrawingMode = (board) => {
5889
6198
  const drawingMode = isGeometryPointer && isDrawingMode(board);
5890
6199
  return drawingMode;
5891
6200
  };
6201
+ const getGeometryGeneratorByShape = (board, shape) => {
6202
+ if (PlaitDrawElement.isUMLClassOrInterface({ shape: shape })) {
6203
+ return new TableGenerator(board);
6204
+ }
6205
+ else {
6206
+ return new GeometryShapeGenerator(board);
6207
+ }
6208
+ };
5892
6209
  const withGeometryCreateByDrag = (board) => {
5893
6210
  const { pointerMove, globalPointerUp, pointerUp } = board;
5894
6211
  let geometryShapeG = null;
@@ -5897,12 +6214,12 @@ const withGeometryCreateByDrag = (board) => {
5897
6214
  board.pointerMove = (event) => {
5898
6215
  geometryShapeG?.remove();
5899
6216
  geometryShapeG = createG();
5900
- const geometryGenerator = new GeometryShapeGenerator(board);
5901
6217
  const geometryPointers = getGeometryPointers();
5902
6218
  const isGeometryPointer = PlaitBoard.isInPointer(board, geometryPointers);
5903
6219
  const dragMode = isGeometryPointer && isDndMode(board);
5904
6220
  const movingPoint = toViewBoxPoint(board, toHostPoint(board, event.x, event.y));
5905
6221
  const pointer = PlaitBoard.getPointer(board);
6222
+ const geometryGenerator = getGeometryGeneratorByShape(board, pointer);
5906
6223
  if (dragMode) {
5907
6224
  const memorizedLatest = getMemorizedLatestByPointer(pointer);
5908
6225
  if (pointer === BasicShapes.text) {
@@ -5997,9 +6314,9 @@ const withGeometryCreateByDrawing = (board) => {
5997
6314
  board.pointerMove = (event) => {
5998
6315
  geometryShapeG?.remove();
5999
6316
  geometryShapeG = createG();
6000
- const geometryGenerator = new GeometryShapeGenerator(board);
6001
6317
  const movingPoint = toViewBoxPoint(board, toHostPoint(board, event.x, event.y));
6002
6318
  const pointer = PlaitBoard.getPointer(board);
6319
+ const geometryGenerator = getGeometryGeneratorByShape(board, pointer);
6003
6320
  snapG?.remove();
6004
6321
  if (start && isGeometryDrawingMode(board)) {
6005
6322
  let points = normalizeShapePoints([start, movingPoint], isShift);
@@ -6132,7 +6449,8 @@ const withDrawFragment = (baseBoard) => {
6132
6449
  const tableElements = drawElements.filter(value => PlaitDrawElement.isTable(value));
6133
6450
  const boundLineElements = [
6134
6451
  ...getBoundedLineElements(board, geometryElements),
6135
- ...getBoundedLineElements(board, imageElements)
6452
+ ...getBoundedLineElements(board, imageElements),
6453
+ ...getBoundedLineElements(board, tableElements)
6136
6454
  ].filter(line => !lineElements.includes(line));
6137
6455
  data.push(...[
6138
6456
  ...geometryElements,
@@ -6900,21 +7218,6 @@ const withDrawRotate = (board) => {
6900
7218
  return board;
6901
7219
  };
6902
7220
 
6903
- class TableGenerator extends Generator {
6904
- canDraw(element, data) {
6905
- return true;
6906
- }
6907
- draw(element, data) {
6908
- const rectangle = RectangleClient.getRectangleByPoints(element.points);
6909
- return getEngine(TableSymbols.table).draw(this.board, rectangle, {
6910
- strokeWidth: 2,
6911
- stroke: getDrawDefaultStrokeColor(this.board.theme.themeColorMode),
6912
- }, {
6913
- element: element
6914
- });
6915
- }
6916
- }
6917
-
6918
7221
  class TableComponent extends CommonElementFlavour {
6919
7222
  constructor() {
6920
7223
  super();
@@ -7228,7 +7531,13 @@ function buildSwimlaneTable(element) {
7228
7531
  };
7229
7532
  }
7230
7533
  if (item.text && item.textHeight && !item.text.direction) {
7231
- item.text.direction = 'vertical';
7534
+ item = {
7535
+ ...item,
7536
+ text: {
7537
+ ...item.text,
7538
+ direction: 'vertical'
7539
+ }
7540
+ };
7232
7541
  }
7233
7542
  return item;
7234
7543
  });
@@ -7580,5 +7889,5 @@ const withDraw = (board) => {
7580
7889
  * Generated bundle index. Do not edit.
7581
7890
  */
7582
7891
 
7583
- export { BasicShapes, DEFAULT_IMAGE_WIDTH, DEFAULT_TEXT_HEIGHT, DefaultActorProperty, DefaultArrowProperty, DefaultBasicShapeProperty, DefaultBasicShapePropertyMap, DefaultCloudProperty, DefaultCombinedFragmentProperty, DefaultConnectorProperty, DefaultContainerProperty, DefaultDataBaseProperty, DefaultDataProperty, DefaultDecisionProperty, DefaultDocumentProperty, DefaultDrawActiveStyle, DefaultDrawStyle, DefaultFlowchartProperty, DefaultFlowchartPropertyMap, DefaultInternalStorageProperty, DefaultManualInputProperty, DefaultMergeProperty, DefaultMultiDocumentProperty, DefaultNoteProperty, DefaultPackageProperty, DefaultPentagonArrowProperty, DefaultSwimlaneHorizontalProperty, DefaultSwimlanePropertyMap, DefaultSwimlaneVerticalProperty, DefaultTextProperty, DefaultTwoWayArrowProperty, DefaultUMLPropertyMap, DrawThemeColors, DrawTransforms, FlowchartSymbols, GEOMETRY_WITHOUT_TEXT, GEOMETRY_WITH_MULTIPLE_TEXT, GeometryComponent, GeometryShapeGenerator, GeometryThreshold, KEY_TO_TEXT_MANAGE, LINE_HIT_GEOMETRY_BUFFER, LINE_SNAPPING_BUFFER, LINE_SNAPPING_CONNECTOR_BUFFER, LineActiveGenerator, LineAutoCompleteGenerator, LineComponent, LineHandleKey, LineMarkerType, LineShape, MemorizeKey, MultipleTextGeometryCommonTextKeys, MultipleTextGeometryTextKeys, PlaitDrawElement, PlaitGeometry, PlaitLine, Q2C, ShapeDefaultSpace, SingleTextGenerator, StrokeStyle, SwimlaneSymbols, TableGenerator, TableSymbols, TextGenerator, UMLSymbols, WithLineAutoCompletePluginKey, alignElbowSegment, alignPoints, buildDefaultTextsByShape, createDefaultFlowchart, createDefaultGeometry, createGeometryElement, createGeometryElementWithText, createGeometryElementWithoutText, createLineElement, createMultipleTextGeometryElement, createTextElement, debugGenerator$1 as debugGenerator, deleteTextManage, drawBoundReaction, drawGeometry, drawLine, drawLineArrow, drawShape, editText, getAutoCompletePoints, getBasicPointers, getCenterPointsOnPolygon$1 as getCenterPointsOnPolygon, getConnectionPoint, getCurvePoints, getDefaultBasicShapeProperty, getDefaultFlowchartProperty, getDefaultGeometryPoints, getDefaultGeometryProperty, getDefaultTextPoints, getDefaultUMLProperty, getDrawDefaultStrokeColor, getElbowLineRouteOptions, getElbowPoints, getFillByElement, getFlowchartDefaultFill, getFlowchartPointers, getGeometryAlign, getGeometryPointers, getHitConnection, getHitConnectorPoint, getHitIndexOfAutoCompletePoint, getHitMultipleGeometryText, getHitShape, getIndexAndDeleteCountByKeyPoint, getLineDashByElement, getLineHandleRefPair, getLineMemorizedLatest, getLinePointers, getLinePoints, getLineTextRectangle, getLines, getMemorizeKey, getMemorizedLatestByPointer, getMemorizedLatestShape, getMidKeyPoints, getMiddlePoints, getMirrorDataPoints, getMultipleTextGeometryTextKeys, getNearestPoint, getNextRenderPoints, getNextSourceAndTargetPoints, getResizedPreviousAndNextPoint, getSelectedDrawElements, getSelectedGeometryElements, getSelectedImageElements, getSelectedLineElements, getSelectedTableElements, getSnapResizingRef, getSnapResizingRefOptions, getSnappingRef, getSnappingShape, getSourceAndTargetRectangle, getStrokeColorByElement, getStrokeStyleByElement, getStrokeWidthByElement, getSwimlanePointers, getTextKey, getTextManage, getTextRectangle, getTextShapeProperty, getUMLPointers, getVectorByConnection, handleLineCreating, hasIllegalElbowPoint, insertElement, isDrawElementIncludeText, isDrawElementsIncludeText, isGeometryIncludeText, isHitDrawElement, isHitEdgeOfShape, isHitElementInside, isHitElementText, isHitLine, isHitLineText, isHitPolyLine, isInsideOfShape, isMultipleTextGeometry, isMultipleTextShape, isRectangleHitDrawElement, isRectangleHitElementText, isSelfLoop, isSingleSelectSwimlane, isSingleSelectTable, isSingleTextGeometry, isSingleTextShape, isTextExceedingBounds, isUpdatedHandleIndex, isUseDefaultOrthogonalRoute, memorizeLatestShape, memorizeLatestText, rerenderGeometryActive, setTextManage, traverseDrawShapes, withDraw, withLineAutoComplete };
7892
+ export { BasicShapes, DEFAULT_IMAGE_WIDTH, DEFAULT_TEXT_HEIGHT, DefaultActivationProperty, DefaultActorProperty, DefaultArrowProperty, DefaultBasicShapeProperty, DefaultBasicShapePropertyMap, DefaultClassProperty, DefaultCloudProperty, DefaultCombinedFragmentProperty, DefaultConnectorProperty, DefaultContainerProperty, DefaultDataBaseProperty, DefaultDataProperty, DefaultDecisionProperty, DefaultDeletionProperty, DefaultDocumentProperty, DefaultDrawActiveStyle, DefaultDrawStyle, DefaultFlowchartProperty, DefaultFlowchartPropertyMap, DefaultInterfaceProperty, DefaultInternalStorageProperty, DefaultManualInputProperty, DefaultMergeProperty, DefaultMultiDocumentProperty, DefaultNoteProperty, DefaultObjectProperty, DefaultPackageProperty, DefaultPentagonArrowProperty, DefaultPortProperty, DefaultSwimlaneHorizontalProperty, DefaultSwimlanePropertyMap, DefaultSwimlaneVerticalProperty, DefaultTextProperty, DefaultTwoWayArrowProperty, DefaultUMLPropertyMap, DrawThemeColors, DrawTransforms, FlowchartSymbols, GEOMETRY_WITHOUT_TEXT, GEOMETRY_WITH_MULTIPLE_TEXT, GeometryComponent, GeometryShapeGenerator, GeometryThreshold, KEY_TO_TEXT_MANAGE, LINE_HIT_GEOMETRY_BUFFER, LINE_SNAPPING_BUFFER, LINE_SNAPPING_CONNECTOR_BUFFER, LineActiveGenerator, LineAutoCompleteGenerator, LineComponent, LineHandleKey, LineMarkerType, LineShape, MemorizeKey, MultipleTextGeometryCommonTextKeys, MultipleTextGeometryTextKeys, PlaitDrawElement, PlaitGeometry, PlaitLine, Q2C, ShapeDefaultSpace, SingleTextGenerator, StrokeStyle, SwimlaneSymbols, TableGenerator, TableSymbols, TextGenerator, UMLSymbols, WithLineAutoCompletePluginKey, alignElbowSegment, alignPoints, buildDefaultTextsByShape, createDefaultFlowchart, createDefaultGeometry, createGeometryElement, createGeometryElementWithText, createGeometryElementWithoutText, createLineElement, createMultipleTextGeometryElement, createTextElement, createUMLClassOrInterfaceGeometryElement, debugGenerator$1 as debugGenerator, deleteTextManage, drawBoundReaction, drawGeometry, drawLine, drawLineArrow, drawShape, editText, getAutoCompletePoints, getBasicPointers, getCenterPointsOnPolygon$1 as getCenterPointsOnPolygon, getConnectionPoint, getCurvePoints, getDefaultBasicShapeProperty, getDefaultFlowchartProperty, getDefaultGeometryPoints, getDefaultGeometryProperty, getDefaultTextPoints, getDefaultUMLProperty, getDrawDefaultStrokeColor, getElbowLineRouteOptions, getElbowPoints, getFillByElement, getFlowchartDefaultFill, getFlowchartPointers, getGeometryAlign, getGeometryPointers, getHitConnection, getHitConnectorPoint, getHitIndexOfAutoCompletePoint, getHitMultipleGeometryText, getHitShape, getIndexAndDeleteCountByKeyPoint, getLineDashByElement, getLineHandleRefPair, getLineMemorizedLatest, getLinePointers, getLinePoints, getLineTextRectangle, getLines, getMemorizeKey, getMemorizedLatestByPointer, getMemorizedLatestShape, getMidKeyPoints, getMiddlePoints, getMirrorDataPoints, getMultipleTextGeometryTextKeys, getNearestPoint, getNextRenderPoints, getNextSourceAndTargetPoints, getResizedPreviousAndNextPoint, getSelectedDrawElements, getSelectedGeometryElements, getSelectedImageElements, getSelectedLineElements, getSelectedTableElements, getSnapResizingRef, getSnapResizingRefOptions, getSnappingRef, getSnappingShape, getSourceAndTargetRectangle, getStrokeColorByElement, getStrokeStyleByElement, getStrokeWidthByElement, getSwimlanePointers, getTextKey, getTextManage, getTextRectangle, getTextShapeProperty, getUMLPointers, getVectorByConnection, handleLineCreating, hasIllegalElbowPoint, insertElement, isDrawElementIncludeText, isDrawElementsIncludeText, isGeometryIncludeText, isHitDrawElement, isHitEdgeOfShape, isHitElementInside, isHitElementText, isHitLine, isHitLineText, isHitPolyLine, isInsideOfShape, isMultipleTextGeometry, isMultipleTextShape, isRectangleHitDrawElement, isRectangleHitElementText, isSelfLoop, isSingleSelectSwimlane, isSingleSelectTable, isSingleTextGeometry, isSingleTextShape, isTextExceedingBounds, isUpdatedHandleIndex, isUseDefaultOrthogonalRoute, memorizeLatestShape, memorizeLatestText, rerenderGeometryActive, setTextManage, traverseDrawShapes, withDraw, withLineAutoComplete };
7584
7893
  //# sourceMappingURL=plait-draw.mjs.map