suneditor 3.1.3 → 3.2.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 (219) hide show
  1. package/dist/suneditor-contents.min.css +1 -1
  2. package/dist/suneditor.min.css +28 -1
  3. package/dist/suneditor.min.js +1 -1
  4. package/package.json +2 -1
  5. package/src/assets/design/color.css +12 -0
  6. package/src/assets/design/size.css +9 -2
  7. package/src/assets/icons/defaultIcons.js +96 -47
  8. package/src/assets/suneditor-contents.css +3 -2
  9. package/src/assets/suneditor.css +480 -31
  10. package/src/core/config/contextProvider.js +2 -1
  11. package/src/core/config/eventManager.js +41 -2
  12. package/src/core/config/optionProvider.js +23 -2
  13. package/src/core/editor.js +32 -14
  14. package/src/core/event/actions/index.js +76 -9
  15. package/src/core/event/effects/common.registry.js +2 -1
  16. package/src/core/event/effects/keydown.registry.js +169 -33
  17. package/src/core/event/effects/ruleHelpers.js +20 -6
  18. package/src/core/event/eventOrchestrator.js +136 -23
  19. package/src/core/event/handlers/handler_toolbar.js +4 -2
  20. package/src/core/event/handlers/handler_ww_dragDrop.js +10 -0
  21. package/src/core/event/handlers/handler_ww_input.js +9 -2
  22. package/src/core/event/handlers/handler_ww_key.js +86 -17
  23. package/src/core/event/handlers/handler_ww_mouse.js +45 -8
  24. package/src/core/event/ports.js +23 -5
  25. package/src/core/event/reducers/keydown.reducer.js +15 -2
  26. package/src/core/event/rules/keydown.rule.arrow.js +12 -2
  27. package/src/core/event/rules/keydown.rule.backspace.js +110 -15
  28. package/src/core/event/rules/keydown.rule.delete.js +62 -7
  29. package/src/core/event/rules/keydown.rule.enter.js +62 -31
  30. package/src/core/event/support/defaultLineManager.js +9 -2
  31. package/src/core/event/support/selectionState.js +13 -3
  32. package/src/core/kernel/coreKernel.js +1 -0
  33. package/src/core/logic/dom/char.js +13 -3
  34. package/src/core/logic/dom/format.js +171 -39
  35. package/src/core/logic/dom/html.js +357 -87
  36. package/src/core/logic/dom/inline.js +229 -34
  37. package/src/core/logic/dom/listFormat.js +111 -20
  38. package/src/core/logic/dom/nodeTransform.js +36 -11
  39. package/src/core/logic/dom/offset.js +116 -31
  40. package/src/core/logic/dom/selection.js +147 -29
  41. package/src/core/logic/panel/blockHandle.js +785 -0
  42. package/src/core/logic/panel/blockResolver.js +278 -0
  43. package/src/core/logic/panel/finder.js +16 -6
  44. package/src/core/logic/panel/menu.js +119 -18
  45. package/src/core/logic/panel/toolbar.js +75 -19
  46. package/src/core/logic/panel/viewer.js +76 -20
  47. package/src/core/logic/shell/_commandExecutor.js +44 -9
  48. package/src/core/logic/shell/commandDispatcher.js +46 -4
  49. package/src/core/logic/shell/component.js +102 -25
  50. package/src/core/logic/shell/focusManager.js +13 -3
  51. package/src/core/logic/shell/history.js +21 -6
  52. package/src/core/logic/shell/pluginManager.js +21 -13
  53. package/src/core/logic/shell/shortcuts.js +9 -1
  54. package/src/core/logic/shell/ui.js +139 -37
  55. package/src/core/schema/frameContext.js +34 -3
  56. package/src/core/schema/options.js +61 -19
  57. package/src/core/section/constructor.js +537 -103
  58. package/src/core/section/documentType.js +35 -6
  59. package/src/helper/converter.js +24 -7
  60. package/src/helper/dom/domCheck.js +25 -5
  61. package/src/helper/dom/domQuery.js +2 -1
  62. package/src/helper/dom/domUtils.js +17 -4
  63. package/src/helper/env.js +11 -2
  64. package/src/helper/keyCodeMap.js +6 -2
  65. package/src/helper/markdown.js +24 -5
  66. package/src/helper/msOffice.js +9 -2
  67. package/src/interfaces/plugins.js +1 -1
  68. package/src/langs/ckb.js +0 -1
  69. package/src/langs/cs.js +0 -1
  70. package/src/langs/da.js +0 -1
  71. package/src/langs/de.js +0 -1
  72. package/src/langs/en.js +0 -1
  73. package/src/langs/es.js +0 -1
  74. package/src/langs/fa.js +0 -1
  75. package/src/langs/fr.js +0 -1
  76. package/src/langs/he.js +0 -1
  77. package/src/langs/hu.js +0 -1
  78. package/src/langs/index.js +27 -1
  79. package/src/langs/it.js +0 -1
  80. package/src/langs/ja.js +0 -1
  81. package/src/langs/km.js +0 -1
  82. package/src/langs/ko.js +0 -1
  83. package/src/langs/lv.js +0 -1
  84. package/src/langs/nl.js +0 -1
  85. package/src/langs/pl.js +0 -1
  86. package/src/langs/pt_br.js +0 -1
  87. package/src/langs/ro.js +0 -1
  88. package/src/langs/ru.js +0 -1
  89. package/src/langs/se.js +0 -1
  90. package/src/langs/tr.js +0 -1
  91. package/src/langs/uk.js +0 -1
  92. package/src/langs/ur.js +0 -1
  93. package/src/langs/zh_cn.js +0 -1
  94. package/src/modules/contract/Browser.js +68 -23
  95. package/src/modules/contract/ColorPicker.js +12 -4
  96. package/src/modules/contract/Controller.js +37 -7
  97. package/src/modules/contract/Figure.js +159 -36
  98. package/src/modules/contract/HueSlider.js +27 -4
  99. package/src/modules/contract/Modal.js +62 -11
  100. package/src/modules/manager/FileManager.js +50 -8
  101. package/src/modules/ui/CommandMenu.js +597 -0
  102. package/src/modules/ui/ModalAnchorEditor.js +41 -9
  103. package/src/modules/ui/SelectMenu.js +481 -36
  104. package/src/modules/ui/index.js +1 -0
  105. package/src/plugins/browser/audioGallery.js +8 -1
  106. package/src/plugins/browser/fileBrowser.js +15 -2
  107. package/src/plugins/browser/fileGallery.js +8 -1
  108. package/src/plugins/browser/imageGallery.js +24 -3
  109. package/src/plugins/browser/videoGallery.js +19 -4
  110. package/src/plugins/command/blockquote.js +6 -1
  111. package/src/plugins/command/codeBlock.js +43 -5
  112. package/src/plugins/command/exportPDF.js +20 -4
  113. package/src/plugins/command/fileUpload.js +46 -11
  114. package/src/plugins/command/list_bulleted.js +6 -1
  115. package/src/plugins/command/list_numbered.js +6 -1
  116. package/src/plugins/dropdown/align.js +21 -33
  117. package/src/plugins/dropdown/backgroundColor.js +10 -2
  118. package/src/plugins/dropdown/blockStyle.js +17 -22
  119. package/src/plugins/dropdown/font.js +34 -34
  120. package/src/plugins/dropdown/hr.js +15 -43
  121. package/src/plugins/dropdown/layout.js +10 -27
  122. package/src/plugins/dropdown/lineHeight.js +10 -33
  123. package/src/plugins/dropdown/list.js +19 -25
  124. package/src/plugins/dropdown/paragraphStyle.js +16 -24
  125. package/src/plugins/dropdown/table/index.js +72 -17
  126. package/src/plugins/dropdown/table/render/table.html.js +3 -1
  127. package/src/plugins/dropdown/table/services/table.cell.js +33 -7
  128. package/src/plugins/dropdown/table/services/table.clipboard.js +5 -1
  129. package/src/plugins/dropdown/table/services/table.grid.js +40 -9
  130. package/src/plugins/dropdown/table/services/table.resize.js +55 -11
  131. package/src/plugins/dropdown/table/services/table.selection.js +27 -7
  132. package/src/plugins/dropdown/table/services/table.style.js +120 -20
  133. package/src/plugins/dropdown/template.js +13 -29
  134. package/src/plugins/dropdown/textStyle.js +22 -35
  135. package/src/plugins/field/autocomplete.js +8 -4
  136. package/src/plugins/field/slashCommand.js +297 -0
  137. package/src/plugins/index.js +3 -0
  138. package/src/plugins/input/fontSize.js +37 -8
  139. package/src/plugins/input/pageNavigator.js +7 -1
  140. package/src/plugins/modal/audio.js +71 -17
  141. package/src/plugins/modal/drawing.js +41 -11
  142. package/src/plugins/modal/embed.js +132 -22
  143. package/src/plugins/modal/image/index.js +115 -28
  144. package/src/plugins/modal/image/services/image.size.js +9 -2
  145. package/src/plugins/modal/image/services/image.upload.js +38 -4
  146. package/src/plugins/modal/link.js +9 -2
  147. package/src/plugins/modal/math.js +10 -2
  148. package/src/plugins/modal/video/index.js +112 -26
  149. package/src/plugins/modal/video/render/video.html.js +4 -1
  150. package/src/plugins/modal/video/services/video.size.js +15 -4
  151. package/src/plugins/modal/video/services/video.upload.js +10 -2
  152. package/src/plugins/popup/anchor.js +14 -2
  153. package/src/suneditor.js +8 -2
  154. package/src/themes/cobalt.css +12 -0
  155. package/src/themes/cream.css +12 -0
  156. package/src/themes/dark.css +12 -0
  157. package/src/themes/midnight.css +12 -0
  158. package/src/typedef.js +32 -21
  159. package/types/assets/icons/defaultIcons.d.ts +1 -0
  160. package/types/core/config/contextProvider.d.ts +7 -1
  161. package/types/core/config/eventManager.d.ts +37 -4
  162. package/types/core/config/optionProvider.d.ts +5 -1
  163. package/types/core/event/actions/index.d.ts +44 -6
  164. package/types/core/event/effects/keydown.registry.d.ts +37 -7
  165. package/types/core/event/effects/ruleHelpers.d.ts +6 -1
  166. package/types/core/event/eventOrchestrator.d.ts +6 -1
  167. package/types/core/event/handlers/handler_ww_clipboard.d.ts +15 -3
  168. package/types/core/event/handlers/handler_ww_dragDrop.d.ts +14 -2
  169. package/types/core/event/handlers/handler_ww_input.d.ts +10 -2
  170. package/types/core/event/handlers/handler_ww_key.d.ts +10 -2
  171. package/types/core/event/handlers/handler_ww_mouse.d.ts +25 -5
  172. package/types/core/event/ports.d.ts +7 -2
  173. package/types/core/event/rules/keydown.rule.backspace.d.ts +6 -1
  174. package/types/core/kernel/store.d.ts +4 -1
  175. package/types/core/logic/dom/format.d.ts +32 -14
  176. package/types/core/logic/dom/html.d.ts +11 -3
  177. package/types/core/logic/dom/nodeTransform.d.ts +6 -6
  178. package/types/core/logic/panel/blockHandle.d.ts +64 -0
  179. package/types/core/logic/panel/blockResolver.d.ts +50 -0
  180. package/types/core/logic/panel/menu.d.ts +72 -3
  181. package/types/core/logic/shell/commandDispatcher.d.ts +8 -0
  182. package/types/core/logic/shell/component.d.ts +5 -3
  183. package/types/core/logic/shell/shortcuts.d.ts +10 -1
  184. package/types/core/logic/shell/ui.d.ts +7 -1
  185. package/types/core/schema/context.d.ts +7 -1
  186. package/types/core/schema/frameContext.d.ts +36 -4
  187. package/types/core/schema/options.d.ts +110 -37
  188. package/types/core/section/constructor.d.ts +38 -1
  189. package/types/events.d.ts +208 -32
  190. package/types/helper/converter.d.ts +4 -2
  191. package/types/helper/dom/domCheck.d.ts +12 -2
  192. package/types/helper/dom/domQuery.d.ts +35 -7
  193. package/types/helper/dom/domUtils.d.ts +4 -1
  194. package/types/interfaces/plugins.d.ts +2 -2
  195. package/types/langs/_Lang.d.ts +0 -1
  196. package/types/modules/contract/Browser.d.ts +7 -7
  197. package/types/modules/contract/ColorPicker.d.ts +2 -2
  198. package/types/modules/contract/Controller.d.ts +7 -0
  199. package/types/modules/contract/Figure.d.ts +31 -4
  200. package/types/modules/ui/CommandMenu.d.ts +262 -0
  201. package/types/modules/ui/ModalAnchorEditor.d.ts +6 -1
  202. package/types/modules/ui/SelectMenu.d.ts +56 -3
  203. package/types/modules/ui/index.d.ts +1 -0
  204. package/types/plugins/browser/audioGallery.d.ts +17 -1
  205. package/types/plugins/browser/fileBrowser.d.ts +17 -1
  206. package/types/plugins/browser/fileGallery.d.ts +17 -1
  207. package/types/plugins/browser/imageGallery.d.ts +17 -1
  208. package/types/plugins/browser/videoGallery.d.ts +17 -1
  209. package/types/plugins/dropdown/align.d.ts +1 -1
  210. package/types/plugins/dropdown/blockStyle.d.ts +3 -1
  211. package/types/plugins/dropdown/table/index.d.ts +4 -1
  212. package/types/plugins/dropdown/table/services/table.clipboard.d.ts +5 -1
  213. package/types/plugins/dropdown/table/services/table.grid.d.ts +10 -2
  214. package/types/plugins/field/autocomplete.d.ts +0 -1
  215. package/types/plugins/field/slashCommand.d.ts +165 -0
  216. package/types/plugins/index.d.ts +3 -0
  217. package/types/plugins/modal/embed.d.ts +34 -0
  218. package/types/plugins/modal/link.d.ts +4 -1
  219. package/types/typedef.d.ts +48 -23
