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,856 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Component class
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import CoreInjector from '../../editorInjector/_core';
|
|
6
|
-
import { dom, env, numbers, unicode, keyCodeMap, converter } from '../../helper';
|
|
7
|
-
import { Figure, _DragHandle } from '../../modules';
|
|
8
|
-
|
|
9
|
-
const { _w, ON_OVER_COMPONENT, isMobile } = env;
|
|
10
|
-
const DIR_KEYCODE = /^Arrow(Left|Up|Right|Down)$/;
|
|
11
|
-
const DIR_UP_KEYCODE = /^Arrow(Left|Up)$/;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @typedef {Omit<Component & Partial<__se__EditorInjector>, 'component'>} ComponentThis
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @constructor
|
|
19
|
-
* @this {ComponentThis}
|
|
20
|
-
* @description Class for managing components such as images and tables that are not in line format
|
|
21
|
-
* @param {__se__EditorCore} editor - The root editor instance
|
|
22
|
-
*/
|
|
23
|
-
function Component(editor) {
|
|
24
|
-
CoreInjector.call(this, editor);
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @description The current component information, used copy, cut, and keydown events
|
|
28
|
-
* @type {__se__ComponentInfo}
|
|
29
|
-
*/
|
|
30
|
-
this.info = null;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @description Component is selected
|
|
34
|
-
* @type {boolean}
|
|
35
|
-
*/
|
|
36
|
-
this.isSelected = false;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @description Currently selected component target
|
|
40
|
-
* @type {Node|null}
|
|
41
|
-
*/
|
|
42
|
-
this.currentTarget = null;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @description Currently selected component plugin instance
|
|
46
|
-
* @type {*}
|
|
47
|
-
*/
|
|
48
|
-
this.currentPlugin = null;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* @description Currently selected component plugin name
|
|
52
|
-
* @type {*}
|
|
53
|
-
*/
|
|
54
|
-
this.currentPluginName = '';
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* @description Currently selected component information
|
|
58
|
-
* @type {__se__ComponentInfo|null}
|
|
59
|
-
*/
|
|
60
|
-
this.currentInfo = null;
|
|
61
|
-
|
|
62
|
-
/** @type {Object<string, (...args: *) => *>} */
|
|
63
|
-
this.__globalEvents = {
|
|
64
|
-
copy: OnCopy_component.bind(this),
|
|
65
|
-
cut: OnCut_component.bind(this),
|
|
66
|
-
keydown: OnKeyDown_component.bind(this),
|
|
67
|
-
mousedown: CloseListener_mousedown.bind(this)
|
|
68
|
-
};
|
|
69
|
-
/** @type {__se__GlobalEventInfo|void} */
|
|
70
|
-
this._bindClose_copy = null;
|
|
71
|
-
/** @type {__se__GlobalEventInfo|void} */
|
|
72
|
-
this._bindClose_cut = null;
|
|
73
|
-
/** @type {__se__GlobalEventInfo|void} */
|
|
74
|
-
this._bindClose_keydown = null;
|
|
75
|
-
/** @type {__se__GlobalEventInfo|void} */
|
|
76
|
-
this._bindClose_mousedown = null;
|
|
77
|
-
/** @type {__se__GlobalEventInfo|void} */
|
|
78
|
-
this._bindClose_touchstart = null;
|
|
79
|
-
/** @type {boolean} */
|
|
80
|
-
this.__selectionSelected = false;
|
|
81
|
-
|
|
82
|
-
this.__prevent = false;
|
|
83
|
-
|
|
84
|
-
this.editor.applyFrameRoots((e) => {
|
|
85
|
-
// drag
|
|
86
|
-
const dragHandle = dom.utils.createElement('DIV', { class: 'se-drag-handle', draggable: 'true' }, this.icons.selection);
|
|
87
|
-
e.get('wrapper').appendChild(dragHandle);
|
|
88
|
-
this.eventManager.addEvent(dragHandle, 'mouseenter', OnDragEnter.bind(this));
|
|
89
|
-
this.eventManager.addEvent(dragHandle, 'mouseleave', OnDragLeave.bind(this));
|
|
90
|
-
this.eventManager.addEvent(dragHandle, 'dragstart', OnDragStart.bind(this));
|
|
91
|
-
this.eventManager.addEvent(dragHandle, 'dragend', OnDragEnd.bind(this));
|
|
92
|
-
this.eventManager.addEvent(dragHandle, 'click', OnDragClick.bind(this));
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
Component.prototype = {
|
|
97
|
-
/**
|
|
98
|
-
* @this {ComponentThis}
|
|
99
|
-
* @description Inserts an element and returns it. (Used for elements: table, hr, image, video)
|
|
100
|
-
* - If "element" is "HR", inserts and returns the new line.
|
|
101
|
-
* @param {Node} element Element to be inserted
|
|
102
|
-
* @param {Object} [options] Options
|
|
103
|
-
* @param {boolean} [options.skipCharCount=false] If true, it will be inserted even if "frameOptions.get('charCounter_max')" is exceeded.
|
|
104
|
-
* @param {boolean} [options.skipSelection=false] If true, do not automatically select the inserted component.
|
|
105
|
-
* @param {boolean} [options.skipHistory=false] If true, do not push to history.
|
|
106
|
-
* @returns {HTMLElement} The inserted element or new line (for HR)
|
|
107
|
-
*/
|
|
108
|
-
insert(element, { skipCharCount, skipSelection, skipHistory } = {}) {
|
|
109
|
-
if (this.editor.frameContext.get('isReadOnly') || (!skipCharCount && !this.char.check(element))) {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const r = this.html.remove();
|
|
114
|
-
const isInline = this.isInline(element);
|
|
115
|
-
this.selection.getRangeAndAddLine(this.selection.getRange(), r.container);
|
|
116
|
-
const selectionNode = this.selection.getNode();
|
|
117
|
-
let oNode = null;
|
|
118
|
-
let formatEl = this.format.getLine(selectionNode, null);
|
|
119
|
-
|
|
120
|
-
if (dom.check.isListCell(formatEl)) {
|
|
121
|
-
this.html.insertNode(element, { afterNode: isInline ? null : selectionNode === formatEl ? null : r.container.nextSibling, skipCharCount: true });
|
|
122
|
-
if (!isInline && !element.nextSibling) element.parentNode.appendChild(dom.utils.createElement('BR'));
|
|
123
|
-
} else {
|
|
124
|
-
if (!isInline && this.selection.getRange().collapsed && (r.container.nodeType === 3 || dom.check.isBreak(r.container))) {
|
|
125
|
-
const depthFormat = dom.query.getParentElement(r.container, this.format.isBlock.bind(this.format));
|
|
126
|
-
oNode = this.nodeTransform.split(r.container, r.offset, !depthFormat ? 0 : dom.query.getNodeDepth(depthFormat) + 1);
|
|
127
|
-
if (oNode) formatEl = /** @type {HTMLElement} */ (oNode.previousSibling);
|
|
128
|
-
}
|
|
129
|
-
this.html.insertNode(element, { afterNode: isInline ? null : this.format.isBlock(formatEl) ? null : formatEl, skipCharCount: true });
|
|
130
|
-
if (!isInline && formatEl && dom.check.isZeroWidth(formatEl)) dom.utils.removeItem(formatEl);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (isInline) {
|
|
134
|
-
const empty = dom.utils.createTextNode(unicode.zeroWidthSpace);
|
|
135
|
-
element.parentNode.insertBefore(empty, element.nextSibling);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (!skipHistory) this.history.push(false);
|
|
139
|
-
|
|
140
|
-
if (!skipSelection) {
|
|
141
|
-
this.selection.setRange(element, 0, element, 0);
|
|
142
|
-
const fileComponentInfo = this.get(element);
|
|
143
|
-
if (fileComponentInfo) {
|
|
144
|
-
this.select(fileComponentInfo.target, fileComponentInfo.pluginName);
|
|
145
|
-
} else if (oNode) {
|
|
146
|
-
oNode = dom.query.getEdgeChildNodes(oNode, null).sc || oNode;
|
|
147
|
-
this.selection.setRange(oNode, 0, oNode, 0);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// document type
|
|
152
|
-
if (this.editor.frameContext.has('documentType-use-header')) {
|
|
153
|
-
this.editor.frameContext.get('documentType').reHeader();
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return /** @type {HTMLElement} */ (oNode || element);
|
|
157
|
-
},
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* @this {ComponentThis}
|
|
161
|
-
* @description Gets the file component and that plugin name
|
|
162
|
-
* - return: {target, component, pluginName} | null
|
|
163
|
-
* @param {Node} element Target element (figure tag, component div, file tag)
|
|
164
|
-
* @returns {__se__ComponentInfo|null}
|
|
165
|
-
*/
|
|
166
|
-
get(element) {
|
|
167
|
-
if (!element) return null;
|
|
168
|
-
|
|
169
|
-
let target;
|
|
170
|
-
let pluginName = '';
|
|
171
|
-
let options = {};
|
|
172
|
-
let isFile = false;
|
|
173
|
-
let launcher = null;
|
|
174
|
-
|
|
175
|
-
if (this.is(element)) {
|
|
176
|
-
if (dom.utils.hasClass(element, 'se-component') && !dom.utils.hasClass(element, 'se-inline-component')) element = /** @type {HTMLElement} */ (element).firstElementChild || element;
|
|
177
|
-
if (/^FIGURE$/i.test(element.nodeName)) element = /** @type {HTMLElement} */ (element).firstElementChild;
|
|
178
|
-
if (!element) return null;
|
|
179
|
-
|
|
180
|
-
const comp = this.editor._componentManager.map((f) => f(element)).find((e) => e);
|
|
181
|
-
if (!comp) return null;
|
|
182
|
-
target = comp.target;
|
|
183
|
-
pluginName = comp.pluginName;
|
|
184
|
-
options = comp.options;
|
|
185
|
-
launcher = comp.launcher;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if (!target && element.nodeName) {
|
|
189
|
-
if (this.__isFiles(element)) {
|
|
190
|
-
isFile = true;
|
|
191
|
-
}
|
|
192
|
-
const comp = this.editor._componentManager.map((f) => f(element)).find((e) => e);
|
|
193
|
-
if (!comp) return null;
|
|
194
|
-
target = comp.target;
|
|
195
|
-
pluginName = comp.pluginName;
|
|
196
|
-
options = comp.options;
|
|
197
|
-
launcher = comp.launcher;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (!target) {
|
|
201
|
-
return null;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const figureInfo = Figure.GetContainer(target);
|
|
205
|
-
const container = figureInfo.container || figureInfo.cover || target;
|
|
206
|
-
return (this.info = {
|
|
207
|
-
target,
|
|
208
|
-
pluginName,
|
|
209
|
-
options,
|
|
210
|
-
container: container,
|
|
211
|
-
cover: figureInfo.cover,
|
|
212
|
-
inlineCover: figureInfo.inlineCover,
|
|
213
|
-
caption: figureInfo.caption,
|
|
214
|
-
isFile,
|
|
215
|
-
launcher,
|
|
216
|
-
isInputType: dom.utils.hasClass(container, 'se-input-component')
|
|
217
|
-
});
|
|
218
|
-
},
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* @this {ComponentThis}
|
|
222
|
-
* @description The component(media, file component, table, etc) is selected and the resizing module is called.
|
|
223
|
-
* @param {Node} element Target element
|
|
224
|
-
* @param {string} pluginName The plugin name for the selected target.
|
|
225
|
-
* @param {Object} [options] Options
|
|
226
|
-
* @param {boolean} [options.isInput=false] Whether the target is an input component.(table)
|
|
227
|
-
*/
|
|
228
|
-
select(element, pluginName, { isInput = false } = {}) {
|
|
229
|
-
const info = this.get(element);
|
|
230
|
-
if (!info || dom.check.isUneditable(dom.query.getParentElement(element, this.is.bind(this))) || dom.check.isUneditable(element)) return false;
|
|
231
|
-
|
|
232
|
-
const plugin = info.launcher || this.plugins[pluginName];
|
|
233
|
-
if (!plugin) return;
|
|
234
|
-
|
|
235
|
-
const notOver = _DragHandle.get('__overInfo') !== ON_OVER_COMPONENT;
|
|
236
|
-
if (!isInput && notOver) {
|
|
237
|
-
if (this.editor.status._onMousedown) return;
|
|
238
|
-
|
|
239
|
-
this.editor._preventBlur = true;
|
|
240
|
-
this.__selectionSelected = true;
|
|
241
|
-
if (this.isInline(info.container)) {
|
|
242
|
-
this.selection.setRange(info.container, 0, info.container, 0);
|
|
243
|
-
}
|
|
244
|
-
this.editor.blur();
|
|
245
|
-
_w.setTimeout(() => {
|
|
246
|
-
this.__selectionSelected = false;
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
this.isSelected = true;
|
|
251
|
-
this.__prevent = true;
|
|
252
|
-
|
|
253
|
-
let isNonFigureComponent;
|
|
254
|
-
if (typeof plugin.select === 'function') isNonFigureComponent = plugin.select(element);
|
|
255
|
-
|
|
256
|
-
const isBreakComponent = dom.utils.hasClass(info.target, 'se-component-line-break');
|
|
257
|
-
if (isBreakComponent || (!isNonFigureComponent && !dom.utils.hasClass(info.container, 'se-inline-component'))) this._setComponentLineBreaker(/** @type {HTMLElement} */ (info.container || info.cover || element));
|
|
258
|
-
|
|
259
|
-
this.currentTarget = element;
|
|
260
|
-
this.currentPlugin = plugin;
|
|
261
|
-
this.currentPluginName = pluginName;
|
|
262
|
-
this.currentInfo = info;
|
|
263
|
-
|
|
264
|
-
_DragHandle.set('__dragInst', this);
|
|
265
|
-
|
|
266
|
-
const __overInfo = _DragHandle.get('__overInfo');
|
|
267
|
-
_w.setTimeout(() => {
|
|
268
|
-
_DragHandle.set('__overInfo', __overInfo === ON_OVER_COMPONENT ? undefined : false);
|
|
269
|
-
if (__overInfo !== ON_OVER_COMPONENT) this.__addGlobalEvent();
|
|
270
|
-
if (!info.isFile) this.__addNotFileGlobalEvent();
|
|
271
|
-
}, 0);
|
|
272
|
-
|
|
273
|
-
converter.debounce(() => {
|
|
274
|
-
dom.utils.addClass(info.container, 'se-component-selected');
|
|
275
|
-
}, 0)();
|
|
276
|
-
|
|
277
|
-
if (notOver && !this.status.hasFocus && !this.editor._preventFocus) {
|
|
278
|
-
this.eventManager.__postFocusEvent(this.editor.frameContext, null);
|
|
279
|
-
this.editor._preventFocus = true;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
if (!isBreakComponent && __overInfo !== ON_OVER_COMPONENT) {
|
|
283
|
-
// set zero width space
|
|
284
|
-
if (!this.isInline(info.container)) return;
|
|
285
|
-
|
|
286
|
-
const oNode = info.container;
|
|
287
|
-
let zeroWidth = null;
|
|
288
|
-
if (!oNode.previousSibling || dom.check.isBreak(oNode.previousSibling)) {
|
|
289
|
-
zeroWidth = dom.utils.createTextNode(unicode.zeroWidthSpace);
|
|
290
|
-
oNode.parentNode.insertBefore(zeroWidth, oNode);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
if (!oNode.nextSibling || dom.check.isBreak(oNode.nextSibling)) {
|
|
294
|
-
zeroWidth = dom.utils.createTextNode(unicode.zeroWidthSpace);
|
|
295
|
-
oNode.parentNode.insertBefore(zeroWidth, oNode.nextSibling);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
this.editor.status.onSelected = true;
|
|
299
|
-
} else if (isBreakComponent || !dom.utils.hasClass(info.container, 'se-input-component')) {
|
|
300
|
-
const dragHandle = this.editor.frameContext.get('wrapper').querySelector('.se-drag-handle');
|
|
301
|
-
dom.utils.addClass(dragHandle, 'se-drag-handle-full');
|
|
302
|
-
this.ui._visibleControllers(false, false);
|
|
303
|
-
|
|
304
|
-
const sizeTarget = info.caption ? info.target : info.cover || info.container || info.target;
|
|
305
|
-
const w = sizeTarget.offsetWidth;
|
|
306
|
-
const h = sizeTarget.offsetHeight;
|
|
307
|
-
const { top, left } = this.offset.getLocal(sizeTarget);
|
|
308
|
-
|
|
309
|
-
dragHandle.style.opacity = 0;
|
|
310
|
-
dragHandle.style.width = w + 'px';
|
|
311
|
-
dragHandle.style.height = h + 'px';
|
|
312
|
-
dragHandle.style.top = top + 'px';
|
|
313
|
-
dragHandle.style.left = left + 'px';
|
|
314
|
-
|
|
315
|
-
_DragHandle.set('__dragHandler', dragHandle);
|
|
316
|
-
_DragHandle.set('__dragContainer', info.container);
|
|
317
|
-
_DragHandle.set('__dragCover', info.cover);
|
|
318
|
-
|
|
319
|
-
dragHandle.style.display = 'block';
|
|
320
|
-
}
|
|
321
|
-
},
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* @this {ComponentThis}
|
|
325
|
-
* @description Deselects the selected component.
|
|
326
|
-
*/
|
|
327
|
-
deselect() {
|
|
328
|
-
_w.setTimeout(() => {
|
|
329
|
-
this.editor.status.onSelected = false;
|
|
330
|
-
}, 0);
|
|
331
|
-
this.__deselect();
|
|
332
|
-
this.ui.setControllerOnDisabledButtons(false);
|
|
333
|
-
|
|
334
|
-
if (this.editor._preventFocus && !this.status.hasFocus && !this.__prevent) {
|
|
335
|
-
this.eventManager.__postBlurEvent(this.editor.frameContext, null);
|
|
336
|
-
this.editor._preventFocus = false;
|
|
337
|
-
}
|
|
338
|
-
},
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* @this {ComponentThis}
|
|
342
|
-
* @description Determines if the specified node is a block component (e.g., img, iframe, video, audio, table) with the class "se-component"
|
|
343
|
-
* - or a direct FIGURE node. This function checks if the node itself is a component
|
|
344
|
-
* - or if it belongs to any components identified by the component manager.
|
|
345
|
-
* @param {Node} element The DOM node to check.
|
|
346
|
-
* @returns {boolean} True if the node is a block component or part of it, otherwise false.
|
|
347
|
-
*/
|
|
348
|
-
is(element) {
|
|
349
|
-
if (!element) return false;
|
|
350
|
-
|
|
351
|
-
if (/^FIGURE$/i.test(element.nodeName) || dom.utils.hasClass(element, 'se-component')) return true;
|
|
352
|
-
if (this.editor._componentManager.find((f) => f(element))) return true;
|
|
353
|
-
|
|
354
|
-
return false;
|
|
355
|
-
},
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* @this {ComponentThis}
|
|
359
|
-
* @description Checks if the given node is an inline component (class "se-inline-component").
|
|
360
|
-
* - If the node is a FIGURE, it checks the parent element instead.
|
|
361
|
-
* - It also verifies whether the node is part of an inline component recognized by the component manager.
|
|
362
|
-
* @param {Node} element The DOM node to check.
|
|
363
|
-
* @returns {boolean} True if the node is an inline component or part of it, otherwise false.
|
|
364
|
-
*/
|
|
365
|
-
isInline(element) {
|
|
366
|
-
if (!element) return false;
|
|
367
|
-
|
|
368
|
-
if (/^FIGURE$/i.test(element.nodeName)) element = element.parentElement;
|
|
369
|
-
if (dom.utils.hasClass(element, 'se-inline-component')) return true;
|
|
370
|
-
|
|
371
|
-
const container = this.editor._componentManager.find((f) => f(element));
|
|
372
|
-
if (container && dom.utils.hasClass(element, 'se-inline-component')) return true;
|
|
373
|
-
|
|
374
|
-
return false;
|
|
375
|
-
},
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* @this {ComponentThis}
|
|
379
|
-
* @description Checks if the specified node qualifies as a basic component within the editor.
|
|
380
|
-
* - This function verifies whether the node is recognized as a component by the `is` function, while also ensuring that it is not an inline component as determined by the `isInline` function.
|
|
381
|
-
* - This is used to identify block-level elements or standalone components that are not part of the inline component classification.
|
|
382
|
-
* @param {Node} element The DOM node to check.
|
|
383
|
-
* @returns {boolean} True if the node is a basic (non-inline) component, otherwise false.
|
|
384
|
-
*/
|
|
385
|
-
isBasic(element) {
|
|
386
|
-
return this.is(element) && !this.isInline(element);
|
|
387
|
-
},
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
* @this {ComponentThis}
|
|
391
|
-
* @description Copies the specified component node to the clipboard.
|
|
392
|
-
* - This function is different from the one called when the user presses the "Ctrl + C" key combination.
|
|
393
|
-
* @param {Node} container The DOM node to check.
|
|
394
|
-
*/
|
|
395
|
-
copy(container) {
|
|
396
|
-
const cloneContainer = /** @type {HTMLElement} */ (dom.utils.clone(container, true));
|
|
397
|
-
|
|
398
|
-
// remove selected class
|
|
399
|
-
dom.utils.removeClass(cloneContainer, 'se-component-selected');
|
|
400
|
-
dom.utils.removeClass(cloneContainer.querySelectorAll('.se-figure-selected'), 'se-figure-selected');
|
|
401
|
-
dom.utils.removeClass(cloneContainer.querySelectorAll('.se-selected-table-cell'), 'se-selected-table-cell');
|
|
402
|
-
dom.utils.removeClass(cloneContainer.querySelector('.se-selected-cell-focus'), 'se-selected-cell-focus');
|
|
403
|
-
|
|
404
|
-
// copy to clipboard
|
|
405
|
-
this.html.copy(cloneContainer);
|
|
406
|
-
|
|
407
|
-
// copy effect
|
|
408
|
-
dom.utils.flashClass(container, 'se-copy');
|
|
409
|
-
},
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* @private
|
|
413
|
-
* @this {ComponentThis}
|
|
414
|
-
* @description Checks if the given element is a file component by matching its tag name against the file manager's regular expressions.
|
|
415
|
-
* - It also verifies whether the element has the required attributes based on the tag type.
|
|
416
|
-
* @param {Node} element The element to check.
|
|
417
|
-
* @returns {boolean} Returns true if the element is a file component, otherwise false.
|
|
418
|
-
*/
|
|
419
|
-
__isFiles(element) {
|
|
420
|
-
const nodeName = element.nodeName.toLowerCase();
|
|
421
|
-
return this.editor._fileManager.regExp.test(nodeName) && (!this.editor._fileManager.tagAttrs[nodeName] || this.editor._fileManager.tagAttrs[nodeName]?.every((v) => /** @type {HTMLElement} */ (element).hasAttribute(v)));
|
|
422
|
-
},
|
|
423
|
-
|
|
424
|
-
/**
|
|
425
|
-
* @private
|
|
426
|
-
* @this {ComponentThis}
|
|
427
|
-
* @description Deselects the currently selected component, removing any selection effects and associated event listeners.
|
|
428
|
-
* - This method resets the selection state and hides UI elements related to the component selection.
|
|
429
|
-
*/
|
|
430
|
-
__deselect() {
|
|
431
|
-
this.editor._preventBlur = false;
|
|
432
|
-
_DragHandle.set('__overInfo', null);
|
|
433
|
-
this._removeDragEvent();
|
|
434
|
-
|
|
435
|
-
if (this.currentInfo) {
|
|
436
|
-
const infoContainer = this.currentInfo.container;
|
|
437
|
-
const infoCover = this.currentInfo.cover;
|
|
438
|
-
converter.debounce(() => {
|
|
439
|
-
dom.utils.removeClass(infoContainer, 'se-component-selected');
|
|
440
|
-
dom.utils.removeClass(infoCover, 'se-figure-over-selected');
|
|
441
|
-
}, 0)();
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
const { frameContext } = this.editor;
|
|
445
|
-
frameContext.get('lineBreaker_t').style.display = frameContext.get('lineBreaker_b').style.display = 'none';
|
|
446
|
-
|
|
447
|
-
if (this.currentPlugin && typeof this.currentPlugin.deselect === 'function') {
|
|
448
|
-
this.currentPlugin.deselect(this.currentTarget);
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
this.isSelected = false;
|
|
452
|
-
this.currentPlugin = null;
|
|
453
|
-
this.currentTarget = null;
|
|
454
|
-
this.currentPluginName = '';
|
|
455
|
-
this.currentInfo = null;
|
|
456
|
-
this.__removeGlobalEvent();
|
|
457
|
-
this.ui.__offControllers();
|
|
458
|
-
},
|
|
459
|
-
|
|
460
|
-
/**
|
|
461
|
-
* @private
|
|
462
|
-
* @this {ComponentThis}
|
|
463
|
-
* @description Set line breaker of component
|
|
464
|
-
* @param {HTMLElement} element Element tag
|
|
465
|
-
*/
|
|
466
|
-
_setComponentLineBreaker(element) {
|
|
467
|
-
const _overInfo = _DragHandle.get('__overInfo') === ON_OVER_COMPONENT;
|
|
468
|
-
this.eventManager._lineBreakComp = null;
|
|
469
|
-
const info = this.get(element);
|
|
470
|
-
if (!info) return;
|
|
471
|
-
|
|
472
|
-
const fc = this.editor.frameContext;
|
|
473
|
-
const container = info.container;
|
|
474
|
-
const isNonSelected = dom.utils.hasClass(container, 'se-flex-component');
|
|
475
|
-
const lb_t = fc.get('lineBreaker_t');
|
|
476
|
-
const lb_b = fc.get('lineBreaker_b');
|
|
477
|
-
const t_style = lb_t.style;
|
|
478
|
-
const b_style = lb_b.style;
|
|
479
|
-
const offsetTarget = container.offsetWidth < element.offsetWidth ? container : element;
|
|
480
|
-
const target = this.editor._figureContainer?.style.display === 'block' ? this.editor._figureContainer : offsetTarget;
|
|
481
|
-
const isList = dom.check.isListCell(container.parentNode);
|
|
482
|
-
|
|
483
|
-
// top
|
|
484
|
-
let componentTop, w;
|
|
485
|
-
const isRtl = this.options.get('_rtl');
|
|
486
|
-
const dir = isRtl ? ['right', 'left'] : ['left', 'right'];
|
|
487
|
-
const { top, left, right, scrollX, scrollY } = this.offset.getLocal(offsetTarget);
|
|
488
|
-
const sideOffset = isRtl ? right : left;
|
|
489
|
-
|
|
490
|
-
if (isList ? !container.previousSibling : !this.format.isLine(container.previousElementSibling)) {
|
|
491
|
-
const cStyle = _w.getComputedStyle(lb_t);
|
|
492
|
-
const cH = numbers.get(cStyle.height, 1);
|
|
493
|
-
const cW = numbers.get(cStyle.width, 1);
|
|
494
|
-
|
|
495
|
-
this.eventManager._lineBreakComp = container;
|
|
496
|
-
componentTop = top;
|
|
497
|
-
w = target.offsetWidth / 2 / 2;
|
|
498
|
-
|
|
499
|
-
t_style.top = componentTop - scrollY - cH / 2 + 'px';
|
|
500
|
-
t_style[dir[0]] = (isNonSelected ? sideOffset - cW / 2 : sideOffset + w) + 'px';
|
|
501
|
-
t_style[dir[1]] = '';
|
|
502
|
-
|
|
503
|
-
lb_t.setAttribute('data-offset', scrollY + ',' + scrollX);
|
|
504
|
-
if (_overInfo) dom.utils.removeClass(lb_t, 'se-on-selected');
|
|
505
|
-
else dom.utils.addClass(lb_t, 'se-on-selected');
|
|
506
|
-
|
|
507
|
-
t_style.display = 'block';
|
|
508
|
-
t_style.visibility = '';
|
|
509
|
-
} else {
|
|
510
|
-
t_style.display = 'none';
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
// bottom
|
|
514
|
-
if (isList ? !container.nextSibling : !this.format.isLine(container.nextElementSibling)) {
|
|
515
|
-
const cStyle = _w.getComputedStyle(lb_b);
|
|
516
|
-
const cH = numbers.get(cStyle.height, 1);
|
|
517
|
-
const cW = numbers.get(cStyle.width, 1);
|
|
518
|
-
|
|
519
|
-
if (!componentTop) {
|
|
520
|
-
this.eventManager._lineBreakComp = container;
|
|
521
|
-
componentTop = top;
|
|
522
|
-
w = target.offsetWidth / 2 / 2;
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
b_style.top = componentTop + target.offsetHeight - scrollY - cH / 2 + 'px';
|
|
526
|
-
b_style[dir[0]] = sideOffset + target.offsetWidth - (isNonSelected ? 0 : w) - (isNonSelected ? cW / 2 : cW) + 'px';
|
|
527
|
-
b_style[dir[1]] = '';
|
|
528
|
-
|
|
529
|
-
lb_b.setAttribute('data-offset', scrollY + ',' + dir[0] + ',' + scrollX);
|
|
530
|
-
if (_overInfo) dom.utils.removeClass(lb_b, 'se-on-selected');
|
|
531
|
-
else dom.utils.addClass(lb_b, 'se-on-selected');
|
|
532
|
-
|
|
533
|
-
b_style.display = 'block';
|
|
534
|
-
b_style.visibility = '';
|
|
535
|
-
} else {
|
|
536
|
-
b_style.display = 'none';
|
|
537
|
-
}
|
|
538
|
-
},
|
|
539
|
-
|
|
540
|
-
/**
|
|
541
|
-
* @private
|
|
542
|
-
* @this {ComponentThis}
|
|
543
|
-
* @description Adds global event listeners for component interactions such as copy, cut, and keydown events.
|
|
544
|
-
*/
|
|
545
|
-
__addGlobalEvent() {
|
|
546
|
-
this.__removeGlobalEvent();
|
|
547
|
-
this._bindClose_copy = this.eventManager.addGlobalEvent('copy', this.__globalEvents.copy);
|
|
548
|
-
this._bindClose_cut = this.eventManager.addGlobalEvent('cut', this.__globalEvents.cut);
|
|
549
|
-
this._bindClose_keydown = this.eventManager.addGlobalEvent('keydown', this.__globalEvents.keydown);
|
|
550
|
-
},
|
|
551
|
-
|
|
552
|
-
/**
|
|
553
|
-
* @private
|
|
554
|
-
* @this {ComponentThis}
|
|
555
|
-
* @description Removes global event listeners that were previously added for component interactions.
|
|
556
|
-
*/
|
|
557
|
-
__removeGlobalEvent() {
|
|
558
|
-
this.__removeNotFileGlobalEvent();
|
|
559
|
-
if (this._bindClose_copy) this._bindClose_copy = this.eventManager.removeGlobalEvent(this._bindClose_copy);
|
|
560
|
-
if (this._bindClose_cut) this._bindClose_cut = this.eventManager.removeGlobalEvent(this._bindClose_cut);
|
|
561
|
-
if (this._bindClose_keydown) this._bindClose_keydown = this.eventManager.removeGlobalEvent(this._bindClose_keydown);
|
|
562
|
-
},
|
|
563
|
-
|
|
564
|
-
/**
|
|
565
|
-
* @private
|
|
566
|
-
* @this {ComponentThis}
|
|
567
|
-
* @description Adds global event listeners for non-file-related interactions such as mouse and touch events.
|
|
568
|
-
*/
|
|
569
|
-
__addNotFileGlobalEvent() {
|
|
570
|
-
this.__removeNotFileGlobalEvent();
|
|
571
|
-
if (!isMobile) this._bindClose_mousedown = this.eventManager.addGlobalEvent('mousedown', this.__globalEvents.mousedown, true);
|
|
572
|
-
else this._bindClose_touchstart = this.eventManager.addGlobalEvent('touchstart', this.__globalEvents.mousedown, true);
|
|
573
|
-
},
|
|
574
|
-
|
|
575
|
-
/**
|
|
576
|
-
* @private
|
|
577
|
-
* @this {ComponentThis}
|
|
578
|
-
* @description Removes global event listeners related to non-file interactions.
|
|
579
|
-
*/
|
|
580
|
-
__removeNotFileGlobalEvent() {
|
|
581
|
-
if (this._bindClose_mousedown) this._bindClose_mousedown = this.eventManager.removeGlobalEvent(this._bindClose_mousedown);
|
|
582
|
-
if (this._bindClose_touchstart) this._bindClose_touchstart = this.eventManager.removeGlobalEvent(this._bindClose_touchstart);
|
|
583
|
-
},
|
|
584
|
-
|
|
585
|
-
/**
|
|
586
|
-
* @private
|
|
587
|
-
* @this {ComponentThis}
|
|
588
|
-
* @description Removes drag-related events and resets drag-related states.
|
|
589
|
-
*/
|
|
590
|
-
_removeDragEvent() {
|
|
591
|
-
/** @type {HTMLElement} */ (this.carrierWrapper.querySelector('.se-drag-cursor')).style.left = '-10000px';
|
|
592
|
-
if (_DragHandle.get('__dragHandler')) _DragHandle.get('__dragHandler').style.display = 'none';
|
|
593
|
-
|
|
594
|
-
dom.utils.removeClass([_DragHandle.get('__dragHandler'), _DragHandle.get('__dragContainer')], 'se-dragging');
|
|
595
|
-
dom.utils.removeClass([_DragHandle.get('__dragCover'), _DragHandle.get('__dragContainer')], 'se-drag-over');
|
|
596
|
-
|
|
597
|
-
_DragHandle.set('__figureInst', null);
|
|
598
|
-
_DragHandle.set('__dragInst', null);
|
|
599
|
-
_DragHandle.set('__dragHandler', null);
|
|
600
|
-
_DragHandle.set('__dragContainer', null);
|
|
601
|
-
_DragHandle.set('__dragCover', null);
|
|
602
|
-
_DragHandle.set('__dragMove', null);
|
|
603
|
-
_DragHandle.set('__overInfo', null);
|
|
604
|
-
},
|
|
605
|
-
|
|
606
|
-
constructor: Component
|
|
607
|
-
};
|
|
608
|
-
|
|
609
|
-
/**
|
|
610
|
-
* @this {ComponentThis}
|
|
611
|
-
*/
|
|
612
|
-
function OnDragEnter() {
|
|
613
|
-
this.editor._preventBlur = true;
|
|
614
|
-
this.ui._visibleControllers(false, dom.utils.hasClass(_DragHandle.get('__dragHandler'), 'se-drag-handle-full'));
|
|
615
|
-
dom.utils.addClass(_DragHandle.get('__dragCover') || _DragHandle.get('__dragContainer'), 'se-drag-over');
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
/**
|
|
619
|
-
* @this {ComponentThis}
|
|
620
|
-
*/
|
|
621
|
-
function OnDragLeave() {
|
|
622
|
-
this.editor._preventBlur = false;
|
|
623
|
-
if (!dom.utils.hasClass(_DragHandle.get('__dragHandler'), 'se-drag-handle-full')) this.ui._visibleControllers(true, true);
|
|
624
|
-
dom.utils.removeClass([_DragHandle.get('__dragCover'), _DragHandle.get('__dragContainer')], 'se-drag-over');
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
/**
|
|
628
|
-
* @this {ComponentThis}
|
|
629
|
-
* @param {DragEvent} e - Drag event
|
|
630
|
-
*/
|
|
631
|
-
function OnDragStart(e) {
|
|
632
|
-
const cover = _DragHandle.get('__dragCover') || _DragHandle.get('__dragContainer');
|
|
633
|
-
|
|
634
|
-
if (!cover) {
|
|
635
|
-
e.preventDefault();
|
|
636
|
-
return;
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
this.editor._preventBlur = false;
|
|
640
|
-
dom.utils.addClass(_DragHandle.get('__dragHandler'), 'se-dragging');
|
|
641
|
-
dom.utils.addClass(_DragHandle.get('__dragContainer'), 'se-dragging');
|
|
642
|
-
e.dataTransfer.setDragImage(cover, this.options.get('_rtl') ? cover.offsetWidth : -5, -5);
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
/**
|
|
646
|
-
* @this {ComponentThis}
|
|
647
|
-
*/
|
|
648
|
-
function OnDragEnd() {
|
|
649
|
-
this.editor._preventBlur = false;
|
|
650
|
-
dom.utils.removeClass([_DragHandle.get('__dragHandler'), _DragHandle.get('__dragContainer')], 'se-dragging');
|
|
651
|
-
this._removeDragEvent();
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
/**
|
|
655
|
-
* @this {ComponentThis}
|
|
656
|
-
* @param {MouseEvent} e - Mouse event
|
|
657
|
-
*/
|
|
658
|
-
function OnDragClick(e) {
|
|
659
|
-
const target = dom.query.getEventTarget(e);
|
|
660
|
-
if (!dom.utils.hasClass(target, 'se-drag-handle-full')) return;
|
|
661
|
-
|
|
662
|
-
const dragInst = _DragHandle.get('__dragInst');
|
|
663
|
-
this._removeDragEvent();
|
|
664
|
-
this.select(dragInst.currentTarget, dragInst.currentPluginName);
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
/**
|
|
668
|
-
* @this {ComponentThis}
|
|
669
|
-
* @param {MouseEvent} e - Mouse event
|
|
670
|
-
*/
|
|
671
|
-
function CloseListener_mousedown(e) {
|
|
672
|
-
const target = dom.query.getEventTarget(e);
|
|
673
|
-
if (
|
|
674
|
-
this.currentTarget?.contains(target) ||
|
|
675
|
-
dom.query.getParentElement(target, '.se-controller') ||
|
|
676
|
-
dom.utils.hasClass(target, 'se-drag-handle') ||
|
|
677
|
-
(this.currentPluginName === this.editor.currentControllerName && this.editor.opendControllers.some(({ form }) => form.contains(target)))
|
|
678
|
-
) {
|
|
679
|
-
return;
|
|
680
|
-
}
|
|
681
|
-
this.deselect();
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
/**
|
|
685
|
-
* @this {ComponentThis}
|
|
686
|
-
* @param {ClipboardEvent} e - Event object
|
|
687
|
-
*/
|
|
688
|
-
function OnCopy_component(e) {
|
|
689
|
-
const target = dom.query.getEventTarget(e);
|
|
690
|
-
if (dom.check.isInputElement(target) && dom.query.getParentElement(target, '.se-modal')) return;
|
|
691
|
-
|
|
692
|
-
const info = this.info;
|
|
693
|
-
if (!info) return;
|
|
694
|
-
|
|
695
|
-
const cloneContainer = info.container.cloneNode(true);
|
|
696
|
-
dom.utils.removeClass(cloneContainer, 'se-component-selected');
|
|
697
|
-
|
|
698
|
-
if (typeof this.plugins[info.pluginName]?.onCopyComponent !== 'function' || this.plugins[info.pluginName].onCopyComponent({ event: e, cloneContainer, info }) === false) {
|
|
699
|
-
SetClipboardComponent(e, cloneContainer, e.clipboardData);
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
// copy effect
|
|
703
|
-
dom.utils.flashClass(info.container, 'se-copy');
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
/**
|
|
707
|
-
* @this {ComponentThis}
|
|
708
|
-
* @param {ClipboardEvent} e - Event object
|
|
709
|
-
*/
|
|
710
|
-
function OnCut_component(e) {
|
|
711
|
-
const info = this.info;
|
|
712
|
-
if (!info) return;
|
|
713
|
-
|
|
714
|
-
const cloneContainer = info.container.cloneNode(true);
|
|
715
|
-
dom.utils.removeClass(cloneContainer, 'se-component-selected');
|
|
716
|
-
|
|
717
|
-
SetClipboardComponent(e, cloneContainer, e.clipboardData);
|
|
718
|
-
this.deselect();
|
|
719
|
-
dom.utils.removeItem(info.container);
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
/**
|
|
723
|
-
* @this {ComponentThis}
|
|
724
|
-
* @param {KeyboardEvent} e - Event object
|
|
725
|
-
*/
|
|
726
|
-
async function OnKeyDown_component(e) {
|
|
727
|
-
if (this.editor.selectMenuOn) return;
|
|
728
|
-
|
|
729
|
-
const keyCode = e.code;
|
|
730
|
-
const ctrl = keyCodeMap.isCtrl(e);
|
|
731
|
-
|
|
732
|
-
// redo, undo
|
|
733
|
-
if (ctrl) {
|
|
734
|
-
if (keyCode !== 'ControlRight' && keyCode !== 'ControlLeft') {
|
|
735
|
-
const info = this.editor.shortcutsKeyMap.get(keyCode + (e.shiftKey ? '1000' : ''));
|
|
736
|
-
if (/^(redo|undo)$/.test(info?.c)) {
|
|
737
|
-
e.preventDefault();
|
|
738
|
-
e.stopPropagation();
|
|
739
|
-
this.editor.run(info.c, info.t, info.e);
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
return;
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
// backspace key, delete key
|
|
746
|
-
if (keyCodeMap.isRemoveKey(keyCode)) {
|
|
747
|
-
e.preventDefault();
|
|
748
|
-
e.stopPropagation();
|
|
749
|
-
if (typeof this.currentPlugin?.destroy === 'function') {
|
|
750
|
-
await this.currentPlugin.destroy(this.currentTarget);
|
|
751
|
-
this.deselect();
|
|
752
|
-
this.editor.focus();
|
|
753
|
-
return;
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
// enter key
|
|
758
|
-
if (keyCodeMap.isEnter(keyCode)) {
|
|
759
|
-
e.preventDefault();
|
|
760
|
-
const compContext = this.currentInfo || this.get(this.currentTarget);
|
|
761
|
-
const container = compContext.container || compContext.target;
|
|
762
|
-
const sibling = container.previousElementSibling || container.nextElementSibling;
|
|
763
|
-
let newEl = null;
|
|
764
|
-
if (dom.check.isListCell(container.parentNode)) {
|
|
765
|
-
newEl = dom.utils.createElement('BR');
|
|
766
|
-
} else {
|
|
767
|
-
newEl = dom.utils.createElement(this.format.isLine(sibling) ? sibling.nodeName : this.options.get('defaultLine'), null, '<br>');
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
const pluginName = this.currentPluginName;
|
|
771
|
-
this.deselect();
|
|
772
|
-
container.parentNode.insertBefore(newEl, container);
|
|
773
|
-
if (this.select(compContext.target, pluginName) === false) this.editor.blur();
|
|
774
|
-
this.history.push(false);
|
|
775
|
-
|
|
776
|
-
return;
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
// up down, left right
|
|
780
|
-
if (DIR_KEYCODE.test(keyCode)) {
|
|
781
|
-
const { container } = this.get(this.currentTarget);
|
|
782
|
-
const isInline = this.isInline(container || this.currentTarget);
|
|
783
|
-
|
|
784
|
-
let el = null;
|
|
785
|
-
let offset = 1;
|
|
786
|
-
if (isInline) {
|
|
787
|
-
switch (keyCode) {
|
|
788
|
-
case 'ArrowLeft': // left
|
|
789
|
-
el = container.previousSibling;
|
|
790
|
-
offset = el?.nodeType === 3 ? el.textContent.length : 1;
|
|
791
|
-
break;
|
|
792
|
-
case 'ArrowRight': // right
|
|
793
|
-
el = container.nextSibling;
|
|
794
|
-
offset = 0;
|
|
795
|
-
break;
|
|
796
|
-
case 'ArrowUp': {
|
|
797
|
-
// up
|
|
798
|
-
const line = this.format.getLine(container, null);
|
|
799
|
-
el = line?.previousElementSibling;
|
|
800
|
-
offset = 0;
|
|
801
|
-
break;
|
|
802
|
-
}
|
|
803
|
-
case 'ArrowDown': {
|
|
804
|
-
// down
|
|
805
|
-
const line = this.format.getLine(container, null);
|
|
806
|
-
el = line?.nextElementSibling;
|
|
807
|
-
break;
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
} else {
|
|
811
|
-
if (DIR_UP_KEYCODE.test(keyCode)) {
|
|
812
|
-
el = container.previousElementSibling;
|
|
813
|
-
} else {
|
|
814
|
-
el = container.nextElementSibling;
|
|
815
|
-
offset = 0;
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
if (!el) return;
|
|
820
|
-
|
|
821
|
-
this.deselect();
|
|
822
|
-
|
|
823
|
-
const elComp = this.get(el);
|
|
824
|
-
if (elComp?.container) {
|
|
825
|
-
e.stopPropagation();
|
|
826
|
-
e.preventDefault();
|
|
827
|
-
this.select(elComp.target, elComp.pluginName);
|
|
828
|
-
} else {
|
|
829
|
-
try {
|
|
830
|
-
this.editor._preventBlur = true;
|
|
831
|
-
e.stopPropagation();
|
|
832
|
-
e.preventDefault();
|
|
833
|
-
this.selection.setRange(el, offset, el, offset);
|
|
834
|
-
} finally {
|
|
835
|
-
this.editor._preventBlur = false;
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
return;
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
// ESC
|
|
843
|
-
if (keyCodeMap.isEsc(keyCode)) {
|
|
844
|
-
this.deselect();
|
|
845
|
-
return;
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
function SetClipboardComponent(e, container, clipboardData) {
|
|
850
|
-
e.preventDefault();
|
|
851
|
-
e.stopPropagation();
|
|
852
|
-
container.querySelectorAll('.se-figure-selected').forEach((el) => dom.utils.removeClass(el, 'se-figure-selected'));
|
|
853
|
-
clipboardData.setData('text/html', container.outerHTML);
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
export default Component;
|