@leafer-in/editor 1.0.0-rc.22 → 1.0.0-rc.24
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/dist/editor.cjs +1803 -0
- package/dist/editor.esm.js +186 -114
- package/dist/editor.esm.min.js +1 -1
- package/dist/editor.js +190 -112
- package/dist/editor.min.cjs +1 -0
- package/dist/editor.min.js +1 -1
- package/package.json +12 -6
- package/src/Editor.ts +4 -8
- package/src/config.ts +1 -1
- package/src/display/EditBox.ts +3 -2
- package/src/display/Stroker.ts +12 -15
- package/src/helper/EditDataHelper.ts +29 -25
- package/src/index.ts +2 -6
- package/src/tool/EditTool.ts +3 -3
- package/src/tool/LineEditTool.ts +88 -36
- package/types/index.d.ts +6 -2
package/dist/editor.js
CHANGED
|
@@ -81,6 +81,39 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
81
81
|
};
|
|
82
82
|
const { scalePoints } = PathScaler;
|
|
83
83
|
|
|
84
|
+
const matrix$1 = draw.MatrixHelper.get();
|
|
85
|
+
function scaleResize(leaf, scaleX, scaleY) {
|
|
86
|
+
if (leaf.pathInputed) {
|
|
87
|
+
scaleResizePath(leaf, scaleX, scaleY);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
leaf.width *= scaleX;
|
|
91
|
+
leaf.height *= scaleY;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function scaleResizeFont(leaf, scaleX, scaleY) {
|
|
95
|
+
if (scaleX !== 1)
|
|
96
|
+
leaf.fontSize *= scaleX;
|
|
97
|
+
else if (scaleY !== 1)
|
|
98
|
+
leaf.fontSize *= scaleY;
|
|
99
|
+
}
|
|
100
|
+
function scaleResizePath(leaf, scaleX, scaleY) {
|
|
101
|
+
PathScaler.scale(leaf.__.path, scaleX, scaleY);
|
|
102
|
+
leaf.path = leaf.__.path;
|
|
103
|
+
}
|
|
104
|
+
function scaleResizePoints(leaf, scaleX, scaleY) {
|
|
105
|
+
PathScaler.scalePoints(leaf.__.points, scaleX, scaleY);
|
|
106
|
+
leaf.points = leaf.__.points;
|
|
107
|
+
}
|
|
108
|
+
function scaleResizeGroup(group, scaleX, scaleY) {
|
|
109
|
+
const { children } = group;
|
|
110
|
+
for (let i = 0; i < children.length; i++) {
|
|
111
|
+
matrix$1.a = scaleX;
|
|
112
|
+
matrix$1.d = scaleY;
|
|
113
|
+
children[i].transform(matrix$1, true);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
84
117
|
draw.Leaf.prototype.scaleResize = function (scaleX, scaleY = scaleX, noResize) {
|
|
85
118
|
const data = this;
|
|
86
119
|
if (noResize) {
|
|
@@ -95,23 +128,26 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
95
128
|
this.__scaleResize(scaleX, scaleY);
|
|
96
129
|
}
|
|
97
130
|
};
|
|
98
|
-
function scaleResize(leaf, scaleX, scaleY) {
|
|
99
|
-
if (scaleX !== 1)
|
|
100
|
-
leaf.width *= scaleX;
|
|
101
|
-
if (scaleY !== 1)
|
|
102
|
-
leaf.height *= scaleY;
|
|
103
|
-
}
|
|
104
131
|
draw.Leaf.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
105
132
|
scaleResize(this, scaleX, scaleY);
|
|
106
133
|
};
|
|
134
|
+
draw.Text.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
135
|
+
if (this.editConfig && this.editConfig.editSize === 'font-size') {
|
|
136
|
+
scaleResizeFont(this, scaleX, scaleY);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
scaleResize(this, scaleX, scaleY);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
107
142
|
draw.Path.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
108
|
-
|
|
109
|
-
this.path = this.__.path;
|
|
143
|
+
scaleResizePath(this, scaleX, scaleY);
|
|
110
144
|
};
|
|
111
145
|
draw.Line.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
112
|
-
if (this.
|
|
113
|
-
|
|
114
|
-
|
|
146
|
+
if (this.pathInputed) {
|
|
147
|
+
scaleResizePath(this, scaleX, scaleY);
|
|
148
|
+
}
|
|
149
|
+
else if (this.points) {
|
|
150
|
+
scaleResizePoints(this, scaleX, scaleY);
|
|
115
151
|
}
|
|
116
152
|
else {
|
|
117
153
|
const point = this.toPoint;
|
|
@@ -121,29 +157,22 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
121
157
|
}
|
|
122
158
|
};
|
|
123
159
|
draw.Polygon.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
124
|
-
if (this.
|
|
125
|
-
|
|
126
|
-
|
|
160
|
+
if (this.pathInputed) {
|
|
161
|
+
scaleResizePath(this, scaleX, scaleY);
|
|
162
|
+
}
|
|
163
|
+
else if (this.points) {
|
|
164
|
+
scaleResizePoints(this, scaleX, scaleY);
|
|
127
165
|
}
|
|
128
166
|
else {
|
|
129
167
|
scaleResize(this, scaleX, scaleY);
|
|
130
168
|
}
|
|
131
169
|
};
|
|
132
|
-
const matrix$1 = draw.MatrixHelper.get();
|
|
133
|
-
function groupScaleResize(group, scaleX, scaleY) {
|
|
134
|
-
const { children } = group;
|
|
135
|
-
for (let i = 0; i < children.length; i++) {
|
|
136
|
-
matrix$1.a = scaleX;
|
|
137
|
-
matrix$1.d = scaleY;
|
|
138
|
-
children[i].transform(matrix$1, true);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
170
|
draw.Group.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
142
|
-
|
|
171
|
+
scaleResizeGroup(this, scaleX, scaleY);
|
|
143
172
|
};
|
|
144
173
|
draw.Box.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
145
174
|
if (this.__.__autoSize && this.children.length) {
|
|
146
|
-
|
|
175
|
+
scaleResizeGroup(this, scaleX, scaleY);
|
|
147
176
|
}
|
|
148
177
|
else {
|
|
149
178
|
scaleResize(this, scaleX, scaleY);
|
|
@@ -238,7 +267,7 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
238
267
|
|
|
239
268
|
const matrix = draw.MatrixHelper.get();
|
|
240
269
|
const { abs } = Math;
|
|
241
|
-
const { copy, scale } = draw.MatrixHelper;
|
|
270
|
+
const { copy: copy$1, scale } = draw.MatrixHelper;
|
|
242
271
|
class Stroker extends draw.UI {
|
|
243
272
|
constructor() {
|
|
244
273
|
super();
|
|
@@ -259,21 +288,17 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
259
288
|
for (let i = 0; i < list.length; i++) {
|
|
260
289
|
leaf = list[i];
|
|
261
290
|
if (bounds && bounds.hit(leaf.__world, options.matrix)) {
|
|
262
|
-
|
|
263
|
-
if (
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
const { x, y, width, height } = leaf.__layout.boxBounds;
|
|
272
|
-
canvas.rect(x * aScaleX, y * aScaleY, width * aScaleX, height * aScaleY);
|
|
273
|
-
drewPath = true;
|
|
274
|
-
}
|
|
291
|
+
const aScaleX = abs(leaf.__world.scaleX), aScaleY = abs(leaf.__world.scaleY);
|
|
292
|
+
if (aScaleX !== aScaleY) {
|
|
293
|
+
copy$1(matrix, leaf.__world);
|
|
294
|
+
scale(matrix, 1 / aScaleX, 1 / aScaleY);
|
|
295
|
+
canvas.setWorld(matrix, options.matrix);
|
|
296
|
+
canvas.beginPath();
|
|
297
|
+
this.__.strokeWidth = strokeWidth;
|
|
298
|
+
const { x, y, width, height } = leaf.__layout.boxBounds;
|
|
299
|
+
canvas.rect(x * aScaleX, y * aScaleY, width * aScaleX, height * aScaleY);
|
|
275
300
|
}
|
|
276
|
-
|
|
301
|
+
else {
|
|
277
302
|
canvas.setWorld(leaf.__world, options.matrix);
|
|
278
303
|
canvas.beginPath();
|
|
279
304
|
if (leaf.__.__useArrow) {
|
|
@@ -551,7 +576,7 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
551
576
|
const { toPoint } = draw.AroundHelper;
|
|
552
577
|
const EditDataHelper = {
|
|
553
578
|
getScaleData(bounds, direction, pointMove, lockRatio, around) {
|
|
554
|
-
let origin, scaleX = 1, scaleY = 1;
|
|
579
|
+
let align, origin = {}, scaleX = 1, scaleY = 1;
|
|
555
580
|
const { width, height } = bounds;
|
|
556
581
|
if (around) {
|
|
557
582
|
pointMove.x *= 2;
|
|
@@ -568,97 +593,100 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
568
593
|
switch (direction) {
|
|
569
594
|
case top:
|
|
570
595
|
scaleY = topScale;
|
|
571
|
-
|
|
596
|
+
align = 'bottom';
|
|
572
597
|
break;
|
|
573
598
|
case right$1:
|
|
574
599
|
scaleX = rightScale;
|
|
575
|
-
|
|
600
|
+
align = 'left';
|
|
576
601
|
break;
|
|
577
602
|
case bottom:
|
|
578
603
|
scaleY = bottomScale;
|
|
579
|
-
|
|
604
|
+
align = 'top';
|
|
580
605
|
break;
|
|
581
606
|
case left$1:
|
|
582
607
|
scaleX = leftScale;
|
|
583
|
-
|
|
608
|
+
align = 'right';
|
|
584
609
|
break;
|
|
585
610
|
case topLeft:
|
|
586
611
|
scaleY = topScale;
|
|
587
612
|
scaleX = leftScale;
|
|
588
|
-
|
|
613
|
+
align = 'bottom-right';
|
|
589
614
|
break;
|
|
590
615
|
case topRight:
|
|
591
616
|
scaleY = topScale;
|
|
592
617
|
scaleX = rightScale;
|
|
593
|
-
|
|
618
|
+
align = 'bottom-left';
|
|
594
619
|
break;
|
|
595
620
|
case bottomRight:
|
|
596
621
|
scaleY = bottomScale;
|
|
597
622
|
scaleX = rightScale;
|
|
598
|
-
|
|
623
|
+
align = 'top-left';
|
|
599
624
|
break;
|
|
600
625
|
case bottomLeft:
|
|
601
626
|
scaleY = bottomScale;
|
|
602
627
|
scaleX = leftScale;
|
|
603
|
-
|
|
628
|
+
align = 'top-right';
|
|
604
629
|
}
|
|
605
630
|
if (lockRatio) {
|
|
606
631
|
const unlockSide = lockRatio === 'corner' && direction % 2;
|
|
607
|
-
if (!unlockSide)
|
|
608
|
-
|
|
632
|
+
if (!unlockSide) {
|
|
633
|
+
const scale = Math.sqrt(Math.abs(scaleX * scaleY));
|
|
634
|
+
scaleX = scaleX < 0 ? -scale : scale;
|
|
635
|
+
scaleY = scaleY < 0 ? -scale : scale;
|
|
636
|
+
}
|
|
609
637
|
}
|
|
610
|
-
toPoint(around ||
|
|
638
|
+
toPoint(around || align, bounds, origin);
|
|
611
639
|
return { origin, scaleX, scaleY, direction, lockRatio, around };
|
|
612
640
|
},
|
|
613
641
|
getRotateData(bounds, direction, current, last, around) {
|
|
614
|
-
let origin;
|
|
642
|
+
let align, origin = {};
|
|
615
643
|
switch (direction) {
|
|
616
644
|
case topLeft:
|
|
617
|
-
|
|
645
|
+
align = 'bottom-right';
|
|
618
646
|
break;
|
|
619
647
|
case topRight:
|
|
620
|
-
|
|
648
|
+
align = 'bottom-left';
|
|
621
649
|
break;
|
|
622
650
|
case bottomRight:
|
|
623
|
-
|
|
651
|
+
align = 'top-left';
|
|
624
652
|
break;
|
|
625
653
|
case bottomLeft:
|
|
626
|
-
|
|
654
|
+
align = 'top-right';
|
|
627
655
|
break;
|
|
628
656
|
default:
|
|
629
|
-
|
|
657
|
+
align = 'center';
|
|
630
658
|
}
|
|
631
|
-
toPoint(around ||
|
|
659
|
+
toPoint(around || align, bounds, origin);
|
|
632
660
|
return { origin, rotation: draw.PointHelper.getRotation(last, origin, current) };
|
|
633
661
|
},
|
|
634
662
|
getSkewData(bounds, direction, move, around) {
|
|
635
|
-
let origin, skewX = 0, skewY = 0;
|
|
663
|
+
let align, origin = {}, skewX = 0, skewY = 0;
|
|
636
664
|
let last;
|
|
637
665
|
switch (direction) {
|
|
638
666
|
case top:
|
|
639
667
|
last = { x: 0.5, y: 0 };
|
|
640
|
-
|
|
668
|
+
align = 'bottom';
|
|
641
669
|
skewX = 1;
|
|
642
670
|
break;
|
|
643
671
|
case bottom:
|
|
644
672
|
last = { x: 0.5, y: 1 };
|
|
645
|
-
|
|
673
|
+
align = 'top';
|
|
646
674
|
skewX = 1;
|
|
647
675
|
break;
|
|
648
676
|
case left$1:
|
|
649
677
|
last = { x: 0, y: 0.5 };
|
|
650
|
-
|
|
678
|
+
align = 'right';
|
|
651
679
|
skewY = 1;
|
|
652
680
|
break;
|
|
653
681
|
case right$1:
|
|
654
682
|
last = { x: 1, y: 0.5 };
|
|
655
|
-
|
|
683
|
+
align = 'left';
|
|
656
684
|
skewY = 1;
|
|
657
685
|
}
|
|
658
686
|
const { x, y, width, height } = bounds;
|
|
659
687
|
last.x = x + last.x * width;
|
|
660
688
|
last.y = y + last.y * height;
|
|
661
|
-
toPoint(around ||
|
|
689
|
+
toPoint(around || align, bounds, origin);
|
|
662
690
|
const rotation = draw.PointHelper.getRotation(last, origin, { x: last.x + (skewX ? move.x : 0), y: last.y + (skewY ? move.y : 0) });
|
|
663
691
|
skewX ? skewX = -rotation : skewY = rotation;
|
|
664
692
|
return { origin, skewX, skewY };
|
|
@@ -781,7 +809,7 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
781
809
|
create() {
|
|
782
810
|
let rotatePoint, resizeLine, resizePoint;
|
|
783
811
|
const { view, resizePoints, rotatePoints, resizeLines, rect, circle, buttons } = this;
|
|
784
|
-
const arounds = [
|
|
812
|
+
const arounds = ['bottom-right', 'bottom', 'bottom-left', 'left', 'top-left', 'top', 'top-right', 'right'];
|
|
785
813
|
for (let i = 0; i < 8; i++) {
|
|
786
814
|
rotatePoint = new EditPoint({ name: 'rotate-point', around: arounds[i], width: 15, height: 15, hitFill: "all" });
|
|
787
815
|
rotatePoints.push(rotatePoint);
|
|
@@ -855,6 +883,8 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
855
883
|
}
|
|
856
884
|
}
|
|
857
885
|
circle.visible = showPoints && rotateable && !!mergeConfig.rotatePoint;
|
|
886
|
+
if (rect.path)
|
|
887
|
+
rect.path = null;
|
|
858
888
|
rect.set(Object.assign(Object.assign({}, bounds), { visible: true }));
|
|
859
889
|
const buttonVisible = showPoints && (circle.visible || this.buttons.children.length > 1);
|
|
860
890
|
this.buttons.visible = buttonVisible;
|
|
@@ -1065,7 +1095,7 @@ ${filterStyle}
|
|
|
1065
1095
|
`;
|
|
1066
1096
|
|
|
1067
1097
|
const config = {
|
|
1068
|
-
editSize: '
|
|
1098
|
+
editSize: 'size',
|
|
1069
1099
|
keyEvent: true,
|
|
1070
1100
|
stroke: '#836DFF',
|
|
1071
1101
|
strokeWidth: 2,
|
|
@@ -1276,18 +1306,12 @@ ${filterStyle}
|
|
|
1276
1306
|
this.editTool.load();
|
|
1277
1307
|
}
|
|
1278
1308
|
}
|
|
1279
|
-
getEditSize(
|
|
1280
|
-
|
|
1281
|
-
return editSize === 'auto' ? ui.editSize : editSize;
|
|
1309
|
+
getEditSize(_ui) {
|
|
1310
|
+
return this.mergeConfig.editSize;
|
|
1282
1311
|
}
|
|
1283
1312
|
onMove(e) {
|
|
1284
1313
|
const total = { x: e.totalX, y: e.totalY };
|
|
1285
|
-
|
|
1286
|
-
if (lockMove === 'x')
|
|
1287
|
-
total.y = 0;
|
|
1288
|
-
else if (lockMove === 'y')
|
|
1289
|
-
total.x = 0;
|
|
1290
|
-
else if (e.shiftKey) {
|
|
1314
|
+
if (e.shiftKey) {
|
|
1291
1315
|
if (Math.abs(total.x) > Math.abs(total.y))
|
|
1292
1316
|
total.y = 0;
|
|
1293
1317
|
else
|
|
@@ -1342,7 +1366,7 @@ ${filterStyle}
|
|
|
1342
1366
|
this.skewOf(origin, skewX, skewY);
|
|
1343
1367
|
}
|
|
1344
1368
|
move(x, y = 0) {
|
|
1345
|
-
if (!this.mergeConfig.moveable)
|
|
1369
|
+
if (!this.mergeConfig.moveable || this.element.locked)
|
|
1346
1370
|
return;
|
|
1347
1371
|
const { element } = this;
|
|
1348
1372
|
const world = element.getWorldPointByLocal(typeof x === 'object' ? Object.assign({}, x) : { x, y }, null, true);
|
|
@@ -1561,7 +1585,7 @@ ${filterStyle}
|
|
|
1561
1585
|
const { app, list } = editor;
|
|
1562
1586
|
app.lockLayout();
|
|
1563
1587
|
list.forEach(target => {
|
|
1564
|
-
const resize = editor.getEditSize(target)
|
|
1588
|
+
const resize = editor.getEditSize(target) !== 'scale';
|
|
1565
1589
|
if (transform) {
|
|
1566
1590
|
target.transformWorld(transform, resize);
|
|
1567
1591
|
}
|
|
@@ -1576,7 +1600,7 @@ ${filterStyle}
|
|
|
1576
1600
|
const { app, list } = editor;
|
|
1577
1601
|
app.lockLayout();
|
|
1578
1602
|
list.forEach(target => {
|
|
1579
|
-
const resize = editor.getEditSize(target)
|
|
1603
|
+
const resize = editor.getEditSize(target) !== 'scale';
|
|
1580
1604
|
if (transform) {
|
|
1581
1605
|
target.transformWorld(transform, resize);
|
|
1582
1606
|
}
|
|
@@ -1591,7 +1615,7 @@ ${filterStyle}
|
|
|
1591
1615
|
const { app, list } = editor;
|
|
1592
1616
|
app.lockLayout();
|
|
1593
1617
|
list.forEach(target => {
|
|
1594
|
-
const resize = editor.getEditSize(target)
|
|
1618
|
+
const resize = editor.getEditSize(target) !== 'scale';
|
|
1595
1619
|
if (transform) {
|
|
1596
1620
|
target.transformWorld(transform, resize);
|
|
1597
1621
|
}
|
|
@@ -1625,6 +1649,7 @@ ${filterStyle}
|
|
|
1625
1649
|
], exports.EditTool);
|
|
1626
1650
|
|
|
1627
1651
|
const { left, right } = draw.Direction9;
|
|
1652
|
+
const { move, copy } = draw.PointHelper;
|
|
1628
1653
|
exports.LineEditTool = class LineEditTool extends exports.EditTool {
|
|
1629
1654
|
constructor() {
|
|
1630
1655
|
super(...arguments);
|
|
@@ -1633,50 +1658,100 @@ ${filterStyle}
|
|
|
1633
1658
|
get tag() { return 'LineEditTool'; }
|
|
1634
1659
|
onScaleWithDrag(e) {
|
|
1635
1660
|
const { drag, direction, lockRatio, around } = e;
|
|
1636
|
-
const
|
|
1637
|
-
const
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1661
|
+
const line = e.target;
|
|
1662
|
+
const isDragFrom = direction === left;
|
|
1663
|
+
if (line.pathInputed) {
|
|
1664
|
+
const { path } = line.__;
|
|
1665
|
+
const { from, to } = this.getFromToByPath(path);
|
|
1666
|
+
this.dragPoint(from, to, isDragFrom, around, this.getInnerMove(line, drag, lockRatio));
|
|
1667
|
+
path[1] = from.x, path[2] = from.y;
|
|
1668
|
+
path[4] = to.x, path[5] = to.y;
|
|
1669
|
+
line.path = path;
|
|
1670
|
+
}
|
|
1671
|
+
else if (line.points) {
|
|
1672
|
+
const { points } = line;
|
|
1673
|
+
const { from, to } = this.getFromToByPoints(points);
|
|
1674
|
+
this.dragPoint(from, to, isDragFrom, around, this.getInnerMove(line, drag, lockRatio));
|
|
1675
|
+
points[0] = from.x, points[1] = from.y;
|
|
1676
|
+
points[2] = to.x, points[3] = to.y;
|
|
1677
|
+
line.points = points;
|
|
1678
|
+
}
|
|
1679
|
+
else {
|
|
1680
|
+
const from = draw.getPointData();
|
|
1681
|
+
const { toPoint } = line;
|
|
1682
|
+
line.rotation = 0;
|
|
1683
|
+
this.dragPoint(from, toPoint, isDragFrom, around, this.getInnerMove(line, drag, lockRatio));
|
|
1684
|
+
line.getLocalPointByInner(from, null, null, true);
|
|
1685
|
+
line.getLocalPointByInner(toPoint, null, null, true);
|
|
1686
|
+
line.x = from.x;
|
|
1687
|
+
line.y = from.y;
|
|
1688
|
+
line.getInnerPointByLocal(toPoint, null, null, true);
|
|
1689
|
+
line.toPoint = toPoint;
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
getInnerMove(ui, event, lockRatio) {
|
|
1693
|
+
const movePoint = event.getInnerMove(ui);
|
|
1641
1694
|
if (lockRatio) {
|
|
1642
|
-
if (Math.abs(x) > Math.abs(y)) {
|
|
1643
|
-
y = 0;
|
|
1695
|
+
if (Math.abs(movePoint.x) > Math.abs(movePoint.y)) {
|
|
1696
|
+
movePoint.y = 0;
|
|
1644
1697
|
}
|
|
1645
1698
|
else {
|
|
1646
|
-
x = 0;
|
|
1699
|
+
movePoint.x = 0;
|
|
1647
1700
|
}
|
|
1648
1701
|
}
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1702
|
+
return movePoint;
|
|
1703
|
+
}
|
|
1704
|
+
getFromToByPath(path) {
|
|
1705
|
+
return {
|
|
1706
|
+
from: { x: path[1], y: path[2] },
|
|
1707
|
+
to: { x: path[4], y: path[5] }
|
|
1708
|
+
};
|
|
1709
|
+
}
|
|
1710
|
+
getFromToByPoints(points) {
|
|
1711
|
+
return {
|
|
1712
|
+
from: { x: points[0], y: points[1] },
|
|
1713
|
+
to: { x: points[2], y: points[3] }
|
|
1714
|
+
};
|
|
1715
|
+
}
|
|
1716
|
+
dragPoint(fromPoint, toPoint, isDragFrom, around, movePoint) {
|
|
1717
|
+
const { x, y } = movePoint;
|
|
1718
|
+
if (isDragFrom) {
|
|
1719
|
+
move(fromPoint, x, y);
|
|
1720
|
+
if (around)
|
|
1721
|
+
move(toPoint, -x, -y);
|
|
1656
1722
|
}
|
|
1657
1723
|
else {
|
|
1658
|
-
if (around)
|
|
1659
|
-
fromPoint
|
|
1660
|
-
|
|
1661
|
-
}
|
|
1662
|
-
toPoint.x += x;
|
|
1663
|
-
toPoint.y += y;
|
|
1724
|
+
if (around)
|
|
1725
|
+
move(fromPoint, -x, -y);
|
|
1726
|
+
move(toPoint, x, y);
|
|
1664
1727
|
}
|
|
1665
|
-
target.getLocalPointByInner(fromPoint, null, null, true);
|
|
1666
|
-
target.getLocalPointByInner(toPoint, null, null, true);
|
|
1667
|
-
target.x = fromPoint.x;
|
|
1668
|
-
target.y = fromPoint.y;
|
|
1669
|
-
target.getInnerPointByLocal(toPoint, null, null, true);
|
|
1670
|
-
target.toPoint = toPoint;
|
|
1671
1728
|
}
|
|
1672
1729
|
onSkew(_e) {
|
|
1673
1730
|
}
|
|
1674
1731
|
onUpdate() {
|
|
1675
|
-
const { rotatePoints, resizeLines, resizePoints } =
|
|
1732
|
+
const { editBox } = this, { rotatePoints, resizeLines, resizePoints, rect } = editBox;
|
|
1733
|
+
const line = this.editor.element;
|
|
1734
|
+
let fromTo, leftOrRight;
|
|
1735
|
+
if (line.pathInputed)
|
|
1736
|
+
fromTo = this.getFromToByPath(line.__.path);
|
|
1737
|
+
else if (line.points)
|
|
1738
|
+
fromTo = this.getFromToByPoints(line.__.points);
|
|
1739
|
+
if (fromTo) {
|
|
1740
|
+
const { from, to } = fromTo;
|
|
1741
|
+
line.innerToWorld(from, from, false, editBox);
|
|
1742
|
+
line.innerToWorld(to, to, false, editBox);
|
|
1743
|
+
rect.pen.clearPath().moveTo(from.x, from.y).lineTo(to.x, to.y);
|
|
1744
|
+
copy(resizePoints[7], from);
|
|
1745
|
+
copy(rotatePoints[7], from);
|
|
1746
|
+
copy(resizePoints[3], to);
|
|
1747
|
+
copy(rotatePoints[3], to);
|
|
1748
|
+
}
|
|
1676
1749
|
for (let i = 0; i < 8; i++) {
|
|
1677
1750
|
if (i < 4)
|
|
1678
1751
|
resizeLines[i].visible = false;
|
|
1679
|
-
|
|
1752
|
+
leftOrRight = i === left || i === right;
|
|
1753
|
+
resizePoints[i].visible = leftOrRight;
|
|
1754
|
+
rotatePoints[i].visible = fromTo ? false : leftOrRight;
|
|
1680
1755
|
}
|
|
1681
1756
|
}
|
|
1682
1757
|
};
|
|
@@ -1700,9 +1775,6 @@ ${filterStyle}
|
|
|
1700
1775
|
get() { return typeof editorName === 'string' ? editorName : editorName(this); }
|
|
1701
1776
|
});
|
|
1702
1777
|
};
|
|
1703
|
-
draw.Line.setEditOuter(function (line) {
|
|
1704
|
-
return (line.points || line.pathInputed) ? 'EditTool' : 'LineEditTool';
|
|
1705
|
-
});
|
|
1706
1778
|
|
|
1707
1779
|
exports.EditBox = EditBox;
|
|
1708
1780
|
exports.EditDataHelper = EditDataHelper;
|
|
@@ -1718,10 +1790,16 @@ ${filterStyle}
|
|
|
1718
1790
|
exports.EditorScaleEvent = EditorScaleEvent;
|
|
1719
1791
|
exports.EditorSkewEvent = EditorSkewEvent;
|
|
1720
1792
|
exports.InnerEditor = InnerEditor;
|
|
1793
|
+
exports.PathScaler = PathScaler;
|
|
1721
1794
|
exports.SelectArea = SelectArea;
|
|
1722
1795
|
exports.Stroker = Stroker;
|
|
1723
1796
|
exports.registerEditTool = registerEditTool;
|
|
1724
1797
|
exports.registerInnerEditor = registerInnerEditor;
|
|
1798
|
+
exports.scaleResize = scaleResize;
|
|
1799
|
+
exports.scaleResizeFont = scaleResizeFont;
|
|
1800
|
+
exports.scaleResizeGroup = scaleResizeGroup;
|
|
1801
|
+
exports.scaleResizePath = scaleResizePath;
|
|
1802
|
+
exports.scaleResizePoints = scaleResizePoints;
|
|
1725
1803
|
|
|
1726
1804
|
return exports;
|
|
1727
1805
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var t=require("@leafer-ui/draw"),e=require("@leafer-ui/core");const{M:i,L:o,C:s,Q:n,Z:r,N:a,D:l,X:h,G:d,F:c,O:g,P:u,U:p}=t.PathCommandMap,f={scale(t,e,f){if(!t)return;let m,y=0,L=t.length;for(;y<L;)switch(m=t[y],m){case i:case o:v(t,e,f,y,1),y+=3;break;case s:v(t,e,f,y,3),y+=7;break;case n:v(t,e,f,y,2),y+=5;break;case r:y+=1;break;case a:v(t,e,f,y,2),y+=5;break;case l:v(t,e,f,y,2),y+=9;break;case h:v(t,e,f,y,2),y+=6;break;case d:v(t,e,f,y,2),y+=9;break;case c:v(t,e,f,y,2),y+=5;break;case g:t[y]=d,t.splice(y+4,0,t[y+3],0),v(t,e,f,y,2),y+=9,L+=2;break;case u:t[y]=c,t.splice(y+4,0,t[y+3]),v(t,e,f,y,2),y+=5,L+=1;break;case p:v(t,e,f,y,2),y+=6}},scalePoints(t,e,i,o,s){for(let n=s?o+1:0,r=s?n+2*s:t.length;n<r;n+=2)t[n]*=e,t[n+1]*=i}},{scalePoints:v}=f,m=t.MatrixHelper.get();function y(t,e,i){t.pathInputed?w(t,e,i):(t.width*=e,t.height*=i)}function L(t,e,i){1!==e?t.fontSize*=e:1!==i&&(t.fontSize*=i)}function w(t,e,i){f.scale(t.__.path,e,i),t.path=t.__.path}function b(t,e,i){f.scalePoints(t.__.points,e,i),t.points=t.__.points}function E(t,e,i){const{children:o}=t;for(let t=0;t<o.length;t++)m.a=e,m.d=i,o[t].transform(m,!0)}function x(t,e,i,o){var s,n=arguments.length,r=n<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,o);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(r=(n<3?s(r):n>3?s(e,i,r):s(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r}function _(t){return t?t instanceof Array?t:[t]:[]}t.Leaf.prototype.scaleResize=function(t,e=t,i){const o=this;i?(o.scaleX*=t,o.scaleY*=e):(t<0&&(o.scaleX*=-1,t=-t),e<0&&(o.scaleY*=-1,e=-e),this.__scaleResize(t,e))},t.Leaf.prototype.__scaleResize=function(t,e){y(this,t,e)},t.Text.prototype.__scaleResize=function(t,e){this.editConfig&&"font-size"===this.editConfig.editSize?L(this,t,e):y(this,t,e)},t.Path.prototype.__scaleResize=function(t,e){w(this,t,e)},t.Line.prototype.__scaleResize=function(t,e){if(this.pathInputed)w(this,t,e);else if(this.points)b(this,t,e);else{const i=this.toPoint;i.x*=t,i.y*=e,this.toPoint=i}},t.Polygon.prototype.__scaleResize=function(t,e){this.pathInputed?w(this,t,e):this.points?b(this,t,e):y(this,t,e)},t.Group.prototype.__scaleResize=function(t,e){E(this,t,e)},t.Box.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?E(this,t,e):y(this,t,e)},"function"==typeof SuppressedError&&SuppressedError;class k extends t.Event{get list(){return _(this.value)}get oldList(){return _(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}k.SELECT="editor.select",k.HOVER="editor.hover";class M extends k{constructor(t,e){super(t,e)}}M.MOVE="editor.move";class T extends k{constructor(t,e){super(t,e)}}T.SCALE="editor.scale";class S extends k{constructor(t,e){super(t,e)}}S.ROTATE="editor.rotate";class P extends k{constructor(t,e){super(t,e)}}function H(e){return(i,o)=>{const s="_"+o;t.defineKey(i,o,{get(){return this[s]},set(t){const i=this[s];i!==t&&(this[s]=t,e(this,i))}})}}P.SKEW="editor.skew";const V=t.MatrixHelper.get(),{abs:O}=Math,{copy:I,scale:D}=t.MatrixHelper;class R extends t.UI{constructor(){super(),this.list=[],this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){this.set(e),this.target=t}__draw(e,i){const{list:o}=this;if(o.length){let s;const{stroke:n,strokeWidth:r,fill:a}=this.__,{bounds:l}=i;for(let h=0;h<o.length;h++)if(s=o[h],l&&l.hit(s.__world,i.matrix)){const o=O(s.__world.scaleX),l=O(s.__world.scaleY);if(o!==l){I(V,s.__world),D(V,1/o,1/l),e.setWorld(V,i.matrix),e.beginPath(),this.__.strokeWidth=r;const{x:t,y:n,width:a,height:h}=s.__layout.boxBounds;e.rect(t*o,n*l,a*o,h*l)}else e.setWorld(s.__world,i.matrix),e.beginPath(),s.__.__useArrow?s.__drawPath(e):s.__.__pathForRender?s.__drawRenderPath(e):s.__drawPathByBox(e),this.__.strokeWidth=r/O(s.__world.scaleX);n&&("string"==typeof n?t.Paint.stroke(n,this,e):t.Paint.strokes(n,this,e)),a&&("string"==typeof a?t.Paint.fill(a,this,e):t.Paint.fills(a,this,e))}this.__.strokeWidth=r}}destroy(){this.target=null,super.destroy()}}x([H((function(t){const e=t.target;t.list=e?e instanceof Array?e:[e]:[],t.forceUpdate()}))],R.prototype,"target",void 0);class C extends t.Group{constructor(e){super(e),this.strokeArea=new t.Rect({strokeAlign:"center"}),this.fillArea=new t.Rect,this.visible=this.hittable=!1,this.addMany(this.fillArea,this.strokeArea)}setStyle(t,e){const{visible:i,stroke:o,strokeWidth:s}=t;this.visible=i,this.strokeArea.reset(Object.assign({stroke:o,strokeWidth:s},e||{})),this.fillArea.reset({visible:!e,fill:o,opacity:.2})}setBounds(t){this.strokeArea.set(t),this.fillArea.set(t)}}const{No:B,Yes:A,NoAndSkip:Z,YesAndSkip:z}=t.Answer,W={findOne:t=>t.list.find((t=>t.editable)),findBounds(t,e){if(t.__.hittable&&t.__.visible&&!t.__.locked&&e.hit(t.__world)){if(t.__.editable){if(t.isBranch&&!t.__.hitChildren)return t.__.hitSelf?z:Z;if(t.isFrame)return e.includes(t.__layout.boxBounds,t.__world)?z:B;if(e.hit(t.__layout.boxBounds,t.__world)&&t.__.hitSelf)return A}return B}return t.isBranch?Z:B}},{findOne:G}=W;class X extends t.Group{get dragging(){return!!this.originList}get running(){const{editor:t}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector}get isMoveMode(){return this.app&&this.app.interaction.moveMode}constructor(e){super(),this.hoverStroker=new R,this.targetStroker=new R,this.bounds=new t.Bounds,this.selectArea=new C,this.__eventIds=[],this.editor=e,this.addMany(this.targetStroker,this.hoverStroker,this.selectArea),this.__listenEvents()}onHover(){const{editor:t}=this;if(!this.running||this.dragging||t.dragging)this.hoverStroker.target=null;else{const{stroke:e,strokeWidth:i,hover:o,hoverStyle:s}=t.mergeConfig;this.hoverStroker.setTarget(o?this.editor.hoverTarget:null,Object.assign({stroke:e,strokeWidth:i},s||{}))}}onSelect(){if(this.running){const{mergeConfig:t,list:e}=this.editor,{stroke:i,strokeWidth:o}=t;this.targetStroker.setTarget(e,{stroke:i,strokeWidth:Math.max(1,o/2)}),this.hoverStroker.target=null}}update(){this.targetStroker.target&&this.targetStroker.forceUpdate()}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.config.pointer.hover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){const{select:e}=this.editor.mergeConfig;"press"===e&&this.checkAndSelect(t)}onTap(t){const{editor:e}=this,{select:i}=e.mergeConfig;"tap"===i&&this.checkAndSelect(t),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(e.target=null)}checkAndSelect(t){if(this.needRemoveItem=null,this.allowSelect(t)){const{editor:e}=this,i=this.findUI(t);i?this.isMultipleSelect(t)?e.hasItem(i)?this.needRemoveItem=i:e.addItem(i):e.target=i:this.allow(t.target)&&(t.shiftKey||(e.target=null))}}onDragStart(t){if(this.allowDrag(t)){const{editor:e}=this,{stroke:i,area:o}=e.mergeConfig,{x:s,y:n}=t.getInner(this);this.bounds.set(s,n),this.selectArea.setStyle({visible:!0,stroke:i,x:s,y:n},o),this.selectArea.setBounds(this.bounds.get()),this.originList=e.leafList.clone()}}onDrag(e){if(this.editor.dragging)this.onDragEnd();else if(this.dragging){const{editor:i}=this,o=e.getInnerTotal(this),s=this.bounds.clone().unsign(),n=new t.LeafList(i.app.find(W.findBounds,s));if(this.bounds.width=o.x,this.bounds.height=o.y,this.selectArea.setBounds(s.get()),n.length){const t=[];this.originList.forEach((e=>{n.has(e)||t.push(e)})),n.forEach((e=>{this.originList.has(e)||t.push(e)})),(t.length!==i.list.length||i.list.some(((e,i)=>e!==t[i])))&&(i.target=t)}else i.target=this.originList.list}}onDragEnd(){this.dragging&&(this.originList=null,this.selectArea.visible=!1)}onAutoMove(t){if(this.dragging){const{x:e,y:i}=t.getLocalMove(this);this.bounds.x+=e,this.bounds.y+=i}}allow(t){return t.leafer!==this.editor.leafer}allowDrag(t){return!(!this.running||!this.editor.mergeConfig.boxSelect||t.target.draggable)&&(!this.editor.editing&&this.allow(t.target)||t.shiftKey&&!G(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(e){const i={exclude:new t.LeafList(this.editor.editBox.rect)};return G(e.target.leafer.interaction.findPath(e,i))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):G(t.path)}isMultipleSelect(t){return t.shiftKey||this.editor.mergeConfig.continuousSelect}__listenEvents(){const{editor:t}=this;t.waitLeafer((()=>{const{app:i}=t;i.selector.proxy=t,this.__eventIds=[t.on_(k.HOVER,this.onHover,this),t.on_(k.SELECT,this.onSelect,this),i.on_(e.PointerEvent.MOVE,this.onPointerMove,this),i.on_(e.PointerEvent.BEFORE_DOWN,this.onBeforeDown,this),i.on_(e.PointerEvent.TAP,this.onTap,this),i.on_(e.DragEvent.START,this.onDragStart,this),i.on_(e.DragEvent.DRAG,this.onDrag,this),i.on_(e.DragEvent.END,this.onDragEnd,this),i.on_(e.MoveEvent.MOVE,this.onAutoMove,this),i.on_([e.ZoomEvent.ZOOM,e.MoveEvent.MOVE],(()=>{this.editor.hoverTarget=null}))]}))}__removeListenEvents(){this.__eventIds&&(this.off_(this.__eventIds),this.__eventIds.length=0)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:Y,top:F,topRight:U,right:K,bottomRight:j,bottom:N,bottomLeft:q,left:$}=t.Direction9,{toPoint:Q}=t.AroundHelper,J={getScaleData(t,e,i,o,s){let n,r={},a=1,l=1;const{width:h,height:d}=t;s&&(i.x*=2,i.y*=2),Math.abs(i.x)===h&&(i.x+=.1),Math.abs(i.y)===d&&(i.y+=.1);const c=(-i.y+d)/d,g=(i.x+h)/h,u=(i.y+d)/d,p=(-i.x+h)/h;switch(e){case F:l=c,n="bottom";break;case K:a=g,n="left";break;case N:l=u,n="top";break;case $:a=p,n="right";break;case Y:l=c,a=p,n="bottom-right";break;case U:l=c,a=g,n="bottom-left";break;case j:l=u,a=g,n="top-left";break;case q:l=u,a=p,n="top-right"}if(o){if(!("corner"===o&&e%2)){const t=Math.sqrt(Math.abs(a*l));a=a<0?-t:t,l=l<0?-t:t}}return Q(s||n,t,r),{origin:r,scaleX:a,scaleY:l,direction:e,lockRatio:o,around:s}},getRotateData(e,i,o,s,n){let r,a={};switch(i){case Y:r="bottom-right";break;case U:r="bottom-left";break;case j:r="top-left";break;case q:r="top-right";break;default:r="center"}return Q(n||r,e,a),{origin:a,rotation:t.PointHelper.getRotation(s,a,o)}},getSkewData(e,i,o,s){let n,r,a={},l=0,h=0;switch(i){case F:r={x:.5,y:0},n="bottom",l=1;break;case N:r={x:.5,y:1},n="top",l=1;break;case $:r={x:0,y:.5},n="right",h=1;break;case K:r={x:1,y:.5},n="left",h=1}const{x:d,y:c,width:g,height:u}=e;r.x=d+r.x*g,r.y=c+r.y*u,Q(s||n,e,a);const p=t.PointHelper.getRotation(r,a,{x:r.x+(l?o.x:0),y:r.y+(h?o.y:0)});return l?l=-p:h=p,{origin:a,skewX:l,skewY:h}},getAround:(t,e)=>e&&!t?"center":t,getRotateDirection:(t,e,i=8)=>((t=(t+Math.round(e/(360/i)))%i)<0&&(t+=i),t),getFlipDirection(t,e,i){if(e)switch(t){case $:t=K;break;case Y:t=U;break;case q:t=j;break;case K:t=$;break;case U:t=Y;break;case j:t=q}if(i)switch(t){case F:t=N;break;case Y:t=q;break;case U:t=j;break;case N:t=F;break;case q:t=Y;break;case j:t=U}return t}},tt={};function et(e,i){const{editBox:o}=e,s=o.enterPoint;if(!s||!e.editing||!o.visible)return;if("circle"===s.name)return;let{rotation:n}=o;const{resizeCursor:r,rotateCursor:a,skewCursor:l,resizeable:h,rotateable:d,skewable:c}=e.mergeConfig,{pointType:g}=s,{flippedX:u,flippedY:p}=o;let f="resize"===g;f&&d&&(i.metaKey||i.ctrlKey||!h)&&(f=!1);const v=c&&!f&&"resize-line"===s.name?l:f?r:a;n+=45*(J.getFlipDirection(s.direction,u,p)+1),n=2*Math.round(t.MathHelper.formatRotation(n,!0)/2);const{url:m,x:y,y:L}=v,w=m+n;tt[w]?s.cursor=tt[w]:tt[w]=s.cursor={url:ot(m,n),x:y,y:L}}function it(t){t.editBox.rect.cursor=t.mergeConfig.moveCursor}function ot(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class st extends t.Box{}const nt=["top","right","bottom","left"];class rt extends t.Group{get flipped(){return this.flippedX||this.flippedY}get flippedX(){return this.scaleX<0}get flippedY(){return this.scaleY<0}get flippedOne(){return this.scaleX*this.scaleY<0}constructor(e){super(),this.view=new t.Group,this.rect=new t.Box({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new st({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new t.Group({around:"center",hitSelf:!1}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.__eventIds=[],this.editor=e,this.visible=!1,this.create(),this.__listenEvents()}create(){let t,e,i;const{view:o,resizePoints:s,rotatePoints:n,resizeLines:r,rect:a,circle:l,buttons:h}=this,d=["bottom-right","bottom","bottom-left","left","top-left","top","top-right","right"];for(let o=0;o<8;o++)t=new st({name:"rotate-point",around:d[o],width:15,height:15,hitFill:"all"}),n.push(t),this.listenPointEvents(t,"rotate",o),o%2&&(e=new st({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",o)),i=new st({name:"resize-point",hitRadius:5}),s.push(i),this.listenPointEvents(i,"resize",o);h.add(l),this.listenPointEvents(l,"rotate",2),o.addMany(...n,a,h,...r,...s),this.add(o)}load(){const{mergeConfig:t,element:e,single:i}=this.editor,{rect:o,circle:s,resizePoints:n}=this,{stroke:r,strokeWidth:a,moveable:l}=t,h=this.getPointsStyle(),d=this.getMiddlePointsStyle();let c;for(let t=0;t<8;t++)c=n[t],c.set(this.getPointStyle(t%2?d[(t-1)/2%d.length]:h[t/2%h.length])),t%2||(c.rotation=t/2*90);s.set(this.getPointStyle(t.rotatePoint||h[0])),o.set(Object.assign({stroke:r,strokeWidth:a},t.rect||{})),o.hittable=!i&&l,e.syncEventer=i&&l?o:null,this.app.interaction.bottomList=i&&l?[{target:o,proxy:e}]:null,this.visible=!e.locked}update(e){if(this.view.worldOpacity){const{mergeConfig:i}=this.editor,{width:o,height:s}=e,{rect:n,circle:r,resizePoints:a,rotatePoints:l,resizeLines:h}=this,{middlePoint:d,resizeable:c,rotateable:g,hideOnSmall:u}=i,p="number"==typeof u?u:10,f=!(u&&o<p&&s<p);let v,m,y,L={};for(let n=0;n<8;n++)t.AroundHelper.toPoint(t.AroundHelper.directionData[n],e,L),m=a[n],v=l[n],y=h[Math.floor(n/2)],m.set(L),v.set(L),y.set(L),m.visible=y.visible=f&&(c||g),v.visible=f&&g&&c&&!i.rotatePoint,n%2&&(m.visible=v.visible=f&&!!d,(n+1)/2%2?(y.width=o,m.width>o-30&&(m.visible=!1)):(y.height=s,m.rotation=90,m.width>s-30&&(m.visible=!1)));r.visible=f&&g&&!!i.rotatePoint,n.path&&(n.path=null),n.set(Object.assign(Object.assign({},e),{visible:!0}));const w=f&&(r.visible||this.buttons.children.length>1);this.buttons.visible=w,w&&this.layoutButtons()}}layoutButtons(){const{buttons:t,resizePoints:e}=this,{buttonsDirection:i,buttonsFixed:o,buttonsMargin:s,middlePoint:n}=this.editor.mergeConfig,{flippedX:r,flippedY:a}=this;let l=nt.indexOf(i);(l%2&&r||(l+1)%2&&a)&&o&&(l=(l+2)%4);const h=o?J.getRotateDirection(l,this.flippedOne?this.rotation:-this.rotation,4):l,d=e[2*h+1],c=h%2,g=h&&3!==h?1:-1,u=(s+(l%2?(n?d.width:0)+t.boxBounds.width:(n?d.height:0)+t.boxBounds.height)/2)*g;c?(t.x=d.x+u,t.y=d.y):(t.x=d.x,t.y=d.y+u),o&&(t.rotation=90*(h-l),t.scaleX=r?-1:1,t.scaleY=a?-1:1)}unload(){this.visible=!1}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:o,pointSize:s,pointRadius:n}=this.editor.mergeConfig,r={fill:o,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",width:s,height:s,cornerRadius:n};return t?Object.assign(r,t):r}getPointsStyle(){const{point:t}=this.editor.mergeConfig;return t instanceof Array?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.editor.mergeConfig;return t instanceof Array?t:t?[t]:this.getPointsStyle()}onSelect(t){1===t.oldList.length&&(t.oldList[0].syncEventer=this.app.interaction.bottomList=null)}onDragStart(t){if(this.dragging=!0,"rect"===t.current.name){const{editor:t}=this;this.moving=!0,t.dragStartPoint={x:t.element.x,y:t.element.y},t.opacity=t.mergeConfig.hideOnMove?0:1}}onDragEnd(t){this.dragging=!1,this.moving=!1,"rect"===t.current.name&&(this.editor.opacity=1)}onDrag(t){const{editor:e}=this;"rotate"===(this.enterPoint=t.current).pointType||t.metaKey||t.ctrlKey||!e.mergeConfig.resizeable?e.mergeConfig.rotateable&&e.onRotate(t):e.onScale(t),et(e,t)}onArrow(t){if(this.editor.editing&&this.editor.mergeConfig.keyEvent){const e={x:0,y:0},i=t.shiftKey?10:1;switch(t.code){case"ArrowDown":e.y=i;break;case"ArrowUp":e.y=-i;break;case"ArrowLeft":e.x=-i;break;case"ArrowRight":e.x=i}this.editor.move(e)}}onDoubleTap(t){"double"===this.editor.mergeConfig.openInner&&this.openInner(t)}onLongPress(t){"long"===this.editor.mergeConfig.openInner&&this.openInner(t)}openInner(t){const{editor:e}=this;if(e.single){const{element:i}=e;i.isBranch?(e.openGroup(i),e.target=e.selector.findDeepOne(t)):e.openInnerEditor()}}listenPointEvents(t,i,o){const{editor:s}=this;t.direction=o,t.pointType=i,t.on_(e.DragEvent.START,this.onDragStart,this),t.on_(e.DragEvent.DRAG,this.onDrag,this),t.on_(e.DragEvent.END,this.onDragEnd,this),t.on_(e.PointerEvent.LEAVE,(()=>this.enterPoint=null)),"circle"!==t.name&&t.on_(e.PointerEvent.ENTER,(e=>{this.enterPoint=t,et(s,e)}))}__listenEvents(){const{rect:t,editor:i}=this;this.__eventIds=[i.on_(k.SELECT,this.onSelect,this),t.on_(e.DragEvent.START,this.onDragStart,this),t.on_(e.DragEvent.DRAG,i.onMove,i),t.on_(e.DragEvent.END,this.onDragEnd,this),t.on_(e.PointerEvent.ENTER,(()=>it(i))),t.on_(e.PointerEvent.DOUBLE_TAP,this.onDoubleTap,this),t.on_(e.PointerEvent.LONG_PRESS,this.onLongPress,this)]}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}const at='\n<feOffset dy="1"/>\n<feGaussianBlur stdDeviation="1.5"/>\n<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>\n<feBlend mode="normal" in="SourceGraphic" result="shape"/>',lt={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,buttonsDirection:"bottom",buttonsMargin:12,hideOnSmall:!0,moveCursor:"move",resizeCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate({{rotation}},12,12)">\n<path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>\n<path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">\n${at}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},rotateCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(135,12,12),rotate({{rotation}},12,12)">\n<path d="M20.4 8H21.4L20.8 7.1L17.3 2.6L17 2.1L16.6 2.6L13.1 7.1L12.5 8H13.5H15.4C14.9 11.8 11.8 14.9 8 15.4V13.5V12.5L7.1 13.1L2.6 16.6L2.1 17L2.6 17.3L7.1 20.8L8 21.4V20.4V18.4C13.5 17.9 17.9 13.5 18.4 8H20.4Z" stroke="white"/>\n<path fill-rule="evenodd" d="M17 3L20.4 7.5H17.9C17.7 13.1 13.1 17.7 7.5 17.9V20.4L3 17L7.5 13.5V15.9C12.0 15.7 15.7 12.0 15.9 7.5H13.5L17 3Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="-0.6" width="27.1" height="27.1" filterUnits="userSpaceOnUse">\n${at}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},skewCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(90,12,12),rotate({{rotation}},12,12)">\n<path d="M21 10.4L21 11.4L23.8 11.4L21.6 9.6L21 10.4ZM17 10.4V11.4L17 11.4L17 10.4ZM15.5 6L16.1 5.2L14.5 3.9V6H15.5ZM15.5 8.4V9.4H16.5V8.4H15.5ZM6 8.4V7.4H5V8.4H6ZM6 10.4H5V11.4H6V10.4ZM7 14.4V13.4L7 13.4L7 14.4ZM3 14.4L3 13.4L0.1 13.4L2.3 15.2L3 14.4ZM8.5 18.9L7.8 19.7L9.5 21.0V18.9H8.5ZM8.5 16.4V15.4H7.5V16.4H8.5ZM19 16.4V17.4H20V16.4H19ZM19 14.4H20V13.4H19V14.4ZM21 9.4L17 9.4L17 11.4L21 11.4L21 9.4ZM14.8 6.7L20.3 11.2L21.6 9.6L16.1 5.2L14.8 6.7ZM16.5 8.4V6H14.5V8.4H16.5ZM6 9.4H15.5V7.4H6V9.4ZM7 10.4V8.4H5V10.4H7ZM15.5 9.4H6V11.4H15.5V9.4ZM17 9.4H15.5V11.4H17V9.4ZM7 15.4H8.5V13.4H7V15.4ZM3 15.4L7 15.4L7 13.4L3 13.4L3 15.4ZM9.1 18.1L3.6 13.6L2.3 15.2L7.8 19.7L9.1 18.1ZM7.5 16.4V18.9H9.5V16.4H7.5ZM19 15.4H8.5V17.4H19V15.4ZM18 14.4V16.4H20V14.4H18ZM8.5 15.4H19V13.4H8.5V15.4Z" fill="white"/>\n<path fill-rule="evenodd" d="M17 10.4L21 10.4L15.5 6V8.4H6V10.4H15.5H17ZM8.5 14.4H7L3 14.4L8.5 18.9V16.4H19V14.4H8.5Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter x="-2.8" y="1.9" width="29.6" height="23.1" filterUnits="userSpaceOnUse" >\n${at}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},selector:!0,hover:!0,select:"press",openInner:"double",boxSelect:!0,moveable:!0,resizeable:!0,rotateable:!0,skewable:!0};const ht=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),dt=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),ct={group(e,i,o){e.sort(dt);const{app:s,parent:n}=e[0];let r;r=o&&o.add?o:new t.Group(o),n.addAt(r,n.children.indexOf(e[0])),e.sort(ht);const a=new t.Matrix(i.worldTransform);return a.divideParent(n.worldTransform),r.setTransform(a),r.editable=!0,r.hitChildren=!1,s.lockLayout(),e.forEach((t=>t.dropTo(r))),s.unlockLayout(),r},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach((t=>{if(t.isBranch){const{parent:e,children:o}=t;for(;o.length;)i.push(o[0]),o[0].dropTo(e,e.children.indexOf(t));t.remove()}else i.push(t)})),e.unlockLayout(),i},toTop(t){t.sort(ht),t.forEach((t=>{t.parent&&t.parent.add(t)}))},toBottom(t){t.sort(dt),t.forEach((t=>{t.parent&&t.parent.addAt(t,0)}))}},gt=t.Debug.get("EditToolCreator");function ut(){return t=>{ft.register(t)}}const pt=ut,ft={list:{},register(t){const{tag:e}=t.prototype;vt[e]?gt.repeat(e):vt[e]=t},get:(t,e)=>new vt[t](e)},{list:vt}=ft;class mt extends t.Group{get list(){return this.leafList.list}get editing(){return!!this.list.length}get groupOpening(){return!!this.openedGroupList.length}get multiple(){return this.list.length>1}get single(){return 1===this.list.length}get dragging(){return this.editBox.dragging}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}constructor(e,i){super(i),this.config=lt,this.mergeConfig=lt,this.leafList=new t.LeafList,this.openedGroupList=new t.LeafList,this.simulateTarget=new t.Rect({visible:!1}),this.editBox=new rt(this),this.editToolList={},this.selector=new X(this),this.targetEventIds=[],e&&(this.config=t.DataHelper.default(e,this.config)),this.addMany(this.selector,this.editBox)}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}update(){this.editing&&(this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update())}updateEditTool(){const t=this.editTool;if(t&&(this.editBox.unload(),t.unload(),this.editTool=null),this.editing){const t=this.single?this.list[0].editOuter:"EditTool";this.editTool=this.editToolList[t]=this.editToolList[t]||ft.get(t,this);const{editConfig:e}=this.element;this.mergeConfig=this.single&&e?Object.assign(Object.assign({},this.mergeConfig),e):this.config,this.editBox.load(),this.editTool.load()}}getEditSize(t){return this.mergeConfig.editSize}onMove(t){const i={x:t.totalX,y:t.totalY};t.shiftKey&&(Math.abs(i.x)>Math.abs(i.y)?i.y=0:i.x=0),this.move(e.DragEvent.getValidMove(this.element,this.dragStartPoint,i))}onScale(t){const{element:e}=this,{direction:i}=t.current;let{around:o,lockRatio:s}=this.mergeConfig;t.shiftKey&&(s=!0);const n=J.getScaleData(e.boxBounds,i,t.getInnerMove(e),s,J.getAround(o,t.altKey));this.editTool.onScaleWithDrag?(n.drag=t,this.scaleWithDrag(n)):this.scaleOf(n.origin,n.scaleX,n.scaleY)}onRotate(i){const{skewable:o,around:s,rotateGap:n}=this.mergeConfig,{direction:r,name:a}=i.current;if(o&&"resize-line"===a)return this.onSkew(i);const{element:l}=this;let h,d;if(i instanceof e.RotateEvent)d=i.rotation,h=l.getInnerPoint(i);else{const t={x:i.x-i.moveX,y:i.y-i.moveY},e=J.getRotateData(l.boxBounds,r,i.getInner(l),l.getInnerPoint(t),i.shiftKey?null:s||"center");d=e.rotation,h=e.origin}d=t.MathHelper.getGapRotation(d,n,l.rotation),d&&(l.scaleX*l.scaleY<0&&(d=-d),this.rotateOf(h,t.MathHelper.float(d,2)))}onSkew(t){const{element:e}=this,{around:i}=this.mergeConfig,{origin:o,skewX:s,skewY:n}=J.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),J.getAround(i,t.altKey));(s||n)&&this.skewOf(o,s,n)}move(t,e=0){if(!this.mergeConfig.moveable||this.element.locked)return;const{element:i}=this,o=i.getWorldPointByLocal("object"==typeof t?Object.assign({},t):{x:t,y:e},null,!0),s=new M(M.MOVE,{target:i,editor:this,moveX:o.x,moveY:o.y});this.editTool.onMove(s),this.emitEvent(s),this.multiple&&i.move(t,e)}scaleWithDrag(t){const{element:e}=this,i=e.getWorldPoint(t.origin),o=new T(T.SCALE,Object.assign(Object.assign({},t),{target:e,editor:this,worldOrigin:i}));this.editTool.onScaleWithDrag(o),this.emitEvent(o)}scaleOf(e,i,o=i,s){const{element:n}=this,r=n.getWorldPoint(e);let a;if(this.multiple){const s=new t.Matrix(n.worldTransform);n.scaleOf(e,i,o),a=new t.Matrix(n.worldTransform).divide(s)}const l=new T(T.SCALE,{target:n,editor:this,worldOrigin:r,scaleX:i,scaleY:o,transform:a});this.editTool.onScale(l),this.emitEvent(l)}rotateOf(e,i){const{element:o}=this,s=o.getWorldPoint(e);let n;if(this.multiple){const s=new t.Matrix(o.worldTransform);o.rotateOf(e,i),n=new t.Matrix(o.worldTransform).divide(s)}const r=new S(S.ROTATE,{target:o,editor:this,worldOrigin:s,rotation:i,transform:n});this.editTool.onRotate(r),this.emitEvent(r)}skewOf(e,i,o=0,s){const{element:n}=this,r=n.getWorldPoint(e);let a;if(this.multiple){const s=new t.Matrix(n.worldTransform);n.skewOf(e,i,o),a=new t.Matrix(n.worldTransform).divide(s)}const l=new P(P.SKEW,{target:n,editor:this,skewX:i,skewY:o,transform:a,worldOrigin:r});this.editTool.onSkew(l),this.emitEvent(l)}group(t){return this.multiple&&(this.target=ct.group(this.list,this.element,t)),this.target}ungroup(){return this.list.length&&(this.target=ct.ungroup(this.list)),this.list}openGroup(t){this.openedGroupList.add(t),t.hitChildren=!0}closeGroup(t){this.openedGroupList.remove(t),t.hitChildren=!1}checkOpenedGroups(){const e=this.openedGroupList;if(e.length){let{list:i}=e;this.editing&&(i=[],e.forEach((e=>this.list.every((i=>!t.LeafHelper.hasParent(i,e)))&&i.push(e)))),i.forEach((t=>this.closeGroup(t)))}}openInnerEditor(){if(this.single){const t=this.element.editInner;t&&ft.list[t]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[t]||ft.get(t,this),this.innerEditor.load())}}closeInnerEditor(){this.innerEditing&&(this.innerEditing=!1,this.innerEditor.unload(),this.editTool.load(),this.innerEditor=null)}lock(){this.list.forEach((t=>t.locked=!0)),this.update()}unlock(){this.list.forEach((t=>t.locked=!1)),this.update()}toTop(){this.list.length&&(ct.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(ct.toBottom(this.list),this.leafList.update())}listenTargetEvents(){if(!this.targetEventIds.length){const{leafer:i}=this.list[0];this.targetEventIds=[i.on_(t.RenderEvent.START,this.update,this),i.on_([e.KeyEvent.HOLD,e.KeyEvent.UP],(t=>{et(this,t)})),i.on_(e.KeyEvent.DOWN,this.editBox.onArrow,this.editBox)]}}removeTargetEvents(){const{targetEventIds:t}=this;t.length&&(this.off_(t),t.length=0)}destroy(){this.destroyed||(this.simulateTarget.destroy(),Object.values(this.editToolList).forEach((t=>t.destroy())),this.editToolList={},this.target=this.hoverTarget=this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}}x([H((function(t,e){t.emitEvent(new k(k.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))}))],mt.prototype,"hoverTarget",void 0),x([H((function(e,i){const{target:o}=e;o?e.leafList=o instanceof t.LeafList?o:new t.LeafList(o):e.leafList.reset(),e.emitEvent(new k(k.SELECT,{editor:e,value:o,oldValue:i})),e.checkOpenedGroups(),e.editing?e.waitLeafer((()=>{e.multiple&&function(e){const{simulateTarget:i,leafList:o}=e,{x:s,y:n,width:r,height:a}=(new t.Bounds).setListWithFn(o.list,(t=>t.worldBoxBounds)),l=i.parent=o.list[0].leafer.zoomLayer,{scaleX:h,scaleY:d,e:c,f:g}=l.__world;i.reset({x:(s-c)/h,y:(n-g)/d,width:r/h,height:a/d})}(e),it(e),e.updateEditTool(),e.update(),e.listenTargetEvents()})):(e.updateEditTool(),e.removeTargetEvents())}))],mt.prototype,"target",void 0);class yt{static registerInnerEditor(){ft.register(this)}get tag(){return"InnerEditor"}get editBox(){return this.editor.editBox}constructor(t){this.editor=t,this.create()}onCreate(){}create(){this.view=new t.Group,this.onCreate()}onLoad(){}load(){this.editor.selector.hittable=this.editor.app.tree.hitChildren=!1,this.onLoad()}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){this.editor.selector.hittable=this.editor.app.tree.hitChildren=!0,this.onUnload()}onDestroy(){}destroy(){this.onDestroy(),this.editor&&(this.view&&this.view.destroy(),this.eventIds&&this.editor.off_(this.eventIds),this.editor=this.view=this.eventIds=null)}}exports.EditTool=class extends yt{static registerEditTool(){ft.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:o}=t,{app:s,list:n}=o;s.lockLayout(),n.forEach((t=>{t.moveWorld(e,i)})),s.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:o,worldOrigin:s,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);o?t.transformWorld(o,r):t.scaleOfWorld(s,e,i,r)})),r.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:o,editor:s}=t,{app:n,list:r}=s;n.lockLayout(),r.forEach((t=>{const n="scale"!==s.getEditSize(t);i?t.transformWorld(i,n):t.rotateOfWorld(o,e)})),n.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:o,worldOrigin:s,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);o?t.transformWorld(o,r):t.skewOfWorld(s,e,i,r)})),r.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){const{editor:t,editBox:e}=this,{simulateTarget:i,element:o}=t;t.multiple&&i.parent.updateLayout();const{x:s,y:n,scaleX:r,scaleY:a,rotation:l,skewX:h,skewY:d,width:c,height:g}=o.getLayoutBounds("box",t,!0);e.set({x:s,y:n,scaleX:r,scaleY:a,rotation:l,skewX:h,skewY:d}),e.update({x:0,y:0,width:c,height:g}),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}},exports.EditTool=x([ut()],exports.EditTool);const{left:Lt,right:wt}=t.Direction9,{move:bt,copy:Et}=t.PointHelper;exports.LineEditTool=class extends exports.EditTool{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(e){const{drag:i,direction:o,lockRatio:s,around:n}=e,r=e.target,a=o===Lt;if(r.pathInputed){const{path:t}=r.__,{from:e,to:o}=this.getFromToByPath(t);this.dragPoint(e,o,a,n,this.getInnerMove(r,i,s)),t[1]=e.x,t[2]=e.y,t[4]=o.x,t[5]=o.y,r.path=t}else if(r.points){const{points:t}=r,{from:e,to:o}=this.getFromToByPoints(t);this.dragPoint(e,o,a,n,this.getInnerMove(r,i,s)),t[0]=e.x,t[1]=e.y,t[2]=o.x,t[3]=o.y,r.points=t}else{const e=t.getPointData(),{toPoint:o}=r;r.rotation=0,this.dragPoint(e,o,a,n,this.getInnerMove(r,i,s)),r.getLocalPointByInner(e,null,null,!0),r.getLocalPointByInner(o,null,null,!0),r.x=e.x,r.y=e.y,r.getInnerPointByLocal(o,null,null,!0),r.toPoint=o}}getInnerMove(t,e,i){const o=e.getInnerMove(t);return i&&(Math.abs(o.x)>Math.abs(o.y)?o.y=0:o.x=0),o}getFromToByPath(t){return{from:{x:t[1],y:t[2]},to:{x:t[4],y:t[5]}}}getFromToByPoints(t){return{from:{x:t[0],y:t[1]},to:{x:t[2],y:t[3]}}}dragPoint(t,e,i,o,s){const{x:n,y:r}=s;i?(bt(t,n,r),o&&bt(e,-n,-r)):(o&&bt(t,-n,-r),bt(e,n,r))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:o,rect:s}=t,n=this.editor.element;let r,a;if(n.pathInputed?r=this.getFromToByPath(n.__.path):n.points&&(r=this.getFromToByPoints(n.__.points)),r){const{from:i,to:a}=r;n.innerToWorld(i,i,!1,t),n.innerToWorld(a,a,!1,t),s.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),Et(o[7],i),Et(e[7],i),Et(o[3],a),Et(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===Lt||t===wt,o[t].visible=a,e[t].visible=!r&&a}},exports.LineEditTool=x([ut()],exports.LineEditTool),t.Creator.editor=function(t){return new mt(t)},t.UI.setEditConfig=function(e){t.defineKey(this.prototype,"editConfig",{get(){return"function"==typeof e?e(this):e}})},t.UI.setEditOuter=function(e){t.defineKey(this.prototype,"editOuter",{get(){return"string"==typeof e?e:e(this)}})},t.UI.setEditInner=function(e){t.defineKey(this.prototype,"editInner",{get(){return"string"==typeof e?e:e(this)}})},exports.EditBox=rt,exports.EditDataHelper=J,exports.EditPoint=st,exports.EditSelect=X,exports.EditSelectHelper=W,exports.EditToolCreator=ft,exports.Editor=mt,exports.EditorEvent=k,exports.EditorHelper=ct,exports.EditorMoveEvent=M,exports.EditorRotateEvent=S,exports.EditorScaleEvent=T,exports.EditorSkewEvent=P,exports.InnerEditor=yt,exports.PathScaler=f,exports.SelectArea=C,exports.Stroker=R,exports.registerEditTool=ut,exports.registerInnerEditor=pt,exports.scaleResize=y,exports.scaleResizeFont=L,exports.scaleResizeGroup=E,exports.scaleResizePath=w,exports.scaleResizePoints=b;
|