@leafer-in/editor 2.2.10 → 2.2.11
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 +20 -4
- package/dist/editor.esm.js +20 -4
- package/dist/editor.esm.min.js +1 -1
- package/dist/editor.esm.min.js.map +1 -1
- package/dist/editor.js +20 -4
- 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/display/EditBox.ts +18 -3
- package/src/tool/EditTool.ts +14 -4
- package/types/index.d.ts +8 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-in/editor",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.11",
|
|
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": "^2.2.
|
|
38
|
-
"@leafer-ui/core": "^2.2.
|
|
39
|
-
"@leafer-in/resize": "^2.2.
|
|
40
|
-
"@leafer-ui/interface": "^2.2.
|
|
41
|
-
"@leafer-in/interface": "^2.2.
|
|
37
|
+
"@leafer-ui/draw": "^2.2.11",
|
|
38
|
+
"@leafer-ui/core": "^2.2.11",
|
|
39
|
+
"@leafer-in/resize": "^2.2.11",
|
|
40
|
+
"@leafer-ui/interface": "^2.2.11",
|
|
41
|
+
"@leafer-in/interface": "^2.2.11"
|
|
42
42
|
}
|
|
43
43
|
}
|
package/src/display/EditBox.ts
CHANGED
|
@@ -354,6 +354,7 @@ export class EditBox extends Group implements IEditBox {
|
|
|
354
354
|
// alt复制钩子
|
|
355
355
|
if (e.altKey && onCopy && onCopy() && this.editor.single) this.app.interaction.replaceDownTarget(this.target)
|
|
356
356
|
moveable && (this.moving = true)
|
|
357
|
+
if (this.moving) this.widgetsMoveStart(e)
|
|
357
358
|
} else {
|
|
358
359
|
if (pointType.includes('rotate') || this.isHoldRotateKey(e) || !resizeable) {
|
|
359
360
|
rotateable && (this.rotating = true)
|
|
@@ -370,6 +371,7 @@ export class EditBox extends Group implements IEditBox {
|
|
|
370
371
|
const { transformTool, moving, resizing, rotating, skewing } = this
|
|
371
372
|
if (moving) {
|
|
372
373
|
transformTool.onMove(e)
|
|
374
|
+
this.widgetsMove(e)
|
|
373
375
|
} else if (resizing || rotating || skewing) {
|
|
374
376
|
const point = e.current as IEditPoint
|
|
375
377
|
if (point.pointType) this.enterPoint = point// 防止变化
|
|
@@ -381,6 +383,7 @@ export class EditBox extends Group implements IEditBox {
|
|
|
381
383
|
}
|
|
382
384
|
|
|
383
385
|
public onDragEnd(e: DragEvent): void {
|
|
386
|
+
if (this.moving) this.widgetsMoveEnd(e)
|
|
384
387
|
this.onTransformEnd(e)
|
|
385
388
|
this.dragPoint = null
|
|
386
389
|
}
|
|
@@ -418,9 +421,9 @@ export class EditBox extends Group implements IEditBox {
|
|
|
418
421
|
if (isString(this.mergedConfig.moveable)) {
|
|
419
422
|
this.gesturing = this.moving = true
|
|
420
423
|
switch (e.type) {
|
|
421
|
-
case MoveEvent.START: this.onTransformStart(e); break
|
|
422
|
-
case MoveEvent.END: this.onTransformEnd(e); break
|
|
423
|
-
default: this.transformTool.onMove(e)
|
|
424
|
+
case MoveEvent.START: this.onTransformStart(e), this.widgetsMoveStart(e); break
|
|
425
|
+
case MoveEvent.END: this.onTransformEnd(e), this.widgetsMoveEnd(e); break
|
|
426
|
+
default: this.transformTool.onMove(e), this.widgetsMove(e)
|
|
424
427
|
}
|
|
425
428
|
}
|
|
426
429
|
}
|
|
@@ -595,6 +598,18 @@ export class EditBox extends Group implements IEditBox {
|
|
|
595
598
|
this.widgets.forEach(item => item.onUnload())
|
|
596
599
|
}
|
|
597
600
|
|
|
601
|
+
protected widgetsMoveStart(e: DragEvent | MoveEvent): void {
|
|
602
|
+
this.widgets.forEach(item => item.onMove && item.onMoveStart(e))
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
protected widgetsMove(e: DragEvent | MoveEvent): void {
|
|
606
|
+
this.widgets.forEach(item => item.onMove && item.onMove(e))
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
protected widgetsMoveEnd(e: DragEvent | MoveEvent): void {
|
|
610
|
+
this.widgets.forEach(item => item.onMove && item.onMoveEnd(e))
|
|
611
|
+
}
|
|
612
|
+
|
|
598
613
|
protected destroyWidgets(): void {
|
|
599
614
|
this.widgets.forEach(item => item.onDestroy())
|
|
600
615
|
}
|
package/src/tool/EditTool.ts
CHANGED
|
@@ -19,8 +19,9 @@ export class EditTool extends InnerEditor implements IEditTool {
|
|
|
19
19
|
// 操作
|
|
20
20
|
|
|
21
21
|
public onMove(e: IEditorMoveEvent): void {
|
|
22
|
-
if (this.isMotionElement
|
|
23
|
-
|
|
22
|
+
if (this.isMotionElement && this.onMoveMotion(e)) return
|
|
23
|
+
if (this.isFlowElement && this.onMoveFlow(e)) return
|
|
24
|
+
|
|
24
25
|
const { moveX, moveY, editor } = e
|
|
25
26
|
const { app, list } = editor
|
|
26
27
|
app.lockLayout()
|
|
@@ -29,6 +30,8 @@ export class EditTool extends InnerEditor implements IEditTool {
|
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
public onScale(e: IEditorScaleEvent): void {
|
|
33
|
+
if (this.isFlowElement && this.onScaleFlow(e)) return
|
|
34
|
+
|
|
32
35
|
const { scaleX, scaleY, transform, worldOrigin, editor } = e
|
|
33
36
|
const { app, list } = editor
|
|
34
37
|
app.lockLayout()
|
|
@@ -41,6 +44,8 @@ export class EditTool extends InnerEditor implements IEditTool {
|
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
public onRotate(e: IEditorRotateEvent): void {
|
|
47
|
+
if (this.isFlowElement && this.onRotateFlow(e)) return
|
|
48
|
+
|
|
44
49
|
const { rotation, transform, worldOrigin, editor } = e
|
|
45
50
|
const { app, list } = editor
|
|
46
51
|
app.lockLayout()
|
|
@@ -53,6 +58,8 @@ export class EditTool extends InnerEditor implements IEditTool {
|
|
|
53
58
|
}
|
|
54
59
|
|
|
55
60
|
public onSkew(e: IEditorSkewEvent): void {
|
|
61
|
+
if (this.isFlowElement && this.onSkewFlow(e)) return
|
|
62
|
+
|
|
56
63
|
const { skewX, skewY, transform, worldOrigin, editor } = e
|
|
57
64
|
const { app, list } = editor
|
|
58
65
|
app.lockLayout()
|
|
@@ -89,6 +96,9 @@ export interface EditTool {
|
|
|
89
96
|
readonly isMotionElement?: boolean
|
|
90
97
|
readonly isFlowElement?: boolean
|
|
91
98
|
|
|
92
|
-
onMoveMotion(e: IEditorMoveEvent):
|
|
93
|
-
onMoveFlow(e: IEditorMoveEvent):
|
|
99
|
+
onMoveMotion(e: IEditorMoveEvent): boolean
|
|
100
|
+
onMoveFlow(e: IEditorMoveEvent): boolean
|
|
101
|
+
onScaleFlow(e: IEditorScaleEvent): boolean
|
|
102
|
+
onRotateFlow(e: IEditorRotateEvent): boolean
|
|
103
|
+
onSkewFlow(e: IEditorSkewEvent): boolean
|
|
94
104
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -221,6 +221,9 @@ declare class EditBox extends Group implements IEditBox {
|
|
|
221
221
|
protected loadWidgets(): void;
|
|
222
222
|
protected updateWidgets(): void;
|
|
223
223
|
protected unloadWidgets(): void;
|
|
224
|
+
protected widgetsMoveStart(e: DragEvent | MoveEvent): void;
|
|
225
|
+
protected widgetsMove(e: DragEvent | MoveEvent): void;
|
|
226
|
+
protected widgetsMoveEnd(e: DragEvent | MoveEvent): void;
|
|
224
227
|
protected destroyWidgets(): void;
|
|
225
228
|
destroy(): void;
|
|
226
229
|
}
|
|
@@ -386,8 +389,11 @@ declare class EditTool extends InnerEditor implements IEditTool {
|
|
|
386
389
|
interface EditTool {
|
|
387
390
|
readonly isMotionElement?: boolean;
|
|
388
391
|
readonly isFlowElement?: boolean;
|
|
389
|
-
onMoveMotion(e: IEditorMoveEvent):
|
|
390
|
-
onMoveFlow(e: IEditorMoveEvent):
|
|
392
|
+
onMoveMotion(e: IEditorMoveEvent): boolean;
|
|
393
|
+
onMoveFlow(e: IEditorMoveEvent): boolean;
|
|
394
|
+
onScaleFlow(e: IEditorScaleEvent): boolean;
|
|
395
|
+
onRotateFlow(e: IEditorRotateEvent): boolean;
|
|
396
|
+
onSkewFlow(e: IEditorSkewEvent): boolean;
|
|
391
397
|
}
|
|
392
398
|
|
|
393
399
|
declare class LineEditTool extends EditTool {
|