modern-idoc 0.1.3 → 0.1.5
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 +33 -41
- package/dist/index.d.cts +16 -12
- package/dist/index.d.mts +16 -12
- package/dist/index.d.ts +16 -12
- package/dist/index.js +1 -1
- package/dist/index.mjs +32 -42
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -1,16 +1,37 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
function
|
|
3
|
+
function getDefaultShadowStyle() {
|
|
4
|
+
return {
|
|
5
|
+
shadowColor: "transparent",
|
|
6
|
+
shadowOffsetX: 0,
|
|
7
|
+
shadowOffsetY: 0,
|
|
8
|
+
shadowBlur: 0
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function getDefaultTransformStyle() {
|
|
4
13
|
return {
|
|
5
|
-
overflow: "visible",
|
|
6
|
-
visibility: "visible",
|
|
7
|
-
filter: "none",
|
|
8
|
-
// position
|
|
9
14
|
left: 0,
|
|
10
15
|
top: 0,
|
|
11
16
|
width: 0,
|
|
12
17
|
height: 0,
|
|
13
18
|
rotate: 0,
|
|
19
|
+
scaleX: 1,
|
|
20
|
+
scaleY: 1,
|
|
21
|
+
skewX: 0,
|
|
22
|
+
skewY: 0,
|
|
23
|
+
translateX: 0,
|
|
24
|
+
translateY: 0,
|
|
25
|
+
transform: "none",
|
|
26
|
+
transformOrigin: "center"
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function getDefaultElementStyle() {
|
|
31
|
+
return {
|
|
32
|
+
overflow: "visible",
|
|
33
|
+
visibility: "visible",
|
|
34
|
+
filter: "none",
|
|
14
35
|
opacity: 1,
|
|
15
36
|
// margin
|
|
16
37
|
marginLeft: 0,
|
|
@@ -23,22 +44,12 @@ function getDefaultElementStyle() {
|
|
|
23
44
|
paddingRight: 0,
|
|
24
45
|
paddingBottom: 0,
|
|
25
46
|
// transform
|
|
26
|
-
|
|
27
|
-
scaleY: 1,
|
|
28
|
-
skewX: 0,
|
|
29
|
-
skewY: 0,
|
|
30
|
-
translateX: 0,
|
|
31
|
-
translateY: 0,
|
|
32
|
-
transform: "none",
|
|
33
|
-
transformOrigin: "50% 50%",
|
|
47
|
+
...getDefaultTransformStyle(),
|
|
34
48
|
// background
|
|
35
49
|
backgroundImage: "none",
|
|
36
50
|
backgroundColor: "transparent",
|
|
37
51
|
// shadow
|
|
38
|
-
|
|
39
|
-
shadowOffsetX: 0,
|
|
40
|
-
shadowOffsetY: 0,
|
|
41
|
-
shadowBlur: 0,
|
|
52
|
+
...getDefaultShadowStyle(),
|
|
42
53
|
// border
|
|
43
54
|
borderRadius: 0,
|
|
44
55
|
borderColor: "transparent",
|
|
@@ -83,21 +94,7 @@ function getDefaultTextStyle() {
|
|
|
83
94
|
highlightColormap: "none",
|
|
84
95
|
highlightLine: "none",
|
|
85
96
|
highlightSize: "cover",
|
|
86
|
-
highlightThickness: "100%"
|
|
87
|
-
// transform
|
|
88
|
-
scaleX: 1,
|
|
89
|
-
scaleY: 1,
|
|
90
|
-
skewX: 0,
|
|
91
|
-
skewY: 0,
|
|
92
|
-
translateX: 0,
|
|
93
|
-
translateY: 0,
|
|
94
|
-
transform: "none",
|
|
95
|
-
transformOrigin: "50% 50%",
|
|
96
|
-
// shadow
|
|
97
|
-
shadowColor: "transparent",
|
|
98
|
-
shadowOffsetX: 0,
|
|
99
|
-
shadowOffsetY: 0,
|
|
100
|
-
shadowBlur: 0
|
|
97
|
+
highlightThickness: "100%"
|
|
101
98
|
};
|
|
102
99
|
}
|
|
103
100
|
|
|
@@ -132,15 +129,6 @@ function normalizeGeometry(geometry) {
|
|
|
132
129
|
} else if (Array.isArray(geometry)) {
|
|
133
130
|
return {
|
|
134
131
|
data: geometry.map((data) => {
|
|
135
|
-
return {
|
|
136
|
-
data
|
|
137
|
-
};
|
|
138
|
-
})
|
|
139
|
-
};
|
|
140
|
-
} else {
|
|
141
|
-
return {
|
|
142
|
-
...geometry,
|
|
143
|
-
data: geometry.data.map((data) => {
|
|
144
132
|
if (typeof data === "string") {
|
|
145
133
|
return {
|
|
146
134
|
data
|
|
@@ -149,6 +137,8 @@ function normalizeGeometry(geometry) {
|
|
|
149
137
|
return data;
|
|
150
138
|
})
|
|
151
139
|
};
|
|
140
|
+
} else {
|
|
141
|
+
return geometry;
|
|
152
142
|
}
|
|
153
143
|
}
|
|
154
144
|
|
|
@@ -269,8 +259,10 @@ function normalizeElement(element) {
|
|
|
269
259
|
}
|
|
270
260
|
|
|
271
261
|
exports.getDefaultElementStyle = getDefaultElementStyle;
|
|
262
|
+
exports.getDefaultShadowStyle = getDefaultShadowStyle;
|
|
272
263
|
exports.getDefaultStyle = getDefaultStyle;
|
|
273
264
|
exports.getDefaultTextStyle = getDefaultTextStyle;
|
|
265
|
+
exports.getDefaultTransformStyle = getDefaultTransformStyle;
|
|
274
266
|
exports.normalizeElement = normalizeElement;
|
|
275
267
|
exports.normalizeFill = normalizeFill;
|
|
276
268
|
exports.normalizeGeometry = normalizeGeometry;
|
package/dist/index.d.cts
CHANGED
|
@@ -37,10 +37,10 @@ interface IDOCPath2D extends Partial<IDOCPath2DStyle> {
|
|
|
37
37
|
data: SVGPathData;
|
|
38
38
|
}
|
|
39
39
|
interface IDOCGeometryDeclaration {
|
|
40
|
-
data:
|
|
40
|
+
data: IDOCPath2D[];
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
type IDOCGeometryProp = Noneable | SVGPathData | SVGPathData[] | IDOCGeometryDeclaration;
|
|
43
|
+
type IDOCGeometryProp = Noneable | SVGPathData | SVGPathData[] | IDOCPath2D[] | IDOCGeometryDeclaration;
|
|
44
44
|
|
|
45
45
|
interface IDOCImageDeclaration {
|
|
46
46
|
url: string;
|
|
@@ -76,7 +76,7 @@ type TextWrap = 'wrap' | 'nowrap';
|
|
|
76
76
|
type TextAlign = 'center' | 'end' | 'left' | 'right' | 'start';
|
|
77
77
|
type TextTransform = Noneable | 'uppercase' | 'lowercase';
|
|
78
78
|
type TextOrientation = 'mixed' | 'upright' | 'sideways-right' | 'sideways';
|
|
79
|
-
type
|
|
79
|
+
type TextDecoration = Noneable | 'underline' | 'line-through' | 'overline';
|
|
80
80
|
type VerticalAlign = 'baseline' | 'top' | 'middle' | 'bottom' | 'sub' | 'super' | 'text-top' | 'text-bottom';
|
|
81
81
|
type WritingMode = 'horizontal-tb' | 'vertical-lr' | 'vertical-rl';
|
|
82
82
|
type ListStyleType = Noneable | 'disc';
|
|
@@ -99,7 +99,7 @@ interface IDOCListStyleStyleDeclaration {
|
|
|
99
99
|
listStyleSize: ListStyleSize;
|
|
100
100
|
listStylePosition: ListStylePosition;
|
|
101
101
|
}
|
|
102
|
-
type HighlightLine =
|
|
102
|
+
type HighlightLine = TextDecoration | 'outline';
|
|
103
103
|
type HighlightImage = Noneable | string;
|
|
104
104
|
type HighlightReferImage = Noneable | string;
|
|
105
105
|
type HighlightColormap = Noneable | Record<string, string>;
|
|
@@ -136,6 +136,11 @@ interface IDOCShadowStyleDeclaration {
|
|
|
136
136
|
shadowBlur: number;
|
|
137
137
|
}
|
|
138
138
|
interface IDOCTransformStyleDeclaration {
|
|
139
|
+
left: number;
|
|
140
|
+
top: number;
|
|
141
|
+
width: number;
|
|
142
|
+
height: number;
|
|
143
|
+
rotate: number;
|
|
139
144
|
scaleX: number;
|
|
140
145
|
scaleY: number;
|
|
141
146
|
skewX: number;
|
|
@@ -164,9 +169,9 @@ interface IDOCTextInlineStyleDeclaration extends IDOCHighlightStyleDeclaration {
|
|
|
164
169
|
fontKerning: FontKerning;
|
|
165
170
|
textTransform: TextTransform;
|
|
166
171
|
textOrientation: TextOrientation;
|
|
167
|
-
textDecoration:
|
|
172
|
+
textDecoration: TextDecoration;
|
|
168
173
|
}
|
|
169
|
-
interface IDOCTextDrawStyleDeclaration
|
|
174
|
+
interface IDOCTextDrawStyleDeclaration {
|
|
170
175
|
textStrokeWidth: number;
|
|
171
176
|
textStrokeColor: string;
|
|
172
177
|
}
|
|
@@ -176,11 +181,6 @@ interface IDOCElementStyleDeclaration extends IDOCShadowStyleDeclaration, IDOCTr
|
|
|
176
181
|
overflow: Overflow;
|
|
177
182
|
visibility: Visibility;
|
|
178
183
|
filter: string;
|
|
179
|
-
left: number;
|
|
180
|
-
top: number;
|
|
181
|
-
width: number;
|
|
182
|
-
height: number;
|
|
183
|
-
rotate: number;
|
|
184
184
|
opacity: number;
|
|
185
185
|
marginLeft: number;
|
|
186
186
|
marginTop: number;
|
|
@@ -255,10 +255,14 @@ interface IDOCElementDeclaration extends IDOCElement {
|
|
|
255
255
|
|
|
256
256
|
declare function getDefaultElementStyle(): IDOCElementStyleDeclaration;
|
|
257
257
|
|
|
258
|
+
declare function getDefaultShadowStyle(): IDOCShadowStyleDeclaration;
|
|
259
|
+
|
|
258
260
|
declare function getDefaultStyle(): IDOCStyleDeclaration;
|
|
259
261
|
|
|
260
262
|
declare function getDefaultTextStyle(): IDOCTextStyleDeclaration;
|
|
261
263
|
|
|
264
|
+
declare function getDefaultTransformStyle(): IDOCTransformStyleDeclaration;
|
|
265
|
+
|
|
262
266
|
declare function normalizeElement(element: IDOCElement): IDOCElementDeclaration;
|
|
263
267
|
|
|
264
268
|
declare function normalizeFill(fill?: IDOCFillProp): IDOCFillDeclaration | undefined;
|
|
@@ -275,4 +279,4 @@ declare function normalizeTextContent(content?: IDOCTextContent): IDOCTextConten
|
|
|
275
279
|
|
|
276
280
|
declare function normalizeVideo(video?: IDOCVideoProp): IDOCVideoDeclaration | undefined;
|
|
277
281
|
|
|
278
|
-
export { type FillRule, type FontKerning, type FontStyle, type FontWeight, type HighlightColormap, type HighlightImage, type HighlightLine, type HighlightReferImage, type HighlightSize, type HighlightThickness, type IDCOShadowDeclaration, type IDOCDocument, type IDOCElement, type IDOCElementDeclaration, type IDOCElementStyleDeclaration, type IDOCFillDeclaration, type IDOCFillProp, type IDOCFragmentContent, type IDOCGeometryDeclaration, type IDOCGeometryProp, type IDOCHighlightDeclaration, type IDOCHighlightStyleDeclaration, type IDOCImageDeclaration, type IDOCImageProp, type IDOCListStyleDeclaration, type IDOCListStyleStyleDeclaration, type IDOCMetaProp, type IDOCNode, type IDOCParagraphContent, type IDOCPath2D, type IDOCPath2DStyle, type IDOCShadowStyleDeclaration, type IDOCStrokeDeclaration, type IDOCStrokeProp, type IDOCStyleDeclaration, type IDOCStyleProp, type IDOCTextContent, type IDOCTextContentDeclaration, type IDOCTextContentFlat, type IDOCTextDeclaration, type IDOCTextDrawStyleDeclaration, type IDOCTextInlineStyleDeclaration, type IDOCTextLineStyleDeclaration, type IDOCTextProp, type IDOCTextStyleDeclaration, type IDOCTransformStyleDeclaration, type IDOCVideoDeclaration, type IDOCVideoProp, type ListStyleColormap, type ListStyleImage, type ListStylePosition, type ListStyleSize, type ListStyleType, type Overflow, type SVGPathData, type StrokeLinecap, type StrokeLinejoin, type TextAlign, type
|
|
282
|
+
export { type FillRule, type FontKerning, type FontStyle, type FontWeight, type HighlightColormap, type HighlightImage, type HighlightLine, type HighlightReferImage, type HighlightSize, type HighlightThickness, type IDCOShadowDeclaration, type IDOCDocument, type IDOCElement, type IDOCElementDeclaration, type IDOCElementStyleDeclaration, type IDOCFillDeclaration, type IDOCFillProp, type IDOCFragmentContent, type IDOCGeometryDeclaration, type IDOCGeometryProp, type IDOCHighlightDeclaration, type IDOCHighlightStyleDeclaration, type IDOCImageDeclaration, type IDOCImageProp, type IDOCListStyleDeclaration, type IDOCListStyleStyleDeclaration, type IDOCMetaProp, type IDOCNode, type IDOCParagraphContent, type IDOCPath2D, type IDOCPath2DStyle, type IDOCShadowStyleDeclaration, type IDOCStrokeDeclaration, type IDOCStrokeProp, type IDOCStyleDeclaration, type IDOCStyleProp, type IDOCTextContent, type IDOCTextContentDeclaration, type IDOCTextContentFlat, type IDOCTextDeclaration, type IDOCTextDrawStyleDeclaration, type IDOCTextInlineStyleDeclaration, type IDOCTextLineStyleDeclaration, type IDOCTextProp, type IDOCTextStyleDeclaration, type IDOCTransformStyleDeclaration, type IDOCVideoDeclaration, type IDOCVideoProp, type ListStyleColormap, type ListStyleImage, type ListStylePosition, type ListStyleSize, type ListStyleType, type Overflow, type SVGPathData, type StrokeLinecap, type StrokeLinejoin, type TextAlign, type TextDecoration, type TextOrientation, type TextTransform, type TextWrap, type VerticalAlign, type Visibility, type WritingMode, getDefaultElementStyle, getDefaultShadowStyle, getDefaultStyle, getDefaultTextStyle, getDefaultTransformStyle, normalizeElement, normalizeFill, normalizeGeometry, normalizeImage, normalizeStroke, normalizeText, normalizeTextContent, normalizeVideo };
|
package/dist/index.d.mts
CHANGED
|
@@ -37,10 +37,10 @@ interface IDOCPath2D extends Partial<IDOCPath2DStyle> {
|
|
|
37
37
|
data: SVGPathData;
|
|
38
38
|
}
|
|
39
39
|
interface IDOCGeometryDeclaration {
|
|
40
|
-
data:
|
|
40
|
+
data: IDOCPath2D[];
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
type IDOCGeometryProp = Noneable | SVGPathData | SVGPathData[] | IDOCGeometryDeclaration;
|
|
43
|
+
type IDOCGeometryProp = Noneable | SVGPathData | SVGPathData[] | IDOCPath2D[] | IDOCGeometryDeclaration;
|
|
44
44
|
|
|
45
45
|
interface IDOCImageDeclaration {
|
|
46
46
|
url: string;
|
|
@@ -76,7 +76,7 @@ type TextWrap = 'wrap' | 'nowrap';
|
|
|
76
76
|
type TextAlign = 'center' | 'end' | 'left' | 'right' | 'start';
|
|
77
77
|
type TextTransform = Noneable | 'uppercase' | 'lowercase';
|
|
78
78
|
type TextOrientation = 'mixed' | 'upright' | 'sideways-right' | 'sideways';
|
|
79
|
-
type
|
|
79
|
+
type TextDecoration = Noneable | 'underline' | 'line-through' | 'overline';
|
|
80
80
|
type VerticalAlign = 'baseline' | 'top' | 'middle' | 'bottom' | 'sub' | 'super' | 'text-top' | 'text-bottom';
|
|
81
81
|
type WritingMode = 'horizontal-tb' | 'vertical-lr' | 'vertical-rl';
|
|
82
82
|
type ListStyleType = Noneable | 'disc';
|
|
@@ -99,7 +99,7 @@ interface IDOCListStyleStyleDeclaration {
|
|
|
99
99
|
listStyleSize: ListStyleSize;
|
|
100
100
|
listStylePosition: ListStylePosition;
|
|
101
101
|
}
|
|
102
|
-
type HighlightLine =
|
|
102
|
+
type HighlightLine = TextDecoration | 'outline';
|
|
103
103
|
type HighlightImage = Noneable | string;
|
|
104
104
|
type HighlightReferImage = Noneable | string;
|
|
105
105
|
type HighlightColormap = Noneable | Record<string, string>;
|
|
@@ -136,6 +136,11 @@ interface IDOCShadowStyleDeclaration {
|
|
|
136
136
|
shadowBlur: number;
|
|
137
137
|
}
|
|
138
138
|
interface IDOCTransformStyleDeclaration {
|
|
139
|
+
left: number;
|
|
140
|
+
top: number;
|
|
141
|
+
width: number;
|
|
142
|
+
height: number;
|
|
143
|
+
rotate: number;
|
|
139
144
|
scaleX: number;
|
|
140
145
|
scaleY: number;
|
|
141
146
|
skewX: number;
|
|
@@ -164,9 +169,9 @@ interface IDOCTextInlineStyleDeclaration extends IDOCHighlightStyleDeclaration {
|
|
|
164
169
|
fontKerning: FontKerning;
|
|
165
170
|
textTransform: TextTransform;
|
|
166
171
|
textOrientation: TextOrientation;
|
|
167
|
-
textDecoration:
|
|
172
|
+
textDecoration: TextDecoration;
|
|
168
173
|
}
|
|
169
|
-
interface IDOCTextDrawStyleDeclaration
|
|
174
|
+
interface IDOCTextDrawStyleDeclaration {
|
|
170
175
|
textStrokeWidth: number;
|
|
171
176
|
textStrokeColor: string;
|
|
172
177
|
}
|
|
@@ -176,11 +181,6 @@ interface IDOCElementStyleDeclaration extends IDOCShadowStyleDeclaration, IDOCTr
|
|
|
176
181
|
overflow: Overflow;
|
|
177
182
|
visibility: Visibility;
|
|
178
183
|
filter: string;
|
|
179
|
-
left: number;
|
|
180
|
-
top: number;
|
|
181
|
-
width: number;
|
|
182
|
-
height: number;
|
|
183
|
-
rotate: number;
|
|
184
184
|
opacity: number;
|
|
185
185
|
marginLeft: number;
|
|
186
186
|
marginTop: number;
|
|
@@ -255,10 +255,14 @@ interface IDOCElementDeclaration extends IDOCElement {
|
|
|
255
255
|
|
|
256
256
|
declare function getDefaultElementStyle(): IDOCElementStyleDeclaration;
|
|
257
257
|
|
|
258
|
+
declare function getDefaultShadowStyle(): IDOCShadowStyleDeclaration;
|
|
259
|
+
|
|
258
260
|
declare function getDefaultStyle(): IDOCStyleDeclaration;
|
|
259
261
|
|
|
260
262
|
declare function getDefaultTextStyle(): IDOCTextStyleDeclaration;
|
|
261
263
|
|
|
264
|
+
declare function getDefaultTransformStyle(): IDOCTransformStyleDeclaration;
|
|
265
|
+
|
|
262
266
|
declare function normalizeElement(element: IDOCElement): IDOCElementDeclaration;
|
|
263
267
|
|
|
264
268
|
declare function normalizeFill(fill?: IDOCFillProp): IDOCFillDeclaration | undefined;
|
|
@@ -275,4 +279,4 @@ declare function normalizeTextContent(content?: IDOCTextContent): IDOCTextConten
|
|
|
275
279
|
|
|
276
280
|
declare function normalizeVideo(video?: IDOCVideoProp): IDOCVideoDeclaration | undefined;
|
|
277
281
|
|
|
278
|
-
export { type FillRule, type FontKerning, type FontStyle, type FontWeight, type HighlightColormap, type HighlightImage, type HighlightLine, type HighlightReferImage, type HighlightSize, type HighlightThickness, type IDCOShadowDeclaration, type IDOCDocument, type IDOCElement, type IDOCElementDeclaration, type IDOCElementStyleDeclaration, type IDOCFillDeclaration, type IDOCFillProp, type IDOCFragmentContent, type IDOCGeometryDeclaration, type IDOCGeometryProp, type IDOCHighlightDeclaration, type IDOCHighlightStyleDeclaration, type IDOCImageDeclaration, type IDOCImageProp, type IDOCListStyleDeclaration, type IDOCListStyleStyleDeclaration, type IDOCMetaProp, type IDOCNode, type IDOCParagraphContent, type IDOCPath2D, type IDOCPath2DStyle, type IDOCShadowStyleDeclaration, type IDOCStrokeDeclaration, type IDOCStrokeProp, type IDOCStyleDeclaration, type IDOCStyleProp, type IDOCTextContent, type IDOCTextContentDeclaration, type IDOCTextContentFlat, type IDOCTextDeclaration, type IDOCTextDrawStyleDeclaration, type IDOCTextInlineStyleDeclaration, type IDOCTextLineStyleDeclaration, type IDOCTextProp, type IDOCTextStyleDeclaration, type IDOCTransformStyleDeclaration, type IDOCVideoDeclaration, type IDOCVideoProp, type ListStyleColormap, type ListStyleImage, type ListStylePosition, type ListStyleSize, type ListStyleType, type Overflow, type SVGPathData, type StrokeLinecap, type StrokeLinejoin, type TextAlign, type
|
|
282
|
+
export { type FillRule, type FontKerning, type FontStyle, type FontWeight, type HighlightColormap, type HighlightImage, type HighlightLine, type HighlightReferImage, type HighlightSize, type HighlightThickness, type IDCOShadowDeclaration, type IDOCDocument, type IDOCElement, type IDOCElementDeclaration, type IDOCElementStyleDeclaration, type IDOCFillDeclaration, type IDOCFillProp, type IDOCFragmentContent, type IDOCGeometryDeclaration, type IDOCGeometryProp, type IDOCHighlightDeclaration, type IDOCHighlightStyleDeclaration, type IDOCImageDeclaration, type IDOCImageProp, type IDOCListStyleDeclaration, type IDOCListStyleStyleDeclaration, type IDOCMetaProp, type IDOCNode, type IDOCParagraphContent, type IDOCPath2D, type IDOCPath2DStyle, type IDOCShadowStyleDeclaration, type IDOCStrokeDeclaration, type IDOCStrokeProp, type IDOCStyleDeclaration, type IDOCStyleProp, type IDOCTextContent, type IDOCTextContentDeclaration, type IDOCTextContentFlat, type IDOCTextDeclaration, type IDOCTextDrawStyleDeclaration, type IDOCTextInlineStyleDeclaration, type IDOCTextLineStyleDeclaration, type IDOCTextProp, type IDOCTextStyleDeclaration, type IDOCTransformStyleDeclaration, type IDOCVideoDeclaration, type IDOCVideoProp, type ListStyleColormap, type ListStyleImage, type ListStylePosition, type ListStyleSize, type ListStyleType, type Overflow, type SVGPathData, type StrokeLinecap, type StrokeLinejoin, type TextAlign, type TextDecoration, type TextOrientation, type TextTransform, type TextWrap, type VerticalAlign, type Visibility, type WritingMode, getDefaultElementStyle, getDefaultShadowStyle, getDefaultStyle, getDefaultTextStyle, getDefaultTransformStyle, normalizeElement, normalizeFill, normalizeGeometry, normalizeImage, normalizeStroke, normalizeText, normalizeTextContent, normalizeVideo };
|
package/dist/index.d.ts
CHANGED
|
@@ -37,10 +37,10 @@ interface IDOCPath2D extends Partial<IDOCPath2DStyle> {
|
|
|
37
37
|
data: SVGPathData;
|
|
38
38
|
}
|
|
39
39
|
interface IDOCGeometryDeclaration {
|
|
40
|
-
data:
|
|
40
|
+
data: IDOCPath2D[];
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
type IDOCGeometryProp = Noneable | SVGPathData | SVGPathData[] | IDOCGeometryDeclaration;
|
|
43
|
+
type IDOCGeometryProp = Noneable | SVGPathData | SVGPathData[] | IDOCPath2D[] | IDOCGeometryDeclaration;
|
|
44
44
|
|
|
45
45
|
interface IDOCImageDeclaration {
|
|
46
46
|
url: string;
|
|
@@ -76,7 +76,7 @@ type TextWrap = 'wrap' | 'nowrap';
|
|
|
76
76
|
type TextAlign = 'center' | 'end' | 'left' | 'right' | 'start';
|
|
77
77
|
type TextTransform = Noneable | 'uppercase' | 'lowercase';
|
|
78
78
|
type TextOrientation = 'mixed' | 'upright' | 'sideways-right' | 'sideways';
|
|
79
|
-
type
|
|
79
|
+
type TextDecoration = Noneable | 'underline' | 'line-through' | 'overline';
|
|
80
80
|
type VerticalAlign = 'baseline' | 'top' | 'middle' | 'bottom' | 'sub' | 'super' | 'text-top' | 'text-bottom';
|
|
81
81
|
type WritingMode = 'horizontal-tb' | 'vertical-lr' | 'vertical-rl';
|
|
82
82
|
type ListStyleType = Noneable | 'disc';
|
|
@@ -99,7 +99,7 @@ interface IDOCListStyleStyleDeclaration {
|
|
|
99
99
|
listStyleSize: ListStyleSize;
|
|
100
100
|
listStylePosition: ListStylePosition;
|
|
101
101
|
}
|
|
102
|
-
type HighlightLine =
|
|
102
|
+
type HighlightLine = TextDecoration | 'outline';
|
|
103
103
|
type HighlightImage = Noneable | string;
|
|
104
104
|
type HighlightReferImage = Noneable | string;
|
|
105
105
|
type HighlightColormap = Noneable | Record<string, string>;
|
|
@@ -136,6 +136,11 @@ interface IDOCShadowStyleDeclaration {
|
|
|
136
136
|
shadowBlur: number;
|
|
137
137
|
}
|
|
138
138
|
interface IDOCTransformStyleDeclaration {
|
|
139
|
+
left: number;
|
|
140
|
+
top: number;
|
|
141
|
+
width: number;
|
|
142
|
+
height: number;
|
|
143
|
+
rotate: number;
|
|
139
144
|
scaleX: number;
|
|
140
145
|
scaleY: number;
|
|
141
146
|
skewX: number;
|
|
@@ -164,9 +169,9 @@ interface IDOCTextInlineStyleDeclaration extends IDOCHighlightStyleDeclaration {
|
|
|
164
169
|
fontKerning: FontKerning;
|
|
165
170
|
textTransform: TextTransform;
|
|
166
171
|
textOrientation: TextOrientation;
|
|
167
|
-
textDecoration:
|
|
172
|
+
textDecoration: TextDecoration;
|
|
168
173
|
}
|
|
169
|
-
interface IDOCTextDrawStyleDeclaration
|
|
174
|
+
interface IDOCTextDrawStyleDeclaration {
|
|
170
175
|
textStrokeWidth: number;
|
|
171
176
|
textStrokeColor: string;
|
|
172
177
|
}
|
|
@@ -176,11 +181,6 @@ interface IDOCElementStyleDeclaration extends IDOCShadowStyleDeclaration, IDOCTr
|
|
|
176
181
|
overflow: Overflow;
|
|
177
182
|
visibility: Visibility;
|
|
178
183
|
filter: string;
|
|
179
|
-
left: number;
|
|
180
|
-
top: number;
|
|
181
|
-
width: number;
|
|
182
|
-
height: number;
|
|
183
|
-
rotate: number;
|
|
184
184
|
opacity: number;
|
|
185
185
|
marginLeft: number;
|
|
186
186
|
marginTop: number;
|
|
@@ -255,10 +255,14 @@ interface IDOCElementDeclaration extends IDOCElement {
|
|
|
255
255
|
|
|
256
256
|
declare function getDefaultElementStyle(): IDOCElementStyleDeclaration;
|
|
257
257
|
|
|
258
|
+
declare function getDefaultShadowStyle(): IDOCShadowStyleDeclaration;
|
|
259
|
+
|
|
258
260
|
declare function getDefaultStyle(): IDOCStyleDeclaration;
|
|
259
261
|
|
|
260
262
|
declare function getDefaultTextStyle(): IDOCTextStyleDeclaration;
|
|
261
263
|
|
|
264
|
+
declare function getDefaultTransformStyle(): IDOCTransformStyleDeclaration;
|
|
265
|
+
|
|
262
266
|
declare function normalizeElement(element: IDOCElement): IDOCElementDeclaration;
|
|
263
267
|
|
|
264
268
|
declare function normalizeFill(fill?: IDOCFillProp): IDOCFillDeclaration | undefined;
|
|
@@ -275,4 +279,4 @@ declare function normalizeTextContent(content?: IDOCTextContent): IDOCTextConten
|
|
|
275
279
|
|
|
276
280
|
declare function normalizeVideo(video?: IDOCVideoProp): IDOCVideoDeclaration | undefined;
|
|
277
281
|
|
|
278
|
-
export { type FillRule, type FontKerning, type FontStyle, type FontWeight, type HighlightColormap, type HighlightImage, type HighlightLine, type HighlightReferImage, type HighlightSize, type HighlightThickness, type IDCOShadowDeclaration, type IDOCDocument, type IDOCElement, type IDOCElementDeclaration, type IDOCElementStyleDeclaration, type IDOCFillDeclaration, type IDOCFillProp, type IDOCFragmentContent, type IDOCGeometryDeclaration, type IDOCGeometryProp, type IDOCHighlightDeclaration, type IDOCHighlightStyleDeclaration, type IDOCImageDeclaration, type IDOCImageProp, type IDOCListStyleDeclaration, type IDOCListStyleStyleDeclaration, type IDOCMetaProp, type IDOCNode, type IDOCParagraphContent, type IDOCPath2D, type IDOCPath2DStyle, type IDOCShadowStyleDeclaration, type IDOCStrokeDeclaration, type IDOCStrokeProp, type IDOCStyleDeclaration, type IDOCStyleProp, type IDOCTextContent, type IDOCTextContentDeclaration, type IDOCTextContentFlat, type IDOCTextDeclaration, type IDOCTextDrawStyleDeclaration, type IDOCTextInlineStyleDeclaration, type IDOCTextLineStyleDeclaration, type IDOCTextProp, type IDOCTextStyleDeclaration, type IDOCTransformStyleDeclaration, type IDOCVideoDeclaration, type IDOCVideoProp, type ListStyleColormap, type ListStyleImage, type ListStylePosition, type ListStyleSize, type ListStyleType, type Overflow, type SVGPathData, type StrokeLinecap, type StrokeLinejoin, type TextAlign, type
|
|
282
|
+
export { type FillRule, type FontKerning, type FontStyle, type FontWeight, type HighlightColormap, type HighlightImage, type HighlightLine, type HighlightReferImage, type HighlightSize, type HighlightThickness, type IDCOShadowDeclaration, type IDOCDocument, type IDOCElement, type IDOCElementDeclaration, type IDOCElementStyleDeclaration, type IDOCFillDeclaration, type IDOCFillProp, type IDOCFragmentContent, type IDOCGeometryDeclaration, type IDOCGeometryProp, type IDOCHighlightDeclaration, type IDOCHighlightStyleDeclaration, type IDOCImageDeclaration, type IDOCImageProp, type IDOCListStyleDeclaration, type IDOCListStyleStyleDeclaration, type IDOCMetaProp, type IDOCNode, type IDOCParagraphContent, type IDOCPath2D, type IDOCPath2DStyle, type IDOCShadowStyleDeclaration, type IDOCStrokeDeclaration, type IDOCStrokeProp, type IDOCStyleDeclaration, type IDOCStyleProp, type IDOCTextContent, type IDOCTextContentDeclaration, type IDOCTextContentFlat, type IDOCTextDeclaration, type IDOCTextDrawStyleDeclaration, type IDOCTextInlineStyleDeclaration, type IDOCTextLineStyleDeclaration, type IDOCTextProp, type IDOCTextStyleDeclaration, type IDOCTransformStyleDeclaration, type IDOCVideoDeclaration, type IDOCVideoProp, type ListStyleColormap, type ListStyleImage, type ListStylePosition, type ListStyleSize, type ListStyleType, type Overflow, type SVGPathData, type StrokeLinecap, type StrokeLinejoin, type TextAlign, type TextDecoration, type TextOrientation, type TextTransform, type TextWrap, type VerticalAlign, type Visibility, type WritingMode, getDefaultElementStyle, getDefaultShadowStyle, getDefaultStyle, getDefaultTextStyle, getDefaultTransformStyle, normalizeElement, normalizeFill, normalizeGeometry, normalizeImage, normalizeStroke, normalizeText, normalizeTextContent, normalizeVideo };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(n,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(n=typeof globalThis<"u"?globalThis:n||self,i(n.modernIdoc={}))})(this,function(n){"use strict";function i(){return{
|
|
1
|
+
(function(n,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(n=typeof globalThis<"u"?globalThis:n||self,i(n.modernIdoc={}))})(this,function(n){"use strict";function i(){return{shadowColor:"transparent",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0}}function a(){return{left:0,top:0,width:0,height:0,rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function f(){return{overflow:"visible",visibility:"visible",filter:"none",opacity:1,marginLeft:0,marginTop:0,marginRight:0,marginBottom:0,paddingLeft:0,paddingTop:0,paddingRight:0,paddingBottom:0,...a(),backgroundImage:"none",backgroundColor:"transparent",...i(),borderRadius:0,borderColor:"transparent",borderWidth:1}}function u(){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 S(){return{...f(),...u()}}function s(e){if(!(!e||e==="none"))return typeof e=="string"?{color:e}:e}function g(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 d(e){if(!(!e||e==="none"))return typeof e=="string"?{url:e}:e}function m(e){if(!(!e||e==="none"))return typeof e=="string"?{color:e}:e}function l(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(o=>({...o}))}:Array.isArray(t)?{fragments:t.map(o=>typeof o=="string"?{content:o}:{...o})}:{fragments:[]})}function c(e){if(!(!e||e==="none"))return typeof e=="string"?{content:[{fragments:[{content:e}]}]}:"content"in e?{...e,content:l(e.content)}:{content:l(e)}}function h(e){if(!(!e||e==="none"))return typeof e=="string"?{url:e}:{...e}}function y(e){var r;return{...e,image:d(e.image),video:h(e.video),text:c(e.text),geometry:g(e.geometry),fill:s(e.fill),stroke:m(e.stroke),children:(r=e.children)==null?void 0:r.map(t=>y(t))}}n.getDefaultElementStyle=f,n.getDefaultShadowStyle=i,n.getDefaultStyle=S,n.getDefaultTextStyle=u,n.getDefaultTransformStyle=a,n.normalizeElement=y,n.normalizeFill=s,n.normalizeGeometry=g,n.normalizeImage=d,n.normalizeStroke=m,n.normalizeText=c,n.normalizeTextContent=l,n.normalizeVideo=h,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,35 @@
|
|
|
1
|
-
function
|
|
1
|
+
function getDefaultShadowStyle() {
|
|
2
|
+
return {
|
|
3
|
+
shadowColor: "transparent",
|
|
4
|
+
shadowOffsetX: 0,
|
|
5
|
+
shadowOffsetY: 0,
|
|
6
|
+
shadowBlur: 0
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function getDefaultTransformStyle() {
|
|
2
11
|
return {
|
|
3
|
-
overflow: "visible",
|
|
4
|
-
visibility: "visible",
|
|
5
|
-
filter: "none",
|
|
6
|
-
// position
|
|
7
12
|
left: 0,
|
|
8
13
|
top: 0,
|
|
9
14
|
width: 0,
|
|
10
15
|
height: 0,
|
|
11
16
|
rotate: 0,
|
|
17
|
+
scaleX: 1,
|
|
18
|
+
scaleY: 1,
|
|
19
|
+
skewX: 0,
|
|
20
|
+
skewY: 0,
|
|
21
|
+
translateX: 0,
|
|
22
|
+
translateY: 0,
|
|
23
|
+
transform: "none",
|
|
24
|
+
transformOrigin: "center"
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getDefaultElementStyle() {
|
|
29
|
+
return {
|
|
30
|
+
overflow: "visible",
|
|
31
|
+
visibility: "visible",
|
|
32
|
+
filter: "none",
|
|
12
33
|
opacity: 1,
|
|
13
34
|
// margin
|
|
14
35
|
marginLeft: 0,
|
|
@@ -21,22 +42,12 @@ function getDefaultElementStyle() {
|
|
|
21
42
|
paddingRight: 0,
|
|
22
43
|
paddingBottom: 0,
|
|
23
44
|
// transform
|
|
24
|
-
|
|
25
|
-
scaleY: 1,
|
|
26
|
-
skewX: 0,
|
|
27
|
-
skewY: 0,
|
|
28
|
-
translateX: 0,
|
|
29
|
-
translateY: 0,
|
|
30
|
-
transform: "none",
|
|
31
|
-
transformOrigin: "50% 50%",
|
|
45
|
+
...getDefaultTransformStyle(),
|
|
32
46
|
// background
|
|
33
47
|
backgroundImage: "none",
|
|
34
48
|
backgroundColor: "transparent",
|
|
35
49
|
// shadow
|
|
36
|
-
|
|
37
|
-
shadowOffsetX: 0,
|
|
38
|
-
shadowOffsetY: 0,
|
|
39
|
-
shadowBlur: 0,
|
|
50
|
+
...getDefaultShadowStyle(),
|
|
40
51
|
// border
|
|
41
52
|
borderRadius: 0,
|
|
42
53
|
borderColor: "transparent",
|
|
@@ -81,21 +92,7 @@ function getDefaultTextStyle() {
|
|
|
81
92
|
highlightColormap: "none",
|
|
82
93
|
highlightLine: "none",
|
|
83
94
|
highlightSize: "cover",
|
|
84
|
-
highlightThickness: "100%"
|
|
85
|
-
// transform
|
|
86
|
-
scaleX: 1,
|
|
87
|
-
scaleY: 1,
|
|
88
|
-
skewX: 0,
|
|
89
|
-
skewY: 0,
|
|
90
|
-
translateX: 0,
|
|
91
|
-
translateY: 0,
|
|
92
|
-
transform: "none",
|
|
93
|
-
transformOrigin: "50% 50%",
|
|
94
|
-
// shadow
|
|
95
|
-
shadowColor: "transparent",
|
|
96
|
-
shadowOffsetX: 0,
|
|
97
|
-
shadowOffsetY: 0,
|
|
98
|
-
shadowBlur: 0
|
|
95
|
+
highlightThickness: "100%"
|
|
99
96
|
};
|
|
100
97
|
}
|
|
101
98
|
|
|
@@ -130,15 +127,6 @@ function normalizeGeometry(geometry) {
|
|
|
130
127
|
} else if (Array.isArray(geometry)) {
|
|
131
128
|
return {
|
|
132
129
|
data: geometry.map((data) => {
|
|
133
|
-
return {
|
|
134
|
-
data
|
|
135
|
-
};
|
|
136
|
-
})
|
|
137
|
-
};
|
|
138
|
-
} else {
|
|
139
|
-
return {
|
|
140
|
-
...geometry,
|
|
141
|
-
data: geometry.data.map((data) => {
|
|
142
130
|
if (typeof data === "string") {
|
|
143
131
|
return {
|
|
144
132
|
data
|
|
@@ -147,6 +135,8 @@ function normalizeGeometry(geometry) {
|
|
|
147
135
|
return data;
|
|
148
136
|
})
|
|
149
137
|
};
|
|
138
|
+
} else {
|
|
139
|
+
return geometry;
|
|
150
140
|
}
|
|
151
141
|
}
|
|
152
142
|
|
|
@@ -266,4 +256,4 @@ function normalizeElement(element) {
|
|
|
266
256
|
};
|
|
267
257
|
}
|
|
268
258
|
|
|
269
|
-
export { getDefaultElementStyle, getDefaultStyle, getDefaultTextStyle, normalizeElement, normalizeFill, normalizeGeometry, normalizeImage, normalizeStroke, normalizeText, normalizeTextContent, normalizeVideo };
|
|
259
|
+
export { getDefaultElementStyle, getDefaultShadowStyle, getDefaultStyle, getDefaultTextStyle, getDefaultTransformStyle, normalizeElement, normalizeFill, normalizeGeometry, normalizeImage, normalizeStroke, normalizeText, normalizeTextContent, normalizeVideo };
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "modern-idoc",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
5
|
-
"packageManager": "pnpm@9.
|
|
4
|
+
"version": "0.1.5",
|
|
5
|
+
"packageManager": "pnpm@9.15.1",
|
|
6
6
|
"description": "Intermediate document for modern codec libs",
|
|
7
7
|
"author": "wxm",
|
|
8
8
|
"license": "MIT",
|
|
@@ -55,15 +55,15 @@
|
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@antfu/eslint-config": "^3.12.1",
|
|
58
|
-
"@types/node": "^22.10.
|
|
58
|
+
"@types/node": "^22.10.3",
|
|
59
59
|
"bumpp": "^9.9.2",
|
|
60
60
|
"conventional-changelog-cli": "^5.0.0",
|
|
61
61
|
"eslint": "^9.17.0",
|
|
62
|
-
"lint-staged": "^15.
|
|
62
|
+
"lint-staged": "^15.3.0",
|
|
63
63
|
"simple-git-hooks": "^2.11.1",
|
|
64
64
|
"typescript": "^5.7.2",
|
|
65
|
-
"unbuild": "^3.0
|
|
66
|
-
"vite": "^6.0.
|
|
65
|
+
"unbuild": "^3.2.0",
|
|
66
|
+
"vite": "^6.0.6",
|
|
67
67
|
"vitest": "^2.1.8"
|
|
68
68
|
},
|
|
69
69
|
"simple-git-hooks": {
|