pptxtojson 1.3.2 → 1.5.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 +8 -5
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1 -0
- 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 +2 -2
- package/package.json +1 -1
- package/rollup.config.js +5 -0
- package/src/fill.js +4 -2
- package/src/pptxtojson.js +20 -1
- package/src/shapePath.js +4635 -0
- package/src/utils.js +4 -1
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/"
|
|
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
package/rollup.config.js
CHANGED
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'
|
|
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
|
|
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/pptxtojson.js
CHANGED
|
@@ -12,6 +12,7 @@ import { getShadow } from './shadow'
|
|
|
12
12
|
import { getTableBorders, getTableCellParams, getTableRowParams } from './table'
|
|
13
13
|
import { RATIO_EMUs_Points } from './constants'
|
|
14
14
|
import { findOMath, latexFormart, parseOMath } from './math'
|
|
15
|
+
import { getShapePath } from './shapePath'
|
|
15
16
|
|
|
16
17
|
export async function parse(file) {
|
|
17
18
|
const slides = []
|
|
@@ -438,6 +439,12 @@ async function processMathNode(node, warpObj, source) {
|
|
|
438
439
|
const blipFill = getTextByPathList(fallback, ['p:sp', 'p:spPr', 'a:blipFill'])
|
|
439
440
|
const picBase64 = await getPicFill(source, blipFill, warpObj)
|
|
440
441
|
|
|
442
|
+
let text = ''
|
|
443
|
+
if (getTextByPathList(choice, ['p:sp', 'p:txBody', 'a:p', 'a:r'])) {
|
|
444
|
+
const sp = getTextByPathList(choice, ['p:sp'])
|
|
445
|
+
text = genTextBody(sp['p:txBody'], sp, undefined, undefined, warpObj)
|
|
446
|
+
}
|
|
447
|
+
|
|
441
448
|
return {
|
|
442
449
|
type: 'math',
|
|
443
450
|
top,
|
|
@@ -446,6 +453,7 @@ async function processMathNode(node, warpObj, source) {
|
|
|
446
453
|
height,
|
|
447
454
|
latex,
|
|
448
455
|
picBase64,
|
|
456
|
+
text,
|
|
449
457
|
order,
|
|
450
458
|
}
|
|
451
459
|
}
|
|
@@ -628,12 +636,17 @@ async function genShape(node, pNode, slideLayoutSpNode, slideMasterSpNode, name,
|
|
|
628
636
|
path: d,
|
|
629
637
|
}
|
|
630
638
|
}
|
|
639
|
+
|
|
640
|
+
let shapePath = ''
|
|
641
|
+
if (shapType) shapePath = getShapePath(shapType, width, height, node)
|
|
642
|
+
|
|
631
643
|
if (shapType && (type === 'obj' || !type || shapType !== 'rect')) {
|
|
632
644
|
if (!isHasValidText) data.content = ''
|
|
633
645
|
return {
|
|
634
646
|
...data,
|
|
635
647
|
type: 'shape',
|
|
636
648
|
shapType,
|
|
649
|
+
path: shapePath,
|
|
637
650
|
}
|
|
638
651
|
}
|
|
639
652
|
if (shapType && !isHasValidText && (fill || borderWidth)) {
|
|
@@ -642,6 +655,7 @@ async function genShape(node, pNode, slideLayoutSpNode, slideMasterSpNode, name,
|
|
|
642
655
|
type: 'shape',
|
|
643
656
|
content: '',
|
|
644
657
|
shapType,
|
|
658
|
+
path: shapePath,
|
|
645
659
|
}
|
|
646
660
|
}
|
|
647
661
|
return {
|
|
@@ -665,7 +679,12 @@ async function processPicNode(node, warpObj, source) {
|
|
|
665
679
|
const imgFileExt = extractFileExtension(imgName).toLowerCase()
|
|
666
680
|
const zip = warpObj['zip']
|
|
667
681
|
const imgArrayBuffer = await zip.file(imgName).async('arraybuffer')
|
|
668
|
-
|
|
682
|
+
|
|
683
|
+
let xfrmNode = node['p:spPr']['a:xfrm']
|
|
684
|
+
if (!xfrmNode) {
|
|
685
|
+
const idx = getTextByPathList(node, ['p:nvPicPr', 'p:nvPr', 'p:ph', 'attrs', 'idx'])
|
|
686
|
+
if (idx) xfrmNode = getTextByPathList(warpObj['slideLayoutTables'], ['idxTable', idx, 'p:spPr', 'a:xfrm'])
|
|
687
|
+
}
|
|
669
688
|
|
|
670
689
|
const mimeType = getMimeType(imgFileExt)
|
|
671
690
|
const { top, left } = getPosition(xfrmNode, undefined, undefined)
|