pptxtojson 1.1.0 → 1.2.0
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 +55 -37
- package/dist/index.d.ts +45 -30
- 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/dist/wx.png +0 -0
- package/index.html +1 -1
- package/package.json +2 -2
- package/src/chart.js +41 -1
- package/src/fill.js +72 -37
- package/src/pptxtojson.js +187 -172
- package/src/readXmlFile.js +8 -4
- package/src/table.js +6 -2
- package/src/utils.js +9 -2
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
|
|
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
|
-
|
|
50
|
-
"
|
|
51
|
-
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
####
|
|
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
|
-
-
|
|
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
|
-
-
|
|
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,32 @@ 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
|
+
rot: number
|
|
25
|
+
colors: {
|
|
26
|
+
pos: string
|
|
27
|
+
color: string
|
|
28
|
+
}[]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type Fill = ColorFill | ImageFill | GradientFill
|
|
33
|
+
|
|
8
34
|
export interface Shape {
|
|
9
35
|
type: 'shape'
|
|
10
36
|
left: number
|
|
@@ -16,7 +42,7 @@ export interface Shape {
|
|
|
16
42
|
borderType: 'solid' | 'dashed' | 'dotted'
|
|
17
43
|
borderStrokeDasharray: string
|
|
18
44
|
shadow?: Shadow
|
|
19
|
-
|
|
45
|
+
fill: Fill
|
|
20
46
|
content: string
|
|
21
47
|
isFlipV: boolean
|
|
22
48
|
isFlipH: boolean
|
|
@@ -25,6 +51,7 @@ export interface Shape {
|
|
|
25
51
|
vAlign: string
|
|
26
52
|
path?: string
|
|
27
53
|
name: string
|
|
54
|
+
order: number
|
|
28
55
|
}
|
|
29
56
|
|
|
30
57
|
export interface Text {
|
|
@@ -38,7 +65,7 @@ export interface Text {
|
|
|
38
65
|
borderType: 'solid' | 'dashed' | 'dotted'
|
|
39
66
|
borderStrokeDasharray: string
|
|
40
67
|
shadow?: Shadow
|
|
41
|
-
|
|
68
|
+
fill: Fill
|
|
42
69
|
isFlipV: boolean
|
|
43
70
|
isFlipH: boolean
|
|
44
71
|
isVertical: boolean
|
|
@@ -46,6 +73,7 @@ export interface Text {
|
|
|
46
73
|
content: string
|
|
47
74
|
vAlign: string
|
|
48
75
|
name: string
|
|
76
|
+
order: number
|
|
49
77
|
}
|
|
50
78
|
|
|
51
79
|
export interface Image {
|
|
@@ -58,6 +86,7 @@ export interface Image {
|
|
|
58
86
|
rotate: number
|
|
59
87
|
isFlipH: boolean
|
|
60
88
|
isFlipV: boolean
|
|
89
|
+
order: number
|
|
61
90
|
}
|
|
62
91
|
|
|
63
92
|
export interface TableCell {
|
|
@@ -80,6 +109,7 @@ export interface Table {
|
|
|
80
109
|
borderColor: string
|
|
81
110
|
borderWidth: number
|
|
82
111
|
borderType: 'solid' | 'dashed' | 'dotted'
|
|
112
|
+
order: number
|
|
83
113
|
}
|
|
84
114
|
|
|
85
115
|
export type ChartType = 'lineChart' |
|
|
@@ -118,12 +148,14 @@ export interface CommonChart {
|
|
|
118
148
|
width: number
|
|
119
149
|
height: number
|
|
120
150
|
data: ChartItem[]
|
|
151
|
+
colors: string[]
|
|
121
152
|
chartType: Exclude<ChartType, 'scatterChart' | 'bubbleChart'>
|
|
122
153
|
barDir?: 'bar' | 'col'
|
|
123
154
|
marker?: boolean
|
|
124
155
|
holeSize?: string
|
|
125
156
|
grouping?: string
|
|
126
157
|
style?: string
|
|
158
|
+
order: number
|
|
127
159
|
}
|
|
128
160
|
export interface ScatterChart {
|
|
129
161
|
type: 'chart'
|
|
@@ -131,8 +163,10 @@ export interface ScatterChart {
|
|
|
131
163
|
top: number
|
|
132
164
|
width: number
|
|
133
165
|
height: number
|
|
134
|
-
data: ScatterChartData
|
|
166
|
+
data: ScatterChartData
|
|
167
|
+
colors: string[]
|
|
135
168
|
chartType: 'scatterChart' | 'bubbleChart'
|
|
169
|
+
order: number
|
|
136
170
|
}
|
|
137
171
|
export type Chart = CommonChart | ScatterChart
|
|
138
172
|
|
|
@@ -144,6 +178,7 @@ export interface Video {
|
|
|
144
178
|
height: number
|
|
145
179
|
blob?: string
|
|
146
180
|
src?: string
|
|
181
|
+
order: number
|
|
147
182
|
}
|
|
148
183
|
|
|
149
184
|
export interface Audio {
|
|
@@ -153,6 +188,7 @@ export interface Audio {
|
|
|
153
188
|
width: number
|
|
154
189
|
height: number
|
|
155
190
|
blob: string
|
|
191
|
+
order: number
|
|
156
192
|
}
|
|
157
193
|
|
|
158
194
|
export interface Diagram {
|
|
@@ -162,6 +198,7 @@ export interface Diagram {
|
|
|
162
198
|
width: number
|
|
163
199
|
height: number
|
|
164
200
|
elements: (Shape | Text)[]
|
|
201
|
+
order: number
|
|
165
202
|
}
|
|
166
203
|
|
|
167
204
|
export interface Math {
|
|
@@ -171,6 +208,7 @@ export interface Math {
|
|
|
171
208
|
width: number
|
|
172
209
|
height: number
|
|
173
210
|
latex: string
|
|
211
|
+
order: number
|
|
174
212
|
}
|
|
175
213
|
|
|
176
214
|
export type BaseElement = Shape | Text | Image | Table | Chart | Video | Audio | Diagram | Math
|
|
@@ -183,38 +221,14 @@ export interface Group {
|
|
|
183
221
|
height: number
|
|
184
222
|
rotate: number
|
|
185
223
|
elements: BaseElement[]
|
|
224
|
+
order: number
|
|
186
225
|
}
|
|
187
226
|
export type Element = BaseElement | Group
|
|
188
227
|
|
|
189
|
-
export interface SlideColorFill {
|
|
190
|
-
type: 'color'
|
|
191
|
-
value: string
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
export interface SlideImageFill {
|
|
195
|
-
type: 'image'
|
|
196
|
-
value: {
|
|
197
|
-
picBase64: string
|
|
198
|
-
opacity: number
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export interface SlideGradientFill {
|
|
203
|
-
type: 'gradient'
|
|
204
|
-
value: {
|
|
205
|
-
rot: number
|
|
206
|
-
colors: {
|
|
207
|
-
pos: string
|
|
208
|
-
color: string
|
|
209
|
-
}[]
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
export type SlideFill = SlideColorFill | SlideImageFill | SlideGradientFill
|
|
214
|
-
|
|
215
228
|
export interface Slide {
|
|
216
|
-
fill:
|
|
229
|
+
fill: Fill
|
|
217
230
|
elements: Element[]
|
|
231
|
+
layoutElements: Element[]
|
|
218
232
|
note: string
|
|
219
233
|
}
|
|
220
234
|
|
|
@@ -225,6 +239,7 @@ export interface Options {
|
|
|
225
239
|
|
|
226
240
|
export const parse: (file: ArrayBuffer, options?: Options) => Promise<{
|
|
227
241
|
slides: Slide[]
|
|
242
|
+
themeColors: string[]
|
|
228
243
|
size: {
|
|
229
244
|
width: number
|
|
230
245
|
height: number
|