suneditor 2.41.2 → 2.43.0

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 (50) hide show
  1. package/README.md +116 -28
  2. package/dist/css/suneditor.min.css +1 -1
  3. package/dist/suneditor.min.js +2 -2
  4. package/package.json +4 -4
  5. package/src/assets/css/suneditor-contents.css +1 -1
  6. package/src/assets/css/suneditor.css +27 -7
  7. package/src/assets/defaultIcons.js +2 -0
  8. package/src/lang/Lang.d.ts +3 -1
  9. package/src/lang/ckb.js +2 -0
  10. package/src/lang/da.js +2 -0
  11. package/src/lang/de.js +2 -0
  12. package/src/lang/en.js +2 -0
  13. package/src/lang/es.js +2 -0
  14. package/src/lang/fr.js +10 -8
  15. package/src/lang/he.js +2 -0
  16. package/src/lang/it.js +2 -0
  17. package/src/lang/ja.js +2 -0
  18. package/src/lang/ko.js +2 -0
  19. package/src/lang/lv.js +2 -0
  20. package/src/lang/nl.js +2 -0
  21. package/src/lang/pl.js +2 -0
  22. package/src/lang/pt_br.js +2 -0
  23. package/src/lang/ro.js +2 -0
  24. package/src/lang/ru.js +2 -0
  25. package/src/lang/se.js +2 -0
  26. package/src/lang/ua.js +2 -0
  27. package/src/lang/zh_cn.js +3 -1
  28. package/src/lib/constructor.js +68 -16
  29. package/src/lib/context.js +5 -1
  30. package/src/lib/core.d.ts +88 -12
  31. package/src/lib/core.js +789 -212
  32. package/src/lib/util.d.ts +24 -1
  33. package/src/lib/util.js +105 -18
  34. package/src/options.d.ts +79 -9
  35. package/src/plugins/dialog/audio.js +5 -5
  36. package/src/plugins/dialog/image.js +30 -20
  37. package/src/plugins/dialog/link.js +1 -0
  38. package/src/plugins/dialog/video.js +16 -15
  39. package/src/plugins/fileBrowser/imageGallery.js +2 -3
  40. package/src/plugins/modules/_anchor.js +24 -15
  41. package/src/plugins/modules/component.d.ts +1 -1
  42. package/src/plugins/modules/fileBrowser.js +6 -1
  43. package/src/plugins/modules/fileManager.js +1 -3
  44. package/src/plugins/modules/resizing.js +11 -6
  45. package/src/plugins/submenu/align.js +32 -27
  46. package/src/plugins/submenu/font.js +1 -1
  47. package/src/plugins/submenu/fontSize.js +1 -1
  48. package/src/plugins/submenu/horizontalRule.js +19 -25
  49. package/src/plugins/submenu/list.js +13 -5
  50. package/src/plugins/submenu/template.js +5 -2
