suneditor 3.1.4 → 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 (216) 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 +350 -72
  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 +46 -4
  57. package/src/core/section/constructor.js +537 -93
  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 +58 -14
  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 +156 -36
  98. package/src/modules/contract/HueSlider.js +27 -4
  99. package/src/modules/contract/Modal.js +50 -10
  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 +33 -6
  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 +2 -1
  106. package/src/plugins/browser/fileBrowser.js +9 -2
  107. package/src/plugins/browser/fileGallery.js +2 -1
  108. package/src/plugins/browser/imageGallery.js +18 -3
  109. package/src/plugins/browser/videoGallery.js +13 -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 +92 -22
  143. package/src/plugins/modal/image/index.js +114 -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 +83 -2
  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/ColorPicker.d.ts +2 -2
  197. package/types/modules/contract/Controller.d.ts +7 -0
  198. package/types/modules/contract/Figure.d.ts +31 -4
  199. package/types/modules/ui/CommandMenu.d.ts +262 -0
  200. package/types/modules/ui/SelectMenu.d.ts +56 -3
  201. package/types/modules/ui/index.d.ts +1 -0
  202. package/types/plugins/browser/audioGallery.d.ts +1 -1
  203. package/types/plugins/browser/fileBrowser.d.ts +1 -1
  204. package/types/plugins/browser/fileGallery.d.ts +1 -1
  205. package/types/plugins/browser/imageGallery.d.ts +1 -1
  206. package/types/plugins/browser/videoGallery.d.ts +1 -1
  207. package/types/plugins/dropdown/align.d.ts +1 -1
  208. package/types/plugins/dropdown/blockStyle.d.ts +3 -1
  209. package/types/plugins/dropdown/table/index.d.ts +4 -1
  210. package/types/plugins/dropdown/table/services/table.clipboard.d.ts +5 -1
  211. package/types/plugins/dropdown/table/services/table.grid.d.ts +10 -2
  212. package/types/plugins/field/autocomplete.d.ts +0 -1
  213. package/types/plugins/field/slashCommand.d.ts +165 -0
  214. package/types/plugins/index.d.ts +3 -0
  215. package/types/plugins/modal/link.d.ts +4 -1
  216. package/types/typedef.d.ts +48 -23
