pptxtojson 1.1.1 → 1.2.1

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
@@ -9,9 +9,9 @@
9
9
 
10
10
  # 🎯 注意事项
11
11
  ### ⚒️ 使用场景
12
- 本仓库诞生于项目 [PPTist](https://github.com/pipipi-pikachu/PPTist) ,希望为其“导入 .pptx 文件功能”提供一个参考示例。不过就目前来说,解析出来的PPT信息与源文件在样式上还是存在不少差距,还不足以直接运用到生产环境中。
12
+ 本仓库诞生于项目 [PPTist](https://github.com/pipipi-pikachu/PPTist) ,希望为其“导入 .pptx 文件功能”提供一个参考示例。不过就目前来说,解析出来的PPT信息与源文件在样式上还是存在差距,还不足以直接运用到生产环境中。
13
13
 
14
- 但如果你只是需要提取PPT文件的文本内容和媒体资源信息,对排版精准度/样式信息没有特别高的要求,那么 pptxtojson 可能会对你有一些帮助。
14
+ 但如果你只是需要提取PPT文件的文本内容、媒体资源信息、结构信息等,对排版/样式精准度没有特别高的要求,那么 pptxtojson 可能会对你有帮助。
15
15
 
16
16
  ### 📏 长度值单位
17
17
  输出的JSON中,所有数值长度值单位都为`pt`(point)
@@ -45,35 +45,45 @@ document.querySelector('input').addEventListener('change', evt => {
45
45
  ```javascript
46
46
  // 输出示例
47
47
  {
48
- "slides": {
49
- "fill": {
50
- "type": "color",
51
- "value": "#FF0000"
52
- },
53
- "elements": [
54
- {
55
- "left": 0,
56
- "top": 0,
57
- "width": 72,
58
- "height": 72,
59
- "borderColor": "#1f4e79",
60
- "borderWidth": 1,
61
- "borderType": "solid",
62
- "borderStrokeDasharray": 0,
63
- "fillColor": "#5b9bd5",
64
- "content": "<p style=\"text-align: center;\"><span style=\"font-size: 18pt;font-family: Calibri;\">TEST</span></p>",
65
- "isFlipV": false,
66
- "isFlipH": false,
67
- "rotate": 0,
68
- "vAlign": "mid",
69
- "name": "矩形 1",
70
- "type": "shape",
71
- "shapType": "rect"
48
+ "slides": [
49
+ {
50
+ "fill": {
51
+ "type": "color",
52
+ "value": "#FF0000"
72
53
  },
73
- // more...
74
- ],
75
- "note": "演讲者备注内容..."
76
- },
54
+ "elements": [
55
+ {
56
+ "left": 0,
57
+ "top": 0,
58
+ "width": 72,
59
+ "height": 72,
60
+ "borderColor": "#1F4E79",
61
+ "borderWidth": 1,
62
+ "borderType": "solid",
63
+ "borderStrokeDasharray": 0,
64
+ "fill": {
65
+ "type": "color",
66
+ "value": "#FF0000"
67
+ },
68
+ "content": "<p style=\"text-align: center;\"><span style=\"font-size: 18pt;font-family: Calibri;\">TEST</span></p>",
69
+ "isFlipV": false,
70
+ "isFlipH": false,
71
+ "rotate": 0,
72
+ "vAlign": "mid",
73
+ "name": "矩形 1",
74
+ "type": "shape",
75
+ "shapType": "rect"
76
+ },
77
+ // more...
78
+ ],
79
+ "layoutElements": [
80
+ // more...
81
+ ],
82
+ "note": "演讲者备注内容..."
83
+ },
84
+ // more...
85
+ ],
86
+ "themeColors": ['#4472C4', '#ED7D31', '#A5A5A5', '#FFC000', '#5B9BD5', '#70AD47'],
77
87
  "size": {
78
88
  "width": 960,
79
89
  "height": 540
@@ -83,18 +93,18 @@ document.querySelector('input').addEventListener('change', evt => {
83
93
 
84
94
  # 📕 完整功能支持
85
95
 
96
+ ### 幻灯片主题色 `themeColors`
97
+
86
98
  ### 幻灯片尺寸 `size`
87
99
  - 幻灯片宽度 `width`
88
100
  - 幻灯片高度 `height`
89
101
 
90
102
  ### 幻灯片页面 `slides`
91
- #### 页面背景填充 `fill`
92
- - 背景类型(颜色、图片、渐变) `type`
93
- - 背景值 `value`
103
+ #### 页面背景填充(颜色、图片、渐变) `fill`
94
104
 
95
105
  #### 页面备注 `note`
96
106
 
97
- #### 页面内元素 `elements`
107
+ #### 页面内元素 `elements` / 母版元素 `layoutElements`
98
108
  ##### 文字
99
109
  - 类型 `type='text'`
100
110
  - 水平坐标 `left`
@@ -106,7 +116,7 @@ document.querySelector('input').addEventListener('change', evt => {
106
116
  - 边框类型(实线、点线、虚线) `borderType`
107
117
  - 非实线边框样式 `borderStrokeDasharray`
108
118
  - 阴影 `shadow`
109
- - 填充色 `fillColor`
119
+ - 填充(颜色、图片、渐变) `fill`
110
120
  - 内容文字(HTML富文本) `content`
111
121
  - 垂直翻转 `isFlipV`
112
122
  - 水平翻转 `isFlipH`
@@ -135,7 +145,7 @@ document.querySelector('input').addEventListener('change', evt => {
135
145
  - 边框类型(实线、点线、虚线) `borderType`
136
146
  - 非实线边框样式 `borderStrokeDasharray`
137
147
  - 阴影 `shadow`
138
- - 填充色 `fillColor`
148
+ - 填充(颜色、图片、渐变) `fill`
139
149
  - 内容文字(HTML富文本) `content`
140
150
  - 垂直翻转 `isFlipV`
141
151
  - 水平翻转 `isFlipH`
@@ -163,6 +173,7 @@ document.querySelector('input').addEventListener('change', evt => {
163
173
  - 宽度 `width`
164
174
  - 高度 `height`
165
175
  - 图表数据 `data`
176
+ - 图表主题色 `colors`
166
177
  - 图表类型 `chartType`
167
178
  - 柱状图方向 `barDir`
168
179
  - 是否带数据标记 `marker`
@@ -219,4 +230,11 @@ document.querySelector('input').addEventListener('change', evt => {
219
230
  > 与它们不同的是,PPTX2HTML 和 PPTXjs 是将PPT文件转换为能够运行的 HTML 页面,而 pptxtojson 做的是将PPT文件转换为干净的 JSON 数据
220
231
 
221
232
  # 📄 开源协议
222
- MIT License | Copyright © 2020-PRESENT [pipipi-pikachu](https://github.com/pipipi-pikachu)
233
+ MIT License | Copyright © 2020-PRESENT [pipipi-pikachu](https://github.com/pipipi-pikachu)
234
+
235
+ # ☕ 打赏
236
+ 如果该项目帮到了您,还请您不吝打赏!
237
+
238
+ <p align="left">
239
+ <img src='/dist/wx.png' />
240
+ </p>
package/dist/index.d.ts CHANGED
@@ -5,6 +5,33 @@ export interface Shadow {
5
5
  color: string
6
6
  }
7
7
 
8
+ export interface ColorFill {
9
+ type: 'color'
10
+ value: string
11
+ }
12
+
13
+ export interface ImageFill {
14
+ type: 'image'
15
+ value: {
16
+ picBase64: string
17
+ opacity: number
18
+ }
19
+ }
20
+
21
+ export interface GradientFill {
22
+ type: 'gradient'
23
+ value: {
24
+ path: 'line' | 'circle' | 'rect' | 'shape'
25
+ rot: number
26
+ colors: {
27
+ pos: string
28
+ color: string
29
+ }[]
30
+ }
31
+ }
32
+
33
+ export type Fill = ColorFill | ImageFill | GradientFill
34
+
8
35
  export interface Shape {
9
36
  type: 'shape'
10
37
  left: number
@@ -16,7 +43,7 @@ export interface Shape {
16
43
  borderType: 'solid' | 'dashed' | 'dotted'
17
44
  borderStrokeDasharray: string
18
45
  shadow?: Shadow
19
- fillColor: string
46
+ fill: Fill
20
47
  content: string
21
48
  isFlipV: boolean
22
49
  isFlipH: boolean
@@ -39,7 +66,7 @@ export interface Text {
39
66
  borderType: 'solid' | 'dashed' | 'dotted'
40
67
  borderStrokeDasharray: string
41
68
  shadow?: Shadow
42
- fillColor: string
69
+ fill: Fill
43
70
  isFlipV: boolean
44
71
  isFlipH: boolean
45
72
  isVertical: boolean
@@ -122,6 +149,7 @@ export interface CommonChart {
122
149
  width: number
123
150
  height: number
124
151
  data: ChartItem[]
152
+ colors: string[]
125
153
  chartType: Exclude<ChartType, 'scatterChart' | 'bubbleChart'>
126
154
  barDir?: 'bar' | 'col'
127
155
  marker?: boolean
@@ -136,7 +164,8 @@ export interface ScatterChart {
136
164
  top: number
137
165
  width: number
138
166
  height: number
139
- data: ScatterChartData,
167
+ data: ScatterChartData
168
+ colors: string[]
140
169
  chartType: 'scatterChart' | 'bubbleChart'
141
170
  order: number
142
171
  }
@@ -197,35 +226,10 @@ export interface Group {
197
226
  }
198
227
  export type Element = BaseElement | Group
199
228
 
200
- export interface SlideColorFill {
201
- type: 'color'
202
- value: string
203
- }
204
-
205
- export interface SlideImageFill {
206
- type: 'image'
207
- value: {
208
- picBase64: string
209
- opacity: number
210
- }
211
- }
212
-
213
- export interface SlideGradientFill {
214
- type: 'gradient'
215
- value: {
216
- rot: number
217
- colors: {
218
- pos: string
219
- color: string
220
- }[]
221
- }
222
- }
223
-
224
- export type SlideFill = SlideColorFill | SlideImageFill | SlideGradientFill
225
-
226
229
  export interface Slide {
227
- fill: SlideFill
230
+ fill: Fill
228
231
  elements: Element[]
232
+ layoutElements: Element[]
229
233
  note: string
230
234
  }
231
235
 
@@ -236,6 +240,7 @@ export interface Options {
236
240
 
237
241
  export const parse: (file: ArrayBuffer, options?: Options) => Promise<{
238
242
  slides: Slide[]
243
+ themeColors: string[]
239
244
  size: {
240
245
  width: number
241
246
  height: number