suneditor 2.41.3 → 2.42.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 (45) hide show
  1. package/README.md +107 -24
  2. package/dist/css/suneditor.min.css +1 -1
  3. package/dist/suneditor.min.js +2 -2
  4. package/package.json +1 -1
  5. package/src/assets/css/suneditor.css +25 -6
  6. package/src/assets/defaultIcons.js +2 -0
  7. package/src/lang/Lang.d.ts +3 -1
  8. package/src/lang/ckb.js +2 -0
  9. package/src/lang/da.js +2 -0
  10. package/src/lang/de.js +2 -0
  11. package/src/lang/en.js +2 -0
  12. package/src/lang/es.js +2 -0
  13. package/src/lang/fr.js +10 -8
  14. package/src/lang/he.js +2 -0
  15. package/src/lang/it.js +2 -0
  16. package/src/lang/ja.js +2 -0
  17. package/src/lang/ko.js +2 -0
  18. package/src/lang/lv.js +2 -0
  19. package/src/lang/nl.js +2 -0
  20. package/src/lang/pl.js +2 -0
  21. package/src/lang/pt_br.js +2 -0
  22. package/src/lang/ro.js +2 -0
  23. package/src/lang/ru.js +2 -0
  24. package/src/lang/se.js +2 -0
  25. package/src/lang/ua.js +2 -0
  26. package/src/lang/zh_cn.js +2 -0
  27. package/src/lib/constructor.js +50 -11
  28. package/src/lib/context.js +4 -1
  29. package/src/lib/core.d.ts +86 -11
  30. package/src/lib/core.js +555 -147
  31. package/src/lib/util.d.ts +24 -1
  32. package/src/lib/util.js +64 -15
  33. package/src/options.d.ts +63 -8
  34. package/src/plugins/dialog/audio.js +5 -5
  35. package/src/plugins/dialog/image.js +30 -20
  36. package/src/plugins/dialog/video.js +13 -13
  37. package/src/plugins/fileBrowser/imageGallery.js +2 -3
  38. package/src/plugins/modules/_anchor.js +6 -4
  39. package/src/plugins/modules/component.d.ts +1 -1
  40. package/src/plugins/modules/fileBrowser.js +6 -1
  41. package/src/plugins/modules/fileManager.js +1 -3
  42. package/src/plugins/modules/resizing.js +11 -6
  43. package/src/plugins/submenu/align.js +32 -27
  44. package/src/plugins/submenu/font.js +1 -1
  45. package/src/plugins/submenu/horizontalRule.js +19 -25
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.
@@ -876,6 +938,14 @@ export default class SunEditor {
876
938
  */
877
939
  onResizeEditor: (height: number, prevHeight: number, core: Core) => {};
878
940
 
941
+ /**
942
+ * @description Called after the "setToolbarButtons" invocation.
943
+ * Can be used to tweak buttons properties (useful for custom buttons)
944
+ * @param buttonList Button list
945
+ * @param core Core object
946
+ */
947
+ onSetToolbarButtons: (buttonList: any[], core: Core) => void;
948
+
879
949
  /**
880
950
  * @description Reset the buttons on the toolbar. (Editor is not reloaded)
881
951
  * You cannot set a new plugin for the button.
@@ -1006,12 +1076,12 @@ export default class SunEditor {
1006
1076
  /**
1007
1077
  * @description Disable the suneditor
1008
1078
  */
1009
- disabled(): void;
1079
+ disable(): void;
1010
1080
 
1011
1081
  /**
1012
1082
  * @description Enable the suneditor
1013
1083
  */
1014
- enabled(): void;
1084
+ enable(): void;
1015
1085
 
1016
1086
  /**
1017
1087
  * @description Show the suneditor
@@ -1032,4 +1102,9 @@ export default class SunEditor {
1032
1102
  * @description Toolbar methods
1033
1103
  */
1034
1104
  toolbar: Toolbar;
1105
+
1106
+ /**
1107
+ * @description Wysiwyg methods
1108
+ */
1109
+ wysiwyg: Wysiwyg;
1035
1110
  }