pptxtojson 1.4.0 → 1.5.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/index.html CHANGED
@@ -98,8 +98,8 @@
98
98
  </div>
99
99
 
100
100
  <div class="link">
101
- <a target="_blank" href="https://github.com/pipipi-pikachu/pptx2json">Github仓库</a>
102
- <a target="_blank" href="https://pipipi-pikachu.github.io/PPTist/">可视化测试</a>
101
+ <a target="_blank" href="https://github.com/pipipi-pikachu/pptx2json">Github 仓库</a>
102
+ <a target="_blank" href="https://pipipi-pikachu.github.io/PPTist/">在 PPTist 中测试</a>
103
103
  </div>
104
104
  </div>
105
105
  <div id="jsoneditor"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pptxtojson",
3
- "version": "1.4.0",
3
+ "version": "1.5.1",
4
4
  "description": "A javascript tool for parsing .pptx file",
5
5
  "type": "module",
6
6
  "main": "./dist/index.umd.js",
package/rollup.config.js CHANGED
@@ -22,6 +22,11 @@ export default {
22
22
  name: 'pptxtojson',
23
23
  sourcemap: true,
24
24
  },
25
+ {
26
+ file: 'dist/index.cjs',
27
+ format: 'cjs',
28
+ sourcemap: true,
29
+ },
25
30
  {
26
31
  file: 'dist/index.js',
27
32
  format: 'es',
package/src/fill.js CHANGED
@@ -33,8 +33,10 @@ export function getFillType(node) {
33
33
  }
34
34
 
35
35
  export async function getPicFill(type, node, warpObj) {
36
+ if (!node) return ''
37
+
36
38
  let img
37
- const rId = node['a:blip']['attrs']['r:embed']
39
+ const rId = getTextByPathList(node, ['a:blip', 'attrs', 'r:embed'])
38
40
  let imgPath
39
41
  if (type === 'slideBg' || type === 'slide') {
40
42
  imgPath = getTextByPathList(warpObj, ['slideResObj', rId, 'target'])
@@ -58,7 +60,7 @@ export async function getPicFill(type, node, warpObj) {
58
60
  imgPath = escapeHtml(imgPath)
59
61
 
60
62
  const imgExt = imgPath.split('.').pop()
61
- if (imgExt === 'xml') return undefined
63
+ if (imgExt === 'xml') return ''
62
64
 
63
65
  const imgArrayBuffer = await warpObj['zip'].file(imgPath).async('arraybuffer')
64
66
  const imgMimeType = getMimeType(imgExt)
package/src/shape.js CHANGED
@@ -45,11 +45,12 @@ export function getCustomShapePath(custShapType, w, h) {
45
45
 
46
46
  let moveToNode = getTextByPathList(pathNodes, ['a:moveTo'])
47
47
 
48
- const lnToNodes = pathNodes['a:lnTo']
48
+ let lnToNodes = pathNodes['a:lnTo']
49
49
  let cubicBezToNodes = pathNodes['a:cubicBezTo']
50
50
  const arcToNodes = pathNodes['a:arcTo']
51
51
  let closeNode = getTextByPathList(pathNodes, ['a:close'])
52
52
  if (!Array.isArray(moveToNode)) moveToNode = [moveToNode]
53
+ if (!Array.isArray(lnToNodes)) lnToNodes = [lnToNodes]
53
54
 
54
55
  const multiSapeAry = []
55
56
  if (moveToNode.length > 0) {
@@ -91,9 +92,7 @@ export function getCustomShapePath(custShapType, w, h) {
91
92
  }
92
93
  if (cubicBezToNodes) {
93
94
  const cubicBezToPtNodesAry = []
94
- if (!Array.isArray(cubicBezToNodes)) {
95
- cubicBezToNodes = [cubicBezToNodes]
96
- }
95
+ if (!Array.isArray(cubicBezToNodes)) cubicBezToNodes = [cubicBezToNodes]
97
96
  Object.keys(cubicBezToNodes).forEach(key => {
98
97
  cubicBezToPtNodesAry.push(cubicBezToNodes[key]['a:pt'])
99
98
  })