pptxtojson 1.2.0 → 1.2.2
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 +4 -3
- package/dist/index.d.ts +2 -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/dist/wx.png +0 -0
- package/package.json +1 -1
- package/src/border.js +12 -2
- package/src/fill.js +16 -4
- package/src/pptxtojson.js +17 -6
- package/src/shape.js +1 -1
package/dist/wx.png
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/src/border.js
CHANGED
|
@@ -3,9 +3,19 @@ import { getSchemeColorFromTheme } from './schemeColor'
|
|
|
3
3
|
import { getTextByPathList } from './utils'
|
|
4
4
|
|
|
5
5
|
export function getBorder(node, elType, warpObj) {
|
|
6
|
-
|
|
6
|
+
let lineNode = node['p:spPr']['a:ln']
|
|
7
|
+
if (!lineNode) {
|
|
8
|
+
const lnRefNode = getTextByPathList(node, ['p:style', 'a:lnRef'])
|
|
9
|
+
if (lnRefNode) {
|
|
10
|
+
const lnIdx = getTextByPathList(lnRefNode, ['attrs', 'idx'])
|
|
11
|
+
lineNode = warpObj['themeContent']['a:theme']['a:themeElements']['a:fmtScheme']['a:lnStyleLst']['a:ln'][Number(lnIdx) - 1]
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
if (!lineNode) lineNode = node
|
|
15
|
+
|
|
16
|
+
const isNoFill = getTextByPathList(lineNode, ['a:noFill'])
|
|
7
17
|
|
|
8
|
-
let borderWidth = parseInt(getTextByPathList(lineNode, ['attrs', 'w'])) / 12700
|
|
18
|
+
let borderWidth = isNoFill ? 0 : (parseInt(getTextByPathList(lineNode, ['attrs', 'w'])) / 12700)
|
|
9
19
|
if (isNaN(borderWidth)) {
|
|
10
20
|
if (lineNode) borderWidth = 0
|
|
11
21
|
else if (elType !== 'obj') borderWidth = 0
|
package/src/fill.js
CHANGED
|
@@ -112,10 +112,16 @@ export function getGradientFill(node, warpObj) {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
const lin = node['a:lin']
|
|
115
|
-
let rot =
|
|
116
|
-
|
|
115
|
+
let rot = 0
|
|
116
|
+
let pathType = 'line'
|
|
117
|
+
if (lin) rot = angleToDegrees(lin['attrs']['ang'])
|
|
118
|
+
else {
|
|
119
|
+
const path = node['a:path']
|
|
120
|
+
if (path && path['attrs'] && path['attrs']['path']) pathType = path['attrs']['path']
|
|
121
|
+
}
|
|
117
122
|
return {
|
|
118
123
|
rot,
|
|
124
|
+
path: pathType,
|
|
119
125
|
colors: colors.sort((a, b) => parseInt(a.pos) - parseInt(b.pos)),
|
|
120
126
|
}
|
|
121
127
|
}
|
|
@@ -136,10 +142,16 @@ export function getBgGradientFill(bgPr, phClr, slideMasterContent, warpObj) {
|
|
|
136
142
|
}
|
|
137
143
|
}
|
|
138
144
|
const lin = grdFill['a:lin']
|
|
139
|
-
let rot =
|
|
140
|
-
|
|
145
|
+
let rot = 0
|
|
146
|
+
let pathType = 'line'
|
|
147
|
+
if (lin) rot = angleToDegrees(lin['attrs']['ang']) + 0
|
|
148
|
+
else {
|
|
149
|
+
const path = grdFill['a:path']
|
|
150
|
+
if (path && path['attrs'] && path['attrs']['path']) pathType = path['attrs']['path']
|
|
151
|
+
}
|
|
141
152
|
return {
|
|
142
153
|
rot,
|
|
154
|
+
path: pathType,
|
|
143
155
|
colors: colors.sort((a, b) => parseInt(a.pos) - parseInt(b.pos)),
|
|
144
156
|
}
|
|
145
157
|
}
|
package/src/pptxtojson.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import JSZip from 'jszip'
|
|
2
2
|
import { readXmlFile } from './readXmlFile'
|
|
3
3
|
import { getBorder } from './border'
|
|
4
|
-
import { getSlideBackgroundFill, getShapeFill, getSolidFill } from './fill'
|
|
4
|
+
import { getSlideBackgroundFill, getShapeFill, getSolidFill, getPicFill } from './fill'
|
|
5
5
|
import { getChartInfo } from './chart'
|
|
6
6
|
import { getVerticalAlign } from './align'
|
|
7
7
|
import { getPosition, getSize } from './position'
|
|
@@ -414,7 +414,7 @@ async function processNodesInSlide(nodeKey, nodeValue, warpObj, source) {
|
|
|
414
414
|
json = await processGroupSpNode(getTextByPathList(nodeValue, ['mc:Fallback']), warpObj, source)
|
|
415
415
|
}
|
|
416
416
|
else if (getTextByPathList(nodeValue, ['mc:Choice'])) {
|
|
417
|
-
json = processMathNode(
|
|
417
|
+
json = await processMathNode(nodeValue, warpObj, source)
|
|
418
418
|
}
|
|
419
419
|
break
|
|
420
420
|
default:
|
|
@@ -423,15 +423,21 @@ async function processNodesInSlide(nodeKey, nodeValue, warpObj, source) {
|
|
|
423
423
|
return json
|
|
424
424
|
}
|
|
425
425
|
|
|
426
|
-
function processMathNode(node) {
|
|
426
|
+
async function processMathNode(node, warpObj, source) {
|
|
427
|
+
const choice = getTextByPathList(node, ['mc:Choice'])
|
|
428
|
+
const fallback = getTextByPathList(node, ['mc:Fallback'])
|
|
429
|
+
|
|
427
430
|
const order = node['attrs']['order']
|
|
428
|
-
const xfrmNode = getTextByPathList(
|
|
431
|
+
const xfrmNode = getTextByPathList(choice, ['p:sp', 'p:spPr', 'a:xfrm'])
|
|
429
432
|
const { top, left } = getPosition(xfrmNode, undefined, undefined)
|
|
430
433
|
const { width, height } = getSize(xfrmNode, undefined, undefined)
|
|
431
434
|
|
|
432
|
-
const oMath = findOMath(
|
|
435
|
+
const oMath = findOMath(choice)[0]
|
|
433
436
|
const latex = latexFormart(parseOMath(oMath))
|
|
434
437
|
|
|
438
|
+
const blipFill = getTextByPathList(fallback, ['p:sp', 'p:spPr', 'a:blipFill'])
|
|
439
|
+
const picBase64 = await getPicFill(source, blipFill, warpObj)
|
|
440
|
+
|
|
435
441
|
return {
|
|
436
442
|
type: 'math',
|
|
437
443
|
top,
|
|
@@ -439,6 +445,7 @@ function processMathNode(node) {
|
|
|
439
445
|
width,
|
|
440
446
|
height,
|
|
441
447
|
latex,
|
|
448
|
+
picBase64,
|
|
442
449
|
order,
|
|
443
450
|
}
|
|
444
451
|
}
|
|
@@ -949,7 +956,11 @@ async function genChart(node, warpObj) {
|
|
|
949
956
|
const { width, height } = getSize(xfrmNode, undefined, undefined)
|
|
950
957
|
|
|
951
958
|
const rid = node['a:graphic']['a:graphicData']['c:chart']['attrs']['r:id']
|
|
952
|
-
|
|
959
|
+
let refName = getTextByPathList(warpObj['slideResObj'], [rid, 'target'])
|
|
960
|
+
if (!refName) refName = getTextByPathList(warpObj['layoutResObj'], [rid, 'target'])
|
|
961
|
+
if (!refName) refName = getTextByPathList(warpObj['masterResObj'], [rid, 'target'])
|
|
962
|
+
if (!refName) return {}
|
|
963
|
+
|
|
953
964
|
const content = await readXmlFile(warpObj['zip'], refName)
|
|
954
965
|
const plotArea = getTextByPathList(content, ['c:chartSpace', 'c:chart', 'c:plotArea'])
|
|
955
966
|
|
package/src/shape.js
CHANGED
|
@@ -35,7 +35,7 @@ export function getCustomShapePath(custShapType, w, h) {
|
|
|
35
35
|
const pathLstNode = getTextByPathList(custShapType, ['a:pathLst'])
|
|
36
36
|
let pathNodes = getTextByPathList(pathLstNode, ['a:path'])
|
|
37
37
|
|
|
38
|
-
if (Array.isArray(pathNodes)) pathNodes = pathNodes.
|
|
38
|
+
if (Array.isArray(pathNodes)) pathNodes = pathNodes.shift()
|
|
39
39
|
|
|
40
40
|
const maxX = parseInt(pathNodes['attrs']['w'])
|
|
41
41
|
const maxY = parseInt(pathNodes['attrs']['h'])
|