@plait/draw 0.62.0-next.4 → 0.62.0-next.5.1
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/esm2022/constants/geometry.mjs +3 -3
- package/esm2022/engines/basic-shapes/ellipse.mjs +5 -3
- package/esm2022/engines/basic-shapes/round-comment.mjs +5 -3
- package/esm2022/engines/flowchart/note-curly-left.mjs +2 -2
- package/esm2022/engines/flowchart/note-curly-right.mjs +7 -7
- package/esm2022/engines/flowchart/note-square.mjs +2 -2
- package/esm2022/engines/flowchart/or.mjs +5 -3
- package/esm2022/engines/flowchart/summing-junction.mjs +5 -3
- package/esm2022/engines/table/table.mjs +48 -26
- package/esm2022/engines/uml/deletion.mjs +3 -2
- package/esm2022/engines/uml/required-interface.mjs +3 -2
- package/esm2022/interfaces/index.mjs +6 -3
- package/esm2022/line.component.mjs +5 -3
- package/esm2022/plugins/with-draw-resize.mjs +11 -4
- package/esm2022/plugins/with-draw.mjs +10 -3
- package/esm2022/plugins/with-geometry-resize.mjs +1 -1
- package/esm2022/plugins/with-line-text.mjs +4 -3
- package/esm2022/plugins/with-swimlane.mjs +1 -20
- package/esm2022/plugins/with-table.mjs +34 -7
- package/esm2022/table.component.mjs +3 -3
- package/esm2022/transforms/index.mjs +5 -4
- package/esm2022/transforms/swimlane.mjs +1 -29
- package/esm2022/transforms/table-text.mjs +5 -5
- package/esm2022/transforms/table.mjs +30 -0
- package/esm2022/utils/hit.mjs +54 -31
- package/esm2022/utils/memorize.mjs +1 -2
- package/esm2022/utils/style/stroke.mjs +2 -2
- package/esm2022/utils/swimlane.mjs +11 -5
- package/esm2022/utils/table-selected.mjs +3 -4
- package/esm2022/utils/table.mjs +28 -5
- package/fesm2022/plait-draw.mjs +278 -166
- package/fesm2022/plait-draw.mjs.map +1 -1
- package/package.json +1 -1
- package/plugins/with-swimlane.d.ts +1 -2
- package/transforms/index.d.ts +2 -2
- package/transforms/swimlane.d.ts +1 -3
- package/transforms/table-text.d.ts +2 -3
- package/transforms/table.d.ts +3 -0
- package/utils/hit.d.ts +5 -2
- package/utils/swimlane.d.ts +1 -1
- package/utils/table.d.ts +2 -0
package/fesm2022/plait-draw.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ACTIVE_STROKE_WIDTH, ThemeColorMode, RectangleClient, idCreator, distanceBetweenPointAndSegments, HIT_DISTANCE_BUFFER, rotatePointsByElement, isPolylineHitRectangle, rotateAntiPointsByElement, distanceBetweenPointAndPoint, Transforms, clearSelectedElement, addSelectedElement, BoardTransforms, PlaitPointerType, depthFirstRecursion, PlaitBoard, getIsRecursionFunc, createG, SNAPPING_STROKE_WIDTH, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, drawCircle, createDebugGenerator, Point, arrowPoints, createPath, drawLinearPath, rotate, catmullRomFitting, setStrokeLinecap, findElements, createMask, createRect, PlaitElement,
|
|
2
|
-
import { Alignment, WithTextPluginKey, ELEMENT_TO_TEXT_MANAGES, TextManage, getMemorizedLatest, memorizeLatest, RESIZE_HANDLE_DIAMETER, getPointOnPolyline, buildText,
|
|
1
|
+
import { ACTIVE_STROKE_WIDTH, ThemeColorMode, RectangleClient, getSelectedElements, idCreator, distanceBetweenPointAndSegments, HIT_DISTANCE_BUFFER, rotatePointsByElement, isPolylineHitRectangle, rotateAntiPointsByElement, distanceBetweenPointAndPoint, Transforms, clearSelectedElement, addSelectedElement, BoardTransforms, PlaitPointerType, depthFirstRecursion, PlaitBoard, getIsRecursionFunc, createG, SNAPPING_STROKE_WIDTH, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, drawCircle, createDebugGenerator, Point, arrowPoints, createPath, drawLinearPath, rotate, catmullRomFitting, setStrokeLinecap, findElements, createMask, createRect, PlaitElement, getElementById, Path, Direction, PlaitNode, hasValidAngle, toViewBoxPoint, toHostPoint, rotatePoints, getRectangleByElements, getSelectionAngle, rotatedDataPoints, isAxisChangedByAngle, isSelectionMoving, drawRectangle, getRectangleByAngle, getSnapRectangles, getTripleAxis, getMinPointDelta, SNAP_TOLERANCE, drawPointSnapLines, drawSolidLines, isPointInPolygon, getNearestPointBetweenPointAndSegments, isPointInEllipse, getNearestPointBetweenPointAndEllipse, getEllipseTangentSlope, getVectorFromPointAndSlope, drawRoundRectangle, isPointInRoundRectangle, setPathStrokeLinecap, getCrossingPointsBetweenEllipseAndSegment, drawLine as drawLine$1, RgbaToHEX, getHitElementByPoint, preventTouchMove, WritableClipboardOperationType, createClipboardContext, WritableClipboardType, addClipboardContext, setAngleForG, CursorClass, temporaryDisableSelection, PRESS_AND_MOVE_BUFFER, isMainPointer, throttleRAF, getAngleBetweenPoints, normalizeAngle, degreesToRadians, rotateElements, MERGING, ROTATE_HANDLE_CLASS_NAME, SELECTION_RECTANGLE_CLASS_NAME, isSelectedElement, isDragging } from '@plait/core';
|
|
2
|
+
import { DEFAULT_FILL, Alignment, WithTextPluginKey, ELEMENT_TO_TEXT_MANAGES, TextManage, getMemorizedLatest, memorizeLatest, RESIZE_HANDLE_DIAMETER, getPointOnPolyline, buildText, sortElementsByArea, isFilled, getTextEditorsByElement, Generator, removeDuplicatePoints, generateElbowLineRoute, simplifyOrthogonalPoints, getExtendPoint, getUnitVectorByPointAndPoint, getPointByVectorComponent, measureElement, DEFAULT_FONT_FAMILY, getFirstTextManage, ActiveGenerator, isSourceAndTargetIntersect, getPoints, DEFAULT_ROUTE_MARGIN, getDirectionByVector, normalizeShapePoints, getFirstTextEditor, resetPointsAfterResize, getRectangleResizeHandleRefs, getRotatedResizeCursorClassByAngle, ROTATE_HANDLE_DISTANCE_TO_ELEMENT, ROTATE_HANDLE_SIZE, isCornerHandle, getIndexByResizeHandle, withResize, drawHandle, getSymmetricHandleIndex, getResizeHandlePointByIndex, getDirectionFactorByDirectionComponent, getCrossingPointsBetweenPointAndSegment, isPointOnSegment, getDirectionByPointOfRectangle, getDirectionFactor, rotateVector, getOppositeDirection, rotateVectorAnti90, getSourceAndTargetOuterRectangle, getNextPoint, PRIMARY_COLOR, CommonElementFlavour, canResize, drawPrimaryHandle, drawFillPrimaryHandle, isVirtualKey, isDelete, isSpaceHotkey, isDndMode, isDrawingMode, getElementsText, acceptImageTypes, getElementOfFocusedImage, buildImage, isResizingByCondition, getRatioByPoint, getTextManages, ImageGenerator, ResizeHandle, addRotating, removeRotating, drawRotateHandle } from '@plait/common';
|
|
3
3
|
import { pointsOnBezierCurves } from 'points-on-curve';
|
|
4
4
|
import { TEXT_DEFAULT_HEIGHT, DEFAULT_FONT_SIZE, AlignEditor } from '@plait/text-plugins';
|
|
5
5
|
import { isKeyHotkey } from 'is-hotkey';
|
|
@@ -120,7 +120,7 @@ const DefaultDrawStyle = {
|
|
|
120
120
|
strokeWidth: 2,
|
|
121
121
|
defaultRadius: 4,
|
|
122
122
|
strokeColor: '#000',
|
|
123
|
-
fill:
|
|
123
|
+
fill: DEFAULT_FILL
|
|
124
124
|
};
|
|
125
125
|
const DefaultDrawActiveStyle = {
|
|
126
126
|
strokeWidth: ACTIVE_STROKE_WIDTH,
|
|
@@ -578,8 +578,34 @@ class TextGenerator {
|
|
|
578
578
|
}
|
|
579
579
|
}
|
|
580
580
|
|
|
581
|
+
const isSingleSelectTable = (board) => {
|
|
582
|
+
const selectedElements = getSelectedElements(board);
|
|
583
|
+
return selectedElements && selectedElements.length === 1 && PlaitDrawElement.isElementByTable(selectedElements[0]);
|
|
584
|
+
};
|
|
585
|
+
const isSingleSelectElementByTable = (board) => {
|
|
586
|
+
const selectedElements = getSelectedElements(board);
|
|
587
|
+
return selectedElements && selectedElements.length === 1 && PlaitDrawElement.isElementByTable(selectedElements[0]);
|
|
588
|
+
};
|
|
589
|
+
const getSelectedTableElements = (board, elements) => {
|
|
590
|
+
const selectedElements = elements?.length ? elements : getSelectedElements(board);
|
|
591
|
+
return selectedElements.filter(value => PlaitDrawElement.isElementByTable(value));
|
|
592
|
+
};
|
|
593
|
+
const SELECTED_CELLS = new WeakMap();
|
|
594
|
+
function getSelectedCells(element) {
|
|
595
|
+
return SELECTED_CELLS.get(element);
|
|
596
|
+
}
|
|
597
|
+
function setSelectedCells(element, cells) {
|
|
598
|
+
return SELECTED_CELLS.set(element, cells);
|
|
599
|
+
}
|
|
600
|
+
function clearSelectedCells(element) {
|
|
601
|
+
return SELECTED_CELLS.delete(element);
|
|
602
|
+
}
|
|
603
|
+
|
|
581
604
|
function getCellsWithPoints(board, element) {
|
|
582
|
-
const table = board
|
|
605
|
+
const table = board?.buildTable(element);
|
|
606
|
+
if (!table || !table.points || !table.columns || !table.rows) {
|
|
607
|
+
throw new Error('can not get table cells points');
|
|
608
|
+
}
|
|
583
609
|
const rectangle = RectangleClient.getRectangleByPoints(table.points);
|
|
584
610
|
const columnsCount = table.columns.length;
|
|
585
611
|
const rowsCount = table.rows.length;
|
|
@@ -611,9 +637,14 @@ function getCellsWithPoints(board, element) {
|
|
|
611
637
|
return cells;
|
|
612
638
|
}
|
|
613
639
|
function getCellWithPoints(board, table, cellId) {
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
640
|
+
try {
|
|
641
|
+
const cells = getCellsWithPoints(board, table);
|
|
642
|
+
const cellIndex = cells && table.cells.findIndex(item => item.id === cellId);
|
|
643
|
+
return cells[cellIndex];
|
|
644
|
+
}
|
|
645
|
+
catch (error) {
|
|
646
|
+
throw new Error('can not get table cell points');
|
|
647
|
+
}
|
|
617
648
|
}
|
|
618
649
|
function calculateCellsSize(items, tableSize, count, isWidth) {
|
|
619
650
|
const cellSizes = [];
|
|
@@ -722,6 +753,20 @@ const createCell = (rowId, columnId, text = null) => {
|
|
|
722
753
|
}
|
|
723
754
|
return cell;
|
|
724
755
|
};
|
|
756
|
+
const getSelectedTableCellsEditor = (board) => {
|
|
757
|
+
if (isSingleSelectElementByTable(board)) {
|
|
758
|
+
const elements = getSelectedTableElements(board);
|
|
759
|
+
const selectedCells = getSelectedCells(elements[0]);
|
|
760
|
+
const selectedCellsEditor = selectedCells?.map(cell => {
|
|
761
|
+
const textManage = getTextManageByCell(cell);
|
|
762
|
+
return textManage?.editor;
|
|
763
|
+
});
|
|
764
|
+
if (selectedCellsEditor?.length) {
|
|
765
|
+
return selectedCellsEditor;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
return undefined;
|
|
769
|
+
};
|
|
725
770
|
|
|
726
771
|
const SHAPE_MAX_LENGTH = 6;
|
|
727
772
|
const memorizedShape = new WeakMap();
|
|
@@ -752,7 +797,6 @@ const getMemorizeKey = (element) => {
|
|
|
752
797
|
};
|
|
753
798
|
const getLineMemorizedLatest = () => {
|
|
754
799
|
const properties = getMemorizedLatest(MemorizeKey.line);
|
|
755
|
-
delete properties?.text;
|
|
756
800
|
return { ...properties } || {};
|
|
757
801
|
};
|
|
758
802
|
const getMemorizedLatestByPointer = (pointer) => {
|
|
@@ -951,34 +995,34 @@ const isHitLine = (board, element, point) => {
|
|
|
951
995
|
const isHitText = isHitLineText(board, element, point);
|
|
952
996
|
return isHitText || isHitPolyLine(points, point);
|
|
953
997
|
};
|
|
954
|
-
const
|
|
998
|
+
const isRectangleHitElementText = (element, rectangle) => {
|
|
955
999
|
const engine = getEngine(element.shape);
|
|
956
1000
|
if (isMultipleTextGeometry(element)) {
|
|
957
1001
|
const texts = element.texts;
|
|
958
1002
|
return texts.some(item => {
|
|
959
1003
|
const textClient = engine.getTextRectangle(element, { key: item.key });
|
|
960
|
-
|
|
1004
|
+
const rotatedCornerPoints = rotatePointsByElement(RectangleClient.getCornerPoints(textClient), element) || RectangleClient.getCornerPoints(textClient);
|
|
1005
|
+
return isPolylineHitRectangle(rotatedCornerPoints, rectangle);
|
|
961
1006
|
});
|
|
962
1007
|
}
|
|
963
1008
|
else {
|
|
964
1009
|
const textClient = engine.getTextRectangle ? engine.getTextRectangle(element) : getTextRectangle(element);
|
|
965
|
-
|
|
1010
|
+
const rotatedCornerPoints = rotatePointsByElement(RectangleClient.getCornerPoints(textClient), element) || RectangleClient.getCornerPoints(textClient);
|
|
1011
|
+
return isPolylineHitRectangle(rotatedCornerPoints, rectangle);
|
|
966
1012
|
}
|
|
967
1013
|
};
|
|
968
|
-
const
|
|
1014
|
+
const isHitElementText = (element, point) => {
|
|
969
1015
|
const engine = getEngine(element.shape);
|
|
970
1016
|
if (isMultipleTextGeometry(element)) {
|
|
971
1017
|
const texts = element.texts;
|
|
972
1018
|
return texts.some(item => {
|
|
973
1019
|
const textClient = engine.getTextRectangle(element, { key: item.key });
|
|
974
|
-
|
|
975
|
-
return isPolylineHitRectangle(rotatedCornerPoints, rectangle);
|
|
1020
|
+
return RectangleClient.isPointInRectangle(textClient, point);
|
|
976
1021
|
});
|
|
977
1022
|
}
|
|
978
1023
|
else {
|
|
979
1024
|
const textClient = engine.getTextRectangle ? engine.getTextRectangle(element) : getTextRectangle(element);
|
|
980
|
-
|
|
981
|
-
return isPolylineHitRectangle(rotatedCornerPoints, rectangle);
|
|
1025
|
+
return RectangleClient.isPointInRectangle(textClient, point);
|
|
982
1026
|
}
|
|
983
1027
|
};
|
|
984
1028
|
const isRectangleHitDrawElement = (board, element, selection) => {
|
|
@@ -1003,35 +1047,59 @@ const isRectangleHitDrawElement = (board, element, selection) => {
|
|
|
1003
1047
|
}
|
|
1004
1048
|
return null;
|
|
1005
1049
|
};
|
|
1050
|
+
const getDrawHitElement = (board, elements) => {
|
|
1051
|
+
let firstFilledElement = getFirstFilledDrawElement(board, elements);
|
|
1052
|
+
let endIndex = elements.length;
|
|
1053
|
+
if (firstFilledElement) {
|
|
1054
|
+
endIndex = elements.indexOf(firstFilledElement) + 1;
|
|
1055
|
+
}
|
|
1056
|
+
const newElements = elements.slice(0, endIndex);
|
|
1057
|
+
const element = getFirstTextOrLineElement(newElements);
|
|
1058
|
+
if (element) {
|
|
1059
|
+
return element;
|
|
1060
|
+
}
|
|
1061
|
+
const sortElements = sortElementsByArea(board, newElements, 'asc');
|
|
1062
|
+
return sortElements[0];
|
|
1063
|
+
};
|
|
1064
|
+
const getFirstFilledDrawElement = (board, elements) => {
|
|
1065
|
+
let filledElement = null;
|
|
1066
|
+
for (let i = 0; i < elements.length; i++) {
|
|
1067
|
+
const element = elements[i];
|
|
1068
|
+
if (PlaitDrawElement.isGeometry(element) && !PlaitDrawElement.isText(element)) {
|
|
1069
|
+
const fill = getFillByElement(board, element);
|
|
1070
|
+
if (isFilled(fill)) {
|
|
1071
|
+
filledElement = element;
|
|
1072
|
+
break;
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
return filledElement;
|
|
1077
|
+
};
|
|
1078
|
+
const getFirstTextOrLineElement = (elements) => {
|
|
1079
|
+
const texts = elements.filter(item => PlaitDrawElement.isText(item));
|
|
1080
|
+
if (texts.length) {
|
|
1081
|
+
return texts[0];
|
|
1082
|
+
}
|
|
1083
|
+
const lines = elements.filter(item => PlaitDrawElement.isLine(item));
|
|
1084
|
+
if (lines.length) {
|
|
1085
|
+
return lines[0];
|
|
1086
|
+
}
|
|
1087
|
+
return null;
|
|
1088
|
+
};
|
|
1006
1089
|
const isHitDrawElement = (board, element, point) => {
|
|
1007
1090
|
const rectangle = board.getRectangle(element);
|
|
1008
1091
|
point = rotateAntiPointsByElement(point, element) || point;
|
|
1009
1092
|
if (PlaitDrawElement.isGeometry(element)) {
|
|
1010
|
-
const fill = getFillByElement(board, element);
|
|
1011
1093
|
if (isHitEdgeOfShape(board, element, point, HIT_DISTANCE_BUFFER)) {
|
|
1012
1094
|
return true;
|
|
1013
1095
|
}
|
|
1014
1096
|
const engine = getEngine(getElementShape(element));
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
if (isHitInside) {
|
|
1019
|
-
return isHitInside;
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
else {
|
|
1023
|
-
// if shape equals text, only check text rectangle
|
|
1024
|
-
if (PlaitDrawElement.isText(element)) {
|
|
1025
|
-
const textClient = getTextRectangle(element);
|
|
1026
|
-
let isHitText = RectangleClient.isPointInRectangle(textClient, point);
|
|
1027
|
-
return isHitText;
|
|
1028
|
-
}
|
|
1029
|
-
// check textRectangle of element
|
|
1030
|
-
const isHitText = isHitElementText(element, point);
|
|
1031
|
-
if (isHitText) {
|
|
1032
|
-
return isHitText;
|
|
1033
|
-
}
|
|
1097
|
+
if (PlaitDrawElement.isText(element)) {
|
|
1098
|
+
const textClient = getTextRectangle(element);
|
|
1099
|
+
return RectangleClient.isPointInRectangle(textClient, point);
|
|
1034
1100
|
}
|
|
1101
|
+
const isHitText = isHitElementText(element, point);
|
|
1102
|
+
return isHitText || engine.isInsidePoint(rectangle, point);
|
|
1035
1103
|
}
|
|
1036
1104
|
if (PlaitDrawElement.isImage(element)) {
|
|
1037
1105
|
const client = RectangleClient.getRectangleByPoints(element.points);
|
|
@@ -1238,7 +1306,7 @@ const getLineDashByElement = (element) => {
|
|
|
1238
1306
|
case StrokeStyle.dashed:
|
|
1239
1307
|
return [8, 8 + getStrokeWidthByElement(element)];
|
|
1240
1308
|
case StrokeStyle.dotted:
|
|
1241
|
-
return [
|
|
1309
|
+
return [2, 4 + getStrokeWidthByElement(element)];
|
|
1242
1310
|
default:
|
|
1243
1311
|
return undefined;
|
|
1244
1312
|
}
|
|
@@ -2649,8 +2717,10 @@ const getDefaultSwimlanePoints = (pointer, centerPoint) => {
|
|
|
2649
2717
|
const createDefaultSwimlane = (shape, points) => {
|
|
2650
2718
|
const header = isSwimlaneWithHeader(shape);
|
|
2651
2719
|
const dataShape = adjustSwimlaneShape(shape);
|
|
2652
|
-
const
|
|
2653
|
-
const
|
|
2720
|
+
const width = points[1][0] - points[0][0];
|
|
2721
|
+
const height = points[1][1] - points[0][1];
|
|
2722
|
+
const rows = createDefaultRowsOrColumns(dataShape, 'row', header, height);
|
|
2723
|
+
const columns = createDefaultRowsOrColumns(dataShape, 'column', header, width);
|
|
2654
2724
|
const swimlane = {
|
|
2655
2725
|
id: idCreator(),
|
|
2656
2726
|
type: 'swimlane',
|
|
@@ -2663,18 +2733,22 @@ const createDefaultSwimlane = (shape, points) => {
|
|
|
2663
2733
|
};
|
|
2664
2734
|
return swimlane;
|
|
2665
2735
|
};
|
|
2666
|
-
const createDefaultRowsOrColumns = (shape, type, header) => {
|
|
2736
|
+
const createDefaultRowsOrColumns = (shape, type, header, size) => {
|
|
2667
2737
|
const createItems = (count) => new Array(count).fill('').map(() => ({ id: idCreator() }));
|
|
2668
2738
|
let data = createItems(3);
|
|
2669
2739
|
if ((type === 'row' && shape === SwimlaneSymbols.swimlaneVertical) ||
|
|
2670
2740
|
(type === 'column' && shape === SwimlaneSymbols.swimlaneHorizontal)) {
|
|
2671
2741
|
data = header ? data : createItems(2);
|
|
2672
2742
|
const dimension = type === 'row' ? 'height' : 'width';
|
|
2743
|
+
let defaultSize = SWIMLANE_HEADER_SIZE;
|
|
2744
|
+
if (size < SWIMLANE_HEADER_SIZE * data.length) {
|
|
2745
|
+
defaultSize = Math.min((size / data.length / SWIMLANE_HEADER_SIZE) * SWIMLANE_HEADER_SIZE, SWIMLANE_HEADER_SIZE);
|
|
2746
|
+
}
|
|
2673
2747
|
data = data.map((item, index) => {
|
|
2674
2748
|
if (index === 0 || (index === 1 && header)) {
|
|
2675
2749
|
return {
|
|
2676
2750
|
...item,
|
|
2677
|
-
[dimension]:
|
|
2751
|
+
[dimension]: defaultSize
|
|
2678
2752
|
};
|
|
2679
2753
|
}
|
|
2680
2754
|
return item;
|
|
@@ -2877,33 +2951,6 @@ const updateSwimlane = (board, swimlane, newColumns, newRows, newCells, newPoint
|
|
|
2877
2951
|
points: newPoints
|
|
2878
2952
|
}, path);
|
|
2879
2953
|
};
|
|
2880
|
-
const setSwimlaneFill = (board, element, fill, path) => {
|
|
2881
|
-
const selectedCells = getSelectedCells(element);
|
|
2882
|
-
let newCells = element.cells;
|
|
2883
|
-
if (selectedCells?.length) {
|
|
2884
|
-
newCells = element.cells.map(cell => {
|
|
2885
|
-
if (selectedCells.map(item => item.id).includes(cell.id)) {
|
|
2886
|
-
return {
|
|
2887
|
-
...cell,
|
|
2888
|
-
fill
|
|
2889
|
-
};
|
|
2890
|
-
}
|
|
2891
|
-
return cell;
|
|
2892
|
-
});
|
|
2893
|
-
}
|
|
2894
|
-
else {
|
|
2895
|
-
newCells = element.cells.map(cell => {
|
|
2896
|
-
if (cell.text && cell.textHeight) {
|
|
2897
|
-
return {
|
|
2898
|
-
...cell,
|
|
2899
|
-
fill
|
|
2900
|
-
};
|
|
2901
|
-
}
|
|
2902
|
-
return cell;
|
|
2903
|
-
});
|
|
2904
|
-
}
|
|
2905
|
-
Transforms.setNode(board, { cells: newCells }, path);
|
|
2906
|
-
};
|
|
2907
2954
|
|
|
2908
2955
|
const setDrawShapeText = (board, element, text) => {
|
|
2909
2956
|
const newTexts = element.texts?.map(item => {
|
|
@@ -2919,7 +2966,8 @@ const setDrawShapeText = (board, element, text) => {
|
|
|
2919
2966
|
Transforms.setNode(board, newElement, [path]);
|
|
2920
2967
|
};
|
|
2921
2968
|
|
|
2922
|
-
const setTableText = (board,
|
|
2969
|
+
const setTableText = (board, path, cellId, text, textHeight) => {
|
|
2970
|
+
const table = PlaitNode.get(board, path);
|
|
2923
2971
|
const cell = getCellWithPoints(board, table, cellId);
|
|
2924
2972
|
const cellIndex = table.cells.findIndex(item => item.id === cell.id);
|
|
2925
2973
|
let rows = [...table.rows];
|
|
@@ -2955,8 +3003,35 @@ const setTableText = (board, table, cellId, text, textWidth, textHeight) => {
|
|
|
2955
3003
|
textHeight: textHeight,
|
|
2956
3004
|
text
|
|
2957
3005
|
};
|
|
2958
|
-
|
|
2959
|
-
|
|
3006
|
+
Transforms.setNode(board, { rows, columns, cells, points }, path);
|
|
3007
|
+
};
|
|
3008
|
+
|
|
3009
|
+
const setTableFill = (board, element, fill, path) => {
|
|
3010
|
+
const selectedCells = getSelectedCells(element);
|
|
3011
|
+
let newCells = element.cells;
|
|
3012
|
+
if (selectedCells?.length) {
|
|
3013
|
+
newCells = element.cells.map(cell => {
|
|
3014
|
+
if (selectedCells.map(item => item.id).includes(cell.id)) {
|
|
3015
|
+
return {
|
|
3016
|
+
...cell,
|
|
3017
|
+
fill
|
|
3018
|
+
};
|
|
3019
|
+
}
|
|
3020
|
+
return cell;
|
|
3021
|
+
});
|
|
3022
|
+
}
|
|
3023
|
+
else {
|
|
3024
|
+
newCells = element.cells.map(cell => {
|
|
3025
|
+
if (cell.text && cell.textHeight) {
|
|
3026
|
+
return {
|
|
3027
|
+
...cell,
|
|
3028
|
+
fill
|
|
3029
|
+
};
|
|
3030
|
+
}
|
|
3031
|
+
return cell;
|
|
3032
|
+
});
|
|
3033
|
+
}
|
|
3034
|
+
Transforms.setNode(board, { cells: newCells }, path);
|
|
2960
3035
|
};
|
|
2961
3036
|
|
|
2962
3037
|
const DrawTransforms = {
|
|
@@ -2980,8 +3055,8 @@ const DrawTransforms = {
|
|
|
2980
3055
|
addSwimlaneColumn,
|
|
2981
3056
|
removeSwimlaneRow,
|
|
2982
3057
|
removeSwimlaneColumn,
|
|
2983
|
-
|
|
2984
|
-
|
|
3058
|
+
updateSwimlaneCount,
|
|
3059
|
+
setTableFill
|
|
2985
3060
|
};
|
|
2986
3061
|
|
|
2987
3062
|
const getHitRectangleResizeHandleRef = (board, rectangle, point, angle = 0) => {
|
|
@@ -3116,8 +3191,14 @@ function withDrawResize(board) {
|
|
|
3116
3191
|
}
|
|
3117
3192
|
}
|
|
3118
3193
|
if (PlaitDrawElement.isGeometry(target)) {
|
|
3119
|
-
|
|
3120
|
-
|
|
3194
|
+
if (isGeometryIncludeText(target)) {
|
|
3195
|
+
const { height: textHeight } = getFirstTextManage(target).getSize();
|
|
3196
|
+
DrawTransforms.resizeGeometry(board, points, textHeight, path);
|
|
3197
|
+
}
|
|
3198
|
+
else {
|
|
3199
|
+
points = normalizeShapePoints(points);
|
|
3200
|
+
Transforms.setNode(board, { points }, path);
|
|
3201
|
+
}
|
|
3121
3202
|
}
|
|
3122
3203
|
else if (PlaitDrawElement.isLine(target)) {
|
|
3123
3204
|
Transforms.setNode(board, { points }, path);
|
|
@@ -3438,29 +3519,6 @@ function drawIsometricSnapLines(board, activePoints, snapRectangles, resizeSnapO
|
|
|
3438
3519
|
return drawSolidLines(board, isometricLines);
|
|
3439
3520
|
}
|
|
3440
3521
|
|
|
3441
|
-
const isSingleSelectTable = (board) => {
|
|
3442
|
-
const selectedElements = getSelectedElements(board);
|
|
3443
|
-
return selectedElements && selectedElements.length === 1 && PlaitTableElement.isTable(selectedElements[0]);
|
|
3444
|
-
};
|
|
3445
|
-
const isSingleSelectElementByTable = (board) => {
|
|
3446
|
-
const selectedElements = getSelectedElements(board);
|
|
3447
|
-
return selectedElements && selectedElements.length === 1 && PlaitDrawElement.isElementByTable(selectedElements[0]);
|
|
3448
|
-
};
|
|
3449
|
-
const getSelectedTableElements = (board, elements) => {
|
|
3450
|
-
const selectedElements = elements?.length ? elements : getSelectedElements(board);
|
|
3451
|
-
return selectedElements.filter(value => PlaitTableElement.isTable(value));
|
|
3452
|
-
};
|
|
3453
|
-
const SELECTED_CELLS = new WeakMap();
|
|
3454
|
-
function getSelectedCells(element) {
|
|
3455
|
-
return SELECTED_CELLS.get(element);
|
|
3456
|
-
}
|
|
3457
|
-
function setSelectedCells(element, cells) {
|
|
3458
|
-
return SELECTED_CELLS.set(element, cells);
|
|
3459
|
-
}
|
|
3460
|
-
function clearSelectedCells(element) {
|
|
3461
|
-
return SELECTED_CELLS.delete(element);
|
|
3462
|
-
}
|
|
3463
|
-
|
|
3464
3522
|
const getCenterPointsOnPolygon = (points) => {
|
|
3465
3523
|
const centerPoints = [];
|
|
3466
3524
|
for (let i = 0; i < points.length; i++) {
|
|
@@ -3644,7 +3702,9 @@ function createEllipseEngine(createOptions) {
|
|
|
3644
3702
|
draw(board, rectangle, options) {
|
|
3645
3703
|
const centerPoint = [rectangle.x + rectangle.width / 2, rectangle.y + rectangle.height / 2];
|
|
3646
3704
|
const rs = PlaitBoard.getRoughSVG(board);
|
|
3647
|
-
|
|
3705
|
+
const shape = rs.ellipse(centerPoint[0], centerPoint[1], rectangle.width, rectangle.height, { ...options, fillStyle: 'solid' });
|
|
3706
|
+
setStrokeLinecap(shape, 'round');
|
|
3707
|
+
return shape;
|
|
3648
3708
|
},
|
|
3649
3709
|
isInsidePoint(rectangle, point) {
|
|
3650
3710
|
const centerPoint = [rectangle.x + rectangle.width / 2, rectangle.y + rectangle.height / 2];
|
|
@@ -3987,7 +4047,9 @@ const RoundCommentEngine = {
|
|
|
3987
4047
|
const point9 = [x1 + rectangle.width / 4, y2];
|
|
3988
4048
|
const point10 = [x1 + rectangle.width / 4, rectangle.y + rectangle.height];
|
|
3989
4049
|
const point11 = [x1 + rectangle.width / 2, y2];
|
|
3990
|
-
|
|
4050
|
+
const shape = rs.path(`M${point2[0]} ${point2[1]} A ${radius} ${radius}, 0, 0, 1, ${point3[0]} ${point3[1]} L ${point4[0]} ${point4[1]} A ${radius} ${radius}, 0, 0, 1, ${point5[0]} ${point5[1]} L ${point11[0]} ${point11[1]} ${point10[0]} ${point10[1]} ${point9[0]} ${point9[1]} ${point6[0]} ${point6[1]} A ${radius} ${radius}, 0, 0, 1, ${point7[0]} ${point7[1]} L ${point8[0]} ${point8[1]} A ${radius} ${radius}, 0, 0, 1, ${point1[0]} ${point1[1]} Z`, { ...options, fillStyle: 'solid' });
|
|
4051
|
+
setStrokeLinecap(shape, 'round');
|
|
4052
|
+
return shape;
|
|
3991
4053
|
},
|
|
3992
4054
|
isInsidePoint(rectangle, point) {
|
|
3993
4055
|
const points = [
|
|
@@ -4571,13 +4633,15 @@ const OrEngine = createEllipseEngine({
|
|
|
4571
4633
|
const rx = rectangle.width / 2;
|
|
4572
4634
|
const ry = rectangle.height / 2;
|
|
4573
4635
|
const startPoint = [rectangle.x + rectangle.width, rectangle.y + rectangle.height / 2];
|
|
4574
|
-
|
|
4636
|
+
const shape = rs.path(`M${startPoint[0]} ${startPoint[1]}
|
|
4575
4637
|
A${rx},${ry} 0 1,1 ${startPoint[0]} ${startPoint[1] - 0.01}
|
|
4576
4638
|
M${rectangle.x} ${rectangle.y + rectangle.height / 2}
|
|
4577
4639
|
L${rectangle.x + rectangle.width} ${rectangle.y + rectangle.height / 2}
|
|
4578
4640
|
M${rectangle.x + rectangle.width / 2} ${rectangle.y}
|
|
4579
4641
|
L${rectangle.x + rectangle.width / 2} ${rectangle.y + rectangle.height}
|
|
4580
4642
|
`, { ...options, fillStyle: 'solid' });
|
|
4643
|
+
setStrokeLinecap(shape, 'round');
|
|
4644
|
+
return shape;
|
|
4581
4645
|
}
|
|
4582
4646
|
});
|
|
4583
4647
|
|
|
@@ -4590,13 +4654,15 @@ const SummingJunctionEngine = createEllipseEngine({
|
|
|
4590
4654
|
const centerPoint = [rectangle.x + rectangle.width / 2, rectangle.y + rectangle.height / 2];
|
|
4591
4655
|
const line1Points = getCrossingPointsBetweenEllipseAndSegment([rectangle.x, rectangle.y], [rectangle.x + rectangle.width, rectangle.y + rectangle.height], centerPoint[0], centerPoint[1], rx, ry);
|
|
4592
4656
|
const line2Points = getCrossingPointsBetweenEllipseAndSegment([rectangle.x + rectangle.width, rectangle.y], [rectangle.x, rectangle.y + rectangle.height], centerPoint[0], centerPoint[1], rx, ry);
|
|
4593
|
-
|
|
4657
|
+
const shape = rs.path(`M${startPoint[0]} ${startPoint[1]}
|
|
4594
4658
|
A${rx},${ry} 0 1,1 ${startPoint[0]} ${startPoint[1] - 0.01}
|
|
4595
4659
|
M${line1Points[0][0]} ${line1Points[0][1]}
|
|
4596
4660
|
L${line1Points[1][0]} ${line1Points[1][1]}
|
|
4597
4661
|
M${line2Points[0][0]} ${line2Points[0][1]}
|
|
4598
4662
|
L${line2Points[1][0]} ${line2Points[1][1]}
|
|
4599
4663
|
`, { ...options, fillStyle: 'solid' });
|
|
4664
|
+
setStrokeLinecap(shape, 'round');
|
|
4665
|
+
return shape;
|
|
4600
4666
|
}
|
|
4601
4667
|
});
|
|
4602
4668
|
|
|
@@ -5023,7 +5089,7 @@ const NoteCurlyLeftEngine = {
|
|
|
5023
5089
|
${rectangle.x + rectangle.width - rectangle.width * 0.09} ${rectangle.y + rectangle.height / 2}
|
|
5024
5090
|
C${rectangle.x + rectangle.width} ${rectangle.y + rectangle.height / 2},
|
|
5025
5091
|
${rectangle.x + rectangle.width - rectangle.width * 0.09} ${rectangle.y + rectangle.height},
|
|
5026
|
-
${rectangle.x + rectangle.width} ${rectangle.y + rectangle.height}`, { ...options, fillStyle: 'solid' });
|
|
5092
|
+
${rectangle.x + rectangle.width} ${rectangle.y + rectangle.height}`, { ...options, fillStyle: 'solid', fill: 'transparent' });
|
|
5027
5093
|
setStrokeLinecap(shape, 'round');
|
|
5028
5094
|
return shape;
|
|
5029
5095
|
},
|
|
@@ -5062,13 +5128,13 @@ const NoteCurlyLeftEngine = {
|
|
|
5062
5128
|
const NoteCurlyRightEngine = {
|
|
5063
5129
|
draw(board, rectangle, options) {
|
|
5064
5130
|
const rs = PlaitBoard.getRoughSVG(board);
|
|
5065
|
-
const shape = rs.path(`M${rectangle.x} ${rectangle.y}
|
|
5066
|
-
C${rectangle.x + rectangle.width * 0.09} ${rectangle.y},
|
|
5067
|
-
${rectangle.x} ${rectangle.y + rectangle.height / 2},
|
|
5131
|
+
const shape = rs.path(`M${rectangle.x} ${rectangle.y}
|
|
5132
|
+
C${rectangle.x + rectangle.width * 0.09} ${rectangle.y},
|
|
5133
|
+
${rectangle.x} ${rectangle.y + rectangle.height / 2},
|
|
5068
5134
|
${rectangle.x + rectangle.width * 0.09} ${rectangle.y + rectangle.height / 2}
|
|
5069
|
-
C${rectangle.x} ${rectangle.y + rectangle.height / 2},
|
|
5070
|
-
${rectangle.x + rectangle.width * 0.09} ${rectangle.y + rectangle.height},
|
|
5071
|
-
${rectangle.x} ${rectangle.y + rectangle.height}`, { ...options, fillStyle: 'solid' });
|
|
5135
|
+
C${rectangle.x} ${rectangle.y + rectangle.height / 2},
|
|
5136
|
+
${rectangle.x + rectangle.width * 0.09} ${rectangle.y + rectangle.height},
|
|
5137
|
+
${rectangle.x} ${rectangle.y + rectangle.height}`, { ...options, fillStyle: 'solid', fill: 'transparent' });
|
|
5072
5138
|
setStrokeLinecap(shape, 'round');
|
|
5073
5139
|
return shape;
|
|
5074
5140
|
},
|
|
@@ -5109,7 +5175,7 @@ const NoteSquareEngine = {
|
|
|
5109
5175
|
const rs = PlaitBoard.getRoughSVG(board);
|
|
5110
5176
|
const shape = rs.path(`M${rectangle.x + rectangle.width * 0.075} ${rectangle.y + rectangle.height} H${rectangle.x} V${rectangle.y} H${rectangle.x +
|
|
5111
5177
|
rectangle.width * 0.075}
|
|
5112
|
-
`, { ...options, fillStyle: 'solid' });
|
|
5178
|
+
`, { ...options, fillStyle: 'solid', fill: 'transparent' });
|
|
5113
5179
|
setStrokeLinecap(shape, 'round');
|
|
5114
5180
|
return shape;
|
|
5115
5181
|
},
|
|
@@ -5219,27 +5285,34 @@ const DisplayEngine = {
|
|
|
5219
5285
|
|
|
5220
5286
|
const TableEngine = {
|
|
5221
5287
|
draw(board, rectangle, roughOptions, options) {
|
|
5222
|
-
const rs = PlaitBoard.getRoughSVG(board);
|
|
5223
5288
|
const g = createG();
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5289
|
+
try {
|
|
5290
|
+
const pointCells = getCellsWithPoints(board, { ...options?.element });
|
|
5291
|
+
if (pointCells) {
|
|
5292
|
+
const rs = PlaitBoard.getRoughSVG(board);
|
|
5293
|
+
const { x, y, width, height } = rectangle;
|
|
5294
|
+
const tableTopBorder = drawLine$1(rs, [x, y], [x + width, y], roughOptions);
|
|
5295
|
+
const tableLeftBorder = drawLine$1(rs, [x, y], [x, y + height], roughOptions);
|
|
5296
|
+
g.append(tableTopBorder, tableLeftBorder);
|
|
5297
|
+
pointCells.forEach(cell => {
|
|
5298
|
+
const rectangle = RectangleClient.getRectangleByPoints(cell.points);
|
|
5299
|
+
const { x, y, width, height } = rectangle;
|
|
5300
|
+
const cellRectangle = drawRectangle(board, {
|
|
5301
|
+
x: x + ACTIVE_STROKE_WIDTH,
|
|
5302
|
+
y: y + ACTIVE_STROKE_WIDTH,
|
|
5303
|
+
width: width - ACTIVE_STROKE_WIDTH * 2,
|
|
5304
|
+
height: height - ACTIVE_STROKE_WIDTH * 2
|
|
5305
|
+
}, { fill: cell.fill, fillStyle: 'solid', strokeWidth: 0 });
|
|
5306
|
+
const cellRightBorder = drawLine$1(rs, [x + width, y], [x + width, y + height], roughOptions);
|
|
5307
|
+
const cellBottomBorder = drawLine$1(rs, [x, y + height], [x + width, y + height], roughOptions);
|
|
5308
|
+
g.append(cellRectangle, cellRightBorder, cellBottomBorder);
|
|
5309
|
+
});
|
|
5310
|
+
setStrokeLinecap(g, 'round');
|
|
5311
|
+
}
|
|
5312
|
+
}
|
|
5313
|
+
catch (error) {
|
|
5314
|
+
console.error(error);
|
|
5315
|
+
}
|
|
5243
5316
|
return g;
|
|
5244
5317
|
},
|
|
5245
5318
|
isInsidePoint(rectangle, point) {
|
|
@@ -5256,13 +5329,28 @@ const TableEngine = {
|
|
|
5256
5329
|
return RectangleClient.getEdgeCenterPoints(rectangle);
|
|
5257
5330
|
},
|
|
5258
5331
|
getTextRectangle(element, options) {
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5332
|
+
try {
|
|
5333
|
+
if (options && options.key) {
|
|
5334
|
+
const cell = getCellWithPoints(options?.board, element, options.key);
|
|
5335
|
+
if (cell) {
|
|
5336
|
+
if (PlaitTableElement.isVerticalText(cell)) {
|
|
5337
|
+
return getVerticalTextRectangle(cell);
|
|
5338
|
+
}
|
|
5339
|
+
else {
|
|
5340
|
+
return getHorizontalTextRectangle(cell);
|
|
5341
|
+
}
|
|
5342
|
+
}
|
|
5343
|
+
}
|
|
5262
5344
|
}
|
|
5263
|
-
|
|
5264
|
-
|
|
5345
|
+
catch (error) {
|
|
5346
|
+
console.error(error);
|
|
5265
5347
|
}
|
|
5348
|
+
return {
|
|
5349
|
+
x: 0,
|
|
5350
|
+
y: 0,
|
|
5351
|
+
width: 0,
|
|
5352
|
+
height: 0
|
|
5353
|
+
};
|
|
5266
5354
|
}
|
|
5267
5355
|
};
|
|
5268
5356
|
function getVerticalTextRectangle(cell) {
|
|
@@ -5563,6 +5651,7 @@ const DeletionEngine = {
|
|
|
5563
5651
|
const shape = rs.path(`M${rectangle.x} ${rectangle.y} L${rectangle.x + rectangle.width} ${rectangle.y + rectangle.height}
|
|
5564
5652
|
M${rectangle.x + rectangle.width} ${rectangle.y} L${rectangle.x} ${rectangle.y + rectangle.height}
|
|
5565
5653
|
`, { ...options, fillStyle: 'solid', strokeWidth: 4 });
|
|
5654
|
+
setStrokeLinecap(shape, 'round');
|
|
5566
5655
|
return shape;
|
|
5567
5656
|
},
|
|
5568
5657
|
isInsidePoint(rectangle, point) {
|
|
@@ -5742,7 +5831,8 @@ const RequiredInterfaceEngine = {
|
|
|
5742
5831
|
M${rectangle.x + rectangle.width * 0.41} ${rectangle.y + rectangle.height / 2} H${rectangle.x + rectangle.width}
|
|
5743
5832
|
`, {
|
|
5744
5833
|
...options,
|
|
5745
|
-
fillStyle: 'solid'
|
|
5834
|
+
fillStyle: 'solid',
|
|
5835
|
+
fill: 'transparent'
|
|
5746
5836
|
});
|
|
5747
5837
|
setStrokeLinecap(shape, 'round');
|
|
5748
5838
|
return shape;
|
|
@@ -6278,7 +6368,10 @@ const PlaitDrawElement = {
|
|
|
6278
6368
|
}
|
|
6279
6369
|
},
|
|
6280
6370
|
isShapeElement: (value) => {
|
|
6281
|
-
return PlaitDrawElement.isImage(value) ||
|
|
6371
|
+
return (PlaitDrawElement.isImage(value) ||
|
|
6372
|
+
PlaitDrawElement.isGeometry(value) ||
|
|
6373
|
+
PlaitDrawElement.isTable(value) ||
|
|
6374
|
+
PlaitDrawElement.isSwimlane(value));
|
|
6282
6375
|
},
|
|
6283
6376
|
isBasicShape: (value) => {
|
|
6284
6377
|
return Object.keys(BasicShapes).includes(value.shape);
|
|
@@ -6306,7 +6399,7 @@ const PlaitDrawElement = {
|
|
|
6306
6399
|
},
|
|
6307
6400
|
isElementByTable: (value) => {
|
|
6308
6401
|
return PlaitDrawElement.isTable(value) || PlaitDrawElement.isSwimlane(value) || PlaitDrawElement.isGeometryByTable(value);
|
|
6309
|
-
}
|
|
6402
|
+
}
|
|
6310
6403
|
};
|
|
6311
6404
|
|
|
6312
6405
|
class GeometryShapeGenerator extends Generator {
|
|
@@ -6688,7 +6781,9 @@ class LineComponent extends CommonElementFlavour {
|
|
|
6688
6781
|
return getLineTextRectangle(this.board, this.element, index);
|
|
6689
6782
|
},
|
|
6690
6783
|
onChange: (textManageChangeData) => {
|
|
6691
|
-
const
|
|
6784
|
+
const path = PlaitBoard.findPath(this.board, this.element);
|
|
6785
|
+
const node = PlaitNode.get(this.board, path);
|
|
6786
|
+
const texts = [...node.texts];
|
|
6692
6787
|
const newWidth = textManageChangeData.width < MIN_TEXT_WIDTH ? MIN_TEXT_WIDTH : textManageChangeData.width;
|
|
6693
6788
|
texts.splice(index, 1, {
|
|
6694
6789
|
text: textManageChangeData.newText ? textManageChangeData.newText : this.element.texts[index].text,
|
|
@@ -7463,8 +7558,9 @@ const withLineText = (board) => {
|
|
|
7463
7558
|
}
|
|
7464
7559
|
else {
|
|
7465
7560
|
const ratio = getRatioByPoint(points, point);
|
|
7561
|
+
const textMemory = getMemorizedLatest('line')?.text || {};
|
|
7466
7562
|
texts.push({
|
|
7467
|
-
text: buildText(LINE_TEXT),
|
|
7563
|
+
text: buildText(LINE_TEXT, undefined, textMemory),
|
|
7468
7564
|
position: ratio,
|
|
7469
7565
|
width: 28,
|
|
7470
7566
|
height: 20
|
|
@@ -7904,9 +8000,9 @@ class TableComponent extends CommonElementFlavour {
|
|
|
7904
8000
|
this.textGenerator = new TextGenerator(this.board, this.element, texts, {
|
|
7905
8001
|
onChange: (value, data, text) => {
|
|
7906
8002
|
const height = data.height / this.board.viewport.zoom;
|
|
7907
|
-
const
|
|
8003
|
+
const path = PlaitBoard.findPath(this.board, value);
|
|
7908
8004
|
if (data.newText) {
|
|
7909
|
-
DrawTransforms.setTableText(this.board,
|
|
8005
|
+
DrawTransforms.setTableText(this.board, path, text.key, data.newText, height);
|
|
7910
8006
|
}
|
|
7911
8007
|
data.operations && memorizeLatestText(value, data.operations);
|
|
7912
8008
|
},
|
|
@@ -8097,7 +8193,7 @@ function withTableResize(board) {
|
|
|
8097
8193
|
|
|
8098
8194
|
const withTable = (board) => {
|
|
8099
8195
|
const tableBoard = board;
|
|
8100
|
-
const { drawElement, getRectangle, isRectangleHit, isHit, isMovable, dblClick, keyDown } = tableBoard;
|
|
8196
|
+
const { drawElement, getRectangle, isRectangleHit, isHit, isMovable, dblClick, keyDown, pointerUp } = tableBoard;
|
|
8101
8197
|
tableBoard.drawElement = (context) => {
|
|
8102
8198
|
if (PlaitDrawElement.isElementByTable(context.element)) {
|
|
8103
8199
|
return TableComponent;
|
|
@@ -8134,12 +8230,21 @@ const withTable = (board) => {
|
|
|
8134
8230
|
const selectedElements = getSelectedElements(board);
|
|
8135
8231
|
const isSingleSelection = selectedElements.length === 1;
|
|
8136
8232
|
const targetElement = selectedElements[0];
|
|
8137
|
-
if (!PlaitBoard.isReadonly(board) &&
|
|
8233
|
+
if (!PlaitBoard.isReadonly(board) &&
|
|
8234
|
+
!PlaitBoard.hasBeenTextEditing(tableBoard) &&
|
|
8235
|
+
!isVirtualKey(event) &&
|
|
8236
|
+
!isDelete(event) &&
|
|
8237
|
+
!isSpaceHotkey(event) &&
|
|
8238
|
+
isSingleSelection) {
|
|
8138
8239
|
event.preventDefault();
|
|
8139
8240
|
if (PlaitDrawElement.isElementByTable(targetElement)) {
|
|
8140
|
-
const
|
|
8141
|
-
|
|
8142
|
-
|
|
8241
|
+
const cells = getSelectedCells(targetElement);
|
|
8242
|
+
let cell = targetElement.cells.find(item => item.text && item.textHeight);
|
|
8243
|
+
if (cells?.length) {
|
|
8244
|
+
cell = cells.find(item => item.text && item.textHeight);
|
|
8245
|
+
}
|
|
8246
|
+
if (cell) {
|
|
8247
|
+
editCell(cell);
|
|
8143
8248
|
return;
|
|
8144
8249
|
}
|
|
8145
8250
|
}
|
|
@@ -8161,6 +8266,23 @@ const withTable = (board) => {
|
|
|
8161
8266
|
}
|
|
8162
8267
|
dblClick(event);
|
|
8163
8268
|
};
|
|
8269
|
+
tableBoard.pointerUp = (event) => {
|
|
8270
|
+
const isSetSelectionPointer = PlaitBoard.isPointer(tableBoard, PlaitPointerType.selection) || PlaitBoard.isPointer(tableBoard, PlaitPointerType.hand);
|
|
8271
|
+
const isSkip = !isMainPointer(event) || isDragging(tableBoard) || !isSetSelectionPointer;
|
|
8272
|
+
if (isSkip) {
|
|
8273
|
+
pointerUp(event);
|
|
8274
|
+
return;
|
|
8275
|
+
}
|
|
8276
|
+
if (isSingleSelectTable(tableBoard)) {
|
|
8277
|
+
const point = toViewBoxPoint(tableBoard, toHostPoint(tableBoard, event.x, event.y));
|
|
8278
|
+
const element = getSelectedTableElements(tableBoard)[0];
|
|
8279
|
+
const hitCell = getHitCell(tableBoard, element, point);
|
|
8280
|
+
if (hitCell && hitCell.text && hitCell.textHeight) {
|
|
8281
|
+
setSelectedCells(element, [hitCell]);
|
|
8282
|
+
}
|
|
8283
|
+
}
|
|
8284
|
+
pointerUp(event);
|
|
8285
|
+
};
|
|
8164
8286
|
tableBoard.buildTable = (element) => {
|
|
8165
8287
|
return element;
|
|
8166
8288
|
};
|
|
@@ -8305,28 +8427,11 @@ const withSwimlane = (board) => {
|
|
|
8305
8427
|
}
|
|
8306
8428
|
return buildTable(element);
|
|
8307
8429
|
};
|
|
8308
|
-
board.pointerUp = (event) => {
|
|
8309
|
-
const isSetSelectionPointer = PlaitBoard.isPointer(board, PlaitPointerType.selection) || PlaitBoard.isPointer(board, PlaitPointerType.hand);
|
|
8310
|
-
const isSkip = !isMainPointer(event) || isDragging(board) || !isSetSelectionPointer;
|
|
8311
|
-
if (isSkip) {
|
|
8312
|
-
pointerUp(event);
|
|
8313
|
-
return;
|
|
8314
|
-
}
|
|
8315
|
-
if (isSingleSelectSwimlane(board)) {
|
|
8316
|
-
const point = toViewBoxPoint(board, toHostPoint(board, event.x, event.y));
|
|
8317
|
-
const element = getSelectedSwimlane(board);
|
|
8318
|
-
const hitCell = getHitCell(board, element, point);
|
|
8319
|
-
if (hitCell && hitCell.text && hitCell.textHeight) {
|
|
8320
|
-
setSelectedCells(element, [hitCell]);
|
|
8321
|
-
}
|
|
8322
|
-
}
|
|
8323
|
-
pointerUp(event);
|
|
8324
|
-
};
|
|
8325
8430
|
return withSwimlaneCreateByDrawing(withSwimlaneCreateByDrag(board));
|
|
8326
8431
|
};
|
|
8327
8432
|
|
|
8328
8433
|
const withDraw = (board) => {
|
|
8329
|
-
const { drawElement, getRectangle, isRectangleHit, isHit, isInsidePoint, isMovable, isAlign, getRelatedFragment } = board;
|
|
8434
|
+
const { drawElement, getRectangle, isRectangleHit, isHit, isInsidePoint, isMovable, isAlign, getRelatedFragment, getHitElement } = board;
|
|
8330
8435
|
board.drawElement = (context) => {
|
|
8331
8436
|
if (PlaitDrawElement.isGeometry(context.element)) {
|
|
8332
8437
|
if (PlaitDrawElement.isUML(context.element)) {
|
|
@@ -8374,6 +8479,13 @@ const withDraw = (board) => {
|
|
|
8374
8479
|
}
|
|
8375
8480
|
return isHit(element, point);
|
|
8376
8481
|
};
|
|
8482
|
+
board.getHitElement = elements => {
|
|
8483
|
+
const isDrawElements = elements.every(item => PlaitDrawElement.isDrawElement(item));
|
|
8484
|
+
if (isDrawElements) {
|
|
8485
|
+
return getDrawHitElement(board, elements);
|
|
8486
|
+
}
|
|
8487
|
+
return getHitElement(elements);
|
|
8488
|
+
};
|
|
8377
8489
|
board.isInsidePoint = (element, point) => {
|
|
8378
8490
|
const result = isHitElementInside(board, element, point);
|
|
8379
8491
|
if (result !== null) {
|
|
@@ -8430,5 +8542,5 @@ const withDraw = (board) => {
|
|
|
8430
8542
|
* Generated bundle index. Do not edit.
|
|
8431
8543
|
*/
|
|
8432
8544
|
|
|
8433
|
-
export { BasicShapes, DEFAULT_IMAGE_WIDTH, DefaultActivationProperty, DefaultActorProperty, DefaultArrowProperty, DefaultAssemblyProperty, DefaultBasicShapeProperty, DefaultBasicShapePropertyMap, DefaultClassProperty, DefaultCloudProperty, DefaultCombinedFragmentProperty, DefaultComponentBoxProperty, DefaultConnectorProperty, DefaultContainerProperty, DefaultDataBaseProperty, DefaultDataProperty, DefaultDecisionProperty, DefaultDeletionProperty, DefaultDocumentProperty, DefaultDrawActiveStyle, DefaultDrawStyle, DefaultFlowchartProperty, DefaultFlowchartPropertyMap, DefaultInterfaceProperty, DefaultInternalStorageProperty, DefaultManualInputProperty, DefaultMergeProperty, DefaultMultiDocumentProperty, DefaultNoteProperty, DefaultObjectProperty, DefaultPackageProperty, DefaultPentagonArrowProperty, DefaultPortProperty, DefaultProvidedInterfaceProperty, DefaultRequiredInterfaceProperty, DefaultSwimlaneHorizontalProperty, DefaultSwimlaneHorizontalWithHeaderProperty, DefaultSwimlanePropertyMap, DefaultSwimlaneVerticalProperty, DefaultSwimlaneVerticalWithHeaderProperty, 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, MIN_TEXT_WIDTH, MemorizeKey, MultipleTextGeometryCommonTextKeys, MultipleTextGeometryTextKeys, PlaitDrawElement, PlaitGeometry, PlaitLine, PlaitTableElement, Q2C, SELECTED_CELLS, SWIMLANE_HEADER_SIZE, ShapeDefaultSpace, SingleTextGenerator, StrokeStyle, SwimlaneDrawSymbols, SwimlaneSymbols, TableGenerator, TableSymbols, TextGenerator, UMLSymbols, WithLineAutoCompletePluginKey, adjustSwimlaneShape, alignElbowSegment, alignPoints, buildDefaultTextsByShape, buildSwimlaneTable, clearSelectedCells, createCell, createDefaultCells, createDefaultFlowchart, createDefaultGeometry, createDefaultRowsOrColumns, createDefaultSwimlane, createGeometryElement, createGeometryElementWithText, createGeometryElementWithoutText, createLineElement, createMultipleTextGeometryElement, createTextElement, createUMLClassOrInterfaceGeometryElement, debugGenerator$1 as debugGenerator, deleteTextManage, drawBoundReaction, drawGeometry, drawLine, drawLineArrow, drawShape, editCell, editText, getAutoCompletePoints, getBasicPointers, getCellWithPoints, getCellsRectangle, getCellsWithPoints, getCenterPointsOnPolygon$1 as getCenterPointsOnPolygon, getConnectionPoint, getCurvePoints, getDefaultBasicShapeProperty, getDefaultFlowchartProperty, getDefaultGeometryPoints, getDefaultGeometryProperty, getDefaultSwimlanePoints, getDefaultTextPoints, getDefaultUMLProperty, getDrawDefaultStrokeColor, getElbowLineRouteOptions, getElbowPoints, getFillByElement, getFlowchartDefaultFill, getFlowchartPointers, getGeometryAlign, getGeometryPointers, getHitCell, getHitConnection, getHitConnectorPoint, getHitIndexOfAutoCompletePoint, getHitMultipleGeometryText, getHitShape, getIndexAndDeleteCountByKeyPoint, getLineDashByElement, getLineHandleRefPair, getLineMemorizedLatest, getLinePointers, getLinePoints, getLineTextRectangle, getLines, getMemorizeKey, getMemorizedLatestByPointer, getMemorizedLatestShape, getMidKeyPoints, getMiddlePoints, getMirrorDataPoints, getMultipleTextGeometryTextKeys, getNearestPoint, getNextRenderPoints, getNextSourceAndTargetPoints, getResizedPreviousAndNextPoint, getSelectedCells, getSelectedDrawElements, getSelectedGeometryElements, getSelectedImageElements, getSelectedLineElements, getSelectedSwimlane, getSelectedTableElements, getSnapResizingRef, getSnapResizingRefOptions, getSnappingRef, getSnappingShape, getSourceAndTargetRectangle, getStrokeColorByElement, getStrokeStyleByElement, getStrokeWidthByElement, getSwimlaneCount, getSwimlanePointers, getTextKey, getTextManage, getTextManageByCell, getTextRectangle, getTextShapeProperty, getUMLPointers, getVectorByConnection, handleLineCreating, hasIllegalElbowPoint, insertElement, isCellIncludeText, isDrawElementIncludeText, isDrawElementsIncludeText, isGeometryIncludeText, isHitDrawElement, isHitEdgeOfShape, isHitElementInside, isHitElementText, isHitLine, isHitLineText, isHitPolyLine, isInsideOfShape, isMultipleTextGeometry, isMultipleTextShape, isRectangleHitDrawElement, isRectangleHitElementText, isSelfLoop, isSingleSelectElementByTable, isSingleSelectSwimlane, isSingleSelectTable, isSingleTextGeometry, isSingleTextShape, isSwimlaneWithHeader, isTextExceedingBounds, isUpdatedHandleIndex, isUseDefaultOrthogonalRoute, memorizeLatestShape, memorizeLatestText, rerenderGeometryActive, setSelectedCells, setTextManage, traverseDrawShapes, updateCellIds, updateCellIdsByRowOrColumn, updateColumns, updateRowOrColumnIds, updateRows, withDraw, withLineAutoComplete };
|
|
8545
|
+
export { BasicShapes, DEFAULT_IMAGE_WIDTH, DefaultActivationProperty, DefaultActorProperty, DefaultArrowProperty, DefaultAssemblyProperty, DefaultBasicShapeProperty, DefaultBasicShapePropertyMap, DefaultClassProperty, DefaultCloudProperty, DefaultCombinedFragmentProperty, DefaultComponentBoxProperty, DefaultConnectorProperty, DefaultContainerProperty, DefaultDataBaseProperty, DefaultDataProperty, DefaultDecisionProperty, DefaultDeletionProperty, DefaultDocumentProperty, DefaultDrawActiveStyle, DefaultDrawStyle, DefaultFlowchartProperty, DefaultFlowchartPropertyMap, DefaultInterfaceProperty, DefaultInternalStorageProperty, DefaultManualInputProperty, DefaultMergeProperty, DefaultMultiDocumentProperty, DefaultNoteProperty, DefaultObjectProperty, DefaultPackageProperty, DefaultPentagonArrowProperty, DefaultPortProperty, DefaultProvidedInterfaceProperty, DefaultRequiredInterfaceProperty, DefaultSwimlaneHorizontalProperty, DefaultSwimlaneHorizontalWithHeaderProperty, DefaultSwimlanePropertyMap, DefaultSwimlaneVerticalProperty, DefaultSwimlaneVerticalWithHeaderProperty, 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, MIN_TEXT_WIDTH, MemorizeKey, MultipleTextGeometryCommonTextKeys, MultipleTextGeometryTextKeys, PlaitDrawElement, PlaitGeometry, PlaitLine, PlaitTableElement, Q2C, SELECTED_CELLS, SWIMLANE_HEADER_SIZE, ShapeDefaultSpace, SingleTextGenerator, StrokeStyle, SwimlaneDrawSymbols, SwimlaneSymbols, TableGenerator, TableSymbols, TextGenerator, UMLSymbols, WithLineAutoCompletePluginKey, adjustSwimlaneShape, alignElbowSegment, alignPoints, buildDefaultTextsByShape, buildSwimlaneTable, clearSelectedCells, createCell, createDefaultCells, createDefaultFlowchart, createDefaultGeometry, createDefaultRowsOrColumns, createDefaultSwimlane, createGeometryElement, createGeometryElementWithText, createGeometryElementWithoutText, createLineElement, createMultipleTextGeometryElement, createTextElement, createUMLClassOrInterfaceGeometryElement, debugGenerator$1 as debugGenerator, deleteTextManage, drawBoundReaction, drawGeometry, drawLine, drawLineArrow, drawShape, editCell, editText, getAutoCompletePoints, getBasicPointers, getCellWithPoints, getCellsRectangle, getCellsWithPoints, getCenterPointsOnPolygon$1 as getCenterPointsOnPolygon, getConnectionPoint, getCurvePoints, getDefaultBasicShapeProperty, getDefaultFlowchartProperty, getDefaultGeometryPoints, getDefaultGeometryProperty, getDefaultSwimlanePoints, getDefaultTextPoints, getDefaultUMLProperty, getDrawDefaultStrokeColor, getDrawHitElement, getElbowLineRouteOptions, getElbowPoints, getFillByElement, getFirstFilledDrawElement, getFirstTextOrLineElement, getFlowchartDefaultFill, getFlowchartPointers, getGeometryAlign, getGeometryPointers, getHitCell, getHitConnection, getHitConnectorPoint, getHitIndexOfAutoCompletePoint, getHitMultipleGeometryText, getHitShape, getIndexAndDeleteCountByKeyPoint, getLineDashByElement, getLineHandleRefPair, getLineMemorizedLatest, getLinePointers, getLinePoints, getLineTextRectangle, getLines, getMemorizeKey, getMemorizedLatestByPointer, getMemorizedLatestShape, getMidKeyPoints, getMiddlePoints, getMirrorDataPoints, getMultipleTextGeometryTextKeys, getNearestPoint, getNextRenderPoints, getNextSourceAndTargetPoints, getResizedPreviousAndNextPoint, getSelectedCells, getSelectedDrawElements, getSelectedGeometryElements, getSelectedImageElements, getSelectedLineElements, getSelectedSwimlane, getSelectedTableCellsEditor, getSelectedTableElements, getSnapResizingRef, getSnapResizingRefOptions, getSnappingRef, getSnappingShape, getSourceAndTargetRectangle, getStrokeColorByElement, getStrokeStyleByElement, getStrokeWidthByElement, getSwimlaneCount, getSwimlanePointers, getTextKey, getTextManage, getTextManageByCell, getTextRectangle, getTextShapeProperty, getUMLPointers, getVectorByConnection, handleLineCreating, hasIllegalElbowPoint, insertElement, isCellIncludeText, isDrawElementIncludeText, isDrawElementsIncludeText, isGeometryIncludeText, isHitDrawElement, isHitEdgeOfShape, isHitElementInside, isHitElementText, isHitLine, isHitLineText, isHitPolyLine, isInsideOfShape, isMultipleTextGeometry, isMultipleTextShape, isRectangleHitDrawElement, isRectangleHitElementText, isSelfLoop, isSingleSelectElementByTable, isSingleSelectSwimlane, isSingleSelectTable, isSingleTextGeometry, isSingleTextShape, isSwimlaneWithHeader, isTextExceedingBounds, isUpdatedHandleIndex, isUseDefaultOrthogonalRoute, memorizeLatestShape, memorizeLatestText, rerenderGeometryActive, setSelectedCells, setTextManage, traverseDrawShapes, updateCellIds, updateCellIdsByRowOrColumn, updateColumns, updateRowOrColumnIds, updateRows, withDraw, withLineAutoComplete };
|
|
8434
8546
|
//# sourceMappingURL=plait-draw.mjs.map
|