pptxtojson 0.0.1
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/.babelrc.cjs +15 -0
- package/.eslintignore +3 -0
- package/.eslintrc.cjs +77 -0
- package/LICENSE +674 -0
- package/README.md +14 -0
- package/dist/index.esm.js +1 -0
- package/dist/index.js +1 -0
- package/favicon.ico +0 -0
- package/index.html +119 -0
- package/package.json +35 -0
- package/rollup.config.js +43 -0
- package/src/pptxtojson.js +1082 -0
- package/src/utils.js +72 -0
- package/test.pptx +0 -0
package/favicon.ico
ADDED
|
Binary file
|
package/index.html
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
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.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
|
+
}
|
|
79
|
+
.upload-input {
|
|
80
|
+
display: none;
|
|
81
|
+
}
|
|
82
|
+
</style>
|
|
83
|
+
</head>
|
|
84
|
+
|
|
85
|
+
<body>
|
|
86
|
+
<div class="main">
|
|
87
|
+
<div class="input-wrap">
|
|
88
|
+
点击上传 .pptx 文件
|
|
89
|
+
<input class="upload-input" type="file" accept="application/vnd.openxmlformats-officedocument.presentationml.presentation"/>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
<div id="jsoneditor"></div>
|
|
93
|
+
|
|
94
|
+
<script>
|
|
95
|
+
const container = document.querySelector('#jsoneditor')
|
|
96
|
+
const inputWrapRef = document.querySelector('.input-wrap')
|
|
97
|
+
const inputRef = document.querySelector('.upload-input')
|
|
98
|
+
|
|
99
|
+
const editor = new JSONEditor(container, { mode: 'view' }, {})
|
|
100
|
+
|
|
101
|
+
inputRef.addEventListener('change', evt => {
|
|
102
|
+
const fileName = evt.target.files[0]
|
|
103
|
+
|
|
104
|
+
const reader = new FileReader()
|
|
105
|
+
reader.onload = async e => {
|
|
106
|
+
const json = await pptxtojson.parse(e.target.result)
|
|
107
|
+
editor.set(json)
|
|
108
|
+
console.log(json)
|
|
109
|
+
}
|
|
110
|
+
reader.readAsArrayBuffer(fileName)
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
inputWrapRef.addEventListener('click', () => {
|
|
114
|
+
inputRef.value = ''
|
|
115
|
+
inputRef.click()
|
|
116
|
+
})
|
|
117
|
+
</script>
|
|
118
|
+
</body>
|
|
119
|
+
</html>
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pptxtojson",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "A javascript tool for parsing .pptx file",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.esm.js",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"clean:dist": "rimraf dist",
|
|
10
|
+
"dev": "rollup -c -w",
|
|
11
|
+
"lint": "eslint src --ext .js,.jsx,.ts,.tsx"
|
|
12
|
+
},
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "GPL-3.0",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"jszip": "^3.10.1",
|
|
17
|
+
"tinycolor2": "^1.4.2",
|
|
18
|
+
"txml": "^5.1.1"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@babel/core": "^7.20.2",
|
|
22
|
+
"@babel/plugin-transform-runtime": "^7.19.6",
|
|
23
|
+
"@babel/preset-env": "^7.20.2",
|
|
24
|
+
"@babel/runtime": "^7.20.1",
|
|
25
|
+
"@rollup/plugin-babel": "^6.0.2",
|
|
26
|
+
"@rollup/plugin-commonjs": "^23.0.2",
|
|
27
|
+
"@rollup/plugin-eslint": "^9.0.1",
|
|
28
|
+
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
29
|
+
"@rollup/plugin-terser": "^0.1.0",
|
|
30
|
+
"eslint": "^8.27.0",
|
|
31
|
+
"rollup": "^3.3.0",
|
|
32
|
+
"rollup-plugin-node-builtins": "^2.1.2",
|
|
33
|
+
"rollup-plugin-node-globals": "^1.4.0"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { nodeResolve } from '@rollup/plugin-node-resolve'
|
|
2
|
+
import commonjs from '@rollup/plugin-commonjs'
|
|
3
|
+
import { babel } from '@rollup/plugin-babel'
|
|
4
|
+
import eslint from '@rollup/plugin-eslint'
|
|
5
|
+
import terser from '@rollup/plugin-terser'
|
|
6
|
+
import globals from 'rollup-plugin-node-globals'
|
|
7
|
+
import builtins from 'rollup-plugin-node-builtins'
|
|
8
|
+
|
|
9
|
+
const onwarn = warning => {
|
|
10
|
+
if (warning.code === 'CIRCULAR_DEPENDENCY') return
|
|
11
|
+
|
|
12
|
+
console.warn(`(!) ${warning.message}`) // eslint-disable-line
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
input: 'src/pptxtojson.js',
|
|
17
|
+
onwarn,
|
|
18
|
+
output: [
|
|
19
|
+
{
|
|
20
|
+
file: 'dist/index.js',
|
|
21
|
+
format: 'umd',
|
|
22
|
+
name: 'pptxtojson',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
file: 'dist/index.esm.js',
|
|
26
|
+
format: 'es',
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
plugins: [
|
|
30
|
+
nodeResolve({
|
|
31
|
+
preferBuiltins: false,
|
|
32
|
+
}),
|
|
33
|
+
commonjs(),
|
|
34
|
+
eslint(),
|
|
35
|
+
babel({
|
|
36
|
+
babelHelpers: 'runtime',
|
|
37
|
+
exclude: ['node_modules/**'],
|
|
38
|
+
}),
|
|
39
|
+
terser(),
|
|
40
|
+
globals(),
|
|
41
|
+
builtins(),
|
|
42
|
+
]
|
|
43
|
+
}
|