pptxtojson 1.3.2 → 1.4.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 +2 -1
- 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/package.json +1 -1
- package/src/pptxtojson.js +20 -1
- package/src/shapePath.js +4635 -0
- package/src/utils.js +4 -1
package/package.json
CHANGED
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)
|