suneditor 3.0.0-beta.3 → 3.0.0-beta.30

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 (241) hide show
  1. package/CONTRIBUTING.md +8 -8
  2. package/README.md +44 -49
  3. package/dist/suneditor.min.css +1 -1
  4. package/dist/suneditor.min.js +1 -1
  5. package/package.json +95 -53
  6. package/src/assets/design/color.css +2 -2
  7. package/src/assets/design/size.css +2 -0
  8. package/src/assets/icons/defaultIcons.js +16 -1
  9. package/src/assets/suneditor-contents.css +9 -8
  10. package/src/assets/suneditor.css +29 -26
  11. package/src/core/{section → base}/actives.js +20 -12
  12. package/src/core/base/history.js +4 -4
  13. package/src/core/class/char.js +10 -10
  14. package/src/core/class/component.js +146 -57
  15. package/src/core/class/format.js +94 -2458
  16. package/src/core/class/html.js +187 -129
  17. package/src/core/class/inline.js +1853 -0
  18. package/src/core/class/listFormat.js +582 -0
  19. package/src/core/class/menu.js +14 -3
  20. package/src/core/class/nodeTransform.js +9 -14
  21. package/src/core/class/offset.js +162 -197
  22. package/src/core/class/selection.js +137 -34
  23. package/src/core/class/toolbar.js +73 -52
  24. package/src/core/class/ui.js +11 -11
  25. package/src/core/class/viewer.js +56 -55
  26. package/src/core/config/context.js +122 -0
  27. package/src/core/config/frameContext.js +204 -0
  28. package/src/core/config/options.js +639 -0
  29. package/src/core/editor.js +181 -108
  30. package/src/core/event/actions/index.js +229 -0
  31. package/src/core/event/effects/common.registry.js +60 -0
  32. package/src/core/event/effects/keydown.registry.js +551 -0
  33. package/src/core/event/effects/ruleHelpers.js +145 -0
  34. package/src/core/{base → event}/eventManager.js +119 -201
  35. package/src/core/event/executor.js +21 -0
  36. package/src/core/{base/eventHandlers → event/handlers}/handler_toolbar.js +4 -4
  37. package/src/core/{base/eventHandlers → event/handlers}/handler_ww_dragDrop.js +2 -2
  38. package/src/core/event/handlers/handler_ww_input.js +77 -0
  39. package/src/core/event/handlers/handler_ww_key.js +228 -0
  40. package/src/core/{base/eventHandlers → event/handlers}/handler_ww_mouse.js +3 -3
  41. package/src/core/event/ports.js +211 -0
  42. package/src/core/event/reducers/keydown.reducer.js +89 -0
  43. package/src/core/event/rules/keydown.rule.arrow.js +54 -0
  44. package/src/core/event/rules/keydown.rule.backspace.js +202 -0
  45. package/src/core/event/rules/keydown.rule.delete.js +126 -0
  46. package/src/core/event/rules/keydown.rule.enter.js +144 -0
  47. package/src/core/event/rules/keydown.rule.tab.js +29 -0
  48. package/src/core/section/constructor.js +79 -388
  49. package/src/core/section/documentType.js +47 -26
  50. package/src/core/util/instanceCheck.js +59 -0
  51. package/src/editorInjector/_classes.js +4 -0
  52. package/src/editorInjector/_core.js +17 -7
  53. package/src/editorInjector/index.js +10 -2
  54. package/src/events.js +6 -0
  55. package/src/helper/clipboard.js +24 -10
  56. package/src/helper/converter.js +17 -12
  57. package/src/helper/dom/domCheck.js +22 -3
  58. package/src/helper/dom/domQuery.js +91 -45
  59. package/src/helper/dom/domUtils.js +93 -19
  60. package/src/helper/dom/index.js +4 -0
  61. package/src/helper/env.js +11 -7
  62. package/src/helper/keyCodeMap.js +4 -3
  63. package/src/langs/ckb.js +1 -1
  64. package/src/langs/cs.js +1 -1
  65. package/src/langs/da.js +1 -1
  66. package/src/langs/de.js +1 -1
  67. package/src/langs/en.js +1 -1
  68. package/src/langs/es.js +1 -1
  69. package/src/langs/fa.js +1 -1
  70. package/src/langs/fr.js +1 -1
  71. package/src/langs/he.js +1 -1
  72. package/src/langs/hu.js +1 -1
  73. package/src/langs/it.js +1 -1
  74. package/src/langs/ja.js +1 -1
  75. package/src/langs/km.js +1 -1
  76. package/src/langs/ko.js +1 -1
  77. package/src/langs/lv.js +1 -1
  78. package/src/langs/nl.js +1 -1
  79. package/src/langs/pl.js +1 -1
  80. package/src/langs/pt_br.js +10 -10
  81. package/src/langs/ro.js +1 -1
  82. package/src/langs/ru.js +1 -1
  83. package/src/langs/se.js +1 -1
  84. package/src/langs/tr.js +1 -1
  85. package/src/langs/uk.js +1 -1
  86. package/src/langs/ur.js +1 -1
  87. package/src/langs/zh_cn.js +1 -1
  88. package/src/modules/ApiManager.js +25 -18
  89. package/src/modules/Browser.js +52 -61
  90. package/src/modules/ColorPicker.js +37 -38
  91. package/src/modules/Controller.js +85 -79
  92. package/src/modules/Figure.js +275 -187
  93. package/src/modules/FileManager.js +86 -92
  94. package/src/modules/HueSlider.js +67 -35
  95. package/src/modules/Modal.js +84 -77
  96. package/src/modules/ModalAnchorEditor.js +62 -79
  97. package/src/modules/SelectMenu.js +89 -86
  98. package/src/plugins/browser/audioGallery.js +9 -5
  99. package/src/plugins/browser/fileBrowser.js +10 -6
  100. package/src/plugins/browser/fileGallery.js +9 -5
  101. package/src/plugins/browser/imageGallery.js +9 -5
  102. package/src/plugins/browser/videoGallery.js +11 -6
  103. package/src/plugins/command/blockquote.js +1 -0
  104. package/src/plugins/command/exportPDF.js +11 -8
  105. package/src/plugins/command/fileUpload.js +41 -29
  106. package/src/plugins/command/list_bulleted.js +2 -1
  107. package/src/plugins/command/list_numbered.js +2 -1
  108. package/src/plugins/dropdown/align.js +8 -2
  109. package/src/plugins/dropdown/backgroundColor.js +19 -11
  110. package/src/plugins/dropdown/font.js +15 -9
  111. package/src/plugins/dropdown/fontColor.js +19 -11
  112. package/src/plugins/dropdown/formatBlock.js +7 -2
  113. package/src/plugins/dropdown/hr.js +7 -3
  114. package/src/plugins/dropdown/layout.js +6 -2
  115. package/src/plugins/dropdown/lineHeight.js +8 -3
  116. package/src/plugins/dropdown/list.js +2 -1
  117. package/src/plugins/dropdown/paragraphStyle.js +15 -11
  118. package/src/plugins/dropdown/{table.js → table/index.js} +514 -362
  119. package/src/plugins/dropdown/template.js +6 -2
  120. package/src/plugins/dropdown/textStyle.js +7 -3
  121. package/src/plugins/field/mention.js +33 -27
  122. package/src/plugins/input/fontSize.js +44 -37
  123. package/src/plugins/input/pageNavigator.js +3 -2
  124. package/src/plugins/modal/audio.js +90 -85
  125. package/src/plugins/modal/drawing.js +58 -66
  126. package/src/plugins/modal/embed.js +193 -180
  127. package/src/plugins/modal/image.js +441 -439
  128. package/src/plugins/modal/link.js +31 -8
  129. package/src/plugins/modal/math.js +23 -22
  130. package/src/plugins/modal/video.js +233 -230
  131. package/src/plugins/popup/anchor.js +24 -18
  132. package/src/suneditor.js +69 -24
  133. package/src/typedef.js +42 -19
  134. package/types/assets/icons/defaultIcons.d.ts +8 -0
  135. package/types/core/class/char.d.ts +1 -1
  136. package/types/core/class/component.d.ts +29 -7
  137. package/types/core/class/format.d.ts +4 -354
  138. package/types/core/class/html.d.ts +13 -4
  139. package/types/core/class/inline.d.ts +263 -0
  140. package/types/core/class/listFormat.d.ts +135 -0
  141. package/types/core/class/menu.d.ts +10 -2
  142. package/types/core/class/offset.d.ts +24 -26
  143. package/types/core/class/selection.d.ts +2 -0
  144. package/types/core/class/toolbar.d.ts +24 -11
  145. package/types/core/class/ui.d.ts +1 -1
  146. package/types/core/class/viewer.d.ts +1 -1
  147. package/types/core/config/context.d.ts +157 -0
  148. package/types/core/config/frameContext.d.ts +367 -0
  149. package/types/core/config/options.d.ts +1119 -0
  150. package/types/core/editor.d.ts +101 -66
  151. package/types/core/event/actions/index.d.ts +47 -0
  152. package/types/core/event/effects/common.registry.d.ts +50 -0
  153. package/types/core/event/effects/keydown.registry.d.ts +73 -0
  154. package/types/core/event/effects/ruleHelpers.d.ts +31 -0
  155. package/types/core/{base → event}/eventManager.d.ts +15 -46
  156. package/types/core/event/executor.d.ts +6 -0
  157. package/types/core/event/handlers/handler_ww_input.d.ts +41 -0
  158. package/types/core/{base/eventHandlers/handler_ww_key_input.d.ts → event/handlers/handler_ww_key.d.ts} +4 -6
  159. package/types/core/event/ports.d.ts +255 -0
  160. package/types/core/event/reducers/keydown.reducer.d.ts +75 -0
  161. package/types/core/event/rules/keydown.rule.arrow.d.ts +8 -0
  162. package/types/core/event/rules/keydown.rule.backspace.d.ts +9 -0
  163. package/types/core/event/rules/keydown.rule.delete.d.ts +9 -0
  164. package/types/core/event/rules/keydown.rule.enter.d.ts +9 -0
  165. package/types/core/event/rules/keydown.rule.tab.d.ts +9 -0
  166. package/types/core/section/constructor.d.ts +101 -631
  167. package/types/core/section/documentType.d.ts +14 -4
  168. package/types/core/util/instanceCheck.d.ts +50 -0
  169. package/types/editorInjector/_classes.d.ts +4 -0
  170. package/types/editorInjector/_core.d.ts +17 -7
  171. package/types/editorInjector/index.d.ts +10 -2
  172. package/types/events.d.ts +1 -0
  173. package/types/helper/clipboard.d.ts +2 -2
  174. package/types/helper/converter.d.ts +6 -9
  175. package/types/helper/dom/domCheck.d.ts +7 -0
  176. package/types/helper/dom/domQuery.d.ts +19 -8
  177. package/types/helper/dom/domUtils.d.ts +24 -2
  178. package/types/helper/dom/index.d.ts +86 -1
  179. package/types/helper/env.d.ts +6 -1
  180. package/types/helper/index.d.ts +7 -1
  181. package/types/helper/keyCodeMap.d.ts +3 -3
  182. package/types/index.d.ts +23 -117
  183. package/types/langs/index.d.ts +2 -2
  184. package/types/modules/ApiManager.d.ts +1 -8
  185. package/types/modules/Browser.d.ts +4 -62
  186. package/types/modules/ColorPicker.d.ts +4 -21
  187. package/types/modules/Controller.d.ts +8 -64
  188. package/types/modules/Figure.d.ts +54 -50
  189. package/types/modules/FileManager.d.ts +1 -13
  190. package/types/modules/HueSlider.d.ts +13 -3
  191. package/types/modules/Modal.d.ts +0 -43
  192. package/types/modules/ModalAnchorEditor.d.ts +0 -73
  193. package/types/modules/SelectMenu.d.ts +0 -85
  194. package/types/modules/index.d.ts +3 -3
  195. package/types/plugins/browser/audioGallery.d.ts +29 -18
  196. package/types/plugins/browser/fileBrowser.d.ts +38 -27
  197. package/types/plugins/browser/fileGallery.d.ts +29 -18
  198. package/types/plugins/browser/imageGallery.d.ts +24 -16
  199. package/types/plugins/browser/videoGallery.d.ts +29 -18
  200. package/types/plugins/command/blockquote.d.ts +1 -0
  201. package/types/plugins/command/exportPDF.d.ts +18 -18
  202. package/types/plugins/command/fileUpload.d.ts +65 -45
  203. package/types/plugins/command/list_bulleted.d.ts +1 -0
  204. package/types/plugins/command/list_numbered.d.ts +1 -0
  205. package/types/plugins/dropdown/align.d.ts +13 -8
  206. package/types/plugins/dropdown/backgroundColor.d.ts +30 -19
  207. package/types/plugins/dropdown/font.d.ts +13 -12
  208. package/types/plugins/dropdown/fontColor.d.ts +30 -19
  209. package/types/plugins/dropdown/formatBlock.d.ts +13 -8
  210. package/types/plugins/dropdown/hr.d.ts +15 -11
  211. package/types/plugins/dropdown/layout.d.ts +15 -11
  212. package/types/plugins/dropdown/lineHeight.d.ts +16 -11
  213. package/types/plugins/dropdown/list.d.ts +1 -0
  214. package/types/plugins/dropdown/paragraphStyle.d.ts +31 -27
  215. package/types/plugins/dropdown/table/index.d.ts +582 -0
  216. package/types/plugins/dropdown/table.d.ts +41 -86
  217. package/types/plugins/dropdown/template.d.ts +15 -11
  218. package/types/plugins/dropdown/textStyle.d.ts +19 -11
  219. package/types/plugins/field/mention.d.ts +58 -56
  220. package/types/plugins/index.d.ts +38 -38
  221. package/types/plugins/input/fontSize.d.ts +46 -50
  222. package/types/plugins/modal/audio.d.ts +26 -56
  223. package/types/plugins/modal/drawing.d.ts +0 -85
  224. package/types/plugins/modal/embed.d.ts +15 -79
  225. package/types/plugins/modal/image.d.ts +24 -136
  226. package/types/plugins/modal/link.d.ts +34 -15
  227. package/types/plugins/modal/math.d.ts +0 -16
  228. package/types/plugins/modal/video.d.ts +17 -86
  229. package/types/plugins/popup/anchor.d.ts +1 -8
  230. package/types/suneditor.d.ts +70 -19
  231. package/types/typedef.d.ts +60 -46
  232. package/src/core/base/eventHandlers/handler_ww_key_input.js +0 -1200
  233. package/src/core/section/context.js +0 -102
  234. package/types/core/section/context.d.ts +0 -45
  235. package/types/langs/_Lang.d.ts +0 -194
  236. /package/src/core/{base/eventHandlers → event/handlers}/handler_ww_clipboard.js +0 -0
  237. /package/types/core/{section → base}/actives.d.ts +0 -0
  238. /package/types/core/{base/eventHandlers → event/handlers}/handler_toolbar.d.ts +0 -0
  239. /package/types/core/{base/eventHandlers → event/handlers}/handler_ww_clipboard.d.ts +0 -0
  240. /package/types/core/{base/eventHandlers → event/handlers}/handler_ww_dragDrop.d.ts +0 -0
  241. /package/types/core/{base/eventHandlers → event/handlers}/handler_ww_mouse.d.ts +0 -0
