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.
- package/CONTRIBUTING.md +8 -8
- package/README.md +44 -49
- package/dist/suneditor.min.css +1 -1
- package/dist/suneditor.min.js +1 -1
- package/package.json +95 -53
- package/src/assets/design/color.css +2 -2
- package/src/assets/design/size.css +2 -0
- package/src/assets/icons/defaultIcons.js +16 -1
- package/src/assets/suneditor-contents.css +9 -8
- package/src/assets/suneditor.css +29 -26
- package/src/core/{section → base}/actives.js +20 -12
- package/src/core/base/history.js +4 -4
- package/src/core/class/char.js +10 -10
- package/src/core/class/component.js +146 -57
- package/src/core/class/format.js +94 -2458
- package/src/core/class/html.js +187 -129
- package/src/core/class/inline.js +1853 -0
- package/src/core/class/listFormat.js +582 -0
- package/src/core/class/menu.js +14 -3
- package/src/core/class/nodeTransform.js +9 -14
- package/src/core/class/offset.js +162 -197
- package/src/core/class/selection.js +137 -34
- package/src/core/class/toolbar.js +73 -52
- package/src/core/class/ui.js +11 -11
- package/src/core/class/viewer.js +56 -55
- package/src/core/config/context.js +122 -0
- package/src/core/config/frameContext.js +204 -0
- package/src/core/config/options.js +639 -0
- package/src/core/editor.js +181 -108
- package/src/core/event/actions/index.js +229 -0
- package/src/core/event/effects/common.registry.js +60 -0
- package/src/core/event/effects/keydown.registry.js +551 -0
- package/src/core/event/effects/ruleHelpers.js +145 -0
- package/src/core/{base → event}/eventManager.js +119 -201
- package/src/core/event/executor.js +21 -0
- package/src/core/{base/eventHandlers → event/handlers}/handler_toolbar.js +4 -4
- package/src/core/{base/eventHandlers → event/handlers}/handler_ww_dragDrop.js +2 -2
- package/src/core/event/handlers/handler_ww_input.js +77 -0
- package/src/core/event/handlers/handler_ww_key.js +228 -0
- package/src/core/{base/eventHandlers → event/handlers}/handler_ww_mouse.js +3 -3
- package/src/core/event/ports.js +211 -0
- package/src/core/event/reducers/keydown.reducer.js +89 -0
- package/src/core/event/rules/keydown.rule.arrow.js +54 -0
- package/src/core/event/rules/keydown.rule.backspace.js +202 -0
- package/src/core/event/rules/keydown.rule.delete.js +126 -0
- package/src/core/event/rules/keydown.rule.enter.js +144 -0
- package/src/core/event/rules/keydown.rule.tab.js +29 -0
- package/src/core/section/constructor.js +79 -388
- package/src/core/section/documentType.js +47 -26
- package/src/core/util/instanceCheck.js +59 -0
- package/src/editorInjector/_classes.js +4 -0
- package/src/editorInjector/_core.js +17 -7
- package/src/editorInjector/index.js +10 -2
- package/src/events.js +6 -0
- package/src/helper/clipboard.js +24 -10
- package/src/helper/converter.js +17 -12
- package/src/helper/dom/domCheck.js +22 -3
- package/src/helper/dom/domQuery.js +91 -45
- package/src/helper/dom/domUtils.js +93 -19
- package/src/helper/dom/index.js +4 -0
- package/src/helper/env.js +11 -7
- package/src/helper/keyCodeMap.js +4 -3
- package/src/langs/ckb.js +1 -1
- package/src/langs/cs.js +1 -1
- package/src/langs/da.js +1 -1
- package/src/langs/de.js +1 -1
- package/src/langs/en.js +1 -1
- package/src/langs/es.js +1 -1
- package/src/langs/fa.js +1 -1
- package/src/langs/fr.js +1 -1
- package/src/langs/he.js +1 -1
- package/src/langs/hu.js +1 -1
- package/src/langs/it.js +1 -1
- package/src/langs/ja.js +1 -1
- package/src/langs/km.js +1 -1
- package/src/langs/ko.js +1 -1
- package/src/langs/lv.js +1 -1
- package/src/langs/nl.js +1 -1
- package/src/langs/pl.js +1 -1
- package/src/langs/pt_br.js +10 -10
- package/src/langs/ro.js +1 -1
- package/src/langs/ru.js +1 -1
- package/src/langs/se.js +1 -1
- package/src/langs/tr.js +1 -1
- package/src/langs/uk.js +1 -1
- package/src/langs/ur.js +1 -1
- package/src/langs/zh_cn.js +1 -1
- package/src/modules/ApiManager.js +25 -18
- package/src/modules/Browser.js +52 -61
- package/src/modules/ColorPicker.js +37 -38
- package/src/modules/Controller.js +85 -79
- package/src/modules/Figure.js +275 -187
- package/src/modules/FileManager.js +86 -92
- package/src/modules/HueSlider.js +67 -35
- package/src/modules/Modal.js +84 -77
- package/src/modules/ModalAnchorEditor.js +62 -79
- package/src/modules/SelectMenu.js +89 -86
- package/src/plugins/browser/audioGallery.js +9 -5
- package/src/plugins/browser/fileBrowser.js +10 -6
- package/src/plugins/browser/fileGallery.js +9 -5
- package/src/plugins/browser/imageGallery.js +9 -5
- package/src/plugins/browser/videoGallery.js +11 -6
- package/src/plugins/command/blockquote.js +1 -0
- package/src/plugins/command/exportPDF.js +11 -8
- package/src/plugins/command/fileUpload.js +41 -29
- package/src/plugins/command/list_bulleted.js +2 -1
- package/src/plugins/command/list_numbered.js +2 -1
- package/src/plugins/dropdown/align.js +8 -2
- package/src/plugins/dropdown/backgroundColor.js +19 -11
- package/src/plugins/dropdown/font.js +15 -9
- package/src/plugins/dropdown/fontColor.js +19 -11
- package/src/plugins/dropdown/formatBlock.js +7 -2
- package/src/plugins/dropdown/hr.js +7 -3
- package/src/plugins/dropdown/layout.js +6 -2
- package/src/plugins/dropdown/lineHeight.js +8 -3
- package/src/plugins/dropdown/list.js +2 -1
- package/src/plugins/dropdown/paragraphStyle.js +15 -11
- package/src/plugins/dropdown/{table.js → table/index.js} +514 -362
- package/src/plugins/dropdown/template.js +6 -2
- package/src/plugins/dropdown/textStyle.js +7 -3
- package/src/plugins/field/mention.js +33 -27
- package/src/plugins/input/fontSize.js +44 -37
- package/src/plugins/input/pageNavigator.js +3 -2
- package/src/plugins/modal/audio.js +90 -85
- package/src/plugins/modal/drawing.js +58 -66
- package/src/plugins/modal/embed.js +193 -180
- package/src/plugins/modal/image.js +441 -439
- package/src/plugins/modal/link.js +31 -8
- package/src/plugins/modal/math.js +23 -22
- package/src/plugins/modal/video.js +233 -230
- package/src/plugins/popup/anchor.js +24 -18
- package/src/suneditor.js +69 -24
- package/src/typedef.js +42 -19
- package/types/assets/icons/defaultIcons.d.ts +8 -0
- package/types/core/class/char.d.ts +1 -1
- package/types/core/class/component.d.ts +29 -7
- package/types/core/class/format.d.ts +4 -354
- package/types/core/class/html.d.ts +13 -4
- package/types/core/class/inline.d.ts +263 -0
- package/types/core/class/listFormat.d.ts +135 -0
- package/types/core/class/menu.d.ts +10 -2
- package/types/core/class/offset.d.ts +24 -26
- package/types/core/class/selection.d.ts +2 -0
- package/types/core/class/toolbar.d.ts +24 -11
- package/types/core/class/ui.d.ts +1 -1
- package/types/core/class/viewer.d.ts +1 -1
- package/types/core/config/context.d.ts +157 -0
- package/types/core/config/frameContext.d.ts +367 -0
- package/types/core/config/options.d.ts +1119 -0
- package/types/core/editor.d.ts +101 -66
- package/types/core/event/actions/index.d.ts +47 -0
- package/types/core/event/effects/common.registry.d.ts +50 -0
- package/types/core/event/effects/keydown.registry.d.ts +73 -0
- package/types/core/event/effects/ruleHelpers.d.ts +31 -0
- package/types/core/{base → event}/eventManager.d.ts +15 -46
- package/types/core/event/executor.d.ts +6 -0
- package/types/core/event/handlers/handler_ww_input.d.ts +41 -0
- package/types/core/{base/eventHandlers/handler_ww_key_input.d.ts → event/handlers/handler_ww_key.d.ts} +4 -6
- package/types/core/event/ports.d.ts +255 -0
- package/types/core/event/reducers/keydown.reducer.d.ts +75 -0
- package/types/core/event/rules/keydown.rule.arrow.d.ts +8 -0
- package/types/core/event/rules/keydown.rule.backspace.d.ts +9 -0
- package/types/core/event/rules/keydown.rule.delete.d.ts +9 -0
- package/types/core/event/rules/keydown.rule.enter.d.ts +9 -0
- package/types/core/event/rules/keydown.rule.tab.d.ts +9 -0
- package/types/core/section/constructor.d.ts +101 -631
- package/types/core/section/documentType.d.ts +14 -4
- package/types/core/util/instanceCheck.d.ts +50 -0
- package/types/editorInjector/_classes.d.ts +4 -0
- package/types/editorInjector/_core.d.ts +17 -7
- package/types/editorInjector/index.d.ts +10 -2
- package/types/events.d.ts +1 -0
- package/types/helper/clipboard.d.ts +2 -2
- package/types/helper/converter.d.ts +6 -9
- package/types/helper/dom/domCheck.d.ts +7 -0
- package/types/helper/dom/domQuery.d.ts +19 -8
- package/types/helper/dom/domUtils.d.ts +24 -2
- package/types/helper/dom/index.d.ts +86 -1
- package/types/helper/env.d.ts +6 -1
- package/types/helper/index.d.ts +7 -1
- package/types/helper/keyCodeMap.d.ts +3 -3
- package/types/index.d.ts +23 -117
- package/types/langs/index.d.ts +2 -2
- package/types/modules/ApiManager.d.ts +1 -8
- package/types/modules/Browser.d.ts +4 -62
- package/types/modules/ColorPicker.d.ts +4 -21
- package/types/modules/Controller.d.ts +8 -64
- package/types/modules/Figure.d.ts +54 -50
- package/types/modules/FileManager.d.ts +1 -13
- package/types/modules/HueSlider.d.ts +13 -3
- package/types/modules/Modal.d.ts +0 -43
- package/types/modules/ModalAnchorEditor.d.ts +0 -73
- package/types/modules/SelectMenu.d.ts +0 -85
- package/types/modules/index.d.ts +3 -3
- package/types/plugins/browser/audioGallery.d.ts +29 -18
- package/types/plugins/browser/fileBrowser.d.ts +38 -27
- package/types/plugins/browser/fileGallery.d.ts +29 -18
- package/types/plugins/browser/imageGallery.d.ts +24 -16
- package/types/plugins/browser/videoGallery.d.ts +29 -18
- package/types/plugins/command/blockquote.d.ts +1 -0
- package/types/plugins/command/exportPDF.d.ts +18 -18
- package/types/plugins/command/fileUpload.d.ts +65 -45
- package/types/plugins/command/list_bulleted.d.ts +1 -0
- package/types/plugins/command/list_numbered.d.ts +1 -0
- package/types/plugins/dropdown/align.d.ts +13 -8
- package/types/plugins/dropdown/backgroundColor.d.ts +30 -19
- package/types/plugins/dropdown/font.d.ts +13 -12
- package/types/plugins/dropdown/fontColor.d.ts +30 -19
- package/types/plugins/dropdown/formatBlock.d.ts +13 -8
- package/types/plugins/dropdown/hr.d.ts +15 -11
- package/types/plugins/dropdown/layout.d.ts +15 -11
- package/types/plugins/dropdown/lineHeight.d.ts +16 -11
- package/types/plugins/dropdown/list.d.ts +1 -0
- package/types/plugins/dropdown/paragraphStyle.d.ts +31 -27
- package/types/plugins/dropdown/table/index.d.ts +582 -0
- package/types/plugins/dropdown/table.d.ts +41 -86
- package/types/plugins/dropdown/template.d.ts +15 -11
- package/types/plugins/dropdown/textStyle.d.ts +19 -11
- package/types/plugins/field/mention.d.ts +58 -56
- package/types/plugins/index.d.ts +38 -38
- package/types/plugins/input/fontSize.d.ts +46 -50
- package/types/plugins/modal/audio.d.ts +26 -56
- package/types/plugins/modal/drawing.d.ts +0 -85
- package/types/plugins/modal/embed.d.ts +15 -79
- package/types/plugins/modal/image.d.ts +24 -136
- package/types/plugins/modal/link.d.ts +34 -15
- package/types/plugins/modal/math.d.ts +0 -16
- package/types/plugins/modal/video.d.ts +17 -86
- package/types/plugins/popup/anchor.d.ts +1 -8
- package/types/suneditor.d.ts +70 -19
- package/types/typedef.d.ts +60 -46
- package/src/core/base/eventHandlers/handler_ww_key_input.js +0 -1200
- package/src/core/section/context.js +0 -102
- package/types/core/section/context.d.ts +0 -45
- package/types/langs/_Lang.d.ts +0 -194
- /package/src/core/{base/eventHandlers → event/handlers}/handler_ww_clipboard.js +0 -0
- /package/types/core/{section → base}/actives.d.ts +0 -0
- /package/types/core/{base/eventHandlers → event/handlers}/handler_toolbar.d.ts +0 -0
- /package/types/core/{base/eventHandlers → event/handlers}/handler_ww_clipboard.d.ts +0 -0
- /package/types/core/{base/eventHandlers → event/handlers}/handler_ww_dragDrop.d.ts +0 -0
- /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.
|
|
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
|
-
|
|
103
|
-
this
|
|
106
|
+
|
|
107
|
+
this.#isRel = this.relList.length > 0;
|
|
104
108
|
// members - rel
|
|
105
|
-
if (this
|
|
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
|
|
131
|
-
this
|
|
132
|
-
this
|
|
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
|
|
138
|
-
this.
|
|
139
|
-
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
|
|
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
|
|
177
|
-
this
|
|
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
|
|
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.
|
|
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
|
-
|
|
222
|
+
#updateAnchor(anchor, url, displayText, title, notText) {
|
|
221
223
|
// download
|
|
222
|
-
if (!this
|
|
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
|
-
|
|
256
|
-
const href =
|
|
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
|
-
|
|
266
|
-
if (!this
|
|
265
|
+
#setRel(relAttr) {
|
|
266
|
+
if (!this.#isRel) return;
|
|
267
267
|
|
|
268
268
|
const rels = (this.currentRel = !relAttr ? [] : relAttr.split(' '));
|
|
269
|
-
const checkedRel = this
|
|
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
|
-
|
|
293
|
-
const headers = dom.query.getListChildren(this.
|
|
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
|
|
306
|
+
this.#selectMenu_bookmark.close();
|
|
308
307
|
} else {
|
|
309
|
-
this
|
|
310
|
-
this
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
410
|
+
#uploadCallBack(xmlHttp) {
|
|
417
411
|
const response = JSON.parse(xmlHttp.responseText);
|
|
418
412
|
if (response.errorMessage) {
|
|
419
|
-
this
|
|
413
|
+
this.#error(response);
|
|
420
414
|
} else {
|
|
421
|
-
this
|
|
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
|
-
|
|
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
|
|
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
|
|
478
|
-
this
|
|
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
|
|
514
|
-
if (this
|
|
515
|
-
else this
|
|
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
|
|
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
|
|
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
|
|
518
|
+
this.#createBookmarkList(url);
|
|
536
519
|
}
|
|
537
520
|
|
|
538
521
|
this.urlInput.value = url;
|
|
539
|
-
this
|
|
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
|
|
534
|
+
this.#setRel(this.#relMerge(this.defaultRel.check_new_window));
|
|
552
535
|
} else {
|
|
553
|
-
this
|
|
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
|
|
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
|
|
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('
|
|
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}">
|