Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
modstart committed Dec 2, 2023
1 parent f385079 commit 006dbe5
Show file tree
Hide file tree
Showing 16 changed files with 421 additions and 50 deletions.
126 changes: 126 additions & 0 deletions dist-min/dialogs/contentimport/contentimport.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<!DOCTYPE html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<script type="text/javascript" src="../internal.js?04dbe7f0"></script>
<style type="text/css">
.wrapper {
width: 600px;
padding: 10px;
height: 352px;
overflow: hidden;
position: relative;
border-bottom: 1px solid #d7d7d7;
}

.wrapper .file-upload {
display: flex;
align-items: center;
}

.wrapper .file-upload .file-tip {
color: #999;
font-size: 12px;
padding-left: 10px;
flex-grow: 1;
}

.wrapper .file-manual {
background: #EEE;
padding: 10px;
border-radius: 5px;
margin-top: 10px;
line-height: 2;
}

.wrapper .file-manual .title {
font-weight: bold;
font-size: 120%;
}

.wrapper .file-manual .body {
}

.wrapper .file-manual .body li {
list-style: disc;
margin-left: 20px;
}

.wrapper .upload-button {
width: 100px;
height: 30px;
background-color: #F8F8F8;
border: 1px solid #EEE;
border-radius: 4px;
text-align: center;
line-height: 28px;
cursor: pointer;
position: relative;
flex-shrink: 0;
}

.wrapper .upload-button .text {
display: inline-block;
vertical-align: middle;
}

.wrapper .upload-button input {
position: absolute;
left: 0;
top: 0;
opacity: 0;
cursor: pointer;
height: 100%;
width: 100%;
}

