Skip to content

Commit 006dbe5

Browse files
committed
build
1 parent f385079 commit 006dbe5

16 files changed

Lines changed: 421 additions & 50 deletions

File tree

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<!DOCTYPE html>
2+
<head>
3+
<title></title>
4+
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
5+
<script type="text/javascript" src="../internal.js?04dbe7f0"></script>
6+
<style type="text/css">
7+
.wrapper {
8+
width: 600px;
9+
padding: 10px;
10+
height: 352px;
11+
overflow: hidden;
12+
position: relative;
13+
border-bottom: 1px solid #d7d7d7;
14+
}
15+
16+
.wrapper .file-upload {
17+
display: flex;
18+
align-items: center;
19+
}
20+
21+
.wrapper .file-upload .file-tip {
22+
color: #999;
23+
font-size: 12px;
24+
padding-left: 10px;
25+
flex-grow: 1;
26+
}
27+
28+
.wrapper .file-manual {
29+
background: #EEE;
30+
padding: 10px;
31+
border-radius: 5px;
32+
margin-top: 10px;
33+
line-height: 2;
34+
}
35+
36+
.wrapper .file-manual .title {
37+
font-weight: bold;
38+
font-size: 120%;
39+
}
40+
41+
.wrapper .file-manual .body {
42+
}
43+
44+
.wrapper .file-manual .body li {
45+
list-style: disc;
46+
margin-left: 20px;
47+
}
48+
49+
.wrapper .upload-button {
50+
width: 100px;
51+
height: 30px;
52+
background-color: #F8F8F8;
53+
border: 1px solid #EEE;
54+
border-radius: 4px;
55+
text-align: center;
56+
line-height: 28px;
57+
cursor: pointer;
58+
position: relative;
59+
flex-shrink: 0;
60+
}
61+
62+
.wrapper .upload-button .text {
63+
display: inline-block;
64+
vertical-align: middle;
65+
}
66+
67+
.wrapper .upload-button input {
68+
position: absolute;
69+
left: 0;
70+
top: 0;
71+
opacity: 0;
72+
cursor: pointer;
73+
height: 100%;
74+
width: 100%;
75+
}
76+
77+
.wrapper .file-result {
78+
border: 1px solid #333;
79+
padding: 10px;
80+
border-radius: 5px;
81+
position: absolute;
82+
left: 10px;
83+
right: 10px;
84+
top: 50px;
85+
background: #FFF;
86+
bottom: 10px;
87+
overflow: auto;
88+
display: none;
89+
}
90+
</style>
91+
</head>
92+
<body>
93+
<div class="wrapper">
94+
<div class="file-upload">
95+
<div class="upload-button">
96+
<div class="text">选择本地文件</div>
97+
<input type="file" id="contentImport"/>
98+
</div>
99+
<div class="file-tip"></div>
100+
</div>
101+
<div class="file-manual">
102+
<div class="title">
103+
支持文档格式
104+
</div>
105+
<div class="body">
106+
<ul>
107+
<li><b>Word</b>:docx</li>
108+
<li><b>Markdown</b>:md</li>
109+
</ul>
110+
</div>
111+
</div>
112+
<div class="file-result"></div>
113+
</div>
114+
<script src="../../third-party/jquery-1.10.2.js?25f4b625"></script>
115+
<script src="https://cdn.bootcdn.net/ajax/libs/mammoth/1.6.0/mammoth.browser.min.js"></script>
116+
<script src="https://cdn.bootcdn.net/ajax/libs/showdown/2.1.0/showdown.min.js"></script>
117+
<script type="text/javascript" src="contentimport.js?07c12a80"></script>
118+
<script type="text/javascript">
119+
utils.domReady(function () {
120+
var options = {};
121+
var callbacks = {};
122+
contentImport.init(options, callbacks);
123+
});
124+
</script>
125+
</body>
126+
</html>

dist-min/dialogs/contentimport/contentimport.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist-min/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
88
<script type="text/javascript" charset="utf-8" src="ueditor.config.js"></script>
99
<script type="text/javascript" charset="utf-8" src="ueditor.all.js"></script>
10-
<script type="text/javascript" charset="utf-8" src="lang/zh-cn/zh-cn.js?70f689bf"></script>
10+
<script type="text/javascript" charset="utf-8" src="lang/zh-cn/zh-cn.js?49010875"></script>
1111
<script src="./plugins/demo/demo.js"></script>
1212
<script>
1313
// window.UEDITOR_CONFIG.toolbars[0].push('undo');

