@leafer-ui/interface 1.0.0-beta.9 → 1.0.0-rc.10
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 +6 -3
- package/src/ICommonAttr.ts +54 -39
- package/src/IUI.ts +112 -49
- package/src/app/IApp.ts +16 -0
- package/src/app/ILeafer.ts +21 -0
- package/src/editor/IEditor.ts +88 -0
- package/src/index.ts +16 -7
- package/src/module/IColorConvert.ts +5 -0
- package/src/module/IEffect.ts +5 -5
- package/src/module/IExport.ts +2 -14
- package/src/module/IPaint.ts +31 -14
- package/src/module/ITextConvert.ts +5 -0
- package/src/type/IComputedType.ts +20 -4
- package/src/type/IType.ts +17 -2
- package/types/index.d.ts +756 -0
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/interface",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-rc.10",
|
|
4
4
|
"description": "@leafer-ui/interface",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "src/index.ts",
|
|
8
|
+
"types": "types/index.d.ts",
|
|
8
9
|
"files": [
|
|
9
|
-
"src"
|
|
10
|
+
"src",
|
|
11
|
+
"types",
|
|
12
|
+
"dist"
|
|
10
13
|
],
|
|
11
14
|
"repository": {
|
|
12
15
|
"type": "git",
|
|
@@ -19,6 +22,6 @@
|
|
|
19
22
|
"leaferjs"
|
|
20
23
|
],
|
|
21
24
|
"dependencies": {
|
|
22
|
-
"@leafer/interface": "1.0.0-
|
|
25
|
+
"@leafer/interface": "1.0.0-rc.10"
|
|
23
26
|
}
|
|
24
27
|
}
|
package/src/ICommonAttr.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { INumber, IBoolean, IString } from '@leafer/interface'
|
|
2
|
+
import { IStrokeAlign, IStrokeCap, IStrokeJoin, IBlurEffect, IFontWeight, ITextCase, ITextDecoration, IShadowEffect, IGrayscaleEffect, ITextAlign, IVerticalAlign, IOverflow, IUnitData, ITextWrap, IStroke, IFill, IArrowType } from './type/IType'
|
|
2
3
|
import { ILeafStrokePaint, ILeafShadowEffect, ILeafPaint } from './type/IComputedType'
|
|
3
|
-
import {
|
|
4
|
+
import { IDashPatternString, IShadowString, IColorString, IStrokeWidthString, ICornerRadiusString } from './type/IStringType'
|
|
5
|
+
|
|
4
6
|
|
|
5
7
|
// corner---
|
|
6
8
|
export interface ICornerRadiusAttrData {
|
|
7
|
-
cornerRadius:
|
|
8
|
-
cornerSmoothing:
|
|
9
|
+
cornerRadius: INumber | INumber[] | ICornerRadiusString
|
|
10
|
+
cornerSmoothing: INumber
|
|
9
11
|
}
|
|
10
12
|
export interface ICornerRadiusInputData {
|
|
11
|
-
cornerRadius?:
|
|
12
|
-
cornerSmoothing?:
|
|
13
|
+
cornerRadius?: INumber | INumber[] | ICornerRadiusString
|
|
14
|
+
cornerSmoothing?: INumber
|
|
13
15
|
}
|
|
14
16
|
export interface ICornerRadiusComputedData {
|
|
15
17
|
cornerRadius?: number
|
|
@@ -18,10 +20,10 @@ export interface ICornerRadiusComputedData {
|
|
|
18
20
|
|
|
19
21
|
// fill---
|
|
20
22
|
export interface IFillAttrData {
|
|
21
|
-
fill:
|
|
23
|
+
fill: IFill
|
|
22
24
|
}
|
|
23
25
|
export interface IFillInputData {
|
|
24
|
-
fill?:
|
|
26
|
+
fill?: IFill
|
|
25
27
|
}
|
|
26
28
|
export interface IFillComputedData {
|
|
27
29
|
fill?: IColorString | ILeafPaint[]
|
|
@@ -35,26 +37,34 @@ export interface IBorderComputedData {
|
|
|
35
37
|
|
|
36
38
|
// stroke---
|
|
37
39
|
export interface IStrokeAttrData {
|
|
38
|
-
stroke:
|
|
40
|
+
stroke: IStroke
|
|
39
41
|
|
|
40
42
|
strokeAlign: IStrokeAlign
|
|
41
|
-
strokeWidth:
|
|
43
|
+
strokeWidth: INumber | INumber[] | IStrokeWidthString
|
|
44
|
+
strokeWidthFixed: IBoolean
|
|
42
45
|
strokeCap: IStrokeCap
|
|
43
46
|
strokeJoin: IStrokeJoin
|
|
44
|
-
dashPattern:
|
|
45
|
-
dashOffset:
|
|
46
|
-
miterLimit:
|
|
47
|
+
dashPattern: INumber[] | IDashPatternString
|
|
48
|
+
dashOffset: INumber
|
|
49
|
+
miterLimit: INumber
|
|
50
|
+
|
|
51
|
+
startArrow: IArrowType
|
|
52
|
+
endArrow: IArrowType
|
|
47
53
|
}
|
|
48
54
|
export interface IStrokeInputData {
|
|
49
|
-
stroke?:
|
|
55
|
+
stroke?: IStroke
|
|
50
56
|
|
|
51
57
|
strokeAlign?: IStrokeAlign
|
|
52
|
-
strokeWidth?:
|
|
58
|
+
strokeWidth?: INumber | INumber[] | IStrokeWidthString
|
|
59
|
+
strokeWidthFixed?: IBoolean
|
|
53
60
|
strokeCap?: IStrokeCap
|
|
54
61
|
strokeJoin?: IStrokeJoin
|
|
55
|
-
dashPattern?:
|
|
56
|
-
dashOffset?:
|
|
57
|
-
miterLimit?:
|
|
62
|
+
dashPattern?: INumber[] | IDashPatternString
|
|
63
|
+
dashOffset?: INumber
|
|
64
|
+
miterLimit?: INumber
|
|
65
|
+
|
|
66
|
+
startArrow?: IArrowType
|
|
67
|
+
endArrow?: IArrowType
|
|
58
68
|
}
|
|
59
69
|
export interface IStrokeComputedData {
|
|
60
70
|
stroke?: IColorString | ILeafStrokePaint[]
|
|
@@ -62,6 +72,7 @@ export interface IStrokeComputedData {
|
|
|
62
72
|
strokeAlign?: IStrokeAlign
|
|
63
73
|
strokeWidth?: number
|
|
64
74
|
strokeWidths?: number[]
|
|
75
|
+
strokeWidthFixed?: boolean
|
|
65
76
|
strokeCap?: IStrokeCap
|
|
66
77
|
strokeJoin?: IStrokeJoin
|
|
67
78
|
dashPattern?: number[]
|
|
@@ -71,39 +82,41 @@ export interface IStrokeComputedData {
|
|
|
71
82
|
|
|
72
83
|
// text---
|
|
73
84
|
export interface ITextStyleAttrData {
|
|
74
|
-
fontFamily:
|
|
75
|
-
fontSize:
|
|
85
|
+
fontFamily: IString
|
|
86
|
+
fontSize: INumber
|
|
76
87
|
fontWeight: IFontWeight
|
|
77
|
-
italic:
|
|
88
|
+
italic: IBoolean
|
|
78
89
|
textCase: ITextCase
|
|
79
90
|
textDecoration: ITextDecoration
|
|
80
|
-
letterSpacing:
|
|
81
|
-
lineHeight:
|
|
91
|
+
letterSpacing: INumber | IUnitData
|
|
92
|
+
lineHeight: INumber | IUnitData
|
|
82
93
|
|
|
83
|
-
paraIndent:
|
|
84
|
-
paraSpacing:
|
|
94
|
+
paraIndent: INumber
|
|
95
|
+
paraSpacing: INumber
|
|
85
96
|
|
|
86
97
|
textAlign: ITextAlign
|
|
87
98
|
verticalAlign: IVerticalAlign
|
|
88
99
|
|
|
100
|
+
textWrap: ITextWrap
|
|
89
101
|
textOverflow: IOverflow | string
|
|
90
102
|
}
|
|
91
103
|
export interface ITextStyleInputData {
|
|
92
|
-
fontFamily?:
|
|
93
|
-
fontSize?:
|
|
104
|
+
fontFamily?: IString
|
|
105
|
+
fontSize?: INumber
|
|
94
106
|
fontWeight?: IFontWeight
|
|
95
|
-
italic?:
|
|
107
|
+
italic?: IBoolean
|
|
96
108
|
textCase?: ITextCase
|
|
97
109
|
textDecoration?: ITextDecoration
|
|
98
|
-
letterSpacing?:
|
|
99
|
-
lineHeight?:
|
|
110
|
+
letterSpacing?: INumber | IUnitData
|
|
111
|
+
lineHeight?: INumber | IUnitData
|
|
100
112
|
|
|
101
|
-
paraIndent?:
|
|
102
|
-
paraSpacing?:
|
|
113
|
+
paraIndent?: INumber
|
|
114
|
+
paraSpacing?: INumber
|
|
103
115
|
|
|
104
116
|
textAlign?: ITextAlign
|
|
105
117
|
verticalAlign?: IVerticalAlign
|
|
106
118
|
|
|
119
|
+
textWrap?: ITextWrap
|
|
107
120
|
textOverflow?: IOverflow | string
|
|
108
121
|
}
|
|
109
122
|
export interface ITextStyleComputedData {
|
|
@@ -121,23 +134,25 @@ export interface ITextStyleComputedData {
|
|
|
121
134
|
|
|
122
135
|
textAlign?: ITextAlign
|
|
123
136
|
verticalAlign?: IVerticalAlign
|
|
124
|
-
|
|
137
|
+
|
|
138
|
+
textWrap?: ITextWrap
|
|
139
|
+
textOverflow?: IOverflow | string
|
|
125
140
|
}
|
|
126
141
|
|
|
127
142
|
// effect---
|
|
128
143
|
export interface IEffectAttrData {
|
|
129
144
|
shadow: IShadowEffect | IShadowEffect[] | IShadowString
|
|
130
145
|
innerShadow: IShadowEffect | IShadowEffect[] | IShadowString
|
|
131
|
-
blur:
|
|
132
|
-
backgroundBlur:
|
|
133
|
-
grayscale:
|
|
146
|
+
blur: INumber | IBlurEffect
|
|
147
|
+
backgroundBlur: INumber | IBlurEffect
|
|
148
|
+
grayscale: INumber | IGrayscaleEffect
|
|
134
149
|
}
|
|
135
150
|
export interface IEffectInputData {
|
|
136
151
|
shadow?: IShadowEffect | IShadowEffect[] | IShadowString
|
|
137
152
|
innerShadow?: IShadowEffect | IShadowEffect[] | IShadowString
|
|
138
|
-
blur?:
|
|
139
|
-
backgroundBlur?:
|
|
140
|
-
grayscale?:
|
|
153
|
+
blur?: INumber | IBlurEffect
|
|
154
|
+
backgroundBlur?: INumber | IBlurEffect
|
|
155
|
+
grayscale?: INumber | IGrayscaleEffect
|
|
141
156
|
}
|
|
142
157
|
export interface IEffectComputedData {
|
|
143
158
|
shadow?: ILeafShadowEffect[]
|
package/src/IUI.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { ILeaf, ILeafComputedData, ILeafData, ILeafInputData, ILeaferCanvas, IRenderOptions, IPathDrawer, IPointData, IPath2D, IPathCommandData, IWindingRule, ILeaferImageConfig, IBoundsData, IObject,
|
|
2
|
-
|
|
3
|
-
import { IOverflow } from './type/IType'
|
|
1
|
+
import { ILeaf, ILeafComputedData, ILeafData, ILeafInputData, ILeaferCanvas, IRenderOptions, IExportOptions, IExportResult, IPathDrawer, IPointData, IPath2D, IPathCommandData, IWindingRule, ILeaferImageConfig, IBoundsData, IObject, IPathString, ILeaferImage, IPathCreator, IAnswer, IPickOptions, IPickResult } from '@leafer/interface'
|
|
4
2
|
|
|
5
3
|
import {
|
|
6
4
|
IFillAttrData, IFillInputData, IFillComputedData,
|
|
@@ -10,18 +8,36 @@ import {
|
|
|
10
8
|
IEffectAttrData, IEffectInputData, IEffectComputedData,
|
|
11
9
|
ITextStyleAttrData, ITextStyleInputData, ITextStyleComputedData
|
|
12
10
|
} from './ICommonAttr'
|
|
13
|
-
import {
|
|
14
|
-
|
|
11
|
+
import { IOverflow } from './type/IType'
|
|
12
|
+
import { ILeafer } from './app/ILeafer'
|
|
15
13
|
|
|
16
14
|
// Line
|
|
17
15
|
export interface ILine extends IUI {
|
|
18
16
|
__: ILineData
|
|
19
17
|
toPoint: IPointData
|
|
18
|
+
points: number[]
|
|
19
|
+
curve: boolean | number
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
|
|
22
|
+
interface ILineAttrData {
|
|
23
23
|
toPoint?: IPointData
|
|
24
|
+
points?: number[]
|
|
25
|
+
curve?: boolean | number
|
|
24
26
|
}
|
|
27
|
+
export interface ILineData extends ILineAttrData, IUIData { }
|
|
28
|
+
export interface ILineInputData extends ILineAttrData, IUIBaseInputData { }
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
// Arrow
|
|
32
|
+
export interface IArrow extends ILine {
|
|
33
|
+
__: IArrowData
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface IArrowAttrData {
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
export interface IArrowData extends IArrowAttrData, ILineData { }
|
|
40
|
+
export interface IArrowInputData extends IArrowAttrData, IUIBaseInputData { }
|
|
25
41
|
|
|
26
42
|
|
|
27
43
|
// Rect
|
|
@@ -29,7 +45,7 @@ export interface IRect extends IUI {
|
|
|
29
45
|
__: IRectData
|
|
30
46
|
}
|
|
31
47
|
export interface IRectData extends IUIData { }
|
|
32
|
-
export interface IRectInputData extends
|
|
48
|
+
export interface IRectInputData extends IUIBaseInputData { }
|
|
33
49
|
|
|
34
50
|
|
|
35
51
|
// Ellipse
|
|
@@ -45,34 +61,38 @@ interface IEllipseAttrData {
|
|
|
45
61
|
innerRadius?: number
|
|
46
62
|
}
|
|
47
63
|
export interface IEllipseData extends IEllipseAttrData, IUIData { }
|
|
48
|
-
export interface IEllipseInputData extends IEllipseAttrData,
|
|
64
|
+
export interface IEllipseInputData extends IEllipseAttrData, IUIBaseInputData { }
|
|
49
65
|
|
|
50
66
|
|
|
51
67
|
// Polygon
|
|
52
68
|
export interface IPolygon extends IUI {
|
|
53
69
|
__: IPolygonData
|
|
54
70
|
sides: number
|
|
71
|
+
points: number[]
|
|
72
|
+
curve: boolean | number
|
|
55
73
|
}
|
|
56
74
|
interface IPolygonAttrData {
|
|
57
75
|
sides?: number
|
|
76
|
+
points?: number[]
|
|
77
|
+
curve?: boolean | number
|
|
58
78
|
}
|
|
59
79
|
export interface IPolygonData extends IPolygonAttrData, IUIData { }
|
|
60
|
-
export interface IPolygonInputData extends IPolygonAttrData,
|
|
80
|
+
export interface IPolygonInputData extends IPolygonAttrData, IUIBaseInputData { }
|
|
61
81
|
|
|
62
82
|
|
|
63
83
|
// Star
|
|
64
84
|
export interface IStar extends IUI {
|
|
65
85
|
__: IStarData
|
|
66
|
-
|
|
86
|
+
corners: number
|
|
67
87
|
innerRadius: number
|
|
68
88
|
}
|
|
69
89
|
interface IStarAttrData {
|
|
70
|
-
|
|
90
|
+
corners?: number
|
|
71
91
|
innerRadius?: number
|
|
72
92
|
}
|
|
73
93
|
|
|
74
94
|
export interface IStarData extends IStarAttrData, IUIData { }
|
|
75
|
-
export interface IStarInputData extends IStarAttrData,
|
|
95
|
+
export interface IStarInputData extends IStarAttrData, IUIBaseInputData { }
|
|
76
96
|
|
|
77
97
|
// Path
|
|
78
98
|
export interface IPath extends IUI {
|
|
@@ -84,34 +104,20 @@ export interface IPathData extends IUIData {
|
|
|
84
104
|
path?: IPathCommandData
|
|
85
105
|
windingRule?: IWindingRule
|
|
86
106
|
}
|
|
87
|
-
export interface IPathInputData extends
|
|
107
|
+
export interface IPathInputData extends IUIBaseInputData {
|
|
88
108
|
path?: IPathCommandData | IPathString
|
|
89
109
|
windingRule?: IWindingRule
|
|
90
110
|
}
|
|
91
111
|
|
|
92
112
|
// Pen
|
|
93
113
|
|
|
94
|
-
export interface IPen extends IGroup {
|
|
114
|
+
export interface IPen extends IGroup, IPathCreator {
|
|
95
115
|
__: IPenData
|
|
96
|
-
|
|
116
|
+
pathElement: IPath
|
|
97
117
|
pathStyle: IPathInputData
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
moveTo(x: number, y: number): IPen
|
|
101
|
-
lineTo(x: number, y: number): IPen
|
|
102
|
-
bezierCurveTo(x1: number, y1: number, x2: number, y2: number, x: number, y: number): IPen
|
|
103
|
-
quadraticCurveTo(x1: number, y1: number, x: number, y: number): IPen
|
|
104
|
-
|
|
105
|
-
rect(x: number, y: number, width: number, height: number): IPen
|
|
106
|
-
roundRect(x: number, y: number, width: number, height: number, cornerRadius: number | number[]): IPen
|
|
107
|
-
ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation?: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean): IPen
|
|
108
|
-
arc(x: number, y: number, radius: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean): IPen
|
|
109
|
-
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): IPen
|
|
110
|
-
|
|
111
|
-
close(): IPen
|
|
112
|
-
clear(): IPen
|
|
113
|
-
|
|
118
|
+
path: IPathCommandData
|
|
114
119
|
paint(): void
|
|
120
|
+
clear(): void
|
|
115
121
|
}
|
|
116
122
|
|
|
117
123
|
export interface IPenData extends IGroupData { }
|
|
@@ -131,8 +137,11 @@ export interface ITextData extends ITextAttrData, ITextStyleComputedData, IUIDat
|
|
|
131
137
|
__baseLine?: number
|
|
132
138
|
__lineHeight?: number
|
|
133
139
|
__letterSpacing?: number
|
|
140
|
+
__padding?: number[]
|
|
141
|
+
__clipText?: boolean
|
|
142
|
+
__textBoxBounds?: IBoundsData
|
|
134
143
|
}
|
|
135
|
-
export interface ITextInputData extends ITextAttrData, ITextStyleInputData,
|
|
144
|
+
export interface ITextInputData extends ITextAttrData, ITextStyleInputData, IUIBaseInputData {
|
|
136
145
|
|
|
137
146
|
}
|
|
138
147
|
|
|
@@ -145,9 +154,13 @@ export interface ITextRowData {
|
|
|
145
154
|
data?: ITextCharData[]
|
|
146
155
|
words?: ITextWordData[]
|
|
147
156
|
|
|
157
|
+
startCharSize?: number
|
|
158
|
+
endCharSize?: number
|
|
159
|
+
|
|
148
160
|
paraStart?: boolean // paragraph start
|
|
149
161
|
paraEnd?: boolean // paragraph end
|
|
150
162
|
isOverflow?: boolean
|
|
163
|
+
textMode?: boolean
|
|
151
164
|
}
|
|
152
165
|
|
|
153
166
|
export interface ITextWordData {
|
|
@@ -186,8 +199,10 @@ export interface IImage extends IRect, ILeaferImageConfig {
|
|
|
186
199
|
interface IImageAttrData {
|
|
187
200
|
url?: string
|
|
188
201
|
}
|
|
189
|
-
export interface IImageData extends IImageAttrData, IRectData {
|
|
190
|
-
|
|
202
|
+
export interface IImageData extends IImageAttrData, IRectData {
|
|
203
|
+
__setImageFill(value: string): void
|
|
204
|
+
}
|
|
205
|
+
export interface IImageInputData extends IImageAttrData, IUIBaseInputData { }
|
|
191
206
|
|
|
192
207
|
export interface ICanvas extends IRect {
|
|
193
208
|
__: ICanvasData
|
|
@@ -201,7 +216,7 @@ interface ICanvasAttrData {
|
|
|
201
216
|
smooth?: boolean
|
|
202
217
|
}
|
|
203
218
|
export interface ICanvasData extends ICanvasAttrData, IRectData { }
|
|
204
|
-
export interface ICanvasInputData extends ICanvasAttrData,
|
|
219
|
+
export interface ICanvasInputData extends ICanvasAttrData, IUIBaseInputData { }
|
|
205
220
|
|
|
206
221
|
|
|
207
222
|
// Leafer
|
|
@@ -213,6 +228,12 @@ export interface ILeaferInputData extends IGroupInputData {
|
|
|
213
228
|
pixelRatio?: number
|
|
214
229
|
}
|
|
215
230
|
|
|
231
|
+
export interface IAppData extends ILeaferData {
|
|
232
|
+
|
|
233
|
+
}
|
|
234
|
+
export interface IAppInputData extends ILeaferInputData {
|
|
235
|
+
|
|
236
|
+
}
|
|
216
237
|
|
|
217
238
|
// Frame
|
|
218
239
|
export interface IFrame extends IBox {
|
|
@@ -245,32 +266,57 @@ export interface IBoxInputData extends IGroupInputData {
|
|
|
245
266
|
export interface IGroup extends IUI {
|
|
246
267
|
__: IGroupData
|
|
247
268
|
children: IUI[]
|
|
248
|
-
|
|
269
|
+
pick(hitPoint: IPointData, options?: IPickOptions): IPickResult
|
|
249
270
|
add(child: IUI, index?: number): void
|
|
250
271
|
addAt(child: IUI, index: number): void
|
|
251
272
|
addAfter(child: IUI, after: IUI): void
|
|
252
273
|
addBefore(child: IUI, before: IUI): void
|
|
274
|
+
addMany(...children: ILeaf[]): void
|
|
253
275
|
remove(child?: IUI): void
|
|
254
276
|
removeAll(): void
|
|
277
|
+
clear(): void
|
|
255
278
|
}
|
|
256
279
|
export interface IGroupData extends IUIData { }
|
|
257
|
-
export interface IGroupInputData extends
|
|
280
|
+
export interface IGroupInputData extends IUIBaseInputData { }
|
|
258
281
|
|
|
259
282
|
// UI
|
|
260
283
|
export interface IUI extends IFillAttrData, IStrokeAttrData, ICornerRadiusAttrData, IEffectAttrData, ILeaf {
|
|
261
284
|
__: IUIData
|
|
285
|
+
|
|
286
|
+
readonly app: ILeafer
|
|
287
|
+
leafer?: ILeafer
|
|
262
288
|
parent?: IGroup
|
|
289
|
+
isFrame?: boolean
|
|
290
|
+
|
|
291
|
+
proxyData: IUIInputData
|
|
292
|
+
__proxyData?: IUIInputData
|
|
293
|
+
|
|
294
|
+
children?: IUI[]
|
|
263
295
|
|
|
264
|
-
|
|
265
|
-
get(): IUITagInputData
|
|
296
|
+
reset(data?: IUIInputData): void
|
|
266
297
|
|
|
267
|
-
|
|
268
|
-
|
|
298
|
+
set(data: IUIInputData): void
|
|
299
|
+
toJSON(): IUIInputData
|
|
300
|
+
|
|
301
|
+
get(): IUIInputData
|
|
302
|
+
createProxyData(): IUIInputData
|
|
303
|
+
|
|
304
|
+
find(condition: number | string | IFindUIMethod, options?: any): IUI[]
|
|
305
|
+
findOne(condition: number | string | IFindUIMethod, options?: any): IUI
|
|
306
|
+
|
|
307
|
+
getPath(curve?: boolean, pathForRender?: boolean): IPathCommandData
|
|
308
|
+
getPathString(curve?: boolean, pathForRender?: boolean): IPathString
|
|
269
309
|
|
|
270
310
|
__drawPathByData(drawer: IPathDrawer, data: IPathCommandData): void
|
|
311
|
+
__drawPathByBox(drawer: IPathDrawer): void
|
|
271
312
|
__drawAfterFill?(canvas: ILeaferCanvas, options: IRenderOptions): void
|
|
272
313
|
|
|
273
|
-
export(filename: string, options?: IExportOptions | number): Promise<
|
|
314
|
+
export(filename: string, options?: IExportOptions | number | boolean): Promise<IExportResult>
|
|
315
|
+
clone(): IUI
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export interface IFindUIMethod {
|
|
319
|
+
(leaf: IUI, options?: any): IAnswer
|
|
274
320
|
}
|
|
275
321
|
|
|
276
322
|
export interface IUIData extends IUIComputedData, ILeafData {
|
|
@@ -281,15 +327,25 @@ export interface IUIData extends IUIComputedData, ILeafData {
|
|
|
281
327
|
// 非数据属性, 自动计算的缓存数据
|
|
282
328
|
__isFills?: boolean
|
|
283
329
|
__isStrokes?: boolean
|
|
330
|
+
|
|
331
|
+
readonly __strokeWidth: number
|
|
332
|
+
|
|
333
|
+
__pixelFill?: boolean // png / svg / webp
|
|
334
|
+
__pixelStroke?: boolean
|
|
335
|
+
|
|
336
|
+
__opacityFill?: boolean // 半透明的
|
|
337
|
+
__opacityStroke?: boolean
|
|
338
|
+
|
|
284
339
|
__drawAfterFill?: boolean
|
|
285
340
|
__isOverflow?: boolean
|
|
286
341
|
__blendLayer?: boolean
|
|
287
342
|
|
|
288
|
-
__isTranslucentFill?: boolean // 半透明的
|
|
289
|
-
__isTranslucentStroke?: boolean
|
|
290
|
-
|
|
291
343
|
__useEffect?: boolean
|
|
292
344
|
|
|
345
|
+
__autoWidth: boolean
|
|
346
|
+
__autoHeight: boolean
|
|
347
|
+
__autoBounds: boolean
|
|
348
|
+
|
|
293
349
|
// path
|
|
294
350
|
path?: IPathCommandData
|
|
295
351
|
windingRule?: IWindingRule
|
|
@@ -303,19 +359,26 @@ export interface IUIData extends IUIComputedData, ILeafData {
|
|
|
303
359
|
__font?: string
|
|
304
360
|
__textDrawData?: ITextDrawData
|
|
305
361
|
|
|
362
|
+
__needComputePaint: boolean
|
|
363
|
+
__computePaint(): void
|
|
364
|
+
|
|
306
365
|
}
|
|
307
366
|
export interface IUIComputedData extends IFillComputedData, IBorderComputedData, IStrokeComputedData, ITextStyleComputedData, ICornerRadiusComputedData, IEffectComputedData, ILeafComputedData {
|
|
308
367
|
padding?: number | number[]
|
|
368
|
+
|
|
309
369
|
locked?: boolean
|
|
310
370
|
}
|
|
311
371
|
|
|
312
|
-
export interface
|
|
372
|
+
export interface IUIBaseInputData extends IFillInputData, IStrokeInputData, ITextStyleInputData, ICornerRadiusInputData, IEffectInputData, ILeafInputData {
|
|
313
373
|
padding?: number | number[]
|
|
314
374
|
locked?: boolean
|
|
375
|
+
children?: IUIInputData[]
|
|
315
376
|
}
|
|
316
377
|
|
|
317
378
|
|
|
318
379
|
export type IUITag =
|
|
380
|
+
| 'App'
|
|
381
|
+
| 'Leafer'
|
|
319
382
|
| 'Rect'
|
|
320
383
|
| 'Ellipse'
|
|
321
384
|
| 'Polygon'
|
|
@@ -331,6 +394,6 @@ export type IUITag =
|
|
|
331
394
|
| 'Box'
|
|
332
395
|
|
|
333
396
|
|
|
334
|
-
export interface
|
|
335
|
-
|
|
397
|
+
export interface IUIInputData extends IRectInputData, IEllipseInputData, IPolygonInputData, IStarInputData, ILineInputData, IPathInputData, ITextInputData, IImageInputData, IGroupInputData, IFrameInputData, IUIBaseInputData, IObject {
|
|
398
|
+
children?: IUIInputData[]
|
|
336
399
|
}
|
package/src/app/IApp.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ILeaferConfig } from '@leafer/interface'
|
|
2
|
+
|
|
3
|
+
import { ILeafer } from './ILeafer'
|
|
4
|
+
import { IEditorConfig } from '../editor/IEditor'
|
|
5
|
+
|
|
6
|
+
export interface IApp extends ILeafer {
|
|
7
|
+
children: ILeafer[]
|
|
8
|
+
realCanvas: boolean
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface IAppConfig extends ILeaferConfig {
|
|
12
|
+
ground?: ILeaferConfig
|
|
13
|
+
tree?: ILeaferConfig
|
|
14
|
+
sky?: ILeaferConfig
|
|
15
|
+
editor?: IEditorConfig
|
|
16
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IControl, ILeaferAttrData, ILeaferConfig, ILeaferType } from '@leafer/interface'
|
|
2
|
+
import { IApp } from './IApp'
|
|
3
|
+
import { IGroup } from '../IUI'
|
|
4
|
+
import { IEditorBase } from '../editor/IEditor'
|
|
5
|
+
|
|
6
|
+
export interface ILeafer extends IGroup, ILeaferAttrData, IControl {
|
|
7
|
+
readonly isApp: boolean
|
|
8
|
+
readonly app: ILeafer
|
|
9
|
+
parent?: IApp
|
|
10
|
+
zoomLayer: IGroup
|
|
11
|
+
editor: IEditorBase
|
|
12
|
+
|
|
13
|
+
ground?: ILeafer
|
|
14
|
+
tree?: ILeafer
|
|
15
|
+
sky?: ILeafer
|
|
16
|
+
|
|
17
|
+
userConfig?: ILeaferConfig
|
|
18
|
+
|
|
19
|
+
onInit(): void
|
|
20
|
+
initType(type: ILeaferType): void
|
|
21
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { IGroup, IUI, IRectInputData, ISelectorProxy, IEditSize, ICursorType, IAround, IDragEvent, IRotateEvent, IStroke, IFill, ILeaf, IObject, IBoxInputData, IGroupInputData, IImageCursor } from '@leafer-ui/interface'
|
|
2
|
+
|
|
3
|
+
export interface IEditorBase extends IGroup, ISelectorProxy {
|
|
4
|
+
config: IEditorConfig
|
|
5
|
+
|
|
6
|
+
hoverTarget: IUI
|
|
7
|
+
target: IUI | IUI[]
|
|
8
|
+
|
|
9
|
+
readonly list: IUI[]
|
|
10
|
+
|
|
11
|
+
readonly hasTarget: boolean
|
|
12
|
+
readonly multiple: boolean
|
|
13
|
+
readonly single: boolean
|
|
14
|
+
|
|
15
|
+
readonly dragging: boolean
|
|
16
|
+
|
|
17
|
+
element: IUI
|
|
18
|
+
buttons: IGroup
|
|
19
|
+
|
|
20
|
+
selector: IGroup
|
|
21
|
+
editBox: IGroup
|
|
22
|
+
editTool: IObject
|
|
23
|
+
|
|
24
|
+
hasItem(item: IUI): boolean
|
|
25
|
+
shiftItem(item: IUI): void
|
|
26
|
+
addItem(item: IUI): void
|
|
27
|
+
removeItem(item: IUI): void
|
|
28
|
+
|
|
29
|
+
update(): void
|
|
30
|
+
updateEditTool(): void
|
|
31
|
+
|
|
32
|
+
getEditSize(ui: ILeaf): IEditSize
|
|
33
|
+
|
|
34
|
+
onMove(e: IDragEvent): void
|
|
35
|
+
onScale(e: IDragEvent): void
|
|
36
|
+
onRotate(e: IDragEvent | IRotateEvent): void
|
|
37
|
+
onSkew(e: IDragEvent): void
|
|
38
|
+
|
|
39
|
+
group(group?: IGroup | IGroupInputData): IGroup
|
|
40
|
+
ungroup(): IUI[]
|
|
41
|
+
|
|
42
|
+
lock(): void
|
|
43
|
+
unlock(): void
|
|
44
|
+
|
|
45
|
+
toTop(): void
|
|
46
|
+
toBottom(): void
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface IEditorConfig {
|
|
50
|
+
editSize?: 'auto' | IEditSize
|
|
51
|
+
|
|
52
|
+
stroke?: IStroke
|
|
53
|
+
strokeWidth?: number
|
|
54
|
+
|
|
55
|
+
pointFill?: IFill
|
|
56
|
+
pointSize?: number
|
|
57
|
+
pointRadius?: number
|
|
58
|
+
|
|
59
|
+
point?: IBoxInputData | IBoxInputData[]
|
|
60
|
+
middlePoint?: IBoxInputData | IBoxInputData[]
|
|
61
|
+
rotatePoint?: IBoxInputData
|
|
62
|
+
|
|
63
|
+
rect?: IBoxInputData
|
|
64
|
+
area?: IRectInputData
|
|
65
|
+
|
|
66
|
+
buttonsDirection?: 'top' | 'right' | 'bottom' | 'left'
|
|
67
|
+
buttonsFixed?: boolean
|
|
68
|
+
buttonsMargin?: number
|
|
69
|
+
|
|
70
|
+
hideOnMove?: boolean
|
|
71
|
+
|
|
72
|
+
moveCursor?: ICursorType
|
|
73
|
+
resizeCursor?: IImageCursor
|
|
74
|
+
rotateCursor?: IImageCursor
|
|
75
|
+
skewCursor?: IImageCursor
|
|
76
|
+
|
|
77
|
+
around?: IAround
|
|
78
|
+
lockRatio?: boolean
|
|
79
|
+
rotateGap?: number
|
|
80
|
+
|
|
81
|
+
selector?: boolean
|
|
82
|
+
hover?: boolean
|
|
83
|
+
boxSelect?: boolean
|
|
84
|
+
|
|
85
|
+
rotateable?: boolean
|
|
86
|
+
resizeable?: boolean
|
|
87
|
+
skewable?: boolean
|
|
88
|
+
}
|