pptxtojson 0.1.4 → 0.1.6

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/index.html CHANGED
@@ -1,125 +1,125 @@
1
- <!DOCTYPE html>
2
- <html lang="zh-CN">
3
- <head>
4
- <meta charset="utf-8">
5
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
- <meta name="viewport" content="width=device-width, initial-scale=1">
7
- <meta name="description" content="基于JavaScript的 .pptx 文件解析工具丨A javascript tool for parsing .pptx file" />
8
- <meta name="keywords" content="ppt,powerpoint,office powerpoint,json,javascript,PPT解析,PPT转JSON" />
9
- <link rel="icon" href="favicon.ico">
10
- <title>pptxtojson - PPTX转JSON</title>
11
-
12
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jsoneditor@9.9.2/dist/jsoneditor.min.css">
13
- <script src="https://cdn.jsdelivr.net/npm/jsoneditor@9.9.2/dist/jsoneditor.min.js"></script>
14
- <script src="dist/index.umd.js"></script>
15
-
16
- <style>
17
- * {
18
- margin: 0;
19
- padding: 0;
20
- box-sizing: border-box;
21
- }
22
- html, body {
23
- height: 100%;
24
- }
25
- ::-webkit-scrollbar {
26
- width: 5px;
27
- height: 5px;
28
- background-color: #fff;
29
- }
30
- ::-webkit-scrollbar-thumb {
31
- background-color: #c1c1c1;
32
- }
33
-
34
- body {
35
- display: flex;
36
- }
37
- .main {
38
- width: 50%;
39
- min-width: 600px;
40
- height: 100%;
41
- margin-right: 10px;
42
- display: flex;
43
- flex-direction: column;
44
- justify-content: center;
45
- align-items: center;
46
- }
47
- #jsoneditor {
48
- flex: 1;
49
- height: 100%;
50
- padding: 10px;
51
- }
52
- .jsoneditor-mode-view {
53
- border: 2px solid #ddd;
54
- }
55
- .jsoneditor-menu {
56
- display: none;
57
- }
58
- .jsoneditor-navigation-bar {
59
- display: none;
60
- }
61
- .jsoneditor-outer.has-nav-bar.has-main-menu-bar {
62
- margin-top: 0 !important;
63
- padding-top: 0 !important;
64
- }
65
-
66
- .input-wrap {
67
- width: 300px;
68
- height: 80px;
69
- background-color: #d14424;
70
- color: #fff;
71
- border-radius: 2px;
72
- line-height: 80px;
73
- font-size: 18px;
74
- font-weight: 700;
75
- text-align: center;
76
- cursor: pointer;
77
- user-select: none;
78
- margin-bottom: 20px;
79
- }
80
- .upload-input {
81
- display: none;
82
- }
83
- </style>
84
- </head>
85
-
86
- <body>
87
- <div class="main">
88
- <div class="input-wrap">
89
- 点击上传 .pptx 文件
90
- <input class="upload-input" type="file" accept="application/vnd.openxmlformats-officedocument.presentationml.presentation"/>
91
- </div>
92
-
93
- <a href="https://github.com/pipipi-pikachu/pptx2json">Github</a>
94
- </div>
95
- <div id="jsoneditor"></div>
96
-
97
- <script>
98
- const container = document.querySelector('#jsoneditor')
99
- const inputWrapRef = document.querySelector('.input-wrap')
100
- const inputRef = document.querySelector('.upload-input')
101
-
102
- const editor = new JSONEditor(container, { mode: 'view' }, {})
103
-
104
- inputRef.addEventListener('change', evt => {
105
- const fileName = evt.target.files[0]
106
-
107
- const reader = new FileReader()
108
- reader.onload = async e => {
109
- const json = await pptxtojson.parse(e.target.result, {
110
- // slideFactor: 75 / 914400,
111
- // fontsizeFactor: 100 / 96,
112
- })
113
- editor.set(json)
114
- console.log(json)
115
- }
116
- reader.readAsArrayBuffer(fileName)
117
- })
118
-
119
- inputWrapRef.addEventListener('click', () => {
120
- inputRef.value = ''
121
- inputRef.click()
122
- })
123
- </script>
124
- </body>
125
- </html>
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1">
7
+ <meta name="description" content="基于JavaScript的 .pptx 文件解析工具丨A javascript tool for parsing .pptx file" />
8
+ <meta name="keywords" content="ppt,powerpoint,office powerpoint,json,javascript,PPT解析,PPT转JSON" />
9
+ <link rel="icon" href="favicon.ico">
10
+ <title>pptxtojson - PPTX转JSON</title>
11
+
12
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jsoneditor@9.9.2/dist/jsoneditor.min.css">
13
+ <script src="https://cdn.jsdelivr.net/npm/jsoneditor@9.9.2/dist/jsoneditor.min.js"></script>
14
+ <script src="dist/index.umd.js"></script>
15
+
16
+ <style>
17
+ * {
18
+ margin: 0;
19
+ padding: 0;
20
+ box-sizing: border-box;
21
+ }
22
+ html, body {
23
+ height: 100%;
24
+ }
25
+ ::-webkit-scrollbar {
26
+ width: 5px;
27
+ height: 5px;
28
+ background-color: #fff;
29
+ }
30
+ ::-webkit-scrollbar-thumb {
31
+ background-color: #c1c1c1;
32
+ }
33
+
34
+ body {
35
+ display: flex;
36
+ }
37
+ .main {
38
+ width: 50%;
39
+ min-width: 600px;
40
+ height: 100%;
41
+ margin-right: 10px;
42
+ display: flex;
43
+ flex-direction: column;
44
+ justify-content: center;
45
+ align-items: center;
46
+ }
47
+ #jsoneditor {
48
+ flex: 1;
49
+ height: 100%;
50
+ padding: 10px;
51
+ }
52
+ .jsoneditor-mode-view {
53
+ border: 2px solid #ddd;
54
+ }
55
+ .jsoneditor-menu {
56
+ display: none;
57
+ }
58
+ .jsoneditor-navigation-bar {
59
+ display: none;
60
+ }
61
+ .jsoneditor-outer.has-nav-bar.has-main-menu-bar {
62
+ margin-top: 0 !important;
63
+ padding-top: 0 !important;
64
+ }
65
+
66
+ .input-wrap {
67
+ width: 300px;
68
+ height: 80px;
69
+ background-color: #d14424;
70
+ color: #fff;
71
+ border-radius: 2px;
72
+ line-height: 80px;
73
+ font-size: 18px;
74
+ font-weight: 700;
75
+ text-align: center;
76
+ cursor: pointer;
77
+ user-select: none;
78
+ margin-bottom: 20px;
79
+ }
80
+ .upload-input {
81
+ display: none;
82
+ }
83
+ </style>
84
+ </head>
85
+
86
+ <body>
87
+ <div class="main">
88
+ <div class="input-wrap">
89
+ 点击上传 .pptx 文件
90
+ <input class="upload-input" type="file" accept="application/vnd.openxmlformats-officedocument.presentationml.presentation"/>
91
+ </div>
92
+
93
+ <a href="https://github.com/pipipi-pikachu/pptx2json">Github</a>
94
+ </div>
95
+ <div id="jsoneditor"></div>
96
+
97
+ <script>
98
+ const container = document.querySelector('#jsoneditor')
99
+ const inputWrapRef = document.querySelector('.input-wrap')
100
+ const inputRef = document.querySelector('.upload-input')
101
+
102
+ const editor = new JSONEditor(container, { mode: 'view' }, {})
103
+
104
+ inputRef.addEventListener('change', evt => {
105
+ const fileName = evt.target.files[0]
106
+
107
+ const reader = new FileReader()
108
+ reader.onload = async e => {
109
+ const json = await pptxtojson.parse(e.target.result, {
110
+ // slideFactor: 75 / 914400,
111
+ // fontsizeFactor: 100 / 96,
112
+ })
113
+ editor.set(json)
114
+ console.log(json)
115
+ }
116
+ reader.readAsArrayBuffer(fileName)
117
+ })
118
+
119
+ inputWrapRef.addEventListener('click', () => {
120
+ inputRef.value = ''
121
+ inputRef.click()
122
+ })
123
+ </script>
124
+ </body>
125
+ </html>
package/package.json CHANGED
@@ -1,39 +1,49 @@
1
- {
2
- "name": "pptxtojson",
3
- "version": "0.1.4",
4
- "description": "A javascript tool for parsing .pptx file",
5
- "type": "module",
6
- "main": "./dist/index.umd.js",
7
- "module": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
9
- "scripts": {
10
- "clean:dist": "rimraf dist",
11
- "dev": "rollup -c -w",
12
- "lint": "eslint src --ext .js,.jsx,.ts,.tsx"
13
- },
14
- "author": "",
15
- "license": "MIT",
16
- "publishConfig": {
17
- "registry": "https://registry.npmjs.com/"
18
- },
19
- "dependencies": {
20
- "jszip": "^3.10.1",
21
- "tinycolor2": "1.6.0",
22
- "txml": "^5.1.1"
23
- },
24
- "devDependencies": {
25
- "@babel/core": "^7.20.2",
26
- "@babel/plugin-transform-runtime": "^7.19.6",
27
- "@babel/preset-env": "^7.20.2",
28
- "@babel/runtime": "^7.20.1",
29
- "@rollup/plugin-babel": "^6.0.2",
30
- "@rollup/plugin-commonjs": "^23.0.2",
31
- "@rollup/plugin-eslint": "^9.0.1",
32
- "@rollup/plugin-node-resolve": "^15.0.1",
33
- "@rollup/plugin-terser": "^0.1.0",
34
- "eslint": "^8.27.0",
35
- "rollup": "^3.3.0",
36
- "rollup-plugin-node-builtins": "^2.1.2",
37
- "rollup-plugin-node-globals": "^1.4.0"
38
- }
39
- }
1
+ {
2
+ "name": "pptxtojson",
3
+ "version": "0.1.6",
4
+ "description": "A javascript tool for parsing .pptx file",
5
+ "type": "module",
6
+ "main": "./dist/index.umd.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "scripts": {
10
+ "clean:dist": "rimraf dist",
11
+ "dev": "rollup -c -w",
12
+ "lint": "eslint src --ext .js,.jsx,.ts,.tsx"
13
+ },
14
+ "author": "pipipi_pikachu@163.com",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/pipipi-pikachu/pptxtojson"
18
+ },
19
+ "keywords": [
20
+ "ppt",
21
+ "pptx",
22
+ "json"
23
+ ],
24
+ "homepage": "https://github.com/pipipi-pikachu/pptxtojson",
25
+ "license": "MIT",
26
+ "publishConfig": {
27
+ "registry": "https://registry.npmjs.org"
28
+ },
29
+ "dependencies": {
30
+ "jszip": "^3.10.1",
31
+ "tinycolor2": "1.6.0",
32
+ "txml": "^5.1.1"
33
+ },
34
+ "devDependencies": {
35
+ "@babel/core": "^7.20.2",
36
+ "@babel/plugin-transform-runtime": "^7.19.6",
37
+ "@babel/preset-env": "^7.20.2",
38
+ "@babel/runtime": "^7.20.1",
39
+ "@rollup/plugin-babel": "^6.0.2",
40
+ "@rollup/plugin-commonjs": "^23.0.2",
41
+ "@rollup/plugin-eslint": "^9.0.1",
42
+ "@rollup/plugin-node-resolve": "^15.0.1",
43
+ "@rollup/plugin-terser": "^0.1.0",
44
+ "eslint": "^8.27.0",
45
+ "rollup": "^3.3.0",
46
+ "rollup-plugin-node-builtins": "^2.1.2",
47
+ "rollup-plugin-node-globals": "^1.4.0"
48
+ }
49
+ }
package/src/border.js CHANGED
@@ -8,7 +8,7 @@ export function getBorder(node, elType, warpObj) {
8
8
  let borderWidth = parseInt(getTextByPathList(lineNode, ['attrs', 'w'])) / 12700
9
9
  if (isNaN(borderWidth)) {
10
10
  if (lineNode) borderWidth = 0
11
- else if (elType === 'text') borderWidth = 0
11
+ else if (elType !== 'obj') borderWidth = 0
12
12
  else borderWidth = 1
13
13
  }
14
14
 
package/src/fill.js CHANGED
@@ -263,7 +263,7 @@ export function getSolidFill(solidFill, clrMap, phClr, warpObj) {
263
263
  }
264
264
  else if (solidFill['a:schemeClr']) {
265
265
  const schemeClr = 'a:' + getTextByPathList(solidFill['a:schemeClr'], ['attrs', 'val'])
266
- color = getSchemeColorFromTheme(schemeClr, warpObj)
266
+ color = getSchemeColorFromTheme(schemeClr, warpObj) || '#ffffffff'
267
267
 
268
268
  let lumMod = parseInt(getTextByPathList(solidFill, ['a:schemeClr', 'a:lumMod', 'attrs', 'val'])) / 100000
269
269
  let lumOff = parseInt(getTextByPathList(solidFill, ['a:schemeClr', 'a:lumOff', 'attrs', 'val'])) / 100000
package/src/fontStyle.js CHANGED
@@ -29,7 +29,7 @@ export function getFontColor(node) {
29
29
  export function getFontSize(node, slideLayoutSpNode, type, slideMasterTextStyles, fontsizeFactor) {
30
30
  let fontSize
31
31
 
32
- if (node['a:rPr']) fontSize = parseInt(node['a:rPr']['attrs']['sz']) / 100
32
+ if (getTextByPathList(node, ['a:rPr', 'attrs', 'sz'])) fontSize = getTextByPathList(node, ['a:rPr', 'attrs', 'sz']) / 100
33
33
 
34
34
  if ((isNaN(fontSize) || !fontSize)) {
35
35
  const sz = getTextByPathList(slideLayoutSpNode, ['p:txBody', 'a:lstStyle', 'a:lvl1pPr', 'a:defRPr', 'attrs', 'sz'])
package/src/pptxtojson.js CHANGED
@@ -567,7 +567,7 @@ function genShape(node, slideLayoutSpNode, slideMasterSpNode, name, type, warpOb
567
567
  path: d,
568
568
  }
569
569
  }
570
- if (shapType && type !== 'text') {
570
+ if (shapType && type === 'obj') {
571
571
  return {
572
572
  ...data,
573
573
  type: 'shape',