@lingxiteam/lcdp-ueditor-react 1.0.0-alpha.2 → 1.0.0-alpha.20

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.
Files changed (132) hide show
  1. package/es/LcdpUeditor.d.ts +4 -0
  2. package/es/LcdpUeditor.js +74 -50
  3. package/es/const.js +4 -4
  4. package/es/defaultConfig.json +76 -76
  5. package/es/tools/UeditorResourceLoader.js +6 -6
  6. package/es/tools/filterHtmlNode.d.ts +5 -0
  7. package/es/tools/filterHtmlNode.js +41 -0
  8. package/es/tools/loadScript.js +3 -3
  9. package/es/type.d.ts +3 -1
  10. package/lib/LcdpUeditor.d.ts +80 -0
  11. package/lib/LcdpUeditor.js +267 -0
  12. package/lib/const.d.ts +12 -0
  13. package/lib/const.js +39 -0
  14. package/lib/defaultConfig.json +77 -0
  15. package/lib/index.d.ts +4 -0
  16. package/lib/index.js +41 -0
  17. package/lib/tools/UeditorResourceLoader.d.ts +21 -0
  18. package/lib/tools/UeditorResourceLoader.js +90 -0
  19. package/lib/tools/filterHtmlNode.d.ts +5 -0
  20. package/lib/tools/filterHtmlNode.js +61 -0
  21. package/lib/tools/loadScript.d.ts +5 -0
  22. package/lib/tools/loadScript.js +39 -0
  23. package/lib/type.d.ts +144 -0
  24. package/lib/type.js +17 -0
  25. package/package.json +34 -32
  26. package/ueditor-resource/dialogs/anchor/anchor.html +62 -62
  27. package/ueditor-resource/dialogs/attachment/attachment.css +716 -716
  28. package/ueditor-resource/dialogs/attachment/attachment.html +61 -61
  29. package/ueditor-resource/dialogs/attachment/attachment.js +803 -803
  30. package/ueditor-resource/dialogs/audio/audio.css +879 -879
  31. package/ueditor-resource/dialogs/audio/audio.html +93 -93
  32. package/ueditor-resource/dialogs/audio/audio.js +815 -815
  33. package/ueditor-resource/dialogs/background/background.css +193 -193
  34. package/ueditor-resource/dialogs/background/background.html +59 -59
  35. package/ueditor-resource/dialogs/background/background.js +370 -370
  36. package/ueditor-resource/dialogs/contentimport/contentimport.html +176 -176
  37. package/ueditor-resource/dialogs/contentimport/contentimport.js +91 -91
  38. package/ueditor-resource/dialogs/emotion/emotion.css +129 -129
  39. package/ueditor-resource/dialogs/emotion/emotion.html +70 -70
  40. package/ueditor-resource/dialogs/emotion/emotion.js +186 -186
  41. package/ueditor-resource/dialogs/formula/formula.html +98 -98
  42. package/ueditor-resource/dialogs/formula/formula.js +147 -147
  43. package/ueditor-resource/dialogs/help/help.css +37 -37
  44. package/ueditor-resource/dialogs/help/help.html +82 -82
  45. package/ueditor-resource/dialogs/help/help.js +57 -57
  46. package/ueditor-resource/dialogs/image/image.css +768 -768
  47. package/ueditor-resource/dialogs/image/image.html +144 -144
  48. package/ueditor-resource/dialogs/image/image.js +1060 -1060
  49. package/ueditor-resource/dialogs/insertframe/insertframe.html +135 -135
  50. package/ueditor-resource/dialogs/internal.js +81 -81
  51. package/ueditor-resource/dialogs/link/link.html +148 -148
  52. package/ueditor-resource/dialogs/preview/preview.html +45 -45
  53. package/ueditor-resource/dialogs/scrawl/scrawl.css +324 -324
  54. package/ueditor-resource/dialogs/scrawl/scrawl.html +95 -95
  55. package/ueditor-resource/dialogs/scrawl/scrawl.js +682 -682
  56. package/ueditor-resource/dialogs/searchreplace/searchreplace.html +144 -144
  57. package/ueditor-resource/dialogs/searchreplace/searchreplace.js +174 -174
  58. package/ueditor-resource/dialogs/spechars/spechars.html +42 -42
  59. package/ueditor-resource/dialogs/spechars/spechars.js +86 -86
  60. package/ueditor-resource/dialogs/table/edittable.css +85 -85
  61. package/ueditor-resource/dialogs/table/edittable.html +69 -69
  62. package/ueditor-resource/dialogs/table/edittable.js +241 -241
  63. package/ueditor-resource/dialogs/table/edittd.html +62 -62
  64. package/ueditor-resource/dialogs/table/edittip.html +33 -33
  65. package/ueditor-resource/dialogs/template/config.js +42 -42
  66. package/ueditor-resource/dialogs/template/template.css +99 -99
  67. package/ueditor-resource/dialogs/template/template.html +26 -26
  68. package/ueditor-resource/dialogs/template/template.js +53 -53
  69. package/ueditor-resource/dialogs/video/video.css +909 -909
  70. package/ueditor-resource/dialogs/video/video.html +114 -114
  71. package/ueditor-resource/dialogs/video/video.js +867 -867
  72. package/ueditor-resource/dialogs/wordimage/wordimage.html +221 -221
  73. package/ueditor-resource/dialogs/wordimage/wordimage.js +93 -93
  74. package/ueditor-resource/lang/en/en.js +686 -686
  75. package/ueditor-resource/lang/zh-cn/zh-cn.js +748 -748
  76. package/ueditor-resource/lang/zh-tw/images/copy.png +0 -0
  77. package/ueditor-resource/lang/zh-tw/images/localimage.png +0 -0
  78. package/ueditor-resource/lang/zh-tw/images/music.png +0 -0
  79. package/ueditor-resource/lang/zh-tw/images/upload.png +0 -0
  80. package/ueditor-resource/lang/zh-tw/zh-tw.js +748 -0
  81. package/ueditor-resource/plugins/demo/demo.js +3 -3
  82. package/ueditor-resource/themes/default/css/ueditor.css +2148 -2148
  83. package/ueditor-resource/themes/default/dialog.css +17 -17
  84. package/ueditor-resource/themes/default/dialogbase.css +132 -132
  85. package/ueditor-resource/themes/default/exts/ai.svg +12 -12
  86. package/ueditor-resource/themes/default/exts/apk.svg +12 -12
  87. package/ueditor-resource/themes/default/exts/chm.svg +12 -12
  88. package/ueditor-resource/themes/default/exts/css.svg +12 -12
  89. package/ueditor-resource/themes/default/exts/doc.svg +22 -22
  90. package/ueditor-resource/themes/default/exts/docx.svg +22 -22
  91. package/ueditor-resource/themes/default/exts/dwg.svg +16 -16
  92. package/ueditor-resource/themes/default/exts/folder.svg +3 -3
  93. package/ueditor-resource/themes/default/exts/gif.svg +14 -14
  94. package/ueditor-resource/themes/default/exts/html.svg +12 -12
  95. package/ueditor-resource/themes/default/exts/jpeg.svg +14 -14
  96. package/ueditor-resource/themes/default/exts/jpg.svg +14 -14
  97. package/ueditor-resource/themes/default/exts/log.svg +12 -12
  98. package/ueditor-resource/themes/default/exts/mp3.svg +14 -14
  99. package/ueditor-resource/themes/default/exts/mp4.svg +12 -12
  100. package/ueditor-resource/themes/default/exts/pdf.svg +14 -14
  101. package/ueditor-resource/themes/default/exts/png.svg +14 -14
  102. package/ueditor-resource/themes/default/exts/ppt.svg +24 -24
  103. package/ueditor-resource/themes/default/exts/pptx.svg +24 -24
  104. package/ueditor-resource/themes/default/exts/psd.svg +12 -12
  105. package/ueditor-resource/themes/default/exts/rar.svg +12 -12
  106. package/ueditor-resource/themes/default/exts/svg.svg +12 -12
  107. package/ueditor-resource/themes/default/exts/torrent.svg +14 -14
  108. package/ueditor-resource/themes/default/exts/txt.svg +14 -14
  109. package/ueditor-resource/themes/default/exts/unknown.svg +12 -12
  110. package/ueditor-resource/themes/default/exts/xls.svg +25 -25
  111. package/ueditor-resource/themes/default/exts/xlsx.svg +25 -25
  112. package/ueditor-resource/themes/default/exts/zip.svg +12 -12
  113. package/ueditor-resource/themes/iframe.css +63 -63
  114. package/ueditor-resource/third-party/SyntaxHighlighter/shCore.js +3655 -3655
  115. package/ueditor-resource/third-party/clipboard/clipboard.js +752 -752
  116. package/ueditor-resource/third-party/codemirror/codemirror.css +106 -106
  117. package/ueditor-resource/third-party/codemirror/codemirror.js +3581 -3581
  118. package/ueditor-resource/third-party/jquery-3.5.1.js +1 -1
  119. package/ueditor-resource/third-party/jquery-3.5.1_1.js +4314 -4314
  120. package/ueditor-resource/third-party/webuploader/webuploader.css +88 -88
  121. package/ueditor-resource/third-party/webuploader/webuploader.js +3 -3
  122. package/ueditor-resource/third-party/zeroclipboard/ZeroClipboard.js +1255 -1255
  123. package/ueditor-resource/ueditor.all.js +5271 -5270
  124. package/ueditor-resource/ueditor.config.js +655 -656
  125. package/ueditor-resource/ueditor.parse.js +13 -13
  126. package/es/LcdpUeditor.d.ts.map +0 -1
  127. package/es/const.d.ts.map +0 -1
  128. package/es/index.d.ts.map +0 -1
  129. package/es/tools/UeditorResourceLoader.d.ts.map +0 -1
  130. package/es/tools/loadScript.d.ts.map +0 -1
  131. package/es/type.d.ts.map +0 -1
  132. package/ueditor-resource/index.html +0 -146
