pptxtojson 0.0.12 → 0.0.13
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/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 +7 -43
package/package.json
CHANGED
package/src/pptxtojson.js
CHANGED
|
@@ -143,7 +143,6 @@ async function processSingleSlide(zip, sldFileName) {
|
|
|
143
143
|
const resContent = await readXmlFile(zip, resName)
|
|
144
144
|
let relationshipArray = resContent['Relationships']['Relationship']
|
|
145
145
|
let layoutFilename = ''
|
|
146
|
-
let diagramFilename = ''
|
|
147
146
|
const slideResObj = {}
|
|
148
147
|
|
|
149
148
|
if (relationshipArray.constructor === Array) {
|
|
@@ -153,7 +152,6 @@ async function processSingleSlide(zip, sldFileName) {
|
|
|
153
152
|
layoutFilename = relationshipArrayItem['attrs']['Target'].replace('../', 'ppt/')
|
|
154
153
|
break
|
|
155
154
|
case 'http://schemas.microsoft.com/office/2007/relationships/diagramDrawing':
|
|
156
|
-
diagramFilename = relationshipArrayItem['attrs']['Target'].replace('../', 'ppt/')
|
|
157
155
|
slideResObj[relationshipArrayItem['attrs']['Id']] = {
|
|
158
156
|
type: relationshipArrayItem['attrs']['Type'].replace('http://schemas.openxmlformats.org/officeDocument/2006/relationships/', ''),
|
|
159
157
|
target: relationshipArrayItem['attrs']['Target'].replace('../', 'ppt/')
|
|
@@ -251,38 +249,6 @@ async function processSingleSlide(zip, sldFileName) {
|
|
|
251
249
|
}
|
|
252
250
|
}
|
|
253
251
|
|
|
254
|
-
const diagramResObj = {}
|
|
255
|
-
let digramFileContent = {}
|
|
256
|
-
if (diagramFilename) {
|
|
257
|
-
const diagName = diagramFilename.split('/').pop()
|
|
258
|
-
const diagramResFileName = diagramFilename.replace(diagName, '_rels/' + diagName) + '.rels'
|
|
259
|
-
digramFileContent = await readXmlFile(zip, diagramFilename)
|
|
260
|
-
if (digramFileContent && digramFileContent && digramFileContent !== '') {
|
|
261
|
-
let digramFileContentObjToStr = JSON.stringify(digramFileContent)
|
|
262
|
-
digramFileContentObjToStr = digramFileContentObjToStr.replace(/dsp:/g, 'p:')
|
|
263
|
-
digramFileContent = JSON.parse(digramFileContentObjToStr)
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
const digramResContent = await readXmlFile(zip, diagramResFileName)
|
|
267
|
-
if (digramResContent) {
|
|
268
|
-
relationshipArray = digramResContent['Relationships']['Relationship']
|
|
269
|
-
if (relationshipArray.constructor === Array) {
|
|
270
|
-
for (const relationshipArrayItem of relationshipArray) {
|
|
271
|
-
diagramResObj[relationshipArrayItem['attrs']['Id']] = {
|
|
272
|
-
type: relationshipArrayItem['attrs']['Type'].replace('http://schemas.openxmlformats.org/officeDocument/2006/relationships/', ''),
|
|
273
|
-
target: relationshipArrayItem['attrs']['Target'].replace('../', 'ppt/'),
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
else {
|
|
278
|
-
diagramResObj[relationshipArray['attrs']['Id']] = {
|
|
279
|
-
type: relationshipArray['attrs']['Type'].replace('http://schemas.openxmlformats.org/officeDocument/2006/relationships/', ''),
|
|
280
|
-
target: relationshipArray['attrs']['Target'].replace('../', 'ppt/'),
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
252
|
const slideContent = await readXmlFile(zip, sldFileName)
|
|
287
253
|
const nodes = slideContent['p:sld']['p:cSld']['p:spTree']
|
|
288
254
|
const warpObj = {
|
|
@@ -298,8 +264,6 @@ async function processSingleSlide(zip, sldFileName) {
|
|
|
298
264
|
masterResObj: masterResObj,
|
|
299
265
|
themeContent: themeContent,
|
|
300
266
|
themeResObj: themeResObj,
|
|
301
|
-
digramFileContent: digramFileContent,
|
|
302
|
-
diagramResObj: diagramResObj,
|
|
303
267
|
defaultTextStyle: defaultTextStyle,
|
|
304
268
|
}
|
|
305
269
|
const bgColor = await getSlideBackgroundFill(warpObj)
|
|
@@ -869,7 +833,10 @@ function genTextBody(textBodyNode, slideLayoutSpNode, slideMasterSpNode, type, w
|
|
|
869
833
|
|
|
870
834
|
if (brNode.length > 1) brNode.shift()
|
|
871
835
|
rNode = rNode.concat(brNode)
|
|
872
|
-
rNode.sort((a, b) =>
|
|
836
|
+
rNode.sort((a, b) => {
|
|
837
|
+
if (!a.attrs || !b.attrs) return true
|
|
838
|
+
return a.attrs.order - b.attrs.order
|
|
839
|
+
})
|
|
873
840
|
}
|
|
874
841
|
}
|
|
875
842
|
|
|
@@ -974,7 +941,7 @@ function genTable(node, warpObj) {
|
|
|
974
941
|
}
|
|
975
942
|
}
|
|
976
943
|
else {
|
|
977
|
-
const text = genTextBody(tcNodes['a:txBody'])
|
|
944
|
+
const text = genTextBody(tcNodes['a:txBody'], undefined, undefined, undefined, warpObj)
|
|
978
945
|
tr.push({ text })
|
|
979
946
|
}
|
|
980
947
|
|
|
@@ -987,12 +954,12 @@ function genTable(node, warpObj) {
|
|
|
987
954
|
|
|
988
955
|
if (tcNodes.constructor === Array) {
|
|
989
956
|
for (const tcNode of tcNodes) {
|
|
990
|
-
const text = genTextBody(tcNode['a:txBody'])
|
|
957
|
+
const text = genTextBody(tcNode['a:txBody'], undefined, undefined, undefined, warpObj)
|
|
991
958
|
tr.push({ text })
|
|
992
959
|
}
|
|
993
960
|
}
|
|
994
961
|
else {
|
|
995
|
-
const text = genTextBody(tcNodes['a:txBody'])
|
|
962
|
+
const text = genTextBody(tcNodes['a:txBody'], undefined, undefined, undefined, warpObj)
|
|
996
963
|
tr.push({ text })
|
|
997
964
|
}
|
|
998
965
|
data.push(tr)
|
|
@@ -1334,9 +1301,6 @@ async function getPicFill(type, node, warpObj) {
|
|
|
1334
1301
|
else if (type === 'themeBg') {
|
|
1335
1302
|
imgPath = getTextByPathList(warpObj, ['themeResObj', rId, 'target'])
|
|
1336
1303
|
}
|
|
1337
|
-
else if (type === 'diagramBg') {
|
|
1338
|
-
imgPath = getTextByPathList(warpObj, ['diagramResObj', rId, 'target'])
|
|
1339
|
-
}
|
|
1340
1304
|
if (!imgPath) return imgPath
|
|
1341
1305
|
|
|
1342
1306
|
img = getTextByPathList(warpObj, ['loaded-images', imgPath])
|