modern-idoc 0.0.1 → 0.0.2
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/README.md +1 -0
- package/dist/index.cjs +98 -2
- package/dist/index.d.cts +50 -28
- package/dist/index.d.mts +50 -28
- package/dist/index.d.ts +50 -28
- package/dist/index.js +1 -1
- package/dist/index.mjs +96 -2
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,101 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var IElementType = /* @__PURE__ */ ((IElementType2) => {
|
|
4
|
+
IElementType2["text"] = "text";
|
|
5
|
+
IElementType2["image"] = "image";
|
|
6
|
+
IElementType2["group"] = "group";
|
|
7
|
+
IElementType2["shape"] = "shape";
|
|
8
|
+
IElementType2["video"] = "video";
|
|
9
|
+
return IElementType2;
|
|
10
|
+
})(IElementType || {});
|
|
4
11
|
|
|
5
|
-
|
|
12
|
+
function getDefaultElementStyle() {
|
|
13
|
+
return {
|
|
14
|
+
overflow: "visible",
|
|
15
|
+
visibility: "visible",
|
|
16
|
+
filter: "none",
|
|
17
|
+
// position
|
|
18
|
+
left: 0,
|
|
19
|
+
top: 0,
|
|
20
|
+
width: 0,
|
|
21
|
+
height: 0,
|
|
22
|
+
rotate: 0,
|
|
23
|
+
opacity: 1,
|
|
24
|
+
// margin
|
|
25
|
+
marginLeft: 0,
|
|
26
|
+
marginTop: 0,
|
|
27
|
+
marginRight: 0,
|
|
28
|
+
marginBottom: 0,
|
|
29
|
+
// padding
|
|
30
|
+
paddingLeft: 0,
|
|
31
|
+
paddingTop: 0,
|
|
32
|
+
paddingRight: 0,
|
|
33
|
+
paddingBottom: 0,
|
|
34
|
+
// transform
|
|
35
|
+
scaleX: 1,
|
|
36
|
+
scaleY: 1,
|
|
37
|
+
skewX: 0,
|
|
38
|
+
skewY: 0,
|
|
39
|
+
translateX: 0,
|
|
40
|
+
translateY: 0,
|
|
41
|
+
transform: "none",
|
|
42
|
+
transformOrigin: "50% 50%",
|
|
43
|
+
// background
|
|
44
|
+
backgroundImage: "none",
|
|
45
|
+
backgroundColor: "transparent",
|
|
46
|
+
// shadow
|
|
47
|
+
shadowColor: "transparent",
|
|
48
|
+
shadowOffsetX: 0,
|
|
49
|
+
shadowOffsetY: 0,
|
|
50
|
+
shadowBlur: 0,
|
|
51
|
+
// border
|
|
52
|
+
borderRadius: 0,
|
|
53
|
+
borderColor: "transparent",
|
|
54
|
+
borderWidth: 1
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function getDefaultTextStyle() {
|
|
59
|
+
return {
|
|
60
|
+
...getDefaultElementStyle(),
|
|
61
|
+
writingMode: "horizontal-tb",
|
|
62
|
+
verticalAlign: "baseline",
|
|
63
|
+
lineHeight: 1.2,
|
|
64
|
+
letterSpacing: 0,
|
|
65
|
+
// font
|
|
66
|
+
fontSize: 14,
|
|
67
|
+
fontWeight: "normal",
|
|
68
|
+
fontFamily: "",
|
|
69
|
+
fontStyle: "normal",
|
|
70
|
+
fontKerning: "normal",
|
|
71
|
+
// text
|
|
72
|
+
textWrap: "wrap",
|
|
73
|
+
textAlign: "start",
|
|
74
|
+
textIndent: 0,
|
|
75
|
+
textTransform: "none",
|
|
76
|
+
textOrientation: "mixed",
|
|
77
|
+
textDecoration: "none",
|
|
78
|
+
// textStroke
|
|
79
|
+
textStrokeWidth: 0,
|
|
80
|
+
textStrokeColor: "black",
|
|
81
|
+
// color
|
|
82
|
+
color: "black",
|
|
83
|
+
// listStyle
|
|
84
|
+
listStyleType: "none",
|
|
85
|
+
listStyleImage: "none",
|
|
86
|
+
listStyleColormap: "none",
|
|
87
|
+
listStyleSize: "cover",
|
|
88
|
+
listStylePosition: "outside",
|
|
89
|
+
// listStyle
|
|
90
|
+
highlightImage: "none",
|
|
91
|
+
highlightReferImage: "none",
|
|
92
|
+
highlightColormap: "none",
|
|
93
|
+
highlightLine: "none",
|
|
94
|
+
highlightSize: "cover",
|
|
95
|
+
highlightThickness: "100%"
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
exports.IElementType = IElementType;
|
|
100
|
+
exports.getDefaultElementStyle = getDefaultElementStyle;
|
|
101
|
+
exports.getDefaultTextStyle = getDefaultTextStyle;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
declare enum IElementType {
|
|
2
|
+
text = "text",
|
|
3
|
+
image = "image",
|
|
4
|
+
group = "group",
|
|
5
|
+
shape = "shape",
|
|
6
|
+
video = "video"
|
|
7
|
+
}
|
|
8
|
+
|
|
1
9
|
interface IBackgroundStyle {
|
|
2
10
|
opacity: number;
|
|
3
11
|
}
|
|
@@ -7,7 +15,7 @@ interface IBackground extends Partial<IBackgroundStyle> {
|
|
|
7
15
|
|
|
8
16
|
type Overflow = 'hidden' | 'visible';
|
|
9
17
|
type Visibility = 'hidden' | 'visible';
|
|
10
|
-
interface
|
|
18
|
+
interface IBaseElementStyle {
|
|
11
19
|
overflow: Overflow;
|
|
12
20
|
visibility: Visibility;
|
|
13
21
|
filter: string;
|
|
@@ -17,8 +25,20 @@ interface IElementStyle {
|
|
|
17
25
|
height: number;
|
|
18
26
|
rotate: number;
|
|
19
27
|
opacity: number;
|
|
28
|
+
marginLeft: number;
|
|
29
|
+
marginTop: number;
|
|
30
|
+
marginRight: number;
|
|
31
|
+
marginBottom: number;
|
|
32
|
+
paddingLeft: number;
|
|
33
|
+
paddingTop: number;
|
|
34
|
+
paddingRight: number;
|
|
35
|
+
paddingBottom: number;
|
|
20
36
|
scaleX: number;
|
|
21
37
|
scaleY: number;
|
|
38
|
+
skewX: number;
|
|
39
|
+
skewY: number;
|
|
40
|
+
translateX: number;
|
|
41
|
+
translateY: number;
|
|
22
42
|
transform: string;
|
|
23
43
|
transformOrigin: string;
|
|
24
44
|
backgroundImage: string;
|
|
@@ -27,28 +47,25 @@ interface IElementStyle {
|
|
|
27
47
|
shadowOffsetX: number;
|
|
28
48
|
shadowOffsetY: number;
|
|
29
49
|
shadowBlur: number;
|
|
30
|
-
marginLeft: number;
|
|
31
|
-
marginTop: number;
|
|
32
|
-
marginRight: number;
|
|
33
|
-
marginBottom: number;
|
|
34
|
-
paddingLeft: number;
|
|
35
|
-
paddingTop: number;
|
|
36
|
-
paddingRight: number;
|
|
37
|
-
paddingBottom: number;
|
|
38
50
|
borderRadius: number;
|
|
39
51
|
borderColor: string;
|
|
40
52
|
borderWidth: number;
|
|
41
53
|
}
|
|
42
54
|
|
|
43
|
-
interface
|
|
55
|
+
interface IBaseElement<T extends IBaseElementStyle = IBaseElementStyle> {
|
|
44
56
|
name?: string;
|
|
45
57
|
style?: Partial<T>;
|
|
46
58
|
background?: IBackground;
|
|
47
59
|
meta?: Record<string, any>;
|
|
48
60
|
}
|
|
49
61
|
|
|
50
|
-
interface
|
|
51
|
-
type:
|
|
62
|
+
interface IGroup extends IBaseElement {
|
|
63
|
+
type: IElementType.group;
|
|
64
|
+
children: IElement[];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
interface IImage extends IBaseElement {
|
|
68
|
+
type: IElementType.image;
|
|
52
69
|
src: string;
|
|
53
70
|
}
|
|
54
71
|
|
|
@@ -81,8 +98,8 @@ interface IPath extends Partial<IPathStyle> {
|
|
|
81
98
|
data: string;
|
|
82
99
|
}
|
|
83
100
|
|
|
84
|
-
interface IShape extends
|
|
85
|
-
type:
|
|
101
|
+
interface IShape extends IBaseElement {
|
|
102
|
+
type: IElementType.shape;
|
|
86
103
|
paths: IPath[];
|
|
87
104
|
}
|
|
88
105
|
|
|
@@ -124,7 +141,7 @@ interface Highlight {
|
|
|
124
141
|
thickness: HighlightThickness;
|
|
125
142
|
}
|
|
126
143
|
interface TextListStyle {
|
|
127
|
-
listStyle
|
|
144
|
+
listStyle?: Partial<ListStyle>;
|
|
128
145
|
listStyleType: ListStyleType;
|
|
129
146
|
listStyleImage: ListStyleImage;
|
|
130
147
|
listStyleColormap: ListStyleColormap;
|
|
@@ -132,7 +149,7 @@ interface TextListStyle {
|
|
|
132
149
|
listStylePosition: ListStylePosition;
|
|
133
150
|
}
|
|
134
151
|
interface TextHighlightStyle {
|
|
135
|
-
highlight
|
|
152
|
+
highlight?: Partial<Highlight>;
|
|
136
153
|
highlightImage: HighlightImage;
|
|
137
154
|
highlightReferImage: HighlightReferImage;
|
|
138
155
|
highlightColormap: HighlightColormap;
|
|
@@ -140,14 +157,14 @@ interface TextHighlightStyle {
|
|
|
140
157
|
highlightSize: HighlightSize;
|
|
141
158
|
highlightThickness: HighlightThickness;
|
|
142
159
|
}
|
|
143
|
-
interface
|
|
160
|
+
interface ITextLineStyle extends TextListStyle {
|
|
144
161
|
writingMode: WritingMode;
|
|
145
162
|
textWrap: TextWrap;
|
|
146
163
|
textAlign: TextAlign;
|
|
147
164
|
textIndent: number;
|
|
148
165
|
lineHeight: number;
|
|
149
166
|
}
|
|
150
|
-
interface
|
|
167
|
+
interface ITextInlineStyle extends TextHighlightStyle {
|
|
151
168
|
color: string;
|
|
152
169
|
verticalAlign: VerticalAlign;
|
|
153
170
|
letterSpacing: number;
|
|
@@ -160,7 +177,7 @@ interface TextInlineStyle extends TextHighlightStyle {
|
|
|
160
177
|
textOrientation: TextOrientation;
|
|
161
178
|
textDecoration: TextDecorationLine;
|
|
162
179
|
}
|
|
163
|
-
interface
|
|
180
|
+
interface ITextDrawStyle {
|
|
164
181
|
textStrokeWidth: number;
|
|
165
182
|
textStrokeColor: string;
|
|
166
183
|
shadowColor: string;
|
|
@@ -172,7 +189,7 @@ interface TextDrawStyle {
|
|
|
172
189
|
skewX: number;
|
|
173
190
|
skewY: number;
|
|
174
191
|
}
|
|
175
|
-
interface ITextStyle extends
|
|
192
|
+
interface ITextStyle extends ITextLineStyle, ITextInlineStyle, ITextDrawStyle, IBaseElementStyle {
|
|
176
193
|
}
|
|
177
194
|
|
|
178
195
|
interface IFragmentContent extends Partial<ITextStyle> {
|
|
@@ -182,19 +199,24 @@ interface IParagraphContent extends Partial<ITextStyle> {
|
|
|
182
199
|
fragments: IFragmentContent[];
|
|
183
200
|
}
|
|
184
201
|
type ITextContent = string | IFragmentContent | IParagraphContent | (string | IFragmentContent | IParagraphContent | (string | IFragmentContent)[])[];
|
|
185
|
-
interface IText extends
|
|
186
|
-
type:
|
|
202
|
+
interface IText extends IBaseElement<ITextStyle> {
|
|
203
|
+
type: IElementType.text;
|
|
187
204
|
content: ITextContent;
|
|
188
205
|
}
|
|
189
206
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
207
|
+
interface IVideo extends IBaseElement {
|
|
208
|
+
type: IElementType.video;
|
|
209
|
+
src: string;
|
|
193
210
|
}
|
|
194
211
|
|
|
195
|
-
|
|
212
|
+
type IElement = IImage | IText | IShape | IVideo | IGroup;
|
|
213
|
+
|
|
214
|
+
interface IDoc extends IBaseElement {
|
|
215
|
+
children: IElement[];
|
|
196
216
|
}
|
|
197
217
|
|
|
198
|
-
declare
|
|
218
|
+
declare function getDefaultElementStyle(): IBaseElementStyle;
|
|
219
|
+
|
|
220
|
+
declare function getDefaultTextStyle(): ITextStyle;
|
|
199
221
|
|
|
200
|
-
export { type FillRule, type FontKerning, type FontStyle, type FontWeight, type Highlight, type HighlightColormap, type HighlightImage, type HighlightLine, type HighlightReferImage, type HighlightSize, type HighlightThickness, type IBackground, type IBackgroundStyle, type
|
|
222
|
+
export { type FillRule, type FontKerning, type FontStyle, type FontWeight, type Highlight, type HighlightColormap, type HighlightImage, type HighlightLine, type HighlightReferImage, type HighlightSize, type HighlightThickness, type IBackground, type IBackgroundStyle, type IBaseElement, type IBaseElementStyle, type IDoc, type IElement, IElementType, type IFragmentContent, type IGroup, type IImage, type IParagraphContent, type IPath, type IPathDrawStyle, type IPathStyle, type IShape, type IText, type ITextContent, type ITextDrawStyle, type ITextInlineStyle, type ITextLineStyle, type ITextStyle, type IVideo, type ListStyle, type ListStyleColormap, type ListStyleImage, type ListStylePosition, type ListStyleSize, type ListStyleType, type Overflow, type Sizeable, type StrokeLinecap, type StrokeLinejoin, type TextAlign, type TextDecorationLine, type TextHighlightStyle, type TextListStyle, type TextOrientation, type TextTransform, type TextWrap, type VerticalAlign, type Visibility, type WritingMode, getDefaultElementStyle, getDefaultTextStyle };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
declare enum IElementType {
|
|
2
|
+
text = "text",
|
|
3
|
+
image = "image",
|
|
4
|
+
group = "group",
|
|
5
|
+
shape = "shape",
|
|
6
|
+
video = "video"
|
|
7
|
+
}
|
|
8
|
+
|
|
1
9
|
interface IBackgroundStyle {
|
|
2
10
|
opacity: number;
|
|
3
11
|
}
|
|
@@ -7,7 +15,7 @@ interface IBackground extends Partial<IBackgroundStyle> {
|
|
|
7
15
|
|
|
8
16
|
type Overflow = 'hidden' | 'visible';
|
|
9
17
|
type Visibility = 'hidden' | 'visible';
|
|
10
|
-
interface
|
|
18
|
+
interface IBaseElementStyle {
|
|
11
19
|
overflow: Overflow;
|
|
12
20
|
visibility: Visibility;
|
|
13
21
|
filter: string;
|
|
@@ -17,8 +25,20 @@ interface IElementStyle {
|
|
|
17
25
|
height: number;
|
|
18
26
|
rotate: number;
|
|
19
27
|
opacity: number;
|
|
28
|
+
marginLeft: number;
|
|
29
|
+
marginTop: number;
|
|
30
|
+
marginRight: number;
|
|
31
|
+
marginBottom: number;
|
|
32
|
+
paddingLeft: number;
|
|
33
|
+
paddingTop: number;
|
|
34
|
+
paddingRight: number;
|
|
35
|
+
paddingBottom: number;
|
|
20
36
|
scaleX: number;
|
|
21
37
|
scaleY: number;
|
|
38
|
+
skewX: number;
|
|
39
|
+
skewY: number;
|
|
40
|
+
translateX: number;
|
|
41
|
+
translateY: number;
|
|
22
42
|
transform: string;
|
|
23
43
|
transformOrigin: string;
|
|
24
44
|
backgroundImage: string;
|
|
@@ -27,28 +47,25 @@ interface IElementStyle {
|
|
|
27
47
|
shadowOffsetX: number;
|
|
28
48
|
shadowOffsetY: number;
|
|
29
49
|
shadowBlur: number;
|
|
30
|
-
marginLeft: number;
|
|
31
|
-
marginTop: number;
|
|
32
|
-
marginRight: number;
|
|
33
|
-
marginBottom: number;
|
|
34
|
-
paddingLeft: number;
|
|
35
|
-
paddingTop: number;
|
|
36
|
-
paddingRight: number;
|
|
37
|
-
paddingBottom: number;
|
|
38
50
|
borderRadius: number;
|
|
39
51
|
borderColor: string;
|
|
40
52
|
borderWidth: number;
|
|
41
53
|
}
|
|
42
54
|
|
|
43
|
-
interface
|
|
55
|
+
interface IBaseElement<T extends IBaseElementStyle = IBaseElementStyle> {
|
|
44
56
|
name?: string;
|
|
45
57
|
style?: Partial<T>;
|
|
46
58
|
background?: IBackground;
|
|
47
59
|
meta?: Record<string, any>;
|
|
48
60
|
}
|
|
49
61
|
|
|
50
|
-
interface
|
|
51
|
-
type:
|
|
62
|
+
interface IGroup extends IBaseElement {
|
|
63
|
+
type: IElementType.group;
|
|
64
|
+
children: IElement[];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
interface IImage extends IBaseElement {
|
|
68
|
+
type: IElementType.image;
|
|
52
69
|
src: string;
|
|
53
70
|
}
|
|
54
71
|
|
|
@@ -81,8 +98,8 @@ interface IPath extends Partial<IPathStyle> {
|
|
|
81
98
|
data: string;
|
|
82
99
|
}
|
|
83
100
|
|
|
84
|
-
interface IShape extends
|
|
85
|
-
type:
|
|
101
|
+
interface IShape extends IBaseElement {
|
|
102
|
+
type: IElementType.shape;
|
|
86
103
|
paths: IPath[];
|
|
87
104
|
}
|
|
88
105
|
|
|
@@ -124,7 +141,7 @@ interface Highlight {
|
|
|
124
141
|
thickness: HighlightThickness;
|
|
125
142
|
}
|
|
126
143
|
interface TextListStyle {
|
|
127
|
-
listStyle
|
|
144
|
+
listStyle?: Partial<ListStyle>;
|
|
128
145
|
listStyleType: ListStyleType;
|
|
129
146
|
listStyleImage: ListStyleImage;
|
|
130
147
|
listStyleColormap: ListStyleColormap;
|
|
@@ -132,7 +149,7 @@ interface TextListStyle {
|
|
|
132
149
|
listStylePosition: ListStylePosition;
|
|
133
150
|
}
|
|
134
151
|
interface TextHighlightStyle {
|
|
135
|
-
highlight
|
|
152
|
+
highlight?: Partial<Highlight>;
|
|
136
153
|
highlightImage: HighlightImage;
|
|
137
154
|
highlightReferImage: HighlightReferImage;
|
|
138
155
|
highlightColormap: HighlightColormap;
|
|
@@ -140,14 +157,14 @@ interface TextHighlightStyle {
|
|
|
140
157
|
highlightSize: HighlightSize;
|
|
141
158
|
highlightThickness: HighlightThickness;
|
|
142
159
|
}
|
|
143
|
-
interface
|
|
160
|
+
interface ITextLineStyle extends TextListStyle {
|
|
144
161
|
writingMode: WritingMode;
|
|
145
162
|
textWrap: TextWrap;
|
|
146
163
|
textAlign: TextAlign;
|
|
147
164
|
textIndent: number;
|
|
148
165
|
lineHeight: number;
|
|
149
166
|
}
|
|
150
|
-
interface
|
|
167
|
+
interface ITextInlineStyle extends TextHighlightStyle {
|
|
151
168
|
color: string;
|
|
152
169
|
verticalAlign: VerticalAlign;
|
|
153
170
|
letterSpacing: number;
|
|
@@ -160,7 +177,7 @@ interface TextInlineStyle extends TextHighlightStyle {
|
|
|
160
177
|
textOrientation: TextOrientation;
|
|
161
178
|
textDecoration: TextDecorationLine;
|
|
162
179
|
}
|
|
163
|
-
interface
|
|
180
|
+
interface ITextDrawStyle {
|
|
164
181
|
textStrokeWidth: number;
|
|
165
182
|
textStrokeColor: string;
|
|
166
183
|
shadowColor: string;
|
|
@@ -172,7 +189,7 @@ interface TextDrawStyle {
|
|
|
172
189
|
skewX: number;
|
|
173
190
|
skewY: number;
|
|
174
191
|
}
|
|
175
|
-
interface ITextStyle extends
|
|
192
|
+
interface ITextStyle extends ITextLineStyle, ITextInlineStyle, ITextDrawStyle, IBaseElementStyle {
|
|
176
193
|
}
|
|
177
194
|
|
|
178
195
|
interface IFragmentContent extends Partial<ITextStyle> {
|
|
@@ -182,19 +199,24 @@ interface IParagraphContent extends Partial<ITextStyle> {
|
|
|
182
199
|
fragments: IFragmentContent[];
|
|
183
200
|
}
|
|
184
201
|
type ITextContent = string | IFragmentContent | IParagraphContent | (string | IFragmentContent | IParagraphContent | (string | IFragmentContent)[])[];
|
|
185
|
-
interface IText extends
|
|
186
|
-
type:
|
|
202
|
+
interface IText extends IBaseElement<ITextStyle> {
|
|
203
|
+
type: IElementType.text;
|
|
187
204
|
content: ITextContent;
|
|
188
205
|
}
|
|
189
206
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
207
|
+
interface IVideo extends IBaseElement {
|
|
208
|
+
type: IElementType.video;
|
|
209
|
+
src: string;
|
|
193
210
|
}
|
|
194
211
|
|
|
195
|
-
|
|
212
|
+
type IElement = IImage | IText | IShape | IVideo | IGroup;
|
|
213
|
+
|
|
214
|
+
interface IDoc extends IBaseElement {
|
|
215
|
+
children: IElement[];
|
|
196
216
|
}
|
|
197
217
|
|
|
198
|
-
declare
|
|
218
|
+
declare function getDefaultElementStyle(): IBaseElementStyle;
|
|
219
|
+
|
|
220
|
+
declare function getDefaultTextStyle(): ITextStyle;
|
|
199
221
|
|
|
200
|
-
export { type FillRule, type FontKerning, type FontStyle, type FontWeight, type Highlight, type HighlightColormap, type HighlightImage, type HighlightLine, type HighlightReferImage, type HighlightSize, type HighlightThickness, type IBackground, type IBackgroundStyle, type
|
|
222
|
+
export { type FillRule, type FontKerning, type FontStyle, type FontWeight, type Highlight, type HighlightColormap, type HighlightImage, type HighlightLine, type HighlightReferImage, type HighlightSize, type HighlightThickness, type IBackground, type IBackgroundStyle, type IBaseElement, type IBaseElementStyle, type IDoc, type IElement, IElementType, type IFragmentContent, type IGroup, type IImage, type IParagraphContent, type IPath, type IPathDrawStyle, type IPathStyle, type IShape, type IText, type ITextContent, type ITextDrawStyle, type ITextInlineStyle, type ITextLineStyle, type ITextStyle, type IVideo, type ListStyle, type ListStyleColormap, type ListStyleImage, type ListStylePosition, type ListStyleSize, type ListStyleType, type Overflow, type Sizeable, type StrokeLinecap, type StrokeLinejoin, type TextAlign, type TextDecorationLine, type TextHighlightStyle, type TextListStyle, type TextOrientation, type TextTransform, type TextWrap, type VerticalAlign, type Visibility, type WritingMode, getDefaultElementStyle, getDefaultTextStyle };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
declare enum IElementType {
|
|
2
|
+
text = "text",
|
|
3
|
+
image = "image",
|
|
4
|
+
group = "group",
|
|
5
|
+
shape = "shape",
|
|
6
|
+
video = "video"
|
|
7
|
+
}
|
|
8
|
+
|
|
1
9
|
interface IBackgroundStyle {
|
|
2
10
|
opacity: number;
|
|
3
11
|
}
|
|
@@ -7,7 +15,7 @@ interface IBackground extends Partial<IBackgroundStyle> {
|
|
|
7
15
|
|
|
8
16
|
type Overflow = 'hidden' | 'visible';
|
|
9
17
|
type Visibility = 'hidden' | 'visible';
|
|
10
|
-
interface
|
|
18
|
+
interface IBaseElementStyle {
|
|
11
19
|
overflow: Overflow;
|
|
12
20
|
visibility: Visibility;
|
|
13
21
|
filter: string;
|
|
@@ -17,8 +25,20 @@ interface IElementStyle {
|
|
|
17
25
|
height: number;
|
|
18
26
|
rotate: number;
|
|
19
27
|
opacity: number;
|
|
28
|
+
marginLeft: number;
|
|
29
|
+
marginTop: number;
|
|
30
|
+
marginRight: number;
|
|
31
|
+
marginBottom: number;
|
|
32
|
+
paddingLeft: number;
|
|
33
|
+
paddingTop: number;
|
|
34
|
+
paddingRight: number;
|
|
35
|
+
paddingBottom: number;
|
|
20
36
|
scaleX: number;
|
|
21
37
|
scaleY: number;
|
|
38
|
+
skewX: number;
|
|
39
|
+
skewY: number;
|
|
40
|
+
translateX: number;
|
|
41
|
+
translateY: number;
|
|
22
42
|
transform: string;
|
|
23
43
|
transformOrigin: string;
|
|
24
44
|
backgroundImage: string;
|
|
@@ -27,28 +47,25 @@ interface IElementStyle {
|
|
|
27
47
|
shadowOffsetX: number;
|
|
28
48
|
shadowOffsetY: number;
|
|
29
49
|
shadowBlur: number;
|
|
30
|
-
marginLeft: number;
|
|
31
|
-
marginTop: number;
|
|
32
|
-
marginRight: number;
|
|
33
|
-
marginBottom: number;
|
|
34
|
-
paddingLeft: number;
|
|
35
|
-
paddingTop: number;
|
|
36
|
-
paddingRight: number;
|
|
37
|
-
paddingBottom: number;
|
|
38
50
|
borderRadius: number;
|
|
39
51
|
borderColor: string;
|
|
40
52
|
borderWidth: number;
|
|
41
53
|
}
|
|
42
54
|
|
|
43
|
-
interface
|
|
55
|
+
interface IBaseElement<T extends IBaseElementStyle = IBaseElementStyle> {
|
|
44
56
|
name?: string;
|
|
45
57
|
style?: Partial<T>;
|
|
46
58
|
background?: IBackground;
|
|
47
59
|
meta?: Record<string, any>;
|
|
48
60
|
}
|
|
49
61
|
|
|
50
|
-
interface
|
|
51
|
-
type:
|
|
62
|
+
interface IGroup extends IBaseElement {
|
|
63
|
+
type: IElementType.group;
|
|
64
|
+
children: IElement[];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
interface IImage extends IBaseElement {
|
|
68
|
+
type: IElementType.image;
|
|
52
69
|
src: string;
|
|
53
70
|
}
|
|
54
71
|
|
|
@@ -81,8 +98,8 @@ interface IPath extends Partial<IPathStyle> {
|
|
|
81
98
|
data: string;
|
|
82
99
|
}
|
|
83
100
|
|
|
84
|
-
interface IShape extends
|
|
85
|
-
type:
|
|
101
|
+
interface IShape extends IBaseElement {
|
|
102
|
+
type: IElementType.shape;
|
|
86
103
|
paths: IPath[];
|
|
87
104
|
}
|
|
88
105
|
|
|
@@ -124,7 +141,7 @@ interface Highlight {
|
|
|
124
141
|
thickness: HighlightThickness;
|
|
125
142
|
}
|
|
126
143
|
interface TextListStyle {
|
|
127
|
-
listStyle
|
|
144
|
+
listStyle?: Partial<ListStyle>;
|
|
128
145
|
listStyleType: ListStyleType;
|
|
129
146
|
listStyleImage: ListStyleImage;
|
|
130
147
|
listStyleColormap: ListStyleColormap;
|
|
@@ -132,7 +149,7 @@ interface TextListStyle {
|
|
|
132
149
|
listStylePosition: ListStylePosition;
|
|
133
150
|
}
|
|
134
151
|
interface TextHighlightStyle {
|
|
135
|
-
highlight
|
|
152
|
+
highlight?: Partial<Highlight>;
|
|
136
153
|
highlightImage: HighlightImage;
|
|
137
154
|
highlightReferImage: HighlightReferImage;
|
|
138
155
|
highlightColormap: HighlightColormap;
|
|
@@ -140,14 +157,14 @@ interface TextHighlightStyle {
|
|
|
140
157
|
highlightSize: HighlightSize;
|
|
141
158
|
highlightThickness: HighlightThickness;
|
|
142
159
|
}
|
|
143
|
-
interface
|
|
160
|
+
interface ITextLineStyle extends TextListStyle {
|
|
144
161
|
writingMode: WritingMode;
|
|
145
162
|
textWrap: TextWrap;
|
|
146
163
|
textAlign: TextAlign;
|
|
147
164
|
textIndent: number;
|
|
148
165
|
lineHeight: number;
|
|
149
166
|
}
|
|
150
|
-
interface
|
|
167
|
+
interface ITextInlineStyle extends TextHighlightStyle {
|
|
151
168
|
color: string;
|
|
152
169
|
verticalAlign: VerticalAlign;
|
|
153
170
|
letterSpacing: number;
|
|
@@ -160,7 +177,7 @@ interface TextInlineStyle extends TextHighlightStyle {
|
|
|
160
177
|
textOrientation: TextOrientation;
|
|
161
178
|
textDecoration: TextDecorationLine;
|
|
162
179
|
}
|
|
163
|
-
interface
|
|
180
|
+
interface ITextDrawStyle {
|
|
164
181
|
textStrokeWidth: number;
|
|
165
182
|
textStrokeColor: string;
|
|
166
183
|
shadowColor: string;
|
|
@@ -172,7 +189,7 @@ interface TextDrawStyle {
|
|
|
172
189
|
skewX: number;
|
|
173
190
|
skewY: number;
|
|
174
191
|
}
|
|
175
|
-
interface ITextStyle extends
|
|
192
|
+
interface ITextStyle extends ITextLineStyle, ITextInlineStyle, ITextDrawStyle, IBaseElementStyle {
|
|
176
193
|
}
|
|
177
194
|
|
|
178
195
|
interface IFragmentContent extends Partial<ITextStyle> {
|
|
@@ -182,19 +199,24 @@ interface IParagraphContent extends Partial<ITextStyle> {
|
|
|
182
199
|
fragments: IFragmentContent[];
|
|
183
200
|
}
|
|
184
201
|
type ITextContent = string | IFragmentContent | IParagraphContent | (string | IFragmentContent | IParagraphContent | (string | IFragmentContent)[])[];
|
|
185
|
-
interface IText extends
|
|
186
|
-
type:
|
|
202
|
+
interface IText extends IBaseElement<ITextStyle> {
|
|
203
|
+
type: IElementType.text;
|
|
187
204
|
content: ITextContent;
|
|
188
205
|
}
|
|
189
206
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
207
|
+
interface IVideo extends IBaseElement {
|
|
208
|
+
type: IElementType.video;
|
|
209
|
+
src: string;
|
|
193
210
|
}
|
|
194
211
|
|
|
195
|
-
|
|
212
|
+
type IElement = IImage | IText | IShape | IVideo | IGroup;
|
|
213
|
+
|
|
214
|
+
interface IDoc extends IBaseElement {
|
|
215
|
+
children: IElement[];
|
|
196
216
|
}
|
|
197
217
|
|
|
198
|
-
declare
|
|
218
|
+
declare function getDefaultElementStyle(): IBaseElementStyle;
|
|
219
|
+
|
|
220
|
+
declare function getDefaultTextStyle(): ITextStyle;
|
|
199
221
|
|
|
200
|
-
export { type FillRule, type FontKerning, type FontStyle, type FontWeight, type Highlight, type HighlightColormap, type HighlightImage, type HighlightLine, type HighlightReferImage, type HighlightSize, type HighlightThickness, type IBackground, type IBackgroundStyle, type
|
|
222
|
+
export { type FillRule, type FontKerning, type FontStyle, type FontWeight, type Highlight, type HighlightColormap, type HighlightImage, type HighlightLine, type HighlightReferImage, type HighlightSize, type HighlightThickness, type IBackground, type IBackgroundStyle, type IBaseElement, type IBaseElementStyle, type IDoc, type IElement, IElementType, type IFragmentContent, type IGroup, type IImage, type IParagraphContent, type IPath, type IPathDrawStyle, type IPathStyle, type IShape, type IText, type ITextContent, type ITextDrawStyle, type ITextInlineStyle, type ITextLineStyle, type ITextStyle, type IVideo, type ListStyle, type ListStyleColormap, type ListStyleImage, type ListStylePosition, type ListStyleSize, type ListStyleType, type Overflow, type Sizeable, type StrokeLinecap, type StrokeLinejoin, type TextAlign, type TextDecorationLine, type TextHighlightStyle, type TextListStyle, type TextOrientation, type TextTransform, type TextWrap, type VerticalAlign, type Visibility, type WritingMode, getDefaultElementStyle, getDefaultTextStyle };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,
|
|
1
|
+
(function(e,t){typeof exports=="object"&&typeof module<"u"?t(exports):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e.modernIdoc={}))})(this,function(e){"use strict";var t=(n=>(n.text="text",n.image="image",n.group="group",n.shape="shape",n.video="video",n))(t||{});function i(){return{overflow:"visible",visibility:"visible",filter:"none",left:0,top:0,width:0,height:0,rotate:0,opacity:1,marginLeft:0,marginTop:0,marginRight:0,marginBottom:0,paddingLeft:0,paddingTop:0,paddingRight:0,paddingBottom:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"50% 50%",backgroundImage:"none",backgroundColor:"transparent",shadowColor:"transparent",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,borderRadius:0,borderColor:"transparent",borderWidth:1}}function o(){return{...i(),writingMode:"horizontal-tb",verticalAlign:"baseline",lineHeight:1.2,letterSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textWrap:"wrap",textAlign:"start",textIndent:0,textTransform:"none",textOrientation:"mixed",textDecoration:"none",textStrokeWidth:0,textStrokeColor:"black",color:"black",listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside",highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}e.IElementType=t,e.getDefaultElementStyle=i,e.getDefaultTextStyle=o,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,97 @@
|
|
|
1
|
-
|
|
1
|
+
var IElementType = /* @__PURE__ */ ((IElementType2) => {
|
|
2
|
+
IElementType2["text"] = "text";
|
|
3
|
+
IElementType2["image"] = "image";
|
|
4
|
+
IElementType2["group"] = "group";
|
|
5
|
+
IElementType2["shape"] = "shape";
|
|
6
|
+
IElementType2["video"] = "video";
|
|
7
|
+
return IElementType2;
|
|
8
|
+
})(IElementType || {});
|
|
2
9
|
|
|
3
|
-
|
|
10
|
+
function getDefaultElementStyle() {
|
|
11
|
+
return {
|
|
12
|
+
overflow: "visible",
|
|
13
|
+
visibility: "visible",
|
|
14
|
+
filter: "none",
|
|
15
|
+
// position
|
|
16
|
+
left: 0,
|
|
17
|
+
top: 0,
|
|
18
|
+
width: 0,
|
|
19
|
+
height: 0,
|
|
20
|
+
rotate: 0,
|
|
21
|
+
opacity: 1,
|
|
22
|
+
// margin
|
|
23
|
+
marginLeft: 0,
|
|
24
|
+
marginTop: 0,
|
|
25
|
+
marginRight: 0,
|
|
26
|
+
marginBottom: 0,
|
|
27
|
+
// padding
|
|
28
|
+
paddingLeft: 0,
|
|
29
|
+
paddingTop: 0,
|
|
30
|
+
paddingRight: 0,
|
|
31
|
+
paddingBottom: 0,
|
|
32
|
+
// transform
|
|
33
|
+
scaleX: 1,
|
|
34
|
+
scaleY: 1,
|
|
35
|
+
skewX: 0,
|
|
36
|
+
skewY: 0,
|
|
37
|
+
translateX: 0,
|
|
38
|
+
translateY: 0,
|
|
39
|
+
transform: "none",
|
|
40
|
+
transformOrigin: "50% 50%",
|
|
41
|
+
// background
|
|
42
|
+
backgroundImage: "none",
|
|
43
|
+
backgroundColor: "transparent",
|
|
44
|
+
// shadow
|
|
45
|
+
shadowColor: "transparent",
|
|
46
|
+
shadowOffsetX: 0,
|
|
47
|
+
shadowOffsetY: 0,
|
|
48
|
+
shadowBlur: 0,
|
|
49
|
+
// border
|
|
50
|
+
borderRadius: 0,
|
|
51
|
+
borderColor: "transparent",
|
|
52
|
+
borderWidth: 1
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function getDefaultTextStyle() {
|
|
57
|
+
return {
|
|
58
|
+
...getDefaultElementStyle(),
|
|
59
|
+
writingMode: "horizontal-tb",
|
|
60
|
+
verticalAlign: "baseline",
|
|
61
|
+
lineHeight: 1.2,
|
|
62
|
+
letterSpacing: 0,
|
|
63
|
+
// font
|
|
64
|
+
fontSize: 14,
|
|
65
|
+
fontWeight: "normal",
|
|
66
|
+
fontFamily: "",
|
|
67
|
+
fontStyle: "normal",
|
|
68
|
+
fontKerning: "normal",
|
|
69
|
+
// text
|
|
70
|
+
textWrap: "wrap",
|
|
71
|
+
textAlign: "start",
|
|
72
|
+
textIndent: 0,
|
|
73
|
+
textTransform: "none",
|
|
74
|
+
textOrientation: "mixed",
|
|
75
|
+
textDecoration: "none",
|
|
76
|
+
// textStroke
|
|
77
|
+
textStrokeWidth: 0,
|
|
78
|
+
textStrokeColor: "black",
|
|
79
|
+
// color
|
|
80
|
+
color: "black",
|
|
81
|
+
// listStyle
|
|
82
|
+
listStyleType: "none",
|
|
83
|
+
listStyleImage: "none",
|
|
84
|
+
listStyleColormap: "none",
|
|
85
|
+
listStyleSize: "cover",
|
|
86
|
+
listStylePosition: "outside",
|
|
87
|
+
// listStyle
|
|
88
|
+
highlightImage: "none",
|
|
89
|
+
highlightReferImage: "none",
|
|
90
|
+
highlightColormap: "none",
|
|
91
|
+
highlightLine: "none",
|
|
92
|
+
highlightSize: "cover",
|
|
93
|
+
highlightThickness: "100%"
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export { IElementType, getDefaultElementStyle, getDefaultTextStyle };
|