pptxtojson 2.0.6 → 2.1.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 +2 -0
- package/README_zh.md +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -0
- 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/border.js +38 -26
- package/src/pptxtojson.js +6 -4
package/package.json
CHANGED
package/src/border.js
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
import tinycolor from 'tinycolor2'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import tinycolor from 'tinycolor2'
|
|
2
|
+
import { getSolidFill } from './fill'
|
|
3
|
+
import { getSchemeColorFromTheme } from './schemeColor'
|
|
4
|
+
import { getTextByPathList } from './utils'
|
|
5
|
+
|
|
6
|
+
function getLineEnd(node) {
|
|
7
|
+
const attrs = getTextByPathList(node, ['attrs'])
|
|
8
|
+
if (!attrs) return undefined
|
|
9
|
+
|
|
10
|
+
const lineEnd = { type: attrs.type || 'none' }
|
|
11
|
+
if (attrs.w) lineEnd.width = attrs.w
|
|
12
|
+
if (attrs.len) lineEnd.length = attrs.len
|
|
13
|
+
return lineEnd
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function getBorder(node, elType, warpObj) {
|
|
6
17
|
let lineNode = getTextByPathList(node, ['p:spPr', 'a:ln'])
|
|
7
18
|
if (!lineNode) {
|
|
8
19
|
const lnRefNode = getTextByPathList(node, ['p:style', 'a:lnRef'])
|
|
@@ -22,12 +33,8 @@ export function getBorder(node, elType, warpObj) {
|
|
|
22
33
|
else borderWidth = 1
|
|
23
34
|
}
|
|
24
35
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const schemeClrNode = getTextByPathList(lineNode, ['a:solidFill', 'a:schemeClr'])
|
|
28
|
-
const schemeClr = 'a:' + getTextByPathList(schemeClrNode, ['attrs', 'val'])
|
|
29
|
-
borderColor = getSchemeColorFromTheme(schemeClr, warpObj)
|
|
30
|
-
}
|
|
36
|
+
const solidFill = getTextByPathList(lineNode, ['a:solidFill'])
|
|
37
|
+
let borderColor = getSolidFill(solidFill, undefined, undefined, warpObj)
|
|
31
38
|
|
|
32
39
|
if (!borderColor) {
|
|
33
40
|
const schemeClrNode = getTextByPathList(node, ['p:style', 'a:lnRef', 'a:schemeClr'])
|
|
@@ -44,15 +51,15 @@ export function getBorder(node, elType, warpObj) {
|
|
|
44
51
|
borderColor = tinycolor({ h: color.h, s: color.s, l: color.l * shade, a: color.a }).toHex()
|
|
45
52
|
}
|
|
46
53
|
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (!borderColor) borderColor = '#000000'
|
|
50
|
-
else borderColor = `#${borderColor}`
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!borderColor) borderColor = '#000000'
|
|
57
|
+
else if (!borderColor.startsWith('#')) borderColor = `#${borderColor}`
|
|
51
58
|
|
|
52
59
|
const type = getTextByPathList(lineNode, ['a:prstDash', 'attrs', 'val'])
|
|
53
60
|
let borderType = 'solid'
|
|
54
61
|
let strokeDasharray = '0'
|
|
55
|
-
switch (type) {
|
|
62
|
+
switch (type) {
|
|
56
63
|
case 'solid':
|
|
57
64
|
borderType = 'solid'
|
|
58
65
|
strokeDasharray = '0'
|
|
@@ -93,13 +100,18 @@ export function getBorder(node, elType, warpObj) {
|
|
|
93
100
|
borderType = 'dotted'
|
|
94
101
|
strokeDasharray = '2, 5'
|
|
95
102
|
break
|
|
96
|
-
default:
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
default:
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const headEnd = getLineEnd(getTextByPathList(lineNode, ['a:headEnd']))
|
|
107
|
+
const tailEnd = getLineEnd(getTextByPathList(lineNode, ['a:tailEnd']))
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
borderColor,
|
|
111
|
+
borderWidth,
|
|
112
|
+
borderType,
|
|
113
|
+
strokeDasharray,
|
|
114
|
+
headEnd,
|
|
115
|
+
tailEnd,
|
|
116
|
+
}
|
|
117
|
+
}
|
package/src/pptxtojson.js
CHANGED
|
@@ -795,7 +795,7 @@ async function genShape(node, slideLayoutSpNode, slideMasterSpNode, name, type,
|
|
|
795
795
|
let content = ''
|
|
796
796
|
if (node['p:txBody']) content = genTextBody(node['p:txBody'], node, slideLayoutSpNode, slideMasterSpNode, type, warpObj)
|
|
797
797
|
|
|
798
|
-
const { borderColor, borderWidth, borderType, strokeDasharray } = getBorder(node, type, warpObj)
|
|
798
|
+
const { borderColor, borderWidth, borderType, strokeDasharray, headEnd, tailEnd } = getBorder(node, type, warpObj)
|
|
799
799
|
const fill = await getShapeFill(node, warpObj, source, {
|
|
800
800
|
groupHierarchy,
|
|
801
801
|
slideLayoutSpNode,
|
|
@@ -831,9 +831,11 @@ async function genShape(node, slideLayoutSpNode, slideMasterSpNode, name, type,
|
|
|
831
831
|
}
|
|
832
832
|
|
|
833
833
|
if (shadow) data.shadow = shadow
|
|
834
|
-
if (autoFit) data.autoFit = autoFit
|
|
835
|
-
if (link) data.link = link
|
|
836
|
-
if (textInset) data.textInset = textInset
|
|
834
|
+
if (autoFit) data.autoFit = autoFit
|
|
835
|
+
if (link) data.link = link
|
|
836
|
+
if (textInset) data.textInset = textInset
|
|
837
|
+
if (headEnd) data.headEnd = headEnd
|
|
838
|
+
if (tailEnd) data.tailEnd = tailEnd
|
|
837
839
|
|
|
838
840
|
const isHasValidText = data.content && hasValidText(data.content)
|
|
839
841
|
|