@@ -2,7 +2,7 @@ import EditorInjector from '../../editorInjector';
2
2
  import { Modal } from '../../modules';
3
3
  import { dom, env } from '../../helper';
4
4
 
5
- const { _w, isMobile } = env;
5
+ const { _w } = env;
6
6
 
7
7
  /**
8
8
  * @typedef {Object} DrawingPluginOptions
@@ -34,6 +34,9 @@ class Drawing extends EditorInjector {
34
34
  static type = 'modal';
35
35
  static className = '';
36
36
 
37
+ #events;
38
+ #eventsRegister;
39
+
37
40
  /**
38
41
  * @constructor
39
42
  * @param {__se__EditorCore} editor - The root editor instance
@@ -96,27 +99,25 @@ class Drawing extends EditorInjector {
96
99
  this.points = [];
97
100
  this.paths = [];
98
101
  this.resizeObserver = null;
99
- this.__events = {
100
- mousedown: isMobile ? this.#OnCanvasTouchStart.bind(this) : this.#OnCanvasMouseDown.bind(this),
101
- mousemove: isMobile ? this.#OnCanvasTouchMove.bind(this) : this.#OnCanvasMouseMove.bind(this),
102
+
103
+ this.#events = {
104
+ touchstart: this.#OnCanvasTouchStart.bind(this),
105
+ touchmove: this.#OnCanvasTouchMove.bind(this),
106
+ mousedown: this.#OnCanvasMouseDown.bind(this),
107
+ mousemove: this.#OnCanvasMouseMove.bind(this),
102
108
  mouseup: this.#OnCanvasMouseUp.bind(this),
103
109
  mouseleave: this.#OnCanvasMouseLeave.bind(this),
104
110
  mouseenter: this.#OnCanvasMouseEnter.bind(this)
105
111
  };
106
- this.__eventsRegister = {
112
+ this.#eventsRegister = {
113
+ touchstart: null,
114
+ touchmove: null,
107
115
  mousedown: null,
108
116
  mousemove: null,
109
117
  mouseup: null,
110
118
  mouseleave: null,
111
119
  mouseenter: null
112
120
  };
113
- this.__eventNameMap = {
114
- mousedown: isMobile ? 'touchstart' : 'mousedown',
115
- mousemove: isMobile ? 'touchmove' : 'mousemove',
116
- mouseup: isMobile ? 'touchend' : 'mouseup',
117
- mouseleave: 'mouseleave',
118
- mouseenter: 'mouseenter'
119
- };
120
121
 
121
122
  // init
122
123
  this.eventManager.addEvent(modalEl.querySelector('[data-command="remove"]'), 'click', this.#OnRemove.bind(this));
@@ -128,10 +129,10 @@ class Drawing extends EditorInjector {
128
129
  */
