suneditor 3.0.0-beta.26 → 3.0.0-beta.28
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.min.css +1 -1
- package/dist/suneditor.min.js +1 -1
- package/package.json +77 -39
- package/src/core/{section → base}/actives.js +1 -1
- package/src/core/class/component.js +2 -0
- package/src/core/class/format.js +44 -2435
- package/src/core/class/html.js +5 -4
- package/src/core/class/inline.js +1853 -0
- package/src/core/class/listFormat.js +582 -0
- package/src/core/class/nodeTransform.js +1 -3
- package/src/core/class/selection.js +4 -2
- package/src/core/class/ui.js +1 -1
- package/src/core/class/viewer.js +4 -4
- package/src/core/config/options.js +37 -18
- package/src/core/editor.js +43 -29
- 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 +8 -124
- package/src/core/event/executor.js +21 -0
- package/src/core/{base/eventHandlers → event/handlers}/handler_toolbar.js +1 -1
- 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 +57 -23
- package/src/editorInjector/_classes.js +4 -0
- package/src/editorInjector/index.js +4 -0
- package/src/helper/clipboard.js +0 -1
- package/src/helper/converter.js +6 -7
- package/src/helper/dom/domCheck.js +1 -1
- package/src/helper/dom/domQuery.js +1 -1
- package/src/helper/dom/domUtils.js +2 -2
- package/src/helper/dom/index.js +4 -0
- package/src/helper/env.js +1 -6
- package/src/helper/keyCodeMap.js +0 -1
- 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 +1 -1
- 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 +5 -0
- package/src/modules/Figure.js +4 -10
- package/src/modules/HueSlider.js +18 -4
- package/src/modules/SelectMenu.js +1 -1
- package/src/plugins/command/fileUpload.js +1 -1
- package/src/plugins/command/list_bulleted.js +1 -1
- package/src/plugins/command/list_numbered.js +1 -1
- package/src/plugins/dropdown/backgroundColor.js +2 -2
- package/src/plugins/dropdown/font.js +2 -2
- package/src/plugins/dropdown/fontColor.js +2 -2
- package/src/plugins/dropdown/list.js +1 -1
- package/src/plugins/dropdown/table.js +1 -3
- package/src/plugins/dropdown/textStyle.js +1 -1
- package/src/plugins/field/mention.js +2 -2
- package/src/plugins/input/fontSize.js +9 -9
- package/src/plugins/modal/audio.js +5 -5
- package/src/plugins/modal/embed.js +5 -5
- package/src/plugins/modal/image.js +7 -7
- package/src/plugins/modal/link.js +23 -8
- package/src/plugins/modal/video.js +5 -5
- package/src/suneditor.js +9 -34
- package/src/typedef.js +15 -9
- package/types/core/class/format.d.ts +2 -352
- package/types/core/class/html.d.ts +2 -2
- package/types/core/class/inline.d.ts +263 -0
- package/types/core/class/listFormat.d.ts +135 -0
- package/types/core/config/options.d.ts +52 -78
- package/types/core/editor.d.ts +22 -12
- 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 +0 -42
- 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 -33
- 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 +165 -39
- package/types/editorInjector/_classes.d.ts +4 -0
- package/types/editorInjector/index.d.ts +4 -0
- package/types/helper/converter.d.ts +4 -20
- package/types/helper/dom/index.d.ts +86 -1
- package/types/index.d.ts +11 -121
- package/types/langs/index.d.ts +2 -2
- package/types/modules/HueSlider.d.ts +12 -0
- package/types/modules/index.d.ts +3 -3
- package/types/plugins/index.d.ts +38 -38
- package/types/plugins/modal/link.d.ts +6 -4
- package/types/suneditor.d.ts +18 -19
- package/types/typedef.d.ts +6 -2
- package/src/core/base/eventHandlers/handler_ww_key_input.js +0 -1267
- package/types/core/section/context.d.ts +0 -67
- package/types/core/section/options.d.ts +0 -1022
- package/types/langs/_Lang.d.ts +0 -194
- /package/src/core/{base/eventHandlers → event/handlers}/handler_ww_clipboard.js +0 -0
- /package/src/core/{base/eventHandlers → event/handlers}/handler_ww_dragDrop.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
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { dom } from '../../../helper';
|
|
2
|
+
import { A } from '../actions';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @this {void}
|
|
6
|
+
* @description Enter key down rule
|
|
7
|
+
* @param {__se__EventActions} actions - Action list
|
|
8
|
+
* @param {__se__EventPorts} ports - Ports for interacting with editor
|
|
9
|
+
* @param {__se__EventKeydownCtx} ctx - Context object
|
|
10
|
+
* @returns {boolean} Return false to stop the processing
|
|
11
|
+
*/
|
|
12
|
+
export function reduceEnterDown(actions, ports, ctx) {
|
|
13
|
+
const { format, char, selection } = ports;
|
|
14
|
+
const { frameOptions, range, formatEl, selectionNode, shift, e } = ctx;
|
|
15
|
+
const selectRange = !range.collapsed || range.startContainer !== range.endContainer;
|
|
16
|
+
|
|
17
|
+
actions.push(A.componentDeselect());
|
|
18
|
+
|
|
19
|
+
const brBlock = format.getBrLine(selectionNode, null);
|
|
20
|
+
const rangeEl = format.getBlock(formatEl, null);
|
|
21
|
+
|
|
22
|
+
if (frameOptions.get('charCounter_type') === 'byte-html') {
|
|
23
|
+
let enterHTML = '';
|
|
24
|
+
if ((!shift && brBlock) || shift) {
|
|
25
|
+
enterHTML = '<br>';
|
|
26
|
+
} else {
|
|
27
|
+
enterHTML = '<' + formatEl.nodeName + '><br></' + formatEl.nodeName + '>';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (!char.check(enterHTML)) {
|
|
31
|
+
actions.push(A.prevent());
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (!shift) {
|
|
37
|
+
const formatEndEdge = !range.endContainer.nextSibling && format.isEdgeLine(range.endContainer, range.endOffset, 'end');
|
|
38
|
+
const formatStartEdge = !range.startContainer.previousSibling && format.isEdgeLine(range.startContainer, range.startOffset, 'front');
|
|
39
|
+
|
|
40
|
+
// add default format line
|
|
41
|
+
if (formatEndEdge && (/^H[1-6]$/i.test(formatEl.nodeName) || /^HR$/i.test(formatEl.nodeName))) {
|
|
42
|
+
ports.enterPrevent(e);
|
|
43
|
+
actions.push(A.enterLineAddDefault(formatEl));
|
|
44
|
+
actions.push(A.enterScrollTo(range));
|
|
45
|
+
return true;
|
|
46
|
+
} else if (rangeEl && formatEl && !dom.check.isTableCell(rangeEl) && !/^FIGCAPTION$/i.test(rangeEl.nodeName)) {
|
|
47
|
+
// add default List line
|
|
48
|
+
const rangeEnt = selection.getRange();
|
|
49
|
+
if (dom.check.isEdgePoint(rangeEnt.endContainer, rangeEnt.endOffset) && dom.check.isList(selectionNode.nextSibling)) {
|
|
50
|
+
ports.enterPrevent(e);
|
|
51
|
+
actions.push(A.enterListAddItem(formatEl, selectionNode));
|
|
52
|
+
actions.push(A.enterScrollTo(range));
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (
|
|
57
|
+
(rangeEnt.commonAncestorContainer.nodeType === 3 ? !(/** @type {HTMLElement} */ (rangeEnt.commonAncestorContainer).nextElementSibling) : true) &&
|
|
58
|
+
dom.check.isZeroWidth(formatEl.innerText.trim()) &&
|
|
59
|
+
!dom.check.isListCell(formatEl.nextElementSibling)
|
|
60
|
+
) {
|
|
61
|
+
ports.enterPrevent(e);
|
|
62
|
+
actions.push(A.enterFormatExitEmpty(formatEl, rangeEl));
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// br line | closure block exception
|
|
68
|
+
if (brBlock || (rangeEl === formatEl && format.isClosureBlock(rangeEl) && format.isLine(formatEl))) {
|
|
69
|
+
ports.enterPrevent(e);
|
|
70
|
+
|
|
71
|
+
const selectionFormat = selectionNode === brBlock;
|
|
72
|
+
const wSelection = selection.get();
|
|
73
|
+
const children = selectionNode.childNodes,
|
|
74
|
+
offset = wSelection.focusOffset,
|
|
75
|
+
prev = selectionNode.previousElementSibling,
|
|
76
|
+
next = selectionNode.nextSibling;
|
|
77
|
+
|
|
78
|
+
if (
|
|
79
|
+
!format.isClosureBrLine(brBlock) &&
|
|
80
|
+
children &&
|
|
81
|
+
((selectionFormat &&
|
|
82
|
+
range.collapsed &&
|
|
83
|
+
children.length - 1 <= offset + 1 &&
|
|
84
|
+
dom.check.isBreak(children[offset]) &&
|
|
85
|
+
(!children[offset + 1] || ((!children[offset + 2] || dom.check.isZeroWidth(children[offset + 2].textContent)) && children[offset + 1].nodeType === 3 && dom.check.isZeroWidth(children[offset + 1].textContent))) &&
|
|
86
|
+
offset > 0 &&
|
|
87
|
+
dom.check.isBreak(children[offset - 1])) ||
|
|
88
|
+
(!selectionFormat &&
|
|
89
|
+
dom.check.isZeroWidth(selectionNode.textContent) &&
|
|
90
|
+
dom.check.isBreak(prev) &&
|
|
91
|
+
(dom.check.isBreak(prev.previousSibling) || !dom.check.isZeroWidth(prev.previousSibling?.textContent)) &&
|
|
92
|
+
(!next || (!dom.check.isBreak(next) && dom.check.isZeroWidth(next.textContent)))))
|
|
93
|
+
) {
|
|
94
|
+
actions.push(A.enterFormatCleanBrAndZWS(selectionNode, selectionFormat, brBlock, children, offset));
|
|
95
|
+
actions.push(A.enterScrollTo(range));
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (selectionFormat) {
|
|
100
|
+
actions.push(A.enterFormatInsertBrHtml(brBlock, range, wSelection, offset));
|
|
101
|
+
} else {
|
|
102
|
+
actions.push(A.enterFormatInsertBrNode(wSelection));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
actions.push(A.enterScrollTo(range));
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// set format attrs - edge
|
|
110
|
+
if (range.collapsed && (formatStartEdge || formatEndEdge)) {
|
|
111
|
+
ports.enterPrevent(e);
|
|
112
|
+
actions.push(A.enterFormatBreakAtEdge(formatEl, selectionNode, formatStartEdge, formatEndEdge));
|
|
113
|
+
actions.push(A.enterScrollTo(range));
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (formatEl) {
|
|
118
|
+
actions.push(A.prevent());
|
|
119
|
+
|
|
120
|
+
/** @type {HTMLElement} */
|
|
121
|
+
if (selectRange) {
|
|
122
|
+
actions.push(A.enterFormatBreakWithSelection(formatEl, range, formatStartEdge, formatEndEdge));
|
|
123
|
+
} else {
|
|
124
|
+
actions.push(A.enterFormatBreakAtCursor(formatEl, range));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
actions.push(A.enterScrollTo(range));
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (selectRange) {
|
|
133
|
+
actions.push(A.enterScrollTo(range));
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (rangeEl && dom.query.getParentElement(rangeEl, 'FIGCAPTION') && dom.query.getParentElement(rangeEl, dom.check.isList)) {
|
|
138
|
+
ports.enterPrevent(e);
|
|
139
|
+
actions.push(A.enterFigcaptionExitInList(formatEl));
|
|
140
|
+
actions.push(A.enterScrollTo(range));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { dom } from '../../../helper';
|
|
2
|
+
import { A } from '../actions';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @this {void}
|
|
6
|
+
* @description Tab key down rule
|
|
7
|
+
* @param {__se__EventActions} actions - Action list
|
|
8
|
+
* @param {__se__EventPorts} _ports - Ports for interacting with editor
|
|
9
|
+
* @param {__se__EventKeydownCtx} ctx - Context object
|
|
10
|
+
* @returns {boolean} Return false to stop the processing
|
|
11
|
+
*/
|
|
12
|
+
export function reduceTabDown(actions, _ports, ctx) {
|
|
13
|
+
const { options, selectionNode, range, formatEl, ctrl, alt, shift } = ctx;
|
|
14
|
+
|
|
15
|
+
if (options.get('tabDisable')) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
actions.push(A.prevent());
|
|
20
|
+
|
|
21
|
+
if (ctrl || alt || dom.check.isWysiwygFrame(selectionNode)) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
actions.push(A.tabFormatIndent(range, formatEl, shift));
|
|
26
|
+
actions.push(A.historyPush(false));
|
|
27
|
+
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
@@ -8,18 +8,48 @@ import { DEFAULTS } from '../config/options';
|
|
|
8
8
|
const _d = env._d;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* @typedef {import('../config/options').EditorFrameOptions}
|
|
11
|
+
* @typedef {import('../config/options').EditorFrameOptions} EditorFrameOptions_constructor
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* @typedef {import('../config/options').EditorInitOptions}
|
|
15
|
+
* @typedef {import('../config/options').EditorInitOptions} EditorInitOptions_constructor
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {import('../config/options').AllBaseOptions} AllBaseOptions_constructor
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {import('../config/options').BaseOptionsMap} BaseOptionsMap_constructor
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @typedef {import('../config/options').FrameOptionsMap} FrameOptionsMap_constructor
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {Object} ConstructorReturnType
|
|
32
|
+
* @property {__se__Context} context - Editor context object
|
|
33
|
+
* @property {HTMLElement} carrierWrapper - Carrier wrapper element
|
|
34
|
+
* @property {__se__BaseOptions} options - Processed editor options (Map)
|
|
35
|
+
* @property {Object<string, *>} plugins - Loaded plugins
|
|
36
|
+
* @property {Object<string, string>} icons - Icon set
|
|
37
|
+
* @property {Object<string, string>} lang - Language pack
|
|
38
|
+
* @property {string|null} value - Initial editor value
|
|
39
|
+
* @property {string|null} rootId - Root frame ID
|
|
40
|
+
* @property {Array<string|null>} rootKeys - Array of frame keys
|
|
41
|
+
* @property {Map<string|null, ReturnType<import('../config/frameContext').CreateFrameContext>>} frameRoots - Map of frame contexts
|
|
42
|
+
* @property {Object<string, Array<HTMLElement>>} pluginCallButtons - Plugin toolbar buttons
|
|
43
|
+
* @property {Array<HTMLElement>} responsiveButtons - Responsive toolbar buttons
|
|
44
|
+
* @property {Object<string, Array<HTMLElement>>|[]} pluginCallButtons_sub - Sub-toolbar plugin buttons
|
|
45
|
+
* @property {Array<HTMLElement>} responsiveButtons_sub - Sub-toolbar responsive buttons
|
|
16
46
|
*/
|
|
17
47
|
|
|
18
48
|
/**
|
|
19
49
|
* @description Creates a new SunEditor instance with specified options.
|
|
20
|
-
* @param {Array<{target: Element, key: *, options:
|
|
21
|
-
* @param {
|
|
22
|
-
* @returns {
|
|
50
|
+
* @param {Array<{target: Element, key: *, options: EditorFrameOptions_constructor}>} editorTargets - Target element or multi-root object.
|
|
51
|
+
* @param {EditorInitOptions_constructor} options - Configuration options for the editor.
|
|
52
|
+
* @returns {ConstructorReturnType} - SunEditor instance with context, options, and DOM elements.
|
|
23
53
|
*/
|
|
24
54
|
function Constructor(editorTargets, options) {
|
|
25
55
|
if (typeof options !== 'object') options = {};
|
|
@@ -339,20 +369,24 @@ function _mergeObject(a, b) {
|
|
|
339
369
|
}, {});
|
|
340
370
|
}
|
|
341
371
|
|
|
372
|
+
/**
|
|
373
|
+
* @typedef {Object} InitOptionsReturnType
|
|
374
|
+
* @property {BaseOptionsMap_constructor} o - Processed base options (Map containing {@link AllBaseOptions_constructor} keys)
|
|
375
|
+
* @property {Object<string, string>} i - Icon set
|
|
376
|
+
* @property {Object<string, string>} l - Language pack
|
|
377
|
+
* @property {string|null} v - Initial editor value
|
|
378
|
+
* @property {Array<string[]|string>} buttons - Toolbar button list (arrays for groups, strings for single buttons)
|
|
379
|
+
* @property {Array<string[]|string>|null} subButtons - Sub-toolbar button list
|
|
380
|
+
* @property {Element|null} statusbarContainer - Container element for status bar (if specified)
|
|
381
|
+
* @property {Map<string|null, FrameOptionsMap_constructor>} frameMap - Map of frame-specific options (frame key => {@link FrameOptionsMap})
|
|
382
|
+
*/
|
|
383
|
+
|
|
342
384
|
/**
|
|
343
385
|
* @description Initialize options
|
|
344
|
-
* @param {
|
|
345
|
-
* @param {Array<{target: Element, key: *, options:
|
|
386
|
+
* @param {EditorInitOptions_constructor} options Configuration options for the editor.
|
|
387
|
+
* @param {Array<{target: Element, key: *, options: EditorFrameOptions_constructor}>} editorTargets Target textarea
|
|
346
388
|
* @param {Object<string, *>} plugins Plugins object
|
|
347
|
-
* @returns {
|
|
348
|
-
* - o: options
|
|
349
|
-
* - i: icons
|
|
350
|
-
* - l: lang
|
|
351
|
-
* - v: value
|
|
352
|
-
* - buttons: Toolbar button list
|
|
353
|
-
* - subButtons: Sub-Toolbar button list
|
|
354
|
-
* - statusbarContainer: statusbar container
|
|
355
|
-
* - frameMap: converted options map
|
|
389
|
+
* @returns {InitOptionsReturnType} Initialized options and configuration
|
|
356
390
|
*/
|
|
357
391
|
export function InitOptions(options, editorTargets, plugins) {
|
|
358
392
|
const buttonList = options.buttonList || DEFAULTS.BUTTON_LIST;
|
|
@@ -619,12 +653,12 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
619
653
|
_h3: ['c+s+Digit3|Numpad3+$~formatBlock.applyHeaderByShortcut', '']
|
|
620
654
|
},
|
|
621
655
|
options.shortcuts || {}
|
|
622
|
-
|
|
656
|
+
].reduce((_default, _new) => {
|
|
623
657
|
for (const key in _new) {
|
|
624
658
|
_default[key] = _new[key];
|
|
625
659
|
}
|
|
626
660
|
return _default;
|
|
627
|
-
|
|
661
|
+
}, {});
|
|
628
662
|
o.set('shortcuts', shortcuts);
|
|
629
663
|
|
|
630
664
|
/** View */
|
|
@@ -665,7 +699,7 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
665
699
|
_default[key] = _new[key];
|
|
666
700
|
}
|
|
667
701
|
return _default;
|
|
668
|
-
|
|
702
|
+
}, {});
|
|
669
703
|
o.set('icons', icons);
|
|
670
704
|
|
|
671
705
|
/** Create all used styles */
|
|
@@ -759,9 +793,9 @@ export function CreateStatusbar(targetOptions, statusbar) {
|
|
|
759
793
|
|
|
760
794
|
/**
|
|
761
795
|
* @description Initialize options.
|
|
762
|
-
* @param {
|
|
763
|
-
* @param {
|
|
764
|
-
* @returns {Map
|
|
796
|
+
* @param {EditorFrameOptions_constructor} o - Target options
|
|
797
|
+
* @param {EditorInitOptions_constructor} origin - Full options
|
|
798
|
+
* @returns {FrameOptionsMap_constructor} Processed frame options Map
|
|
765
799
|
*/
|
|
766
800
|
function InitFrameOptions(o, origin) {
|
|
767
801
|
const fo = new Map();
|
|
@@ -1081,7 +1115,7 @@ function _createButton(className, title, dataCommand, dataType, innerHTML, _disa
|
|
|
1081
1115
|
'data-type': dataType,
|
|
1082
1116
|
'aria-label': label.replace(/<span .+<\/span>/, ''),
|
|
1083
1117
|
tabindex: '-1'
|
|
1084
|
-
|
|
1118
|
+
})
|
|
1085
1119
|
);
|
|
1086
1120
|
|
|
1087
1121
|
if (!isDiv) {
|
|
@@ -17,6 +17,10 @@ function ClassInjector(editor) {
|
|
|
17
17
|
this.format = editor.format;
|
|
18
18
|
/** @description HTML class instance @type {__se__EditorCore['html']} */
|
|
19
19
|
this.html = editor.html;
|
|
20
|
+
/** @description Inline format class instance @type {__se__EditorCore['inline']} */
|
|
21
|
+
this.inline = editor.inline;
|
|
22
|
+
/** @description List format class instance @type {__se__EditorCore['listFormat']} */
|
|
23
|
+
this.listFormat = editor.listFormat;
|
|
20
24
|
/** @description Menu class instance @type {__se__EditorCore['menu']} */
|
|
21
25
|
this.menu = editor.menu;
|
|
22
26
|
/** @description NodeTransform class instance @type {__se__EditorCore['nodeTransform']} */
|
|
@@ -57,6 +57,10 @@ function EditorInjector(editor) {
|
|
|
57
57
|
this.format;
|
|
58
58
|
/** @type {import('./_classes').default['html']} */
|
|
59
59
|
this.html;
|
|
60
|
+
/** @type {import('./_classes').default['inline']} */
|
|
61
|
+
this.inline;
|
|
62
|
+
/** @type {import('./_classes').default['listFormat']} */
|
|
63
|
+
this.listFormat;
|
|
60
64
|
/** @type {import('./_classes').default['menu']} */
|
|
61
65
|
this.menu;
|
|
62
66
|
/** @type {import('./_classes').default['nodeTransform']} */
|
package/src/helper/clipboard.js
CHANGED
package/src/helper/converter.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { _d, _w } from './env';
|
|
2
2
|
|
|
3
|
-
const URLPattern = /https?:\/\/[^\s]+/g;
|
|
4
3
|
const FONT_VALUES_MAP = {
|
|
5
4
|
'xx-small': 0.5625,
|
|
6
5
|
'x-small': 0.625,
|
|
@@ -200,7 +199,7 @@ export function getValues(obj) {
|
|
|
200
199
|
? []
|
|
201
200
|
: Object.keys(obj).map(function (i) {
|
|
202
201
|
return obj[i];
|
|
203
|
-
|
|
202
|
+
});
|
|
204
203
|
}
|
|
205
204
|
|
|
206
205
|
/**
|
|
@@ -377,6 +376,8 @@ export function getWidthInPercentage(target, parentTarget) {
|
|
|
377
376
|
* @returns {boolean} Return true if the text node is converted to an anchor node
|
|
378
377
|
*/
|
|
379
378
|
export function textToAnchor(node) {
|
|
379
|
+
const URLPattern = /https?:\/\/[^\s]+/g;
|
|
380
|
+
|
|
380
381
|
if (node.nodeType === 3 && URLPattern.test(node.textContent) && !/^A$/i.test(node.parentNode?.nodeName)) {
|
|
381
382
|
const textContent = node.textContent;
|
|
382
383
|
const fragment = _d.createDocumentFragment();
|
|
@@ -469,16 +470,14 @@ export function addUrlQuery(url, query) {
|
|
|
469
470
|
}
|
|
470
471
|
|
|
471
472
|
/**
|
|
472
|
-
* @typedef {
|
|
473
|
-
* @property {string} top - Styles applied to the top container (e.g. width, z-index, etc).
|
|
474
|
-
* @property {string} frame - Styles applied to the iframe container (e.g. height, min-height).
|
|
475
|
-
* @property {string} editor - Styles applied to the editable content area.
|
|
473
|
+
* @typedef {import('../core/config/options').OptionStyleResult} OptionStyleResult_converter
|
|
476
474
|
*/
|
|
475
|
+
|
|
477
476
|
/**
|
|
478
477
|
* @description Converts options-related styles and returns them for each frame.
|
|
479
478
|
* @param {Map<string, *>} fo editor.frameOptions
|
|
480
479
|
* @param {string} cssText Style string
|
|
481
|
-
* @returns {
|
|
480
|
+
* @returns {OptionStyleResult_converter}
|
|
482
481
|
* @private
|
|
483
482
|
*/
|
|
484
483
|
export function _setDefaultOptionStyle(fo, cssText) {
|
|
@@ -226,7 +226,7 @@ export function isNonEditable(node) {
|
|
|
226
226
|
export function isSpanWithoutAttr(node) {
|
|
227
227
|
if (node?.nodeType !== 1) return false;
|
|
228
228
|
const el = /** @type {HTMLElement} */ (node);
|
|
229
|
-
return /^SPAN$/i.test(el.nodeName) && !el.className &&
|
|
229
|
+
return /^SPAN$/i.test(el.nodeName) && !el.className && el.style.length === 0;
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
/**
|
|
@@ -224,7 +224,7 @@ export function prevIndex(array, item) {
|
|
|
224
224
|
export function copyTagAttributes(originEl, copyEl, blacklist) {
|
|
225
225
|
const o = /** @type {HTMLElement} */ (originEl);
|
|
226
226
|
const c = /** @type {HTMLElement} */ (copyEl);
|
|
227
|
-
if (c.style.
|
|
227
|
+
if (c.style.length > 0) {
|
|
228
228
|
const copyStyles = c.style;
|
|
229
229
|
for (let i = 0, len = copyStyles.length; i < len; i++) {
|
|
230
230
|
o.style[copyStyles[i]] = copyStyles[copyStyles[i]];
|
|
@@ -303,7 +303,7 @@ export function setStyle(elements, styleName, value) {
|
|
|
303
303
|
for (let i = 0, len = elements.length, e; i < len; i++) {
|
|
304
304
|
e = /** @type {HTMLElement} */ (elements[i]);
|
|
305
305
|
e.style[styleName] = value;
|
|
306
|
-
if (
|
|
306
|
+
if (e.style.length === 0) {
|
|
307
307
|
e.removeAttribute('style');
|
|
308
308
|
}
|
|
309
309
|
}
|
package/src/helper/dom/index.js
CHANGED
package/src/helper/env.js
CHANGED
|
@@ -40,13 +40,11 @@ export function getPageStyle(doc) {
|
|
|
40
40
|
const sheets = (doc || _d).styleSheets;
|
|
41
41
|
|
|
42
42
|
for (let i = 0, len = sheets.length, rules; i < len; i++) {
|
|
43
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
44
43
|
try {
|
|
45
44
|
rules = sheets[i].cssRules;
|
|
46
|
-
} catch
|
|
45
|
+
} catch {
|
|
47
46
|
continue;
|
|
48
47
|
}
|
|
49
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
50
48
|
|
|
51
49
|
if (rules) {
|
|
52
50
|
for (let c = 0, cLen = rules.length; c < cLen; c++) {
|
|
@@ -120,7 +118,6 @@ export const isResizeObserverSupported = (() => {
|
|
|
120
118
|
* @returns {boolean} Whether support navigator.clipboard or not.
|
|
121
119
|
*/
|
|
122
120
|
export const isClipboardSupported = (() => {
|
|
123
|
-
/* eslint-disable-next-line compat/compat */
|
|
124
121
|
return typeof navigator.clipboard?.write === 'function';
|
|
125
122
|
})();
|
|
126
123
|
|
|
@@ -177,7 +174,6 @@ export const isSafari = (() => {
|
|
|
177
174
|
* @type {boolean}
|
|
178
175
|
*/
|
|
179
176
|
export const isMobile = (() => {
|
|
180
|
-
/* eslint-disable-next-line compat/compat */
|
|
181
177
|
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent);
|
|
182
178
|
})();
|
|
183
179
|
|
|
@@ -186,7 +182,6 @@ export const isMobile = (() => {
|
|
|
186
182
|
* @type {boolean}
|
|
187
183
|
*/
|
|
188
184
|
export const isTouchDevice = (() => {
|
|
189
|
-
/* eslint-disable-next-line compat/compat */
|
|
190
185
|
return navigator.maxTouchPoints > 0 && 'ontouchstart' in _w;
|
|
191
186
|
})();
|
|
192
187
|
|
package/src/helper/keyCodeMap.js
CHANGED
package/src/langs/ckb.js
CHANGED
package/src/langs/cs.js
CHANGED
package/src/langs/da.js
CHANGED
package/src/langs/de.js
CHANGED
package/src/langs/en.js
CHANGED
package/src/langs/es.js
CHANGED
package/src/langs/fa.js
CHANGED
package/src/langs/fr.js
CHANGED
package/src/langs/he.js
CHANGED
package/src/langs/hu.js
CHANGED
package/src/langs/it.js
CHANGED
package/src/langs/ja.js
CHANGED
package/src/langs/km.js
CHANGED
package/src/langs/ko.js
CHANGED
package/src/langs/lv.js
CHANGED
package/src/langs/nl.js
CHANGED
package/src/langs/pl.js
CHANGED