suneditor 3.1.4 → 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 +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 -93
- 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 +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 +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
|
@@ -44,7 +44,9 @@ function Constructor(editorTargets, options) {
|
|
|
44
44
|
if (options.plugins) {
|
|
45
45
|
const excludedPlugins = options.excludedPlugins || [];
|
|
46
46
|
const originPlugins = options.plugins;
|
|
47
|
-
const pluginsValues = (Array.isArray(originPlugins) ? originPlugins : Object.keys(originPlugins))
|
|
47
|
+
const pluginsValues = (Array.isArray(originPlugins) ? originPlugins : Object.keys(originPlugins))
|
|
48
|
+
.filter((name) => !excludedPlugins.includes(name))
|
|
49
|
+
.map((name) => originPlugins[name]);
|
|
48
50
|
|
|
49
51
|
for (let i = 0, len = pluginsValues.length, p; i < len; i++) {
|
|
50
52
|
p = pluginsValues[i].default || pluginsValues[i];
|
|
@@ -57,11 +59,20 @@ function Constructor(editorTargets, options) {
|
|
|
57
59
|
const o = optionMap.o;
|
|
58
60
|
const icons = optionMap.i;
|
|
59
61
|
const lang = optionMap.l;
|
|
60
|
-
const loadingBox = dom.utils.createElement(
|
|
62
|
+
const loadingBox = dom.utils.createElement(
|
|
63
|
+
'DIV',
|
|
64
|
+
{ class: 'se-loading-box sun-editor-common' },
|
|
65
|
+
'<div class="se-loading-effect"></div>',
|
|
66
|
+
);
|
|
61
67
|
const editorFormFieldPrefix = 'suneditor-' + ++editorInstanceId;
|
|
62
68
|
|
|
63
69
|
/** --- carrier wrapper --------------------------------------------------------------- */
|
|
64
|
-
const editor_carrier_wrapper = dom.utils.createElement('DIV', {
|
|
70
|
+
const editor_carrier_wrapper = dom.utils.createElement('DIV', {
|
|
71
|
+
class:
|
|
72
|
+
'sun-editor sun-editor-carrier-wrapper sun-editor-common' +
|
|
73
|
+
o.get('_themeClass') +
|
|
74
|
+
(o.get('_rtl') ? ' se-rtl' : ''),
|
|
75
|
+
});
|
|
65
76
|
// menuTray
|
|
66
77
|
const menuTray = dom.utils.createElement('DIV', { class: 'se-menu-tray', popover: 'manual' });
|
|
67
78
|
editor_carrier_wrapper.appendChild(menuTray);
|
|
@@ -80,7 +91,10 @@ function Constructor(editorTargets, options) {
|
|
|
80
91
|
editor_carrier_wrapper.appendChild(focusTemp);
|
|
81
92
|
|
|
82
93
|
// modal
|
|
83
|
-
const modal = dom.utils.createElement('DIV', {
|
|
94
|
+
const modal = dom.utils.createElement('DIV', {
|
|
95
|
+
class: 'se-modal se-modal-area sun-editor-common',
|
|
96
|
+
popover: 'manual',
|
|
97
|
+
});
|
|
84
98
|
const modal_back = dom.utils.createElement('DIV', { class: 'se-modal-back' });
|
|
85
99
|
const modal_inner = dom.utils.createElement('DIV', { class: 'se-modal-inner' });
|
|
86
100
|
modal.appendChild(modal_back);
|
|
@@ -88,7 +102,11 @@ function Constructor(editorTargets, options) {
|
|
|
88
102
|
editor_carrier_wrapper.appendChild(modal);
|
|
89
103
|
|
|
90
104
|
// alert
|
|
91
|
-
const alert = dom.utils.createElement('DIV', {
|
|
105
|
+
const alert = dom.utils.createElement('DIV', {
|
|
106
|
+
class: 'se-alert se-modal-area sun-editor-common',
|
|
107
|
+
style: 'display: none;',
|
|
108
|
+
popover: 'manual',
|
|
109
|
+
});
|
|
92
110
|
const alert_back = dom.utils.createElement('DIV', { class: 'se-modal-back' });
|
|
93
111
|
const alert_inner = dom.utils.createElement('DIV', { class: 'se-modal-inner' });
|
|
94
112
|
alert.appendChild(alert_back);
|
|
@@ -147,9 +165,22 @@ function Constructor(editorTargets, options) {
|
|
|
147
165
|
for (let i = 0, len = editorTargets.length; i < len; i++) {
|
|
148
166
|
const editTarget = editorTargets[i];
|
|
149
167
|
const to = optionMap.frameMap.get(editTarget.key);
|
|
150
|
-
const top_div = dom.utils.createElement('DIV', {
|
|
168
|
+
const top_div = dom.utils.createElement('DIV', {
|
|
169
|
+
class: 'sun-editor' + o.get('_themeClass') + (o.get('_rtl') ? ' se-rtl' : ''),
|
|
170
|
+
});
|
|
151
171
|
const container = dom.utils.createElement('DIV', { class: 'se-container' });
|
|
152
|
-
const
|
|
172
|
+
const isBlockHandle = !!o.get('blockHandle');
|
|
173
|
+
const editor_div = dom.utils.createElement('DIV', {
|
|
174
|
+
class:
|
|
175
|
+
'se-wrapper' +
|
|
176
|
+
(isBlockHandle ? ' se-mode-block' : '') +
|
|
177
|
+
(o.get('type') === 'document' ? ' se-type-document' : '') +
|
|
178
|
+
(o.get('_type_options').includes('header') ? ' se-type-document-header' : ''),
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
const editorInnerW = to.get('innerWidth');
|
|
182
|
+
if (editorInnerW && editorInnerW !== 'auto')
|
|
183
|
+
editor_div.style.setProperty('--se-editor-inner-width', editorInnerW);
|
|
153
184
|
|
|
154
185
|
container.appendChild(dom.utils.createElement('DIV', { class: 'se-toolbar-shadow' }));
|
|
155
186
|
|
|
@@ -162,8 +193,16 @@ function Constructor(editorTargets, options) {
|
|
|
162
193
|
let textarea = initElements.codeView;
|
|
163
194
|
|
|
164
195
|
// line breaker
|
|
165
|
-
const line_breaker_t = dom.utils.createElement(
|
|
166
|
-
|
|
196
|
+
const line_breaker_t = dom.utils.createElement(
|
|
197
|
+
'DIV',
|
|
198
|
+
{ class: 'se-line-breaker-component se-line-breaker-component-t', title: lang.insertLine },
|
|
199
|
+
icons.line_break,
|
|
200
|
+
);
|
|
201
|
+
const line_breaker_b = dom.utils.createElement(
|
|
202
|
+
'DIV',
|
|
203
|
+
{ class: 'se-line-breaker-component se-line-breaker-component-b', title: lang.insertLine },
|
|
204
|
+
icons.line_break,
|
|
205
|
+
);
|
|
167
206
|
|
|
168
207
|
editor_div.appendChild(line_breaker_t);
|
|
169
208
|
editor_div.appendChild(line_breaker_b);
|
|
@@ -177,7 +216,9 @@ function Constructor(editorTargets, options) {
|
|
|
177
216
|
if (statusbar) {
|
|
178
217
|
if (statusbarContainer) {
|
|
179
218
|
if (!default_status_bar) {
|
|
180
|
-
statusbarContainer.appendChild(
|
|
219
|
+
statusbarContainer.appendChild(
|
|
220
|
+
dom.utils.createElement('DIV', { class: 'sun-editor' + o.get('_themeClass') }, statusbar),
|
|
221
|
+
);
|
|
181
222
|
default_status_bar = statusbar;
|
|
182
223
|
}
|
|
183
224
|
} else {
|
|
@@ -205,7 +246,14 @@ function Constructor(editorTargets, options) {
|
|
|
205
246
|
// add line nubers
|
|
206
247
|
const codeNumbers = dom.utils.createElement(
|
|
207
248
|
'TEXTAREA',
|
|
208
|
-
{
|
|
249
|
+
{
|
|
250
|
+
id: editorFormFieldPrefix + '-code-view-line-' + (key || 'default'),
|
|
251
|
+
class: 'se-code-view-line',
|
|
252
|
+
readonly: 'true',
|
|
253
|
+
autocomplete: 'off',
|
|
254
|
+
'aria-hidden': 'true',
|
|
255
|
+
tabindex: '-1',
|
|
256
|
+
},
|
|
209
257
|
null,
|
|
210
258
|
);
|
|
211
259
|
codeWrapper.insertBefore(codeNumbers, textarea);
|
|
@@ -221,7 +269,14 @@ function Constructor(editorTargets, options) {
|
|
|
221
269
|
markdownTextarea = initElements.markdownView;
|
|
222
270
|
const markdownNumbers = dom.utils.createElement(
|
|
223
271
|
'TEXTAREA',
|
|
224
|
-
{
|
|
272
|
+
{
|
|
273
|
+
id: editorFormFieldPrefix + '-markdown-view-line-' + (key || 'default'),
|
|
274
|
+
class: 'se-markdown-view-line',
|
|
275
|
+
readonly: 'true',
|
|
276
|
+
autocomplete: 'off',
|
|
277
|
+
'aria-hidden': 'true',
|
|
278
|
+
tabindex: '-1',
|
|
279
|
+
},
|
|
225
280
|
null,
|
|
226
281
|
);
|
|
227
282
|
markdownWrapper = dom.utils.createElement('DIV', { class: 'se-markdown-wrapper' });
|
|
@@ -234,7 +289,11 @@ function Constructor(editorTargets, options) {
|
|
|
234
289
|
// document type
|
|
235
290
|
const documentTypeInner = { inner: null, page: null, pageMirror: null };
|
|
236
291
|
if (o.get('_type_options').includes('header')) {
|
|
237
|
-
documentTypeInner.inner = dom.utils.createElement(
|
|
292
|
+
documentTypeInner.inner = dom.utils.createElement(
|
|
293
|
+
'DIV',
|
|
294
|
+
{ class: 'se-document-lines', style: `height: ${to.get('height')};` },
|
|
295
|
+
'<div class="se-document-lines-inner"></div>',
|
|
296
|
+
);
|
|
238
297
|
}
|
|
239
298
|
if (o.get('_type_options').includes('page')) {
|
|
240
299
|
documentTypeInner.page = dom.utils.createElement('DIV', { class: 'se-document-page' }, null);
|
|
@@ -248,12 +307,46 @@ function Constructor(editorTargets, options) {
|
|
|
248
307
|
);
|
|
249
308
|
}
|
|
250
309
|
|
|
310
|
+
// block handle
|
|
311
|
+
let blockHandleArea = null;
|
|
312
|
+
if (isBlockHandle) {
|
|
313
|
+
blockHandleArea = dom.utils.createElement('DIV', { class: 'se-block-handle-area' });
|
|
314
|
+
|
|
315
|
+
const blockHandleGroup = dom.utils.createElement('DIV', { class: 'se-block-handle' });
|
|
316
|
+
const blockHandlePlus = dom.utils.createElement(
|
|
317
|
+
'DIV',
|
|
318
|
+
{ class: 'se-block-handle-btn se-block-handle-plus' },
|
|
319
|
+
icons.plus,
|
|
320
|
+
);
|
|
321
|
+
const blockHandleDrag = dom.utils.createElement(
|
|
322
|
+
'DIV',
|
|
323
|
+
{ class: 'se-block-handle-btn se-block-handle-drag' },
|
|
324
|
+
icons.dragHandle,
|
|
325
|
+
);
|
|
326
|
+
blockHandleGroup.appendChild(blockHandlePlus);
|
|
327
|
+
blockHandleGroup.appendChild(blockHandleDrag);
|
|
328
|
+
|
|
329
|
+
blockHandleArea.appendChild(blockHandleGroup);
|
|
330
|
+
}
|
|
331
|
+
|
|
251
332
|
// set container
|
|
252
333
|
top_div.appendChild(container);
|
|
253
334
|
rootKeys.push(key);
|
|
254
335
|
frameRoots.set(
|
|
255
336
|
key,
|
|
256
|
-
CreateFrameContext(
|
|
337
|
+
CreateFrameContext(
|
|
338
|
+
{ target: editTarget.target, key: editTarget.key, options: to },
|
|
339
|
+
top_div,
|
|
340
|
+
wysiwyg_div,
|
|
341
|
+
codeWrapper,
|
|
342
|
+
textarea,
|
|
343
|
+
markdownWrapper,
|
|
344
|
+
markdownTextarea,
|
|
345
|
+
default_status_bar || statusbar,
|
|
346
|
+
documentTypeInner,
|
|
347
|
+
blockHandleArea,
|
|
348
|
+
key,
|
|
349
|
+
),
|
|
257
350
|
);
|
|
258
351
|
}
|
|
259
352
|
/** frame - root set - end -------------------------------------------------------------- */
|
|
@@ -261,7 +354,9 @@ function Constructor(editorTargets, options) {
|
|
|
261
354
|
// toolbar container
|
|
262
355
|
const toolbar_container = o.get('toolbar_container');
|
|
263
356
|
if (toolbar_container) {
|
|
264
|
-
const top_div = dom.utils.createElement('DIV', {
|
|
357
|
+
const top_div = dom.utils.createElement('DIV', {
|
|
358
|
+
class: 'sun-editor' + o.get('_themeClass') + (o.get('_rtl') ? ' se-rtl' : ''),
|
|
359
|
+
});
|
|
265
360
|
const container = dom.utils.createElement('DIV', { class: 'se-container' });
|
|
266
361
|
container.appendChild(toolbar);
|
|
267
362
|
if (subbar) container.appendChild(subbar);
|
|
@@ -311,7 +406,11 @@ export function CreateShortcuts(command, button, values, keyMap, rc, reverseKeys
|
|
|
311
406
|
if (!values || values.length < 2) return;
|
|
312
407
|
const tooptip = button?.querySelector('.se-tooltip-text');
|
|
313
408
|
|
|
314
|
-
for (
|
|
409
|
+
for (
|
|
410
|
+
let i = 0, a, v, c, s, edge, space, enter, textTrigger, plugin, method, t, k, r, _i;
|
|
411
|
+
i < values.length;
|
|
412
|
+
i += 2 + _i
|
|
413
|
+
) {
|
|
315
414
|
_i = 0;
|
|
316
415
|
a = values[i].split('+');
|
|
317
416
|
|
|
@@ -368,7 +467,21 @@ export function CreateShortcuts(command, button, values, keyMap, rc, reverseKeys
|
|
|
368
467
|
r = r === -1 ? '' : numbers.isOdd(r) ? rc[r + 1] : rc[r - 1];
|
|
369
468
|
if (r) reverseKeys.add(k);
|
|
370
469
|
|
|
371
|
-
keyMap.set(k, {
|
|
470
|
+
keyMap.set(k, {
|
|
471
|
+
c,
|
|
472
|
+
s,
|
|
473
|
+
edge,
|
|
474
|
+
space,
|
|
475
|
+
enter,
|
|
476
|
+
textTrigger,
|
|
477
|
+
plugin,
|
|
478
|
+
command,
|
|
479
|
+
method,
|
|
480
|
+
r,
|
|
481
|
+
type: button?.getAttribute('data-type'),
|
|
482
|
+
button,
|
|
483
|
+
key: k,
|
|
484
|
+
});
|
|
372
485
|
}
|
|
373
486
|
}
|
|
374
487
|
|
|
@@ -384,7 +497,11 @@ export function CreateShortcuts(command, button, values, keyMap, rc, reverseKeys
|
|
|
384
497
|
* @param {string} shortcut
|
|
385
498
|
*/
|
|
386
499
|
function _addTooltip(tooptipBtn, shift, shortcut) {
|
|
387
|
-
const tooltip = dom.utils.createElement(
|
|
500
|
+
const tooltip = dom.utils.createElement(
|
|
501
|
+
'SPAN',
|
|
502
|
+
{ class: 'se-shortcut' },
|
|
503
|
+
env.cmdIcon + (shift ? env.shiftIcon : '') + '+<span class="se-shortcut-key">' + shortcut + '</span>',
|
|
504
|
+
);
|
|
388
505
|
const prevTooltip = tooptipBtn.querySelector('.se-shortcut');
|
|
389
506
|
|
|
390
507
|
if (prevTooltip) {
|
|
@@ -434,7 +551,10 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
434
551
|
|
|
435
552
|
/** Multi root */
|
|
436
553
|
if (editorTargets.length > 1) {
|
|
437
|
-
if (!options.toolbar_container && !/inline|balloon/i.test(options.mode))
|
|
554
|
+
if (!options.toolbar_container && !/inline|balloon/i.test(options.mode))
|
|
555
|
+
throw Error(
|
|
556
|
+
'[SUNEDITOR.create.fail] In multi root, The "mode" option cannot be "classic" without using the "toolbar_container" option.',
|
|
557
|
+
);
|
|
438
558
|
}
|
|
439
559
|
|
|
440
560
|
// migration data-.+
|
|
@@ -459,13 +579,27 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
459
579
|
const [modeBase, modePart] = (options.mode || 'classic').split(':');
|
|
460
580
|
o.set('mode', modeBase); // classic, inline, balloon, balloon-always
|
|
461
581
|
o.set('_toolbar_bottom', modePart === 'bottom' && /^(classic|inline)$/i.test(modeBase));
|
|
582
|
+
o.set(
|
|
583
|
+
'blockHandle',
|
|
584
|
+
options.blockHandle ? (typeof options.blockHandle === 'object' ? options.blockHandle : {}) : null,
|
|
585
|
+
);
|
|
462
586
|
o.set('type', options.type?.split(':')[0] || ''); // document:header,page
|
|
463
587
|
o.set('theme', options.theme || '');
|
|
464
588
|
o.set('_themeClass', options.theme ? ` se-theme-${options.theme}` : '');
|
|
465
589
|
o.set('_type_options', options.type?.split(':')[1] || '');
|
|
466
590
|
o.set('externalLibs', options.externalLibs || {});
|
|
467
|
-
o.set(
|
|
468
|
-
|
|
591
|
+
o.set(
|
|
592
|
+
'fontSizeUnits',
|
|
593
|
+
Array.isArray(options.fontSizeUnits) && options.fontSizeUnits.length > 0
|
|
594
|
+
? options.fontSizeUnits.map((v) => v.toLowerCase())
|
|
595
|
+
: DEFAULTS.SIZE_UNITS,
|
|
596
|
+
);
|
|
597
|
+
o.set(
|
|
598
|
+
'allowedClassName',
|
|
599
|
+
new RegExp(
|
|
600
|
+
`${options.allowedClassName && typeof options.allowedClassName === 'string' ? options.allowedClassName + '|' : ''}${DEFAULTS.CLASS_NAME}`,
|
|
601
|
+
),
|
|
602
|
+
);
|
|
469
603
|
o.set('closeModalOutsideClick', !!options.closeModalOutsideClick);
|
|
470
604
|
|
|
471
605
|
// format
|
|
@@ -474,11 +608,16 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
474
608
|
|
|
475
609
|
// auto convert on paste
|
|
476
610
|
o.set('autoLinkify', options.autoLinkify ?? !!plugins.link);
|
|
477
|
-
o.set(
|
|
611
|
+
o.set(
|
|
612
|
+
'autoStyleify',
|
|
613
|
+
Array.isArray(options.autoStyleify) ? options.autoStyleify : ['bold', 'underline', 'italic', 'strike'],
|
|
614
|
+
);
|
|
478
615
|
|
|
479
616
|
let retainStyleMode = options.retainStyleMode || 'repeat';
|
|
480
617
|
if (typeof retainStyleMode === 'string' && !DEFAULTS.RETAIN_STYLE_MODE.includes(retainStyleMode)) {
|
|
481
|
-
console.error(
|
|
618
|
+
console.error(
|
|
619
|
+
`Invalid retainStyleMode: ${retainStyleMode}. Valid options are ${DEFAULTS.RETAIN_STYLE_MODE.join(', ')}. Using default 'repeat'.`,
|
|
620
|
+
);
|
|
482
621
|
retainStyleMode = 'repeat';
|
|
483
622
|
}
|
|
484
623
|
o.set('retainStyleMode', retainStyleMode);
|
|
@@ -493,7 +632,11 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
493
632
|
o.set('events', options.events || {});
|
|
494
633
|
|
|
495
634
|
// text style tags
|
|
496
|
-
o.set(
|
|
635
|
+
o.set(
|
|
636
|
+
'textStyleTags',
|
|
637
|
+
(typeof options.__textStyleTags === 'string' ? options.__textStyleTags : DEFAULTS.TEXT_STYLE_TAGS) +
|
|
638
|
+
(options.textStyleTags ? '|' + options.textStyleTags : ''),
|
|
639
|
+
);
|
|
497
640
|
const textTags = _mergeObject(
|
|
498
641
|
{
|
|
499
642
|
bold: 'strong',
|
|
@@ -509,12 +652,15 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
509
652
|
o.set('_textStyleTags', Object.values(textTags).concat(['span', 'li']));
|
|
510
653
|
o.set(
|
|
511
654
|
'tagStyles',
|
|
512
|
-
[{ ...DEFAULTS.TAG_STYLES, ...(options.__tagStyles || {}) }, options.tagStyles || {}].reduce(
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
655
|
+
[{ ...DEFAULTS.TAG_STYLES, ...(options.__tagStyles || {}) }, options.tagStyles || {}].reduce(
|
|
656
|
+
(_default, _new) => {
|
|
657
|
+
for (const key in _new) {
|
|
658
|
+
_default[key] = _new[key];
|
|
659
|
+
}
|
|
660
|
+
return _default;
|
|
661
|
+
},
|
|
662
|
+
{},
|
|
663
|
+
),
|
|
518
664
|
);
|
|
519
665
|
o.set('_defaultStyleTagMap', {
|
|
520
666
|
strong: textTags.bold,
|
|
@@ -560,36 +706,79 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
560
706
|
o.set('reverseCommands', ['indent-outdent'].concat(options.reverseButtons || []));
|
|
561
707
|
o.set('_reverseCommandArray', ('-' + o.get('reverseCommands').join('-')).split('-'));
|
|
562
708
|
if (numbers.isEven(o.get('_reverseCommandArray').length)) {
|
|
563
|
-
console.warn(
|
|
709
|
+
console.warn(
|
|
710
|
+
'[SUNEDITOR.create.warning] The "reverseCommands" option is invalid, Shortcuts key may not work properly.',
|
|
711
|
+
);
|
|
564
712
|
}
|
|
565
713
|
|
|
566
714
|
// etc
|
|
567
|
-
o.set(
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
o.set(
|
|
715
|
+
o.set(
|
|
716
|
+
'historyStackDelayTime',
|
|
717
|
+
typeof options.historyStackDelayTime === 'number' ? options.historyStackDelayTime : 400,
|
|
718
|
+
);
|
|
719
|
+
o.set(
|
|
720
|
+
'historyStackSize',
|
|
721
|
+
typeof options.historyStackSize === 'number' && options.historyStackSize > 0 ? options.historyStackSize : 100,
|
|
722
|
+
);
|
|
723
|
+
o.set(
|
|
724
|
+
'_editableClass',
|
|
725
|
+
'sun-editor-editable' +
|
|
726
|
+
o.get('_themeClass') +
|
|
727
|
+
(o.get('_rtl') ? ' se-rtl' : '') +
|
|
728
|
+
(o.get('type') === 'document' ? ' se-type-document-editable-a4' : ''),
|
|
729
|
+
);
|
|
730
|
+
o.set(
|
|
731
|
+
'lineAttrReset',
|
|
732
|
+
['id'].concat(
|
|
733
|
+
options.lineAttrReset && typeof options.lineAttrReset === 'string'
|
|
734
|
+
? options.lineAttrReset.toLowerCase().split('|')
|
|
735
|
+
: [],
|
|
736
|
+
),
|
|
737
|
+
);
|
|
738
|
+
o.set(
|
|
739
|
+
'printClass',
|
|
740
|
+
typeof options.printClass === 'string' ? options.printClass + ' ' + o.get('_editableClass') : null,
|
|
741
|
+
);
|
|
572
742
|
|
|
573
743
|
/** whitelist, blacklist */
|
|
574
744
|
// default line
|
|
575
|
-
o.set(
|
|
745
|
+
o.set(
|
|
746
|
+
'defaultLine',
|
|
747
|
+
typeof options.defaultLine === 'string' && options.defaultLine.length > 0 ? options.defaultLine : 'p',
|
|
748
|
+
);
|
|
576
749
|
o.set('defaultLineBreakFormat', options.defaultLineBreakFormat || 'line');
|
|
577
750
|
o.set('scopeSelectionTags', options.scopeSelectionTags || DEFAULTS.SCOPE_SELECTION_TAGS);
|
|
578
751
|
// element
|
|
579
752
|
const elw = (typeof options.elementWhitelist === 'string' ? options.elementWhitelist : '').toLowerCase();
|
|
580
753
|
const mjxEls = o.get('externalLibs').mathjax ? DEFAULTS.CLASS_MJX + '|' : '';
|
|
581
754
|
o.set('elementWhitelist', elw + (elw ? '|' : '') + mjxEls + o.get('_allowedExtraTag'));
|
|
582
|
-
const elb = _createBlacklist(
|
|
755
|
+
const elb = _createBlacklist(
|
|
756
|
+
(typeof options.elementBlacklist === 'string' ? options.elementBlacklist : '').toLowerCase(),
|
|
757
|
+
o.get('defaultLine'),
|
|
758
|
+
);
|
|
583
759
|
o.set('elementBlacklist', elb + (elb ? '|' : '') + o.get('_disallowedExtraTag'));
|
|
584
760
|
// attribute
|
|
585
|
-
o.set(
|
|
586
|
-
|
|
761
|
+
o.set(
|
|
762
|
+
'attributeWhitelist',
|
|
763
|
+
!options.attributeWhitelist || typeof options.attributeWhitelist !== 'object'
|
|
764
|
+
? null
|
|
765
|
+
: options.attributeWhitelist,
|
|
766
|
+
);
|
|
767
|
+
o.set(
|
|
768
|
+
'attributeBlacklist',
|
|
769
|
+
!options.attributeBlacklist || typeof options.attributeBlacklist !== 'object'
|
|
770
|
+
? null
|
|
771
|
+
: options.attributeBlacklist,
|
|
772
|
+
);
|
|
587
773
|
// format tag
|
|
588
774
|
o.set(
|
|
589
775
|
'formatClosureBrLine',
|
|
590
776
|
_createFormatInfo(
|
|
591
777
|
options.formatClosureBrLine,
|
|
592
|
-
(options.__defaultFormatClosureBrLine =
|
|
778
|
+
(options.__defaultFormatClosureBrLine =
|
|
779
|
+
typeof options.__defaultFormatClosureBrLine === 'string'
|
|
780
|
+
? options.__defaultFormatClosureBrLine
|
|
781
|
+
: DEFAULTS.FORMAT_CLOSURE_BR_LINE).toLowerCase(),
|
|
593
782
|
o.get('elementBlacklist'),
|
|
594
783
|
),
|
|
595
784
|
);
|
|
@@ -597,7 +786,10 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
597
786
|
'formatBrLine',
|
|
598
787
|
_createFormatInfo(
|
|
599
788
|
(options.formatBrLine || '') + '|' + o.get('formatClosureBrLine').str,
|
|
600
|
-
(options.__defaultFormatBrLine =
|
|
789
|
+
(options.__defaultFormatBrLine =
|
|
790
|
+
typeof options.__defaultFormatBrLine === 'string'
|
|
791
|
+
? options.__defaultFormatBrLine
|
|
792
|
+
: DEFAULTS.FORMAT_BR_LINE).toLowerCase(),
|
|
601
793
|
o.get('elementBlacklist'),
|
|
602
794
|
),
|
|
603
795
|
);
|
|
@@ -605,21 +797,29 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
605
797
|
'formatLine',
|
|
606
798
|
_createFormatInfo(
|
|
607
799
|
DEFAULTS.REQUIRED_FORMAT_LINE + '|' + (options.formatLine || '') + '|' + o.get('formatBrLine').str,
|
|
608
|
-
(options.__defaultFormatLine =
|
|
800
|
+
(options.__defaultFormatLine =
|
|
801
|
+
typeof options.__defaultFormatLine === 'string'
|
|
802
|
+
? options.__defaultFormatLine
|
|
803
|
+
: DEFAULTS.FORMAT_LINE).toLowerCase(),
|
|
609
804
|
o.get('elementBlacklist'),
|
|
610
805
|
),
|
|
611
806
|
);
|
|
612
807
|
|
|
613
808
|
// Error - default line
|
|
614
809
|
if (!o.get('formatLine').reg.test(o.get('defaultLine'))) {
|
|
615
|
-
throw Error(
|
|
810
|
+
throw Error(
|
|
811
|
+
`[SUNEDITOR.create.fail] The "defaultLine(${o.get('defaultLine')})" option must be included in the "formatLine(${o.get('formatLine').str})" option.`,
|
|
812
|
+
);
|
|
616
813
|
}
|
|
617
814
|
|
|
618
815
|
o.set(
|
|
619
816
|
'formatClosureBlock',
|
|
620
817
|
_createFormatInfo(
|
|
621
818
|
options.formatClosureBlock,
|
|
622
|
-
(options.__defaultFormatClosureBlock =
|
|
819
|
+
(options.__defaultFormatClosureBlock =
|
|
820
|
+
typeof options.__defaultFormatClosureBlock === 'string'
|
|
821
|
+
? options.__defaultFormatClosureBlock
|
|
822
|
+
: DEFAULTS.FORMAT_CLOSURE_BLOCK).toLowerCase(),
|
|
623
823
|
o.get('elementBlacklist'),
|
|
624
824
|
),
|
|
625
825
|
);
|
|
@@ -627,22 +827,64 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
627
827
|
'formatBlock',
|
|
628
828
|
_createFormatInfo(
|
|
629
829
|
(options.formatBlock || '') + '|' + o.get('formatClosureBlock').str,
|
|
630
|
-
(options.__defaultFormatBlock =
|
|
830
|
+
(options.__defaultFormatBlock =
|
|
831
|
+
typeof options.__defaultFormatBlock === 'string'
|
|
832
|
+
? options.__defaultFormatBlock
|
|
833
|
+
: DEFAULTS.FORMAT_BLOCK).toLowerCase(),
|
|
631
834
|
o.get('elementBlacklist'),
|
|
632
835
|
),
|
|
633
836
|
);
|
|
634
837
|
|
|
635
|
-
o.set(
|
|
838
|
+
o.set(
|
|
839
|
+
'allowedEmptyTags',
|
|
840
|
+
DEFAULTS.ALLOWED_EMPTY_NODE_LIST + (options.allowedEmptyTags ? ', ' + options.allowedEmptyTags : ''),
|
|
841
|
+
);
|
|
636
842
|
|
|
637
843
|
/** __defaults */
|
|
638
|
-
o.set(
|
|
639
|
-
|
|
844
|
+
o.set(
|
|
845
|
+
'__defaultElementWhitelist',
|
|
846
|
+
DEFAULTS.REQUIRED_ELEMENT_WHITELIST +
|
|
847
|
+
'|' +
|
|
848
|
+
(typeof options.__defaultElementWhitelist === 'string'
|
|
849
|
+
? options.__defaultElementWhitelist
|
|
850
|
+
: DEFAULTS.ELEMENT_WHITELIST
|
|
851
|
+
).toLowerCase(),
|
|
852
|
+
);
|
|
853
|
+
o.set(
|
|
854
|
+
'__defaultAttributeWhitelist',
|
|
855
|
+
(typeof options.__defaultAttributeWhitelist === 'string'
|
|
856
|
+
? options.__defaultAttributeWhitelist
|
|
857
|
+
: DEFAULTS.ATTRIBUTE_WHITELIST
|
|
858
|
+
).toLowerCase(),
|
|
859
|
+
);
|
|
640
860
|
// --- create element whitelist (__defaultElementWhiteList + elementWhitelist + format[line, BrLine, Block, Closureblock, ClosureBrLine] - elementBlacklist)
|
|
641
861
|
o.set('_editorElementWhitelist', o.get('elementWhitelist') === '*' ? '*' : _createWhitelist(o));
|
|
642
862
|
|
|
643
863
|
/** Toolbar */
|
|
644
|
-
o.set(
|
|
645
|
-
|
|
864
|
+
o.set(
|
|
865
|
+
'toolbar_width',
|
|
866
|
+
options.toolbar_width
|
|
867
|
+
? numbers.is(options.toolbar_width)
|
|
868
|
+
? options.toolbar_width + 'px'
|
|
869
|
+
: options.toolbar_width
|
|
870
|
+
: 'auto',
|
|
871
|
+
);
|
|
872
|
+
o.set(
|
|
873
|
+
'toolbar_innerWidth',
|
|
874
|
+
options.toolbar_innerWidth
|
|
875
|
+
? numbers.is(options.toolbar_innerWidth)
|
|
876
|
+
? options.toolbar_innerWidth + 'px'
|
|
877
|
+
: options.toolbar_innerWidth
|
|
878
|
+
: '',
|
|
879
|
+
);
|
|
880
|
+
o.set(
|
|
881
|
+
'toolbar_container',
|
|
882
|
+
options.toolbar_container && !/inline/i.test(o.get('mode'))
|
|
883
|
+
? typeof options.toolbar_container === 'string'
|
|
884
|
+
? _d.querySelector(options.toolbar_container)
|
|
885
|
+
: options.toolbar_container
|
|
886
|
+
: null,
|
|
887
|
+
);
|
|
646
888
|
|
|
647
889
|
const _stickyOpt = options.toolbar_sticky;
|
|
648
890
|
const _isBalloon = /balloon/i.test(o.get('mode'));
|
|
@@ -664,10 +906,15 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
664
906
|
const subbar = options.subToolbar;
|
|
665
907
|
if (subbar?.buttonList?.length > 0) {
|
|
666
908
|
if (/balloon/.test(o.get('mode'))) {
|
|
667
|
-
console.warn(
|
|
909
|
+
console.warn(
|
|
910
|
+
'[SUNEDITOR.create.subToolbar.fail] When the "mode" option is "balloon-*", the "subToolbar" option is omitted.',
|
|
911
|
+
);
|
|
668
912
|
} else {
|
|
669
913
|
o.set('_subMode', subbar.mode || 'balloon');
|
|
670
|
-
o.set(
|
|
914
|
+
o.set(
|
|
915
|
+
'toolbar_sub_width',
|
|
916
|
+
subbar.width ? (numbers.is(subbar.width) ? subbar.width + 'px' : subbar.width) : 'auto',
|
|
917
|
+
);
|
|
671
918
|
subButtons = o.get('_rtl') ? subbar.buttonList.reverse() : subbar.buttonList;
|
|
672
919
|
o.set('buttons_sub', new Set(subButtons.toString().split(',')));
|
|
673
920
|
}
|
|
@@ -676,7 +923,10 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
676
923
|
/** root options */
|
|
677
924
|
const frameMap = new Map();
|
|
678
925
|
for (let i = 0, len = editorTargets.length; i < len; i++) {
|
|
679
|
-
frameMap.set(
|
|
926
|
+
frameMap.set(
|
|
927
|
+
editorTargets[i].key,
|
|
928
|
+
InitFrameOptions(editorTargets[i].options || /** @type {SunEditor.InitFrameOptions} */ ({}), options),
|
|
929
|
+
);
|
|
680
930
|
}
|
|
681
931
|
|
|
682
932
|
/** Key actions */
|
|
@@ -718,12 +968,24 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
718
968
|
o.set('shortcuts', shortcuts);
|
|
719
969
|
|
|
720
970
|
/** View */
|
|
721
|
-
o.set(
|
|
971
|
+
o.set(
|
|
972
|
+
'fullScreenOffset',
|
|
973
|
+
options.fullScreenOffset === undefined
|
|
974
|
+
? 0
|
|
975
|
+
: numbers.is(options.fullScreenOffset)
|
|
976
|
+
? numbers.get(options.fullScreenOffset, 0)
|
|
977
|
+
: 0,
|
|
978
|
+
);
|
|
722
979
|
o.set('previewTemplate', typeof options.previewTemplate === 'string' ? options.previewTemplate : null);
|
|
723
980
|
o.set('printTemplate', typeof options.printTemplate === 'string' ? options.printTemplate : null);
|
|
724
981
|
|
|
725
982
|
/** --- Media select */
|
|
726
|
-
o.set(
|
|
983
|
+
o.set(
|
|
984
|
+
'componentInsertBehavior',
|
|
985
|
+
['auto', 'select', 'line', 'none'].includes(options.componentInsertBehavior)
|
|
986
|
+
? options.componentInsertBehavior
|
|
987
|
+
: 'auto',
|
|
988
|
+
);
|
|
727
989
|
|
|
728
990
|
/** --- Url input protocol */
|
|
729
991
|
o.set('defaultUrlProtocol', typeof options.defaultUrlProtocol === 'string' ? options.defaultUrlProtocol : null);
|
|
@@ -736,13 +998,18 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
736
998
|
if (cm.src) {
|
|
737
999
|
o.set('codeMirrorEditor', true);
|
|
738
1000
|
} else {
|
|
739
|
-
console.warn(
|
|
1001
|
+
console.warn(
|
|
1002
|
+
'[SUNEDITOR.options.externalLibs.codeMirror.fail] The codeMirror option is set incorrectly. See: https://github.com/ARA-developer/suneditor/blob/develop/guide/external-libraries.md',
|
|
1003
|
+
);
|
|
740
1004
|
o.set('codeMirror', null);
|
|
741
1005
|
}
|
|
742
1006
|
}
|
|
743
1007
|
|
|
744
1008
|
/** Private options */
|
|
745
|
-
o.set(
|
|
1009
|
+
o.set(
|
|
1010
|
+
'__listCommonStyle',
|
|
1011
|
+
options.__listCommonStyle || ['fontSize', 'color', 'fontFamily', 'fontWeight', 'fontStyle'],
|
|
1012
|
+
);
|
|
746
1013
|
|
|
747
1014
|
/** --- Icons ------------------------------------------------------------------------------------------ */
|
|
748
1015
|
const icons =
|
|
@@ -768,7 +1035,8 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
768
1035
|
for (let i = 0, len = _ls.length; i < len; i++) {
|
|
769
1036
|
allUsedStyles.add(_ls[i]);
|
|
770
1037
|
}
|
|
771
|
-
const _aus =
|
|
1038
|
+
const _aus =
|
|
1039
|
+
(typeof options.allUsedStyles === 'string' ? options.allUsedStyles.split('|') : options.allUsedStyles) || [];
|
|
772
1040
|
for (let i = 0, len = _aus.length; i < len; i++) {
|
|
773
1041
|
allUsedStyles.add(_aus[i]);
|
|
774
1042
|
}
|
|
@@ -782,7 +1050,10 @@ export function InitOptions(options, editorTargets, plugins) {
|
|
|
782
1050
|
v: (options.value = typeof options.value === 'string' ? options.value : null),
|
|
783
1051
|
buttons: o.get('_rtl') ? buttonList.reverse() : buttonList,
|
|
784
1052
|
subButtons: subButtons,
|
|
785
|
-
statusbarContainer:
|
|
1053
|
+
statusbarContainer:
|
|
1054
|
+
typeof options.statusbar_container === 'string'
|
|
1055
|
+
? _d.querySelector(options.statusbar_container)
|
|
1056
|
+
: options.statusbar_container,
|
|
786
1057
|
frameMap: frameMap,
|
|
787
1058
|
};
|
|
788
1059
|
}
|
|
@@ -804,20 +1075,28 @@ export function CreateStatusbar(targetOptions, statusbar) {
|
|
|
804
1075
|
statusbar ||= dom.utils.createElement('DIV', { class: 'se-status-bar sun-editor-common' });
|
|
805
1076
|
|
|
806
1077
|
/** navigation */
|
|
807
|
-
navigation =
|
|
1078
|
+
navigation =
|
|
1079
|
+
statusbar.querySelector('.se-navigation') ||
|
|
1080
|
+
dom.utils.createElement('DIV', { class: 'se-navigation sun-editor-common' });
|
|
808
1081
|
statusbar.appendChild(navigation);
|
|
809
1082
|
|
|
810
1083
|
/** word counter (left) */
|
|
811
1084
|
if (targetOptions.get('wordCounter')) {
|
|
812
|
-
wordWrapper =
|
|
1085
|
+
wordWrapper =
|
|
1086
|
+
statusbar.querySelector('.se-word-counter-wrapper') ||
|
|
1087
|
+
dom.utils.createElement('DIV', { class: 'se-word-counter-wrapper' });
|
|
813
1088
|
|
|
814
1089
|
if (targetOptions.get('wordCounter_label')) {
|
|
815
|
-
const wordLabel =
|
|
1090
|
+
const wordLabel =
|
|
1091
|
+
wordWrapper.querySelector('.se-word-label') ||
|
|
1092
|
+
dom.utils.createElement('SPAN', { class: 'se-word-label' });
|
|
816
1093
|
wordLabel.textContent = targetOptions.get('wordCounter_label');
|
|
817
1094
|
wordWrapper.appendChild(wordLabel);
|
|
818
1095
|
}
|
|
819
1096
|
|
|
820
|
-
wordCounter =
|
|
1097
|
+
wordCounter =
|
|
1098
|
+
wordWrapper.querySelector('.se-word-counter') ||
|
|
1099
|
+
dom.utils.createElement('SPAN', { class: 'se-word-counter' });
|
|
821
1100
|
wordCounter.textContent = '0';
|
|
822
1101
|
wordWrapper.appendChild(wordCounter);
|
|
823
1102
|
|
|
@@ -826,24 +1105,32 @@ export function CreateStatusbar(targetOptions, statusbar) {
|
|
|
826
1105
|
|
|
827
1106
|
/** char counter (right) */
|
|
828
1107
|
if (targetOptions.get('charCounter')) {
|
|
829
|
-
charWrapper =
|
|
1108
|
+
charWrapper =
|
|
1109
|
+
statusbar.querySelector('.se-char-counter-wrapper') ||
|
|
1110
|
+
dom.utils.createElement('DIV', { class: 'se-char-counter-wrapper' });
|
|
830
1111
|
|
|
831
1112
|
if (targetOptions.get('wordCounter') && charWrapper.className.indexOf('se-with-word-counter') === -1) {
|
|
832
1113
|
charWrapper.className += ' se-with-word-counter';
|
|
833
1114
|
}
|
|
834
1115
|
|
|
835
1116
|
if (targetOptions.get('charCounter_label')) {
|
|
836
|
-
const charLabel =
|
|
1117
|
+
const charLabel =
|
|
1118
|
+
charWrapper.querySelector('.se-char-label') ||
|
|
1119
|
+
dom.utils.createElement('SPAN', { class: 'se-char-label' });
|
|
837
1120
|
charLabel.textContent = targetOptions.get('charCounter_label');
|
|
838
1121
|
charWrapper.appendChild(charLabel);
|
|
839
1122
|
}
|
|
840
1123
|
|
|
841
|
-
charCounter =
|
|
1124
|
+
charCounter =
|
|
1125
|
+
charWrapper.querySelector('.se-char-counter') ||
|
|
1126
|
+
dom.utils.createElement('SPAN', { class: 'se-char-counter' });
|
|
842
1127
|
charCounter.textContent = '0';
|
|
843
1128
|
charWrapper.appendChild(charCounter);
|
|
844
1129
|
|
|
845
1130
|
if (targetOptions.get('charCounter_max') > 0) {
|
|
846
|
-
const char_max =
|
|
1131
|
+
const char_max =
|
|
1132
|
+
charWrapper.querySelector('.se-char-max') ||
|
|
1133
|
+
dom.utils.createElement('SPAN', { class: 'se-char-max' });
|
|
847
1134
|
char_max.textContent = ' / ' + targetOptions.get('charCounter_max');
|
|
848
1135
|
charWrapper.appendChild(char_max);
|
|
849
1136
|
}
|
|
@@ -877,10 +1164,13 @@ function InitFrameOptions(o, origin) {
|
|
|
877
1164
|
// members
|
|
878
1165
|
const value = o.value === undefined ? origin.value : o.value;
|
|
879
1166
|
const placeholder = o.placeholder === undefined ? origin.placeholder : o.placeholder;
|
|
880
|
-
const
|
|
1167
|
+
const placeholder_line = o.placeholder_line === undefined ? origin.placeholder_line : o.placeholder_line;
|
|
1168
|
+
const editableFrameAttributes =
|
|
1169
|
+
o.editableFrameAttributes === undefined ? origin.editableFrameAttributes : o.editableFrameAttributes;
|
|
881
1170
|
const width = o.width === undefined ? origin.width : o.width;
|
|
882
1171
|
const minWidth = o.minWidth === undefined ? origin.minWidth : o.minWidth;
|
|
883
1172
|
const maxWidth = o.maxWidth === undefined ? origin.maxWidth : o.maxWidth;
|
|
1173
|
+
const innerWidth = o.innerWidth === undefined ? origin.innerWidth : o.innerWidth;
|
|
884
1174
|
const height = o.height === undefined ? origin.height : o.height;
|
|
885
1175
|
const minHeight = o.minHeight === undefined ? origin.minHeight : o.minHeight;
|
|
886
1176
|
const maxHeight = o.maxHeight === undefined ? origin.maxHeight : o.maxHeight;
|
|
@@ -890,23 +1180,36 @@ function InitFrameOptions(o, origin) {
|
|
|
890
1180
|
const iframe_attributes = o.iframe_attributes === undefined ? origin.iframe_attributes : o.iframe_attributes;
|
|
891
1181
|
const iframe_cssFileName = o.iframe_cssFileName === undefined ? origin.iframe_cssFileName : o.iframe_cssFileName;
|
|
892
1182
|
const statusbar = barContainer || o.statusbar === undefined ? origin.statusbar : o.statusbar;
|
|
893
|
-
const statusbar_showPathLabel =
|
|
894
|
-
|
|
1183
|
+
const statusbar_showPathLabel =
|
|
1184
|
+
barContainer || o.statusbar_showPathLabel === undefined
|
|
1185
|
+
? origin.statusbar_showPathLabel
|
|
1186
|
+
: o.statusbar_showPathLabel;
|
|
1187
|
+
const statusbar_resizeEnable = barContainer
|
|
1188
|
+
? false
|
|
1189
|
+
: o.statusbar_resizeEnable === undefined
|
|
1190
|
+
? origin.statusbar_resizeEnable
|
|
1191
|
+
: o.statusbar_resizeEnable;
|
|
895
1192
|
const charCounter = barContainer || o.charCounter === undefined ? origin.charCounter : o.charCounter;
|
|
896
|
-
const charCounter_max =
|
|
897
|
-
|
|
898
|
-
const
|
|
1193
|
+
const charCounter_max =
|
|
1194
|
+
barContainer || o.charCounter_max === undefined ? origin.charCounter_max : o.charCounter_max;
|
|
1195
|
+
const charCounter_label =
|
|
1196
|
+
barContainer || o.charCounter_label === undefined ? origin.charCounter_label : o.charCounter_label;
|
|
1197
|
+
const charCounter_type =
|
|
1198
|
+
barContainer || o.charCounter_type === undefined ? origin.charCounter_type : o.charCounter_type;
|
|
899
1199
|
const wordCounter = barContainer || o.wordCounter === undefined ? origin.wordCounter : o.wordCounter;
|
|
900
|
-
const wordCounter_label =
|
|
1200
|
+
const wordCounter_label =
|
|
1201
|
+
barContainer || o.wordCounter_label === undefined ? origin.wordCounter_label : o.wordCounter_label;
|
|
901
1202
|
|
|
902
1203
|
// value
|
|
903
1204
|
fo.set('value', value);
|
|
904
1205
|
fo.set('placeholder', placeholder);
|
|
1206
|
+
fo.set('placeholder_line', placeholder_line);
|
|
905
1207
|
fo.set('editableFrameAttributes', { spellcheck: 'false', ...editableFrameAttributes });
|
|
906
1208
|
// styles
|
|
907
1209
|
fo.set('width', width ? String(numbers.is(width) ? width + 'px' : width) : '100%');
|
|
908
1210
|
fo.set('minWidth', minWidth ? String(numbers.is(minWidth) ? minWidth + 'px' : minWidth) : '');
|
|
909
1211
|
fo.set('maxWidth', maxWidth ? String(numbers.is(maxWidth) ? maxWidth + 'px' : maxWidth) : '');
|
|
1212
|
+
fo.set('innerWidth', innerWidth ? String(numbers.is(innerWidth) ? innerWidth + 'px' : innerWidth) : '');
|
|
910
1213
|
fo.set('height', height ? String(numbers.is(height) ? height + 'px' : height) : 'auto');
|
|
911
1214
|
fo.set('minHeight', minHeight ? String(numbers.is(minHeight) ? minHeight + 'px' : minHeight) : '');
|
|
912
1215
|
fo.set('maxHeight', maxHeight ? String(numbers.is(maxHeight) ? maxHeight + 'px' : maxHeight) : '');
|
|
@@ -916,12 +1219,23 @@ function InitFrameOptions(o, origin) {
|
|
|
916
1219
|
fo.set('iframe', !!(iframe_fullPage || iframe));
|
|
917
1220
|
fo.set('iframe_fullPage', !!iframe_fullPage);
|
|
918
1221
|
fo.set('iframe_attributes', iframe_attributes || {});
|
|
919
|
-
fo.set(
|
|
1222
|
+
fo.set(
|
|
1223
|
+
'iframe_cssFileName',
|
|
1224
|
+
iframe
|
|
1225
|
+
? (typeof iframe_cssFileName === 'string' ? [iframe_cssFileName] : iframe_cssFileName) || ['suneditor']
|
|
1226
|
+
: null,
|
|
1227
|
+
);
|
|
920
1228
|
// status bar
|
|
921
1229
|
const hasStatusbar = statusbar === undefined ? true : !!statusbar;
|
|
922
1230
|
fo.set('statusbar', hasStatusbar);
|
|
923
|
-
fo.set(
|
|
924
|
-
|
|
1231
|
+
fo.set(
|
|
1232
|
+
'statusbar_showPathLabel',
|
|
1233
|
+
!hasStatusbar ? false : typeof statusbar_showPathLabel === 'boolean' ? statusbar_showPathLabel : true,
|
|
1234
|
+
);
|
|
1235
|
+
fo.set(
|
|
1236
|
+
'statusbar_resizeEnable',
|
|
1237
|
+
!hasStatusbar ? false : statusbar_resizeEnable === undefined ? true : !!statusbar_resizeEnable,
|
|
1238
|
+
);
|
|
925
1239
|
// status bar - character count
|
|
926
1240
|
fo.set('charCounter', charCounter_max > 0 ? true : typeof charCounter === 'boolean' ? charCounter : false);
|
|
927
1241
|
fo.set('charCounter_max', numbers.is(charCounter_max) && charCounter_max > -1 ? charCounter_max * 1 : null);
|
|
@@ -951,7 +1265,9 @@ function _initTargetElements(key, options, topDiv, targetOptions, formFieldPrefi
|
|
|
951
1265
|
/** editor */
|
|
952
1266
|
// wysiwyg div or iframe
|
|
953
1267
|
const wysiwygDiv = dom.utils.createElement(!targetOptions.get('iframe') ? 'DIV' : 'IFRAME', {
|
|
954
|
-
class:
|
|
1268
|
+
class:
|
|
1269
|
+
'se-wrapper-inner se-wrapper-wysiwyg' +
|
|
1270
|
+
(options.get('type') === 'document' ? ' se-type-document-iframe-a4' : ''),
|
|
955
1271
|
'data-root-key': key,
|
|
956
1272
|
});
|
|
957
1273
|
|
|
@@ -997,10 +1313,20 @@ function _initTargetElements(key, options, topDiv, targetOptions, formFieldPrefi
|
|
|
997
1313
|
}
|
|
998
1314
|
|
|
999
1315
|
// textarea for code view
|
|
1000
|
-
const textarea = dom.utils.createElement('TEXTAREA', {
|
|
1316
|
+
const textarea = dom.utils.createElement('TEXTAREA', {
|
|
1317
|
+
id: formFieldPrefix + '-code-viewer-' + (key || 'default'),
|
|
1318
|
+
class: 'se-wrapper-inner se-code-viewer',
|
|
1319
|
+
style: editorStyles.frame,
|
|
1320
|
+
autocomplete: 'off',
|
|
1321
|
+
});
|
|
1001
1322
|
|
|
1002
1323
|
// textarea for markdown view
|
|
1003
|
-
const markdownTextarea = dom.utils.createElement('TEXTAREA', {
|
|
1324
|
+
const markdownTextarea = dom.utils.createElement('TEXTAREA', {
|
|
1325
|
+
id: formFieldPrefix + '-markdown-viewer-' + (key || 'default'),
|
|
1326
|
+
class: 'se-wrapper-inner se-markdown-viewer',
|
|
1327
|
+
style: editorStyles.frame,
|
|
1328
|
+
autocomplete: 'off',
|
|
1329
|
+
});
|
|
1004
1330
|
|
|
1005
1331
|
const placeholder = dom.utils.createElement('SPAN', { class: 'se-placeholder' });
|
|
1006
1332
|
if (targetOptions.get('placeholder')) {
|
|
@@ -1080,7 +1406,9 @@ function _createBlacklist(blacklist, defaultLine) {
|
|
|
1080
1406
|
if (v !== defaultLine) {
|
|
1081
1407
|
return true;
|
|
1082
1408
|
} else {
|
|
1083
|
-
console.warn(
|
|
1409
|
+
console.warn(
|
|
1410
|
+
`[SUNEDITOR.constructor.createBlacklist.warn] defaultLine("<${defaultLine}>") cannot be included in the blacklist and will be removed.`,
|
|
1411
|
+
);
|
|
1084
1412
|
return false;
|
|
1085
1413
|
}
|
|
1086
1414
|
})
|
|
@@ -1114,7 +1442,19 @@ function _createFormatInfo(value, defaultValue, blacklist) {
|
|
|
1114
1442
|
*/
|
|
1115
1443
|
function _createWhitelist(o) {
|
|
1116
1444
|
const blacklist = o.get('elementBlacklist').split('|');
|
|
1117
|
-
const whitelist = (
|
|
1445
|
+
const whitelist = (
|
|
1446
|
+
o.get('__defaultElementWhitelist') +
|
|
1447
|
+
'|' +
|
|
1448
|
+
o.get('elementWhitelist') +
|
|
1449
|
+
'|' +
|
|
1450
|
+
o.get('formatLine').str +
|
|
1451
|
+
'|' +
|
|
1452
|
+
o.get('formatBrLine').str +
|
|
1453
|
+
'|' +
|
|
1454
|
+
o.get('formatClosureBlock').str +
|
|
1455
|
+
'|' +
|
|
1456
|
+
o.get('formatClosureBrLine').str
|
|
1457
|
+
)
|
|
1118
1458
|
.replace(/(^\||\|$)/g, '')
|
|
1119
1459
|
.split('|')
|
|
1120
1460
|
.filter((v, i, a) => v && a.indexOf(v) === i && !blacklist.includes(v));
|
|
@@ -1122,6 +1462,59 @@ function _createWhitelist(o) {
|
|
|
1122
1462
|
return whitelist.join('|');
|
|
1123
1463
|
}
|
|
1124
1464
|
|
|
1465
|
+
/**
|
|
1466
|
+
* @description Toolbar variant — sizes the button row to its content and centers it.
|
|
1467
|
+
* - When `value` is a CSS length (e.g. `"500px"`, `"740px"`): the row is capped at that width.
|
|
1468
|
+
* @param {?HTMLElement} el Target element (`.se-btn-tray`)
|
|
1469
|
+
* @param {string} value CSS length, `'auto'` for center-only, or empty for no constraint
|
|
1470
|
+
*/
|
|
1471
|
+
function _applyToolbarInnerWidth(el, value) {
|
|
1472
|
+
if (!el || !value) return;
|
|
1473
|
+
if (value !== 'auto') el.style.maxWidth = value;
|
|
1474
|
+
el.style.width = 'max-content';
|
|
1475
|
+
el.style.marginLeft = 'auto';
|
|
1476
|
+
el.style.marginRight = 'auto';
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
/**
|
|
1480
|
+
* @description Resolves a button key to its toolbar metadata.
|
|
1481
|
+
* Checks plugins first, then falls back to the default button list.
|
|
1482
|
+
* Same resolution logic as `CreateToolBar`.
|
|
1483
|
+
* @param {string} key Button name
|
|
1484
|
+
* @param {?Object<string, *>} plugins Plugin instances
|
|
1485
|
+
* @param {SunEditor.Options} options Options map
|
|
1486
|
+
* @param {Object<string, string>} icons Icons
|
|
1487
|
+
* @param {Object<string, string>} lang Language object
|
|
1488
|
+
* @returns {{className: string, title: string, command: string, type: string, icon: string}|null}
|
|
1489
|
+
*/
|
|
1490
|
+
export function ResolveButton(key, plugins, options, icons, lang) {
|
|
1491
|
+
const plugin = plugins?.[key];
|
|
1492
|
+
if (plugin) {
|
|
1493
|
+
const s = typeof plugin === 'function' ? plugin : plugin.constructor;
|
|
1494
|
+
return {
|
|
1495
|
+
className: plugin.className || s.className || '',
|
|
1496
|
+
title: lang[plugin.title] || plugin.title || lang[s.title] || s.title || key,
|
|
1497
|
+
command: key,
|
|
1498
|
+
type: plugin.type || s.type || '',
|
|
1499
|
+
icon: icons[plugin.icon] || plugin.icon || icons[s.icon] || s.icon || '',
|
|
1500
|
+
};
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
const defaults = _defaultButtons(options.get('_rtl'), icons, lang);
|
|
1504
|
+
const def = defaults[key];
|
|
1505
|
+
if (def) {
|
|
1506
|
+
return {
|
|
1507
|
+
className: def[0],
|
|
1508
|
+
title: def[1],
|
|
1509
|
+
command: def[2],
|
|
1510
|
+
type: def[3],
|
|
1511
|
+
icon: def[4],
|
|
1512
|
+
};
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
return null;
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1125
1518
|
/**
|
|
1126
1519
|
* @description SunEditor's default button list
|
|
1127
1520
|
* @param {boolean} isRTL `rtl`
|
|
@@ -1141,7 +1534,13 @@ function _defaultButtons(isRTL, icons, lang) {
|
|
|
1141
1534
|
fullScreen: ['se-code-view-enabled se-component-enabled', lang.fullScreen, 'fullScreen', '', icons.expansion],
|
|
1142
1535
|
showBlocks: ['', lang.showBlocks, 'showBlocks', '', icons.show_blocks],
|
|
1143
1536
|
codeView: ['se-code-view-enabled se-component-enabled', lang.codeView, 'codeView', '', icons.code_view],
|
|
1144
|
-
markdownView: [
|
|
1537
|
+
markdownView: [
|
|
1538
|
+
'se-code-view-enabled se-component-enabled',
|
|
1539
|
+
lang.markdownView,
|
|
1540
|
+
'markdownView',
|
|
1541
|
+
'',
|
|
1542
|
+
icons.markdown_view,
|
|
1543
|
+
],
|
|
1145
1544
|
undo: ['se-component-enabled', lang.undo, 'undo', '', icons.undo],
|
|
1146
1545
|
redo: ['se-component-enabled', lang.redo, 'redo', '', icons.redo],
|
|
1147
1546
|
preview: ['se-component-enabled', lang.preview, 'preview', '', icons.preview],
|
|
@@ -1249,7 +1648,10 @@ export function UpdateButton(element, plugin, icons, lang) {
|
|
|
1249
1648
|
} else {
|
|
1250
1649
|
element.innerHTML = noneInner
|
|
1251
1650
|
? ''
|
|
1252
|
-
: (plugin.inner || icons[plugin.icon] || plugin.icon || '<span class="se-icon-text">!</span>') +
|
|
1651
|
+
: (plugin.inner || icons[plugin.icon] || plugin.icon || '<span class="se-icon-text">!</span>') +
|
|
1652
|
+
'<span class="se-tooltip-inner"><span class="se-tooltip-text">' +
|
|
1653
|
+
(lang[plugin.title] || plugin.title) +
|
|
1654
|
+
'</span></span>';
|
|
1253
1655
|
}
|
|
1254
1656
|
|
|
1255
1657
|
element.setAttribute('aria-label', plugin.title);
|
|
@@ -1351,7 +1753,14 @@ export function CreateToolBar(buttonList, plugins, options, icons, lang, isUpdat
|
|
|
1351
1753
|
modules = [plugin.className, plugin.title, button, plugin.type, plugin.innerHTML, plugin._disabled];
|
|
1352
1754
|
} else if (typeof plugin === 'object') {
|
|
1353
1755
|
const originFnc = plugin.constructor;
|
|
1354
|
-
modules = [
|
|
1756
|
+
modules = [
|
|
1757
|
+
plugin.className || originFnc.className,
|
|
1758
|
+
plugin.title || originFnc.title,
|
|
1759
|
+
button,
|
|
1760
|
+
plugin.type || originFnc.type,
|
|
1761
|
+
plugin.innerHTML || originFnc.innerHTML,
|
|
1762
|
+
plugin._disabled || originFnc._disabled,
|
|
1763
|
+
];
|
|
1355
1764
|
} else {
|
|
1356
1765
|
// align
|
|
1357
1766
|
if (/^-/.test(button)) {
|
|
@@ -1374,26 +1783,52 @@ export function CreateToolBar(buttonList, plugins, options, icons, lang, isUpdat
|
|
|
1374
1783
|
moreCommand = '__se__more_' + i;
|
|
1375
1784
|
const title = matched[1].trim();
|
|
1376
1785
|
const innerHTML = matched[2].trim();
|
|
1377
|
-
modules = [
|
|
1786
|
+
modules = [
|
|
1787
|
+
'se-btn-more',
|
|
1788
|
+
/^lang\./i.test(title) ? lang[title.replace(/^lang\./i, '')] : title,
|
|
1789
|
+
moreCommand,
|
|
1790
|
+
'MORE',
|
|
1791
|
+
innerHTML,
|
|
1792
|
+
];
|
|
1378
1793
|
} else if (button === '|') {
|
|
1379
1794
|
// separator vertical
|
|
1380
1795
|
modules = ['se-toolbar-separator-vertical', '', '', 'separator', ''];
|
|
1381
1796
|
} else {
|
|
1382
1797
|
// default command
|
|
1383
1798
|
if (button === 'copy' && !env.isClipboardSupported) {
|
|
1384
|
-
console.warn(
|
|
1799
|
+
console.warn(
|
|
1800
|
+
'[SUNEDITOR.constructor.warn] Clipboard is not supported in this browser. : [copy] button is not rendered.',
|
|
1801
|
+
);
|
|
1385
1802
|
}
|
|
1386
1803
|
modules = defaultButtonList[button];
|
|
1387
1804
|
}
|
|
1388
1805
|
|
|
1389
1806
|
if (!modules) {
|
|
1390
|
-
if (!plugin)
|
|
1807
|
+
if (!plugin)
|
|
1808
|
+
throw Error(
|
|
1809
|
+
`[SUNEDITOR.create.toolbar.fail] The button name of a plugin that does not exist. [${button}]`,
|
|
1810
|
+
);
|
|
1391
1811
|
plugin = typeof plugin === 'object' ? plugin.constructor : plugin;
|
|
1392
|
-
modules = [
|
|
1812
|
+
modules = [
|
|
1813
|
+
plugin.className,
|
|
1814
|
+
plugin.title,
|
|
1815
|
+
plugin.key,
|
|
1816
|
+
plugin.type,
|
|
1817
|
+
plugin.innerHTML,
|
|
1818
|
+
plugin._disabled,
|
|
1819
|
+
];
|
|
1393
1820
|
}
|
|
1394
1821
|
}
|
|
1395
1822
|
|
|
1396
|
-
buttonElement = _createButton(
|
|
1823
|
+
buttonElement = _createButton(
|
|
1824
|
+
modules[0],
|
|
1825
|
+
modules[1],
|
|
1826
|
+
modules[2],
|
|
1827
|
+
modules[3],
|
|
1828
|
+
modules[4],
|
|
1829
|
+
modules[5],
|
|
1830
|
+
icons,
|
|
1831
|
+
);
|
|
1397
1832
|
(more ? moreContainer : moduleElement.ul).appendChild(buttonElement.li);
|
|
1398
1833
|
|
|
1399
1834
|
if (plugin) {
|
|
@@ -1414,7 +1849,10 @@ export function CreateToolBar(buttonList, plugins, options, icons, lang, isUpdat
|
|
|
1414
1849
|
moreContainer = dom.utils.createElement('DIV');
|
|
1415
1850
|
moreContainer.className = 'se-more-layer ' + moreCommand;
|
|
1416
1851
|
moreContainer.setAttribute('data-ref', moreCommand);
|
|
1417
|
-
moreContainer.innerHTML =
|
|
1852
|
+
moreContainer.innerHTML =
|
|
1853
|
+
'<div class="se-more-form"><ul class="se-menu-list"' +
|
|
1854
|
+
(align ? ' style="float: ' + align + ';"' : '') +
|
|
1855
|
+
'></ul></div>';
|
|
1418
1856
|
moreLayer.appendChild(moreContainer);
|
|
1419
1857
|
moreContainer = moreContainer.firstElementChild.firstElementChild;
|
|
1420
1858
|
}
|
|
@@ -1452,8 +1890,14 @@ export function CreateToolBar(buttonList, plugins, options, icons, lang, isUpdat
|
|
|
1452
1890
|
if (moreLayer.children.length > 0) buttonTray.appendChild(moreLayer);
|
|
1453
1891
|
if (responsiveButtons.length > 0) responsiveButtons.unshift(buttonList);
|
|
1454
1892
|
|
|
1893
|
+
_applyToolbarInnerWidth(buttonTray, options.get('toolbar_innerWidth'));
|
|
1894
|
+
|
|
1455
1895
|
// rendering toolbar
|
|
1456
|
-
const tool_bar = dom.utils.createElement(
|
|
1896
|
+
const tool_bar = dom.utils.createElement(
|
|
1897
|
+
'DIV',
|
|
1898
|
+
{ class: 'se-toolbar sun-editor-common' + (!options.get('shortcutsHint') ? ' se-shortcut-hide' : '') },
|
|
1899
|
+
buttonTray,
|
|
1900
|
+
);
|
|
1457
1901
|
|
|
1458
1902
|
if (options.get('toolbar_hide')) tool_bar.style.display = 'none';
|
|
1459
1903
|
|