@leafer-in/editor 1.9.5 → 1.9.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-in/editor",
3
- "version": "1.9.5",
3
+ "version": "1.9.6",
4
4
  "description": "@leafer-in/editor",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -34,10 +34,10 @@
34
34
  "leaferjs"
35
35
  ],
36
36
  "peerDependencies": {
37
- "@leafer-ui/draw": "^1.9.5",
38
- "@leafer-ui/core": "^1.9.5",
39
- "@leafer-in/resize": "^1.9.5",
40
- "@leafer-ui/interface": "^1.9.5",
41
- "@leafer-in/interface": "^1.9.5"
37
+ "@leafer-ui/draw": "^1.9.6",
38
+ "@leafer-ui/core": "^1.9.6",
39
+ "@leafer-in/resize": "^1.9.6",
40
+ "@leafer-ui/interface": "^1.9.6",
41
+ "@leafer-in/interface": "^1.9.6"
42
42
  }
43
43
  }
package/src/Editor.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { IGroupInputData, IUI, IEventListenerId, IPointData, ILeafList, IEditSize, IGroup, IObject, IAlign, IAxis, IFunction, IMatrix, IApp } from '@leafer-ui/interface'
2
- import { Group, DataHelper, LeafList, RenderEvent, LeafHelper, Direction9, Plugin, isString, PropertyEvent } from '@leafer-ui/draw'
1
+ import { IGroupInputData, IUI, IEventListenerId, IPointData, ILeafList, IEditSize, IGroup, IObject, IAlign, IAxis, IFunction, IMatrix, IApp, ILeaferMode } from '@leafer-ui/interface'
2
+ import { Group, DataHelper, LeafList, RenderEvent, LeafHelper, Direction9, Plugin, isString, PropertyEvent, LeaferEvent } from '@leafer-ui/draw'
3
3
  import { DragEvent, RotateEvent, ZoomEvent, MoveEvent, useModule } from '@leafer-ui/core'
4
4
 
5
5
  import { IEditBox, IEditPoint, IEditor, IEditorConfig, IEditTool, IEditorScaleEvent, IInnerEditor, ISimulateElement } from '@leafer-in/interface'
@@ -376,7 +376,8 @@ export class Editor extends Group implements IEditor {
376
376
  this.targetEventIds = [
377
377
  leafer.on_(RenderEvent.START, this.onRenderStart, this),
378
378
  targetLeafer && targetLeafer.on_(PropertyEvent.SCROLL, this.onChildScroll, this),
379
- app.on_(RenderEvent.CHILD_START, this.onAppRenderStart, this)
379
+ app.on_(RenderEvent.CHILD_START, this.onAppRenderStart, this),
380
+ app.on_(LeaferEvent.UPDATE_MODE, (data: { mode: ILeaferMode }) => { if (data.mode && data.mode !== 'normal') this.cancel() })
380
381
  ]
381
382
  if (editMask.visible) editMask.forceRender()
382
383
  }
@@ -17,7 +17,7 @@ export class EditSelect extends Group implements IEditSelect {
17
17
  public editor: IEditor
18
18
 
19
19
  public get dragging(): boolean { return !!this.originList }
20
- public get running(): boolean { const { editor } = this; return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector }
20
+ public get running(): boolean { const { editor } = this; return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector && this.app.mode === 'normal' }
21
21
  public get isMoveMode(): boolean { return this.app && this.app.interaction.moveMode }
22
22
 
23
23
  public hoverStroker: IStroker = new Stroker()
@@ -1,5 +1,5 @@
1
1
  import { IBoundsData, IPointData, IAround, IAlign, IUI, ILayoutBoundsData } from '@leafer-ui/interface'
2
- import { AroundHelper, MathHelper, PointHelper, BoundsHelper, Bounds, Direction9 } from '@leafer-ui/draw'
2
+ import { AroundHelper, MathHelper, PointHelper, Direction9, DragBoundsHelper } from '@leafer-ui/draw'
3
3
 
4
4
  import { IEditorScaleEvent, IEditorSkewEvent, IEditorRotateEvent } from '@leafer-in/interface'
5
5
 
@@ -115,20 +115,10 @@ export const EditDataHelper = {
115
115
  toPoint(around || align, boxBounds, origin, true)
116
116
 
117
117
  if (dragBounds) {
118
- const allowBounds = dragBounds === 'parent' ? target.parent.boxBounds : dragBounds
119
- const childBounds = new Bounds(target.__localBoxBounds)
120
-
121
- if (BoundsHelper.includes(new Bounds(allowBounds).spread(0.1), childBounds)) {
122
-
123
- childBounds.scaleOf(target.getLocalPointByInner(origin), scaleX, scaleY)
124
-
125
- if (!BoundsHelper.includes(allowBounds, childBounds)) {
126
- const realBounds = childBounds.getIntersect(allowBounds)
127
- const fitScaleX = realBounds.width / childBounds.width, fitScaleY = realBounds.height / childBounds.height
128
- if (useScaleX) scaleX *= fitScaleX
129
- if (useScaleY) scaleY *= fitScaleY // 后续需优化带旋转的场景
130
- }
131
- }
118
+ const scaleData = { x: scaleX, y: scaleY }
119
+ DragBoundsHelper.limitScaleOf(target, origin, scaleData)
120
+ scaleX = scaleData.x
121
+ scaleY = scaleData.y
132
122
  }
133
123
 
134
124
  if (useScaleX && widthRange) {