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
|
@@ -195,7 +195,10 @@ class ModalAnchorEditor {
|
|
|
195
195
|
this.titleInput.value = '';
|
|
196
196
|
} else if (this.currentTarget) {
|
|
197
197
|
const href = this.currentTarget.href;
|
|
198
|
-
this.linkValue =
|
|
198
|
+
this.linkValue =
|
|
199
|
+
this.preview.textContent =
|
|
200
|
+
this.urlInput.value =
|
|
201
|
+
this.#selfPathBookmark(href) ? href.substring(href.lastIndexOf('#')) : href;
|
|
199
202
|
this.displayInput.value = this.currentTarget.textContent;
|
|
200
203
|
this.titleInput.value = this.currentTarget.title;
|
|
201
204
|
this.newWindowCheck.checked = /_blank/i.test(this.currentTarget.target) ? true : false;
|
|
@@ -209,6 +212,8 @@ class ModalAnchorEditor {
|
|
|
209
212
|
/**
|
|
210
213
|
* @description Creates an anchor (`<a>`) element with the specified attributes.
|
|
211
214
|
* @param {boolean} notText - If `true`, the anchor will not contain text content.
|
|
215
|
+
* @param {?string} [urlOverride] - Fallback URL used when the modal's `linkValue` is empty
|
|
216
|
+
* - (e.g., when called outside the modal lifecycle such as from `retainFormat`)
|
|
212
217
|
* @returns {HTMLElement|null} - The newly created anchor element, or `null` if the URL is empty.
|
|
213
218
|
* @example
|
|
214
219
|
* // In a link plugin — create anchor with text content:
|
|
@@ -221,11 +226,14 @@ class ModalAnchorEditor {
|
|
|
221
226
|
* if (anchor) {
|
|
222
227
|
* anchor.appendChild(imgElement);
|
|
223
228
|
* }
|
|
229
|
+
*
|
|
230
|
+
* // Preserve an existing parent anchor's href when rebuilding outside the modal:
|
|
231
|
+
* const anchor = this.anchor.create(true, parentAnchor.href);
|
|
224
232
|
*/
|
|
225
|
-
create(notText) {
|
|
226
|
-
|
|
233
|
+
create(notText, urlOverride) {
|
|
234
|
+
const url = this.linkValue || urlOverride || '';
|
|
235
|
+
if (url.length === 0) return null;
|
|
227
236
|
|
|
228
|
-
const url = this.linkValue;
|
|
229
237
|
const displayText = this.displayInput.value.length === 0 ? url : this.displayInput.value;
|
|
230
238
|
|
|
231
239
|
const oA = /** @type {HTMLAnchorElement} */ (this.currentTarget || dom.utils.createElement('A'));
|
|
@@ -291,7 +299,11 @@ class ModalAnchorEditor {
|
|
|
291
299
|
*/
|
|
292
300
|
#selfPathBookmark(path) {
|
|
293
301
|
const href = _w.location.href.replace(/\/$/, '');
|
|
294
|
-
return
|
|
302
|
+
return (
|
|
303
|
+
path.indexOf('#') === 0 ||
|
|
304
|
+
(path.indexOf(href) === 0 &&
|
|
305
|
+
path.indexOf('#') === (!href.includes('#') ? href.length : href.substring(0, href.indexOf('#')).length))
|
|
306
|
+
);
|
|
295
307
|
}
|
|
296
308
|
|
|
297
309
|
/**
|
|
@@ -325,7 +337,11 @@ class ModalAnchorEditor {
|
|
|
325
337
|
* @param {string} urlValue - The current URL input value.
|
|
326
338
|
*/
|
|
327
339
|
#createBookmarkList(urlValue) {
|
|
328
|
-
const headers = dom.query.getListChildren(
|
|
340
|
+
const headers = dom.query.getListChildren(
|
|
341
|
+
this.#$.frameContext.get('wysiwyg'),
|
|
342
|
+
(current) => /h[1-6]/i.test(current.nodeName) || (dom.check.isAnchor(current) && !!current.id),
|
|
343
|
+
null,
|
|
344
|
+
);
|
|
329
345
|
if (headers.length === 0) return;
|
|
330
346
|
|
|
331
347
|
const valueRegExp = new RegExp(`^${urlValue.replace(/^#/, '')}`, 'i');
|
|
@@ -335,7 +351,11 @@ class ModalAnchorEditor {
|
|
|
335
351
|
v = headers[i];
|
|
336
352
|
if (!valueRegExp.test(v.textContent)) continue;
|
|
337
353
|
list.push(v);
|
|
338
|
-
menus.push(
|
|
354
|
+
menus.push(
|
|
355
|
+
dom.check.isAnchor(v)
|
|
356
|
+
? `<div><span class="se-text-prefix-icon">${this.#$.icons.bookmark_anchor}</span>${v.id}</div>`
|
|
357
|
+
: `<div style="${v.style.cssText}">${v.textContent}</div>`,
|
|
358
|
+
);
|
|
339
359
|
}
|
|
340
360
|
|
|
341
361
|
if (list.length === 0) {
|
|
@@ -355,12 +375,24 @@ class ModalAnchorEditor {
|
|
|
355
375
|
const protocol = this.#$.options.get('defaultUrlProtocol');
|
|
356
376
|
const noPrefix = this.noAutoPrefix;
|
|
357
377
|
const reservedProtocol = /^(mailto:|tel:|sms:|https*:\/\/|#)/.test(value) || value.indexOf(protocol) === 0;
|
|
358
|
-
const sameProtocol = !protocol
|
|
378
|
+
const sameProtocol = !protocol
|
|
379
|
+
? false
|
|
380
|
+
: RegExp('^' + unicode.escapeStringRegexp(value.substring(0, protocol.length))).test(protocol);
|
|
359
381
|
|
|
360
382
|
value =
|
|
361
383
|
this.linkValue =
|
|
362
384
|
preview.textContent =
|
|
363
|
-
!value
|
|
385
|
+
!value
|
|
386
|
+
? ''
|
|
387
|
+
: noPrefix
|
|
388
|
+
? value
|
|
389
|
+
: protocol && !reservedProtocol && !sameProtocol
|
|
390
|
+
? protocol + value
|
|
391
|
+
: reservedProtocol
|
|
392
|
+
? value
|
|
393
|
+
: /^www\./.test(value)
|
|
394
|
+
? 'http://' + value
|
|
395
|
+
: this.host + (/^\//.test(value) ? '' : '/') + value;
|
|
364
396
|
|
|
365
397
|
if (this.#selfPathBookmark(value)) {
|
|
366
398
|
this.bookmark.style.display = 'block';
|