suneditor 3.1.3 → 3.2.0
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 +480 -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 +136 -23
- 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 +9 -2
- package/src/core/event/handlers/handler_ww_key.js +86 -17
- package/src/core/event/handlers/handler_ww_mouse.js +45 -8
- package/src/core/event/ports.js +23 -5
- package/src/core/event/reducers/keydown.reducer.js +15 -2
- 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 +357 -87
- 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 +61 -19
- package/src/core/section/constructor.js +537 -103
- 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 +68 -23
- package/src/modules/contract/ColorPicker.js +12 -4
- package/src/modules/contract/Controller.js +37 -7
- package/src/modules/contract/Figure.js +159 -36
- package/src/modules/contract/HueSlider.js +27 -4
- package/src/modules/contract/Modal.js +62 -11
- package/src/modules/manager/FileManager.js +50 -8
- package/src/modules/ui/CommandMenu.js +597 -0
- package/src/modules/ui/ModalAnchorEditor.js +41 -9
- package/src/modules/ui/SelectMenu.js +481 -36
- package/src/modules/ui/index.js +1 -0
- package/src/plugins/browser/audioGallery.js +8 -1
- package/src/plugins/browser/fileBrowser.js +15 -2
- package/src/plugins/browser/fileGallery.js +8 -1
- package/src/plugins/browser/imageGallery.js +24 -3
- package/src/plugins/browser/videoGallery.js +19 -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 +132 -22
- package/src/plugins/modal/image/index.js +115 -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 +6 -1
- 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 +7 -2
- 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 +110 -37
- 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/Browser.d.ts +7 -7
- 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/ModalAnchorEditor.d.ts +6 -1
- 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 +17 -1
- package/types/plugins/browser/fileBrowser.d.ts +17 -1
- package/types/plugins/browser/fileGallery.d.ts +17 -1
- package/types/plugins/browser/imageGallery.d.ts +17 -1
- package/types/plugins/browser/videoGallery.d.ts +17 -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/embed.d.ts +34 -0
- package/types/plugins/modal/link.d.ts +4 -1
- package/types/typedef.d.ts +48 -23
|
@@ -35,15 +35,14 @@ class BlockStyle extends PluginDropdown {
|
|
|
35
35
|
this.title = this.$.lang.formats;
|
|
36
36
|
this.inner = '<span class="se-txt">' + this.$.lang.formats + '</span>' + this.$.icons.arrow_down;
|
|
37
37
|
|
|
38
|
-
// create
|
|
39
|
-
const menu =
|
|
38
|
+
// create menu from items
|
|
39
|
+
const menu = this.$.menu.initDropdownTarget(BlockStyle, CreateItems(this.$, pluginOptions.items), {
|
|
40
|
+
className: 'se-list-format',
|
|
41
|
+
});
|
|
40
42
|
|
|
41
43
|
// members
|
|
42
44
|
this.formatList = menu.querySelectorAll('li button');
|
|
43
45
|
this.currentFormat = '';
|
|
44
|
-
|
|
45
|
-
// init
|
|
46
|
-
this.$.menu.initDropdownTarget(BlockStyle, menu);
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
/**
|
|
@@ -86,7 +85,8 @@ class BlockStyle extends PluginDropdown {
|
|
|
86
85
|
on(target) {
|
|
87
86
|
const formatList = this.formatList;
|
|
88
87
|
const targetText = target.querySelector('.se-txt');
|
|
89
|
-
const currentFormat =
|
|
88
|
+
const currentFormat =
|
|
89
|
+
(targetText.getAttribute('data-value') || '') + (targetText.getAttribute('data-class') || '');
|
|
90
90
|
|
|
91
91
|
if (currentFormat !== this.currentFormat) {
|
|
92
92
|
for (let i = 0, len = formatList.length, f; i < len; i++) {
|
|
@@ -136,15 +136,12 @@ class BlockStyle extends PluginDropdown {
|
|
|
136
136
|
/**
|
|
137
137
|
* @param {SunEditor.Deps} $ - Kernel dependencies
|
|
138
138
|
* @param {Array<string|BlockStyleItem>} [items] - Block style items
|
|
139
|
-
* @returns {
|
|
139
|
+
* @returns {Array<import('../../core/logic/panel/menu').DropdownItem>}
|
|
140
140
|
*/
|
|
141
|
-
function
|
|
141
|
+
function CreateItems({ lang }, items) {
|
|
142
142
|
const defaultFormats = ['p', 'blockquote', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
143
143
|
const formatList = !items || items.length === 0 ? defaultFormats : items;
|
|
144
|
-
|
|
145
|
-
let list = /*html*/ `
|
|
146
|
-
<div class="se-list-inner">
|
|
147
|
-
<ul class="se-list-basic">`;
|
|
144
|
+
const result = [];
|
|
148
145
|
|
|
149
146
|
for (let i = 0, len = formatList.length, format, tagName, command, name, h, attrs, className; i < len; i++) {
|
|
150
147
|
format = formatList[i];
|
|
@@ -165,18 +162,16 @@ function CreateHTML({ lang }, items) {
|
|
|
165
162
|
attrs = className ? ' class="' + className + '"' : '';
|
|
166
163
|
}
|
|
167
164
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
165
|
+
result.push({
|
|
166
|
+
command,
|
|
167
|
+
value: tagName,
|
|
168
|
+
title: name,
|
|
169
|
+
innerHTML: `<${tagName}${attrs}>${name}</${tagName}>`,
|
|
170
|
+
attrs: { 'data-class': className || '' },
|
|
171
|
+
});
|
|
174
172
|
}
|
|
175
|
-
list += /*html*/ `
|
|
176
|
-
</ul>
|
|
177
|
-
</div>`;
|
|
178
173
|
|
|
179
|
-
return
|
|
174
|
+
return result;
|
|
180
175
|
}
|
|
181
176
|
|
|
182
177
|
export default BlockStyle;
|
|
@@ -27,9 +27,22 @@ class Font extends PluginDropdown {
|
|
|
27
27
|
this.title = this.$.lang.font;
|
|
28
28
|
this.inner = '<span class="se-txt">' + this.$.lang.font + '</span>' + this.$.icons.arrow_down;
|
|
29
29
|
|
|
30
|
-
// create
|
|
31
|
-
const fontList = pluginOptions.items || [
|
|
32
|
-
|
|
30
|
+
// create menu from items
|
|
31
|
+
const fontList = pluginOptions.items || [
|
|
32
|
+
'Arial',
|
|
33
|
+
'Comic Sans MS',
|
|
34
|
+
'Courier New',
|
|
35
|
+
'Impact',
|
|
36
|
+
'Georgia',
|
|
37
|
+
'tahoma',
|
|
38
|
+
'Trebuchet MS',
|
|
39
|
+
'Verdana',
|
|
40
|
+
];
|
|
41
|
+
const prependHTML = `<li><button type="button" class="se-btn se-btn-list default_value" data-command="" title="${this.$.lang.default}" aria-label="${this.$.lang.default}">${this.$.lang.default}</button></li><li class="se-btn-list se-sub-list"><span></span></li>`;
|
|
42
|
+
const menu = this.$.menu.initDropdownTarget(Font, CreateItems(fontList), {
|
|
43
|
+
className: 'se-list-font-family',
|
|
44
|
+
prependHTML,
|
|
45
|
+
});
|
|
33
46
|
|
|
34
47
|
// members
|
|
35
48
|
this.currentFont = '';
|
|
@@ -37,9 +50,6 @@ class Font extends PluginDropdown {
|
|
|
37
50
|
this.fontArray = fontList;
|
|
38
51
|
|
|
39
52
|
this.#defaultValue = /** @type {HTMLSpanElement} */ (menu.querySelector('.se-sub-list span'));
|
|
40
|
-
|
|
41
|
-
// init
|
|
42
|
-
this.$.menu.initDropdownTarget(Font, menu);
|
|
43
53
|
}
|
|
44
54
|
|
|
45
55
|
/**
|
|
@@ -52,9 +62,14 @@ class Font extends PluginDropdown {
|
|
|
52
62
|
|
|
53
63
|
let fontFamily = '';
|
|
54
64
|
if (!element) {
|
|
55
|
-
const font = this.$.store.get('hasFocus')
|
|
65
|
+
const font = this.$.store.get('hasFocus')
|
|
66
|
+
? this.$.frameContext.get('wwComputedStyle').fontFamily
|
|
67
|
+
: this.$.lang.font;
|
|
56
68
|
dom.utils.changeTxt(targetText, font);
|
|
57
|
-
dom.utils.changeTxt(
|
|
69
|
+
dom.utils.changeTxt(
|
|
70
|
+
tooltip,
|
|
71
|
+
this.$.store.get('hasFocus') ? this.$.lang.font + (font ? ' (' + font + ')' : '') : font,
|
|
72
|
+
);
|
|
58
73
|
} else if (this.$.format.isLine(element)) {
|
|
59
74
|
return undefined;
|
|
60
75
|
} else if ((fontFamily = dom.utils.getStyle(element, 'fontFamily'))) {
|
|
@@ -122,34 +137,19 @@ class Font extends PluginDropdown {
|
|
|
122
137
|
}
|
|
123
138
|
|
|
124
139
|
/**
|
|
125
|
-
* @param {SunEditor.Deps} $ - Kernel dependencies
|
|
126
140
|
* @param {string[]} fontList - Font name list
|
|
127
|
-
* @returns {
|
|
141
|
+
* @returns {Array<import('../../core/logic/panel/menu').DropdownItem>}
|
|
128
142
|
*/
|
|
129
|
-
function
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
for (let i = 0, len = fontList.length, font, text; i < len; i++) {
|
|
141
|
-
font = fontList[i];
|
|
142
|
-
text = font.split(',')[0];
|
|
143
|
-
list += /*html*/ `
|
|
144
|
-
<li>
|
|
145
|
-
<button type="button" class="se-btn se-btn-list" data-command="${font}" data-txt="${text}" title="${text}" aria-label="${text}" style="font-family:${font};">${text}</button>
|
|
146
|
-
</li>`;
|
|
147
|
-
}
|
|
148
|
-
list += /*html*/ `
|
|
149
|
-
</ul>
|
|
150
|
-
</div>`;
|
|
151
|
-
|
|
152
|
-
return dom.utils.createElement('DIV', { class: 'se-dropdown se-list-layer se-list-font-family' }, list);
|
|
143
|
+
function CreateItems(fontList) {
|
|
144
|
+
return fontList.map((font) => {
|
|
145
|
+
const text = font.split(',')[0];
|
|
146
|
+
return {
|
|
147
|
+
command: font,
|
|
148
|
+
title: text,
|
|
149
|
+
innerHTML: text,
|
|
150
|
+
attrs: { 'data-txt': text, style: `font-family:${font};` },
|
|
151
|
+
};
|
|
152
|
+
});
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
export default Font;
|
|
@@ -39,14 +39,13 @@ class HR extends PluginDropdown {
|
|
|
39
39
|
this.title = this.$.lang.horizontalLine;
|
|
40
40
|
this.icon = 'horizontal_line';
|
|
41
41
|
|
|
42
|
-
// create
|
|
43
|
-
const
|
|
42
|
+
// create menu from items
|
|
43
|
+
const menu = this.$.menu.initDropdownTarget(HR, CreateItems(this.$, pluginOptions.items), {
|
|
44
|
+
className: 'se-list-line',
|
|
45
|
+
});
|
|
44
46
|
|
|
45
47
|
// members
|
|
46
|
-
this.list =
|
|
47
|
-
|
|
48
|
-
// init
|
|
49
|
-
this.$.menu.initDropdownTarget(HR, HRMenus);
|
|
48
|
+
this.list = menu.querySelectorAll('button');
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
/**
|
|
@@ -117,47 +116,20 @@ class HR extends PluginDropdown {
|
|
|
117
116
|
/**
|
|
118
117
|
* @param {SunEditor.Deps} $ - Kernel dependencies
|
|
119
118
|
* @param {Array<{name: string, class: string, style?: string}>} [HRItems] - HR style items
|
|
120
|
-
* @returns {
|
|
119
|
+
* @returns {Array<import('../../core/logic/panel/menu').DropdownItem>}
|
|
121
120
|
*/
|
|
122
|
-
function
|
|
121
|
+
function CreateItems({ lang }, HRItems) {
|
|
123
122
|
const items = HRItems || [
|
|
124
|
-
{
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
style: null,
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
name: lang.hr_dashed,
|
|
131
|
-
class: '__se__dashed',
|
|
132
|
-
style: null,
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
name: lang.hr_dotted,
|
|
136
|
-
class: '__se__dotted',
|
|
137
|
-
style: null,
|
|
138
|
-
},
|
|
123
|
+
{ name: lang.hr_solid, class: '__se__solid', style: null },
|
|
124
|
+
{ name: lang.hr_dashed, class: '__se__dashed', style: null },
|
|
125
|
+
{ name: lang.hr_dotted, class: '__se__dotted', style: null },
|
|
139
126
|
];
|
|
140
127
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
<hr${items[i].class ? ` class="${items[i].class}"` : ''}${items[i].style ? ` style="${items[i].style}"` : ''}/>
|
|
147
|
-
</button>
|
|
148
|
-
</li>`;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return dom.utils.createElement(
|
|
152
|
-
'DIV',
|
|
153
|
-
{
|
|
154
|
-
class: 'se-dropdown se-list-layer se-list-line',
|
|
155
|
-
},
|
|
156
|
-
/*html*/ `
|
|
157
|
-
<div class="se-list-inner">
|
|
158
|
-
<ul class="se-list-basic">${list}</ul>
|
|
159
|
-
</div>`,
|
|
160
|
-
);
|
|
128
|
+
return items.map((item) => ({
|
|
129
|
+
command: 'hr',
|
|
130
|
+
title: item.name,
|
|
131
|
+
innerHTML: `<hr${item.class ? ` class="${item.class}"` : ''}${item.style ? ` style="${item.style}"` : ''}/>`,
|
|
132
|
+
}));
|
|
161
133
|
}
|
|
162
134
|
|
|
163
135
|
export default HR;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PluginDropdown } from '../../interfaces';
|
|
2
|
-
import { dom } from '../../helper';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* @typedef {Object} LayoutPluginOptions
|
|
@@ -32,11 +31,8 @@ class Layout extends PluginDropdown {
|
|
|
32
31
|
this.selectedIndex = -1;
|
|
33
32
|
this.items = pluginOptions.items;
|
|
34
33
|
|
|
35
|
-
// create
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// init
|
|
39
|
-
this.$.menu.initDropdownTarget(Layout, menu);
|
|
34
|
+
// create menu from items
|
|
35
|
+
this.$.menu.initDropdownTarget(Layout, CreateItems(this.items));
|
|
40
36
|
}
|
|
41
37
|
|
|
42
38
|
/**
|
|
@@ -60,32 +56,19 @@ class Layout extends PluginDropdown {
|
|
|
60
56
|
|
|
61
57
|
/**
|
|
62
58
|
* @param {Array<{name: string, html: string}>} layoutList - Layout items
|
|
63
|
-
* @returns {
|
|
59
|
+
* @returns {Array<import('../../core/logic/panel/menu').DropdownItem>}
|
|
64
60
|
*/
|
|
65
|
-
function
|
|
61
|
+
function CreateItems(layoutList) {
|
|
66
62
|
if (!layoutList || layoutList.length === 0) {
|
|
67
63
|
console.warn('[SUNEDITOR.plugins.layout.warn] To use the "layout" plugin, please define the "layouts" option.');
|
|
68
64
|
}
|
|
69
65
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
list += /*html*/ `
|
|
77
|
-
<li>
|
|
78
|
-
<button type="button" class="se-btn se-btn-list" data-command="layout" data-value="${i}" title="${t.name}" aria-label="${t.name}">
|
|
79
|
-
${t.name}
|
|
80
|
-
</button>
|
|
81
|
-
</li>`;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
list += /*html*/ `
|
|
85
|
-
</ul>
|
|
86
|
-
</div>`;
|
|
87
|
-
|
|
88
|
-
return dom.utils.createElement('DIV', { class: 'se-list-layer' }, list);
|
|
66
|
+
return (layoutList || []).map((t, i) => ({
|
|
67
|
+
command: 'layout',
|
|
68
|
+
value: String(i),
|
|
69
|
+
title: t.name,
|
|
70
|
+
innerHTML: t.name,
|
|
71
|
+
}));
|
|
89
72
|
}
|
|
90
73
|
|
|
91
74
|
export default Layout;
|
|
@@ -30,17 +30,15 @@ class LineHeight extends PluginDropdown {
|
|
|
30
30
|
this.title = this.$.lang.lineHeight;
|
|
31
31
|
this.icon = 'line_height';
|
|
32
32
|
|
|
33
|
-
// create
|
|
34
|
-
const
|
|
33
|
+
// create menu from items
|
|
34
|
+
const prependHTML = `<li><button type="button" class="se-btn se-btn-list default_value" data-command="" title="${this.$.lang.default}" aria-label="${this.$.lang.default}">${this.$.lang.default}</button></li><li class="se-btn-list se-sub-list"><span></span></li>`;
|
|
35
|
+
const menu = this.$.menu.initDropdownTarget(LineHeight, CreateItems(pluginOptions.items), { prependHTML });
|
|
35
36
|
|
|
36
37
|
// members
|
|
37
38
|
this.sizeList = menu.querySelectorAll('li button');
|
|
38
39
|
this.currentSize = null;
|
|
39
40
|
|
|
40
41
|
this.#defaultValue = /** @type {HTMLSpanElement} */ (menu.querySelector('.se-sub-list span'));
|
|
41
|
-
|
|
42
|
-
// init
|
|
43
|
-
this.$.menu.initDropdownTarget(LineHeight, menu);
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
/**
|
|
@@ -108,11 +106,10 @@ class LineHeight extends PluginDropdown {
|
|
|
108
106
|
}
|
|
109
107
|
|
|
110
108
|
/**
|
|
111
|
-
* @param {SunEditor.Deps} $ - Kernel dependencies
|
|
112
109
|
* @param {Array<{text: string, value: string}>} [items] - Line height items
|
|
113
|
-
* @returns {
|
|
110
|
+
* @returns {Array<import('../../core/logic/panel/menu').DropdownItem>}
|
|
114
111
|
*/
|
|
115
|
-
function
|
|
112
|
+
function CreateItems(items) {
|
|
116
113
|
const sizeList = items || [
|
|
117
114
|
{ text: '1', value: '1em' },
|
|
118
115
|
{ text: '1.2', value: '1.2em' },
|
|
@@ -120,31 +117,11 @@ function CreateHTML({ lang }, items) {
|
|
|
120
117
|
{ text: '2', value: '2em' },
|
|
121
118
|
];
|
|
122
119
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
${lang.default}
|
|
129
|
-
</button>
|
|
130
|
-
</li>
|
|
131
|
-
<li class="se-btn-list se-sub-list"><span></span></li>`;
|
|
132
|
-
|
|
133
|
-
for (let i = 0, len = sizeList.length, size; i < len; i++) {
|
|
134
|
-
size = sizeList[i];
|
|
135
|
-
list += /*html*/ `
|
|
136
|
-
<li>
|
|
137
|
-
<button type="button" class="se-btn se-btn-list" data-command="${size.value}" title="${size.text}" aria-label="${size.text}">
|
|
138
|
-
${size.text}
|
|
139
|
-
</button>
|
|
140
|
-
</li>`;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
list += /*html*/ `
|
|
144
|
-
</ul>
|
|
145
|
-
</div>`;
|
|
146
|
-
|
|
147
|
-
return dom.utils.createElement('DIV', { class: 'se-dropdown se-list-layer' }, list);
|
|
120
|
+
return sizeList.map((size) => ({
|
|
121
|
+
command: size.value,
|
|
122
|
+
title: size.text,
|
|
123
|
+
innerHTML: size.text,
|
|
124
|
+
}));
|
|
148
125
|
}
|
|
149
126
|
|
|
150
127
|
export default LineHeight;
|
|
@@ -22,18 +22,15 @@ class List extends PluginDropdown {
|
|
|
22
22
|
this.title = this.$.lang.list;
|
|
23
23
|
this.icon = 'list_numbered';
|
|
24
24
|
|
|
25
|
-
// create HTML
|
|
26
|
-
const menu = CreateHTML(this.$);
|
|
27
|
-
|
|
28
25
|
// members
|
|
29
|
-
this.#listItems = menu.querySelectorAll('li button');
|
|
30
26
|
this.#listIcons = {
|
|
31
27
|
bulleted: this.$.icons.list_bulleted,
|
|
32
28
|
numbered: this.$.icons.list_numbered,
|
|
33
29
|
};
|
|
34
30
|
|
|
35
|
-
//
|
|
36
|
-
this.$.menu.initDropdownTarget(List,
|
|
31
|
+
// create menu from items
|
|
32
|
+
const menu = this.$.menu.initDropdownTarget(List, CreateItems(this.$));
|
|
33
|
+
this.#listItems = menu.querySelectorAll('li button');
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
/**
|
|
@@ -97,26 +94,23 @@ class List extends PluginDropdown {
|
|
|
97
94
|
|
|
98
95
|
/**
|
|
99
96
|
* @param {SunEditor.Deps} $ - Kernel dependencies
|
|
100
|
-
* @returns {
|
|
97
|
+
* @returns {Array<import('../../core/logic/panel/menu').DropdownItem>}
|
|
101
98
|
*/
|
|
102
|
-
function
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
</div>`;
|
|
118
|
-
|
|
119
|
-
return dom.utils.createElement('DIV', { class: 'se-dropdown se-list-layer' }, html);
|
|
99
|
+
function CreateItems({ lang, icons }) {
|
|
100
|
+
return [
|
|
101
|
+
{
|
|
102
|
+
command: 'ol',
|
|
103
|
+
title: lang.numberedList,
|
|
104
|
+
innerHTML: icons.list_numbered,
|
|
105
|
+
className: 'se-tooltip se-icon-flip-rtl',
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
command: 'ul',
|
|
109
|
+
title: lang.bulletedList,
|
|
110
|
+
innerHTML: icons.list_bulleted,
|
|
111
|
+
className: 'se-tooltip se-icon-flip-rtl',
|
|
112
|
+
},
|
|
113
|
+
];
|
|
120
114
|
}
|
|
121
115
|
|
|
122
116
|
export default List;
|
|
@@ -35,14 +35,13 @@ class ParagraphStyle extends PluginDropdown {
|
|
|
35
35
|
this.title = this.$.lang.paragraphStyle;
|
|
36
36
|
this.icon = 'paragraph_style';
|
|
37
37
|
|
|
38
|
-
// create
|
|
39
|
-
const menu =
|
|
38
|
+
// create menu from items
|
|
39
|
+
const menu = this.$.menu.initDropdownTarget(ParagraphStyle, CreateItems(this.$, pluginOptions.items), {
|
|
40
|
+
className: 'se-list-format',
|
|
41
|
+
});
|
|
40
42
|
|
|
41
43
|
// members
|
|
42
44
|
this.classList = menu.querySelectorAll('li button');
|
|
43
|
-
|
|
44
|
-
// init
|
|
45
|
-
this.$.menu.initDropdownTarget(ParagraphStyle, menu);
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
/**
|
|
@@ -88,9 +87,9 @@ class ParagraphStyle extends PluginDropdown {
|
|
|
88
87
|
/**
|
|
89
88
|
* @param {SunEditor.Deps} $ - Kernel dependencies
|
|
90
89
|
* @param {Array<string|{name: string, class: string, _class?: string}>} [items] - Paragraph style items
|
|
91
|
-
* @returns {
|
|
90
|
+
* @returns {Array<import('../../core/logic/panel/menu').DropdownItem>}
|
|
92
91
|
*/
|
|
93
|
-
function
|
|
92
|
+
function CreateItems({ lang }, items) {
|
|
94
93
|
const defaultList = {
|
|
95
94
|
spaced: {
|
|
96
95
|
name: lang.menu_spaced,
|
|
@@ -109,12 +108,9 @@ function CreateHTML({ lang }, items) {
|
|
|
109
108
|
},
|
|
110
109
|
};
|
|
111
110
|
const paragraphStyles = !items || items.length === 0 ? ['spaced', 'bordered', 'neon'] : items;
|
|
111
|
+
const result = [];
|
|
112
112
|
|
|
113
|
-
let
|
|
114
|
-
<div class="se-list-inner">
|
|
115
|
-
<ul class="se-list-basic">`;
|
|
116
|
-
|
|
117
|
-
for (let i = 0, len = paragraphStyles.length, p, name, attrs, _class; i < len; i++) {
|
|
113
|
+
for (let i = 0, len = paragraphStyles.length, p, name, attrs; i < len; i++) {
|
|
118
114
|
p = paragraphStyles[i];
|
|
119
115
|
|
|
120
116
|
if (typeof p === 'string') {
|
|
@@ -125,20 +121,16 @@ function CreateHTML({ lang }, items) {
|
|
|
125
121
|
|
|
126
122
|
name = p.name;
|
|
127
123
|
attrs = p.class ? ` class="${p.class}"` : '';
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
</li>`;
|
|
124
|
+
|
|
125
|
+
result.push({
|
|
126
|
+
command: p.class,
|
|
127
|
+
title: name,
|
|
128
|
+
innerHTML: `<div${attrs}>${name}</div>`,
|
|
129
|
+
className: p._class || undefined,
|
|
130
|
+
});
|
|
136
131
|
}
|
|
137
|
-
list += /*html*/ `
|
|
138
|
-
</ul>
|
|
139
|
-
</div>`;
|
|
140
132
|
|
|
141
|
-
return
|
|
133
|
+
return result;
|
|
142
134
|
}
|
|
143
135
|
|
|
144
136
|
export default ParagraphStyle;
|