modern-idoc 0.0.1 → 0.0.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/README.md CHANGED
@@ -21,9 +21,9 @@
21
21
  ## Usage
22
22
 
23
23
  ```ts
24
- import type { IDoc } from 'modern-idoc'
24
+ import type { IDOC } from 'modern-idoc'
25
25
 
26
- const doc: IDoc = {
26
+ const doc: IDOC = {
27
27
  name: 'example.pptx',
28
28
  children: [
29
29
  {
package/dist/index.cjs CHANGED
@@ -1,5 +1,92 @@
1
1
  'use strict';
2
2
 
3
- const index = {};
3
+ function getDefaultElementStyle() {
4
+ return {
5
+ overflow: "visible",
6
+ visibility: "visible",
7
+ filter: "none",
8
+ // position
9
+ left: 0,
10
+ top: 0,
11
+ width: 0,
12
+ height: 0,
13
+ rotate: 0,
14
+ opacity: 1,
15
+ // margin
16
+ marginLeft: 0,
17
+ marginTop: 0,
18
+ marginRight: 0,
19
+ marginBottom: 0,
20
+ // padding
21
+ paddingLeft: 0,
22
+ paddingTop: 0,
23
+ paddingRight: 0,
24
+ paddingBottom: 0,
25
+ // transform
26
+ scaleX: 1,
27
+ scaleY: 1,
28
+ skewX: 0,
29
+ skewY: 0,
30
+ translateX: 0,
31
+ translateY: 0,
32
+ transform: "none",
33
+ transformOrigin: "50% 50%",
34
+ // background
35
+ backgroundImage: "none",
36
+ backgroundColor: "transparent",
37
+ // shadow
38
+ shadowColor: "transparent",
39
+ shadowOffsetX: 0,
40
+ shadowOffsetY: 0,
41
+ shadowBlur: 0,
42
+ // border
43
+ borderRadius: 0,
44
+ borderColor: "transparent",
45
+ borderWidth: 1
46
+ };
47
+ }
4
48
 
5
- module.exports = index;
49
+ function getDefaultTextStyle() {
50
+ return {
51
+ ...getDefaultElementStyle(),
52
+ writingMode: "horizontal-tb",
53
+ verticalAlign: "baseline",
54
+ lineHeight: 1.2,
55
+ letterSpacing: 0,
56
+ wordSpacing: 0,
57
+ // font
58
+ fontSize: 14,
59
+ fontWeight: "normal",
60
+ fontFamily: "",
61
+ fontStyle: "normal",
62
+ fontKerning: "normal",
63
+ // text
64
+ textWrap: "wrap",
65
+ textAlign: "start",
66
+ textIndent: 0,
67
+ textTransform: "none",
68
+ textOrientation: "mixed",
69
+ textDecoration: "none",
70
+ // textStroke
71
+ textStrokeWidth: 0,
72
+ textStrokeColor: "black",
73
+ // color
74
+ color: "black",
75
+ // listStyle
76
+ listStyleType: "none",
77
+ listStyleImage: "none",
78
+ listStyleColormap: "none",
79
+ listStyleSize: "cover",
80
+ listStylePosition: "outside",
81
+ // listStyle
82
+ highlightImage: "none",
83
+ highlightReferImage: "none",
84
+ highlightColormap: "none",
85
+ highlightLine: "none",
86
+ highlightSize: "cover",
87
+ highlightThickness: "100%"
88
+ };
89
+ }
90
+
91
+ exports.getDefaultElementStyle = getDefaultElementStyle;
92
+ exports.getDefaultTextStyle = getDefaultTextStyle;
package/dist/index.d.cts CHANGED
@@ -1,52 +1,11 @@
1
1
  interface IBackgroundStyle {
2
2
  opacity: number;
3
3
  }
4
+
4
5
  interface IBackground extends Partial<IBackgroundStyle> {
5
6
  src: string;
6
7
  }
7
8
 
8
- type Overflow = 'hidden' | 'visible';
9
- type Visibility = 'hidden' | 'visible';
10
- interface IElementStyle {
11
- overflow: Overflow;
12
- visibility: Visibility;
13
- filter: string;
14
- left: number;
15
- top: number;
16
- width: number;
17
- height: number;
18
- rotate: number;
19
- opacity: number;
20
- scaleX: number;
21
- scaleY: number;
22
- transform: string;
23
- transformOrigin: string;
24
- backgroundImage: string;
25
- backgroundColor: string;
26
- shadowColor: string;
27
- shadowOffsetX: number;
28
- shadowOffsetY: number;
29
- 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
- borderRadius: number;
39
- borderColor: string;
40
- borderWidth: number;
41
- }
42
-
43
- interface IElement<T extends IElementStyle = IElementStyle> {
44
- name?: string;
45
- style?: Partial<T>;
46
- background?: IBackground;
47
- meta?: Record<string, any>;
48
- }
49
-
50
9
  interface IImage extends IElement {
51
10
  type: 'image';
52
11
  src: string;
@@ -86,6 +45,45 @@ interface IShape extends IElement {
86
45
  paths: IPath[];
87
46
  }
88
47
 
48
+ type Overflow = 'hidden' | 'visible';
49
+ type Visibility = 'hidden' | 'visible';
50
+ interface IElementStyle {
51
+ overflow: Overflow;
52
+ visibility: Visibility;
53
+ filter: string;
54
+ left: number;
55
+ top: number;
56
+ width: number;
57
+ height: number;
58
+ rotate: number;
59
+ opacity: number;
60
+ marginLeft: number;
61
+ marginTop: number;
62
+ marginRight: number;
63
+ marginBottom: number;
64
+ paddingLeft: number;
65
+ paddingTop: number;
66
+ paddingRight: number;
67
+ paddingBottom: number;
68
+ scaleX: number;
69
+ scaleY: number;
70
+ skewX: number;
71
+ skewY: number;
72
+ translateX: number;
73
+ translateY: number;
74
+ transform: string;
75
+ transformOrigin: string;
76
+ backgroundImage: string;
77
+ backgroundColor: string;
78
+ shadowColor: string;
79
+ shadowOffsetX: number;
80
+ shadowOffsetY: number;
81
+ shadowBlur: number;
82
+ borderRadius: number;
83
+ borderColor: string;
84
+ borderWidth: number;
85
+ }
86
+
89
87
  type FontWeight = 'normal' | 'bold' | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
90
88
  type FontStyle = 'normal' | 'italic' | 'oblique' | `oblique ${string}`;
91
89
  type FontKerning = 'none' | 'auto' | 'normal';
@@ -109,6 +107,14 @@ interface ListStyle {
109
107
  size: ListStyleSize;
110
108
  position: ListStylePosition;
111
109
  }
110
+ interface TextListStyle {
111
+ listStyle?: Partial<ListStyle>;
112
+ listStyleType: ListStyleType;
113
+ listStyleImage: ListStyleImage;
114
+ listStyleColormap: ListStyleColormap;
115
+ listStyleSize: ListStyleSize;
116
+ listStylePosition: ListStylePosition;
117
+ }
112
118
  type HighlightLine = TextDecorationLine | 'outline';
113
119
  type HighlightImage = 'none' | string;
114
120
  type HighlightReferImage = 'none' | string;
@@ -123,16 +129,8 @@ interface Highlight {
123
129
  size: HighlightSize;
124
130
  thickness: HighlightThickness;
125
131
  }
126
- interface TextListStyle {
127
- listStyle: Partial<ListStyle>;
128
- listStyleType: ListStyleType;
129
- listStyleImage: ListStyleImage;
130
- listStyleColormap: ListStyleColormap;
131
- listStyleSize: ListStyleSize;
132
- listStylePosition: ListStylePosition;
133
- }
134
132
  interface TextHighlightStyle {
135
- highlight: Partial<Highlight>;
133
+ highlight?: Partial<Highlight>;
136
134
  highlightImage: HighlightImage;
137
135
  highlightReferImage: HighlightReferImage;
138
136
  highlightColormap: HighlightColormap;
@@ -140,17 +138,18 @@ interface TextHighlightStyle {
140
138
  highlightSize: HighlightSize;
141
139
  highlightThickness: HighlightThickness;
142
140
  }
143
- interface TextLineStyle extends TextListStyle {
141
+ interface ITextLineStyle extends TextListStyle {
144
142
  writingMode: WritingMode;
145
143
  textWrap: TextWrap;
146
144
  textAlign: TextAlign;
147
145
  textIndent: number;
148
146
  lineHeight: number;
149
147
  }
150
- interface TextInlineStyle extends TextHighlightStyle {
148
+ interface ITextInlineStyle extends TextHighlightStyle {
151
149
  color: string;
152
150
  verticalAlign: VerticalAlign;
153
151
  letterSpacing: number;
152
+ wordSpacing: number;
154
153
  fontSize: number;
155
154
  fontWeight: FontWeight;
156
155
  fontFamily: string;
@@ -160,7 +159,7 @@ interface TextInlineStyle extends TextHighlightStyle {
160
159
  textOrientation: TextOrientation;
161
160
  textDecoration: TextDecorationLine;
162
161
  }
163
- interface TextDrawStyle {
162
+ interface ITextDrawStyle {
164
163
  textStrokeWidth: number;
165
164
  textStrokeColor: string;
166
165
  shadowColor: string;
@@ -172,7 +171,7 @@ interface TextDrawStyle {
172
171
  skewX: number;
173
172
  skewY: number;
174
173
  }
175
- interface ITextStyle extends TextLineStyle, TextInlineStyle, TextDrawStyle, IElementStyle {
174
+ interface ITextStyle extends ITextLineStyle, ITextInlineStyle, ITextDrawStyle, IElementStyle {
176
175
  }
177
176
 
178
177
  interface IFragmentContent extends Partial<ITextStyle> {
@@ -185,16 +184,34 @@ type ITextContent = string | IFragmentContent | IParagraphContent | (string | IF
185
184
  interface IText extends IElement<ITextStyle> {
186
185
  type: 'text';
187
186
  content: ITextContent;
187
+ effects?: Partial<ITextStyle>[];
188
+ measureDom?: any;
189
+ fonts?: any;
190
+ }
191
+
192
+ interface IVideo extends IElement {
193
+ type: 'video';
194
+ src: string;
188
195
  }
189
196
 
190
- type IGroupElement = IImage | IText | IShape | IGroup;
191
- interface IGroup extends IElement {
192
- children: IGroupElement[];
197
+ type IElementChild = IElement | IImage | IText | IVideo | IShape;
198
+
199
+ type IElementMeta = Record<string, any>;
200
+
201
+ interface IElement<T = IElementStyle> {
202
+ name?: string;
203
+ style?: Partial<T>;
204
+ background?: IBackground;
205
+ meta?: IElementMeta;
206
+ children?: IElementChild[];
193
207
  }
194
208
 
195
- interface IDoc extends IGroup {
209
+ interface IDOC extends IElement {
210
+ fonts?: any;
196
211
  }
197
212
 
198
- declare const _default: {};
213
+ declare function getDefaultElementStyle(): IElementStyle;
214
+
215
+ declare function getDefaultTextStyle(): ITextStyle;
199
216
 
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 IDoc, type IElement, type IElementStyle, type IFragmentContent, type IGroup, type IGroupElement, type IImage, type IParagraphContent, type IPath, type IPathDrawStyle, type IPathStyle, type IShape, type IText, type ITextContent, type ITextStyle, 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 TextDrawStyle, type TextHighlightStyle, type TextInlineStyle, type TextLineStyle, type TextListStyle, type TextOrientation, type TextTransform, type TextWrap, type VerticalAlign, type Visibility, type WritingMode, _default as default };
217
+ 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 IDOC, type IElement, type IElementChild, type IElementMeta, type IElementStyle, type IFragmentContent, 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,52 +1,11 @@
1
1
  interface IBackgroundStyle {
2
2
  opacity: number;
3
3
  }
4
+
4
5
  interface IBackground extends Partial<IBackgroundStyle> {
5
6
  src: string;
6
7
  }
7
8
 
8
- type Overflow = 'hidden' | 'visible';
9
- type Visibility = 'hidden' | 'visible';
10
- interface IElementStyle {
11
- overflow: Overflow;
12
- visibility: Visibility;
13
- filter: string;
14
- left: number;
15
- top: number;
16
- width: number;
17
- height: number;
18
- rotate: number;
19
- opacity: number;
20
- scaleX: number;
21
- scaleY: number;
22
- transform: string;
23
- transformOrigin: string;
24
- backgroundImage: string;
25
- backgroundColor: string;
26
- shadowColor: string;
27
- shadowOffsetX: number;
28
- shadowOffsetY: number;
29
- 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
- borderRadius: number;
39
- borderColor: string;
40
- borderWidth: number;
41
- }
42
-
43
- interface IElement<T extends IElementStyle = IElementStyle> {
44
- name?: string;
45
- style?: Partial<T>;
46
- background?: IBackground;
47
- meta?: Record<string, any>;
48
- }
49
-
50
9
  interface IImage extends IElement {
51
10
  type: 'image';
52
11
  src: string;
@@ -86,6 +45,45 @@ interface IShape extends IElement {
86
45
  paths: IPath[];
87
46
  }
88
47
 
48
+ type Overflow = 'hidden' | 'visible';
49
+ type Visibility = 'hidden' | 'visible';
50
+ interface IElementStyle {
51
+ overflow: Overflow;
52
+ visibility: Visibility;
53
+ filter: string;
54
+ left: number;
55
+ top: number;
56
+ width: number;
57
+ height: number;
58
+ rotate: number;
59
+ opacity: number;
60
+ marginLeft: number;
61
+ marginTop: number;
62
+ marginRight: number;
63
+ marginBottom: number;
64
+ paddingLeft: number;
65
+ paddingTop: number;
66
+ paddingRight: number;
67
+ paddingBottom: number;
68
+ scaleX: number;
69
+ scaleY: number;
70
+ skewX: number;
71
+ skewY: number;
72
+ translateX: number;
73
+ translateY: number;
74
+ transform: string;
75
+ transformOrigin: string;
76
+ backgroundImage: string;
77
+ backgroundColor: string;
78
+ shadowColor: string;
79
+ shadowOffsetX: number;
80
+ shadowOffsetY: number;
81
+ shadowBlur: number;
82
+ borderRadius: number;
83
+ borderColor: string;
84
+ borderWidth: number;
85
+ }
86
+
89
87
  type FontWeight = 'normal' | 'bold' | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
90
88
  type FontStyle = 'normal' | 'italic' | 'oblique' | `oblique ${string}`;
91
89
  type FontKerning = 'none' | 'auto' | 'normal';
@@ -109,6 +107,14 @@ interface ListStyle {
109
107
  size: ListStyleSize;
110
108
  position: ListStylePosition;
111
109
  }
110
+ interface TextListStyle {
111
+ listStyle?: Partial<ListStyle>;
112
+ listStyleType: ListStyleType;
113
+ listStyleImage: ListStyleImage;
114
+ listStyleColormap: ListStyleColormap;
115
+ listStyleSize: ListStyleSize;
116
+ listStylePosition: ListStylePosition;
117
+ }
112
118
  type HighlightLine = TextDecorationLine | 'outline';
113
119
  type HighlightImage = 'none' | string;
114
120
  type HighlightReferImage = 'none' | string;
@@ -123,16 +129,8 @@ interface Highlight {
123
129
  size: HighlightSize;
124
130
  thickness: HighlightThickness;
125
131
  }
126
- interface TextListStyle {
127
- listStyle: Partial<ListStyle>;
128
- listStyleType: ListStyleType;
129
- listStyleImage: ListStyleImage;
130
- listStyleColormap: ListStyleColormap;
131
- listStyleSize: ListStyleSize;
132
- listStylePosition: ListStylePosition;
133
- }
134
132
  interface TextHighlightStyle {
135
- highlight: Partial<Highlight>;
133
+ highlight?: Partial<Highlight>;
136
134
  highlightImage: HighlightImage;
137
135
  highlightReferImage: HighlightReferImage;
138
136
  highlightColormap: HighlightColormap;
@@ -140,17 +138,18 @@ interface TextHighlightStyle {
140
138
  highlightSize: HighlightSize;
141
139
  highlightThickness: HighlightThickness;
142
140
  }
143
- interface TextLineStyle extends TextListStyle {
141
+ interface ITextLineStyle extends TextListStyle {
144
142
  writingMode: WritingMode;
145
143
  textWrap: TextWrap;
146
144
  textAlign: TextAlign;
147
145
  textIndent: number;
148
146
  lineHeight: number;
149
147
  }
150
- interface TextInlineStyle extends TextHighlightStyle {
148
+ interface ITextInlineStyle extends TextHighlightStyle {
151
149
  color: string;
152
150
  verticalAlign: VerticalAlign;
153
151
  letterSpacing: number;
152
+ wordSpacing: number;
154
153
  fontSize: number;
155
154
  fontWeight: FontWeight;
156
155
  fontFamily: string;
@@ -160,7 +159,7 @@ interface TextInlineStyle extends TextHighlightStyle {
160
159
  textOrientation: TextOrientation;
161
160
  textDecoration: TextDecorationLine;
162
161
  }
163
- interface TextDrawStyle {
162
+ interface ITextDrawStyle {
164
163
  textStrokeWidth: number;
165
164
  textStrokeColor: string;
166
165
  shadowColor: string;
@@ -172,7 +171,7 @@ interface TextDrawStyle {
172
171
  skewX: number;
173
172
  skewY: number;
174
173
  }
175
- interface ITextStyle extends TextLineStyle, TextInlineStyle, TextDrawStyle, IElementStyle {
174
+ interface ITextStyle extends ITextLineStyle, ITextInlineStyle, ITextDrawStyle, IElementStyle {
176
175
  }
177
176
 
178
177
  interface IFragmentContent extends Partial<ITextStyle> {
@@ -185,16 +184,34 @@ type ITextContent = string | IFragmentContent | IParagraphContent | (string | IF
185
184
  interface IText extends IElement<ITextStyle> {
186
185
  type: 'text';
187
186
  content: ITextContent;
187
+ effects?: Partial<ITextStyle>[];
188
+ measureDom?: any;
189
+ fonts?: any;
190
+ }
191
+
192
+ interface IVideo extends IElement {
193
+ type: 'video';
194
+ src: string;
188
195
  }
189
196
 
190
- type IGroupElement = IImage | IText | IShape | IGroup;
191
- interface IGroup extends IElement {
192
- children: IGroupElement[];
197
+ type IElementChild = IElement | IImage | IText | IVideo | IShape;
198
+
199
+ type IElementMeta = Record<string, any>;
200
+
201
+ interface IElement<T = IElementStyle> {
202
+ name?: string;
203
+ style?: Partial<T>;
204
+ background?: IBackground;
205
+ meta?: IElementMeta;
206
+ children?: IElementChild[];
193
207
  }
194
208
 
195
- interface IDoc extends IGroup {
209
+ interface IDOC extends IElement {
210
+ fonts?: any;
196
211
  }
197
212
 
198
- declare const _default: {};
213
+ declare function getDefaultElementStyle(): IElementStyle;
214
+
215
+ declare function getDefaultTextStyle(): ITextStyle;
199
216
 
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 IDoc, type IElement, type IElementStyle, type IFragmentContent, type IGroup, type IGroupElement, type IImage, type IParagraphContent, type IPath, type IPathDrawStyle, type IPathStyle, type IShape, type IText, type ITextContent, type ITextStyle, 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 TextDrawStyle, type TextHighlightStyle, type TextInlineStyle, type TextLineStyle, type TextListStyle, type TextOrientation, type TextTransform, type TextWrap, type VerticalAlign, type Visibility, type WritingMode, _default as default };
217
+ 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 IDOC, type IElement, type IElementChild, type IElementMeta, type IElementStyle, type IFragmentContent, 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,52 +1,11 @@
1
1
  interface IBackgroundStyle {
2
2
  opacity: number;
3
3
  }
4
+
4
5
  interface IBackground extends Partial<IBackgroundStyle> {
5
6
  src: string;
6
7
  }
7
8
 
8
- type Overflow = 'hidden' | 'visible';
9
- type Visibility = 'hidden' | 'visible';
10
- interface IElementStyle {
11
- overflow: Overflow;
12
- visibility: Visibility;
13
- filter: string;
14
- left: number;
15
- top: number;
16
- width: number;
17
- height: number;
18
- rotate: number;
19
- opacity: number;
20
- scaleX: number;
21
- scaleY: number;
22
- transform: string;
23
- transformOrigin: string;
24
- backgroundImage: string;
25
- backgroundColor: string;
26
- shadowColor: string;
27
- shadowOffsetX: number;
28
- shadowOffsetY: number;
29
- 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
- borderRadius: number;
39
- borderColor: string;
40
- borderWidth: number;
41
- }
42
-
43
- interface IElement<T extends IElementStyle = IElementStyle> {
44
- name?: string;
45
- style?: Partial<T>;
46
- background?: IBackground;
47
- meta?: Record<string, any>;
48
- }
49
-
50
9
  interface IImage extends IElement {
51
10
  type: 'image';
52
11
  src: string;
@@ -86,6 +45,45 @@ interface IShape extends IElement {
86
45
  paths: IPath[];
87
46
  }
88
47
 
48
+ type Overflow = 'hidden' | 'visible';
49
+ type Visibility = 'hidden' | 'visible';
50
+ interface IElementStyle {
51
+ overflow: Overflow;
52
+ visibility: Visibility;
53
+ filter: string;
54
+ left: number;
55
+ top: number;
56
+ width: number;
57
+ height: number;
58
+ rotate: number;
59
+ opacity: number;
60
+ marginLeft: number;
61
+ marginTop: number;
62
+ marginRight: number;
63
+ marginBottom: number;
64
+ paddingLeft: number;
65
+ paddingTop: number;
66
+ paddingRight: number;
67
+ paddingBottom: number;
68
+ scaleX: number;
69
+ scaleY: number;
70
+ skewX: number;
71
+ skewY: number;
72
+ translateX: number;
73
+ translateY: number;
74
+ transform: string;
75
+ transformOrigin: string;
76
+ backgroundImage: string;
77
+ backgroundColor: string;
78
+ shadowColor: string;
79
+ shadowOffsetX: number;
80
+ shadowOffsetY: number;
81
+ shadowBlur: number;
82
+ borderRadius: number;
83
+ borderColor: string;
84
+ borderWidth: number;
85
+ }
86
+
89
87
  type FontWeight = 'normal' | 'bold' | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
90
88
  type FontStyle = 'normal' | 'italic' | 'oblique' | `oblique ${string}`;
91
89
  type FontKerning = 'none' | 'auto' | 'normal';
@@ -109,6 +107,14 @@ interface ListStyle {
109
107
  size: ListStyleSize;
110
108
  position: ListStylePosition;
111
109
  }
110
+ interface TextListStyle {
111
+ listStyle?: Partial<ListStyle>;
112
+ listStyleType: ListStyleType;
113
+ listStyleImage: ListStyleImage;
114
+ listStyleColormap: ListStyleColormap;
115
+ listStyleSize: ListStyleSize;
116
+ listStylePosition: ListStylePosition;
117
+ }
112
118
  type HighlightLine = TextDecorationLine | 'outline';
113
119
  type HighlightImage = 'none' | string;
114
120
  type HighlightReferImage = 'none' | string;
@@ -123,16 +129,8 @@ interface Highlight {
123
129
  size: HighlightSize;
124
130
  thickness: HighlightThickness;
125
131
  }
126
- interface TextListStyle {
127
- listStyle: Partial<ListStyle>;
128
- listStyleType: ListStyleType;
129
- listStyleImage: ListStyleImage;
130
- listStyleColormap: ListStyleColormap;
131
- listStyleSize: ListStyleSize;
132
- listStylePosition: ListStylePosition;
133
- }
134
132
  interface TextHighlightStyle {
135
- highlight: Partial<Highlight>;
133
+ highlight?: Partial<Highlight>;
136
134
  highlightImage: HighlightImage;
137
135
  highlightReferImage: HighlightReferImage;
138
136
  highlightColormap: HighlightColormap;
@@ -140,17 +138,18 @@ interface TextHighlightStyle {
140
138
  highlightSize: HighlightSize;
141
139
  highlightThickness: HighlightThickness;
142
140
  }
143
- interface TextLineStyle extends TextListStyle {
141
+ interface ITextLineStyle extends TextListStyle {
144
142
  writingMode: WritingMode;
145
143
  textWrap: TextWrap;
146
144
  textAlign: TextAlign;
147
145
  textIndent: number;
148
146
  lineHeight: number;
149
147
  }
150
- interface TextInlineStyle extends TextHighlightStyle {
148
+ interface ITextInlineStyle extends TextHighlightStyle {
151
149
  color: string;
152
150
  verticalAlign: VerticalAlign;
153
151
  letterSpacing: number;
152
+ wordSpacing: number;
154
153
  fontSize: number;
155
154
  fontWeight: FontWeight;
156
155
  fontFamily: string;
@@ -160,7 +159,7 @@ interface TextInlineStyle extends TextHighlightStyle {
160
159
  textOrientation: TextOrientation;
161
160
  textDecoration: TextDecorationLine;
162
161
  }
163
- interface TextDrawStyle {
162
+ interface ITextDrawStyle {
164
163
  textStrokeWidth: number;
165
164
  textStrokeColor: string;
166
165
  shadowColor: string;
@@ -172,7 +171,7 @@ interface TextDrawStyle {
172
171
  skewX: number;
173
172
  skewY: number;
174
173
  }
175
- interface ITextStyle extends TextLineStyle, TextInlineStyle, TextDrawStyle, IElementStyle {
174
+ interface ITextStyle extends ITextLineStyle, ITextInlineStyle, ITextDrawStyle, IElementStyle {
176
175
  }
177
176
 
178
177
  interface IFragmentContent extends Partial<ITextStyle> {
@@ -185,16 +184,34 @@ type ITextContent = string | IFragmentContent | IParagraphContent | (string | IF
185
184
  interface IText extends IElement<ITextStyle> {
186
185
  type: 'text';
187
186
  content: ITextContent;
187
+ effects?: Partial<ITextStyle>[];
188
+ measureDom?: any;
189
+ fonts?: any;
190
+ }
191
+
192
+ interface IVideo extends IElement {
193
+ type: 'video';
194
+ src: string;
188
195
  }
189
196
 
190
- type IGroupElement = IImage | IText | IShape | IGroup;
191
- interface IGroup extends IElement {
192
- children: IGroupElement[];
197
+ type IElementChild = IElement | IImage | IText | IVideo | IShape;
198
+
199
+ type IElementMeta = Record<string, any>;
200
+
201
+ interface IElement<T = IElementStyle> {
202
+ name?: string;
203
+ style?: Partial<T>;
204
+ background?: IBackground;
205
+ meta?: IElementMeta;
206
+ children?: IElementChild[];
193
207
  }
194
208
 
195
- interface IDoc extends IGroup {
209
+ interface IDOC extends IElement {
210
+ fonts?: any;
196
211
  }
197
212
 
198
- declare const _default: {};
213
+ declare function getDefaultElementStyle(): IElementStyle;
214
+
215
+ declare function getDefaultTextStyle(): ITextStyle;
199
216
 
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 IDoc, type IElement, type IElementStyle, type IFragmentContent, type IGroup, type IGroupElement, type IImage, type IParagraphContent, type IPath, type IPathDrawStyle, type IPathStyle, type IShape, type IText, type ITextContent, type ITextStyle, 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 TextDrawStyle, type TextHighlightStyle, type TextInlineStyle, type TextLineStyle, type TextListStyle, type TextOrientation, type TextTransform, type TextWrap, type VerticalAlign, type Visibility, type WritingMode, _default as default };
217
+ 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 IDOC, type IElement, type IElementChild, type IElementMeta, type IElementStyle, type IFragmentContent, 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,n){typeof exports=="object"&&typeof module<"u"?module.exports=n():typeof define=="function"&&define.amd?define(n):(e=typeof globalThis<"u"?globalThis:e||self,e.modernIdoc=n())})(this,function(){"use strict";return{}});
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";function t(){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 n(){return{...t(),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%"}}e.getDefaultElementStyle=t,e.getDefaultTextStyle=n,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
package/dist/index.mjs CHANGED
@@ -1,3 +1,89 @@
1
- const index = {};
1
+ function getDefaultElementStyle() {
2
+ return {
3
+ overflow: "visible",
4
+ visibility: "visible",
5
+ filter: "none",
6
+ // position
7
+ left: 0,
8
+ top: 0,
9
+ width: 0,
10
+ height: 0,
11
+ rotate: 0,
12
+ opacity: 1,
13
+ // margin
14
+ marginLeft: 0,
15
+ marginTop: 0,
16
+ marginRight: 0,
17
+ marginBottom: 0,
18
+ // padding
19
+ paddingLeft: 0,
20
+ paddingTop: 0,
21
+ paddingRight: 0,
22
+ paddingBottom: 0,
23
+ // transform
24
+ scaleX: 1,
25
+ scaleY: 1,
26
+ skewX: 0,
27
+ skewY: 0,
28
+ translateX: 0,
29
+ translateY: 0,
30
+ transform: "none",
31
+ transformOrigin: "50% 50%",
32
+ // background
33
+ backgroundImage: "none",
34
+ backgroundColor: "transparent",
35
+ // shadow
36
+ shadowColor: "transparent",
37
+ shadowOffsetX: 0,
38
+ shadowOffsetY: 0,
39
+ shadowBlur: 0,
40
+ // border
41
+ borderRadius: 0,
42
+ borderColor: "transparent",
43
+ borderWidth: 1
44
+ };
45
+ }
2
46
 
3
- export { index as default };
47
+ function getDefaultTextStyle() {
48
+ return {
49
+ ...getDefaultElementStyle(),
50
+ writingMode: "horizontal-tb",
51
+ verticalAlign: "baseline",
52
+ lineHeight: 1.2,
53
+ letterSpacing: 0,
54
+ wordSpacing: 0,
55
+ // font
56
+ fontSize: 14,
57
+ fontWeight: "normal",
58
+ fontFamily: "",
59
+ fontStyle: "normal",
60
+ fontKerning: "normal",
61
+ // text
62
+ textWrap: "wrap",
63
+ textAlign: "start",
64
+ textIndent: 0,
65
+ textTransform: "none",
66
+ textOrientation: "mixed",
67
+ textDecoration: "none",
68
+ // textStroke
69
+ textStrokeWidth: 0,
70
+ textStrokeColor: "black",
71
+ // color
72
+ color: "black",
73
+ // listStyle
74
+ listStyleType: "none",
75
+ listStyleImage: "none",
76
+ listStyleColormap: "none",
77
+ listStyleSize: "cover",
78
+ listStylePosition: "outside",
79
+ // listStyle
80
+ highlightImage: "none",
81
+ highlightReferImage: "none",
82
+ highlightColormap: "none",
83
+ highlightLine: "none",
84
+ highlightSize: "cover",
85
+ highlightThickness: "100%"
86
+ };
87
+ }
88
+
89
+ export { getDefaultElementStyle, getDefaultTextStyle };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-idoc",
3
3
  "type": "module",
4
- "version": "0.0.1",
4
+ "version": "0.0.3",
5
5
  "packageManager": "pnpm@9.9.0",
6
6
  "description": "Intermediate document for modern codec libs",
7
7
  "author": "wxm",