@@ -37,6 +37,8 @@ export default {
37
37
 
38
38
  // toolbar
39
39
  const tool_bar = this._createToolBar(doc, options.buttonList, options.plugins, options);
40
+ const toolbarShadow = tool_bar.element.cloneNode(false);
41
+ toolbarShadow.className += ' se-toolbar-shadow';
40
42
  tool_bar.element.style.visibility = 'hidden';
41
43
  if (tool_bar.pluginCallButtons.math) this._checkKatexMath(options.katex);
42
44
  const arrow = doc.createElement('DIV');
@@ -86,12 +88,20 @@ export default {
86
88
  const toolbarContainer = options.toolbarContainer;
87
89
  if (toolbarContainer) {
88
90
  toolbarContainer.appendChild(tool_bar.element);
91
+ toolbarContainer.appendChild(toolbarShadow);
89
92
  }
93
+
94
+ // resizingbar
95
+ const resizingBarContainer = options.resizingBarContainer;
96
+ if (resizing_bar && resizingBarContainer) resizingBarContainer.appendChild(resizing_bar);
90
97
 
91
98
  /** append html */
92
99
  editor_div.appendChild(textarea);
93
100
  if (placeholder_span) editor_div.appendChild(placeholder_span);
94
- if (!toolbarContainer) relative.appendChild(tool_bar.element);
101
+ if (!toolbarContainer) {
102
+ relative.appendChild(tool_bar.element);
103
+ relative.appendChild(toolbarShadow);
104
+ }
95
105
  relative.appendChild(sticky_dummy);
96
106
  relative.appendChild(editor_div);
97
107
  relative.appendChild(resize_back);
@@ -99,7 +109,7 @@ export default {
99
109
  relative.appendChild(line_breaker);
100
110
  relative.appendChild(line_breaker_t);
101
111
  relative.appendChild(line_breaker_b);
102
- if (resizing_bar) relative.appendChild(resizing_bar);
112
+ if (resizing_bar && !resizingBarContainer) relative.appendChild(resizing_bar);
103
113
  top_div.appendChild(relative);
104
114
 
105
115
  textarea = this._checkCodeMirror(options, textarea);
@@ -109,6 +119,7 @@ export default {
109
119
  _top: top_div,
110
120
  _relative: relative,
111
121
  _toolBar: tool_bar.element,
122
+ _toolbarShadow: toolbarShadow,
112
123
  _menuTray: tool_bar._menuTray,
113
124
  _editorArea: editor_div,
114
125
  _wysiwygArea: wysiwyg_div,
@@ -233,8 +244,14 @@ export default {
233
244
  const placeholder_span = initElements.placeholder;
234
245
  let code = initElements.codeView;
235
246
 
236
- if (el.resizingBar) relative.removeChild(el.resizingBar);
237
- if (bottomBar.resizingBar) relative.appendChild(bottomBar.resizingBar);
247
+ if (el.resizingBar) util.removeItem(el.resizingBar);
248
+ if (bottomBar.resizingBar) {
249
+ if (mergeOptions.resizingBarContainer && mergeOptions.resizingBarContainer !== originOptions.resizingBarContainer) {
250
+ mergeOptions.resizingBarContainer.appendChild(bottomBar.resizingBar);
251
+ } else {
252
+ relative.appendChild(bottomBar.resizingBar);
253
+ }
254
+ }
238
255
 
239
256
  editorArea.innerHTML = '';
240
257
  editorArea.appendChild(code);
@@ -291,17 +308,22 @@ export default {
291
308
  if (!options.iframe) {
292
309
  wysiwygDiv.setAttribute('contenteditable', true);
293
310
  wysiwygDiv.setAttribute('scrolling', 'auto');
311
+ for (let key in options.iframeAttributes) {
312
+ wysiwygDiv.setAttribute(key, options.iframeAttributes[key]);
313
+ }
294
314
  wysiwygDiv.className += ' ' + options._editableClass;
295
315
  wysiwygDiv.style.cssText = options._editorStyles.frame + options._editorStyles.editor;
316
+ wysiwygDiv.className += options.className;
296
317
  } else {
297
318
  wysiwygDiv.allowFullscreen = true;
298
319
  wysiwygDiv.frameBorder = 0;
299
320
  wysiwygDiv.style.cssText = options._editorStyles.frame;
321
+ wysiwygDiv.className += options.className;
300
322
  }
301
323
 
302
324
  // textarea for code view
303
325
  const textarea = document.createElement('TEXTAREA');
304
- textarea.className = 'se-wrapper-inner se-wrapper-code';
326
+ textarea.className = 'se-wrapper-inner se-wrapper-code' + options.className;
305
327
  textarea.style.cssText = options._editorStyles.frame;
306
328
  textarea.style.display = 'none';
307
329
  if (options.height === 'auto') textarea.style.overflow = 'hidden';
@@ -376,7 +398,7 @@ export default {
376
398
  _initOptions: function (element, options) {
377
399
  /** Values */
378
400
  options.lang = options.lang || _defaultLang;
379
- options.defaultTag = typeof options.defaultTag === 'string' ? options.defaultTag : 'p';
401
+ options.defaultTag = typeof options.defaultTag === 'string' && options.defaultTag.length > 0 ? options.defaultTag : 'p';
380
402
  const textTags = options.textTags = [{bold: 'STRONG', underline: 'U', italic: 'EM', strike: 'DEL', sub: 'SUB', sup: 'SUP'}, (options.textTags || {})].reduce(function (_default, _new) {
381
403
  for (let key in _new) {
382
404
  _default[key] = _new[key];
@@ -398,23 +420,31 @@ export default {
398
420
  };
399
421
  options.value = typeof options.value === 'string' ? options.value : null;
400
422
  options.historyStackDelayTime = typeof options.historyStackDelayTime === 'number' ? options.historyStackDelayTime : 400;
401
- /** Whitelist */
423
+ /** Whitelist, Blacklist */
402
424
  const whitelist = 'br|p|div|pre|blockquote|h1|h2|h3|h4|h5|h6|ol|ul|li|hr|figure|figcaption|img|iframe|audio|video|source|table|thead|tbody|tr|th|td|a|b|strong|var|i|em|u|ins|s|span|strike|del|sub|sup|code|svg|path|details|summary';
425
+ // tags
426
+ options.tagsBlacklist = options.tagsBlacklist || '';
403
427
  options._defaultTagsWhitelist = typeof options._defaultTagsWhitelist === 'string' ? options._defaultTagsWhitelist : whitelist;
404
- options._editorTagsWhitelist = this._setWhitelist(options._defaultTagsWhitelist + (typeof options.addTagsWhitelist === 'string' && options.addTagsWhitelist.length > 0 ? '|' + options.addTagsWhitelist : ''), options.tagsBlacklist);
405
- options.pasteTagsWhitelist = this._setWhitelist(typeof options.pasteTagsWhitelist === 'string' ? options.pasteTagsWhitelist : options._editorTagsWhitelist, options.pasteTagsBlacklist);
428
+ options._editorTagsWhitelist = options.addTagsWhitelist === '*' ? '*' : this._setWhitelist(options._defaultTagsWhitelist + (typeof options.addTagsWhitelist === 'string' && options.addTagsWhitelist.length > 0 ? '|' + options.addTagsWhitelist : ''), options.tagsBlacklist);
429
+ // paste tags
430
+ options.pasteTagsBlacklist = options.tagsBlacklist + (options.tagsBlacklist && options.pasteTagsBlacklist ? ('|' + options.pasteTagsBlacklist) : (options.pasteTagsBlacklist || ''));
431
+ options.pasteTagsWhitelist = options.pasteTagsWhitelist === '*' ? '*' : this._setWhitelist(typeof options.pasteTagsWhitelist === 'string' ? options.pasteTagsWhitelist : options._editorTagsWhitelist, options.pasteTagsBlacklist);
432
+ // tag attributes
406
433
  options.attributesWhitelist = (!options.attributesWhitelist || typeof options.attributesWhitelist !== 'object') ? null : options.attributesWhitelist;
434
+ options.attributesBlacklist = (!options.attributesBlacklist || typeof options.attributesBlacklist !== 'object') ? null : options.attributesBlacklist;
407
435
  /** Layout */
408
436
  options.mode = options.mode || 'classic'; // classic, inline, balloon, balloon-always
409
437
  options.rtl = !!options.rtl;
438
+ options.lineAttrReset = typeof options.lineAttrReset === 'string' && options.lineAttrReset ? options.lineAttrReset === '*' ? '*' : new RegExp('^(' + options.lineAttrReset + ')$', 'i') : null;
410
439
  options._editableClass = 'sun-editor-editable' + (options.rtl ? ' se-rtl' : '');
411
440
  options._printClass = typeof options._printClass === 'string' ? options._printClass : null;
412
441
  options.toolbarWidth = options.toolbarWidth ? (util.isNumber(options.toolbarWidth) ? options.toolbarWidth + 'px' : options.toolbarWidth) : 'auto';
413
442
  options.toolbarContainer = typeof options.toolbarContainer === 'string' ? document.querySelector(options.toolbarContainer) : options.toolbarContainer;
414
443
  options.stickyToolbar = (/balloon/i.test(options.mode) || !!options.toolbarContainer) ? -1 : options.stickyToolbar === undefined ? 0 : (/^\d+/.test(options.stickyToolbar) ? util.getNumber(options.stickyToolbar, 0) : -1);
415
444
  options.fullScreenOffset = options.fullScreenOffset === undefined ? 0 : (/^\d+/.test(options.fullScreenOffset) ? util.getNumber(options.fullScreenOffset, 0) : 0);
416
- options.iframe = options.fullPage || options.iframe;
417
445
  options.fullPage = !!options.fullPage;
446
+ options.iframe = options.fullPage || !!options.iframe;
447
+ options.iframeAttributes = options.iframeAttributes || {};
418
448
  options.iframeCSSFileName = options.iframe ? typeof options.iframeCSSFileName === 'string' ? [options.iframeCSSFileName] : (options.iframeCSSFileName || ['suneditor']) : null;
419
449
  options.previewTemplate = typeof options.previewTemplate === 'string' ? options.previewTemplate : null;
420
450
  options.printTemplate = typeof options.printTemplate === 'string' ? options.printTemplate : null;
@@ -435,6 +465,8 @@ export default {
435
465
  /** Bottom resizing bar */
436
466
  options.resizingBar = options.resizingBar === undefined ? (/inline|balloon/i.test(options.mode) ? false : true) : options.resizingBar;
437
467
  options.showPathLabel = !options.resizingBar ? false : typeof options.showPathLabel === 'boolean' ? options.showPathLabel : true;
468
+ options.resizeEnable = options.resizeEnable === undefined ? true : !!options.resizeEnable;
469
+ options.resizingBarContainer = typeof options.resizingBarContainer === 'string' ? document.querySelector(options.resizingBarContainer) : options.resizingBarContainer;
438
470
  /** Character count */
439
471
  options.charCounter = options.maxCharCount > 0 ? true : typeof options.charCounter === 'boolean' ? options.charCounter : false;
440
472
  options.charCounterType = typeof options.charCounterType === 'string' ? options.charCounterType : 'char';
@@ -448,7 +480,8 @@ export default {
448
480
  options.height = options.height ? (util.isNumber(options.height) ? options.height + 'px' : options.height) : (element.clientHeight ? element.clientHeight + 'px' : 'auto');
449
481
  options.minHeight = (util.isNumber(options.minHeight) ? options.minHeight + 'px' : options.minHeight) || '';
450
482
  options.maxHeight = (util.isNumber(options.maxHeight) ? options.maxHeight + 'px' : options.maxHeight) || '';
451
- /** Editing area default style */
483
+ /** Editing area */
484
+ options.className = (typeof options.className === 'string' && options.className.length > 0) ? ' ' + options.className : '';
452
485
  options.defaultStyle = typeof options.defaultStyle === 'string' ? options.defaultStyle : '';
453
486
  /** Defining menu items */
454
487
  options.font = !options.font ? null : options.font;
@@ -459,9 +492,11 @@ export default {
459
492
  options.paragraphStyles = !options.paragraphStyles ? null : options.paragraphStyles;
460
493
  options.textStyles = !options.textStyles ? null : options.textStyles;
461
494
  options.fontSizeUnit = typeof options.fontSizeUnit === 'string' ? (options.fontSizeUnit.trim() || 'px') : 'px';
495
+ options.alignItems = typeof options.alignItems === 'object' ? options.alignItems : (options.rtl ? ['right', 'center', 'left', 'justify'] : ['left', 'center', 'right', 'justify']);
462
496
  /** Image */
463
497
  options.imageResizing = options.imageResizing === undefined ? true : options.imageResizing;
464
498
  options.imageHeightShow = options.imageHeightShow === undefined ? true : !!options.imageHeightShow;
499
+ options.imageAlignShow = options.imageAlignShow === undefined ? true : !!options.imageAlignShow;
465
500
  options.imageWidth = !options.imageWidth ? 'auto' : util.isNumber(options.imageWidth) ? options.imageWidth + 'px' : options.imageWidth;
466
501
  options.imageHeight = !options.imageHeight ? 'auto' : util.isNumber(options.imageHeight) ? options.imageHeight + 'px' : options.imageHeight;
467
502
  options.imageSizeOnlyPercentage = !!options.imageSizeOnlyPercentage;
@@ -480,6 +515,7 @@ export default {
480
515
  /** Video */
481
516
  options.videoResizing = options.videoResizing === undefined ? true : options.videoResizing;
482
517
  options.videoHeightShow = options.videoHeightShow === undefined ? true : !!options.videoHeightShow;
518
+ options.videoAlignShow = options.videoAlignShow === undefined ? true : !!options.videoAlignShow;
483
519
  options.videoRatioShow = options.videoRatioShow === undefined ? true : !!options.videoRatioShow;
484
520
  options.videoWidth = !options.videoWidth || !util.getNumber(options.videoWidth, 0) ? '' : util.isNumber(options.videoWidth) ? options.videoWidth + 'px' : options.videoWidth;
485
521
  options.videoHeight = !options.videoHeight || !util.getNumber(options.videoHeight, 0) ? '' : util.isNumber(options.videoHeight) ? options.videoHeight + 'px' : options.videoHeight;
@@ -512,9 +548,12 @@ export default {
512
548
  /** Table */
513
549
  options.tableCellControllerPosition = typeof options.tableCellControllerPosition === 'string' ? options.tableCellControllerPosition.toLowerCase() : 'cell';
514
550
  /** Link */
551
+ options.linkTargetNewWindow = !!options.linkTargetNewWindow;
515
552
  options.linkProtocol = typeof options.linkProtocol === 'string' ? options.linkProtocol : null;
516
553
  options.linkRel = Array.isArray(options.linkRel) ? options.linkRel : [];
517
554
  options.linkRelDefault = options.linkRelDefault || {};
555
+ /** HR */
556
+ // options.hrItems = options.hrItems;
518
557
  /** Key actions */
519
558
  options.tabDisable = !!options.tabDisable;
520
559
  options.shortcutsDisable = Array.isArray(options.shortcutsDisable) ? options.shortcutsDisable : [];
@@ -535,6 +574,9 @@ export default {
535
574
  ['fullScreen', 'showBlocks', 'codeView'],
536
575
  ['preview', 'print']
537
576
  ];
577
+ /** Private options */
578
+ options.__listCommonStyle = options.__listCommonStyle || ['fontSize', 'color', 'fontFamily'];
579
+ // options.__defaultFontSize;
538
580
 
539
581
  /** RTL - buttons */
540
582
  if (options.rtl) {
@@ -594,15 +636,18 @@ export default {
594
636
  subscript: ['_se_command_subscript', lang.toolbar.subscript, 'SUB', '', icons.subscript],
595
637
  superscript: ['_se_command_superscript', lang.toolbar.superscript, 'SUP', '', icons.superscript],
596
638
  removeFormat: ['', lang.toolbar.removeFormat, 'removeFormat', '', icons.erase],
597
- indent: ['_se_command_indent', lang.toolbar.indent + '<span class="se-shortcut">' + (shortcutsDisable.indexOf('indent') > -1 ? '' : cmd + '+<span class="se-shortcut-key">' + indentKey[0] + '</span>') + '</span>', 'indent', '', icons.outdent],
598
- outdent: ['_se_command_outdent', lang.toolbar.outdent + '<span class="se-shortcut">' + (shortcutsDisable.indexOf('indent') > -1 ? '' : cmd + '+<span class="se-shortcut-key">' + indentKey[1] + '</span>') + '</span>', 'outdent', '', icons.indent],
639
+ indent: ['_se_command_indent', lang.toolbar.indent + '<span class="se-shortcut">' + (shortcutsDisable.indexOf('indent') > -1 ? '' : cmd + '+<span class="se-shortcut-key">' + indentKey[0] + '</span>') + '</span>', 'indent', '', icons.indent],
640
+ outdent: ['_se_command_outdent', lang.toolbar.outdent + '<span class="se-shortcut">' + (shortcutsDisable.indexOf('indent') > -1 ? '' : cmd + '+<span class="se-shortcut-key">' + indentKey[1] + '</span>') + '</span>', 'outdent', '', icons.outdent],
599
641
  fullScreen: ['se-code-view-enabled se-resizing-enabled _se_command_fullScreen', lang.toolbar.fullScreen, 'fullScreen', '', icons.expansion],
600
642
  showBlocks: ['_se_command_showBlocks', lang.toolbar.showBlocks, 'showBlocks', '', icons.show_blocks],
601
643
  codeView: ['se-code-view-enabled se-resizing-enabled _se_command_codeView', lang.toolbar.codeView, 'codeView', '', icons.code_view],
602
- undo: ['_se_command_undo se-resizing-enabled', lang.toolbar.undo + '<span class="se-shortcut">' + (shortcutsDisable.indexOf('undo') > -1 ? '' : cmd + '+<span class="se-shortcut-key">Z</span>') + '</span>', 'undo', '', icons.undo],
603
- redo: ['_se_command_redo se-resizing-enabled', lang.toolbar.redo + '<span class="se-shortcut">' + (shortcutsDisable.indexOf('undo') > -1 ? '' : cmd + '+<span class="se-shortcut-key">Y</span> / ' + cmd + addShift + '+<span class="se-shortcut-key">Z</span>') + '</span>', 'redo', '', icons.redo],
644
+ undo: ['_se_command_undo', lang.toolbar.undo + '<span class="se-shortcut">' + (shortcutsDisable.indexOf('undo') > -1 ? '' : cmd + '+<span class="se-shortcut-key">Z</span>') + '</span>', 'undo', '', icons.undo],
645
+ redo: ['_se_command_redo', lang.toolbar.redo + '<span class="se-shortcut">' + (shortcutsDisable.indexOf('undo') > -1 ? '' : cmd + '+<span class="se-shortcut-key">Y</span> / ' + cmd + addShift + '+<span class="se-shortcut-key">Z</span>') + '</span>', 'redo', '', icons.redo],
604
646
  preview: ['se-resizing-enabled', lang.toolbar.preview, 'preview', '', icons.preview],
605
647
  print: ['se-resizing-enabled', lang.toolbar.print, 'print', '', icons.print],
648
+ dir: ['_se_command_dir', lang.toolbar[options.rtl ? 'dir_ltr' : 'dir_rtl'], 'dir', '', icons[options.rtl ? 'dir_ltr' : 'dir_rtl']],
649
+ dir_ltr: ['_se_command_dir_ltr', lang.toolbar.dir_ltr, 'dir_ltr', '', icons.dir_ltr],
650
+ dir_rtl: ['_se_command_dir_rtl', lang.toolbar.dir_rtl, 'dir_rtl', '', icons.dir_rtl],
606
651
  save: ['_se_command_save se-resizing-enabled', lang.toolbar.save + '<span class="se-shortcut">' + (shortcutsDisable.indexOf('save') > -1 ? '' : cmd + '+<span class="se-shortcut-key">S</span>') + '</span>', 'save', '', icons.save],
607
652
  /** plugins - command */
608
653
  blockquote: ['', lang.toolbar.tag_blockquote, 'blockquote', 'command', icons.blockquote],
@@ -772,7 +817,14 @@ export default {
772
817
  // align
773
818
  if (/^\-/.test(button)) {
774
819
  align = button.substr(1);
775
- moduleElement.div.style.float = align;
820
+ moduleElement.div.className += ' module-float-' + align;
821
+ continue;
822
+ }
823
+
824
+ // rtl fix
825
+ if (/^\#/.test(button)) {
826
+ const option = button.substr(1);
827
+ if (option === 'fix') moduleElement.ul.className += ' se-menu-dir-fix';
776
828
  continue;
777
829
  }
778
830
 
@@ -22,6 +22,7 @@ const _Context = function (element, cons, options) {
22
22
  topArea: cons._top,
23
23
  relative: cons._relative,
24
24
  toolbar: cons._toolBar,
25
+ _toolbarShadow: cons._toolbarShadow,
25
26
  _buttonTray: cons._toolBar.querySelector('.se-btn-tray'),
26
27
  _menuTray: cons._menuTray,
27
28
  resizingBar: cons._resizingBar,
@@ -56,7 +57,10 @@ const _Context = function (element, cons, options) {
56
57
  indent: cons._toolBar.querySelector('._se_command_indent'),
57
58
  fullScreen: cons._toolBar.querySelector('._se_command_fullScreen'),
58
59
  showBlocks: cons._toolBar.querySelector('._se_command_showBlocks'),
59
- codeView: cons._toolBar.querySelector('._se_command_codeView')
60
+ codeView: cons._toolBar.querySelector('._se_command_codeView'),
61
+ dir: cons._toolBar.querySelector('._se_command_dir'),
62
+ dir_ltr: cons._toolBar.querySelector('._se_command_dir_ltr'),
63
+ dir_rtl: cons._toolBar.querySelector('._se_command_dir_rtl')
60
64
  },
61
65
  options: options,
62
66
  option: options
package/src/lib/core.d.ts CHANGED
@@ -142,12 +142,24 @@ interface Core {
142
142
  */
143
143
  editorTagsWhitelistRegExp: RegExp;
144
144
 
145
+ /**
146
+ * @description Editor tags blacklist (RegExp object)
147
+ * util.createTagsBlacklist(options.tagsBlacklist)
148
+ */
149
+ editorTagsBlacklistRegExp: RegExp;
150
+
145
151
  /**
146
152
  * @description Tag whitelist when pasting (RegExp object)
147
153
  * util.createTagsWhitelist(options.pasteTagsWhitelist)
148
154
  */
149
155
  pasteTagsWhitelistRegExp: RegExp;
150
156
 
157
+ /**
158
+ * @description Tag blacklist when pasting (RegExp object)
159
+ * util.createTagsBlacklist(options.pasteTagsBlacklist)
160
+ */
161
+ pasteTagsBlacklistRegExp: RegExp;
162
+
151
163
  /**
152
164
  * @description Boolean value of whether the editor has focus
153
165
  */
@@ -180,6 +192,23 @@ interface Core {
180
192
  */
181
193
  commandMap: Record<string, Element>;
182
194
 
195
+ /**
196
+ * @description Contains pairs of all "data-commands" and "elements" setted in toolbar over time
197
+ * Used primarily to save and recover button states after the toolbar re-creation
198
+ * Updates each "_cachingButtons()" invocation
199
+ */
200
+ allCommandButtons: Record<string, Element>;
201
+
202
+ /**
203
+ * @description Save the current buttons states to "allCommandButtons" object
204
+ */
205
+ saveButtonStates(): void;
206
+
207
+ /**
208
+ * @description Recover the current buttons states from "allCommandButtons" object
209
+ */
210
+ recoverButtonStates(): void;
211
+
183
212
  /**
184
213
  * @description If the plugin is not added, add the plugin and call the 'add' function.
185
214
  * If the plugin is added call callBack function.
@@ -210,7 +239,7 @@ interface Core {
210
239
  initMenuTarget(pluginName: string, target: Element | null, menu: Element): void;
211
240
 
212
241
  /**
213
- * @description Enabled submenu
242
+ * @description Enable submenu
214
243
  * @param element Submenu's button element to call
215
244
  */
216
245
  submenuOn(element: Element): void;
@@ -221,7 +250,12 @@ interface Core {
221
250
  submenuOff(): void;
222
251
 
223
252
  /**
224
- * @description Enabled container
253
+ * @description Disable more layer
254
+ */
255
+ moreLayerOff(): void;
256
+
257
+ /**
258
+ * @description Enable container
225
259
  * @param element Container's button element to call
226
260
  */
227
261
  containerOn(element: Element): void;
@@ -507,7 +541,7 @@ interface Core {
507
541
  * @description Changes to full screen or default screen
508
542
  * @param element full screen button
509
543
  */
510
- toggleFullScreen(element: Element): void;
544
+ toggleFullScreen(element: Element | null): void;
511
545
 
512
546
  /**
513
547
  * @description Prints the current contents of the editor.
@@ -519,6 +553,12 @@ interface Core {
519
553
  */
520
554
  preview(): void;
521
555
 
556
+ /**
557
+ * @description Set direction to "rtl" or "ltr".
558
+ * @param dir "rtl" or "ltr"
559
+ */
560
+ setDir(dir: 'rtl' | 'ltr'): void;
561
+
522
562
  /**
523
563
  * @description Sets the HTML string
524
564
  * @param html HTML string
@@ -543,9 +583,11 @@ interface Core {
543
583
  * @param html HTML string
544
584
  * @param whitelist Regular expression of allowed tags.
545
585
  * RegExp object is create by util.createTagsWhitelist method. (core.pasteTagsWhitelistRegExp)
586
+ * @param blacklist Regular expression of disallowed tags.
587
+ * RegExp object is create by util.createTagsBlacklist method. (core.pasteTagsBlacklistRegExp)
546
588
  * @returns
547
589
  */
548
- cleanHTML(html: string, whitelist?: string | RegExp): string;
590
+ cleanHTML(html: string, whitelist?: string | RegExp, blacklist?: string | RegExp): string;
549
591
 
550
592
  /**
551
593
  * @description Converts contents into a format that can be placed in an editor
@@ -557,9 +599,10 @@ interface Core {
557
599
  /**
558
600
  * @description Converts wysiwyg area element into a format that can be placed in an editor of code view mode
559
601
  * @param html WYSIWYG element (context.element.wysiwyg) or HTML string.
602
+ * @param comp If true, does not line break and indentation of tags.
560
603
  * @returns
561
604
  */
562
- convertHTMLForCodeView(html: Element | string): string;
605
+ convertHTMLForCodeView(html: Element | string, comp?: boolean): string;
563
606
 
564
607
  /**
565
608
  * @description Add an event to document.
@@ -598,12 +641,12 @@ interface Toolbar {
598
641
  /**
599
642
  * @description Disable the toolbar
600
643
  */
601
- disabled(): void;
644
+ disable(): void;
602
645
 
603
646
  /**
604
647
  * @description Enable the toolbar
605
648
  */
606
- enabled(): void;
649
+ enable(): void;
607
650
 
608
651
  /**
609
652
  * @description Show the toolbar
@@ -616,6 +659,18 @@ interface Toolbar {
616
659
  hide(): void;
617
660
  }
618
661
 
662
+ interface Wysiwyg {
663
+ /**
664
+ * @description Disable the wysiwyg area
665
+ */
666
+ disable(): void;
667
+
668
+ /**
669
+ * @description Enable the wysiwyg area
670
+ */
671
+ enable(): void;
672
+ }
673
+
619
674
  type EventFn = (e: Event, core: Core) => void;
620
675
 
621
676
  type imageInputInformation = { linkValue: string, linkNewWindow: Window, inputWidth: number, inputHeight: number, align: string, isUpdate: boolean, element: any };
@@ -645,8 +700,15 @@ export default class SunEditor {
645
700
  onBlur: (e: FocusEvent, core: Core) => void;
646
701
  onDrop: (e: Event, cleanData: string, maxCharCount: number, core: Core) => boolean | string;
647
702
  onPaste: (e: Event, cleanData: string, maxCharCount: number, core: Core) => boolean | string;
648
- onCopy: (e: Event, clipboardData: any, core: Core) => void;
649
- onCut: (e: Event, clipboardData: any, core: Core) => void;
703
+ onCopy: (e: Event, clipboardData: any, core: Core) => boolean;
704
+ onCut: (e: Event, clipboardData: any, core: Core) => boolean;
705
+
706
+ /**
707
+ * @description Called just after the save was executed.
708
+ * @param contents Editor content
709
+ * @param core Core object
710
+ */
711
+ onSave: (contents: string, core: Core) => void;
650
712
 
651
713
  /**
652
714
  * @description Called just before the inline toolbar is positioned and displayed on the screen.
@@ -872,9 +934,18 @@ export default class SunEditor {
872
934
  * @param height Height after resized (px)
873
935
  * @param prevHeight Prev height before resized (px)
874
936
  * @param core Core object
937
+ * @param resizeObserverEntry ResizeObserverEntry object (This is not provided in IE Browser.)
875
938
  * @returns
876
939
  */
877
- onResizeEditor: (height: number, prevHeight: number, core: Core) => {};
940
+ onResizeEditor: (height: number, prevHeight: number, core: Core, resizeObserverEntry: ResizeObserverEntry | null) => {};
941
+
942
+ /**
943
+ * @description Called after the "setToolbarButtons" invocation.
944
+ * Can be used to tweak buttons properties (useful for custom buttons)
945
+ * @param buttonList Button list
946
+ * @param core Core object
947
+ */
948
+ onSetToolbarButtons: (buttonList: any[], core: Core) => void;
878
949
 
879
950
  /**
880
951
  * @description Reset the buttons on the toolbar. (Editor is not reloaded)
@@ -1006,12 +1077,12 @@ export default class SunEditor {
1006
1077
  /**
1007
1078
  * @description Disable the suneditor
1008
1079
  */
1009
- disabled(): void;
1080
+ disable(): void;
1010
1081
 
1011
1082
  /**
1012
1083
  * @description Enable the suneditor
1013
1084
  */
1014
- enabled(): void;
1085
+ enable(): void;
1015
1086
 
1016
1087
  /**
1017
1088
  * @description Show the suneditor
@@ -1032,4 +1103,9 @@ export default class SunEditor {
1032
1103
  * @description Toolbar methods
1033
1104
  */
1034
1105
  toolbar: Toolbar;
1106
+
1107
+ /**
1108
+ * @description Wysiwyg methods
1109
+ */
1110
+ wysiwyg: Wysiwyg;
1035
1111
  }