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,191 +0,0 @@
|
|
|
1
|
-
import { env } from '../helper';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @typedef ApiManagerParams
|
|
5
|
-
* @property {string=} method - HTTP method (GET, POST, PUT, DELETE...)
|
|
6
|
-
* @property {string=} url - API's URL
|
|
7
|
-
* @property {Object<string, string>=} headers - HTTP headers
|
|
8
|
-
* @property {*=} data - API data
|
|
9
|
-
* @property {(xmlHttp: XMLHttpRequest) => boolean=} callBack - API success callback
|
|
10
|
-
* @property {(res: *, xmlHttp: XMLHttpRequest) => string=} errorCallBack - API fail callback
|
|
11
|
-
* @property {XMLHttpRequestResponseType=} responseType - XMLHttpRequest.responseType
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @class
|
|
16
|
-
* @description API Manager
|
|
17
|
-
*/
|
|
18
|
-
class ApiManager {
|
|
19
|
-
/**
|
|
20
|
-
* @constructor
|
|
21
|
-
* @param {*} inst The instance object that called the constructor.
|
|
22
|
-
* @param {ApiManagerParams=} params API options
|
|
23
|
-
*/
|
|
24
|
-
constructor(inst, params) {
|
|
25
|
-
/**
|
|
26
|
-
* @description Editor instance
|
|
27
|
-
* @type {__se__EditorCore}
|
|
28
|
-
*/
|
|
29
|
-
this.editor = inst.editor;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @description UI class
|
|
33
|
-
* @type {__se__EditorCore["ui"]}
|
|
34
|
-
*/
|
|
35
|
-
this.ui = this.editor.ui;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* @description Caller instance key name
|
|
39
|
-
* @type {string}
|
|
40
|
-
*/
|
|
41
|
-
this.kind = inst.constructor.key || inst.constructor.name;
|
|
42
|
-
|
|
43
|
-
// members
|
|
44
|
-
this._xhr = env.getXMLHttpRequest();
|
|
45
|
-
// members - option
|
|
46
|
-
this.method = params?.method;
|
|
47
|
-
this.url = params?.url;
|
|
48
|
-
this.headers = params?.headers;
|
|
49
|
-
this.data = params?.data;
|
|
50
|
-
this.callBack = params?.callBack;
|
|
51
|
-
this.errorCallBack = params?.errorCallBack;
|
|
52
|
-
this.responseType = params?.responseType;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* @description Call API
|
|
57
|
-
* @param {ApiManagerParams} params
|
|
58
|
-
*/
|
|
59
|
-
call({ method, url, headers, data, callBack, errorCallBack, responseType }) {
|
|
60
|
-
this.cancel();
|
|
61
|
-
|
|
62
|
-
method = method || this.method;
|
|
63
|
-
url = this._normalizeUrl(url || this.url);
|
|
64
|
-
headers = headers || this.headers;
|
|
65
|
-
data = data || this.data;
|
|
66
|
-
callBack = callBack || this.callBack;
|
|
67
|
-
errorCallBack = errorCallBack || this.errorCallBack;
|
|
68
|
-
responseType = responseType || this.responseType;
|
|
69
|
-
|
|
70
|
-
const xhr = this._xhr;
|
|
71
|
-
if (responseType) xhr.responseType = responseType;
|
|
72
|
-
xhr.onreadystatechange = CallBackApi.bind(this, xhr, callBack, errorCallBack);
|
|
73
|
-
xhr.open(method, url, true);
|
|
74
|
-
if (headers !== null && typeof headers === 'object' && Object.keys(headers).length > 0) {
|
|
75
|
-
for (const key in headers) {
|
|
76
|
-
xhr.setRequestHeader(key, headers[key]);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
xhr.send(data);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* @description Call Async API
|
|
85
|
-
* @param {Object} params
|
|
86
|
-
* @param {string=} params.method - HTTP method (GET, POST, PUT, DELETE...)
|
|
87
|
-
* @param {string=} params.url - API's URL
|
|
88
|
-
* @param {Object<string, string>=} params.headers - HTTP headers
|
|
89
|
-
* @param {*=} params.data - API data
|
|
90
|
-
* @param {XMLHttpRequestResponseType=} params.responseType - XMLHttpRequest.responseType
|
|
91
|
-
* @returns {Promise<XMLHttpRequest>}
|
|
92
|
-
*/
|
|
93
|
-
asyncCall({ method, url, headers, data, responseType }) {
|
|
94
|
-
this.cancel();
|
|
95
|
-
|
|
96
|
-
method = method || this.method;
|
|
97
|
-
url = this._normalizeUrl(url || this.url);
|
|
98
|
-
headers = headers || this.headers;
|
|
99
|
-
data = data || this.data;
|
|
100
|
-
responseType = responseType || this.responseType;
|
|
101
|
-
|
|
102
|
-
const xhr = this._xhr;
|
|
103
|
-
if (responseType) xhr.responseType = responseType;
|
|
104
|
-
|
|
105
|
-
return new Promise((resolve, reject) => {
|
|
106
|
-
xhr.open(method, url, true);
|
|
107
|
-
if (headers !== null && typeof headers === 'object' && Object.keys(headers).length > 0) {
|
|
108
|
-
for (const key in headers) {
|
|
109
|
-
xhr.setRequestHeader(key, headers[key]);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
xhr.onload = () => {
|
|
113
|
-
if (xhr.status === 200) {
|
|
114
|
-
try {
|
|
115
|
-
resolve(xhr);
|
|
116
|
-
} finally {
|
|
117
|
-
this.ui.hideLoading();
|
|
118
|
-
}
|
|
119
|
-
} else {
|
|
120
|
-
try {
|
|
121
|
-
const res = !xhr.responseText ? xhr : JSON.parse(xhr.responseText);
|
|
122
|
-
reject(res);
|
|
123
|
-
} finally {
|
|
124
|
-
this.ui.hideLoading();
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
xhr.onerror = () => {
|
|
130
|
-
reject(new Error('Network error'));
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
xhr.send(data);
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* @description Cancel API (xhr.abort())
|
|
139
|
-
*/
|
|
140
|
-
cancel() {
|
|
141
|
-
if (this._xhr) this._xhr.abort();
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* @private
|
|
146
|
-
* @description Remove unnecessary slashes in API URL.
|
|
147
|
-
* @param {string} url url
|
|
148
|
-
* @returns
|
|
149
|
-
*/
|
|
150
|
-
_normalizeUrl(url) {
|
|
151
|
-
return url.replace(/([^:])\/+/g, '$1/').replace(/\/(\?|#|$)/, '$1');
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* @description API callback
|
|
157
|
-
* @param {XMLHttpRequest} xmlHttp - XMLHttpRequest
|
|
158
|
-
* @param {(xmlHttp: XMLHttpRequest) => Promise<void>} callBack - Callback function
|
|
159
|
-
* @param {(res: *, xmlHttp: XMLHttpRequest) => Promise<string>} errorCallBack - Error callback function
|
|
160
|
-
*/
|
|
161
|
-
async function CallBackApi(xmlHttp, callBack, errorCallBack) {
|
|
162
|
-
if (xmlHttp.readyState === 4) {
|
|
163
|
-
if (xmlHttp.status === 200) {
|
|
164
|
-
try {
|
|
165
|
-
await callBack(xmlHttp);
|
|
166
|
-
} catch (error) {
|
|
167
|
-
throw Error(`[SUNEDITOR.ApiManager[${this.kind}].upload.callBack.fail] ${error.message}`);
|
|
168
|
-
} finally {
|
|
169
|
-
this.ui.hideLoading();
|
|
170
|
-
}
|
|
171
|
-
} else {
|
|
172
|
-
// exception
|
|
173
|
-
console.error(`[SUNEDITOR.ApiManager[${this.kind}].upload.serverException]`, xmlHttp);
|
|
174
|
-
try {
|
|
175
|
-
const res = !xmlHttp.responseText ? xmlHttp : JSON.parse(xmlHttp.responseText);
|
|
176
|
-
let message = '';
|
|
177
|
-
if (typeof errorCallBack === 'function') {
|
|
178
|
-
message = await errorCallBack(res, xmlHttp);
|
|
179
|
-
}
|
|
180
|
-
const err = `[SUNEDITOR.ApiManager[${this.kind}].upload.serverException] status: ${xmlHttp.status}, response: ${message || res.errorMessage || xmlHttp.responseText}`;
|
|
181
|
-
this.ui.alertOpen(err, 'error');
|
|
182
|
-
} catch (error) {
|
|
183
|
-
throw Error(`[SUNEDITOR.ApiManager[${this.kind}].upload.errorCallBack.fail] ${error.message}`);
|
|
184
|
-
} finally {
|
|
185
|
-
this.ui.hideLoading();
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
export default ApiManager;
|
|
@@ -1,474 +0,0 @@
|
|
|
1
|
-
import EditorInjector from '../editorInjector';
|
|
2
|
-
import { dom, env, keyCodeMap } from '../helper';
|
|
3
|
-
import { _DragHandle } from '../modules';
|
|
4
|
-
|
|
5
|
-
const { _w, ON_OVER_COMPONENT } = env;
|
|
6
|
-
const INDEX_00 = '2147483646';
|
|
7
|
-
const INDEX_0 = '2147483645';
|
|
8
|
-
const INDEX_S_1 = '2147483641';
|
|
9
|
-
const INDEX_1 = '2147483640';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @typedef {Object} ControllerInfo
|
|
13
|
-
* @property {*} inst The controller instance
|
|
14
|
-
* @property {string} [position="bottom"] The controller position ("bottom"|"top")
|
|
15
|
-
* @property {HTMLElement} [form=null] The controller element
|
|
16
|
-
* @property {HTMLElement|Range} [target=null] The controller target element
|
|
17
|
-
* @property {boolean} [notInCarrier=false] If the controller is not in the "carrierWrapper", set it to true.
|
|
18
|
-
* @property {boolean} [isRangeTarget=false] If the target is a Range, set it to true.
|
|
19
|
-
* @property {boolean} [fixed=false] If the controller is fixed and should not be closed, set it to true.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @typedef {Object} ControllerParams
|
|
24
|
-
* @property {"top"|"bottom"} [position="bottom"] Controller position
|
|
25
|
-
* @property {boolean=} [isWWTarget=true] If the controller is in the WYSIWYG area, set it to true.
|
|
26
|
-
* @property {() => void=} [initMethod=null] Method to be called when the controller is closed.
|
|
27
|
-
* @property {boolean=} [disabled=false] If true, When the "controller" is opened, buttons without the "se-component-enabled" class are disabled.
|
|
28
|
-
* @property {Array<HTMLElement>=} [parents=[]] The parent "controller" array when "controller" is opened nested.
|
|
29
|
-
* @property {boolean=} [parentsHide=false] If true, the parent element is hidden when the controller is opened.
|
|
30
|
-
* @property {HTMLElement=} [sibling=null] The related sibling controller element that this controller is positioned relative to.
|
|
31
|
-
* @property {"top"|"side"} [siblingPosition="top"] The relative position of this controller to the sibling element (e.g., display above or beside the sibling).
|
|
32
|
-
* @property {boolean=} [isInsideForm=false] If the controller is inside a form, set it to true.
|
|
33
|
-
* @property {boolean=} [isOutsideForm=false] If the controller is outside a form, set it to true.
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @class
|
|
38
|
-
* @description Controller module class that handles the UI and interaction logic for a specific editor controller element.
|
|
39
|
-
*/
|
|
40
|
-
class Controller extends EditorInjector {
|
|
41
|
-
/**
|
|
42
|
-
* @constructor
|
|
43
|
-
* @param {*} inst The instance object that called the constructor.
|
|
44
|
-
* @param {Node} element Controller element
|
|
45
|
-
* @param {ControllerParams} params Controller options
|
|
46
|
-
* @param {?string=} _name An optional name for the controller key.
|
|
47
|
-
*/
|
|
48
|
-
constructor(inst, element, params, _name) {
|
|
49
|
-
super(inst.editor);
|
|
50
|
-
|
|
51
|
-
// members
|
|
52
|
-
this.kind = _name || inst.constructor.key || inst.constructor.name;
|
|
53
|
-
this.inst = inst;
|
|
54
|
-
this.form = /** @type {HTMLFormElement} */ (element);
|
|
55
|
-
this.isOpen = false;
|
|
56
|
-
this.currentTarget = null;
|
|
57
|
-
this.currentPositionTarget = null;
|
|
58
|
-
this.isWWTarget = params.isWWTarget ?? true;
|
|
59
|
-
this.position = params.position || 'bottom';
|
|
60
|
-
this.disabled = !!params.disabled;
|
|
61
|
-
this.parents = /** @type {Array<HTMLElement>} */ (params.parents || []);
|
|
62
|
-
this.parentsHide = !!params.parentsHide;
|
|
63
|
-
this.sibling = /** @type {HTMLElement} */ (params.sibling || null);
|
|
64
|
-
this.siblingPosition = ['top', 'side'].includes(params.siblingPosition) ? params.siblingPosition : 'top';
|
|
65
|
-
this.isInsideForm = !!params.isInsideForm;
|
|
66
|
-
this.isOutsideForm = !!params.isOutsideForm;
|
|
67
|
-
this.toTop = false;
|
|
68
|
-
this._reserveIndex = false;
|
|
69
|
-
this._initMethod = typeof params.initMethod === 'function' ? params.initMethod : null;
|
|
70
|
-
this.__globalEventHandlers = { keydown: this.#CloseListener_keydown.bind(this), mousedown: this.#CloseListener_mousedown.bind(this) };
|
|
71
|
-
this._bindClose_key = null;
|
|
72
|
-
this._bindClose_mouse = null;
|
|
73
|
-
/** @type {{left?: number, top?: number, addOfffset?: {left?: number, top?: number}}} */
|
|
74
|
-
this.__offset = {};
|
|
75
|
-
this.__addOffset = { left: 0, top: 0 };
|
|
76
|
-
this.__shadowRootEventForm = null;
|
|
77
|
-
this.__shadowRootEventListener = null;
|
|
78
|
-
|
|
79
|
-
// add element
|
|
80
|
-
this.carrierWrapper.appendChild(element);
|
|
81
|
-
|
|
82
|
-
// init
|
|
83
|
-
this.eventManager.addEvent(element, 'click', this.#Action.bind(this));
|
|
84
|
-
this.eventManager.addEvent(element, 'mouseenter', this.#MouseEnter.bind(this));
|
|
85
|
-
this.eventManager.addEvent(element, 'mouseleave', this.#MouseLeave.bind(this));
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* @description Open a modal plugin
|
|
90
|
-
* @param {Node|Range} target Target element
|
|
91
|
-
* @param {Node} [positionTarget] Position target element
|
|
92
|
-
* @param {Object} [params={}] params
|
|
93
|
-
* @param {boolean=} params.isWWTarget If the controller is in the WYSIWYG area, set it to true.
|
|
94
|
-
* @param {() => void=} params.initMethod Method to be called when the controller is closed.
|
|
95
|
-
* @param {boolean=} params.disabled If true, When the "controller" is opened, buttons without the "se-component-enabled" class are disabled. (default: this.disabled)
|
|
96
|
-
* @param {{left?: number, top?: number}=} params.addOffset Additional offset values
|
|
97
|
-
*/
|
|
98
|
-
open(target, positionTarget, { isWWTarget, initMethod, disabled, addOffset } = {}) {
|
|
99
|
-
if (_DragHandle.get('__overInfo') === ON_OVER_COMPONENT) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (!target) {
|
|
104
|
-
console.warn('[SUNEDITOR.Controller.open.fail] The target element is required.');
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (this.editor.isBalloon) this.toolbar.hide();
|
|
109
|
-
else if (this.editor.isSubBalloon) this.subToolbar.hide();
|
|
110
|
-
|
|
111
|
-
if (!this.status.hasFocus) {
|
|
112
|
-
if (disabled ?? this.disabled) {
|
|
113
|
-
this.ui.setControllerOnDisabledButtons(true);
|
|
114
|
-
} else {
|
|
115
|
-
this.ui.setControllerOnDisabledButtons(false);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
this.currentPositionTarget = positionTarget || target;
|
|
120
|
-
this.isWWTarget = isWWTarget ?? this.isWWTarget;
|
|
121
|
-
if (typeof initMethod === 'function') this._initMethod = initMethod;
|
|
122
|
-
this.editor.currentControllerName = this.kind;
|
|
123
|
-
|
|
124
|
-
this.__addOffset = { left: 0, top: 0 };
|
|
125
|
-
if (addOffset) this.__addOffset = { ...this.__addOffset, ...addOffset };
|
|
126
|
-
|
|
127
|
-
const parents = this.isOutsideForm ? this.parents : [];
|
|
128
|
-
this.editor.opendControllers?.forEach((e) => {
|
|
129
|
-
if (!parents.includes(e.form)) e.form.style.zIndex = INDEX_1;
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
if (this.parentsHide) {
|
|
133
|
-
this.parents.forEach((e) => {
|
|
134
|
-
e.style.display = 'none';
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
this.__addGlobalEvent();
|
|
139
|
-
|
|
140
|
-
// add sibling offset
|
|
141
|
-
if (this.sibling) {
|
|
142
|
-
if (this.siblingPosition === 'top') {
|
|
143
|
-
this.__addOffset.top += -this.sibling.offsetHeight + 1;
|
|
144
|
-
} else {
|
|
145
|
-
this.__addOffset.left += this.form.offsetWidth + this.sibling.offsetWidth - 1;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
// display controller
|
|
149
|
-
this._setControllerPosition(this.form, this.currentPositionTarget, false);
|
|
150
|
-
|
|
151
|
-
const isRangeTarget = target instanceof Range;
|
|
152
|
-
this.currentTarget = isRangeTarget ? null : target;
|
|
153
|
-
this._controllerOn(this.form, target, isRangeTarget);
|
|
154
|
-
this._w.setTimeout(() => _DragHandle.set('__overInfo', false), 0);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* @description Close a modal plugin
|
|
159
|
-
* - The plugin's "init" method is called.
|
|
160
|
-
* @param {boolean=} force If true, parent controllers are forcibly closed.
|
|
161
|
-
*/
|
|
162
|
-
close(force) {
|
|
163
|
-
if (!this.isOpen) return;
|
|
164
|
-
|
|
165
|
-
this.toTop = false;
|
|
166
|
-
this.isOpen = false;
|
|
167
|
-
this.__offset = {};
|
|
168
|
-
this.__addOffset = { left: 0, top: 0 };
|
|
169
|
-
|
|
170
|
-
this.__removeGlobalEvent();
|
|
171
|
-
|
|
172
|
-
if (typeof this._initMethod === 'function') this._initMethod();
|
|
173
|
-
this._controllerOff();
|
|
174
|
-
|
|
175
|
-
if (this.parentsHide && !force) {
|
|
176
|
-
this.parents.forEach((e) => {
|
|
177
|
-
e.style.display = 'block';
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (this.parents.length > 0) return;
|
|
182
|
-
if (typeof this.inst.close === 'function') this.inst.close();
|
|
183
|
-
this.component.deselect();
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* @description Hide controller
|
|
188
|
-
*/
|
|
189
|
-
hide() {
|
|
190
|
-
this.form.style.display = 'none';
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* @description Show controller
|
|
195
|
-
*/
|
|
196
|
-
show() {
|
|
197
|
-
this._setControllerPosition(this.form, this.currentPositionTarget, false);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* @description Sets whether the element (form) should be brought to the top based on z-index.
|
|
202
|
-
* @param {boolean} value - true: '2147483646', false: '2147483645'.
|
|
203
|
-
*/
|
|
204
|
-
bringToTop(value) {
|
|
205
|
-
this.toTop = value;
|
|
206
|
-
this.form.style.zIndex = value ? INDEX_00 : INDEX_0;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* @description Reset controller position
|
|
211
|
-
* @param {Node=} target
|
|
212
|
-
*/
|
|
213
|
-
resetPosition(target) {
|
|
214
|
-
this._setControllerPosition(this.form, target || this.currentPositionTarget, true);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* @private
|
|
219
|
-
* @description Show controller at editor area (controller elements, function, "controller target element(@Required)", "controller name(@Required)", etc..)
|
|
220
|
-
* @param {HTMLFormElement} form Controller element
|
|
221
|
-
* @param {Node|Range} target Controller target element
|
|
222
|
-
* @param {boolean} isRangeTarget If the target is a Range, set it to true.
|
|
223
|
-
*/
|
|
224
|
-
async _controllerOn(form, target, isRangeTarget) {
|
|
225
|
-
/** @type {ControllerInfo} */
|
|
226
|
-
const info = {
|
|
227
|
-
position: this.position,
|
|
228
|
-
inst: this,
|
|
229
|
-
form: /** @type {HTMLElement} */ (form),
|
|
230
|
-
target: /** @type {HTMLElement} */ (target),
|
|
231
|
-
isRangeTarget,
|
|
232
|
-
notInCarrier: !this.carrierWrapper.contains(form)
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
if ((await this.triggerEvent('onBeforeShowController', { caller: this.kind, frameContext: this.editor.frameContext, info })) === false) return;
|
|
236
|
-
|
|
237
|
-
form.style.display = 'block';
|
|
238
|
-
if (this.editor._shadowRoot) {
|
|
239
|
-
this.__shadowRootEventForm = form;
|
|
240
|
-
this.__shadowRootEventListener = (e) => e.stopPropagation();
|
|
241
|
-
form.addEventListener('mousedown', this.__shadowRootEventListener);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
this.editor._controllerTargetContext = this.editor.frameContext.get('topArea');
|
|
245
|
-
|
|
246
|
-
if (!this.isOpen) {
|
|
247
|
-
this.editor.opendControllers.push(info);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
this.isOpen = true;
|
|
251
|
-
this.editor._preventBlur = true;
|
|
252
|
-
this.editor.status.onSelected = true;
|
|
253
|
-
this.triggerEvent('onShowController', { caller: this.kind, frameContext: this.editor.frameContext, info });
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* @private
|
|
258
|
-
* @description Hide controller at editor area (link button, image resize button..)
|
|
259
|
-
*/
|
|
260
|
-
_controllerOff() {
|
|
261
|
-
this.form.style.display = 'none';
|
|
262
|
-
this.editor.opendControllers = this.editor.opendControllers.filter((v) => v.form !== this.form);
|
|
263
|
-
if (this.editor.currentControllerName !== this.kind && this.editor.opendControllers.length > 0) return;
|
|
264
|
-
|
|
265
|
-
this.ui.setControllerOnDisabledButtons(false);
|
|
266
|
-
|
|
267
|
-
this.editor.frameContext.get('lineBreaker_t').style.display = this.editor.frameContext.get('lineBreaker_b').style.display = 'none';
|
|
268
|
-
this.editor.effectNode = null;
|
|
269
|
-
this.editor.currentControllerName = '';
|
|
270
|
-
this.editor._preventBlur = false;
|
|
271
|
-
this.editor._controllerTargetContext = null;
|
|
272
|
-
_w.setTimeout(() => {
|
|
273
|
-
this.editor.status.onSelected = false;
|
|
274
|
-
}, 0);
|
|
275
|
-
if (this.__shadowRootEventForm) {
|
|
276
|
-
this.__shadowRootEventForm.removeEventListener('mousedown', this.__shadowRootEventListener);
|
|
277
|
-
this.__shadowRootEventForm = this.__shadowRootEventListener = null;
|
|
278
|
-
}
|
|
279
|
-
if (typeof this.inst.reset === 'function') this.inst.reset();
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* @private
|
|
284
|
-
* @description Specify the position of the controller.
|
|
285
|
-
* @param {HTMLElement} controller Controller element.
|
|
286
|
-
* @param {Node|Range} refer Element or Range that is the basis of the controller's position.
|
|
287
|
-
* @param {boolean} [skipAutoReposition=false] If true, skips scroll/resize-based automatic positioning logic.
|
|
288
|
-
*/
|
|
289
|
-
_setControllerPosition(controller, refer, skipAutoReposition) {
|
|
290
|
-
controller.style.visibility = 'hidden';
|
|
291
|
-
controller.style.display = 'block';
|
|
292
|
-
|
|
293
|
-
if (this.selection.isRange(refer)) {
|
|
294
|
-
if (!this.offset.setRangePosition(this.form, /** @type {Range} */ (refer), { position: 'bottom' })) {
|
|
295
|
-
this.hide();
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
|
-
} else {
|
|
299
|
-
if (refer) {
|
|
300
|
-
const positionResult = this.offset.setAbsPosition(controller, /** @type {HTMLElement} */ (refer), { addOffset: this.__addOffset, position: this.position, isWWTarget: this.isWWTarget, inst: this });
|
|
301
|
-
if (!positionResult) {
|
|
302
|
-
this.hide();
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
if (!skipAutoReposition && this.sibling && this.siblingPosition === 'top' && positionResult.position !== this.position) {
|
|
307
|
-
const resetPosition = controller.offsetTop - this.__addOffset.top;
|
|
308
|
-
if (positionResult.position === 'bottom') {
|
|
309
|
-
this._reserveIndex = true;
|
|
310
|
-
controller.style.top = resetPosition + this.sibling.offsetHeight - 2 + 'px';
|
|
311
|
-
} else {
|
|
312
|
-
controller.style.top = resetPosition - this.sibling.offsetHeight + 2 + 'px';
|
|
313
|
-
}
|
|
314
|
-
} else {
|
|
315
|
-
this._reserveIndex = false;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
controller.style.zIndex = this.toTop ? INDEX_0 : this._reserveIndex ? INDEX_S_1 : INDEX_1;
|
|
321
|
-
controller.style.visibility = '';
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* @private
|
|
326
|
-
* @description Adds global event listeners.
|
|
327
|
-
* - When the controller is opened
|
|
328
|
-
*/
|
|
329
|
-
__addGlobalEvent() {
|
|
330
|
-
this.__removeGlobalEvent();
|
|
331
|
-
this._bindClose_key = this.eventManager.addGlobalEvent('keydown', this.__globalEventHandlers.keydown, true);
|
|
332
|
-
this._bindClose_mouse = this.eventManager.addGlobalEvent('mousedown', this.__globalEventHandlers.mousedown, true);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* @private
|
|
337
|
-
* @description Removes global event listeners.
|
|
338
|
-
* - When the ESC key is pressed, the controller is closed.
|
|
339
|
-
*/
|
|
340
|
-
__removeGlobalEvent() {
|
|
341
|
-
this.component.__removeGlobalEvent();
|
|
342
|
-
if (this._bindClose_key) this._bindClose_key = this.eventManager.removeGlobalEvent(this._bindClose_key);
|
|
343
|
-
if (this._bindClose_mouse) this._bindClose_mouse = this.eventManager.removeGlobalEvent(this._bindClose_mouse);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* @private
|
|
348
|
-
* @description Checks if the controller is fixed and should not be closed.
|
|
349
|
-
* @returns {boolean} True if the controller is fixed.
|
|
350
|
-
*/
|
|
351
|
-
_checkFixed() {
|
|
352
|
-
if (this.editor.selectMenuOn) return true;
|
|
353
|
-
|
|
354
|
-
const cont = this.editor.opendControllers;
|
|
355
|
-
for (let i = 0; i < cont.length; i++) {
|
|
356
|
-
if (cont[i].inst === this && cont[i].fixed) {
|
|
357
|
-
return true;
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
return false;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* @private
|
|
365
|
-
* @description Checks if the given target is within a form or controller.
|
|
366
|
-
* @param {Node} target The target element.
|
|
367
|
-
* @returns {boolean} True if the target is inside a form or controller.
|
|
368
|
-
*/
|
|
369
|
-
_checkForm(target) {
|
|
370
|
-
if (dom.check.isWysiwygFrame(target)) return false;
|
|
371
|
-
if (dom.utils.hasClass(target, 'se-drag-handle')) return true;
|
|
372
|
-
|
|
373
|
-
let isParentForm = false;
|
|
374
|
-
if (this.isInsideForm && this.parents?.length > 0) {
|
|
375
|
-
this.parents.some((e) => {
|
|
376
|
-
if (e.contains(target)) {
|
|
377
|
-
isParentForm = true;
|
|
378
|
-
return true;
|
|
379
|
-
}
|
|
380
|
-
});
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
return !isParentForm && (!!dom.query.getParentElement(target, '.se-controller') || target?.contains(this.inst._element));
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* @param {MouseEvent} e - Event object
|
|
388
|
-
*/
|
|
389
|
-
#Action(e) {
|
|
390
|
-
const eventTarget = dom.query.getEventTarget(e);
|
|
391
|
-
const target = dom.query.getCommandTarget(eventTarget);
|
|
392
|
-
if (!target) return;
|
|
393
|
-
|
|
394
|
-
e.stopPropagation();
|
|
395
|
-
e.preventDefault();
|
|
396
|
-
|
|
397
|
-
this.inst.controllerAction(target);
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
/**
|
|
401
|
-
* @param {MouseEvent} e - Event object
|
|
402
|
-
*/
|
|
403
|
-
#MouseEnter(e) {
|
|
404
|
-
this.editor.currentControllerName = this.kind;
|
|
405
|
-
if (this.parents.length > 0 && this.isInsideForm) return;
|
|
406
|
-
|
|
407
|
-
const eventTarget = dom.query.getEventTarget(e);
|
|
408
|
-
eventTarget.style.zIndex = this.toTop ? INDEX_00 : INDEX_0;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* @param {MouseEvent} e - Event object
|
|
413
|
-
*/
|
|
414
|
-
#MouseLeave(e) {
|
|
415
|
-
if (this.parents.length > 0 && this.isInsideForm) return;
|
|
416
|
-
|
|
417
|
-
const eventTarget = dom.query.getEventTarget(e);
|
|
418
|
-
eventTarget.style.zIndex = this.toTop ? INDEX_0 : this._reserveIndex ? INDEX_S_1 : INDEX_1;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
/**
|
|
422
|
-
* @param {KeyboardEvent} e - Event object
|
|
423
|
-
*/
|
|
424
|
-
#CloseListener_keydown(e) {
|
|
425
|
-
if (this._checkFixed()) return;
|
|
426
|
-
const keyCode = e.code;
|
|
427
|
-
const ctrl = keyCodeMap.isCtrl(e);
|
|
428
|
-
if (ctrl || !keyCodeMap.isNonResponseKey(keyCode)) return;
|
|
429
|
-
|
|
430
|
-
const eventTarget = dom.query.getEventTarget(e);
|
|
431
|
-
if (this.form.contains(eventTarget) || this._checkForm(eventTarget)) return;
|
|
432
|
-
if (this.editor._fileManager.pluginRegExp.test(this.kind) && !keyCodeMap.isEsc(keyCode)) return;
|
|
433
|
-
|
|
434
|
-
this.#PostCloseEvent(eventTarget);
|
|
435
|
-
this.close();
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
/**
|
|
439
|
-
* @param {KeyboardEvent} e - Event object
|
|
440
|
-
*/
|
|
441
|
-
#CloseListener_mousedown(e) {
|
|
442
|
-
const eventTarget = dom.query.getEventTarget(e);
|
|
443
|
-
if (this.inst?._element?.contains(eventTarget)) {
|
|
444
|
-
this.isOpen = false;
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
this.isOpen = true;
|
|
449
|
-
if (
|
|
450
|
-
eventTarget === this.inst._element ||
|
|
451
|
-
eventTarget === this.currentTarget ||
|
|
452
|
-
this._checkFixed() ||
|
|
453
|
-
this.form.contains(eventTarget) ||
|
|
454
|
-
this._checkForm(eventTarget) ||
|
|
455
|
-
dom.query.getParentElement(eventTarget, '.se-line-breaker-component')
|
|
456
|
-
) {
|
|
457
|
-
return;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
this.#PostCloseEvent(eventTarget);
|
|
461
|
-
this.close(true);
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
/**
|
|
465
|
-
* @param {HTMLElement} eventTarget - The target element that triggered the event.
|
|
466
|
-
*/
|
|
467
|
-
#PostCloseEvent(eventTarget) {
|
|
468
|
-
if (!this.editor.frameContext.get('wysiwyg').contains(eventTarget)) {
|
|
469
|
-
this.component.__prevent = false;
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
export default Controller;
|