@leafer-in/editor 1.6.7 → 1.8.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/types/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { IBounds, ILeafList, IUI, IFunction, IEventListenerId, ILeaf, IPointerEvent, ILeaferCanvas, IRenderOptions, IGroup, IObject, IGroupInputData, IEditSize, IPointData, IAlign, IAxis, IMatrix, IApp, IBox, IEditorDragStartData, IBoundsData, IEditorConfig as IEditorConfig$1, IBoxInputData, IKeyEvent, IRect, IRectInputData, IMatrixData, IDragEvent, IAround, ILayoutBoundsData } from '@leafer-ui/interface';
2
- import { Group, UI, Direction9, Event, Box } from '@leafer-ui/draw';
1
+ import { IBounds, ILeafList, IUI, IFunction, IEventListenerId, ILeaf, IPointerEvent, ILeaferCanvas, IRenderOptions, IGroup, IObject, IGroupInputData, IEditSize, IPointData, IAlign, IAxis, IMatrix, IApp, IBox, IEditorDragStartData, IEditorConfig as IEditorConfig$1, ITransformTool, IBoundsData, IBoxInputData, IKeyEvent, IRect, IRectInputData, IMatrixData, IDragEvent, IAround, IEvent, ILayoutBoundsData } from '@leafer-ui/interface';
2
+ import { Group, UI, Direction9, Box, Event } from '@leafer-ui/draw';
3
3
  import { PointerEvent, DragEvent, MoveEvent, ZoomEvent, RotateEvent, KeyEvent } from '@leafer-ui/core';
