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 SelectMenu from './SelectMenu';
3
3
  import FileManager from './FileManager';
4
4
  import { dom, numbers, env, unicode } from '../helper';
5
- const { NO_EVENT } = env;
5
+ const { _w, NO_EVENT } = env;
6
6
 
7
7
  /**
8
8
  * @typedef {{default?: string, check_new_window?: string, check_bookmark?: string}} RELAttr
@@ -37,6 +37,11 @@ const { NO_EVENT } = env;
37
37
  * - Use it by inserting it into Modal in a plugin that uses Modal.
38
38
  */
39
39
  class ModalAnchorEditor extends EditorInjector {
40
+ #modalForm;
41
+ #isRel;
42
+ #selectMenu_rel;
43
+ #selectMenu_bookmark;
44
+
40
45
  /**
41
46
  * @constructor
42
47
  * @param {*} inst The instance object that called the constructor.
@@ -74,8 +79,7 @@ class ModalAnchorEditor extends EditorInjector {
74
79
  // members
75
80
  this.kink = inst.constructor.key || inst.constructor.name;
76
81
  this.inst = inst;
77
- this.modalForm = /** @type {HTMLElement} */ (modalForm);
78
- this.host = (this._w.location.origin + this._w.location.pathname).replace(/\/$/, '');
82
+ this.host = (_w.location.origin + _w.location.pathname).replace(/\/$/, '');
79
83
 
80
84
  /** @type {HTMLInputElement} */
81
85
  this.urlInput = forms.querySelector('.se-input-url');
@@ -99,10 +103,10 @@ class ModalAnchorEditor extends EditorInjector {
99
103
  this.currentRel = [];
100
104
  this.currentTarget = null;
101
105
  this.linkValue = '';
102
- this._change = false;
103
- this._isRel = this.relList.length > 0;
106
+
107
+ this.#isRel = this.relList.length > 0;
104
108
  // members - rel
105
- if (this._isRel) {
109
+ if (this.#isRel) {
106
110
  /** @type {HTMLButtonElement} */
107
111
  this.relButton = forms.querySelector('.se-anchor-rel-btn');
108
112
  /** @type {HTMLElement} */
@@ -127,19 +131,19 @@ class ModalAnchorEditor extends EditorInjector {
127
131
  )
128
132
  );
129
133
  }
130
- this.selectMenu_rel = new SelectMenu(this, { checkList: true, position: 'right-middle', dir: 'ltr' });
131
- this.selectMenu_rel.on(this.relButton, this.#SetRelItem.bind(this));
132
- this.selectMenu_rel.create(list);
134
+ this.#selectMenu_rel = new SelectMenu(this, { checkList: true, position: 'right-middle', dir: 'ltr' });
135
+ this.#selectMenu_rel.on(this.relButton, this.#SetRelItem.bind(this));
136
+ this.#selectMenu_rel.create(list);
133
137
  this.eventManager.addEvent(this.relButton, 'click', this.#OnClick_relbutton.bind(this));
134
138
  }
135
139
 
136
140
  // init
137
- this.modalForm.querySelector('.se-anchor-editor').appendChild(forms);
138
- this.selectMenu_bookmark = new SelectMenu(this, { checkList: false, position: 'bottom-left', dir: 'ltr' });
139
- this.selectMenu_bookmark.on(this.urlInput, this.#SetHeaderBookmark.bind(this));
141
+ this.#modalForm = /** @type {HTMLElement} */ (modalForm);
142
+ this.#modalForm.querySelector('.se-anchor-editor').appendChild(forms);
143
+ this.#selectMenu_bookmark = new SelectMenu(this, { checkList: false, position: 'bottom-left', dir: 'ltr' });
144
+ this.#selectMenu_bookmark.on(this.urlInput, this.#SetHeaderBookmark.bind(this));
140
145
  this.eventManager.addEvent(this.newWindowCheck, 'change', this.#OnChange_newWindowCheck.bind(this));
141
146
  this.eventManager.addEvent(this.downloadCheck, 'change', this.#OnChange_downloadCheck.bind(this));
142
- this.eventManager.addEvent(this.displayInput, 'input', this.#OnChange_displayInput.bind(this));
143
147
  this.eventManager.addEvent(this.urlInput, 'input', this.#OnChange_urlInput.bind(this));
144
148
  this.eventManager.addEvent(this.urlInput, 'focus', this.#OnFocus_urlInput.bind(this));
145
149
  this.eventManager.addEvent(this.bookmarkButton, 'click', this.#OnClick_bookmarkButton.bind(this));
@@ -166,15 +170,15 @@ class ModalAnchorEditor extends EditorInjector {
166
170
  this.titleInput.value = '';
167
171
  } else if (this.currentTarget) {
168
172
  const href = this.currentTarget.href;
169
- this.linkValue = this.preview.textContent = this.urlInput.value = this._selfPathBookmark(href) ? href.substring(href.lastIndexOf('#')) : href;
173
+ this.linkValue = this.preview.textContent = this.urlInput.value = this.#selfPathBookmark(href) ? href.substring(href.lastIndexOf('#')) : href;
170
174
  this.displayInput.value = this.currentTarget.textContent;
171
175
  this.titleInput.value = this.currentTarget.title;
172
176
  this.newWindowCheck.checked = /_blank/i.test(this.currentTarget.target) ? true : false;
173
177
  this.downloadCheck.checked = !!this.currentTarget.download;
174
178
  }
175
179
 
176
- this._setRel(isUpdate && this.currentTarget ? this.currentTarget.rel : this.defaultRel.default || '');
177
- this._setLinkPreview(this.linkValue);
180
+ this.#setRel(isUpdate && this.currentTarget ? this.currentTarget.rel : this.defaultRel.default || '');
181
+ this.#setLinkPreview(this.linkValue);
178
182
  }
179
183
 
180
184
  /**
@@ -189,7 +193,7 @@ class ModalAnchorEditor extends EditorInjector {
189
193
  const displayText = this.displayInput.value.length === 0 ? url : this.displayInput.value;
190
194
 
191
195
  const oA = /** @type {HTMLAnchorElement} */ (this.currentTarget || dom.utils.createElement('A'));
192
- this._updateAnchor(oA, url, displayText, this.titleInput.value, notText);
196
+ this.#updateAnchor(oA, url, displayText, this.titleInput.value, notText);
193
197
  this.linkValue = this.preview.textContent = this.urlInput.value = this.displayInput.value = '';
194
198
 
195
199
  return oA;
@@ -204,12 +208,10 @@ class ModalAnchorEditor extends EditorInjector {
204
208
  this.displayInput.value = '';
205
209
  this.newWindowCheck.checked = false;
206
210
  this.downloadCheck.checked = false;
207
- this._change = false;
208
- this._setRel(this.defaultRel.default || '');
211
+ this.#setRel(this.defaultRel.default || '');
209
212
  }
210
213
 
211
214
  /**
212
- * @private
213
215
  * @description Updates the anchor element with new attributes.
214
216
  * @param {HTMLAnchorElement} anchor - The anchor (`<a>`) element to update.
215
217
  * @param {string} url - The URL for the anchor's `href` attribute.
@@ -217,9 +219,9 @@ class ModalAnchorEditor extends EditorInjector {
217
219
  * @param {string} title - The tooltip text (title attribute).
218
220
  * @param {boolean} notText - If `true`, the anchor will not contain text content.
219
221
  */
220
- _updateAnchor(anchor, url, displayText, title, notText) {
222
+ #updateAnchor(anchor, url, displayText, title, notText) {
221
223
  // download
222
- if (!this._selfPathBookmark(url) && this.downloadCheck.checked) {
224
+ if (!this.#selfPathBookmark(url) && this.downloadCheck.checked) {
223
225
  anchor.setAttribute('download', displayText || url);
224
226
  } else {
225
227
  anchor.removeAttribute('download');
@@ -247,26 +249,24 @@ class ModalAnchorEditor extends EditorInjector {
247
249
  }
248
250
 
249
251
  /**
250
- * @private
251
252
  * @description Checks if the given path is an internal bookmark.
252
253
  * @param {string} path - The URL or anchor link.
253
254
  * @returns {boolean} - `true` if the path is an internal bookmark, otherwise `false`.
254
255
  */
255
- _selfPathBookmark(path) {
256
- const href = this._w.location.href.replace(/\/$/, '');
256
+ #selfPathBookmark(path) {
257
+ const href = _w.location.href.replace(/\/$/, '');
257
258
  return path.indexOf('#') === 0 || (path.indexOf(href) === 0 && path.indexOf('#') === (!href.includes('#') ? href.length : href.substring(0, href.indexOf('#')).length));
258
259
  }
259
260
 
260
261
  /**
261
- * @private
262
262
  * @description Updates the `rel` attribute list in the modal and preview.
263
263
  * @param {string} relAttr - The `rel` attribute string to set.
264
264
  */
265
- _setRel(relAttr) {
266
- if (!this._isRel) return;
265
+ #setRel(relAttr) {
266
+ if (!this.#isRel) return;
267
267
 
268
268
  const rels = (this.currentRel = !relAttr ? [] : relAttr.split(' '));
269
- const checkedRel = this.selectMenu_rel.form.querySelectorAll('button');
269
+ const checkedRel = this.#selectMenu_rel.form.querySelectorAll('button');
270
270
  for (let i = 0, len = checkedRel.length, cmd; i < len; i++) {
271
271
  cmd = checkedRel[i].getAttribute('data-command');
272
272
  if (rels.includes(cmd)) {
@@ -285,12 +285,11 @@ class ModalAnchorEditor extends EditorInjector {
285
285
  }
286
286
 
287
287
  /**
288
- * @private
289
288
  * @description Generates a list of bookmark headers within the editor.
290
289
  * @param {string} urlValue - The current URL input value.
291
290
  */
292
- _createBookmarkList(urlValue) {
293
- const headers = dom.query.getListChildren(this.editor.frameContext.get('wysiwyg'), (current) => /h[1-6]/i.test(current.nodeName) || (dom.check.isAnchor(current) && !!current.id));
291
+ #createBookmarkList(urlValue) {
292
+ const headers = dom.query.getListChildren(this.frameContext.get('wysiwyg'), (current) => /h[1-6]/i.test(current.nodeName) || (dom.check.isAnchor(current) && !!current.id), null);
294
293
  if (headers.length === 0) return;
295
294
 
296
295
  const valueRegExp = new RegExp(`^${urlValue.replace(/^#/, '')}`, 'i');
@@ -304,19 +303,18 @@ class ModalAnchorEditor extends EditorInjector {
304
303
  }
305
304
 
306
305
  if (list.length === 0) {
307
- this.selectMenu_bookmark.close();
306
+ this.#selectMenu_bookmark.close();
308
307
  } else {
309
- this.selectMenu_bookmark.create(list, menus);
310
- this.selectMenu_bookmark.open(this.options.get('_rtl') ? 'bottom-right' : '');
308
+ this.#selectMenu_bookmark.create(list, menus);
309
+ this.#selectMenu_bookmark.open(this.options.get('_rtl') ? 'bottom-right' : '');
311
310
  }
312
311
  }
313
312
 
314
313
  /**
315
- * @private
316
314
  * @description Updates the preview of the anchor link.
317
315
  * @param {string} value - The current URL value.
318
316
  */
319
- _setLinkPreview(value) {
317
+ #setLinkPreview(value) {
320
318
  const preview = this.preview;
321
319
  const protocol = this.options.get('defaultUrlProtocol');
322
320
  const noPrefix = this.noAutoPrefix;
@@ -328,7 +326,7 @@ class ModalAnchorEditor extends EditorInjector {
328
326
  preview.textContent =
329
327
  !value ? '' : noPrefix ? value : protocol && !reservedProtocol && !sameProtocol ? protocol + value : reservedProtocol ? value : /^www\./.test(value) ? 'http://' + value : this.host + (/^\//.test(value) ? '' : '/') + value;
330
328
 
331
- if (this._selfPathBookmark(value)) {
329
+ if (this.#selfPathBookmark(value)) {
332
330
  this.bookmark.style.display = 'block';
333
331
  dom.utils.addClass(this.bookmarkButton, 'active');
334
332
  } else {
@@ -336,7 +334,7 @@ class ModalAnchorEditor extends EditorInjector {
336
334
  dom.utils.removeClass(this.bookmarkButton, 'active');
337
335
  }
338
336
 
339
- if (!this._selfPathBookmark(value) && this.downloadCheck.checked) {
337
+ if (!this.#selfPathBookmark(value) && this.downloadCheck.checked) {
340
338
  this.download.style.display = 'block';
341
339
  } else {
342
340
  this.download.style.display = 'none';
@@ -344,12 +342,11 @@ class ModalAnchorEditor extends EditorInjector {
344
342
  }
345
343
 
346
344
  /**
347
- * @private
348
345
  * @description Merges the given `rel` attribute value with the current list.
349
346
  * @param {string} relAttr - The `rel` attribute to merge.
350
347
  * @returns {string} - The updated `rel` attribute string.
351
348
  */
352
- _relMerge(relAttr) {
349
+ #relMerge(relAttr) {
353
350
  const current = this.currentRel;
354
351
  if (!relAttr) return current.join(' ');
355
352
 
@@ -368,12 +365,11 @@ class ModalAnchorEditor extends EditorInjector {
368
365
  }
369
366
 
370
367
  /**
371
- * @private
372
368
  * @description Removes the specified `rel` attribute from the current list.
373
369
  * @param {string} relAttr - The `rel` attribute to remove.
374
370
  * @returns {string} - The updated `rel` attribute string.
375
371
  */
376
- _relDelete(relAttr) {
372
+ #relDelete(relAttr) {
377
373
  if (!relAttr) return this.currentRel.join(' ');
378
374
  if (/^only:/.test(relAttr)) relAttr = relAttr.replace(/^only:/, '').trim();
379
375
 
@@ -383,11 +379,10 @@ class ModalAnchorEditor extends EditorInjector {
383
379
  }
384
380
 
385
381
  /**
386
- * @private
387
382
  * @description Registers a newly uploaded file and sets its URL in the modal form.
388
383
  * @param {Object<string, *>} response - The response object from the file upload request.
389
384
  */
390
- _register(response) {
385
+ #register(response) {
391
386
  const file = response.result[0];
392
387
  this.linkValue = this.preview.textContent = this.urlInput.value = file.url;
393
388
  this.displayInput.value = file.name;
@@ -396,12 +391,11 @@ class ModalAnchorEditor extends EditorInjector {
396
391
  }
397
392
 
398
393
  /**
399
- * @private
400
394
  * @description Handles file upload errors.
401
395
  * @param {Object<string, *>} response - The error response object.
402
396
  * @returns {Promise<void>}
403
397
  */
404
- async _error(response) {
398
+ async #error(response) {
405
399
  const message = await this.triggerEvent('onFileUploadError', { error: response });
406
400
  if (message === false) return;
407
401
  const err = message === NO_EVENT ? response.errorMessage : message || response.errorMessage;
@@ -413,12 +407,12 @@ class ModalAnchorEditor extends EditorInjector {
413
407
  * @description Handles the callback after a file upload completes.
414
408
  * @param {XMLHttpRequest} xmlHttp - The XMLHttpRequest object containing the response.
415
409
  */
416
- _uploadCallBack(xmlHttp) {
410
+ #uploadCallBack(xmlHttp) {
417
411
  const response = JSON.parse(xmlHttp.responseText);
418
412
  if (response.errorMessage) {
419
- this._error(response);
413
+ this.#error(response);
420
414
  } else {
421
- this._register(response);
415
+ this.#register(response);
422
416
  }
423
417
  }
424
418
 
@@ -438,13 +432,11 @@ class ModalAnchorEditor extends EditorInjector {
438
432
  files
439
433
  };
440
434
 
441
- const handler = async function (infos, newInfos) {
435
+ const handler = async function (uploadCallback, infos, newInfos) {
442
436
  infos = newInfos || infos;
443
437
  const xmlHttp = await this.fileManager.asyncUpload(infos.url, infos.uploadHeaders, infos.files);
444
- this._uploadCallBack(xmlHttp);
445
- }.bind(this, fileInfo);
446
- // se-ts-ignore
447
- void this._uploadCallBack;
438
+ uploadCallback(xmlHttp);
439
+ }.bind(this, this.#uploadCallBack.bind(this), fileInfo);
448
440
 
449
441
  const result = await this.triggerEvent('onFileUploadBefore', {
450
442
  info: fileInfo,
@@ -462,7 +454,7 @@ class ModalAnchorEditor extends EditorInjector {
462
454
  * @description Opens the `rel` attribute selection menu.
463
455
  */
464
456
  #OnClick_relbutton() {
465
- this.selectMenu_rel.open(this.options.get('_rtl') ? 'left-middle' : '');
457
+ this.#selectMenu_rel.open(this.options.get('_rtl') ? 'left-middle' : '');
466
458
  }
467
459
 
468
460
  /**
@@ -474,8 +466,8 @@ class ModalAnchorEditor extends EditorInjector {
474
466
  item.id = id;
475
467
  this.urlInput.value = '#' + id;
476
468
 
477
- this._setLinkPreview(this.urlInput.value);
478
- this.selectMenu_bookmark.close();
469
+ this.#setLinkPreview(this.urlInput.value);
470
+ this.#selectMenu_bookmark.close();
479
471
  this.urlInput.focus();
480
472
  }
481
473
 
@@ -494,15 +486,6 @@ class ModalAnchorEditor extends EditorInjector {
494
486
  this.relPreview.title = this.relPreview.textContent = current.join(', ');
495
487
  }
496
488
 
497
- /**
498
- * @param {InputEvent} e - Event object
499
- */
500
- #OnChange_displayInput(e) {
501
- /** @type {HTMLInputElement} */
502
- const eventTarget = dom.query.getEventTarget(e);
503
- this._change = !!eventTarget.value.trim();
504
- }
505
-
506
489
  /**
507
490
  * @param {InputEvent} e - Event object
508
491
  */
@@ -510,19 +493,19 @@ class ModalAnchorEditor extends EditorInjector {
510
493
  /** @type {HTMLInputElement} */
511
494
  const eventTarget = dom.query.getEventTarget(e);
512
495
  const value = eventTarget.value.trim();
513
- this._setLinkPreview(value);
514
- if (this._selfPathBookmark(value)) this._createBookmarkList(value);
515
- else this.selectMenu_bookmark.close();
496
+ this.#setLinkPreview(value);
497
+ if (this.#selfPathBookmark(value)) this.#createBookmarkList(value);
498
+ else this.#selectMenu_bookmark.close();
516
499
  }
517
500
 
518
501
  #OnFocus_urlInput() {
519
502
  const value = this.urlInput.value;
520
- if (this._selfPathBookmark(value)) this._createBookmarkList(value);
503
+ if (this.#selfPathBookmark(value)) this.#createBookmarkList(value);
521
504
  }
522
505
 
523
506
  #OnClick_bookmarkButton() {
524
507
  let url = this.urlInput.value;
525
- if (this._selfPathBookmark(url)) {
508
+ if (this.#selfPathBookmark(url)) {
526
509
  url = url.substring(1);
527
510
  this.bookmark.style.display = 'none';
528
511
  dom.utils.removeClass(this.bookmarkButton, 'active');
@@ -532,11 +515,11 @@ class ModalAnchorEditor extends EditorInjector {
532
515
  dom.utils.addClass(this.bookmarkButton, 'active');
533
516
  this.downloadCheck.checked = false;
534
517
  this.download.style.display = 'none';
535
- this._createBookmarkList(url);
518
+ this.#createBookmarkList(url);
536
519
  }
537
520
 
538
521
  this.urlInput.value = url;
539
- this._setLinkPreview(url);
522
+ this.#setLinkPreview(url);
540
523
  this.urlInput.focus();
541
524
  }
542
525
 
@@ -548,9 +531,9 @@ class ModalAnchorEditor extends EditorInjector {
548
531
  /** @type {HTMLInputElement} */
549
532
  const eventTarget = dom.query.getEventTarget(e);
550
533
  if (eventTarget.checked) {
551
- this._setRel(this._relMerge(this.defaultRel.check_new_window));
534
+ this.#setRel(this.#relMerge(this.defaultRel.check_new_window));
552
535
  } else {
553
- this._setRel(this._relDelete(this.defaultRel.check_new_window));
536
+ this.#setRel(this.#relDelete(this.defaultRel.check_new_window));
554
537
  }
555
538
  }
556
539
 
@@ -566,12 +549,12 @@ class ModalAnchorEditor extends EditorInjector {
566
549
  dom.utils.removeClass(this.bookmarkButton, 'active');
567
550
  this.linkValue = this.preview.textContent = this.urlInput.value = this.urlInput.value.replace(/^#+/, '');
568
551
  if (typeof this.defaultRel.check_bookmark === 'string') {
569
- this._setRel(this._relMerge(this.defaultRel.check_bookmark));
552
+ this.#setRel(this.#relMerge(this.defaultRel.check_bookmark));
570
553
  }
571
554
  } else {
572
555
  this.download.style.display = 'none';
573
556
  if (typeof this.defaultRel.check_bookmark === 'string') {
574
- this._setRel(this._relDelete(this.defaultRel.check_bookmark));
557
+ this.#setRel(this.#relDelete(this.defaultRel.check_bookmark));
575
558
  }
576
559
  }
577
560
  }
@@ -595,7 +578,7 @@ function CreatetModalForm(editor, params, relList) {
595
578
  <div class="se-modal-form">
596
579
  <label>${lang.link_modal_url}</label>
597
580
  <div class="se-modal-form-files">
598
- <input data-focus class="se-input-form se-input-url" type="text" placeholder="${editor.options.get('protocol') || ''}" />
581
+ <input data-focus class="se-input-form se-input-url" type="text" placeholder="${editor.options.get('defaultUrlProtocol') || ''}" />
599
582
  ${
600
583
  params.enableFileUpload
601
584
  ? `<button type="button" class="se-btn se-tooltip se-modal-files-edge-button _se_upload_button" aria-label="${lang.fileUpload}">