dist-min/lang/en/en.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist-min/lang/zh-cn/zh-cn.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist-min/themes/default/css/ueditor.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist-min/ueditor.all.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist-min/ueditor.config.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<!DOCTYPE html>
2+
<head>
3+
<title></title>
4+
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
5+
<script type="text/javascript" src="../internal.js?aea0c61c"></script>
6+
<style type="text/css">
7+
.wrapper {
8+
width: 600px;
9+
padding: 10px;
10+
height: 352px;
11+
overflow: hidden;
12+
position: relative;
13+
border-bottom: 1px solid #d7d7d7;
14+
}
15+
16+
.wrapper .file-upload {
17+
display: flex;
18+
align-items: center;
19+
}
20+
21+
.wrapper .file-upload .file-tip {
22+
color: #999;
23+
font-size: 12px;
24+
padding-left: 10px;
25+
flex-grow: 1;
26+
}
27+
28+
.wrapper .file-manual {
29+
background: #EEE;
30+
padding: 10px;
31+
border-radius: 5px;
32+
margin-top: 10px;
33+
line-height: 2;
34+
}
35+
36+
.wrapper .file-manual .title {
37+
font-weight: bold;
38+
font-size: 120%;
39+
}
40+
41+
.wrapper .file-manual .body {
42+
}
43+
44+
.wrapper .file-manual .body li {
45+
list-style: disc;
46+
margin-left: 20px;
47+
}
48+
49+
.wrapper .upload-button {
50+
width: 100px;
51+
height: 30px;
52+
background-color: #F8F8F8;
53+
border: 1px solid #EEE;
54+
border-radius: 4px;
55+
text-align: center;
56+
line-height: 28px;
57+
cursor: pointer;
58+
position: relative;
59+
flex-shrink: 0;
60+
}
61+
62+
.wrapper .upload-button .text {
63+
display: inline-block;
64+
vertical-align: middle;
65+
}
66+
67+
.wrapper .upload-button input {
68+
position: absolute;
69+
left: 0;
70+
top: 0;
71+
opacity: 0;
72+
cursor: pointer;
73+
height: 100%;
74+
width: 100%;
75+
}
76+
77+
.wrapper .file-result {
78+
border: 1px solid #333;
79+
padding: 10px;
80+
border-radius: 5px;
81+
position: absolute;
82+
left: 10px;
83+
right: 10px;
84+
top: 50px;
85+
background: #FFF;
86+
bottom: 10px;
87+
overflow: auto;
88+
display: none;
89+
}
90+
</style>
91+
</head>
92+
<body>
93+
<div class="wrapper">
94+
<div class="file-upload">
95+
<div class="upload-button">
96+
<div class="text">选择本地文件</div>
97+
<input type="file" id="contentImport"/>
98+
</div>
99+
<div class="file-tip"></div>
100+
</div>
101+
<div class="file-manual">
102+
<div class="title">
103+
支持文档格式
104+
</div>
105+
<div class="body">
106+
<ul>
107+
<li><b>Word</b>:docx</li>
108+
<li><b>Markdown</b>:md</li>
109+
</ul>
110+
</div>
111+
</div>
112+
<div class="file-result"></div>
113+
</div>
114+
<script src="../../third-party/jquery-1.10.2.js?628072e7"></script>
115+
<script src="https://cdn.bootcdn.net/ajax/libs/mammoth/1.6.0/mammoth.browser.min.js"></script>
116+
<script src="https://cdn.bootcdn.net/ajax/libs/showdown/2.1.0/showdown.min.js"></script>
117+
<script type="text/javascript" src="contentimport.js?50c896a4"></script>
118+
<script type="text/javascript">
119+
utils.domReady(function () {
120+
var options = {};
121+
var callbacks = {};
122+
contentImport.init(options, callbacks);
123+
});
124+
</script>
125+
</body>
126+
</html>
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
var contentImport = {};
2+
var g = $G;
3+
4+
contentImport.data = {
5+
result: null,
6+
};
7+
contentImport.init = function (opt, callbacks) {
8+
addUploadButtonListener();
9+
addOkListener();
10+
};
11+
12+
function processWord(file) {
13+
$('.file-tip').html('正在转换Word文件,请稍后...');
14+
$('.file-result').html('').hide();
15+
var reader = new FileReader();
16+
reader.onload = function (loadEvent) {
17+
mammoth.convertToHtml({
18+
arrayBuffer: loadEvent.target.result
19+
})
20+
.then(function displayResult(result) {
21+
$('.file-tip').html('转换成功');
22+
contentImport.data.result = result.value;
23+
$('.file-result').html(result.value).show();
24+
}, function (error) {
25+
$('.file-tip').html('Word文件转换失败:' + error);
26+
});
27+
};
28+
reader.onerror = function (loadEvent) {
29+
$('.file-tip').html('Word文件转换失败:' + loadEvent);
30+
};
31+
reader.readAsArrayBuffer(file);
32+
}
33+
34+
function processMarkdown(file) {
35+
$('.file-tip').html('正在转换Markdown文件,请稍后...');
36+
$('.file-result').html('').hide();
37+
var reader = new FileReader();
38+
reader.onload = function (loadEvent) {
39+
var converter = new showdown.Converter();
40+
var html = converter.makeHtml(loadEvent.target.result);
41+
$('.file-tip').html('转换成功');
42+
contentImport.data.result = html;
43+
$('.file-result').html(html).show();
44+
};
45+
reader.onerror = function (loadEvent) {
46+
$('.file-tip').html('Markdown文件转换失败:' + loadEvent);
47+
};
48+
reader.readAsText(file, "UTF-8");
49+
}
50+
51+
function addUploadButtonListener() {
52+
g('contentImport').addEventListener('change', function () {
53+
const file = this.files[0];
54+
const fileName = file.name;
55+
const fileExt = fileName.substring(fileName.lastIndexOf('.') + 1).toLowerCase();
56+
switch (fileExt) {
57+
case 'docx':
58+
case 'doc':
59+
processWord(file);
60+
break;
61+
case 'md':
62+
processMarkdown(file);
63+
break;
64+
default:
65+
$('.file-tip').html('不支持的文件格式:' + fileExt);
66+
break;
67+
}
68+
});
69+
}
70+
71+
function addOkListener() {
72+
dialog.onok = function () {
73+
if (!contentImport.data.result) {
74+
alert('请先上传文件识别内容');
75+
return false;
76+
}
77+
editor.fireEvent('saveScene');
78+
editor.execCommand("inserthtml", contentImport.data.result);
79+
editor.fireEvent('saveScene');
80+
};
81+
dialog.oncancel = function () {
82+
83+
};
84+
}

0 commit comments

Comments
 (0)