@lingxiteam/lcdp-ueditor-react 1.0.2 → 1.0.3-alpha.2

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 (76) hide show
  1. package/es/LcdpUeditor.d.ts.map +1 -1
  2. package/es/LcdpUeditor.js +2 -1
  3. package/es/tools/UeditorResourceLoader.d.ts +1 -1
  4. package/es/tools/UeditorResourceLoader.d.ts.map +1 -1
  5. package/es/tools/UeditorResourceLoader.js +18 -7
  6. package/es/tools/filterHtmlNode.d.ts.map +1 -1
  7. package/es/tools/filterHtmlNode.js +7 -2
  8. package/lib/LcdpUeditor.js +1 -3
  9. package/lib/tools/UeditorResourceLoader.d.ts +1 -1
  10. package/lib/tools/UeditorResourceLoader.js +15 -7
  11. package/lib/tools/filterHtmlNode.js +8 -4
  12. package/package.json +1 -1
  13. package/ueditor-resource/dialogs/anchor/anchor.html +1 -1
  14. package/ueditor-resource/dialogs/attachment/attachment.css +2 -715
  15. package/ueditor-resource/dialogs/attachment/attachment.html +6 -6
  16. package/ueditor-resource/dialogs/attachment/attachment.js +2 -803
  17. package/ueditor-resource/dialogs/audio/audio.css +2 -878
  18. package/ueditor-resource/dialogs/audio/audio.js +2 -815
  19. package/ueditor-resource/dialogs/background/background.css +2 -192
  20. package/ueditor-resource/dialogs/background/background.html +3 -3
  21. package/ueditor-resource/dialogs/background/background.js +2 -370
  22. package/ueditor-resource/dialogs/contentimport/contentimport.html +3 -3
  23. package/ueditor-resource/dialogs/contentimport/contentimport.js +2 -91
  24. package/ueditor-resource/dialogs/emotion/emotion.css +2 -128
  25. package/ueditor-resource/dialogs/emotion/emotion.html +3 -3
  26. package/ueditor-resource/dialogs/emotion/emotion.js +2 -186
  27. package/ueditor-resource/dialogs/formula/formula.html +4 -4
  28. package/ueditor-resource/dialogs/formula/formula.js +2 -147
  29. package/ueditor-resource/dialogs/help/help.css +2 -36
  30. package/ueditor-resource/dialogs/help/help.html +3 -3
  31. package/ueditor-resource/dialogs/help/help.js +2 -57
  32. package/ueditor-resource/dialogs/image/image.css +2 -767
  33. package/ueditor-resource/dialogs/image/image.js +2 -1060
  34. package/ueditor-resource/dialogs/insertframe/insertframe.html +2 -2
  35. package/ueditor-resource/dialogs/internal.js +2 -81
  36. package/ueditor-resource/dialogs/preview/preview.html +2 -2
  37. package/ueditor-resource/dialogs/scrawl/scrawl.css +2 -323
  38. package/ueditor-resource/dialogs/scrawl/scrawl.html +3 -3
  39. package/ueditor-resource/dialogs/scrawl/scrawl.js +2 -682
  40. package/ueditor-resource/dialogs/searchreplace/searchreplace.html +2 -2
  41. package/ueditor-resource/dialogs/searchreplace/searchreplace.js +2 -174
  42. package/ueditor-resource/dialogs/spechars/spechars.html +2 -2
  43. package/ueditor-resource/dialogs/spechars/spechars.js +2 -86
  44. package/ueditor-resource/dialogs/table/edittable.css +2 -84
  45. package/ueditor-resource/dialogs/table/edittable.html +3 -3
  46. package/ueditor-resource/dialogs/table/edittable.js +2 -241
  47. package/ueditor-resource/dialogs/table/edittd.html +1 -1
  48. package/ueditor-resource/dialogs/table/edittip.html +1 -1
  49. package/ueditor-resource/dialogs/template/config.js +2 -42
  50. package/ueditor-resource/dialogs/template/template.css +2 -98
  51. package/ueditor-resource/dialogs/template/template.html +4 -4
  52. package/ueditor-resource/dialogs/template/template.js +2 -53
  53. package/ueditor-resource/dialogs/video/video.css +2 -908
  54. package/ueditor-resource/dialogs/video/video.js +2 -867
  55. package/ueditor-resource/dialogs/wordimage/wordimage.html +5 -5
  56. package/ueditor-resource/dialogs/wordimage/wordimage.js +2 -93
  57. package/ueditor-resource/lang/en/en.js +2 -686
  58. package/ueditor-resource/lang/zh-cn/zh-cn.js +2 -748
  59. package/ueditor-resource/lang/zh-tw/zh-tw.js +2 -748
  60. package/ueditor-resource/plugins/demo/demo.js +1 -3
  61. package/ueditor-resource/themes/default/css/ueditor.css +2 -2148
  62. package/ueditor-resource/themes/default/dialog.css +2 -16
  63. package/ueditor-resource/themes/default/dialogbase.css +2 -131
  64. package/ueditor-resource/themes/iframe.css +2 -62
  65. package/ueditor-resource/third-party/SyntaxHighlighter/shCore.js +4 -3655
  66. package/ueditor-resource/third-party/SyntaxHighlighter/shCoreDefault.css +3 -1
  67. package/ueditor-resource/third-party/clipboard/clipboard.js +2 -753
  68. package/ueditor-resource/third-party/codemirror/codemirror.css +2 -105
  69. package/ueditor-resource/third-party/codemirror/codemirror.js +3 -3581
  70. package/ueditor-resource/third-party/jquery-3.5.1.js +4 -2
  71. package/ueditor-resource/third-party/jquery-3.5.1_1.js +4 -4314
  72. package/ueditor-resource/third-party/webuploader/webuploader.css +2 -87
  73. package/ueditor-resource/third-party/webuploader/webuploader.js +5 -4
  74. package/ueditor-resource/ueditor.all.js +20 -32644
  75. package/ueditor-resource/ueditor.config.js +2 -655
  76. package/ueditor-resource/ueditor.parse.js +2 -639
