pptxtojson 1.8.0 → 1.9.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 +6 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/align.js +34 -0
- package/src/pptxtojson.js +3 -1
package/package.json
CHANGED
package/src/align.js
CHANGED
|
@@ -62,4 +62,38 @@ export function getVerticalAlign(node, slideLayoutSpNode, slideMasterSpNode) {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
return (anchor === 'ctr') ? 'mid' : ((anchor === 'b') ? 'down' : 'up')
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function getTextAutoFit(node, slideLayoutSpNode, slideMasterSpNode) {
|
|
68
|
+
function checkBodyPr(bodyPr) {
|
|
69
|
+
if (!bodyPr) return null
|
|
70
|
+
|
|
71
|
+
if (bodyPr['a:noAutofit']) return { result: null }
|
|
72
|
+
else if (bodyPr['a:spAutoFit']) return { result: { type: 'shape' } }
|
|
73
|
+
else if (bodyPr['a:normAutofit']) {
|
|
74
|
+
const fontScale = getTextByPathList(bodyPr['a:normAutofit'], ['attrs', 'fontScale'])
|
|
75
|
+
if (fontScale) {
|
|
76
|
+
const scalePercent = parseInt(fontScale) / 1000
|
|
77
|
+
return {
|
|
78
|
+
result: {
|
|
79
|
+
type: 'text',
|
|
80
|
+
fontScale: scalePercent,
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return { result: { type: 'text' } }
|
|
85
|
+
}
|
|
86
|
+
return null
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const nodeCheck = checkBodyPr(getTextByPathList(node, ['p:txBody', 'a:bodyPr']))
|
|
90
|
+
if (nodeCheck) return nodeCheck.result
|
|
91
|
+
|
|
92
|
+
const layoutCheck = checkBodyPr(getTextByPathList(slideLayoutSpNode, ['p:txBody', 'a:bodyPr']))
|
|
93
|
+
if (layoutCheck) return layoutCheck.result
|
|
94
|
+
|
|
95
|
+
const masterCheck = checkBodyPr(getTextByPathList(slideMasterSpNode, ['p:txBody', 'a:bodyPr']))
|
|
96
|
+
if (masterCheck) return masterCheck.result
|
|
97
|
+
|
|
98
|
+
return null
|
|
65
99
|
}
|
package/src/pptxtojson.js
CHANGED
|
@@ -3,7 +3,7 @@ import { readXmlFile } from './readXmlFile'
|
|
|
3
3
|
import { getBorder } from './border'
|
|
4
4
|
import { getSlideBackgroundFill, getShapeFill, getSolidFill, getPicFill, getPicFilters } from './fill'
|
|
5
5
|
import { getChartInfo } from './chart'
|
|
6
|
-
import { getVerticalAlign } from './align'
|
|
6
|
+
import { getVerticalAlign, getTextAutoFit } from './align'
|
|
7
7
|
import { getPosition, getSize } from './position'
|
|
8
8
|
import { genTextBody } from './text'
|
|
9
9
|
import { getCustomShapePath } from './shape'
|
|
@@ -617,6 +617,7 @@ async function genShape(node, pNode, slideLayoutSpNode, slideMasterSpNode, name,
|
|
|
617
617
|
|
|
618
618
|
const vAlign = getVerticalAlign(node, slideLayoutSpNode, slideMasterSpNode, type)
|
|
619
619
|
const isVertical = getTextByPathList(node, ['p:txBody', 'a:bodyPr', 'attrs', 'vert']) === 'eaVert'
|
|
620
|
+
const autoFit = getTextAutoFit(node, slideLayoutSpNode, slideMasterSpNode)
|
|
620
621
|
|
|
621
622
|
const data = {
|
|
622
623
|
left,
|
|
@@ -638,6 +639,7 @@ async function genShape(node, pNode, slideLayoutSpNode, slideMasterSpNode, name,
|
|
|
638
639
|
}
|
|
639
640
|
|
|
640
641
|
if (shadow) data.shadow = shadow
|
|
642
|
+
if (autoFit) data.autoFit = autoFit
|
|
641
643
|
|
|
642
644
|
const isHasValidText = data.content && hasValidText(data.content)
|
|
643
645
|
|