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
package/src/modules/Modal.js
CHANGED
|
@@ -9,6 +9,23 @@ const DIRECTION_CURSOR_MAP = { w: 'ns-resize', h: 'ew-resize', c: 'nwse-resize',
|
|
|
9
9
|
* @description Modal window module
|
|
10
10
|
*/
|
|
11
11
|
class Modal extends CoreInjector {
|
|
12
|
+
/** @type {HTMLElement} */
|
|
13
|
+
#modalArea;
|
|
14
|
+
/** @type {HTMLElement} */
|
|
15
|
+
#modalInner;
|
|
16
|
+
/** @type {HTMLElement} */
|
|
17
|
+
#resizeBody;
|
|
18
|
+
#closeListener;
|
|
19
|
+
#bindClose;
|
|
20
|
+
#closeSignal;
|
|
21
|
+
#currentHandle;
|
|
22
|
+
#resizeDir;
|
|
23
|
+
#offetTop;
|
|
24
|
+
#offetLeft;
|
|
25
|
+
#globalEventHandlers;
|
|
26
|
+
#bindClose_mousemove;
|
|
27
|
+
#bindClose_mouseup;
|
|
28
|
+
|
|
12
29
|
/**
|
|
13
30
|
* @description Modal window module
|
|
14
31
|
* @param {* & {editor: __se__EditorCore}} inst The instance object that called the constructor.
|
|
@@ -27,44 +44,38 @@ class Modal extends CoreInjector {
|
|
|
27
44
|
|
|
28
45
|
/** @type {HTMLInputElement} */
|
|
29
46
|
this.focusElement = element.querySelector('[data-focus]');
|
|
30
|
-
/** @type {HTMLElement} */
|
|
31
|
-
this._modalArea = this.carrierWrapper.querySelector('.se-modal');
|
|
32
|
-
/** @type {HTMLElement} */
|
|
33
|
-
this._modalInner = this.carrierWrapper.querySelector('.se-modal .se-modal-inner');
|
|
34
|
-
|
|
35
|
-
this._closeListener = [this.#CloseListener.bind(this), this.#OnClick_dialog.bind(this)];
|
|
36
|
-
this._bindClose = null;
|
|
37
|
-
this._onClickEvent = null;
|
|
38
|
-
this._closeSignal = false;
|
|
39
47
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
this
|
|
48
|
+
this.#modalArea = this.carrierWrapper.querySelector('.se-modal');
|
|
49
|
+
this.#modalInner = this.carrierWrapper.querySelector('.se-modal .se-modal-inner');
|
|
50
|
+
this.#closeListener = [this.#CloseListener.bind(this), this.#OnClick_dialog.bind(this)];
|
|
51
|
+
this.#bindClose = null;
|
|
52
|
+
this.#closeSignal = false;
|
|
53
|
+
this.#resizeBody = null;
|
|
43
54
|
|
|
44
55
|
// add element
|
|
45
|
-
this.
|
|
56
|
+
this.#modalInner.appendChild(element);
|
|
46
57
|
|
|
47
58
|
// init
|
|
48
59
|
this.eventManager.addEvent(element.querySelector('form'), 'submit', this.#Action.bind(this));
|
|
49
|
-
this
|
|
60
|
+
this.#closeSignal = !this.eventManager.addEvent(element.querySelector('[data-command="close"]'), 'click', this.close.bind(this));
|
|
50
61
|
|
|
51
62
|
// resize
|
|
52
63
|
if (element.querySelector('.se-modal-resize-handle-w') || element.querySelector('.se-modal-resize-handle-h') || element.querySelector('.se-modal-resize-handle-c') || element.querySelector('.se-modal-resize-form')) {
|
|
53
|
-
if (!(this
|
|
64
|
+
if (!(this.#resizeBody = element.querySelector('.se-modal-resize-form')) && (this.#resizeBody = element.querySelector('.se-modal-body'))) {
|
|
54
65
|
this.eventManager.addEvent(element.querySelector('.se-modal-resize-handle-w'), 'mousedown', this.#OnResizeMouseDown.bind(this, 'w'));
|
|
55
66
|
this.eventManager.addEvent(element.querySelector('.se-modal-resize-handle-h'), 'mousedown', this.#OnResizeMouseDown.bind(this, 'h'));
|
|
56
67
|
this.eventManager.addEvent(element.querySelector('.se-modal-resize-handle-c'), 'mousedown', this.#OnResizeMouseDown.bind(this, 'c'));
|
|
57
68
|
|
|
58
|
-
this
|
|
59
|
-
this
|
|
60
|
-
this
|
|
61
|
-
this
|
|
62
|
-
this
|
|
69
|
+
this.#currentHandle = null;
|
|
70
|
+
this.#resizeDir = '';
|
|
71
|
+
this.#offetTop = 0;
|
|
72
|
+
this.#offetLeft = 0;
|
|
73
|
+
this.#globalEventHandlers = {
|
|
63
74
|
mousemove: this.#OnResize.bind(this),
|
|
64
75
|
mouseup: this.#OnResizeMouseUp.bind(this)
|
|
65
76
|
};
|
|
66
|
-
this
|
|
67
|
-
this
|
|
77
|
+
this.#bindClose_mousemove = null;
|
|
78
|
+
this.#bindClose_mouseup = null;
|
|
68
79
|
}
|
|
69
80
|
}
|
|
70
81
|
}
|
|
@@ -135,28 +146,28 @@ class Modal extends CoreInjector {
|
|
|
135
146
|
*/
|
|
136
147
|
open() {
|
|
137
148
|
this.ui._offCurrentModal();
|
|
138
|
-
this
|
|
149
|
+
this.#fixCurrentController(true);
|
|
139
150
|
|
|
140
|
-
if (this
|
|
141
|
-
|
|
142
|
-
this
|
|
151
|
+
if (this.#closeSignal) this.#modalInner.addEventListener('click', this.#closeListener[1]);
|
|
152
|
+
this.#bindClose &&= this.eventManager.removeGlobalEvent(this.#bindClose);
|
|
153
|
+
this.#bindClose = this.eventManager.addGlobalEvent('keydown', this.#closeListener[0]);
|
|
143
154
|
this.isUpdate = this.kind === this.editor.currentControllerName;
|
|
144
155
|
this.editor.opendModal = this;
|
|
145
156
|
|
|
146
157
|
if (!this.isUpdate && typeof this.inst.init === 'function') this.inst.init();
|
|
147
158
|
if (typeof this.inst.on === 'function') this.inst.on(this.isUpdate);
|
|
148
159
|
|
|
149
|
-
dom.utils.addClass(this
|
|
160
|
+
dom.utils.addClass(this.#modalArea, 'se-backdrop-show');
|
|
150
161
|
dom.utils.addClass(this.form, 'se-modal-show');
|
|
151
162
|
|
|
152
|
-
if (this
|
|
153
|
-
const offset = this
|
|
163
|
+
if (this.#resizeBody) {
|
|
164
|
+
const offset = this.#saveOffset();
|
|
154
165
|
const { maxWidth, maxHeight } = _w.getComputedStyle(this.form);
|
|
155
166
|
const mw = `${this.form.offsetWidth - offset.width}px`;
|
|
156
|
-
const mh = `${this.form.offsetTop + (this.form.offsetHeight - this.
|
|
167
|
+
const mh = `${this.form.offsetTop + (this.form.offsetHeight - this.#resizeBody.offsetHeight)}px`;
|
|
157
168
|
// set max
|
|
158
|
-
if (maxWidth && typeof this
|
|
159
|
-
if (maxHeight) dom.utils.setStyle(this
|
|
169
|
+
if (maxWidth && typeof this.#resizeDir === 'string') dom.utils.setStyle(this.#resizeBody, 'max-width', `calc(${maxWidth} - ${mw})`);
|
|
170
|
+
if (maxHeight) dom.utils.setStyle(this.#resizeBody, 'max-height', `calc(${maxHeight} - ${mh})`);
|
|
160
171
|
}
|
|
161
172
|
|
|
162
173
|
if (this.focusElement) this.focusElement.focus();
|
|
@@ -167,30 +178,29 @@ class Modal extends CoreInjector {
|
|
|
167
178
|
* - The plugin's "init" and "off" method is called.
|
|
168
179
|
*/
|
|
169
180
|
close() {
|
|
170
|
-
this
|
|
171
|
-
this
|
|
181
|
+
this.#removeGlobalEvent();
|
|
182
|
+
this.#fixCurrentController(false);
|
|
172
183
|
_w.setTimeout(() => {
|
|
173
184
|
this.editor.opendModal = null;
|
|
174
185
|
}, 0);
|
|
175
186
|
|
|
176
|
-
if (this
|
|
177
|
-
|
|
187
|
+
if (this.#closeSignal) this.#modalInner.removeEventListener('click', this.#closeListener[1]);
|
|
188
|
+
this.#bindClose &&= this.eventManager.removeGlobalEvent(this.#bindClose);
|
|
178
189
|
|
|
179
190
|
// close
|
|
180
|
-
dom.utils.removeClass(this
|
|
191
|
+
dom.utils.removeClass(this.#modalArea, 'se-backdrop-show');
|
|
181
192
|
dom.utils.removeClass(this.form, 'se-modal-show');
|
|
182
193
|
|
|
183
194
|
if (typeof this.inst.init === 'function') this.inst.init();
|
|
184
195
|
if (typeof this.inst.off === 'function') this.inst.off(this.isUpdate);
|
|
185
|
-
this.editor.focus();
|
|
196
|
+
if (!this.isUpdate) this.editor.focus();
|
|
186
197
|
}
|
|
187
198
|
|
|
188
199
|
/**
|
|
189
|
-
* @private
|
|
190
200
|
* @description Fixes the current controller's display state when the modal is opened or closed.
|
|
191
201
|
* @param {boolean} fixed - Whether to fix or unfix the controller.
|
|
192
202
|
*/
|
|
193
|
-
|
|
203
|
+
#fixCurrentController(fixed) {
|
|
194
204
|
const cont = this.editor.opendControllers;
|
|
195
205
|
for (let i = 0; i < cont.length; i++) {
|
|
196
206
|
cont[i].fixed = fixed;
|
|
@@ -199,37 +209,34 @@ class Modal extends CoreInjector {
|
|
|
199
209
|
}
|
|
200
210
|
|
|
201
211
|
/**
|
|
202
|
-
* @private
|
|
203
212
|
* @description Saves the current offset position of the modal for resizing calculations.
|
|
204
213
|
* @returns {__se__Class_OffsetGlobalInfo} The offset position of the modal.
|
|
205
214
|
*/
|
|
206
|
-
|
|
207
|
-
const offset = this.offset.getGlobal(this
|
|
208
|
-
this
|
|
209
|
-
this
|
|
215
|
+
#saveOffset() {
|
|
216
|
+
const offset = this.offset.getGlobal(this.#resizeBody);
|
|
217
|
+
this.#offetTop = offset.top;
|
|
218
|
+
this.#offetLeft = offset.left;
|
|
210
219
|
return offset;
|
|
211
220
|
}
|
|
212
221
|
|
|
213
222
|
/**
|
|
214
|
-
* @private
|
|
215
223
|
* @description Adds global event listeners for resizing the modal.
|
|
216
224
|
* @param {string} dir - The direction in which resizing is occurring.
|
|
217
225
|
*/
|
|
218
|
-
|
|
219
|
-
this
|
|
226
|
+
#addGlobalEvent(dir) {
|
|
227
|
+
this.#removeGlobalEvent();
|
|
220
228
|
this.ui.enableBackWrapper(DIRECTION_CURSOR_MAP[dir]);
|
|
221
|
-
this
|
|
222
|
-
this
|
|
229
|
+
this.#bindClose_mousemove = this.eventManager.addGlobalEvent('mousemove', this.#globalEventHandlers.mousemove, true);
|
|
230
|
+
this.#bindClose_mouseup = this.eventManager.addGlobalEvent('mouseup', this.#globalEventHandlers.mouseup, true);
|
|
223
231
|
}
|
|
224
232
|
|
|
225
233
|
/**
|
|
226
|
-
* @private
|
|
227
234
|
* @description Removes global event listeners related to modal resizing.
|
|
228
235
|
*/
|
|
229
|
-
|
|
236
|
+
#removeGlobalEvent() {
|
|
230
237
|
this.ui.disableBackWrapper();
|
|
231
|
-
|
|
232
|
-
|
|
238
|
+
this.#bindClose_mousemove &&= this.eventManager.removeGlobalEvent(this.#bindClose_mousemove);
|
|
239
|
+
this.#bindClose_mouseup &&= this.eventManager.removeGlobalEvent(this.#bindClose_mouseup);
|
|
233
240
|
}
|
|
234
241
|
|
|
235
242
|
/**
|
|
@@ -270,7 +277,7 @@ class Modal extends CoreInjector {
|
|
|
270
277
|
*/
|
|
271
278
|
#OnClick_dialog(e) {
|
|
272
279
|
const eventTarget = dom.query.getEventTarget(e);
|
|
273
|
-
if (/close/.test(eventTarget.getAttribute('data-command')) || eventTarget === this
|
|
280
|
+
if (/close/.test(eventTarget.getAttribute('data-command')) || eventTarget === this.#modalInner) {
|
|
274
281
|
this.close();
|
|
275
282
|
}
|
|
276
283
|
}
|
|
@@ -289,57 +296,57 @@ class Modal extends CoreInjector {
|
|
|
289
296
|
* @param {MouseEvent} e - Event object
|
|
290
297
|
*/
|
|
291
298
|
#OnResizeMouseDown(dir, e) {
|
|
292
|
-
this
|
|
293
|
-
dom.utils.addClass(this
|
|
294
|
-
this
|
|
299
|
+
this.#currentHandle = dom.query.getEventTarget(e);
|
|
300
|
+
dom.utils.addClass(this.#currentHandle, 'active');
|
|
301
|
+
this.#addGlobalEvent((this.#resizeDir = dir + (this.options.get('_rtl') ? 'RTL' : '')));
|
|
295
302
|
}
|
|
296
303
|
|
|
297
304
|
/**
|
|
298
305
|
* @param {MouseEvent} e - Event object
|
|
299
306
|
*/
|
|
300
307
|
#OnResize(e) {
|
|
301
|
-
switch (this
|
|
308
|
+
switch (this.#resizeDir) {
|
|
302
309
|
case 'w':
|
|
303
310
|
case 'wRTL': {
|
|
304
|
-
const h = e.clientY - this
|
|
305
|
-
this.
|
|
311
|
+
const h = e.clientY - this.#offetTop - this.#resizeBody.offsetHeight;
|
|
312
|
+
this.#resizeBody.style.height = this.#resizeBody.offsetHeight + h + 'px';
|
|
306
313
|
break;
|
|
307
314
|
}
|
|
308
315
|
case 'h': {
|
|
309
|
-
const w = e.clientX - this
|
|
310
|
-
this.
|
|
316
|
+
const w = e.clientX - this.#offetLeft - this.#resizeBody.offsetWidth;
|
|
317
|
+
this.#resizeBody.style.width = this.#resizeBody.offsetWidth + w + 'px';
|
|
311
318
|
break;
|
|
312
319
|
}
|
|
313
320
|
case 'hRTL': {
|
|
314
|
-
const w = this
|
|
315
|
-
this.
|
|
321
|
+
const w = this.#offetLeft - e.clientX;
|
|
322
|
+
this.#resizeBody.style.width = this.#resizeBody.offsetWidth + w + 'px';
|
|
316
323
|
break;
|
|
317
324
|
}
|
|
318
325
|
case 'c': {
|
|
319
|
-
const w = e.clientX - this
|
|
320
|
-
const h = e.clientY - this
|
|
321
|
-
this.
|
|
322
|
-
this.
|
|
326
|
+
const w = e.clientX - this.#offetLeft - this.#resizeBody.offsetWidth;
|
|
327
|
+
const h = e.clientY - this.#offetTop - this.#resizeBody.offsetHeight;
|
|
328
|
+
this.#resizeBody.style.width = this.#resizeBody.offsetWidth + w + 'px';
|
|
329
|
+
this.#resizeBody.style.height = this.#resizeBody.offsetHeight + h + 'px';
|
|
323
330
|
break;
|
|
324
331
|
}
|
|
325
332
|
case 'cRTL': {
|
|
326
|
-
const w = this
|
|
327
|
-
const h = e.clientY - this
|
|
328
|
-
this.
|
|
329
|
-
this.
|
|
333
|
+
const w = this.#offetLeft - e.clientX;
|
|
334
|
+
const h = e.clientY - this.#offetTop - this.#resizeBody.offsetHeight;
|
|
335
|
+
this.#resizeBody.style.width = this.#resizeBody.offsetWidth + w + 'px';
|
|
336
|
+
this.#resizeBody.style.height = this.#resizeBody.offsetHeight + h + 'px';
|
|
330
337
|
break;
|
|
331
338
|
}
|
|
332
339
|
}
|
|
333
340
|
|
|
334
|
-
this
|
|
341
|
+
this.#saveOffset();
|
|
335
342
|
|
|
336
343
|
if (typeof this.inst.modalResize === 'function') this.inst.modalResize();
|
|
337
344
|
}
|
|
338
345
|
|
|
339
346
|
#OnResizeMouseUp() {
|
|
340
|
-
dom.utils.removeClass(this
|
|
341
|
-
this
|
|
342
|
-
this
|
|
347
|
+
dom.utils.removeClass(this.#currentHandle, 'active');
|
|
348
|
+
this.#currentHandle = null;
|
|
349
|
+
this.#removeGlobalEvent();
|
|
343
350
|
}
|
|
344
351
|
}
|
|
345
352
|
|