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
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import common from './effects/common.registry';
|
|
2
|
+
import keydown from './effects/keydown.registry';
|
|
3
|
+
|
|
4
|
+
const HALT = 'action.stop';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {import('./actions').Action[]} EventActions
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @description Execute actions sequentially by dispatching each action to its corresponding effect handler.
|
|
12
|
+
* Stops execution early if a HALT action is encountered or if any effect returns `false`.
|
|
13
|
+
* @param {EventActions} actions - Array of actions to execute
|
|
14
|
+
* @param {*} effContext - Effect context containing ports, ctx, and event
|
|
15
|
+
* @returns {Promise<false|undefined>} Returns `false` if execution was halted, `undefined` if all actions completed.
|
|
16
|
+
*/
|
|
17
|
+
export async function actionExecutor(actions, effContext) {
|
|
18
|
+
const effects = { ...common, ...keydown };
|
|
19
|
+
for (const a of actions) {
|
|
20
|
+
if (a.t === HALT) return false;
|
|
21
|
+
const eff = effects[a.t];
|
|
22
|
+
if (eff) {
|
|
23
|
+
const r = await eff(effContext, a.p);
|
|
24
|
+
if (r === false) return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { dom, env } from '../../../helper';
|
|
2
2
|
|
|
3
|
-
const { isMobile } = env;
|
|
3
|
+
const { isMobile, _w } = env;
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* @typedef {
|
|
6
|
+
* @typedef {import('../eventOrchestrator').default} EventManagerThis_handler_toolbar
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* @private
|
|
11
10
|
* @this {EventManagerThis_handler_toolbar}
|
|
12
11
|
* @param {MouseEvent} e - Event object
|
|
13
12
|
*/
|
|
@@ -15,21 +14,21 @@ export function ButtonsHandler(e) {
|
|
|
15
14
|
const eventTarget = dom.query.getEventTarget(e);
|
|
16
15
|
let target = eventTarget;
|
|
17
16
|
|
|
18
|
-
if (this.
|
|
17
|
+
if (this.$.store.mode.isBalloon && !this.$.context.get('toolbar_sub_main')?.contains(target)) {
|
|
19
18
|
this._hideToolbar_sub();
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
const isInput = dom.check.isInputElement(target);
|
|
23
22
|
|
|
24
23
|
if (isInput) {
|
|
25
|
-
this.
|
|
26
|
-
} else if (!this
|
|
27
|
-
this.
|
|
24
|
+
this.$.store.set('_preventBlur', false);
|
|
25
|
+
} else if (!this.$.frameContext.get('wysiwyg').contains(this.$.selection.getNode())) {
|
|
26
|
+
this.$.focusManager.focus();
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
if (dom.query.getParentElement(target, '.se-dropdown')) {
|
|
31
30
|
e.stopPropagation();
|
|
32
|
-
this.
|
|
31
|
+
this.$.ui.preventToolbarHide(true);
|
|
33
32
|
} else {
|
|
34
33
|
let command = target.getAttribute('data-command');
|
|
35
34
|
let className = target.className;
|
|
@@ -42,26 +41,28 @@ export function ButtonsHandler(e) {
|
|
|
42
41
|
|
|
43
42
|
// toolbar input button
|
|
44
43
|
if (isInput && /^INPUT$/i.test(target?.getAttribute('data-type'))) {
|
|
45
|
-
this.
|
|
46
|
-
|
|
44
|
+
this.$.store.set('_preventBlur', true);
|
|
45
|
+
this._inputFocus = true;
|
|
46
|
+
if (!this.$.store.get('hasFocus')) this.applyTagEffect();
|
|
47
47
|
/* event */
|
|
48
48
|
if (!dom.check.isInputElement(eventTarget) || eventTarget.disabled) return;
|
|
49
49
|
|
|
50
|
-
const plugin = this
|
|
50
|
+
const plugin = this.$.plugins[command];
|
|
51
51
|
if (!plugin) return;
|
|
52
52
|
|
|
53
53
|
if (this.__inputBlurEvent) this.__removeInput();
|
|
54
54
|
|
|
55
55
|
// blur event
|
|
56
|
-
if (typeof plugin.
|
|
57
|
-
this.__inputBlurEvent = this.addEvent(eventTarget, 'blur', (ev) => {
|
|
56
|
+
if (typeof plugin.toolbarInputChange === 'function') this.__inputPlugin = { obj: plugin, target: eventTarget, value: eventTarget.value };
|
|
57
|
+
this.__inputBlurEvent = this.$.eventManager.addEvent(eventTarget, 'blur', (ev) => {
|
|
58
58
|
if (plugin.isInputActive) return;
|
|
59
59
|
|
|
60
60
|
try {
|
|
61
61
|
const value = eventTarget.value.trim();
|
|
62
|
-
if (typeof plugin.
|
|
62
|
+
if (typeof plugin.toolbarInputChange === 'function' && value !== this.__inputPlugin.value) plugin.toolbarInputChange({ target: eventTarget, value, event: ev });
|
|
63
63
|
} finally {
|
|
64
|
-
|
|
64
|
+
// Defer flag reset — wysiwyg focus event fires synchronously during blur and checks this flag
|
|
65
|
+
_w.setTimeout(() => (this._inputFocus = false), 0);
|
|
65
66
|
this.__removeInput();
|
|
66
67
|
}
|
|
67
68
|
});
|
|
@@ -69,38 +70,37 @@ export function ButtonsHandler(e) {
|
|
|
69
70
|
if (!plugin) return;
|
|
70
71
|
|
|
71
72
|
// keydown event
|
|
72
|
-
if (typeof plugin.
|
|
73
|
-
this.__inputKeyEvent = this.addEvent(eventTarget, 'keydown', (event) => {
|
|
74
|
-
plugin.
|
|
73
|
+
if (typeof plugin.toolbarInputKeyDown === 'function') {
|
|
74
|
+
this.__inputKeyEvent = this.$.eventManager.addEvent(eventTarget, 'keydown', (event) => {
|
|
75
|
+
plugin.toolbarInputKeyDown({ target: eventTarget, event });
|
|
75
76
|
});
|
|
76
77
|
}
|
|
77
78
|
} else if (this.__inputBlurEvent && this.__inputPlugin) {
|
|
78
79
|
const value = this.__inputPlugin.target.value.trim();
|
|
79
80
|
if (value !== this.__inputPlugin.value) {
|
|
80
|
-
this.__inputPlugin.obj.
|
|
81
|
+
this.__inputPlugin.obj.toolbarInputChange({ target: this.__inputPlugin.target, value, event: e });
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
this.__removeInput();
|
|
84
85
|
return;
|
|
85
|
-
} else if (!this
|
|
86
|
+
} else if (!this.$.frameContext.get('isCodeView')) {
|
|
86
87
|
if (isMobile) {
|
|
87
|
-
this.
|
|
88
|
+
this.$.store.set('_preventBlur', true);
|
|
88
89
|
} else {
|
|
89
90
|
e.preventDefault();
|
|
90
91
|
if (env.isGecko && command) {
|
|
91
|
-
this._injectActiveEvent(target);
|
|
92
|
+
this.$.eventManager._injectActiveEvent(target);
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
if (command === this
|
|
97
|
+
if (command === this.$.menu.currentDropdownName || command === this.$.menu.currentContainerName) {
|
|
97
98
|
e.stopPropagation();
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
/**
|
|
103
|
-
* @private
|
|
104
104
|
* @this {EventManagerThis_handler_toolbar}
|
|
105
105
|
* @param {MouseEvent} e - Event object
|
|
106
106
|
*/
|
|
@@ -113,11 +113,11 @@ export function OnClick_menuTray(e) {
|
|
|
113
113
|
let k = '';
|
|
114
114
|
while (t && !/se-menu-tray/.test(t.className) && !k) {
|
|
115
115
|
t = t.parentElement;
|
|
116
|
-
k = t
|
|
116
|
+
k = t?.getAttribute('data-key');
|
|
117
117
|
}
|
|
118
118
|
if (!k) return;
|
|
119
119
|
|
|
120
|
-
const plugin = this
|
|
120
|
+
const plugin = this.$.plugins[k];
|
|
121
121
|
if (!plugin || typeof plugin.action !== 'function') return;
|
|
122
122
|
|
|
123
123
|
e.stopPropagation();
|
|
@@ -125,11 +125,10 @@ export function OnClick_menuTray(e) {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
/**
|
|
128
|
-
* @private
|
|
129
128
|
* @this {EventManagerThis_handler_toolbar}
|
|
130
129
|
* @param {MouseEvent} e - Event object
|
|
131
130
|
*/
|
|
132
131
|
export function OnClick_toolbar(e) {
|
|
133
132
|
const eventTarget = dom.query.getEventTarget(e);
|
|
134
|
-
this.
|
|
133
|
+
this.$.commandDispatcher.runFromTarget(eventTarget);
|
|
135
134
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { env } from '../../../helper';
|
|
2
|
+
|
|
3
|
+
const { _w } = env;
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
|
-
* @typedef {
|
|
6
|
+
* @typedef {import('../eventOrchestrator').default} EventManagerThis_handler_ww_clipboard
|
|
3
7
|
*/
|
|
4
8
|
|
|
5
9
|
/**
|
|
6
|
-
* @private
|
|
7
10
|
* @this {EventManagerThis_handler_ww_clipboard}
|
|
8
11
|
* @param {ClipboardEvent} e - Event object
|
|
9
12
|
*/
|
|
@@ -14,7 +17,6 @@ export function OnPaste_wysiwyg(frameContext, e) {
|
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
/**
|
|
17
|
-
* @private
|
|
18
20
|
* @this {EventManagerThis_handler_ww_clipboard}
|
|
19
21
|
* @param {ClipboardEvent} e - Event object
|
|
20
22
|
*/
|
|
@@ -22,7 +24,7 @@ export async function OnCopy_wysiwyg(frameContext, e) {
|
|
|
22
24
|
const clipboardData = e.clipboardData;
|
|
23
25
|
|
|
24
26
|
// user event
|
|
25
|
-
if ((await this.triggerEvent('onCopy', { frameContext, event: e, clipboardData })) === false) {
|
|
27
|
+
if ((await this.$.eventManager.triggerEvent('onCopy', { frameContext, event: e, clipboardData })) === false) {
|
|
26
28
|
e.preventDefault();
|
|
27
29
|
e.stopPropagation();
|
|
28
30
|
return false;
|
|
@@ -33,7 +35,6 @@ export async function OnCopy_wysiwyg(frameContext, e) {
|
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
/**
|
|
36
|
-
* @private
|
|
37
38
|
* @this {EventManagerThis_handler_ww_clipboard}
|
|
38
39
|
* @param {ClipboardEvent} e - Event object
|
|
39
40
|
*/
|
|
@@ -41,7 +42,7 @@ export async function OnCut_wysiwyg(frameContext, e) {
|
|
|
41
42
|
const clipboardData = e.clipboardData;
|
|
42
43
|
|
|
43
44
|
// user event
|
|
44
|
-
if ((await this.triggerEvent('onCut', { frameContext, event: e, clipboardData })) === false) {
|
|
45
|
+
if ((await this.$.eventManager.triggerEvent('onCut', { frameContext, event: e, clipboardData })) === false) {
|
|
45
46
|
e.preventDefault();
|
|
46
47
|
e.stopPropagation();
|
|
47
48
|
return false;
|
|
@@ -50,7 +51,8 @@ export async function OnCut_wysiwyg(frameContext, e) {
|
|
|
50
51
|
const fcSelection = frameContext.get('_ww').getSelection();
|
|
51
52
|
this.__secopy = fcSelection.toString();
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
// Defer history snapshot — browser applies the cut to the DOM after the cut event returns
|
|
55
|
+
_w.setTimeout(() => {
|
|
56
|
+
this.$.history.push(false);
|
|
55
57
|
}, 0);
|
|
56
58
|
}
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { dom } from '../../../helper';
|
|
2
|
-
import { _DragHandle } from '../../../modules';
|
|
1
|
+
import { dom, env } from '../../../helper';
|
|
2
|
+
import { _DragHandle } from '../../../modules/ui';
|
|
3
|
+
|
|
4
|
+
const { _w } = env;
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
|
-
* @typedef {
|
|
7
|
+
* @typedef {import('../eventOrchestrator').default} EventManagerThis_handler_ww_dragDrop
|
|
6
8
|
*/
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
|
-
* @private
|
|
10
11
|
* @this {EventManagerThis_handler_ww_dragDrop}
|
|
11
|
-
* @param {
|
|
12
|
+
* @param {SunEditor.FrameContext} fc - Frame context object
|
|
12
13
|
* @param {HTMLElement} dragCursor - Drag cursor element
|
|
13
14
|
* @param {?HTMLElement} _iframeTopArea - Iframe top area element
|
|
14
15
|
* @param {?HTMLElement} _innerToolbar - Inner toolbar element
|
|
15
16
|
* @param {DragEvent} e - Event object
|
|
16
17
|
*/
|
|
17
18
|
export function OnDragOver_wysiwyg(fc, dragCursor, _iframeTopArea, _innerToolbar, e) {
|
|
18
|
-
const { sc, so, ec, eo } = this
|
|
19
|
+
const { sc, so, ec, eo } = this.$.selection.getDragEventLocationRange(e);
|
|
19
20
|
if (!sc) return;
|
|
20
21
|
|
|
21
22
|
e.preventDefault();
|
|
@@ -26,10 +27,10 @@ export function OnDragOver_wysiwyg(fc, dragCursor, _iframeTopArea, _innerToolbar
|
|
|
26
27
|
|
|
27
28
|
const _offset = { y: 0, x: 0 };
|
|
28
29
|
if (_iframeTopArea) {
|
|
29
|
-
const iframeOffset = this
|
|
30
|
-
const toolbarH = _innerToolbar ? this
|
|
31
|
-
_offset.y = iframeOffset.top + toolbarH -
|
|
32
|
-
_offset.x = iframeOffset.left -
|
|
30
|
+
const iframeOffset = this.$.offset.getGlobal(_iframeTopArea);
|
|
31
|
+
const toolbarH = _innerToolbar ? this.$.context.get('toolbar_main').offsetHeight : 0;
|
|
32
|
+
_offset.y = iframeOffset.top + toolbarH - _w.scrollY;
|
|
33
|
+
_offset.x = iframeOffset.left - _w.scrollX;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
const rect = cursorRange.getBoundingClientRect();
|
|
@@ -41,8 +42,8 @@ export function OnDragOver_wysiwyg(fc, dragCursor, _iframeTopArea, _innerToolbar
|
|
|
41
42
|
frameX = wwFrame.offsetLeft;
|
|
42
43
|
frameY = wwFrame.offsetTop;
|
|
43
44
|
}
|
|
44
|
-
dragCursor.style.left = `${rect.right +
|
|
45
|
-
dragCursor.style.top = `${rect.top +
|
|
45
|
+
dragCursor.style.left = `${rect.right + _w.scrollX + _offset.x + frameX}px`;
|
|
46
|
+
dragCursor.style.top = `${rect.top + _w.scrollY + _offset.y - 5 + frameY}px`;
|
|
46
47
|
dragCursor.style.height = `${rect.height + 10}px`;
|
|
47
48
|
dragCursor.style.display = 'block';
|
|
48
49
|
} else {
|
|
@@ -51,7 +52,6 @@ export function OnDragOver_wysiwyg(fc, dragCursor, _iframeTopArea, _innerToolbar
|
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
/**
|
|
54
|
-
* @private
|
|
55
55
|
* @this {EventManagerThis_handler_ww_dragDrop}
|
|
56
56
|
* @param {HTMLElement} dragCursor - Drag cursor element
|
|
57
57
|
*/
|
|
@@ -60,9 +60,8 @@ export function OnDragEnd_wysiwyg(dragCursor) {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
|
-
* @private
|
|
64
63
|
* @this {EventManagerThis_handler_ww_dragDrop}
|
|
65
|
-
* @param {
|
|
64
|
+
* @param {SunEditor.FrameContext} fc - Frame context object
|
|
66
65
|
* @param {HTMLElement} dragCursor - Drag cursor element
|
|
67
66
|
* @param {DragEvent} e - Event object
|
|
68
67
|
*/
|
|
@@ -77,7 +76,7 @@ export function OnDrop_wysiwyg(fc, dragCursor, e) {
|
|
|
77
76
|
const dataTransfer = e.dataTransfer;
|
|
78
77
|
if (!dataTransfer) return true;
|
|
79
78
|
|
|
80
|
-
const { sc, so, ec, eo } = this
|
|
79
|
+
const { sc, so, ec, eo } = this.$.selection.getDragEventLocationRange(e);
|
|
81
80
|
if (!sc) return;
|
|
82
81
|
|
|
83
82
|
if (dom.query.getParentElement(sc, '.se-disable-pointer')) {
|
|
@@ -88,17 +87,17 @@ export function OnDrop_wysiwyg(fc, dragCursor, e) {
|
|
|
88
87
|
if (_DragHandle.get('__dragContainer')) {
|
|
89
88
|
e.preventDefault();
|
|
90
89
|
if (_DragHandle.get('__dragContainer').contains(e.target)) {
|
|
91
|
-
this
|
|
90
|
+
this.$.component.deselect();
|
|
92
91
|
return;
|
|
93
92
|
}
|
|
94
93
|
|
|
95
94
|
const dragContainer = _DragHandle.get('__dragContainer');
|
|
96
|
-
this
|
|
97
|
-
this
|
|
98
|
-
this
|
|
95
|
+
this.$.component.deselect();
|
|
96
|
+
this.$.selection.setRange(sc, so, ec, eo);
|
|
97
|
+
this.$.html.insertNode(dragContainer, { afterNode: null, skipCharCount: true });
|
|
99
98
|
|
|
100
99
|
// document type page
|
|
101
|
-
if (fc.has('
|
|
100
|
+
if (fc.has('documentType_use_page')) {
|
|
102
101
|
fc.get('documentTypePageMirror').innerHTML = fc.get('wysiwyg').innerHTML;
|
|
103
102
|
fc.get('documentType').rePage(true);
|
|
104
103
|
}
|
|
@@ -106,8 +105,8 @@ export function OnDrop_wysiwyg(fc, dragCursor, e) {
|
|
|
106
105
|
return;
|
|
107
106
|
}
|
|
108
107
|
|
|
109
|
-
this
|
|
110
|
-
this
|
|
108
|
+
this.$.html.remove();
|
|
109
|
+
this.$.selection.setRange(sc, so, ec, eo);
|
|
111
110
|
return this._dataTransferAction('drop', e, dataTransfer, fc);
|
|
112
111
|
} finally {
|
|
113
112
|
dragCursor.style.display = 'none';
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { dom, keyCodeMap } from '../../../helper';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {import('../eventOrchestrator').default} EventManagerThis_handler_ww_input
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @this {EventManagerThis_handler_ww_input}
|
|
9
|
+
* @param {SunEditor.FrameContext} fc - Frame context object
|
|
10
|
+
* @param {InputEvent} e - Event object
|
|
11
|
+
*/
|
|
12
|
+
export async function OnBeforeInput_wysiwyg(fc, e) {
|
|
13
|
+
if (fc.get('isReadOnly') || fc.get('isDisabled')) {
|
|
14
|
+
e.preventDefault();
|
|
15
|
+
e.stopPropagation();
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const data = (e.data === null ? '' : e.data === undefined ? ' ' : e.data) || '';
|
|
20
|
+
if (!keyCodeMap.isComposing(e)) {
|
|
21
|
+
if (!this.$.char.test(data, false)) {
|
|
22
|
+
e.preventDefault();
|
|
23
|
+
e.stopPropagation();
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
this._handledInBefore = true;
|
|
27
|
+
} else {
|
|
28
|
+
this._handledInBefore = false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// user event
|
|
32
|
+
if ((await this.$.eventManager.triggerEvent('onBeforeInput', { frameContext: fc, event: e, data })) === false) return;
|
|
33
|
+
// plugin event
|
|
34
|
+
await this._callPluginEventAsync('onBeforeInput', { frameContext: fc, event: e, data });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @this {EventManagerThis_handler_ww_input}
|
|
39
|
+
* @param {SunEditor.FrameContext} fc - Frame context object
|
|
40
|
+
* @param {InputEvent} e - Event object
|
|
41
|
+
*/
|
|
42
|
+
export async function OnInput_wysiwyg(fc, e) {
|
|
43
|
+
if (fc.get('isReadOnly') || fc.get('isDisabled')) {
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
e.stopPropagation();
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const range = this.$.selection.getRange();
|
|
50
|
+
const selectionNode = this.$.selection.getNode();
|
|
51
|
+
const formatEl = this.$.format.getLine(selectionNode, null);
|
|
52
|
+
if (!this.$.format.isNormalLine(formatEl) && !this.$.format.isBrLine(formatEl) && range.collapsed && !this.$.component.is(selectionNode) && !dom.check.isList(selectionNode)) {
|
|
53
|
+
const rangeEl = this.$.format.getBlock(selectionNode, null);
|
|
54
|
+
this._setDefaultLine(this.$.format.isBlock(rangeEl) ? 'DIV' : this.$.options.get('defaultLine'));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
this.$.selection.init();
|
|
58
|
+
|
|
59
|
+
const data = (e.data === null ? '' : e.data === undefined ? ' ' : e.data) || '';
|
|
60
|
+
if (!this._handledInBefore) {
|
|
61
|
+
if (!this.$.char.test(data, true)) {
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
e.stopPropagation();
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
this._handledInBefore = false;
|
|
68
|
+
|
|
69
|
+
// user event
|
|
70
|
+
if ((await this.$.eventManager.triggerEvent('onInput', { frameContext: fc, event: e, data })) === false) return;
|
|
71
|
+
// plugin event
|
|
72
|
+
await this._callPluginEventAsync('onInput', { frameContext: fc, event: e, data });
|
|
73
|
+
|
|
74
|
+
this.$.history.push(true);
|
|
75
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { dom, env, unicode, keyCodeMap } from '../../../helper';
|
|
2
|
+
import { actionExecutor } from '../executor';
|
|
3
|
+
import { makePorts } from '../ports';
|
|
4
|
+
import { reduceKeydown } from '../reducers/keydown.reducer';
|
|
5
|
+
|
|
6
|
+
const { _w } = env;
|
|
7
|
+
const FRONT_ZEROWIDTH = new RegExp(unicode.zeroWidthSpace + '+', '');
|
|
8
|
+
|
|
9
|
+
const keyState = {
|
|
10
|
+
ctrl: false,
|
|
11
|
+
alt: false,
|
|
12
|
+
};
|
|
13
|
+
const _styleNodes = Object.preventExtensions({ value: [] });
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {import('../eventOrchestrator').default} EventManagerThis_handler_ww_key_input
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @this {EventManagerThis_handler_ww_key_input}
|
|
21
|
+
* @param {SunEditor.FrameContext} fc - Frame context object
|
|
22
|
+
* @param {KeyboardEvent} e - Event object
|
|
23
|
+
*/
|
|
24
|
+
export async function OnKeyDown_wysiwyg(fc, e) {
|
|
25
|
+
if ((this.isComposing = keyCodeMap.isComposing(e))) return true;
|
|
26
|
+
if (this.$.ui.selectMenuOn || !e.isTrusted) return;
|
|
27
|
+
|
|
28
|
+
let selectionNode = this.$.selection.getNode();
|
|
29
|
+
if (dom.check.isInputElement(selectionNode)) return;
|
|
30
|
+
if (this.$.menu.currentDropdownName) return;
|
|
31
|
+
|
|
32
|
+
const keyCode = e.code;
|
|
33
|
+
const shift = keyCodeMap.isShift(e);
|
|
34
|
+
const ctrl = (keyState.ctrl = keyCodeMap.isCtrl(e));
|
|
35
|
+
const alt = (keyState.alt = keyCodeMap.isAlt(e));
|
|
36
|
+
|
|
37
|
+
if (!ctrl && fc.get('isReadOnly') && !keyCodeMap.isDirectionKey(keyCode)) {
|
|
38
|
+
e.preventDefault();
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
this.$.menu.dropdownOff();
|
|
43
|
+
|
|
44
|
+
if (this.$.store.mode.isBalloon) {
|
|
45
|
+
this._hideToolbar();
|
|
46
|
+
} else if (this.$.store.mode.isSubBalloon) {
|
|
47
|
+
this._hideToolbar_sub();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// user event
|
|
51
|
+
if ((await this.$.eventManager.triggerEvent('onKeyDown', { frameContext: fc, event: e })) === false) return;
|
|
52
|
+
|
|
53
|
+
/** default key action */
|
|
54
|
+
if (keyCodeMap.isEnter(keyCode) && this.$.format.isLine(this.$.selection.getRange()?.startContainer)) {
|
|
55
|
+
this.$.selection.resetRangeToTextNode();
|
|
56
|
+
selectionNode = this.$.selection.getNode();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const range = this.$.selection.getRange();
|
|
60
|
+
const formatEl = /** @type {HTMLElement} */ (this.$.format.getLine(selectionNode, null) || selectionNode);
|
|
61
|
+
|
|
62
|
+
/** Shortcuts */
|
|
63
|
+
if (ctrl && !keyCodeMap.isNonTextKey(keyCode) && this.$.shortcuts.command(e, ctrl, shift, keyCode, '', false, null, null)) {
|
|
64
|
+
this._onShortcutKey = true;
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
e.stopPropagation();
|
|
67
|
+
return false;
|
|
68
|
+
} else if (!ctrl && !keyCodeMap.isNonTextKey(keyCode) && this.$.format.isLine(formatEl) && range.collapsed && dom.check.isEdgePoint(range.startContainer, 0, 'front')) {
|
|
69
|
+
const keyword = /** @type {Text} */ (range.startContainer).substringData?.(0, range.startOffset);
|
|
70
|
+
if (keyword && this.$.shortcuts.command(e, false, shift, keyCode, keyword, true, formatEl, range)) {
|
|
71
|
+
this._onShortcutKey = true;
|
|
72
|
+
e.preventDefault();
|
|
73
|
+
e.stopPropagation();
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
} else if (this._onShortcutKey) {
|
|
77
|
+
this._onShortcutKey = false;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// plugin event
|
|
81
|
+
if ((await this._callPluginEventAsync('onKeyDown', { frameContext: fc, event: e, range, line: formatEl })) === false) return;
|
|
82
|
+
|
|
83
|
+
// reducer / actions
|
|
84
|
+
/** @type {import('../reducers/keydown.reducer').KeydownReducerCtx} */
|
|
85
|
+
const ctx = { e, fc, store: this.$.store, options: this.$.options, frameOptions: this.$.frameOptions, range, selectionNode, formatEl, keyCode, ctrl, alt, shift };
|
|
86
|
+
const ports = makePorts(this, { _styleNodes });
|
|
87
|
+
|
|
88
|
+
// action execute
|
|
89
|
+
const actions = await reduceKeydown(ports, ctx);
|
|
90
|
+
await actionExecutor(actions, { ports, ctx });
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @this {EventManagerThis_handler_ww_key_input}
|
|
95
|
+
* @param {SunEditor.FrameContext} fc - Frame context object
|
|
96
|
+
* @param {KeyboardEvent} e - Event object
|
|
97
|
+
*/
|
|
98
|
+
export async function OnKeyUp_wysiwyg(fc, e) {
|
|
99
|
+
if (this._onShortcutKey || this.$.menu.currentDropdownName) return;
|
|
100
|
+
|
|
101
|
+
const keyCode = e.code;
|
|
102
|
+
const ctrl = keyCodeMap.isCtrl(e);
|
|
103
|
+
const alt = keyCodeMap.isAlt(e);
|
|
104
|
+
|
|
105
|
+
if (ctrl) keyState.ctrl = false;
|
|
106
|
+
if (alt) keyState.alt = false;
|
|
107
|
+
|
|
108
|
+
if (fc.get('isReadOnly')) return;
|
|
109
|
+
|
|
110
|
+
const range = this.$.selection.getRange();
|
|
111
|
+
let selectionNode = this.$.selection.getNode();
|
|
112
|
+
|
|
113
|
+
if ((this.$.store.mode.isBalloon || this.$.store.mode.isSubBalloon) && (((this.$.store.mode.isBalloonAlways || this.$.store.mode.isSubBalloonAlways) && !keyCodeMap.isEsc(keyCode)) || !range.collapsed)) {
|
|
114
|
+
if (this.$.store.mode.isBalloonAlways || this.$.store.mode.isSubBalloonAlways) {
|
|
115
|
+
if (!keyCodeMap.isEsc(keyCode)) this._showToolbarBalloonDelay();
|
|
116
|
+
} else {
|
|
117
|
+
if (this.$.store.mode.isSubBalloon) this.$.subToolbar._showBalloon();
|
|
118
|
+
else this.$.toolbar._showBalloon();
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** when format tag deleted */
|
|
124
|
+
if (keyCodeMap.isBackspace(keyCode) && dom.check.isWysiwygFrame(selectionNode) && selectionNode.textContent === '' && selectionNode.children.length === 0) {
|
|
125
|
+
e.preventDefault();
|
|
126
|
+
e.stopPropagation();
|
|
127
|
+
|
|
128
|
+
selectionNode.innerHTML = '';
|
|
129
|
+
|
|
130
|
+
const currentNodeName = this.$.store.get('currentNodes')[0];
|
|
131
|
+
const oFormatTag = dom.utils.createElement(this.$.format.isLine(currentNodeName) && !dom.check.isListCell(currentNodeName) ? currentNodeName : this.$.options.get('defaultLine'), null, '<br>');
|
|
132
|
+
selectionNode.appendChild(oFormatTag);
|
|
133
|
+
this.$.selection.setRange(oFormatTag, 0, oFormatTag, 0);
|
|
134
|
+
this.applyTagEffect();
|
|
135
|
+
|
|
136
|
+
this.$.history.push(false);
|
|
137
|
+
|
|
138
|
+
// document type
|
|
139
|
+
if (fc.has('documentType_use_header')) {
|
|
140
|
+
if (keyCodeMap.isDocumentTypeObserverKey(keyCode)) {
|
|
141
|
+
fc.get('documentType').reHeader();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const formatEl = this.$.format.getLine(selectionNode, null);
|
|
149
|
+
const rangeEl = this.$.format.getBlock(selectionNode, null);
|
|
150
|
+
const attrs = this._formatAttrsTemp;
|
|
151
|
+
|
|
152
|
+
if (formatEl && attrs) {
|
|
153
|
+
for (let i = 0, len = attrs.length; i < len; i++) {
|
|
154
|
+
if (keyCodeMap.isEnter(keyCode) && /^id$/i.test(attrs[i].name)) {
|
|
155
|
+
formatEl.removeAttribute('id');
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
formatEl.setAttribute(attrs[i].name, attrs[i].value);
|
|
159
|
+
}
|
|
160
|
+
this._formatAttrsTemp = null;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (
|
|
164
|
+
!this.$.format.isNormalLine(formatEl) &&
|
|
165
|
+
!this.$.format.isBrLine(formatEl) &&
|
|
166
|
+
range.collapsed &&
|
|
167
|
+
!this.$.component.is(selectionNode) &&
|
|
168
|
+
!dom.check.isList(selectionNode) &&
|
|
169
|
+
this._setDefaultLine(this.$.format.isBlock(rangeEl) ? 'DIV' : this.$.options.get('defaultLine')) !== null
|
|
170
|
+
) {
|
|
171
|
+
selectionNode = this.$.selection.getNode();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const textKey = !keyState.ctrl && !keyState.alt && !keyCodeMap.isNonTextKey(keyCode);
|
|
175
|
+
if (textKey && selectionNode.nodeType === 3 && unicode.zeroWidthRegExp.test(selectionNode.textContent) && !(e.isComposing !== undefined ? e.isComposing : this.isComposing)) {
|
|
176
|
+
let so = range.startOffset,
|
|
177
|
+
eo = range.endOffset;
|
|
178
|
+
const frontZeroWidthCnt = (selectionNode.textContent.substring(0, eo).match(FRONT_ZEROWIDTH) || '').length;
|
|
179
|
+
so = range.startOffset - frontZeroWidthCnt;
|
|
180
|
+
eo = range.endOffset - frontZeroWidthCnt;
|
|
181
|
+
selectionNode.textContent = selectionNode.textContent.replace(unicode.zeroWidthRegExp, '');
|
|
182
|
+
this.$.selection.setRange(selectionNode, so < 0 ? 0 : so, selectionNode, eo < 0 ? 0 : eo);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (keyCodeMap.isRemoveKey(keyCode) && dom.check.isZeroWidth(formatEl?.textContent) && !formatEl.previousElementSibling && !dom.check.isListCell(formatEl)) {
|
|
186
|
+
const rsMode = this.$.options.get('retainStyleMode');
|
|
187
|
+
if (rsMode !== 'none' && _styleNodes.value?.length > 0) {
|
|
188
|
+
if (rsMode === 'repeat') {
|
|
189
|
+
if (this.__retainTimer) {
|
|
190
|
+
this.__retainTimer = _w.clearTimeout(this.__retainTimer);
|
|
191
|
+
this._clearRetainStyleNodes(formatEl);
|
|
192
|
+
} else {
|
|
193
|
+
// Timer as a "first press" flag — next keydown within the same tick clears and toggles to "remove" mode (repeat mode toggle)
|
|
194
|
+
this.__retainTimer = _w.setTimeout(() => {
|
|
195
|
+
this.__retainTimer = null;
|
|
196
|
+
}, 0);
|
|
197
|
+
this._retainStyleNodes(formatEl, _styleNodes.value);
|
|
198
|
+
}
|
|
199
|
+
} else {
|
|
200
|
+
this.__retainTimer = null;
|
|
201
|
+
this._retainStyleNodes(formatEl, _styleNodes.value);
|
|
202
|
+
}
|
|
203
|
+
} else {
|
|
204
|
+
this._clearRetainStyleNodes(formatEl);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// document type
|
|
209
|
+
if (fc.has('documentType_use_header')) {
|
|
210
|
+
if (keyCodeMap.isDocumentTypeObserverKey(keyCode)) {
|
|
211
|
+
fc.get('documentType').reHeader();
|
|
212
|
+
const el = dom.query.getParentElement(this.$.selection.selectionNode, this.$.format.isLine.bind(this.$.format));
|
|
213
|
+
fc.get('documentType').on(el);
|
|
214
|
+
} else {
|
|
215
|
+
const el = dom.query.getParentElement(selectionNode, (current) => current.nodeType === 1);
|
|
216
|
+
fc.get('documentType').onChangeText(el);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// user event
|
|
221
|
+
if ((await this.$.eventManager.triggerEvent('onKeyUp', { frameContext: fc, event: e })) === false) return;
|
|
222
|
+
// plugin event
|
|
223
|
+
if ((await this._callPluginEventAsync('onKeyUp', { frameContext: fc, event: e, range, line: formatEl })) === false) return;
|
|
224
|
+
|
|
225
|
+
if (keyCodeMap.isHistoryRelevantKey(keyCode)) {
|
|
226
|
+
this.$.history.push(true);
|
|
227
|
+
}
|
|
228
|
+
}
|