@leafer-in/interface 1.0.0-rc.6 → 1.0.0-rc.8
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/package.json +3 -3
- package/src/editor/IEditBox.ts +29 -0
- package/src/editor/IEditPoint.ts +9 -0
- package/src/editor/IEditSelect.ts +20 -0
- package/src/editor/IEditor.ts +81 -0
- package/src/editor/ISelectArea.ts +6 -0
- package/src/editor/IStroker.ts +6 -0
- package/src/html/IHTMLTextData.ts +9 -0
- package/src/index.ts +11 -1
- package/types/index.d.ts +93 -51
- package/src/IEditor.ts +0 -98
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-in/interface",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.8",
|
|
4
4
|
"description": "@leafer-in/interface",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"leaferjs"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@leafer-ui/interface": "1.0.0-rc.
|
|
29
|
-
"@leafer/interface": "1.0.0-rc.
|
|
28
|
+
"@leafer-ui/interface": "1.0.0-rc.8",
|
|
29
|
+
"@leafer/interface": "1.0.0-rc.8"
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { IGroup, IRect, IBoundsData, IKeyEvent } from '@leafer-ui/interface'
|
|
2
|
+
import { IEditor } from '@leafer-in/interface'
|
|
3
|
+
import { IEditPoint } from './IEditPoint'
|
|
4
|
+
|
|
5
|
+
export interface IEditBox extends IGroup {
|
|
6
|
+
|
|
7
|
+
editor: IEditor
|
|
8
|
+
dragging?: boolean
|
|
9
|
+
|
|
10
|
+
circle: IEditPoint
|
|
11
|
+
rect: IRect
|
|
12
|
+
|
|
13
|
+
buttons: IGroup
|
|
14
|
+
|
|
15
|
+
resizePoints: IEditPoint[]
|
|
16
|
+
rotatePoints: IEditPoint[]
|
|
17
|
+
resizeLines: IEditPoint[]
|
|
18
|
+
|
|
19
|
+
readonly flipped: boolean
|
|
20
|
+
readonly flippedX: boolean
|
|
21
|
+
readonly flippedY: boolean
|
|
22
|
+
readonly flippedOne: boolean
|
|
23
|
+
|
|
24
|
+
enterPoint: IEditPoint
|
|
25
|
+
|
|
26
|
+
update(bounds: IBoundsData): void
|
|
27
|
+
onArrow(e: IKeyEvent): void
|
|
28
|
+
|
|
29
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { IGroup, IBounds } from '@leafer-ui/interface'
|
|
2
|
+
|
|
3
|
+
import { IStroker } from './IStroker'
|
|
4
|
+
import { ISelectArea } from './ISelectArea'
|
|
5
|
+
import { IEditor } from './IEditor'
|
|
6
|
+
|
|
7
|
+
export interface IEditSelect extends IGroup {
|
|
8
|
+
editor: IEditor
|
|
9
|
+
|
|
10
|
+
dragging: boolean
|
|
11
|
+
running: boolean
|
|
12
|
+
|
|
13
|
+
hoverStroker: IStroker
|
|
14
|
+
targetStroker: IStroker
|
|
15
|
+
|
|
16
|
+
selectArea: ISelectArea
|
|
17
|
+
bounds: IBounds
|
|
18
|
+
|
|
19
|
+
update(): void
|
|
20
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { IUI, IPointData, IAround, IDragEvent, IEvent, IEventListenerId, ILeafList, IMatrixData, IEditorBase } from '@leafer-ui/interface'
|
|
2
|
+
import { IEditBox } from './IEditBox'
|
|
3
|
+
import { IEditSelect } from './IEditSelect'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export interface IEditor extends IEditorBase {
|
|
7
|
+
leafList: ILeafList
|
|
8
|
+
|
|
9
|
+
simulateTarget: IUI
|
|
10
|
+
|
|
11
|
+
selector: IEditSelect
|
|
12
|
+
editBox: IEditBox
|
|
13
|
+
editTool: IEditTool
|
|
14
|
+
|
|
15
|
+
targetEventIds: IEventListenerId[]
|
|
16
|
+
|
|
17
|
+
listenTargetEvents(): void
|
|
18
|
+
removeTargetEvents(): void
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface IEditTool {
|
|
22
|
+
tag: string
|
|
23
|
+
onMove(e: IEditorMoveEvent): void
|
|
24
|
+
onScale(e: IEditorScaleEvent): void
|
|
25
|
+
onScaleWithDrag?(e: IEditorScaleEvent): void
|
|
26
|
+
onRotate(e: IEditorRotateEvent): void
|
|
27
|
+
onSkew(e: IEditorSkewEvent): void
|
|
28
|
+
update(editor: IEditor): void
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export enum IDirection8 {
|
|
32
|
+
topLeft,
|
|
33
|
+
top,
|
|
34
|
+
topRight,
|
|
35
|
+
right,
|
|
36
|
+
bottomRight,
|
|
37
|
+
bottom,
|
|
38
|
+
bottomLeft,
|
|
39
|
+
left
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface IEditorEvent extends IEvent {
|
|
43
|
+
readonly target?: IUI
|
|
44
|
+
readonly editor?: IEditor
|
|
45
|
+
|
|
46
|
+
readonly value?: IUI | IUI[]
|
|
47
|
+
readonly oldValue?: IUI | IUI[]
|
|
48
|
+
|
|
49
|
+
readonly worldOrigin?: IPointData
|
|
50
|
+
readonly origin?: IPointData
|
|
51
|
+
}
|
|
52
|
+
export interface IEditorMoveEvent extends IEditorEvent {
|
|
53
|
+
readonly moveX: number
|
|
54
|
+
readonly moveY: number
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface IEditorScaleEvent extends IEditorEvent {
|
|
58
|
+
// scaleOf(origin, scaleX, scaleY, resize) / transform(transform, resize)
|
|
59
|
+
readonly scaleX?: number
|
|
60
|
+
readonly scaleY?: number
|
|
61
|
+
transform?: IMatrixData
|
|
62
|
+
|
|
63
|
+
readonly direction?: IDirection8
|
|
64
|
+
readonly lockRatio?: boolean
|
|
65
|
+
readonly around?: IAround
|
|
66
|
+
|
|
67
|
+
drag?: IDragEvent
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface IEditorRotateEvent extends IEditorEvent {
|
|
71
|
+
// rotateOf(origin, rotation)
|
|
72
|
+
readonly rotation?: number
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface IEditorSkewEvent extends IEditorEvent {
|
|
76
|
+
// skewOf(origin, skewX, skewY)
|
|
77
|
+
transform?: IMatrixData
|
|
78
|
+
readonly skewX?: number
|
|
79
|
+
readonly skewY?: number
|
|
80
|
+
}
|
|
81
|
+
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IImageInputData, IImageData } from '@leafer-ui/interface'
|
|
2
|
+
|
|
3
|
+
interface IHTMLTextAttrData {
|
|
4
|
+
text?: string
|
|
5
|
+
__htmlChanged?: boolean
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface IHTMLTextData extends IHTMLTextAttrData, IImageData { }
|
|
9
|
+
export interface IHTMLTextInputData extends IHTMLTextAttrData, IImageInputData { }
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
export * from '@leafer-ui/interface'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// editor
|
|
4
|
+
export { IEditor, IEditTool, IDirection8, IEditorScaleEvent, IEditorRotateEvent, IEditorSkewEvent, IEditorEvent, IEditorMoveEvent } from './editor/IEditor'
|
|
5
|
+
export { IStroker } from './editor/IStroker'
|
|
6
|
+
export { IEditBox } from './editor/IEditBox'
|
|
7
|
+
export { ISelectArea } from './editor/ISelectArea'
|
|
8
|
+
export { IEditSelect } from './editor/IEditSelect'
|
|
9
|
+
export { IEditPoint, IEditPointType } from './editor/IEditPoint'
|
|
10
|
+
|
|
11
|
+
// html
|
|
12
|
+
|
|
13
|
+
export { IHTMLTextData, IHTMLTextInputData } from './html/IHTMLTextData'
|
package/types/index.d.ts
CHANGED
|
@@ -1,46 +1,70 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IBox, IGroup, IRect, IBoundsData, IKeyEvent, IUI, IRectInputData, IBounds, IEditorBase, ILeafList, IEventListenerId, IEvent, IPointData, IMatrixData, IAround, IDragEvent, IImageData, IImageInputData } from '@leafer-ui/interface';
|
|
2
2
|
export * from '@leafer-ui/interface';
|
|
3
|
+
import { IEditor as IEditor$1 } from '@leafer-in/interface';
|
|
3
4
|
|
|
4
|
-
interface
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
interface IEditPoint extends IBox {
|
|
6
|
+
direction: IDirection8;
|
|
7
|
+
pointType: IEditPointType;
|
|
8
|
+
}
|
|
9
|
+
type IEditPointType = 'rotate' | 'resize';
|
|
10
|
+
|
|
11
|
+
interface IEditBox extends IGroup {
|
|
12
|
+
editor: IEditor$1;
|
|
13
|
+
dragging?: boolean;
|
|
14
|
+
circle: IEditPoint;
|
|
15
|
+
rect: IRect;
|
|
16
|
+
buttons: IGroup;
|
|
17
|
+
resizePoints: IEditPoint[];
|
|
18
|
+
rotatePoints: IEditPoint[];
|
|
19
|
+
resizeLines: IEditPoint[];
|
|
20
|
+
readonly flipped: boolean;
|
|
21
|
+
readonly flippedX: boolean;
|
|
22
|
+
readonly flippedY: boolean;
|
|
23
|
+
readonly flippedOne: boolean;
|
|
24
|
+
enterPoint: IEditPoint;
|
|
25
|
+
update(bounds: IBoundsData): void;
|
|
26
|
+
onArrow(e: IKeyEvent): void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface IStroker extends IUI {
|
|
30
|
+
target: IUI | IUI[];
|
|
31
|
+
setTarget(target: IUI | IUI[], style: IRectInputData): void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface ISelectArea extends IGroup {
|
|
35
|
+
setStyle(style: IRectInputData, userStyle?: IRectInputData): void;
|
|
36
|
+
setBounds(bounds: IBoundsData): void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface IEditSelect extends IGroup {
|
|
40
|
+
editor: IEditor;
|
|
41
|
+
dragging: boolean;
|
|
42
|
+
running: boolean;
|
|
43
|
+
hoverStroker: IStroker;
|
|
44
|
+
targetStroker: IStroker;
|
|
45
|
+
selectArea: ISelectArea;
|
|
46
|
+
bounds: IBounds;
|
|
16
47
|
update(): void;
|
|
17
48
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
49
|
+
|
|
50
|
+
interface IEditor extends IEditorBase {
|
|
51
|
+
leafList: ILeafList;
|
|
52
|
+
simulateTarget: IUI;
|
|
53
|
+
selector: IEditSelect;
|
|
54
|
+
editBox: IEditBox;
|
|
55
|
+
editTool: IEditTool;
|
|
56
|
+
targetEventIds: IEventListenerId[];
|
|
57
|
+
listenTargetEvents(): void;
|
|
58
|
+
removeTargetEvents(): void;
|
|
24
59
|
}
|
|
25
|
-
interface
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
pointSize?: number;
|
|
34
|
-
pointRadius?: number;
|
|
35
|
-
point?: IRectInputData | IRectInputData[];
|
|
36
|
-
rotatePoint?: IRectInputData;
|
|
37
|
-
rect?: IRectInputData;
|
|
38
|
-
hideOnMove?: boolean;
|
|
39
|
-
moveCursor?: ICursorType;
|
|
40
|
-
resizeCursor?: ICursorType[];
|
|
41
|
-
rotateCursor?: ICursorType[];
|
|
42
|
-
rotateable?: boolean;
|
|
43
|
-
resizeable?: boolean;
|
|
60
|
+
interface IEditTool {
|
|
61
|
+
tag: string;
|
|
62
|
+
onMove(e: IEditorMoveEvent): void;
|
|
63
|
+
onScale(e: IEditorScaleEvent): void;
|
|
64
|
+
onScaleWithDrag?(e: IEditorScaleEvent): void;
|
|
65
|
+
onRotate(e: IEditorRotateEvent): void;
|
|
66
|
+
onSkew(e: IEditorSkewEvent): void;
|
|
67
|
+
update(editor: IEditor): void;
|
|
44
68
|
}
|
|
45
69
|
declare enum IDirection8 {
|
|
46
70
|
topLeft = 0,
|
|
@@ -52,25 +76,43 @@ declare enum IDirection8 {
|
|
|
52
76
|
bottomLeft = 6,
|
|
53
77
|
left = 7
|
|
54
78
|
}
|
|
55
|
-
interface
|
|
79
|
+
interface IEditorEvent extends IEvent {
|
|
56
80
|
readonly target?: IUI;
|
|
57
81
|
readonly editor?: IEditor;
|
|
58
|
-
readonly
|
|
59
|
-
readonly
|
|
60
|
-
readonly
|
|
61
|
-
readonly dragEvent?: IDragEvent;
|
|
62
|
-
readonly direction?: IDirection8;
|
|
63
|
-
readonly bounds?: IBoundsData;
|
|
64
|
-
readonly old?: IBoundsData;
|
|
82
|
+
readonly value?: IUI | IUI[];
|
|
83
|
+
readonly oldValue?: IUI | IUI[];
|
|
84
|
+
readonly worldOrigin?: IPointData;
|
|
65
85
|
readonly origin?: IPointData;
|
|
86
|
+
}
|
|
87
|
+
interface IEditorMoveEvent extends IEditorEvent {
|
|
88
|
+
readonly moveX: number;
|
|
89
|
+
readonly moveY: number;
|
|
90
|
+
}
|
|
91
|
+
interface IEditorScaleEvent extends IEditorEvent {
|
|
66
92
|
readonly scaleX?: number;
|
|
67
93
|
readonly scaleY?: number;
|
|
94
|
+
transform?: IMatrixData;
|
|
95
|
+
readonly direction?: IDirection8;
|
|
96
|
+
readonly lockRatio?: boolean;
|
|
97
|
+
readonly around?: IAround;
|
|
98
|
+
drag?: IDragEvent;
|
|
68
99
|
}
|
|
69
|
-
interface IEditorRotateEvent extends
|
|
70
|
-
readonly target?: IUI;
|
|
71
|
-
readonly editor?: IEditor;
|
|
72
|
-
readonly origin?: IPointData;
|
|
100
|
+
interface IEditorRotateEvent extends IEditorEvent {
|
|
73
101
|
readonly rotation?: number;
|
|
74
102
|
}
|
|
103
|
+
interface IEditorSkewEvent extends IEditorEvent {
|
|
104
|
+
transform?: IMatrixData;
|
|
105
|
+
readonly skewX?: number;
|
|
106
|
+
readonly skewY?: number;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
interface IHTMLTextAttrData {
|
|
110
|
+
text?: string;
|
|
111
|
+
__htmlChanged?: boolean;
|
|
112
|
+
}
|
|
113
|
+
interface IHTMLTextData extends IHTMLTextAttrData, IImageData {
|
|
114
|
+
}
|
|
115
|
+
interface IHTMLTextInputData extends IHTMLTextAttrData, IImageInputData {
|
|
116
|
+
}
|
|
75
117
|
|
|
76
|
-
export { IDirection8, type IEditor, type
|
|
118
|
+
export { IDirection8, type IEditBox, type IEditPoint, type IEditPointType, type IEditSelect, type IEditTool, type IEditor, type IEditorEvent, type IEditorMoveEvent, type IEditorRotateEvent, type IEditorScaleEvent, type IEditorSkewEvent, type IHTMLTextData, type IHTMLTextInputData, type ISelectArea, type IStroker };
|
package/src/IEditor.ts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { IGroup, IUI, IRectInputData, IResizeType, IPolygon, ICursorType, IBoundsData, IPointData, IAround, IDragEvent, IEvent } from '@leafer-ui/interface'
|
|
2
|
-
|
|
3
|
-
export interface IEditor extends IGroup {
|
|
4
|
-
config: IEditorConfig
|
|
5
|
-
|
|
6
|
-
resizePoints: IUI[]
|
|
7
|
-
rotatePoints: IUI[]
|
|
8
|
-
resizeLines: IUI[]
|
|
9
|
-
|
|
10
|
-
circle: IUI
|
|
11
|
-
targetRect: IUI
|
|
12
|
-
rect: IPolygon
|
|
13
|
-
|
|
14
|
-
target: IUI
|
|
15
|
-
|
|
16
|
-
tool: IEditorTool
|
|
17
|
-
|
|
18
|
-
enterPoint: IUI
|
|
19
|
-
|
|
20
|
-
getTool(value: IUI): IEditorTool
|
|
21
|
-
update(): void
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface IEditorTool {
|
|
25
|
-
name: string
|
|
26
|
-
getMirrorData(editor: IEditor): IPointData
|
|
27
|
-
resize(e: IEditorResizeEvent): void
|
|
28
|
-
rotate(e: IEditorRotateEvent): void
|
|
29
|
-
update(editor: IEditor): void
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface IEditorConfig {
|
|
33
|
-
type?: 'pc' | 'mobile'
|
|
34
|
-
resizeType?: 'auto' | IResizeType
|
|
35
|
-
|
|
36
|
-
around?: IAround
|
|
37
|
-
lockRatio?: boolean
|
|
38
|
-
rotateGap?: number
|
|
39
|
-
|
|
40
|
-
stroke?: string
|
|
41
|
-
pointFill?: string
|
|
42
|
-
pointSize?: number
|
|
43
|
-
pointRadius?: number
|
|
44
|
-
|
|
45
|
-
point?: IRectInputData | IRectInputData[]
|
|
46
|
-
rotatePoint?: IRectInputData
|
|
47
|
-
rect?: IRectInputData
|
|
48
|
-
|
|
49
|
-
hideOnMove?: boolean
|
|
50
|
-
|
|
51
|
-
moveCursor?: ICursorType
|
|
52
|
-
resizeCursor?: ICursorType[]
|
|
53
|
-
rotateCursor?: ICursorType[]
|
|
54
|
-
|
|
55
|
-
rotateable?: boolean
|
|
56
|
-
resizeable?: boolean
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export enum IDirection8 {
|
|
60
|
-
topLeft,
|
|
61
|
-
top,
|
|
62
|
-
topRight,
|
|
63
|
-
right,
|
|
64
|
-
bottomRight,
|
|
65
|
-
bottom,
|
|
66
|
-
bottomLeft,
|
|
67
|
-
left
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface IEditorResizeEvent extends IEvent {
|
|
71
|
-
readonly target?: IUI
|
|
72
|
-
readonly editor?: IEditor
|
|
73
|
-
|
|
74
|
-
readonly resizeType?: IResizeType
|
|
75
|
-
readonly lockRatio?: boolean
|
|
76
|
-
readonly around?: IAround
|
|
77
|
-
|
|
78
|
-
readonly dragEvent?: IDragEvent
|
|
79
|
-
readonly direction?: IDirection8
|
|
80
|
-
|
|
81
|
-
// from old to bounds
|
|
82
|
-
readonly bounds?: IBoundsData
|
|
83
|
-
readonly old?: IBoundsData
|
|
84
|
-
|
|
85
|
-
// scaleOf(origin, scaleX, scaleY)
|
|
86
|
-
readonly origin?: IPointData
|
|
87
|
-
readonly scaleX?: number
|
|
88
|
-
readonly scaleY?: number
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export interface IEditorRotateEvent extends IEvent {
|
|
92
|
-
readonly target?: IUI
|
|
93
|
-
readonly editor?: IEditor
|
|
94
|
-
|
|
95
|
-
// rotateOf(origin, rotation)
|
|
96
|
-
readonly origin?: IPointData
|
|
97
|
-
readonly rotation?: number
|
|
98
|
-
}
|