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

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 (82) hide show
  1. package/es/LcdpUeditor.d.ts +4 -0
  2. package/es/LcdpUeditor.js +45 -8
  3. package/es/tools/UeditorResourceLoader.d.ts +1 -1
  4. package/es/tools/UeditorResourceLoader.js +18 -7
  5. package/es/tools/filterHtmlNode.js +7 -2
  6. package/lib/LcdpUeditor.d.ts +4 -0
  7. package/lib/LcdpUeditor.js +35 -10
  8. package/lib/tools/UeditorResourceLoader.d.ts +1 -1
  9. package/lib/tools/UeditorResourceLoader.js +15 -7
  10. package/lib/tools/filterHtmlNode.js +8 -4
  11. package/package.json +1 -1
  12. package/ueditor-resource/dialogs/anchor/anchor.html +1 -1
  13. package/ueditor-resource/dialogs/attachment/attachment.css +2 -715
  14. package/ueditor-resource/dialogs/attachment/attachment.html +6 -6
  15. package/ueditor-resource/dialogs/attachment/attachment.js +2 -803
  16. package/ueditor-resource/dialogs/audio/audio.css +2 -878
  17. package/ueditor-resource/dialogs/audio/audio.js +2 -815
  18. package/ueditor-resource/dialogs/background/background.css +2 -192
  19. package/ueditor-resource/dialogs/background/background.html +3 -3
  20. package/ueditor-resource/dialogs/background/background.js +2 -370
  21. package/ueditor-resource/dialogs/contentimport/contentimport.html +3 -3
  22. package/ueditor-resource/dialogs/contentimport/contentimport.js +2 -91
  23. package/ueditor-resource/dialogs/emotion/emotion.css +2 -128
  24. package/ueditor-resource/dialogs/emotion/emotion.html +3 -3
  25. package/ueditor-resource/dialogs/emotion/emotion.js +2 -186
  26. package/ueditor-resource/dialogs/formula/formula.html +4 -4
  27. package/ueditor-resource/dialogs/formula/formula.js +2 -147
  28. package/ueditor-resource/dialogs/help/help.css +2 -36
  29. package/ueditor-resource/dialogs/help/help.html +3 -3
  30. package/ueditor-resource/dialogs/help/help.js +2 -57
  31. package/ueditor-resource/dialogs/image/image.css +2 -767
  32. package/ueditor-resource/dialogs/image/image.js +2 -1060
  33. package/ueditor-resource/dialogs/insertframe/insertframe.html +2 -2
  34. package/ueditor-resource/dialogs/internal.js +2 -81
  35. package/ueditor-resource/dialogs/preview/preview.html +2 -2
  36. package/ueditor-resource/dialogs/scrawl/scrawl.css +2 -323
  37. package/ueditor-resource/dialogs/scrawl/scrawl.html +3 -3
  38. package/ueditor-resource/dialogs/scrawl/scrawl.js +2 -682
  39. package/ueditor-resource/dialogs/searchreplace/searchreplace.html +2 -2
  40. package/ueditor-resource/dialogs/searchreplace/searchreplace.js +2 -174
  41. package/ueditor-resource/dialogs/spechars/spechars.html +2 -2
  42. package/ueditor-resource/dialogs/spechars/spechars.js +2 -86
  43. package/ueditor-resource/dialogs/table/edittable.css +2 -84
  44. package/ueditor-resource/dialogs/table/edittable.html +3 -3
  45. package/ueditor-resource/dialogs/table/edittable.js +2 -241
  46. package/ueditor-resource/dialogs/table/edittd.html +1 -1
  47. package/ueditor-resource/dialogs/table/edittip.html +1 -1
  48. package/ueditor-resource/dialogs/template/config.js +2 -42
  49. package/ueditor-resource/dialogs/template/template.css +2 -98
  50. package/ueditor-resource/dialogs/template/template.html +4 -4
  51. package/ueditor-resource/dialogs/template/template.js +2 -53
  52. package/ueditor-resource/dialogs/video/video.css +2 -908
  53. package/ueditor-resource/dialogs/video/video.js +2 -867
  54. package/ueditor-resource/dialogs/wordimage/wordimage.html +5 -5
  55. package/ueditor-resource/dialogs/wordimage/wordimage.js +2 -93
  56. package/ueditor-resource/lang/en/en.js +2 -686
  57. package/ueditor-resource/lang/zh-cn/zh-cn.js +2 -748
  58. package/ueditor-resource/lang/zh-tw/zh-tw.js +2 -748
  59. package/ueditor-resource/plugins/browser-image-compression.js +9 -0
  60. package/ueditor-resource/themes/default/css/ueditor.css +2 -2148
  61. package/ueditor-resource/themes/default/dialog.css +2 -16
  62. package/ueditor-resource/themes/default/dialogbase.css +2 -131
  63. package/ueditor-resource/themes/iframe.css +2 -62
  64. package/ueditor-resource/third-party/SyntaxHighlighter/shCore.js +4 -3655
  65. package/ueditor-resource/third-party/SyntaxHighlighter/shCoreDefault.css +3 -1
  66. package/ueditor-resource/third-party/clipboard/clipboard.js +2 -753
  67. package/ueditor-resource/third-party/codemirror/codemirror.css +2 -105
  68. package/ueditor-resource/third-party/codemirror/codemirror.js +4 -3581
  69. package/ueditor-resource/third-party/jquery-3.5.1.js +4 -2
  70. package/ueditor-resource/third-party/jquery-3.5.1_1.js +4 -4314
  71. package/ueditor-resource/third-party/webuploader/webuploader.css +2 -87
  72. package/ueditor-resource/third-party/webuploader/webuploader.js +5 -4
  73. package/ueditor-resource/ueditor.all.js +23 -32644
  74. package/ueditor-resource/ueditor.config.js +2 -655
  75. package/ueditor-resource/ueditor.parse.js +2 -639
  76. package/es/LcdpUeditor.d.ts.map +0 -1
  77. package/es/const.d.ts.map +0 -1
  78. package/es/index.d.ts.map +0 -1
  79. package/es/tools/UeditorResourceLoader.d.ts.map +0 -1
  80. package/es/tools/filterHtmlNode.d.ts.map +0 -1
  81. package/es/tools/loadScript.d.ts.map +0 -1
  82. package/es/type.d.ts.map +0 -1
