@leafer-in/editor 1.0.0-rc.9 → 1.0.1
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 +2008 -0
- package/dist/editor.esm.js +1197 -458
- package/dist/editor.esm.min.js +1 -1
- package/dist/editor.js +1235 -487
- package/dist/editor.min.cjs +1 -0
- package/dist/editor.min.js +1 -1
- package/package.json +12 -7
- package/src/Editor.ts +268 -76
- package/src/config.ts +14 -4
- package/src/decorator/data.ts +1 -1
- package/src/display/EditBox.ts +164 -81
- package/src/display/EditMask.ts +37 -0
- package/src/display/EditPoint.ts +3 -3
- package/src/display/EditSelect.ts +84 -49
- package/src/display/SelectArea.ts +1 -1
- package/src/display/Stroker.ts +24 -21
- package/src/editor/cursor.ts +29 -38
- package/src/editor/simulate.ts +2 -2
- package/src/editor/target.ts +4 -2
- package/src/event/EditorEvent.ts +8 -1
- package/src/event/EditorGroupEvent.ts +23 -0
- package/src/event/EditorScaleEvent.ts +3 -2
- package/src/event/InnerEditorEvent.ts +23 -0
- package/src/helper/EditDataHelper.ts +112 -41
- package/src/helper/EditSelectHelper.ts +5 -4
- package/src/helper/EditorHelper.ts +11 -4
- package/src/index.ts +29 -5
- package/src/svg.ts +54 -0
- package/src/tool/EditTool.ts +51 -22
- package/src/tool/EditToolCreator.ts +32 -0
- package/src/tool/InnerEditor.ts +68 -0
- package/src/tool/LineEditTool.ts +94 -38
- package/types/index.d.ts +157 -52
- package/src/tool/index.ts +0 -21
package/src/tool/LineEditTool.ts
CHANGED
|
@@ -1,78 +1,134 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IEditorScaleEvent, ILine, IEditorSkewEvent, IPointData, IAround, IPathCommandData, IFromToData, IUI, IDragEvent } from '@leafer-in/interface'
|
|
2
|
+
|
|
3
|
+
import { getPointData, Direction9, PointHelper } from '@leafer-ui/draw'
|
|
2
4
|
|
|
3
5
|
import { EditTool } from './EditTool'
|
|
6
|
+
import { registerEditTool } from './EditToolCreator'
|
|
4
7
|
|
|
5
8
|
|
|
6
|
-
const { left, right } =
|
|
9
|
+
const { left, right } = Direction9
|
|
10
|
+
const { move, copy } = PointHelper
|
|
7
11
|
|
|
12
|
+
@registerEditTool()
|
|
8
13
|
export class LineEditTool extends EditTool {
|
|
9
14
|
|
|
10
|
-
public tag
|
|
15
|
+
public get tag() { return 'LineEditTool' }
|
|
11
16
|
|
|
12
17
|
public scaleOfEvent = true
|
|
13
18
|
|
|
14
19
|
onScaleWithDrag(e: IEditorScaleEvent): void {
|
|
15
20
|
const { drag, direction, lockRatio, around } = e
|
|
16
|
-
const
|
|
21
|
+
const line = e.target as ILine
|
|
22
|
+
const isDragFrom = direction === left
|
|
17
23
|
|
|
18
|
-
|
|
19
|
-
const { toPoint } = target
|
|
24
|
+
if (line.pathInputed) {
|
|
20
25
|
|
|
21
|
-
|
|
26
|
+
const { path } = line.__
|
|
27
|
+
const { from, to } = this.getFromToByPath(path)
|
|
22
28
|
|
|
23
|
-
|
|
29
|
+
this.dragPoint(from, to, isDragFrom, around, this.getInnerMove(line, drag, lockRatio))
|
|
24
30
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
} else {
|
|
29
|
-
x = 0
|
|
30
|
-
}
|
|
31
|
-
}
|
|
31
|
+
path[1] = from.x, path[2] = from.y
|
|
32
|
+
path[4] = to.x, path[5] = to.y
|
|
33
|
+
line.path = path
|
|
32
34
|
|
|
33
|
-
if (
|
|
35
|
+
} else if (line.points) {
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
const { points } = line
|
|
38
|
+
const { from, to } = this.getFromToByPoints(points)
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
this.dragPoint(from, to, isDragFrom, around, this.getInnerMove(line, drag, lockRatio))
|
|
41
|
+
|
|
42
|
+
points[0] = from.x, points[1] = from.y
|
|
43
|
+
points[2] = to.x, points[3] = to.y
|
|
44
|
+
line.points = points
|
|
42
45
|
|
|
43
46
|
} else {
|
|
44
47
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
const from = getPointData()
|
|
49
|
+
const { toPoint } = line
|
|
50
|
+
line.rotation = 0
|
|
51
|
+
|
|
52
|
+
this.dragPoint(from, toPoint, isDragFrom, around, this.getInnerMove(line, drag, lockRatio))
|
|
53
|
+
|
|
54
|
+
line.getLocalPointByInner(from, null, null, true)
|
|
55
|
+
line.getLocalPointByInner(toPoint, null, null, true)
|
|
56
|
+
line.x = from.x
|
|
57
|
+
line.y = from.y
|
|
58
|
+
|
|
59
|
+
line.getInnerPointByLocal(toPoint, null, null, true)
|
|
60
|
+
line.toPoint = toPoint
|
|
61
|
+
|
|
62
|
+
}
|
|
49
63
|
|
|
50
|
-
|
|
51
|
-
toPoint.y += y
|
|
64
|
+
}
|
|
52
65
|
|
|
66
|
+
getInnerMove(ui: IUI, event: IDragEvent, lockRatio: boolean | 'corner'): IPointData {
|
|
67
|
+
const movePoint = event.getInnerMove(ui)
|
|
68
|
+
if (lockRatio) {
|
|
69
|
+
if (Math.abs(movePoint.x) > Math.abs(movePoint.y)) {
|
|
70
|
+
movePoint.y = 0
|
|
71
|
+
} else {
|
|
72
|
+
movePoint.x = 0
|
|
73
|
+
}
|
|
53
74
|
}
|
|
75
|
+
return movePoint
|
|
76
|
+
}
|
|
54
77
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
78
|
+
getFromToByPath(path: IPathCommandData): IFromToData {
|
|
79
|
+
return {
|
|
80
|
+
from: { x: path[1], y: path[2] },
|
|
81
|
+
to: { x: path[4], y: path[5] }
|
|
82
|
+
}
|
|
83
|
+
}
|
|
59
84
|
|
|
60
|
-
|
|
61
|
-
|
|
85
|
+
getFromToByPoints(points: number[]): IFromToData {
|
|
86
|
+
return {
|
|
87
|
+
from: { x: points[0], y: points[1] },
|
|
88
|
+
to: { x: points[2], y: points[3] }
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
}
|
|
62
92
|
|
|
93
|
+
dragPoint(fromPoint: IPointData, toPoint: IPointData, isDragFrom: boolean, around: IAround, movePoint: IPointData): void {
|
|
94
|
+
const { x, y } = movePoint
|
|
95
|
+
if (isDragFrom) {
|
|
96
|
+
move(fromPoint, x, y)
|
|
97
|
+
if (around) move(toPoint, -x, -y)
|
|
98
|
+
} else {
|
|
99
|
+
if (around) move(fromPoint, -x, -y)
|
|
100
|
+
move(toPoint, x, y)
|
|
101
|
+
}
|
|
63
102
|
}
|
|
64
103
|
|
|
65
104
|
onSkew(_e: IEditorSkewEvent): void {
|
|
66
105
|
|
|
67
106
|
}
|
|
68
107
|
|
|
69
|
-
|
|
70
|
-
const { rotatePoints, resizeLines, resizePoints } =
|
|
71
|
-
|
|
108
|
+
onUpdate() {
|
|
109
|
+
const { editBox } = this, { rotatePoints, resizeLines, resizePoints, rect } = editBox
|
|
110
|
+
const line = this.editor.element as ILine
|
|
111
|
+
|
|
112
|
+
let fromTo: IFromToData, leftOrRight: boolean
|
|
113
|
+
if (line.pathInputed) fromTo = this.getFromToByPath(line.__.path)
|
|
114
|
+
else if (line.points) fromTo = this.getFromToByPoints(line.__.points)
|
|
115
|
+
|
|
116
|
+
if (fromTo) {
|
|
117
|
+
const { from, to } = fromTo
|
|
118
|
+
line.innerToWorld(from, from, false, editBox)
|
|
119
|
+
line.innerToWorld(to, to, false, editBox)
|
|
120
|
+
rect.pen.clearPath().moveTo(from.x, from.y).lineTo(to.x, to.y)
|
|
121
|
+
copy(resizePoints[7] as IPointData, from)
|
|
122
|
+
copy(rotatePoints[7] as IPointData, from)
|
|
123
|
+
copy(resizePoints[3] as IPointData, to)
|
|
124
|
+
copy(rotatePoints[3] as IPointData, to)
|
|
125
|
+
}
|
|
72
126
|
|
|
73
127
|
for (let i = 0; i < 8; i++) {
|
|
74
128
|
if (i < 4) resizeLines[i].visible = false
|
|
75
|
-
|
|
129
|
+
leftOrRight = i === left || i === right
|
|
130
|
+
resizePoints[i].visible = leftOrRight
|
|
131
|
+
rotatePoints[i].visible = fromTo ? false : leftOrRight
|
|
76
132
|
}
|
|
77
133
|
}
|
|
78
134
|
|
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
export * from '@leafer-in/resize';
|
|
2
|
+
import { IBounds, ILeafList, IUI, IFunction, IEventListenerId, ILeaf, IPointerEvent, ILeaferCanvas, IRenderOptions, IGroup, IObject, IPointData, ILayoutBoundsData, IGroupInputData, IEditSize, IAlign, IAxis, IBox, IBoundsData, IEditorConfig as IEditorConfig$1, IBoxInputData, IKeyEvent, IRect, IRectInputData, IMatrixData, IDragEvent, IAround } from '@leafer-ui/interface';
|
|
3
|
+
import { Group, UI, Matrix, Event, Direction9, Box, Answer } from '@leafer-ui/draw';
|
|
4
|
+
import { PointerEvent, DragEvent, MoveEvent, ZoomEvent, RotateEvent } from '@leafer-ui/core';
|
|
5
|
+
import { IEditSelect, IEditor, IStroker, ISelectArea, IEditorConfig, IEditBox, IEditTool, IInnerEditor, IEditorScaleEvent, IEditorEvent, IEditPoint, IEditPointType, IEditorMoveEvent, IEditorRotateEvent, IEditorSkewEvent, IEditorGroupEvent, IInnerEditorEvent, IUI as IUI$1, IDragEvent as IDragEvent$1, IPointData as IPointData$1, IPathCommandData, IFromToData, IAround as IAround$1 } from '@leafer-in/interface';
|
|
4
6
|
|
|
5
7
|
declare class EditSelect extends Group implements IEditSelect {
|
|
6
8
|
editor: IEditor;
|
|
@@ -12,7 +14,8 @@ declare class EditSelect extends Group implements IEditSelect {
|
|
|
12
14
|
bounds: IBounds;
|
|
13
15
|
selectArea: ISelectArea;
|
|
14
16
|
protected originList: ILeafList;
|
|
15
|
-
protected
|
|
17
|
+
protected needRemoveItem: IUI;
|
|
18
|
+
protected waitSelect: IFunction;
|
|
16
19
|
protected __eventIds: IEventListenerId[];
|
|
17
20
|
constructor(editor: IEditor);
|
|
18
21
|
protected onHover(): void;
|
|
@@ -21,54 +24,88 @@ declare class EditSelect extends Group implements IEditSelect {
|
|
|
21
24
|
protected onPointerMove(e: PointerEvent): void;
|
|
22
25
|
protected onBeforeDown(e: PointerEvent): void;
|
|
23
26
|
protected onTap(e: PointerEvent): void;
|
|
27
|
+
protected checkAndSelect(e: PointerEvent): void;
|
|
24
28
|
protected onDragStart(e: DragEvent): void;
|
|
25
29
|
protected onDrag(e: DragEvent): void;
|
|
26
|
-
protected onDragEnd(): void;
|
|
30
|
+
protected onDragEnd(e: DragEvent): void;
|
|
27
31
|
protected onAutoMove(e: MoveEvent): void;
|
|
28
32
|
protected allow(target: ILeaf): boolean;
|
|
29
33
|
protected allowDrag(e: DragEvent): boolean;
|
|
30
|
-
protected
|
|
34
|
+
protected allowSelect(e: IPointerEvent): boolean;
|
|
35
|
+
findDeepOne(e: PointerEvent): IUI;
|
|
36
|
+
findUI(e: PointerEvent): IUI;
|
|
37
|
+
isMultipleSelect(e: IPointerEvent): boolean;
|
|
31
38
|
protected __listenEvents(): void;
|
|
32
39
|
protected __removeListenEvents(): void;
|
|
33
40
|
destroy(): void;
|
|
34
41
|
}
|
|
35
42
|
|
|
43
|
+
declare class EditMask extends UI {
|
|
44
|
+
editor: IEditor;
|
|
45
|
+
constructor(editor: IEditor);
|
|
46
|
+
__draw(canvas: ILeaferCanvas, options: IRenderOptions): void;
|
|
47
|
+
destroy(): void;
|
|
48
|
+
}
|
|
49
|
+
|
|
36
50
|
declare class Editor extends Group implements IEditor {
|
|
37
51
|
config: IEditorConfig;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
52
|
+
get mergeConfig(): IEditorConfig;
|
|
53
|
+
hoverTarget?: IUI;
|
|
54
|
+
target?: IUI | IUI[];
|
|
41
55
|
get list(): IUI[];
|
|
42
|
-
|
|
56
|
+
leafList: ILeafList;
|
|
57
|
+
openedGroupList: ILeafList;
|
|
58
|
+
get editing(): boolean;
|
|
59
|
+
innerEditing: boolean;
|
|
60
|
+
get groupOpening(): boolean;
|
|
43
61
|
get multiple(): boolean;
|
|
44
62
|
get single(): boolean;
|
|
63
|
+
get dragging(): boolean;
|
|
45
64
|
get element(): IUI;
|
|
46
65
|
simulateTarget: IUI;
|
|
47
66
|
editBox: IEditBox;
|
|
48
67
|
get buttons(): IGroup;
|
|
49
|
-
editTool
|
|
68
|
+
editTool?: IEditTool;
|
|
69
|
+
innerEditor?: IInnerEditor;
|
|
70
|
+
editToolList: IObject;
|
|
50
71
|
selector: EditSelect;
|
|
51
|
-
|
|
72
|
+
editMask: EditMask;
|
|
73
|
+
dragStartPoint: IPointData;
|
|
74
|
+
dragStartBounds: ILayoutBoundsData;
|
|
52
75
|
targetEventIds: IEventListenerId[];
|
|
53
76
|
constructor(userConfig?: IEditorConfig, data?: IGroupInputData);
|
|
77
|
+
select(target: IUI | IUI[]): void;
|
|
78
|
+
cancel(): void;
|
|
54
79
|
hasItem(item: IUI): boolean;
|
|
55
80
|
addItem(item: IUI): void;
|
|
56
81
|
removeItem(item: IUI): void;
|
|
57
82
|
shiftItem(item: IUI): void;
|
|
58
83
|
update(): void;
|
|
84
|
+
updateEditBox(): void;
|
|
59
85
|
updateEditTool(): void;
|
|
60
|
-
getEditSize(
|
|
61
|
-
onMove(e: DragEvent): void;
|
|
62
|
-
onScale(e: DragEvent): void;
|
|
86
|
+
getEditSize(_ui: IUI): IEditSize;
|
|
87
|
+
onMove(e: DragEvent | MoveEvent): void;
|
|
88
|
+
onScale(e: DragEvent | ZoomEvent): void;
|
|
63
89
|
onRotate(e: DragEvent | RotateEvent): void;
|
|
64
90
|
onSkew(e: DragEvent): void;
|
|
65
|
-
move(x: number, y
|
|
91
|
+
move(x: number | IPointData, y?: number): void;
|
|
66
92
|
scaleWithDrag(data: IEditorScaleEvent): void;
|
|
67
|
-
scaleOf(origin: IPointData, scaleX: number, scaleY?: number, _resize?: boolean): void;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
93
|
+
scaleOf(origin: IPointData | IAlign, scaleX: number, scaleY?: number, _resize?: boolean): void;
|
|
94
|
+
flip(axis: IAxis): void;
|
|
95
|
+
rotateOf(origin: IPointData | IAlign, rotation: number): void;
|
|
96
|
+
skewOf(origin: IPointData | IAlign, skewX: number, skewY?: number, _resize?: boolean): void;
|
|
97
|
+
protected getWorldOrigin(origin: IPointData | IAlign): IPointData;
|
|
98
|
+
protected getChangedTransform(func: IFunction): Matrix;
|
|
99
|
+
group(userGroup?: IGroup | IGroupInputData): IGroup;
|
|
71
100
|
ungroup(): IUI[];
|
|
101
|
+
openGroup(group: IGroup): void;
|
|
102
|
+
closeGroup(group: IGroup): void;
|
|
103
|
+
checkOpenedGroups(): void;
|
|
104
|
+
checkDeepSelect(): void;
|
|
105
|
+
emitGroupEvent(type: string, group: IGroup): void;
|
|
106
|
+
openInnerEditor(target?: IUI): void;
|
|
107
|
+
closeInnerEditor(): void;
|
|
108
|
+
emitInnerEvent(type: string): void;
|
|
72
109
|
lock(): void;
|
|
73
110
|
unlock(): void;
|
|
74
111
|
toTop(): void;
|
|
@@ -78,9 +115,25 @@ declare class Editor extends Group implements IEditor {
|
|
|
78
115
|
destroy(): void;
|
|
79
116
|
}
|
|
80
117
|
|
|
118
|
+
declare class EditorEvent extends Event implements IEditorEvent {
|
|
119
|
+
static SELECT: string;
|
|
120
|
+
static HOVER: string;
|
|
121
|
+
readonly target: IUI;
|
|
122
|
+
readonly editor: IEditor;
|
|
123
|
+
readonly value: IUI | IUI[];
|
|
124
|
+
readonly oldValue: IUI | IUI[];
|
|
125
|
+
get list(): IUI[];
|
|
126
|
+
get oldList(): IUI[];
|
|
127
|
+
readonly worldOrigin: IPointData;
|
|
128
|
+
readonly origin: IPointData;
|
|
129
|
+
constructor(type: string, data?: IEditorEvent);
|
|
130
|
+
}
|
|
131
|
+
|
|
81
132
|
declare class EditBox extends Group implements IEditBox {
|
|
82
133
|
editor: IEditor;
|
|
83
134
|
dragging: boolean;
|
|
135
|
+
moving: boolean;
|
|
136
|
+
view: IGroup;
|
|
84
137
|
rect: IBox;
|
|
85
138
|
circle: IEditPoint;
|
|
86
139
|
buttons: IGroup;
|
|
@@ -95,24 +148,31 @@ declare class EditBox extends Group implements IEditBox {
|
|
|
95
148
|
protected __eventIds: IEventListenerId[];
|
|
96
149
|
constructor(editor: IEditor);
|
|
97
150
|
create(): void;
|
|
151
|
+
load(): void;
|
|
98
152
|
update(bounds: IBoundsData): void;
|
|
99
|
-
protected
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
153
|
+
protected layoutCircle(config: IEditorConfig$1): void;
|
|
154
|
+
protected layoutButtons(config: IEditorConfig$1): void;
|
|
155
|
+
protected setButtonPosition(buttons: IUI, direction: number, buttonsMargin: number, useMiddlePoint: boolean): void;
|
|
156
|
+
unload(): void;
|
|
157
|
+
getPointStyle(userStyle?: IBoxInputData): IBoxInputData;
|
|
158
|
+
getPointsStyle(): IBoxInputData[];
|
|
159
|
+
getMiddlePointsStyle(): IBoxInputData[];
|
|
160
|
+
protected onSelect(e: EditorEvent): void;
|
|
103
161
|
protected onDragStart(e: DragEvent): void;
|
|
104
162
|
protected onDragEnd(e: DragEvent): void;
|
|
105
163
|
protected onDrag(e: DragEvent): void;
|
|
106
164
|
onArrow(e: IKeyEvent): void;
|
|
107
|
-
protected
|
|
108
|
-
|
|
165
|
+
protected onDoubleTap(e: PointerEvent): void;
|
|
166
|
+
protected onLongPress(e: PointerEvent): void;
|
|
167
|
+
protected openInner(e: PointerEvent): void;
|
|
168
|
+
listenPointEvents(point: IEditPoint, type: IEditPointType, direction: Direction9): void;
|
|
109
169
|
protected __listenEvents(): void;
|
|
110
170
|
protected __removeListenEvents(): void;
|
|
111
171
|
destroy(): void;
|
|
112
172
|
}
|
|
113
173
|
|
|
114
174
|
declare class EditPoint extends Box implements IEditPoint {
|
|
115
|
-
direction:
|
|
175
|
+
direction: Direction9;
|
|
116
176
|
pointType: IEditPointType;
|
|
117
177
|
}
|
|
118
178
|
|
|
@@ -133,18 +193,6 @@ declare class Stroker extends UI implements IStroker {
|
|
|
133
193
|
destroy(): void;
|
|
134
194
|
}
|
|
135
195
|
|
|
136
|
-
declare class EditorEvent extends Event implements IEditorEvent {
|
|
137
|
-
static SELECT: string;
|
|
138
|
-
static HOVER: string;
|
|
139
|
-
readonly target: IUI;
|
|
140
|
-
readonly editor: IEditor;
|
|
141
|
-
readonly value: IUI | IUI[];
|
|
142
|
-
readonly oldValue: IUI | IUI[];
|
|
143
|
-
readonly worldOrigin: IPointData;
|
|
144
|
-
readonly origin: IPointData;
|
|
145
|
-
constructor(type: string, data?: IEditorEvent);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
196
|
declare class EditorMoveEvent extends EditorEvent implements IEditorMoveEvent {
|
|
149
197
|
static MOVE: string;
|
|
150
198
|
readonly moveX: number;
|
|
@@ -158,7 +206,7 @@ declare class EditorScaleEvent extends EditorEvent implements IEditorScaleEvent
|
|
|
158
206
|
readonly scaleY: number;
|
|
159
207
|
readonly transform?: IMatrixData;
|
|
160
208
|
readonly drag: IDragEvent;
|
|
161
|
-
readonly direction:
|
|
209
|
+
readonly direction: Direction9;
|
|
162
210
|
readonly lockRatio: boolean;
|
|
163
211
|
readonly around: IAround;
|
|
164
212
|
constructor(type: string, data?: IEditorScaleEvent);
|
|
@@ -177,42 +225,99 @@ declare class EditorSkewEvent extends EditorEvent implements IEditorSkewEvent {
|
|
|
177
225
|
constructor(type: string, data?: IEditorSkewEvent);
|
|
178
226
|
}
|
|
179
227
|
|
|
180
|
-
declare class
|
|
181
|
-
static
|
|
182
|
-
|
|
228
|
+
declare class EditorGroupEvent extends EditorEvent implements IEditorGroupEvent {
|
|
229
|
+
static GROUP: string;
|
|
230
|
+
static BEFORE_UNGROUP: string;
|
|
231
|
+
static UNGROUP: string;
|
|
232
|
+
static OPEN: string;
|
|
233
|
+
static CLOSE: string;
|
|
234
|
+
readonly editTarget: IGroup;
|
|
235
|
+
constructor(type: string, data?: IEditorGroupEvent);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
declare class InnerEditorEvent extends EditorEvent implements IInnerEditorEvent {
|
|
239
|
+
static BEFORE_OPEN: string;
|
|
240
|
+
static OPEN: string;
|
|
241
|
+
static BEFORE_CLOSE: string;
|
|
242
|
+
static CLOSE: string;
|
|
243
|
+
readonly editTarget: IUI;
|
|
244
|
+
readonly innerEditor: IInnerEditor;
|
|
245
|
+
constructor(type: string, data?: IInnerEditorEvent);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
declare function registerEditTool(): (target: IObject) => void;
|
|
249
|
+
declare const registerInnerEditor: typeof registerEditTool;
|
|
250
|
+
declare const EditToolCreator: {
|
|
251
|
+
list: IObject;
|
|
252
|
+
register(EditTool: IObject): void;
|
|
253
|
+
get(tag: string, editor: IEditor): IEditTool;
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
declare class InnerEditor implements IInnerEditor {
|
|
257
|
+
static registerInnerEditor(): void;
|
|
258
|
+
get tag(): string;
|
|
259
|
+
editTarget: IUI;
|
|
260
|
+
config: IObject;
|
|
261
|
+
editor: IEditor;
|
|
262
|
+
get editBox(): IEditBox;
|
|
263
|
+
view: IGroup;
|
|
264
|
+
eventIds: IEventListenerId[];
|
|
265
|
+
constructor(editor: IEditor);
|
|
266
|
+
onCreate(): void;
|
|
267
|
+
create(): void;
|
|
268
|
+
onLoad(): void;
|
|
269
|
+
load(): void;
|
|
270
|
+
onUpdate(): void;
|
|
271
|
+
update(): void;
|
|
272
|
+
onUnload(): void;
|
|
273
|
+
unload(): void;
|
|
274
|
+
onDestroy(): void;
|
|
275
|
+
destroy(): void;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
declare class EditTool extends InnerEditor implements IEditTool {
|
|
279
|
+
static registerEditTool(): void;
|
|
280
|
+
get tag(): string;
|
|
183
281
|
onMove(e: IEditorMoveEvent): void;
|
|
184
282
|
onScale(e: IEditorScaleEvent): void;
|
|
185
283
|
onRotate(e: IEditorRotateEvent): void;
|
|
186
284
|
onSkew(e: IEditorSkewEvent): void;
|
|
187
|
-
|
|
285
|
+
load(): void;
|
|
286
|
+
update(): void;
|
|
287
|
+
unload(): void;
|
|
188
288
|
}
|
|
189
289
|
|
|
190
290
|
declare class LineEditTool extends EditTool {
|
|
191
|
-
tag: string;
|
|
291
|
+
get tag(): string;
|
|
192
292
|
scaleOfEvent: boolean;
|
|
193
293
|
onScaleWithDrag(e: IEditorScaleEvent): void;
|
|
294
|
+
getInnerMove(ui: IUI$1, event: IDragEvent$1, lockRatio: boolean | 'corner'): IPointData$1;
|
|
295
|
+
getFromToByPath(path: IPathCommandData): IFromToData;
|
|
296
|
+
getFromToByPoints(points: number[]): IFromToData;
|
|
297
|
+
dragPoint(fromPoint: IPointData$1, toPoint: IPointData$1, isDragFrom: boolean, around: IAround$1, movePoint: IPointData$1): void;
|
|
194
298
|
onSkew(_e: IEditorSkewEvent): void;
|
|
195
|
-
|
|
299
|
+
onUpdate(): void;
|
|
196
300
|
}
|
|
197
301
|
|
|
198
302
|
declare const EditorHelper: {
|
|
199
|
-
group(list: IUI[], element?: IUI,
|
|
303
|
+
group(list: IUI[], element?: IUI, userGroup?: IGroup | IGroupInputData): IGroup;
|
|
200
304
|
ungroup(list: IUI[]): IUI[];
|
|
201
305
|
toTop(list: IUI[]): void;
|
|
202
306
|
toBottom(list: IUI[]): void;
|
|
203
307
|
};
|
|
204
308
|
|
|
205
309
|
declare const EditDataHelper: {
|
|
206
|
-
getScaleData(
|
|
207
|
-
getRotateData(bounds: IBoundsData, direction:
|
|
208
|
-
getSkewData(bounds: IBoundsData, direction:
|
|
310
|
+
getScaleData(element: IUI, startBounds: ILayoutBoundsData, direction: Direction9, totalMove: IPointData, lockRatio: boolean | "corner", around: IAround, flipable: boolean, scaleMode: boolean): IEditorScaleEvent;
|
|
311
|
+
getRotateData(bounds: IBoundsData, direction: Direction9, current: IPointData, last: IPointData, around: IAround): IEditorRotateEvent;
|
|
312
|
+
getSkewData(bounds: IBoundsData, direction: Direction9, move: IPointData, around: IAround): IEditorSkewEvent;
|
|
209
313
|
getAround(around: IAround, altKey: boolean): IAround;
|
|
210
314
|
getRotateDirection(direction: number, rotation: number, totalDirection?: number): number;
|
|
315
|
+
getFlipDirection(direction: Direction9, flipedX: boolean, flipedY: boolean): Direction9;
|
|
211
316
|
};
|
|
212
317
|
|
|
213
318
|
declare const EditSelectHelper: {
|
|
214
319
|
findOne(path: ILeafList): IUI;
|
|
215
|
-
findBounds(leaf: IUI, bounds: IBounds):
|
|
320
|
+
findBounds(leaf: IUI, bounds: IBounds): Answer;
|
|
216
321
|
};
|
|
217
322
|
|
|
218
|
-
export { EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, Editor, EditorEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, LineEditTool, SelectArea, Stroker };
|
|
323
|
+
export { EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, InnerEditor, InnerEditorEvent, 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
|
-
}
|