@leafer-in/editor 1.0.0-rc.21 → 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 +462 -286
- package/dist/editor.esm.min.js +1 -1
- package/dist/editor.js +463 -285
- package/dist/editor.min.js +1 -1
- package/package.json +5 -5
- package/src/Editor.ts +114 -26
- package/src/config.ts +1 -0
- package/src/display/EditBox.ts +125 -70
- package/src/display/EditPoint.ts +3 -3
- package/src/display/EditSelect.ts +40 -35
- package/src/display/Stroker.ts +4 -4
- package/src/editor/cursor.ts +3 -3
- package/src/editor/target.ts +3 -1
- package/src/event/EditorScaleEvent.ts +3 -2
- package/src/helper/EditDataHelper.ts +8 -11
- 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 +95 -42
- package/src/tool/index.ts +0 -21
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/draw'
|
|
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,8 +1,8 @@
|
|
|
1
1
|
export * from '@leafer-ui/scale';
|
|
2
|
-
import { IBounds, ILeafList, IUI, IEventListenerId, ILeaf, IGroup, IGroupInputData, IEditSize,
|
|
3
|
-
import { Group, Box, UI,
|
|
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
4
|
import { PointerEvent, DragEvent, MoveEvent, RotateEvent } from '@leafer-ui/core';
|
|
5
|
-
import { IEditSelect, IEditor, IStroker, ISelectArea, IEditorConfig, IEditBox, IEditTool,
|
|
5
|
+
import { IEditSelect, IEditor, IStroker, ISelectArea, IEditorConfig, IEditBox, IEditTool, IInnerEditor, IEditorScaleEvent, IEditorEvent, IEditPoint, IEditPointType, IEditorMoveEvent, IEditorRotateEvent, IEditorSkewEvent } from '@leafer-in/interface';
|
|
6
6
|
|
|
7
7
|
declare class EditSelect extends Group implements IEditSelect {
|
|
8
8
|
editor: IEditor;
|
|
@@ -14,7 +14,7 @@ declare class EditSelect extends Group implements IEditSelect {
|
|
|
14
14
|
bounds: IBounds;
|
|
15
15
|
selectArea: ISelectArea;
|
|
16
16
|
protected originList: ILeafList;
|
|
17
|
-
protected
|
|
17
|
+
protected needRemoveItem: IUI;
|
|
18
18
|
protected __eventIds: IEventListenerId[];
|
|
19
19
|
constructor(editor: IEditor);
|
|
20
20
|
protected onHover(): void;
|
|
@@ -23,14 +23,17 @@ declare class EditSelect extends Group implements IEditSelect {
|
|
|
23
23
|
protected onPointerMove(e: PointerEvent): void;
|
|
24
24
|
protected onBeforeDown(e: PointerEvent): void;
|
|
25
25
|
protected onTap(e: PointerEvent): void;
|
|
26
|
-
protected checkAndSelect(e: PointerEvent
|
|
26
|
+
protected checkAndSelect(e: PointerEvent): void;
|
|
27
27
|
protected onDragStart(e: DragEvent): void;
|
|
28
28
|
protected onDrag(e: DragEvent): void;
|
|
29
29
|
protected onDragEnd(): void;
|
|
30
30
|
protected onAutoMove(e: MoveEvent): void;
|
|
31
31
|
protected allow(target: ILeaf): boolean;
|
|
32
32
|
protected allowDrag(e: DragEvent): boolean;
|
|
33
|
-
protected
|
|
33
|
+
protected allowSelect(e: IPointerEvent): boolean;
|
|
34
|
+
findDeepOne(e: PointerEvent): IUI;
|
|
35
|
+
findUI(e: PointerEvent): IUI;
|
|
36
|
+
isMultipleSelect(e: IPointerEvent): boolean;
|
|
34
37
|
protected __listenEvents(): void;
|
|
35
38
|
protected __removeListenEvents(): void;
|
|
36
39
|
destroy(): void;
|
|
@@ -38,22 +41,31 @@ declare class EditSelect extends Group implements IEditSelect {
|
|
|
38
41
|
|
|
39
42
|
declare class Editor extends Group implements IEditor {
|
|
40
43
|
config: IEditorConfig;
|
|
44
|
+
mergeConfig: IEditorConfig;
|
|
41
45
|
hoverTarget: IUI;
|
|
42
46
|
target: IUI | IUI[];
|
|
43
|
-
leafList: ILeafList;
|
|
44
47
|
get list(): IUI[];
|
|
45
|
-
|
|
48
|
+
leafList: ILeafList;
|
|
49
|
+
openedGroupList: ILeafList;
|
|
50
|
+
get editing(): boolean;
|
|
51
|
+
innerEditing: boolean;
|
|
52
|
+
get groupOpening(): boolean;
|
|
46
53
|
get multiple(): boolean;
|
|
47
54
|
get single(): boolean;
|
|
55
|
+
get dragging(): boolean;
|
|
48
56
|
get element(): IUI;
|
|
49
57
|
simulateTarget: IUI;
|
|
50
58
|
editBox: IEditBox;
|
|
51
59
|
get buttons(): IGroup;
|
|
52
60
|
editTool: IEditTool;
|
|
61
|
+
innerEditor: IInnerEditor;
|
|
62
|
+
editToolList: IObject;
|
|
53
63
|
selector: EditSelect;
|
|
54
|
-
|
|
64
|
+
dragStartPoint: IPointData;
|
|
55
65
|
targetEventIds: IEventListenerId[];
|
|
56
66
|
constructor(userConfig?: IEditorConfig, data?: IGroupInputData);
|
|
67
|
+
select(target: IUI | IUI[]): void;
|
|
68
|
+
cancel(): void;
|
|
57
69
|
hasItem(item: IUI): boolean;
|
|
58
70
|
addItem(item: IUI): void;
|
|
59
71
|
removeItem(item: IUI): void;
|
|
@@ -65,13 +77,18 @@ declare class Editor extends Group implements IEditor {
|
|
|
65
77
|
onScale(e: DragEvent): void;
|
|
66
78
|
onRotate(e: DragEvent | RotateEvent): void;
|
|
67
79
|
onSkew(e: DragEvent): void;
|
|
68
|
-
move(x: number, y
|
|
80
|
+
move(x: number | IPointData, y?: number): void;
|
|
69
81
|
scaleWithDrag(data: IEditorScaleEvent): void;
|
|
70
82
|
scaleOf(origin: IPointData, scaleX: number, scaleY?: number, _resize?: boolean): void;
|
|
71
83
|
rotateOf(origin: IPointData, rotation: number): void;
|
|
72
84
|
skewOf(origin: IPointData, skewX: number, skewY?: number, _resize?: boolean): void;
|
|
73
85
|
group(userGroup?: IGroup | IGroupInputData): IGroup;
|
|
74
86
|
ungroup(): IUI[];
|
|
87
|
+
openGroup(group: IGroup): void;
|
|
88
|
+
closeGroup(group: IGroup): void;
|
|
89
|
+
checkOpenedGroups(): void;
|
|
90
|
+
openInnerEditor(): void;
|
|
91
|
+
closeInnerEditor(): void;
|
|
75
92
|
lock(): void;
|
|
76
93
|
unlock(): void;
|
|
77
94
|
toTop(): void;
|
|
@@ -81,10 +98,25 @@ declare class Editor extends Group implements IEditor {
|
|
|
81
98
|
destroy(): void;
|
|
82
99
|
}
|
|
83
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
|
+
|
|
84
115
|
declare class EditBox extends Group implements IEditBox {
|
|
85
116
|
editor: IEditor;
|
|
86
117
|
dragging: boolean;
|
|
87
118
|
moving: boolean;
|
|
119
|
+
view: IGroup;
|
|
88
120
|
rect: IBox;
|
|
89
121
|
circle: IEditPoint;
|
|
90
122
|
buttons: IGroup;
|
|
@@ -99,24 +131,29 @@ declare class EditBox extends Group implements IEditBox {
|
|
|
99
131
|
protected __eventIds: IEventListenerId[];
|
|
100
132
|
constructor(editor: IEditor);
|
|
101
133
|
create(): void;
|
|
134
|
+
load(): void;
|
|
102
135
|
update(bounds: IBoundsData): void;
|
|
103
136
|
protected layoutButtons(): void;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
137
|
+
unload(): void;
|
|
138
|
+
getPointStyle(userStyle?: IBoxInputData): IBoxInputData;
|
|
139
|
+
getPointsStyle(): IBoxInputData[];
|
|
140
|
+
getMiddlePointsStyle(): IBoxInputData[];
|
|
141
|
+
protected onSelect(e: EditorEvent): void;
|
|
107
142
|
protected onDragStart(e: DragEvent): void;
|
|
108
143
|
protected onDragEnd(e: DragEvent): void;
|
|
109
144
|
protected onDrag(e: DragEvent): void;
|
|
110
145
|
onArrow(e: IKeyEvent): void;
|
|
111
|
-
protected
|
|
112
|
-
|
|
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;
|
|
113
150
|
protected __listenEvents(): void;
|
|
114
151
|
protected __removeListenEvents(): void;
|
|
115
152
|
destroy(): void;
|
|
116
153
|
}
|
|
117
154
|
|
|
118
155
|
declare class EditPoint extends Box implements IEditPoint {
|
|
119
|
-
direction:
|
|
156
|
+
direction: Direction9;
|
|
120
157
|
pointType: IEditPointType;
|
|
121
158
|
}
|
|
122
159
|
|
|
@@ -137,20 +174,6 @@ declare class Stroker extends UI implements IStroker {
|
|
|
137
174
|
destroy(): void;
|
|
138
175
|
}
|
|
139
176
|
|
|
140
|
-
declare class EditorEvent extends Event implements IEditorEvent {
|
|
141
|
-
static SELECT: string;
|
|
142
|
-
static HOVER: string;
|
|
143
|
-
readonly target: IUI;
|
|
144
|
-
readonly editor: IEditor;
|
|
145
|
-
readonly value: IUI | IUI[];
|
|
146
|
-
readonly oldValue: IUI | IUI[];
|
|
147
|
-
get list(): IUI[];
|
|
148
|
-
get oldList(): IUI[];
|
|
149
|
-
readonly worldOrigin: IPointData;
|
|
150
|
-
readonly origin: IPointData;
|
|
151
|
-
constructor(type: string, data?: IEditorEvent);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
177
|
declare class EditorMoveEvent extends EditorEvent implements IEditorMoveEvent {
|
|
155
178
|
static MOVE: string;
|
|
156
179
|
readonly moveX: number;
|
|
@@ -164,7 +187,7 @@ declare class EditorScaleEvent extends EditorEvent implements IEditorScaleEvent
|
|
|
164
187
|
readonly scaleY: number;
|
|
165
188
|
readonly transform?: IMatrixData;
|
|
166
189
|
readonly drag: IDragEvent;
|
|
167
|
-
readonly direction:
|
|
190
|
+
readonly direction: Direction9;
|
|
168
191
|
readonly lockRatio: boolean;
|
|
169
192
|
readonly around: IAround;
|
|
170
193
|
constructor(type: string, data?: IEditorScaleEvent);
|
|
@@ -183,22 +206,52 @@ declare class EditorSkewEvent extends EditorEvent implements IEditorSkewEvent {
|
|
|
183
206
|
constructor(type: string, data?: IEditorSkewEvent);
|
|
184
207
|
}
|
|
185
208
|
|
|
186
|
-
declare
|
|
187
|
-
|
|
188
|
-
|
|
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;
|
|
189
240
|
onMove(e: IEditorMoveEvent): void;
|
|
190
241
|
onScale(e: IEditorScaleEvent): void;
|
|
191
242
|
onRotate(e: IEditorRotateEvent): void;
|
|
192
243
|
onSkew(e: IEditorSkewEvent): void;
|
|
193
|
-
|
|
244
|
+
load(): void;
|
|
245
|
+
update(): void;
|
|
246
|
+
unload(): void;
|
|
194
247
|
}
|
|
195
248
|
|
|
196
249
|
declare class LineEditTool extends EditTool {
|
|
197
|
-
tag: string;
|
|
250
|
+
get tag(): string;
|
|
198
251
|
scaleOfEvent: boolean;
|
|
199
252
|
onScaleWithDrag(e: IEditorScaleEvent): void;
|
|
200
253
|
onSkew(_e: IEditorSkewEvent): void;
|
|
201
|
-
|
|
254
|
+
onUpdate(): void;
|
|
202
255
|
}
|
|
203
256
|
|
|
204
257
|
declare const EditorHelper: {
|
|
@@ -209,12 +262,12 @@ declare const EditorHelper: {
|
|
|
209
262
|
};
|
|
210
263
|
|
|
211
264
|
declare const EditDataHelper: {
|
|
212
|
-
getScaleData(bounds: IBoundsData, direction:
|
|
213
|
-
getRotateData(bounds: IBoundsData, direction:
|
|
214
|
-
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;
|
|
215
268
|
getAround(around: IAround, altKey: boolean): IAround;
|
|
216
269
|
getRotateDirection(direction: number, rotation: number, totalDirection?: number): number;
|
|
217
|
-
getFlipDirection(direction:
|
|
270
|
+
getFlipDirection(direction: Direction9, flipedX: boolean, flipedY: boolean): Direction9;
|
|
218
271
|
};
|
|
219
272
|
|
|
220
273
|
declare const EditSelectHelper: {
|
|
@@ -222,4 +275,4 @@ declare const EditSelectHelper: {
|
|
|
222
275
|
findBounds(leaf: IUI, bounds: IBounds): Answer;
|
|
223
276
|
};
|
|
224
277
|
|
|
225
|
-
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/draw'
|
|
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
|
-
}
|