pptxtojson 1.12.0 → 2.0.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 +58 -10
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +17 -6
- 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 +5 -1
- package/package.json +1 -1
- package/src/align.js +31 -16
- package/src/chart.js +4 -0
- package/src/color.js +4 -3
- package/src/diagram.js +88 -0
- package/src/fill.js +139 -31
- package/src/fontStyle.js +237 -213
- package/src/pptxtojson.js +204 -120
- package/src/schemeColor.js +1 -1
- package/src/shape.js +31 -28
- package/src/table.js +13 -7
- package/src/text.js +17 -19
- package/src/utils.js +1 -1
package/README.md
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
<a href="https://www.github.com/pipipi-pikachu/pptxtojson/network/members" target="_black"><img src="https://img.shields.io/github/forks/pipipi-pikachu/pptxtojson?logo=github" alt="forks" /></a>
|
|
6
6
|
<a href="https://www.github.com/pipipi-pikachu/pptxtojson/blob/master/LICENSE" target="_black"><img src="https://img.shields.io/github/license/pipipi-pikachu/pptxtojson?logo=github" alt="license" /></a>
|
|
7
7
|
<a href="https://github.com/pipipi-pikachu/pptxtojson/issues" target="_black"><img src="https://img.shields.io/github/issues-closed/pipipi-pikachu/pptxtojson?logo=github" alt="issue"></a>
|
|
8
|
+
<a href="https://gitee.com/pptist/pptxtojson" target="_black"><img src="https://gitee.com/pptist/pptxtojson/badge/star.svg?version=latest" alt="gitee"></a>
|
|
9
|
+
<a href="https://gitcode.com/pipipi-pikachu/pptxtojson" target="_black"><img src="https://gitcode.com/pipipi-pikachu/pptxtojson/star/badge.svg" alt="gitcode"></a>
|
|
8
10
|
</p>
|
|
9
11
|
|
|
10
12
|
一个运行在浏览器中,可以将 .pptx 文件转为可读的 JSON 数据的 JavaScript 库。
|
|
@@ -15,6 +17,8 @@
|
|
|
15
17
|
|
|
16
18
|
在线DEMO:https://pipipi-pikachu.github.io/pptxtojson/
|
|
17
19
|
|
|
20
|
+
> 国内镜像(定期同步):[Gitee](https://gitee.com/pptist/pptxtojson)、[GitCode](https://gitcode.com/pipipi-pikachu/pptxtojson)
|
|
21
|
+
|
|
18
22
|
# 🎯 注意事项
|
|
19
23
|
### ⚒️ 使用场景
|
|
20
24
|
本仓库诞生于项目 [PPTist](https://github.com/pipipi-pikachu/PPTist) ,希望为其“导入 .pptx 文件功能”提供一个参考示例。不过就目前来说,解析出来的PPT信息与源文件在样式上还是存在差异。
|
|
@@ -23,7 +27,6 @@
|
|
|
23
27
|
|
|
24
28
|
### 📏 长度值单位
|
|
25
29
|
输出的JSON中,所有数值长度值单位都为`pt`(point)
|
|
26
|
-
> 注意:在0.x版本中,所有输出的长度值单位都是px(像素)
|
|
27
30
|
|
|
28
31
|
# 🔨安装
|
|
29
32
|
```
|
|
@@ -31,8 +34,11 @@ npm install pptxtojson
|
|
|
31
34
|
```
|
|
32
35
|
|
|
33
36
|
# 💿用法
|
|
37
|
+
```javascript
|
|
38
|
+
parse(file, options = {})
|
|
39
|
+
```
|
|
34
40
|
|
|
35
|
-
###
|
|
41
|
+
### 浏览器示例
|
|
36
42
|
```html
|
|
37
43
|
<input type="file" accept="application/vnd.openxmlformats-officedocument.presentationml.presentation"/>
|
|
38
44
|
```
|
|
@@ -45,14 +51,18 @@ document.querySelector('input').addEventListener('change', evt => {
|
|
|
45
51
|
|
|
46
52
|
const reader = new FileReader()
|
|
47
53
|
reader.onload = async e => {
|
|
48
|
-
const json = await parse(e.target.result
|
|
54
|
+
const json = await parse(e.target.result, {
|
|
55
|
+
imageMode: 'base64',
|
|
56
|
+
videoMode: 'none',
|
|
57
|
+
audioMode: 'none',
|
|
58
|
+
})
|
|
49
59
|
console.log(json)
|
|
50
60
|
}
|
|
51
61
|
reader.readAsArrayBuffer(file)
|
|
52
62
|
})
|
|
53
63
|
```
|
|
54
64
|
|
|
55
|
-
### Node.js
|
|
65
|
+
### Node.js 示例(实验性,1.5.0以上版本)
|
|
56
66
|
```javascript
|
|
57
67
|
const pptxtojson = require('pptxtojson/dist/index.cjs')
|
|
58
68
|
const fs = require('fs')
|
|
@@ -60,7 +70,11 @@ const fs = require('fs')
|
|
|
60
70
|
async function func() {
|
|
61
71
|
const buffer = fs.readFileSync('test.pptx')
|
|
62
72
|
|
|
63
|
-
const json = await pptxtojson.parse(buffer.buffer
|
|
73
|
+
const json = await pptxtojson.parse(buffer.buffer, {
|
|
74
|
+
imageMode: 'base64',
|
|
75
|
+
videoMode: 'none',
|
|
76
|
+
audioMode: 'none',
|
|
77
|
+
})
|
|
64
78
|
console.log(json)
|
|
65
79
|
}
|
|
66
80
|
|
|
@@ -116,7 +130,33 @@ func()
|
|
|
116
130
|
}
|
|
117
131
|
```
|
|
118
132
|
|
|
119
|
-
#
|
|
133
|
+
# 🎲 Options 配置说明
|
|
134
|
+
> options 为可选参数,不传时使用默认配置。
|
|
135
|
+
|
|
136
|
+
- `imageMode`:控制图片资源的解析方式,可选值为 `base64`、`blob`、`both`、`none`,默认值为 `base64`。
|
|
137
|
+
- `base64` 表示仅解析 `base64`。
|
|
138
|
+
- `blob` 表示仅解析 `blob`。
|
|
139
|
+
- `both` 表示同时解析 `base64` 和 `blob`。
|
|
140
|
+
- `none` 表示不解析图片内容。
|
|
141
|
+
|
|
142
|
+
- `videoMode`:控制视频资源的解析方式,可选值为 `blob`、`none`,默认值为 `none`。
|
|
143
|
+
- `blob` 表示解析视频 `blob`。
|
|
144
|
+
- `none` 表示不解析视频内容。
|
|
145
|
+
|
|
146
|
+
- `audioMode`:控制音频资源的解析方式,可选值为 `blob`、`none`,默认值为 `none`。
|
|
147
|
+
- `blob` 表示解析音频 `blob`。
|
|
148
|
+
- `none` 表示不解析音频内容。
|
|
149
|
+
|
|
150
|
+
# 🕰️ 旧版本说明
|
|
151
|
+
- 在0.x版本中,所有输出的长度值单位都是px(像素)
|
|
152
|
+
- 在1.x及以下版本:
|
|
153
|
+
- 图片元素使用 `src` 字段返回 base64 数据;
|
|
154
|
+
- 图片填充仅返回 `picBase64`;
|
|
155
|
+
- 视频元素可能返回 `blob` 或 `src`;
|
|
156
|
+
- 音频元素仅返回 `blob`;
|
|
157
|
+
- 公式图片仅返回 `picBase64`;
|
|
158
|
+
|
|
159
|
+
# 📕 解析属性
|
|
120
160
|
|
|
121
161
|
- 幻灯片主题色 `themeColors`
|
|
122
162
|
|
|
@@ -164,6 +204,7 @@ func()
|
|
|
164
204
|
- `shape`:文本框高度会根据文本内容自动调整
|
|
165
205
|
- `text`:文本框大小固定,字号会自动缩放以适应文本框(注:autoFit不存在时,也会固定文本框大小,但字号不会缩放)
|
|
166
206
|
- 字体缩放比例(type='text'专有,默认为1) `fontScale`
|
|
207
|
+
- 超链接 `link`
|
|
167
208
|
|
|
168
209
|
- 图片
|
|
169
210
|
- 类型 `type='image'`
|
|
@@ -177,9 +218,12 @@ func()
|
|
|
177
218
|
- 非实线边框样式 `borderStrokeDasharray`
|
|
178
219
|
- 裁剪形状 `geom`
|
|
179
220
|
- 裁剪范围 `rect`
|
|
180
|
-
-
|
|
221
|
+
- 资源引用路径 `ref`
|
|
222
|
+
- 图片base64 `base64`
|
|
223
|
+
- 图片blob `blob`
|
|
181
224
|
- 旋转角度 `rotate`
|
|
182
225
|
- 滤镜 `filters`
|
|
226
|
+
- 超链接 `link`
|
|
183
227
|
|
|
184
228
|
- 形状
|
|
185
229
|
- 类型 `type='shape'`
|
|
@@ -203,6 +247,7 @@ func()
|
|
|
203
247
|
- 形状调整参数 `keypoints`
|
|
204
248
|
- 元素名 `name`
|
|
205
249
|
- 自动调整大小 `autoFit`
|
|
250
|
+
- 超链接 `link`
|
|
206
251
|
|
|
207
252
|
- 表格
|
|
208
253
|
- 类型 `type='table'`
|
|
@@ -236,8 +281,8 @@ func()
|
|
|
236
281
|
- 垂直坐标 `top`
|
|
237
282
|
- 宽度 `width`
|
|
238
283
|
- 高度 `height`
|
|
284
|
+
- 资源引用路径 `ref`
|
|
239
285
|
- 视频blob `blob`
|
|
240
|
-
- 视频src `src`
|
|
241
286
|
|
|
242
287
|
- 音频
|
|
243
288
|
- 类型 `type='audio'`
|
|
@@ -245,6 +290,7 @@ func()
|
|
|
245
290
|
- 垂直坐标 `top`
|
|
246
291
|
- 宽度 `width`
|
|
247
292
|
- 高度 `height`
|
|
293
|
+
- 资源引用路径 `ref`
|
|
248
294
|
- 音频blob `blob`
|
|
249
295
|
|
|
250
296
|
- 公式
|
|
@@ -253,7 +299,9 @@ func()
|
|
|
253
299
|
- 垂直坐标 `top`
|
|
254
300
|
- 宽度 `width`
|
|
255
301
|
- 高度 `height`
|
|
256
|
-
-
|
|
302
|
+
- 公式图片引用路径 `picRef`
|
|
303
|
+
- 公式图片base64 `picBase64`
|
|
304
|
+
- 公式图片blob `picBlob`
|
|
257
305
|
- LaTeX表达式(仅支持常见结构) `latex`
|
|
258
306
|
- 文本(文本和公式混排时存在) `text`
|
|
259
307
|
|
|
@@ -264,7 +312,7 @@ func()
|
|
|
264
312
|
- 宽度 `width`
|
|
265
313
|
- 高度 `height`
|
|
266
314
|
- 子元素集合 `elements`
|
|
267
|
-
- 文本列表(Smart
|
|
315
|
+
- 文本列表(Smart图中的文字内容清单) `textList`
|
|
268
316
|
|
|
269
317
|
- 多元素组合
|
|
270
318
|
- 类型 `type='group'`
|