pptxtojson 2.0.5 → 2.0.6
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 +1 -0
- package/README_zh.md +6 -5
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +20 -12
- 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 +15 -3
package/package.json
CHANGED
package/src/pptxtojson.js
CHANGED
|
@@ -267,7 +267,9 @@ async function processSingleSlide(zip, sldFileName, themeContent, defaultTextSty
|
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
+
let currentThemeContent = themeContent
|
|
270
271
|
if (themeFilename) {
|
|
272
|
+
currentThemeContent = currentThemeContent || await readXmlFileCached(zip, themeFilename, xmlCache)
|
|
271
273
|
const themeName = themeFilename.split('/').pop()
|
|
272
274
|
const themeResFileName = themeFilename.replace(themeName, '_rels/' + themeName) + '.rels'
|
|
273
275
|
const themeResContent = await readXmlFile(zip, themeResFileName)
|
|
@@ -305,7 +307,7 @@ async function processSingleSlide(zip, sldFileName, themeContent, defaultTextSty
|
|
|
305
307
|
slideMasterTextStyles,
|
|
306
308
|
layoutResObj,
|
|
307
309
|
masterResObj,
|
|
308
|
-
themeContent,
|
|
310
|
+
themeContent: currentThemeContent,
|
|
309
311
|
themeResObj,
|
|
310
312
|
diagramFileCache: {},
|
|
311
313
|
defaultTextStyle,
|
|
@@ -775,6 +777,7 @@ async function genShape(node, slideLayoutSpNode, slideMasterSpNode, name, type,
|
|
|
775
777
|
|
|
776
778
|
const { top, left } = getPosition(slideXfrmNode, slideLayoutXfrmNode, slideMasterXfrmNode)
|
|
777
779
|
const { width, height } = getSize(slideXfrmNode, slideLayoutXfrmNode, slideMasterXfrmNode)
|
|
780
|
+
const pathViewBox = { x: 0, y: 0, width, height }
|
|
778
781
|
|
|
779
782
|
const isFlipV = getTextByPathList(slideXfrmNode, ['attrs', 'flipV']) === '1'
|
|
780
783
|
const isFlipH = getTextByPathList(slideXfrmNode, ['attrs', 'flipH']) === '1'
|
|
@@ -846,6 +849,7 @@ async function genShape(node, slideLayoutSpNode, slideMasterSpNode, name, type,
|
|
|
846
849
|
type: 'shape',
|
|
847
850
|
shapType: 'custom',
|
|
848
851
|
path: d,
|
|
852
|
+
pathViewBox: { x: 0, y: 0, width: w, height: h },
|
|
849
853
|
}
|
|
850
854
|
if (isStrokeOnlyCustomGeometry(custShapType)) customShapeData.strokeOnly = true
|
|
851
855
|
|
|
@@ -854,26 +858,34 @@ async function genShape(node, slideLayoutSpNode, slideMasterSpNode, name, type,
|
|
|
854
858
|
|
|
855
859
|
let shapePath = ''
|
|
856
860
|
if (shapType) shapePath = getShapePath(shapType, width, height, node)
|
|
861
|
+
const STROKE_ONLY_PRESET_SHAPE_TYPES = ['arc', 'leftBrace', 'rightBrace', 'bracePair', 'leftBracket', 'rightBracket', 'bracketPair']
|
|
862
|
+
const isStrokeOnlyPresetShape = STROKE_ONLY_PRESET_SHAPE_TYPES.includes(shapType)
|
|
857
863
|
|
|
858
864
|
if (shapType && (type === 'obj' || !type || shapType !== 'rect')) {
|
|
859
865
|
if (!isHasValidText) data.content = ''
|
|
860
|
-
|
|
866
|
+
const shapeData = {
|
|
861
867
|
...data,
|
|
862
868
|
type: 'shape',
|
|
863
869
|
shapType,
|
|
864
870
|
path: shapePath,
|
|
871
|
+
pathViewBox,
|
|
865
872
|
keypoints,
|
|
866
873
|
}
|
|
874
|
+
if (isStrokeOnlyPresetShape) shapeData.strokeOnly = true
|
|
875
|
+
return shapeData
|
|
867
876
|
}
|
|
868
877
|
if (shapType && !isHasValidText && (fill || borderWidth)) {
|
|
869
|
-
|
|
878
|
+
const shapeData = {
|
|
870
879
|
...data,
|
|
871
880
|
type: 'shape',
|
|
872
881
|
content: '',
|
|
873
882
|
shapType,
|
|
874
883
|
path: shapePath,
|
|
884
|
+
pathViewBox,
|
|
875
885
|
keypoints,
|
|
876
886
|
}
|
|
887
|
+
if (isStrokeOnlyPresetShape) shapeData.strokeOnly = true
|
|
888
|
+
return shapeData
|
|
877
889
|
}
|
|
878
890
|
return {
|
|
879
891
|
...data,
|