@@ -1,176 +1,176 @@
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?32939b8e"></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
- margin-right: 5px;
61
- }
62
-
63
- .wrapper .upload-button .text {
64
- display: inline-block;
65
- vertical-align: middle;
66
- }
67
-
68
- .wrapper .upload-button input {
69
- position: absolute;
70
- left: 0;
71
- top: 0;
72
- opacity: 0;
73
- cursor: pointer;
74
- height: 100%;
75
- width: 100%;
76
- }
77
-
78
- .wrapper .file-result {
79
- border: 1px solid #333;
80
- padding: 10px;
81
- border-radius: 5px;
82
- position: absolute;
83
- left: 10px;
84
- right: 10px;
85
- top: 50px;
86
- background: #FFF;
87
- bottom: 10px;
88
- overflow: auto;
89
- display: none;
90
- }
91
- .wrapper .file-input{
92
- position: absolute;
93
- left: 10px;
94
- right: 10px;
95
- top: 50px;
96
- background: #EEE;
97
- bottom: 10px;
98
- border-radius: 5px;
99
- display:none;
100
- }
101
- .wrapper .file-input textarea{
102
- position: absolute;
103
- left: 10px;
104
- right: 10px;
105
- bottom: 10px;
106
- border: none;
107
- resize: none;
108
- border-radius: 5px;
109
- padding: 5px;
110
- outline: none;
111
- top: 30px;
112
- }
113
- .wrapper .file-input .tool{
114
- text-align: right;
115
- padding: 5px 10px;
116
- }
117
- .wrapper .file-input .tool a{
118
- display: inline-block;
119
- text-decoration: none;
120
- color: #333;
121
- background: #FFF;
122
- padding: 0 10px;
123
- line-height: 20px;
124
- border-radius: 3px;
125
- }
126
- </style>
127
- </head>
128
- <body>
129
- <div class="wrapper">
130
- <div class="file-upload">
131
- <div class="upload-button">
132
- <div class="text">选择本地文件</div>
133
- <input type="file" id="contentImport"/>
134
- </div>
135
- <div class="upload-button">
136
- <div class="text" onclick="$('.file-input').show();">粘贴Markdown</div>
137
- </div>
138
- <div class="file-tip"></div>
139
- </div>
140
- <div class="file-manual">
141
- <div class="title">
142
- 支持文档格式
143
- </div>
144
- <div class="body">
145
- <ul>
146
- <li><b>Word</b>:docx</li>
147
- <li><b>Markdown</b>:md</li>
148
- </ul>
149
- </div>
150
- </div>
151
- <div class="file-result"></div>
152
- <div class="file-input">
153
- <textarea id="fileInputContent"></textarea>
154
- <div class="tool">
155
- <a href="javascript:;" id="fileInputConfirm">
156
- 确定
157
- </a>
158
- <a href="javascript:;" onclick="$(this).closest('.file-input').hide();">
159
- 关闭
160
- </a>
161
- </div>
162
- </div>
163
- </div>
164
- <script src="../../third-party/jquery-3.5.1.js?89c36344"></script>
165
- <script src="https://cdn.bootcdn.net/ajax/libs/mammoth/1.6.0/mammoth.browser.min.js"></script>
166
- <script src="https://cdn.bootcdn.net/ajax/libs/showdown/2.1.0/showdown.min.js"></script>
167
- <script type="text/javascript" src="contentimport.js?34705cde"></script>
168
- <script type="text/javascript">
169
- utils.domReady(function () {
170
- var options = {};
171
- var callbacks = {};
172
- contentImport.init(options, callbacks);
173
- });
174
- </script>
175
- </body>
176
- </html>
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
+ margin-right: 5px;
61
+ }
62
+
63
+ .wrapper .upload-button .text {
64
+ display: inline-block;
65
+ vertical-align: middle;
66
+ }
67
+
68
+ .wrapper .upload-button input {
69
+ position: absolute;
70
+ left: 0;
71
+ top: 0;
72
+ opacity: 0;
73
+ cursor: pointer;
74
+ height: 100%;
75
+ width: 100%;
76
+ }
77
+
78
+ .wrapper .file-result {
79
+ border: 1px solid #333;
80
+ padding: 10px;
81
+ border-radius: 5px;
82
+ position: absolute;
83
+ left: 10px;
84
+ right: 10px;
85
+ top: 50px;
86
+ background: #FFF;
87
+ bottom: 10px;
88
+ overflow: auto;
89
+ display: none;
90
+ }
91
+ .wrapper .file-input{
92
+ position: absolute;
93
+ left: 10px;
94
+ right: 10px;
95
+ top: 50px;
96
+ background: #EEE;
97
+ bottom: 10px;
98
+ border-radius: 5px;
99
+ display:none;
100
+ }
101
+ .wrapper .file-input textarea{
102
+ position: absolute;
103
+ left: 10px;
104
+ right: 10px;
105
+ bottom: 10px;
106
+ border: none;
107
+ resize: none;
108
+ border-radius: 5px;
109
+ padding: 5px;
110
+ outline: none;
111
+ top: 30px;
112
+ }
113
+ .wrapper .file-input .tool{
114
+ text-align: right;
115
+ padding: 5px 10px;
116
+ }
117
+ .wrapper .file-input .tool a{
118
+ display: inline-block;
119
+ text-decoration: none;
120
+ color: #333;
121
+ background: #FFF;
122
+ padding: 0 10px;
123
+ line-height: 20px;
124
+ border-radius: 3px;
125
+ }
126
+ </style>
127
+ </head>
128
+ <body>
129
+ <div class="wrapper">
130
+ <div class="file-upload">
131
+ <div class="upload-button">
132
+ <div class="text">选择本地文件</div>
133
+ <input type="file" id="contentImport"/>
134
+ </div>
135
+ <div class="upload-button">
136
+ <div class="text" onclick="$('.file-input').show();">粘贴Markdown</div>
137
+ </div>
138
+ <div class="file-tip"></div>
139
+ </div>
140
+ <div class="file-manual">
141
+ <div class="title">
142
+ 支持文档格式
143
+ </div>
144
+ <div class="body">
145
+ <ul>
146
+ <li><b>Word</b>:docx</li>
147
+ <li><b>Markdown</b>:md</li>
148
+ </ul>
149
+ </div>
150
+ </div>
151
+ <div class="file-result"></div>
152
+ <div class="file-input">
153
+ <textarea id="fileInputContent"></textarea>
154
+ <div class="tool">
155
+ <a href="javascript:;" id="fileInputConfirm">
156
+ 确定
157
+ </a>
158
+ <a href="javascript:;" onclick="$(this).closest('.file-input').hide();">
159
+ 关闭
160
+ </a>
161
+ </div>
162
+ </div>
163
+ </div>
164
+ <script src="../../third-party/jquery-3.5.1.js?064a9f9e"></script>
165
+ <script src="https://cdn.bootcdn.net/ajax/libs/mammoth/1.6.0/mammoth.browser.min.js"></script>
166
+ <script src="https://cdn.bootcdn.net/ajax/libs/showdown/2.1.0/showdown.min.js"></script>
167
+ <script type="text/javascript" src="contentimport.js?5760833a"></script>
168
+ <script type="text/javascript">
169
+ utils.domReady(function () {
170
+ var options = {};
171
+ var callbacks = {};
172
+ contentImport.init(options, callbacks);
173
+ });
174
+ </script>
175
+ </body>
176
+ </html>
@@ -1,91 +1,91 @@
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( markdown ){
35
- var converter = new showdown.Converter();
36
- var html = converter.makeHtml(markdown);
37
- $('.file-tip').html('转换成功');
38
- contentImport.data.result = html;
39
- $('.file-result').html(html).show();
40
- }
41
-
42
- function processMarkdownFile(file) {
43
- $('.file-tip').html('正在转换Markdown文件,请稍后...');
44
- $('.file-result').html('').hide();
45
- var reader = new FileReader();
46
- reader.onload = function (loadEvent) {
47
- processMarkdown( loadEvent.target.result );
48
- };
49
- reader.onerror = function (loadEvent) {
50
- $('.file-tip').html('Markdown文件转换失败:' + loadEvent);
51
- };
52
- reader.readAsText(file, "UTF-8");
53
- }
54
-
55
- function addUploadButtonListener() {
56
- g('contentImport').addEventListener('change', function () {
57
- const file = this.files[0];
58
- const fileName = file.name;
59
- const fileExt = fileName.substring(fileName.lastIndexOf('.') + 1).toLowerCase();
60
- switch (fileExt) {
61
- case 'docx':
62
- case 'doc':
63
- processWord(file);
64
- break;
65
- case 'md':
66
- processMarkdownFile(file);
67
- break;
68
- default:
69
- $('.file-tip').html('不支持的文件格式:' + fileExt);
70
- break;
71
- }
72
- });
73
- g('fileInputConfirm').addEventListener('click', function () {
74
- processMarkdown( g('fileInputContent').value );
75
- $('.file-input').hide();
76
- });
77
- }
78
-
79
- function addOkListener() {
80
- dialog.onok = function () {
81
- if (!contentImport.data.result) {
82
- alert('请先上传文件识别内容');
83
- return false;
84
- }
85
- editor.fireEvent('saveScene');
86
- editor.execCommand("inserthtml", contentImport.data.result);
87
- editor.fireEvent('saveScene');
88
- };
89
- dialog.oncancel = function () {
90
- };
91
- }
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( markdown ){
35
+ var converter = new showdown.Converter();
36
+ var html = converter.makeHtml(markdown);
37
+ $('.file-tip').html('转换成功');
38
+ contentImport.data.result = html;
39
+ $('.file-result').html(html).show();
40
+ }
41
+
42
+ function processMarkdownFile(file) {
43
+ $('.file-tip').html('正在转换Markdown文件,请稍后...');
44
+ $('.file-result').html('').hide();
45
+ var reader = new FileReader();
46
+ reader.onload = function (loadEvent) {
47
+ processMarkdown( loadEvent.target.result );
48
+ };
49
+ reader.onerror = function (loadEvent) {
50
+ $('.file-tip').html('Markdown文件转换失败:' + loadEvent);
51
+ };
52
+ reader.readAsText(file, "UTF-8");
53
+ }
54
+
55
+ function addUploadButtonListener() {
56
+ g('contentImport').addEventListener('change', function () {
57
+ const file = this.files[0];
58
+ const fileName = file.name;
59
+ const fileExt = fileName.substring(fileName.lastIndexOf('.') + 1).toLowerCase();
60
+ switch (fileExt) {
61
+ case 'docx':
62
+ case 'doc':
63
+ processWord(file);
64
+ break;
65
+ case 'md':
66
+ processMarkdownFile(file);
67
+ break;
68
+ default:
69
+ $('.file-tip').html('不支持的文件格式:' + fileExt);
70
+ break;
71
+ }
72
+ });
73
+ g('fileInputConfirm').addEventListener('click', function () {
74
+ processMarkdown( g('fileInputContent').value );
75
+ $('.file-input').hide();
76
+ });
77
+ }
78
+
79
+ function addOkListener() {
80
+ dialog.onok = function () {
81
+ if (!contentImport.data.result) {
82
+ alert('请先上传文件识别内容');
83
+ return false;
84
+ }
85
+ editor.fireEvent('saveScene');
86
+ editor.execCommand("inserthtml", contentImport.data.result);
87
+ editor.fireEvent('saveScene');
88
+ };
89
+ dialog.oncancel = function () {
90
+ };
91
+ }