@leafer-in/editor 1.9.11 → 1.10.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 +61 -19
- package/dist/editor.esm.js +62 -20
- package/dist/editor.esm.min.js +1 -1
- package/dist/editor.esm.min.js.map +1 -1
- package/dist/editor.js +61 -19
- 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 +6 -6
- package/src/Editor.ts +15 -4
- package/src/display/EditBox.ts +29 -22
- package/src/display/Stroker.ts +2 -2
- package/src/helper/EditDataHelper.ts +3 -0
- package/types/index.d.ts +3 -2
package/dist/editor.cjs
CHANGED
|
@@ -176,8 +176,8 @@ class Stroker extends draw.UI {
|
|
|
176
176
|
if (leaf.__.__useArrow) leaf.__drawPath(canvas); else leaf.__.__pathForRender ? leaf.__drawRenderPath(canvas) : leaf.__drawPathByBox(canvas);
|
|
177
177
|
data.strokeWidth = strokeWidth / abs$1(worldTransform.scaleX);
|
|
178
178
|
}
|
|
179
|
-
if (stroke) draw.isString(stroke) ? draw.Paint.stroke(stroke, this, canvas) : draw.Paint.strokes(stroke, this, canvas);
|
|
180
|
-
if (fill) draw.isString(fill) ? draw.Paint.fill(fill, this, canvas) : draw.Paint.fills(fill, this, canvas);
|
|
179
|
+
if (stroke) draw.isString(stroke) ? draw.Paint.stroke(stroke, this, canvas, options) : draw.Paint.strokes(stroke, this, canvas, options);
|
|
180
|
+
if (fill) draw.isString(fill) ? draw.Paint.fill(fill, this, canvas, options) : draw.Paint.fills(fill, this, canvas, options);
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
data.strokeWidth = strokeWidth;
|
|
@@ -595,6 +595,8 @@ const EditDataHelper = {
|
|
|
595
595
|
scaleX = sign(scaleX) * lockScale;
|
|
596
596
|
scaleY = sign(scaleY) * lockScale;
|
|
597
597
|
}
|
|
598
|
+
isFinite(scaleX) || (scaleX = 1);
|
|
599
|
+
isFinite(scaleY) || (scaleY = 1);
|
|
598
600
|
return {
|
|
599
601
|
origin: origin,
|
|
600
602
|
scaleX: scaleX,
|
|
@@ -925,9 +927,10 @@ class EditBox extends draw.Group {
|
|
|
925
927
|
}
|
|
926
928
|
load() {
|
|
927
929
|
const {target: target, mergeConfig: mergeConfig, single: single, rect: rect, circle: circle, resizePoints: resizePoints, resizeLines: resizeLines} = this;
|
|
928
|
-
const {stroke: stroke, strokeWidth: strokeWidth,
|
|
930
|
+
const {stroke: stroke, strokeWidth: strokeWidth, ignorePixelSnap: ignorePixelSnap} = mergeConfig;
|
|
929
931
|
const pointsStyle = this.getPointsStyle();
|
|
930
932
|
const middlePointsStyle = this.getMiddlePointsStyle();
|
|
933
|
+
const resizeLinesStyle = this.getResizeLinesStyle();
|
|
931
934
|
this.visible = !target.locked;
|
|
932
935
|
let resizeP;
|
|
933
936
|
for (let i = 0; i < 8; i++) {
|
|
@@ -937,12 +940,13 @@ class EditBox extends draw.Group {
|
|
|
937
940
|
if (i % 2) resizeLines[(i - 1) / 2].set(Object.assign({
|
|
938
941
|
pointType: "resize",
|
|
939
942
|
rotation: (i - 1) / 2 * 90
|
|
940
|
-
},
|
|
943
|
+
}, resizeLinesStyle[(i - 1) / 2 % resizeLinesStyle.length] || {}));
|
|
941
944
|
}
|
|
942
945
|
circle.set(this.getPointStyle(mergeConfig.circle || mergeConfig.rotatePoint || pointsStyle[0]));
|
|
943
946
|
rect.set(Object.assign({
|
|
944
947
|
stroke: stroke,
|
|
945
948
|
strokeWidth: strokeWidth,
|
|
949
|
+
opacity: 1,
|
|
946
950
|
editConfig: editConfig
|
|
947
951
|
}, mergeConfig.rect || {}));
|
|
948
952
|
const rectThrough = draw.isNull(mergeConfig.rectThrough) ? single : mergeConfig.rectThrough;
|
|
@@ -1067,6 +1071,7 @@ class EditBox extends draw.Group {
|
|
|
1067
1071
|
strokeWidth: strokeWidth,
|
|
1068
1072
|
around: "center",
|
|
1069
1073
|
strokeAlign: "center",
|
|
1074
|
+
opacity: 1,
|
|
1070
1075
|
width: pointSize,
|
|
1071
1076
|
height: pointSize,
|
|
1072
1077
|
cornerRadius: pointRadius,
|
|
@@ -1084,6 +1089,10 @@ class EditBox extends draw.Group {
|
|
|
1084
1089
|
const {middlePoint: middlePoint} = this.mergedConfig;
|
|
1085
1090
|
return draw.isArray(middlePoint) ? middlePoint : middlePoint ? [ middlePoint ] : this.getPointsStyle();
|
|
1086
1091
|
}
|
|
1092
|
+
getResizeLinesStyle() {
|
|
1093
|
+
const {resizeLine: resizeLine} = this.mergedConfig;
|
|
1094
|
+
return draw.isArray(resizeLine) ? resizeLine : [ resizeLine ];
|
|
1095
|
+
}
|
|
1087
1096
|
onDragStart(e) {
|
|
1088
1097
|
this.dragging = true;
|
|
1089
1098
|
const point = this.dragPoint = e.current, {pointType: pointType} = point;
|
|
@@ -1118,7 +1127,7 @@ class EditBox extends draw.Group {
|
|
|
1118
1127
|
this.dragPoint = null;
|
|
1119
1128
|
}
|
|
1120
1129
|
onTransformStart(e) {
|
|
1121
|
-
if (this.moving) this.editor.opacity = this.mergedConfig.hideOnMove ? 0 : 1;
|
|
1130
|
+
if (this.moving || this.gesturing) this.editor.opacity = this.mergedConfig.hideOnMove ? 0 : 1;
|
|
1122
1131
|
if (this.resizing) draw.ResizeEvent.resizingKeys = this.editor.leafList.keys;
|
|
1123
1132
|
const {dragStartData: dragStartData, target: target} = this;
|
|
1124
1133
|
dragStartData.x = e.x;
|
|
@@ -1143,7 +1152,18 @@ class EditBox extends draw.Group {
|
|
|
1143
1152
|
e.stop();
|
|
1144
1153
|
if (draw.isString(this.mergedConfig.moveable)) {
|
|
1145
1154
|
this.gesturing = this.moving = true;
|
|
1146
|
-
e.type
|
|
1155
|
+
switch (e.type) {
|
|
1156
|
+
case core.MoveEvent.START:
|
|
1157
|
+
this.onTransformStart(e);
|
|
1158
|
+
break;
|
|
1159
|
+
|
|
1160
|
+
case core.MoveEvent.END:
|
|
1161
|
+
this.onTransformEnd(e);
|
|
1162
|
+
break;
|
|
1163
|
+
|
|
1164
|
+
default:
|
|
1165
|
+
this.transformTool.onMove(e);
|
|
1166
|
+
}
|
|
1147
1167
|
}
|
|
1148
1168
|
}
|
|
1149
1169
|
}
|
|
@@ -1152,7 +1172,18 @@ class EditBox extends draw.Group {
|
|
|
1152
1172
|
e.stop();
|
|
1153
1173
|
if (draw.isString(this.mergedConfig.resizeable)) {
|
|
1154
1174
|
this.gesturing = this.resizing = true;
|
|
1155
|
-
e.type
|
|
1175
|
+
switch (e.type) {
|
|
1176
|
+
case core.ZoomEvent.START:
|
|
1177
|
+
this.onTransformStart(e);
|
|
1178
|
+
break;
|
|
1179
|
+
|
|
1180
|
+
case core.ZoomEvent.END:
|
|
1181
|
+
this.onTransformEnd(e);
|
|
1182
|
+
break;
|
|
1183
|
+
|
|
1184
|
+
default:
|
|
1185
|
+
this.transformTool.onScale(e);
|
|
1186
|
+
}
|
|
1156
1187
|
}
|
|
1157
1188
|
}
|
|
1158
1189
|
}
|
|
@@ -1161,16 +1192,21 @@ class EditBox extends draw.Group {
|
|
|
1161
1192
|
e.stop();
|
|
1162
1193
|
if (draw.isString(this.mergedConfig.rotateable)) {
|
|
1163
1194
|
this.gesturing = this.rotating = true;
|
|
1164
|
-
e.type
|
|
1195
|
+
switch (e.type) {
|
|
1196
|
+
case core.ZoomEvent.START:
|
|
1197
|
+
this.onTransformStart(e);
|
|
1198
|
+
break;
|
|
1199
|
+
|
|
1200
|
+
case core.ZoomEvent.END:
|
|
1201
|
+
this.onTransformEnd(e);
|
|
1202
|
+
break;
|
|
1203
|
+
|
|
1204
|
+
default:
|
|
1205
|
+
this.transformTool.onRotate(e);
|
|
1206
|
+
}
|
|
1165
1207
|
}
|
|
1166
1208
|
}
|
|
1167
1209
|
}
|
|
1168
|
-
onGestureStart(e) {
|
|
1169
|
-
if (this.canGesture && e.moveType !== "drag") this.onTransformStart(e);
|
|
1170
|
-
}
|
|
1171
|
-
onGestureEnd(e) {
|
|
1172
|
-
if (this.canGesture && e.moveType !== "drag") this.onTransformEnd(e);
|
|
1173
|
-
}
|
|
1174
1210
|
isHoldRotateKey(e) {
|
|
1175
1211
|
const {rotateKey: rotateKey} = this.mergedConfig;
|
|
1176
1212
|
if (rotateKey) return e.isHoldKeys(rotateKey);
|
|
@@ -1240,7 +1276,7 @@ class EditBox extends draw.Group {
|
|
|
1240
1276
|
const {rect: rect, editor: editor, __eventIds: events} = this;
|
|
1241
1277
|
events.push(rect.on_([ [ core.PointerEvent.DOUBLE_TAP, this.onDoubleTap, this ], [ core.PointerEvent.LONG_PRESS, this.onLongPress, this ] ]));
|
|
1242
1278
|
this.waitLeafer(() => {
|
|
1243
|
-
events.push(editor.app.on_([ [ [ core.KeyEvent.HOLD, core.KeyEvent.UP ], this.onKey, this ], [ core.KeyEvent.DOWN, this.onArrow, this ], [ core.MoveEvent.
|
|
1279
|
+
events.push(editor.app.on_([ [ [ core.KeyEvent.HOLD, core.KeyEvent.UP ], this.onKey, this ], [ core.KeyEvent.DOWN, this.onArrow, this ], [ [ core.MoveEvent.START, core.MoveEvent.BEFORE_MOVE, core.MoveEvent.END ], this.onMove, this, true ], [ [ core.ZoomEvent.START, core.ZoomEvent.BEFORE_ZOOM, core.ZoomEvent.END ], this.onScale, this, true ], [ [ core.RotateEvent.START, core.RotateEvent.BEFORE_ROTATE, core.RotateEvent.END ], this.onRotate, this, true ] ]));
|
|
1244
1280
|
});
|
|
1245
1281
|
}
|
|
1246
1282
|
__removeListenEvents() {
|
|
@@ -1993,6 +2029,9 @@ exports.Editor = class Editor extends draw.Group {
|
|
|
1993
2029
|
if (this.multiple) simulate(this);
|
|
1994
2030
|
this.update();
|
|
1995
2031
|
}
|
|
2032
|
+
getEditTool(name) {
|
|
2033
|
+
return this.editToolList[name] = this.editToolList[name] || EditToolCreator.get(name, this);
|
|
2034
|
+
}
|
|
1996
2035
|
updateEditTool() {
|
|
1997
2036
|
this.unloadEditTool();
|
|
1998
2037
|
if (this.editing) {
|
|
@@ -2007,7 +2046,7 @@ exports.Editor = class Editor extends draw.Group {
|
|
|
2007
2046
|
if (draw.isString(check)) name = check; else if (check === false) return;
|
|
2008
2047
|
}
|
|
2009
2048
|
if (EditToolCreator.list[name]) {
|
|
2010
|
-
const tool = this.editTool = this.
|
|
2049
|
+
const tool = this.editTool = this.getEditTool(name);
|
|
2011
2050
|
this.editBox.load();
|
|
2012
2051
|
tool.load();
|
|
2013
2052
|
this.update();
|
|
@@ -2096,9 +2135,12 @@ exports.Editor = class Editor extends draw.Group {
|
|
|
2096
2135
|
const event = new EditorGroupEvent(type, {
|
|
2097
2136
|
editTarget: group
|
|
2098
2137
|
});
|
|
2099
|
-
|
|
2138
|
+
this.emitEvent(event);
|
|
2100
2139
|
if (group) group.emitEvent(event);
|
|
2101
2140
|
}
|
|
2141
|
+
getInnerEditor(name) {
|
|
2142
|
+
return this.editToolList[name] = this.editToolList[name] || EditToolCreator.get(name, this);
|
|
2143
|
+
}
|
|
2102
2144
|
openInnerEditor(target, nameOrSelect, select) {
|
|
2103
2145
|
let name;
|
|
2104
2146
|
if (draw.isString(nameOrSelect)) name = nameOrSelect; else if (!select) select = nameOrSelect;
|
|
@@ -2117,7 +2159,7 @@ exports.Editor = class Editor extends draw.Group {
|
|
|
2117
2159
|
if (EditToolCreator.list[name]) {
|
|
2118
2160
|
this.editTool.unload();
|
|
2119
2161
|
this.innerEditing = true;
|
|
2120
|
-
this.innerEditor = this.
|
|
2162
|
+
this.innerEditor = this.getInnerEditor(name);
|
|
2121
2163
|
this.innerEditor.editTarget = target;
|
|
2122
2164
|
this.emitInnerEvent(InnerEditorEvent.BEFORE_OPEN);
|
|
2123
2165
|
this.innerEditor.load();
|
|
@@ -2141,7 +2183,7 @@ exports.Editor = class Editor extends draw.Group {
|
|
|
2141
2183
|
editTarget: editTarget,
|
|
2142
2184
|
innerEditor: innerEditor
|
|
2143
2185
|
});
|
|
2144
|
-
|
|
2186
|
+
this.emitEvent(event);
|
|
2145
2187
|
editTarget.emitEvent(event);
|
|
2146
2188
|
}
|
|
2147
2189
|
lock() {
|
package/dist/editor.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Event, isArray, defineKey, isNull, isUndefined, isObject, MatrixHelper, BoundsHelper, LeafBoundsHelper, getMatrixData, getBoundsData, UI, isString, Paint, Group, Rect, Bounds, LeafList, Direction9, AroundHelper, MathHelper, PointHelper, isNumber, Box, DataHelper, ResizeEvent, getPointData, Text, Matrix, Debug, LeafHelper, PropertyEvent, Plugin, RenderEvent, LeaferEvent, Creator, dataType } from "@leafer-ui/draw";
|
|
2
2
|
|
|
3
|
-
import { PointerEvent, DragEvent, MoveEvent, ZoomEvent, DragBoundsHelper,
|
|
3
|
+
import { PointerEvent, DragEvent, MoveEvent, ZoomEvent, DragBoundsHelper, KeyEvent, RotateEvent, useModule } from "@leafer-ui/core";
|
|
4
4
|
|
|
5
5
|
import "@leafer-in/resize";
|
|
6
6
|
|
|
@@ -174,8 +174,8 @@ class Stroker extends UI {
|
|
|
174
174
|
if (leaf.__.__useArrow) leaf.__drawPath(canvas); else leaf.__.__pathForRender ? leaf.__drawRenderPath(canvas) : leaf.__drawPathByBox(canvas);
|
|
175
175
|
data.strokeWidth = strokeWidth / abs$1(worldTransform.scaleX);
|
|
176
176
|
}
|
|
177
|
-
if (stroke) isString(stroke) ? Paint.stroke(stroke, this, canvas) : Paint.strokes(stroke, this, canvas);
|
|
178
|
-
if (fill) isString(fill) ? Paint.fill(fill, this, canvas) : Paint.fills(fill, this, canvas);
|
|
177
|
+
if (stroke) isString(stroke) ? Paint.stroke(stroke, this, canvas, options) : Paint.strokes(stroke, this, canvas, options);
|
|
178
|
+
if (fill) isString(fill) ? Paint.fill(fill, this, canvas, options) : Paint.fills(fill, this, canvas, options);
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
data.strokeWidth = strokeWidth;
|
|
@@ -593,6 +593,8 @@ const EditDataHelper = {
|
|
|
593
593
|
scaleX = sign(scaleX) * lockScale;
|
|
594
594
|
scaleY = sign(scaleY) * lockScale;
|
|
595
595
|
}
|
|
596
|
+
isFinite(scaleX) || (scaleX = 1);
|
|
597
|
+
isFinite(scaleY) || (scaleY = 1);
|
|
596
598
|
return {
|
|
597
599
|
origin: origin,
|
|
598
600
|
scaleX: scaleX,
|
|
@@ -923,9 +925,10 @@ class EditBox extends Group {
|
|
|
923
925
|
}
|
|
924
926
|
load() {
|
|
925
927
|
const {target: target, mergeConfig: mergeConfig, single: single, rect: rect, circle: circle, resizePoints: resizePoints, resizeLines: resizeLines} = this;
|
|
926
|
-
const {stroke: stroke, strokeWidth: strokeWidth,
|
|
928
|
+
const {stroke: stroke, strokeWidth: strokeWidth, ignorePixelSnap: ignorePixelSnap} = mergeConfig;
|
|
927
929
|
const pointsStyle = this.getPointsStyle();
|
|
928
930
|
const middlePointsStyle = this.getMiddlePointsStyle();
|
|
931
|
+
const resizeLinesStyle = this.getResizeLinesStyle();
|
|
929
932
|
this.visible = !target.locked;
|
|
930
933
|
let resizeP;
|
|
931
934
|
for (let i = 0; i < 8; i++) {
|
|
@@ -935,12 +938,13 @@ class EditBox extends Group {
|
|
|
935
938
|
if (i % 2) resizeLines[(i - 1) / 2].set(Object.assign({
|
|
936
939
|
pointType: "resize",
|
|
937
940
|
rotation: (i - 1) / 2 * 90
|
|
938
|
-
},
|
|
941
|
+
}, resizeLinesStyle[(i - 1) / 2 % resizeLinesStyle.length] || {}));
|
|
939
942
|
}
|
|
940
943
|
circle.set(this.getPointStyle(mergeConfig.circle || mergeConfig.rotatePoint || pointsStyle[0]));
|
|
941
944
|
rect.set(Object.assign({
|
|
942
945
|
stroke: stroke,
|
|
943
946
|
strokeWidth: strokeWidth,
|
|
947
|
+
opacity: 1,
|
|
944
948
|
editConfig: editConfig
|
|
945
949
|
}, mergeConfig.rect || {}));
|
|
946
950
|
const rectThrough = isNull(mergeConfig.rectThrough) ? single : mergeConfig.rectThrough;
|
|
@@ -1065,6 +1069,7 @@ class EditBox extends Group {
|
|
|
1065
1069
|
strokeWidth: strokeWidth,
|
|
1066
1070
|
around: "center",
|
|
1067
1071
|
strokeAlign: "center",
|
|
1072
|
+
opacity: 1,
|
|
1068
1073
|
width: pointSize,
|
|
1069
1074
|
height: pointSize,
|
|
1070
1075
|
cornerRadius: pointRadius,
|
|
@@ -1082,6 +1087,10 @@ class EditBox extends Group {
|
|
|
1082
1087
|
const {middlePoint: middlePoint} = this.mergedConfig;
|
|
1083
1088
|
return isArray(middlePoint) ? middlePoint : middlePoint ? [ middlePoint ] : this.getPointsStyle();
|
|
1084
1089
|
}
|
|
1090
|
+
getResizeLinesStyle() {
|
|
1091
|
+
const {resizeLine: resizeLine} = this.mergedConfig;
|
|
1092
|
+
return isArray(resizeLine) ? resizeLine : [ resizeLine ];
|
|
1093
|
+
}
|
|
1085
1094
|
onDragStart(e) {
|
|
1086
1095
|
this.dragging = true;
|
|
1087
1096
|
const point = this.dragPoint = e.current, {pointType: pointType} = point;
|
|
@@ -1116,7 +1125,7 @@ class EditBox extends Group {
|
|
|
1116
1125
|
this.dragPoint = null;
|
|
1117
1126
|
}
|
|
1118
1127
|
onTransformStart(e) {
|
|
1119
|
-
if (this.moving) this.editor.opacity = this.mergedConfig.hideOnMove ? 0 : 1;
|
|
1128
|
+
if (this.moving || this.gesturing) this.editor.opacity = this.mergedConfig.hideOnMove ? 0 : 1;
|
|
1120
1129
|
if (this.resizing) ResizeEvent.resizingKeys = this.editor.leafList.keys;
|
|
1121
1130
|
const {dragStartData: dragStartData, target: target} = this;
|
|
1122
1131
|
dragStartData.x = e.x;
|
|
@@ -1141,7 +1150,18 @@ class EditBox extends Group {
|
|
|
1141
1150
|
e.stop();
|
|
1142
1151
|
if (isString(this.mergedConfig.moveable)) {
|
|
1143
1152
|
this.gesturing = this.moving = true;
|
|
1144
|
-
e.type
|
|
1153
|
+
switch (e.type) {
|
|
1154
|
+
case MoveEvent.START:
|
|
1155
|
+
this.onTransformStart(e);
|
|
1156
|
+
break;
|
|
1157
|
+
|
|
1158
|
+
case MoveEvent.END:
|
|
1159
|
+
this.onTransformEnd(e);
|
|
1160
|
+
break;
|
|
1161
|
+
|
|
1162
|
+
default:
|
|
1163
|
+
this.transformTool.onMove(e);
|
|
1164
|
+
}
|
|
1145
1165
|
}
|
|
1146
1166
|
}
|
|
1147
1167
|
}
|
|
@@ -1150,7 +1170,18 @@ class EditBox extends Group {
|
|
|
1150
1170
|
e.stop();
|
|
1151
1171
|
if (isString(this.mergedConfig.resizeable)) {
|
|
1152
1172
|
this.gesturing = this.resizing = true;
|
|
1153
|
-
e.type
|
|
1173
|
+
switch (e.type) {
|
|
1174
|
+
case ZoomEvent.START:
|
|
1175
|
+
this.onTransformStart(e);
|
|
1176
|
+
break;
|
|
1177
|
+
|
|
1178
|
+
case ZoomEvent.END:
|
|
1179
|
+
this.onTransformEnd(e);
|
|
1180
|
+
break;
|
|
1181
|
+
|
|
1182
|
+
default:
|
|
1183
|
+
this.transformTool.onScale(e);
|
|
1184
|
+
}
|
|
1154
1185
|
}
|
|
1155
1186
|
}
|
|
1156
1187
|
}
|
|
@@ -1159,16 +1190,21 @@ class EditBox extends Group {
|
|
|
1159
1190
|
e.stop();
|
|
1160
1191
|
if (isString(this.mergedConfig.rotateable)) {
|
|
1161
1192
|
this.gesturing = this.rotating = true;
|
|
1162
|
-
e.type
|
|
1193
|
+
switch (e.type) {
|
|
1194
|
+
case ZoomEvent.START:
|
|
1195
|
+
this.onTransformStart(e);
|
|
1196
|
+
break;
|
|
1197
|
+
|
|
1198
|
+
case ZoomEvent.END:
|
|
1199
|
+
this.onTransformEnd(e);
|
|
1200
|
+
break;
|
|
1201
|
+
|
|
1202
|
+
default:
|
|
1203
|
+
this.transformTool.onRotate(e);
|
|
1204
|
+
}
|
|
1163
1205
|
}
|
|
1164
1206
|
}
|
|
1165
1207
|
}
|
|
1166
|
-
onGestureStart(e) {
|
|
1167
|
-
if (this.canGesture && e.moveType !== "drag") this.onTransformStart(e);
|
|
1168
|
-
}
|
|
1169
|
-
onGestureEnd(e) {
|
|
1170
|
-
if (this.canGesture && e.moveType !== "drag") this.onTransformEnd(e);
|
|
1171
|
-
}
|
|
1172
1208
|
isHoldRotateKey(e) {
|
|
1173
1209
|
const {rotateKey: rotateKey} = this.mergedConfig;
|
|
1174
1210
|
if (rotateKey) return e.isHoldKeys(rotateKey);
|
|
@@ -1238,7 +1274,7 @@ class EditBox extends Group {
|
|
|
1238
1274
|
const {rect: rect, editor: editor, __eventIds: events} = this;
|
|
1239
1275
|
events.push(rect.on_([ [ PointerEvent.DOUBLE_TAP, this.onDoubleTap, this ], [ PointerEvent.LONG_PRESS, this.onLongPress, this ] ]));
|
|
1240
1276
|
this.waitLeafer(() => {
|
|
1241
|
-
events.push(editor.app.on_([ [ [ KeyEvent.HOLD, KeyEvent.UP ], this.onKey, this ], [ KeyEvent.DOWN, this.onArrow, this ], [ MoveEvent.
|
|
1277
|
+
events.push(editor.app.on_([ [ [ KeyEvent.HOLD, KeyEvent.UP ], this.onKey, this ], [ KeyEvent.DOWN, this.onArrow, this ], [ [ MoveEvent.START, MoveEvent.BEFORE_MOVE, MoveEvent.END ], this.onMove, this, true ], [ [ ZoomEvent.START, ZoomEvent.BEFORE_ZOOM, ZoomEvent.END ], this.onScale, this, true ], [ [ RotateEvent.START, RotateEvent.BEFORE_ROTATE, RotateEvent.END ], this.onRotate, this, true ] ]));
|
|
1242
1278
|
});
|
|
1243
1279
|
}
|
|
1244
1280
|
__removeListenEvents() {
|
|
@@ -1991,6 +2027,9 @@ let Editor = class Editor extends Group {
|
|
|
1991
2027
|
if (this.multiple) simulate(this);
|
|
1992
2028
|
this.update();
|
|
1993
2029
|
}
|
|
2030
|
+
getEditTool(name) {
|
|
2031
|
+
return this.editToolList[name] = this.editToolList[name] || EditToolCreator.get(name, this);
|
|
2032
|
+
}
|
|
1994
2033
|
updateEditTool() {
|
|
1995
2034
|
this.unloadEditTool();
|
|
1996
2035
|
if (this.editing) {
|
|
@@ -2005,7 +2044,7 @@ let Editor = class Editor extends Group {
|
|
|
2005
2044
|
if (isString(check)) name = check; else if (check === false) return;
|
|
2006
2045
|
}
|
|
2007
2046
|
if (EditToolCreator.list[name]) {
|
|
2008
|
-
const tool = this.editTool = this.
|
|
2047
|
+
const tool = this.editTool = this.getEditTool(name);
|
|
2009
2048
|
this.editBox.load();
|
|
2010
2049
|
tool.load();
|
|
2011
2050
|
this.update();
|
|
@@ -2094,9 +2133,12 @@ let Editor = class Editor extends Group {
|
|
|
2094
2133
|
const event = new EditorGroupEvent(type, {
|
|
2095
2134
|
editTarget: group
|
|
2096
2135
|
});
|
|
2097
|
-
|
|
2136
|
+
this.emitEvent(event);
|
|
2098
2137
|
if (group) group.emitEvent(event);
|
|
2099
2138
|
}
|
|
2139
|
+
getInnerEditor(name) {
|
|
2140
|
+
return this.editToolList[name] = this.editToolList[name] || EditToolCreator.get(name, this);
|
|
2141
|
+
}
|
|
2100
2142
|
openInnerEditor(target, nameOrSelect, select) {
|
|
2101
2143
|
let name;
|
|
2102
2144
|
if (isString(nameOrSelect)) name = nameOrSelect; else if (!select) select = nameOrSelect;
|
|
@@ -2115,7 +2157,7 @@ let Editor = class Editor extends Group {
|
|
|
2115
2157
|
if (EditToolCreator.list[name]) {
|
|
2116
2158
|
this.editTool.unload();
|
|
2117
2159
|
this.innerEditing = true;
|
|
2118
|
-
this.innerEditor = this.
|
|
2160
|
+
this.innerEditor = this.getInnerEditor(name);
|
|
2119
2161
|
this.innerEditor.editTarget = target;
|
|
2120
2162
|
this.emitInnerEvent(InnerEditorEvent.BEFORE_OPEN);
|
|
2121
2163
|
this.innerEditor.load();
|
|
@@ -2139,7 +2181,7 @@ let Editor = class Editor extends Group {
|
|
|
2139
2181
|
editTarget: editTarget,
|
|
2140
2182
|
innerEditor: innerEditor
|
|
2141
2183
|
});
|
|
2142
|
-
|
|
2184
|
+
this.emitEvent(event);
|
|
2143
2185
|
editTarget.emitEvent(event);
|
|
2144
2186
|
}
|
|
2145
2187
|
lock() {
|