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
|
@@ -128,93 +128,6 @@ class FileManager extends CoreInjector {
|
|
|
128
128
|
/** @type {Element} */ (element).setAttribute('data-se-file-size', size + '');
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
/**
|
|
132
|
-
* @private
|
|
133
|
-
* @description Create info object of file and add it to "infoList"
|
|
134
|
-
* @param {HTMLMediaElement} element
|
|
135
|
-
* @param {{name: string, size: number}|null} file File information
|
|
136
|
-
*/
|
|
137
|
-
_setInfo(element, file) {
|
|
138
|
-
let dataIndex = Number(GetAttr(element, 'index'));
|
|
139
|
-
let info = null;
|
|
140
|
-
let state = '';
|
|
141
|
-
|
|
142
|
-
if (!file) {
|
|
143
|
-
file = {
|
|
144
|
-
name: GetAttr(element, 'file-name') || (typeof element.src === 'string' ? element.src.split('/').pop() : ''),
|
|
145
|
-
size: Number(GetAttr(element, 'file-size')) || 0
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// create
|
|
150
|
-
if (!dataIndex || this.editor._componentsInfoInit) {
|
|
151
|
-
state = 'create';
|
|
152
|
-
dataIndex = this.infoIndex++;
|
|
153
|
-
|
|
154
|
-
element.setAttribute('data-se-index', dataIndex + '');
|
|
155
|
-
element.setAttribute('data-se-file-name', file.name);
|
|
156
|
-
element.setAttribute('data-se-file-size', file.size + '');
|
|
157
|
-
|
|
158
|
-
info = {
|
|
159
|
-
src: element.src,
|
|
160
|
-
index: dataIndex,
|
|
161
|
-
name: file.name,
|
|
162
|
-
size: file.size
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
this.infoList.push(info);
|
|
166
|
-
} else {
|
|
167
|
-
// update
|
|
168
|
-
state = 'update';
|
|
169
|
-
dataIndex *= 1;
|
|
170
|
-
|
|
171
|
-
for (let i = 0, len = this.infoList.length; i < len; i++) {
|
|
172
|
-
if (dataIndex === this.infoList[i].index) {
|
|
173
|
-
info = this.infoList[i];
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (!info) {
|
|
179
|
-
dataIndex = this.infoIndex++;
|
|
180
|
-
info = {
|
|
181
|
-
index: dataIndex
|
|
182
|
-
};
|
|
183
|
-
this.infoList.push(info);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
info.src = element.src;
|
|
187
|
-
info.name = GetAttr(element, 'file-name');
|
|
188
|
-
info.size = Number(GetAttr(element, 'file-size'));
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// method bind
|
|
192
|
-
info.element = element;
|
|
193
|
-
|
|
194
|
-
info.delete = function (el) {
|
|
195
|
-
if (typeof this.inst.destroy === 'function') this.inst.destroy.call(this.inst, el);
|
|
196
|
-
this._deleteInfo(Number(GetAttr(el, 'index')));
|
|
197
|
-
}.bind(this, element);
|
|
198
|
-
// se-ts-ignore
|
|
199
|
-
void this._deleteInfo;
|
|
200
|
-
|
|
201
|
-
info.select = function (el) {
|
|
202
|
-
el.scrollIntoView(this.options.get('componentScrollToOptions'));
|
|
203
|
-
const comp = this.component.get(el);
|
|
204
|
-
if (comp) {
|
|
205
|
-
this.component.select(comp.target, comp.pluginName);
|
|
206
|
-
} else if (typeof this.inst.select === 'function') {
|
|
207
|
-
this.inst.select(el);
|
|
208
|
-
}
|
|
209
|
-
}.bind(this, element);
|
|
210
|
-
|
|
211
|
-
const params = { editor: this.editor, element, index: dataIndex, state, info, remainingFilesCount: --this.uploadFileLength < 0 ? 0 : this.uploadFileLength, pluginName: this.kind };
|
|
212
|
-
if (typeof this.eventHandler === 'function') {
|
|
213
|
-
this.eventHandler(params);
|
|
214
|
-
}
|
|
215
|
-
this.triggerEvent('onFileManagerAction', { ...params, pluginName: this.kind });
|
|
216
|
-
}
|
|
217
|
-
|
|
218
131
|
/**
|
|
219
132
|
* @description Gets the sum of the sizes of the currently saved files.
|
|
220
133
|
* @returns {number} Size
|
|
@@ -233,13 +146,13 @@ class FileManager extends CoreInjector {
|
|
|
233
146
|
* @param {boolean} loaded Whether the editor is loaded
|
|
234
147
|
*/
|
|
235
148
|
_checkInfo(loaded) {
|
|
236
|
-
const tags = [].slice.call(this.
|
|
149
|
+
const tags = [].slice.call(this.frameContext.get('wysiwyg').querySelectorAll(this.query));
|
|
237
150
|
const infoList = this.infoList;
|
|
238
151
|
if (tags.length === infoList.length) {
|
|
239
152
|
// reset
|
|
240
153
|
if (this.editor._componentsInfoReset) {
|
|
241
154
|
for (let i = 0, len = tags.length; i < len; i++) {
|
|
242
|
-
this
|
|
155
|
+
this.#setInfo(tags[i], null);
|
|
243
156
|
}
|
|
244
157
|
return;
|
|
245
158
|
} else {
|
|
@@ -274,7 +187,7 @@ class FileManager extends CoreInjector {
|
|
|
274
187
|
if (!GetAttr(tag, 'index') || !infoIndex.includes(Number(GetAttr(tag, 'index')))) {
|
|
275
188
|
currentTags.push(this.infoIndex);
|
|
276
189
|
tag.removeAttribute('data-se-index');
|
|
277
|
-
this
|
|
190
|
+
this.#setInfo(tag, null);
|
|
278
191
|
} else {
|
|
279
192
|
currentTags.push(Number(GetAttr(tag, 'index')));
|
|
280
193
|
}
|
|
@@ -319,11 +232,10 @@ class FileManager extends CoreInjector {
|
|
|
319
232
|
}
|
|
320
233
|
|
|
321
234
|
/**
|
|
322
|
-
* @private
|
|
323
235
|
* @description Delete info object at "infoList"
|
|
324
236
|
* @param {number} index index of info object infoList[].index)
|
|
325
237
|
*/
|
|
326
|
-
|
|
238
|
+
#deleteInfo(index) {
|
|
327
239
|
if (index >= 0) {
|
|
328
240
|
for (let i = 0, len = this.infoList.length; i < len; i++) {
|
|
329
241
|
if (index === this.infoList[i].index) {
|
|
@@ -336,6 +248,88 @@ class FileManager extends CoreInjector {
|
|
|
336
248
|
}
|
|
337
249
|
}
|
|
338
250
|
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* @description Create info object of file and add it to "infoList"
|
|
254
|
+
* @param {HTMLMediaElement} element
|
|
255
|
+
* @param {{name: string, size: number}|null} file File information
|
|
256
|
+
*/
|
|
257
|
+
#setInfo(element, file) {
|
|
258
|
+
let dataIndex = Number(GetAttr(element, 'index'));
|
|
259
|
+
let info = null;
|
|
260
|
+
let state = '';
|
|
261
|
+
|
|
262
|
+
file ||= {
|
|
263
|
+
name: GetAttr(element, 'file-name') || (typeof element.src === 'string' ? element.src.split('/').pop() : ''),
|
|
264
|
+
size: Number(GetAttr(element, 'file-size')) || 0
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
// create
|
|
268
|
+
if (!dataIndex || this.editor._componentsInfoInit) {
|
|
269
|
+
state = 'create';
|
|
270
|
+
dataIndex = this.infoIndex++;
|
|
271
|
+
|
|
272
|
+
element.setAttribute('data-se-index', dataIndex + '');
|
|
273
|
+
element.setAttribute('data-se-file-name', file.name);
|
|
274
|
+
element.setAttribute('data-se-file-size', file.size + '');
|
|
275
|
+
|
|
276
|
+
info = {
|
|
277
|
+
src: element.src,
|
|
278
|
+
index: dataIndex,
|
|
279
|
+
name: file.name,
|
|
280
|
+
size: file.size
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
this.infoList.push(info);
|
|
284
|
+
} else {
|
|
285
|
+
// update
|
|
286
|
+
state = 'update';
|
|
287
|
+
dataIndex *= 1;
|
|
288
|
+
|
|
289
|
+
for (let i = 0, len = this.infoList.length; i < len; i++) {
|
|
290
|
+
if (dataIndex === this.infoList[i].index) {
|
|
291
|
+
info = this.infoList[i];
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
if (!info) {
|
|
297
|
+
dataIndex = this.infoIndex++;
|
|
298
|
+
info = {
|
|
299
|
+
index: dataIndex
|
|
300
|
+
};
|
|
301
|
+
this.infoList.push(info);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
info.src = element.src;
|
|
305
|
+
info.name = GetAttr(element, 'file-name');
|
|
306
|
+
info.size = Number(GetAttr(element, 'file-size'));
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// method bind
|
|
310
|
+
info.element = element;
|
|
311
|
+
|
|
312
|
+
info.delete = function (deleteCallback, el) {
|
|
313
|
+
if (typeof this.inst.destroy === 'function') this.inst.destroy.call(this.inst, el);
|
|
314
|
+
deleteCallback(Number(GetAttr(el, 'index')));
|
|
315
|
+
}.bind(this, this.#deleteInfo.bind(this), element);
|
|
316
|
+
|
|
317
|
+
info.select = function (el) {
|
|
318
|
+
el.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'nearest' });
|
|
319
|
+
const comp = this.component.get(el);
|
|
320
|
+
if (comp) {
|
|
321
|
+
this.component.select(comp.target, comp.pluginName);
|
|
322
|
+
} else if (typeof this.inst.select === 'function') {
|
|
323
|
+
this.inst.select(el);
|
|
324
|
+
}
|
|
325
|
+
}.bind(this, element);
|
|
326
|
+
|
|
327
|
+
const params = { editor: this.editor, element, index: dataIndex, state, info, remainingFilesCount: --this.uploadFileLength < 0 ? 0 : this.uploadFileLength, pluginName: this.kind };
|
|
328
|
+
if (typeof this.eventHandler === 'function') {
|
|
329
|
+
this.eventHandler(params);
|
|
330
|
+
}
|
|
331
|
+
this.triggerEvent('onFileManagerAction', { ...params, pluginName: this.kind });
|
|
332
|
+
}
|
|
339
333
|
}
|
|
340
334
|
|
|
341
335
|
/**
|
package/src/modules/HueSlider.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { dom, env } from '../helper';
|
|
6
6
|
import Controller from './Controller';
|
|
7
7
|
|
|
8
|
-
const {
|
|
8
|
+
const { isTouchDevice } = env;
|
|
9
9
|
|
|
10
10
|
const SIZE = 240;
|
|
11
11
|
const BAR_H = 28;
|
|
@@ -25,6 +25,8 @@ let wheelY = SIZE / 2;
|
|
|
25
25
|
let finalColor = DEFAULT_COLOR_VALUE;
|
|
26
26
|
let ctx;
|
|
27
27
|
|
|
28
|
+
let _bootstrapped = false;
|
|
29
|
+
|
|
28
30
|
function CreateSliderCtx() {
|
|
29
31
|
const offscreenCanvas = document.createElement('canvas');
|
|
30
32
|
offscreenCanvas.width = SIZE;
|
|
@@ -93,15 +95,20 @@ function CreateSliderCtx() {
|
|
|
93
95
|
* It must be called every time it is used.
|
|
94
96
|
*/
|
|
95
97
|
class HueSlider {
|
|
98
|
+
#globalMouseDown;
|
|
99
|
+
#globalTouchMove;
|
|
100
|
+
#globalMouseUp;
|
|
101
|
+
#globalMouseMove;
|
|
102
|
+
#globalTouchStart;
|
|
103
|
+
#globalTouchEnd;
|
|
104
|
+
|
|
96
105
|
/**
|
|
97
106
|
* @constructor
|
|
98
107
|
* @param {*} inst The instance object that called the constructor.
|
|
99
108
|
* @param {HueSliderParams} [params={}] Hue slider options
|
|
100
109
|
* @param {string} [className=""] The class name of the hue slider.
|
|
101
110
|
*/
|
|
102
|
-
constructor(inst, params, className) {
|
|
103
|
-
if (!params) params = {};
|
|
104
|
-
|
|
111
|
+
constructor(inst, params = {}, className = '') {
|
|
105
112
|
this.editor = inst.editor;
|
|
106
113
|
this.eventManager = inst.eventManager;
|
|
107
114
|
this.inst = inst;
|
|
@@ -119,9 +126,13 @@ class HueSlider {
|
|
|
119
126
|
};
|
|
120
127
|
this.isOpen = false;
|
|
121
128
|
this.controlle = null;
|
|
122
|
-
|
|
123
|
-
this
|
|
124
|
-
this
|
|
129
|
+
|
|
130
|
+
this.#globalMouseDown = null;
|
|
131
|
+
this.#globalTouchMove = null;
|
|
132
|
+
this.#globalMouseUp = null;
|
|
133
|
+
this.#globalMouseMove = null;
|
|
134
|
+
this.#globalTouchStart = null;
|
|
135
|
+
this.#globalTouchEnd = null;
|
|
125
136
|
|
|
126
137
|
// init default controller
|
|
127
138
|
if (!params.isNewForm) {
|
|
@@ -189,6 +200,8 @@ class HueSlider {
|
|
|
189
200
|
* @param {?Node=} form The element to attach the hue slider.
|
|
190
201
|
*/
|
|
191
202
|
attach(form) {
|
|
203
|
+
if (!_bootstrapped) InitRender();
|
|
204
|
+
|
|
192
205
|
// drow
|
|
193
206
|
this.init();
|
|
194
207
|
(form || this.form).appendChild(slider);
|
|
@@ -206,30 +219,34 @@ class HueSlider {
|
|
|
206
219
|
createGradientBar(getDefaultColor());
|
|
207
220
|
}
|
|
208
221
|
|
|
209
|
-
// event
|
|
210
|
-
|
|
211
|
-
const moveEvent = { name: 'mousemove', func: OnMousemove, option: true };
|
|
212
|
-
const upEvent = {
|
|
213
|
-
name: 'mouseup',
|
|
214
|
-
func: () => {
|
|
215
|
-
isWheelragging = false;
|
|
216
|
-
isBarDragging = false;
|
|
217
|
-
}
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
if (isMobile) {
|
|
222
|
+
// touch event
|
|
223
|
+
if (isTouchDevice) {
|
|
221
224
|
// mobile name
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
225
|
+
this.#globalTouchStart = this.eventManager.addGlobalEvent('touchstart', OnTouchstart, { passive: false, capture: true });
|
|
226
|
+
this.#globalTouchMove = this.eventManager.addGlobalEvent('touchmove', OnTouchmove, true);
|
|
227
|
+
this.#globalTouchEnd = this.eventManager.addGlobalEvent(
|
|
228
|
+
'touchend',
|
|
229
|
+
() => {
|
|
230
|
+
isWheelragging = false;
|
|
231
|
+
isBarDragging = false;
|
|
232
|
+
},
|
|
233
|
+
true
|
|
234
|
+
);
|
|
228
235
|
}
|
|
229
236
|
|
|
230
|
-
|
|
231
|
-
this
|
|
232
|
-
this
|
|
237
|
+
// mouse event
|
|
238
|
+
this.#globalMouseDown = this.eventManager.addGlobalEvent('mousedown', OnMousedown, { passive: false, capture: true });
|
|
239
|
+
this.#globalMouseMove = this.eventManager.addGlobalEvent('mousemove', OnMousemove, true);
|
|
240
|
+
this.#globalMouseUp = this.eventManager.addGlobalEvent(
|
|
241
|
+
'mouseup',
|
|
242
|
+
() => {
|
|
243
|
+
isWheelragging = false;
|
|
244
|
+
isBarDragging = false;
|
|
245
|
+
},
|
|
246
|
+
true
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
// open
|
|
233
250
|
this.isOpen = true;
|
|
234
251
|
}
|
|
235
252
|
|
|
@@ -240,9 +257,14 @@ class HueSlider {
|
|
|
240
257
|
this.isOpen = false;
|
|
241
258
|
isWheelragging = false;
|
|
242
259
|
isBarDragging = false;
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
260
|
+
|
|
261
|
+
this.#globalMouseDown &&= this.eventManager.removeGlobalEvent(this.#globalMouseDown);
|
|
262
|
+
this.#globalMouseMove &&= this.eventManager.removeGlobalEvent(this.#globalMouseMove);
|
|
263
|
+
this.#globalMouseUp &&= this.eventManager.removeGlobalEvent(this.#globalMouseUp);
|
|
264
|
+
|
|
265
|
+
this.#globalTouchStart &&= this.eventManager.removeGlobalEvent(this.#globalTouchStart);
|
|
266
|
+
this.#globalTouchMove &&= this.eventManager.removeGlobalEvent(this.#globalTouchMove);
|
|
267
|
+
this.#globalTouchEnd &&= this.eventManager.removeGlobalEvent(this.#globalTouchEnd);
|
|
246
268
|
}
|
|
247
269
|
}
|
|
248
270
|
|
|
@@ -439,7 +461,10 @@ function drawWheelGradient() {
|
|
|
439
461
|
}
|
|
440
462
|
|
|
441
463
|
function drawColorWheelToContext(context) {
|
|
442
|
-
if (!context)
|
|
464
|
+
if (!context) {
|
|
465
|
+
console.warn('[HueSlider.fail] Context not found.');
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
443
468
|
|
|
444
469
|
const fixedSaturation = SATURATION * 100;
|
|
445
470
|
|
|
@@ -458,6 +483,8 @@ function drawColorWheelToContext(context) {
|
|
|
458
483
|
context.fill();
|
|
459
484
|
}
|
|
460
485
|
}
|
|
486
|
+
|
|
487
|
+
_bootstrapped = true;
|
|
461
488
|
}
|
|
462
489
|
|
|
463
490
|
function degreeToRadian(deg) {
|
|
@@ -542,9 +569,13 @@ function roundNumber(num) {
|
|
|
542
569
|
return Math.round(num * factor) / factor;
|
|
543
570
|
}
|
|
544
571
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
572
|
+
function InitRender() {
|
|
573
|
+
// create
|
|
574
|
+
drawColorWheelToContext(offscreenCtx);
|
|
575
|
+
if (_bootstrapped) drawColorWheel();
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
InitRender();
|
|
548
579
|
|
|
549
580
|
function CreateHTML_basicControllerForm({ lang, icons }, className) {
|
|
550
581
|
const hueController = dom.utils.createElement(
|
|
@@ -562,4 +593,5 @@ function CreateHTML_basicControllerForm({ lang, icons }, className) {
|
|
|
562
593
|
return hueController;
|
|
563
594
|
}
|
|
564
595
|
|
|
596
|
+
export { CreateSliderCtx };
|
|
565
597
|
export default HueSlider;
|