@leafer-in/editor 1.9.1 → 1.9.2
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 +22 -9
- package/dist/editor.esm.js +22 -9
- package/dist/editor.esm.min.js +1 -1
- package/dist/editor.esm.min.js.map +1 -1
- package/dist/editor.js +22 -9
- 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 +7 -3
- package/src/display/EditBox.ts +7 -2
- package/src/helper/EditorHelper.ts +1 -1
- package/src/tool/TransformTool.ts +9 -6
- package/types/index.d.ts +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-in/editor",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.2",
|
|
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.
|
|
38
|
-
"@leafer-ui/core": "^1.9.
|
|
39
|
-
"@leafer-in/resize": "^1.9.
|
|
40
|
-
"@leafer-ui/interface": "^1.9.
|
|
41
|
-
"@leafer-in/interface": "^1.9.
|
|
37
|
+
"@leafer-ui/draw": "^1.9.2",
|
|
38
|
+
"@leafer-ui/core": "^1.9.2",
|
|
39
|
+
"@leafer-in/resize": "^1.9.2",
|
|
40
|
+
"@leafer-ui/interface": "^1.9.2",
|
|
41
|
+
"@leafer-in/interface": "^1.9.2"
|
|
42
42
|
}
|
|
43
43
|
}
|
package/src/Editor.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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 } from '@leafer-ui/draw'
|
|
2
|
+
import { Group, DataHelper, LeafList, RenderEvent, LeafHelper, Direction9, Plugin, isString, PropertyEvent } 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'
|
|
@@ -78,6 +78,7 @@ export class Editor extends Group implements IEditor {
|
|
|
78
78
|
public selector: EditSelect = new EditSelect(this)
|
|
79
79
|
public editMask: EditMask = new EditMask(this)
|
|
80
80
|
|
|
81
|
+
public get targetLeafer() { const first = this.list[0]; return first && first.leafer }
|
|
81
82
|
public targetChanged: boolean
|
|
82
83
|
public targetEventIds: IEventListenerId[] = []
|
|
83
84
|
|
|
@@ -284,7 +285,6 @@ export class Editor extends Group implements IEditor {
|
|
|
284
285
|
this.emitInnerEvent(InnerEditorEvent.BEFORE_OPEN)
|
|
285
286
|
this.innerEditor.load()
|
|
286
287
|
this.emitInnerEvent(InnerEditorEvent.OPEN)
|
|
287
|
-
console.log('hello')
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
}
|
|
@@ -345,14 +345,18 @@ export class Editor extends Group implements IEditor {
|
|
|
345
345
|
if (this.targetChanged) this.update()
|
|
346
346
|
}
|
|
347
347
|
|
|
348
|
+
protected onChildScroll(): void {
|
|
349
|
+
if (this.multiple) this.updateEditBox()
|
|
350
|
+
}
|
|
348
351
|
|
|
349
352
|
// event
|
|
350
353
|
|
|
351
354
|
public listenTargetEvents(): void {
|
|
352
355
|
if (!this.targetEventIds.length) {
|
|
353
|
-
const { app, leafer, editMask } = this
|
|
356
|
+
const { app, leafer, targetLeafer, editMask } = this
|
|
354
357
|
this.targetEventIds = [
|
|
355
358
|
leafer.on_(RenderEvent.START, this.onRenderStart, this),
|
|
359
|
+
targetLeafer && targetLeafer.on_(PropertyEvent.SCROLL, this.onChildScroll, this),
|
|
356
360
|
app.on_(RenderEvent.CHILD_START, this.onAppRenderStart, this)
|
|
357
361
|
]
|
|
358
362
|
if (editMask.visible) editMask.forceRender()
|
package/src/display/EditBox.ts
CHANGED
|
@@ -307,7 +307,7 @@ export class EditBox extends Group implements IEditBox {
|
|
|
307
307
|
}
|
|
308
308
|
|
|
309
309
|
protected onDragEnd(e: DragEvent): void {
|
|
310
|
-
if (this.
|
|
310
|
+
if (this.moving) this.transformTool.onMove(e)
|
|
311
311
|
|
|
312
312
|
this.dragPoint = null
|
|
313
313
|
this.resetDoing()
|
|
@@ -347,6 +347,11 @@ export class EditBox extends Group implements IEditBox {
|
|
|
347
347
|
}
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
+
public onMoveEnd(e: MoveEvent): void {
|
|
351
|
+
if (this.moving) this.transformTool.onMove(e)
|
|
352
|
+
this.resetDoing()
|
|
353
|
+
}
|
|
354
|
+
|
|
350
355
|
public onScale(e: ZoomEvent): void {
|
|
351
356
|
if (this.canGesture) {
|
|
352
357
|
e.stop()
|
|
@@ -468,7 +473,7 @@ export class EditBox extends Group implements IEditBox {
|
|
|
468
473
|
[MoveEvent.BEFORE_MOVE, this.onMove, this, true],
|
|
469
474
|
[ZoomEvent.BEFORE_ZOOM, this.onScale, this, true],
|
|
470
475
|
[RotateEvent.BEFORE_ROTATE, this.onRotate, this, true],
|
|
471
|
-
[MoveEvent.END, this.
|
|
476
|
+
[MoveEvent.END, this.onMoveEnd, this],
|
|
472
477
|
[ZoomEvent.END, this.resetDoing, this],
|
|
473
478
|
[RotateEvent.END, this.resetDoing, this],
|
|
474
479
|
])
|
|
@@ -22,7 +22,7 @@ export const EditorHelper = {
|
|
|
22
22
|
list.sort(order)
|
|
23
23
|
|
|
24
24
|
const matrx = new Matrix(element.worldTransform)
|
|
25
|
-
matrx.divideParent(parent.
|
|
25
|
+
matrx.divideParent(parent.scrollWorldTransform)
|
|
26
26
|
group.setTransform(matrx)
|
|
27
27
|
group.editable = true
|
|
28
28
|
group.hitChildren = false
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IEvent, IPointData, IAlign, IAxis, IFunction, IMatrix, IUI } from '@leafer-ui/interface'
|
|
2
|
-
import { MathHelper, Matrix, LeafHelper, AroundHelper, isObject, isNumber, isUndefined } from '@leafer-ui/draw'
|
|
2
|
+
import { MathHelper, Matrix, LeafHelper, AroundHelper, isObject, isString, isNumber, isUndefined } from '@leafer-ui/draw'
|
|
3
3
|
import { DragEvent, RotateEvent, ZoomEvent, MoveEvent } from '@leafer-ui/core'
|
|
4
4
|
|
|
5
5
|
import { IEditBox, IEditPoint, IEditTool, IEditorScaleEvent, ISimulateElement, IEditorMoveEvent, IEditorRotateEvent, IEditorSkewEvent } from '@leafer-in/interface'
|
|
@@ -26,10 +26,12 @@ export class TransformTool implements ITransformTool { // Editor use
|
|
|
26
26
|
const { target, mergeConfig, dragStartData, app } = this.editBox
|
|
27
27
|
|
|
28
28
|
let move: IPointData, { dragLimitAnimate } = mergeConfig
|
|
29
|
+
|
|
29
30
|
if (isUndefined(dragLimitAnimate)) dragLimitAnimate = app && app.config.pointer.dragLimitAnimate
|
|
30
31
|
|
|
31
|
-
const isMoveEnd = e.type ===
|
|
32
|
-
const
|
|
32
|
+
const isMoveEnd = e.type === MoveEvent.END || e.type === DragEvent.END
|
|
33
|
+
const axisDrag = isString(target.draggable)
|
|
34
|
+
const checkLimitMove = !dragLimitAnimate || isMoveEnd || axisDrag
|
|
33
35
|
|
|
34
36
|
if (e instanceof MoveEvent) {
|
|
35
37
|
|
|
@@ -49,9 +51,10 @@ export class TransformTool implements ITransformTool { // Editor use
|
|
|
49
51
|
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
if (
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
if (move.x || move.y) {
|
|
55
|
+
if (dragLimitAnimate && !axisDrag && isMoveEnd) LeafHelper.animateMove(this as unknown as IUI, move, isNumber(dragLimitAnimate) ? dragLimitAnimate : 0.3) // 是否进行动画
|
|
56
|
+
else this.move(move)
|
|
57
|
+
}
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
public onScale(e: DragEvent | ZoomEvent): void {
|
package/types/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as _leafer_ui_interface from '@leafer-ui/interface';
|
|
1
2
|
import { IBounds, ILeafList, IUI, IFunction, IEventListenerId, ILeaf, IPointerEvent, ILeaferCanvas, IRenderOptions, IGroup, IObject, IGroupInputData, IEditSize, IPointData, IAlign, IAxis, IMatrix, IApp, IBox, IEditorDragStartData, IEditorConfig as IEditorConfig$1, ITransformTool, IBoundsData, IBoxInputData, IUIEvent, IKeyEvent, IRect, IRectInputData, IMatrixData, IDragEvent, IAround, IEvent, ILayoutBoundsData } from '@leafer-ui/interface';
|
|
2
3
|
import { Group, UI, Direction9, Box, Event } from '@leafer-ui/draw';
|
|
3
4
|
import { PointerEvent, DragEvent, MoveEvent, ZoomEvent, RotateEvent, KeyEvent } from '@leafer-ui/core';
|
|
@@ -80,6 +81,7 @@ declare class Editor extends Group implements IEditor {
|
|
|
80
81
|
editToolList: IObject;
|
|
81
82
|
selector: EditSelect;
|
|
82
83
|
editMask: EditMask;
|
|
84
|
+
get targetLeafer(): _leafer_ui_interface.ILeafer;
|
|
83
85
|
targetChanged: boolean;
|
|
84
86
|
targetEventIds: IEventListenerId[];
|
|
85
87
|
constructor(userConfig?: IEditorConfig, data?: IGroupInputData);
|
|
@@ -123,6 +125,7 @@ declare class Editor extends Group implements IEditor {
|
|
|
123
125
|
toBottom(): void;
|
|
124
126
|
protected onAppRenderStart(app: IApp): void;
|
|
125
127
|
protected onRenderStart(): void;
|
|
128
|
+
protected onChildScroll(): void;
|
|
126
129
|
listenTargetEvents(): void;
|
|
127
130
|
removeTargetEvents(): void;
|
|
128
131
|
destroy(): void;
|
|
@@ -180,6 +183,7 @@ declare class EditBox extends Group implements IEditBox {
|
|
|
180
183
|
protected onDrag(e: DragEvent): void;
|
|
181
184
|
protected resetDoing(): void;
|
|
182
185
|
onMove(e: MoveEvent): void;
|
|
186
|
+
onMoveEnd(e: MoveEvent): void;
|
|
183
187
|
onScale(e: ZoomEvent): void;
|
|
184
188
|
onRotate(e: RotateEvent): void;
|
|
185
189
|
isHoldRotateKey(e: IUIEvent): boolean;
|