pptxtojson 1.0.2 → 1.0.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pptxtojson",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "A javascript tool for parsing .pptx file",
5
5
  "type": "module",
6
6
  "main": "./dist/index.umd.js",
package/src/fill.js CHANGED
@@ -452,9 +452,9 @@ export function getShapeFill(node, isSvgMode, warpObj) {
452
452
  }
453
453
 
454
454
  export function getSolidFill(solidFill, clrMap, phClr, warpObj) {
455
- if (!solidFill) return solidFill
455
+ if (!solidFill) return ''
456
456
 
457
- let color = '#ffffff'
457
+ let color = ''
458
458
  let clrNode
459
459
 
460
460
  if (solidFill['a:srgbClr']) {
@@ -464,7 +464,7 @@ export function getSolidFill(solidFill, clrMap, phClr, warpObj) {
464
464
  else if (solidFill['a:schemeClr']) {
465
465
  clrNode = solidFill['a:schemeClr']
466
466
  const schemeClr = 'a:' + getTextByPathList(clrNode, ['attrs', 'val'])
467
- color = getSchemeColorFromTheme(schemeClr, warpObj, clrMap, phClr) || '#ffffff'
467
+ color = getSchemeColorFromTheme(schemeClr, warpObj, clrMap, phClr) || ''
468
468
  }
469
469
  else if (solidFill['a:scrgbClr']) {
470
470
  clrNode = solidFill['a:scrgbClr']
package/src/fontStyle.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { getTextByPathList } from './utils'
2
2
  import { getShadow } from './shadow'
3
+ import { getFillType, getSolidFill } from './fill'
3
4
 
4
5
  export function getFontType(node, type, warpObj) {
5
6
  let typeface = getTextByPathList(node, ['a:rPr', 'a:latin', 'attrs', 'typeface'])
@@ -21,9 +22,30 @@ export function getFontType(node, type, warpObj) {
21
22
  return typeface || ''
22
23
  }
23
24
 
24
- export function getFontColor(node) {
25
- const color = getTextByPathList(node, ['a:rPr', 'a:solidFill', 'a:srgbClr', 'attrs', 'val'])
26
- return color ? `#${color}` : ''
25
+ export function getFontColor(node, pNode, lstStyle, pFontStyle, lvl, warpObj) {
26
+ const rPrNode = getTextByPathList(node, ['a:rPr'])
27
+ let filTyp, color
28
+ if (rPrNode) {
29
+ filTyp = getFillType(rPrNode)
30
+ if (filTyp === 'SOLID_FILL') {
31
+ const solidFillNode = rPrNode['a:solidFill']
32
+ color = getSolidFill(solidFillNode, undefined, undefined, warpObj)
33
+ }
34
+ }
35
+ if (!color && getTextByPathList(lstStyle, ['a:lvl' + lvl + 'pPr', 'a:defRPr'])) {
36
+ const lstStyledefRPr = getTextByPathList(lstStyle, ['a:lvl' + lvl + 'pPr', 'a:defRPr'])
37
+ filTyp = getFillType(lstStyledefRPr)
38
+ if (filTyp === 'SOLID_FILL') {
39
+ const solidFillNode = lstStyledefRPr['a:solidFill']
40
+ color = getSolidFill(solidFillNode, undefined, undefined, warpObj)
41
+ }
42
+ }
43
+ if (!color) {
44
+ const sPstyle = getTextByPathList(pNode, ['p:style', 'a:fontRef'])
45
+ if (sPstyle) color = getSolidFill(sPstyle, undefined, undefined, warpObj)
46
+ if (!color && pFontStyle) color = getSolidFill(pFontStyle, undefined, undefined, warpObj)
47
+ }
48
+ return color || ''
27
49
  }
28
50
 
29
51
  export function getFontSize(node, slideLayoutSpNode, type, slideMasterTextStyles) {
package/src/pptxtojson.js CHANGED
@@ -410,7 +410,10 @@ async function processGroupSpNode(node, warpObj, source) {
410
410
  const cy = parseInt(xfrmNode['a:ext']['attrs']['cy']) * RATIO_EMUs_Points
411
411
  const chcx = parseInt(xfrmNode['a:chExt']['attrs']['cx']) * RATIO_EMUs_Points
412
412
  const chcy = parseInt(xfrmNode['a:chExt']['attrs']['cy']) * RATIO_EMUs_Points
413
- // children coordinate
413
+
414
+ let rotate = getTextByPathList(xfrmNode, ['attrs', 'rot']) || 0
415
+ if (rotate) rotate = angleToDegrees(rotate)
416
+
414
417
  const ws = cx / chcx
415
418
  const hs = cy / chcy
416
419
 
@@ -434,6 +437,7 @@ async function processGroupSpNode(node, warpObj, source) {
434
437
  left: x,
435
438
  width: cx,
436
439
  height: cy,
440
+ rotate,
437
441
  elements: elements.map(element => ({
438
442
  ...element,
439
443
  left: (element.left - chx) * ws,
package/src/table.js CHANGED
@@ -3,7 +3,7 @@ import { getTextByPathList } from './utils'
3
3
  import { getBorder } from './border'
4
4
 
5
5
  export function getTableBorders(node, warpObj) {
6
- let borderStyles = {}
6
+ const borderStyles = {}
7
7
  if (node['a:bottom']) {
8
8
  const obj = {
9
9
  'p:spPr': {
package/src/text.js CHANGED
@@ -19,6 +19,8 @@ export function genTextBody(textBodyNode, spNode, slideLayoutSpNode, type, warpO
19
19
 
20
20
  let text = ''
21
21
 
22
+ const pFontStyle = getTextByPathList(spNode, ['p:style', 'a:fontRef'])
23
+
22
24
  const pNode = textBodyNode['a:p']
23
25
  const pNodes = pNode.constructor === Array ? pNode : [pNode]
24
26
 
@@ -71,10 +73,10 @@ export function genTextBody(textBodyNode, spNode, slideLayoutSpNode, type, warpO
71
73
  text += `<p style="text-align: ${align};">`
72
74
  }
73
75
 
74
- if (!rNode) text += genSpanElement(pNode, slideLayoutSpNode, type, warpObj)
76
+ if (!rNode) text += genSpanElement(pNode, spNode, textBodyNode, pFontStyle, slideLayoutSpNode, type, warpObj)
75
77
  else {
76
78
  for (const rNodeItem of rNode) {
77
- text += genSpanElement(rNodeItem, slideLayoutSpNode, type, warpObj)
79
+ text += genSpanElement(rNodeItem, pNode, textBodyNode, pFontStyle, slideLayoutSpNode, type, warpObj)
78
80
  }
79
81
  }
80
82
 
@@ -94,15 +96,21 @@ export function getListType(node) {
94
96
  return ''
95
97
  }
96
98
 
97
- export function genSpanElement(node, slideLayoutSpNode, type, warpObj) {
99
+ export function genSpanElement(node, pNode, textBodyNode, pFontStyle, slideLayoutSpNode, type, warpObj) {
100
+ const lstStyle = textBodyNode['a:lstStyle']
98
101
  const slideMasterTextStyles = warpObj['slideMasterTextStyles']
99
102
 
103
+ let lvl = 1
104
+ const pPrNode = pNode['a:pPr']
105
+ const lvlNode = getTextByPathList(pPrNode, ['attrs', 'lvl'])
106
+ if (lvlNode !== undefined) lvl = parseInt(lvlNode) + 1
107
+
100
108
  let text = node['a:t']
101
109
  if (typeof text !== 'string') text = getTextByPathList(node, ['a:fld', 'a:t'])
102
110
  if (typeof text !== 'string') text = '&nbsp;'
103
111
 
104
112
  let styleText = ''
105
- const fontColor = getFontColor(node)
113
+ const fontColor = getFontColor(node, pNode, lstStyle, pFontStyle, lvl, warpObj)
106
114
  const fontSize = getFontSize(node, slideLayoutSpNode, type, slideMasterTextStyles)
107
115
  const fontType = getFontType(node, type, warpObj)
108
116
  const fontBold = getFontBold(node)