pptxtojson 1.1.0 → 1.2.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 +55 -37
- package/dist/index.d.ts +45 -30
- 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/dist/wx.png +0 -0
- package/index.html +1 -1
- package/package.json +2 -2
- package/src/chart.js +41 -1
- package/src/fill.js +72 -37
- package/src/pptxtojson.js +187 -172
- package/src/readXmlFile.js +8 -4
- package/src/table.js +6 -2
- package/src/utils.js +9 -2
package/src/readXmlFile.js
CHANGED
|
@@ -19,11 +19,15 @@ export function simplifyLostLess(children, parentAttributes = {}) {
|
|
|
19
19
|
if (!out[child.tagName]) out[child.tagName] = []
|
|
20
20
|
|
|
21
21
|
const kids = simplifyLostLess(child.children || [], child.attributes)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
kids.attrs =
|
|
22
|
+
|
|
23
|
+
if (typeof kids === 'object') {
|
|
24
|
+
if (!kids.attrs) kids.attrs = { order: cust_attr_order++ }
|
|
25
|
+
else kids.attrs.order = cust_attr_order++
|
|
26
26
|
}
|
|
27
|
+
if (Object.keys(child.attributes || {}).length) {
|
|
28
|
+
kids.attrs = { ...kids.attrs, ...child.attributes }
|
|
29
|
+
}
|
|
30
|
+
out[child.tagName].push(kids)
|
|
27
31
|
}
|
|
28
32
|
for (const child in out) {
|
|
29
33
|
if (out[child].length === 1) out[child] = out[child][0]
|
package/src/table.js
CHANGED
|
@@ -43,7 +43,7 @@ export function getTableBorders(node, warpObj) {
|
|
|
43
43
|
return borderStyles
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export function getTableCellParams(tcNode, thisTblStyle, cellSource, warpObj) {
|
|
46
|
+
export async function getTableCellParams(tcNode, thisTblStyle, cellSource, warpObj) {
|
|
47
47
|
const rowSpan = getTextByPathList(tcNode, ['attrs', 'rowSpan'])
|
|
48
48
|
const colSpan = getTextByPathList(tcNode, ['attrs', 'gridSpan'])
|
|
49
49
|
const vMerge = getTextByPathList(tcNode, ['attrs', 'vMerge'])
|
|
@@ -55,7 +55,11 @@ export function getTableCellParams(tcNode, thisTblStyle, cellSource, warpObj) {
|
|
|
55
55
|
const getCelFill = getTextByPathList(tcNode, ['a:tcPr'])
|
|
56
56
|
if (getCelFill) {
|
|
57
57
|
const cellObj = { 'p:spPr': getCelFill }
|
|
58
|
-
|
|
58
|
+
const fill = await getShapeFill(cellObj, undefined, warpObj)
|
|
59
|
+
|
|
60
|
+
if (fill && fill.type === 'color' && fill.value) {
|
|
61
|
+
fillColor = fill.value
|
|
62
|
+
}
|
|
59
63
|
}
|
|
60
64
|
if (!fillColor) {
|
|
61
65
|
let bgFillschemeClr
|
package/src/utils.js
CHANGED
|
@@ -54,8 +54,6 @@ export function eachElement(node, func) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
export function getTextByPathList(node, path) {
|
|
57
|
-
if (path.constructor !== Array) throw Error('Error of path type! path is not array.')
|
|
58
|
-
|
|
59
57
|
if (!node) return node
|
|
60
58
|
|
|
61
59
|
for (const key of path) {
|
|
@@ -150,4 +148,13 @@ export function toHex(n) {
|
|
|
150
148
|
hex = '0' + hex
|
|
151
149
|
}
|
|
152
150
|
return hex
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export function hasValidText(htmlString) {
|
|
154
|
+
if (!DOMParser) return true
|
|
155
|
+
|
|
156
|
+
const parser = new DOMParser()
|
|
157
|
+
const doc = parser.parseFromString(htmlString, 'text/html')
|
|
158
|
+
const text = doc.body.textContent || doc.body.innerText
|
|
159
|
+
return text.trim() !== ''
|
|
153
160
|
}
|