@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.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PathCommandMap, Leaf, Path, Line, Polygon,
|
|
1
|
+
import { PathCommandMap, MatrixHelper, Leaf, Text, Path, Line, Polygon, Group, Box, Event, defineKey, UI, Paint, Rect, Answer, Bounds, LeafList, PointHelper, AroundHelper, Direction9, MathHelper, Matrix, Debug, DataHelper, LeafHelper, RenderEvent, getPointData, Creator } from '@leafer-ui/draw';
|
|
2
2
|
import { PointerEvent, DragEvent, MoveEvent, ZoomEvent, RotateEvent, KeyEvent } from '@leafer-ui/core';
|
|
3
3
|
|
|
4
4
|
const { M, L, C, Q, Z, N, D, X, G, F, O, P, U } = PathCommandMap;
|
|
@@ -80,6 +80,39 @@ const PathScaler = {
|
|
|
80
80
|
};
|
|
81
81
|
const { scalePoints } = PathScaler;
|
|
82
82
|
|
|
83
|
+
const matrix$1 = MatrixHelper.get();
|
|
84
|
+
function scaleResize(leaf, scaleX, scaleY) {
|
|
85
|
+
if (leaf.pathInputed) {
|
|
86
|
+
scaleResizePath(leaf, scaleX, scaleY);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
leaf.width *= scaleX;
|
|
90
|
+
leaf.height *= scaleY;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function scaleResizeFont(leaf, scaleX, scaleY) {
|
|
94
|
+
if (scaleX !== 1)
|
|
95
|
+
leaf.fontSize *= scaleX;
|
|
96
|
+
else if (scaleY !== 1)
|
|
97
|
+
leaf.fontSize *= scaleY;
|
|
98
|
+
}
|
|
99
|
+
function scaleResizePath(leaf, scaleX, scaleY) {
|
|
100
|
+
PathScaler.scale(leaf.__.path, scaleX, scaleY);
|
|
101
|
+
leaf.path = leaf.__.path;
|
|
102
|
+
}
|
|
103
|
+
function scaleResizePoints(leaf, scaleX, scaleY) {
|
|
104
|
+
PathScaler.scalePoints(leaf.__.points, scaleX, scaleY);
|
|
105
|
+
leaf.points = leaf.__.points;
|
|
106
|
+
}
|
|
107
|
+
function scaleResizeGroup(group, scaleX, scaleY) {
|
|
108
|
+
const { children } = group;
|
|
109
|
+
for (let i = 0; i < children.length; i++) {
|
|
110
|
+
matrix$1.a = scaleX;
|
|
111
|
+
matrix$1.d = scaleY;
|
|
112
|
+
children[i].transform(matrix$1, true);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
83
116
|
Leaf.prototype.scaleResize = function (scaleX, scaleY = scaleX, noResize) {
|
|
84
117
|
const data = this;
|
|
85
118
|
if (noResize) {
|
|
@@ -94,23 +127,26 @@ Leaf.prototype.scaleResize = function (scaleX, scaleY = scaleX, noResize) {
|
|
|
94
127
|
this.__scaleResize(scaleX, scaleY);
|
|
95
128
|
}
|
|
96
129
|
};
|
|
97
|
-
function scaleResize(leaf, scaleX, scaleY) {
|
|
98
|
-
if (scaleX !== 1)
|
|
99
|
-
leaf.width *= scaleX;
|
|
100
|
-
if (scaleY !== 1)
|
|
101
|
-
leaf.height *= scaleY;
|
|
102
|
-
}
|
|
103
130
|
Leaf.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
104
131
|
scaleResize(this, scaleX, scaleY);
|
|
105
132
|
};
|
|
133
|
+
Text.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
134
|
+
if (this.editConfig && this.editConfig.editSize === 'font-size') {
|
|
135
|
+
scaleResizeFont(this, scaleX, scaleY);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
scaleResize(this, scaleX, scaleY);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
106
141
|
Path.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
107
|
-
|
|
108
|
-
this.path = this.__.path;
|
|
142
|
+
scaleResizePath(this, scaleX, scaleY);
|
|
109
143
|
};
|
|
110
144
|
Line.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
111
|
-
if (this.
|
|
112
|
-
|
|
113
|
-
|
|
145
|
+
if (this.pathInputed) {
|
|
146
|
+
scaleResizePath(this, scaleX, scaleY);
|
|
147
|
+
}
|
|
148
|
+
else if (this.points) {
|
|
149
|
+
scaleResizePoints(this, scaleX, scaleY);
|
|
114
150
|
}
|
|
115
151
|
else {
|
|
116
152
|
const point = this.toPoint;
|
|
@@ -120,29 +156,22 @@ Line.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
|
120
156
|
}
|
|
121
157
|
};
|
|
122
158
|
Polygon.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
123
|
-
if (this.
|
|
124
|
-
|
|
125
|
-
|
|
159
|
+
if (this.pathInputed) {
|
|
160
|
+
scaleResizePath(this, scaleX, scaleY);
|
|
161
|
+
}
|
|
162
|
+
else if (this.points) {
|
|
163
|
+
scaleResizePoints(this, scaleX, scaleY);
|
|
126
164
|
}
|
|
127
165
|
else {
|
|
128
166
|
scaleResize(this, scaleX, scaleY);
|
|
129
167
|
}
|
|
130
168
|
};
|
|
131
|
-
const matrix$1 = MatrixHelper.get();
|
|
132
|
-
function groupScaleResize(group, scaleX, scaleY) {
|
|
133
|
-
const { children } = group;
|
|
134
|
-
for (let i = 0; i < children.length; i++) {
|
|
135
|
-
matrix$1.a = scaleX;
|
|
136
|
-
matrix$1.d = scaleY;
|
|
137
|
-
children[i].transform(matrix$1, true);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
169
|
Group.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
141
|
-
|
|
170
|
+
scaleResizeGroup(this, scaleX, scaleY);
|
|
142
171
|
};
|
|
143
172
|
Box.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
144
173
|
if (this.__.__autoSize && this.children.length) {
|
|
145
|
-
|
|
174
|
+
scaleResizeGroup(this, scaleX, scaleY);
|
|
146
175
|
}
|
|
147
176
|
else {
|
|
148
177
|
scaleResize(this, scaleX, scaleY);
|
|
@@ -237,7 +266,7 @@ function targetAttr(fn) {
|
|
|
237
266
|
|
|
238
267
|
const matrix = MatrixHelper.get();
|
|
239
268
|
const { abs } = Math;
|
|
240
|
-
const { copy, scale } = MatrixHelper;
|
|
269
|
+
const { copy: copy$1, scale } = MatrixHelper;
|
|
241
270
|
class Stroker extends UI {
|
|
242
271
|
constructor() {
|
|
243
272
|
super();
|
|
@@ -258,21 +287,17 @@ class Stroker extends UI {
|
|
|
258
287
|
for (let i = 0; i < list.length; i++) {
|
|
259
288
|
leaf = list[i];
|
|
260
289
|
if (bounds && bounds.hit(leaf.__world, options.matrix)) {
|
|
261
|
-
|
|
262
|
-
if (
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
const { x, y, width, height } = leaf.__layout.boxBounds;
|
|
271
|
-
canvas.rect(x * aScaleX, y * aScaleY, width * aScaleX, height * aScaleY);
|
|
272
|
-
drewPath = true;
|
|
273
|
-
}
|
|
290
|
+
const aScaleX = abs(leaf.__world.scaleX), aScaleY = abs(leaf.__world.scaleY);
|
|
291
|
+
if (aScaleX !== aScaleY) {
|
|
292
|
+
copy$1(matrix, leaf.__world);
|
|
293
|
+
scale(matrix, 1 / aScaleX, 1 / aScaleY);
|
|
294
|
+
canvas.setWorld(matrix, options.matrix);
|
|
295
|
+
canvas.beginPath();
|
|
296
|
+
this.__.strokeWidth = strokeWidth;
|
|
297
|
+
const { x, y, width, height } = leaf.__layout.boxBounds;
|
|
298
|
+
canvas.rect(x * aScaleX, y * aScaleY, width * aScaleX, height * aScaleY);
|
|
274
299
|
}
|
|
275
|
-
|
|
300
|
+
else {
|
|
276
301
|
canvas.setWorld(leaf.__world, options.matrix);
|
|
277
302
|
canvas.beginPath();
|
|
278
303
|
if (leaf.__.__useArrow) {
|
|
@@ -550,7 +575,7 @@ const { topLeft, top, topRight, right: right$1, bottomRight, bottom, bottomLeft,
|
|
|
550
575
|
const { toPoint } = AroundHelper;
|
|
551
576
|
const EditDataHelper = {
|
|
552
577
|
getScaleData(bounds, direction, pointMove, lockRatio, around) {
|
|
553
|
-
let origin, scaleX = 1, scaleY = 1;
|
|
578
|
+
let align, origin = {}, scaleX = 1, scaleY = 1;
|
|
554
579
|
const { width, height } = bounds;
|
|
555
580
|
if (around) {
|
|
556
581
|
pointMove.x *= 2;
|
|
@@ -567,97 +592,100 @@ const EditDataHelper = {
|
|
|
567
592
|
switch (direction) {
|
|
568
593
|
case top:
|
|
569
594
|
scaleY = topScale;
|
|
570
|
-
|
|
595
|
+
align = 'bottom';
|
|
571
596
|
break;
|
|
572
597
|
case right$1:
|
|
573
598
|
scaleX = rightScale;
|
|
574
|
-
|
|
599
|
+
align = 'left';
|
|
575
600
|
break;
|
|
576
601
|
case bottom:
|
|
577
602
|
scaleY = bottomScale;
|
|
578
|
-
|
|
603
|
+
align = 'top';
|
|
579
604
|
break;
|
|
580
605
|
case left$1:
|
|
581
606
|
scaleX = leftScale;
|
|
582
|
-
|
|
607
|
+
align = 'right';
|
|
583
608
|
break;
|
|
584
609
|
case topLeft:
|
|
585
610
|
scaleY = topScale;
|
|
586
611
|
scaleX = leftScale;
|
|
587
|
-
|
|
612
|
+
align = 'bottom-right';
|
|
588
613
|
break;
|
|
589
614
|
case topRight:
|
|
590
615
|
scaleY = topScale;
|
|
591
616
|
scaleX = rightScale;
|
|
592
|
-
|
|
617
|
+
align = 'bottom-left';
|
|
593
618
|
break;
|
|
594
619
|
case bottomRight:
|
|
595
620
|
scaleY = bottomScale;
|
|
596
621
|
scaleX = rightScale;
|
|
597
|
-
|
|
622
|
+
align = 'top-left';
|
|
598
623
|
break;
|
|
599
624
|
case bottomLeft:
|
|
600
625
|
scaleY = bottomScale;
|
|
601
626
|
scaleX = leftScale;
|
|
602
|
-
|
|
627
|
+
align = 'top-right';
|
|
603
628
|
}
|
|
604
629
|
if (lockRatio) {
|
|
605
630
|
const unlockSide = lockRatio === 'corner' && direction % 2;
|
|
606
|
-
if (!unlockSide)
|
|
607
|
-
|
|
631
|
+
if (!unlockSide) {
|
|
632
|
+
const scale = Math.sqrt(Math.abs(scaleX * scaleY));
|
|
633
|
+
scaleX = scaleX < 0 ? -scale : scale;
|
|
634
|
+
scaleY = scaleY < 0 ? -scale : scale;
|
|
635
|
+
}
|
|
608
636
|
}
|
|
609
|
-
toPoint(around ||
|
|
637
|
+
toPoint(around || align, bounds, origin);
|
|
610
638
|
return { origin, scaleX, scaleY, direction, lockRatio, around };
|
|
611
639
|
},
|
|
612
640
|
getRotateData(bounds, direction, current, last, around) {
|
|
613
|
-
let origin;
|
|
641
|
+
let align, origin = {};
|
|
614
642
|
switch (direction) {
|
|
615
643
|
case topLeft:
|
|
616
|
-
|
|
644
|
+
align = 'bottom-right';
|
|
617
645
|
break;
|
|
618
646
|
case topRight:
|
|
619
|
-
|
|
647
|
+
align = 'bottom-left';
|
|
620
648
|
break;
|
|
621
649
|
case bottomRight:
|
|
622
|
-
|
|
650
|
+
align = 'top-left';
|
|
623
651
|
break;
|
|
624
652
|
case bottomLeft:
|
|
625
|
-
|
|
653
|
+
align = 'top-right';
|
|
626
654
|
break;
|
|
627
655
|
default:
|
|
628
|
-
|
|
656
|
+
align = 'center';
|
|
629
657
|
}
|
|
630
|
-
toPoint(around ||
|
|
658
|
+
toPoint(around || align, bounds, origin);
|
|
631
659
|
return { origin, rotation: PointHelper.getRotation(last, origin, current) };
|
|
632
660
|
},
|
|
633
661
|
getSkewData(bounds, direction, move, around) {
|
|
634
|
-
let origin, skewX = 0, skewY = 0;
|
|
662
|
+
let align, origin = {}, skewX = 0, skewY = 0;
|
|
635
663
|
let last;
|
|
636
664
|
switch (direction) {
|
|
637
665
|
case top:
|
|
638
666
|
last = { x: 0.5, y: 0 };
|
|
639
|
-
|
|
667
|
+
align = 'bottom';
|
|
640
668
|
skewX = 1;
|
|
641
669
|
break;
|
|
642
670
|
case bottom:
|
|
643
671
|
last = { x: 0.5, y: 1 };
|
|
644
|
-
|
|
672
|
+
align = 'top';
|
|
645
673
|
skewX = 1;
|
|
646
674
|
break;
|
|
647
675
|
case left$1:
|
|
648
676
|
last = { x: 0, y: 0.5 };
|
|
649
|
-
|
|
677
|
+
align = 'right';
|
|
650
678
|
skewY = 1;
|
|
651
679
|
break;
|
|
652
680
|
case right$1:
|
|
653
681
|
last = { x: 1, y: 0.5 };
|
|
654
|
-
|
|
682
|
+
align = 'left';
|
|
655
683
|
skewY = 1;
|
|
656
684
|
}
|
|
657
685
|
const { x, y, width, height } = bounds;
|
|
658
686
|
last.x = x + last.x * width;
|
|
659
687
|
last.y = y + last.y * height;
|
|
660
|
-
toPoint(around ||
|
|
688
|
+
toPoint(around || align, bounds, origin);
|
|
661
689
|
const rotation = PointHelper.getRotation(last, origin, { x: last.x + (skewX ? move.x : 0), y: last.y + (skewY ? move.y : 0) });
|
|
662
690
|
skewX ? skewX = -rotation : skewY = rotation;
|
|
663
691
|
return { origin, skewX, skewY };
|
|
@@ -780,7 +808,7 @@ class EditBox extends Group {
|
|
|
780
808
|
create() {
|
|
781
809
|
let rotatePoint, resizeLine, resizePoint;
|
|
782
810
|
const { view, resizePoints, rotatePoints, resizeLines, rect, circle, buttons } = this;
|
|
783
|
-
const arounds = [
|
|
811
|
+
const arounds = ['bottom-right', 'bottom', 'bottom-left', 'left', 'top-left', 'top', 'top-right', 'right'];
|
|
784
812
|
for (let i = 0; i < 8; i++) {
|
|
785
813
|
rotatePoint = new EditPoint({ name: 'rotate-point', around: arounds[i], width: 15, height: 15, hitFill: "all" });
|
|
786
814
|
rotatePoints.push(rotatePoint);
|
|
@@ -854,6 +882,8 @@ class EditBox extends Group {
|
|
|
854
882
|
}
|
|
855
883
|
}
|
|
856
884
|
circle.visible = showPoints && rotateable && !!mergeConfig.rotatePoint;
|
|
885
|
+
if (rect.path)
|
|
886
|
+
rect.path = null;
|
|
857
887
|
rect.set(Object.assign(Object.assign({}, bounds), { visible: true }));
|
|
858
888
|
const buttonVisible = showPoints && (circle.visible || this.buttons.children.length > 1);
|
|
859
889
|
this.buttons.visible = buttonVisible;
|
|
@@ -1064,7 +1094,7 @@ ${filterStyle}
|
|
|
1064
1094
|
`;
|
|
1065
1095
|
|
|
1066
1096
|
const config = {
|
|
1067
|
-
editSize: '
|
|
1097
|
+
editSize: 'size',
|
|
1068
1098
|
keyEvent: true,
|
|
1069
1099
|
stroke: '#836DFF',
|
|
1070
1100
|
strokeWidth: 2,
|
|
@@ -1275,18 +1305,12 @@ class Editor extends Group {
|
|
|
1275
1305
|
this.editTool.load();
|
|
1276
1306
|
}
|
|
1277
1307
|
}
|
|
1278
|
-
getEditSize(
|
|
1279
|
-
|
|
1280
|
-
return editSize === 'auto' ? ui.editSize : editSize;
|
|
1308
|
+
getEditSize(_ui) {
|
|
1309
|
+
return this.mergeConfig.editSize;
|
|
1281
1310
|
}
|
|
1282
1311
|
onMove(e) {
|
|
1283
1312
|
const total = { x: e.totalX, y: e.totalY };
|
|
1284
|
-
|
|
1285
|
-
if (lockMove === 'x')
|
|
1286
|
-
total.y = 0;
|
|
1287
|
-
else if (lockMove === 'y')
|
|
1288
|
-
total.x = 0;
|
|
1289
|
-
else if (e.shiftKey) {
|
|
1313
|
+
if (e.shiftKey) {
|
|
1290
1314
|
if (Math.abs(total.x) > Math.abs(total.y))
|
|
1291
1315
|
total.y = 0;
|
|
1292
1316
|
else
|
|
@@ -1341,7 +1365,7 @@ class Editor extends Group {
|
|
|
1341
1365
|
this.skewOf(origin, skewX, skewY);
|
|
1342
1366
|
}
|
|
1343
1367
|
move(x, y = 0) {
|
|
1344
|
-
if (!this.mergeConfig.moveable)
|
|
1368
|
+
if (!this.mergeConfig.moveable || this.element.locked)
|
|
1345
1369
|
return;
|
|
1346
1370
|
const { element } = this;
|
|
1347
1371
|
const world = element.getWorldPointByLocal(typeof x === 'object' ? Object.assign({}, x) : { x, y }, null, true);
|
|
@@ -1560,7 +1584,7 @@ let EditTool = class EditTool extends InnerEditor {
|
|
|
1560
1584
|
const { app, list } = editor;
|
|
1561
1585
|
app.lockLayout();
|
|
1562
1586
|
list.forEach(target => {
|
|
1563
|
-
const resize = editor.getEditSize(target)
|
|
1587
|
+
const resize = editor.getEditSize(target) !== 'scale';
|
|
1564
1588
|
if (transform) {
|
|
1565
1589
|
target.transformWorld(transform, resize);
|
|
1566
1590
|
}
|
|
@@ -1575,7 +1599,7 @@ let EditTool = class EditTool extends InnerEditor {
|
|
|
1575
1599
|
const { app, list } = editor;
|
|
1576
1600
|
app.lockLayout();
|
|
1577
1601
|
list.forEach(target => {
|
|
1578
|
-
const resize = editor.getEditSize(target)
|
|
1602
|
+
const resize = editor.getEditSize(target) !== 'scale';
|
|
1579
1603
|
if (transform) {
|
|
1580
1604
|
target.transformWorld(transform, resize);
|
|
1581
1605
|
}
|
|
@@ -1590,7 +1614,7 @@ let EditTool = class EditTool extends InnerEditor {
|
|
|
1590
1614
|
const { app, list } = editor;
|
|
1591
1615
|
app.lockLayout();
|
|
1592
1616
|
list.forEach(target => {
|
|
1593
|
-
const resize = editor.getEditSize(target)
|
|
1617
|
+
const resize = editor.getEditSize(target) !== 'scale';
|
|
1594
1618
|
if (transform) {
|
|
1595
1619
|
target.transformWorld(transform, resize);
|
|
1596
1620
|
}
|
|
@@ -1624,6 +1648,7 @@ EditTool = __decorate([
|
|
|
1624
1648
|
], EditTool);
|
|
1625
1649
|
|
|
1626
1650
|
const { left, right } = Direction9;
|
|
1651
|
+
const { move, copy } = PointHelper;
|
|
1627
1652
|
let LineEditTool = class LineEditTool extends EditTool {
|
|
1628
1653
|
constructor() {
|
|
1629
1654
|
super(...arguments);
|
|
@@ -1632,50 +1657,100 @@ let LineEditTool = class LineEditTool extends EditTool {
|
|
|
1632
1657
|
get tag() { return 'LineEditTool'; }
|
|
1633
1658
|
onScaleWithDrag(e) {
|
|
1634
1659
|
const { drag, direction, lockRatio, around } = e;
|
|
1635
|
-
const
|
|
1636
|
-
const
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1660
|
+
const line = e.target;
|
|
1661
|
+
const isDragFrom = direction === left;
|
|
1662
|
+
if (line.pathInputed) {
|
|
1663
|
+
const { path } = line.__;
|
|
1664
|
+
const { from, to } = this.getFromToByPath(path);
|
|
1665
|
+
this.dragPoint(from, to, isDragFrom, around, this.getInnerMove(line, drag, lockRatio));
|
|
1666
|
+
path[1] = from.x, path[2] = from.y;
|
|
1667
|
+
path[4] = to.x, path[5] = to.y;
|
|
1668
|
+
line.path = path;
|
|
1669
|
+
}
|
|
1670
|
+
else if (line.points) {
|
|
1671
|
+
const { points } = line;
|
|
1672
|
+
const { from, to } = this.getFromToByPoints(points);
|
|
1673
|
+
this.dragPoint(from, to, isDragFrom, around, this.getInnerMove(line, drag, lockRatio));
|
|
1674
|
+
points[0] = from.x, points[1] = from.y;
|
|
1675
|
+
points[2] = to.x, points[3] = to.y;
|
|
1676
|
+
line.points = points;
|
|
1677
|
+
}
|
|
1678
|
+
else {
|
|
1679
|
+
const from = getPointData();
|
|
1680
|
+
const { toPoint } = line;
|
|
1681
|
+
line.rotation = 0;
|
|
1682
|
+
this.dragPoint(from, toPoint, isDragFrom, around, this.getInnerMove(line, drag, lockRatio));
|
|
1683
|
+
line.getLocalPointByInner(from, null, null, true);
|
|
1684
|
+
line.getLocalPointByInner(toPoint, null, null, true);
|
|
1685
|
+
line.x = from.x;
|
|
1686
|
+
line.y = from.y;
|
|
1687
|
+
line.getInnerPointByLocal(toPoint, null, null, true);
|
|
1688
|
+
line.toPoint = toPoint;
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
getInnerMove(ui, event, lockRatio) {
|
|
1692
|
+
const movePoint = event.getInnerMove(ui);
|
|
1640
1693
|
if (lockRatio) {
|
|
1641
|
-
if (Math.abs(x) > Math.abs(y)) {
|
|
1642
|
-
y = 0;
|
|
1694
|
+
if (Math.abs(movePoint.x) > Math.abs(movePoint.y)) {
|
|
1695
|
+
movePoint.y = 0;
|
|
1643
1696
|
}
|
|
1644
1697
|
else {
|
|
1645
|
-
x = 0;
|
|
1698
|
+
movePoint.x = 0;
|
|
1646
1699
|
}
|
|
1647
1700
|
}
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1701
|
+
return movePoint;
|
|
1702
|
+
}
|
|
1703
|
+
getFromToByPath(path) {
|
|
1704
|
+
return {
|
|
1705
|
+
from: { x: path[1], y: path[2] },
|
|
1706
|
+
to: { x: path[4], y: path[5] }
|
|
1707
|
+
};
|
|
1708
|
+
}
|
|
1709
|
+
getFromToByPoints(points) {
|
|
1710
|
+
return {
|
|
1711
|
+
from: { x: points[0], y: points[1] },
|
|
1712
|
+
to: { x: points[2], y: points[3] }
|
|
1713
|
+
};
|
|
1714
|
+
}
|
|
1715
|
+
dragPoint(fromPoint, toPoint, isDragFrom, around, movePoint) {
|
|
1716
|
+
const { x, y } = movePoint;
|
|
1717
|
+
if (isDragFrom) {
|
|
1718
|
+
move(fromPoint, x, y);
|
|
1719
|
+
if (around)
|
|
1720
|
+
move(toPoint, -x, -y);
|
|
1655
1721
|
}
|
|
1656
1722
|
else {
|
|
1657
|
-
if (around)
|
|
1658
|
-
fromPoint
|
|
1659
|
-
|
|
1660
|
-
}
|
|
1661
|
-
toPoint.x += x;
|
|
1662
|
-
toPoint.y += y;
|
|
1723
|
+
if (around)
|
|
1724
|
+
move(fromPoint, -x, -y);
|
|
1725
|
+
move(toPoint, x, y);
|
|
1663
1726
|
}
|
|
1664
|
-
target.getLocalPointByInner(fromPoint, null, null, true);
|
|
1665
|
-
target.getLocalPointByInner(toPoint, null, null, true);
|
|
1666
|
-
target.x = fromPoint.x;
|
|
1667
|
-
target.y = fromPoint.y;
|
|
1668
|
-
target.getInnerPointByLocal(toPoint, null, null, true);
|
|
1669
|
-
target.toPoint = toPoint;
|
|
1670
1727
|
}
|
|
1671
1728
|
onSkew(_e) {
|
|
1672
1729
|
}
|
|
1673
1730
|
onUpdate() {
|
|
1674
|
-
const { rotatePoints, resizeLines, resizePoints } =
|
|
1731
|
+
const { editBox } = this, { rotatePoints, resizeLines, resizePoints, rect } = editBox;
|
|
1732
|
+
const line = this.editor.element;
|
|
1733
|
+
let fromTo, leftOrRight;
|
|
1734
|
+
if (line.pathInputed)
|
|
1735
|
+
fromTo = this.getFromToByPath(line.__.path);
|
|
1736
|
+
else if (line.points)
|
|
1737
|
+
fromTo = this.getFromToByPoints(line.__.points);
|
|
1738
|
+
if (fromTo) {
|
|
1739
|
+
const { from, to } = fromTo;
|
|
1740
|
+
line.innerToWorld(from, from, false, editBox);
|
|
1741
|
+
line.innerToWorld(to, to, false, editBox);
|
|
1742
|
+
rect.pen.clearPath().moveTo(from.x, from.y).lineTo(to.x, to.y);
|
|
1743
|
+
copy(resizePoints[7], from);
|
|
1744
|
+
copy(rotatePoints[7], from);
|
|
1745
|
+
copy(resizePoints[3], to);
|
|
1746
|
+
copy(rotatePoints[3], to);
|
|
1747
|
+
}
|
|
1675
1748
|
for (let i = 0; i < 8; i++) {
|
|
1676
1749
|
if (i < 4)
|
|
1677
1750
|
resizeLines[i].visible = false;
|
|
1678
|
-
|
|
1751
|
+
leftOrRight = i === left || i === right;
|
|
1752
|
+
resizePoints[i].visible = leftOrRight;
|
|
1753
|
+
rotatePoints[i].visible = fromTo ? false : leftOrRight;
|
|
1679
1754
|
}
|
|
1680
1755
|
}
|
|
1681
1756
|
};
|
|
@@ -1699,8 +1774,5 @@ UI.setEditInner = function (editorName) {
|
|
|
1699
1774
|
get() { return typeof editorName === 'string' ? editorName : editorName(this); }
|
|
1700
1775
|
});
|
|
1701
1776
|
};
|
|
1702
|
-
Line.setEditOuter(function (line) {
|
|
1703
|
-
return (line.points || line.pathInputed) ? 'EditTool' : 'LineEditTool';
|
|
1704
|
-
});
|
|
1705
1777
|
|
|
1706
|
-
export { EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, InnerEditor, LineEditTool, SelectArea, Stroker, registerEditTool, registerInnerEditor };
|
|
1778
|
+
export { EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, InnerEditor, LineEditTool, PathScaler, SelectArea, Stroker, registerEditTool, registerInnerEditor, scaleResize, scaleResizeFont, scaleResizeGroup, scaleResizePath, scaleResizePoints };
|