@leafer-in/editor 1.7.0 → 1.8.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.
@@ -62,6 +62,8 @@ function targetAttr(fn) {
62
62
  if (isSelect) {
63
63
  if (value instanceof Array && value.length > 1 && value[0].locked)
64
64
  value.splice(0, 1);
65
+ if (this.single)
66
+ this.element.syncEventer = null;
65
67
  const { beforeSelect } = this.config;
66
68
  if (beforeSelect) {
67
69
  const check = beforeSelect({ target: value });
@@ -85,9 +87,11 @@ function mergeConfigAttr() {
85
87
  return (target, key) => {
86
88
  defineKey(target, key, {
87
89
  get() {
88
- const { config, element, dragPoint } = this, mergeConfig = Object.assign({}, config);
90
+ const { config, element, dragPoint, editBox } = this, mergeConfig = Object.assign({}, config);
89
91
  if (element && element.editConfig)
90
92
  Object.assign(mergeConfig, element.editConfig);
93
+ if (editBox.config)
94
+ Object.assign(mergeConfig, editBox.config);
91
95
  if (dragPoint) {
92
96
  if (dragPoint.editConfig)
93
97
  Object.assign(mergeConfig, dragPoint.editConfig);
@@ -119,14 +123,17 @@ class Stroker extends UI {
119
123
  this.strokeAlign = 'center';
120
124
  }
121
125
  setTarget(target, style) {
122
- this.set(style);
126
+ if (style)
127
+ this.set(style);
123
128
  this.target = target;
124
129
  this.update();
125
130
  }
126
- update() {
131
+ update(style) {
127
132
  const { list } = this;
128
133
  if (list.length) {
129
134
  setListWithFn(bounds$1, list, worldBounds);
135
+ if (style)
136
+ this.set(style);
130
137
  this.set(bounds$1);
131
138
  this.visible = true;
132
139
  }
@@ -269,15 +276,14 @@ class EditSelect extends Group {
269
276
  }
270
277
  onSelect() {
271
278
  if (this.running) {
272
- const { mergeConfig, list } = this.editor;
273
- const { stroke, strokeWidth, selectedStyle } = mergeConfig;
274
- this.targetStroker.setTarget(list, Object.assign({ stroke, strokeWidth: Math.max(1, strokeWidth / 2) }, (selectedStyle || {})));
279
+ this.targetStroker.setTarget(this.editor.list);
275
280
  this.hoverStroker.target = null;
276
281
  }
277
282
  }
278
283
  update() {
279
284
  this.hoverStroker.update();
280
- this.targetStroker.update();
285
+ const { stroke, strokeWidth, selectedStyle } = this.editor.mergedConfig;
286
+ this.targetStroker.update(Object.assign({ stroke, strokeWidth: strokeWidth && Math.max(1, strokeWidth / 2) }, (selectedStyle || {})));
281
287
  }
282
288
  onPointerMove(e) {
283
289
  const { app, editor } = this;
@@ -553,15 +559,17 @@ const EditDataHelper = {
553
559
  toPoint(around || align, boxBounds, origin, true);
554
560
  if (dragBounds) {
555
561
  const allowBounds = dragBounds === 'parent' ? target.parent.boxBounds : dragBounds;
556
- const localBounds = new Bounds(target.__localBoxBounds);
557
- localBounds.scaleOf(target.getLocalPointByInner(origin), scaleX, scaleY);
558
- if (!BoundsHelper.includes(allowBounds, localBounds)) {
559
- const realBounds = localBounds.getIntersect(allowBounds);
560
- const fitScaleX = realBounds.width / localBounds.width, fitScaleY = realBounds.height / localBounds.height;
561
- if (useScaleX)
562
- scaleX *= fitScaleX;
563
- if (useScaleY)
564
- scaleY *= fitScaleY;
562
+ const childBounds = new Bounds(target.__localBoxBounds);
563
+ if (BoundsHelper.includes(new Bounds(allowBounds).spread(0.1), childBounds)) {
564
+ childBounds.scaleOf(target.getLocalPointByInner(origin), scaleX, scaleY);
565
+ if (!BoundsHelper.includes(allowBounds, childBounds)) {
566
+ const realBounds = childBounds.getIntersect(allowBounds);
567
+ const fitScaleX = realBounds.width / childBounds.width, fitScaleY = realBounds.height / childBounds.height;
568
+ if (useScaleX)
569
+ scaleX *= fitScaleX;
570
+ if (useScaleY)
571
+ scaleY *= fitScaleY;
572
+ }
565
573
  }
566
574
  }
567
575
  if (useScaleX && widthRange) {
@@ -696,9 +704,9 @@ const EditDataHelper = {
696
704
  };
697
705
 
698
706
  const cacheCursors = {};
699
- function updateCursor(editBox, e) {
700
- const { enterPoint: point } = editBox;
701
- if (!point || !editBox.editor.editing || !editBox.visible)
707
+ function updatePointCursor(editBox, e) {
708
+ const { enterPoint: point, dragging, skewing, resizing, flippedX, flippedY } = editBox;
709
+ if (!point || !editBox.editor.editing || !editBox.canUse)
702
710
  return;
703
711
  if (point.name === 'circle')
704
712
  return;
@@ -707,13 +715,15 @@ function updateCursor(editBox, e) {
707
715
  point.cursor = 'pointer';
708
716
  return;
709
717
  }
710
- let { rotation, flippedX, flippedY } = editBox;
718
+ let { rotation } = editBox;
711
719
  const { pointType } = point, { resizeCursor, rotateCursor, skewCursor, resizeable, rotateable, skewable } = editBox.mergeConfig;
712
720
  let showResize = pointType.includes('resize');
713
721
  if (showResize && rotateable && (e.metaKey || e.ctrlKey || !resizeable))
714
722
  showResize = false;
715
723
  const showSkew = skewable && !showResize && (point.name === 'resize-line' || pointType === 'skew');
716
- const cursor = showSkew ? skewCursor : (showResize ? resizeCursor : rotateCursor);
724
+ const cursor = dragging
725
+ ? (skewing ? skewCursor : (resizing ? resizeCursor : rotateCursor))
726
+ : (showSkew ? skewCursor : (showResize ? resizeCursor : rotateCursor));
717
727
  rotation += (EditDataHelper.getFlipDirection(point.direction, flippedX, flippedY) + 1) * 45;
718
728
  rotation = Math.round(MathHelper.formatRotation(rotation, true) / 2) * 2;
719
729
  const { url, x, y } = cursor;
@@ -727,7 +737,8 @@ function updateCursor(editBox, e) {
727
737
  }
728
738
  function updateMoveCursor(editBox) {
729
739
  const { moveCursor, moveable } = editBox.mergeConfig;
730
- editBox.rect.cursor = moveable ? moveCursor : undefined;
740
+ if (editBox.canUse)
741
+ editBox.rect.cursor = moveable ? moveCursor : undefined;
731
742
  }
732
743
  function toDataURL(svg, rotation) {
733
744
  return '"data:image/svg+xml,' + encodeURIComponent(svg.replace('{{rotation}}', rotation.toString())) + '"';
@@ -743,8 +754,8 @@ class EditPoint extends Box {
743
754
  const fourDirection = ['top', 'right', 'bottom', 'left'], editConfig = undefined;
744
755
  class EditBox extends Group {
745
756
  get mergeConfig() {
746
- const { config } = this, { mergeConfig } = this.editor;
747
- return this.mergedConfig = config ? Object.assign(Object.assign({}, mergeConfig), config) : mergeConfig;
757
+ const { config } = this, { mergeConfig, editBox } = this.editor;
758
+ return this.mergedConfig = config && (editBox !== this) ? Object.assign(Object.assign({}, mergeConfig), config) : mergeConfig;
748
759
  }
749
760
  get target() { return this._target || this.editor.element; }
750
761
  set target(target) { this._target = target; }
@@ -755,6 +766,13 @@ class EditBox extends Group {
755
766
  get flippedX() { return this.scaleX < 0; }
756
767
  get flippedY() { return this.scaleY < 0; }
757
768
  get flippedOne() { return this.scaleX * this.scaleY < 0; }
769
+ get canUse() { return (this.visible && this.view.visible); }
770
+ get canGesture() {
771
+ if (!this.canUse)
772
+ return false;
773
+ const { moveable, resizeable, rotateable } = this.mergeConfig;
774
+ return typeof moveable === 'string' || typeof resizeable === 'string' || typeof rotateable === 'string';
775
+ }
758
776
  constructor(editor) {
759
777
  super();
760
778
  this.view = new Group();
@@ -801,8 +819,7 @@ class EditBox extends Group {
801
819
  for (let i = 0; i < 8; i++) {
802
820
  resizeP = resizePoints[i];
803
821
  resizeP.set(this.getPointStyle((i % 2) ? middlePointsStyle[((i - 1) / 2) % middlePointsStyle.length] : pointsStyle[(i / 2) % pointsStyle.length]));
804
- if (!(i % 2))
805
- resizeP.rotation = (i / 2) * 90;
822
+ resizeP.rotation = ((i - (i % 2 ? 1 : 0)) / 2) * 90;
806
823
  }
807
824
  circle.set(this.getPointStyle(mergeConfig.circle || mergeConfig.rotatePoint || pointsStyle[0]));
808
825
  rect.set(Object.assign({ stroke, strokeWidth, editConfig }, (mergeConfig.rect || {})));
@@ -821,12 +838,19 @@ class EditBox extends Group {
821
838
  this.set({ x, y, scaleX, scaleY, rotation, skewX, skewY });
822
839
  this.updateBounds({ x: 0, y: 0, width, height });
823
840
  }
841
+ unload() {
842
+ this.visible = false;
843
+ if (this.app)
844
+ this.rect.syncEventer = this.app.interaction.bottomList = null;
845
+ }
824
846
  updateBounds(bounds) {
825
847
  const { editMask } = this.editor;
826
848
  const { mergeConfig, single, rect, circle, buttons, resizePoints, rotatePoints, resizeLines } = this;
827
- const { middlePoint, resizeable, rotateable, hideOnSmall, editBox, mask } = mergeConfig;
849
+ const { middlePoint, resizeable, rotateable, hideOnSmall, editBox, mask, spread } = mergeConfig;
828
850
  this.visible = !this.target.locked;
829
851
  editMask.visible = mask ? true : 0;
852
+ if (spread)
853
+ BoundsHelper.spread(bounds, spread);
830
854
  if (this.view.worldOpacity) {
831
855
  const { width, height } = bounds;
832
856
  const smallSize = typeof hideOnSmall === 'number' ? hideOnSmall : 10;
@@ -851,7 +875,6 @@ class EditBox extends Group {
851
875
  }
852
876
  else {
853
877
  resizeL.height = height;
854
- resizeP.rotation = 90;
855
878
  if (hideOnSmall && resizeP.width * 2 > height)
856
879
  resizeP.visible = false;
857
880
  }
@@ -906,9 +929,6 @@ class EditBox extends Group {
906
929
  buttons.y = point.y + margin;
907
930
  }
908
931
  }
909
- unload() {
910
- this.visible = false;
911
- }
912
932
  getPointStyle(userStyle) {
913
933
  const { stroke, strokeWidth, pointFill, pointSize, pointRadius } = this.mergedConfig;
914
934
  const defaultStyle = { fill: pointFill, stroke, strokeWidth, around: 'center', strokeAlign: 'center', width: pointSize, height: pointSize, cornerRadius: pointRadius, offsetX: 0, offsetY: 0, editConfig };
@@ -922,20 +942,26 @@ class EditBox extends Group {
922
942
  const { middlePoint } = this.mergedConfig;
923
943
  return middlePoint instanceof Array ? middlePoint : (middlePoint ? [middlePoint] : this.getPointsStyle());
924
944
  }
925
- onSelect(e) {
926
- if (e.oldList.length === 1) {
927
- e.oldList[0].syncEventer = null;
928
- if (this.app)
929
- this.app.interaction.bottomList = null;
930
- }
931
- }
932
945
  onDragStart(e) {
933
946
  this.dragging = true;
934
947
  const point = this.dragPoint = e.current, { pointType } = point;
935
- const { editor, dragStartData } = this, { target } = this;
948
+ const { editor, dragStartData } = this, { target } = this, { moveable, resizeable, rotateable, skewable, hideOnMove } = this.mergeConfig;
936
949
  if (point.name === 'rect') {
937
- this.moving = true;
938
- editor.opacity = this.mergeConfig.hideOnMove ? 0 : 1;
950
+ moveable && (this.moving = true);
951
+ editor.opacity = hideOnMove ? 0 : 1;
952
+ }
953
+ else {
954
+ if (pointType.includes('rotate') || e.metaKey || e.ctrlKey || !resizeable) {
955
+ rotateable && (this.rotating = true);
956
+ if (pointType === 'resize-rotate')
957
+ resizeable && (this.resizing = true);
958
+ else if (point.name === 'resize-line')
959
+ skewable && (this.skewing = true), this.rotating = false;
960
+ }
961
+ else if (pointType === 'resize')
962
+ resizeable && (this.resizing = true);
963
+ if (pointType === 'skew')
964
+ skewable && (this.skewing = true);
939
965
  }
940
966
  dragStartData.x = e.x;
941
967
  dragStartData.y = e.y;
@@ -946,9 +972,8 @@ class EditBox extends Group {
946
972
  ResizeEvent.resizingKeys = editor.leafList.keys;
947
973
  }
948
974
  onDragEnd(e) {
949
- this.dragging = false;
950
975
  this.dragPoint = null;
951
- this.moving = false;
976
+ this.resetDoing();
952
977
  const { name, pointType } = e.current;
953
978
  if (name === 'rect')
954
979
  this.editor.opacity = 1;
@@ -956,31 +981,61 @@ class EditBox extends Group {
956
981
  ResizeEvent.resizingKeys = null;
957
982
  }
958
983
  onDrag(e) {
959
- const { transformTool } = this, point = e.current;
960
- if (point.name === 'rect') {
984
+ const { transformTool, moving, resizing, rotating, skewing } = this;
985
+ if (moving) {
961
986
  transformTool.onMove(e);
962
987
  updateMoveCursor(this);
963
988
  }
964
- else {
965
- const { pointType } = this.enterPoint = point;
966
- if (pointType.includes('rotate') || e.metaKey || e.ctrlKey || !this.mergeConfig.resizeable) {
989
+ else if (resizing || rotating || skewing) {
990
+ const point = e.current;
991
+ if (point.pointType)
992
+ this.enterPoint = point;
993
+ if (rotating)
967
994
  transformTool.onRotate(e);
968
- if (pointType === 'resize-rotate')
969
- transformTool.onScale(e);
970
- }
971
- else if (pointType === 'resize')
995
+ if (resizing)
972
996
  transformTool.onScale(e);
973
- if (pointType === 'skew')
997
+ if (skewing)
974
998
  transformTool.onSkew(e);
975
- updateCursor(this, e);
999
+ updatePointCursor(this, e);
1000
+ }
1001
+ }
1002
+ resetDoing() {
1003
+ if (this.canUse)
1004
+ this.dragging = this.gesturing = this.moving = this.resizing = this.rotating = this.skewing = false;
1005
+ }
1006
+ onMove(e) {
1007
+ if (this.canGesture && e.moveType !== 'drag') {
1008
+ e.stop();
1009
+ if (typeof this.mergeConfig.moveable === 'string') {
1010
+ this.gesturing = this.moving = true;
1011
+ this.transformTool.onMove(e);
1012
+ }
1013
+ }
1014
+ }
1015
+ onScale(e) {
1016
+ if (this.canGesture) {
1017
+ e.stop();
1018
+ if (typeof this.mergeConfig.resizeable === 'string') {
1019
+ this.gesturing = this.resizing = true;
1020
+ this.transformTool.onScale(e);
1021
+ }
1022
+ }
1023
+ }
1024
+ onRotate(e) {
1025
+ if (this.canGesture) {
1026
+ e.stop();
1027
+ if (typeof this.mergeConfig.rotateable === 'string') {
1028
+ this.gesturing = this.rotating = true;
1029
+ this.transformTool.onRotate(e);
1030
+ }
976
1031
  }
977
1032
  }
978
1033
  onKey(e) {
979
- updateCursor(this, e);
1034
+ updatePointCursor(this, e);
980
1035
  }
981
1036
  onArrow(e) {
982
- const { editor } = this;
983
- if (editor.editing && this.mergeConfig.keyEvent) {
1037
+ const { editor, transformTool } = this;
1038
+ if (this.canUse && editor.editing && this.mergeConfig.keyEvent) {
984
1039
  let x = 0, y = 0;
985
1040
  const distance = e.shiftKey ? 10 : 1;
986
1041
  switch (e.code) {
@@ -997,7 +1052,7 @@ class EditBox extends Group {
997
1052
  x = distance;
998
1053
  }
999
1054
  if (x || y)
1000
- editor.move(x, y);
1055
+ transformTool.move(x, y);
1001
1056
  }
1002
1057
  }
1003
1058
  onDoubleTap(e) {
@@ -1040,12 +1095,12 @@ class EditBox extends Group {
1040
1095
  [PointerEvent.LEAVE, () => { this.enterPoint = null; }],
1041
1096
  ];
1042
1097
  if (point.name !== 'circle')
1043
- events.push([PointerEvent.ENTER, (e) => { this.enterPoint = point, updateCursor(this, e); }]);
1098
+ events.push([PointerEvent.ENTER, (e) => { this.enterPoint = point, updatePointCursor(this, e); }]);
1044
1099
  this.__eventIds.push(point.on_(events));
1045
1100
  }
1046
1101
  __listenEvents() {
1047
1102
  const { rect, editor, __eventIds: events } = this;
1048
- events.push(editor.on_(EditorEvent.SELECT, this.onSelect, this), rect.on_([
1103
+ events.push(rect.on_([
1049
1104
  [DragEvent.START, this.onDragStart, this],
1050
1105
  [DragEvent.DRAG, this.onDrag, this],
1051
1106
  [DragEvent.END, this.onDragEnd, this],
@@ -1056,7 +1111,13 @@ class EditBox extends Group {
1056
1111
  this.waitLeafer(() => {
1057
1112
  events.push(editor.app.on_([
1058
1113
  [[KeyEvent.HOLD, KeyEvent.UP], this.onKey, this],
1059
- [KeyEvent.DOWN, this.onArrow, this]
1114
+ [KeyEvent.DOWN, this.onArrow, this],
1115
+ [MoveEvent.BEFORE_MOVE, this.onMove, this, true],
1116
+ [ZoomEvent.BEFORE_ZOOM, this.onScale, this, true],
1117
+ [RotateEvent.BEFORE_ROTATE, this.onRotate, this, true],
1118
+ [MoveEvent.END, this.resetDoing, this],
1119
+ [ZoomEvent.END, this.resetDoing, this],
1120
+ [RotateEvent.END, this.resetDoing, this],
1060
1121
  ]));
1061
1122
  });
1062
1123
  }
@@ -1212,7 +1273,8 @@ function onTarget(editor, oldValue) {
1212
1273
  editor.simulateTarget.remove();
1213
1274
  editor.leafList.reset();
1214
1275
  }
1215
- editor.closeInnerEditor();
1276
+ editor.closeInnerEditor(true);
1277
+ editor.unloadEditTool();
1216
1278
  const data = { editor, value: target, oldValue };
1217
1279
  editor.emitEvent(new EditorEvent(EditorEvent.SELECT, data));
1218
1280
  editor.checkOpenedGroups();
@@ -1432,16 +1494,10 @@ EditorSkewEvent.SKEW = 'editor.skew';
1432
1494
 
1433
1495
  class TransformTool {
1434
1496
  onMove(e) {
1435
- const { target, mergeConfig, dragStartData } = this.editBox;
1497
+ const { target, dragStartData } = this.editBox;
1436
1498
  if (e instanceof MoveEvent) {
1437
- if (e.moveType !== 'drag') {
1438
- const { moveable, resizeable } = mergeConfig;
1439
- const move = e.getLocalMove(target);
1440
- if (moveable === 'move')
1441
- e.stop(), this.move(move.x, move.y);
1442
- else if (resizeable === 'zoom')
1443
- e.stop();
1444
- }
1499
+ const move = e.getLocalMove(target);
1500
+ this.move(move.x, move.y);
1445
1501
  }
1446
1502
  else {
1447
1503
  const total = { x: e.totalX, y: e.totalY };
@@ -1456,10 +1512,9 @@ class TransformTool {
1456
1512
  }
1457
1513
  onScale(e) {
1458
1514
  const { target, mergeConfig, single, dragStartData } = this.editBox;
1459
- let { around, lockRatio, resizeable, flipable, editSize } = mergeConfig;
1515
+ let { around, lockRatio, flipable, editSize } = mergeConfig;
1460
1516
  if (e instanceof ZoomEvent) {
1461
- if (resizeable === 'zoom')
1462
- e.stop(), this.scaleOf(target.getBoxPoint(e), e.scale, e.scale);
1517
+ this.scaleOf(target.getBoxPoint(e), e.scale, e.scale);
1463
1518
  }
1464
1519
  else {
1465
1520
  const { direction } = e.current;
@@ -1477,28 +1532,18 @@ class TransformTool {
1477
1532
  }
1478
1533
  onRotate(e) {
1479
1534
  const { target, mergeConfig, dragStartData } = this.editBox;
1480
- const { skewable, rotateable, around, rotateGap } = mergeConfig;
1481
- const { direction, name } = e.current;
1482
- if (skewable && name === 'resize-line')
1483
- return this.onSkew(e);
1535
+ const { around, rotateAround, rotateGap } = mergeConfig;
1536
+ const { direction } = e.current;
1484
1537
  let origin, rotation;
1485
1538
  if (e instanceof RotateEvent) {
1486
- if (rotateable === 'rotate')
1487
- e.stop(), rotation = e.rotation, origin = target.getBoxPoint(e);
1488
- else
1489
- return;
1490
- if (target.scaleX * target.scaleY < 0)
1491
- rotation = -rotation;
1539
+ rotation = e.rotation;
1540
+ origin = rotateAround ? AroundHelper.getPoint(rotateAround, target.boxBounds) : target.getBoxPoint(e);
1492
1541
  }
1493
1542
  else {
1494
- const data = EditDataHelper.getRotateData(target, direction, e, dragStartData, e.shiftKey ? null : (target.around || target.origin || around || 'center'));
1495
- rotation = data.rotation;
1543
+ const data = EditDataHelper.getRotateData(target, direction, e, dragStartData, e.shiftKey ? null : (rotateAround || target.around || target.origin || around || 'center'));
1544
+ rotation = dragStartData.rotation + data.rotation - target.rotation;
1496
1545
  origin = data.origin;
1497
1546
  }
1498
- if (target.scaleX * target.scaleY < 0)
1499
- rotation = -rotation;
1500
- if (e instanceof DragEvent)
1501
- rotation = dragStartData.rotation + rotation - target.rotation;
1502
1547
  rotation = MathHelper.float(MathHelper.getGapRotation(rotation, rotateGap, target.rotation), 2);
1503
1548
  if (!rotation)
1504
1549
  return;
@@ -1664,9 +1709,13 @@ let Editor = class Editor extends Group {
1664
1709
  get groupOpening() { return !!this.openedGroupList.length; }
1665
1710
  get multiple() { return this.list.length > 1; }
1666
1711
  get single() { return this.list.length === 1; }
1712
+ get dragPoint() { return this.editBox.dragPoint; }
1667
1713
  get dragging() { return this.editBox.dragging; }
1714
+ get gesturing() { return this.editBox.gesturing; }
1668
1715
  get moving() { return this.editBox.moving; }
1669
- get dragPoint() { return this.editBox.dragPoint; }
1716
+ get resizing() { return this.editBox.resizing; }
1717
+ get rotating() { return this.editBox.rotating; }
1718
+ get skewing() { return this.editBox.skewing; }
1670
1719
  get element() { return this.multiple ? this.simulateTarget : this.list[0]; }
1671
1720
  get buttons() { return this.editBox.buttons; }
1672
1721
  constructor(userConfig, data) {
@@ -1723,19 +1772,22 @@ let Editor = class Editor extends Group {
1723
1772
  this.update();
1724
1773
  }
1725
1774
  updateEditTool() {
1775
+ this.unloadEditTool();
1776
+ if (this.editing) {
1777
+ const name = this.element.editOuter || 'EditTool';
1778
+ const tool = this.editTool = this.editToolList[name] = this.editToolList[name] || EditToolCreator.get(name, this);
1779
+ this.editBox.load();
1780
+ tool.load();
1781
+ this.update();
1782
+ }
1783
+ }
1784
+ unloadEditTool() {
1726
1785
  let tool = this.editTool;
1727
1786
  if (tool) {
1728
1787
  this.editBox.unload();
1729
1788
  tool.unload();
1730
1789
  this.editTool = null;
1731
1790
  }
1732
- if (this.editing) {
1733
- const tag = this.element.editOuter || 'EditTool';
1734
- tool = this.editTool = this.editToolList[tag] = this.editToolList[tag] || EditToolCreator.get(tag, this);
1735
- this.editBox.load();
1736
- tool.load();
1737
- this.update();
1738
- }
1739
1791
  }
1740
1792
  getEditSize(_ui) {
1741
1793
  return this.mergeConfig.editSize;
@@ -1809,16 +1861,21 @@ let Editor = class Editor extends Group {
1809
1861
  if (group)
1810
1862
  group.emitEvent(event);
1811
1863
  }
1812
- openInnerEditor(target, select) {
1864
+ openInnerEditor(target, nameOrSelect, select) {
1865
+ let name;
1866
+ if (typeof nameOrSelect === 'string')
1867
+ name = nameOrSelect;
1868
+ else if (!select)
1869
+ select = nameOrSelect;
1813
1870
  if (target && select)
1814
1871
  this.target = target;
1815
1872
  if (this.single) {
1816
1873
  const editTarget = target || this.element;
1817
- const tag = editTarget.editInner;
1818
- if (tag && EditToolCreator.list[tag]) {
1874
+ name || (name = editTarget.editInner);
1875
+ if (name && EditToolCreator.list[name]) {
1819
1876
  this.editTool.unload();
1820
1877
  this.innerEditing = true;
1821
- this.innerEditor = this.editToolList[tag] || EditToolCreator.get(tag, this);
1878
+ this.innerEditor = this.editToolList[name] = this.editToolList[name] || EditToolCreator.get(name, this);
1822
1879
  this.innerEditor.editTarget = editTarget;
1823
1880
  this.emitInnerEvent(InnerEditorEvent.BEFORE_OPEN);
1824
1881
  this.innerEditor.load();
@@ -1826,13 +1883,14 @@ let Editor = class Editor extends Group {
1826
1883
  }
1827
1884
  }
1828
1885
  }
1829
- closeInnerEditor() {
1886
+ closeInnerEditor(onlyInnerEditor) {
1830
1887
  if (this.innerEditing) {
1831
1888
  this.innerEditing = false;
1832
1889
  this.emitInnerEvent(InnerEditorEvent.BEFORE_CLOSE);
1833
1890
  this.innerEditor.unload();
1834
1891
  this.emitInnerEvent(InnerEditorEvent.CLOSE);
1835
- this.editTool.load();
1892
+ if (!onlyInnerEditor)
1893
+ this.updateEditTool();
1836
1894
  this.innerEditor = null;
1837
1895
  }
1838
1896
  }
@@ -1875,12 +1933,7 @@ let Editor = class Editor extends Group {
1875
1933
  const { app, leafer, editMask } = this;
1876
1934
  this.targetEventIds = [
1877
1935
  leafer.on_(RenderEvent.START, this.onRenderStart, this),
1878
- app.on_([
1879
- [RenderEvent.CHILD_START, this.onAppRenderStart, this],
1880
- [MoveEvent.BEFORE_MOVE, this.onMove, this, true],
1881
- [ZoomEvent.BEFORE_ZOOM, this.onScale, this, true],
1882
- [RotateEvent.BEFORE_ROTATE, this.onRotate, this, true],
1883
- ])
1936
+ app.on_(RenderEvent.CHILD_START, this.onAppRenderStart, this)
1884
1937
  ];
1885
1938
  if (editMask.visible)
1886
1939
  editMask.forceRender();
@@ -2151,7 +2204,7 @@ Creator.editor = function (options, app) {
2151
2204
  };
2152
2205
  Box.addAttr('textBox', false, dataType);
2153
2206
  UI.addAttr('editConfig', undefined, dataType);
2154
- UI.addAttr('editOuter', (ui) => ui.__.__isLinePath ? 'LineEditTool' : 'EditTool', dataType);
2207
+ UI.addAttr('editOuter', (ui) => { ui.updateLayout(); return ui.__.__isLinePath ? 'LineEditTool' : 'EditTool'; }, dataType);
2155
2208
  UI.addAttr('editInner', 'PathEditor', dataType);
2156
2209
  Group.addAttr('editInner', '', dataType);
2157
2210
  Text.addAttr('editInner', 'TextEditor', dataType);