@leafer-in/editor 1.5.2 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editor.cjs +149 -91
- package/dist/editor.cjs.map +1 -1
- package/dist/editor.esm.js +150 -92
- 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 +149 -91
- 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 +45 -6
- 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/editor/target.ts +2 -11
- package/src/helper/EditDataHelper.ts +12 -9
- package/src/tool/EditTool.ts +7 -18
- package/types/index.d.ts +9 -3
package/dist/editor.js
CHANGED
|
@@ -88,15 +88,52 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
88
88
|
set(value) {
|
|
89
89
|
const old = this[privateKey];
|
|
90
90
|
if (old !== value) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
if (this.config) {
|
|
92
|
+
const isSelect = key === 'target';
|
|
93
|
+
if (isSelect) {
|
|
94
|
+
if (value instanceof Array && value.length > 1 && value[0].locked)
|
|
95
|
+
value.splice(0, 1);
|
|
96
|
+
const { beforeSelect } = this.config;
|
|
97
|
+
if (beforeSelect) {
|
|
98
|
+
const check = beforeSelect({ target: value });
|
|
99
|
+
if (typeof check === 'object')
|
|
100
|
+
value = check;
|
|
101
|
+
else if (check === false)
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const type = isSelect ? EditorEvent.BEFORE_SELECT : EditorEvent.BEFORE_HOVER;
|
|
106
|
+
if (this.hasEvent(type))
|
|
107
|
+
this.emitEvent(new EditorEvent(type, { editor: this, value: value, oldValue: old }));
|
|
108
|
+
}
|
|
94
109
|
this[privateKey] = value, fn(this, old);
|
|
95
110
|
}
|
|
96
111
|
}
|
|
97
112
|
});
|
|
98
113
|
};
|
|
99
114
|
}
|
|
115
|
+
function mergeConfigAttr() {
|
|
116
|
+
return (target, key) => {
|
|
117
|
+
draw.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
|
+
draw.isNull(mergeConfig.lockRatio) && (mergeConfig.lockRatio = true);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return this.mergedConfig = mergeConfig;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
}
|
|
100
137
|
|
|
101
138
|
const { abs } = Math;
|
|
102
139
|
const { copy: copy$1, scale } = draw.MatrixHelper;
|
|
@@ -108,6 +145,7 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
108
145
|
constructor() {
|
|
109
146
|
super();
|
|
110
147
|
this.list = [];
|
|
148
|
+
this.visible = 0;
|
|
111
149
|
this.hittable = false;
|
|
112
150
|
this.strokeAlign = 'center';
|
|
113
151
|
}
|
|
@@ -121,10 +159,10 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
121
159
|
if (list.length) {
|
|
122
160
|
setListWithFn(bounds$1, list, worldBounds);
|
|
123
161
|
this.set(bounds$1);
|
|
162
|
+
this.visible = true;
|
|
124
163
|
}
|
|
125
|
-
else
|
|
126
|
-
this.
|
|
127
|
-
}
|
|
164
|
+
else
|
|
165
|
+
this.visible = 0;
|
|
128
166
|
}
|
|
129
167
|
__draw(canvas, options) {
|
|
130
168
|
const { list } = this;
|
|
@@ -136,8 +174,9 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
136
174
|
const { worldTransform, worldRenderBounds } = leaf;
|
|
137
175
|
if (worldRenderBounds.width && worldRenderBounds.height && (!bounds || bounds.hit(worldRenderBounds, options.matrix))) {
|
|
138
176
|
const aScaleX = abs(worldTransform.scaleX), aScaleY = abs(worldTransform.scaleY);
|
|
177
|
+
copy$1(matrix, worldTransform);
|
|
178
|
+
matrix.half = strokeWidth % 2;
|
|
139
179
|
if (aScaleX !== aScaleY) {
|
|
140
|
-
copy$1(matrix, worldTransform);
|
|
141
180
|
scale(matrix, 1 / aScaleX, 1 / aScaleY);
|
|
142
181
|
canvas.setWorld(matrix, options.matrix);
|
|
143
182
|
canvas.beginPath();
|
|
@@ -146,7 +185,7 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
146
185
|
canvas.rect(x * aScaleX, y * aScaleY, width * aScaleX, height * aScaleY);
|
|
147
186
|
}
|
|
148
187
|
else {
|
|
149
|
-
canvas.setWorld(
|
|
188
|
+
canvas.setWorld(matrix, options.matrix);
|
|
150
189
|
canvas.beginPath();
|
|
151
190
|
if (leaf.__.__useArrow)
|
|
152
191
|
leaf.__drawPath(canvas);
|
|
@@ -181,7 +220,8 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
181
220
|
super(data);
|
|
182
221
|
this.strokeArea = new draw.Rect({ strokeAlign: 'center' });
|
|
183
222
|
this.fillArea = new draw.Rect();
|
|
184
|
-
this.visible =
|
|
223
|
+
this.visible = 0;
|
|
224
|
+
this.hittable = false;
|
|
185
225
|
this.addMany(this.fillArea, this.strokeArea);
|
|
186
226
|
}
|
|
187
227
|
setStyle(style, userStyle) {
|
|
@@ -378,7 +418,7 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
378
418
|
if (e.multiTouch)
|
|
379
419
|
return;
|
|
380
420
|
if (this.dragging)
|
|
381
|
-
this.originList = null, this.selectArea.visible =
|
|
421
|
+
this.originList = null, this.selectArea.visible = 0;
|
|
382
422
|
}
|
|
383
423
|
onAutoMove(e) {
|
|
384
424
|
if (this.dragging) {
|
|
@@ -526,8 +566,11 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
526
566
|
scaleY = scaleY < 0 ? -scale : scale;
|
|
527
567
|
}
|
|
528
568
|
}
|
|
529
|
-
scaleX
|
|
530
|
-
|
|
569
|
+
const useScaleX = scaleX !== 1, useScaleY = scaleY !== 1;
|
|
570
|
+
if (useScaleX)
|
|
571
|
+
scaleX /= changedScaleX;
|
|
572
|
+
if (useScaleY)
|
|
573
|
+
scaleY /= changedScaleY;
|
|
531
574
|
if (!flipable) {
|
|
532
575
|
const { worldTransform } = element;
|
|
533
576
|
if (scaleX < 0)
|
|
@@ -542,22 +585,27 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
542
585
|
localBounds.scaleOf(element.getLocalPointByInner(origin), scaleX, scaleY);
|
|
543
586
|
if (!draw.BoundsHelper.includes(allowBounds, localBounds)) {
|
|
544
587
|
const realBounds = localBounds.getIntersect(allowBounds);
|
|
545
|
-
|
|
546
|
-
|
|
588
|
+
const fitScaleX = realBounds.width / localBounds.width, fitScaleY = realBounds.height / localBounds.height;
|
|
589
|
+
if (useScaleX)
|
|
590
|
+
scaleX *= fitScaleX;
|
|
591
|
+
if (useScaleY)
|
|
592
|
+
scaleY *= fitScaleY;
|
|
547
593
|
}
|
|
548
594
|
}
|
|
549
|
-
if (widthRange) {
|
|
595
|
+
if (useScaleX && widthRange) {
|
|
550
596
|
const nowWidth = boxBounds.width * element.scaleX;
|
|
551
597
|
scaleX = within(nowWidth * scaleX, widthRange) / nowWidth;
|
|
552
598
|
}
|
|
553
|
-
if (heightRange) {
|
|
599
|
+
if (useScaleY && heightRange) {
|
|
554
600
|
const nowHeight = boxBounds.height * element.scaleY;
|
|
555
601
|
scaleY = within(nowHeight * scaleY, heightRange) / nowHeight;
|
|
556
602
|
}
|
|
557
|
-
if (Math.abs(scaleX * worldBoxBounds.width) < 1)
|
|
603
|
+
if (useScaleX && Math.abs(scaleX * worldBoxBounds.width) < 1)
|
|
558
604
|
scaleX = (scaleX < 0 ? -1 : 1) / worldBoxBounds.width;
|
|
559
|
-
if (Math.abs(scaleY * worldBoxBounds.height) < 1)
|
|
605
|
+
if (useScaleY && Math.abs(scaleY * worldBoxBounds.height) < 1)
|
|
560
606
|
scaleY = (scaleY < 0 ? -1 : 1) / worldBoxBounds.height;
|
|
607
|
+
if (lockRatio && scaleX !== scaleY)
|
|
608
|
+
scaleY = scaleX = Math.min(scaleX, scaleY);
|
|
561
609
|
return { origin, scaleX, scaleY, direction, lockRatio, around };
|
|
562
610
|
},
|
|
563
611
|
getRotateData(bounds, direction, current, last, around) {
|
|
@@ -728,7 +776,7 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
728
776
|
this.view = new draw.Group();
|
|
729
777
|
this.rect = new draw.Box({ name: 'rect', hitFill: 'all', hitStroke: 'none', strokeAlign: 'center', hitRadius: 5 });
|
|
730
778
|
this.circle = new EditPoint({ name: 'circle', strokeAlign: 'center', around: 'center', cursor: 'crosshair', hitRadius: 5 });
|
|
731
|
-
this.buttons = new draw.Group({ around: 'center', hitSelf: false });
|
|
779
|
+
this.buttons = new draw.Group({ around: 'center', hitSelf: false, visible: 0 });
|
|
732
780
|
this.resizePoints = [];
|
|
733
781
|
this.rotatePoints = [];
|
|
734
782
|
this.resizeLines = [];
|
|
@@ -783,12 +831,13 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
783
831
|
}
|
|
784
832
|
}
|
|
785
833
|
update(bounds) {
|
|
786
|
-
const {
|
|
787
|
-
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;
|
|
788
837
|
this.visible = !element.locked;
|
|
838
|
+
editMask.visible = mask ? true : 0;
|
|
789
839
|
if (this.view.worldOpacity) {
|
|
790
840
|
const { width, height } = bounds;
|
|
791
|
-
const { rect, circle, buttons, resizePoints, rotatePoints, resizeLines } = this;
|
|
792
841
|
const smallSize = typeof hideOnSmall === 'number' ? hideOnSmall : 10;
|
|
793
842
|
const showPoints = editBox && !(hideOnSmall && width < smallSize && height < smallSize);
|
|
794
843
|
let point = {}, rotateP, resizeP, resizeL;
|
|
@@ -823,10 +872,12 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
823
872
|
if (rect.path)
|
|
824
873
|
rect.path = null;
|
|
825
874
|
rect.set(Object.assign(Object.assign({}, bounds), { visible: multiple ? true : editBox }));
|
|
826
|
-
buttons.visible = showPoints && buttons.children.length > 0;
|
|
875
|
+
buttons.visible = showPoints && buttons.children.length > 0 || 0;
|
|
827
876
|
if (buttons.visible)
|
|
828
877
|
this.layoutButtons(mergeConfig);
|
|
829
878
|
}
|
|
879
|
+
else
|
|
880
|
+
rect.set(bounds);
|
|
830
881
|
}
|
|
831
882
|
layoutCircle(config) {
|
|
832
883
|
const { circleDirection, circleMargin, buttonsMargin, buttonsDirection, middlePoint } = config;
|
|
@@ -889,7 +940,7 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
889
940
|
}
|
|
890
941
|
onDragStart(e) {
|
|
891
942
|
this.dragging = true;
|
|
892
|
-
const point = this.dragPoint = e.current;
|
|
943
|
+
const point = this.dragPoint = e.current, { pointType } = point;
|
|
893
944
|
const { editor, dragStartData } = this, { element } = editor;
|
|
894
945
|
if (point.name === 'rect') {
|
|
895
946
|
this.moving = true;
|
|
@@ -900,43 +951,53 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
900
951
|
dragStartData.point = { x: element.x, y: element.y };
|
|
901
952
|
dragStartData.bounds = Object.assign({}, element.getLayoutBounds('box', 'local'));
|
|
902
953
|
dragStartData.rotation = element.rotation;
|
|
954
|
+
if (pointType && pointType.includes('resize'))
|
|
955
|
+
draw.ResizeEvent.resizingKeys = editor.leafList.keys;
|
|
903
956
|
}
|
|
904
957
|
onDragEnd(e) {
|
|
905
958
|
this.dragging = false;
|
|
906
959
|
this.dragPoint = null;
|
|
907
960
|
this.moving = false;
|
|
908
|
-
|
|
961
|
+
const { name, pointType } = e.current;
|
|
962
|
+
if (name === 'rect')
|
|
909
963
|
this.editor.opacity = 1;
|
|
964
|
+
if (pointType && pointType.includes('resize'))
|
|
965
|
+
draw.ResizeEvent.resizingKeys = null;
|
|
910
966
|
}
|
|
911
967
|
onDrag(e) {
|
|
912
968
|
const { editor } = this;
|
|
913
969
|
const { pointType } = this.enterPoint = e.current;
|
|
914
|
-
if (pointType.includes('rotate') || e.metaKey || e.ctrlKey || !editor.mergeConfig.resizeable)
|
|
970
|
+
if (pointType.includes('rotate') || e.metaKey || e.ctrlKey || !editor.mergeConfig.resizeable) {
|
|
915
971
|
editor.onRotate(e);
|
|
916
|
-
|
|
972
|
+
if (pointType === 'resize-rotate')
|
|
973
|
+
editor.onScale(e);
|
|
974
|
+
}
|
|
975
|
+
else if (pointType === 'resize')
|
|
917
976
|
editor.onScale(e);
|
|
918
977
|
if (pointType === 'skew')
|
|
919
978
|
editor.onSkew(e);
|
|
920
979
|
updateCursor(editor, e);
|
|
921
980
|
}
|
|
922
981
|
onArrow(e) {
|
|
923
|
-
|
|
924
|
-
|
|
982
|
+
const { editor } = this;
|
|
983
|
+
if (editor.editing && editor.mergeConfig.keyEvent) {
|
|
984
|
+
let x = 0, y = 0;
|
|
925
985
|
const distance = e.shiftKey ? 10 : 1;
|
|
926
986
|
switch (e.code) {
|
|
927
987
|
case 'ArrowDown':
|
|
928
|
-
|
|
988
|
+
y = distance;
|
|
929
989
|
break;
|
|
930
990
|
case 'ArrowUp':
|
|
931
|
-
|
|
991
|
+
y = -distance;
|
|
932
992
|
break;
|
|
933
993
|
case 'ArrowLeft':
|
|
934
|
-
|
|
994
|
+
x = -distance;
|
|
935
995
|
break;
|
|
936
996
|
case 'ArrowRight':
|
|
937
|
-
|
|
997
|
+
x = distance;
|
|
938
998
|
}
|
|
939
|
-
|
|
999
|
+
if (x || y)
|
|
1000
|
+
editor.move(x, y);
|
|
940
1001
|
}
|
|
941
1002
|
}
|
|
942
1003
|
onDoubleTap(e) {
|
|
@@ -1002,22 +1063,32 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
1002
1063
|
}
|
|
1003
1064
|
}
|
|
1004
1065
|
|
|
1066
|
+
const bigBounds = { x: 0, y: 0, width: 100000, height: 100000 };
|
|
1005
1067
|
class EditMask extends draw.UI {
|
|
1006
1068
|
constructor(editor) {
|
|
1007
1069
|
super();
|
|
1008
1070
|
this.editor = editor;
|
|
1009
1071
|
this.hittable = false;
|
|
1072
|
+
this.visible = 0;
|
|
1073
|
+
}
|
|
1074
|
+
__updateWorldBounds() {
|
|
1075
|
+
Object.assign(this.__local, bigBounds);
|
|
1076
|
+
Object.assign(this.__world, bigBounds);
|
|
1010
1077
|
}
|
|
1011
1078
|
__draw(canvas, options) {
|
|
1012
|
-
const { editor } = this;
|
|
1013
|
-
|
|
1014
|
-
if (mask && editor.list.length) {
|
|
1015
|
-
const { rect } = editor.editBox;
|
|
1016
|
-
const { width, height } = rect.__;
|
|
1017
|
-
canvas.resetTransform();
|
|
1079
|
+
const { editor } = this, { mask } = editor.mergedConfig;
|
|
1080
|
+
if (mask && editor.editing) {
|
|
1018
1081
|
canvas.fillWorld(canvas.bounds, mask === true ? 'rgba(0,0,0,0.8)' : mask);
|
|
1019
|
-
|
|
1020
|
-
|
|
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();
|
|
1021
1092
|
}
|
|
1022
1093
|
}
|
|
1023
1094
|
destroy() {
|
|
@@ -1125,11 +1196,7 @@ ${filterStyle}
|
|
|
1125
1196
|
function onTarget(editor, oldValue) {
|
|
1126
1197
|
const { target } = editor;
|
|
1127
1198
|
if (target) {
|
|
1128
|
-
|
|
1129
|
-
if (!list.every(checkEditable)) {
|
|
1130
|
-
editor.target = list.filter(checkEditable);
|
|
1131
|
-
return;
|
|
1132
|
-
}
|
|
1199
|
+
editor.leafList = target instanceof draw.LeafList ? target : new draw.LeafList(target);
|
|
1133
1200
|
if (editor.multiple)
|
|
1134
1201
|
simulate(editor);
|
|
1135
1202
|
}
|
|
@@ -1156,9 +1223,6 @@ ${filterStyle}
|
|
|
1156
1223
|
function onHover(editor, oldValue) {
|
|
1157
1224
|
editor.emitEvent(new EditorEvent(EditorEvent.HOVER, { editor, value: editor.hoverTarget, oldValue }));
|
|
1158
1225
|
}
|
|
1159
|
-
function checkEditable(item) {
|
|
1160
|
-
return item.editable && !item.locked;
|
|
1161
|
-
}
|
|
1162
1226
|
|
|
1163
1227
|
const order = (a, b) => a.parent.children.indexOf(a) - b.parent.children.indexOf(b);
|
|
1164
1228
|
const reverseOrder = (a, b) => b.parent.children.indexOf(b) - a.parent.children.indexOf(a);
|
|
@@ -1327,22 +1391,6 @@ ${filterStyle}
|
|
|
1327
1391
|
}
|
|
1328
1392
|
|
|
1329
1393
|
class Editor extends draw.Group {
|
|
1330
|
-
get mergeConfig() {
|
|
1331
|
-
const { config, element, dragPoint } = this, mergeConfig = Object.assign({}, config);
|
|
1332
|
-
if (element && element.editConfig)
|
|
1333
|
-
Object.assign(mergeConfig, element.editConfig);
|
|
1334
|
-
if (dragPoint) {
|
|
1335
|
-
if (dragPoint.editConfig)
|
|
1336
|
-
Object.assign(mergeConfig, dragPoint.editConfig);
|
|
1337
|
-
if (mergeConfig.editSize === 'font-size')
|
|
1338
|
-
mergeConfig.lockRatio = true;
|
|
1339
|
-
if (dragPoint.pointType === 'resize-rotate') {
|
|
1340
|
-
mergeConfig.around || (mergeConfig.around = 'center');
|
|
1341
|
-
draw.isNull(mergeConfig.lockRatio) && (mergeConfig.lockRatio = true);
|
|
1342
|
-
}
|
|
1343
|
-
}
|
|
1344
|
-
return mergeConfig;
|
|
1345
|
-
}
|
|
1346
1394
|
get list() { return this.leafList.list; }
|
|
1347
1395
|
get dragHoverExclude() { return [this.editBox.rect]; }
|
|
1348
1396
|
get editing() { return !!this.list.length; }
|
|
@@ -1356,7 +1404,6 @@ ${filterStyle}
|
|
|
1356
1404
|
get buttons() { return this.editBox.buttons; }
|
|
1357
1405
|
constructor(userConfig, data) {
|
|
1358
1406
|
super(data);
|
|
1359
|
-
this.config = draw.DataHelper.clone(config);
|
|
1360
1407
|
this.leafList = new draw.LeafList();
|
|
1361
1408
|
this.openedGroupList = new draw.LeafList();
|
|
1362
1409
|
this.simulateTarget = new SimulateElement(this);
|
|
@@ -1365,8 +1412,10 @@ ${filterStyle}
|
|
|
1365
1412
|
this.selector = new EditSelect(this);
|
|
1366
1413
|
this.editMask = new EditMask(this);
|
|
1367
1414
|
this.targetEventIds = [];
|
|
1415
|
+
let mergedConfig = draw.DataHelper.clone(config);
|
|
1368
1416
|
if (userConfig)
|
|
1369
|
-
|
|
1417
|
+
mergedConfig = draw.DataHelper.default(userConfig, mergedConfig);
|
|
1418
|
+
this.mergedConfig = this.config = mergedConfig;
|
|
1370
1419
|
this.addMany(this.editMask, this.selector, this.editBox);
|
|
1371
1420
|
if (!core.Plugin.has('resize'))
|
|
1372
1421
|
this.config.editSize = 'scale';
|
|
@@ -1706,8 +1755,7 @@ ${filterStyle}
|
|
|
1706
1755
|
}
|
|
1707
1756
|
}
|
|
1708
1757
|
emitInnerEvent(type) {
|
|
1709
|
-
const { innerEditor } = this;
|
|
1710
|
-
const { editTarget } = innerEditor;
|
|
1758
|
+
const { innerEditor } = this, { editTarget } = innerEditor;
|
|
1711
1759
|
const event = new InnerEditorEvent(type, { editTarget, innerEditor });
|
|
1712
1760
|
this.emitEvent(event);
|
|
1713
1761
|
editTarget.emitEvent(event);
|
|
@@ -1732,25 +1780,40 @@ ${filterStyle}
|
|
|
1732
1780
|
this.leafList.update();
|
|
1733
1781
|
}
|
|
1734
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
|
+
}
|
|
1735
1794
|
listenTargetEvents() {
|
|
1736
1795
|
if (!this.targetEventIds.length) {
|
|
1737
|
-
const { app, leafer } = this;
|
|
1796
|
+
const { app, leafer, editBox, editMask } = this;
|
|
1738
1797
|
this.targetEventIds = [
|
|
1739
|
-
leafer.on_(draw.RenderEvent.START, this.
|
|
1740
|
-
app.on_(draw.RenderEvent.CHILD_START, this.
|
|
1798
|
+
leafer.on_(draw.RenderEvent.START, this.onRenderStart, this),
|
|
1799
|
+
app.on_(draw.RenderEvent.CHILD_START, this.onAppRenderStart, this),
|
|
1741
1800
|
app.on_(core.MoveEvent.BEFORE_MOVE, this.onMove, this, true),
|
|
1742
1801
|
app.on_(core.ZoomEvent.BEFORE_ZOOM, this.onScale, this, true),
|
|
1743
1802
|
app.on_(core.RotateEvent.BEFORE_ROTATE, this.onRotate, this, true),
|
|
1744
|
-
app.on_([core.KeyEvent.HOLD, core.KeyEvent.UP],
|
|
1745
|
-
app.on_(core.KeyEvent.DOWN,
|
|
1803
|
+
app.on_([core.KeyEvent.HOLD, core.KeyEvent.UP], this.onKey, this),
|
|
1804
|
+
app.on_(core.KeyEvent.DOWN, editBox.onArrow, editBox)
|
|
1746
1805
|
];
|
|
1806
|
+
if (editMask.visible)
|
|
1807
|
+
editMask.forceRender();
|
|
1747
1808
|
}
|
|
1748
1809
|
}
|
|
1749
1810
|
removeTargetEvents() {
|
|
1750
|
-
const { targetEventIds } = this;
|
|
1811
|
+
const { targetEventIds, editMask } = this;
|
|
1751
1812
|
if (targetEventIds.length) {
|
|
1752
1813
|
this.off_(targetEventIds);
|
|
1753
1814
|
targetEventIds.length = 0;
|
|
1815
|
+
if (editMask.visible)
|
|
1816
|
+
editMask.forceRender();
|
|
1754
1817
|
}
|
|
1755
1818
|
}
|
|
1756
1819
|
destroy() {
|
|
@@ -1764,6 +1827,9 @@ ${filterStyle}
|
|
|
1764
1827
|
}
|
|
1765
1828
|
}
|
|
1766
1829
|
}
|
|
1830
|
+
__decorate([
|
|
1831
|
+
mergeConfigAttr()
|
|
1832
|
+
], Editor.prototype, "mergeConfig", void 0);
|
|
1767
1833
|
__decorate([
|
|
1768
1834
|
targetAttr(onHover)
|
|
1769
1835
|
], Editor.prototype, "hoverTarget", void 0);
|
|
@@ -1828,9 +1894,7 @@ ${filterStyle}
|
|
|
1828
1894
|
const { moveX, moveY, editor } = e;
|
|
1829
1895
|
const { app, list } = editor;
|
|
1830
1896
|
app.lockLayout();
|
|
1831
|
-
list.forEach(target => {
|
|
1832
|
-
target.moveWorld(moveX, moveY);
|
|
1833
|
-
});
|
|
1897
|
+
list.forEach(target => { target.moveWorld(moveX, moveY); });
|
|
1834
1898
|
app.unlockLayout();
|
|
1835
1899
|
}
|
|
1836
1900
|
onScale(e) {
|
|
@@ -1839,12 +1903,10 @@ ${filterStyle}
|
|
|
1839
1903
|
app.lockLayout();
|
|
1840
1904
|
list.forEach(target => {
|
|
1841
1905
|
const resize = editor.getEditSize(target) !== 'scale';
|
|
1842
|
-
if (transform)
|
|
1906
|
+
if (transform)
|
|
1843
1907
|
target.transformWorld(transform, resize);
|
|
1844
|
-
|
|
1845
|
-
else {
|
|
1908
|
+
else
|
|
1846
1909
|
target.scaleOfWorld(worldOrigin, scaleX, scaleY, resize);
|
|
1847
|
-
}
|
|
1848
1910
|
});
|
|
1849
1911
|
app.unlockLayout();
|
|
1850
1912
|
}
|
|
@@ -1854,12 +1916,10 @@ ${filterStyle}
|
|
|
1854
1916
|
app.lockLayout();
|
|
1855
1917
|
list.forEach(target => {
|
|
1856
1918
|
const resize = editor.getEditSize(target) !== 'scale';
|
|
1857
|
-
if (transform)
|
|
1919
|
+
if (transform)
|
|
1858
1920
|
target.transformWorld(transform, resize);
|
|
1859
|
-
|
|
1860
|
-
else {
|
|
1921
|
+
else
|
|
1861
1922
|
target.rotateOfWorld(worldOrigin, rotation);
|
|
1862
|
-
}
|
|
1863
1923
|
});
|
|
1864
1924
|
app.unlockLayout();
|
|
1865
1925
|
}
|
|
@@ -1869,12 +1929,10 @@ ${filterStyle}
|
|
|
1869
1929
|
app.lockLayout();
|
|
1870
1930
|
list.forEach(target => {
|
|
1871
1931
|
const resize = editor.getEditSize(target) !== 'scale';
|
|
1872
|
-
if (transform)
|
|
1932
|
+
if (transform)
|
|
1873
1933
|
target.transformWorld(transform, resize);
|
|
1874
|
-
|
|
1875
|
-
else {
|
|
1934
|
+
else
|
|
1876
1935
|
target.skewOfWorld(worldOrigin, skewX, skewY, resize);
|
|
1877
|
-
}
|
|
1878
1936
|
});
|
|
1879
1937
|
app.unlockLayout();
|
|
1880
1938
|
}
|