@plait/common 0.53.0 → 0.55.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.
- package/constants/default.d.ts +2 -0
- package/core/group.component.d.ts +2 -3
- package/esm2022/constants/default.mjs +3 -1
- package/esm2022/core/group.component.mjs +5 -6
- package/esm2022/generators/active.generator.mjs +3 -2
- package/esm2022/generators/generator.mjs +13 -4
- package/esm2022/plugins/with-group.mjs +25 -22
- package/esm2022/public-api.mjs +2 -2
- package/esm2022/transforms/index.mjs +1 -1
- package/esm2022/types/index.mjs +3 -0
- package/esm2022/types/rotate.mjs +2 -0
- package/esm2022/utils/drawing/index.mjs +2 -1
- package/esm2022/utils/drawing/resize-handle.mjs +5 -3
- package/esm2022/utils/drawing/rotate-handle.mjs +22 -0
- package/esm2022/utils/elbow-line-route.mjs +21 -10
- package/esm2022/utils/index.mjs +2 -1
- package/esm2022/utils/resize.mjs +4 -4
- package/esm2022/utils/rotate.mjs +16 -0
- package/fesm2022/plait-common.mjs +103 -41
- package/fesm2022/plait-common.mjs.map +1 -1
- package/package.json +1 -1
- package/public-api.d.ts +1 -1
- package/types/index.d.ts +2 -0
- package/types/rotate.d.ts +6 -0
- package/utils/drawing/index.d.ts +1 -0
- package/utils/drawing/rotate-handle.d.ts +2 -0
- package/utils/elbow-line-route.d.ts +3 -3
- package/utils/index.d.ts +1 -0
- package/utils/resize.d.ts +1 -1
- package/utils/rotate.d.ts +6 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { setAngleForG, RectangleClient, drawCircle, PlaitBoard, createG, drawRectangle, createForeignObject, updateForeignObject, ResizeCursorClass, RESIZE_CURSORS, setDragging, rotatePoints, distanceBetweenPointAndPoint, Point, Direction, hotkeys, PlaitElement, PlaitContextService, getSelectedElements, Transforms, getHighestSelectedElements, getRectangleByElements,
|
|
1
|
+
import { PlaitGroupElement, getSelectionAngle, getElementsInGroup, setAngleForG, RectangleClient, drawCircle, PlaitBoard, RESIZE_HANDLE_CLASS_NAME, createG, setStrokeLinecap, drawRectangle, SELECTION_RECTANGLE_CLASS_NAME, createForeignObject, updateForeignObject, ResizeCursorClass, RESIZE_CURSORS, setDragging, rotatePoints, distanceBetweenPointAndPoint, Point, Direction, hotkeys, PlaitElement, PlaitContextService, createDebugGenerator, getSelectedElements, Transforms, getHighestSelectedElements, getRectangleByElements, MERGING, PlaitPointerType, isMainPointer, toViewBoxPoint, toHostPoint, preventTouchMove, PRESS_AND_MOVE_BUFFER, isDragging, throttleRAF, handleTouchTarget, ACTIVE_STROKE_WIDTH, getRectangleByGroup, PlaitPluginElementComponent, isSelectionMoving, isSelectedElementOrGroup, Selection, getHitElementsBySelection, createGroupRectangleG, getSelectedGroups, getHighestSelectedGroups, getSelectedIsolatedElements, idCreator, getSelectedIsolatedElementsCanAddToGroup, getGroupByElement } from '@plait/core';
|
|
2
2
|
import { isKeyHotkey } from 'is-hotkey';
|
|
3
3
|
import { PlaitMarkEditor, MarkTypes, AlignEditor } from '@plait/text';
|
|
4
4
|
import { Node, Transforms as Transforms$1, Editor } from 'slate';
|
|
@@ -11,6 +11,8 @@ const RESIZE_HANDLE_DIAMETER = 9;
|
|
|
11
11
|
const WithTextPluginKey = 'plait-text-plugin-key';
|
|
12
12
|
const DEFAULT_ROUTE_MARGIN = 30;
|
|
13
13
|
const TRANSPARENT = 'transparent';
|
|
14
|
+
const ROTATE_HANDLE_DISTANCE_TO_ELEMENT = 20;
|
|
15
|
+
const ROTATE_HANDLE_SIZE = 18;
|
|
14
16
|
|
|
15
17
|
var MediaKeys;
|
|
16
18
|
(function (MediaKeys) {
|
|
@@ -54,8 +56,17 @@ class Generator {
|
|
|
54
56
|
}
|
|
55
57
|
this.g = g;
|
|
56
58
|
const rect = this.board.getRectangle(element);
|
|
57
|
-
if (rect
|
|
58
|
-
|
|
59
|
+
if (rect) {
|
|
60
|
+
let angle;
|
|
61
|
+
if (PlaitGroupElement.isGroup(element)) {
|
|
62
|
+
angle = getSelectionAngle(getElementsInGroup(this.board, element, true));
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
angle = element.angle;
|
|
66
|
+
}
|
|
67
|
+
if (angle) {
|
|
68
|
+
setAngleForG(g, RectangleClient.getCenterPoint(rect), angle);
|
|
69
|
+
}
|
|
59
70
|
}
|
|
60
71
|
}
|
|
61
72
|
else {
|
|
@@ -85,7 +96,9 @@ function hasAfterDraw(value) {
|
|
|
85
96
|
|
|
86
97
|
const drawHandle = (board, centerPoint) => {
|
|
87
98
|
const options = { stroke: '#99999995', strokeWidth: 2, fill: '#FFF', fillStyle: 'solid' };
|
|
88
|
-
|
|
99
|
+
const handleG = drawCircle(PlaitBoard.getRoughSVG(board), centerPoint, RESIZE_HANDLE_DIAMETER, options);
|
|
100
|
+
handleG.classList.add(RESIZE_HANDLE_CLASS_NAME);
|
|
101
|
+
return handleG;
|
|
89
102
|
};
|
|
90
103
|
function drawFillPrimaryHandle(board, point) {
|
|
91
104
|
return drawCircle(PlaitBoard.getRoughSVG(board), point, RESIZE_HANDLE_DIAMETER, {
|
|
@@ -104,6 +117,26 @@ function drawPrimaryHandle(board, point) {
|
|
|
104
117
|
});
|
|
105
118
|
}
|
|
106
119
|
|
|
120
|
+
const rotateHandleRadius = 6;
|
|
121
|
+
const drawRotateHandle = (board, rectangle) => {
|
|
122
|
+
const options = { stroke: '#333', strokeWidth: 1, fillStyle: 'solid' };
|
|
123
|
+
const handleCenterPoint = [
|
|
124
|
+
rectangle.x - ROTATE_HANDLE_DISTANCE_TO_ELEMENT - ROTATE_HANDLE_SIZE / 2,
|
|
125
|
+
rectangle.y + rectangle.height + ROTATE_HANDLE_DISTANCE_TO_ELEMENT + ROTATE_HANDLE_SIZE / 2
|
|
126
|
+
];
|
|
127
|
+
const rs = PlaitBoard.getRoughSVG(board);
|
|
128
|
+
const handleG = createG();
|
|
129
|
+
const line = rs.path(`M ${handleCenterPoint[0] + rotateHandleRadius} ${handleCenterPoint[1]} A ${rotateHandleRadius} ${rotateHandleRadius}, 0, 1, 0, ${handleCenterPoint[0]} ${handleCenterPoint[1] + rotateHandleRadius}`, options);
|
|
130
|
+
const arrow = rs.polygon([
|
|
131
|
+
[handleCenterPoint[0], handleCenterPoint[1] + rotateHandleRadius - 2],
|
|
132
|
+
[handleCenterPoint[0], handleCenterPoint[1] + rotateHandleRadius + 2],
|
|
133
|
+
[handleCenterPoint[0] + 4.5, handleCenterPoint[1] + rotateHandleRadius]
|
|
134
|
+
], { ...options, fill: '#333' });
|
|
135
|
+
setStrokeLinecap(arrow, 'round');
|
|
136
|
+
handleG.append(line, arrow);
|
|
137
|
+
return handleG;
|
|
138
|
+
};
|
|
139
|
+
|
|
107
140
|
class ActiveGenerator extends Generator {
|
|
108
141
|
constructor(board, options) {
|
|
109
142
|
super(board, options);
|
|
@@ -129,6 +162,7 @@ class ActiveGenerator extends Generator {
|
|
|
129
162
|
strokeWidth: delta
|
|
130
163
|
});
|
|
131
164
|
activeG.append(strokeG);
|
|
165
|
+
strokeG.classList.add(SELECTION_RECTANGLE_CLASS_NAME);
|
|
132
166
|
strokeG.style.opacity = `${this.options.getStrokeOpacity()}`;
|
|
133
167
|
if (this.options.hasResizeHandle()) {
|
|
134
168
|
this.hasResizeHandle = true;
|
|
@@ -240,7 +274,7 @@ const getRotatedResizeCursorClassByAngle = (cursor, angle) => {
|
|
|
240
274
|
}
|
|
241
275
|
return cursor;
|
|
242
276
|
};
|
|
243
|
-
const getRectangleResizeHandleRefs = (rectangle, diameter
|
|
277
|
+
const getRectangleResizeHandleRefs = (rectangle, diameter) => {
|
|
244
278
|
const corners = RectangleClient.getCornerPoints(rectangle);
|
|
245
279
|
const refs = corners.map((corner, index) => {
|
|
246
280
|
return {
|
|
@@ -251,7 +285,7 @@ const getRectangleResizeHandleRefs = (rectangle, diameter, angle = 0) => {
|
|
|
251
285
|
height: diameter
|
|
252
286
|
},
|
|
253
287
|
handle: getResizeHandleByIndex(index),
|
|
254
|
-
cursorClass:
|
|
288
|
+
cursorClass: getResizeCursorClassByIndex(index)
|
|
255
289
|
};
|
|
256
290
|
});
|
|
257
291
|
const rectangles = getResizeSideRectangles(corners, diameter / 2);
|
|
@@ -259,7 +293,7 @@ const getRectangleResizeHandleRefs = (rectangle, diameter, angle = 0) => {
|
|
|
259
293
|
return {
|
|
260
294
|
rectangle,
|
|
261
295
|
handle: getResizeHandleByIndex(index + 4),
|
|
262
|
-
cursorClass:
|
|
296
|
+
cursorClass: getResizeCursorClassByIndex(index + 4)
|
|
263
297
|
};
|
|
264
298
|
}));
|
|
265
299
|
return refs;
|
|
@@ -917,7 +951,8 @@ class PointGraph {
|
|
|
917
951
|
}
|
|
918
952
|
}
|
|
919
953
|
|
|
920
|
-
const
|
|
954
|
+
const debugGenerator = createDebugGenerator('debug:plait:elbow-line-routing');
|
|
955
|
+
const generateElbowLineRoute = (options, board) => {
|
|
921
956
|
const { nextSourcePoint, nextTargetPoint } = options;
|
|
922
957
|
const points = getGraphPoints(options);
|
|
923
958
|
const graph = createGraph(points);
|
|
@@ -935,15 +970,18 @@ const generateElbowLineRoute = (options) => {
|
|
|
935
970
|
const isHitY = RectangleClient.isHitY(options.sourceOuterRectangle, options.targetOuterRectangle);
|
|
936
971
|
const centerX = isHitX ? undefined : RectangleClient.getGapCenter(options.sourceOuterRectangle, options.targetOuterRectangle, true);
|
|
937
972
|
const centerY = isHitY ? undefined : RectangleClient.getGapCenter(options.sourceOuterRectangle, options.targetOuterRectangle, false);
|
|
938
|
-
route = routeAdjust(route, { centerX, centerY, sourceRectangle: options.sourceRectangle, targetRectangle: options.targetRectangle });
|
|
973
|
+
route = routeAdjust(route, { centerX, centerY, sourceRectangle: options.sourceRectangle, targetRectangle: options.targetRectangle }, board);
|
|
939
974
|
return route;
|
|
940
975
|
};
|
|
941
|
-
const routeAdjust = (path, options) => {
|
|
976
|
+
const routeAdjust = (path, options, board) => {
|
|
942
977
|
const { sourceRectangle, targetRectangle, centerX, centerY } = options;
|
|
978
|
+
if (board) {
|
|
979
|
+
debugGenerator.clear();
|
|
980
|
+
}
|
|
943
981
|
if (centerX !== undefined) {
|
|
944
982
|
const optionsX = getAdjustOptions(path, centerX, true);
|
|
945
983
|
const resultX = optionsX.pointOfHit &&
|
|
946
|
-
adjust(path, { parallelPaths: optionsX.parallelPaths, pointOfHit: optionsX.pointOfHit, sourceRectangle, targetRectangle });
|
|
984
|
+
adjust(path, { parallelPaths: optionsX.parallelPaths, pointOfHit: optionsX.pointOfHit, sourceRectangle, targetRectangle }, board);
|
|
947
985
|
if (resultX) {
|
|
948
986
|
path = resultX;
|
|
949
987
|
}
|
|
@@ -951,14 +989,14 @@ const routeAdjust = (path, options) => {
|
|
|
951
989
|
if (centerY !== undefined) {
|
|
952
990
|
const optionsY = getAdjustOptions(path, centerY, false);
|
|
953
991
|
const resultY = optionsY.pointOfHit &&
|
|
954
|
-
adjust(path, { parallelPaths: optionsY.parallelPaths, pointOfHit: optionsY.pointOfHit, sourceRectangle, targetRectangle });
|
|
992
|
+
adjust(path, { parallelPaths: optionsY.parallelPaths, pointOfHit: optionsY.pointOfHit, sourceRectangle, targetRectangle }, board);
|
|
955
993
|
if (resultY) {
|
|
956
994
|
path = resultY;
|
|
957
995
|
}
|
|
958
996
|
}
|
|
959
997
|
return path;
|
|
960
998
|
};
|
|
961
|
-
const adjust = (route, options) => {
|
|
999
|
+
const adjust = (route, options, board) => {
|
|
962
1000
|
const { parallelPaths, pointOfHit, sourceRectangle, targetRectangle } = options;
|
|
963
1001
|
let result = null;
|
|
964
1002
|
parallelPaths.forEach(parallelPath => {
|
|
@@ -967,7 +1005,10 @@ const adjust = (route, options) => {
|
|
|
967
1005
|
// directly use getCornerPoints will bring the precision issue (eg: 263.6923375175286 - 57.130859375)
|
|
968
1006
|
const tempRect = RectangleClient.getRectangleByPoints(tempRectPoints);
|
|
969
1007
|
if (!RectangleClient.isHit(tempRect, sourceRectangle) && !RectangleClient.isHit(tempRect, targetRectangle)) {
|
|
970
|
-
const tempCorners = RectangleClient.
|
|
1008
|
+
const tempCorners = RectangleClient.getCornerPointsByPoints(tempRectPoints);
|
|
1009
|
+
if (board) {
|
|
1010
|
+
debugGenerator.drawRectangle(board, tempRect);
|
|
1011
|
+
}
|
|
971
1012
|
const indexRangeInPath = [];
|
|
972
1013
|
const indexRangeInCorner = [];
|
|
973
1014
|
route.forEach((point, index) => {
|
|
@@ -982,7 +1023,11 @@ const adjust = (route, options) => {
|
|
|
982
1023
|
const removeLength = Math.abs(indexRangeInPath[0] - indexRangeInPath[indexRangeInPath.length - 1]) + 1;
|
|
983
1024
|
newPath.splice(indexRangeInPath[0] + 1, removeLength - 2, missCorner);
|
|
984
1025
|
const turnCount = simplifyOrthogonalPoints([...route]).length - 1;
|
|
985
|
-
const
|
|
1026
|
+
const simplifyPoints = simplifyOrthogonalPoints([...newPath]);
|
|
1027
|
+
// if (board) {
|
|
1028
|
+
// debugGenerator.drawLine(board, simplifyPoints);
|
|
1029
|
+
// }
|
|
1030
|
+
const newTurnCount = simplifyPoints.length - 1;
|
|
986
1031
|
if (newTurnCount <= turnCount) {
|
|
987
1032
|
result = newPath;
|
|
988
1033
|
}
|
|
@@ -1168,6 +1213,21 @@ const getMemorizedLatest = (memorizedKey) => {
|
|
|
1168
1213
|
return map.get(memorizedKey);
|
|
1169
1214
|
};
|
|
1170
1215
|
|
|
1216
|
+
const IS_ROTATING = new WeakMap();
|
|
1217
|
+
const isRotating = (board) => {
|
|
1218
|
+
return !!IS_ROTATING.get(board);
|
|
1219
|
+
};
|
|
1220
|
+
const addRotating = (board, rotateRef) => {
|
|
1221
|
+
PlaitBoard.getBoardContainer(board).classList.add(`draw-elements-rotating`);
|
|
1222
|
+
IS_ROTATING.set(board, rotateRef);
|
|
1223
|
+
setDragging(board, true);
|
|
1224
|
+
};
|
|
1225
|
+
const removeRotating = (board) => {
|
|
1226
|
+
PlaitBoard.getBoardContainer(board).classList.remove(`draw-elements-rotating`);
|
|
1227
|
+
IS_ROTATING.delete(board);
|
|
1228
|
+
setDragging(board, false);
|
|
1229
|
+
};
|
|
1230
|
+
|
|
1171
1231
|
const setProperty = (board, properties, options) => {
|
|
1172
1232
|
const selectedElements = getSelectedElements(board);
|
|
1173
1233
|
selectedElements.forEach(element => {
|
|
@@ -1546,9 +1606,8 @@ class CommonPluginElement extends PlaitPluginElementComponent {
|
|
|
1546
1606
|
}
|
|
1547
1607
|
|
|
1548
1608
|
class GroupComponent extends CommonPluginElement {
|
|
1549
|
-
constructor(
|
|
1609
|
+
constructor(cdr) {
|
|
1550
1610
|
super(cdr);
|
|
1551
|
-
this.viewContainerRef = viewContainerRef;
|
|
1552
1611
|
this.cdr = cdr;
|
|
1553
1612
|
}
|
|
1554
1613
|
initializeGenerator() {
|
|
@@ -1572,9 +1631,9 @@ class GroupComponent extends CommonPluginElement {
|
|
|
1572
1631
|
const elementsInGroup = getElementsInGroup(this.board, value.element, false, true);
|
|
1573
1632
|
const isPartialSelectGroup = elementsInGroup.some(item => isSelectedElementOrGroup(this.board, item)) &&
|
|
1574
1633
|
!elementsInGroup.every(item => isSelectedElementOrGroup(this.board, item));
|
|
1575
|
-
this.groupGenerator.processDrawing(value.element, this.
|
|
1634
|
+
this.groupGenerator.processDrawing(value.element, this.getElementG(), isPartialSelectGroup);
|
|
1576
1635
|
}
|
|
1577
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: GroupComponent, deps: [{ token: i0.
|
|
1636
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: GroupComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1578
1637
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.4", type: GroupComponent, isStandalone: true, selector: "plait-group", usesInheritance: true, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
1579
1638
|
}
|
|
1580
1639
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: GroupComponent, decorators: [{
|
|
@@ -1585,7 +1644,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImpor
|
|
|
1585
1644
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1586
1645
|
standalone: true
|
|
1587
1646
|
}]
|
|
1588
|
-
}], ctorParameters: () => [{ type: i0.
|
|
1647
|
+
}], ctorParameters: () => [{ type: i0.ChangeDetectorRef }] });
|
|
1589
1648
|
|
|
1590
1649
|
function withGroup(board) {
|
|
1591
1650
|
let groupRectangleG;
|
|
@@ -1616,50 +1675,53 @@ function withGroup(board) {
|
|
|
1616
1675
|
groupRectangleG = null;
|
|
1617
1676
|
globalPointerUp(event);
|
|
1618
1677
|
};
|
|
1619
|
-
board.getRelatedFragment = (elements) => {
|
|
1620
|
-
const groups = getSelectedGroups(board);
|
|
1621
|
-
return getRelatedFragment([...elements, ...groups]);
|
|
1678
|
+
board.getRelatedFragment = (elements, originData) => {
|
|
1679
|
+
const groups = getSelectedGroups(board, originData);
|
|
1680
|
+
return getRelatedFragment([...elements, ...groups], originData);
|
|
1622
1681
|
};
|
|
1623
|
-
board.insertFragment = (
|
|
1624
|
-
|
|
1682
|
+
board.insertFragment = (clipboardData, targetPoint) => {
|
|
1683
|
+
let elements = [];
|
|
1625
1684
|
if (clipboardData?.elements?.length) {
|
|
1685
|
+
elements = new Array(clipboardData?.elements?.length);
|
|
1626
1686
|
const groups = getHighestSelectedGroups(board, clipboardData?.elements);
|
|
1627
1687
|
const selectedIsolatedElements = getSelectedIsolatedElements(board, clipboardData?.elements);
|
|
1628
1688
|
selectedIsolatedElements.forEach(item => {
|
|
1629
|
-
elements.
|
|
1689
|
+
const index = clipboardData.elements.map(element => element.id).indexOf(item.id);
|
|
1690
|
+
elements.splice(index, 1, !item.groupId ? item : updateGroupId(item, undefined));
|
|
1630
1691
|
});
|
|
1631
1692
|
if (groups.length) {
|
|
1632
1693
|
groups.forEach(item => {
|
|
1694
|
+
const index = clipboardData.elements.map(element => element.id).indexOf(item.id);
|
|
1633
1695
|
const newGroup = { ...updateGroupId(item, undefined), id: idCreator() };
|
|
1634
|
-
elements.
|
|
1635
|
-
|
|
1696
|
+
elements.splice(index, 1, newGroup);
|
|
1697
|
+
updateElementsGroupId(item, clipboardData.elements, newGroup.id, elements);
|
|
1636
1698
|
});
|
|
1637
1699
|
}
|
|
1638
1700
|
clipboardData.elements = elements;
|
|
1639
1701
|
}
|
|
1640
|
-
insertFragment(
|
|
1702
|
+
insertFragment(clipboardData, targetPoint);
|
|
1641
1703
|
const groupElements = elements?.filter(value => PlaitGroupElement.isGroup(value));
|
|
1642
1704
|
groupElements.forEach(element => {
|
|
1643
1705
|
Transforms.insertNode(board, element, [board.children.length]);
|
|
1644
1706
|
});
|
|
1645
1707
|
};
|
|
1646
1708
|
board.getDeletedFragment = (data) => {
|
|
1709
|
+
removeGroups = getRemoveGroups(board);
|
|
1647
1710
|
if (removeGroups && removeGroups.length) {
|
|
1648
1711
|
data.push(...removeGroups);
|
|
1649
1712
|
}
|
|
1650
1713
|
return getDeletedFragment(data);
|
|
1651
1714
|
};
|
|
1652
|
-
board.deleteFragment = (
|
|
1653
|
-
removeGroups = getRemoveGroups(board);
|
|
1715
|
+
board.deleteFragment = (elements) => {
|
|
1654
1716
|
if (removeGroups?.length) {
|
|
1655
1717
|
updateSiblingElementGroupId(board, removeGroups);
|
|
1656
1718
|
}
|
|
1657
|
-
deleteFragment(
|
|
1719
|
+
deleteFragment(elements);
|
|
1658
1720
|
removeGroups = null;
|
|
1659
1721
|
};
|
|
1660
1722
|
board.getRectangle = (element) => {
|
|
1661
1723
|
if (PlaitGroupElement.isGroup(element)) {
|
|
1662
|
-
return getRectangleByGroup(board, element);
|
|
1724
|
+
return getRectangleByGroup(board, element, true);
|
|
1663
1725
|
}
|
|
1664
1726
|
return getRectangle(element);
|
|
1665
1727
|
};
|
|
@@ -1667,12 +1729,12 @@ function withGroup(board) {
|
|
|
1667
1729
|
if (!PlaitBoard.isReadonly(board)) {
|
|
1668
1730
|
if (isKeyHotkey('mod+g', event)) {
|
|
1669
1731
|
event.preventDefault();
|
|
1670
|
-
|
|
1732
|
+
Transforms.addGroup(board);
|
|
1671
1733
|
return;
|
|
1672
1734
|
}
|
|
1673
1735
|
if (isKeyHotkey('mod+shift+g', event)) {
|
|
1674
1736
|
event.preventDefault();
|
|
1675
|
-
|
|
1737
|
+
Transforms.removeGroup(board);
|
|
1676
1738
|
return;
|
|
1677
1739
|
}
|
|
1678
1740
|
}
|
|
@@ -1686,18 +1748,18 @@ const updateGroupId = (element, groupId) => {
|
|
|
1686
1748
|
groupId: groupId
|
|
1687
1749
|
};
|
|
1688
1750
|
};
|
|
1689
|
-
const updateElementsGroupId = (group, clipboardDataElements, newGroupId) => {
|
|
1690
|
-
const elements = [];
|
|
1751
|
+
const updateElementsGroupId = (group, clipboardDataElements, newGroupId, elements) => {
|
|
1691
1752
|
const elementsInGroup = clipboardDataElements.filter(item => item.groupId === group.id);
|
|
1692
1753
|
if (elementsInGroup.length) {
|
|
1693
1754
|
elementsInGroup.forEach(item => {
|
|
1755
|
+
const index = clipboardDataElements.map(item => item.id).indexOf(item.id);
|
|
1694
1756
|
if (PlaitGroupElement.isGroup(item)) {
|
|
1695
1757
|
const newGroup = { ...updateGroupId(item, newGroupId), id: idCreator() };
|
|
1696
|
-
elements.
|
|
1697
|
-
|
|
1758
|
+
elements.splice(index, 1, newGroup);
|
|
1759
|
+
updateElementsGroupId(item, clipboardDataElements, newGroup.id, elements);
|
|
1698
1760
|
}
|
|
1699
1761
|
else {
|
|
1700
|
-
elements.
|
|
1762
|
+
elements.splice(index, 1, updateGroupId(item, newGroupId));
|
|
1701
1763
|
}
|
|
1702
1764
|
});
|
|
1703
1765
|
}
|
|
@@ -1870,5 +1932,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImpor
|
|
|
1870
1932
|
* Generated bundle index. Do not edit.
|
|
1871
1933
|
*/
|
|
1872
1934
|
|
|
1873
|
-
export { AStar, ActiveGenerator, AlignTransform, BASE, BoardCreationMode, CommonPluginElement, DEFAULT_ROUTE_MARGIN, Generator, IS_RESIZING, ImageBaseComponent, ImageGenerator, MediaKeys, PICTURE_ACCEPTED_UPLOAD_SIZE, PRIMARY_COLOR, PointGraph, PointNode, PriorityQueue, PropertyTransforms, RESIZE_HANDLE_DIAMETER, ResizeHandle, TRANSPARENT, TextTransforms, WithCommonPluginKey, WithTextPluginKey, acceptImageTypes, addElementOfFocusedImage, addResizing, alignBottom, alignHorizontalCenter, alignLeft, alignRight, alignTop, alignVerticalCenter, buildImage, calculatePolylineLength, createGraph, distributeHorizontal, distributeVertical, drawFillPrimaryHandle, drawHandle, drawPrimaryHandle, generateElbowLineRoute, getCreationMode, getCrossingPointsBetweenPointAndSegment, getDirectionBetweenPointAndPoint, getDirectionByPointOfRectangle, getDirectionByVector, getDirectionFactor, getDirectionFactorByDirectionComponent, getElementOfFocusedImage, getElementsText, getExtendPoint, getFirstTextEditor, getFirstTextManage, getGraphPoints, getIndexByResizeHandle, getMemorizedLatest, getNextPoint, getOppositeDirection, getPointByVectorComponent, getPointByVectorDirectionComponent, getPointOnPolyline, getPoints, getRatioByPoint, getRectangleResizeHandleRefs, getResizeHandleByIndex, getResizeHandlePointByIndex, getRotatedResizeCursorClassByAngle, getSourceAndTargetOuterRectangle, getSymmetricHandleIndex, getTextEditors, getTextManages, getTextMarksByElement, getUnitVectorByPointAndPoint, hasAfterDraw, isCornerHandle, isDelete, isDndMode, isDrawingMode, isEdgeHandle, isEnterHotkey, isExpandHotkey, isPointOnSegment, isResizing, isResizingByCondition, isSourceAndTargetIntersect, isSpaceHotkey, isTabHotkey, isVirtualKey, memorizeLatest, normalizeShapePoints, reduceRouteMargin, removeDuplicatePoints, removeElementOfFocusedImage, removeResizing, resetPointsAfterResize, rotateVector, rotateVectorAnti90, routeAdjust, selectImage, setCreationMode, setProperty, simplifyOrthogonalPoints, withGroup, withResize };
|
|
1935
|
+
export { AStar, ActiveGenerator, AlignTransform, BASE, BoardCreationMode, CommonPluginElement, DEFAULT_ROUTE_MARGIN, Generator, IS_RESIZING, IS_ROTATING, ImageBaseComponent, ImageGenerator, MediaKeys, PICTURE_ACCEPTED_UPLOAD_SIZE, PRIMARY_COLOR, PointGraph, PointNode, PriorityQueue, PropertyTransforms, RESIZE_HANDLE_DIAMETER, ROTATE_HANDLE_DISTANCE_TO_ELEMENT, ROTATE_HANDLE_SIZE, ResizeHandle, TRANSPARENT, TextTransforms, WithCommonPluginKey, WithTextPluginKey, acceptImageTypes, addElementOfFocusedImage, addResizing, addRotating, alignBottom, alignHorizontalCenter, alignLeft, alignRight, alignTop, alignVerticalCenter, buildImage, calculatePolylineLength, createGraph, distributeHorizontal, distributeVertical, drawFillPrimaryHandle, drawHandle, drawPrimaryHandle, drawRotateHandle, generateElbowLineRoute, getCreationMode, getCrossingPointsBetweenPointAndSegment, getDirectionBetweenPointAndPoint, getDirectionByPointOfRectangle, getDirectionByVector, getDirectionFactor, getDirectionFactorByDirectionComponent, getElementOfFocusedImage, getElementsText, getExtendPoint, getFirstTextEditor, getFirstTextManage, getGraphPoints, getIndexByResizeHandle, getMemorizedLatest, getNextPoint, getOppositeDirection, getPointByVectorComponent, getPointByVectorDirectionComponent, getPointOnPolyline, getPoints, getRatioByPoint, getRectangleResizeHandleRefs, getResizeHandleByIndex, getResizeHandlePointByIndex, getRotatedResizeCursorClassByAngle, getSourceAndTargetOuterRectangle, getSymmetricHandleIndex, getTextEditors, getTextManages, getTextMarksByElement, getUnitVectorByPointAndPoint, hasAfterDraw, isCornerHandle, isDelete, isDndMode, isDrawingMode, isEdgeHandle, isEnterHotkey, isExpandHotkey, isPointOnSegment, isResizing, isResizingByCondition, isRotating, isSourceAndTargetIntersect, isSpaceHotkey, isTabHotkey, isVirtualKey, memorizeLatest, normalizeShapePoints, reduceRouteMargin, removeDuplicatePoints, removeElementOfFocusedImage, removeResizing, removeRotating, resetPointsAfterResize, rotateVector, rotateVectorAnti90, routeAdjust, selectImage, setCreationMode, setProperty, simplifyOrthogonalPoints, withGroup, withResize };
|
|
1874
1936
|
//# sourceMappingURL=plait-common.mjs.map
|