pptxtojson 1.1.1 → 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 +34 -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 +167 -174
- package/src/table.js +6 -2
- package/src/utils.js +0 -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
|
|
@@ -39,7 +65,7 @@ export interface Text {
|
|
|
39
65
|
borderType: 'solid' | 'dashed' | 'dotted'
|
|
40
66
|
borderStrokeDasharray: string
|
|
41
67
|
shadow?: Shadow
|
|
42
|
-
|
|
68
|
+
fill: Fill
|
|
43
69
|
isFlipV: boolean
|
|
44
70
|
isFlipH: boolean
|
|
45
71
|
isVertical: boolean
|
|
@@ -122,6 +148,7 @@ export interface CommonChart {
|
|
|
122
148
|
width: number
|
|
123
149
|
height: number
|
|
124
150
|
data: ChartItem[]
|
|
151
|
+
colors: string[]
|
|
125
152
|
chartType: Exclude<ChartType, 'scatterChart' | 'bubbleChart'>
|
|
126
153
|
barDir?: 'bar' | 'col'
|
|
127
154
|
marker?: boolean
|
|
@@ -136,7 +163,8 @@ export interface ScatterChart {
|
|
|
136
163
|
top: number
|
|
137
164
|
width: number
|
|
138
165
|
height: number
|
|
139
|
-
data: ScatterChartData
|
|
166
|
+
data: ScatterChartData
|
|
167
|
+
colors: string[]
|
|
140
168
|
chartType: 'scatterChart' | 'bubbleChart'
|
|
141
169
|
order: number
|
|
142
170
|
}
|
|
@@ -197,35 +225,10 @@ export interface Group {
|
|
|
197
225
|
}
|
|
198
226
|
export type Element = BaseElement | Group
|
|
199
227
|
|
|
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
228
|
export interface Slide {
|
|
227
|
-
fill:
|
|
229
|
+
fill: Fill
|
|
228
230
|
elements: Element[]
|
|
231
|
+
layoutElements: Element[]
|
|
229
232
|
note: string
|
|
230
233
|
}
|
|
231
234
|
|
|
@@ -236,6 +239,7 @@ export interface Options {
|
|
|
236
239
|
|
|
237
240
|
export const parse: (file: ArrayBuffer, options?: Options) => Promise<{
|
|
238
241
|
slides: Slide[]
|
|
242
|
+
themeColors: string[]
|
|
239
243
|
size: {
|
|
240
244
|
width: number
|
|
241
245
|
height: number
|