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
|
@@ -65,8 +65,10 @@ class Component {
|
|
|
65
65
|
this.currentTarget = null;
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
|
-
* @description Currently selected component plugin instance
|
|
69
|
-
*
|
|
68
|
+
* @description Currently selected component plugin instance (a full plugin) or a
|
|
69
|
+
* launcher stand-in for non-plugin components (e.g. `pageBreak`). Consumers call the
|
|
70
|
+
* shared component hooks (`componentDestroy`/`componentSelect`/`componentDeselect`) on it.
|
|
71
|
+
* @type {?SunEditor.ComponentLauncher}
|
|
70
72
|
*/
|
|
71
73
|
this.currentPlugin = null;
|
|
72
74
|
|
|
@@ -101,7 +103,11 @@ class Component {
|
|
|
101
103
|
_init() {
|
|
102
104
|
this.#contextProvider.applyToRoots((e) => {
|
|
103
105
|
// drag
|
|
104
|
-
const dragHandle = dom.utils.createElement(
|
|
106
|
+
const dragHandle = dom.utils.createElement(
|
|
107
|
+
'DIV',
|
|
108
|
+
{ class: 'se-drag-handle', draggable: 'true' },
|
|
109
|
+
this.#contextProvider.icons.selection,
|
|
110
|
+
);
|
|
105
111
|
e.get('wrapper').appendChild(dragHandle);
|
|
106
112
|
this.#eventManager.addEvent(dragHandle, 'mouseenter', this.#OnDragEnter.bind(this));
|
|
107
113
|
this.#eventManager.addEvent(dragHandle, 'mouseleave', this.#OnDragLeave.bind(this));
|
|
@@ -139,15 +145,36 @@ class Component {
|
|
|
139
145
|
|
|
140
146
|
try {
|
|
141
147
|
if (dom.check.isListCell(formatEl)) {
|
|
142
|
-
this.#$.html.insertNode(element, {
|
|
148
|
+
this.#$.html.insertNode(element, {
|
|
149
|
+
afterNode: isInline
|
|
150
|
+
? null
|
|
151
|
+
: !dom.check.isZeroWidth(selectionNode)
|
|
152
|
+
? null
|
|
153
|
+
: (selectionNode || r.container || {}).nextSibling,
|
|
154
|
+
skipCharCount: true,
|
|
155
|
+
});
|
|
143
156
|
if (!isInline && !element.nextSibling) element.parentNode.appendChild(dom.utils.createElement('BR'));
|
|
144
157
|
} else {
|
|
145
|
-
if (
|
|
146
|
-
|
|
147
|
-
|
|
158
|
+
if (
|
|
159
|
+
!isInline &&
|
|
160
|
+
this.#$.selection.getRange().collapsed &&
|
|
161
|
+
(r.container?.nodeType === 3 || dom.check.isBreak(r.container))
|
|
162
|
+
) {
|
|
163
|
+
const depthFormat = dom.query.getParentElement(
|
|
164
|
+
r.container,
|
|
165
|
+
this.#$.format.isBlock.bind(this.#$.format),
|
|
166
|
+
);
|
|
167
|
+
oNode = this.#$.nodeTransform.split(
|
|
168
|
+
r.container,
|
|
169
|
+
r.offset,
|
|
170
|
+
!depthFormat ? 0 : dom.query.getNodeDepth(depthFormat) + 1,
|
|
171
|
+
);
|
|
148
172
|
if (oNode) formatEl = /** @type {HTMLElement} */ (oNode.previousSibling);
|
|
149
173
|
}
|
|
150
|
-
this.#$.html.insertNode(element, {
|
|
174
|
+
this.#$.html.insertNode(element, {
|
|
175
|
+
afterNode: isInline ? null : this.#$.format.isBlock(formatEl) ? null : formatEl,
|
|
176
|
+
skipCharCount: true,
|
|
177
|
+
});
|
|
151
178
|
if (!isInline && formatEl && dom.check.isZeroWidth(formatEl)) dom.utils.removeItem(formatEl);
|
|
152
179
|
}
|
|
153
180
|
|
|
@@ -243,7 +270,8 @@ class Component {
|
|
|
243
270
|
let launcher = null;
|
|
244
271
|
|
|
245
272
|
if (this.is(element)) {
|
|
246
|
-
if (dom.check.isComponentContainer(element) && !dom.utils.hasClass(element, 'se-inline-component'))
|
|
273
|
+
if (dom.check.isComponentContainer(element) && !dom.utils.hasClass(element, 'se-inline-component'))
|
|
274
|
+
element = /** @type {HTMLElement} */ (element).firstElementChild || element;
|
|
247
275
|
if (/^FIGURE$/i.test(element.nodeName)) element = /** @type {HTMLElement} */ (element).firstElementChild;
|
|
248
276
|
if (!element) return null;
|
|
249
277
|
|
|
@@ -296,7 +324,12 @@ class Component {
|
|
|
296
324
|
*/
|
|
297
325
|
select(element, pluginName, { isInput = false } = {}) {
|
|
298
326
|
const info = this.get(element);
|
|
299
|
-
if (
|
|
327
|
+
if (
|
|
328
|
+
!info ||
|
|
329
|
+
dom.check.isUneditable(dom.query.getParentElement(element, this.is.bind(this))) ||
|
|
330
|
+
dom.check.isUneditable(element)
|
|
331
|
+
)
|
|
332
|
+
return false;
|
|
300
333
|
|
|
301
334
|
const plugin = info.launcher || this.#$.plugins[pluginName];
|
|
302
335
|
if (!plugin) return;
|
|
@@ -324,7 +357,8 @@ class Component {
|
|
|
324
357
|
if (typeof plugin.componentSelect === 'function') isNonFigureComponent = plugin.componentSelect(element);
|
|
325
358
|
|
|
326
359
|
const isBreakComponent = dom.utils.hasClass(info.target, 'se-component-line-break');
|
|
327
|
-
if (isBreakComponent || (!isNonFigureComponent && !dom.utils.hasClass(info.container, 'se-inline-component')))
|
|
360
|
+
if (isBreakComponent || (!isNonFigureComponent && !dom.utils.hasClass(info.container, 'se-inline-component')))
|
|
361
|
+
this._setComponentLineBreaker(/** @type {HTMLElement} */ (info.container || info.cover || element));
|
|
328
362
|
|
|
329
363
|
this.currentTarget = element;
|
|
330
364
|
this.currentPlugin = plugin;
|
|
@@ -365,7 +399,9 @@ class Component {
|
|
|
365
399
|
|
|
366
400
|
this.#store.set('controlActive', true);
|
|
367
401
|
} else if (isBreakComponent || !dom.utils.hasClass(info.container, 'se-input-component')) {
|
|
368
|
-
const dragHandle = /** @type {HTMLElement} */ (
|
|
402
|
+
const dragHandle = /** @type {HTMLElement} */ (
|
|
403
|
+
this.#frameContext.get('wrapper').querySelector('.se-drag-handle')
|
|
404
|
+
);
|
|
369
405
|
dom.utils.addClass(dragHandle, 'se-drag-handle-full');
|
|
370
406
|
this.#$.ui._visibleControllers(false, false);
|
|
371
407
|
|
|
@@ -435,7 +471,12 @@ class Component {
|
|
|
435
471
|
if (dom.utils.hasClass(element, 'se-inline-component')) return true;
|
|
436
472
|
|
|
437
473
|
const comp = this.#$.pluginManager.findComponentInfo(element);
|
|
438
|
-
if (
|
|
474
|
+
if (
|
|
475
|
+
comp &&
|
|
476
|
+
(dom.utils.hasClass(element, 'se-inline-component') ||
|
|
477
|
+
dom.utils.hasClass(element.parentElement, 'se-inline-component'))
|
|
478
|
+
)
|
|
479
|
+
return true;
|
|
439
480
|
|
|
440
481
|
return false;
|
|
441
482
|
}
|
|
@@ -518,7 +559,9 @@ class Component {
|
|
|
518
559
|
}
|
|
519
560
|
|
|
520
561
|
if (this.#frameContext.get('lineBreaker_t')) {
|
|
521
|
-
this.#frameContext.get('lineBreaker_t').style.display = this.#frameContext.get(
|
|
562
|
+
this.#frameContext.get('lineBreaker_t').style.display = this.#frameContext.get(
|
|
563
|
+
'lineBreaker_b',
|
|
564
|
+
).style.display = 'none';
|
|
522
565
|
}
|
|
523
566
|
|
|
524
567
|
if (this.currentPlugin) {
|
|
@@ -563,7 +606,13 @@ class Component {
|
|
|
563
606
|
const { top, left, right, scrollX, scrollY } = this.#$.offset.getLocal(offsetTarget);
|
|
564
607
|
const sideOffset = isRtl ? right : left;
|
|
565
608
|
|
|
566
|
-
if (
|
|
609
|
+
if (
|
|
610
|
+
isList
|
|
611
|
+
? (!dom.check.isBreak(container.previousElementSibling) &&
|
|
612
|
+
!container.previousSibling?.textContent?.trim()) ||
|
|
613
|
+
this.is(container.previousElementSibling)
|
|
614
|
+
: !this.#$.format.isLine(container.previousElementSibling)
|
|
615
|
+
) {
|
|
567
616
|
const cStyle = _w.getComputedStyle(lb_t);
|
|
568
617
|
const cH = numbers.get(cStyle.height, 1);
|
|
569
618
|
const cW = numbers.get(cStyle.width, 1);
|
|
@@ -587,7 +636,12 @@ class Component {
|
|
|
587
636
|
}
|
|
588
637
|
|
|
589
638
|
// bottom
|
|
590
|
-
if (
|
|
639
|
+
if (
|
|
640
|
+
isList
|
|
641
|
+
? (!dom.check.isBreak(container.nextElementSibling) && !container.nextSibling?.textContent?.trim()) ||
|
|
642
|
+
this.is(container.nextElementSibling)
|
|
643
|
+
: !this.#$.format.isLine(container.nextElementSibling)
|
|
644
|
+
) {
|
|
591
645
|
const cStyle = _w.getComputedStyle(lb_b);
|
|
592
646
|
const cH = numbers.get(cStyle.height, 1);
|
|
593
647
|
const cW = numbers.get(cStyle.width, 1);
|
|
@@ -599,7 +653,8 @@ class Component {
|
|
|
599
653
|
}
|
|
600
654
|
|
|
601
655
|
b_style.top = componentTop + target.offsetHeight - cH / 2 + 'px';
|
|
602
|
-
b_style[dir[0]] =
|
|
656
|
+
b_style[dir[0]] =
|
|
657
|
+
sideOffset + target.offsetWidth - (isNonSelected ? 0 : w) - (isNonSelected ? cW / 2 : cW) + 'px';
|
|
603
658
|
b_style[dir[1]] = '';
|
|
604
659
|
|
|
605
660
|
lb_b.setAttribute('data-offset', scrollY + ',' + dir[0] + ',' + scrollX);
|
|
@@ -659,7 +714,11 @@ class Component {
|
|
|
659
714
|
*/
|
|
660
715
|
#addNotFileGlobalEvent() {
|
|
661
716
|
this.#removeNotFileGlobalEvent();
|
|
662
|
-
this.#bindClose_mousedown = this.#eventManager.addGlobalEvent(
|
|
717
|
+
this.#bindClose_mousedown = this.#eventManager.addGlobalEvent(
|
|
718
|
+
isMobile ? 'click' : 'mousedown',
|
|
719
|
+
this.#globalEvents.mousedown,
|
|
720
|
+
true,
|
|
721
|
+
);
|
|
663
722
|
}
|
|
664
723
|
|
|
665
724
|
/**
|
|
@@ -703,19 +762,26 @@ class Component {
|
|
|
703
762
|
const nodeName = element.nodeName.toLowerCase();
|
|
704
763
|
return (
|
|
705
764
|
this.#$.pluginManager.fileInfo.regExp.test(nodeName) &&
|
|
706
|
-
(!this.#$.pluginManager.fileInfo.tagAttrs[nodeName] ||
|
|
765
|
+
(!this.#$.pluginManager.fileInfo.tagAttrs[nodeName] ||
|
|
766
|
+
this.#$.pluginManager.fileInfo.tagAttrs[nodeName]?.every((v) =>
|
|
767
|
+
/** @type {HTMLElement} */ (element).hasAttribute(v),
|
|
768
|
+
))
|
|
707
769
|
);
|
|
708
770
|
}
|
|
709
771
|
|
|
710
772
|
#OnDragEnter() {
|
|
711
773
|
this.#store.set('_preventBlur', true);
|
|
712
|
-
this.#$.ui._visibleControllers(
|
|
774
|
+
this.#$.ui._visibleControllers(
|
|
775
|
+
false,
|
|
776
|
+
dom.utils.hasClass(_DragHandle.get('__dragHandler'), 'se-drag-handle-full'),
|
|
777
|
+
);
|
|
713
778
|
dom.utils.addClass(_DragHandle.get('__dragCover') || _DragHandle.get('__dragContainer'), 'se-drag-over');
|
|
714
779
|
}
|
|
715
780
|
|
|
716
781
|
#OnDragLeave() {
|
|
717
782
|
this.#store.set('_preventBlur', false);
|
|
718
|
-
if (!dom.utils.hasClass(_DragHandle.get('__dragHandler'), 'se-drag-handle-full'))
|
|
783
|
+
if (!dom.utils.hasClass(_DragHandle.get('__dragHandler'), 'se-drag-handle-full'))
|
|
784
|
+
this.#$.ui._visibleControllers(true, true);
|
|
719
785
|
dom.utils.removeClass([_DragHandle.get('__dragCover'), _DragHandle.get('__dragContainer')], 'se-drag-over');
|
|
720
786
|
}
|
|
721
787
|
|
|
@@ -765,7 +831,8 @@ class Component {
|
|
|
765
831
|
this.currentTarget?.contains(target) ||
|
|
766
832
|
dom.query.getParentElement(target, '.se-controller') ||
|
|
767
833
|
dom.utils.hasClass(target, 'se-drag-handle') ||
|
|
768
|
-
(this.currentPluginName === this.#$.ui.currentControllerName &&
|
|
834
|
+
(this.currentPluginName === this.#$.ui.currentControllerName &&
|
|
835
|
+
this.#$.ui.opendControllers.some(({ form }) => form.contains(target)))
|
|
769
836
|
) {
|
|
770
837
|
return;
|
|
771
838
|
}
|
|
@@ -783,7 +850,10 @@ class Component {
|
|
|
783
850
|
if (!info) return;
|
|
784
851
|
|
|
785
852
|
const cloneContainer = info.container.cloneNode(true);
|
|
786
|
-
if (
|
|
853
|
+
if (
|
|
854
|
+
typeof this.#$.plugins[info.pluginName]?.componentCopy !== 'function' ||
|
|
855
|
+
this.#$.plugins[info.pluginName].componentCopy({ event: e, cloneContainer, info }) === false
|
|
856
|
+
) {
|
|
787
857
|
SetClipboardComponent(e, cloneContainer, e.clipboardData);
|
|
788
858
|
}
|
|
789
859
|
|
|
@@ -833,7 +903,10 @@ class Component {
|
|
|
833
903
|
e.preventDefault();
|
|
834
904
|
e.stopPropagation();
|
|
835
905
|
|
|
836
|
-
if (
|
|
906
|
+
if (
|
|
907
|
+
typeof this.currentPlugin?.componentDestroy === 'function' &&
|
|
908
|
+
(!this.info.isInputType || !this.#store.get('hasFocus'))
|
|
909
|
+
) {
|
|
837
910
|
const focusNode = this.info.container.previousSibling;
|
|
838
911
|
await this.currentPlugin.componentDestroy(this.currentTarget);
|
|
839
912
|
this.deselect();
|
|
@@ -857,7 +930,11 @@ class Component {
|
|
|
857
930
|
if (dom.check.isListCell(container.parentNode)) {
|
|
858
931
|
newEl = dom.utils.createElement('BR');
|
|
859
932
|
} else {
|
|
860
|
-
newEl = dom.utils.createElement(
|
|
933
|
+
newEl = dom.utils.createElement(
|
|
934
|
+
this.#$.format.isLine(sibling) ? sibling.nodeName : this.#options.get('defaultLine'),
|
|
935
|
+
null,
|
|
936
|
+
'<br>',
|
|
937
|
+
);
|
|
861
938
|
}
|
|
862
939
|
|
|
863
940
|
const pluginName = this.currentPluginName;
|
|
@@ -35,13 +35,18 @@ export default class FocusManager {
|
|
|
35
35
|
if (this.#frameContext.get('wysiwygFrame').style.display === 'none') return;
|
|
36
36
|
this.#store.set('_preventBlur', false);
|
|
37
37
|
|
|
38
|
-
if (
|
|
38
|
+
if (
|
|
39
|
+
this.#frameOptions.get('iframe') ||
|
|
40
|
+
!this.#frameContext.get('wysiwyg').contains(this.#$.selection.getNode())
|
|
41
|
+
) {
|
|
39
42
|
this.nativeFocus();
|
|
40
43
|
} else {
|
|
41
44
|
try {
|
|
42
45
|
const range = this.#$.selection.getRange();
|
|
43
46
|
if (range.startContainer === range.endContainer && dom.check.isWysiwygFrame(range.startContainer)) {
|
|
44
|
-
const currentNode = /** @type {HTMLElement} */ (range.commonAncestorContainer).children[
|
|
47
|
+
const currentNode = /** @type {HTMLElement} */ (range.commonAncestorContainer).children[
|
|
48
|
+
range.startOffset
|
|
49
|
+
];
|
|
45
50
|
if (!this.#$.format.isLine(currentNode) && !this.#$.component.is(currentNode)) {
|
|
46
51
|
const br = dom.utils.createElement('BR');
|
|
47
52
|
const format = dom.utils.createElement(this.#options.get('defaultLine'), null, br);
|
|
@@ -50,7 +55,12 @@ export default class FocusManager {
|
|
|
50
55
|
return;
|
|
51
56
|
}
|
|
52
57
|
}
|
|
53
|
-
this.#$.selection.setRange(
|
|
58
|
+
this.#$.selection.setRange(
|
|
59
|
+
range.startContainer,
|
|
60
|
+
range.startOffset,
|
|
61
|
+
range.endContainer,
|
|
62
|
+
range.endOffset,
|
|
63
|
+
);
|
|
54
64
|
} catch (e) {
|
|
55
65
|
console.warn('[SUNEDITOR.focus.warn] ', e);
|
|
56
66
|
this.nativeFocus();
|
|
@@ -36,7 +36,8 @@ export default function History(kernel) {
|
|
|
36
36
|
// user event
|
|
37
37
|
eventManager.triggerEvent('onChange', { frameContext: fc, data: fc.get('wysiwyg').innerHTML });
|
|
38
38
|
if (context.get('toolbar_main').style.display === 'block') $.toolbar._showBalloon();
|
|
39
|
-
else if (store.mode.isSubBalloon && context.get('toolbar_sub_main').style.display === 'block')
|
|
39
|
+
else if (store.mode.isSubBalloon && context.get('toolbar_sub_main').style.display === 'block')
|
|
40
|
+
$.subToolbar._showBalloon();
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
/**
|
|
@@ -48,14 +49,17 @@ export default function History(kernel) {
|
|
|
48
49
|
const prevRoot = rootStack[prevKey];
|
|
49
50
|
|
|
50
51
|
stackIndex += increase;
|
|
51
|
-
const rootKey =
|
|
52
|
+
const rootKey =
|
|
53
|
+
increase < 0 && prevKey !== stack[stackIndex] && prevRoot.index > 0 ? prevKey : stack[stackIndex];
|
|
52
54
|
const root = rootStack[rootKey];
|
|
53
55
|
root.index += increase;
|
|
54
56
|
|
|
55
57
|
const item = root.value[root.index];
|
|
56
58
|
|
|
57
59
|
if (!item) {
|
|
58
|
-
console.warn(
|
|
60
|
+
console.warn(
|
|
61
|
+
'[SunEditor.history.setContent.fail] History state desynchronized. Aborting undo/redo operation.',
|
|
62
|
+
);
|
|
59
63
|
// Rollback to prevent stuck state
|
|
60
64
|
root.index -= increase;
|
|
61
65
|
stackIndex -= increase;
|
|
@@ -84,7 +88,12 @@ export default function History(kernel) {
|
|
|
84
88
|
}
|
|
85
89
|
|
|
86
90
|
$.facade.changeFrameContext(focusKey);
|
|
87
|
-
$.selection.setRange(
|
|
91
|
+
$.selection.setRange(
|
|
92
|
+
getNodeFromPath(focusItem.s.path, focusItem.frame),
|
|
93
|
+
focusItem.s.offset,
|
|
94
|
+
getNodeFromPath(focusItem.e.path, focusItem.frame),
|
|
95
|
+
focusItem.e.offset,
|
|
96
|
+
);
|
|
88
97
|
$.focusManager.focus();
|
|
89
98
|
|
|
90
99
|
if (stackIndex < 0) stackIndex = 0;
|
|
@@ -309,7 +318,12 @@ export default function History(kernel) {
|
|
|
309
318
|
* @param {string} [rootKey] The key of the root frame to overwrite.
|
|
310
319
|
*/
|
|
311
320
|
overwrite(rootKey) {
|
|
312
|
-
setStack(
|
|
321
|
+
setStack(
|
|
322
|
+
frameRoots.get(rootKey || store.get('rootKey')).get('wysiwyg').innerHTML,
|
|
323
|
+
null,
|
|
324
|
+
store.get('rootKey'),
|
|
325
|
+
0,
|
|
326
|
+
);
|
|
313
327
|
},
|
|
314
328
|
|
|
315
329
|
/**
|
|
@@ -385,7 +399,8 @@ export default function History(kernel) {
|
|
|
385
399
|
|
|
386
400
|
const savedIndex = target.get('savedIndex');
|
|
387
401
|
const historyIndex = target.get('historyIndex');
|
|
388
|
-
const isChanged =
|
|
402
|
+
const isChanged =
|
|
403
|
+
savedIndex > -1 ? savedIndex !== index : isReset ? root.index > 0 : index > 0 && historyIndex !== index;
|
|
389
404
|
|
|
390
405
|
target.set('historyIndex', index);
|
|
391
406
|
target.set('isChanged', isChanged);
|
|
@@ -216,7 +216,9 @@ class PluginManager {
|
|
|
216
216
|
register(pluginName, targets, pluginOptions) {
|
|
217
217
|
let plugin = this.#plugins[pluginName];
|
|
218
218
|
if (!plugin) {
|
|
219
|
-
throw Error(
|
|
219
|
+
throw Error(
|
|
220
|
+
`[SUNEDITOR.registerPlugin.fail] The called plugin does not exist or is in an invalid format. (pluginName: "${pluginName}")`,
|
|
221
|
+
);
|
|
220
222
|
} else if (typeof this.#plugins[pluginName] === 'function') {
|
|
221
223
|
plugin = this.#plugins[pluginName] = new this.#plugins[pluginName](this.#kernel, pluginOptions || {});
|
|
222
224
|
}
|
|
@@ -227,7 +229,10 @@ class PluginManager {
|
|
|
227
229
|
UpdateButton(targets[i], plugin, icons, lang);
|
|
228
230
|
}
|
|
229
231
|
|
|
230
|
-
if (
|
|
232
|
+
if (
|
|
233
|
+
!this.#$.commandDispatcher.activeCommands.includes(pluginName) &&
|
|
234
|
+
typeof this.#plugins[pluginName].active === 'function'
|
|
235
|
+
) {
|
|
231
236
|
this.#$.commandDispatcher.activeCommands.push(pluginName);
|
|
232
237
|
}
|
|
233
238
|
}
|
|
@@ -308,24 +313,27 @@ class PluginManager {
|
|
|
308
313
|
this.#componentCheckers.push(
|
|
309
314
|
function (focusManager, history, element) {
|
|
310
315
|
if (!element || !dom.utils.hasClass(element, 'se-page-break')) return null;
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
},
|
|
316
|
+
// Typed as an assignment (not a cast) so a mis-named hook (e.g. `destroy`) is a tsc excess-property error.
|
|
317
|
+
/** @type {SunEditor.ComponentLauncher} */
|
|
318
|
+
const launcher = {
|
|
319
|
+
componentDestroy: (target) => {
|
|
320
|
+
const focusEl = target.previousElementSibling || target.nextElementSibling;
|
|
321
|
+
dom.utils.removeItem(target);
|
|
322
|
+
// focus
|
|
323
|
+
focusManager.focusEdge(focusEl);
|
|
324
|
+
history.push(false);
|
|
321
325
|
},
|
|
322
326
|
};
|
|
327
|
+
return { target: element, launcher };
|
|
323
328
|
}.bind(null, this.#$.focusManager, this.#$.history),
|
|
324
329
|
);
|
|
325
330
|
}
|
|
326
331
|
|
|
327
332
|
this.#fileInfo.regExp = new RegExp(`^(${this.#fileInfo.tags.join('|') || '\\^'})$`, 'i');
|
|
328
|
-
this.#fileInfo.pluginRegExp = new RegExp(
|
|
333
|
+
this.#fileInfo.pluginRegExp = new RegExp(
|
|
334
|
+
`^(${filePluginRegExp.length === 0 ? '\\^' : filePluginRegExp.join('|')})$`,
|
|
335
|
+
'i',
|
|
336
|
+
);
|
|
329
337
|
|
|
330
338
|
this.#pluginCallButtons = null;
|
|
331
339
|
this.#pluginCallButtons_sub = null;
|
|
@@ -74,7 +74,15 @@ class Shortcuts {
|
|
|
74
74
|
info = this.keyMap.get(text) || this.keyMap.get(text + event.key);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
if (
|
|
77
|
+
if (
|
|
78
|
+
!info ||
|
|
79
|
+
(!shift && info.s) ||
|
|
80
|
+
(info.space && !keyCodeMap.isSpace(keyCode)) ||
|
|
81
|
+
(info.enter && !keyCodeMap.isEnter(keyCode)) ||
|
|
82
|
+
(info.textTrigger && !event.key.trim()) ||
|
|
83
|
+
(info.edge && !edge)
|
|
84
|
+
)
|
|
85
|
+
return false;
|
|
78
86
|
|
|
79
87
|
if (info.plugin && typeof info.method === 'string') {
|
|
80
88
|
this.#$.plugins[info.plugin][info.method]?.({ range, line, info, event, keyCode });
|