suneditor 3.0.0-beta.9 → 3.0.0-rc.2
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/README.md +65 -57
- package/dist/suneditor-contents.min.css +1 -0
- package/dist/suneditor.min.css +1 -1
- package/dist/suneditor.min.js +1 -1
- package/package.json +110 -61
- package/src/assets/design/color.css +36 -17
- package/src/assets/design/size.css +2 -0
- package/src/assets/icons/defaultIcons.js +17 -2
- package/src/assets/suneditor-contents.css +51 -16
- package/src/assets/suneditor.css +116 -43
- package/src/core/config/contextProvider.js +288 -0
- package/src/core/config/eventManager.js +188 -0
- package/src/core/config/instanceCheck.js +59 -0
- package/src/core/config/optionProvider.js +452 -0
- package/src/core/editor.js +166 -1637
- package/src/core/event/actions/index.js +229 -0
- package/src/core/event/effects/common.registry.js +74 -0
- package/src/core/event/effects/keydown.registry.js +573 -0
- package/src/core/event/effects/ruleHelpers.js +148 -0
- package/src/core/event/eventOrchestrator.js +944 -0
- package/src/core/event/executor.js +27 -0
- package/src/core/{base/eventHandlers → event/handlers}/handler_toolbar.js +27 -28
- package/src/core/{base/eventHandlers → event/handlers}/handler_ww_clipboard.js +10 -8
- package/src/core/{base/eventHandlers → event/handlers}/handler_ww_dragDrop.js +22 -23
- package/src/core/event/handlers/handler_ww_input.js +75 -0
- package/src/core/event/handlers/handler_ww_key.js +228 -0
- package/src/core/event/handlers/handler_ww_mouse.js +166 -0
- package/src/core/event/ports.js +211 -0
- package/src/core/event/reducers/keydown.reducer.js +97 -0
- package/src/core/event/rules/keydown.rule.arrow.js +63 -0
- package/src/core/event/rules/keydown.rule.backspace.js +208 -0
- package/src/core/event/rules/keydown.rule.delete.js +132 -0
- package/src/core/event/rules/keydown.rule.enter.js +150 -0
- package/src/core/event/rules/keydown.rule.tab.js +35 -0
- package/src/core/event/support/defaultLineManager.js +136 -0
- package/src/core/event/support/selectionState.js +204 -0
- package/src/core/kernel/coreKernel.js +320 -0
- package/src/core/kernel/kernelInjector.js +19 -0
- package/src/core/kernel/store.js +173 -0
- package/src/core/{class → logic/dom}/char.js +42 -45
- package/src/core/logic/dom/format.js +1075 -0
- package/src/core/{class → logic/dom}/html.js +743 -624
- package/src/core/logic/dom/inline.js +1847 -0
- package/src/core/logic/dom/listFormat.js +601 -0
- package/src/core/{class → logic/dom}/nodeTransform.js +92 -72
- package/src/core/{class → logic/dom}/offset.js +254 -317
- package/src/core/logic/dom/selection.js +754 -0
- package/src/core/logic/panel/menu.js +389 -0
- package/src/core/logic/panel/toolbar.js +449 -0
- package/src/core/logic/panel/viewer.js +761 -0
- package/src/core/logic/shell/_commandExecutor.js +380 -0
- package/src/core/logic/shell/commandDispatcher.js +241 -0
- package/src/core/logic/shell/component.js +970 -0
- package/src/core/logic/shell/focusManager.js +110 -0
- package/src/core/{base → logic/shell}/history.js +110 -60
- package/src/core/logic/shell/pluginManager.js +363 -0
- package/src/core/logic/shell/shortcuts.js +130 -0
- package/src/core/logic/shell/ui.js +904 -0
- package/src/core/schema/context.js +66 -0
- package/src/core/schema/frameContext.js +160 -0
- package/src/core/schema/options.js +628 -0
- package/src/core/section/constructor.js +194 -500
- package/src/core/section/documentType.js +297 -222
- package/src/events.js +808 -543
- package/src/helper/clipboard.js +27 -16
- package/src/helper/converter.js +100 -78
- package/src/helper/dom/domCheck.js +56 -30
- package/src/helper/dom/domQuery.js +159 -89
- package/src/helper/dom/domUtils.js +114 -49
- package/src/helper/dom/index.js +5 -1
- package/src/helper/env.js +26 -26
- package/src/helper/index.js +1 -1
- package/src/helper/keyCodeMap.js +25 -28
- package/src/helper/numbers.js +4 -8
- package/src/helper/unicode.js +4 -8
- package/src/hooks/base.js +307 -0
- package/src/hooks/params.js +130 -0
- package/src/interfaces/contracts.js +227 -0
- package/src/interfaces/index.js +7 -0
- package/src/interfaces/plugins.js +239 -0
- package/src/langs/ckb.js +4 -4
- package/src/langs/cs.js +4 -4
- package/src/langs/da.js +4 -4
- package/src/langs/de.js +4 -4
- package/src/langs/en.js +4 -4
- package/src/langs/es.js +4 -4
- package/src/langs/fa.js +4 -4
- package/src/langs/fr.js +4 -4
- package/src/langs/he.js +4 -4
- package/src/langs/hu.js +4 -4
- package/src/langs/it.js +4 -4
- package/src/langs/ja.js +4 -4
- package/src/langs/km.js +4 -4
- package/src/langs/ko.js +4 -4
- package/src/langs/lv.js +4 -4
- package/src/langs/nl.js +4 -4
- package/src/langs/pl.js +4 -4
- package/src/langs/pt_br.js +13 -13
- package/src/langs/ro.js +4 -4
- package/src/langs/ru.js +4 -4
- package/src/langs/se.js +4 -4
- package/src/langs/tr.js +4 -4
- package/src/langs/uk.js +4 -4
- package/src/langs/ur.js +4 -4
- package/src/langs/zh_cn.js +4 -4
- package/src/modules/{Browser.js → contract/Browser.js} +119 -128
- package/src/modules/{ColorPicker.js → contract/ColorPicker.js} +132 -142
- package/src/modules/contract/Controller.js +589 -0
- package/src/modules/{Figure.js → contract/Figure.js} +591 -411
- package/src/modules/{HueSlider.js → contract/HueSlider.js} +125 -86
- package/src/modules/contract/Modal.js +357 -0
- package/src/modules/contract/index.js +9 -0
- package/src/modules/manager/ApiManager.js +197 -0
- package/src/modules/{FileManager.js → manager/FileManager.js} +128 -160
- package/src/modules/manager/index.js +5 -0
- package/src/modules/{ModalAnchorEditor.js → ui/ModalAnchorEditor.js} +108 -138
- package/src/modules/{SelectMenu.js → ui/SelectMenu.js} +119 -120
- package/src/modules/{_DragHandle.js → ui/_DragHandle.js} +1 -1
- package/src/modules/ui/index.js +6 -0
- package/src/plugins/browser/audioGallery.js +23 -26
- package/src/plugins/browser/fileBrowser.js +25 -28
- package/src/plugins/browser/fileGallery.js +20 -23
- package/src/plugins/browser/imageGallery.js +24 -23
- package/src/plugins/browser/videoGallery.js +27 -29
- package/src/plugins/command/blockquote.js +11 -17
- package/src/plugins/command/exportPDF.js +26 -26
- package/src/plugins/command/fileUpload.js +138 -133
- package/src/plugins/command/list_bulleted.js +48 -44
- package/src/plugins/command/list_numbered.js +48 -44
- package/src/plugins/dropdown/align.js +64 -50
- package/src/plugins/dropdown/backgroundColor.js +34 -35
- package/src/plugins/dropdown/{formatBlock.js → blockStyle.js} +43 -37
- package/src/plugins/dropdown/font.js +50 -36
- package/src/plugins/dropdown/fontColor.js +34 -35
- package/src/plugins/dropdown/hr.js +55 -50
- package/src/plugins/dropdown/layout.js +20 -15
- package/src/plugins/dropdown/lineHeight.js +46 -30
- package/src/plugins/dropdown/list.js +32 -33
- package/src/plugins/dropdown/paragraphStyle.js +40 -34
- package/src/plugins/dropdown/table/index.js +915 -0
- package/src/plugins/dropdown/table/render/table.html.js +308 -0
- package/src/plugins/dropdown/table/render/table.menu.js +121 -0
- package/src/plugins/dropdown/table/services/table.cell.js +465 -0
- package/src/plugins/dropdown/table/services/table.clipboard.js +414 -0
- package/src/plugins/dropdown/table/services/table.grid.js +504 -0
- package/src/plugins/dropdown/table/services/table.resize.js +463 -0
- package/src/plugins/dropdown/table/services/table.selection.js +466 -0
- package/src/plugins/dropdown/table/services/table.style.js +844 -0
- package/src/plugins/dropdown/table/shared/table.constants.js +109 -0
- package/src/plugins/dropdown/table/shared/table.utils.js +219 -0
- package/src/plugins/dropdown/template.js +20 -15
- package/src/plugins/dropdown/textStyle.js +28 -22
- package/src/plugins/field/mention.js +54 -49
- package/src/plugins/index.js +5 -5
- package/src/plugins/input/fontSize.js +100 -97
- package/src/plugins/input/pageNavigator.js +13 -10
- package/src/plugins/modal/audio.js +208 -219
- package/src/plugins/modal/drawing.js +99 -104
- package/src/plugins/modal/embed.js +323 -312
- package/src/plugins/modal/image/index.js +942 -0
- package/src/plugins/modal/image/render/image.html.js +150 -0
- package/src/plugins/modal/image/services/image.size.js +198 -0
- package/src/plugins/modal/image/services/image.upload.js +216 -0
- package/src/plugins/modal/image/shared/image.constants.js +20 -0
- package/src/plugins/modal/link.js +74 -54
- package/src/plugins/modal/math.js +126 -119
- package/src/plugins/modal/video/index.js +858 -0
- package/src/plugins/modal/video/render/video.html.js +131 -0
- package/src/plugins/modal/video/services/video.size.js +281 -0
- package/src/plugins/modal/video/services/video.upload.js +92 -0
- package/src/plugins/popup/anchor.js +57 -49
- package/src/suneditor.js +73 -61
- package/src/themes/cobalt.css +155 -0
- package/src/themes/dark.css +143 -120
- package/src/typedef.js +214 -63
- package/types/assets/icons/defaultIcons.d.ts +8 -0
- package/types/assets/suneditor-contents.css.d.ts +1 -0
- package/types/assets/suneditor.css.d.ts +1 -0
- package/types/core/config/contextProvider.d.ts +148 -0
- package/types/core/config/eventManager.d.ts +68 -0
- package/types/core/config/instanceCheck.d.ts +33 -0
- package/types/core/config/optionProvider.d.ts +147 -0
- package/types/core/editor.d.ts +27 -586
- package/types/core/event/actions/index.d.ts +50 -0
- package/types/core/event/effects/common.registry.d.ts +56 -0
- package/types/core/event/effects/keydown.registry.d.ts +80 -0
- package/types/core/event/effects/ruleHelpers.d.ts +36 -0
- package/types/core/event/eventOrchestrator.d.ts +191 -0
- package/types/core/event/executor.d.ts +13 -0
- package/types/core/event/handlers/handler_toolbar.d.ts +38 -0
- package/types/core/event/handlers/handler_ww_clipboard.d.ts +36 -0
- package/types/core/event/handlers/handler_ww_dragDrop.d.ts +26 -0
- package/types/core/event/handlers/handler_ww_input.d.ts +38 -0
- package/types/core/event/handlers/handler_ww_key.d.ts +40 -0
- package/types/core/event/handlers/handler_ww_mouse.d.ts +47 -0
- package/types/core/event/ports.d.ts +256 -0
- package/types/core/event/reducers/keydown.reducer.d.ts +84 -0
- package/types/core/event/rules/keydown.rule.arrow.d.ts +19 -0
- package/types/core/event/rules/keydown.rule.backspace.d.ts +18 -0
- package/types/core/event/rules/keydown.rule.delete.d.ts +18 -0
- package/types/core/event/rules/keydown.rule.enter.d.ts +18 -0
- package/types/core/event/rules/keydown.rule.tab.d.ts +18 -0
- package/types/core/event/support/defaultLineManager.d.ts +22 -0
- package/types/core/event/support/selectionState.d.ts +29 -0
- package/types/core/kernel/coreKernel.d.ts +219 -0
- package/types/core/kernel/kernelInjector.d.ts +16 -0
- package/types/core/kernel/store.d.ts +170 -0
- package/types/core/logic/dom/char.d.ts +46 -0
- package/types/core/logic/dom/format.d.ts +234 -0
- package/types/core/logic/dom/html.d.ts +290 -0
- package/types/core/logic/dom/inline.d.ts +93 -0
- package/types/core/logic/dom/listFormat.d.ts +101 -0
- package/types/core/logic/dom/nodeTransform.d.ts +110 -0
- package/types/core/logic/dom/offset.d.ts +335 -0
- package/types/core/logic/dom/selection.d.ts +165 -0
- package/types/core/logic/panel/menu.d.ts +93 -0
- package/types/core/logic/panel/toolbar.d.ts +128 -0
- package/types/core/logic/panel/viewer.d.ts +89 -0
- package/types/core/logic/shell/_commandExecutor.d.ts +18 -0
- package/types/core/logic/shell/commandDispatcher.d.ts +65 -0
- package/types/core/logic/shell/component.d.ts +182 -0
- package/types/core/logic/shell/focusManager.d.ts +31 -0
- package/types/core/{base → logic/shell}/history.d.ts +13 -12
- package/types/core/logic/shell/pluginManager.d.ts +115 -0
- package/types/core/logic/shell/shortcuts.d.ts +131 -0
- package/types/core/logic/shell/ui.d.ts +261 -0
- package/types/core/schema/context.d.ts +104 -0
- package/types/core/schema/frameContext.d.ts +320 -0
- package/types/core/schema/options.d.ts +1241 -0
- package/types/core/section/constructor.d.ts +117 -652
- package/types/core/section/documentType.d.ts +43 -61
- package/types/events.d.ts +796 -65
- package/types/helper/clipboard.d.ts +5 -4
- package/types/helper/converter.d.ts +55 -43
- package/types/helper/dom/domCheck.d.ts +27 -19
- package/types/helper/dom/domQuery.d.ts +76 -57
- package/types/helper/dom/domUtils.d.ts +62 -39
- package/types/helper/dom/index.d.ts +87 -1
- package/types/helper/env.d.ts +16 -13
- package/types/helper/index.d.ts +8 -2
- package/types/helper/keyCodeMap.d.ts +24 -23
- package/types/helper/numbers.d.ts +4 -6
- package/types/helper/unicode.d.ts +4 -3
- package/types/hooks/base.d.ts +239 -0
- package/types/hooks/params.d.ts +65 -0
- package/types/index.d.ts +20 -117
- package/types/interfaces/contracts.d.ts +183 -0
- package/types/interfaces/index.d.ts +3 -0
- package/types/interfaces/plugins.d.ts +168 -0
- package/types/langs/_Lang.d.ts +2 -2
- package/types/langs/index.d.ts +2 -2
- package/types/modules/contract/Browser.d.ts +262 -0
- package/types/modules/contract/ColorPicker.d.ts +99 -0
- package/types/modules/contract/Controller.d.ts +204 -0
- package/types/modules/contract/Figure.d.ts +529 -0
- package/types/modules/{HueSlider.d.ts → contract/HueSlider.d.ts} +39 -28
- package/types/modules/contract/Modal.d.ts +62 -0
- package/types/modules/contract/index.d.ts +7 -0
- package/types/modules/manager/ApiManager.d.ts +106 -0
- package/types/modules/manager/FileManager.d.ts +124 -0
- package/types/modules/manager/index.d.ts +3 -0
- package/types/modules/ui/ModalAnchorEditor.d.ts +152 -0
- package/types/modules/ui/SelectMenu.d.ts +107 -0
- package/types/modules/{_DragHandle.d.ts → ui/_DragHandle.d.ts} +1 -0
- package/types/modules/ui/index.d.ts +4 -0
- package/types/plugins/browser/audioGallery.d.ts +33 -41
- package/types/plugins/browser/fileBrowser.d.ts +42 -50
- package/types/plugins/browser/fileGallery.d.ts +33 -41
- package/types/plugins/browser/imageGallery.d.ts +30 -37
- package/types/plugins/browser/videoGallery.d.ts +33 -41
- package/types/plugins/command/blockquote.d.ts +4 -21
- package/types/plugins/command/exportPDF.d.ts +23 -33
- package/types/plugins/command/fileUpload.d.ts +80 -100
- package/types/plugins/command/list_bulleted.d.ts +9 -35
- package/types/plugins/command/list_numbered.d.ts +9 -35
- package/types/plugins/dropdown/align.d.ts +23 -46
- package/types/plugins/dropdown/backgroundColor.d.ts +35 -53
- package/types/plugins/dropdown/blockStyle.d.ts +45 -0
- package/types/plugins/dropdown/font.d.ts +18 -41
- package/types/plugins/dropdown/fontColor.d.ts +35 -53
- package/types/plugins/dropdown/hr.d.ts +26 -52
- package/types/plugins/dropdown/layout.d.ts +19 -25
- package/types/plugins/dropdown/lineHeight.d.ts +21 -39
- package/types/plugins/dropdown/list.d.ts +6 -34
- package/types/plugins/dropdown/paragraphStyle.d.ts +34 -45
- package/types/plugins/dropdown/table/index.d.ts +158 -0
- package/types/plugins/dropdown/table/render/table.html.d.ts +71 -0
- package/types/plugins/dropdown/table/render/table.menu.d.ts +59 -0
- package/types/plugins/dropdown/table/services/table.cell.d.ts +76 -0
- package/types/plugins/dropdown/table/services/table.clipboard.d.ts +26 -0
- package/types/plugins/dropdown/table/services/table.grid.d.ts +77 -0
- package/types/plugins/dropdown/table/services/table.resize.d.ts +72 -0
- package/types/plugins/dropdown/table/services/table.selection.d.ts +59 -0
- package/types/plugins/dropdown/table/services/table.style.d.ts +162 -0
- package/types/plugins/dropdown/table/shared/table.constants.d.ts +134 -0
- package/types/plugins/dropdown/table/shared/table.utils.d.ts +91 -0
- package/types/plugins/dropdown/template.d.ts +19 -25
- package/types/plugins/dropdown/textStyle.d.ts +23 -30
- package/types/plugins/field/mention.d.ts +66 -72
- package/types/plugins/index.d.ts +41 -40
- package/types/plugins/input/fontSize.d.ts +57 -96
- package/types/plugins/input/pageNavigator.d.ts +5 -8
- package/types/plugins/modal/audio.d.ts +60 -153
- package/types/plugins/modal/drawing.d.ts +16 -118
- package/types/plugins/modal/embed.d.ts +46 -166
- package/types/plugins/modal/image/index.d.ts +281 -0
- package/types/plugins/modal/image/render/image.html.d.ts +45 -0
- package/types/plugins/modal/image/services/image.size.d.ts +55 -0
- package/types/plugins/modal/image/services/image.upload.d.ts +24 -0
- package/types/plugins/modal/image/shared/image.constants.d.ts +17 -0
- package/types/plugins/modal/link.d.ts +46 -66
- package/types/plugins/modal/math.d.ts +17 -86
- package/types/plugins/modal/{video.d.ts → video/index.d.ts} +89 -221
- package/types/plugins/modal/video/render/video.html.d.ts +37 -0
- package/types/plugins/modal/video/services/video.size.d.ts +74 -0
- package/types/plugins/modal/video/services/video.upload.d.ts +19 -0
- package/types/plugins/popup/anchor.d.ts +8 -38
- package/types/suneditor.d.ts +55 -24
- package/types/typedef.d.ts +344 -228
- package/CONTRIBUTING.md +0 -186
- package/src/core/base/eventHandlers/handler_ww_key_input.js +0 -1200
- package/src/core/base/eventHandlers/handler_ww_mouse.js +0 -194
- package/src/core/base/eventManager.js +0 -1523
- package/src/core/class/component.js +0 -856
- package/src/core/class/format.js +0 -3433
- package/src/core/class/menu.js +0 -346
- package/src/core/class/selection.js +0 -610
- package/src/core/class/shortcuts.js +0 -98
- package/src/core/class/toolbar.js +0 -431
- package/src/core/class/ui.js +0 -424
- package/src/core/class/viewer.js +0 -750
- package/src/core/section/actives.js +0 -266
- package/src/core/section/context.js +0 -102
- package/src/editorInjector/_classes.js +0 -36
- package/src/editorInjector/_core.js +0 -87
- package/src/editorInjector/index.js +0 -73
- package/src/modules/ApiManager.js +0 -191
- package/src/modules/Controller.js +0 -474
- package/src/modules/Modal.js +0 -346
- package/src/modules/index.js +0 -14
- package/src/plugins/dropdown/table.js +0 -4034
- package/src/plugins/modal/image.js +0 -1376
- package/src/plugins/modal/video.js +0 -1226
- package/types/core/base/eventHandlers/handler_toolbar.d.ts +0 -41
- package/types/core/base/eventHandlers/handler_ww_clipboard.d.ts +0 -40
- package/types/core/base/eventHandlers/handler_ww_dragDrop.d.ts +0 -35
- package/types/core/base/eventHandlers/handler_ww_key_input.d.ts +0 -45
- package/types/core/base/eventHandlers/handler_ww_mouse.d.ts +0 -39
- package/types/core/base/eventManager.d.ts +0 -401
- package/types/core/class/char.d.ts +0 -61
- package/types/core/class/component.d.ts +0 -213
- package/types/core/class/format.d.ts +0 -623
- package/types/core/class/html.d.ts +0 -430
- package/types/core/class/menu.d.ts +0 -126
- package/types/core/class/nodeTransform.d.ts +0 -93
- package/types/core/class/offset.d.ts +0 -522
- package/types/core/class/selection.d.ts +0 -188
- package/types/core/class/shortcuts.d.ts +0 -142
- package/types/core/class/toolbar.d.ts +0 -189
- package/types/core/class/ui.d.ts +0 -164
- package/types/core/class/viewer.d.ts +0 -140
- package/types/core/section/actives.d.ts +0 -46
- package/types/core/section/context.d.ts +0 -45
- package/types/editorInjector/_classes.d.ts +0 -41
- package/types/editorInjector/_core.d.ts +0 -87
- package/types/editorInjector/index.d.ts +0 -69
- package/types/modules/ApiManager.d.ts +0 -125
- package/types/modules/Browser.d.ts +0 -326
- package/types/modules/ColorPicker.d.ts +0 -135
- package/types/modules/Controller.d.ts +0 -251
- package/types/modules/Figure.d.ts +0 -517
- package/types/modules/FileManager.d.ts +0 -202
- package/types/modules/Modal.d.ts +0 -111
- package/types/modules/ModalAnchorEditor.d.ts +0 -236
- package/types/modules/SelectMenu.d.ts +0 -194
- package/types/modules/index.d.ts +0 -26
- package/types/plugins/dropdown/formatBlock.d.ts +0 -55
- package/types/plugins/dropdown/table.d.ts +0 -627
- package/types/plugins/modal/image.d.ts +0 -451
- /package/{LICENSE → LICENSE.txt} +0 -0
|
@@ -1,34 +1,22 @@
|
|
|
1
|
-
import EditorInjector from '../editorInjector';
|
|
2
1
|
import SelectMenu from './SelectMenu';
|
|
3
|
-
import FileManager from '
|
|
4
|
-
import { dom, numbers, env, unicode } from '
|
|
5
|
-
const { NO_EVENT } = env;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {{default?: string, check_new_window?: string, check_bookmark?: string}} RELAttr
|
|
9
|
-
*/
|
|
2
|
+
import FileManager from '../manager/FileManager';
|
|
3
|
+
import { dom, numbers, env, unicode } from '../../helper';
|
|
4
|
+
const { _w, NO_EVENT } = env;
|
|
10
5
|
|
|
11
6
|
/**
|
|
12
7
|
* @typedef {Object} ModalAnchorEditorParams
|
|
13
8
|
* @property {boolean} [title=false] - Modal title display.
|
|
14
9
|
* @property {boolean} [textToDisplay=''] - Create Text to display input.
|
|
15
10
|
* @property {boolean} [openNewWindow=false] - Default checked value of the "Open in new window" checkbox.
|
|
16
|
-
* @property {boolean} [noAutoPrefix=false] - If true
|
|
17
|
-
* @property {Array<string>} [relList=[]] - The
|
|
18
|
-
* @property {
|
|
19
|
-
* @property {string
|
|
20
|
-
* @property {Object<string, string
|
|
21
|
-
* @property {number
|
|
22
|
-
* @property {number
|
|
23
|
-
* @property {string
|
|
24
|
-
* @property {boolean
|
|
25
|
-
* @example "REL" structure
|
|
26
|
-
{
|
|
27
|
-
default: 'nofollow', // Default rel
|
|
28
|
-
check_new_window: 'noreferrer noopener', // When "open new window" is checked
|
|
29
|
-
check_bookmark: 'bookmark' // When "bookmark" is checked
|
|
30
|
-
}
|
|
31
|
-
If true, disables the automatic prefixing of the host URL to the value of the link.
|
|
11
|
+
* @property {boolean} [noAutoPrefix=false] - If `true`, disables the automatic prefixing of the host URL to the value of the link.
|
|
12
|
+
* @property {Array<string>} [relList=[]] - The `rel` attribute list of anchor tag.
|
|
13
|
+
* @property {{default?: string, check_new_window?: string, check_bookmark?: string}} [defaultRel={}] - Default `rel` attributes of anchor tag.
|
|
14
|
+
* @property {string} [uploadUrl] - File upload URL.
|
|
15
|
+
* @property {Object<string, string>} [uploadHeaders] - File upload headers.
|
|
16
|
+
* @property {number} [uploadSizeLimit] - File upload size limit.
|
|
17
|
+
* @property {number} [uploadSingleSizeLimit] - File upload single size limit.
|
|
18
|
+
* @property {string} [acceptedFormats] - File upload accepted formats.
|
|
19
|
+
* @property {boolean} [enableFileUpload] - If `true`, enables file upload.
|
|
32
20
|
*/
|
|
33
21
|
|
|
34
22
|
/**
|
|
@@ -36,16 +24,22 @@ const { NO_EVENT } = env;
|
|
|
36
24
|
* @description Modal form Anchor tag editor
|
|
37
25
|
* - Use it by inserting it into Modal in a plugin that uses Modal.
|
|
38
26
|
*/
|
|
39
|
-
class ModalAnchorEditor
|
|
27
|
+
class ModalAnchorEditor {
|
|
28
|
+
#$;
|
|
29
|
+
|
|
30
|
+
#modalForm;
|
|
31
|
+
#isRel;
|
|
32
|
+
#selectMenu_rel;
|
|
33
|
+
#selectMenu_bookmark;
|
|
34
|
+
|
|
40
35
|
/**
|
|
41
36
|
* @constructor
|
|
42
|
-
* @param {
|
|
43
|
-
* @param {
|
|
37
|
+
* @param {SunEditor.Deps} $ Kernel dependencies
|
|
38
|
+
* @param {HTMLElement} modalForm Modal <form>
|
|
44
39
|
* @param {ModalAnchorEditorParams} params ModalAnchorEditor options
|
|
45
40
|
*/
|
|
46
|
-
constructor(
|
|
47
|
-
|
|
48
|
-
super(inst.editor);
|
|
41
|
+
constructor($, modalForm, params) {
|
|
42
|
+
this.#$ = $;
|
|
49
43
|
|
|
50
44
|
// params
|
|
51
45
|
this.openNewWindow = !!params.openNewWindow;
|
|
@@ -59,23 +53,20 @@ class ModalAnchorEditor extends EditorInjector {
|
|
|
59
53
|
this.uploadSizeLimit = numbers.get(params.uploadSizeLimit, 0) || null;
|
|
60
54
|
this.uploadSingleSizeLimit = numbers.get(params.uploadSingleSizeLimit, 0) || null;
|
|
61
55
|
this.input = dom.utils.createElement('input', { type: 'file', accept: params.acceptedFormats || '*' });
|
|
62
|
-
this
|
|
56
|
+
this.#$.eventManager.addEvent(this.input, 'change', this.#OnChangeFile.bind(this));
|
|
63
57
|
// file manager
|
|
64
|
-
this.fileManager = new FileManager(this, {
|
|
58
|
+
this.fileManager = new FileManager(this, $, {
|
|
65
59
|
query: 'a[download]:not([data-se-file-download])',
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
loadEventName: 'onFileLoad',
|
|
61
|
+
actionEventName: 'onFileAction',
|
|
68
62
|
});
|
|
69
63
|
}
|
|
70
64
|
|
|
71
65
|
// create HTML
|
|
72
|
-
const forms =
|
|
66
|
+
const forms = CreateModalForm($, params, this.relList);
|
|
73
67
|
|
|
74
68
|
// members
|
|
75
|
-
this.
|
|
76
|
-
this.inst = inst;
|
|
77
|
-
this.modalForm = /** @type {HTMLElement} */ (modalForm);
|
|
78
|
-
this.host = (this._w.location.origin + this._w.location.pathname).replace(/\/$/, '');
|
|
69
|
+
this.host = (_w.location.origin + _w.location.pathname).replace(/\/$/, '');
|
|
79
70
|
|
|
80
71
|
/** @type {HTMLInputElement} */
|
|
81
72
|
this.urlInput = forms.querySelector('.se-input-url');
|
|
@@ -99,10 +90,10 @@ class ModalAnchorEditor extends EditorInjector {
|
|
|
99
90
|
this.currentRel = [];
|
|
100
91
|
this.currentTarget = null;
|
|
101
92
|
this.linkValue = '';
|
|
102
|
-
|
|
103
|
-
this
|
|
93
|
+
|
|
94
|
+
this.#isRel = this.relList.length > 0;
|
|
104
95
|
// members - rel
|
|
105
|
-
if (this
|
|
96
|
+
if (this.#isRel) {
|
|
106
97
|
/** @type {HTMLButtonElement} */
|
|
107
98
|
this.relButton = forms.querySelector('.se-anchor-rel-btn');
|
|
108
99
|
/** @type {HTMLElement} */
|
|
@@ -121,30 +112,31 @@ class ModalAnchorEditor extends EditorInjector {
|
|
|
121
112
|
class: 'se-btn-list' + (defaultRel.includes(rel) ? ' se-checked' : ''),
|
|
122
113
|
'data-command': rel,
|
|
123
114
|
title: rel,
|
|
124
|
-
'aria-label': rel
|
|
115
|
+
'aria-label': rel,
|
|
125
116
|
},
|
|
126
|
-
rel + '<span class="se-svg">' + this
|
|
127
|
-
)
|
|
117
|
+
rel + '<span class="se-svg">' + this.#$.icons.checked + '</span>',
|
|
118
|
+
),
|
|
128
119
|
);
|
|
129
120
|
}
|
|
130
|
-
this
|
|
131
|
-
this
|
|
132
|
-
this
|
|
133
|
-
this
|
|
121
|
+
this.#selectMenu_rel = new SelectMenu($, { checkList: true, position: 'right-middle', dir: 'ltr' });
|
|
122
|
+
this.#selectMenu_rel.on(this.relButton, this.#SetRelItem.bind(this));
|
|
123
|
+
this.#selectMenu_rel.create(list);
|
|
124
|
+
this.#$.eventManager.addEvent(this.relButton, 'click', this.#OnClick_relbutton.bind(this));
|
|
134
125
|
}
|
|
135
126
|
|
|
136
127
|
// init
|
|
137
|
-
this
|
|
138
|
-
this.
|
|
139
|
-
this
|
|
140
|
-
this.
|
|
141
|
-
this
|
|
142
|
-
this
|
|
143
|
-
this
|
|
144
|
-
this
|
|
145
|
-
this
|
|
146
|
-
this
|
|
128
|
+
this.#modalForm = /** @type {HTMLElement} */ (modalForm);
|
|
129
|
+
this.#modalForm.querySelector('.se-anchor-editor').appendChild(forms);
|
|
130
|
+
this.#selectMenu_bookmark = new SelectMenu($, { checkList: false, position: 'bottom-left', dir: 'ltr' });
|
|
131
|
+
this.#selectMenu_bookmark.on(this.urlInput, this.#SetHeaderBookmark.bind(this));
|
|
132
|
+
this.#$.eventManager.addEvent(this.newWindowCheck, 'change', this.#OnChange_newWindowCheck.bind(this));
|
|
133
|
+
this.#$.eventManager.addEvent(this.downloadCheck, 'change', this.#OnChange_downloadCheck.bind(this));
|
|
134
|
+
this.#$.eventManager.addEvent(this.urlInput, 'input', this.#OnChange_urlInput.bind(this));
|
|
135
|
+
this.#$.eventManager.addEvent(this.urlInput, 'focus', this.#OnFocus_urlInput.bind(this));
|
|
136
|
+
this.#$.eventManager.addEvent(this.bookmarkButton, 'click', this.#OnClick_bookmarkButton.bind(this));
|
|
137
|
+
this.#$.eventManager.addEvent(forms.querySelector('._se_upload_button'), 'click', () => this.input.click());
|
|
147
138
|
}
|
|
139
|
+
|
|
148
140
|
/**
|
|
149
141
|
* @description Initialize.
|
|
150
142
|
* - Sets the current anchor element to be edited.
|
|
@@ -161,20 +153,20 @@ class ModalAnchorEditor extends EditorInjector {
|
|
|
161
153
|
on(isUpdate) {
|
|
162
154
|
if (!isUpdate) {
|
|
163
155
|
this.init();
|
|
164
|
-
this.displayInput.value = this
|
|
156
|
+
this.displayInput.value = this.#$.selection.get().toString().trim();
|
|
165
157
|
this.newWindowCheck.checked = this.openNewWindow;
|
|
166
158
|
this.titleInput.value = '';
|
|
167
159
|
} else if (this.currentTarget) {
|
|
168
160
|
const href = this.currentTarget.href;
|
|
169
|
-
this.linkValue = this.preview.textContent = this.urlInput.value = this
|
|
161
|
+
this.linkValue = this.preview.textContent = this.urlInput.value = this.#selfPathBookmark(href) ? href.substring(href.lastIndexOf('#')) : href;
|
|
170
162
|
this.displayInput.value = this.currentTarget.textContent;
|
|
171
163
|
this.titleInput.value = this.currentTarget.title;
|
|
172
164
|
this.newWindowCheck.checked = /_blank/i.test(this.currentTarget.target) ? true : false;
|
|
173
165
|
this.downloadCheck.checked = !!this.currentTarget.download;
|
|
174
166
|
}
|
|
175
167
|
|
|
176
|
-
this
|
|
177
|
-
this
|
|
168
|
+
this.#setRel(isUpdate && this.currentTarget ? this.currentTarget.rel : this.defaultRel.default || '');
|
|
169
|
+
this.#setLinkPreview(this.linkValue);
|
|
178
170
|
}
|
|
179
171
|
|
|
180
172
|
/**
|
|
@@ -189,7 +181,7 @@ class ModalAnchorEditor extends EditorInjector {
|
|
|
189
181
|
const displayText = this.displayInput.value.length === 0 ? url : this.displayInput.value;
|
|
190
182
|
|
|
191
183
|
const oA = /** @type {HTMLAnchorElement} */ (this.currentTarget || dom.utils.createElement('A'));
|
|
192
|
-
this
|
|
184
|
+
this.#updateAnchor(oA, url, displayText, this.titleInput.value, notText);
|
|
193
185
|
this.linkValue = this.preview.textContent = this.urlInput.value = this.displayInput.value = '';
|
|
194
186
|
|
|
195
187
|
return oA;
|
|
@@ -204,12 +196,10 @@ class ModalAnchorEditor extends EditorInjector {
|
|
|
204
196
|
this.displayInput.value = '';
|
|
205
197
|
this.newWindowCheck.checked = false;
|
|
206
198
|
this.downloadCheck.checked = false;
|
|
207
|
-
this.
|
|
208
|
-
this._setRel(this.defaultRel.default || '');
|
|
199
|
+
this.#setRel(this.defaultRel.default || '');
|
|
209
200
|
}
|
|
210
201
|
|
|
211
202
|
/**
|
|
212
|
-
* @private
|
|
213
203
|
* @description Updates the anchor element with new attributes.
|
|
214
204
|
* @param {HTMLAnchorElement} anchor - The anchor (`<a>`) element to update.
|
|
215
205
|
* @param {string} url - The URL for the anchor's `href` attribute.
|
|
@@ -217,9 +207,9 @@ class ModalAnchorEditor extends EditorInjector {
|
|
|
217
207
|
* @param {string} title - The tooltip text (title attribute).
|
|
218
208
|
* @param {boolean} notText - If `true`, the anchor will not contain text content.
|
|
219
209
|
*/
|
|
220
|
-
|
|
210
|
+
#updateAnchor(anchor, url, displayText, title, notText) {
|
|
221
211
|
// download
|
|
222
|
-
if (!this
|
|
212
|
+
if (!this.#selfPathBookmark(url) && this.downloadCheck.checked) {
|
|
223
213
|
anchor.setAttribute('download', displayText || url);
|
|
224
214
|
} else {
|
|
225
215
|
anchor.removeAttribute('download');
|
|
@@ -247,26 +237,24 @@ class ModalAnchorEditor extends EditorInjector {
|
|
|
247
237
|
}
|
|
248
238
|
|
|
249
239
|
/**
|
|
250
|
-
* @private
|
|
251
240
|
* @description Checks if the given path is an internal bookmark.
|
|
252
241
|
* @param {string} path - The URL or anchor link.
|
|
253
242
|
* @returns {boolean} - `true` if the path is an internal bookmark, otherwise `false`.
|
|
254
243
|
*/
|
|
255
|
-
|
|
256
|
-
const href =
|
|
244
|
+
#selfPathBookmark(path) {
|
|
245
|
+
const href = _w.location.href.replace(/\/$/, '');
|
|
257
246
|
return path.indexOf('#') === 0 || (path.indexOf(href) === 0 && path.indexOf('#') === (!href.includes('#') ? href.length : href.substring(0, href.indexOf('#')).length));
|
|
258
247
|
}
|
|
259
248
|
|
|
260
249
|
/**
|
|
261
|
-
* @private
|
|
262
250
|
* @description Updates the `rel` attribute list in the modal and preview.
|
|
263
251
|
* @param {string} relAttr - The `rel` attribute string to set.
|
|
264
252
|
*/
|
|
265
|
-
|
|
266
|
-
if (!this
|
|
253
|
+
#setRel(relAttr) {
|
|
254
|
+
if (!this.#isRel) return;
|
|
267
255
|
|
|
268
256
|
const rels = (this.currentRel = !relAttr ? [] : relAttr.split(' '));
|
|
269
|
-
const checkedRel = this
|
|
257
|
+
const checkedRel = this.#selectMenu_rel.form.querySelectorAll('button');
|
|
270
258
|
for (let i = 0, len = checkedRel.length, cmd; i < len; i++) {
|
|
271
259
|
cmd = checkedRel[i].getAttribute('data-command');
|
|
272
260
|
if (rels.includes(cmd)) {
|
|
@@ -285,12 +273,11 @@ class ModalAnchorEditor extends EditorInjector {
|
|
|
285
273
|
}
|
|
286
274
|
|
|
287
275
|
/**
|
|
288
|
-
* @private
|
|
289
276
|
* @description Generates a list of bookmark headers within the editor.
|
|
290
277
|
* @param {string} urlValue - The current URL input value.
|
|
291
278
|
*/
|
|
292
|
-
|
|
293
|
-
const headers = dom.query.getListChildren(this
|
|
279
|
+
#createBookmarkList(urlValue) {
|
|
280
|
+
const headers = dom.query.getListChildren(this.#$.frameContext.get('wysiwyg'), (current) => /h[1-6]/i.test(current.nodeName) || (dom.check.isAnchor(current) && !!current.id), null);
|
|
294
281
|
if (headers.length === 0) return;
|
|
295
282
|
|
|
296
283
|
const valueRegExp = new RegExp(`^${urlValue.replace(/^#/, '')}`, 'i');
|
|
@@ -300,25 +287,24 @@ class ModalAnchorEditor extends EditorInjector {
|
|
|
300
287
|
v = headers[i];
|
|
301
288
|
if (!valueRegExp.test(v.textContent)) continue;
|
|
302
289
|
list.push(v);
|
|
303
|
-
menus.push(dom.check.isAnchor(v) ? `<div><span class="se-text-prefix-icon">${this
|
|
290
|
+
menus.push(dom.check.isAnchor(v) ? `<div><span class="se-text-prefix-icon">${this.#$.icons.bookmark_anchor}</span>${v.id}</div>` : `<div style="${v.style.cssText}">${v.textContent}</div>`);
|
|
304
291
|
}
|
|
305
292
|
|
|
306
293
|
if (list.length === 0) {
|
|
307
|
-
this
|
|
294
|
+
this.#selectMenu_bookmark.close();
|
|
308
295
|
} else {
|
|
309
|
-
this
|
|
310
|
-
this
|
|
296
|
+
this.#selectMenu_bookmark.create(list, menus);
|
|
297
|
+
this.#selectMenu_bookmark.open(this.#$.options.get('_rtl') ? 'bottom-right' : '');
|
|
311
298
|
}
|
|
312
299
|
}
|
|
313
300
|
|
|
314
301
|
/**
|
|
315
|
-
* @private
|
|
316
302
|
* @description Updates the preview of the anchor link.
|
|
317
303
|
* @param {string} value - The current URL value.
|
|
318
304
|
*/
|
|
319
|
-
|
|
305
|
+
#setLinkPreview(value) {
|
|
320
306
|
const preview = this.preview;
|
|
321
|
-
const protocol = this
|
|
307
|
+
const protocol = this.#$.options.get('defaultUrlProtocol');
|
|
322
308
|
const noPrefix = this.noAutoPrefix;
|
|
323
309
|
const reservedProtocol = /^(mailto:|tel:|sms:|https*:\/\/|#)/.test(value) || value.indexOf(protocol) === 0;
|
|
324
310
|
const sameProtocol = !protocol ? false : RegExp('^' + unicode.escapeStringRegexp(value.substring(0, protocol.length))).test(protocol);
|
|
@@ -328,7 +314,7 @@ class ModalAnchorEditor extends EditorInjector {
|
|
|
328
314
|
preview.textContent =
|
|
329
315
|
!value ? '' : noPrefix ? value : protocol && !reservedProtocol && !sameProtocol ? protocol + value : reservedProtocol ? value : /^www\./.test(value) ? 'http://' + value : this.host + (/^\//.test(value) ? '' : '/') + value;
|
|
330
316
|
|
|
331
|
-
if (this
|
|
317
|
+
if (this.#selfPathBookmark(value)) {
|
|
332
318
|
this.bookmark.style.display = 'block';
|
|
333
319
|
dom.utils.addClass(this.bookmarkButton, 'active');
|
|
334
320
|
} else {
|
|
@@ -336,7 +322,7 @@ class ModalAnchorEditor extends EditorInjector {
|
|
|
336
322
|
dom.utils.removeClass(this.bookmarkButton, 'active');
|
|
337
323
|
}
|
|
338
324
|
|
|
339
|
-
if (!this
|
|
325
|
+
if (!this.#selfPathBookmark(value) && this.downloadCheck.checked) {
|
|
340
326
|
this.download.style.display = 'block';
|
|
341
327
|
} else {
|
|
342
328
|
this.download.style.display = 'none';
|
|
@@ -344,12 +330,11 @@ class ModalAnchorEditor extends EditorInjector {
|
|
|
344
330
|
}
|
|
345
331
|
|
|
346
332
|
/**
|
|
347
|
-
* @private
|
|
348
333
|
* @description Merges the given `rel` attribute value with the current list.
|
|
349
334
|
* @param {string} relAttr - The `rel` attribute to merge.
|
|
350
335
|
* @returns {string} - The updated `rel` attribute string.
|
|
351
336
|
*/
|
|
352
|
-
|
|
337
|
+
#relMerge(relAttr) {
|
|
353
338
|
const current = this.currentRel;
|
|
354
339
|
if (!relAttr) return current.join(' ');
|
|
355
340
|
|
|
@@ -368,12 +353,11 @@ class ModalAnchorEditor extends EditorInjector {
|
|
|
368
353
|
}
|
|
369
354
|
|
|
370
355
|
/**
|
|
371
|
-
* @private
|
|
372
356
|
* @description Removes the specified `rel` attribute from the current list.
|
|
373
357
|
* @param {string} relAttr - The `rel` attribute to remove.
|
|
374
358
|
* @returns {string} - The updated `rel` attribute string.
|
|
375
359
|
*/
|
|
376
|
-
|
|
360
|
+
#relDelete(relAttr) {
|
|
377
361
|
if (!relAttr) return this.currentRel.join(' ');
|
|
378
362
|
if (/^only:/.test(relAttr)) relAttr = relAttr.replace(/^only:/, '').trim();
|
|
379
363
|
|
|
@@ -383,11 +367,10 @@ class ModalAnchorEditor extends EditorInjector {
|
|
|
383
367
|
}
|
|
384
368
|
|
|
385
369
|
/**
|
|
386
|
-
* @private
|
|
387
370
|
* @description Registers a newly uploaded file and sets its URL in the modal form.
|
|
388
371
|
* @param {Object<string, *>} response - The response object from the file upload request.
|
|
389
372
|
*/
|
|
390
|
-
|
|
373
|
+
#register(response) {
|
|
391
374
|
const file = response.result[0];
|
|
392
375
|
this.linkValue = this.preview.textContent = this.urlInput.value = file.url;
|
|
393
376
|
this.displayInput.value = file.name;
|
|
@@ -396,16 +379,15 @@ class ModalAnchorEditor extends EditorInjector {
|
|
|
396
379
|
}
|
|
397
380
|
|
|
398
381
|
/**
|
|
399
|
-
* @private
|
|
400
382
|
* @description Handles file upload errors.
|
|
401
383
|
* @param {Object<string, *>} response - The error response object.
|
|
402
384
|
* @returns {Promise<void>}
|
|
403
385
|
*/
|
|
404
|
-
async
|
|
405
|
-
const message = await this.triggerEvent('onFileUploadError', { error: response });
|
|
386
|
+
async #error(response) {
|
|
387
|
+
const message = await this.#$.eventManager.triggerEvent('onFileUploadError', { error: response });
|
|
406
388
|
if (message === false) return;
|
|
407
389
|
const err = message === NO_EVENT ? response.errorMessage : message || response.errorMessage;
|
|
408
|
-
this
|
|
390
|
+
this.#$.ui.alertOpen(err, 'error');
|
|
409
391
|
console.error('[SUNEDITOR.plugin.fileUpload.error]', err);
|
|
410
392
|
}
|
|
411
393
|
|
|
@@ -413,12 +395,12 @@ class ModalAnchorEditor extends EditorInjector {
|
|
|
413
395
|
* @description Handles the callback after a file upload completes.
|
|
414
396
|
* @param {XMLHttpRequest} xmlHttp - The XMLHttpRequest object containing the response.
|
|
415
397
|
*/
|
|
416
|
-
|
|
398
|
+
#uploadCallBack(xmlHttp) {
|
|
417
399
|
const response = JSON.parse(xmlHttp.responseText);
|
|
418
400
|
if (response.errorMessage) {
|
|
419
|
-
this
|
|
401
|
+
this.#error(response);
|
|
420
402
|
} else {
|
|
421
|
-
this
|
|
403
|
+
this.#register(response);
|
|
422
404
|
}
|
|
423
405
|
}
|
|
424
406
|
|
|
@@ -435,20 +417,18 @@ class ModalAnchorEditor extends EditorInjector {
|
|
|
435
417
|
const fileInfo = {
|
|
436
418
|
url: this.uploadUrl,
|
|
437
419
|
uploadHeaders: this.uploadHeaders,
|
|
438
|
-
files
|
|
420
|
+
files,
|
|
439
421
|
};
|
|
440
422
|
|
|
441
|
-
const handler = async function (infos, newInfos) {
|
|
423
|
+
const handler = async function (uploadCallback, infos, newInfos) {
|
|
442
424
|
infos = newInfos || infos;
|
|
443
425
|
const xmlHttp = await this.fileManager.asyncUpload(infos.url, infos.uploadHeaders, infos.files);
|
|
444
|
-
|
|
445
|
-
}.bind(this, fileInfo);
|
|
446
|
-
// se-ts-ignore
|
|
447
|
-
void this._uploadCallBack;
|
|
426
|
+
uploadCallback(xmlHttp);
|
|
427
|
+
}.bind(this, this.#uploadCallBack.bind(this), fileInfo);
|
|
448
428
|
|
|
449
|
-
const result = await this.triggerEvent('onFileUploadBefore', {
|
|
429
|
+
const result = await this.#$.eventManager.triggerEvent('onFileUploadBefore', {
|
|
450
430
|
info: fileInfo,
|
|
451
|
-
handler
|
|
431
|
+
handler,
|
|
452
432
|
});
|
|
453
433
|
|
|
454
434
|
if (result === undefined) return true;
|
|
@@ -462,7 +442,7 @@ class ModalAnchorEditor extends EditorInjector {
|
|
|
462
442
|
* @description Opens the `rel` attribute selection menu.
|
|
463
443
|
*/
|
|
464
444
|
#OnClick_relbutton() {
|
|
465
|
-
this
|
|
445
|
+
this.#selectMenu_rel.open(this.#$.options.get('_rtl') ? 'left-middle' : '');
|
|
466
446
|
}
|
|
467
447
|
|
|
468
448
|
/**
|
|
@@ -474,8 +454,8 @@ class ModalAnchorEditor extends EditorInjector {
|
|
|
474
454
|
item.id = id;
|
|
475
455
|
this.urlInput.value = '#' + id;
|
|
476
456
|
|
|
477
|
-
this
|
|
478
|
-
this
|
|
457
|
+
this.#setLinkPreview(this.urlInput.value);
|
|
458
|
+
this.#selectMenu_bookmark.close();
|
|
479
459
|
this.urlInput.focus();
|
|
480
460
|
}
|
|
481
461
|
|
|
@@ -494,15 +474,6 @@ class ModalAnchorEditor extends EditorInjector {
|
|
|
494
474
|
this.relPreview.title = this.relPreview.textContent = current.join(', ');
|
|
495
475
|
}
|
|
496
476
|
|
|
497
|
-
/**
|
|
498
|
-
* @param {InputEvent} e - Event object
|
|
499
|
-
*/
|
|
500
|
-
#OnChange_displayInput(e) {
|
|
501
|
-
/** @type {HTMLInputElement} */
|
|
502
|
-
const eventTarget = dom.query.getEventTarget(e);
|
|
503
|
-
this._change = !!eventTarget.value.trim();
|
|
504
|
-
}
|
|
505
|
-
|
|
506
477
|
/**
|
|
507
478
|
* @param {InputEvent} e - Event object
|
|
508
479
|
*/
|
|
@@ -510,19 +481,19 @@ class ModalAnchorEditor extends EditorInjector {
|
|
|
510
481
|
/** @type {HTMLInputElement} */
|
|
511
482
|
const eventTarget = dom.query.getEventTarget(e);
|
|
512
483
|
const value = eventTarget.value.trim();
|
|
513
|
-
this
|
|
514
|
-
if (this
|
|
515
|
-
else this
|
|
484
|
+
this.#setLinkPreview(value);
|
|
485
|
+
if (this.#selfPathBookmark(value)) this.#createBookmarkList(value);
|
|
486
|
+
else this.#selectMenu_bookmark.close();
|
|
516
487
|
}
|
|
517
488
|
|
|
518
489
|
#OnFocus_urlInput() {
|
|
519
490
|
const value = this.urlInput.value;
|
|
520
|
-
if (this
|
|
491
|
+
if (this.#selfPathBookmark(value)) this.#createBookmarkList(value);
|
|
521
492
|
}
|
|
522
493
|
|
|
523
494
|
#OnClick_bookmarkButton() {
|
|
524
495
|
let url = this.urlInput.value;
|
|
525
|
-
if (this
|
|
496
|
+
if (this.#selfPathBookmark(url)) {
|
|
526
497
|
url = url.substring(1);
|
|
527
498
|
this.bookmark.style.display = 'none';
|
|
528
499
|
dom.utils.removeClass(this.bookmarkButton, 'active');
|
|
@@ -532,11 +503,11 @@ class ModalAnchorEditor extends EditorInjector {
|
|
|
532
503
|
dom.utils.addClass(this.bookmarkButton, 'active');
|
|
533
504
|
this.downloadCheck.checked = false;
|
|
534
505
|
this.download.style.display = 'none';
|
|
535
|
-
this
|
|
506
|
+
this.#createBookmarkList(url);
|
|
536
507
|
}
|
|
537
508
|
|
|
538
509
|
this.urlInput.value = url;
|
|
539
|
-
this
|
|
510
|
+
this.#setLinkPreview(url);
|
|
540
511
|
this.urlInput.focus();
|
|
541
512
|
}
|
|
542
513
|
|
|
@@ -548,9 +519,9 @@ class ModalAnchorEditor extends EditorInjector {
|
|
|
548
519
|
/** @type {HTMLInputElement} */
|
|
549
520
|
const eventTarget = dom.query.getEventTarget(e);
|
|
550
521
|
if (eventTarget.checked) {
|
|
551
|
-
this
|
|
522
|
+
this.#setRel(this.#relMerge(this.defaultRel.check_new_window));
|
|
552
523
|
} else {
|
|
553
|
-
this
|
|
524
|
+
this.#setRel(this.#relDelete(this.defaultRel.check_new_window));
|
|
554
525
|
}
|
|
555
526
|
}
|
|
556
527
|
|
|
@@ -566,27 +537,26 @@ class ModalAnchorEditor extends EditorInjector {
|
|
|
566
537
|
dom.utils.removeClass(this.bookmarkButton, 'active');
|
|
567
538
|
this.linkValue = this.preview.textContent = this.urlInput.value = this.urlInput.value.replace(/^#+/, '');
|
|
568
539
|
if (typeof this.defaultRel.check_bookmark === 'string') {
|
|
569
|
-
this
|
|
540
|
+
this.#setRel(this.#relMerge(this.defaultRel.check_bookmark));
|
|
570
541
|
}
|
|
571
542
|
} else {
|
|
572
543
|
this.download.style.display = 'none';
|
|
573
544
|
if (typeof this.defaultRel.check_bookmark === 'string') {
|
|
574
|
-
this
|
|
545
|
+
this.#setRel(this.#relDelete(this.defaultRel.check_bookmark));
|
|
575
546
|
}
|
|
576
547
|
}
|
|
577
548
|
}
|
|
578
549
|
}
|
|
579
550
|
|
|
580
551
|
/**
|
|
581
|
-
* @
|
|
582
|
-
* @param {__se__EditorCore} editor - Editor instance
|
|
552
|
+
* @param {SunEditor.Deps} $ - Editor instance
|
|
583
553
|
* @param {ModalAnchorEditorParams} params - ModalAnchorEditor options
|
|
584
554
|
* @param {Array<string>} relList - REL attribute list
|
|
585
555
|
* @returns {HTMLElement} - Modal form element
|
|
586
556
|
*/
|
|
587
|
-
function
|
|
588
|
-
const lang =
|
|
589
|
-
const icons =
|
|
557
|
+
function CreateModalForm($, params, relList) {
|
|
558
|
+
const lang = $.lang;
|
|
559
|
+
const icons = $.icons;
|
|
590
560
|
const textDisplayShow = params.textToDisplay ? '' : 'style="display: none;"';
|
|
591
561
|
const titleShow = params.title ? '' : 'style="display: none;"';
|
|
592
562
|
|
|
@@ -595,7 +565,7 @@ function CreatetModalForm(editor, params, relList) {
|
|
|
595
565
|
<div class="se-modal-form">
|
|
596
566
|
<label>${lang.link_modal_url}</label>
|
|
597
567
|
<div class="se-modal-form-files">
|
|
598
|
-
<input data-focus class="se-input-form se-input-url" type="text" placeholder="${
|
|
568
|
+
<input data-focus class="se-input-form se-input-url" type="text" placeholder="${$.options.get('defaultUrlProtocol') || ''}" />
|
|
599
569
|
${
|
|
600
570
|
params.enableFileUpload
|
|
601
571
|
? `<button type="button" class="se-btn se-tooltip se-modal-files-edge-button _se_upload_button" aria-label="${lang.fileUpload}">
|