pptxtojson 1.0.3 → 1.1.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 +133 -143
- package/dist/index.d.ts +22 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/index.html +13 -3
- package/package.json +2 -2
- package/src/math.js +184 -0
- package/src/pptxtojson.js +79 -7
- package/src/readXmlFile.js +8 -4
- package/src/utils.js +9 -0
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
在线DEMO:https://pipipi-pikachu.github.io/pptxtojson/
|
|
9
9
|
|
|
10
|
-
#
|
|
10
|
+
# 🎯 注意事项
|
|
11
11
|
### ⚒️ 使用场景
|
|
12
12
|
本仓库诞生于项目 [PPTist](https://github.com/pipipi-pikachu/PPTist) ,希望为其“导入 .pptx 文件功能”提供一个参考示例。不过就目前来说,解析出来的PPT信息与源文件在样式上还是存在不少差距,还不足以直接运用到生产环境中。
|
|
13
13
|
|
|
@@ -27,7 +27,7 @@ npm install pptxtojson
|
|
|
27
27
|
<input type="file" accept="application/vnd.openxmlformats-officedocument.presentationml.presentation"/>
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
```
|
|
30
|
+
```javascript
|
|
31
31
|
import { parse } from 'pptxtojson'
|
|
32
32
|
|
|
33
33
|
document.querySelector('input').addEventListener('change', evt => {
|
|
@@ -42,7 +42,7 @@ document.querySelector('input').addEventListener('change', evt => {
|
|
|
42
42
|
})
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
```
|
|
45
|
+
```javascript
|
|
46
46
|
// 输出示例
|
|
47
47
|
{
|
|
48
48
|
"slides": {
|
|
@@ -72,6 +72,7 @@ document.querySelector('input').addEventListener('change', evt => {
|
|
|
72
72
|
},
|
|
73
73
|
// more...
|
|
74
74
|
],
|
|
75
|
+
"note": "演讲者备注内容..."
|
|
75
76
|
},
|
|
76
77
|
"size": {
|
|
77
78
|
"width": 960,
|
|
@@ -80,146 +81,135 @@ document.querySelector('input').addEventListener('change', evt => {
|
|
|
80
81
|
}
|
|
81
82
|
```
|
|
82
83
|
|
|
83
|
-
# 📕
|
|
84
|
-
|
|
85
|
-
### 幻灯片尺寸
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
| elements | (Shape 丨 Text)[] | 子元素集合
|
|
213
|
-
|
|
214
|
-
#### 多元素组合
|
|
215
|
-
| prop | type | 描述
|
|
216
|
-
|------------------------|--------------------------------|---------------
|
|
217
|
-
| type | 'group' | 类型
|
|
218
|
-
| left | number | 水平坐标
|
|
219
|
-
| top | number | 垂直坐标
|
|
220
|
-
| width | number | 宽度
|
|
221
|
-
| height | number | 高度
|
|
222
|
-
| elements | Element[] | 子元素集合
|
|
84
|
+
# 📕 完整功能支持
|
|
85
|
+
|
|
86
|
+
### 幻灯片尺寸 `size`
|
|
87
|
+
- 幻灯片宽度 `width`
|
|
88
|
+
- 幻灯片高度 `height`
|
|
89
|
+
|
|
90
|
+
### 幻灯片页面 `slides`
|
|
91
|
+
#### 页面背景填充 `fill`
|
|
92
|
+
- 背景类型(颜色、图片、渐变) `type`
|
|
93
|
+
- 背景值 `value`
|
|
94
|
+
|
|
95
|
+
#### 页面备注 `note`
|
|
96
|
+
|
|
97
|
+
#### 页面内元素 `elements`
|
|
98
|
+
##### 文字
|
|
99
|
+
- 类型 `type='text'`
|
|
100
|
+
- 水平坐标 `left`
|
|
101
|
+
- 垂直坐标 `top`
|
|
102
|
+
- 宽度 `width`
|
|
103
|
+
- 高度 `height`
|
|
104
|
+
- 边框颜色 `borderColor`
|
|
105
|
+
- 边框宽度 `borderWidth`
|
|
106
|
+
- 边框类型(实线、点线、虚线) `borderType`
|
|
107
|
+
- 非实线边框样式 `borderStrokeDasharray`
|
|
108
|
+
- 阴影 `shadow`
|
|
109
|
+
- 填充色 `fillColor`
|
|
110
|
+
- 内容文字(HTML富文本) `content`
|
|
111
|
+
- 垂直翻转 `isFlipV`
|
|
112
|
+
- 水平翻转 `isFlipH`
|
|
113
|
+
- 旋转角度 `rotate`
|
|
114
|
+
- 垂直对齐方向 `vAlign`
|
|
115
|
+
- 是否为竖向文本 `isVertical`
|
|
116
|
+
- 元素名 `name`
|
|
117
|
+
|
|
118
|
+
##### 图片
|
|
119
|
+
- 类型 `type='image'`
|
|
120
|
+
- 水平坐标 `left`
|
|
121
|
+
- 垂直坐标 `top`
|
|
122
|
+
- 宽度 `width`
|
|
123
|
+
- 高度 `height`
|
|
124
|
+
- 图片地址(base64) `src`
|
|
125
|
+
- 旋转角度 `rotate`
|
|
126
|
+
|
|
127
|
+
##### 形状
|
|
128
|
+
- 类型 `type='shape'`
|
|
129
|
+
- 水平坐标 `left`
|
|
130
|
+
- 垂直坐标 `top`
|
|
131
|
+
- 宽度 `width`
|
|
132
|
+
- 高度 `height`
|
|
133
|
+
- 边框颜色 `borderColor`
|
|
134
|
+
- 边框宽度 `borderWidth`
|
|
135
|
+
- 边框类型(实线、点线、虚线) `borderType`
|
|
136
|
+
- 非实线边框样式 `borderStrokeDasharray`
|
|
137
|
+
- 阴影 `shadow`
|
|
138
|
+
- 填充色 `fillColor`
|
|
139
|
+
- 内容文字(HTML富文本) `content`
|
|
140
|
+
- 垂直翻转 `isFlipV`
|
|
141
|
+
- 水平翻转 `isFlipH`
|
|
142
|
+
- 旋转角度 `rotate`
|
|
143
|
+
- 形状类型 `shapType`
|
|
144
|
+
- 垂直对齐方向 `vAlign`
|
|
145
|
+
- 路径(自定义形状) `path`
|
|
146
|
+
- 元素名 `name`
|
|
147
|
+
|
|
148
|
+
##### 表格
|
|
149
|
+
- 类型 `type='table'`
|
|
150
|
+
- 水平坐标 `left`
|
|
151
|
+
- 垂直坐标 `top`
|
|
152
|
+
- 宽度 `width`
|
|
153
|
+
- 高度 `height`
|
|
154
|
+
- 边框颜色 `borderColor`
|
|
155
|
+
- 边框宽度 `borderWidth`
|
|
156
|
+
- 边框类型(实线、点线、虚线) `borderType`
|
|
157
|
+
- 表格数据 `data`
|
|
158
|
+
|
|
159
|
+
##### 图表
|
|
160
|
+
- 类型 `type='chart'`
|
|
161
|
+
- 水平坐标 `left`
|
|
162
|
+
- 垂直坐标 `top`
|
|
163
|
+
- 宽度 `width`
|
|
164
|
+
- 高度 `height`
|
|
165
|
+
- 图表数据 `data`
|
|
166
|
+
- 图表类型 `chartType`
|
|
167
|
+
- 柱状图方向 `barDir`
|
|
168
|
+
- 是否带数据标记 `marker`
|
|
169
|
+
- 环形图尺寸 `holeSize`
|
|
170
|
+
- 分组模式 `grouping`
|
|
171
|
+
- 图表样式 `style`
|
|
172
|
+
|
|
173
|
+
##### 视频
|
|
174
|
+
- 类型 `type='video'`
|
|
175
|
+
- 水平坐标 `left`
|
|
176
|
+
- 垂直坐标 `top`
|
|
177
|
+
- 宽度 `width`
|
|
178
|
+
- 高度 `height`
|
|
179
|
+
- 视频blob `blob`
|
|
180
|
+
- 视频src `src`
|
|
181
|
+
|
|
182
|
+
##### 音频
|
|
183
|
+
- 类型 `type='audio'`
|
|
184
|
+
- 水平坐标 `left`
|
|
185
|
+
- 垂直坐标 `top`
|
|
186
|
+
- 宽度 `width`
|
|
187
|
+
- 高度 `height`
|
|
188
|
+
- 音频blob `blob`
|
|
189
|
+
|
|
190
|
+
##### 公式(仅支持常见结构)
|
|
191
|
+
- 类型 `type='math'`
|
|
192
|
+
- 水平坐标 `left`
|
|
193
|
+
- 垂直坐标 `top`
|
|
194
|
+
- 宽度 `width`
|
|
195
|
+
- 高度 `height`
|
|
196
|
+
- LaTeX表达式 `latex`
|
|
197
|
+
|
|
198
|
+
##### Smart图
|
|
199
|
+
- 类型 `type='diagram'`
|
|
200
|
+
- 水平坐标 `left`
|
|
201
|
+
- 垂直坐标 `top`
|
|
202
|
+
- 宽度 `width`
|
|
203
|
+
- 高度 `height`
|
|
204
|
+
- 子元素集合 `elements`
|
|
205
|
+
|
|
206
|
+
##### 多元素组合
|
|
207
|
+
- 类型 `type='group'`
|
|
208
|
+
- 水平坐标 `left`
|
|
209
|
+
- 垂直坐标 `top`
|
|
210
|
+
- 宽度 `width`
|
|
211
|
+
- 高度 `height`
|
|
212
|
+
- 子元素集合 `elements`
|
|
223
213
|
|
|
224
214
|
### 更多类型请参考 👇
|
|
225
215
|
[https://github.com/pipipi-pikachu/pptxtojson/blob/master/dist/index.d.ts](https://github.com/pipipi-pikachu/pptxtojson/blob/master/dist/index.d.ts)
|
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export interface Shape {
|
|
|
25
25
|
vAlign: string
|
|
26
26
|
path?: string
|
|
27
27
|
name: string
|
|
28
|
+
order: number
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
export interface Text {
|
|
@@ -46,6 +47,7 @@ export interface Text {
|
|
|
46
47
|
content: string
|
|
47
48
|
vAlign: string
|
|
48
49
|
name: string
|
|
50
|
+
order: number
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
export interface Image {
|
|
@@ -58,6 +60,7 @@ export interface Image {
|
|
|
58
60
|
rotate: number
|
|
59
61
|
isFlipH: boolean
|
|
60
62
|
isFlipV: boolean
|
|
63
|
+
order: number
|
|
61
64
|
}
|
|
62
65
|
|
|
63
66
|
export interface TableCell {
|
|
@@ -80,6 +83,7 @@ export interface Table {
|
|
|
80
83
|
borderColor: string
|
|
81
84
|
borderWidth: number
|
|
82
85
|
borderType: 'solid' | 'dashed' | 'dotted'
|
|
86
|
+
order: number
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
export type ChartType = 'lineChart' |
|
|
@@ -124,6 +128,7 @@ export interface CommonChart {
|
|
|
124
128
|
holeSize?: string
|
|
125
129
|
grouping?: string
|
|
126
130
|
style?: string
|
|
131
|
+
order: number
|
|
127
132
|
}
|
|
128
133
|
export interface ScatterChart {
|
|
129
134
|
type: 'chart'
|
|
@@ -133,6 +138,7 @@ export interface ScatterChart {
|
|
|
133
138
|
height: number
|
|
134
139
|
data: ScatterChartData,
|
|
135
140
|
chartType: 'scatterChart' | 'bubbleChart'
|
|
141
|
+
order: number
|
|
136
142
|
}
|
|
137
143
|
export type Chart = CommonChart | ScatterChart
|
|
138
144
|
|
|
@@ -144,6 +150,7 @@ export interface Video {
|
|
|
144
150
|
height: number
|
|
145
151
|
blob?: string
|
|
146
152
|
src?: string
|
|
153
|
+
order: number
|
|
147
154
|
}
|
|
148
155
|
|
|
149
156
|
export interface Audio {
|
|
@@ -153,6 +160,7 @@ export interface Audio {
|
|
|
153
160
|
width: number
|
|
154
161
|
height: number
|
|
155
162
|
blob: string
|
|
163
|
+
order: number
|
|
156
164
|
}
|
|
157
165
|
|
|
158
166
|
export interface Diagram {
|
|
@@ -162,9 +170,20 @@ export interface Diagram {
|
|
|
162
170
|
width: number
|
|
163
171
|
height: number
|
|
164
172
|
elements: (Shape | Text)[]
|
|
173
|
+
order: number
|
|
165
174
|
}
|
|
166
175
|
|
|
167
|
-
export
|
|
176
|
+
export interface Math {
|
|
177
|
+
type: 'math'
|
|
178
|
+
left: number
|
|
179
|
+
top: number
|
|
180
|
+
width: number
|
|
181
|
+
height: number
|
|
182
|
+
latex: string
|
|
183
|
+
order: number
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export type BaseElement = Shape | Text | Image | Table | Chart | Video | Audio | Diagram | Math
|
|
168
187
|
|
|
169
188
|
export interface Group {
|
|
170
189
|
type: 'group'
|
|
@@ -174,6 +193,7 @@ export interface Group {
|
|
|
174
193
|
height: number
|
|
175
194
|
rotate: number
|
|
176
195
|
elements: BaseElement[]
|
|
196
|
+
order: number
|
|
177
197
|
}
|
|
178
198
|
export type Element = BaseElement | Group
|
|
179
199
|
|
|
@@ -206,6 +226,7 @@ export type SlideFill = SlideColorFill | SlideImageFill | SlideGradientFill
|
|
|
206
226
|
export interface Slide {
|
|
207
227
|
fill: SlideFill
|
|
208
228
|
elements: Element[]
|
|
229
|
+
note: string
|
|
209
230
|
}
|
|
210
231
|
|
|
211
232
|
export interface Options {
|