@@ -44,7 +44,11 @@ export class TableStyleService {
44
44
  // props
45
45
  const controller_props = CreateHTML_controller_properties(this.#$);
46
46
  const propsTargets = [this.#main.controller_table, this.#main.controller_cell];
47
- this.controller_props = new Controller(this, this.#$, controller_props.html, { position: 'bottom', parents: propsTargets, isInsideForm: true });
47
+ this.controller_props = new Controller(this, this.#$, controller_props.html, {
48
+ position: 'bottom',
49
+ parents: propsTargets,
50
+ isInsideForm: true,
51
+ });
48
52
  this.controller_props_title = controller_props.controller_props_title;
49
53
 
50
54
  // color picker
@@ -65,7 +69,9 @@ export class TableStyleService {
65
69
  colorList: pluginOptions.colorList || Constants.DEFAULT_COLOR_LIST,
66
70
  splitNum: 5,
67
71
  disableRemove: true,
68
- hueSliderOptions: { controllerOptions: { isOutsideForm: true, parents: [this.controller_colorPicker], parentsHide: true } },
72
+ hueSliderOptions: {
73
+ controllerOptions: { isOutsideForm: true, parents: [this.controller_colorPicker], parentsHide: true },
74
+ },
69
75
  });
70
76
 
71
77
  // members - SelectMenu - properties - border style
@@ -78,14 +84,34 @@ export class TableStyleService {
78
84
  // members - SelectMenu - properties - border format
79
85
  const borderFormatMenu = CreateBorderFormatMenu(this.#$.lang, this.#$.icons, []);
80
86
  const borderFormatButton = controller_props.borderFormatButton;
81
- this.selectMenu_props_border_format = new SelectMenu(this.#$, { checkList: false, position: 'bottom-left', dir: 'ltr', splitNum: 5 });
87
+ this.selectMenu_props_border_format = new SelectMenu(this.#$, {
88
+ checkList: false,
89
+ position: 'bottom-left',
90
+ dir: 'ltr',
91
+ splitNum: 5,
92
+ });
82
93
  this.selectMenu_props_border_format.on(borderFormatButton, this.#OnPropsBorderFormatEdit.bind(this, 'all'));
83
94
  this.selectMenu_props_border_format.create(borderFormatMenu.items, borderFormatMenu.menus);
84
95
 
85
- const borderFormatMenu_oneCell = CreateBorderFormatMenu(this.#$.lang, this.#$.icons, Constants.BORDER_FORMAT_INSIDE);
86
- this.selectMenu_props_border_format_oneCell = new SelectMenu(this.#$, { checkList: false, position: 'bottom-left', dir: 'ltr', splitNum: 6 });
87
- this.selectMenu_props_border_format_oneCell.on(borderFormatButton, this.#OnPropsBorderFormatEdit.bind(this, 'outside'));
88
- this.selectMenu_props_border_format_oneCell.create(borderFormatMenu_oneCell.items, borderFormatMenu_oneCell.menus);
96
+ const borderFormatMenu_oneCell = CreateBorderFormatMenu(
97
+ this.#$.lang,
98
+ this.#$.icons,
99
+ Constants.BORDER_FORMAT_INSIDE,
100
+ );
101
+ this.selectMenu_props_border_format_oneCell = new SelectMenu(this.#$, {
102
+ checkList: false,
103
+ position: 'bottom-left',
104
+ dir: 'ltr',
105
+ splitNum: 6,
106
+ });
107
+ this.selectMenu_props_border_format_oneCell.on(
108
+ borderFormatButton,
109
+ this.#OnPropsBorderFormatEdit.bind(this, 'outside'),
110
+ );
111
+ this.selectMenu_props_border_format_oneCell.create(
112
+ borderFormatMenu_oneCell.items,
113
+ borderFormatMenu_oneCell.menus,
114
+ );
89
115
 
90
116
  // memberts - elements..
91
117
  this.maxText = this.#$.lang.maxSize;
@@ -170,7 +196,11 @@ export class TableStyleService {
170
196
  } else {
171
197
  this.controller_props_title.textContent = this.#$.lang.tableProperties;
172
198
  this.#setCtrlProps('table');
173
- this.controller_props.open(target, this.#main.controller_table.form, { isWWTarget: false, initMethod: null, addOffset: null });
199
+ this.controller_props.open(target, this.#main.controller_table.form, {
200
+ isWWTarget: false,
201
+ initMethod: null,
202
+ addOffset: null,
203
+ });
174
204
  }
175
205
  }
176
206
 
@@ -184,7 +214,11 @@ export class TableStyleService {
184
214
  } else {
185
215
  this.controller_props_title.textContent = this.#$.lang.cellProperties;
186
216
  this.#setCtrlProps('cell');
187
- this.controller_props.open(target, this.#main.controller_cell.form, { isWWTarget: false, initMethod: null, addOffset: null });
217
+ this.controller_props.open(target, this.#main.controller_cell.form, {
218
+ isWWTarget: false,
219
+ initMethod: null,
220
+ addOffset: null,
221
+ });
188
222
  }
189
223
  }
190
224
 
@@ -268,7 +302,9 @@ export class TableStyleService {
268
302
  const table = this.#main._element;
269
303
 
270
304
  if (!active) {
271
- const caption = dom.utils.createElement('CAPTION', { class: `se-table-caption-${this.#main.captionPosition}` });
305
+ const caption = dom.utils.createElement('CAPTION', {
306
+ class: `se-table-caption-${this.#main.captionPosition}`,
307
+ });
272
308
  caption.innerHTML = '<div><br></div>';
273
309
  table.insertBefore(caption, table.firstElementChild);
274
310
  } else {
@@ -404,7 +440,16 @@ export class TableStyleService {
404
440
  const targets = isTable ? [this.#main._element] : this.#state.selectedCells;
405
441
  const tr = /** @type {HTMLTableCellElement} */ (targets[0]);
406
442
  const trStyles = _w.getComputedStyle(tr);
407
- const { border_format, border_color, border_style, border_width, back_color, font_color, cell_alignment, cell_alignment_vertical } = this.propTargets;
443
+ const {
444
+ border_format,
445
+ border_color,
446
+ border_style,
447
+ border_width,
448
+ back_color,
449
+ font_color,
450
+ cell_alignment,
451
+ cell_alignment_vertical,
452
+ } = this.propTargets;
408
453
 
409
454
  const borderFormat = border_format.getAttribute('se-border-format') || '';
410
455
  const hasFormat = borderFormat !== 'all';
@@ -445,7 +490,11 @@ export class TableStyleService {
445
490
  ce -= cs;
446
491
  cs -= cs;
447
492
  let prevRow = /** @type {HTMLElement} */ (trRow);
448
- for (let i = 0, cellCnt = 0, len = targets.length, e, es, rowIndex = 0, cellIndex, colspan, rowspan; i < len; i++, cellCnt++) {
493
+ for (
494
+ let i = 0, cellCnt = 0, len = targets.length, e, es, rowIndex = 0, cellIndex, colspan, rowspan;
495
+ i < len;
496
+ i++, cellCnt++
497
+ ) {
449
498
  e = /** @type {HTMLTableCellElement} */ (targets[i]);
450
499
  colspan = e.colSpan;
451
500
  rowspan = e.rowSpan;
@@ -481,7 +530,8 @@ export class TableStyleService {
481
530
  if (rowIndex === re || isBottom) cells.bottom.push(e);
482
531
  if (cellIndex === cs) cells.left.push(e);
483
532
  if (cellIndex === ce || cellIndex + colspan - 1 === ce) cells.right.push(e);
484
- if (!isBottom && rowIndex !== rs && rowIndex !== re && cellIndex !== cs && cellIndex !== ce) cells.middle.push(e);
533
+ if (!isBottom && rowIndex !== rs && rowIndex !== re && cellIndex !== cs && cellIndex !== ce)
534
+ cells.middle.push(e);
485
535
 
486
536
  // --- set styles
487
537
  es = e.style;
@@ -575,11 +625,28 @@ export class TableStyleService {
575
625
  const targets = isTable ? [this.#main._element] : this.#state.selectedCells;
576
626
  if (!targets?.[0]) return;
577
627
 
578
- const { border_format, border_color, border_style, border_width, back_color, font_color, cell_alignment, cell_alignment_vertical, cell_alignment_table_text, font_bold, font_underline, font_italic, font_strike } = this.propTargets;
579
- const { border, backgroundColor, color, textAlign, verticalAlign, fontWeight, textDecoration, fontStyle } = _w.getComputedStyle(targets[0]);
628
+ const {
629
+ border_format,
630
+ border_color,
631
+ border_style,
632
+ border_width,
633
+ back_color,
634
+ font_color,
635
+ cell_alignment,
636
+ cell_alignment_vertical,
637
+ cell_alignment_table_text,
638
+ font_bold,
639
+ font_underline,
640
+ font_italic,
641
+ font_strike,
642
+ } = this.propTargets;
643
+ const { border, backgroundColor, color, textAlign, verticalAlign, fontWeight, textDecoration, fontStyle } =
644
+ _w.getComputedStyle(targets[0]);
580
645
  const cellBorder = this.#getBorderStyle(border);
581
646
 
582
- /** @type {HTMLElement} */ (cell_alignment.querySelector('[data-value="justify"]')).style.display = isTable ? 'none' : '';
647
+ /** @type {HTMLElement} */ (cell_alignment.querySelector('[data-value="justify"]')).style.display = isTable
648
+ ? 'none'
649
+ : '';
583
650
  cell_alignment_table_text.style.display = isTable ? '' : 'none';
584
651
  if (isTable) cell_alignment_vertical.style.display = 'none';
585
652
  else cell_alignment_vertical.style.display = '';
@@ -640,7 +707,8 @@ export class TableStyleService {
640
707
  }
641
708
 
642
709
  // border - format
643
- border_format.firstElementChild.innerHTML = this.#$.icons[Constants.BORDER_FORMATS[targets.length === 1 ? 'outside' : 'all']];
710
+ border_format.firstElementChild.innerHTML =
711
+ this.#$.icons[Constants.BORDER_FORMATS[targets.length === 1 ? 'outside' : 'all']];
644
712
  border_format.setAttribute('se-border-format', 'all');
645
713
  dom.utils.removeClass(border_format, 'active');
646
714
 
@@ -674,7 +742,10 @@ export class TableStyleService {
674
742
  const { font_bold, font_italic, font_strike, font_underline } = this.propTargets;
675
743
  styles.fontWeight = dom.utils.hasClass(font_bold, 'on') ? 'bold' : '';
676
744
  styles.fontStyle = dom.utils.hasClass(font_italic, 'on') ? 'italic' : '';
677
- styles.textDecoration = ((dom.utils.hasClass(font_strike, 'on') ? 'line-through ' : '') + (dom.utils.hasClass(font_underline, 'on') ? 'underline' : '')).trim();
745
+ styles.textDecoration = (
746
+ (dom.utils.hasClass(font_strike, 'on') ? 'line-through ' : '') +
747
+ (dom.utils.hasClass(font_underline, 'on') ? 'underline' : '')
748
+ ).trim();
678
749
  }
679
750
 
680
751
  /**
@@ -841,8 +912,37 @@ export class TableStyleService {
841
912
  * @description Initialize the style service (resets properties).
842
913
  */
843
914
  init() {
844
- const { border_format, border_color, border_style, border_width, back_color, font_color, cell_alignment, cell_alignment_vertical, font_bold, font_underline, font_italic, font_strike } = this.propTargets;
845
- dom.utils.removeClass([border_format, border_color, border_style, border_width, back_color, font_color, cell_alignment, cell_alignment_vertical, font_bold, font_underline, font_italic, font_strike], 'on');
915
+ const {
916
+ border_format,
917
+ border_color,
918
+ border_style,
919
+ border_width,
920
+ back_color,
921
+ font_color,
922
+ cell_alignment,
923
+ cell_alignment_vertical,
924
+ font_bold,
925
+ font_underline,
926
+ font_italic,
927
+ font_strike,
928
+ } = this.propTargets;
929
+ dom.utils.removeClass(
930
+ [
931
+ border_format,
932
+ border_color,
933
+ border_style,
934
+ border_width,
935
+ back_color,
936
+ font_color,
937
+ cell_alignment,
938
+ cell_alignment_vertical,
939
+ font_bold,
940
+ font_underline,
941
+ font_italic,
942
+ font_strike,
943
+ ],
944
+ 'on',
945
+ );
846
946
  }
847
947
  }
848
948
 
@@ -1,5 +1,4 @@
1
1
  import { PluginDropdown } from '../../interfaces';
2
- import { dom } from '../../helper';
3
2
 
4
3
  /**
5
4
  * @typedef {Object} TemplatePluginOptions
@@ -32,11 +31,8 @@ class Template extends PluginDropdown {
32
31
  this.selectedIndex = -1;
33
32
  this.items = pluginOptions.items;
34
33
 
35
- // create HTML
36
- const menu = CreateHTML(this.items);
37
-
38
- // init
39
- this.$.menu.initDropdownTarget(Template, menu);
34
+ // create menu from items
35
+ this.$.menu.initDropdownTarget(Template, CreateItems(this.items));
40
36
  }
41
37
 
42
38
  /**
@@ -60,33 +56,21 @@ class Template extends PluginDropdown {
60
56
 
61
57
  /**
62
58
  * @param {Array<{name: string, html: string}>} templateList - Template items
63
- * @returns {HTMLElement}
59
+ * @returns {Array<import('../../core/logic/panel/menu').DropdownItem>}
64
60
  */
65
- function CreateHTML(templateList) {
61
+ function CreateItems(templateList) {
66
62
  if (!templateList || templateList.length === 0) {
67
- console.warn('[SUNEDITOR.plugins.template.warn] To use the "template" plugin, please define the "templates" option.');
68
- }
69
-
70
- let list = '<div class="se-dropdown se-list-inner"><ul class="se-list-basic">';
71
- for (let i = 0, len = (templateList || []).length, t; i < len; i++) {
72
- t = templateList[i];
73
- list += /*html*/ `
74
- <li>
75
- <button
76
- type="button"
77
- class="se-btn se-btn-list"
78
- data-command="template"
79
- data-value="${i}"
80
- title="${t.name}"
81
- aria-label="${t.name}"
82
- >
83
- ${t.name}
84
- </button>
85
- </li>`;
63
+ console.warn(
64
+ '[SUNEDITOR.plugins.template.warn] To use the "template" plugin, please define the "templates" option.',
65
+ );
86
66
  }
87
- list += '</ul></div>';
88
67
 
89
- return dom.utils.createElement('DIV', { class: 'se-list-layer' }, list);
68
+ return (templateList || []).map((t, i) => ({
69
+ command: 'template',
70
+ value: String(i),
71
+ title: t.name,
72
+ innerHTML: t.name,
73
+ }));
90
74
  }
91
75
 
92
76
  export default Template;
@@ -29,14 +29,13 @@ class TextStyle extends PluginDropdown {
29
29
  this.title = this.$.lang.textStyle;
30
30
  this.icon = 'text_style';
31
31
 
32
- // create HTML
33
- const menu = CreateHTML(this.$, pluginOptions.items);
32
+ // create menu from items
33
+ const menu = this.$.menu.initDropdownTarget(TextStyle, CreateItems(this.$, pluginOptions.items), {
34
+ className: 'se-list-format',
35
+ });
34
36
 
35
37
  // members
36
38
  this.styleList = menu.querySelectorAll('li button');
37
-
38
- // init
39
- this.$.menu.initDropdownTarget(TextStyle, menu);
40
39
  }
41
40
 
42
41
  /**
@@ -58,7 +57,11 @@ class TextStyle extends PluginDropdown {
58
57
  while (node && !this.$.format.isLine(node) && !this.$.component.is(node)) {
59
58
  if (node.nodeName.toLowerCase() === btn.getAttribute('data-command').toLowerCase()) {
60
59
  value = data[v];
61
- if (/^\./.test(value) ? dom.utils.hasClass(node, value.replace(/^\./, '')) : /** @type {HTMLElement} */ (node).style[value]) {
60
+ if (
61
+ /^\./.test(value)
62
+ ? dom.utils.hasClass(node, value.replace(/^\./, ''))
63
+ : /** @type {HTMLElement} */ (node).style[value]
64
+ ) {
62
65
  active = true;
63
66
  break;
64
67
  }
@@ -98,9 +101,9 @@ class TextStyle extends PluginDropdown {
98
101
  /**
99
102
  * @param {SunEditor.Deps} $ - Kernel dependencies
100
103
  * @param {Array<string|{name: string, class: string, tag?: string}>} [items] - Text style items
101
- * @returns {HTMLElement}
104
+ * @returns {Array<import('../../core/logic/panel/menu').DropdownItem>}
102
105
  */
103
- function CreateHTML({ lang }, items) {
106
+ function CreateItems({ lang }, items) {
104
107
  const defaultList = {
105
108
  code: {
106
109
  name: lang.menu_code,
@@ -114,13 +117,10 @@ function CreateHTML({ lang }, items) {
114
117
  },
115
118
  };
116
119
  const styleList = items || Object.keys(defaultList);
120
+ const result = [];
117
121
 
118
- let list = '<div class="se-list-inner"><ul class="se-list-basic">';
119
- for (let i = 0, len = styleList.length, t, tag, name, attrs, command, value; i < len; i++) {
122
+ for (let i = 0, len = styleList.length, t, tag, name, value; i < len; i++) {
120
123
  t = styleList[i];
121
- attrs = '';
122
- value = '';
123
- command = [];
124
124
 
125
125
  if (typeof t === 'string') {
126
126
  const cssText = defaultList[t.toLowerCase()];
@@ -130,30 +130,17 @@ function CreateHTML({ lang }, items) {
130
130
 
131
131
  name = t.name;
132
132
  tag = t.tag || 'span';
133
-
134
- attrs += ` class="${t.class}"`;
135
- value += `.${t.class.trim().replace(/\s+/g, ',.')}`;
136
- command.push('class');
137
-
138
- value = value.replace(/,$/, '');
139
-
140
- list += `
141
- <li>
142
- <button
143
- type="button"
144
- class="se-btn se-btn-list"
145
- data-command="${tag}"
146
- data-value="${value}"
147
- title="${name}"
148
- aria-label="${name}"
149
- >
150
- <${tag}${attrs}>${name}</${tag}>
151
- </button>
152
- </li>`;
133
+ value = `.${t.class.trim().replace(/\s+/g, ',.')}`.replace(/,$/, '');
134
+
135
+ result.push({
136
+ command: tag,
137
+ value,
138
+ title: name,
139
+ innerHTML: `<${tag} class="${t.class}">${name}</${tag}>`,
140
+ });
153
141
  }
154
- list += '</ul></div>';
155
142
 
156
- return dom.utils.createElement('DIV', { class: 'se-dropdown se-list-layer se-list-format' }, list);
143
+ return result;
157
144
  }
158
145
 
159
146
  export default TextStyle;
@@ -128,8 +128,6 @@ class Autocomplete extends PluginField {
128
128
  */
129
129
  constructor(kernel, pluginOptions) {
130
130
  super(kernel);
131
- this.title = this.$.lang.autocomplete;
132
- this.icon = 'autocomplete';
133
131
 
134
132
  // global defaults
135
133
  const limitSize = pluginOptions.limitSize || 5;
@@ -164,7 +162,11 @@ class Autocomplete extends PluginField {
164
162
 
165
163
  // controller
166
164
  const controllerEl = CreateHTML_controller();
167
- this.selectMenu = new SelectMenu(this.$, { position: 'right-bottom', dir: 'ltr', closeMethod: () => this.controller.close() });
165
+ this.selectMenu = new SelectMenu(this.$, {
166
+ position: 'right-bottom',
167
+ dir: 'ltr',
168
+ closeMethod: () => this.controller.close(),
169
+ });
168
170
  this.controller = new Controller(
169
171
  this,
170
172
  this.$,
@@ -263,7 +265,9 @@ class Autocomplete extends PluginField {
263
265
 
264
266
  if (!response) {
265
267
  if (ctx.directData) {
266
- response = ctx.directData.filter((item) => item.key.toLowerCase().startsWith(lowerValue)).slice(0, limit);
268
+ response = ctx.directData
269
+ .filter((item) => item.key.toLowerCase().startsWith(lowerValue))
270
+ .slice(0, limit);
267
271
  } else {
268
272
  const xmlHttp = await ctx.apiManager.asyncCall({ method: 'GET', url: this.#createUrl(ctx, value) });
269
273
  const json = JSON.parse(xmlHttp.responseText);