@@ -1,753 +1,2 @@
1
- /*!
2
- * clipboard.js v1.5.15
3
- * https://zenorocha.github.io/clipboard.js
4
- *
5
- * Licensed MIT © Zeno Rocha
6
- */
7
- (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Clipboard = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
8
- /**
9
- * A polyfill for Element.matches()
10
- */
11
- if (Element && !Element.prototype.matches) {
12
- var proto = Element.prototype;
13
-
14
- proto.matches = proto.matchesSelector ||
15
- proto.mozMatchesSelector ||
16
- proto.msMatchesSelector ||
17
- proto.oMatchesSelector ||
18
- proto.webkitMatchesSelector;
19
- }
20
-
21
- /**
22
- * Finds the closest parent that matches a selector.
23
- *
24
- * @param {Element} element
25
- * @param {String} selector
26
- * @return {Function}
27
- */
28
- function closest (element, selector) {
29
- while (element && element !== document) {
30
- if (element.matches(selector)) return element;
31
- element = element.parentNode;
32
- }
33
- }
34
-
35
- module.exports = closest;
36
-
37
- },{}],2:[function(require,module,exports){
38
- var closest = require('./closest');
39
-
40
- /**
41
- * Delegates event to a selector.
42
- *
43
- * @param {Element} element
44
- * @param {String} selector
45
- * @param {String} type
46
- * @param {Function} callback
47
- * @param {Boolean} useCapture
48
- * @return {Object}
49
- */
50
- function delegate(element, selector, type, callback, useCapture) {
51
- var listenerFn = listener.apply(this, arguments);
52
-
53
- element.addEventListener(type, listenerFn, useCapture);
54
-
55
- return {
56
- destroy: function() {
57
- element.removeEventListener(type, listenerFn, useCapture);
58
- }
59
- }
60
- }
61
-
62
- /**
63
- * Finds closest match and invokes callback.
64
- *
65
- * @param {Element} element
66
- * @param {String} selector
67
- * @param {String} type
68
- * @param {Function} callback
69
- * @return {Function}
70
- */
71
- function listener(element, selector, type, callback) {
72
- return function(e) {
73
- e.delegateTarget = closest(e.target, selector);
74
-
75
- if (e.delegateTarget) {
76
- callback.call(element, e);
77
- }
78
- }
79
- }
80
-
81
- module.exports = delegate;
82
-
83
- },{"./closest":1}],3:[function(require,module,exports){
84
- /**
85
- * Check if argument is a HTML element.
86
- *
87
- * @param {Object} value
88
- * @return {Boolean}
89
- */
90
- exports.node = function(value) {
91
- return value !== undefined
92
- && value instanceof HTMLElement
93
- && value.nodeType === 1;
94
- };
95
-
96
- /**
97
- * Check if argument is a list of HTML elements.
98
- *
99
- * @param {Object} value
100
- * @return {Boolean}
101
- */
102
- exports.nodeList = function(value) {
103
- var type = Object.prototype.toString.call(value);
104
-
105
- return value !== undefined
106
- && (type === '[object NodeList]' || type === '[object HTMLCollection]')
107
- && ('length' in value)
108
- && (value.length === 0 || exports.node(value[0]));
109
- };
110
-
111
- /**
112
- * Check if argument is a string.
113
- *
114
- * @param {Object} value
115
- * @return {Boolean}
116
- */
117
- exports.string = function(value) {
118
- return typeof value === 'string'
119
- || value instanceof String;
120
- };
121
-
122
- /**
123
- * Check if argument is a function.
124
- *
125
- * @param {Object} value
126
- * @return {Boolean}
127
- */
128
- exports.fn = function(value) {
129
- var type = Object.prototype.toString.call(value);
130
-
131
- return type === '[object Function]';
132
- };
133
-
134
- },{}],4:[function(require,module,exports){
135
- var is = require('./is');
136
- var delegate = require('delegate');
137
-
138
- /**
139
- * Validates all params and calls the right
140
- * listener function based on its target type.
141
- *
142
- * @param {String|HTMLElement|HTMLCollection|NodeList} target
143
- * @param {String} type
144
- * @param {Function} callback
145
- * @return {Object}
146
- */
147
- function listen(target, type, callback) {
148
- if (!target && !type && !callback) {
149
- throw new Error('Missing required arguments');
150
- }
151
-
152
- if (!is.string(type)) {
153
- throw new TypeError('Second argument must be a String');
154
- }
155
-
156
- if (!is.fn(callback)) {
157
- throw new TypeError('Third argument must be a Function');
158
- }
159
-
160
- if (is.node(target)) {
161
- return listenNode(target, type, callback);
162
- }
163
- else if (is.nodeList(target)) {
164
- return listenNodeList(target, type, callback);
165
- }
166
- else if (is.string(target)) {
167
- return listenSelector(target, type, callback);
168
- }
169
- else {
170
- throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList');
171
- }
172
- }
173
-
174
- /**
175
- * Adds an event listener to a HTML element
176
- * and returns a remove listener function.
177
- *
178
- * @param {HTMLElement} node
179
- * @param {String} type
180
- * @param {Function} callback
181
- * @return {Object}
182
- */
183
- function listenNode(node, type, callback) {
184
- node.addEventListener(type, callback);
185
-
186
- return {
187
- destroy: function() {
188
- node.removeEventListener(type, callback);
189
- }
190
- }
191
- }
192
-
193
- /**
194
- * Add an event listener to a list of HTML elements
195
- * and returns a remove listener function.
196
- *
197
- * @param {NodeList|HTMLCollection} nodeList
198
- * @param {String} type
199
- * @param {Function} callback
200
- * @return {Object}
201
- */
202
- function listenNodeList(nodeList, type, callback) {
203
- Array.prototype.forEach.call(nodeList, function(node) {
204
- node.addEventListener(type, callback);
205
- });
206
-
207
- return {
208
- destroy: function() {
209
- Array.prototype.forEach.call(nodeList, function(node) {
210
- node.removeEventListener(type, callback);
211
- });
212
- }
213
- }
214
- }
215
-
216
- /**
217
- * Add an event listener to a selector
218
- * and returns a remove listener function.
219
- *
220
- * @param {String} selector
221
- * @param {String} type
222
- * @param {Function} callback
223
- * @return {Object}
224
- */
225
- function listenSelector(selector, type, callback) {
226
- return delegate(document.body, selector, type, callback);
227
- }
228
-
229
- module.exports = listen;
230
-
231
- },{"./is":3,"delegate":2}],5:[function(require,module,exports){
232
- function select(element) {
233
- var selectedText;
234
-
235
- if (element.nodeName === 'SELECT') {
236
- element.focus();
237
-
238
- selectedText = element.value;
239
- }
240
- else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
241
- element.focus();
242
- element.setSelectionRange(0, element.value.length);
243
-
244
- selectedText = element.value;
245
- }
246
- else {
247
- if (element.hasAttribute('contenteditable')) {
248
- element.focus();
249
- }
250
-
251
- var selection = window.getSelection();
252
- var range = document.createRange();
253
-
254
- range.selectNodeContents(element);
255
- selection.removeAllRanges();
256
- selection.addRange(range);
257
-
258
- selectedText = selection.toString();
259
- }
260
-
261
- return selectedText;
262
- }
263
-
264
- module.exports = select;
265
-
266
- },{}],6:[function(require,module,exports){
267
- function E () {
268
- // Keep this empty so it's easier to inherit from
269
- // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
270
- }
271
-
272
- E.prototype = {
273
- on: function (name, callback, ctx) {
274
- var e = this.e || (this.e = {});
275
-
276
- (e[name] || (e[name] = [])).push({
277
- fn: callback,
278
- ctx: ctx
279
- });
280
-
281
- return this;
282
- },
283
-
284
- once: function (name, callback, ctx) {
285
- var self = this;
286
- function listener () {
287
- self.off(name, listener);
288
- callback.apply(ctx, arguments);
289
- };
290
-
291
- listener._ = callback
292
- return this.on(name, listener, ctx);
293
- },
294
-
295
- emit: function (name) {
296
- var data = [].slice.call(arguments, 1);
297
- var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
298
- var i = 0;
299
- var len = evtArr.length;
300
-
301
- for (i; i < len; i++) {
302
- evtArr[i].fn.apply(evtArr[i].ctx, data);
303
- }
304
-
305
- return this;
306
- },
307
-
308
- off: function (name, callback) {
309
- var e = this.e || (this.e = {});
310
- var evts = e[name];
311
- var liveEvents = [];
312
-
313
- if (evts && callback) {
314
- for (var i = 0, len = evts.length; i < len; i++) {
315
- if (evts[i].fn !== callback && evts[i].fn._ !== callback)
316
- liveEvents.push(evts[i]);
317
- }
318
- }
319
-
320
- // Remove event from queue to prevent memory leak
321
- // Suggested by https://github.com/lazd
322
- // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
323
-
324
- (liveEvents.length)
325
- ? e[name] = liveEvents
326
- : delete e[name];
327
-
328
- return this;
329
- }
330
- };
331
-
332
- module.exports = E;
333
-
334
- },{}],7:[function(require,module,exports){
335
- (function (global, factory) {
336
- if (typeof define === "function" && define.amd) {
337
- define(['module', 'select'], factory);
338
- } else if (typeof exports !== "undefined") {
339
- factory(module, require('select'));
340
- } else {
341
- var mod = {
342
- exports: {}
343
- };
344
- factory(mod, global.select);
345
- global.clipboardAction = mod.exports;
346
- }
347
- })(this, function (module, _select) {
348
- 'use strict';
349
-
350
- var _select2 = _interopRequireDefault(_select);
351
-
352
- function _interopRequireDefault(obj) {
353
- return obj && obj.__esModule ? obj : {
354
- default: obj
355
- };
356
- }
357
-
358
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
359
- return typeof obj;
360
- } : function (obj) {
361
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
362
- };
363
-
364
- function _classCallCheck(instance, Constructor) {
365
- if (!(instance instanceof Constructor)) {
366
- throw new TypeError("Cannot call a class as a function");
367
- }
368
- }
369
-
370
- var _createClass = function () {
371
- function defineProperties(target, props) {
372
- for (var i = 0; i < props.length; i++) {
373
- var descriptor = props[i];
374
- descriptor.enumerable = descriptor.enumerable || false;
375
- descriptor.configurable = true;
376
- if ("value" in descriptor) descriptor.writable = true;
377
- Object.defineProperty(target, descriptor.key, descriptor);
378
- }
379
- }
380
-
381
- return function (Constructor, protoProps, staticProps) {
382
- if (protoProps) defineProperties(Constructor.prototype, protoProps);
383
- if (staticProps) defineProperties(Constructor, staticProps);
384
- return Constructor;
385
- };
386
- }();
387
-
388
- var ClipboardAction = function () {
389
- /**
390
- * @param {Object} options
391
- */
392
- function ClipboardAction(options) {
393
- _classCallCheck(this, ClipboardAction);
394
-
395
- this.resolveOptions(options);
396
- this.initSelection();
397
- }
398
-
399
- /**
400
- * Defines base properties passed from constructor.
401
- * @param {Object} options
402
- */
403
-
404
-
405
- _createClass(ClipboardAction, [{
406
- key: 'resolveOptions',
407
- value: function resolveOptions() {
408
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
409
-
410
- this.action = options.action;
411
- this.emitter = options.emitter;
412
- this.target = options.target;
413
- this.text = options.text;
414
- this.trigger = options.trigger;
415
-
416
- this.selectedText = '';
417
- }
418
- }, {
419
- key: 'initSelection',
420
- value: function initSelection() {
421
- if (this.text) {
422
- this.selectFake();
423
- } else if (this.target) {
424
- this.selectTarget();
425
- }
426
- }
427
- }, {
428
- key: 'selectFake',
429
- value: function selectFake() {
430
- var _this = this;
431
-
432
- var isRTL = document.documentElement.getAttribute('dir') == 'rtl';
433
-
434
- this.removeFake();
435
-
436
- this.fakeHandlerCallback = function () {
437
- return _this.removeFake();
438
- };
439
- this.fakeHandler = document.body.addEventListener('click', this.fakeHandlerCallback) || true;
440
-
441
- this.fakeElem = document.createElement('textarea');
442
- // Prevent zooming on iOS
443
- this.fakeElem.style.fontSize = '12pt';
444
- // Reset box model
445
- this.fakeElem.style.border = '0';
446
- this.fakeElem.style.padding = '0';
447
- this.fakeElem.style.margin = '0';
448
- // Move element out of screen horizontally
449
- this.fakeElem.style.position = 'absolute';
450
- this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';
451
- // Move element to the same position vertically
452
- var yPosition = window.pageYOffset || document.documentElement.scrollTop;
453
- this.fakeElem.addEventListener('focus', window.scrollTo(0, yPosition));
454
- this.fakeElem.style.top = yPosition + 'px';
455
-
456
- this.fakeElem.setAttribute('readonly', '');
457
- this.fakeElem.value = this.text;
458
-
459
- document.body.appendChild(this.fakeElem);
460
-
461
- this.selectedText = (0, _select2.default)(this.fakeElem);
462
- this.copyText();
463
- }
464
- }, {
465
- key: 'removeFake',
466
- value: function removeFake() {
467
- if (this.fakeHandler) {
468
- document.body.removeEventListener('click', this.fakeHandlerCallback);
469
- this.fakeHandler = null;
470
- this.fakeHandlerCallback = null;
471
- }
472
-
473
- if (this.fakeElem) {
474
- document.body.removeChild(this.fakeElem);
475
- this.fakeElem = null;
476
- }
477
- }
478
- }, {
479
- key: 'selectTarget',
480
- value: function selectTarget() {
481
- this.selectedText = (0, _select2.default)(this.target);
482
- this.copyText();
483
- }
484
- }, {
485
- key: 'copyText',
486
- value: function copyText() {
487
- var succeeded = void 0;
488
-
489
- try {
490
- succeeded = document.execCommand(this.action);
491
- } catch (err) {
492
- succeeded = false;
493
- }
494
-
495
- this.handleResult(succeeded);
496
- }
497
- }, {
498
- key: 'handleResult',
499
- value: function handleResult(succeeded) {
500
- this.emitter.emit(succeeded ? 'success' : 'error', {
501
- action: this.action,
502
- text: this.selectedText,
503
- trigger: this.trigger,
504
- clearSelection: this.clearSelection.bind(this)
505
- });
506
- }
507
- }, {
508
- key: 'clearSelection',
509
- value: function clearSelection() {
510
- if (this.target) {
511
- this.target.blur();
512
- }
513
-
514
- window.getSelection().removeAllRanges();
515
- }
516
- }, {
517
- key: 'destroy',
518
- value: function destroy() {
519
- this.removeFake();
520
- }
521
- }, {
522
- key: 'action',
523
- set: function set() {
524
- var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy';
525
-
526
- this._action = action;
527
-
528
- if (this._action !== 'copy' && this._action !== 'cut') {
529
- throw new Error('Invalid "action" value, use either "copy" or "cut"');
530
- }
531
- },
532
- get: function get() {
533
- return this._action;
534
- }
535
- }, {
536
- key: 'target',
537
- set: function set(target) {
538
- if (target !== undefined) {
539
- if (target && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' && target.nodeType === 1) {
540
- if (this.action === 'copy' && target.hasAttribute('disabled')) {
541
- throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');
542
- }
543
-
544
- if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) {
545
- throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');
546
- }
547
-
548
- this._target = target;
549
- } else {
550
- throw new Error('Invalid "target" value, use a valid Element');
551
- }
552
- }
553
- },
554
- get: function get() {
555
- return this._target;
556
- }
557
- }]);
558
-
559
- return ClipboardAction;
560
- }();
561
-
562
- module.exports = ClipboardAction;
563
- });
564
-
565
- },{"select":5}],8:[function(require,module,exports){
566
- (function (global, factory) {
567
- if (typeof define === "function" && define.amd) {
568
- define(['module', './clipboard-action', 'tiny-emitter', 'good-listener'], factory);
569
- } else if (typeof exports !== "undefined") {
570
- factory(module, require('./clipboard-action'), require('tiny-emitter'), require('good-listener'));
571
- } else {
572
- var mod = {
573
- exports: {}
574
- };
575
- factory(mod, global.clipboardAction, global.tinyEmitter, global.goodListener);
576
- global.clipboard = mod.exports;
577
- }
578
- })(this, function (module, _clipboardAction, _tinyEmitter, _goodListener) {
579
- 'use strict';
580
-
581
- var _clipboardAction2 = _interopRequireDefault(_clipboardAction);
582
-
583
- var _tinyEmitter2 = _interopRequireDefault(_tinyEmitter);
584
-
585
- var _goodListener2 = _interopRequireDefault(_goodListener);
586
-
587
- function _interopRequireDefault(obj) {
588
- return obj && obj.__esModule ? obj : {
589
- default: obj
590
- };
591
- }
592
-
593
- function _classCallCheck(instance, Constructor) {
594
- if (!(instance instanceof Constructor)) {
595
- throw new TypeError("Cannot call a class as a function");
596
- }
597
- }
598
-
599
- var _createClass = function () {
600
- function defineProperties(target, props) {
601
- for (var i = 0; i < props.length; i++) {
602
- var descriptor = props[i];
603
- descriptor.enumerable = descriptor.enumerable || false;
604
- descriptor.configurable = true;
605
- if ("value" in descriptor) descriptor.writable = true;
606
- Object.defineProperty(target, descriptor.key, descriptor);
607
- }
608
- }
609
-
610
- return function (Constructor, protoProps, staticProps) {
611
- if (protoProps) defineProperties(Constructor.prototype, protoProps);
612
- if (staticProps) defineProperties(Constructor, staticProps);
613
- return Constructor;
614
- };
615
- }();
616
-
617
- function _possibleConstructorReturn(self, call) {
618
- if (!self) {
619
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
620
- }
621
-
622
- return call && (typeof call === "object" || typeof call === "function") ? call : self;
623
- }
624
-
625
- function _inherits(subClass, superClass) {
626
- if (typeof superClass !== "function" && superClass !== null) {
627
- throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
628
- }
629
-
630
- subClass.prototype = Object.create(superClass && superClass.prototype, {
631
- constructor: {
632
- value: subClass,
633
- enumerable: false,
634
- writable: true,
635
- configurable: true
636
- }
637
- });
638
- if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
639
- }
640
-
641
- var Clipboard = function (_Emitter) {
642
- _inherits(Clipboard, _Emitter);
643
-
644
- /**
645
- * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
646
- * @param {Object} options
647
- */
648
- function Clipboard(trigger, options) {
649
- _classCallCheck(this, Clipboard);
650
-
651
- var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this));
652
-
653
- _this.resolveOptions(options);
654
- _this.listenClick(trigger);
655
- return _this;
656
- }
657
-
658
- /**
659
- * Defines if attributes would be resolved using internal setter functions
660
- * or custom functions that were passed in the constructor.
661
- * @param {Object} options
662
- */
663
-
664
-
665
- _createClass(Clipboard, [{
666
- key: 'resolveOptions',
667
- value: function resolveOptions() {
668
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
669
-
670
- this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
671
- this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
672
- this.text = typeof options.text === 'function' ? options.text : this.defaultText;
673
- }
674
- }, {
675
- key: 'listenClick',
676
- value: function listenClick(trigger) {
677
- var _this2 = this;
678
-
679
- this.listener = (0, _goodListener2.default)(trigger, 'click', function (e) {
680
- return _this2.onClick(e);
681
- });
682
- }
683
- }, {
684
- key: 'onClick',
685
- value: function onClick(e) {
686
- var trigger = e.delegateTarget || e.currentTarget;
687
-
688
- if (this.clipboardAction) {
689
- this.clipboardAction = null;
690
- }
691
-
692
- this.clipboardAction = new _clipboardAction2.default({
693
- action: this.action(trigger),
694
- target: this.target(trigger),
695
- text: this.text(trigger),
696
- trigger: trigger,
697
- emitter: this
698
- });
699
- }
700
- }, {
701
- key: 'defaultAction',
702
- value: function defaultAction(trigger) {
703
- return getAttributeValue('action', trigger);
704
- }
705
- }, {
706
- key: 'defaultTarget',
707
- value: function defaultTarget(trigger) {
708
- var selector = getAttributeValue('target', trigger);
709
-
710
- if (selector) {
711
- return document.querySelector(selector);
712
- }
713
- }
714
- }, {
715
- key: 'defaultText',
716
- value: function defaultText(trigger) {
717
- return getAttributeValue('text', trigger);
718
- }
719
- }, {
720
- key: 'destroy',
721
- value: function destroy() {
722
- this.listener.destroy();
723
-
724
- if (this.clipboardAction) {
725
- this.clipboardAction.destroy();
726
- this.clipboardAction = null;
727
- }
728
- }
729
- }]);
730
-
731
- return Clipboard;
732
- }(_tinyEmitter2.default);
733
-
734
- /**
735
- * Helper function to retrieve attribute value.
736
- * @param {String} suffix
737
- * @param {Element} element
738
- */
739
- function getAttributeValue(suffix, element) {
740
- var attribute = 'data-clipboard-' + suffix;
741
-
742
- if (!element.hasAttribute(attribute)) {
743
- return;
744
- }
745
-
746
- return element.getAttribute(attribute);
747
- }
748
-
749
- module.exports = Clipboard;
750
- });
751
-
752
- },{"./clipboard-action":7,"good-listener":4,"tiny-emitter":6}]},{},[8])(8)
753
- });
1
+ /*! UEditorPlus v2.0.0*/
2
+ !function(f){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=f();else if("function"==typeof define&&define.amd)define([],f);else{var g;g="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,g.Clipboard=f()}}(function(){var define;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){function closest(element,selector){for(;element&&element!==document;){if(element.matches(selector))return element;element=element.parentNode}}if(Element&&!Element.prototype.matches){var proto=Element.prototype;proto.matches=proto.matchesSelector||proto.mozMatchesSelector||proto.msMatchesSelector||proto.oMatchesSelector||proto.webkitMatchesSelector}module.exports=closest},{}],2:[function(require,module,exports){function delegate(element,selector,type,callback,useCapture){var listenerFn=listener.apply(this,arguments);return element.addEventListener(type,listenerFn,useCapture),{destroy:function(){element.removeEventListener(type,listenerFn,useCapture)}}}function listener(element,selector,type,callback){return function(e){e.delegateTarget=closest(e.target,selector),e.delegateTarget&&callback.call(element,e)}}var closest=require("./closest");module.exports=delegate},{"./closest":1}],3:[function(require,module,exports){exports.node=function(value){return void 0!==value&&value instanceof HTMLElement&&1===value.nodeType},exports.nodeList=function(value){var type=Object.prototype.toString.call(value);return void 0!==value&&("[object NodeList]"===type||"[object HTMLCollection]"===type)&&"length"in value&&(0===value.length||exports.node(value[0]))},exports.string=function(value){return"string"==typeof value||value instanceof String},exports.fn=function(value){var type=Object.prototype.toString.call(value);return"[object Function]"===type}},{}],4:[function(require,module,exports){function listen(target,type,callback){if(!target&&!type&&!callback)throw new Error("Missing required arguments");if(!is.string(type))throw new TypeError("Second argument must be a String");if(!is.fn(callback))throw new TypeError("Third argument must be a Function");if(is.node(target))return listenNode(target,type,callback);if(is.nodeList(target))return listenNodeList(target,type,callback);if(is.string(target))return listenSelector(target,type,callback);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function listenNode(node,type,callback){return node.addEventListener(type,callback),{destroy:function(){node.removeEventListener(type,callback)}}}function listenNodeList(nodeList,type,callback){return Array.prototype.forEach.call(nodeList,function(node){node.addEventListener(type,callback)}),{destroy:function(){Array.prototype.forEach.call(nodeList,function(node){node.removeEventListener(type,callback)})}}}function listenSelector(selector,type,callback){return delegate(document.body,selector,type,callback)}var is=require("./is"),delegate=require("delegate");module.exports=listen},{"./is":3,delegate:2}],5:[function(require,module,exports){function select(element){var selectedText;if("SELECT"===element.nodeName)element.focus(),selectedText=element.value;else if("INPUT"===element.nodeName||"TEXTAREA"===element.nodeName)element.focus(),element.setSelectionRange(0,element.value.length),selectedText=element.value;else{element.hasAttribute("contenteditable")&&element.focus();var selection=window.getSelection(),range=document.createRange();range.selectNodeContents(element),selection.removeAllRanges(),selection.addRange(range),selectedText=selection.toString()}return selectedText}module.exports=select},{}],6:[function(require,module,exports){function E(){}E.prototype={on:function(name,callback,ctx){var e=this.e||(this.e={});return(e[name]||(e[name]=[])).push({fn:callback,ctx:ctx}),this},once:function(name,callback,ctx){function listener(){self.off(name,listener),callback.apply(ctx,arguments)}var self=this;return listener._=callback,this.on(name,listener,ctx)},emit:function(name){var data=[].slice.call(arguments,1),evtArr=((this.e||(this.e={}))[name]||[]).slice(),i=0,len=evtArr.length;for(i;i<len;i++)evtArr[i].fn.apply(evtArr[i].ctx,data);return this},off:function(name,callback){var e=this.e||(this.e={}),evts=e[name],liveEvents=[];if(evts&&callback)for(var i=0,len=evts.length;i<len;i++)evts[i].fn!==callback&&evts[i].fn._!==callback&&liveEvents.push(evts[i]);return liveEvents.length?e[name]=liveEvents:delete e[name],this}},module.exports=E},{}],7:[function(require,module,exports){!function(global,factory){if("function"==typeof define&&define.amd)define(["module","select"],factory);else if("undefined"!=typeof exports)factory(module,require("select"));else{var mod={exports:{}};factory(mod,global.select),global.clipboardAction=mod.exports}}(this,function(module,_select){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _select2=_interopRequireDefault(_select),_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},_createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),ClipboardAction=function(){function ClipboardAction(options){_classCallCheck(this,ClipboardAction),this.resolveOptions(options),this.initSelection()}return _createClass(ClipboardAction,[{key:"resolveOptions",value:function(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.action=options.action,this.emitter=options.emitter,this.target=options.target,this.text=options.text,this.trigger=options.trigger,this.selectedText=""}},{key:"initSelection",value:function(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"selectFake",value:function(){var _this=this,isRTL="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=function(){return _this.removeFake()},this.fakeHandler=document.body.addEventListener("click",this.fakeHandlerCallback)||!0,this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[isRTL?"right":"left"]="-9999px";var yPosition=window.pageYOffset||document.documentElement.scrollTop;this.fakeElem.addEventListener("focus",window.scrollTo(0,yPosition)),this.fakeElem.style.top=yPosition+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,document.body.appendChild(this.fakeElem),this.selectedText=(0,_select2["default"])(this.fakeElem),this.copyText()}},{key:"removeFake",value:function(){this.fakeHandler&&(document.body.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(document.body.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function(){this.selectedText=(0,_select2["default"])(this.target),this.copyText()}},{key:"copyText",value:function(){var succeeded=void 0;try{succeeded=document.execCommand(this.action)}catch(err){succeeded=!1}this.handleResult(succeeded)}},{key:"handleResult",value:function(succeeded){this.emitter.emit(succeeded?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function(){this.target&&this.target.blur(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function(){this.removeFake()}},{key:"action",set:function(){var action=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"copy";if(this._action=action,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function(){return this._action}},{key:"target",set:function(target){if(void 0!==target){if(!target||"object"!==("undefined"==typeof target?"undefined":_typeof(target))||1!==target.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&target.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(target.hasAttribute("readonly")||target.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=target}},get:function(){return this._target}}]),ClipboardAction}();module.exports=ClipboardAction})},{select:5}],8:[function(require,module,exports){!function(global,factory){if("function"==typeof define&&define.amd)define(["module","./clipboard-action","tiny-emitter","good-listener"],factory);else if("undefined"!=typeof exports)factory(module,require("./clipboard-action"),require("tiny-emitter"),require("good-listener"));else{var mod={exports:{}};factory(mod,global.clipboardAction,global.tinyEmitter,global.goodListener),global.clipboard=mod.exports}}(this,function(module,_clipboardAction,_tinyEmitter,_goodListener){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}function getAttributeValue(suffix,element){var attribute="data-clipboard-"+suffix;if(element.hasAttribute(attribute))return element.getAttribute(attribute)}var _clipboardAction2=_interopRequireDefault(_clipboardAction),_tinyEmitter2=_interopRequireDefault(_tinyEmitter),_goodListener2=_interopRequireDefault(_goodListener),_createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),Clipboard=function(_Emitter){function Clipboard(trigger,options){_classCallCheck(this,Clipboard);var _this=_possibleConstructorReturn(this,(Clipboard.__proto__||Object.getPrototypeOf(Clipboard)).call(this));return _this.resolveOptions(options),_this.listenClick(trigger),_this}return _inherits(Clipboard,_Emitter),_createClass(Clipboard,[{key:"resolveOptions",value:function(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof options.action?options.action:this.defaultAction,this.target="function"==typeof options.target?options.target:this.defaultTarget,this.text="function"==typeof options.text?options.text:this.defaultText}},{key:"listenClick",value:function(trigger){var _this2=this;this.listener=(0,_goodListener2["default"])(trigger,"click",function(e){return _this2.onClick(e)})}},{key:"onClick",value:function(e){var trigger=e.delegateTarget||e.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new _clipboardAction2["default"]({action:this.action(trigger),target:this.target(trigger),text:this.text(trigger),trigger:trigger,emitter:this})}},{key:"defaultAction",value:function(trigger){return getAttributeValue("action",trigger)}},{key:"defaultTarget",value:function(trigger){var selector=getAttributeValue("target",trigger);if(selector)return document.querySelector(selector)}},{key:"defaultText",value:function(trigger){return getAttributeValue("text",trigger)}},{key:"destroy",value:function(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}]),Clipboard}(_tinyEmitter2["default"]);module.exports=Clipboard})},{"./clipboard-action":7,"good-listener":4,"tiny-emitter":6}]},{},[8])(8)});