4
- import { IEditSelect, IEditor, IStroker, ISelectArea, IEditorConfig, IEditPoint, ISimulateElement, IEditBox, IEditTool, IInnerEditor, IEditorScaleEvent, IEditorEvent, IEditPointType, IEditPointInputData, 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
+ import { IEditSelect, IEditor, IStroker, ISelectArea, IEditorConfig, IEditPoint, ISimulateElement, IEditBox, IEditTool, IInnerEditor, IEditorScaleEvent, IEditPointType, IEditPointInputData, IEditorEvent, IEditorMoveEvent, IEditorRotateEvent, IEditorSkewEvent, IEditorGroupEvent, IInnerEditorEvent, IInnerEditorMode, IUI as IUI$1, IDragEvent as IDragEvent$1, IPointData as IPointData$1, IPathCommandData, IFromToData, IAround as IAround$1 } from '@leafer-in/interface';
5
5
 
6
6
  declare class EditSelect extends Group implements IEditSelect {
7
7
  editor: IEditor;
@@ -63,9 +63,13 @@ declare class Editor extends Group implements IEditor {
63
63
  resizeDirection?: Direction9;
64
64
  get multiple(): boolean;
65
65
  get single(): boolean;
66
+ get dragPoint(): IEditPoint;
66
67
  get dragging(): boolean;
68
+ get gesturing(): boolean;
67
69
  get moving(): boolean;
68
- get dragPoint(): IEditPoint;
70
+ get resizing(): boolean;
71
+ get rotating(): boolean;
72
+ get skewing(): boolean;
69
73
  get element(): ISimulateElement;
70
74
  simulateTarget: ISimulateElement;
71
75
  editBox: IEditBox;
@@ -87,20 +91,21 @@ declare class Editor extends Group implements IEditor {
87
91
  update(): void;
88
92
  updateEditBox(): void;
89
93
  updateEditTool(): void;
94
+ unloadEditTool(): void;
90
95
  getEditSize(_ui: IUI): IEditSize;
91
- onMove(e: DragEvent | MoveEvent): void;
92
- onScale(e: DragEvent | ZoomEvent): void;
93
- onRotate(e: DragEvent | RotateEvent): void;
94
- onSkew(e: DragEvent): void;
95
- move(x: number | IPointData, y?: number): void;
96
- scaleWithDrag(data: IEditorScaleEvent): void;
97
- scaleOf(origin: IPointData | IAlign, scaleX: number, scaleY?: number, _resize?: boolean): void;
98
- flip(axis: IAxis): void;
99
- rotateOf(origin: IPointData | IAlign, rotation: number): void;
100
- skewOf(origin: IPointData | IAlign, skewX: number, skewY?: number, _resize?: boolean): void;
101
- checkTransform(type: 'moveable' | 'resizeable' | 'rotateable' | 'skewable'): boolean;
102
- protected getWorldOrigin(origin: IPointData | IAlign): IPointData;
103
- protected getChangedTransform(func: IFunction): IMatrix;
96
+ onMove(_e: DragEvent | MoveEvent): void;
97
+ onScale(_e: DragEvent | ZoomEvent): void;
98
+ onRotate(_e: DragEvent | RotateEvent): void;
99
+ onSkew(_e: DragEvent): void;
100
+ move(_x: number | IPointData, _y?: number): void;
101
+ scaleWithDrag(_data: IEditorScaleEvent): void;
102
+ scaleOf(_origin: IPointData | IAlign, scaleX: number, _scaleY?: number, _resize?: boolean): void;
103
+ flip(_axis: IAxis): void;
104
+ rotateOf(_origin: IPointData | IAlign, _rotation: number): void;
105
+ skewOf(_origin: IPointData | IAlign, _skewX: number, _skewY?: number, _resize?: boolean): void;
106
+ checkTransform(_type: 'moveable' | 'resizeable' | 'rotateable' | 'skewable'): boolean;
107
+ protected getWorldOrigin(_origin: IPointData | IAlign): IPointData;
108
+ protected getChangedTransform(_func: IFunction): IMatrix;
104
109
  group(userGroup?: IGroup | IGroupInputData): IGroup;
105
110
  ungroup(): IUI[];
106
111
  openGroup(group: IGroup): void;
@@ -108,8 +113,8 @@ declare class Editor extends Group implements IEditor {
108
113
  checkOpenedGroups(): void;
109
114
  checkDeepSelect(): void;
110
115
  emitGroupEvent(type: string, group?: IGroup): void;
111
- openInnerEditor(target?: IUI, select?: boolean): void;
112
- closeInnerEditor(): void;
116
+ openInnerEditor(target?: IUI, nameOrSelect?: string | boolean, select?: boolean): void;
117
+ closeInnerEditor(onlyInnerEditor?: boolean): void;
113
118
  emitInnerEvent(type: string): void;
114
119
  lock(): void;
115
120
  unlock(): void;
@@ -117,32 +122,19 @@ declare class Editor extends Group implements IEditor {
117
122
  toBottom(): void;
118
123
  protected onAppRenderStart(app: IApp): void;
119
124
  protected onRenderStart(): void;
120
- protected onKey(e: KeyEvent): void;
121
125
  listenTargetEvents(): void;
122
126
  removeTargetEvents(): void;
123
127
  destroy(): void;
124
128
  }
125
129
 
126
- declare class EditorEvent extends Event implements IEditorEvent {
127
- static BEFORE_SELECT: string;
128
- static SELECT: string;
129
- static BEFORE_HOVER: string;
130
- static HOVER: string;
131
- readonly target: IUI;
132
- readonly editor: IEditor;
133
- readonly value: IUI | IUI[];
134
- readonly oldValue: IUI | IUI[];
135
- get list(): IUI[];
136
- get oldList(): IUI[];
137
- readonly worldOrigin: IPointData;
138
- readonly origin: IPointData;
139
- constructor(type: string, data?: IEditorEvent);
140
- }
141
-
142
130
  declare class EditBox extends Group implements IEditBox {
143
131
  editor: IEditor;
144
132
  dragging: boolean;
133
+ gesturing: boolean;
145
134
  moving: boolean;
135
+ resizing: boolean;
136
+ rotating: boolean;
137
+ skewing: boolean;
146
138
  view: IGroup;
147
139
  rect: IBox;
148
140
  circle: IEditPoint;
@@ -153,26 +145,43 @@ declare class EditBox extends Group implements IEditBox {
153
145
  enterPoint: IEditPoint;
154
146
  dragPoint: IEditPoint;
155
147
  dragStartData: IEditorDragStartData;
148
+ config: IEditorConfig$1;
149
+ mergedConfig: IEditorConfig$1;
150
+ get mergeConfig(): IEditorConfig$1;
151
+ protected _target: IUI;
152
+ get target(): IUI;
153
+ set target(target: IUI);
154
+ get single(): boolean;
155
+ protected _transformTool: ITransformTool;
156
+ get transformTool(): ITransformTool;
157
+ set transformTool(tool: ITransformTool);
156
158
  get flipped(): boolean;
157
159
  get flippedX(): boolean;
158
160
  get flippedY(): boolean;
159
161
  get flippedOne(): boolean;
162
+ get canUse(): boolean;
163
+ get canGesture(): boolean;
160
164
  protected __eventIds: IEventListenerId[];
161
165
  constructor(editor: IEditor);
162
166
  create(): void;
163
167
  load(): void;
164
- update(bounds: IBoundsData): void;
165
- protected layoutCircle(config: IEditorConfig$1): void;
166
- protected layoutButtons(config: IEditorConfig$1): void;
167
- protected setButtonPosition(buttons: IUI, direction: number, buttonsMargin: number, useMiddlePoint: boolean): void;
168
+ update(): void;
168
169
  unload(): void;
170
+ updateBounds(bounds: IBoundsData): void;
171
+ protected layoutCircle(): void;
172
+ protected layoutButtons(): void;
173
+ protected setButtonPosition(buttons: IUI, direction: number, buttonsMargin: number, useMiddlePoint: boolean): void;
169
174
  getPointStyle(userStyle?: IBoxInputData): IBoxInputData;
170
175
  getPointsStyle(): IBoxInputData[];
171
176
  getMiddlePointsStyle(): IBoxInputData[];
172
- protected onSelect(e: EditorEvent): void;
173
177
  protected onDragStart(e: DragEvent): void;
174
178
  protected onDragEnd(e: DragEvent): void;
175
179
  protected onDrag(e: DragEvent): void;
180
+ protected resetDoing(): void;
181
+ onMove(e: MoveEvent): void;
182
+ onScale(e: ZoomEvent): void;
183
+ onRotate(e: RotateEvent): void;
184
+ protected onKey(e: KeyEvent): void;
176
185
  onArrow(e: IKeyEvent): void;
177
186
  protected onDoubleTap(e: PointerEvent): void;
178
187
  protected onLongPress(e: PointerEvent): void;
@@ -201,12 +210,29 @@ declare class Stroker extends UI implements IStroker {
201
210
  target: IUI | IUI[];
202
211
  list: IUI[];
203
212
  constructor();
204
- setTarget(target: IUI | IUI[], style: IRectInputData): void;
205
- update(): void;
213
+ setTarget(target: IUI | IUI[], style?: IRectInputData): void;
214
+ update(style?: IRectInputData): void;
206
215
  __draw(canvas: ILeaferCanvas, options: IRenderOptions): void;
207
216
  destroy(): void;
208
217
  }
209
218
 
219
+ declare class EditorEvent extends Event implements IEditorEvent {
220
+ static BEFORE_SELECT: string;
221
+ static SELECT: string;
222
+ static AFTER_SELECT: string;
223
+ static BEFORE_HOVER: string;
224
+ static HOVER: string;
225
+ readonly target: IUI;
226
+ readonly editor: IEditor;
227
+ readonly value: IUI | IUI[];
228
+ readonly oldValue: IUI | IUI[];
229
+ get list(): IUI[];
230
+ get oldList(): IUI[];
231
+ readonly worldOrigin: IPointData;
232
+ readonly origin: IPointData;
233
+ constructor(type: string, data?: IEditorEvent);
234
+ }
235
+
210
236
  declare class EditorMoveEvent extends EditorEvent implements IEditorMoveEvent {
211
237
  static BEFORE_MOVE: string;
212
238
  static MOVE: string;
@@ -277,6 +303,7 @@ declare const EditToolCreator: {
277
303
  declare class InnerEditor implements IInnerEditor {
278
304
  static registerInnerEditor(): void;
279
305
  get tag(): string;
306
+ get mode(): IInnerEditorMode;
280
307
  editTarget: IUI;
281
308
  config: IObject;
282
309
  editor: IEditor;
@@ -320,6 +347,29 @@ declare class LineEditTool extends EditTool {
320
347
  onUpdate(): void;
321
348
  }
322
349
 
350
+ declare class TransformTool implements ITransformTool {
351
+ editBox: IEditBox;
352
+ editTool?: IEditTool;
353
+ onMove(e: DragEvent | MoveEvent): void;
354
+ onScale(e: DragEvent | ZoomEvent): void;
355
+ onRotate(e: DragEvent | RotateEvent): void;
356
+ onSkew(e: DragEvent): void;
357
+ move(x: number | IPointData, y?: number): void;
358
+ scaleWithDrag(data: IEditorScaleEvent): void;
359
+ scaleOf(origin: IPointData | IAlign, scaleX: number, scaleY?: number, _resize?: boolean): void;
360
+ flip(axis: IAxis): void;
361
+ rotateOf(origin: IPointData | IAlign, rotation: number): void;
362
+ skewOf(origin: IPointData | IAlign, skewX: number, skewY?: number, _resize?: boolean): void;
363
+ protected doMove(event: IEditorMoveEvent): void;
364
+ protected doScale(event: IEditorScaleEvent): void;
365
+ protected doRotate(event: IEditorRotateEvent): void;
366
+ protected doSkew(event: IEditorSkewEvent): void;
367
+ checkTransform(type: 'moveable' | 'resizeable' | 'rotateable' | 'skewable'): boolean;
368
+ protected getWorldOrigin(origin: IPointData | IAlign): IPointData;
369
+ protected getChangedTransform(func: IFunction): IMatrix;
370
+ emitEvent(event?: IEvent, capture?: boolean): void;
371
+ }
372
+
323
373
  declare const EditorHelper: {
324
374
  group(list: IUI[], element?: IUI, userGroup?: IGroup | IGroupInputData): IGroup;
325
375
  ungroup(list: IUI[]): IUI[];
@@ -328,8 +378,8 @@ declare const EditorHelper: {
328
378
  };
329
379
 
330
380
  declare const EditDataHelper: {
331
- getScaleData(element: IUI, startBounds: ILayoutBoundsData, direction: Direction9, totalMove: IPointData, lockRatio: boolean | "corner", around: IAround, flipable: boolean, scaleMode: boolean): IEditorScaleEvent;
332
- getRotateData(bounds: IBoundsData, direction: Direction9, current: IPointData, last: IPointData, around: IAround): IEditorRotateEvent;
381
+ getScaleData(target: IUI, startBounds: ILayoutBoundsData, direction: Direction9, totalMove: IPointData, lockRatio: boolean | "corner", around: IAround, flipable: boolean, scaleMode: boolean): IEditorScaleEvent;
382
+ getRotateData(target: IUI, direction: Direction9, current: IPointData, last: IPointData, around: IAround): IEditorRotateEvent;
333
383
  getSkewData(bounds: IBoundsData, direction: Direction9, move: IPointData, around: IAround): IEditorSkewEvent;
334
384
  getAround(around: IAround, altKey: boolean): IAround;
335
385
  getRotateDirection(direction: number, rotation: number, totalDirection?: number): number;
@@ -341,4 +391,4 @@ declare const EditSelectHelper: {
341
391
  findByBounds(branch: IUI, bounds: IBounds): IUI[];
342
392
  };
343
393
 
344
- export { EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, InnerEditor, InnerEditorEvent, LineEditTool, SelectArea, Stroker, registerEditTool, registerInnerEditor };
394
+ export { EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, InnerEditor, InnerEditorEvent, LineEditTool, SelectArea, Stroker, TransformTool, registerEditTool, registerInnerEditor };