pptxtojson 1.12.1 → 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 CHANGED
@@ -27,7 +27,6 @@
27
27
 
28
28
  ### 📏 长度值单位
29
29
  输出的JSON中,所有数值长度值单位都为`pt`(point)
30
- > 注意:在0.x版本中,所有输出的长度值单位都是px(像素)
31
30
 
32
31
  # 🔨安装
33
32
  ```
@@ -35,8 +34,11 @@ npm install pptxtojson
35
34
  ```
36
35
 
37
36
  # 💿用法
37
+ ```javascript
38
+ parse(file, options = {})
39
+ ```
38
40
 
39
- ### 浏览器
41
+ ### 浏览器示例
40
42
  ```html
41
43
  <input type="file" accept="application/vnd.openxmlformats-officedocument.presentationml.presentation"/>
42
44
  ```
@@ -49,14 +51,18 @@ document.querySelector('input').addEventListener('change', evt => {
49
51
 
50
52
  const reader = new FileReader()
51
53
  reader.onload = async e => {
52
- 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
+ })
53
59
  console.log(json)
54
60
  }
55
61
  reader.readAsArrayBuffer(file)
56
62
  })
57
63
  ```
58
64
 
59
- ### Node.js(实验性,1.5.0以上版本)
65
+ ### Node.js 示例(实验性,1.5.0以上版本)
60
66
  ```javascript
61
67
  const pptxtojson = require('pptxtojson/dist/index.cjs')
62
68
  const fs = require('fs')
@@ -64,7 +70,11 @@ const fs = require('fs')
64
70
  async function func() {
65
71
  const buffer = fs.readFileSync('test.pptx')
66
72
 
67
- 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
+ })
68
78
  console.log(json)
69
79
  }
70
80
 
@@ -120,7 +130,33 @@ func()
120
130
  }
121
131
  ```
122
132
 
123
- # 📕 完整功能支持
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
+ # 📕 解析属性
124
160
 
125
161
  - 幻灯片主题色 `themeColors`
126
162
 
@@ -182,7 +218,9 @@ func()
182
218
  - 非实线边框样式 `borderStrokeDasharray`
183
219
  - 裁剪形状 `geom`
184
220
  - 裁剪范围 `rect`
185
- - 图片地址(base64) `src`
221
+ - 资源引用路径 `ref`
222
+ - 图片base64 `base64`
223
+ - 图片blob `blob`
186
224
  - 旋转角度 `rotate`
187
225
  - 滤镜 `filters`
188
226
  - 超链接 `link`
@@ -243,8 +281,8 @@ func()
243
281
  - 垂直坐标 `top`
244
282
  - 宽度 `width`
245
283
  - 高度 `height`
284
+ - 资源引用路径 `ref`
246
285
  - 视频blob `blob`
247
- - 视频src `src`
248
286
 
249
287
  - 音频
250
288
  - 类型 `type='audio'`
@@ -252,6 +290,7 @@ func()
252
290
  - 垂直坐标 `top`
253
291
  - 宽度 `width`
254
292
  - 高度 `height`
293
+ - 资源引用路径 `ref`
255
294
  - 音频blob `blob`
256
295
 
257
296
  - 公式
@@ -260,7 +299,9 @@ func()
260
299
  - 垂直坐标 `top`
261
300
  - 宽度 `width`
262
301
  - 高度 `height`
263
- - 公式图片 `picBase64`
302
+ - 公式图片引用路径 `picRef`
303
+ - 公式图片base64 `picBase64`
304
+ - 公式图片blob `picBlob`
264
305
  - LaTeX表达式(仅支持常见结构) `latex`
265
306
  - 文本(文本和公式混排时存在) `text`
266
307
 
@@ -271,7 +312,7 @@ func()
271
312
  - 宽度 `width`
272
313
  - 高度 `height`
273
314
  - 子元素集合 `elements`
274
- - 文本列表(Smart图中的文字内容清单,仅在elements无法解析时存在) `textList`
315
+ - 文本列表(Smart图中的文字内容清单) `textList`
275
316
 
276
317
  - 多元素组合
277
318
  - 类型 `type='group'`