@@ -78,8 +78,15 @@ class Image_ extends PluginModal {
78
78
  * @returns {Element|null} Returns a node if the node is a valid component.
79
79
  */
80
80
  static component(node) {
81
- const compNode = dom.check.isFigure(node) || (/^span$/i.test(node.nodeName) && dom.check.isComponentContainer(node)) ? node.firstElementChild : node;
82
- return /^IMG$/i.test(compNode?.nodeName) ? compNode : dom.check.isAnchor(compNode) && /^IMG$/i.test(compNode?.firstElementChild?.nodeName) ? compNode?.firstElementChild : null;
81
+ const compNode =
82
+ dom.check.isFigure(node) || (/^span$/i.test(node.nodeName) && dom.check.isComponentContainer(node))
83
+ ? node.firstElementChild
84
+ : node;
85
+ return /^IMG$/i.test(compNode?.nodeName)
86
+ ? compNode
87
+ : dom.check.isAnchor(compNode) && /^IMG$/i.test(compNode?.firstElementChild?.nodeName)
88
+ ? compNode?.firstElementChild
89
+ : null;
83
90
  }
84
91
 
85
92
  #resizing;
@@ -108,19 +115,35 @@ class Image_ extends PluginModal {
108
115
  this.pluginOptions = {
109
116
  canResize: pluginOptions.canResize === undefined ? true : pluginOptions.canResize,
110
117
  showHeightInput: pluginOptions.showHeightInput === undefined ? true : !!pluginOptions.showHeightInput,
111
- defaultWidth: !pluginOptions.defaultWidth ? 'auto' : numbers.is(pluginOptions.defaultWidth) ? pluginOptions.defaultWidth + SIZE_UNIT.PIXEL : pluginOptions.defaultWidth,
112
- defaultHeight: !pluginOptions.defaultHeight ? 'auto' : numbers.is(pluginOptions.defaultHeight) ? pluginOptions.defaultHeight + SIZE_UNIT.PIXEL : pluginOptions.defaultHeight,
118
+ defaultWidth: !pluginOptions.defaultWidth
119
+ ? 'auto'
120
+ : numbers.is(pluginOptions.defaultWidth)
121
+ ? pluginOptions.defaultWidth + SIZE_UNIT.PIXEL
122
+ : pluginOptions.defaultWidth,
123
+ defaultHeight: !pluginOptions.defaultHeight
124
+ ? 'auto'
125
+ : numbers.is(pluginOptions.defaultHeight)
126
+ ? pluginOptions.defaultHeight + SIZE_UNIT.PIXEL
127
+ : pluginOptions.defaultHeight,
113
128
  percentageOnlySize: !!pluginOptions.percentageOnlySize,
114
129
  createFileInput: pluginOptions.createFileInput === undefined ? true : pluginOptions.createFileInput,
115
- createUrlInput: pluginOptions.createUrlInput === undefined || !pluginOptions.createFileInput ? true : pluginOptions.createUrlInput,
130
+ createUrlInput:
131
+ pluginOptions.createUrlInput === undefined || !pluginOptions.createFileInput
132
+ ? true
133
+ : pluginOptions.createUrlInput,
116
134
  uploadUrl: typeof pluginOptions.uploadUrl === 'string' ? pluginOptions.uploadUrl : null,
117
135
  uploadHeaders: pluginOptions.uploadHeaders || null,
118
136
  uploadSizeLimit: numbers.get(pluginOptions.uploadSizeLimit, 0),
119
137
  uploadSingleSizeLimit: numbers.get(pluginOptions.uploadSingleSizeLimit, 0),
120
138
  allowMultiple: !!pluginOptions.allowMultiple,
121
- acceptedFormats: typeof pluginOptions.acceptedFormats !== 'string' || pluginOptions.acceptedFormats.trim() === '*' ? DEFAULT_ACCEPTED_FORMATS : pluginOptions.acceptedFormats.trim() || DEFAULT_ACCEPTED_FORMATS,
139
+ acceptedFormats:
140
+ typeof pluginOptions.acceptedFormats !== 'string' || pluginOptions.acceptedFormats.trim() === '*'
141
+ ? DEFAULT_ACCEPTED_FORMATS
142
+ : pluginOptions.acceptedFormats.trim() || DEFAULT_ACCEPTED_FORMATS,
122
143
  useFormatType: pluginOptions.useFormatType ?? true,
123
- defaultFormatType: [FORMAT_TYPE.BLOCK, FORMAT_TYPE.INLINE].includes(pluginOptions.defaultFormatType) ? pluginOptions.defaultFormatType : FORMAT_TYPE.BLOCK,
144
+ defaultFormatType: [FORMAT_TYPE.BLOCK, FORMAT_TYPE.INLINE].includes(pluginOptions.defaultFormatType)
145
+ ? pluginOptions.defaultFormatType
146
+ : FORMAT_TYPE.BLOCK,
124
147
  keepFormatType: pluginOptions.keepFormatType ?? false,
125
148
  insertBehavior: pluginOptions.insertBehavior,
126
149
  };
@@ -181,16 +204,19 @@ class Image_ extends PluginModal {
181
204
 
182
205
  this.as = FORMAT_TYPE.BLOCK;
183
206
  this.#resizing = this.pluginOptions.canResize;
184
- this.#nonResizing = !this.#resizing || !this.pluginOptions.showHeightInput || this.pluginOptions.percentageOnlySize;
207
+ this.#nonResizing =
208
+ !this.#resizing || !this.pluginOptions.showHeightInput || this.pluginOptions.percentageOnlySize;
185
209
 
186
210
  this.sizeService = new ImageSizeService(this, modalEl);
187
211
  this.uploadService = new ImageUploadService(this);
188
212
 
189
213
  // init
190
214
  this.$.eventManager.addEvent(modalEl.tabs, 'click', this.#OpenTab.bind(this));
191
- if (this.imgInputFile) this.$.eventManager.addEvent(modalEl.fileRemoveBtn, 'click', this.#RemoveSelectedFiles.bind(this));
215
+ if (this.imgInputFile)
216
+ this.$.eventManager.addEvent(modalEl.fileRemoveBtn, 'click', this.#RemoveSelectedFiles.bind(this));
192
217
  if (this.imgUrlFile) this.$.eventManager.addEvent(this.imgUrlFile, 'input', this.#OnLinkPreview.bind(this));
193
- if (this.imgInputFile && this.imgUrlFile) this.$.eventManager.addEvent(this.imgInputFile, 'change', this.#OnfileInputChange.bind(this));
218
+ if (this.imgInputFile && this.imgUrlFile)
219
+ this.$.eventManager.addEvent(this.imgInputFile, 'change', this.#OnfileInputChange.bind(this));
194
220
 
195
221
  const galleryButton = modalEl.galleryButton;
196
222
  if (galleryButton) this.$.eventManager.addEvent(galleryButton, 'click', this.#OpenGallery.bind(this));
@@ -257,7 +283,8 @@ class Image_ extends PluginModal {
257
283
  modalOn(isUpdate) {
258
284
  if (!isUpdate) {
259
285
  this.sizeService.on();
260
- if (this.imgInputFile && this.pluginOptions.allowMultiple) this.imgInputFile.setAttribute('multiple', 'multiple');
286
+ if (this.imgInputFile && this.pluginOptions.allowMultiple)
287
+ this.imgInputFile.setAttribute('multiple', 'multiple');
261
288
  } else {
262
289
  if (this.imgInputFile && this.pluginOptions.allowMultiple) this.imgInputFile.removeAttribute('multiple');
263
290
  }
@@ -270,7 +297,9 @@ class Image_ extends PluginModal {
270
297
  * @type {SunEditor.Hook.Modal.Action}
271
298
  */
272
299
  async modalAction() {
273
- this.#align = /** @type {HTMLInputElement} */ (this.modal.form.querySelector('input[name="suneditor_image_radio"]:checked')).value;
300
+ this.#align = /** @type {HTMLInputElement} */ (
301
+ this.modal.form.querySelector('input[name="suneditor_image_radio"]:checked')
302
+ ).value;
274
303
 
275
304
  if (this.modal.isUpdate) {
276
305
  this.#fixTagStructure();
@@ -300,7 +329,9 @@ class Image_ extends PluginModal {
300
329
  }
301
330
 
302
331
  this.altText.value = '';
303
- /** @type {HTMLInputElement} */ (this.modal.form.querySelector('input[name="suneditor_image_radio"][value="none"]')).checked = true;
332
+ /** @type {HTMLInputElement} */ (
333
+ this.modal.form.querySelector('input[name="suneditor_image_radio"][value="none"]')
334
+ ).checked = true;
304
335
  this.captionCheckEl.checked = false;
305
336
  this.#element = null;
306
337
  this.#OpenTab('init');
@@ -308,7 +339,10 @@ class Image_ extends PluginModal {
308
339
  this.sizeService.init();
309
340
 
310
341
  if (this.pluginOptions.useFormatType) {
311
- this.#activeAsInline((this.pluginOptions.keepFormatType ? this.as : this.pluginOptions.defaultFormatType) === FORMAT_TYPE.INLINE);
342
+ this.#activeAsInline(
343
+ (this.pluginOptions.keepFormatType ? this.as : this.pluginOptions.defaultFormatType) ===
344
+ FORMAT_TYPE.INLINE,
345
+ );
312
346
  }
313
347
 
314
348
  this.anchor.init();
@@ -340,7 +374,13 @@ class Image_ extends PluginModal {
340
374
  const focusEl = container.previousElementSibling || container.nextElementSibling;
341
375
  const emptyDiv = container.parentNode;
342
376
 
343
- const message = await this.$.eventManager.triggerEvent('onImageDeleteBefore', { element: targetEl, container, align: this.#align, alt: this.altText.value, url: this.#linkValue });
377
+ const message = await this.$.eventManager.triggerEvent('onImageDeleteBefore', {
378
+ element: targetEl,
379
+ container,
380
+ align: this.#align,
381
+ alt: this.altText.value,
382
+ url: this.#linkValue,
383
+ });
344
384
  if (message === false) return;
345
385
 
346
386
  dom.utils.removeItem(container);
@@ -378,7 +418,8 @@ class Image_ extends PluginModal {
378
418
 
379
419
  s = f.size;
380
420
  if (singleSizeLimit > 0 && s > singleSizeLimit) {
381
- const err = '[SUNEDITOR.imageUpload.fail] Size of uploadable single file: ' + singleSizeLimit / 1000 + 'KB';
421
+ const err =
422
+ '[SUNEDITOR.imageUpload.fail] Size of uploadable single file: ' + singleSizeLimit / 1000 + 'KB';
382
423
  const message = await this.$.eventManager.triggerEvent('onImageUploadError', {
383
424
  error: err,
384
425
  limitSize: singleSizeLimit,
@@ -494,7 +535,13 @@ class Image_ extends PluginModal {
494
535
  this.#element = oImg;
495
536
  this.#cover = cover;
496
537
  this.#container = container;
497
- this.figure.open(oImg, { nonResizing: this.#nonResizing, nonSizeInfo: false, nonBorder: false, figureTarget: false, infoOnly: true });
538
+ this.figure.open(oImg, {
539
+ nonResizing: this.#nonResizing,
540
+ nonSizeInfo: false,
541
+ nonBorder: false,
542
+ figureTarget: false,
543
+ infoOnly: true,
544
+ });
498
545
 
499
546
  // set size
500
547
  this.sizeService.applySize(width, height);
@@ -532,7 +579,13 @@ class Image_ extends PluginModal {
532
579
 
533
580
  this.#element = oImg;
534
581
  this.#container = container;
535
- this.figure.open(oImg, { nonResizing: this.#nonResizing, nonSizeInfo: false, nonBorder: false, figureTarget: false, infoOnly: true });
582
+ this.figure.open(oImg, {
583
+ nonResizing: this.#nonResizing,
584
+ nonSizeInfo: false,
585
+ nonBorder: false,
586
+ figureTarget: false,
587
+ infoOnly: true,
588
+ });
536
589
 
537
590
  // set size
538
591
  this.sizeService.applySize(width, height);
@@ -554,7 +607,13 @@ class Image_ extends PluginModal {
554
607
  */
555
608
  #ready(target, infoOnly = false) {
556
609
  if (!target) return;
557
- const figureInfo = this.figure.open(target, { nonResizing: this.#nonResizing, nonSizeInfo: false, nonBorder: false, figureTarget: false, infoOnly });
610
+ const figureInfo = this.figure.open(target, {
611
+ nonResizing: this.#nonResizing,
612
+ nonSizeInfo: false,
613
+ nonBorder: false,
614
+ figureTarget: false,
615
+ infoOnly,
616
+ });
558
617
  this.anchor.set(dom.check.isAnchor(target.parentNode) ? target.parentNode : null);
559
618
 
560
619
  this.#linkElement = this.anchor.currentTarget;
@@ -565,13 +624,18 @@ class Image_ extends PluginModal {
565
624
  this.#align = figureInfo.align;
566
625
  target.style.float = '';
567
626
 
568
- this.sizeService.setOriginSize(String(figureInfo.originWidth || figureInfo.w || ''), String(figureInfo.originHeight || figureInfo.h || ''));
627
+ this.sizeService.setOriginSize(
628
+ String(figureInfo.originWidth || figureInfo.w || ''),
629
+ String(figureInfo.originHeight || figureInfo.h || ''),
630
+ );
569
631
  this.altText.value = this.#element.alt;
570
632
 
571
633
  if (this.imgUrlFile) this.#linkValue = this.previewSrc.textContent = this.imgUrlFile.value = this.#element.src;
572
634
 
573
635
  /** @type {HTMLInputElement} */
574
- const activeAlign = this.modal.form.querySelector('input[name="suneditor_image_radio"][value="' + this.#align + '"]') || this.modal.form.querySelector('input[name="suneditor_image_radio"][value="none"]');
636
+ const activeAlign =
637
+ this.modal.form.querySelector('input[name="suneditor_image_radio"][value="' + this.#align + '"]') ||
638
+ this.modal.form.querySelector('input[name="suneditor_image_radio"][value="none"]');
575
639
  activeAlign.checked = true;
576
640
  this.captionCheckEl.checked = !!this.#caption;
577
641
 
@@ -743,13 +807,22 @@ class Image_ extends PluginModal {
743
807
  isNewContainer = true;
744
808
  imageEl = this.#element.cloneNode(true);
745
809
  const figureInfo =
746
- this.pluginOptions.useFormatType && width !== 'auto' && (/^span$/i.test(this.#element.parentElement?.nodeName) || this.$.format.isLine(this.#element.parentElement))
810
+ this.pluginOptions.useFormatType &&
811
+ width !== 'auto' &&
812
+ (/^span$/i.test(this.#element.parentElement?.nodeName) ||
813
+ this.$.format.isLine(this.#element.parentElement))
747
814
  ? Figure.CreateInlineContainer(imageEl, 'se-image-container')
748
815
  : Figure.CreateContainer(imageEl, 'se-image-container');
749
816
  cover = figureInfo.cover;
750
817
  container = figureInfo.container;
751
818
  inlineCover = figureInfo.inlineCover;
752
- this.figure.open(imageEl, { nonResizing: true, nonSizeInfo: false, nonBorder: false, figureTarget: false, infoOnly: true });
819
+ this.figure.open(imageEl, {
820
+ nonResizing: true,
821
+ nonSizeInfo: false,
822
+ nonBorder: false,
823
+ figureTarget: false,
824
+ infoOnly: true,
825
+ });
753
826
  }
754
827
 
755
828
  // alt
@@ -774,7 +847,10 @@ class Image_ extends PluginModal {
774
847
 
775
848
  // link
776
849
  let isNewAnchor = null;
777
- const anchor = this.anchor.create(true, dom.check.isAnchor(this.#element.parentElement) ? this.#element.parentElement.href : null);
850
+ const anchor = this.anchor.create(
851
+ true,
852
+ dom.check.isAnchor(this.#element.parentElement) ? this.#element.parentElement.href : null,
853
+ );
778
854
  if (anchor) {
779
855
  if (this.#linkElement !== anchor || (isNewContainer && !container.contains(anchor))) {
780
856
  this.#linkElement = anchor.cloneNode(false);
@@ -854,7 +930,8 @@ class Image_ extends PluginModal {
854
930
  */
855
931
  #OpenTab(e) {
856
932
  const modalForm = this.modal.form;
857
- const targetElement = typeof e === 'string' ? modalForm.querySelector('._se_tab_link') : dom.query.getEventTarget(e);
933
+ const targetElement =
934
+ typeof e === 'string' ? modalForm.querySelector('._se_tab_link') : dom.query.getEventTarget(e);
858
935
 
859
936
  if (!/^BUTTON$/i.test(targetElement.tagName)) {
860
937
  return false;
@@ -865,7 +942,9 @@ class Image_ extends PluginModal {
865
942
  let i;
866
943
 
867
944
  // Get all elements with class="tabcontent" and hide them
868
- const tabContent = /** @type {HTMLCollectionOf<HTMLElement>}*/ (modalForm.getElementsByClassName('_se_tab_content'));
945
+ const tabContent = /** @type {HTMLCollectionOf<HTMLElement>}*/ (
946
+ modalForm.getElementsByClassName('_se_tab_content')
947
+ );
869
948
  for (i = 0; i < tabContent.length; i++) {
870
949
  tabContent[i].style.display = 'none';
871
950
  }
@@ -937,7 +1016,10 @@ class Image_ extends PluginModal {
937
1016
 
938
1017
  #SetUrlInput(target) {
939
1018
  this.altText.value = target.getAttribute('data-value') || target.alt;
940
- this.#linkValue = this.previewSrc.textContent = this.imgUrlFile.value = target.getAttribute('data-command') || target.src;
1019
+ this.#linkValue =
1020
+ this.previewSrc.textContent =
1021
+ this.imgUrlFile.value =
1022
+ target.getAttribute('data-command') || target.src;
941
1023
  this.imgUrlFile.focus();
942
1024
  }
943
1025
 
@@ -949,7 +1031,11 @@ class Image_ extends PluginModal {
949
1031
  if (oImg.offsetWidth === 0) this.sizeService.applySize(_svgDefaultSize, '');
950
1032
 
951
1033
  if (this.state.produceIndex === 0) {
952
- this.$.component.applyInsertBehavior(container, null, this.pluginOptions.insertBehavior || this.$.options.get('componentInsertBehavior'));
1034
+ this.$.component.applyInsertBehavior(
1035
+ container,
1036
+ null,
1037
+ this.pluginOptions.insertBehavior || this.$.options.get('componentInsertBehavior'),
1038
+ );
953
1039
 
954
1040
  this.$.ui._iframeAutoHeight(this.$.frameContext);
955
1041
  this.$.history.push(false);
@@ -166,7 +166,12 @@ export class ImageSizeService {
166
166
  if (xy === 'x' && this.#state.onlyPercentage && Number(target.value) > 100) {
167
167
  target.value = '100';
168
168
  } else if (this.#proportion.checked) {
169
- const ratioSize = Figure.CalcRatio(this.#inputX.value, this.#inputY.value, this.#state.sizeUnit, this.#ratio);
169
+ const ratioSize = Figure.CalcRatio(
170
+ this.#inputX.value,
171
+ this.#inputY.value,
172
+ this.#state.sizeUnit,
173
+ this.#ratio,
174
+ );
170
175
  if (xy === 'x') {
171
176
  this.#inputY.value = String(ratioSize.h);
172
177
  } else {
@@ -179,7 +184,9 @@ export class ImageSizeService {
179
184
  * @description Updates the ratio based on current input values.
180
185
  */
181
186
  #OnChangeRatio() {
182
- this.#ratio = this.#proportion.checked ? Figure.GetRatio(this.#inputX.value, this.#inputY.value, this.#state.sizeUnit) : { w: 0, h: 0 };
187
+ this.#ratio = this.#proportion.checked
188
+ ? Figure.GetRatio(this.#inputX.value, this.#inputY.value, this.#state.sizeUnit)
189
+ : { w: 0, h: 0 };
183
190
  }
184
191
 
185
192
  /**
@@ -40,7 +40,13 @@ export class ImageUploadService {
40
40
  // server upload
41
41
  const imageUploadUrl = this.#pluginOptions.uploadUrl;
42
42
  if (typeof imageUploadUrl === 'string' && imageUploadUrl.length > 0) {
43
- this.#main.fileManager.upload(imageUploadUrl, this.#pluginOptions.uploadHeaders, info.files, this.#UploadCallBack.bind(this, info), this.#error.bind(this));
43
+ this.#main.fileManager.upload(
44
+ imageUploadUrl,
45
+ this.#pluginOptions.uploadHeaders,
46
+ info.files,
47
+ this.#UploadCallBack.bind(this, info),
48
+ this.#error.bind(this),
49
+ );
44
50
  } else {
45
51
  this.#setBase64(info);
46
52
  }
@@ -55,7 +61,17 @@ export class ImageUploadService {
55
61
  const infoUrl = info.url;
56
62
 
57
63
  if (this.#main.modal.isUpdate) this.#updateSrc(infoUrl, info.element, info.files);
58
- else this.#produce(infoUrl, info.anchor, info.inputWidth, info.inputHeight, info.align, info.files, info.alt, true);
64
+ else
65
+ this.#produce(
66
+ infoUrl,
67
+ info.anchor,
68
+ info.inputWidth,
69
+ info.inputHeight,
70
+ info.align,
71
+ info.files,
72
+ info.alt,
73
+ true,
74
+ );
59
75
  }
60
76
 
61
77
  /**
@@ -107,7 +123,16 @@ export class ImageUploadService {
107
123
  this.#updateSrc(fileList[i].url, info.element, file);
108
124
  break;
109
125
  } else {
110
- this.#produce(fileList[i].url, info.anchor, info.inputWidth, info.inputHeight, info.align, file, info.alt, i === len - 1);
126
+ this.#produce(
127
+ fileList[i].url,
128
+ info.anchor,
129
+ info.inputWidth,
130
+ info.inputHeight,
131
+ info.align,
132
+ file,
133
+ info.alt,
134
+ i === len - 1,
135
+ );
111
136
  }
112
137
  }
113
138
  }
@@ -179,7 +204,16 @@ export class ImageUploadService {
179
204
  if (update) {
180
205
  this.#updateSrc(filesStack[i].result, updateElement, filesStack[i].file);
181
206
  } else {
182
- this.#produce(filesStack[i].result, anchor, width, height, align, filesStack[i].file, alt, i === len - 1);
207
+ this.#produce(
208
+ filesStack[i].result,
209
+ anchor,
210
+ width,
211
+ height,
212
+ align,
213
+ filesStack[i].file,
214
+ alt,
215
+ i === len - 1,
216
+ );
183
217
  }
184
218
  }
185
219
  }
@@ -69,7 +69,8 @@ class Link extends PluginModal {
69
69
  uploadHeaders: pluginOptions.uploadHeaders || null,
70
70
  uploadSizeLimit: numbers.get(pluginOptions.uploadSizeLimit, 0),
71
71
  uploadSingleSizeLimit: numbers.get(pluginOptions.uploadSingleSizeLimit, 0),
72
- acceptedFormats: typeof pluginOptions.acceptedFormats === 'string' ? pluginOptions.acceptedFormats.trim() : null,
72
+ acceptedFormats:
73
+ typeof pluginOptions.acceptedFormats === 'string' ? pluginOptions.acceptedFormats.trim() : null,
73
74
  enableFileUpload: !!uploadUrl,
74
75
  };
75
76
 
@@ -135,7 +136,13 @@ class Link extends PluginModal {
135
136
  if (!this.isUpdateState) {
136
137
  const selectedFormats = this.$.format.getLines();
137
138
  if (selectedFormats.length > 1) {
138
- if (!this.$.html.insertNode(dom.utils.createElement(selectedFormats[0].nodeName, null, oA), { afterNode: null, skipCharCount: false })) return true;
139
+ if (
140
+ !this.$.html.insertNode(dom.utils.createElement(selectedFormats[0].nodeName, null, oA), {
141
+ afterNode: null,
142
+ skipCharCount: false,
143
+ })
144
+ )
145
+ return true;
139
146
  } else {
140
147
  if (!this.$.html.insertNode(oA, { afterNode: null, skipCharCount: false })) return true;
141
148
  }
@@ -157,7 +157,11 @@ class Math_ extends PluginModal {
157
157
  const value = getValue(element);
158
158
  if (!value) return;
159
159
 
160
- const domParser = _d.createRange().createContextualFragment(this.#renderer(converter.entityToHTML(this.#escapeBackslashes(value, true))));
160
+ const domParser = _d
161
+ .createRange()
162
+ .createContextualFragment(
163
+ this.#renderer(converter.entityToHTML(this.#escapeBackslashes(value, true))),
164
+ );
161
165
  element.innerHTML = domParser.querySelector('.se-math, .katex').innerHTML;
162
166
  element.setAttribute('contenteditable', 'false');
163
167
  dom.utils.addClass(element, 'se-component|se-inline-component|se-disable-pointer|se-math');
@@ -512,7 +516,11 @@ function CreateHTML_modal(inst) {
512
516
  </form>`;
513
517
 
514
518
  inst.defaultFontSize = defaultFontSize;
515
- return dom.utils.createElement('DIV', { class: 'se-modal-content se-modal-responsive', style: `max-width: ${maxWidth}; max-height: ${maxHeight};` }, html);
519
+ return dom.utils.createElement(
520
+ 'DIV',
521
+ { class: 'se-modal-content se-modal-responsive', style: `max-width: ${maxWidth}; max-height: ${maxHeight};` },
522
+ html,
523
+ );
516
524
  }
517
525
 
518
526
  /**