@@ -1,815 +1,2 @@
1
- /**
2
- * Created by JetBrains PhpStorm.
3
- * User: taoqili
4
- * Date: 12-2-20
5
- * Time: 上午11:19
6
- * To change this template use File | Settings | File Templates.
7
- */
8
-
9
- (function () {
10
-
11
- var audio = {},
12
- uploadaudioList = [],
13
- isModifyUploadaudio = false,
14
- uploadFile;
15
- var editorOpt = {};
16
-
17
- window.onload = function () {
18
- editorOpt = editor.getOpt('audioConfig');
19
- $focus($G("audioUrl"));
20
- initTabs();
21
- initAudio();
22
- initUpload();
23
- };
24
-
25
- /* 初始化tab标签 */
26
- function initTabs() {
27
- var tabs = $G('tabHeads').children;
28
- for (var i = 0; i < tabs.length; i++) {
29
- domUtils.on(tabs[i], "click", function (e) {
30
- var j, bodyId, target = e.target || e.srcElement;
31
- for (j = 0; j < tabs.length; j++) {
32
- bodyId = tabs[j].getAttribute('data-content-id');
33
- if (tabs[j] == target) {
34
- domUtils.addClass(tabs[j], 'focus');
35
- domUtils.addClass($G(bodyId), 'focus');
36
- } else {
37
- domUtils.removeClasses(tabs[j], 'focus');
38
- domUtils.removeClasses($G(bodyId), 'focus');
39
- }
40
- }
41
- });
42
- }
43
- if (!editorOpt.disableUpload) {
44
- $G('tabHeads').querySelector('[data-content-id="upload"]').style.display = 'inline-block';
45
- }
46
- if (!!editorOpt.selectCallback) {
47
- $G('audioSelect').style.display = 'inline-block';
48
- domUtils.on($G('audioSelect'), "click", function (e) {
49
- editorOpt.selectCallback(editor, function (info) {
50
- if (info) {
51
- $G('audioUrl').value = info.path;
52
- createPreview(info.path);
53
- }
54
- });
55
- });
56
- }
57
- }
58
-
59
- function initAudio() {
60
- createAlignButton(["audioFloat", "upload_alignment"]);
61
- addUrlChangeListener($G("audioUrl"));
62
- addOkListener();
63
-
64
- //编辑视频时初始化相关信息
65
- (function () {
66
- var img = editor.selection.getRange().getClosedNode(), url;
67
- if (img && img.className) {
68
- var hasFakedClass = (img.className == "edui-faked-audio"),
69
- hasUploadClass = img.className.indexOf("edui-upload-audio") != -1;
70
- if (hasFakedClass || hasUploadClass) {
71
- $G("audioUrl").value = url = img.getAttribute("_url");
72
- var align = domUtils.getComputedStyle(img, "float"),
73
- parentAlign = domUtils.getComputedStyle(img.parentNode, "text-align");
74
- updateAlignButton(parentAlign === "center" ? "center" : align);
75
- }
76
- if (hasUploadClass) {
77
- isModifyUploadaudio = true;
78
- }
79
- }
80
- createPreview(url);
81
- })();
82
- }
83
-
84
- /**
85
- * 监听确认和取消两个按钮事件,用户执行插入或者清空正在播放的视频实例操作
86
- */
87
- function addOkListener() {
88
- dialog.onok = function () {
89
- $G("preview").innerHTML = "";
90
- var currentTab = findFocus("tabHeads", "tabSrc");
91
- switch (currentTab) {
92
- case "audio":
93
- return insertSingle();
94
- // case "audioSearch":
95
- // return insertSearch("searchList");
96
- // break;
97
- case "upload":
98
- return insertUpload();
99
- }
100
- };
101
- dialog.oncancel = function () {
102
- $G("preview").innerHTML = "";
103
- };
104
- }
105
-
106
- /**
107
- * 依据传入的align值更新按钮信息
108
- * @param align
109
- */
110
- function updateAlignButton(align) {
111
- var aligns = $G("audioFloat").children;
112
- for (var i = 0, ci; ci = aligns[i++];) {
113
- if (ci.getAttribute("name") == align) {
114
- if (ci.className != "focus") {
115
- ci.className = "focus";
116
- }
117
- } else {
118
- if (ci.className == "focus") {
119
- ci.className = "";
120
- }
121
- }
122
- }
123
- }
124
-
125
- /**
126
- * 将单个视频信息插入编辑器中
127
- */
128
- function insertSingle() {
129
- var url = $G('audioUrl').value,
130
- align = findFocus("audioFloat", "name");
131
- if (!url) return false;
132
- editor.execCommand('insertaudio', {
133
- url: url,
134
- }, isModifyUploadaudio ? 'upload' : null);
135
- }
136
-
137
- /**
138
- * 将元素id下的所有代表视频的图片插入编辑器中
139
- * @param id
140
- */
141
- function insertSearch(id) {
142
- var imgs = domUtils.getElementsByTagName($G(id), "img"),
143
- audioObjs = [];
144
- for (var i = 0, img; img = imgs[i++];) {
145
- if (img.getAttribute("selected")) {
146
- audioObjs.push({
147
- url: img.getAttribute("ue_audio_url"),
148
- width: 420,
149
- height: 280,
150
- align: "none"
151
- });
152
- }
153
- }
154
- editor.execCommand('insertaudio', audioObjs);
155
- }
156
-
157
- /**
158
- * 找到id下具有focus类的节点并返回该节点下的某个属性
159
- * @param id
160
- * @param returnProperty
161
- */
162
- function findFocus(id, returnProperty) {
163
- var tabs = $G(id).children,
164
- property;
165
- for (var i = 0, ci; ci = tabs[i++];) {
166
- if (ci.className == "focus") {
167
- property = ci.getAttribute(returnProperty);
168
- break;
169
- }
170
- }
171
- return property;
172
- }
173
-
174
- /**
175
- * 数字判断
176
- * @param value
177
- */
178
- function isNumber(value) {
179
- return /(0|^[1-9]\d*$)/.test(value);
180
- }
181
-
182
- /**
183
- * 创建图片浮动选择按钮
184
- * @param ids
185
- */
186
- function createAlignButton(ids) {
187
- for (var i = 0, ci; ci = ids[i++];) {
188
- var floatContainer = $G(ci),
189
- nameMaps = {
190
- "none": lang['default'],
191
- "left": lang.floatLeft,
192
- "right": lang.floatRight,
193
- "center": lang.block
194
- };
195
- for (var j in nameMaps) {
196
- var div = document.createElement("div");
197
- div.setAttribute("name", j);
198
- if (j == "none") {
199
- div.className = "focus"
200
- div.style.cssText = "background-image:url(icon/" + j + "-active.png);";
201
- } else {
202
- div.style.cssText = "background-image:url(icon/" + j + ".png);";
203
- }
204
- div.setAttribute("title", nameMaps[j]);
205
- floatContainer.appendChild(div);
206
- }
207
- switchSelect(ci);
208
- }
209
- }
210
-
211
- /**
212
- * 选择切换
213
- * @param selectParentId
214
- */
215
- function switchSelect(selectParentId) {
216
- var selects = $G(selectParentId).children;
217
- for (var i = 0, ci; ci = selects[i++];) {
218
- domUtils.on(ci, "click", function () {
219
- for (var j = 0, cj; cj = selects[j++];) {
220
- cj.className = "";
221
- cj.style.cssText = "background-image:url(icon/" + cj.getAttribute('name') + ".png);";
222
- cj.removeAttribute && cj.removeAttribute("class");
223
- }
224
- this.className = "focus";
225
- this.style.cssText = "background-image:url(icon/" + this.getAttribute('name') + "-active.png);";
226
- })
227
- }
228
- }
229
-
230
- /**
231
- * 监听url改变事件
232
- * @param url
233
- */
234
- function addUrlChangeListener(url) {
235
- if (browser.ie) {
236
- url.onpropertychange = function () {
237
- createPreview(this.value);
238
- }
239
- } else {
240
- url.addEventListener("input", function () {
241
- createPreview(this.value);
242
- }, false);
243
- }
244
- }
245
-
246
- function createAudioHtml(url, param) {
247
- param = param || {};
248
- var str = [
249
- "<audio",
250
- (param.id ? ' id="' + param.id + '"' : ""),
251
- (param.cls ? ' class="' + param.cls + '"' : ''),
252
- ' controls >',
253
- '<source src="' + url + '" type="audio/mpeg' + '" />',
254
- '</audio>',
255
- ];
256
- return str.join('');
257
- }
258
-
259
- /**
260
- * 根据url生成视频预览
261
- * @param url
262
- */
263
- function createPreview(url) {
264
- if (!url) {
265
- return;
266
- }
267
-
268
- $G("preview").innerHTML = '<div class="previewMsg"><span>' + lang.urlError + '</span></div>' +
269
- '<div style="position: absolute; inset: 0; background: #FFF; text-align: center; display: flex; justify-items: center; align-items: center;">' +
270
- '<div style="text-align:center;flex-grow:1;">' + createAudioHtml(url) + '</div>'
271
- + '</div>';
272
- }
273
-
274
-
275
- /* 插入上传视频 */
276
- function insertUpload() {
277
- var audioObjs = [],
278
- uploadDir = editor.getOpt('audioUrlPrefix'),
279
- align = findFocus("upload_alignment", "name") || 'none';
280
- for (var key in uploadaudioList) {
281
- var file = uploadaudioList[key];
282
- audioObjs.push({
283
- url: uploadDir + file.url,
284
- align: align
285
- });
286
- }
287
-
288
- var count = uploadFile.getQueueCount();
289
- if (count) {
290
- $('.info', '#queueList').html('<span style="color:red;">' + '还有2个未上传文件'.replace(/[\d]/, count) + '</span>');
291
- return false;
292
- } else {
293
- editor.execCommand('insertaudio', audioObjs, 'upload');
294
- }
295
- }
296
-
297
- /*初始化上传标签*/
298
- function initUpload() {
299
- uploadFile = new UploadFile('queueList');
300
- }
301
-
302
-
303
- /* 上传附件 */
304
- function UploadFile(target) {
305
- this.$wrap = target.constructor == String ? $('#' + target) : $(target);
306
- this.init();
307
- }
308
-
309
- UploadFile.prototype = {
310
- init: function () {
311
- this.fileList = [];
312
- this.initContainer();
313
- this.initUploader();
314
- },
315
- initContainer: function () {
316
- this.$queue = this.$wrap.find('.filelist');
317
- },
318
- /* 初始化容器 */
319
- initUploader: function () {
320
- var _this = this,
321
- $ = jQuery, // just in case. Make sure it's not an other libaray.
322
- $wrap = _this.$wrap,
323
- // 图片容器
324
- $queue = $wrap.find('.filelist'),
325
- // 状态栏,包括进度和控制按钮
326
- $statusBar = $wrap.find('.statusBar'),
327
- // 文件总体选择信息。
328
- $info = $statusBar.find('.info'),
329
- // 上传按钮
330
- $upload = $wrap.find('.uploadBtn'),
331
- // 上传按钮
332
- $filePickerBtn = $wrap.find('.filePickerBtn'),
333
- // 上传按钮
334
- $filePickerBlock = $wrap.find('.filePickerBlock'),
335
- // 没选择文件之前的内容。
336
- $placeHolder = $wrap.find('.placeholder'),
337
- // 总体进度条
338
- $progress = $statusBar.find('.progress').hide(),
339
- // 添加的文件数量
340
- fileCount = 0,
341
- // 添加的文件总大小
342
- fileSize = 0,
343
- // 优化retina, 在retina下这个值是2
344
- ratio = window.devicePixelRatio || 1,
345
- // 缩略图大小
346
- thumbnailWidth = 113 * ratio,
347
- thumbnailHeight = 113 * ratio,
348
- // 可能有pedding, ready, uploading, confirm, done.
349
- state = '',
350
- // 所有文件的进度信息,key为file id
351
- percentages = {},
352
- supportTransition = (function () {
353
- var s = document.createElement('p').style,
354
- r = 'transition' in s ||
355
- 'WebkitTransition' in s ||
356
- 'MozTransition' in s ||
357
- 'msTransition' in s ||
358
- 'OTransition' in s;
359
- s = null;
360
- return r;
361
- })(),
362
- // WebUploader实例
363
- uploader,
364
- actionUrl = editor.getActionUrl(editor.getOpt('audioActionName')),
365
- fileMaxSize = editor.getOpt('audioMaxSize'),
366
- acceptExtensions = (editor.getOpt('audioAllowFiles') || []).join('').replace(/\./g, ',').replace(/^[,]/, '');
367
- // 隐藏上传按钮
368
- $upload.hide();
369
-
370
- if (!WebUploader.Uploader.support()) {
371
- $('#filePickerReady').after($('<div>').html(lang.errorNotSupport)).hide();
372
- return;
373
- } else if (!editor.getOpt('audioActionName')) {
374
- $('#filePickerReady').after($('<div>').html(lang.errorLoadConfig)).hide();
375
- return;
376
- }
377
-
378
- uploader = _this.uploader = WebUploader.create({
379
- pick: {
380
- id: '#filePickerReady',
381
- label: lang.uploadSelectFile
382
- },
383
- swf: '../../third-party/webuploader/Uploader.swf',
384
- server: actionUrl,
385
- fileVal: editor.getOpt('audioFieldName'),
386
- duplicate: true,
387
- fileSingleSizeLimit: fileMaxSize,
388
- headers: editor.getOpt('serverHeaders') || {},
389
- compress: false
390
- });
391
- uploader.addButton({
392
- id: '#filePickerBlock'
393
- });
394
- uploader.addButton({
395
- id: '#filePickerBtn',
396
- label: lang.uploadAddFile
397
- });
398
-
399
- setState('pedding');
400
-
401
- // 当有文件添加进来时执行,负责view的创建
402
- function addFile(file) {
403
- var $li = $('<li id="' + file.id + '">' +
404
- '<p class="title">' + file.name + '</p>' +
405
- '<p class="imgWrap"></p>' +
406
- '<p class="progress"><span></span></p>' +
407
- '</li>'),
408
-
409
- $btns = $('<div class="file-panel">' +
410
- '<span class="cancel">' + lang.uploadDelete + '</span>' +
411
- '<span class="rotateRight">' + lang.uploadTurnRight + '</span>' +
412
- '<span class="rotateLeft">' + lang.uploadTurnLeft + '</span></div>').appendTo($li),
413
- $prgress = $li.find('p.progress span'),
414
- $wrap = $li.find('p.imgWrap'),
415
- $info = $('<p class="error"></p>').hide().appendTo($li),
416
-
417
- showError = function (code) {
418
- switch (code) {
419
- case 'exceed_size':
420
- text = lang.errorExceedSize;
421
- break;
422
- case 'interrupt':
423
- text = lang.errorInterrupt;
424
- break;
425
- case 'http':
426
- text = lang.errorHttp;
427
- break;
428
- case 'not_allow_type':
429
- text = lang.errorFileType;
430
- break;
431
- default:
432
- text = lang.errorUploadRetry;
433
- break;
434
- }
435
- $info.text(text).show();
436
- };
437
-
438
- if (file.getStatus() === 'invalid') {
439
- showError(file.statusText);
440
- } else {
441
- $wrap.text(lang.uploadPreview);
442
- if ('|png|jpg|jpeg|bmp|gif|'.indexOf('|' + file.ext.toLowerCase() + '|') == -1) {
443
- $wrap.empty().addClass('notimage').append('<i class="file-preview file-type-' + file.ext.toLowerCase() + '"></i>' +
444
- '<span class="file-title">' + file.name + '</span>');
445
- } else {
446
- if (browser.ie && browser.version <= 7) {
447
- $wrap.text(lang.uploadNoPreview);
448
- } else {
449
- uploader.makeThumb(file, function (error, src) {
450
- if (error || !src || (/^data:/.test(src) && browser.ie && browser.version <= 7)) {
451
- $wrap.text(lang.uploadNoPreview);
452
- } else {
453
- var $img = $('<img src="' + src + '">');
454
- $wrap.empty().append($img);
455
- $img.on('error', function () {
456
- $wrap.text(lang.uploadNoPreview);
457
- });
458
- }
459
- }, thumbnailWidth, thumbnailHeight);
460
- }
461
- }
462
- percentages[file.id] = [file.size, 0];
463
- file.rotation = 0;
464
-
465
- /* 检查文件格式 */
466
- if (!file.ext || acceptExtensions.indexOf(file.ext.toLowerCase()) == -1) {
467
- showError('not_allow_type');
468
- uploader.removeFile(file);
469
- }
470
- }
471
-
472
- file.on('statuschange', function (cur, prev) {
473
- if (prev === 'progress') {
474
- $prgress.hide().width(0);
475
- } else if (prev === 'queued') {
476
- $li.off('mouseenter mouseleave');
477
- $btns.remove();
478
- }
479
- // 成功
480
- if (cur === 'error' || cur === 'invalid') {
481
- showError(file.statusText);
482
- percentages[file.id][1] = 1;
483
- } else if (cur === 'interrupt') {
484
- showError('interrupt');
485
- } else if (cur === 'queued') {
486
- percentages[file.id][1] = 0;
487
- } else if (cur === 'progress') {
488
- $info.hide();
489
- $prgress.css('display', 'block');
490
- } else if (cur === 'complete') {
491
- }
492
-
493
- $li.removeClass('state-' + prev).addClass('state-' + cur);
494
- });
495
-
496
- $li.on('mouseenter', function () {
497
- $btns.stop().animate({ height: 30 });
498
- });
499
- $li.on('mouseleave', function () {
500
- $btns.stop().animate({ height: 0 });
501
- });
502
-
503
- $btns.on('click', 'span', function () {
504
- var index = $(this).index(),
505
- deg;
506
-
507
- switch (index) {
508
- case 0:
509
- uploader.removeFile(file);
510
- return;
511
- case 1:
512
- file.rotation += 90;
513
- break;
514
- case 2:
515
- file.rotation -= 90;
516
- break;
517
- }
518
-
519
- if (supportTransition) {
520
- deg = 'rotate(' + file.rotation + 'deg)';
521
- $wrap.css({
522
- '-webkit-transform': deg,
523
- '-mos-transform': deg,
524
- '-o-transform': deg,
525
- 'transform': deg
526
- });
527
- } else {
528
- $wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')');
529
- }
530
-
531
- });
532
-
533
- $li.insertBefore($filePickerBlock);
534
- }
535
-
536
- // 负责view的销毁
537
- function removeFile(file) {
538
- var $li = $('#' + file.id);
539
- delete percentages[file.id];
540
- updateTotalProgress();
541
- $li.off().find('.file-panel').off().end().remove();
542
- }
543
-
544
- function updateTotalProgress() {
545
- var loaded = 0,
546
- total = 0,
547
- spans = $progress.children(),
548
- percent;
549
-
550
- $.each(percentages, function (k, v) {
551
- total += v[0];
552
- loaded += v[0] * v[1];
553
- });
554
-
555
- percent = total ? loaded / total : 0;
556
-
557
- spans.eq(0).text(Math.round(percent * 100) + '%');
558
- spans.eq(1).css('width', Math.round(percent * 100) + '%');
559
- updateStatus();
560
- }
561
-
562
- function setState(val, files) {
563
-
564
- if (val != state) {
565
-
566
- var stats = uploader.getStats();
567
-
568
- $upload.removeClass('state-' + state);
569
- $upload.addClass('state-' + val);
570
-
571
- switch (val) {
572
-
573
- /* 未选择文件 */
574
- case 'pedding':
575
- $queue.addClass('element-invisible');
576
- $statusBar.addClass('element-invisible');
577
- $placeHolder.removeClass('element-invisible');
578
- $progress.hide();
579
- $info.hide();
580
- uploader.refresh();
581
- break;
582
-
583
- /* 可以开始上传 */
584
- case 'ready':
585
- $placeHolder.addClass('element-invisible');
586
- $queue.removeClass('element-invisible');
587
- $statusBar.removeClass('element-invisible');
588
- $progress.hide();
589
- $info.show();
590
- $upload.text(lang.uploadStart);
591
- uploader.refresh();
592
- break;
593
-
594
- /* 上传中 */
595
- case 'uploading':
596
- $progress.show();
597
- $info.hide();
598
- $upload.text(lang.uploadPause);
599
- break;
600
-
601
- /* 暂停上传 */
602
- case 'paused':
603
- $progress.show();
604
- $info.hide();
605
- $upload.text(lang.uploadContinue);
606
- break;
607
-
608
- case 'confirm':
609
- $progress.show();
610
- $info.hide();
611
- $upload.text(lang.uploadStart);
612
-
613
- stats = uploader.getStats();
614
- if (stats.successNum && !stats.uploadFailNum) {
615
- setState('finish');
616
- return;
617
- }
618
- break;
619
-
620
- case 'finish':
621
- $progress.hide();
622
- $info.show();
623
- if (stats.uploadFailNum) {
624
- $upload.text(lang.uploadRetry);
625
- } else {
626
- $upload.text(lang.uploadStart);
627
- }
628
- break;
629
- }
630
-
631
- state = val;
632
- updateStatus();
633
-
634
- }
635
-
636
- if (!_this.getQueueCount()) {
637
- $upload.addClass('disabled')
638
- } else {
639
- $upload.removeClass('disabled')
640
- }
641
-
642
- }
643
-
644
- function updateStatus() {
645
- var text = '', stats;
646
-
647
- if (state === 'ready') {
648
- text = lang.updateStatusReady.replace('_', fileCount).replace('_KB', WebUploader.formatSize(fileSize));
649
- } else if (state === 'confirm') {
650
- stats = uploader.getStats();
651
- if (stats.uploadFailNum) {
652
- text = lang.updateStatusConfirm.replace('_', stats.successNum).replace('_', stats.successNum);
653
- }
654
- } else {
655
- stats = uploader.getStats();
656
- text = lang.updateStatusFinish.replace('_', fileCount).replace('_KB', WebUploader.formatSize(fileSize)).replace('_', stats.successNum);
657
-
658
- if (stats.uploadFailNum) {
659
- text += lang.updateStatusError.replace('_', stats.uploadFailNum);
660
- }
661
- }
662
-
663
- $info.html(text);
664
- }
665
-
666
- /**
667
- * 前置校验
668
- */
669
- uploader.on('beforeFileQueued', function (file) {
670
- if (file.ext && acceptExtensions.indexOf(file.ext.toLowerCase()) != -1) {
671
- return true;
672
- }
673
- return false;
674
- })
675
-
676
- uploader.on('fileQueued', function (file) {
677
- fileCount++;
678
- fileSize += file.size;
679
-
680
- if (fileCount === 1) {
681
- $placeHolder.addClass('element-invisible');
682
- $statusBar.show();
683
- }
684
-
685
- addFile(file);
686
-
687
- const uploadFunc = editor.getOpt('uploadFunction');
688
- if (typeof uploadFunc === 'function') {
689
- // 开始上传
690
- if (state === 'ready') {
691
- setState('uploading');
692
- } else if (state === 'pedding') {
693
- setState('ready');
694
- setState('uploading');
695
- }
696
- file.setStatus('progress');
697
- uploader.trigger('uploadProgress', file, 0);
698
- uploadFunc(file.source.source).then(function (response) {
699
- uploader.trigger('uploadProgress', file, 1);
700
- file.setStatus('complete');
701
- setState('finish');
702
- uploader.trigger('uploadSuccess', file, response);
703
- uploader.trigger('uploadComplete', file);
704
- });
705
- }
706
- });
707
-
708
- uploader.on('fileDequeued', function (file) {
709
- fileCount--;
710
- fileSize -= file.size;
711
-
712
- removeFile(file);
713
- updateTotalProgress();
714
- });
715
-
716
- uploader.on('filesQueued', function (file) {
717
- if (!uploader.isInProgress() && (state == 'pedding' || state == 'finish' || state == 'confirm' || state == 'ready')) {
718
- setState('ready');
719
- }
720
- updateTotalProgress();
721
- });
722
-
723
- uploader.on('all', function (type, files) {
724
- switch (type) {
725
- case 'uploadFinished':
726
- setState('confirm', files);
727
- break;
728
- case 'startUpload':
729
- /* 添加额外的GET参数 */
730
- var params = utils.serializeParam(editor.queryCommandValue('serverparam')) || '',
731
- url = utils.formatUrl(actionUrl + (actionUrl.indexOf('?') == -1 ? '?' : '&') + 'encode=utf-8&' + params);
732
- uploader.option('server', url);
733
- setState('uploading', files);
734
- break;
735
- case 'stopUpload':
736
- setState('paused', files);
737
- break;
738
- }
739
- });
740
-
741
- uploader.on('uploadBeforeSend', function (file, data, header) {
742
- //这里可以通过data对象添加POST参数
743
- if (actionUrl.toLowerCase().indexOf('jsp') != -1) {
744
- header['X_Requested_With'] = 'XMLHttpRequest';
745
- }
746
- });
747
-
748
- uploader.on('uploadProgress', function (file, percentage) {
749
- var $li = $('#' + file.id),
750
- $percent = $li.find('.progress span');
751
-
752
- $percent.css('width', percentage * 100 + '%');
753
- percentages[file.id][1] = percentage;
754
- updateTotalProgress();
755
- });
756
-
757
- uploader.on('uploadSuccess', function (file, json) {
758
- var $file = $('#' + file.id);
759
- try {
760
- if (json.state == 'SUCCESS') {
761
- uploadaudioList.push({
762
- 'url': json.url,
763
- 'type': json.type,
764
- 'original': json.original
765
- });
766
- $file.append('<span class="success"></span>');
767
- } else {
768
- $file.find('.error').text(json.state).show();
769
- }
770
- } catch (e) {
771
- $file.find('.error').text(lang.errorServerUpload).show();
772
- }
773
- });
774
-
775
- uploader.on('uploadError', function (file, code) {
776
- });
777
- uploader.on('error', function (code, file) {
778
- if (code == 'Q_TYPE_DENIED' || code == 'F_EXCEED_SIZE') {
779
- addFile(file);
780
- }
781
- });
782
- uploader.on('uploadComplete', function (file, ret) {
783
- });
784
-
785
- $upload.on('click', function () {
786
- if ($(this).hasClass('disabled')) {
787
- return false;
788
- }
789
-
790
- if (state === 'ready') {
791
- uploader.upload();
792
- } else if (state === 'paused') {
793
- uploader.upload();
794
- } else if (state === 'uploading') {
795
- uploader.stop();
796
- }
797
- });
798
-
799
- $upload.addClass('state-' + state);
800
- updateTotalProgress();
801
- },
802
- getQueueCount: function () {
803
- var file, i, status, readyFile = 0, files = this.uploader.getFiles();
804
- for (i = 0; file = files[i++];) {
805
- status = file.getStatus();
806
- if (status == 'queued' || status == 'uploading' || status == 'progress') readyFile++;
807
- }
808
- return readyFile;
809
- },
810
- refresh: function () {
811
- this.uploader.refresh();
812
- }
813
- };
814
-
815
- })();
1
+ /*! UEditorPlus v2.0.0*/
2
+ !function(){function a(){for(var a=$G("tabHeads").children,b=0;b<a.length;b++)domUtils.on(a[b],"click",function(b){var c,d,e=b.target||b.srcElement;for(c=0;c<a.length;c++)d=a[c].getAttribute("data-content-id"),a[c]==e?(domUtils.addClass(a[c],"focus"),domUtils.addClass($G(d),"focus")):(domUtils.removeClasses(a[c],"focus"),domUtils.removeClasses($G(d),"focus"))});r.disableUpload||($G("tabHeads").querySelector('[data-content-id="upload"]').style.display="inline-block"),r.selectCallback&&($G("audioSelect").style.display="inline-block",domUtils.on($G("audioSelect"),"click",function(a){r.selectCallback(editor,function(a){a&&($G("audioUrl").value=a.path,k(a.path))})}))}function b(){g(["audioFloat","upload_alignment"]),i($G("audioUrl")),c(),function(){var a,b=editor.selection.getRange().getClosedNode();if(b&&b.className){var c="edui-faked-audio"==b.className,e=b.className.indexOf("edui-upload-audio")!=-1;if(c||e){$G("audioUrl").value=a=b.getAttribute("_url");var f=domUtils.getComputedStyle(b,"float"),g=domUtils.getComputedStyle(b.parentNode,"text-align");d("center"===g?"center":f)}e&&(q=!0)}k(a)}()}function c(){dialog.onok=function(){$G("preview").innerHTML="";var a=f("tabHeads","tabSrc");switch(a){case"audio":return e();case"upload":return l()}},dialog.oncancel=function(){$G("preview").innerHTML=""}}function d(a){for(var b,c=$G("audioFloat").children,d=0;b=c[d++];)b.getAttribute("name")==a?"focus"!=b.className&&(b.className="focus"):"focus"==b.className&&(b.className="")}function e(){var a=$G("audioUrl").value;f("audioFloat","name");return!!a&&void editor.execCommand("insertaudio",{url:a},q?"upload":null)}function f(a,b){for(var c,d,e=$G(a).children,f=0;d=e[f++];)if("focus"==d.className){c=d.getAttribute(b);break}return c}function g(a){for(var b,c=0;b=a[c++];){var d=$G(b),e={none:lang["default"],left:lang.floatLeft,right:lang.floatRight,center:lang.block};for(var f in e){var g=document.createElement("div");g.setAttribute("name",f),"none"==f?(g.className="focus",g.style.cssText="background-image:url(icon/"+f+"-active.png);"):g.style.cssText="background-image:url(icon/"+f+".png);",g.setAttribute("title",e[f]),d.appendChild(g)}h(b)}}function h(a){for(var b,c=$G(a).children,d=0;b=c[d++];)domUtils.on(b,"click",function(){for(var a,b=0;a=c[b++];)a.className="",a.style.cssText="background-image:url(icon/"+a.getAttribute("name")+".png);",a.removeAttribute&&a.removeAttribute("class");this.className="focus",this.style.cssText="background-image:url(icon/"+this.getAttribute("name")+"-active.png);"})}function i(a){browser.ie?a.onpropertychange=function(){k(this.value)}:a.addEventListener("input",function(){k(this.value)},!1)}function j(a,b){b=b||{};var c=["<audio",b.id?' id="'+b.id+'"':"",b.cls?' class="'+b.cls+'"':""," controls >",'<source src="'+a+'" type="audio/mpeg" />',"</audio>"];return c.join("")}function k(a){a&&($G("preview").innerHTML='<div class="previewMsg"><span>'+lang.urlError+'</span></div><div style="position: absolute; inset: 0; background: #FFF; text-align: center; display: flex; justify-items: center; align-items: center;"><div style="text-align:center;flex-grow:1;">'+j(a)+"</div></div>")}function l(){var a=[],b=editor.getOpt("audioUrlPrefix"),c=f("upload_alignment","name")||"none";for(var d in p){var e=p[d];a.push({url:b+e.url,align:c})}var g=o.getQueueCount();return g?($(".info","#queueList").html('<span style="color:red;">'+"还有2个未上传文件".replace(/[\d]/,g)+"</span>"),!1):void editor.execCommand("insertaudio",a,"upload")}function m(){o=new n("queueList")}function n(a){this.$wrap=a.constructor==String?$("#"+a):$(a),this.init()}var o,p=[],q=!1,r={};window.onload=function(){r=editor.getOpt("audioConfig"),$focus($G("audioUrl")),a(),b(),m()},n.prototype={init:function(){this.fileList=[],this.initContainer(),this.initUploader()},initContainer:function(){this.$queue=this.$wrap.find(".filelist")},initUploader:function(){function a(a){var b=h('<li id="'+a.id+'"><p class="title">'+a.name+'</p><p class="imgWrap"></p><p class="progress"><span></span></p></li>'),c=h('<div class="file-panel"><span class="cancel">'+lang.uploadDelete+'</span><span class="rotateRight">'+lang.uploadTurnRight+'</span><span class="rotateLeft">'+lang.uploadTurnLeft+"</span></div>").appendTo(b),d=b.find("p.progress span"),e=b.find("p.imgWrap"),g=h('<p class="error"></p>').hide().appendTo(b),i=function(a){switch(a){case"exceed_size":text=lang.errorExceedSize;break;case"interrupt":text=lang.errorInterrupt;break;case"http":text=lang.errorHttp;break;case"not_allow_type":text=lang.errorFileType;break;default:text=lang.errorUploadRetry}g.text(text).show()};"invalid"===a.getStatus()?i(a.statusText):(e.text(lang.uploadPreview),"|png|jpg|jpeg|bmp|gif|".indexOf("|"+a.ext.toLowerCase()+"|")==-1?e.empty().addClass("notimage").append('<i class="file-preview file-type-'+a.ext.toLowerCase()+'"></i><span class="file-title">'+a.name+"</span>"):browser.ie&&browser.version<=7?e.text(lang.uploadNoPreview):f.makeThumb(a,function(a,b){if(a||!b||/^data:/.test(b)&&browser.ie&&browser.version<=7)e.text(lang.uploadNoPreview);else{var c=h('<img src="'+b+'">');e.empty().append(c),c.on("error",function(){e.text(lang.uploadNoPreview)})}},u,v),x[a.id]=[a.size,0],a.rotation=0,a.ext&&B.indexOf(a.ext.toLowerCase())!=-1||(i("not_allow_type"),f.removeFile(a))),a.on("statuschange",function(e,f){"progress"===f?d.hide().width(0):"queued"===f&&(b.off("mouseenter mouseleave"),c.remove()),"error"===e||"invalid"===e?(i(a.statusText),x[a.id][1]=1):"interrupt"===e?i("interrupt"):"queued"===e?x[a.id][1]=0:"progress"===e&&(g.hide(),d.css("display","block")),b.removeClass("state-"+f).addClass("state-"+e)}),b.on("mouseenter",function(){c.stop().animate({height:30})}),b.on("mouseleave",function(){c.stop().animate({height:0})}),c.on("click","span",function(){var b,c=h(this).index();switch(c){case 0:return void f.removeFile(a);case 1:a.rotation+=90;break;case 2:a.rotation-=90}y?(b="rotate("+a.rotation+"deg)",e.css({"-webkit-transform":b,"-mos-transform":b,"-o-transform":b,transform:b})):e.css("filter","progid:DXImageTransform.Microsoft.BasicImage(rotation="+~~(a.rotation/90%4+4)%4+")")}),b.insertBefore(n)}function b(a){var b=h("#"+a.id);delete x[a.id],c(),b.off().find(".file-panel").off().end().remove()}function c(){var a,b=0,c=0,d=q.children();h.each(x,function(a,d){c+=d[0],b+=d[0]*d[1]}),a=c?b/c:0,d.eq(0).text(Math.round(100*a)+"%"),d.eq(1).css("width",Math.round(100*a)+"%"),e()}function d(a,b){if(a!=w){var c=f.getStats();switch(m.removeClass("state-"+w),m.addClass("state-"+a),a){case"pedding":j.addClass("element-invisible"),k.addClass("element-invisible"),o.removeClass("element-invisible"),q.hide(),l.hide(),f.refresh();break;case"ready":o.addClass("element-invisible"),j.removeClass("element-invisible"),k.removeClass("element-invisible"),q.hide(),l.show(),m.text(lang.uploadStart),f.refresh();break;case"uploading":q.show(),l.hide(),m.text(lang.uploadPause);break;case"paused":q.show(),l.hide(),m.text(lang.uploadContinue);break;case"confirm":if(q.show(),l.hide(),m.text(lang.uploadStart),c=f.getStats(),c.successNum&&!c.uploadFailNum)return void d("finish");break;case"finish":q.hide(),l.show(),c.uploadFailNum?m.text(lang.uploadRetry):m.text(lang.uploadStart)}w=a,e()}g.getQueueCount()?m.removeClass("disabled"):m.addClass("disabled")}function e(){var a,b="";"ready"===w?b=lang.updateStatusReady.replace("_",r).replace("_KB",WebUploader.formatSize(s)):"confirm"===w?(a=f.getStats(),a.uploadFailNum&&(b=lang.updateStatusConfirm.replace("_",a.successNum).replace("_",a.successNum))):(a=f.getStats(),b=lang.updateStatusFinish.replace("_",r).replace("_KB",WebUploader.formatSize(s)).replace("_",a.successNum),a.uploadFailNum&&(b+=lang.updateStatusError.replace("_",a.uploadFailNum))),l.html(b)}var f,g=this,h=jQuery,i=g.$wrap,j=i.find(".filelist"),k=i.find(".statusBar"),l=k.find(".info"),m=i.find(".uploadBtn"),n=(i.find(".filePickerBtn"),i.find(".filePickerBlock")),o=i.find(".placeholder"),q=k.find(".progress").hide(),r=0,s=0,t=window.devicePixelRatio||1,u=113*t,v=113*t,w="",x={},y=function(){var a=document.createElement("p").style,b="transition"in a||"WebkitTransition"in a||"MozTransition"in a||"msTransition"in a||"OTransition"in a;return a=null,b}(),z=editor.getActionUrl(editor.getOpt("audioActionName")),A=editor.getOpt("audioMaxSize"),B=(editor.getOpt("audioAllowFiles")||[]).join("").replace(/\./g,",").replace(/^[,]/,"");return m.hide(),WebUploader.Uploader.support()?editor.getOpt("audioActionName")?(f=g.uploader=WebUploader.create({pick:{id:"#filePickerReady",label:lang.uploadSelectFile},swf:"../../third-party/webuploader/Uploader.swf",server:z,fileVal:editor.getOpt("audioFieldName"),duplicate:!0,fileSingleSizeLimit:A,headers:editor.getOpt("serverHeaders")||{},compress:!1}),f.addButton({id:"#filePickerBlock"}),f.addButton({id:"#filePickerBtn",label:lang.uploadAddFile}),d("pedding"),f.on("beforeFileQueued",function(a){return!(!a.ext||B.indexOf(a.ext.toLowerCase())==-1)}),f.on("fileQueued",function(b){r++,s+=b.size,1===r&&(o.addClass("element-invisible"),k.show()),a(b);const c=editor.getOpt("uploadFunction");"function"==typeof c&&("ready"===w?d("uploading"):"pedding"===w&&(d("ready"),d("uploading")),b.setStatus("progress"),f.trigger("uploadProgress",b,0),c(b.source.source).then(function(a){f.trigger("uploadProgress",b,1),b.setStatus("complete"),d("finish"),f.trigger("uploadSuccess",b,a),f.trigger("uploadComplete",b)}))}),f.on("fileDequeued",function(a){r--,s-=a.size,b(a),c()}),f.on("filesQueued",function(a){f.isInProgress()||"pedding"!=w&&"finish"!=w&&"confirm"!=w&&"ready"!=w||d("ready"),c()}),f.on("all",function(a,b){switch(a){case"uploadFinished":d("confirm",b);break;case"startUpload":var c=utils.serializeParam(editor.queryCommandValue("serverparam"))||"",e=utils.formatUrl(z+(z.indexOf("?")==-1?"?":"&")+"encode=utf-8&"+c);f.option("server",e),d("uploading",b);break;case"stopUpload":d("paused",b)}}),f.on("uploadBeforeSend",function(a,b,c){z.toLowerCase().indexOf("jsp")!=-1&&(c.X_Requested_With="XMLHttpRequest")}),f.on("uploadProgress",function(a,b){var d=h("#"+a.id),e=d.find(".progress span");e.css("width",100*b+"%"),x[a.id][1]=b,c()}),f.on("uploadSuccess",function(a,b){var c=h("#"+a.id);try{"SUCCESS"==b.state?(p.push({url:b.url,type:b.type,original:b.original}),c.append('<span class="success"></span>')):c.find(".error").text(b.state).show()}catch(d){c.find(".error").text(lang.errorServerUpload).show()}}),f.on("uploadError",function(a,b){}),f.on("error",function(b,c){"Q_TYPE_DENIED"!=b&&"F_EXCEED_SIZE"!=b||a(c)}),f.on("uploadComplete",function(a,b){}),m.on("click",function(){return!h(this).hasClass("disabled")&&void("ready"===w?f.upload():"paused"===w?f.upload():"uploading"===w&&f.stop())}),m.addClass("state-"+w),void c()):void h("#filePickerReady").after(h("<div>").html(lang.errorLoadConfig)).hide():void h("#filePickerReady").after(h("<div>").html(lang.errorNotSupport)).hide()},getQueueCount:function(){var a,b,c,d=0,e=this.uploader.getFiles();for(b=0;a=e[b++];)c=a.getStatus(),"queued"!=c&&"uploading"!=c&&"progress"!=c||d++;return d},refresh:function(){this.uploader.refresh()}}}();