suneditor 3.1.4 → 3.2.1
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/dist/suneditor-contents.min.css +1 -1
- package/dist/suneditor.min.css +28 -1
- package/dist/suneditor.min.js +1 -1
- package/package.json +2 -1
- package/src/assets/design/color.css +12 -0
- package/src/assets/design/size.css +9 -2
- package/src/assets/icons/defaultIcons.js +96 -47
- package/src/assets/suneditor-contents.css +3 -2
- package/src/assets/suneditor.css +481 -31
- package/src/core/config/contextProvider.js +2 -1
- package/src/core/config/eventManager.js +41 -2
- package/src/core/config/optionProvider.js +23 -2
- package/src/core/editor.js +32 -14
- package/src/core/event/actions/index.js +76 -9
- package/src/core/event/effects/common.registry.js +2 -1
- package/src/core/event/effects/keydown.registry.js +169 -33
- package/src/core/event/effects/ruleHelpers.js +20 -6
- package/src/core/event/eventOrchestrator.js +162 -30
- package/src/core/event/handlers/handler_toolbar.js +4 -2
- package/src/core/event/handlers/handler_ww_dragDrop.js +10 -0
- package/src/core/event/handlers/handler_ww_input.js +84 -2
- package/src/core/event/handlers/handler_ww_key.js +82 -21
- package/src/core/event/handlers/handler_ww_mouse.js +45 -8
- package/src/core/event/ports.js +27 -13
- package/src/core/event/reducers/keydown.reducer.js +33 -5
- package/src/core/event/rules/keydown.rule.arrow.js +12 -2
- package/src/core/event/rules/keydown.rule.backspace.js +110 -15
- package/src/core/event/rules/keydown.rule.delete.js +62 -7
- package/src/core/event/rules/keydown.rule.enter.js +62 -31
- package/src/core/event/support/defaultLineManager.js +9 -2
- package/src/core/event/support/selectionState.js +13 -3
- package/src/core/kernel/coreKernel.js +1 -0
- package/src/core/logic/dom/char.js +13 -3
- package/src/core/logic/dom/format.js +171 -39
- package/src/core/logic/dom/html.js +350 -72
- package/src/core/logic/dom/inline.js +229 -34
- package/src/core/logic/dom/listFormat.js +111 -20
- package/src/core/logic/dom/nodeTransform.js +36 -11
- package/src/core/logic/dom/offset.js +116 -31
- package/src/core/logic/dom/selection.js +147 -29
- package/src/core/logic/panel/blockHandle.js +785 -0
- package/src/core/logic/panel/blockResolver.js +278 -0
- package/src/core/logic/panel/finder.js +16 -6
- package/src/core/logic/panel/menu.js +119 -18
- package/src/core/logic/panel/toolbar.js +75 -19
- package/src/core/logic/panel/viewer.js +76 -20
- package/src/core/logic/shell/_commandExecutor.js +44 -9
- package/src/core/logic/shell/commandDispatcher.js +46 -4
- package/src/core/logic/shell/component.js +102 -25
- package/src/core/logic/shell/focusManager.js +13 -3
- package/src/core/logic/shell/history.js +21 -6
- package/src/core/logic/shell/pluginManager.js +21 -13
- package/src/core/logic/shell/shortcuts.js +9 -1
- package/src/core/logic/shell/ui.js +139 -37
- package/src/core/schema/frameContext.js +34 -3
- package/src/core/schema/options.js +46 -4
- package/src/core/section/constructor.js +537 -106
- package/src/core/section/documentType.js +35 -6
- package/src/helper/converter.js +24 -7
- package/src/helper/dom/domCheck.js +25 -5
- package/src/helper/dom/domQuery.js +2 -1
- package/src/helper/dom/domUtils.js +17 -4
- package/src/helper/env.js +11 -2
- package/src/helper/keyCodeMap.js +6 -2
- package/src/helper/markdown.js +24 -5
- package/src/helper/msOffice.js +9 -2
- package/src/interfaces/plugins.js +1 -1
- package/src/langs/ckb.js +0 -1
- package/src/langs/cs.js +0 -1
- package/src/langs/da.js +0 -1
- package/src/langs/de.js +0 -1
- package/src/langs/en.js +0 -1
- package/src/langs/es.js +0 -1
- package/src/langs/fa.js +0 -1
- package/src/langs/fr.js +0 -1
- package/src/langs/he.js +0 -1
- package/src/langs/hu.js +0 -1
- package/src/langs/index.js +27 -1
- package/src/langs/it.js +0 -1
- package/src/langs/ja.js +0 -1
- package/src/langs/km.js +0 -1
- package/src/langs/ko.js +0 -1
- package/src/langs/lv.js +0 -1
- package/src/langs/nl.js +0 -1
- package/src/langs/pl.js +0 -1
- package/src/langs/pt_br.js +0 -1
- package/src/langs/ro.js +0 -1
- package/src/langs/ru.js +0 -1
- package/src/langs/se.js +0 -1
- package/src/langs/tr.js +0 -1
- package/src/langs/uk.js +0 -1
- package/src/langs/ur.js +0 -1
- package/src/langs/zh_cn.js +0 -1
- package/src/modules/contract/Browser.js +58 -14
- package/src/modules/contract/ColorPicker.js +12 -4
- package/src/modules/contract/Controller.js +37 -7
- package/src/modules/contract/Figure.js +156 -36
- package/src/modules/contract/HueSlider.js +27 -4
- package/src/modules/contract/Modal.js +50 -10
- package/src/modules/manager/FileManager.js +50 -8
- package/src/modules/ui/CommandMenu.js +597 -0
- package/src/modules/ui/ModalAnchorEditor.js +33 -6
- package/src/modules/ui/SelectMenu.js +481 -36
- package/src/modules/ui/index.js +1 -0
- package/src/plugins/browser/audioGallery.js +2 -1
- package/src/plugins/browser/fileBrowser.js +9 -2
- package/src/plugins/browser/fileGallery.js +2 -1
- package/src/plugins/browser/imageGallery.js +18 -3
- package/src/plugins/browser/videoGallery.js +13 -4
- package/src/plugins/command/blockquote.js +6 -1
- package/src/plugins/command/codeBlock.js +43 -5
- package/src/plugins/command/exportPDF.js +20 -4
- package/src/plugins/command/fileUpload.js +46 -11
- package/src/plugins/command/list_bulleted.js +6 -1
- package/src/plugins/command/list_numbered.js +6 -1
- package/src/plugins/dropdown/align.js +21 -33
- package/src/plugins/dropdown/backgroundColor.js +10 -2
- package/src/plugins/dropdown/blockStyle.js +17 -22
- package/src/plugins/dropdown/font.js +34 -34
- package/src/plugins/dropdown/hr.js +15 -43
- package/src/plugins/dropdown/layout.js +10 -27
- package/src/plugins/dropdown/lineHeight.js +10 -33
- package/src/plugins/dropdown/list.js +19 -25
- package/src/plugins/dropdown/paragraphStyle.js +16 -24
- package/src/plugins/dropdown/table/index.js +72 -17
- package/src/plugins/dropdown/table/render/table.html.js +3 -1
- package/src/plugins/dropdown/table/services/table.cell.js +33 -7
- package/src/plugins/dropdown/table/services/table.clipboard.js +5 -1
- package/src/plugins/dropdown/table/services/table.grid.js +40 -9
- package/src/plugins/dropdown/table/services/table.resize.js +55 -11
- package/src/plugins/dropdown/table/services/table.selection.js +27 -7
- package/src/plugins/dropdown/table/services/table.style.js +120 -20
- package/src/plugins/dropdown/template.js +13 -29
- package/src/plugins/dropdown/textStyle.js +22 -35
- package/src/plugins/field/autocomplete.js +8 -4
- package/src/plugins/field/slashCommand.js +297 -0
- package/src/plugins/index.js +3 -0
- package/src/plugins/input/fontSize.js +37 -8
- package/src/plugins/input/pageNavigator.js +7 -1
- package/src/plugins/modal/audio.js +71 -17
- package/src/plugins/modal/drawing.js +41 -11
- package/src/plugins/modal/embed.js +92 -22
- package/src/plugins/modal/image/index.js +114 -28
- package/src/plugins/modal/image/services/image.size.js +9 -2
- package/src/plugins/modal/image/services/image.upload.js +38 -4
- package/src/plugins/modal/link.js +9 -2
- package/src/plugins/modal/math.js +10 -2
- package/src/plugins/modal/video/index.js +112 -26
- package/src/plugins/modal/video/render/video.html.js +4 -1
- package/src/plugins/modal/video/services/video.size.js +15 -4
- package/src/plugins/modal/video/services/video.upload.js +10 -2
- package/src/plugins/popup/anchor.js +14 -2
- package/src/suneditor.js +8 -2
- package/src/themes/cobalt.css +12 -0
- package/src/themes/cream.css +12 -0
- package/src/themes/dark.css +12 -0
- package/src/themes/midnight.css +12 -0
- package/src/typedef.js +32 -21
- package/types/assets/icons/defaultIcons.d.ts +1 -0
- package/types/core/config/contextProvider.d.ts +7 -1
- package/types/core/config/eventManager.d.ts +37 -4
- package/types/core/config/optionProvider.d.ts +5 -1
- package/types/core/event/actions/index.d.ts +44 -6
- package/types/core/event/effects/keydown.registry.d.ts +37 -7
- package/types/core/event/effects/ruleHelpers.d.ts +6 -1
- package/types/core/event/eventOrchestrator.d.ts +13 -3
- package/types/core/event/handlers/handler_ww_clipboard.d.ts +15 -3
- package/types/core/event/handlers/handler_ww_dragDrop.d.ts +14 -2
- package/types/core/event/handlers/handler_ww_input.d.ts +10 -2
- package/types/core/event/handlers/handler_ww_key.d.ts +10 -2
- package/types/core/event/handlers/handler_ww_mouse.d.ts +25 -5
- package/types/core/event/ports.d.ts +11 -4
- package/types/core/event/reducers/keydown.reducer.d.ts +12 -3
- package/types/core/event/rules/keydown.rule.backspace.d.ts +6 -1
- package/types/core/kernel/store.d.ts +4 -1
- package/types/core/logic/dom/format.d.ts +32 -14
- package/types/core/logic/dom/html.d.ts +11 -3
- package/types/core/logic/dom/nodeTransform.d.ts +6 -6
- package/types/core/logic/panel/blockHandle.d.ts +64 -0
- package/types/core/logic/panel/blockResolver.d.ts +50 -0
- package/types/core/logic/panel/menu.d.ts +72 -3
- package/types/core/logic/shell/commandDispatcher.d.ts +8 -0
- package/types/core/logic/shell/component.d.ts +5 -3
- package/types/core/logic/shell/shortcuts.d.ts +10 -1
- package/types/core/logic/shell/ui.d.ts +7 -1
- package/types/core/schema/context.d.ts +7 -1
- package/types/core/schema/frameContext.d.ts +36 -4
- package/types/core/schema/options.d.ts +83 -2
- package/types/core/section/constructor.d.ts +38 -1
- package/types/events.d.ts +208 -32
- package/types/helper/converter.d.ts +4 -2
- package/types/helper/dom/domCheck.d.ts +12 -2
- package/types/helper/dom/domQuery.d.ts +35 -7
- package/types/helper/dom/domUtils.d.ts +4 -1
- package/types/interfaces/plugins.d.ts +2 -2
- package/types/langs/_Lang.d.ts +0 -1
- package/types/modules/contract/ColorPicker.d.ts +2 -2
- package/types/modules/contract/Controller.d.ts +7 -0
- package/types/modules/contract/Figure.d.ts +31 -4
- package/types/modules/ui/CommandMenu.d.ts +262 -0
- package/types/modules/ui/SelectMenu.d.ts +56 -3
- package/types/modules/ui/index.d.ts +1 -0
- package/types/plugins/browser/audioGallery.d.ts +1 -1
- package/types/plugins/browser/fileBrowser.d.ts +1 -1
- package/types/plugins/browser/fileGallery.d.ts +1 -1
- package/types/plugins/browser/imageGallery.d.ts +1 -1
- package/types/plugins/browser/videoGallery.d.ts +1 -1
- package/types/plugins/dropdown/align.d.ts +1 -1
- package/types/plugins/dropdown/blockStyle.d.ts +3 -1
- package/types/plugins/dropdown/table/index.d.ts +4 -1
- package/types/plugins/dropdown/table/services/table.clipboard.d.ts +5 -1
- package/types/plugins/dropdown/table/services/table.grid.d.ts +10 -2
- package/types/plugins/field/autocomplete.d.ts +0 -1
- package/types/plugins/field/slashCommand.d.ts +165 -0
- package/types/plugins/index.d.ts +3 -0
- package/types/plugins/modal/link.d.ts +4 -1
- package/types/typedef.d.ts +48 -23
|
@@ -76,16 +76,30 @@ class Audio_ extends PluginModal {
|
|
|
76
76
|
|
|
77
77
|
// define plugin options
|
|
78
78
|
this.pluginOptions = {
|
|
79
|
-
defaultWidth: !pluginOptions.defaultWidth
|
|
80
|
-
|
|
79
|
+
defaultWidth: !pluginOptions.defaultWidth
|
|
80
|
+
? ''
|
|
81
|
+
: numbers.is(pluginOptions.defaultWidth)
|
|
82
|
+
? pluginOptions.defaultWidth + 'px'
|
|
83
|
+
: pluginOptions.defaultWidth,
|
|
84
|
+
defaultHeight: !pluginOptions.defaultHeight
|
|
85
|
+
? ''
|
|
86
|
+
: numbers.is(pluginOptions.defaultHeight)
|
|
87
|
+
? pluginOptions.defaultHeight + 'px'
|
|
88
|
+
: pluginOptions.defaultHeight,
|
|
81
89
|
createFileInput: !!pluginOptions.createFileInput,
|
|
82
|
-
createUrlInput:
|
|
90
|
+
createUrlInput:
|
|
91
|
+
pluginOptions.createUrlInput === undefined || !pluginOptions.createFileInput
|
|
92
|
+
? true
|
|
93
|
+
: pluginOptions.createUrlInput,
|
|
83
94
|
uploadUrl: typeof pluginOptions.uploadUrl === 'string' ? pluginOptions.uploadUrl : null,
|
|
84
95
|
uploadHeaders: pluginOptions.uploadHeaders || null,
|
|
85
96
|
uploadSizeLimit: numbers.get(pluginOptions.uploadSizeLimit, 0),
|
|
86
97
|
uploadSingleSizeLimit: numbers.get(pluginOptions.uploadSingleSizeLimit, 0),
|
|
87
98
|
allowMultiple: !!pluginOptions.allowMultiple,
|
|
88
|
-
acceptedFormats:
|
|
99
|
+
acceptedFormats:
|
|
100
|
+
typeof pluginOptions.acceptedFormats !== 'string' || pluginOptions.acceptedFormats.trim() === '*'
|
|
101
|
+
? 'audio/*'
|
|
102
|
+
: pluginOptions.acceptedFormats.trim() || 'audio/*',
|
|
89
103
|
audioTagAttributes: pluginOptions.audioTagAttributes || null,
|
|
90
104
|
insertBehavior: pluginOptions.insertBehavior,
|
|
91
105
|
};
|
|
@@ -124,7 +138,11 @@ class Audio_ extends PluginModal {
|
|
|
124
138
|
|
|
125
139
|
// init
|
|
126
140
|
if (this.audioInputFile) {
|
|
127
|
-
this.$.eventManager.addEvent(
|
|
141
|
+
this.$.eventManager.addEvent(
|
|
142
|
+
modalEl.querySelector('.se-modal-files-edge-button'),
|
|
143
|
+
'click',
|
|
144
|
+
this.#RemoveSelectedFiles.bind(this, this.audioUrlFile, this.preview),
|
|
145
|
+
);
|
|
128
146
|
if (this.audioUrlFile) {
|
|
129
147
|
this.$.eventManager.addEvent(this.audioInputFile, 'change', this.#FileInputChange.bind(this));
|
|
130
148
|
}
|
|
@@ -177,12 +195,15 @@ class Audio_ extends PluginModal {
|
|
|
177
195
|
*/
|
|
178
196
|
modalOn(isUpdate) {
|
|
179
197
|
if (!isUpdate) {
|
|
180
|
-
if (this.audioInputFile && this.pluginOptions.allowMultiple)
|
|
198
|
+
if (this.audioInputFile && this.pluginOptions.allowMultiple)
|
|
199
|
+
this.audioInputFile.setAttribute('multiple', 'multiple');
|
|
181
200
|
} else if (this.#element) {
|
|
182
201
|
this.#urlValue = this.preview.textContent = this.audioUrlFile.value = this.#element.src;
|
|
183
|
-
if (this.audioInputFile && this.pluginOptions.allowMultiple)
|
|
202
|
+
if (this.audioInputFile && this.pluginOptions.allowMultiple)
|
|
203
|
+
this.audioInputFile.removeAttribute('multiple');
|
|
184
204
|
} else {
|
|
185
|
-
if (this.audioInputFile && this.pluginOptions.allowMultiple)
|
|
205
|
+
if (this.audioInputFile && this.pluginOptions.allowMultiple)
|
|
206
|
+
this.audioInputFile.removeAttribute('multiple');
|
|
186
207
|
}
|
|
187
208
|
}
|
|
188
209
|
|
|
@@ -220,7 +241,8 @@ class Audio_ extends PluginModal {
|
|
|
220
241
|
controllerAction(target) {
|
|
221
242
|
switch (target.getAttribute('data-command')) {
|
|
222
243
|
case 'update':
|
|
223
|
-
if (this.audioUrlFile)
|
|
244
|
+
if (this.audioUrlFile)
|
|
245
|
+
this.#urlValue = this.preview.textContent = this.audioUrlFile.value = this.#element.src;
|
|
224
246
|
this.open();
|
|
225
247
|
break;
|
|
226
248
|
case 'copy': {
|
|
@@ -239,7 +261,13 @@ class Audio_ extends PluginModal {
|
|
|
239
261
|
* @type {SunEditor.Hook.Component.Select}
|
|
240
262
|
*/
|
|
241
263
|
componentSelect(target) {
|
|
242
|
-
this.figure.open(target, {
|
|
264
|
+
this.figure.open(target, {
|
|
265
|
+
nonResizing: true,
|
|
266
|
+
nonSizeInfo: true,
|
|
267
|
+
nonBorder: true,
|
|
268
|
+
figureTarget: true,
|
|
269
|
+
infoOnly: false,
|
|
270
|
+
});
|
|
243
271
|
this.#ready(target);
|
|
244
272
|
}
|
|
245
273
|
|
|
@@ -253,7 +281,11 @@ class Audio_ extends PluginModal {
|
|
|
253
281
|
const container = figure.container || element;
|
|
254
282
|
const focusEl = container.previousElementSibling || container.nextElementSibling;
|
|
255
283
|
|
|
256
|
-
const message = await this.$.eventManager.triggerEvent('onAudioDeleteBefore', {
|
|
284
|
+
const message = await this.$.eventManager.triggerEvent('onAudioDeleteBefore', {
|
|
285
|
+
element: element,
|
|
286
|
+
container: figure,
|
|
287
|
+
url: element.getAttribute('src'),
|
|
288
|
+
});
|
|
257
289
|
if (message === false) return;
|
|
258
290
|
|
|
259
291
|
const emptyDiv = container.parentNode;
|
|
@@ -293,7 +325,8 @@ class Audio_ extends PluginModal {
|
|
|
293
325
|
|
|
294
326
|
s = f.size;
|
|
295
327
|
if (singleSizeLimit > 0 && s > singleSizeLimit) {
|
|
296
|
-
const err =
|
|
328
|
+
const err =
|
|
329
|
+
'[SUNEDITOR.audioUpload.fail] Size of uploadable single file: ' + singleSizeLimit / 1000 + 'KB';
|
|
297
330
|
const message = await this.$.eventManager.triggerEvent('onAudioUploadError', {
|
|
298
331
|
error: err,
|
|
299
332
|
limitSize: singleSizeLimit,
|
|
@@ -313,7 +346,12 @@ class Audio_ extends PluginModal {
|
|
|
313
346
|
const limitSize = this.pluginOptions.uploadSizeLimit;
|
|
314
347
|
if (limitSize > 0 && fileSize + this.fileManager.getSize() > limitSize) {
|
|
315
348
|
const err = '[SUNEDITOR.audioUpload.fail] Size of uploadable total audios: ' + limitSize / 1000 + 'KB';
|
|
316
|
-
const message = await this.$.eventManager.triggerEvent('onAudioUploadError', {
|
|
349
|
+
const message = await this.$.eventManager.triggerEvent('onAudioUploadError', {
|
|
350
|
+
error: err,
|
|
351
|
+
limitSize,
|
|
352
|
+
currentSize: this.fileManager.getSize(),
|
|
353
|
+
uploadSize: fileSize,
|
|
354
|
+
});
|
|
317
355
|
|
|
318
356
|
this.$.ui.alertOpen(message === NO_EVENT ? err : message || err, 'error');
|
|
319
357
|
|
|
@@ -396,7 +434,12 @@ class Audio_ extends PluginModal {
|
|
|
396
434
|
this.fileManager.setFileData(element, file);
|
|
397
435
|
element.src = src;
|
|
398
436
|
const figure = Figure.CreateContainer(element, 'se-flex-component');
|
|
399
|
-
if (
|
|
437
|
+
if (
|
|
438
|
+
!this.$.component.insert(figure.container, {
|
|
439
|
+
scrollTo: isLast ? true : false,
|
|
440
|
+
insertBehavior: isLast ? this.pluginOptions.insertBehavior : 'line',
|
|
441
|
+
})
|
|
442
|
+
) {
|
|
400
443
|
if (isLast) this.$.focusManager.focus();
|
|
401
444
|
return;
|
|
402
445
|
}
|
|
@@ -458,7 +501,9 @@ class Audio_ extends PluginModal {
|
|
|
458
501
|
const w = this.#defaultWidth;
|
|
459
502
|
const h = this.#defaultHeight;
|
|
460
503
|
/** @type {HTMLAudioElement} */
|
|
461
|
-
const oAudio = dom.utils.createElement('AUDIO', {
|
|
504
|
+
const oAudio = dom.utils.createElement('AUDIO', {
|
|
505
|
+
style: (w ? 'width:' + w + '; ' : '') + (h ? 'height:' + h + ';' : ''),
|
|
506
|
+
});
|
|
462
507
|
this.#setTagAttrs(oAudio);
|
|
463
508
|
return oAudio;
|
|
464
509
|
}
|
|
@@ -489,7 +534,13 @@ class Audio_ extends PluginModal {
|
|
|
489
534
|
if (!files) return;
|
|
490
535
|
|
|
491
536
|
const uploadFiles = this.modal.isUpdate ? [files[0]] : files;
|
|
492
|
-
this.fileManager.upload(
|
|
537
|
+
this.fileManager.upload(
|
|
538
|
+
this.pluginOptions.uploadUrl,
|
|
539
|
+
this.pluginOptions.uploadHeaders,
|
|
540
|
+
uploadFiles,
|
|
541
|
+
this.#UploadCallBack.bind(this, info),
|
|
542
|
+
this.#error.bind(this),
|
|
543
|
+
);
|
|
493
544
|
}
|
|
494
545
|
|
|
495
546
|
/**
|
|
@@ -555,7 +606,10 @@ class Audio_ extends PluginModal {
|
|
|
555
606
|
* @param {HTMLInputElement} target - The target element.
|
|
556
607
|
*/
|
|
557
608
|
#SetUrlInput(target) {
|
|
558
|
-
this.#urlValue =
|
|
609
|
+
this.#urlValue =
|
|
610
|
+
this.preview.textContent =
|
|
611
|
+
this.audioUrlFile.value =
|
|
612
|
+
target.getAttribute('data-command') || target.src;
|
|
559
613
|
this.audioUrlFile.focus();
|
|
560
614
|
}
|
|
561
615
|
|
|
@@ -49,7 +49,9 @@ class Drawing extends PluginModal {
|
|
|
49
49
|
this.pluginOptions = {
|
|
50
50
|
outputFormat: pluginOptions.outputFormat || 'dataurl', // dataurl, svg
|
|
51
51
|
useFormatType: pluginOptions.useFormatType ?? false,
|
|
52
|
-
defaultFormatType: ['block', 'inline'].includes(pluginOptions.defaultFormatType)
|
|
52
|
+
defaultFormatType: ['block', 'inline'].includes(pluginOptions.defaultFormatType)
|
|
53
|
+
? pluginOptions.defaultFormatType
|
|
54
|
+
: 'block',
|
|
53
55
|
keepFormatType: pluginOptions.keepFormatType ?? false,
|
|
54
56
|
lineWidth: pluginOptions.lineWidth || 5,
|
|
55
57
|
lineReconnect: !!pluginOptions.lineReconnect,
|
|
@@ -70,9 +72,13 @@ class Drawing extends PluginModal {
|
|
|
70
72
|
|
|
71
73
|
// exception
|
|
72
74
|
if (!this.$.plugins.image) {
|
|
73
|
-
console.warn(
|
|
75
|
+
console.warn(
|
|
76
|
+
'[SUNEDITOR.plugins.drawing.warn] The drawing plugin must need either "image" plugin. Please add the "image" plugin.',
|
|
77
|
+
);
|
|
74
78
|
} else if (this.pluginOptions.outputFormat === 'svg' && !this.$.plugins.image.pluginOptions.uploadUrl) {
|
|
75
|
-
console.warn(
|
|
79
|
+
console.warn(
|
|
80
|
+
'[SUNEDITOR.plugins.drawing.warn] The drawing plugin must need the "image" plugin with the "uploadUrl" option. Please add the "image" plugin with the "uploadUrl" option.',
|
|
81
|
+
);
|
|
76
82
|
}
|
|
77
83
|
|
|
78
84
|
// create HTML
|
|
@@ -119,7 +125,11 @@ class Drawing extends PluginModal {
|
|
|
119
125
|
};
|
|
120
126
|
|
|
121
127
|
// init
|
|
122
|
-
this.$.eventManager.addEvent(
|
|
128
|
+
this.$.eventManager.addEvent(
|
|
129
|
+
modalEl.querySelector('[data-command="remove"]'),
|
|
130
|
+
'click',
|
|
131
|
+
this.#OnRemove.bind(this),
|
|
132
|
+
);
|
|
123
133
|
}
|
|
124
134
|
|
|
125
135
|
/**
|
|
@@ -128,7 +138,9 @@ class Drawing extends PluginModal {
|
|
|
128
138
|
*/
|
|
129
139
|
open() {
|
|
130
140
|
if (this.pluginOptions.useFormatType) {
|
|
131
|
-
this.#activeAsInline(
|
|
141
|
+
this.#activeAsInline(
|
|
142
|
+
(this.pluginOptions.keepFormatType ? this.as : this.pluginOptions.defaultFormatType) === 'inline',
|
|
143
|
+
);
|
|
132
144
|
}
|
|
133
145
|
this.modal.open();
|
|
134
146
|
this.#initDrawing();
|
|
@@ -180,10 +192,26 @@ class Drawing extends PluginModal {
|
|
|
180
192
|
|
|
181
193
|
this.#setCtx();
|
|
182
194
|
|
|
183
|
-
this.#eventsRegister.touchstart = this.$.eventManager.addEvent(canvas, 'touchstart', this.#events.touchstart, {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
195
|
+
this.#eventsRegister.touchstart = this.$.eventManager.addEvent(canvas, 'touchstart', this.#events.touchstart, {
|
|
196
|
+
passive: false,
|
|
197
|
+
capture: true,
|
|
198
|
+
});
|
|
199
|
+
this.#eventsRegister.touchmove = this.$.eventManager.addEvent(
|
|
200
|
+
canvas,
|
|
201
|
+
'touchmove',
|
|
202
|
+
this.#events.touchmove,
|
|
203
|
+
true,
|
|
204
|
+
);
|
|
205
|
+
this.#eventsRegister.mousedown = this.$.eventManager.addEvent(canvas, 'mousedown', this.#events.mousedown, {
|
|
206
|
+
passive: false,
|
|
207
|
+
capture: true,
|
|
208
|
+
});
|
|
209
|
+
this.#eventsRegister.mousemove = this.$.eventManager.addEvent(
|
|
210
|
+
canvas,
|
|
211
|
+
'mousemove',
|
|
212
|
+
this.#events.mousemove,
|
|
213
|
+
true,
|
|
214
|
+
);
|
|
187
215
|
this.#eventsRegister.mouseup = this.$.eventManager.addEvent(canvas, 'mouseup', this.#events.mouseup, true);
|
|
188
216
|
this.#eventsRegister.mouseleave = this.$.eventManager.addEvent(canvas, 'mouseleave', this.#events.mouseleave);
|
|
189
217
|
this.#eventsRegister.mouseenter = this.$.eventManager.addEvent(canvas, 'mouseenter', this.#events.mouseenter);
|
|
@@ -202,7 +230,8 @@ class Drawing extends PluginModal {
|
|
|
202
230
|
canvas.width = newWidth;
|
|
203
231
|
canvas.height = newHeight;
|
|
204
232
|
if (prevWidth !== canvas.width || prevHeight !== canvas.height) {
|
|
205
|
-
if (this.pluginOptions.maintainRatio)
|
|
233
|
+
if (this.pluginOptions.maintainRatio)
|
|
234
|
+
this.#adjustPathsToNewDimensions(prevWidth, prevHeight, newWidth, newHeight);
|
|
206
235
|
this.#drawAll();
|
|
207
236
|
}
|
|
208
237
|
});
|
|
@@ -241,7 +270,8 @@ class Drawing extends PluginModal {
|
|
|
241
270
|
#setCtx() {
|
|
242
271
|
this.ctx.lineWidth = this.pluginOptions.lineWidth;
|
|
243
272
|
this.ctx.lineCap = this.pluginOptions.lineCap;
|
|
244
|
-
this.ctx.strokeStyle =
|
|
273
|
+
this.ctx.strokeStyle =
|
|
274
|
+
this.pluginOptions.lineColor || _w.getComputedStyle(this.$.contextProvider.carrierWrapper).color;
|
|
245
275
|
}
|
|
246
276
|
|
|
247
277
|
/**
|
|
@@ -181,8 +181,18 @@ class Embed extends PluginModal {
|
|
|
181
181
|
this.pluginOptions = {
|
|
182
182
|
canResize: pluginOptions.canResize === undefined ? true : pluginOptions.canResize,
|
|
183
183
|
showHeightInput: pluginOptions.showHeightInput === undefined ? true : !!pluginOptions.showHeightInput,
|
|
184
|
-
defaultWidth:
|
|
185
|
-
|
|
184
|
+
defaultWidth:
|
|
185
|
+
!pluginOptions.defaultWidth || !numbers.get(pluginOptions.defaultWidth, 0)
|
|
186
|
+
? ''
|
|
187
|
+
: numbers.is(pluginOptions.defaultWidth)
|
|
188
|
+
? pluginOptions.defaultWidth + 'px'
|
|
189
|
+
: pluginOptions.defaultWidth,
|
|
190
|
+
defaultHeight:
|
|
191
|
+
!pluginOptions.defaultHeight || !numbers.get(pluginOptions.defaultHeight, 0)
|
|
192
|
+
? ''
|
|
193
|
+
: numbers.is(pluginOptions.defaultHeight)
|
|
194
|
+
? pluginOptions.defaultHeight + 'px'
|
|
195
|
+
: pluginOptions.defaultHeight,
|
|
186
196
|
percentageOnlySize: !!pluginOptions.percentageOnlySize,
|
|
187
197
|
uploadUrl: typeof pluginOptions.uploadUrl === 'string' ? pluginOptions.uploadUrl : null,
|
|
188
198
|
uploadHeaders: pluginOptions.uploadHeaders || null,
|
|
@@ -198,10 +208,15 @@ class Embed extends PluginModal {
|
|
|
198
208
|
// create HTML
|
|
199
209
|
const sizeUnit = this.pluginOptions.percentageOnlySize ? '%' : 'px';
|
|
200
210
|
const modalEl = CreateHTML_modal(this.$, this.pluginOptions);
|
|
201
|
-
const figureControls =
|
|
211
|
+
const figureControls =
|
|
212
|
+
pluginOptions.controls ||
|
|
213
|
+
(!this.pluginOptions.canResize
|
|
214
|
+
? [['align', 'edit', 'copy', 'remove']]
|
|
215
|
+
: [['resize_auto,75,50', 'align', 'edit', 'revert', 'copy', 'remove']]);
|
|
202
216
|
|
|
203
217
|
// show align
|
|
204
|
-
if (!figureControls.some((subArray) => subArray.includes('align')))
|
|
218
|
+
if (!figureControls.some((subArray) => subArray.includes('align')))
|
|
219
|
+
modalEl.figureAlignBtn.style.display = 'none';
|
|
205
220
|
|
|
206
221
|
// modules
|
|
207
222
|
this.modal = new Modal(this, this.$, modalEl.html);
|
|
@@ -234,7 +249,8 @@ class Embed extends PluginModal {
|
|
|
234
249
|
tag: 'iframe',
|
|
235
250
|
},
|
|
236
251
|
twitter: {
|
|
237
|
-
pattern:
|
|
252
|
+
pattern:
|
|
253
|
+
/^(?:https?:\/\/)?(?:(?:www\.)?(?:twitter\.com|x\.com)\/(?:[^/?#]+\/)?status\/\d+(?:[/?#]|$)|platform\.twitter\.com\/embed\/Tweet\.html(?:[?#].*)?$)/i,
|
|
238
254
|
action: (url) => {
|
|
239
255
|
return `https://platform.twitter.com/embed/Tweet.html?url=${encodeURIComponent(url)}`;
|
|
240
256
|
},
|
|
@@ -343,11 +359,16 @@ class Embed extends PluginModal {
|
|
|
343
359
|
*/
|
|
344
360
|
modalOn(isUpdate) {
|
|
345
361
|
if (!isUpdate && this.#resizing) {
|
|
346
|
-
this.inputX.value = this.#origin_w =
|
|
347
|
-
|
|
362
|
+
this.inputX.value = this.#origin_w =
|
|
363
|
+
this.pluginOptions.defaultWidth === 'auto' ? '' : this.pluginOptions.defaultWidth;
|
|
364
|
+
this.inputY.value = this.#origin_h =
|
|
365
|
+
this.pluginOptions.defaultHeight === 'auto' ? '' : this.pluginOptions.defaultHeight;
|
|
348
366
|
this.proportion.disabled = true;
|
|
349
367
|
} else if (isUpdate) {
|
|
350
|
-
this.#linkValue =
|
|
368
|
+
this.#linkValue =
|
|
369
|
+
this.previewSrc.textContent =
|
|
370
|
+
this.embedInput.value =
|
|
371
|
+
this.#cover.getAttribute('data-se-origin') || '';
|
|
351
372
|
}
|
|
352
373
|
}
|
|
353
374
|
|
|
@@ -356,7 +377,9 @@ class Embed extends PluginModal {
|
|
|
356
377
|
* @type {SunEditor.Hook.Modal.Action}
|
|
357
378
|
*/
|
|
358
379
|
async modalAction() {
|
|
359
|
-
this.#align = /** @type {HTMLInputElement} */ (
|
|
380
|
+
this.#align = /** @type {HTMLInputElement} */ (
|
|
381
|
+
this.modal.form.querySelector('input[name="suneditor_embed_radio"]:checked')
|
|
382
|
+
).value;
|
|
360
383
|
|
|
361
384
|
let result = false;
|
|
362
385
|
if (this.#linkValue.length > 0) {
|
|
@@ -376,13 +399,17 @@ class Embed extends PluginModal {
|
|
|
376
399
|
Modal.OnChangeFile(this.fileModalWrapper, []);
|
|
377
400
|
this.#linkValue = this.previewSrc.textContent = this.embedInput.value = '';
|
|
378
401
|
|
|
379
|
-
/** @type {HTMLInputElement} */ (
|
|
402
|
+
/** @type {HTMLInputElement} */ (
|
|
403
|
+
this.modal.form.querySelector('input[name="suneditor_embed_radio"][value="none"]')
|
|
404
|
+
).checked = true;
|
|
380
405
|
this.#ratio = { w: 0, h: 0 };
|
|
381
406
|
this.#nonResizing = false;
|
|
382
407
|
|
|
383
408
|
if (this.#resizing) {
|
|
384
|
-
this.inputX.value =
|
|
385
|
-
|
|
409
|
+
this.inputX.value =
|
|
410
|
+
this.pluginOptions.defaultWidth === this.#defaultSizeX ? '' : this.pluginOptions.defaultWidth;
|
|
411
|
+
this.inputY.value =
|
|
412
|
+
this.pluginOptions.defaultHeight === this.#defaultSizeY ? '' : this.pluginOptions.defaultHeight;
|
|
386
413
|
this.proportion.checked = false;
|
|
387
414
|
this.proportion.disabled = true;
|
|
388
415
|
}
|
|
@@ -414,7 +441,12 @@ class Embed extends PluginModal {
|
|
|
414
441
|
const focusEl = container.previousElementSibling || container.nextElementSibling;
|
|
415
442
|
const emptyDiv = container.parentNode;
|
|
416
443
|
|
|
417
|
-
const message = await this.$.eventManager.triggerEvent('onEmbedDeleteBefore', {
|
|
444
|
+
const message = await this.$.eventManager.triggerEvent('onEmbedDeleteBefore', {
|
|
445
|
+
element: targetEl,
|
|
446
|
+
container,
|
|
447
|
+
align: this.#align,
|
|
448
|
+
url: this.#linkValue,
|
|
449
|
+
});
|
|
418
450
|
if (message === false) return;
|
|
419
451
|
|
|
420
452
|
dom.utils.removeItem(container);
|
|
@@ -474,7 +506,8 @@ class Embed extends PluginModal {
|
|
|
474
506
|
// Validate every iframe in the raw HTML against the URL whitelist.
|
|
475
507
|
for (let i = 0; i < embedDOM.length; i++) {
|
|
476
508
|
const node = /** @type {Element} */ (embedDOM[i]);
|
|
477
|
-
if (/^iframe$/i.test(node.nodeName) && !Embed.#checkContentType(node.getAttribute('src') || ''))
|
|
509
|
+
if (/^iframe$/i.test(node.nodeName) && !Embed.#checkContentType(node.getAttribute('src') || ''))
|
|
510
|
+
return false;
|
|
478
511
|
const nested = node.querySelectorAll?.('iframe');
|
|
479
512
|
if (nested) {
|
|
480
513
|
for (let j = 0; j < nested.length; j++) {
|
|
@@ -498,7 +531,16 @@ class Embed extends PluginModal {
|
|
|
498
531
|
|
|
499
532
|
const handler = function (uploadCallback, infos, newInfos) {
|
|
500
533
|
infos = newInfos || infos;
|
|
501
|
-
uploadCallback(
|
|
534
|
+
uploadCallback(
|
|
535
|
+
src,
|
|
536
|
+
infos.process,
|
|
537
|
+
infos.url,
|
|
538
|
+
infos.children,
|
|
539
|
+
infos.inputWidth,
|
|
540
|
+
infos.inputHeight,
|
|
541
|
+
infos.align,
|
|
542
|
+
infos.isUpdate,
|
|
543
|
+
);
|
|
502
544
|
}.bind(this, this.#create.bind(this), embedInfo);
|
|
503
545
|
|
|
504
546
|
const result = await this.$.eventManager.triggerEvent('onEmbedInputBefore', {
|
|
@@ -524,7 +566,13 @@ class Embed extends PluginModal {
|
|
|
524
566
|
*/
|
|
525
567
|
#ready(target, infoOnly = false) {
|
|
526
568
|
if (!target) return;
|
|
527
|
-
const figureInfo = this.figure.open(target, {
|
|
569
|
+
const figureInfo = this.figure.open(target, {
|
|
570
|
+
nonResizing: this.#nonResizing,
|
|
571
|
+
nonSizeInfo: false,
|
|
572
|
+
nonBorder: false,
|
|
573
|
+
figureTarget: false,
|
|
574
|
+
infoOnly,
|
|
575
|
+
});
|
|
528
576
|
|
|
529
577
|
this.#element = target;
|
|
530
578
|
this.#cover = figureInfo.cover;
|
|
@@ -545,7 +593,9 @@ class Embed extends PluginModal {
|
|
|
545
593
|
this.#origin_h = String(figureInfo.originHeight || figureInfo.h || '');
|
|
546
594
|
|
|
547
595
|
/** @type {HTMLInputElement} */
|
|
548
|
-
const activeAlign =
|
|
596
|
+
const activeAlign =
|
|
597
|
+
this.modal.form.querySelector('input[name="suneditor_embed_radio"][value="' + this.#align + '"]') ||
|
|
598
|
+
this.modal.form.querySelector('input[name="suneditor_embed_radio"][value="none"]');
|
|
549
599
|
activeAlign.checked = true;
|
|
550
600
|
|
|
551
601
|
if (!this.#resizing) return;
|
|
@@ -658,7 +708,13 @@ class Embed extends PluginModal {
|
|
|
658
708
|
this.#element = oFrame;
|
|
659
709
|
this.#cover = cover;
|
|
660
710
|
this.#container = container;
|
|
661
|
-
this.figure.open(oFrame, {
|
|
711
|
+
this.figure.open(oFrame, {
|
|
712
|
+
nonResizing: this.#nonResizing,
|
|
713
|
+
nonSizeInfo: false,
|
|
714
|
+
nonBorder: false,
|
|
715
|
+
figureTarget: false,
|
|
716
|
+
infoOnly: true,
|
|
717
|
+
});
|
|
662
718
|
|
|
663
719
|
width ||= this.#defaultSizeX;
|
|
664
720
|
height ||= this.#defaultSizeY;
|
|
@@ -679,7 +735,11 @@ class Embed extends PluginModal {
|
|
|
679
735
|
cover.setAttribute('data-se-origin', originSrc);
|
|
680
736
|
|
|
681
737
|
if (!isUpdate) {
|
|
682
|
-
this.$.component.insert(container, {
|
|
738
|
+
this.$.component.insert(container, {
|
|
739
|
+
skipHistory: true,
|
|
740
|
+
scrollTo: false,
|
|
741
|
+
insertBehavior: this.pluginOptions.insertBehavior,
|
|
742
|
+
});
|
|
683
743
|
|
|
684
744
|
if (scriptTag) {
|
|
685
745
|
try {
|
|
@@ -721,7 +781,8 @@ class Embed extends PluginModal {
|
|
|
721
781
|
return;
|
|
722
782
|
}
|
|
723
783
|
|
|
724
|
-
if (!this.#resizing || !changeSize || !this.figure.isVertical)
|
|
784
|
+
if (!this.#resizing || !changeSize || !this.figure.isVertical)
|
|
785
|
+
this.figure.setTransform(oFrame, width, height, 0);
|
|
725
786
|
if (!scriptTag) this.$.history.push(false);
|
|
726
787
|
}
|
|
727
788
|
|
|
@@ -740,7 +801,13 @@ class Embed extends PluginModal {
|
|
|
740
801
|
const container = figure.container;
|
|
741
802
|
|
|
742
803
|
// size
|
|
743
|
-
this.figure.open(oFrame, {
|
|
804
|
+
this.figure.open(oFrame, {
|
|
805
|
+
nonResizing: this.#nonResizing,
|
|
806
|
+
nonSizeInfo: false,
|
|
807
|
+
nonBorder: false,
|
|
808
|
+
figureTarget: false,
|
|
809
|
+
infoOnly: true,
|
|
810
|
+
});
|
|
744
811
|
const size = (oFrame.getAttribute('data-se-size') || ',').split(',');
|
|
745
812
|
|
|
746
813
|
const width = size[0] || prevFrame.width || '';
|
|
@@ -900,7 +967,10 @@ function CreateHTML_modal({ lang, icons }, pluginOptions) {
|
|
|
900
967
|
const onlyPercentDisplay = onlyPercentage ? ' style="display: none !important;"' : '';
|
|
901
968
|
const heightDisplay = !pluginOptions.showHeightInput ? ' style="display: none !important;"' : '';
|
|
902
969
|
const ratioDisplay = !pluginOptions.showRatioOption ? ' style="display: none !important;"' : '';
|
|
903
|
-
const onlyWidthDisplay =
|
|
970
|
+
const onlyWidthDisplay =
|
|
971
|
+
!onlyPercentage && !pluginOptions.showHeightInput && !pluginOptions.showRatioOption
|
|
972
|
+
? ' style="display: none !important;"'
|
|
973
|
+
: '';
|
|
904
974
|
html += /*html*/ `
|
|
905
975
|
<div class="se-modal-form">
|
|
906
976
|
<div class="se-modal-size-text">
|