modern-idoc 0.2.1 → 0.2.3
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/index.cjs +55 -13
- package/dist/index.d.cts +45 -46
- package/dist/index.d.mts +45 -46
- package/dist/index.d.ts +45 -46
- package/dist/index.js +1 -1
- package/dist/index.mjs +52 -13
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -49,10 +49,6 @@ function getDefaultLayoutStyle() {
|
|
|
49
49
|
|
|
50
50
|
function getDefaultShadowStyle() {
|
|
51
51
|
return {
|
|
52
|
-
shadowColor: "transparent",
|
|
53
|
-
shadowOffsetX: 0,
|
|
54
|
-
shadowOffsetY: 0,
|
|
55
|
-
shadowBlur: 0,
|
|
56
52
|
boxShadow: "none"
|
|
57
53
|
};
|
|
58
54
|
}
|
|
@@ -136,11 +132,41 @@ function getDefaultStyle() {
|
|
|
136
132
|
};
|
|
137
133
|
}
|
|
138
134
|
|
|
135
|
+
function clearUndef(obj, deep = false) {
|
|
136
|
+
if (typeof obj !== "object" || !obj) {
|
|
137
|
+
return obj;
|
|
138
|
+
}
|
|
139
|
+
if (Array.isArray(obj)) {
|
|
140
|
+
if (deep) {
|
|
141
|
+
return obj.map((v) => clearUndef(v, deep));
|
|
142
|
+
} else {
|
|
143
|
+
return obj;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const newObj = {};
|
|
147
|
+
for (const key in obj) {
|
|
148
|
+
const value = obj[key];
|
|
149
|
+
if (value === void 0 || value === null) {
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
if (deep) {
|
|
153
|
+
newObj[key] = clearUndef(value, deep);
|
|
154
|
+
} else {
|
|
155
|
+
newObj[key] = value;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return newObj;
|
|
159
|
+
}
|
|
160
|
+
function deepClearUndef(obj) {
|
|
161
|
+
return clearUndef(obj, true);
|
|
162
|
+
}
|
|
163
|
+
|
|
139
164
|
function normalizeFill(fill) {
|
|
140
165
|
if (!fill || fill === "none") {
|
|
141
166
|
return void 0;
|
|
142
167
|
} else if (typeof fill === "string") {
|
|
143
168
|
return {
|
|
169
|
+
type: "color",
|
|
144
170
|
color: fill
|
|
145
171
|
};
|
|
146
172
|
} else {
|
|
@@ -185,15 +211,27 @@ function normalizeImage(image) {
|
|
|
185
211
|
}
|
|
186
212
|
}
|
|
187
213
|
|
|
188
|
-
function
|
|
189
|
-
if (!
|
|
214
|
+
function normalizeOutline(outline) {
|
|
215
|
+
if (!outline || outline === "none") {
|
|
190
216
|
return void 0;
|
|
191
|
-
} else if (typeof
|
|
217
|
+
} else if (typeof outline === "string") {
|
|
192
218
|
return {
|
|
193
|
-
color:
|
|
219
|
+
color: outline
|
|
194
220
|
};
|
|
195
221
|
} else {
|
|
196
|
-
return
|
|
222
|
+
return outline;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function normalizeShadow(shadow) {
|
|
227
|
+
if (!shadow || shadow === "none") {
|
|
228
|
+
return void 0;
|
|
229
|
+
} else if (typeof shadow === "string") {
|
|
230
|
+
return {
|
|
231
|
+
color: shadow
|
|
232
|
+
};
|
|
233
|
+
} else {
|
|
234
|
+
return shadow;
|
|
197
235
|
}
|
|
198
236
|
}
|
|
199
237
|
|
|
@@ -277,18 +315,21 @@ function normalizeVideo(video) {
|
|
|
277
315
|
}
|
|
278
316
|
|
|
279
317
|
function normalizeElement(element) {
|
|
280
|
-
return {
|
|
318
|
+
return clearUndef({
|
|
281
319
|
...element,
|
|
282
320
|
image: normalizeImage(element.image),
|
|
283
321
|
video: normalizeVideo(element.video),
|
|
284
322
|
text: normalizeText(element.text),
|
|
285
323
|
geometry: normalizeGeometry(element.geometry),
|
|
286
324
|
fill: normalizeFill(element.fill),
|
|
287
|
-
|
|
325
|
+
outline: normalizeOutline(element.outline),
|
|
326
|
+
shadow: normalizeShadow(element.shadow),
|
|
288
327
|
children: element.children?.map((child) => normalizeElement(child))
|
|
289
|
-
};
|
|
328
|
+
});
|
|
290
329
|
}
|
|
291
330
|
|
|
331
|
+
exports.clearUndef = clearUndef;
|
|
332
|
+
exports.deepClearUndef = deepClearUndef;
|
|
292
333
|
exports.getDefaultElementStyle = getDefaultElementStyle;
|
|
293
334
|
exports.getDefaultShadowStyle = getDefaultShadowStyle;
|
|
294
335
|
exports.getDefaultStyle = getDefaultStyle;
|
|
@@ -298,7 +339,8 @@ exports.normalizeElement = normalizeElement;
|
|
|
298
339
|
exports.normalizeFill = normalizeFill;
|
|
299
340
|
exports.normalizeGeometry = normalizeGeometry;
|
|
300
341
|
exports.normalizeImage = normalizeImage;
|
|
301
|
-
exports.
|
|
342
|
+
exports.normalizeOutline = normalizeOutline;
|
|
343
|
+
exports.normalizeShadow = normalizeShadow;
|
|
302
344
|
exports.normalizeText = normalizeText;
|
|
303
345
|
exports.normalizeTextContent = normalizeTextContent;
|
|
304
346
|
exports.normalizeVideo = normalizeVideo;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
type Noneable = 'none';
|
|
2
|
+
type Sizeable = `${number}%` | `${number}rem` | number;
|
|
3
|
+
|
|
4
|
+
interface ImageFillRect {
|
|
2
5
|
left?: number;
|
|
3
6
|
top?: number;
|
|
4
7
|
bottom?: number;
|
|
5
8
|
right?: number;
|
|
6
9
|
}
|
|
7
|
-
interface
|
|
10
|
+
interface ImageFillTile {
|
|
8
11
|
alignment?: string;
|
|
9
12
|
scaleX?: number;
|
|
10
13
|
scaleY?: number;
|
|
@@ -12,16 +15,24 @@ interface FillTile {
|
|
|
12
15
|
translateY?: number;
|
|
13
16
|
flip?: string;
|
|
14
17
|
}
|
|
15
|
-
interface
|
|
18
|
+
interface CommonFillDeclaration {
|
|
16
19
|
opacity?: number;
|
|
17
|
-
|
|
20
|
+
}
|
|
21
|
+
interface ImageFillDeclaration extends CommonFillDeclaration {
|
|
22
|
+
type: 'image';
|
|
23
|
+
image: string;
|
|
18
24
|
dpi?: number;
|
|
19
25
|
rotateWithShape?: boolean;
|
|
20
|
-
srcRect?:
|
|
21
|
-
fillRect?:
|
|
22
|
-
tile?:
|
|
23
|
-
|
|
26
|
+
srcRect?: ImageFillRect;
|
|
27
|
+
fillRect?: ImageFillRect;
|
|
28
|
+
tile?: ImageFillTile;
|
|
29
|
+
}
|
|
30
|
+
interface ColorFillDeclaration extends CommonFillDeclaration {
|
|
31
|
+
type: 'color';
|
|
32
|
+
color: string;
|
|
24
33
|
}
|
|
34
|
+
type FillDeclaration = ImageFillDeclaration | ColorFillDeclaration;
|
|
35
|
+
type FillProp = Noneable | string | FillDeclaration;
|
|
25
36
|
|
|
26
37
|
type SVGPathData = string;
|
|
27
38
|
type FillRule = 'nonzero' | 'evenodd';
|
|
@@ -53,12 +64,6 @@ interface Path2DDeclaration extends Partial<Path2DStyle> {
|
|
|
53
64
|
interface GeometryDeclaration {
|
|
54
65
|
data: Path2DDeclaration[];
|
|
55
66
|
}
|
|
56
|
-
|
|
57
|
-
type Noneable = 'none';
|
|
58
|
-
type Sizeable = `${number}%` | `${number}rem` | number;
|
|
59
|
-
|
|
60
|
-
type FillProp = Noneable | string | FillDeclaration;
|
|
61
|
-
|
|
62
67
|
type GeometryProp = Noneable | SVGPathData | SVGPathData[] | Path2DDeclaration[] | GeometryDeclaration;
|
|
63
68
|
|
|
64
69
|
interface MetaProp {
|
|
@@ -75,18 +80,27 @@ interface ImageDeclaration {
|
|
|
75
80
|
url: string;
|
|
76
81
|
opacity?: number;
|
|
77
82
|
}
|
|
78
|
-
|
|
79
83
|
type ImageProp = Noneable | string | ImageDeclaration;
|
|
80
84
|
|
|
81
|
-
interface
|
|
85
|
+
interface OutlineDeclaration {
|
|
82
86
|
width?: number;
|
|
83
87
|
style?: 'dashed' | 'solid' | string;
|
|
84
88
|
image?: string;
|
|
85
89
|
color?: string;
|
|
86
90
|
opacity?: number;
|
|
87
91
|
}
|
|
92
|
+
type OutlineProp = Noneable | string | Partial<OutlineDeclaration>;
|
|
88
93
|
|
|
89
|
-
|
|
94
|
+
interface ShadowDeclaration {
|
|
95
|
+
color: string;
|
|
96
|
+
offsetX?: number;
|
|
97
|
+
offsetY?: number;
|
|
98
|
+
blur?: number;
|
|
99
|
+
}
|
|
100
|
+
type ShadowProp = Noneable | string | ShadowDeclaration;
|
|
101
|
+
interface ShadowStyleDeclaration {
|
|
102
|
+
boxShadow: Noneable | string;
|
|
103
|
+
}
|
|
90
104
|
|
|
91
105
|
type Overflow = 'hidden' | 'visible';
|
|
92
106
|
type Visibility = 'hidden' | 'visible';
|
|
@@ -163,22 +177,6 @@ interface LayoutStyleDeclaration {
|
|
|
163
177
|
width: number | 'auto' | `${number}%`;
|
|
164
178
|
}
|
|
165
179
|
|
|
166
|
-
interface ShadowDeclaration {
|
|
167
|
-
color: string;
|
|
168
|
-
offsetX: number;
|
|
169
|
-
offsetY: number;
|
|
170
|
-
blur: number;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
interface ShadowStyleDeclaration {
|
|
174
|
-
shadow?: Partial<ShadowDeclaration>;
|
|
175
|
-
shadowColor: string;
|
|
176
|
-
shadowOffsetX: number;
|
|
177
|
-
shadowOffsetY: number;
|
|
178
|
-
shadowBlur: number;
|
|
179
|
-
boxShadow: 'none' | string;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
180
|
interface TransformStyleDeclaration {
|
|
183
181
|
rotate: number;
|
|
184
182
|
scaleX: number;
|
|
@@ -209,7 +207,6 @@ interface HighlightDeclaration {
|
|
|
209
207
|
size: HighlightSize;
|
|
210
208
|
thickness: HighlightThickness;
|
|
211
209
|
}
|
|
212
|
-
|
|
213
210
|
interface HighlightStyleDeclaration {
|
|
214
211
|
highlight?: Partial<HighlightDeclaration>;
|
|
215
212
|
highlightImage: HighlightImage;
|
|
@@ -227,7 +224,6 @@ interface ListStyleDeclaration {
|
|
|
227
224
|
size: ListStyleSize;
|
|
228
225
|
position: ListStylePosition;
|
|
229
226
|
}
|
|
230
|
-
|
|
231
227
|
interface ListStyleStyleDeclaration {
|
|
232
228
|
listStyle?: Partial<ListStyleDeclaration>;
|
|
233
229
|
listStyleType: ListStyleType;
|
|
@@ -269,7 +265,6 @@ interface TextStyleDeclaration extends TextLineStyleDeclaration, TextInlineStyle
|
|
|
269
265
|
|
|
270
266
|
interface StyleDeclaration extends TextStyleDeclaration, ElementStyleDeclaration {
|
|
271
267
|
}
|
|
272
|
-
|
|
273
268
|
type StyleProp = Partial<StyleDeclaration>;
|
|
274
269
|
|
|
275
270
|
interface FragmentContent extends Partial<StyleDeclaration> {
|
|
@@ -287,7 +282,6 @@ interface TextDeclaration {
|
|
|
287
282
|
measureDom?: any;
|
|
288
283
|
fonts?: any;
|
|
289
284
|
}
|
|
290
|
-
|
|
291
285
|
type TextProp = string | TextContent | (TextDeclaration & {
|
|
292
286
|
content: TextContent;
|
|
293
287
|
}) | TextDeclaration;
|
|
@@ -296,7 +290,6 @@ interface VideoDeclaration {
|
|
|
296
290
|
url: string;
|
|
297
291
|
opacity?: number;
|
|
298
292
|
}
|
|
299
|
-
|
|
300
293
|
type VideoProp = Noneable | string | VideoDeclaration;
|
|
301
294
|
|
|
302
295
|
interface IDOCElement extends IDOCNode {
|
|
@@ -306,18 +299,19 @@ interface IDOCElement extends IDOCNode {
|
|
|
306
299
|
text?: TextProp;
|
|
307
300
|
geometry?: GeometryProp;
|
|
308
301
|
fill?: FillProp;
|
|
309
|
-
|
|
302
|
+
outline?: OutlineProp;
|
|
303
|
+
shadow?: ShadowProp;
|
|
310
304
|
children?: IDOCElement[];
|
|
311
305
|
}
|
|
312
|
-
|
|
313
|
-
interface ElementDeclaration extends IDOCElement {
|
|
306
|
+
interface IDOCElementDeclaration extends IDOCElement {
|
|
314
307
|
image?: ImageDeclaration;
|
|
315
308
|
video?: VideoDeclaration;
|
|
316
309
|
text?: TextDeclaration;
|
|
317
310
|
geometry?: GeometryDeclaration;
|
|
318
311
|
fill?: FillDeclaration;
|
|
319
|
-
|
|
320
|
-
|
|
312
|
+
outline?: OutlineDeclaration;
|
|
313
|
+
shadow?: ShadowDeclaration;
|
|
314
|
+
children?: IDOCElementDeclaration[];
|
|
321
315
|
}
|
|
322
316
|
|
|
323
317
|
interface IDOCDocument extends IDOCElement {
|
|
@@ -334,7 +328,10 @@ declare function getDefaultTextStyle(): TextStyleDeclaration;
|
|
|
334
328
|
|
|
335
329
|
declare function getDefaultTransformStyle(): TransformStyleDeclaration;
|
|
336
330
|
|
|
337
|
-
declare function
|
|
331
|
+
declare function clearUndef<T>(obj: T, deep?: boolean): T;
|
|
332
|
+
declare function deepClearUndef<T>(obj: T): T;
|
|
333
|
+
|
|
334
|
+
declare function normalizeElement(element: IDOCElement): IDOCElementDeclaration;
|
|
338
335
|
|
|
339
336
|
declare function normalizeFill(fill?: FillProp): FillDeclaration | undefined;
|
|
340
337
|
|
|
@@ -342,7 +339,9 @@ declare function normalizeGeometry(geometry?: GeometryProp): GeometryDeclaration
|
|
|
342
339
|
|
|
343
340
|
declare function normalizeImage(image?: ImageProp): ImageDeclaration | undefined;
|
|
344
341
|
|
|
345
|
-
declare function
|
|
342
|
+
declare function normalizeOutline(outline?: OutlineProp): OutlineDeclaration | undefined;
|
|
343
|
+
|
|
344
|
+
declare function normalizeShadow(shadow?: ShadowProp): ShadowDeclaration | undefined;
|
|
346
345
|
|
|
347
346
|
declare function normalizeText(text?: TextProp): TextDeclaration | undefined;
|
|
348
347
|
|
|
@@ -350,4 +349,4 @@ declare function normalizeTextContent(content?: TextContent): TextContentDeclara
|
|
|
350
349
|
|
|
351
350
|
declare function normalizeVideo(video?: VideoProp): VideoDeclaration | undefined;
|
|
352
351
|
|
|
353
|
-
export { type
|
|
352
|
+
export { type ColorFillDeclaration, type CommonFillDeclaration, type ElementStyleDeclaration, type FillDeclaration, type FillProp, type FillRule, type FragmentContent, type GeometryDeclaration, type GeometryProp, type HighlightDeclaration, type HighlightStyleDeclaration, type IDOCDocument, type IDOCElement, type IDOCElementDeclaration, type IDOCNode, type ImageDeclaration, type ImageFillDeclaration, type ImageFillRect, type ImageFillTile, type ImageProp, type LayoutStyleDeclaration, type ListStyleDeclaration, type ListStyleStyleDeclaration, type MetaProp, type OutlineDeclaration, type OutlineProp, type ParagraphContent, type Path2DDeclaration, type Path2DStyle, type SVGPathData, type ShadowDeclaration, type ShadowProp, type ShadowStyleDeclaration, type StrokeLinecap, type StrokeLinejoin, type StyleDeclaration, type StyleProp, type TextContent, type TextContentDeclaration, type TextContentFlat, type TextDeclaration, type TextDrawStyleDeclaration, type TextInlineStyleDeclaration, type TextLineStyleDeclaration, type TextProp, type TextStyleDeclaration, type TransformStyleDeclaration, type VideoDeclaration, type VideoProp, clearUndef, deepClearUndef, getDefaultElementStyle, getDefaultShadowStyle, getDefaultStyle, getDefaultTextStyle, getDefaultTransformStyle, normalizeElement, normalizeFill, normalizeGeometry, normalizeImage, normalizeOutline, normalizeShadow, normalizeText, normalizeTextContent, normalizeVideo };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
type Noneable = 'none';
|
|
2
|
+
type Sizeable = `${number}%` | `${number}rem` | number;
|
|
3
|
+
|
|
4
|
+
interface ImageFillRect {
|
|
2
5
|
left?: number;
|
|
3
6
|
top?: number;
|
|
4
7
|
bottom?: number;
|
|
5
8
|
right?: number;
|
|
6
9
|
}
|
|
7
|
-
interface
|
|
10
|
+
interface ImageFillTile {
|
|
8
11
|
alignment?: string;
|
|
9
12
|
scaleX?: number;
|
|
10
13
|
scaleY?: number;
|
|
@@ -12,16 +15,24 @@ interface FillTile {
|
|
|
12
15
|
translateY?: number;
|
|
13
16
|
flip?: string;
|
|
14
17
|
}
|
|
15
|
-
interface
|
|
18
|
+
interface CommonFillDeclaration {
|
|
16
19
|
opacity?: number;
|
|
17
|
-
|
|
20
|
+
}
|
|
21
|
+
interface ImageFillDeclaration extends CommonFillDeclaration {
|
|
22
|
+
type: 'image';
|
|
23
|
+
image: string;
|
|
18
24
|
dpi?: number;
|
|
19
25
|
rotateWithShape?: boolean;
|
|
20
|
-
srcRect?:
|
|
21
|
-
fillRect?:
|
|
22
|
-
tile?:
|
|
23
|
-
|
|
26
|
+
srcRect?: ImageFillRect;
|
|
27
|
+
fillRect?: ImageFillRect;
|
|
28
|
+
tile?: ImageFillTile;
|
|
29
|
+
}
|
|
30
|
+
interface ColorFillDeclaration extends CommonFillDeclaration {
|
|
31
|
+
type: 'color';
|
|
32
|
+
color: string;
|
|
24
33
|
}
|
|
34
|
+
type FillDeclaration = ImageFillDeclaration | ColorFillDeclaration;
|
|
35
|
+
type FillProp = Noneable | string | FillDeclaration;
|
|
25
36
|
|
|
26
37
|
type SVGPathData = string;
|
|
27
38
|
type FillRule = 'nonzero' | 'evenodd';
|
|
@@ -53,12 +64,6 @@ interface Path2DDeclaration extends Partial<Path2DStyle> {
|
|
|
53
64
|
interface GeometryDeclaration {
|
|
54
65
|
data: Path2DDeclaration[];
|
|
55
66
|
}
|
|
56
|
-
|
|
57
|
-
type Noneable = 'none';
|
|
58
|
-
type Sizeable = `${number}%` | `${number}rem` | number;
|
|
59
|
-
|
|
60
|
-
type FillProp = Noneable | string | FillDeclaration;
|
|
61
|
-
|
|
62
67
|
type GeometryProp = Noneable | SVGPathData | SVGPathData[] | Path2DDeclaration[] | GeometryDeclaration;
|
|
63
68
|
|
|
64
69
|
interface MetaProp {
|
|
@@ -75,18 +80,27 @@ interface ImageDeclaration {
|
|
|
75
80
|
url: string;
|
|
76
81
|
opacity?: number;
|
|
77
82
|
}
|
|
78
|
-
|
|
79
83
|
type ImageProp = Noneable | string | ImageDeclaration;
|
|
80
84
|
|
|
81
|
-
interface
|
|
85
|
+
interface OutlineDeclaration {
|
|
82
86
|
width?: number;
|
|
83
87
|
style?: 'dashed' | 'solid' | string;
|
|
84
88
|
image?: string;
|
|
85
89
|
color?: string;
|
|
86
90
|
opacity?: number;
|
|
87
91
|
}
|
|
92
|
+
type OutlineProp = Noneable | string | Partial<OutlineDeclaration>;
|
|
88
93
|
|
|
89
|
-
|
|
94
|
+
interface ShadowDeclaration {
|
|
95
|
+
color: string;
|
|
96
|
+
offsetX?: number;
|
|
97
|
+
offsetY?: number;
|
|
98
|
+
blur?: number;
|
|
99
|
+
}
|
|
100
|
+
type ShadowProp = Noneable | string | ShadowDeclaration;
|
|
101
|
+
interface ShadowStyleDeclaration {
|
|
102
|
+
boxShadow: Noneable | string;
|
|
103
|
+
}
|
|
90
104
|
|
|
91
105
|
type Overflow = 'hidden' | 'visible';
|
|
92
106
|
type Visibility = 'hidden' | 'visible';
|
|
@@ -163,22 +177,6 @@ interface LayoutStyleDeclaration {
|
|
|
163
177
|
width: number | 'auto' | `${number}%`;
|
|
164
178
|
}
|
|
165
179
|
|
|
166
|
-
interface ShadowDeclaration {
|
|
167
|
-
color: string;
|
|
168
|
-
offsetX: number;
|
|
169
|
-
offsetY: number;
|
|
170
|
-
blur: number;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
interface ShadowStyleDeclaration {
|
|
174
|
-
shadow?: Partial<ShadowDeclaration>;
|
|
175
|
-
shadowColor: string;
|
|
176
|
-
shadowOffsetX: number;
|
|
177
|
-
shadowOffsetY: number;
|
|
178
|
-
shadowBlur: number;
|
|
179
|
-
boxShadow: 'none' | string;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
180
|
interface TransformStyleDeclaration {
|
|
183
181
|
rotate: number;
|
|
184
182
|
scaleX: number;
|
|
@@ -209,7 +207,6 @@ interface HighlightDeclaration {
|
|
|
209
207
|
size: HighlightSize;
|
|
210
208
|
thickness: HighlightThickness;
|
|
211
209
|
}
|
|
212
|
-
|
|
213
210
|
interface HighlightStyleDeclaration {
|
|
214
211
|
highlight?: Partial<HighlightDeclaration>;
|
|
215
212
|
highlightImage: HighlightImage;
|
|
@@ -227,7 +224,6 @@ interface ListStyleDeclaration {
|
|
|
227
224
|
size: ListStyleSize;
|
|
228
225
|
position: ListStylePosition;
|
|
229
226
|
}
|
|
230
|
-
|
|
231
227
|
interface ListStyleStyleDeclaration {
|
|
232
228
|
listStyle?: Partial<ListStyleDeclaration>;
|
|
233
229
|
listStyleType: ListStyleType;
|
|
@@ -269,7 +265,6 @@ interface TextStyleDeclaration extends TextLineStyleDeclaration, TextInlineStyle
|
|
|
269
265
|
|
|
270
266
|
interface StyleDeclaration extends TextStyleDeclaration, ElementStyleDeclaration {
|
|
271
267
|
}
|
|
272
|
-
|
|
273
268
|
type StyleProp = Partial<StyleDeclaration>;
|
|
274
269
|
|
|
275
270
|
interface FragmentContent extends Partial<StyleDeclaration> {
|
|
@@ -287,7 +282,6 @@ interface TextDeclaration {
|
|
|
287
282
|
measureDom?: any;
|
|
288
283
|
fonts?: any;
|
|
289
284
|
}
|
|
290
|
-
|
|
291
285
|
type TextProp = string | TextContent | (TextDeclaration & {
|
|
292
286
|
content: TextContent;
|
|
293
287
|
}) | TextDeclaration;
|
|
@@ -296,7 +290,6 @@ interface VideoDeclaration {
|
|
|
296
290
|
url: string;
|
|
297
291
|
opacity?: number;
|
|
298
292
|
}
|
|
299
|
-
|
|
300
293
|
type VideoProp = Noneable | string | VideoDeclaration;
|
|
301
294
|
|
|
302
295
|
interface IDOCElement extends IDOCNode {
|
|
@@ -306,18 +299,19 @@ interface IDOCElement extends IDOCNode {
|
|
|
306
299
|
text?: TextProp;
|
|
307
300
|
geometry?: GeometryProp;
|
|
308
301
|
fill?: FillProp;
|
|
309
|
-
|
|
302
|
+
outline?: OutlineProp;
|
|
303
|
+
shadow?: ShadowProp;
|
|
310
304
|
children?: IDOCElement[];
|
|
311
305
|
}
|
|
312
|
-
|
|
313
|
-
interface ElementDeclaration extends IDOCElement {
|
|
306
|
+
interface IDOCElementDeclaration extends IDOCElement {
|
|
314
307
|
image?: ImageDeclaration;
|
|
315
308
|
video?: VideoDeclaration;
|
|
316
309
|
text?: TextDeclaration;
|
|
317
310
|
geometry?: GeometryDeclaration;
|
|
318
311
|
fill?: FillDeclaration;
|
|
319
|
-
|
|
320
|
-
|
|
312
|
+
outline?: OutlineDeclaration;
|
|
313
|
+
shadow?: ShadowDeclaration;
|
|
314
|
+
children?: IDOCElementDeclaration[];
|
|
321
315
|
}
|
|
322
316
|
|
|
323
317
|
interface IDOCDocument extends IDOCElement {
|
|
@@ -334,7 +328,10 @@ declare function getDefaultTextStyle(): TextStyleDeclaration;
|
|
|
334
328
|
|
|
335
329
|
declare function getDefaultTransformStyle(): TransformStyleDeclaration;
|
|
336
330
|
|
|
337
|
-
declare function
|
|
331
|
+
declare function clearUndef<T>(obj: T, deep?: boolean): T;
|
|
332
|
+
declare function deepClearUndef<T>(obj: T): T;
|
|
333
|
+
|
|
334
|
+
declare function normalizeElement(element: IDOCElement): IDOCElementDeclaration;
|
|
338
335
|
|
|
339
336
|
declare function normalizeFill(fill?: FillProp): FillDeclaration | undefined;
|
|
340
337
|
|
|
@@ -342,7 +339,9 @@ declare function normalizeGeometry(geometry?: GeometryProp): GeometryDeclaration
|
|
|
342
339
|
|
|
343
340
|
declare function normalizeImage(image?: ImageProp): ImageDeclaration | undefined;
|
|
344
341
|
|
|
345
|
-
declare function
|
|
342
|
+
declare function normalizeOutline(outline?: OutlineProp): OutlineDeclaration | undefined;
|
|
343
|
+
|
|
344
|
+
declare function normalizeShadow(shadow?: ShadowProp): ShadowDeclaration | undefined;
|
|
346
345
|
|
|
347
346
|
declare function normalizeText(text?: TextProp): TextDeclaration | undefined;
|
|
348
347
|
|
|
@@ -350,4 +349,4 @@ declare function normalizeTextContent(content?: TextContent): TextContentDeclara
|
|
|
350
349
|
|
|
351
350
|
declare function normalizeVideo(video?: VideoProp): VideoDeclaration | undefined;
|
|
352
351
|
|
|
353
|
-
export { type
|
|
352
|
+
export { type ColorFillDeclaration, type CommonFillDeclaration, type ElementStyleDeclaration, type FillDeclaration, type FillProp, type FillRule, type FragmentContent, type GeometryDeclaration, type GeometryProp, type HighlightDeclaration, type HighlightStyleDeclaration, type IDOCDocument, type IDOCElement, type IDOCElementDeclaration, type IDOCNode, type ImageDeclaration, type ImageFillDeclaration, type ImageFillRect, type ImageFillTile, type ImageProp, type LayoutStyleDeclaration, type ListStyleDeclaration, type ListStyleStyleDeclaration, type MetaProp, type OutlineDeclaration, type OutlineProp, type ParagraphContent, type Path2DDeclaration, type Path2DStyle, type SVGPathData, type ShadowDeclaration, type ShadowProp, type ShadowStyleDeclaration, type StrokeLinecap, type StrokeLinejoin, type StyleDeclaration, type StyleProp, type TextContent, type TextContentDeclaration, type TextContentFlat, type TextDeclaration, type TextDrawStyleDeclaration, type TextInlineStyleDeclaration, type TextLineStyleDeclaration, type TextProp, type TextStyleDeclaration, type TransformStyleDeclaration, type VideoDeclaration, type VideoProp, clearUndef, deepClearUndef, getDefaultElementStyle, getDefaultShadowStyle, getDefaultStyle, getDefaultTextStyle, getDefaultTransformStyle, normalizeElement, normalizeFill, normalizeGeometry, normalizeImage, normalizeOutline, normalizeShadow, normalizeText, normalizeTextContent, normalizeVideo };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
type Noneable = 'none';
|
|
2
|
+
type Sizeable = `${number}%` | `${number}rem` | number;
|
|
3
|
+
|
|
4
|
+
interface ImageFillRect {
|
|
2
5
|
left?: number;
|
|
3
6
|
top?: number;
|
|
4
7
|
bottom?: number;
|
|
5
8
|
right?: number;
|
|
6
9
|
}
|
|
7
|
-
interface
|
|
10
|
+
interface ImageFillTile {
|
|
8
11
|
alignment?: string;
|
|
9
12
|
scaleX?: number;
|
|
10
13
|
scaleY?: number;
|
|
@@ -12,16 +15,24 @@ interface FillTile {
|
|
|
12
15
|
translateY?: number;
|
|
13
16
|
flip?: string;
|
|
14
17
|
}
|
|
15
|
-
interface
|
|
18
|
+
interface CommonFillDeclaration {
|
|
16
19
|
opacity?: number;
|
|
17
|
-
|
|
20
|
+
}
|
|
21
|
+
interface ImageFillDeclaration extends CommonFillDeclaration {
|
|
22
|
+
type: 'image';
|
|
23
|
+
image: string;
|
|
18
24
|
dpi?: number;
|
|
19
25
|
rotateWithShape?: boolean;
|
|
20
|
-
srcRect?:
|
|
21
|
-
fillRect?:
|
|
22
|
-
tile?:
|
|
23
|
-
|
|
26
|
+
srcRect?: ImageFillRect;
|
|
27
|
+
fillRect?: ImageFillRect;
|
|
28
|
+
tile?: ImageFillTile;
|
|
29
|
+
}
|
|
30
|
+
interface ColorFillDeclaration extends CommonFillDeclaration {
|
|
31
|
+
type: 'color';
|
|
32
|
+
color: string;
|
|
24
33
|
}
|
|
34
|
+
type FillDeclaration = ImageFillDeclaration | ColorFillDeclaration;
|
|
35
|
+
type FillProp = Noneable | string | FillDeclaration;
|
|
25
36
|
|
|
26
37
|
type SVGPathData = string;
|
|
27
38
|
type FillRule = 'nonzero' | 'evenodd';
|
|
@@ -53,12 +64,6 @@ interface Path2DDeclaration extends Partial<Path2DStyle> {
|
|
|
53
64
|
interface GeometryDeclaration {
|
|
54
65
|
data: Path2DDeclaration[];
|
|
55
66
|
}
|
|
56
|
-
|
|
57
|
-
type Noneable = 'none';
|
|
58
|
-
type Sizeable = `${number}%` | `${number}rem` | number;
|
|
59
|
-
|
|
60
|
-
type FillProp = Noneable | string | FillDeclaration;
|
|
61
|
-
|
|
62
67
|
type GeometryProp = Noneable | SVGPathData | SVGPathData[] | Path2DDeclaration[] | GeometryDeclaration;
|
|
63
68
|
|
|
64
69
|
interface MetaProp {
|
|
@@ -75,18 +80,27 @@ interface ImageDeclaration {
|
|
|
75
80
|
url: string;
|
|
76
81
|
opacity?: number;
|
|
77
82
|
}
|
|
78
|
-
|
|
79
83
|
type ImageProp = Noneable | string | ImageDeclaration;
|
|
80
84
|
|
|
81
|
-
interface
|
|
85
|
+
interface OutlineDeclaration {
|
|
82
86
|
width?: number;
|
|
83
87
|
style?: 'dashed' | 'solid' | string;
|
|
84
88
|
image?: string;
|
|
85
89
|
color?: string;
|
|
86
90
|
opacity?: number;
|
|
87
91
|
}
|
|
92
|
+
type OutlineProp = Noneable | string | Partial<OutlineDeclaration>;
|
|
88
93
|
|
|
89
|
-
|
|
94
|
+
interface ShadowDeclaration {
|
|
95
|
+
color: string;
|
|
96
|
+
offsetX?: number;
|
|
97
|
+
offsetY?: number;
|
|
98
|
+
blur?: number;
|
|
99
|
+
}
|
|
100
|
+
type ShadowProp = Noneable | string | ShadowDeclaration;
|
|
101
|
+
interface ShadowStyleDeclaration {
|
|
102
|
+
boxShadow: Noneable | string;
|
|
103
|
+
}
|
|
90
104
|
|
|
91
105
|
type Overflow = 'hidden' | 'visible';
|
|
92
106
|
type Visibility = 'hidden' | 'visible';
|
|
@@ -163,22 +177,6 @@ interface LayoutStyleDeclaration {
|
|
|
163
177
|
width: number | 'auto' | `${number}%`;
|
|
164
178
|
}
|
|
165
179
|
|
|
166
|
-
interface ShadowDeclaration {
|
|
167
|
-
color: string;
|
|
168
|
-
offsetX: number;
|
|
169
|
-
offsetY: number;
|
|
170
|
-
blur: number;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
interface ShadowStyleDeclaration {
|
|
174
|
-
shadow?: Partial<ShadowDeclaration>;
|
|
175
|
-
shadowColor: string;
|
|
176
|
-
shadowOffsetX: number;
|
|
177
|
-
shadowOffsetY: number;
|
|
178
|
-
shadowBlur: number;
|
|
179
|
-
boxShadow: 'none' | string;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
180
|
interface TransformStyleDeclaration {
|
|
183
181
|
rotate: number;
|
|
184
182
|
scaleX: number;
|
|
@@ -209,7 +207,6 @@ interface HighlightDeclaration {
|
|
|
209
207
|
size: HighlightSize;
|
|
210
208
|
thickness: HighlightThickness;
|
|
211
209
|
}
|
|
212
|
-
|
|
213
210
|
interface HighlightStyleDeclaration {
|
|
214
211
|
highlight?: Partial<HighlightDeclaration>;
|
|
215
212
|
highlightImage: HighlightImage;
|
|
@@ -227,7 +224,6 @@ interface ListStyleDeclaration {
|
|
|
227
224
|
size: ListStyleSize;
|
|
228
225
|
position: ListStylePosition;
|
|
229
226
|
}
|
|
230
|
-
|
|
231
227
|
interface ListStyleStyleDeclaration {
|
|
232
228
|
listStyle?: Partial<ListStyleDeclaration>;
|
|
233
229
|
listStyleType: ListStyleType;
|
|
@@ -269,7 +265,6 @@ interface TextStyleDeclaration extends TextLineStyleDeclaration, TextInlineStyle
|
|
|
269
265
|
|
|
270
266
|
interface StyleDeclaration extends TextStyleDeclaration, ElementStyleDeclaration {
|
|
271
267
|
}
|
|
272
|
-
|
|
273
268
|
type StyleProp = Partial<StyleDeclaration>;
|
|
274
269
|
|
|
275
270
|
interface FragmentContent extends Partial<StyleDeclaration> {
|
|
@@ -287,7 +282,6 @@ interface TextDeclaration {
|
|
|
287
282
|
measureDom?: any;
|
|
288
283
|
fonts?: any;
|
|
289
284
|
}
|
|
290
|
-
|
|
291
285
|
type TextProp = string | TextContent | (TextDeclaration & {
|
|
292
286
|
content: TextContent;
|
|
293
287
|
}) | TextDeclaration;
|
|
@@ -296,7 +290,6 @@ interface VideoDeclaration {
|
|
|
296
290
|
url: string;
|
|
297
291
|
opacity?: number;
|
|
298
292
|
}
|
|
299
|
-
|
|
300
293
|
type VideoProp = Noneable | string | VideoDeclaration;
|
|
301
294
|
|
|
302
295
|
interface IDOCElement extends IDOCNode {
|
|
@@ -306,18 +299,19 @@ interface IDOCElement extends IDOCNode {
|
|
|
306
299
|
text?: TextProp;
|
|
307
300
|
geometry?: GeometryProp;
|
|
308
301
|
fill?: FillProp;
|
|
309
|
-
|
|
302
|
+
outline?: OutlineProp;
|
|
303
|
+
shadow?: ShadowProp;
|
|
310
304
|
children?: IDOCElement[];
|
|
311
305
|
}
|
|
312
|
-
|
|
313
|
-
interface ElementDeclaration extends IDOCElement {
|
|
306
|
+
interface IDOCElementDeclaration extends IDOCElement {
|
|
314
307
|
image?: ImageDeclaration;
|
|
315
308
|
video?: VideoDeclaration;
|
|
316
309
|
text?: TextDeclaration;
|
|
317
310
|
geometry?: GeometryDeclaration;
|
|
318
311
|
fill?: FillDeclaration;
|
|
319
|
-
|
|
320
|
-
|
|
312
|
+
outline?: OutlineDeclaration;
|
|
313
|
+
shadow?: ShadowDeclaration;
|
|
314
|
+
children?: IDOCElementDeclaration[];
|
|
321
315
|
}
|
|
322
316
|
|
|
323
317
|
interface IDOCDocument extends IDOCElement {
|
|
@@ -334,7 +328,10 @@ declare function getDefaultTextStyle(): TextStyleDeclaration;
|
|
|
334
328
|
|
|
335
329
|
declare function getDefaultTransformStyle(): TransformStyleDeclaration;
|
|
336
330
|
|
|
337
|
-
declare function
|
|
331
|
+
declare function clearUndef<T>(obj: T, deep?: boolean): T;
|
|
332
|
+
declare function deepClearUndef<T>(obj: T): T;
|
|
333
|
+
|
|
334
|
+
declare function normalizeElement(element: IDOCElement): IDOCElementDeclaration;
|
|
338
335
|
|
|
339
336
|
declare function normalizeFill(fill?: FillProp): FillDeclaration | undefined;
|
|
340
337
|
|
|
@@ -342,7 +339,9 @@ declare function normalizeGeometry(geometry?: GeometryProp): GeometryDeclaration
|
|
|
342
339
|
|
|
343
340
|
declare function normalizeImage(image?: ImageProp): ImageDeclaration | undefined;
|
|
344
341
|
|
|
345
|
-
declare function
|
|
342
|
+
declare function normalizeOutline(outline?: OutlineProp): OutlineDeclaration | undefined;
|
|
343
|
+
|
|
344
|
+
declare function normalizeShadow(shadow?: ShadowProp): ShadowDeclaration | undefined;
|
|
346
345
|
|
|
347
346
|
declare function normalizeText(text?: TextProp): TextDeclaration | undefined;
|
|
348
347
|
|
|
@@ -350,4 +349,4 @@ declare function normalizeTextContent(content?: TextContent): TextContentDeclara
|
|
|
350
349
|
|
|
351
350
|
declare function normalizeVideo(video?: VideoProp): VideoDeclaration | undefined;
|
|
352
351
|
|
|
353
|
-
export { type
|
|
352
|
+
export { type ColorFillDeclaration, type CommonFillDeclaration, type ElementStyleDeclaration, type FillDeclaration, type FillProp, type FillRule, type FragmentContent, type GeometryDeclaration, type GeometryProp, type HighlightDeclaration, type HighlightStyleDeclaration, type IDOCDocument, type IDOCElement, type IDOCElementDeclaration, type IDOCNode, type ImageDeclaration, type ImageFillDeclaration, type ImageFillRect, type ImageFillTile, type ImageProp, type LayoutStyleDeclaration, type ListStyleDeclaration, type ListStyleStyleDeclaration, type MetaProp, type OutlineDeclaration, type OutlineProp, type ParagraphContent, type Path2DDeclaration, type Path2DStyle, type SVGPathData, type ShadowDeclaration, type ShadowProp, type ShadowStyleDeclaration, type StrokeLinecap, type StrokeLinejoin, type StyleDeclaration, type StyleProp, type TextContent, type TextContentDeclaration, type TextContentFlat, type TextDeclaration, type TextDrawStyleDeclaration, type TextInlineStyleDeclaration, type TextLineStyleDeclaration, type TextProp, type TextStyleDeclaration, type TransformStyleDeclaration, type VideoDeclaration, type VideoProp, clearUndef, deepClearUndef, getDefaultElementStyle, getDefaultShadowStyle, getDefaultStyle, getDefaultTextStyle, getDefaultTransformStyle, normalizeElement, normalizeFill, normalizeGeometry, normalizeImage, normalizeOutline, normalizeShadow, normalizeText, normalizeTextContent, normalizeVideo };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(n,
|
|
1
|
+
(function(n,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(n=typeof globalThis<"u"?globalThis:n||self,o(n.modernIdoc={}))})(this,function(n){"use strict";function o(){return{overflow:"visible",alignContent:"stretch",alignItems:"stretch",alignSelf:"auto",borderTop:"none",borderLeft:"none",borderRight:"none",borderBottom:"none",borderWidth:0,border:"none",direction:"inherit",display:"flex",flex:0,flexBasis:"auto",flexDirection:"row",flexGrow:0,flexShrink:1,flexWrap:"nowrap",height:"auto",justifyContent:"flex-start",gap:0,marginTop:0,marginLeft:0,marginRight:0,marginBottom:0,margin:0,maxHeight:0,maxWidth:0,minHeight:0,minWidth:0,paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,padding:0,top:0,bottom:0,left:0,right:0,position:"static",boxSizing:"content-box",width:"auto"}}function u(){return{boxShadow:"none"}}function s(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function g(){return{...s(),...o(),...u(),visibility:"visible",filter:"none",opacity:1,backgroundImage:"none",backgroundColor:"transparent",borderRadius:0,borderColor:"transparent"}}function c(){return{writingMode:"horizontal-tb",verticalAlign:"baseline",lineHeight:1.2,letterSpacing:0,wordSpacing: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%"}}function T(){return{...g(),...c()}}function l(e,r=!1){if(typeof e!="object"||!e)return e;if(Array.isArray(e))return r?e.map(i=>l(i,r)):e;const t={};for(const i in e){const a=e[i];a!=null&&(r?t[i]=l(a,r):t[i]=a)}return t}function v(e){return l(e,!0)}function d(e){if(!(!e||e==="none"))return typeof e=="string"?{type:"color",color:e}:e}function m(e){if(!(!e||e==="none"))return typeof e=="string"?{data:[{data:e}]}:Array.isArray(e)?{data:e.map(r=>typeof r=="string"?{data:r}:r)}:e}function h(e){if(!(!e||e==="none"))return typeof e=="string"?{url:e}:e}function y(e){if(!(!e||e==="none"))return typeof e=="string"?{color:e}:e}function S(e){if(!(!e||e==="none"))return typeof e=="string"?{color:e}:e}function f(e=""){return(Array.isArray(e)?e:[e]).map(t=>typeof t=="string"?{fragments:[{content:t}]}:"content"in t?{fragments:[{...t}]}:"fragments"in t?{...t,fragments:t.fragments.map(i=>({...i}))}:Array.isArray(t)?{fragments:t.map(i=>typeof i=="string"?{content:i}:{...i})}:{fragments:[]})}function p(e){if(!(!e||e==="none"))return typeof e=="string"?{content:[{fragments:[{content:e}]}]}:"content"in e?{...e,content:f(e.content)}:{content:f(e)}}function z(e){if(!(!e||e==="none"))return typeof e=="string"?{url:e}:{...e}}function b(e){var r;return l({...e,image:h(e.image),video:z(e.video),text:p(e.text),geometry:m(e.geometry),fill:d(e.fill),outline:y(e.outline),shadow:S(e.shadow),children:(r=e.children)==null?void 0:r.map(t=>b(t))})}n.clearUndef=l,n.deepClearUndef=v,n.getDefaultElementStyle=g,n.getDefaultShadowStyle=u,n.getDefaultStyle=T,n.getDefaultTextStyle=c,n.getDefaultTransformStyle=s,n.normalizeElement=b,n.normalizeFill=d,n.normalizeGeometry=m,n.normalizeImage=h,n.normalizeOutline=y,n.normalizeShadow=S,n.normalizeText=p,n.normalizeTextContent=f,n.normalizeVideo=z,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
|
package/dist/index.mjs
CHANGED
|
@@ -47,10 +47,6 @@ function getDefaultLayoutStyle() {
|
|
|
47
47
|
|
|
48
48
|
function getDefaultShadowStyle() {
|
|
49
49
|
return {
|
|
50
|
-
shadowColor: "transparent",
|
|
51
|
-
shadowOffsetX: 0,
|
|
52
|
-
shadowOffsetY: 0,
|
|
53
|
-
shadowBlur: 0,
|
|
54
50
|
boxShadow: "none"
|
|
55
51
|
};
|
|
56
52
|
}
|
|
@@ -134,11 +130,41 @@ function getDefaultStyle() {
|
|
|
134
130
|
};
|
|
135
131
|
}
|
|
136
132
|
|
|
133
|
+
function clearUndef(obj, deep = false) {
|
|
134
|
+
if (typeof obj !== "object" || !obj) {
|
|
135
|
+
return obj;
|
|
136
|
+
}
|
|
137
|
+
if (Array.isArray(obj)) {
|
|
138
|
+
if (deep) {
|
|
139
|
+
return obj.map((v) => clearUndef(v, deep));
|
|
140
|
+
} else {
|
|
141
|
+
return obj;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const newObj = {};
|
|
145
|
+
for (const key in obj) {
|
|
146
|
+
const value = obj[key];
|
|
147
|
+
if (value === void 0 || value === null) {
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (deep) {
|
|
151
|
+
newObj[key] = clearUndef(value, deep);
|
|
152
|
+
} else {
|
|
153
|
+
newObj[key] = value;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return newObj;
|
|
157
|
+
}
|
|
158
|
+
function deepClearUndef(obj) {
|
|
159
|
+
return clearUndef(obj, true);
|
|
160
|
+
}
|
|
161
|
+
|
|
137
162
|
function normalizeFill(fill) {
|
|
138
163
|
if (!fill || fill === "none") {
|
|
139
164
|
return void 0;
|
|
140
165
|
} else if (typeof fill === "string") {
|
|
141
166
|
return {
|
|
167
|
+
type: "color",
|
|
142
168
|
color: fill
|
|
143
169
|
};
|
|
144
170
|
} else {
|
|
@@ -183,15 +209,27 @@ function normalizeImage(image) {
|
|
|
183
209
|
}
|
|
184
210
|
}
|
|
185
211
|
|
|
186
|
-
function
|
|
187
|
-
if (!
|
|
212
|
+
function normalizeOutline(outline) {
|
|
213
|
+
if (!outline || outline === "none") {
|
|
188
214
|
return void 0;
|
|
189
|
-
} else if (typeof
|
|
215
|
+
} else if (typeof outline === "string") {
|
|
190
216
|
return {
|
|
191
|
-
color:
|
|
217
|
+
color: outline
|
|
192
218
|
};
|
|
193
219
|
} else {
|
|
194
|
-
return
|
|
220
|
+
return outline;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function normalizeShadow(shadow) {
|
|
225
|
+
if (!shadow || shadow === "none") {
|
|
226
|
+
return void 0;
|
|
227
|
+
} else if (typeof shadow === "string") {
|
|
228
|
+
return {
|
|
229
|
+
color: shadow
|
|
230
|
+
};
|
|
231
|
+
} else {
|
|
232
|
+
return shadow;
|
|
195
233
|
}
|
|
196
234
|
}
|
|
197
235
|
|
|
@@ -275,16 +313,17 @@ function normalizeVideo(video) {
|
|
|
275
313
|
}
|
|
276
314
|
|
|
277
315
|
function normalizeElement(element) {
|
|
278
|
-
return {
|
|
316
|
+
return clearUndef({
|
|
279
317
|
...element,
|
|
280
318
|
image: normalizeImage(element.image),
|
|
281
319
|
video: normalizeVideo(element.video),
|
|
282
320
|
text: normalizeText(element.text),
|
|
283
321
|
geometry: normalizeGeometry(element.geometry),
|
|
284
322
|
fill: normalizeFill(element.fill),
|
|
285
|
-
|
|
323
|
+
outline: normalizeOutline(element.outline),
|
|
324
|
+
shadow: normalizeShadow(element.shadow),
|
|
286
325
|
children: element.children?.map((child) => normalizeElement(child))
|
|
287
|
-
};
|
|
326
|
+
});
|
|
288
327
|
}
|
|
289
328
|
|
|
290
|
-
export { getDefaultElementStyle, getDefaultShadowStyle, getDefaultStyle, getDefaultTextStyle, getDefaultTransformStyle, normalizeElement, normalizeFill, normalizeGeometry, normalizeImage,
|
|
329
|
+
export { clearUndef, deepClearUndef, getDefaultElementStyle, getDefaultShadowStyle, getDefaultStyle, getDefaultTextStyle, getDefaultTransformStyle, normalizeElement, normalizeFill, normalizeGeometry, normalizeImage, normalizeOutline, normalizeShadow, normalizeText, normalizeTextContent, normalizeVideo };
|