.wrapper .file-result {
border: 1px solid #333;
padding: 10px;
border-radius: 5px;
position: absolute;
left: 10px;
right: 10px;
top: 50px;
background: #FFF;
bottom: 10px;
overflow: auto;
display: none;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="file-upload">
<div class="upload-button">
<div class="text">选择本地文件</div>
<input type="file" id="contentImport"/>
</div>
<div class="file-tip"></div>
</div>
<div class="file-manual">
<div class="title">
支持文档格式
</div>
<div class="body">
<ul>
<li><b>Word</b>:docx</li>
<li><b>Markdown</b>:md</li>
</ul>
</div>
</div>
<div class="file-result"></div>
</div>
<script src="../../third-party/jquery-1.10.2.js?25f4b625"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/mammoth/1.6.0/mammoth.browser.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/showdown/2.1.0/showdown.min.js"></script>
<script type="text/javascript" src="contentimport.js?07c12a80"></script>
<script type="text/javascript">
utils.domReady(function () {
var options = {};
var callbacks = {};
contentImport.init(options, callbacks);
});
</script>
</body>
</html>
2 changes: 2 additions & 0 deletions dist-min/dialogs/contentimport/contentimport.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist-min/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<script type="text/javascript" charset="utf-8" src="ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="ueditor.all.js"></script>
<script type="text/javascript" charset="utf-8" src="lang/zh-cn/zh-cn.js?70f689bf"></script>
<script type="text/javascript" charset="utf-8" src="lang/zh-cn/zh-cn.js?49010875"></script>
<script src="./plugins/demo/demo.js"></script>
<script>
// window.UEDITOR_CONFIG.toolbars[0].push('undo');
Expand Down
2 changes: 1 addition & 1 deletion dist-min/lang/en/en.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist-min/lang/zh-cn/zh-cn.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist-min/themes/default/css/ueditor.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist-min/ueditor.all.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist-min/ueditor.config.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

126 changes: 126 additions & 0 deletions dist/dialogs/contentimport/contentimport.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<!DOCTYPE html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<script type="text/javascript" src="../internal.js?aea0c61c"></script>
<style type="text/css">
.wrapper {
width: 600px;
padding: 10px;
height: 352px;
overflow: hidden;
position: relative;
border-bottom: 1px solid #d7d7d7;
}

.wrapper .file-upload {
display: flex;
align-items: center;
}

.wrapper .file-upload .file-tip {
color: #999;
font-size: 12px;
padding-left: 10px;
flex-grow: 1;
}

.wrapper .file-manual {
background: #EEE;
padding: 10px;
border-radius: 5px;
margin-top: 10px;
line-height: 2;
}

.wrapper .file-manual .title {
font-weight: bold;
font-size: 120%;
}

.wrapper .file-manual .body {
}

.wrapper .file-manual .body li {
list-style: disc;
margin-left: 20px;
}

.wrapper .upload-button {
width: 100px;
height: 30px;
background-color: #F8F8F8;
border: 1px solid #EEE;
border-radius: 4px;
text-align: center;
line-height: 28px;
cursor: pointer;
position: relative;
flex-shrink: 0;
}

.wrapper .upload-button .text {
display: inline-block;
vertical-align: middle;
}

.wrapper .upload-button input {
position: absolute;
left: 0;
top: 0;
opacity: 0;
cursor: pointer;
height: 100%;
width: 100%;
}

.wrapper .file-result {
border: 1px solid #333;
padding: 10px;
border-radius: 5px;
position: absolute;
left: 10px;
right: 10px;
top: 50px;
background: #FFF;
bottom: 10px;
overflow: auto;
display: none;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="file-upload">
<div class="upload-button">
<div class="text">选择本地文件</div>
<input type="file" id="contentImport"/>
</div>
<div class="file-tip"></div>
</div>
<div class="file-manual">
<div class="title">
支持文档格式
</div>
<div class="body">
<ul>
<li><b>Word</b>:docx</li>
<li><b>Markdown</b>:md</li>
</ul>
</div>
</div>
<div class="file-result"></div>
</div>
<script src="../../third-party/jquery-1.10.2.js?628072e7"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/mammoth/1.6.0/mammoth.browser.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/showdown/2.1.0/showdown.min.js"></script>
<script type="text/javascript" src="contentimport.js?50c896a4"></script>
<script type="text/javascript">
utils.domReady(function () {
var options = {};
var callbacks = {};
contentImport.init(options, callbacks);
});
</script>
</body>
</html>
84 changes: 84 additions & 0 deletions dist/dialogs/contentimport/contentimport.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
var contentImport = {};
var g = $G;

contentImport.data = {
result: null,
};
contentImport.init = function (opt, callbacks) {
addUploadButtonListener();
addOkListener();
};

function processWord(file) {
$('.file-tip').html('正在转换Word文件,请稍后...');
$('.file-result').html('').hide();
var reader = new FileReader();
reader.onload = function (loadEvent) {
mammoth.convertToHtml({
arrayBuffer: loadEvent.target.result
})
.then(function displayResult(result) {
$('.file-tip').html('转换成功');
contentImport.data.result = result.value;
$('.file-result').html(result.value).show();
}, function (error) {
$('.file-tip').html('Word文件转换失败:' + error);
});
};
reader.onerror = function (loadEvent) {
$('.file-tip').html('Word文件转换失败:' + loadEvent);
};
reader.readAsArrayBuffer(file);
}

function processMarkdown(file) {
$('.file-tip').html('正在转换Markdown文件,请稍后...');
$('.file-result').html('').hide();
var reader = new FileReader();
reader.onload = function (loadEvent) {
var converter = new showdown.Converter();
var html = converter.makeHtml(loadEvent.target.result);
$('.file-tip').html('转换成功');
contentImport.data.result = html;
$('.file-result').html(html).show();
};
reader.onerror = function (loadEvent) {
$('.file-tip').html('Markdown文件转换失败:' + loadEvent);
};
reader.readAsText(file, "UTF-8");
}

function addUploadButtonListener() {
g('contentImport').addEventListener('change', function () {
const file = this.files[0];
const fileName = file.name;
const fileExt = fileName.substring(fileName.lastIndexOf('.') + 1).toLowerCase();
switch (fileExt) {
case 'docx':
case 'doc':
processWord(file);
break;
case 'md':
processMarkdown(file);
break;
default:
$('.file-tip').html('不支持的文件格式:' + fileExt);
break;
}
});
}

function addOkListener() {
dialog.onok = function () {
if (!contentImport.data.result) {
alert('请先上传文件识别内容');
return false;
}
editor.fireEvent('saveScene');
editor.execCommand("inserthtml", contentImport.data.result);
editor.fireEvent('saveScene');
};
dialog.oncancel = function () {

};
}
2 changes: 1 addition & 1 deletion dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<script type="text/javascript" charset="utf-8" src="ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="ueditor.all.js"></script>
<script type="text/javascript" charset="utf-8" src="lang/zh-cn/zh-cn.js?73781e3d"></script>
<script type="text/javascript" charset="utf-8" src="lang/zh-cn/zh-cn.js?7a537435"></script>
<script src="./plugins/demo/demo.js"></script>
<script>
// window.UEDITOR_CONFIG.toolbars[0].push('undo');
Expand Down
1 change: 1 addition & 0 deletions dist/lang/en/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ UE.I18N['en'] = {
'mergecells': 'MergeCells',
'deletetable': 'DeleteTable',
'cleardoc': 'Clear',
'contentimport': 'Content Import',
'insertparagraphbeforetable': "InsertParagraphBeforeTable",
'fontfamily': 'FontFamily',
'fontsize': 'FontSize',
Expand Down
1 change: 1 addition & 0 deletions dist/lang/zh-cn/zh-cn.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ UE.I18N['zh-cn'] = {
'mergecells': '合并多个单元格',
'deletetable': '删除表格',
'cleardoc': '清空文档',
'contentimport': '导入内容',
'insertparagraphbeforetable': "表格前插入行",
'insertcode': '代码语言',
'fontfamily': '字体',
Expand Down
12 changes: 11 additions & 1 deletion dist/themes/default/css/ueditor.css

Large diffs are not rendered by default.

Loading

0 comments on commit 006dbe5

Please sign in to comment.