pptxtojson 1.0.1 → 1.0.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 +9 -5
- package/dist/index.d.ts +5 -2
- 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/fontStyle.js +1 -1
- package/src/pptxtojson.js +12 -3
- package/src/table.js +45 -4
package/package.json
CHANGED
package/src/fontStyle.js
CHANGED
|
@@ -95,7 +95,7 @@ export function getFontShadow(node, warpObj) {
|
|
|
95
95
|
if (shadow) {
|
|
96
96
|
const { h, v, blur, color } = shadow
|
|
97
97
|
if (!isNaN(v) && !isNaN(h)) {
|
|
98
|
-
return h + '
|
|
98
|
+
return h + 'pt ' + v + 'pt ' + (blur ? blur + 'pt' : '') + ' ' + color
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
}
|
package/src/pptxtojson.js
CHANGED
|
@@ -9,7 +9,7 @@ import { genTextBody } from './text'
|
|
|
9
9
|
import { getCustomShapePath } from './shape'
|
|
10
10
|
import { extractFileExtension, base64ArrayBuffer, getTextByPathList, angleToDegrees, getMimeType, isVideoLink, escapeHtml } from './utils'
|
|
11
11
|
import { getShadow } from './shadow'
|
|
12
|
-
import { getTableCellParams, getTableRowParams } from './table'
|
|
12
|
+
import { getTableBorders, getTableCellParams, getTableRowParams } from './table'
|
|
13
13
|
import { RATIO_EMUs_Points } from './constants'
|
|
14
14
|
|
|
15
15
|
export async function parse(file) {
|
|
@@ -748,6 +748,14 @@ function genTable(node, warpObj) {
|
|
|
748
748
|
}
|
|
749
749
|
if (thisTblStyle) thisTblStyle['tblStylAttrObj'] = tblStylAttrObj
|
|
750
750
|
|
|
751
|
+
let tbl_border
|
|
752
|
+
const tblStyl = getTextByPathList(thisTblStyle, ['a:wholeTbl', 'a:tcStyle'])
|
|
753
|
+
const tblBorderStyl = getTextByPathList(tblStyl, ['a:tcBdr'])
|
|
754
|
+
if (tblBorderStyl) {
|
|
755
|
+
const tbl_borders = getTableBorders(tblBorderStyl, warpObj)
|
|
756
|
+
if (tbl_borders) tbl_border = tbl_borders.bottom || tbl_borders.left || tbl_borders.right || tbl_borders.top
|
|
757
|
+
}
|
|
758
|
+
|
|
751
759
|
let tbl_bgcolor = ''
|
|
752
760
|
let tbl_bgFillschemeClr = getTextByPathList(thisTblStyle, ['a:tblBg', 'a:fillRef'])
|
|
753
761
|
if (tbl_bgFillschemeClr) {
|
|
@@ -821,7 +829,7 @@ function genTable(node, warpObj) {
|
|
|
821
829
|
if (cell.hMerge) td.hMerge = cell.hMerge
|
|
822
830
|
if (cell.fontBold || fontBold) td.fontBold = cell.fontBold || fontBold
|
|
823
831
|
if (cell.fontColor || fontColor) td.fontColor = cell.fontColor || fontColor
|
|
824
|
-
if (cell.fillColor || fillColor || tbl_bgcolor) td.
|
|
832
|
+
if (cell.fillColor || fillColor || tbl_bgcolor) td.fillColor = cell.fillColor || fillColor || tbl_bgcolor
|
|
825
833
|
|
|
826
834
|
tr.push(td)
|
|
827
835
|
}
|
|
@@ -852,7 +860,7 @@ function genTable(node, warpObj) {
|
|
|
852
860
|
if (cell.hMerge) td.hMerge = cell.hMerge
|
|
853
861
|
if (cell.fontBold || fontBold) td.fontBold = cell.fontBold || fontBold
|
|
854
862
|
if (cell.fontColor || fontColor) td.fontColor = cell.fontColor || fontColor
|
|
855
|
-
if (cell.fillColor || fillColor || tbl_bgcolor) td.
|
|
863
|
+
if (cell.fillColor || fillColor || tbl_bgcolor) td.fillColor = cell.fillColor || fillColor || tbl_bgcolor
|
|
856
864
|
|
|
857
865
|
tr.push(td)
|
|
858
866
|
}
|
|
@@ -866,6 +874,7 @@ function genTable(node, warpObj) {
|
|
|
866
874
|
width,
|
|
867
875
|
height,
|
|
868
876
|
data,
|
|
877
|
+
...(tbl_border || {}),
|
|
869
878
|
}
|
|
870
879
|
}
|
|
871
880
|
|
package/src/table.js
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
import { getShapeFill, getSolidFill } from './fill'
|
|
2
2
|
import { getTextByPathList } from './utils'
|
|
3
|
+
import { getBorder } from './border'
|
|
3
4
|
|
|
5
|
+
export function getTableBorders(node, warpObj) {
|
|
6
|
+
let borderStyles = {}
|
|
7
|
+
if (node['a:bottom']) {
|
|
8
|
+
const obj = {
|
|
9
|
+
'p:spPr': {
|
|
10
|
+
'a:ln': node['a:bottom']['a:ln']
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const border = getBorder(obj, undefined, warpObj)
|
|
14
|
+
borderStyles.bottom = border
|
|
15
|
+
}
|
|
16
|
+
if (node['a:top']) {
|
|
17
|
+
const obj = {
|
|
18
|
+
'p:spPr': {
|
|
19
|
+
'a:ln': node['a:top']['a:ln']
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const border = getBorder(obj, undefined, warpObj)
|
|
23
|
+
borderStyles.top = border
|
|
24
|
+
}
|
|
25
|
+
if (node['a:right']) {
|
|
26
|
+
const obj = {
|
|
27
|
+
'p:spPr': {
|
|
28
|
+
'a:ln': node['a:right']['a:ln']
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const border = getBorder(obj, undefined, warpObj)
|
|
32
|
+
borderStyles.right = border
|
|
33
|
+
}
|
|
34
|
+
if (node['a:left']) {
|
|
35
|
+
const obj = {
|
|
36
|
+
'p:spPr': {
|
|
37
|
+
'a:ln': node['a:left']['a:ln']
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const border = getBorder(obj, undefined, warpObj)
|
|
41
|
+
borderStyles.left = border
|
|
42
|
+
}
|
|
43
|
+
return borderStyles
|
|
44
|
+
}
|
|
4
45
|
|
|
5
46
|
export function getTableCellParams(tcNode, thisTblStyle, cellSource, warpObj) {
|
|
6
47
|
const rowSpan = getTextByPathList(tcNode, ['attrs', 'rowSpan'])
|
|
@@ -35,10 +76,10 @@ export function getTableCellParams(tcNode, thisTblStyle, cellSource, warpObj) {
|
|
|
35
76
|
fillColor,
|
|
36
77
|
fontColor,
|
|
37
78
|
fontBold,
|
|
38
|
-
rowSpan,
|
|
39
|
-
colSpan,
|
|
40
|
-
vMerge,
|
|
41
|
-
hMerge,
|
|
79
|
+
rowSpan: rowSpan ? +rowSpan : undefined,
|
|
80
|
+
colSpan: colSpan ? +colSpan : undefined,
|
|
81
|
+
vMerge: vMerge ? +vMerge : undefined,
|
|
82
|
+
hMerge: hMerge ? +hMerge : undefined,
|
|
42
83
|
}
|
|
43
84
|
}
|
|
44
85
|
|