@leafer-in/editor 1.0.0-rc.20 → 1.0.0-rc.22
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.esm.js +472 -296
- package/dist/editor.esm.min.js +1 -1
- package/dist/editor.js +501 -323
- package/dist/editor.min.js +1 -1
- package/package.json +5 -7
- package/src/Editor.ts +115 -26
- package/src/config.ts +1 -0
- package/src/decorator/data.ts +1 -1
- package/src/display/EditBox.ts +126 -70
- package/src/display/EditPoint.ts +3 -3
- package/src/display/EditSelect.ts +42 -36
- package/src/display/SelectArea.ts +1 -1
- package/src/display/Stroker.ts +5 -5
- package/src/editor/cursor.ts +4 -4
- package/src/editor/simulate.ts +1 -1
- package/src/editor/target.ts +4 -2
- package/src/event/EditorEvent.ts +1 -1
- package/src/event/EditorScaleEvent.ts +3 -2
- package/src/helper/EditDataHelper.ts +8 -11
- package/src/helper/EditSelectHelper.ts +1 -1
- package/src/helper/EditorHelper.ts +1 -1
- package/src/index.ts +29 -6
- package/src/tool/EditTool.ts +36 -12
- package/src/tool/EditToolCreator.ts +32 -0
- package/src/tool/InnerEditor.ts +64 -0
- package/src/tool/LineEditTool.ts +8 -8
- package/types/index.d.ts +96 -42
- package/src/tool/index.ts +0 -21
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { IBoundsData, IPointData, IAround } from '@leafer-ui/interface'
|
|
2
|
-
import { AroundHelper, PointHelper } from '@leafer-ui/
|
|
2
|
+
import { AroundHelper, PointHelper, Direction9 } from '@leafer-ui/draw'
|
|
3
3
|
|
|
4
|
-
import { IEditorScaleEvent,
|
|
4
|
+
import { IEditorScaleEvent, IEditorSkewEvent, IEditorRotateEvent } from '@leafer-in/interface'
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
const { topLeft, top, topRight, right, bottomRight, bottom, bottomLeft, left } =
|
|
7
|
+
const { topLeft, top, topRight, right, bottomRight, bottom, bottomLeft, left } = Direction9
|
|
8
8
|
const { toPoint } = AroundHelper
|
|
9
9
|
|
|
10
10
|
export const EditDataHelper = {
|
|
11
11
|
|
|
12
|
-
getScaleData(bounds: IBoundsData, direction:
|
|
12
|
+
getScaleData(bounds: IBoundsData, direction: Direction9, pointMove: IPointData, lockRatio: boolean | 'corner', around: IAround): IEditorScaleEvent {
|
|
13
13
|
let origin: IPointData, scaleX: number = 1, scaleY: number = 1
|
|
14
14
|
const { width, height } = bounds
|
|
15
15
|
|
|
@@ -67,10 +67,7 @@ export const EditDataHelper = {
|
|
|
67
67
|
|
|
68
68
|
if (lockRatio) {
|
|
69
69
|
const unlockSide = lockRatio === 'corner' && direction % 2
|
|
70
|
-
if (!unlockSide)
|
|
71
|
-
if (scaleY !== 1) scaleX = scaleY
|
|
72
|
-
else scaleY = scaleX
|
|
73
|
-
}
|
|
70
|
+
if (!unlockSide) scaleX = scaleY = Math.sqrt(scaleX * scaleY)
|
|
74
71
|
}
|
|
75
72
|
|
|
76
73
|
toPoint(around || origin, bounds, origin)
|
|
@@ -78,7 +75,7 @@ export const EditDataHelper = {
|
|
|
78
75
|
return { origin, scaleX, scaleY, direction, lockRatio, around }
|
|
79
76
|
},
|
|
80
77
|
|
|
81
|
-
getRotateData(bounds: IBoundsData, direction:
|
|
78
|
+
getRotateData(bounds: IBoundsData, direction: Direction9, current: IPointData, last: IPointData, around: IAround): IEditorRotateEvent {
|
|
82
79
|
let origin: IPointData
|
|
83
80
|
|
|
84
81
|
switch (direction) {
|
|
@@ -103,7 +100,7 @@ export const EditDataHelper = {
|
|
|
103
100
|
return { origin, rotation: PointHelper.getRotation(last, origin, current) }
|
|
104
101
|
},
|
|
105
102
|
|
|
106
|
-
getSkewData(bounds: IBoundsData, direction:
|
|
103
|
+
getSkewData(bounds: IBoundsData, direction: Direction9, move: IPointData, around: IAround): IEditorSkewEvent {
|
|
107
104
|
let origin: IPointData, skewX = 0, skewY = 0
|
|
108
105
|
let last: IPointData
|
|
109
106
|
|
|
@@ -153,7 +150,7 @@ export const EditDataHelper = {
|
|
|
153
150
|
return direction
|
|
154
151
|
},
|
|
155
152
|
|
|
156
|
-
getFlipDirection(direction:
|
|
153
|
+
getFlipDirection(direction: Direction9, flipedX: boolean, flipedY: boolean): Direction9 {
|
|
157
154
|
if (flipedX) {
|
|
158
155
|
switch (direction) {
|
|
159
156
|
case left: direction = right; break
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IGroup, IGroupInputData, ILeaf, IUI } from '@leafer-ui/interface'
|
|
2
|
-
import { Group, Matrix } from '@leafer-ui/
|
|
2
|
+
import { Group, Matrix } from '@leafer-ui/draw'
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
const order = (a: ILeaf, b: ILeaf) => a.parent.children.indexOf(a) - b.parent.children.indexOf(b)
|
package/src/index.ts
CHANGED
|
@@ -14,17 +14,40 @@ export { EditorScaleEvent } from './event/EditorScaleEvent'
|
|
|
14
14
|
export { EditorRotateEvent } from './event/EditorRotateEvent'
|
|
15
15
|
export { EditorSkewEvent } from './event/EditorSkewEvent'
|
|
16
16
|
|
|
17
|
-
export {
|
|
17
|
+
export { EditToolCreator, registerEditTool, registerInnerEditor } from './tool/EditToolCreator'
|
|
18
|
+
export { InnerEditor } from './tool/InnerEditor'
|
|
18
19
|
export { EditTool } from './tool/EditTool'
|
|
20
|
+
export { LineEditTool } from './tool/LineEditTool'
|
|
19
21
|
|
|
20
22
|
export { EditorHelper } from './helper/EditorHelper'
|
|
21
23
|
export { EditDataHelper } from './helper/EditDataHelper'
|
|
22
24
|
export { EditSelectHelper } from './helper/EditSelectHelper'
|
|
23
25
|
|
|
24
|
-
import { IEditor, IEditorConfig } from '@leafer-in/interface'
|
|
25
|
-
import { Creator } from '@leafer-ui/
|
|
26
|
+
import { IEditor, IEditorConfig, IEditToolFunction, IEditorConfigFunction } from '@leafer-in/interface'
|
|
27
|
+
import { Creator, UI, Line, defineKey } from '@leafer-ui/draw'
|
|
28
|
+
|
|
26
29
|
import { Editor } from './Editor'
|
|
27
30
|
|
|
28
|
-
Creator.editor = function (options?: IEditorConfig): IEditor {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
Creator.editor = function (options?: IEditorConfig): IEditor { return new Editor(options) }
|
|
32
|
+
|
|
33
|
+
UI.setEditConfig = function (config: IEditorConfig | IEditorConfigFunction): void {
|
|
34
|
+
defineKey(this.prototype, 'editConfig', {
|
|
35
|
+
get(): IEditorConfig { return typeof config === 'function' ? config(this) : config }
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
UI.setEditOuter = function (toolName: string | IEditToolFunction): void {
|
|
40
|
+
defineKey(this.prototype, 'editOuter', {
|
|
41
|
+
get(): string { return typeof toolName === 'string' ? toolName : toolName(this) }
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
UI.setEditInner = function (editorName: string | IEditToolFunction): void {
|
|
46
|
+
defineKey(this.prototype, 'editInner', {
|
|
47
|
+
get(): string { return typeof editorName === 'string' ? editorName : editorName(this) }
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
Line.setEditOuter(function (line: Line): string {
|
|
52
|
+
return (line.points || line.pathInputed) ? 'EditTool' : 'LineEditTool'
|
|
53
|
+
})
|
package/src/tool/EditTool.ts
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IEditorScaleEvent, IEditorRotateEvent, IEditTool, IEditorSkewEvent, IEditorMoveEvent } from '@leafer-in/interface'
|
|
2
2
|
|
|
3
|
+
import { registerEditTool, EditToolCreator } from './EditToolCreator'
|
|
4
|
+
import { InnerEditor } from './InnerEditor'
|
|
3
5
|
|
|
4
|
-
export class EditTool implements IEditTool {
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
@registerEditTool()
|
|
8
|
+
export class EditTool extends InnerEditor implements IEditTool {
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
static registerEditTool() {
|
|
11
|
+
EditToolCreator.register(this)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
public get tag() { return 'EditTool' }
|
|
9
16
|
|
|
10
|
-
|
|
17
|
+
|
|
18
|
+
// 操作
|
|
19
|
+
|
|
20
|
+
public onMove(e: IEditorMoveEvent): void {
|
|
11
21
|
const { moveX, moveY, editor } = e
|
|
12
22
|
const { app, list } = editor
|
|
13
23
|
app.lockLayout()
|
|
@@ -17,7 +27,7 @@ export class EditTool implements IEditTool {
|
|
|
17
27
|
app.unlockLayout()
|
|
18
28
|
}
|
|
19
29
|
|
|
20
|
-
onScale(e: IEditorScaleEvent): void {
|
|
30
|
+
public onScale(e: IEditorScaleEvent): void {
|
|
21
31
|
const { scaleX, scaleY, transform, worldOrigin, editor } = e
|
|
22
32
|
const { app, list } = editor
|
|
23
33
|
app.lockLayout()
|
|
@@ -32,7 +42,7 @@ export class EditTool implements IEditTool {
|
|
|
32
42
|
app.unlockLayout()
|
|
33
43
|
}
|
|
34
44
|
|
|
35
|
-
onRotate(e: IEditorRotateEvent): void {
|
|
45
|
+
public onRotate(e: IEditorRotateEvent): void {
|
|
36
46
|
const { rotation, transform, worldOrigin, editor } = e
|
|
37
47
|
const { app, list } = editor
|
|
38
48
|
app.lockLayout()
|
|
@@ -47,7 +57,7 @@ export class EditTool implements IEditTool {
|
|
|
47
57
|
app.unlockLayout()
|
|
48
58
|
}
|
|
49
59
|
|
|
50
|
-
onSkew(e: IEditorSkewEvent): void {
|
|
60
|
+
public onSkew(e: IEditorSkewEvent): void {
|
|
51
61
|
const { skewX, skewY, transform, worldOrigin, editor } = e
|
|
52
62
|
const { app, list } = editor
|
|
53
63
|
app.lockLayout()
|
|
@@ -62,14 +72,28 @@ export class EditTool implements IEditTool {
|
|
|
62
72
|
app.unlockLayout()
|
|
63
73
|
}
|
|
64
74
|
|
|
65
|
-
|
|
66
|
-
const { simulateTarget, element } = editor
|
|
75
|
+
// 状态
|
|
67
76
|
|
|
77
|
+
public load(): void {
|
|
78
|
+
this.editBox.view.visible = true
|
|
79
|
+
this.onLoad()
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public update(): void {
|
|
83
|
+
const { editor, editBox } = this
|
|
84
|
+
|
|
85
|
+
const { simulateTarget, element } = editor
|
|
68
86
|
if (editor.multiple) simulateTarget.parent.updateLayout()
|
|
69
87
|
|
|
70
88
|
const { x, y, scaleX, scaleY, rotation, skewX, skewY, width, height } = element.getLayoutBounds('box', editor, true)
|
|
71
|
-
|
|
72
|
-
|
|
89
|
+
editBox.set({ x, y, scaleX, scaleY, rotation, skewX, skewY })
|
|
90
|
+
editBox.update({ x: 0, y: 0, width, height })
|
|
91
|
+
this.onUpdate()
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
public unload(): void {
|
|
95
|
+
this.editBox.view.visible = false
|
|
96
|
+
this.onUnload()
|
|
73
97
|
}
|
|
74
98
|
|
|
75
99
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { IObject } from '@leafer-ui/interface'
|
|
2
|
+
import { Debug } from '@leafer-ui/draw'
|
|
3
|
+
|
|
4
|
+
import { IEditTool, IEditor } from '@leafer-in/interface'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const debug = Debug.get('EditToolCreator')
|
|
8
|
+
|
|
9
|
+
export function registerEditTool() {
|
|
10
|
+
return (target: IObject) => {
|
|
11
|
+
EditToolCreator.register(target)
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const registerInnerEditor = registerEditTool
|
|
16
|
+
|
|
17
|
+
export const EditToolCreator = {
|
|
18
|
+
|
|
19
|
+
list: {} as IObject,
|
|
20
|
+
|
|
21
|
+
register(EditTool: IObject): void {
|
|
22
|
+
const { tag } = EditTool.prototype as IEditTool
|
|
23
|
+
list[tag] ? debug.repeat(tag) : (list[tag] = EditTool)
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
get(tag: string, editor: IEditor): IEditTool {
|
|
27
|
+
return new list[tag](editor)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const { list } = EditToolCreator
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { IGroup, IEventListenerId } from '@leafer-ui/interface'
|
|
2
|
+
import { IInnerEditor, IEditor, IEditBox } from '@leafer-in/interface'
|
|
3
|
+
|
|
4
|
+
import { Group } from '@leafer-ui/draw'
|
|
5
|
+
import { EditToolCreator } from './EditToolCreator'
|
|
6
|
+
|
|
7
|
+
export class InnerEditor implements IInnerEditor {
|
|
8
|
+
|
|
9
|
+
static registerInnerEditor() {
|
|
10
|
+
EditToolCreator.register(this)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
public get tag() { return 'InnerEditor' }
|
|
15
|
+
|
|
16
|
+
public editor: IEditor
|
|
17
|
+
public get editBox(): IEditBox { return this.editor.editBox }
|
|
18
|
+
|
|
19
|
+
public view: IGroup
|
|
20
|
+
|
|
21
|
+
public eventIds: IEventListenerId[]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
constructor(editor: IEditor) {
|
|
25
|
+
this.editor = editor
|
|
26
|
+
this.create()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
public onCreate(): void { }
|
|
31
|
+
public create(): void {
|
|
32
|
+
this.view = new Group()
|
|
33
|
+
this.onCreate()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
// 状态
|
|
38
|
+
|
|
39
|
+
public onLoad(): void { }
|
|
40
|
+
public load(): void {
|
|
41
|
+
this.editor.selector.hittable = this.editor.app.tree.hitChildren = false
|
|
42
|
+
this.onLoad()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public onUpdate(): void { }
|
|
46
|
+
public update(): void { this.onUpdate() }
|
|
47
|
+
|
|
48
|
+
public onUnload(): void { }
|
|
49
|
+
public unload(): void {
|
|
50
|
+
this.editor.selector.hittable = this.editor.app.tree.hitChildren = true
|
|
51
|
+
this.onUnload()
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public onDestroy(): void { }
|
|
55
|
+
public destroy(): void {
|
|
56
|
+
this.onDestroy()
|
|
57
|
+
if (this.editor) {
|
|
58
|
+
if (this.view) this.view.destroy()
|
|
59
|
+
if (this.eventIds) this.editor.off_(this.eventIds)
|
|
60
|
+
this.editor = this.view = this.eventIds = null
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
}
|
package/src/tool/LineEditTool.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IEditorScaleEvent, ILine, IEditorSkewEvent } from '@leafer-in/interface'
|
|
2
2
|
|
|
3
|
-
import { getPointData } from '@leafer-ui/
|
|
3
|
+
import { getPointData, Direction9 } from '@leafer-ui/draw'
|
|
4
4
|
|
|
5
5
|
import { EditTool } from './EditTool'
|
|
6
|
+
import { registerEditTool } from './EditToolCreator'
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
const { left, right } =
|
|
10
|
+
const { left, right } = Direction9
|
|
10
11
|
|
|
12
|
+
@registerEditTool()
|
|
11
13
|
export class LineEditTool extends EditTool {
|
|
12
14
|
|
|
13
|
-
public tag
|
|
15
|
+
public get tag() { return 'LineEditTool' }
|
|
14
16
|
|
|
15
17
|
public scaleOfEvent = true
|
|
16
18
|
|
|
@@ -69,10 +71,8 @@ export class LineEditTool extends EditTool {
|
|
|
69
71
|
|
|
70
72
|
}
|
|
71
73
|
|
|
72
|
-
|
|
73
|
-
const { rotatePoints, resizeLines, resizePoints } = editor.editBox
|
|
74
|
-
super.update(editor)
|
|
75
|
-
|
|
74
|
+
onUpdate() {
|
|
75
|
+
const { rotatePoints, resizeLines, resizePoints } = this.editor.editBox
|
|
76
76
|
for (let i = 0; i < 8; i++) {
|
|
77
77
|
if (i < 4) resizeLines[i].visible = false
|
|
78
78
|
resizePoints[i].visible = rotatePoints[i].visible = (i === left || i === right)
|
package/types/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export * from '@leafer-ui/scale';
|
|
2
|
-
import { IBounds, ILeafList, IUI, IEventListenerId, ILeaf, IGroup, IGroupInputData, IEditSize,
|
|
3
|
-
import { Group,
|
|
4
|
-
import {
|
|
2
|
+
import { IBounds, ILeafList, IUI, IEventListenerId, ILeaf, IPointerEvent, IGroup, IObject, IPointData, IGroupInputData, IEditSize, IBox, IBoundsData, IBoxInputData, IKeyEvent, IRect, IRectInputData, ILeaferCanvas, IRenderOptions, IMatrixData, IDragEvent, IAround } from '@leafer-ui/interface';
|
|
3
|
+
import { Group, Event, Direction9, Box, UI, Answer } from '@leafer-ui/draw';
|
|
4
|
+
import { PointerEvent, DragEvent, MoveEvent, RotateEvent } from '@leafer-ui/core';
|
|
5
|
+
import { IEditSelect, IEditor, IStroker, ISelectArea, IEditorConfig, IEditBox, IEditTool, IInnerEditor, IEditorScaleEvent, IEditorEvent, IEditPoint, IEditPointType, IEditorMoveEvent, IEditorRotateEvent, IEditorSkewEvent } from '@leafer-in/interface';
|
|
5
6
|
|
|
6
7
|
declare class EditSelect extends Group implements IEditSelect {
|
|
7
8
|
editor: IEditor;
|
|
@@ -13,7 +14,7 @@ declare class EditSelect extends Group implements IEditSelect {
|
|
|
13
14
|
bounds: IBounds;
|
|
14
15
|
selectArea: ISelectArea;
|
|
15
16
|
protected originList: ILeafList;
|
|
16
|
-
protected
|
|
17
|
+
protected needRemoveItem: IUI;
|
|
17
18
|
protected __eventIds: IEventListenerId[];
|
|
18
19
|
constructor(editor: IEditor);
|
|
19
20
|
protected onHover(): void;
|
|
@@ -22,14 +23,17 @@ declare class EditSelect extends Group implements IEditSelect {
|
|
|
22
23
|
protected onPointerMove(e: PointerEvent): void;
|
|
23
24
|
protected onBeforeDown(e: PointerEvent): void;
|
|
24
25
|
protected onTap(e: PointerEvent): void;
|
|
25
|
-
protected checkAndSelect(e: PointerEvent
|
|
26
|
+
protected checkAndSelect(e: PointerEvent): void;
|
|
26
27
|
protected onDragStart(e: DragEvent): void;
|
|
27
28
|
protected onDrag(e: DragEvent): void;
|
|
28
29
|
protected onDragEnd(): void;
|
|
29
30
|
protected onAutoMove(e: MoveEvent): void;
|
|
30
31
|
protected allow(target: ILeaf): boolean;
|
|
31
32
|
protected allowDrag(e: DragEvent): boolean;
|
|
32
|
-
protected
|
|
33
|
+
protected allowSelect(e: IPointerEvent): boolean;
|
|
34
|
+
findDeepOne(e: PointerEvent): IUI;
|
|
35
|
+
findUI(e: PointerEvent): IUI;
|
|
36
|
+
isMultipleSelect(e: IPointerEvent): boolean;
|
|
33
37
|
protected __listenEvents(): void;
|
|
34
38
|
protected __removeListenEvents(): void;
|
|
35
39
|
destroy(): void;
|
|
@@ -37,22 +41,31 @@ declare class EditSelect extends Group implements IEditSelect {
|
|
|
37
41
|
|
|
38
42
|
declare class Editor extends Group implements IEditor {
|
|
39
43
|
config: IEditorConfig;
|
|
44
|
+
mergeConfig: IEditorConfig;
|
|
40
45
|
hoverTarget: IUI;
|
|
41
46
|
target: IUI | IUI[];
|
|
42
|
-
leafList: ILeafList;
|
|
43
47
|
get list(): IUI[];
|
|
44
|
-
|
|
48
|
+
leafList: ILeafList;
|
|
49
|
+
openedGroupList: ILeafList;
|
|
50
|
+
get editing(): boolean;
|
|
51
|
+
innerEditing: boolean;
|
|
52
|
+
get groupOpening(): boolean;
|
|
45
53
|
get multiple(): boolean;
|
|
46
54
|
get single(): boolean;
|
|
55
|
+
get dragging(): boolean;
|
|
47
56
|
get element(): IUI;
|
|
48
57
|
simulateTarget: IUI;
|
|
49
58
|
editBox: IEditBox;
|
|
50
59
|
get buttons(): IGroup;
|
|
51
60
|
editTool: IEditTool;
|
|
61
|
+
innerEditor: IInnerEditor;
|
|
62
|
+
editToolList: IObject;
|
|
52
63
|
selector: EditSelect;
|
|
53
|
-
|
|
64
|
+
dragStartPoint: IPointData;
|
|
54
65
|
targetEventIds: IEventListenerId[];
|
|
55
66
|
constructor(userConfig?: IEditorConfig, data?: IGroupInputData);
|
|
67
|
+
select(target: IUI | IUI[]): void;
|
|
68
|
+
cancel(): void;
|
|
56
69
|
hasItem(item: IUI): boolean;
|
|
57
70
|
addItem(item: IUI): void;
|
|
58
71
|
removeItem(item: IUI): void;
|
|
@@ -64,13 +77,18 @@ declare class Editor extends Group implements IEditor {
|
|
|
64
77
|
onScale(e: DragEvent): void;
|
|
65
78
|
onRotate(e: DragEvent | RotateEvent): void;
|
|
66
79
|
onSkew(e: DragEvent): void;
|
|
67
|
-
move(x: number, y
|
|
80
|
+
move(x: number | IPointData, y?: number): void;
|
|
68
81
|
scaleWithDrag(data: IEditorScaleEvent): void;
|
|
69
82
|
scaleOf(origin: IPointData, scaleX: number, scaleY?: number, _resize?: boolean): void;
|
|
70
83
|
rotateOf(origin: IPointData, rotation: number): void;
|
|
71
84
|
skewOf(origin: IPointData, skewX: number, skewY?: number, _resize?: boolean): void;
|
|
72
85
|
group(userGroup?: IGroup | IGroupInputData): IGroup;
|
|
73
86
|
ungroup(): IUI[];
|
|
87
|
+
openGroup(group: IGroup): void;
|
|
88
|
+
closeGroup(group: IGroup): void;
|
|
89
|
+
checkOpenedGroups(): void;
|
|
90
|
+
openInnerEditor(): void;
|
|
91
|
+
closeInnerEditor(): void;
|
|
74
92
|
lock(): void;
|
|
75
93
|
unlock(): void;
|
|
76
94
|
toTop(): void;
|
|
@@ -80,10 +98,25 @@ declare class Editor extends Group implements IEditor {
|
|
|
80
98
|
destroy(): void;
|
|
81
99
|
}
|
|
82
100
|
|
|
101
|
+
declare class EditorEvent extends Event implements IEditorEvent {
|
|
102
|
+
static SELECT: string;
|
|
103
|
+
static HOVER: string;
|
|
104
|
+
readonly target: IUI;
|
|
105
|
+
readonly editor: IEditor;
|
|
106
|
+
readonly value: IUI | IUI[];
|
|
107
|
+
readonly oldValue: IUI | IUI[];
|
|
108
|
+
get list(): IUI[];
|
|
109
|
+
get oldList(): IUI[];
|
|
110
|
+
readonly worldOrigin: IPointData;
|
|
111
|
+
readonly origin: IPointData;
|
|
112
|
+
constructor(type: string, data?: IEditorEvent);
|
|
113
|
+
}
|
|
114
|
+
|
|
83
115
|
declare class EditBox extends Group implements IEditBox {
|
|
84
116
|
editor: IEditor;
|
|
85
117
|
dragging: boolean;
|
|
86
118
|
moving: boolean;
|
|
119
|
+
view: IGroup;
|
|
87
120
|
rect: IBox;
|
|
88
121
|
circle: IEditPoint;
|
|
89
122
|
buttons: IGroup;
|
|
@@ -98,24 +131,29 @@ declare class EditBox extends Group implements IEditBox {
|
|
|
98
131
|
protected __eventIds: IEventListenerId[];
|
|
99
132
|
constructor(editor: IEditor);
|
|
100
133
|
create(): void;
|
|
134
|
+
load(): void;
|
|
101
135
|
update(bounds: IBoundsData): void;
|
|
102
136
|
protected layoutButtons(): void;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
137
|
+
unload(): void;
|
|
138
|
+
getPointStyle(userStyle?: IBoxInputData): IBoxInputData;
|
|
139
|
+
getPointsStyle(): IBoxInputData[];
|
|
140
|
+
getMiddlePointsStyle(): IBoxInputData[];
|
|
141
|
+
protected onSelect(e: EditorEvent): void;
|
|
106
142
|
protected onDragStart(e: DragEvent): void;
|
|
107
143
|
protected onDragEnd(e: DragEvent): void;
|
|
108
144
|
protected onDrag(e: DragEvent): void;
|
|
109
145
|
onArrow(e: IKeyEvent): void;
|
|
110
|
-
protected
|
|
111
|
-
|
|
146
|
+
protected onDoubleTap(e: PointerEvent): void;
|
|
147
|
+
protected onLongPress(e: PointerEvent): void;
|
|
148
|
+
protected openInner(e: PointerEvent): void;
|
|
149
|
+
listenPointEvents(point: IEditPoint, type: IEditPointType, direction: Direction9): void;
|
|
112
150
|
protected __listenEvents(): void;
|
|
113
151
|
protected __removeListenEvents(): void;
|
|
114
152
|
destroy(): void;
|
|
115
153
|
}
|
|
116
154
|
|
|
117
155
|
declare class EditPoint extends Box implements IEditPoint {
|
|
118
|
-
direction:
|
|
156
|
+
direction: Direction9;
|
|
119
157
|
pointType: IEditPointType;
|
|
120
158
|
}
|
|
121
159
|
|
|
@@ -136,20 +174,6 @@ declare class Stroker extends UI implements IStroker {
|
|
|
136
174
|
destroy(): void;
|
|
137
175
|
}
|
|
138
176
|
|
|
139
|
-
declare class EditorEvent extends Event implements IEditorEvent {
|
|
140
|
-
static SELECT: string;
|
|
141
|
-
static HOVER: string;
|
|
142
|
-
readonly target: IUI;
|
|
143
|
-
readonly editor: IEditor;
|
|
144
|
-
readonly value: IUI | IUI[];
|
|
145
|
-
readonly oldValue: IUI | IUI[];
|
|
146
|
-
get list(): IUI[];
|
|
147
|
-
get oldList(): IUI[];
|
|
148
|
-
readonly worldOrigin: IPointData;
|
|
149
|
-
readonly origin: IPointData;
|
|
150
|
-
constructor(type: string, data?: IEditorEvent);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
177
|
declare class EditorMoveEvent extends EditorEvent implements IEditorMoveEvent {
|
|
154
178
|
static MOVE: string;
|
|
155
179
|
readonly moveX: number;
|
|
@@ -163,7 +187,7 @@ declare class EditorScaleEvent extends EditorEvent implements IEditorScaleEvent
|
|
|
163
187
|
readonly scaleY: number;
|
|
164
188
|
readonly transform?: IMatrixData;
|
|
165
189
|
readonly drag: IDragEvent;
|
|
166
|
-
readonly direction:
|
|
190
|
+
readonly direction: Direction9;
|
|
167
191
|
readonly lockRatio: boolean;
|
|
168
192
|
readonly around: IAround;
|
|
169
193
|
constructor(type: string, data?: IEditorScaleEvent);
|
|
@@ -182,22 +206,52 @@ declare class EditorSkewEvent extends EditorEvent implements IEditorSkewEvent {
|
|
|
182
206
|
constructor(type: string, data?: IEditorSkewEvent);
|
|
183
207
|
}
|
|
184
208
|
|
|
185
|
-
declare
|
|
186
|
-
|
|
187
|
-
|
|
209
|
+
declare function registerEditTool(): (target: IObject) => void;
|
|
210
|
+
declare const registerInnerEditor: typeof registerEditTool;
|
|
211
|
+
declare const EditToolCreator: {
|
|
212
|
+
list: IObject;
|
|
213
|
+
register(EditTool: IObject): void;
|
|
214
|
+
get(tag: string, editor: IEditor): IEditTool;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
declare class InnerEditor implements IInnerEditor {
|
|
218
|
+
static registerInnerEditor(): void;
|
|
219
|
+
get tag(): string;
|
|
220
|
+
editor: IEditor;
|
|
221
|
+
get editBox(): IEditBox;
|
|
222
|
+
view: IGroup;
|
|
223
|
+
eventIds: IEventListenerId[];
|
|
224
|
+
constructor(editor: IEditor);
|
|
225
|
+
onCreate(): void;
|
|
226
|
+
create(): void;
|
|
227
|
+
onLoad(): void;
|
|
228
|
+
load(): void;
|
|
229
|
+
onUpdate(): void;
|
|
230
|
+
update(): void;
|
|
231
|
+
onUnload(): void;
|
|
232
|
+
unload(): void;
|
|
233
|
+
onDestroy(): void;
|
|
234
|
+
destroy(): void;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
declare class EditTool extends InnerEditor implements IEditTool {
|
|
238
|
+
static registerEditTool(): void;
|
|
239
|
+
get tag(): string;
|
|
188
240
|
onMove(e: IEditorMoveEvent): void;
|
|
189
241
|
onScale(e: IEditorScaleEvent): void;
|
|
190
242
|
onRotate(e: IEditorRotateEvent): void;
|
|
191
243
|
onSkew(e: IEditorSkewEvent): void;
|
|
192
|
-
|
|
244
|
+
load(): void;
|
|
245
|
+
update(): void;
|
|
246
|
+
unload(): void;
|
|
193
247
|
}
|
|
194
248
|
|
|
195
249
|
declare class LineEditTool extends EditTool {
|
|
196
|
-
tag: string;
|
|
250
|
+
get tag(): string;
|
|
197
251
|
scaleOfEvent: boolean;
|
|
198
252
|
onScaleWithDrag(e: IEditorScaleEvent): void;
|
|
199
253
|
onSkew(_e: IEditorSkewEvent): void;
|
|
200
|
-
|
|
254
|
+
onUpdate(): void;
|
|
201
255
|
}
|
|
202
256
|
|
|
203
257
|
declare const EditorHelper: {
|
|
@@ -208,12 +262,12 @@ declare const EditorHelper: {
|
|
|
208
262
|
};
|
|
209
263
|
|
|
210
264
|
declare const EditDataHelper: {
|
|
211
|
-
getScaleData(bounds: IBoundsData, direction:
|
|
212
|
-
getRotateData(bounds: IBoundsData, direction:
|
|
213
|
-
getSkewData(bounds: IBoundsData, direction:
|
|
265
|
+
getScaleData(bounds: IBoundsData, direction: Direction9, pointMove: IPointData, lockRatio: boolean | 'corner', around: IAround): IEditorScaleEvent;
|
|
266
|
+
getRotateData(bounds: IBoundsData, direction: Direction9, current: IPointData, last: IPointData, around: IAround): IEditorRotateEvent;
|
|
267
|
+
getSkewData(bounds: IBoundsData, direction: Direction9, move: IPointData, around: IAround): IEditorSkewEvent;
|
|
214
268
|
getAround(around: IAround, altKey: boolean): IAround;
|
|
215
269
|
getRotateDirection(direction: number, rotation: number, totalDirection?: number): number;
|
|
216
|
-
getFlipDirection(direction:
|
|
270
|
+
getFlipDirection(direction: Direction9, flipedX: boolean, flipedY: boolean): Direction9;
|
|
217
271
|
};
|
|
218
272
|
|
|
219
273
|
declare const EditSelectHelper: {
|
|
@@ -221,4 +275,4 @@ declare const EditSelectHelper: {
|
|
|
221
275
|
findBounds(leaf: IUI, bounds: IBounds): Answer;
|
|
222
276
|
};
|
|
223
277
|
|
|
224
|
-
export { EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, Editor, EditorEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, LineEditTool, SelectArea, Stroker };
|
|
278
|
+
export { EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, InnerEditor, LineEditTool, SelectArea, Stroker, registerEditTool, registerInnerEditor };
|
package/src/tool/index.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { IUI } from '@leafer-ui/interface'
|
|
2
|
-
import { Line } from '@leafer-ui/core'
|
|
3
|
-
|
|
4
|
-
import { IEditTool } from '@leafer-in/interface'
|
|
5
|
-
|
|
6
|
-
import { EditTool } from './EditTool'
|
|
7
|
-
import { LineEditTool } from './LineEditTool'
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export function getEditTool(list: IUI[]): IEditTool {
|
|
11
|
-
if (list.length === 1) {
|
|
12
|
-
const leaf = list[0]
|
|
13
|
-
if (leaf instanceof Line && !leaf.points) {
|
|
14
|
-
return new LineEditTool()
|
|
15
|
-
} else {
|
|
16
|
-
return new EditTool()
|
|
17
|
-
}
|
|
18
|
-
} else {
|
|
19
|
-
return new EditTool()
|
|
20
|
-
}
|
|
21
|
-
}
|