@leafer-in/editor 1.9.5 → 1.9.7

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 CHANGED
@@ -54,12 +54,15 @@ function targetAttr(fn) {
54
54
  set(value) {
55
55
  const old = this[privateKey];
56
56
  if (old !== value) {
57
- if (this.config) {
57
+ const t = this;
58
+ if (t.config) {
58
59
  const isSelect = key === "target";
59
60
  if (isSelect) {
61
+ t.setDimOthers(false);
62
+ t.setBright(false);
60
63
  if (draw.isArray(value) && value.length > 1 && value[0].locked) value.splice(0, 1);
61
- if (this.single) this.element.syncEventer = null;
62
- const {beforeSelect: beforeSelect} = this.config;
64
+ if (t.single) t.element.syncEventer = null;
65
+ const {beforeSelect: beforeSelect} = t.config;
63
66
  if (beforeSelect) {
64
67
  const check = beforeSelect({
65
68
  target: value
@@ -69,7 +72,7 @@ function targetAttr(fn) {
69
72
  }
70
73
  const type = isSelect ? EditorEvent.BEFORE_SELECT : EditorEvent.BEFORE_HOVER;
71
74
  if (this.hasEvent(type)) this.emitEvent(new EditorEvent(type, {
72
- editor: this,
75
+ editor: t,
73
76
  value: value,
74
77
  oldValue: old
75
78
  }));
@@ -252,7 +255,7 @@ class EditSelect extends draw.Group {
252
255
  }
253
256
  get running() {
254
257
  const {editor: editor} = this;
255
- return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector;
258
+ return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector && this.app.mode === "normal";
256
259
  }
257
260
  get isMoveMode() {
258
261
  return this.app && this.app.interaction.moveMode;
@@ -554,17 +557,13 @@ const EditDataHelper = {
554
557
  }
555
558
  toPoint(around || align, boxBounds, origin, true);
556
559
  if (dragBounds) {
557
- const allowBounds = dragBounds === "parent" ? target.parent.boxBounds : dragBounds;
558
- const childBounds = new draw.Bounds(target.__localBoxBounds);
559
- if (draw.BoundsHelper.includes(new draw.Bounds(allowBounds).spread(.1), childBounds)) {
560
- childBounds.scaleOf(target.getLocalPointByInner(origin), scaleX, scaleY);
561
- if (!draw.BoundsHelper.includes(allowBounds, childBounds)) {
562
- const realBounds = childBounds.getIntersect(allowBounds);
563
- const fitScaleX = realBounds.width / childBounds.width, fitScaleY = realBounds.height / childBounds.height;
564
- if (useScaleX) scaleX *= fitScaleX;
565
- if (useScaleY) scaleY *= fitScaleY;
566
- }
567
- }
560
+ const scaleData = {
561
+ x: scaleX,
562
+ y: scaleY
563
+ };
564
+ draw.DragBoundsHelper.limitScaleOf(target, origin, scaleData);
565
+ scaleX = scaleData.x;
566
+ scaleY = scaleData.y;
568
567
  }
569
568
  if (useScaleX && widthRange) {
570
569
  const nowWidth = boxBounds.width * target.scaleX;
@@ -744,13 +743,18 @@ const cacheCursors = {};
744
743
  function updatePointCursor(editBox, e) {
745
744
  const {enterPoint: point, dragging: dragging, skewing: skewing, resizing: resizing, flippedX: flippedX, flippedY: flippedY} = editBox;
746
745
  if (!point || !editBox.editor.editing || !editBox.canUse) return;
746
+ if (point.name === "rect") return updateMoveCursor(editBox);
747
747
  if (point.name === "circle") return;
748
- if (point.pointType === "button") {
748
+ let {rotation: rotation} = editBox;
749
+ const {pointType: pointType} = point, {moveCursor: moveCursor, resizeCursor: resizeCursor, rotateCursor: rotateCursor, skewCursor: skewCursor, moveable: moveable, resizeable: resizeable, rotateable: rotateable, skewable: skewable} = editBox.mergeConfig;
750
+ if (pointType === "move") {
751
+ point.cursor = moveCursor;
752
+ if (!moveable) point.visible = false;
753
+ return;
754
+ } else if (pointType === "button") {
749
755
  if (!point.cursor) point.cursor = "pointer";
750
756
  return;
751
757
  }
752
- let {rotation: rotation} = editBox;
753
- const {pointType: pointType} = point, {resizeCursor: resizeCursor, rotateCursor: rotateCursor, skewCursor: skewCursor, resizeable: resizeable, rotateable: rotateable, skewable: skewable} = editBox.mergeConfig;
754
758
  let showResize = pointType.includes("resize");
755
759
  if (showResize && rotateable && (editBox.isHoldRotateKey(e) || !resizeable)) showResize = false;
756
760
  const showSkew = skewable && !showResize && (point.name === "resize-line" || pointType === "skew");
@@ -831,7 +835,7 @@ class EditBox extends draw.Group {
831
835
  constructor(editor) {
832
836
  super();
833
837
  this.view = new draw.Group;
834
- this.rect = new draw.Box({
838
+ this.rect = new EditPoint({
835
839
  name: "rect",
836
840
  hitFill: "all",
837
841
  hitStroke: "none",
@@ -893,12 +897,13 @@ class EditBox extends draw.Group {
893
897
  this.listenPointEvents(resizePoint, "resize", i);
894
898
  }
895
899
  this.listenPointEvents(circle, "rotate", 2);
900
+ this.listenPointEvents(rect, "move", 8);
896
901
  view.addMany(...rotatePoints, rect, circle, buttons, ...resizeLines, ...resizePoints);
897
902
  this.add(view);
898
903
  }
899
904
  load() {
900
- const {target: target, mergeConfig: mergeConfig, single: single, rect: rect, circle: circle, resizePoints: resizePoints} = this;
901
- const {stroke: stroke, strokeWidth: strokeWidth} = mergeConfig;
905
+ const {target: target, mergeConfig: mergeConfig, single: single, rect: rect, circle: circle, resizePoints: resizePoints, resizeLines: resizeLines} = this;
906
+ const {stroke: stroke, strokeWidth: strokeWidth, resizeLine: resizeLine} = mergeConfig;
902
907
  const pointsStyle = this.getPointsStyle();
903
908
  const middlePointsStyle = this.getMiddlePointsStyle();
904
909
  this.visible = !target.locked;
@@ -907,6 +912,10 @@ class EditBox extends draw.Group {
907
912
  resizeP = resizePoints[i];
908
913
  resizeP.set(this.getPointStyle(i % 2 ? middlePointsStyle[(i - 1) / 2 % middlePointsStyle.length] : pointsStyle[i / 2 % pointsStyle.length]));
909
914
  resizeP.rotation = (i - (i % 2 ? 1 : 0)) / 2 * 90;
915
+ if (i % 2) resizeLines[(i - 1) / 2].set(Object.assign({
916
+ pointType: "resize",
917
+ rotation: (i - 1) / 2 * 90
918
+ }, resizeLine || {}));
910
919
  }
911
920
  circle.set(this.getPointStyle(mergeConfig.circle || mergeConfig.rotatePoint || pointsStyle[0]));
912
921
  rect.set(Object.assign({
@@ -951,10 +960,12 @@ class EditBox extends draw.Group {
951
960
  if (this.app) this.rect.syncEventer = this.app.interaction.bottomList = null;
952
961
  }
953
962
  updateBounds(bounds) {
954
- const {editMask: editMask} = this.editor;
955
- const {mergeConfig: mergeConfig, single: single, rect: rect, circle: circle, buttons: buttons, resizePoints: resizePoints, rotatePoints: rotatePoints, resizeLines: resizeLines} = this;
956
- const {middlePoint: middlePoint, resizeable: resizeable, rotateable: rotateable, hideOnSmall: hideOnSmall, editBox: editBox, mask: mask, spread: spread, hideRotatePoints: hideRotatePoints, hideResizeLines: hideResizeLines} = mergeConfig;
963
+ const {editor: editor, mergeConfig: mergeConfig, single: single, rect: rect, circle: circle, buttons: buttons, resizePoints: resizePoints, rotatePoints: rotatePoints, resizeLines: resizeLines} = this;
964
+ const {editMask: editMask} = editor;
965
+ const {middlePoint: middlePoint, resizeable: resizeable, rotateable: rotateable, hideOnSmall: hideOnSmall, editBox: editBox, mask: mask, dimOthers: dimOthers, bright: bright, spread: spread, hideRotatePoints: hideRotatePoints, hideResizeLines: hideResizeLines} = mergeConfig;
957
966
  editMask.visible = mask ? true : 0;
967
+ editor.setDimOthers(dimOthers);
968
+ editor.setBright(!!dimOthers || bright);
958
969
  if (spread) draw.BoundsHelper.spread(bounds, spread);
959
970
  if (this.view.worldOpacity) {
960
971
  const {width: width, height: height} = bounds;
@@ -975,10 +986,10 @@ class EditBox extends draw.Group {
975
986
  resizeL.visible = resizeP.visible && !hideResizeLines;
976
987
  resizeP.visible = rotateP.visible = showPoints && !!middlePoint;
977
988
  if ((i + 1) / 2 % 2) {
978
- resizeL.width = width;
989
+ resizeL.width = width + resizeL.height;
979
990
  if (hideOnSmall && resizeP.width * 2 > width) resizeP.visible = false;
980
991
  } else {
981
- resizeL.height = height;
992
+ resizeL.width = height + resizeL.height;
982
993
  if (hideOnSmall && resizeP.width * 2 > height) resizeP.visible = false;
983
994
  }
984
995
  }
@@ -1055,7 +1066,7 @@ class EditBox extends draw.Group {
1055
1066
  this.dragging = true;
1056
1067
  const point = this.dragPoint = e.current, {pointType: pointType} = point;
1057
1068
  const {editor: editor, dragStartData: dragStartData} = this, {target: target} = this, {moveable: moveable, resizeable: resizeable, rotateable: rotateable, skewable: skewable, hideOnMove: hideOnMove} = this.mergeConfig;
1058
- if (point.name === "rect") {
1069
+ if (pointType === "move") {
1059
1070
  moveable && (this.moving = true);
1060
1071
  editor.opacity = hideOnMove ? 0 : 1;
1061
1072
  } else {
@@ -1080,23 +1091,22 @@ class EditBox extends draw.Group {
1080
1091
  if (this.moving && this.mergeConfig.dragLimitAnimate && this.target.dragBounds) this.transformTool.onMove(e);
1081
1092
  this.dragPoint = null;
1082
1093
  this.resetDoing();
1083
- const {name: name, pointType: pointType} = e.current;
1084
- if (name === "rect") this.editor.opacity = 1;
1094
+ const {pointType: pointType} = e.current;
1095
+ if (pointType === "move") this.editor.opacity = 1;
1085
1096
  if (pointType && pointType.includes("resize")) draw.ResizeEvent.resizingKeys = null;
1086
1097
  }
1087
1098
  onDrag(e) {
1088
1099
  const {transformTool: transformTool, moving: moving, resizing: resizing, rotating: rotating, skewing: skewing} = this;
1089
1100
  if (moving) {
1090
1101
  transformTool.onMove(e);
1091
- updateMoveCursor(this);
1092
1102
  } else if (resizing || rotating || skewing) {
1093
1103
  const point = e.current;
1094
1104
  if (point.pointType) this.enterPoint = point;
1095
1105
  if (rotating) transformTool.onRotate(e);
1096
1106
  if (resizing) transformTool.onScale(e);
1097
1107
  if (skewing) transformTool.onSkew(e);
1098
- updatePointCursor(this, e);
1099
1108
  }
1109
+ updatePointCursor(this, e);
1100
1110
  }
1101
1111
  resetDoing() {
1102
1112
  if (this.canUse) this.dragging = this.gesturing = this.moving = this.resizing = this.rotating = this.skewing = false;
@@ -1192,17 +1202,15 @@ class EditBox extends draw.Group {
1192
1202
  listenPointEvents(point, type, direction) {
1193
1203
  point.direction = direction;
1194
1204
  point.pointType = type;
1195
- const events = [ [ core.DragEvent.START, this.onDragStart, this ], [ core.DragEvent.DRAG, this.onDrag, this ], [ core.DragEvent.END, this.onDragEnd, this ], [ core.PointerEvent.LEAVE, () => {
1196
- this.enterPoint = null;
1197
- } ] ];
1198
- if (point.name !== "circle") events.push([ core.PointerEvent.ENTER, e => {
1205
+ this.__eventIds.push(point.on_([ [ core.DragEvent.START, this.onDragStart, this ], [ core.DragEvent.DRAG, this.onDrag, this ], [ core.DragEvent.END, this.onDragEnd, this ], [ core.PointerEvent.ENTER, e => {
1199
1206
  this.enterPoint = point, updatePointCursor(this, e);
1200
- } ]);
1201
- this.__eventIds.push(point.on_(events));
1207
+ } ], [ core.PointerEvent.LEAVE, () => {
1208
+ this.enterPoint = null;
1209
+ } ] ]));
1202
1210
  }
1203
1211
  __listenEvents() {
1204
1212
  const {rect: rect, editor: editor, __eventIds: events} = this;
1205
- events.push(rect.on_([ [ core.DragEvent.START, this.onDragStart, this ], [ core.DragEvent.DRAG, this.onDrag, this ], [ core.DragEvent.END, this.onDragEnd, this ], [ core.PointerEvent.ENTER, () => updateMoveCursor(this) ], [ core.PointerEvent.DOUBLE_TAP, this.onDoubleTap, this ], [ core.PointerEvent.LONG_PRESS, this.onLongPress, this ] ]));
1213
+ events.push(rect.on_([ [ core.PointerEvent.DOUBLE_TAP, this.onDoubleTap, this ], [ core.PointerEvent.LONG_PRESS, this.onLongPress, this ] ]));
1206
1214
  this.waitLeafer(() => {
1207
1215
  events.push(editor.app.on_([ [ [ core.KeyEvent.HOLD, core.KeyEvent.UP ], this.onKey, this ], [ core.KeyEvent.DOWN, this.onArrow, this ], [ core.MoveEvent.BEFORE_MOVE, this.onMove, this, true ], [ core.ZoomEvent.BEFORE_ZOOM, this.onScale, this, true ], [ core.RotateEvent.BEFORE_ROTATE, this.onRotate, this, true ], [ core.MoveEvent.END, this.onMoveEnd, this ], [ core.ZoomEvent.END, this.resetDoing, this ], [ core.RotateEvent.END, this.resetDoing, this ] ]));
1208
1216
  });
@@ -1930,6 +1938,16 @@ exports.Editor = class Editor extends draw.Group {
1930
1938
  shiftItem(item) {
1931
1939
  this.hasItem(item) ? this.removeItem(item) : this.addItem(item);
1932
1940
  }
1941
+ setDimOthers(value, attrName = "dim", list) {
1942
+ if (!list) {
1943
+ const {dimTarget: dimTarget, targetLeafer: targetLeafer} = this;
1944
+ list = dimTarget ? draw.isArray(dimTarget) ? dimTarget : [ dimTarget ] : [ targetLeafer ];
1945
+ }
1946
+ if (list[0] && list[0][attrName] !== (value || false)) list.forEach(item => draw.DataHelper.stintSet(item, attrName, value));
1947
+ }
1948
+ setBright(value) {
1949
+ this.setDimOthers(value, "bright", this.list);
1950
+ }
1933
1951
  update() {
1934
1952
  if (this.editing) {
1935
1953
  if (!this.element.parent) return this.cancel();
@@ -2125,7 +2143,9 @@ exports.Editor = class Editor extends draw.Group {
2125
2143
  listenTargetEvents() {
2126
2144
  if (!this.targetEventIds.length) {
2127
2145
  const {app: app, leafer: leafer, targetLeafer: targetLeafer, editMask: editMask} = this;
2128
- this.targetEventIds = [ leafer.on_(draw.RenderEvent.START, this.onRenderStart, this), targetLeafer && targetLeafer.on_(draw.PropertyEvent.SCROLL, this.onChildScroll, this), app.on_(draw.RenderEvent.CHILD_START, this.onAppRenderStart, this) ];
2146
+ this.targetEventIds = [ leafer.on_(draw.RenderEvent.START, this.onRenderStart, this), targetLeafer && targetLeafer.on_(draw.PropertyEvent.SCROLL, this.onChildScroll, this), app.on_(draw.RenderEvent.CHILD_START, this.onAppRenderStart, this), app.on_(draw.LeaferEvent.UPDATE_MODE, data => {
2147
+ if (data.mode && data.mode !== "normal") this.cancel();
2148
+ }) ];
2129
2149
  if (editMask.visible) editMask.forceRender();
2130
2150
  }
2131
2151
  }
@@ -2150,10 +2170,10 @@ exports.Editor = class Editor extends draw.Group {
2150
2170
 
2151
2171
  __decorate([ mergeConfigAttr() ], exports.Editor.prototype, "mergeConfig", void 0);
2152
2172
 
2153
- __decorate([ targetAttr(onHover) ], exports.Editor.prototype, "hoverTarget", void 0);
2154
-
2155
2173
  __decorate([ targetAttr(onTarget) ], exports.Editor.prototype, "target", void 0);
2156
2174
 
2175
+ __decorate([ targetAttr(onHover) ], exports.Editor.prototype, "hoverTarget", void 0);
2176
+
2157
2177
  exports.Editor = __decorate([ core.useModule(TransformTool, [ "editBox", "editTool", "emitEvent" ]) ], exports.Editor);
2158
2178
 
2159
2179
  class InnerEditor {
@@ -1,4 +1,4 @@
1
- import { Event, isArray, defineKey, isNull, isUndefined, isObject, MatrixHelper, BoundsHelper, LeafBoundsHelper, getMatrixData, getBoundsData, UI, isString, Paint, Group, Rect, Bounds, LeafList, Direction9, AroundHelper, MathHelper, PointHelper, Box, isNumber, ResizeEvent, Text, Matrix, Debug, LeafHelper, PropertyEvent, DataHelper, Plugin, RenderEvent, getPointData, Creator, dataType } from "@leafer-ui/draw";
1
+ import { Event, isArray, defineKey, isNull, isUndefined, isObject, MatrixHelper, BoundsHelper, LeafBoundsHelper, getMatrixData, getBoundsData, UI, isString, Paint, Group, Rect, Bounds, LeafList, Direction9, AroundHelper, MathHelper, PointHelper, DragBoundsHelper, Box, isNumber, ResizeEvent, Text, Matrix, Debug, LeafHelper, PropertyEvent, DataHelper, Plugin, RenderEvent, LeaferEvent, getPointData, Creator, dataType } from "@leafer-ui/draw";
2
2
 
3
3
  import { PointerEvent, DragEvent, MoveEvent, ZoomEvent, KeyEvent, RotateEvent, useModule } from "@leafer-ui/core";
4
4
 
@@ -52,12 +52,15 @@ function targetAttr(fn) {
52
52
  set(value) {
53
53
  const old = this[privateKey];
54
54
  if (old !== value) {
55
- if (this.config) {
55
+ const t = this;
56
+ if (t.config) {
56
57
  const isSelect = key === "target";
57
58
  if (isSelect) {
59
+ t.setDimOthers(false);
60
+ t.setBright(false);
58
61
  if (isArray(value) && value.length > 1 && value[0].locked) value.splice(0, 1);
59
- if (this.single) this.element.syncEventer = null;
60
- const {beforeSelect: beforeSelect} = this.config;
62
+ if (t.single) t.element.syncEventer = null;
63
+ const {beforeSelect: beforeSelect} = t.config;
61
64
  if (beforeSelect) {
62
65
  const check = beforeSelect({
63
66
  target: value
@@ -67,7 +70,7 @@ function targetAttr(fn) {
67
70
  }
68
71
  const type = isSelect ? EditorEvent.BEFORE_SELECT : EditorEvent.BEFORE_HOVER;
69
72
  if (this.hasEvent(type)) this.emitEvent(new EditorEvent(type, {
70
- editor: this,
73
+ editor: t,
71
74
  value: value,
72
75
  oldValue: old
73
76
  }));
@@ -250,7 +253,7 @@ class EditSelect extends Group {
250
253
  }
251
254
  get running() {
252
255
  const {editor: editor} = this;
253
- return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector;
256
+ return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector && this.app.mode === "normal";
254
257
  }
255
258
  get isMoveMode() {
256
259
  return this.app && this.app.interaction.moveMode;
@@ -552,17 +555,13 @@ const EditDataHelper = {
552
555
  }
553
556
  toPoint(around || align, boxBounds, origin, true);
554
557
  if (dragBounds) {
555
- const allowBounds = dragBounds === "parent" ? target.parent.boxBounds : dragBounds;
556
- const childBounds = new Bounds(target.__localBoxBounds);
557
- if (BoundsHelper.includes(new Bounds(allowBounds).spread(.1), childBounds)) {
558
- childBounds.scaleOf(target.getLocalPointByInner(origin), scaleX, scaleY);
559
- if (!BoundsHelper.includes(allowBounds, childBounds)) {
560
- const realBounds = childBounds.getIntersect(allowBounds);
561
- const fitScaleX = realBounds.width / childBounds.width, fitScaleY = realBounds.height / childBounds.height;
562
- if (useScaleX) scaleX *= fitScaleX;
563
- if (useScaleY) scaleY *= fitScaleY;
564
- }
565
- }
558
+ const scaleData = {
559
+ x: scaleX,
560
+ y: scaleY
561
+ };
562
+ DragBoundsHelper.limitScaleOf(target, origin, scaleData);
563
+ scaleX = scaleData.x;
564
+ scaleY = scaleData.y;
566
565
  }
567
566
  if (useScaleX && widthRange) {
568
567
  const nowWidth = boxBounds.width * target.scaleX;
@@ -742,13 +741,18 @@ const cacheCursors = {};
742
741
  function updatePointCursor(editBox, e) {
743
742
  const {enterPoint: point, dragging: dragging, skewing: skewing, resizing: resizing, flippedX: flippedX, flippedY: flippedY} = editBox;
744
743
  if (!point || !editBox.editor.editing || !editBox.canUse) return;
744
+ if (point.name === "rect") return updateMoveCursor(editBox);
745
745
  if (point.name === "circle") return;
746
- if (point.pointType === "button") {
746
+ let {rotation: rotation} = editBox;
747
+ const {pointType: pointType} = point, {moveCursor: moveCursor, resizeCursor: resizeCursor, rotateCursor: rotateCursor, skewCursor: skewCursor, moveable: moveable, resizeable: resizeable, rotateable: rotateable, skewable: skewable} = editBox.mergeConfig;
748
+ if (pointType === "move") {
749
+ point.cursor = moveCursor;
750
+ if (!moveable) point.visible = false;
751
+ return;
752
+ } else if (pointType === "button") {
747
753
  if (!point.cursor) point.cursor = "pointer";
748
754
  return;
749
755
  }
750
- let {rotation: rotation} = editBox;
751
- const {pointType: pointType} = point, {resizeCursor: resizeCursor, rotateCursor: rotateCursor, skewCursor: skewCursor, resizeable: resizeable, rotateable: rotateable, skewable: skewable} = editBox.mergeConfig;
752
756
  let showResize = pointType.includes("resize");
753
757
  if (showResize && rotateable && (editBox.isHoldRotateKey(e) || !resizeable)) showResize = false;
754
758
  const showSkew = skewable && !showResize && (point.name === "resize-line" || pointType === "skew");
@@ -829,7 +833,7 @@ class EditBox extends Group {
829
833
  constructor(editor) {
830
834
  super();
831
835
  this.view = new Group;
832
- this.rect = new Box({
836
+ this.rect = new EditPoint({
833
837
  name: "rect",
834
838
  hitFill: "all",
835
839
  hitStroke: "none",
@@ -891,12 +895,13 @@ class EditBox extends Group {
891
895
  this.listenPointEvents(resizePoint, "resize", i);
892
896
  }
893
897
  this.listenPointEvents(circle, "rotate", 2);
898
+ this.listenPointEvents(rect, "move", 8);
894
899
  view.addMany(...rotatePoints, rect, circle, buttons, ...resizeLines, ...resizePoints);
895
900
  this.add(view);
896
901
  }
897
902
  load() {
898
- const {target: target, mergeConfig: mergeConfig, single: single, rect: rect, circle: circle, resizePoints: resizePoints} = this;
899
- const {stroke: stroke, strokeWidth: strokeWidth} = mergeConfig;
903
+ const {target: target, mergeConfig: mergeConfig, single: single, rect: rect, circle: circle, resizePoints: resizePoints, resizeLines: resizeLines} = this;
904
+ const {stroke: stroke, strokeWidth: strokeWidth, resizeLine: resizeLine} = mergeConfig;
900
905
  const pointsStyle = this.getPointsStyle();
901
906
  const middlePointsStyle = this.getMiddlePointsStyle();
902
907
  this.visible = !target.locked;
@@ -905,6 +910,10 @@ class EditBox extends Group {
905
910
  resizeP = resizePoints[i];
906
911
  resizeP.set(this.getPointStyle(i % 2 ? middlePointsStyle[(i - 1) / 2 % middlePointsStyle.length] : pointsStyle[i / 2 % pointsStyle.length]));
907
912
  resizeP.rotation = (i - (i % 2 ? 1 : 0)) / 2 * 90;
913
+ if (i % 2) resizeLines[(i - 1) / 2].set(Object.assign({
914
+ pointType: "resize",
915
+ rotation: (i - 1) / 2 * 90
916
+ }, resizeLine || {}));
908
917
  }
909
918
  circle.set(this.getPointStyle(mergeConfig.circle || mergeConfig.rotatePoint || pointsStyle[0]));
910
919
  rect.set(Object.assign({
@@ -949,10 +958,12 @@ class EditBox extends Group {
949
958
  if (this.app) this.rect.syncEventer = this.app.interaction.bottomList = null;
950
959
  }
951
960
  updateBounds(bounds) {
952
- const {editMask: editMask} = this.editor;
953
- const {mergeConfig: mergeConfig, single: single, rect: rect, circle: circle, buttons: buttons, resizePoints: resizePoints, rotatePoints: rotatePoints, resizeLines: resizeLines} = this;
954
- const {middlePoint: middlePoint, resizeable: resizeable, rotateable: rotateable, hideOnSmall: hideOnSmall, editBox: editBox, mask: mask, spread: spread, hideRotatePoints: hideRotatePoints, hideResizeLines: hideResizeLines} = mergeConfig;
961
+ const {editor: editor, mergeConfig: mergeConfig, single: single, rect: rect, circle: circle, buttons: buttons, resizePoints: resizePoints, rotatePoints: rotatePoints, resizeLines: resizeLines} = this;
962
+ const {editMask: editMask} = editor;
963
+ const {middlePoint: middlePoint, resizeable: resizeable, rotateable: rotateable, hideOnSmall: hideOnSmall, editBox: editBox, mask: mask, dimOthers: dimOthers, bright: bright, spread: spread, hideRotatePoints: hideRotatePoints, hideResizeLines: hideResizeLines} = mergeConfig;
955
964
  editMask.visible = mask ? true : 0;
965
+ editor.setDimOthers(dimOthers);
966
+ editor.setBright(!!dimOthers || bright);
956
967
  if (spread) BoundsHelper.spread(bounds, spread);
957
968
  if (this.view.worldOpacity) {
958
969
  const {width: width, height: height} = bounds;
@@ -973,10 +984,10 @@ class EditBox extends Group {
973
984
  resizeL.visible = resizeP.visible && !hideResizeLines;
974
985
  resizeP.visible = rotateP.visible = showPoints && !!middlePoint;
975
986
  if ((i + 1) / 2 % 2) {
976
- resizeL.width = width;
987
+ resizeL.width = width + resizeL.height;
977
988
  if (hideOnSmall && resizeP.width * 2 > width) resizeP.visible = false;
978
989
  } else {
979
- resizeL.height = height;
990
+ resizeL.width = height + resizeL.height;
980
991
  if (hideOnSmall && resizeP.width * 2 > height) resizeP.visible = false;
981
992
  }
982
993
  }
@@ -1053,7 +1064,7 @@ class EditBox extends Group {
1053
1064
  this.dragging = true;
1054
1065
  const point = this.dragPoint = e.current, {pointType: pointType} = point;
1055
1066
  const {editor: editor, dragStartData: dragStartData} = this, {target: target} = this, {moveable: moveable, resizeable: resizeable, rotateable: rotateable, skewable: skewable, hideOnMove: hideOnMove} = this.mergeConfig;
1056
- if (point.name === "rect") {
1067
+ if (pointType === "move") {
1057
1068
  moveable && (this.moving = true);
1058
1069
  editor.opacity = hideOnMove ? 0 : 1;
1059
1070
  } else {
@@ -1078,23 +1089,22 @@ class EditBox extends Group {
1078
1089
  if (this.moving && this.mergeConfig.dragLimitAnimate && this.target.dragBounds) this.transformTool.onMove(e);
1079
1090
  this.dragPoint = null;
1080
1091
  this.resetDoing();
1081
- const {name: name, pointType: pointType} = e.current;
1082
- if (name === "rect") this.editor.opacity = 1;
1092
+ const {pointType: pointType} = e.current;
1093
+ if (pointType === "move") this.editor.opacity = 1;
1083
1094
  if (pointType && pointType.includes("resize")) ResizeEvent.resizingKeys = null;
1084
1095
  }
1085
1096
  onDrag(e) {
1086
1097
  const {transformTool: transformTool, moving: moving, resizing: resizing, rotating: rotating, skewing: skewing} = this;
1087
1098
  if (moving) {
1088
1099
  transformTool.onMove(e);
1089
- updateMoveCursor(this);
1090
1100
  } else if (resizing || rotating || skewing) {
1091
1101
  const point = e.current;
1092
1102
  if (point.pointType) this.enterPoint = point;
1093
1103
  if (rotating) transformTool.onRotate(e);
1094
1104
  if (resizing) transformTool.onScale(e);
1095
1105
  if (skewing) transformTool.onSkew(e);
1096
- updatePointCursor(this, e);
1097
1106
  }
1107
+ updatePointCursor(this, e);
1098
1108
  }
1099
1109
  resetDoing() {
1100
1110
  if (this.canUse) this.dragging = this.gesturing = this.moving = this.resizing = this.rotating = this.skewing = false;
@@ -1190,17 +1200,15 @@ class EditBox extends Group {
1190
1200
  listenPointEvents(point, type, direction) {
1191
1201
  point.direction = direction;
1192
1202
  point.pointType = type;
1193
- const events = [ [ DragEvent.START, this.onDragStart, this ], [ DragEvent.DRAG, this.onDrag, this ], [ DragEvent.END, this.onDragEnd, this ], [ PointerEvent.LEAVE, () => {
1194
- this.enterPoint = null;
1195
- } ] ];
1196
- if (point.name !== "circle") events.push([ PointerEvent.ENTER, e => {
1203
+ this.__eventIds.push(point.on_([ [ DragEvent.START, this.onDragStart, this ], [ DragEvent.DRAG, this.onDrag, this ], [ DragEvent.END, this.onDragEnd, this ], [ PointerEvent.ENTER, e => {
1197
1204
  this.enterPoint = point, updatePointCursor(this, e);
1198
- } ]);
1199
- this.__eventIds.push(point.on_(events));
1205
+ } ], [ PointerEvent.LEAVE, () => {
1206
+ this.enterPoint = null;
1207
+ } ] ]));
1200
1208
  }
1201
1209
  __listenEvents() {
1202
1210
  const {rect: rect, editor: editor, __eventIds: events} = this;
1203
- events.push(rect.on_([ [ DragEvent.START, this.onDragStart, this ], [ DragEvent.DRAG, this.onDrag, this ], [ DragEvent.END, this.onDragEnd, this ], [ PointerEvent.ENTER, () => updateMoveCursor(this) ], [ PointerEvent.DOUBLE_TAP, this.onDoubleTap, this ], [ PointerEvent.LONG_PRESS, this.onLongPress, this ] ]));
1211
+ events.push(rect.on_([ [ PointerEvent.DOUBLE_TAP, this.onDoubleTap, this ], [ PointerEvent.LONG_PRESS, this.onLongPress, this ] ]));
1204
1212
  this.waitLeafer(() => {
1205
1213
  events.push(editor.app.on_([ [ [ KeyEvent.HOLD, KeyEvent.UP ], this.onKey, this ], [ KeyEvent.DOWN, this.onArrow, this ], [ MoveEvent.BEFORE_MOVE, this.onMove, this, true ], [ ZoomEvent.BEFORE_ZOOM, this.onScale, this, true ], [ RotateEvent.BEFORE_ROTATE, this.onRotate, this, true ], [ MoveEvent.END, this.onMoveEnd, this ], [ ZoomEvent.END, this.resetDoing, this ], [ RotateEvent.END, this.resetDoing, this ] ]));
1206
1214
  });
@@ -1928,6 +1936,16 @@ let Editor = class Editor extends Group {
1928
1936
  shiftItem(item) {
1929
1937
  this.hasItem(item) ? this.removeItem(item) : this.addItem(item);
1930
1938
  }
1939
+ setDimOthers(value, attrName = "dim", list) {
1940
+ if (!list) {
1941
+ const {dimTarget: dimTarget, targetLeafer: targetLeafer} = this;
1942
+ list = dimTarget ? isArray(dimTarget) ? dimTarget : [ dimTarget ] : [ targetLeafer ];
1943
+ }
1944
+ if (list[0] && list[0][attrName] !== (value || false)) list.forEach(item => DataHelper.stintSet(item, attrName, value));
1945
+ }
1946
+ setBright(value) {
1947
+ this.setDimOthers(value, "bright", this.list);
1948
+ }
1931
1949
  update() {
1932
1950
  if (this.editing) {
1933
1951
  if (!this.element.parent) return this.cancel();
@@ -2123,7 +2141,9 @@ let Editor = class Editor extends Group {
2123
2141
  listenTargetEvents() {
2124
2142
  if (!this.targetEventIds.length) {
2125
2143
  const {app: app, leafer: leafer, targetLeafer: targetLeafer, editMask: editMask} = this;
2126
- this.targetEventIds = [ leafer.on_(RenderEvent.START, this.onRenderStart, this), targetLeafer && targetLeafer.on_(PropertyEvent.SCROLL, this.onChildScroll, this), app.on_(RenderEvent.CHILD_START, this.onAppRenderStart, this) ];
2144
+ this.targetEventIds = [ leafer.on_(RenderEvent.START, this.onRenderStart, this), targetLeafer && targetLeafer.on_(PropertyEvent.SCROLL, this.onChildScroll, this), app.on_(RenderEvent.CHILD_START, this.onAppRenderStart, this), app.on_(LeaferEvent.UPDATE_MODE, data => {
2145
+ if (data.mode && data.mode !== "normal") this.cancel();
2146
+ }) ];
2127
2147
  if (editMask.visible) editMask.forceRender();
2128
2148
  }
2129
2149
  }
@@ -2148,10 +2168,10 @@ let Editor = class Editor extends Group {
2148
2168
 
2149
2169
  __decorate([ mergeConfigAttr() ], Editor.prototype, "mergeConfig", void 0);
2150
2170
 
2151
- __decorate([ targetAttr(onHover) ], Editor.prototype, "hoverTarget", void 0);
2152
-
2153
2171
  __decorate([ targetAttr(onTarget) ], Editor.prototype, "target", void 0);
2154
2172
 
2173
+ __decorate([ targetAttr(onHover) ], Editor.prototype, "hoverTarget", void 0);
2174
+
2155
2175
  Editor = __decorate([ useModule(TransformTool, [ "editBox", "editTool", "emitEvent" ]) ], Editor);
2156
2176
 
2157
2177
  class InnerEditor {