forked from samclarke/SCEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSCEditor.js
2472 lines (2137 loc) · 53.3 KB
/
SCEditor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import createNanoEvents from './events.js';
import * as dom from './dom.js';
import * as utils from './utils.js';
import defaultOptions from './defaultOptions.js';
import defaultCommands from './defaultCommands.js';
import PluginManager from './PluginManager.js';
import RangeHelper from './RangeHelper.js';
import Dropdown from './dropdown.js';
import Popup from './popup.js';
import _tmpl from './templates.js';
import * as escape from './escape.js';
import * as browser from './browser.js';
var globalWin = window;
var globalDoc = document;
var IE_VER = browser.ie;
// In IE < 11 a BR at the end of a block level element
// causes a line break. In all other browsers it's collapsed.
var IE_BR_FIX = IE_VER && IE_VER < 11;
var IMAGE_MIME_REGEX = /^image\/(p?jpe?g|gif|png|bmp)$/i;
/**
* Wrap inlines that are in the root in paragraphs.
*
* @param {HTMLBodyElement} body
* @param {Document} doc
* @private
*/
function wrapInlines(body, doc)
{
var wrapper;
dom.traverse(body, function (node)
{
if (dom.isInline(node, true))
{
if (!wrapper)
{
wrapper = dom.createElement('p', {}, doc);
dom.insertBefore(wrapper, node);
}
if (node.nodeType !== dom.TEXT_NODE || node.nodeValue !== '')
dom.appendChild(wrapper, node);
}
else
wrapper = null;
}, false, true);
};
/**
* SCEditor - A lightweight WYSIWYG editor
*
* @param {HTMLTextAreaElement} original The textarea to be converted
* @param {object} userOptions
* @class SCEditor
* @name SCEditor
*/
export default function SCEditor(original, userOptions)
{
/**
* Alias of this
*
* @private
*/
var base = this;
/**
* Editor format like BBCode or HTML
*/
var format;
/**
* The div which contains the editor and toolbar
*
* @type {HTMLDivElement}
* @private
*/
var editorContainer;
/**
* Map of events handlers bound to this instance.
*
* @type {object}
* @private
*/
var eventHandlers = {};
/**
* The editors toolbar
*
* @type {HTMLDivElement}
* @private
*/
var toolbar;
/**
* The editors iframe which should be in design mode
*
* @type {HTMLIFrameElement}
* @private
*/
var wysiwygEditor;
/**
* The editors window
*
* @type {Window}
* @private
*/
var wysiwygWindow;
/**
* The WYSIWYG editors body element
*
* @type {HTMLBodyElement}
* @private
*/
var wysiwygBody;
/**
* The WYSIWYG editors document
*
* @type {Document}
* @private
*/
var wysiwygDocument;
/**
* The editors textarea for viewing source
*
* @type {HTMLTextAreaElement}
* @private
*/
var sourceEditor;
/**
* If the user is currently composing text via IME
*
* @type {boolean}
*/
var isComposing;
/**
* Timer for valueChanged key handler
*
* @type {number}
*/
var valueChangedKeyUpTimer;
/**
* The editors rangeHelper instance
*
* @type {RangeHelper}
* @private
*/
var rangeHelper;
/**
* An array of button state handlers
*
* @type {Array.<object>}
* @private
*/
var btnStateHandlers = [];
/**
* Plugin manager instance
*
* @type {PluginManager}
* @private
*/
var pluginManager;
/**
* The current node containing the selection/caret
*
* @type {Node}
* @private
*/
var currentNode;
/**
* The first block level parent of the current node
*
* @type {node}
* @private
*/
var currentBlockNode;
/**
* The current node selection/caret
*
* @type {object}
* @private
*/
var currentSelection;
/**
* Used to make sure only 1 selection changed
* check is called every 100ms.
*
* Helps improve performance as it is checked a lot.
*
* @type {boolean}
* @private
*/
var isSelectionCheckPending;
/**
* If content is required (equivalent to the HTML5 required attribute)
*
* @type {boolean}
* @private
*/
var isRequired;
/**
* The inline CSS style element. Will be undefined
* until css() is called for the first time.
*
* @type {HTMLStyleElement}
* @private
*/
var inlineCss;
/**
* Object containing a list of shortcut handlers
*
* @type {object}
* @private
*/
var shortcutHandlers = {};
/**
* The min and max heights that autoExpand should stay within
*
* @type {object}
* @private
*/
var autoExpandBounds;
/**
* Timeout for the autoExpand function to throttle calls
*
* @private
*/
var autoExpandThrottle;
/**
* Last scroll position before maximizing so
* it can be restored when finished.
*
* @type {number}
* @private
*/
var maximizeScrollPosition;
/**
* Stores the contents while a paste is taking place.
*
* Needed to support browsers that lack clipboard API support.
*
* @type {?DocumentFragment}
* @private
*/
var pasteContentFragment;
var lastVal;
/**
* Private functions
*
* @private
*/
var
init,
handleCommand,
initEditor,
initToolBar,
initEvents,
handlePasteEvt,
handlePasteData,
handleKeyDown,
handleBackSpace,
handleKeyPress,
handleComposition,
updateActiveButtons,
appendNewLine,
checkSelectionChanged,
checkNodeChanged,
autofocus,
currentStyledBlockNode,
triggerValueChanged,
valueChangedBlur,
valueChangedKeyUp,
autoExpand;
/**
* Options for this editor instance
*
* @name opts
*/
var options = Object.assign(defaultOptions, userOptions);
/**
* The editors locale
*
* @private
*/
var locale = options.locale || {};
/**
* All the commands supported by the editor
*
* @name commands
*/
var commands = userOptions.commands || defaultCommands;
/**
* All the events supported by the editor
*
* The supported events are:
*
* * keyup
* * keydown
* * Keypress
* * blur
* * focus
* * nodechanged - When the current node containing
* the selection changes in WYSIWYG mode
* * contextmenu
* * selectionchanged
* * valuechanged
*
* @name events
*/
var events = createNanoEvents();
base.commands = commands;
base.opts = options;
base.events = events;
/**
* Creates the editor iframe and textarea
*
* @private
*/
init = function ()
{
original._sceditor = base;
editorContainer = dom.createElement('div', {
className: 'sceditor-container'
});
dom.insertBefore(editorContainer, original);
base.dropdown = new Dropdown(editorContainer);
base.popup = new Popup(editorContainer);
// Locale DateTime format overrides any specified in the options
if (locale && locale.dateFormat)
options.dateFormat = locale.dateFormat;
isRequired = original.required;
original.required = false;
var FormatCtor = window[options.format];
format = FormatCtor ? new FormatCtor(options.parserOptions) : {};
if (!FormatCtor)
throw new Error(`Format plugin not found: ${options.format}`);
base.opts.format = format;
initEditor();
pluginManager = new PluginManager(base);
options.plugins.forEach(pluginManager.register);
if ('init' in format)
format.init.call(base);
commands = base.commands;
options = base.opts;
// force into source mode if is a browser that can't handle
// full editing
if (!browser.isWysiwygSupported)
base.toggleSourceMode();
initToolBar();
initEvents();
// load any textarea value into the editor
dom.hide(original);
base.insert(original.value);
var loaded = function ()
{
dom.off(globalWin, 'load', loaded);
if (options.autofocus)
autofocus();
autoExpand();
appendNewLine();
};
dom.on(globalWin, 'load', loaded);
if (globalDoc.readyState === 'complete')
loaded();
};
/**
* Creates the editor iframe and textarea
*
* @private
*/
initEditor = function ()
{
sourceEditor = dom.createElement('textarea');
wysiwygEditor = dom.createElement('iframe', {
frameborder: 0,
allowfullscreen: true
});
/*
* This needs to be done right after they are created because,
* for any reason, the user may not want the value to be tinkered
* by any filters.
*/
if (options.startInSourceMode)
{
dom.addClass(editorContainer, 'sourceMode');
dom.hide(wysiwygEditor);
}
else
{
dom.addClass(editorContainer, 'wysiwygMode');
dom.hide(sourceEditor);
}
if (!options.spellcheck)
dom.attr(editorContainer, 'spellcheck', 'false');
if (globalWin.location.protocol === 'https:')
dom.attr(wysiwygEditor, 'src', 'about:blank');
// Add the editor to the container
dom.appendChild(editorContainer, wysiwygEditor);
dom.appendChild(editorContainer, sourceEditor);
// TODO: make this optional somehow
base.dimensions(
options.width || dom.width(original),
options.height || dom.height(original)
);
// Add IE version class to the HTML element so can apply
// conditional styling without CSS hacks
var className = IE_VER ? 'ie ie' + IE_VER : '';
// Add ios to HTML so can apply CSS fix to only it
className += browser.ios ? ' ios' : '';
wysiwygDocument = wysiwygEditor.contentDocument;
wysiwygDocument.open();
wysiwygDocument.write(_tmpl('html', {
attrs: ' class="' + className + '"',
spellcheck: options.spellcheck ? '' : 'spellcheck="false"',
charset: options.charset,
style: options.style
}));
wysiwygDocument.close();
wysiwygBody = wysiwygDocument.body;
wysiwygWindow = wysiwygEditor.contentWindow;
var tabIndex = dom.attr(original, 'tabindex');
dom.attr(sourceEditor, 'tabindex', tabIndex);
dom.attr(wysiwygEditor, 'tabindex', tabIndex);
rangeHelper = new RangeHelper(wysiwygWindow);
};
/**
* Initialises events
*
* @private
*/
initEvents = function ()
{
var compositionEvents = 'compositionstart compositionend';
var eventsToForward = 'keydown keyup keypress focus blur contextmenu';
var checkSelectionEvents = 'onselectionchange' in wysiwygDocument ?
'selectionchange' :
'keyup focus blur contextmenu mouseup touchend click';
dom.on(window, 'beforeunload', base.updateOriginal);
dom.on(wysiwygBody, 'keypress', handleKeyPress);
dom.on(wysiwygBody, 'keydown', handleKeyDown);
dom.on(wysiwygBody, 'keydown', handleBackSpace);
dom.on(wysiwygBody, 'keyup', appendNewLine);
dom.on(wysiwygBody, 'blur', valueChangedBlur);
dom.on(wysiwygBody, 'keyup', valueChangedKeyUp);
dom.on(wysiwygBody, 'paste', handlePasteEvt);
dom.on(wysiwygBody, compositionEvents, handleComposition);
dom.on(wysiwygBody, checkSelectionEvents, checkSelectionChanged);
dom.on(wysiwygBody, eventsToForward, base.events.emit.bind(null));
dom.on(sourceEditor, 'blur', valueChangedBlur);
dom.on(sourceEditor, 'keyup', valueChangedKeyUp);
dom.on(sourceEditor, 'keydown', handleKeyDown);
dom.on(sourceEditor, compositionEvents, handleComposition);
dom.on(sourceEditor, eventsToForward, base.events.emit.bind(null));
dom.on(wysiwygDocument, checkSelectionEvents, checkSelectionChanged);
dom.on(wysiwygDocument, 'keyup', appendNewLine);
dom.on(editorContainer, 'selectionchanged', checkNodeChanged);
dom.on(editorContainer, 'selectionchanged', updateActiveButtons);
if (options.autoExpand)
{
// Need to update when images (or anything else) loads
dom.on(wysiwygBody, 'load', autoExpand, dom.EVENT_CAPTURE);
dom.on(wysiwygBody, 'input', autoExpand);
dom.on(sourceEditor, 'input', autoExpand);
}
};
var stopEvent = e =>
{
e.preventDefault();
};
var handleClick = e =>
{
if (!dom.hasClass(this, 'disabled'))
handleCommand(this, commands[dom.attr(e.target, 'data-sceditor-command')]);
updateActiveButtons();
stopEvent(e);
};
/**
* Creates the toolbar and appends it to the container
*
* @private
*/
initToolBar = function ()
{
var
group,
Icons = options.icons;
toolbar = dom.createElement('div', {
className: 'sceditor-toolbar'
});
options.icons = new Icons;
for (var rowItems of options.toolbar)
{
var row = dom.createElement('div');
for (var menuItems of rowItems)
{
group = dom.createElement('span');
for (let commandName of menuItems)
{
let
button,
command = commands[commandName];
// The commandName must be valid
if (!command)
continue;
let
shortcut = command.shortcut,
tooltip = command.tooltip,
attrs = {
className: 'sceditor-button',
'data-sceditor-command': commandName,
title: base._(tooltip || commandName)
};
if (tooltip && shortcut)
attrs.title += ` (${shortcut})`;
button = dom.createElement('a', attrs);
dom.appendChild(button, options.icons.create(commandName));
dom.on(button, 'click', handleClick);
// Prevent editor losing focus when button clicked
dom.on(button, 'mousedown', stopEvent);
if (shortcut)
base.addShortcut(shortcut, commandName);
if (command.state || utils.isString(command.exec))
btnStateHandlers.push({
name: commandName,
button: button,
state: command.state || command.exec
});
dom.appendChild(group, button);
}
// Exclude empty groups
if (group.firstChild)
dom.appendChild(row, group);
}
// Exclude empty rows
if (row.firstChild)
dom.appendChild(toolbar, row);
}
// Append the toolbar to the toolbarContainer option if given
if (options.toolbarContainer)
dom.appendChild(options.toolbarContainer, toolbar);
else
dom.insertBefore(toolbar, wysiwygEditor);
};
/**
* Autofocus the editor
*
* @private
*/
autofocus = function ()
{
var
range, txtPos,
node = wysiwygBody.firstChild,
focusEnd = !!options.autofocusEnd;
// Can't focus invisible elements
if (!dom.isVisible(editorContainer))
return;
if (base.isInSourceMode())
{
txtPos = focusEnd ? sourceEditor.value.length : 0;
sourceEditor.setSelectionRange(txtPos, txtPos);
return;
}
dom.removeWhiteSpace(wysiwygBody);
if (focusEnd)
{
if (!(node = wysiwygBody.lastChild))
{
node = dom.createElement('p', {}, wysiwygDocument);
dom.appendChild(wysiwygBody, node);
}
while (node.lastChild)
{
node = node.lastChild;
// IE < 11 should place the cursor after the <br> as
// it will show it as a newline. IE >= 11 and all
// other browsers should place the cursor before.
if (!IE_BR_FIX && dom.is(node, 'br') && node.previousSibling)
node = node.previousSibling;
}
}
range = wysiwygDocument.createRange();
if (!dom.canHaveChildren(node))
{
range.setStartBefore(node);
if (focusEnd)
range.setStartAfter(node);
}
else
range.selectNodeContents(node);
range.collapse(!focusEnd);
rangeHelper.selectRange(range);
currentSelection = range;
if (focusEnd)
wysiwygBody.scrollTop = wysiwygBody.scrollHeight;
base.focus();
};
/**
* Gets if the editor is read only
*
* @since 3.0.0
* @function
* @name isReadOnly
* @returns {boolean}
*/
base.isReadOnly = () => !sourceEditor.readonly;
/**
* Sets if the editor is read only
*
* @param {boolean} readOnly
* @since 1.3.5
* @function
* @name readOnly
*/
base.readOnly = function (readOnly)
{
wysiwygBody.contentEditable = !readOnly;
sourceEditor.readonly = !readOnly;
dom.toggleClass(editorContainer, 'disabled', readOnly);
};
/**
* Gets the width of the editor in pixels
*
* @since 1.3.5
* @function
* @name width
* @returns {number}
*/
/**
* Sets the width of the editor
*
* @param {number} width Width in pixels
* @since 1.3.5
* @function
* @name width^2
* @returns {this}
*/
/**
* Sets the width of the editor
*
* The saveWidth specifies if to save the width. The stored width can be
* used for things like restoring from maximized state.
*
* @param {number} width Width in pixels
* @param {boolean} [saveWidth=true] If to store the width
* @since 1.4.1
* @function
* @name width^3
* @returns {this}
*/
base.width = function (width, saveWidth)
{
if (!width && width !== 0)
return dom.width(editorContainer);
base.dimensions(width, null, saveWidth);
return base;
};
/**
* Returns an object with the properties width and height
* which are the width and height of the editor in px.
*
* @since 1.4.1
* @function
* @name dimensions
* @returns {object}
*/
/**
* <p>Sets the width and/or height of the editor.</p>
*
* <p>If width or height is not numeric it is ignored.</p>
*
* @param {number} width Width in px
* @param {number} height Height in px
* @since 1.4.1
* @function
* @name dimensions^2
* @returns {this}
*/
/**
* <p>Sets the width and/or height of the editor.</p>
*
* <p>If width or height is not numeric it is ignored.</p>
*
* <p>The save argument specifies if to save the new sizes.
* The saved sizes can be used for things like restoring from
* maximized state. This should normally be left as true.</p>
*
* @param {number} width Width in px
* @param {number} height Height in px
* @param {boolean} [save=true] If to store the new sizes
* @since 1.4.1
* @function
* @name dimensions^3
* @returns {this}
*/
base.dimensions = function (width, height, save)
{
// set undefined width/height to boolean false
width = (!width && width !== 0) ? false : width;
height = (!height && height !== 0) ? false : height;
if (width === false && height === false)
return { width: base.width(), height: base.height() };
if (width !== false)
{
if (save !== false)
options.width = width;
dom.width(editorContainer, width);
}
if (height !== false)
{
if (save !== false)
options.height = height;
dom.height(editorContainer, height);
}
return base;
};
/**
* Gets the height of the editor in px
*
* @since 1.3.5
* @function
* @name height
* @returns {number}
*/
/**
* Sets the height of the editor
*
* @param {number} height Height in px
* @since 1.3.5
* @function
* @name height^2
* @returns {this}
*/
/**
* Sets the height of the editor
*
* The saveHeight specifies if to save the height.
*
* The stored height can be used for things like
* restoring from maximized state.
*
* @param {number} height Height in px
* @param {boolean} [saveHeight=true] If to store the height
* @since 1.4.1
* @function
* @name height^3
* @returns {this}
*/
base.height = function (height, saveHeight)
{
if (!height && height !== 0)
return dom.height(editorContainer);
base.dimensions(null, height, saveHeight);
return base;
};
/**
* Gets if the editor is maximised or not
*
* @since 1.4.1
* @function
* @name maximize
* @returns {boolean}
*/
/**
* Sets if the editor is maximised or not
*
* @param {boolean} maximize If to maximise the editor
* @since 1.4.1
* @function
* @name maximize^2
* @returns {this}
*/
base.maximize = function (maximize)
{
var maximizeSize = 'sceditor-maximize';
if (utils.isUndefined(maximize))
return dom.hasClass(editorContainer, maximizeSize);
maximize = !!maximize;
if (maximize)
maximizeScrollPosition = globalWin.pageYOffset;
dom.toggleClass(globalDoc.documentElement, maximizeSize, maximize);
dom.toggleClass(globalDoc.body, maximizeSize, maximize);
dom.toggleClass(editorContainer, maximizeSize, maximize);
base.width(maximize ? '100%' : options.width, false);
base.height(maximize ? '100%' : options.height, false);
if (!maximize)
globalWin.scrollTo(0, maximizeScrollPosition);
autoExpand();
return base;
};
autoExpand = function ()
{
if (options.autoExpand && !autoExpandThrottle)
autoExpandThrottle = setTimeout(base.expandToContent, 200);
};
/**
* Expands or shrinks the editors height to the height of it's content
*
* @function
* @name expandToContent
*/
base.expandToContent = function ()
{
if (base.maximize())
return;
clearTimeout(autoExpandThrottle);
if (!autoExpandBounds)
autoExpandBounds = [
options.height || dom.height(original),
globalDoc.documentElement.clientHeight - wysiwygBody.offsetTop
];
base.height(
Math.max(
Math.min(wysiwygBody.scrollHeight, autoExpandBounds[0]),
autoExpandBounds[1]
)
);
};
/**
* Destroys the editor, removing all elements and
* event handlers.
*
* Leaves only the original textarea.
*
* @function
* @name destroy
*/
base.destroy = function ()
{
// Don't destroy if the editor has already been destroyed
if (!pluginManager)
return;
pluginManager.destroy();
base.dropdown.destroy();
base.popup.destroy();
rangeHelper = null;
pluginManager = null;
base.dropdown = null;
base.popup = null;
dom.off(window, 'unload', base.updateOriginal);
dom.remove(sourceEditor);
dom.remove(toolbar);
dom.remove(editorContainer);
delete original._sceditor;
dom.show(original);
original.required = isRequired;
};
/**
* Handles the WYSIWYG editors paste event
*
* @param e
* @private
*/
handlePasteEvt = function (e)
{
var isIeOrEdge = IE_VER || browser.edge;
var editable = wysiwygBody;
var clipboard = e.clipboardData;
var loadImage = function (file)
{
var reader = new FileReader();
reader.onload = function (e)
{
handlePasteData({
html: '<img src="' + e.target.result + '" />'
});
};