@leafer-in/editor 1.5.3 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editor.cjs +130 -80
- package/dist/editor.cjs.map +1 -1
- package/dist/editor.esm.js +131 -81
- package/dist/editor.esm.js.map +1 -1
- package/dist/editor.esm.min.js +1 -1
- package/dist/editor.esm.min.js.map +1 -1
- package/dist/editor.js +130 -80
- package/dist/editor.js.map +1 -1
- package/dist/editor.min.cjs +1 -1
- package/dist/editor.min.cjs.map +1 -1
- package/dist/editor.min.js +1 -1
- package/dist/editor.min.js.map +1 -1
- package/package.json +5 -5
- package/src/Editor.ts +34 -27
- package/src/decorator/data.ts +25 -2
- package/src/display/EditBox.ts +26 -19
- package/src/display/EditMask.ts +19 -10
- package/src/display/EditSelect.ts +1 -1
- package/src/display/SelectArea.ts +2 -1
- package/src/display/Stroker.ts +9 -8
- package/src/helper/EditDataHelper.ts +12 -9
- package/src/tool/EditTool.ts +7 -18
- package/types/index.d.ts +9 -3
package/dist/editor.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Event, defineKey, MatrixHelper, BoundsHelper, LeafBoundsHelper, getMatrixData, getBoundsData, UI, Paint, Group, Rect, Bounds, LeafList, Direction9, AroundHelper, MathHelper, PointHelper, Box, Text, Matrix, Debug, LeafHelper, PropertyEvent,
|
|
1
|
+
import { Event, defineKey, isNull, MatrixHelper, BoundsHelper, LeafBoundsHelper, getMatrixData, getBoundsData, UI, Paint, Group, Rect, Bounds, LeafList, Direction9, AroundHelper, MathHelper, PointHelper, Box, ResizeEvent, Text, Matrix, Debug, LeafHelper, PropertyEvent, DataHelper, RenderEvent, getPointData, Plugin as Plugin$1, Creator, dataType } from '@leafer-ui/draw';
|
|
2
2
|
import { PointerEvent, DragEvent, MoveEvent, ZoomEvent, Plugin, RotateEvent, KeyEvent } from '@leafer-ui/core';
|
|
3
3
|
import '@leafer-in/resize';
|
|
4
4
|
|
|
@@ -112,6 +112,28 @@ function targetAttr(fn) {
|
|
|
112
112
|
});
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
+
function mergeConfigAttr() {
|
|
116
|
+
return (target, key) => {
|
|
117
|
+
defineKey(target, key, {
|
|
118
|
+
get() {
|
|
119
|
+
const { config, element, dragPoint } = this, mergeConfig = Object.assign({}, config);
|
|
120
|
+
if (element && element.editConfig)
|
|
121
|
+
Object.assign(mergeConfig, element.editConfig);
|
|
122
|
+
if (dragPoint) {
|
|
123
|
+
if (dragPoint.editConfig)
|
|
124
|
+
Object.assign(mergeConfig, dragPoint.editConfig);
|
|
125
|
+
if (mergeConfig.editSize === 'font-size')
|
|
126
|
+
mergeConfig.lockRatio = true;
|
|
127
|
+
if (dragPoint.pointType === 'resize-rotate') {
|
|
128
|
+
mergeConfig.around || (mergeConfig.around = 'center');
|
|
129
|
+
isNull(mergeConfig.lockRatio) && (mergeConfig.lockRatio = true);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return this.mergedConfig = mergeConfig;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
}
|
|
115
137
|
|
|
116
138
|
const { abs } = Math;
|
|
117
139
|
const { copy: copy$1, scale } = MatrixHelper;
|
|
@@ -123,6 +145,7 @@ class Stroker extends UI {
|
|
|
123
145
|
constructor() {
|
|
124
146
|
super();
|
|
125
147
|
this.list = [];
|
|
148
|
+
this.visible = 0;
|
|
126
149
|
this.hittable = false;
|
|
127
150
|
this.strokeAlign = 'center';
|
|
128
151
|
}
|
|
@@ -136,10 +159,10 @@ class Stroker extends UI {
|
|
|
136
159
|
if (list.length) {
|
|
137
160
|
setListWithFn(bounds$1, list, worldBounds);
|
|
138
161
|
this.set(bounds$1);
|
|
162
|
+
this.visible = true;
|
|
139
163
|
}
|
|
140
|
-
else
|
|
141
|
-
this.
|
|
142
|
-
}
|
|
164
|
+
else
|
|
165
|
+
this.visible = 0;
|
|
143
166
|
}
|
|
144
167
|
__draw(canvas, options) {
|
|
145
168
|
const { list } = this;
|
|
@@ -151,8 +174,9 @@ class Stroker extends UI {
|
|
|
151
174
|
const { worldTransform, worldRenderBounds } = leaf;
|
|
152
175
|
if (worldRenderBounds.width && worldRenderBounds.height && (!bounds || bounds.hit(worldRenderBounds, options.matrix))) {
|
|
153
176
|
const aScaleX = abs(worldTransform.scaleX), aScaleY = abs(worldTransform.scaleY);
|
|
177
|
+
copy$1(matrix, worldTransform);
|
|
178
|
+
matrix.half = strokeWidth % 2;
|
|
154
179
|
if (aScaleX !== aScaleY) {
|
|
155
|
-
copy$1(matrix, worldTransform);
|
|
156
180
|
scale(matrix, 1 / aScaleX, 1 / aScaleY);
|
|
157
181
|
canvas.setWorld(matrix, options.matrix);
|
|
158
182
|
canvas.beginPath();
|
|
@@ -161,7 +185,7 @@ class Stroker extends UI {
|
|
|
161
185
|
canvas.rect(x * aScaleX, y * aScaleY, width * aScaleX, height * aScaleY);
|
|
162
186
|
}
|
|
163
187
|
else {
|
|
164
|
-
canvas.setWorld(
|
|
188
|
+
canvas.setWorld(matrix, options.matrix);
|
|
165
189
|
canvas.beginPath();
|
|
166
190
|
if (leaf.__.__useArrow)
|
|
167
191
|
leaf.__drawPath(canvas);
|
|
@@ -196,7 +220,8 @@ class SelectArea extends Group {
|
|
|
196
220
|
super(data);
|
|
197
221
|
this.strokeArea = new Rect({ strokeAlign: 'center' });
|
|
198
222
|
this.fillArea = new Rect();
|
|
199
|
-
this.visible =
|
|
223
|
+
this.visible = 0;
|
|
224
|
+
this.hittable = false;
|
|
200
225
|
this.addMany(this.fillArea, this.strokeArea);
|
|
201
226
|
}
|
|
202
227
|
setStyle(style, userStyle) {
|
|
@@ -393,7 +418,7 @@ class EditSelect extends Group {
|
|
|
393
418
|
if (e.multiTouch)
|
|
394
419
|
return;
|
|
395
420
|
if (this.dragging)
|
|
396
|
-
this.originList = null, this.selectArea.visible =
|
|
421
|
+
this.originList = null, this.selectArea.visible = 0;
|
|
397
422
|
}
|
|
398
423
|
onAutoMove(e) {
|
|
399
424
|
if (this.dragging) {
|
|
@@ -541,8 +566,11 @@ const EditDataHelper = {
|
|
|
541
566
|
scaleY = scaleY < 0 ? -scale : scale;
|
|
542
567
|
}
|
|
543
568
|
}
|
|
544
|
-
scaleX
|
|
545
|
-
|
|
569
|
+
const useScaleX = scaleX !== 1, useScaleY = scaleY !== 1;
|
|
570
|
+
if (useScaleX)
|
|
571
|
+
scaleX /= changedScaleX;
|
|
572
|
+
if (useScaleY)
|
|
573
|
+
scaleY /= changedScaleY;
|
|
546
574
|
if (!flipable) {
|
|
547
575
|
const { worldTransform } = element;
|
|
548
576
|
if (scaleX < 0)
|
|
@@ -557,22 +585,27 @@ const EditDataHelper = {
|
|
|
557
585
|
localBounds.scaleOf(element.getLocalPointByInner(origin), scaleX, scaleY);
|
|
558
586
|
if (!BoundsHelper.includes(allowBounds, localBounds)) {
|
|
559
587
|
const realBounds = localBounds.getIntersect(allowBounds);
|
|
560
|
-
|
|
561
|
-
|
|
588
|
+
const fitScaleX = realBounds.width / localBounds.width, fitScaleY = realBounds.height / localBounds.height;
|
|
589
|
+
if (useScaleX)
|
|
590
|
+
scaleX *= fitScaleX;
|
|
591
|
+
if (useScaleY)
|
|
592
|
+
scaleY *= fitScaleY;
|
|
562
593
|
}
|
|
563
594
|
}
|
|
564
|
-
if (widthRange) {
|
|
595
|
+
if (useScaleX && widthRange) {
|
|
565
596
|
const nowWidth = boxBounds.width * element.scaleX;
|
|
566
597
|
scaleX = within(nowWidth * scaleX, widthRange) / nowWidth;
|
|
567
598
|
}
|
|
568
|
-
if (heightRange) {
|
|
599
|
+
if (useScaleY && heightRange) {
|
|
569
600
|
const nowHeight = boxBounds.height * element.scaleY;
|
|
570
601
|
scaleY = within(nowHeight * scaleY, heightRange) / nowHeight;
|
|
571
602
|
}
|
|
572
|
-
if (Math.abs(scaleX * worldBoxBounds.width) < 1)
|
|
603
|
+
if (useScaleX && Math.abs(scaleX * worldBoxBounds.width) < 1)
|
|
573
604
|
scaleX = (scaleX < 0 ? -1 : 1) / worldBoxBounds.width;
|
|
574
|
-
if (Math.abs(scaleY * worldBoxBounds.height) < 1)
|
|
605
|
+
if (useScaleY && Math.abs(scaleY * worldBoxBounds.height) < 1)
|
|
575
606
|
scaleY = (scaleY < 0 ? -1 : 1) / worldBoxBounds.height;
|
|
607
|
+
if (lockRatio && scaleX !== scaleY)
|
|
608
|
+
scaleY = scaleX = Math.min(scaleX, scaleY);
|
|
576
609
|
return { origin, scaleX, scaleY, direction, lockRatio, around };
|
|
577
610
|
},
|
|
578
611
|
getRotateData(bounds, direction, current, last, around) {
|
|
@@ -743,7 +776,7 @@ class EditBox extends Group {
|
|
|
743
776
|
this.view = new Group();
|
|
744
777
|
this.rect = new Box({ name: 'rect', hitFill: 'all', hitStroke: 'none', strokeAlign: 'center', hitRadius: 5 });
|
|
745
778
|
this.circle = new EditPoint({ name: 'circle', strokeAlign: 'center', around: 'center', cursor: 'crosshair', hitRadius: 5 });
|
|
746
|
-
this.buttons = new Group({ around: 'center', hitSelf: false });
|
|
779
|
+
this.buttons = new Group({ around: 'center', hitSelf: false, visible: 0 });
|
|
747
780
|
this.resizePoints = [];
|
|
748
781
|
this.rotatePoints = [];
|
|
749
782
|
this.resizeLines = [];
|
|
@@ -798,12 +831,13 @@ class EditBox extends Group {
|
|
|
798
831
|
}
|
|
799
832
|
}
|
|
800
833
|
update(bounds) {
|
|
801
|
-
const {
|
|
802
|
-
const {
|
|
834
|
+
const { rect, circle, buttons, resizePoints, rotatePoints, resizeLines, editor } = this;
|
|
835
|
+
const { mergeConfig, element, multiple, editMask } = editor;
|
|
836
|
+
const { middlePoint, resizeable, rotateable, hideOnSmall, editBox, mask } = mergeConfig;
|
|
803
837
|
this.visible = !element.locked;
|
|
838
|
+
editMask.visible = mask ? true : 0;
|
|
804
839
|
if (this.view.worldOpacity) {
|
|
805
840
|
const { width, height } = bounds;
|
|
806
|
-
const { rect, circle, buttons, resizePoints, rotatePoints, resizeLines } = this;
|
|
807
841
|
const smallSize = typeof hideOnSmall === 'number' ? hideOnSmall : 10;
|
|
808
842
|
const showPoints = editBox && !(hideOnSmall && width < smallSize && height < smallSize);
|
|
809
843
|
let point = {}, rotateP, resizeP, resizeL;
|
|
@@ -838,10 +872,12 @@ class EditBox extends Group {
|
|
|
838
872
|
if (rect.path)
|
|
839
873
|
rect.path = null;
|
|
840
874
|
rect.set(Object.assign(Object.assign({}, bounds), { visible: multiple ? true : editBox }));
|
|
841
|
-
buttons.visible = showPoints && buttons.children.length > 0;
|
|
875
|
+
buttons.visible = showPoints && buttons.children.length > 0 || 0;
|
|
842
876
|
if (buttons.visible)
|
|
843
877
|
this.layoutButtons(mergeConfig);
|
|
844
878
|
}
|
|
879
|
+
else
|
|
880
|
+
rect.set(bounds);
|
|
845
881
|
}
|
|
846
882
|
layoutCircle(config) {
|
|
847
883
|
const { circleDirection, circleMargin, buttonsMargin, buttonsDirection, middlePoint } = config;
|
|
@@ -904,7 +940,7 @@ class EditBox extends Group {
|
|
|
904
940
|
}
|
|
905
941
|
onDragStart(e) {
|
|
906
942
|
this.dragging = true;
|
|
907
|
-
const point = this.dragPoint = e.current;
|
|
943
|
+
const point = this.dragPoint = e.current, { pointType } = point;
|
|
908
944
|
const { editor, dragStartData } = this, { element } = editor;
|
|
909
945
|
if (point.name === 'rect') {
|
|
910
946
|
this.moving = true;
|
|
@@ -915,43 +951,53 @@ class EditBox extends Group {
|
|
|
915
951
|
dragStartData.point = { x: element.x, y: element.y };
|
|
916
952
|
dragStartData.bounds = Object.assign({}, element.getLayoutBounds('box', 'local'));
|
|
917
953
|
dragStartData.rotation = element.rotation;
|
|
954
|
+
if (pointType && pointType.includes('resize'))
|
|
955
|
+
ResizeEvent.resizingKeys = editor.leafList.keys;
|
|
918
956
|
}
|
|
919
957
|
onDragEnd(e) {
|
|
920
958
|
this.dragging = false;
|
|
921
959
|
this.dragPoint = null;
|
|
922
960
|
this.moving = false;
|
|
923
|
-
|
|
961
|
+
const { name, pointType } = e.current;
|
|
962
|
+
if (name === 'rect')
|
|
924
963
|
this.editor.opacity = 1;
|
|
964
|
+
if (pointType && pointType.includes('resize'))
|
|
965
|
+
ResizeEvent.resizingKeys = null;
|
|
925
966
|
}
|
|
926
967
|
onDrag(e) {
|
|
927
968
|
const { editor } = this;
|
|
928
969
|
const { pointType } = this.enterPoint = e.current;
|
|
929
|
-
if (pointType.includes('rotate') || e.metaKey || e.ctrlKey || !editor.mergeConfig.resizeable)
|
|
970
|
+
if (pointType.includes('rotate') || e.metaKey || e.ctrlKey || !editor.mergeConfig.resizeable) {
|
|
930
971
|
editor.onRotate(e);
|
|
931
|
-
|
|
972
|
+
if (pointType === 'resize-rotate')
|
|
973
|
+
editor.onScale(e);
|
|
974
|
+
}
|
|
975
|
+
else if (pointType === 'resize')
|
|
932
976
|
editor.onScale(e);
|
|
933
977
|
if (pointType === 'skew')
|
|
934
978
|
editor.onSkew(e);
|
|
935
979
|
updateCursor(editor, e);
|
|
936
980
|
}
|
|
937
981
|
onArrow(e) {
|
|
938
|
-
|
|
939
|
-
|
|
982
|
+
const { editor } = this;
|
|
983
|
+
if (editor.editing && editor.mergeConfig.keyEvent) {
|
|
984
|
+
let x = 0, y = 0;
|
|
940
985
|
const distance = e.shiftKey ? 10 : 1;
|
|
941
986
|
switch (e.code) {
|
|
942
987
|
case 'ArrowDown':
|
|
943
|
-
|
|
988
|
+
y = distance;
|
|
944
989
|
break;
|
|
945
990
|
case 'ArrowUp':
|
|
946
|
-
|
|
991
|
+
y = -distance;
|
|
947
992
|
break;
|
|
948
993
|
case 'ArrowLeft':
|
|
949
|
-
|
|
994
|
+
x = -distance;
|
|
950
995
|
break;
|
|
951
996
|
case 'ArrowRight':
|
|
952
|
-
|
|
997
|
+
x = distance;
|
|
953
998
|
}
|
|
954
|
-
|
|
999
|
+
if (x || y)
|
|
1000
|
+
editor.move(x, y);
|
|
955
1001
|
}
|
|
956
1002
|
}
|
|
957
1003
|
onDoubleTap(e) {
|
|
@@ -1017,22 +1063,32 @@ class EditBox extends Group {
|
|
|
1017
1063
|
}
|
|
1018
1064
|
}
|
|
1019
1065
|
|
|
1066
|
+
const bigBounds = { x: 0, y: 0, width: 100000, height: 100000 };
|
|
1020
1067
|
class EditMask extends UI {
|
|
1021
1068
|
constructor(editor) {
|
|
1022
1069
|
super();
|
|
1023
1070
|
this.editor = editor;
|
|
1024
1071
|
this.hittable = false;
|
|
1072
|
+
this.visible = 0;
|
|
1073
|
+
}
|
|
1074
|
+
__updateWorldBounds() {
|
|
1075
|
+
Object.assign(this.__local, bigBounds);
|
|
1076
|
+
Object.assign(this.__world, bigBounds);
|
|
1025
1077
|
}
|
|
1026
1078
|
__draw(canvas, options) {
|
|
1027
|
-
const { editor } = this;
|
|
1028
|
-
|
|
1029
|
-
if (mask && editor.list.length) {
|
|
1030
|
-
const { rect } = editor.editBox;
|
|
1031
|
-
const { width, height } = rect.__;
|
|
1032
|
-
canvas.resetTransform();
|
|
1079
|
+
const { editor } = this, { mask } = editor.mergedConfig;
|
|
1080
|
+
if (mask && editor.editing) {
|
|
1033
1081
|
canvas.fillWorld(canvas.bounds, mask === true ? 'rgba(0,0,0,0.8)' : mask);
|
|
1034
|
-
|
|
1035
|
-
|
|
1082
|
+
if (options.bounds && !options.bounds.hit(editor.editBox.rect.__world, options.matrix))
|
|
1083
|
+
return;
|
|
1084
|
+
canvas.saveBlendMode('destination-out');
|
|
1085
|
+
editor.list.forEach(item => {
|
|
1086
|
+
item.__renderShape(canvas, options);
|
|
1087
|
+
const { __box, parent } = item;
|
|
1088
|
+
if ((item = __box) || ((item = parent) && parent.textBox))
|
|
1089
|
+
item.__renderShape(canvas, options);
|
|
1090
|
+
});
|
|
1091
|
+
canvas.restoreBlendMode();
|
|
1036
1092
|
}
|
|
1037
1093
|
}
|
|
1038
1094
|
destroy() {
|
|
@@ -1335,22 +1391,6 @@ class SimulateElement extends Rect {
|
|
|
1335
1391
|
}
|
|
1336
1392
|
|
|
1337
1393
|
class Editor extends Group {
|
|
1338
|
-
get mergeConfig() {
|
|
1339
|
-
const { config, element, dragPoint } = this, mergeConfig = Object.assign({}, config);
|
|
1340
|
-
if (element && element.editConfig)
|
|
1341
|
-
Object.assign(mergeConfig, element.editConfig);
|
|
1342
|
-
if (dragPoint) {
|
|
1343
|
-
if (dragPoint.editConfig)
|
|
1344
|
-
Object.assign(mergeConfig, dragPoint.editConfig);
|
|
1345
|
-
if (mergeConfig.editSize === 'font-size')
|
|
1346
|
-
mergeConfig.lockRatio = true;
|
|
1347
|
-
if (dragPoint.pointType === 'resize-rotate') {
|
|
1348
|
-
mergeConfig.around || (mergeConfig.around = 'center');
|
|
1349
|
-
isNull(mergeConfig.lockRatio) && (mergeConfig.lockRatio = true);
|
|
1350
|
-
}
|
|
1351
|
-
}
|
|
1352
|
-
return mergeConfig;
|
|
1353
|
-
}
|
|
1354
1394
|
get list() { return this.leafList.list; }
|
|
1355
1395
|
get dragHoverExclude() { return [this.editBox.rect]; }
|
|
1356
1396
|
get editing() { return !!this.list.length; }
|
|
@@ -1364,7 +1404,6 @@ class Editor extends Group {
|
|
|
1364
1404
|
get buttons() { return this.editBox.buttons; }
|
|
1365
1405
|
constructor(userConfig, data) {
|
|
1366
1406
|
super(data);
|
|
1367
|
-
this.config = DataHelper.clone(config);
|
|
1368
1407
|
this.leafList = new LeafList();
|
|
1369
1408
|
this.openedGroupList = new LeafList();
|
|
1370
1409
|
this.simulateTarget = new SimulateElement(this);
|
|
@@ -1373,8 +1412,10 @@ class Editor extends Group {
|
|
|
1373
1412
|
this.selector = new EditSelect(this);
|
|
1374
1413
|
this.editMask = new EditMask(this);
|
|
1375
1414
|
this.targetEventIds = [];
|
|
1415
|
+
let mergedConfig = DataHelper.clone(config);
|
|
1376
1416
|
if (userConfig)
|
|
1377
|
-
|
|
1417
|
+
mergedConfig = DataHelper.default(userConfig, mergedConfig);
|
|
1418
|
+
this.mergedConfig = this.config = mergedConfig;
|
|
1378
1419
|
this.addMany(this.editMask, this.selector, this.editBox);
|
|
1379
1420
|
if (!Plugin.has('resize'))
|
|
1380
1421
|
this.config.editSize = 'scale';
|
|
@@ -1714,8 +1755,7 @@ class Editor extends Group {
|
|
|
1714
1755
|
}
|
|
1715
1756
|
}
|
|
1716
1757
|
emitInnerEvent(type) {
|
|
1717
|
-
const { innerEditor } = this;
|
|
1718
|
-
const { editTarget } = innerEditor;
|
|
1758
|
+
const { innerEditor } = this, { editTarget } = innerEditor;
|
|
1719
1759
|
const event = new InnerEditorEvent(type, { editTarget, innerEditor });
|
|
1720
1760
|
this.emitEvent(event);
|
|
1721
1761
|
editTarget.emitEvent(event);
|
|
@@ -1740,25 +1780,40 @@ class Editor extends Group {
|
|
|
1740
1780
|
this.leafList.update();
|
|
1741
1781
|
}
|
|
1742
1782
|
}
|
|
1783
|
+
onAppRenderStart(app) {
|
|
1784
|
+
if (this.targetChanged = app.children.some(leafer => leafer !== this.leafer && leafer.renderer.changed))
|
|
1785
|
+
this.editBox.forceRender();
|
|
1786
|
+
}
|
|
1787
|
+
onRenderStart() {
|
|
1788
|
+
if (this.targetChanged)
|
|
1789
|
+
this.update();
|
|
1790
|
+
}
|
|
1791
|
+
onKey(e) {
|
|
1792
|
+
updateCursor(this, e);
|
|
1793
|
+
}
|
|
1743
1794
|
listenTargetEvents() {
|
|
1744
1795
|
if (!this.targetEventIds.length) {
|
|
1745
|
-
const { app, leafer } = this;
|
|
1796
|
+
const { app, leafer, editBox, editMask } = this;
|
|
1746
1797
|
this.targetEventIds = [
|
|
1747
|
-
leafer.on_(RenderEvent.START, this.
|
|
1748
|
-
app.on_(RenderEvent.CHILD_START, this.
|
|
1798
|
+
leafer.on_(RenderEvent.START, this.onRenderStart, this),
|
|
1799
|
+
app.on_(RenderEvent.CHILD_START, this.onAppRenderStart, this),
|
|
1749
1800
|
app.on_(MoveEvent.BEFORE_MOVE, this.onMove, this, true),
|
|
1750
1801
|
app.on_(ZoomEvent.BEFORE_ZOOM, this.onScale, this, true),
|
|
1751
1802
|
app.on_(RotateEvent.BEFORE_ROTATE, this.onRotate, this, true),
|
|
1752
|
-
app.on_([KeyEvent.HOLD, KeyEvent.UP],
|
|
1753
|
-
app.on_(KeyEvent.DOWN,
|
|
1803
|
+
app.on_([KeyEvent.HOLD, KeyEvent.UP], this.onKey, this),
|
|
1804
|
+
app.on_(KeyEvent.DOWN, editBox.onArrow, editBox)
|
|
1754
1805
|
];
|
|
1806
|
+
if (editMask.visible)
|
|
1807
|
+
editMask.forceRender();
|
|
1755
1808
|
}
|
|
1756
1809
|
}
|
|
1757
1810
|
removeTargetEvents() {
|
|
1758
|
-
const { targetEventIds } = this;
|
|
1811
|
+
const { targetEventIds, editMask } = this;
|
|
1759
1812
|
if (targetEventIds.length) {
|
|
1760
1813
|
this.off_(targetEventIds);
|
|
1761
1814
|
targetEventIds.length = 0;
|
|
1815
|
+
if (editMask.visible)
|
|
1816
|
+
editMask.forceRender();
|
|
1762
1817
|
}
|
|
1763
1818
|
}
|
|
1764
1819
|
destroy() {
|
|
@@ -1772,6 +1827,9 @@ class Editor extends Group {
|
|
|
1772
1827
|
}
|
|
1773
1828
|
}
|
|
1774
1829
|
}
|
|
1830
|
+
__decorate([
|
|
1831
|
+
mergeConfigAttr()
|
|
1832
|
+
], Editor.prototype, "mergeConfig", void 0);
|
|
1775
1833
|
__decorate([
|
|
1776
1834
|
targetAttr(onHover)
|
|
1777
1835
|
], Editor.prototype, "hoverTarget", void 0);
|
|
@@ -1836,9 +1894,7 @@ let EditTool = class EditTool extends InnerEditor {
|
|
|
1836
1894
|
const { moveX, moveY, editor } = e;
|
|
1837
1895
|
const { app, list } = editor;
|
|
1838
1896
|
app.lockLayout();
|
|
1839
|
-
list.forEach(target => {
|
|
1840
|
-
target.moveWorld(moveX, moveY);
|
|
1841
|
-
});
|
|
1897
|
+
list.forEach(target => { target.moveWorld(moveX, moveY); });
|
|
1842
1898
|
app.unlockLayout();
|
|
1843
1899
|
}
|
|
1844
1900
|
onScale(e) {
|
|
@@ -1847,12 +1903,10 @@ let EditTool = class EditTool extends InnerEditor {
|
|
|
1847
1903
|
app.lockLayout();
|
|
1848
1904
|
list.forEach(target => {
|
|
1849
1905
|
const resize = editor.getEditSize(target) !== 'scale';
|
|
1850
|
-
if (transform)
|
|
1906
|
+
if (transform)
|
|
1851
1907
|
target.transformWorld(transform, resize);
|
|
1852
|
-
|
|
1853
|
-
else {
|
|
1908
|
+
else
|
|
1854
1909
|
target.scaleOfWorld(worldOrigin, scaleX, scaleY, resize);
|
|
1855
|
-
}
|
|
1856
1910
|
});
|
|
1857
1911
|
app.unlockLayout();
|
|
1858
1912
|
}
|
|
@@ -1862,12 +1916,10 @@ let EditTool = class EditTool extends InnerEditor {
|
|
|
1862
1916
|
app.lockLayout();
|
|
1863
1917
|
list.forEach(target => {
|
|
1864
1918
|
const resize = editor.getEditSize(target) !== 'scale';
|
|
1865
|
-
if (transform)
|
|
1919
|
+
if (transform)
|
|
1866
1920
|
target.transformWorld(transform, resize);
|
|
1867
|
-
|
|
1868
|
-
else {
|
|
1921
|
+
else
|
|
1869
1922
|
target.rotateOfWorld(worldOrigin, rotation);
|
|
1870
|
-
}
|
|
1871
1923
|
});
|
|
1872
1924
|
app.unlockLayout();
|
|
1873
1925
|
}
|
|
@@ -1877,12 +1929,10 @@ let EditTool = class EditTool extends InnerEditor {
|
|
|
1877
1929
|
app.lockLayout();
|
|
1878
1930
|
list.forEach(target => {
|
|
1879
1931
|
const resize = editor.getEditSize(target) !== 'scale';
|
|
1880
|
-
if (transform)
|
|
1932
|
+
if (transform)
|
|
1881
1933
|
target.transformWorld(transform, resize);
|
|
1882
|
-
|
|
1883
|
-
else {
|
|
1934
|
+
else
|
|
1884
1935
|
target.skewOfWorld(worldOrigin, skewX, skewY, resize);
|
|
1885
|
-
}
|
|
1886
1936
|
});
|
|
1887
1937
|
app.unlockLayout();
|
|
1888
1938
|
}
|