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