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