129
130
  open() {
130
131
  if (this.pluginOptions.useFormatType) {
131
- this._activeAsInline((this.pluginOptions.keepFormatType ? this.as : this.pluginOptions.defaultFormatType) === 'inline');
132
+ this.#activeAsInline((this.pluginOptions.keepFormatType ? this.as : this.pluginOptions.defaultFormatType) === 'inline');
132
133
  }
133
134
  this.modal.open();
134
- this._initDrawing();
135
+ this.#initDrawing();
135
136
  }
136
137
 
137
138
  /**
@@ -139,7 +140,7 @@ class Drawing extends EditorInjector {
139
140
  * @description Executes the method that is called when a plugin's "modal" is closed.
140
141
  */
141
142
  off() {
142
- this._destroyDrawing();
143
+ this.#destroyDrawing();
143
144
  }
144
145
 
145
146
  /**
@@ -149,7 +150,7 @@ class Drawing extends EditorInjector {
149
150
  */
150
151
  modalAction() {
151
152
  if (this.pluginOptions.outputFormat === 'svg') {
152
- const files = this._getSVGFileList();
153
+ const files = this.#getSVGFileList();
153
154
  this.plugins.image.init();
154
155
  this.plugins.image.submitFile(files);
155
156
  } else {
@@ -168,10 +169,9 @@ class Drawing extends EditorInjector {
168
169
  }
169
170
 
170
171
  /**
171
- * @private
172
172
  * @description Initializes the drawing canvas, sets up event listeners, and configures resize handling.
173
173
  */
174
- _initDrawing() {
174
+ #initDrawing() {
175
175
  const canvas = (this.canvas = this.modal.form.querySelector('.se-drawing-canvas'));
176
176
  this.ctx = canvas.getContext('2d');
177
177
  canvas.width = canvas.offsetWidth;
@@ -180,13 +180,15 @@ class Drawing extends EditorInjector {
180
180
  this.points = [];
181
181
  this.paths = [];
182
182
 
183
- this._setCtx();
183
+ this.#setCtx();
184
184
 
185
- this.__eventsRegister.mousedown = this.eventManager.addEvent(canvas, this.__eventNameMap.mousedown, this.__events.mousedown, { passive: false, capture: true });
186
- this.__eventsRegister.mousemove = this.eventManager.addEvent(canvas, this.__eventNameMap.mousemove, this.__events.mousemove, true);
187
- this.__eventsRegister.mouseup = this.eventManager.addEvent(canvas, this.__eventNameMap.mouseup, this.__events.mouseup, true);
188
- this.__eventsRegister.mouseleave = this.eventManager.addEvent(canvas, this.__eventNameMap.mouseleave, this.__events.mouseleave);
189
- this.__eventsRegister.mouseenter = this.eventManager.addEvent(canvas, this.__eventNameMap.mouseenter, this.__events.mouseenter);
185
+ this.#eventsRegister.touchstart = this.eventManager.addEvent(canvas, 'touchstart', this.#events.touchstart, { passive: false, capture: true });
186
+ this.#eventsRegister.touchmove = this.eventManager.addEvent(canvas, 'touchmove', this.#events.touchmove, true);
187
+ this.#eventsRegister.mousedown = this.eventManager.addEvent(canvas, 'mousedown', this.#events.mousedown, { passive: false, capture: true });
188
+ this.#eventsRegister.mousemove = this.eventManager.addEvent(canvas, 'mousemove', this.#events.mousemove, true);
189
+ this.#eventsRegister.mouseup = this.eventManager.addEvent(canvas, 'mouseup', this.#events.mouseup, true);
190
+ this.#eventsRegister.mouseleave = this.eventManager.addEvent(canvas, 'mouseleave', this.#events.mouseleave);
191
+ this.#eventsRegister.mouseenter = this.eventManager.addEvent(canvas, 'mouseenter', this.#events.mouseenter);
190
192
 
191
193
  if (this.resizeObserver) {
192
194
  this.resizeObserver.disconnect();
@@ -202,8 +204,8 @@ class Drawing extends EditorInjector {
202
204
  canvas.width = newWidth;
203
205
  canvas.height = newHeight;
204
206
  if (prevWidth !== canvas.width || prevHeight !== canvas.height) {
205
- if (this.pluginOptions.maintainRatio) this._adjustPathsToNewDimensions(prevWidth, prevHeight, newWidth, newHeight);
206
- this._drawAll();
207
+ if (this.pluginOptions.maintainRatio) this.#adjustPathsToNewDimensions(prevWidth, prevHeight, newWidth, newHeight);
208
+ this.#drawAll();
207
209
  }
208
210
  });
209
211
 
@@ -212,21 +214,20 @@ class Drawing extends EditorInjector {
212
214
  }
213
215
 
214
216
  /**
215
- * @private
216
217
  * @description Destroys the drawing canvas, removes event listeners, and clears stored drawing data.
217
218
  */
218
- _destroyDrawing() {
219
+ #destroyDrawing() {
219
220
  if (this.resizeObserver) {
220
221
  this.resizeObserver.disconnect();
221
222
  this.resizeObserver = null;
222
223
  }
223
224
 
224
225
  if (this.canvas) {
225
- this.eventManager.removeEvent(this.__eventsRegister.mousedown);
226
- this.eventManager.removeEvent(this.__eventsRegister.mousemove);
227
- this.eventManager.removeEvent(this.__eventsRegister.mouseup);
228
- this.eventManager.removeEvent(this.__eventsRegister.mouseleave);
229
- this.eventManager.removeEvent(this.__eventsRegister.mouseenter);
226
+ this.eventManager.removeEvent(this.#eventsRegister.mousedown);
227
+ this.eventManager.removeEvent(this.#eventsRegister.mousemove);
228
+ this.eventManager.removeEvent(this.#eventsRegister.mouseup);
229
+ this.eventManager.removeEvent(this.#eventsRegister.mouseleave);
230
+ this.eventManager.removeEvent(this.#eventsRegister.mouseenter);
230
231
  }
231
232
 
232
233
  this.canvas = null;
@@ -237,21 +238,19 @@ class Drawing extends EditorInjector {
237
238
  }
238
239
 
239
240
  /**
240
- * @private
241
241
  * @description Configures the drawing context (canvas settings like line width, color, etc.).
242
242
  */
243
- _setCtx() {
243
+ #setCtx() {
244
244
  this.ctx.lineWidth = this.pluginOptions.lineWidth;
245
245
  this.ctx.lineCap = this.pluginOptions.lineCap;
246
246
  this.ctx.strokeStyle = this.pluginOptions.lineColor || _w.getComputedStyle(this.carrierWrapper).color;
247
247
  }
248
248
 
249
249
  /**
250
- * @private
251
250
  * @description Draws the current stroke based on collected points.
252
251
  */
253
- _draw() {
254
- this._setCtx();
252
+ #draw() {
253
+ this.#setCtx();
255
254
  this.ctx.beginPath();
256
255
  this.points.forEach(([x, y], i) => {
257
256
  if (i === 0) {
@@ -264,28 +263,26 @@ class Drawing extends EditorInjector {
264
263
  }
265
264
 
266
265
  /**
267
- * @private
268
266
  * @description Redraws all stored paths onto the canvas.
269
267
  */
270
- _drawAll() {
271
- this._setCtx();
268
+ #drawAll() {
269
+ this.#setCtx();
272
270
  this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
273
271
  this.paths.forEach((path) => {
274
272
  this.points = path;
275
- this._draw();
273
+ this.#draw();
276
274
  });
277
275
  this.points = [];
278
276
  }
279
277
 
280
278
  /**
281
- * @private
282
279
  * @description Adjusts all stored paths to fit new canvas dimensions after a resize event.
283
280
  * @param {number} prevWidth - The previous width of the canvas.
284
281
  * @param {number} prevHeight - The previous height of the canvas.
285
282
  * @param {number} newWidth - The new width of the canvas.
286
283
  * @param {number} newHeight - The new height of the canvas.
287
284
  */
288
- _adjustPathsToNewDimensions(prevWidth, prevHeight, newWidth, newHeight) {
285
+ #adjustPathsToNewDimensions(prevWidth, prevHeight, newWidth, newHeight) {
289
286
  const xRatio = newWidth / prevWidth;
290
287
  const yRatio = newHeight / prevHeight;
291
288
 
@@ -293,21 +290,19 @@ class Drawing extends EditorInjector {
293
290
  }
294
291
 
295
292
  /**
296
- * @private
297
293
  * @description Clears the canvas and resets stored drawing paths.
298
294
  */
299
- _clearCanvas() {
295
+ #clearCanvas() {
300
296
  this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
301
297
  this.points = [];
302
298
  this.paths = [];
303
299
  }
304
300
 
305
301
  /**
306
- * @private
307
302
  * @description Generates an SVG representation of the drawn content.
308
303
  * @returns {*} The generated SVG element.
309
304
  */
310
- _getSVG() {
305
+ #getSVG() {
311
306
  const svgNS = 'http://www.w3.org/2000/svg';
312
307
  const svg = document.createElementNS(svgNS, 'svg');
313
308
  svg.setAttribute('width', this.canvas.width + '');
@@ -331,12 +326,11 @@ class Drawing extends EditorInjector {
331
326
  }
332
327
 
333
328
  /**
334
- * @private
335
329
  * @description Converts the SVG element into a downloadable file.
336
330
  * @returns {FileList} A FileList containing the generated SVG file.
337
331
  */
338
- _getSVGFileList() {
339
- const svgElement = this._getSVG();
332
+ #getSVGFileList() {
333
+ const svgElement = this.#getSVG();
340
334
  const serializer = new XMLSerializer();
341
335
  const svgString = serializer.serializeToString(svgElement);
342
336
  const blob = new Blob([svgString], { type: 'image/svg+xml' });
@@ -350,12 +344,11 @@ class Drawing extends EditorInjector {
350
344
  }
351
345
 
352
346
  /**
353
- * @private
354
347
  * @description Retrieves touch coordinates relative to the canvas.
355
348
  * @param {TouchEvent} e - The touch event.
356
349
  * @returns {{x: number, y: number}} An object containing the x and y coordinates.
357
350
  */
358
- _getCanvasTouchPointer(e) {
351
+ #getCanvasTouchPointer(e) {
359
352
  const { touches } = e;
360
353
  const rect = this.canvas.getBoundingClientRect();
361
354
  const x = touches[0].clientX - rect.left;
@@ -364,11 +357,10 @@ class Drawing extends EditorInjector {
364
357
  }
365
358
 
366
359
  /**
367
- * @private
368
360
  * @description Activates either block or inline format mode for inserted drawings.
369
361
  * @param {boolean} isInline - Whether the drawing should be inserted as an inline element.
370
362
  */
371
- _activeAsInline(isInline) {
363
+ #activeAsInline(isInline) {
372
364
  if (isInline) {
373
365
  dom.utils.addClass(this.asInline, 'on');
374
366
  dom.utils.removeClass(this.asBlock, 'on');
@@ -387,7 +379,7 @@ class Drawing extends EditorInjector {
387
379
  e.preventDefault();
388
380
  this.isDrawing = true;
389
381
  this.points.push([e.offsetX, e.offsetY]);
390
- this._draw();
382
+ this.#draw();
391
383
  }
392
384
 
393
385
  /**
@@ -397,7 +389,7 @@ class Drawing extends EditorInjector {
397
389
  e.preventDefault();
398
390
  if (!this.isDrawing) return;
399
391
  this.points.push([e.offsetX, e.offsetY]);
400
- this._draw();
392
+ this.#draw();
401
393
  }
402
394
 
403
395
  /**
@@ -405,10 +397,10 @@ class Drawing extends EditorInjector {
405
397
  */
406
398
  #OnCanvasTouchStart(e) {
407
399
  e.preventDefault();
408
- const { x, y } = this._getCanvasTouchPointer(e);
400
+ const { x, y } = this.#getCanvasTouchPointer(e);
409
401
  this.isDrawing = true;
410
402
  this.points.push([x, y]);
411
- this._draw();
403
+ this.#draw();
412
404
  }
413
405
 
414
406
  /**
@@ -416,10 +408,10 @@ class Drawing extends EditorInjector {
416
408
  */
417
409
  #OnCanvasTouchMove(e) {
418
410
  e.preventDefault();
419
- const { x, y } = this._getCanvasTouchPointer(e);
411
+ const { x, y } = this.#getCanvasTouchPointer(e);
420
412
  if (!this.isDrawing) return;
421
413
  this.points.push([x, y]);
422
- this._draw();
414
+ this.#draw();
423
415
  }
424
416
 
425
417
  #OnCanvasMouseUp() {
@@ -449,24 +441,24 @@ class Drawing extends EditorInjector {
449
441
  if (!this.pluginOptions.lineReconnect) {
450
442
  this.points.push([e.offsetX, e.offsetY]);
451
443
  } else {
452
- const lastPath = this.paths[this.paths.length - 1];
453
- const lastPoint = lastPath[lastPath.length - 1];
444
+ const lastPath = this.paths.at(-1);
445
+ const lastPoint = lastPath.at(-1);
454
446
  this.points.push([lastPoint[0], lastPoint[1]]);
455
447
  this.points.push([e.offsetX, e.offsetY]);
456
448
  }
457
- this._draw();
449
+ this.#draw();
458
450
  }
459
451
  }
460
452
 
461
453
  #OnRemove() {
462
- this._clearCanvas();
454
+ this.#clearCanvas();
463
455
  }
464
456
 
465
457
  /**
466
458
  * @param {MouseEvent} e - Event object
467
459
  */
468
460
  #OnClickAsButton(e) {
469
- this._activeAsInline(dom.query.getEventTarget(e).getAttribute('data-command') === 'asInline');
461
+ this.#activeAsInline(dom.query.getEventTarget(e).getAttribute('data-command') === 'asInline');
470
462
  }
471
463
  }
472
464