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,17 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import { getParentElement } from '../../helper/dom/domQuery';
|
|
7
|
-
import { isWysiwygFrame, isElement } from '../../helper/dom/domCheck';
|
|
8
|
-
import { hasClass, addClass, removeClass, getClientSize } from '../../helper/dom/domUtils';
|
|
9
|
-
import { numbers } from '../../helper';
|
|
10
|
-
import { _w, _d } from '../../helper/env';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @typedef {Omit<Offset & Partial<__se__EditorInjector>, 'offset'>} OffsetThis
|
|
14
|
-
*/
|
|
1
|
+
import { getParentElement } from '../../../helper/dom/domQuery';
|
|
2
|
+
import { isWysiwygFrame, isElement } from '../../../helper/dom/domCheck';
|
|
3
|
+
import { hasClass, addClass, removeClass, getClientSize } from '../../../helper/dom/domUtils';
|
|
4
|
+
import { numbers } from '../../../helper';
|
|
5
|
+
import { _w, _d } from '../../../helper/env';
|
|
15
6
|
|
|
16
7
|
/**
|
|
17
8
|
* @typedef {Object} RectsInfo Bounding rectangle information of the selection range.
|
|
@@ -37,16 +28,17 @@ import { _w, _d } from '../../helper/env';
|
|
|
37
28
|
* @property {number} right - The right position of the node relative to the WYSIWYG editor.
|
|
38
29
|
* @property {number} scrollX - The horizontal scroll offset inside the WYSIWYG editor.
|
|
39
30
|
* @property {number} scrollY - The vertical scroll offset inside the WYSIWYG editor.
|
|
31
|
+
* @property {number} scrollH - The vertical scroll height inside the WYSIWYG editor.
|
|
40
32
|
*/
|
|
41
33
|
|
|
42
34
|
/**
|
|
43
35
|
* @typedef {Object} OffsetGlobalInfo
|
|
44
36
|
* @property {number} top - The top position of the element relative to the entire document.
|
|
45
37
|
* @property {number} left - The left position of the element relative to the entire document.
|
|
38
|
+
* @property {number} fixedTop - The top position within the current viewport, without taking scrolling into account.
|
|
39
|
+
* @property {number} fixedLeft - The left position within the current viewport, without taking scrolling into account.
|
|
46
40
|
* @property {number} width - The total width of the element, including its content, padding, and border.
|
|
47
41
|
* @property {number} height - The total height of the element, including its content, padding, and border.
|
|
48
|
-
* @property {number} scrollTop - The amount of vertical scrolling applied to the element.
|
|
49
|
-
* @property {number} scrollLeft - The amount of horizontal scrolling applied to the element.
|
|
50
42
|
*/
|
|
51
43
|
|
|
52
44
|
/**
|
|
@@ -74,45 +66,55 @@ import { _w, _d } from '../../helper/env';
|
|
|
74
66
|
* @property {number} width - The total width of the WYSIWYG editor's scrollable area.
|
|
75
67
|
* @property {number} height - The total height of the WYSIWYG editor's scrollable area.
|
|
76
68
|
* @property {number} bottom - The sum of `top` and `height`, representing the bottom-most scrollable position.
|
|
77
|
-
* @property {RectsInfo} rects - The bounding rectangle of the editor's visible area.
|
|
78
69
|
*/
|
|
79
70
|
|
|
80
71
|
/**
|
|
81
|
-
* @constructor
|
|
82
|
-
* @this {OffsetThis}
|
|
83
72
|
* @description Offset class, get the position of the element
|
|
84
|
-
* @param {__se__EditorCore} editor - The root editor instance
|
|
85
73
|
*/
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
74
|
+
class Offset {
|
|
75
|
+
#$;
|
|
76
|
+
#store;
|
|
77
|
+
|
|
78
|
+
#shadowRoot;
|
|
79
|
+
#carrierWrapper;
|
|
80
|
+
#context;
|
|
81
|
+
#frameContext;
|
|
82
|
+
#options;
|
|
83
|
+
#frameOptions;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @constructor
|
|
87
|
+
* @param {SunEditor.Kernel} kernel
|
|
88
|
+
*/
|
|
89
|
+
constructor(kernel) {
|
|
90
|
+
this.#$ = kernel.$;
|
|
91
|
+
this.#store = kernel.store;
|
|
92
|
+
|
|
93
|
+
this.#shadowRoot = this.#$.contextProvider.shadowRoot;
|
|
94
|
+
this.#carrierWrapper = this.#$.contextProvider.carrierWrapper;
|
|
95
|
+
this.#context = this.#$.context;
|
|
96
|
+
this.#frameContext = this.#$.frameContext;
|
|
97
|
+
this.#options = this.#$.options;
|
|
98
|
+
this.#frameOptions = this.#$.frameOptions;
|
|
99
|
+
}
|
|
95
100
|
|
|
96
|
-
Offset.prototype = {
|
|
97
101
|
/**
|
|
98
|
-
* @this {OffsetThis}
|
|
99
102
|
* @description Gets the position just outside the argument's internal editor (wysiwygFrame).
|
|
100
103
|
* @param {Node} node Target node.
|
|
101
104
|
* @returns {OffsetInfo} Position relative to the editor frame.
|
|
102
105
|
*/
|
|
103
106
|
get(node) {
|
|
104
|
-
const wFrame = this
|
|
107
|
+
const wFrame = this.#frameContext.get('wysiwygFrame');
|
|
105
108
|
const iframe = /iframe/i.test(wFrame?.nodeName);
|
|
106
109
|
const off = this.getLocal(node);
|
|
107
110
|
|
|
108
111
|
return {
|
|
109
112
|
left: off.left + (iframe ? wFrame.parentElement.offsetLeft : 0),
|
|
110
|
-
top: off.top + (iframe ? wFrame.parentElement.offsetTop : 0)
|
|
113
|
+
top: off.top + (iframe ? wFrame.parentElement.offsetTop : 0),
|
|
111
114
|
};
|
|
112
|
-
}
|
|
115
|
+
}
|
|
113
116
|
|
|
114
117
|
/**
|
|
115
|
-
* @this {OffsetThis}
|
|
116
118
|
* @description Gets the position inside the internal editor of the argument.
|
|
117
119
|
* @param {Node} node Target node.
|
|
118
120
|
* @returns {OffsetLocalInfo} Position relative to the WYSIWYG editor.
|
|
@@ -135,89 +137,79 @@ Offset.prototype = {
|
|
|
135
137
|
offsetElement = /** @type {HTMLElement} */ (offsetElement.offsetParent);
|
|
136
138
|
}
|
|
137
139
|
|
|
138
|
-
const wwFrame = this
|
|
139
|
-
if (this
|
|
140
|
+
const wwFrame = this.#frameContext.get('wysiwygFrame');
|
|
141
|
+
if (this.#frameContext.get('wysiwyg').contains(target)) {
|
|
140
142
|
l = wwFrame.offsetLeft;
|
|
141
143
|
t = wwFrame.offsetTop;
|
|
142
144
|
r = wwFrame.parentElement.offsetWidth - (wwFrame.offsetLeft + wwFrame.offsetWidth);
|
|
143
145
|
}
|
|
144
146
|
|
|
145
|
-
const eventWysiwyg = this
|
|
146
|
-
offsetLeft += l;
|
|
147
|
+
const eventWysiwyg = this.#frameContext.get('eventWysiwyg');
|
|
148
|
+
offsetLeft += l - (wysiwyg ? wysiwyg.scrollLeft : 0);
|
|
147
149
|
offsetTop += t - (wysiwyg ? wysiwyg.scrollTop : 0);
|
|
148
150
|
return {
|
|
149
151
|
left: offsetLeft,
|
|
150
152
|
top: offsetTop,
|
|
151
153
|
right: offsetElement?.offsetWidth ? offsetElement.offsetWidth - (offsetLeft - l + targetWidth) + r : 0,
|
|
152
|
-
scrollX: eventWysiwyg.
|
|
153
|
-
scrollY: eventWysiwyg.
|
|
154
|
+
scrollX: eventWysiwyg.scrollLeft || eventWysiwyg.scrollX || 0,
|
|
155
|
+
scrollY: eventWysiwyg.scrollTop || eventWysiwyg.scrollY || 0,
|
|
156
|
+
scrollH: this.#frameContext.get('wysiwyg').scrollHeight || 0,
|
|
154
157
|
};
|
|
155
|
-
}
|
|
158
|
+
}
|
|
156
159
|
|
|
157
160
|
/**
|
|
158
|
-
* @this {OffsetThis}
|
|
159
161
|
* @description Returns the position of the argument relative to the global document.
|
|
160
|
-
*
|
|
162
|
+
* This is a refactored version using getBoundingClientRect for better performance and accuracy.
|
|
163
|
+
* @param {?Node} [node] Target element.
|
|
161
164
|
* @returns {OffsetGlobalInfo} Global position and scroll values.
|
|
162
165
|
*/
|
|
163
166
|
getGlobal(node) {
|
|
164
|
-
const topArea = this
|
|
165
|
-
const wFrame = this
|
|
167
|
+
const topArea = this.#frameContext.get('topArea');
|
|
168
|
+
const wFrame = this.#frameContext.get('wysiwygFrame');
|
|
166
169
|
|
|
167
|
-
|
|
168
|
-
let targetAbs = false;
|
|
169
|
-
if (!node) node = topArea;
|
|
170
|
-
if (node === topArea) isTop = true;
|
|
171
|
-
if (!isTop && isElement(node)) {
|
|
172
|
-
targetAbs = _w.getComputedStyle(node).position === 'absolute';
|
|
173
|
-
}
|
|
170
|
+
node ||= topArea;
|
|
174
171
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const h = element.offsetHeight;
|
|
178
|
-
let t = 0,
|
|
179
|
-
l = 0,
|
|
180
|
-
st = 0,
|
|
181
|
-
sl = 0;
|
|
182
|
-
|
|
183
|
-
while (element) {
|
|
184
|
-
t += element.offsetTop;
|
|
185
|
-
l += element.offsetLeft;
|
|
186
|
-
st += element.scrollTop;
|
|
187
|
-
sl += element.scrollLeft;
|
|
188
|
-
element = /** @type {HTMLElement} */ (element.offsetParent);
|
|
172
|
+
if (!isElement(node)) {
|
|
173
|
+
return { top: 0, left: 0, fixedTop: 0, fixedLeft: 0, width: 0, height: 0 };
|
|
189
174
|
}
|
|
190
175
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
176
|
+
const element = /** @type {HTMLElement} */ (node);
|
|
177
|
+
|
|
178
|
+
const rect = element.getBoundingClientRect();
|
|
179
|
+
|
|
180
|
+
let top = rect.top;
|
|
181
|
+
let left = rect.left;
|
|
182
|
+
|
|
183
|
+
const isIframe = /^iframe$/i.test(wFrame.nodeName);
|
|
184
|
+
if (isIframe && wFrame.contentDocument.contains(element)) {
|
|
185
|
+
const iframeRect = wFrame.getBoundingClientRect();
|
|
186
|
+
top += iframeRect.top;
|
|
187
|
+
left += iframeRect.left;
|
|
198
188
|
}
|
|
199
189
|
|
|
190
|
+
const wy = _w.scrollY;
|
|
191
|
+
const wx = _w.scrollX;
|
|
192
|
+
|
|
200
193
|
return {
|
|
201
|
-
top:
|
|
202
|
-
left:
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
194
|
+
top: top + wy,
|
|
195
|
+
left: left + wx,
|
|
196
|
+
fixedTop: top,
|
|
197
|
+
fixedLeft: left,
|
|
198
|
+
width: element.offsetWidth,
|
|
199
|
+
height: element.offsetHeight,
|
|
207
200
|
};
|
|
208
|
-
}
|
|
201
|
+
}
|
|
209
202
|
|
|
210
203
|
/**
|
|
211
|
-
* @this {OffsetThis}
|
|
212
204
|
* @description Gets the current editor-relative scroll offset.
|
|
213
|
-
* @param {?Node
|
|
205
|
+
* @param {?Node} [node] Target element.
|
|
214
206
|
* @returns {OffsetGlobalScrollInfo} Global scroll information.
|
|
215
207
|
*/
|
|
216
208
|
getGlobalScroll(node) {
|
|
217
|
-
const topArea = this
|
|
209
|
+
const topArea = this.#frameContext.get('topArea');
|
|
218
210
|
let isTop = false;
|
|
219
211
|
let targetAbs = false;
|
|
220
|
-
|
|
212
|
+
node ||= topArea;
|
|
221
213
|
if (node === topArea) isTop = true;
|
|
222
214
|
if (!isTop && isElement(node)) {
|
|
223
215
|
targetAbs = _w.getComputedStyle(node).position === 'absolute';
|
|
@@ -246,7 +238,7 @@ Offset.prototype = {
|
|
|
246
238
|
if (el.scrollTop > 0) {
|
|
247
239
|
y += el.offsetTop;
|
|
248
240
|
}
|
|
249
|
-
if (el.scrollHeight
|
|
241
|
+
if (el.scrollHeight >= el.clientHeight) {
|
|
250
242
|
oh = /^html$/i.test(el.nodeName) ? oh || el.clientHeight : el.clientHeight + (ohel ? -ohel.clientTop : 0);
|
|
251
243
|
ohOffsetEl = ohel || ohOffsetEl || el;
|
|
252
244
|
ohel = el;
|
|
@@ -254,7 +246,7 @@ Offset.prototype = {
|
|
|
254
246
|
if (el.scrollLeft > 0) {
|
|
255
247
|
x += el.offsetLeft;
|
|
256
248
|
}
|
|
257
|
-
if (el.scrollWidth
|
|
249
|
+
if (el.scrollWidth >= el.clientWidth) {
|
|
258
250
|
ow = /^html$/i.test(el.nodeName) ? ow || el.clientWidth : el.clientWidth + (owel ? -owel.clientLeft : 0);
|
|
259
251
|
owOffsetEl = owel || owOffsetEl || el;
|
|
260
252
|
owel = el;
|
|
@@ -262,8 +254,8 @@ Offset.prototype = {
|
|
|
262
254
|
el = el.parentElement;
|
|
263
255
|
}
|
|
264
256
|
|
|
265
|
-
if (!targetAbs && !isTop && /^iframe$/i.test(this
|
|
266
|
-
el = this
|
|
257
|
+
if (!targetAbs && !isTop && /^iframe$/i.test(this.#frameContext.get('wysiwygFrame').nodeName)) {
|
|
258
|
+
el = this.#frameContext.get('wrapper');
|
|
267
259
|
ohOffsetEl = owOffsetEl = topArea;
|
|
268
260
|
while (el) {
|
|
269
261
|
t += el.scrollTop;
|
|
@@ -273,14 +265,14 @@ Offset.prototype = {
|
|
|
273
265
|
if (el.scrollTop > 0) {
|
|
274
266
|
y += el.offsetTop;
|
|
275
267
|
}
|
|
276
|
-
if (el.scrollHeight
|
|
268
|
+
if (el.scrollHeight >= el.clientHeight) {
|
|
277
269
|
oh = /^html$/i.test(el.nodeName) ? oh || el.clientHeight : el.clientHeight + (ohel ? -ohel.clientTop : 0);
|
|
278
270
|
ohel = el;
|
|
279
271
|
}
|
|
280
272
|
if (el.scrollLeft > 0) {
|
|
281
273
|
x += el.offsetLeft;
|
|
282
274
|
}
|
|
283
|
-
if (el.scrollWidth
|
|
275
|
+
if (el.scrollWidth >= el.clientWidth) {
|
|
284
276
|
ow = /^html$/i.test(el.nodeName) ? ow || el.clientWidth : el.clientWidth + (owel ? -owel.clientLeft : 0);
|
|
285
277
|
owel = el;
|
|
286
278
|
}
|
|
@@ -288,7 +280,7 @@ Offset.prototype = {
|
|
|
288
280
|
}
|
|
289
281
|
}
|
|
290
282
|
|
|
291
|
-
el = /** @type {HTMLElement} */ (this
|
|
283
|
+
el = /** @type {HTMLElement} */ (this.#shadowRoot?.host);
|
|
292
284
|
if (el) ohOffsetEl = owOffsetEl = topArea;
|
|
293
285
|
while (el) {
|
|
294
286
|
t += el.scrollTop;
|
|
@@ -298,14 +290,14 @@ Offset.prototype = {
|
|
|
298
290
|
if (el.scrollTop > 0) {
|
|
299
291
|
y += el.offsetTop;
|
|
300
292
|
}
|
|
301
|
-
if (el.scrollHeight
|
|
293
|
+
if (el.scrollHeight >= el.clientHeight) {
|
|
302
294
|
oh = /^html$/i.test(el.nodeName) ? oh || el.clientHeight : el.clientHeight + (ohel ? -ohel.clientTop : 0);
|
|
303
295
|
ohel = el;
|
|
304
296
|
}
|
|
305
297
|
if (el.scrollLeft > 0) {
|
|
306
298
|
x += el.offsetLeft;
|
|
307
299
|
}
|
|
308
|
-
if (el.scrollWidth
|
|
300
|
+
if (el.scrollWidth >= el.clientWidth) {
|
|
309
301
|
ow = /^html$/i.test(el.nodeName) ? ow || el.clientWidth : el.clientWidth + (owel ? -owel.clientLeft : 0);
|
|
310
302
|
owel = el;
|
|
311
303
|
}
|
|
@@ -322,7 +314,7 @@ Offset.prototype = {
|
|
|
322
314
|
oh = heightEditorRefer ? topArea.clientHeight : oh;
|
|
323
315
|
ow = widthEditorRefer ? topArea.clientWidth : ow;
|
|
324
316
|
|
|
325
|
-
const clientSize = getClientSize(this
|
|
317
|
+
const clientSize = getClientSize(this.#frameContext.get('_wd'));
|
|
326
318
|
return {
|
|
327
319
|
top: t,
|
|
328
320
|
left: l,
|
|
@@ -337,114 +329,97 @@ Offset.prototype = {
|
|
|
337
329
|
oh: targetAbs ? clientSize.h : oh,
|
|
338
330
|
ow: targetAbs ? clientSize.w : ow,
|
|
339
331
|
heightEditorRefer: heightEditorRefer,
|
|
340
|
-
widthEditorRefer: widthEditorRefer
|
|
332
|
+
widthEditorRefer: widthEditorRefer,
|
|
341
333
|
};
|
|
342
|
-
}
|
|
334
|
+
}
|
|
343
335
|
|
|
344
336
|
/**
|
|
345
|
-
* @this {OffsetThis}
|
|
346
337
|
* @description Get the scroll info of the WYSIWYG area.
|
|
347
338
|
* @returns {OffsetWWScrollInfo} Scroll information within the editor.
|
|
348
339
|
*/
|
|
349
340
|
getWWScroll() {
|
|
350
|
-
const eventWysiwyg = this
|
|
351
|
-
const
|
|
352
|
-
const
|
|
353
|
-
const height = eventWysiwyg.scrollHeight || 0;
|
|
341
|
+
const eventWysiwyg = this.#frameContext.get('eventWysiwyg');
|
|
342
|
+
const top = eventWysiwyg.scrollTop || eventWysiwyg.scrollY || 0;
|
|
343
|
+
const height = eventWysiwyg.scrollHeight || eventWysiwyg.document?.documentElement.scrollHeight || 0;
|
|
354
344
|
|
|
355
345
|
return {
|
|
356
346
|
top,
|
|
357
|
-
left: eventWysiwyg.
|
|
358
|
-
width: eventWysiwyg.scrollWidth || 0,
|
|
347
|
+
left: eventWysiwyg.scrollLeft || eventWysiwyg.scrollX || 0,
|
|
348
|
+
width: eventWysiwyg.scrollWidth || eventWysiwyg.document?.documentElement.scrollWidth || 0,
|
|
359
349
|
height,
|
|
360
350
|
bottom: top + height,
|
|
361
|
-
rects
|
|
362
351
|
};
|
|
363
|
-
}
|
|
352
|
+
}
|
|
364
353
|
|
|
365
354
|
/**
|
|
366
|
-
* @this {OffsetThis}
|
|
367
355
|
* @description Sets the relative position of an element
|
|
368
356
|
* @param {HTMLElement} element Element to position
|
|
369
357
|
* @param {HTMLElement} e_container Element's root container
|
|
370
358
|
* @param {HTMLElement} target Target element to position against
|
|
371
359
|
* @param {HTMLElement} t_container Target's root container
|
|
372
|
-
* @param {boolean} _reload Whether to reload position
|
|
373
360
|
*/
|
|
374
|
-
setRelPosition(element, e_container, target, t_container
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
361
|
+
setRelPosition(element, e_container, target, t_container) {
|
|
362
|
+
const isFixedContainer = /^fixed$/i.test(_w.getComputedStyle(t_container).position);
|
|
363
|
+
const tGlobal = this.getGlobal(target);
|
|
364
|
+
|
|
365
|
+
// top
|
|
366
|
+
if (isFixedContainer) {
|
|
367
|
+
element.style.position = 'fixed';
|
|
368
|
+
element.style.top = `${tGlobal.fixedTop + tGlobal.height}px`;
|
|
369
|
+
} else {
|
|
370
|
+
element.style.position = '';
|
|
371
|
+
|
|
372
|
+
const isSameContainer = t_container.contains(element);
|
|
373
|
+
const containerTop = isSameContainer ? this.getGlobal(e_container).top : 0;
|
|
374
|
+
const elHeight = element.offsetHeight;
|
|
375
|
+
const scrollTop = this.getGlobalScroll().top;
|
|
376
|
+
const bt = tGlobal.top;
|
|
377
|
+
|
|
378
|
+
const menuHeight_bottom = getClientSize(_d).h - (containerTop - scrollTop + bt + target.offsetHeight);
|
|
379
|
+
if (menuHeight_bottom < elHeight) {
|
|
380
|
+
let menuTop = -1 * (elHeight - bt + 3);
|
|
381
|
+
const insTop = containerTop - scrollTop + menuTop;
|
|
382
|
+
const menuHeight_top = elHeight + (insTop < 0 ? insTop : 0);
|
|
383
|
+
|
|
384
|
+
if (menuHeight_top > menuHeight_bottom) {
|
|
385
|
+
element.style.height = `${menuHeight_top}px`;
|
|
386
|
+
menuTop = -1 * (menuHeight_top - bt + 3);
|
|
387
|
+
} else {
|
|
388
|
+
element.style.height = `${menuHeight_bottom}px`;
|
|
389
|
+
menuTop = bt + target.offsetHeight;
|
|
390
|
+
}
|
|
384
391
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
392
|
+
element.style.top = `${menuTop}px`;
|
|
393
|
+
} else {
|
|
394
|
+
element.style.top = `${bt + target.offsetHeight}px`;
|
|
395
|
+
}
|
|
388
396
|
}
|
|
389
397
|
|
|
398
|
+
// left
|
|
390
399
|
const ew = element.offsetWidth;
|
|
391
400
|
const tw = target.offsetWidth;
|
|
392
|
-
const tl =
|
|
401
|
+
const tl = tGlobal.left;
|
|
393
402
|
const tcleft = this.getGlobal(t_container).left;
|
|
394
403
|
|
|
395
|
-
|
|
396
|
-
if (this.options.get('_rtl')) {
|
|
404
|
+
if (this.#options.get('_rtl')) {
|
|
397
405
|
const rtlW = ew > tw ? ew - tw : 0;
|
|
398
406
|
const rtlL = rtlW > 0 ? 0 : tw - ew;
|
|
399
|
-
element.style.left = `${tl - rtlW + rtlL
|
|
407
|
+
element.style.left = `${tl - rtlW + rtlL}px`;
|
|
400
408
|
if (tcleft > this.getGlobal(element).left) {
|
|
401
409
|
element.style.left = tcleft + 'px';
|
|
402
410
|
}
|
|
403
411
|
} else {
|
|
404
412
|
const cw = t_container.offsetWidth + tcleft;
|
|
405
413
|
const overLeft = cw <= ew ? 0 : cw - (tl + ew);
|
|
406
|
-
if (overLeft < 0)
|
|
407
|
-
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
// top
|
|
411
|
-
const isSameContainer = t_container.contains(element);
|
|
412
|
-
const containerTop = isSameContainer ? this.getGlobal(e_container).top : 0;
|
|
413
|
-
const elHeight = element.offsetHeight;
|
|
414
|
-
const scrollTop = this.getGlobalScroll().top;
|
|
415
|
-
let bt = wy;
|
|
416
|
-
let offsetEl = target;
|
|
417
|
-
while (offsetEl && offsetEl !== e_container) {
|
|
418
|
-
bt += offsetEl.offsetTop;
|
|
419
|
-
offsetEl = /** @type {HTMLElement} */ (offsetEl.offsetParent);
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
const menuHeight_bottom = getClientSize(_d).h - (containerTop - scrollTop + bt + target.offsetHeight);
|
|
423
|
-
if (menuHeight_bottom < elHeight) {
|
|
424
|
-
let menuTop = -1 * (elHeight - bt + 3);
|
|
425
|
-
const insTop = containerTop - scrollTop + menuTop;
|
|
426
|
-
const menuHeight_top = elHeight + (insTop < 0 ? insTop : 0);
|
|
427
|
-
|
|
428
|
-
if (menuHeight_top > menuHeight_bottom) {
|
|
429
|
-
element.style.height = `${menuHeight_top}px`;
|
|
430
|
-
menuTop = -1 * (menuHeight_top - bt + 3);
|
|
414
|
+
if (overLeft < 0) {
|
|
415
|
+
element.style.left = `${tl + overLeft}px`;
|
|
431
416
|
} else {
|
|
432
|
-
element.style.
|
|
433
|
-
menuTop = bt + target.offsetHeight;
|
|
417
|
+
element.style.left = `${tl}px`;
|
|
434
418
|
}
|
|
435
|
-
|
|
436
|
-
element.style.top = `${menuTop}px`;
|
|
437
|
-
} else {
|
|
438
|
-
element.style.top = `${bt + target.offsetHeight}px`;
|
|
439
419
|
}
|
|
440
|
-
|
|
441
|
-
if (this._isFixed) {
|
|
442
|
-
this._elTop = element.offsetTop;
|
|
443
|
-
}
|
|
444
|
-
},
|
|
420
|
+
}
|
|
445
421
|
|
|
446
422
|
/**
|
|
447
|
-
* @this {OffsetThis}
|
|
448
423
|
* @description Sets the absolute position of an element
|
|
449
424
|
* @param {HTMLElement} element Element to position
|
|
450
425
|
* @param {HTMLElement} target Target element
|
|
@@ -453,76 +428,97 @@ Offset.prototype = {
|
|
|
453
428
|
* @param {{left:number, top:number}} [params.addOffset={left:0, top:0}] Additional offset
|
|
454
429
|
* @param {"bottom"|"top"} [params.position="bottom"] Position ('bottom'|'top')
|
|
455
430
|
* @param {*} params.inst Instance object of caller
|
|
431
|
+
* @param {HTMLElement} [params.sibling=null] The sibling controller element
|
|
456
432
|
* @returns {{position: "top" | "bottom"} | undefined} Success -> {position: current position}
|
|
457
433
|
*/
|
|
458
434
|
setAbsPosition(element, target, params) {
|
|
459
435
|
const addOffset = {
|
|
460
436
|
left: 0,
|
|
461
437
|
top: 0,
|
|
462
|
-
...params.addOffset
|
|
438
|
+
...params.addOffset,
|
|
463
439
|
};
|
|
464
440
|
const position = params.position || 'bottom';
|
|
465
441
|
const inst = params.inst;
|
|
466
|
-
const isLTR = !this
|
|
442
|
+
const isLTR = !this.#options.get('_rtl');
|
|
467
443
|
|
|
468
444
|
if (!isLTR) {
|
|
469
445
|
addOffset.left *= -1;
|
|
470
446
|
}
|
|
471
447
|
|
|
472
|
-
const
|
|
473
|
-
const
|
|
474
|
-
const
|
|
448
|
+
const isIframe = this.#frameOptions.get('iframe');
|
|
449
|
+
const isWWTarget = this.#frameContext.get('wrapper').contains(target) || params.isWWTarget || (isIframe ? this.#frameContext.get('wysiwyg').contains(target) : false);
|
|
450
|
+
const isToolbarTarget = Boolean(getParentElement(target, '.se-toolbar'));
|
|
451
|
+
const isElTarget = target.nodeType === 1;
|
|
452
|
+
|
|
453
|
+
const isTextSelection = isWWTarget && !isElTarget;
|
|
454
|
+
const isInlineTarget = isElTarget && /inline/.test(_w.getComputedStyle(target).display);
|
|
475
455
|
const clientSize = getClientSize(_d);
|
|
476
|
-
const wwScroll =
|
|
477
|
-
const targetRect =
|
|
456
|
+
const wwScroll = isTextSelection ? this.getWWScroll() : this.#getWindowScroll();
|
|
457
|
+
const targetRect = !isWWTarget || (!isIframe && isElTarget) ? target.getBoundingClientRect() : this.#$.selection.getRects(target, 'start').rects;
|
|
478
458
|
const targetOffset = this.getGlobal(target);
|
|
479
459
|
const arrow = /** @type {HTMLElement} */ (hasClass(element.firstElementChild, 'se-arrow') ? element.firstElementChild : null);
|
|
480
460
|
|
|
481
461
|
// top ----------------------------------------------------------------------------------------------------
|
|
462
|
+
const siblingH = params.sibling?.offsetHeight || 0;
|
|
482
463
|
const ah = arrow ? arrow.offsetHeight : 0;
|
|
483
464
|
const elH = element.offsetHeight;
|
|
484
465
|
const targetH = target.offsetHeight;
|
|
485
466
|
// margin
|
|
486
467
|
const tmtw = targetRect.top;
|
|
487
468
|
const tmbw = clientSize.h - targetRect.bottom;
|
|
488
|
-
const
|
|
469
|
+
const globalTop = this.getGlobal(this.#frameContext.get('topArea')).top;
|
|
470
|
+
const wScrollY = _w.scrollY;
|
|
471
|
+
const th = this.#context.get('toolbar_main').offsetHeight;
|
|
472
|
+
const containerToolbar = this.#options.get('toolbar_container');
|
|
473
|
+
const headLess = this.#store.mode.isBalloon || this.#store.mode.isInline || containerToolbar;
|
|
474
|
+
const toolbarH = (containerToolbar && globalTop - wScrollY - th > 0) || (!this.#$.toolbar.isSticky && headLess) ? 0 : th + (this.#$.toolbar.isSticky ? this.#options.get('toolbar_sticky') : 0);
|
|
475
|
+
const statusBarH = this.#frameContext.get('statusbar')?.offsetHeight || 0;
|
|
489
476
|
|
|
490
477
|
// check margin
|
|
491
|
-
const { rmt, rmb, rt } = this
|
|
492
|
-
if (isWWTarget && (rmb + targetH <= 0 || rmt + rt + targetH <= 0)) return;
|
|
478
|
+
const { rmt, rmb, bMargin, rt } = this.#getVMargin(tmtw, tmbw, toolbarH, clientSize, targetRect, isTextSelection, isToolbarTarget);
|
|
479
|
+
if ((isWWTarget && (rmb - statusBarH + targetH <= 0 || rmt + rt + targetH - (this.#$.toolbar.isSticky && isInlineTarget ? toolbarH : 0) <= 0)) || rmt + targetH < 0) return;
|
|
493
480
|
|
|
481
|
+
const isSticky = this.#$.toolbar.isSticky && this.#context.get('toolbar_main').style.display !== 'none' && (!headLess || this.#frameContext.get('topArea').getBoundingClientRect().top <= th);
|
|
494
482
|
let t = addOffset.top;
|
|
495
483
|
let y = 0;
|
|
496
484
|
let arrowDir = '';
|
|
485
|
+
|
|
486
|
+
// [bottom] position
|
|
497
487
|
if (position === 'bottom') {
|
|
498
488
|
arrowDir = 'up';
|
|
499
|
-
t += targetRect.bottom + ah +
|
|
489
|
+
t += targetRect.bottom + ah + wScrollY;
|
|
500
490
|
y = rmb - (elH + ah);
|
|
501
|
-
|
|
491
|
+
// change to <top> position
|
|
492
|
+
if (y - siblingH < 0) {
|
|
502
493
|
arrowDir = 'down';
|
|
503
494
|
t -= targetH + elH + ah * 2;
|
|
504
|
-
y =
|
|
505
|
-
|
|
495
|
+
y = rmt - (elH + ah);
|
|
496
|
+
// sticky the <top> position
|
|
497
|
+
if (y - siblingH < 0) {
|
|
506
498
|
arrowDir = '';
|
|
507
|
-
t -= y;
|
|
499
|
+
t -= y - siblingH - Math.max(1, y + elH + ah);
|
|
508
500
|
}
|
|
509
501
|
}
|
|
510
|
-
}
|
|
502
|
+
}
|
|
503
|
+
// <top> position
|
|
504
|
+
else {
|
|
511
505
|
arrowDir = 'down';
|
|
512
|
-
t += targetRect.top - elH - ah +
|
|
513
|
-
y = rmt -
|
|
514
|
-
|
|
506
|
+
t += targetRect.top - elH - ah + wScrollY;
|
|
507
|
+
y = (isSticky ? targetRect.top - toolbarH : rmt) - elH - ah;
|
|
508
|
+
// change to [bottom] position
|
|
509
|
+
if (y - siblingH < 0) {
|
|
515
510
|
arrowDir = 'up';
|
|
516
511
|
t += targetH + elH + ah * 2;
|
|
517
|
-
y = rmb - (elH + ah);
|
|
518
|
-
|
|
512
|
+
y = (rmb > 0 ? bMargin : rmb) - (elH + ah) - statusBarH;
|
|
513
|
+
// sticky the [bottom] position
|
|
514
|
+
if (y - siblingH < 0) {
|
|
519
515
|
arrowDir = '';
|
|
520
|
-
t += y;
|
|
516
|
+
t += y - 2;
|
|
521
517
|
}
|
|
522
518
|
}
|
|
523
519
|
}
|
|
524
520
|
|
|
525
|
-
this
|
|
521
|
+
this.#setArrow(arrow, arrowDir);
|
|
526
522
|
element.style.top = `${t}px`;
|
|
527
523
|
|
|
528
524
|
// left ----------------------------------------------------------------------------------------------------
|
|
@@ -531,16 +527,8 @@ Offset.prototype = {
|
|
|
531
527
|
const elW = element.offsetWidth;
|
|
532
528
|
const aw = arrow ? arrow.offsetWidth : 0;
|
|
533
529
|
// margin
|
|
534
|
-
const
|
|
535
|
-
const
|
|
536
|
-
let rml, rmr;
|
|
537
|
-
if (this.editor.frameContext.get('isFullScreen')) {
|
|
538
|
-
rml = tmlw;
|
|
539
|
-
rmr = tmrw;
|
|
540
|
-
} else {
|
|
541
|
-
rml = targetRect.left;
|
|
542
|
-
rmr = clientSize.w - targetRect.right;
|
|
543
|
-
}
|
|
530
|
+
const rml = targetRect.left;
|
|
531
|
+
const rmr = clientSize.w - targetRect.right;
|
|
544
532
|
|
|
545
533
|
if (isWWTarget && (rml + targetW <= 0 || rmr + targetW <= 0)) return;
|
|
546
534
|
if (arrow) {
|
|
@@ -588,14 +576,13 @@ Offset.prototype = {
|
|
|
588
576
|
inst.__offset = {
|
|
589
577
|
left: element.offsetLeft + wwScroll.left,
|
|
590
578
|
top: element.offsetTop + wwScroll.top,
|
|
591
|
-
addOffset: addOffset
|
|
579
|
+
addOffset: addOffset,
|
|
592
580
|
};
|
|
593
581
|
|
|
594
582
|
return { position: arrowDir === 'up' ? 'bottom' : 'top' };
|
|
595
|
-
}
|
|
583
|
+
}
|
|
596
584
|
|
|
597
585
|
/**
|
|
598
|
-
* @this {OffsetThis}
|
|
599
586
|
* @description Sets the position of an element relative to a range
|
|
600
587
|
* @param {HTMLElement} element Element to position
|
|
601
588
|
* @param {?Range} range Range to position against.
|
|
@@ -611,12 +598,12 @@ Offset.prototype = {
|
|
|
611
598
|
element.style.display = 'block';
|
|
612
599
|
|
|
613
600
|
let positionTop = position === 'top';
|
|
614
|
-
range
|
|
615
|
-
const rectsObj = this
|
|
601
|
+
range ||= this.#$.selection.getRange();
|
|
602
|
+
const rectsObj = this.#$.selection.getRects(range, positionTop ? 'start' : 'end');
|
|
616
603
|
positionTop = rectsObj.position === 'start';
|
|
617
604
|
|
|
618
|
-
const isFullScreen = this
|
|
619
|
-
const topArea = this
|
|
605
|
+
const isFullScreen = this.#frameContext.get('isFullScreen');
|
|
606
|
+
const topArea = this.#frameContext.get('topArea');
|
|
620
607
|
const rects = rectsObj.rects;
|
|
621
608
|
const scrollLeft = isFullScreen ? 0 : rectsObj.scrollLeft;
|
|
622
609
|
const scrollTop = isFullScreen ? 0 : rectsObj.scrollTop;
|
|
@@ -626,38 +613,33 @@ Offset.prototype = {
|
|
|
626
613
|
const toolbarWidth = element.offsetWidth;
|
|
627
614
|
const toolbarHeight = element.offsetHeight;
|
|
628
615
|
|
|
629
|
-
this
|
|
616
|
+
this.#setOffsetOnRange(positionTop, rects, element, editorLeft, editorWidth, scrollLeft, scrollTop, addTop);
|
|
630
617
|
if (this.getGlobal(element).top - offsets.top < 0) {
|
|
631
618
|
positionTop = !positionTop;
|
|
632
|
-
this
|
|
619
|
+
this.#setOffsetOnRange(positionTop, rects, element, editorLeft, editorWidth, scrollLeft, scrollTop, addTop);
|
|
633
620
|
}
|
|
634
621
|
|
|
635
622
|
if (toolbarWidth !== element.offsetWidth || toolbarHeight !== element.offsetHeight) {
|
|
636
|
-
this
|
|
623
|
+
this.#setOffsetOnRange(positionTop, rects, element, editorLeft, editorWidth, scrollLeft, scrollTop, addTop);
|
|
637
624
|
}
|
|
638
625
|
|
|
639
626
|
// check margin
|
|
640
|
-
const
|
|
627
|
+
const isTextSelection = !this.#carrierWrapper.contains(element);
|
|
641
628
|
const clientSize = getClientSize(_d);
|
|
642
|
-
const wwScroll = isTargetAbs ? this.getWWScroll() : this._getWindowScroll();
|
|
643
629
|
const targetH = rects.height;
|
|
644
630
|
const tmtw = rects.top;
|
|
645
631
|
const tmbw = clientSize.h - rects.bottom;
|
|
646
|
-
const toolbarH = !this
|
|
632
|
+
const toolbarH = !this.#$.toolbar.isSticky && (this.#store.mode.isBalloon || this.#store.mode.isInline) ? 0 : this.#context.get('toolbar_main').offsetHeight;
|
|
647
633
|
|
|
648
|
-
const { rmt, rmb, rt } = this
|
|
634
|
+
const { rmt, rmb, rt } = this.#getVMargin(tmtw, tmbw, toolbarH, clientSize, rects, isTextSelection, false);
|
|
649
635
|
if (rmb + targetH <= 0 || rmt + rt + targetH <= 0) return;
|
|
650
636
|
|
|
651
|
-
|
|
652
|
-
element.style.visibility = '';
|
|
653
|
-
}, 0);
|
|
637
|
+
element.style.visibility = '';
|
|
654
638
|
|
|
655
639
|
return true;
|
|
656
|
-
}
|
|
640
|
+
}
|
|
657
641
|
|
|
658
642
|
/**
|
|
659
|
-
* @private
|
|
660
|
-
* @this {OffsetThis}
|
|
661
643
|
* @description Sets the position of an element relative to the selection range in the editor.
|
|
662
644
|
* - This method calculates the top and left offsets for the element, ensuring it
|
|
663
645
|
* - does not overflow the editor boundaries and adjusts the arrow positioning accordingly.
|
|
@@ -670,7 +652,7 @@ Offset.prototype = {
|
|
|
670
652
|
* @param {number} scrollTop - The vertical scroll offset.
|
|
671
653
|
* @param {number} [addTop=0] - Additional top margin adjustment.
|
|
672
654
|
*/
|
|
673
|
-
|
|
655
|
+
#setOffsetOnRange(isDirTop, rects, element, editorLeft, editorWidth, scrollLeft, scrollTop, addTop = 0) {
|
|
674
656
|
const padding = 1;
|
|
675
657
|
const arrow = /** @type {HTMLElement} */ (element.querySelector('.se-arrow '));
|
|
676
658
|
const arrowMargin = Math.round(arrow.offsetWidth / 2);
|
|
@@ -684,8 +666,8 @@ Offset.prototype = {
|
|
|
684
666
|
const l = absoluteLeft < 0 ? padding : overRight < 0 ? absoluteLeft : absoluteLeft - overRight - padding - 1;
|
|
685
667
|
|
|
686
668
|
let resetTop = false;
|
|
687
|
-
const space = t + (isDirTop ? this.getGlobal(this
|
|
688
|
-
if (!isDirTop && space > 0 && this
|
|
669
|
+
const space = t + (isDirTop ? this.getGlobal(this.#frameContext.get('topArea')).top : element.offsetHeight - this.#frameContext.get('wysiwyg').offsetHeight);
|
|
670
|
+
if (!isDirTop && space > 0 && this.#getPageBottomSpace() < space) {
|
|
689
671
|
isDirTop = true;
|
|
690
672
|
resetTop = true;
|
|
691
673
|
} else if (isDirTop && _d.documentElement.offsetTop > space) {
|
|
@@ -708,22 +690,18 @@ Offset.prototype = {
|
|
|
708
690
|
|
|
709
691
|
const arrow_left = Math.floor(elW / 2 + (absoluteLeft - l));
|
|
710
692
|
arrow.style.left = (arrow_left + arrowMargin > element.offsetWidth ? element.offsetWidth - arrowMargin : arrow_left < arrowMargin ? arrowMargin : arrow_left) + 'px';
|
|
711
|
-
}
|
|
693
|
+
}
|
|
712
694
|
|
|
713
695
|
/**
|
|
714
|
-
* @private
|
|
715
|
-
* @this {OffsetThis}
|
|
716
696
|
* @description Get available space from page bottom
|
|
717
697
|
* @returns {number} Available space
|
|
718
698
|
*/
|
|
719
|
-
|
|
720
|
-
const topArea = this
|
|
699
|
+
#getPageBottomSpace() {
|
|
700
|
+
const topArea = this.#frameContext.get('topArea');
|
|
721
701
|
return _d.documentElement.scrollHeight - (this.getGlobal(topArea).top + topArea.offsetHeight);
|
|
722
|
-
}
|
|
702
|
+
}
|
|
723
703
|
|
|
724
704
|
/**
|
|
725
|
-
* @private
|
|
726
|
-
* @this {OffsetThis}
|
|
727
705
|
* @description Calculates the vertical margin offsets for the target element relative to the editor frame.
|
|
728
706
|
* - This method determines the top and bottom margins based on various conditions such as
|
|
729
707
|
* - fullscreen mode, iframe usage, toolbar height, and scroll positions.
|
|
@@ -732,67 +710,68 @@ Offset.prototype = {
|
|
|
732
710
|
* @param {number} toolbarH Toolbar height
|
|
733
711
|
* @param {{w: number, h: number}} clientSize documentElement.clientWidth, documentElement.clientHeight
|
|
734
712
|
* @param {RectsInfo} targetRect Target rect object
|
|
735
|
-
* @param {boolean}
|
|
736
|
-
* @param {
|
|
737
|
-
* @returns {{rmt:number, rmb:number, rt:number
|
|
713
|
+
* @param {boolean} isTextSelection Is text selection or Range
|
|
714
|
+
* @param {boolean} isToolbarTarget Indicates if the target is a toolbar element
|
|
715
|
+
* @returns {{rmt:number, rmb:number, rt:number, tMargin:number, bMargin:number}} Margin values
|
|
716
|
+
* - rmt: top margin to frame
|
|
717
|
+
* - rmb: bottom margin to frame
|
|
718
|
+
* - rt: Toolbar height offset adjustment
|
|
719
|
+
* - tMargin: top margin
|
|
720
|
+
* - bMargin: bottom margin
|
|
738
721
|
*/
|
|
739
|
-
|
|
722
|
+
#getVMargin(tmtw, tmbw, toolbarH, clientSize, targetRect, isTextSelection, isToolbarTarget) {
|
|
723
|
+
const wwRects = this.#$.selection.getRects(this.#frameContext.get('wysiwyg'), 'start').rects;
|
|
724
|
+
|
|
740
725
|
let rmt = 0;
|
|
741
726
|
let rmb = 0;
|
|
742
727
|
let rt = 0;
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
728
|
+
let tMargin = 0;
|
|
729
|
+
let bMargin = 0;
|
|
730
|
+
|
|
731
|
+
const isIframe = this.#frameOptions.get('iframe');
|
|
732
|
+
tMargin = targetRect.top;
|
|
733
|
+
bMargin = clientSize.h - targetRect.bottom;
|
|
734
|
+
const editorOffset = this.getGlobal();
|
|
735
|
+
|
|
736
|
+
if (!isTextSelection) {
|
|
737
|
+
const emt = editorOffset.fixedTop > 0 ? editorOffset.fixedTop : 0;
|
|
738
|
+
const emb = _w.innerHeight - (editorOffset.fixedTop + editorOffset.height);
|
|
739
|
+
rt = !isToolbarTarget && (this.#$.toolbar.isSticky || !this.#$.toolbar.isBalloonMode) ? toolbarH : 0;
|
|
740
|
+
rmt = tMargin - (!isToolbarTarget ? emt : 0) - rt;
|
|
741
|
+
rmb = bMargin - (emb > 0 ? emb : 0);
|
|
746
742
|
} else {
|
|
747
|
-
|
|
748
|
-
const
|
|
749
|
-
const
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
if (isIframe) {
|
|
755
|
-
const emt = editorOffset.top - editorScroll.top - editorScroll.ts;
|
|
756
|
-
const editorH = this.editor.frameContext.get('topArea').offsetHeight;
|
|
757
|
-
rmt = targetRect.top - emt;
|
|
758
|
-
rmb = bMargin - (editorScroll.oh - (editorH + emt) + statusBarH);
|
|
759
|
-
} else {
|
|
760
|
-
rt = !this.editor.toolbar._sticky && !this.options.get('toolbar_container') ? toolbarH : 0;
|
|
761
|
-
const wst = !isTargetAbs && /\d+/.test(this.editor.frameOptions.get('height')) ? editorOffset.top - _w.scrollY + rt : 0;
|
|
762
|
-
const wsb = !isTargetAbs && /\d+/.test(this.editor.frameOptions.get('height')) ? _w.innerHeight - (editorOffset.top + editorOffset.height - _w.scrollY) : 0;
|
|
763
|
-
let st = wst;
|
|
764
|
-
if (toolbarH > wst) {
|
|
765
|
-
if (this.editor.toolbar._sticky) {
|
|
766
|
-
st = toolbarH;
|
|
767
|
-
toolbarH = 0;
|
|
768
|
-
} else {
|
|
769
|
-
st = wst + toolbarH;
|
|
770
|
-
}
|
|
771
|
-
} else if (this.options.get('toolbar_container')) {
|
|
772
|
-
toolbarH = 0;
|
|
743
|
+
rt = !isToolbarTarget && !this.#$.toolbar.isSticky && !this.#options.get('toolbar_container') ? toolbarH : 0;
|
|
744
|
+
const wst = !isIframe ? editorOffset.top - _w.scrollY + rt : 0;
|
|
745
|
+
const wsb = !isIframe ? this.#store.get('currentViewportHeight') - (editorOffset.top + editorOffset.height - _w.scrollY) : 0;
|
|
746
|
+
let st = wst;
|
|
747
|
+
if (toolbarH > wst) {
|
|
748
|
+
if (this.#$.toolbar.isSticky) {
|
|
749
|
+
st = toolbarH;
|
|
773
750
|
} else {
|
|
774
|
-
st = wst +
|
|
751
|
+
st = wst + toolbarH;
|
|
775
752
|
}
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
753
|
+
} else if (this.#options.get('toolbar_container') && !this.#$.toolbar.isSticky) {
|
|
754
|
+
toolbarH = 0;
|
|
755
|
+
} else {
|
|
756
|
+
st = wst + toolbarH;
|
|
779
757
|
}
|
|
780
758
|
|
|
759
|
+
rmt = targetRect.top - (wwRects.top - st) + toolbarH;
|
|
760
|
+
rmb = wwRects.bottom - (targetRect.bottom - wsb);
|
|
781
761
|
// display margin
|
|
782
|
-
rmt =
|
|
783
|
-
rmb = rmb > 0 ? bMargin : rmb;
|
|
762
|
+
rmt = rmt > 0 ? rmt : rmt - toolbarH;
|
|
784
763
|
}
|
|
785
764
|
|
|
786
765
|
return {
|
|
787
766
|
rmt,
|
|
788
767
|
rmb,
|
|
789
|
-
rt
|
|
768
|
+
rt,
|
|
769
|
+
tMargin,
|
|
770
|
+
bMargin,
|
|
790
771
|
};
|
|
791
|
-
}
|
|
772
|
+
}
|
|
792
773
|
|
|
793
774
|
/**
|
|
794
|
-
* @private
|
|
795
|
-
* @this {OffsetThis}
|
|
796
775
|
* @description Sets the visibility and direction of the arrow element.
|
|
797
776
|
* - This method applies the appropriate class (`se-arrow-up` or `se-arrow-down`)
|
|
798
777
|
* - based on the specified direction key and adjusts the visibility of the arrow.
|
|
@@ -801,7 +780,7 @@ Offset.prototype = {
|
|
|
801
780
|
* - Accepts `'up'` for an upward arrow, `'down'` for a downward arrow,
|
|
802
781
|
* - or any other value to hide the arrow.
|
|
803
782
|
*/
|
|
804
|
-
|
|
783
|
+
#setArrow(arrow, key) {
|
|
805
784
|
if (key === 'up') {
|
|
806
785
|
if (arrow) arrow.style.visibility = '';
|
|
807
786
|
addClass(arrow, 'se-arrow-up');
|
|
@@ -813,11 +792,9 @@ Offset.prototype = {
|
|
|
813
792
|
} else {
|
|
814
793
|
if (arrow) arrow.style.visibility = 'hidden';
|
|
815
794
|
}
|
|
816
|
-
}
|
|
795
|
+
}
|
|
817
796
|
|
|
818
797
|
/**
|
|
819
|
-
* @private
|
|
820
|
-
* @this {OffsetThis}
|
|
821
798
|
* @description Retrieves the current window scroll position and viewport size.
|
|
822
799
|
* - Returns an object containing the scroll offsets, viewport dimensions, and boundary rects.
|
|
823
800
|
* @returns {{
|
|
@@ -829,8 +806,7 @@ Offset.prototype = {
|
|
|
829
806
|
* rects: RectsInfo
|
|
830
807
|
* }} An object with scroll and viewport information.
|
|
831
808
|
*/
|
|
832
|
-
|
|
833
|
-
_getWindowScroll() {
|
|
809
|
+
#getWindowScroll() {
|
|
834
810
|
const viewPort = getClientSize(_d);
|
|
835
811
|
return {
|
|
836
812
|
top: _w.scrollY,
|
|
@@ -842,50 +818,11 @@ Offset.prototype = {
|
|
|
842
818
|
left: 0,
|
|
843
819
|
top: 0,
|
|
844
820
|
right: _w.innerWidth,
|
|
845
|
-
bottom: _w.innerHeight,
|
|
846
|
-
noText: true
|
|
847
|
-
}
|
|
821
|
+
bottom: this.#store.get('currentViewportHeight') || _w.innerHeight,
|
|
822
|
+
noText: true,
|
|
823
|
+
},
|
|
848
824
|
};
|
|
849
|
-
},
|
|
850
|
-
|
|
851
|
-
/**
|
|
852
|
-
* @private
|
|
853
|
-
* @this {OffsetThis}
|
|
854
|
-
* @description Removes the global scroll event listener from the editor.
|
|
855
|
-
* - Resets related scroll tracking properties.
|
|
856
|
-
*/
|
|
857
|
-
__removeGlobalEvent() {
|
|
858
|
-
if (this._scrollEvent) {
|
|
859
|
-
this._scrollEvent = this.editor.eventManager.removeGlobalEvent(this._scrollEvent);
|
|
860
|
-
this._scrollY = 0;
|
|
861
|
-
this._elTop = null;
|
|
862
|
-
}
|
|
863
|
-
},
|
|
864
|
-
|
|
865
|
-
constructor: Offset
|
|
866
|
-
};
|
|
867
|
-
|
|
868
|
-
/**
|
|
869
|
-
* @private
|
|
870
|
-
* @this {OffsetThis}
|
|
871
|
-
* @param {HTMLElement} element - The element to check for a specific class name.
|
|
872
|
-
* @param {HTMLElement} e_container - The root container of the element.
|
|
873
|
-
* @param {HTMLElement} target - The target element to position against.
|
|
874
|
-
* @param {HTMLElement} t_container - The root container of the target element.
|
|
875
|
-
*/
|
|
876
|
-
function FixedScroll(element, e_container, target, t_container) {
|
|
877
|
-
const isFixed = /^fixed$/i.test(_w.getComputedStyle(t_container).position);
|
|
878
|
-
if (!this._isFixed) {
|
|
879
|
-
if (isFixed) {
|
|
880
|
-
this.setRelPosition(element, e_container, target, t_container, true);
|
|
881
|
-
}
|
|
882
|
-
return;
|
|
883
|
-
} else if (!isFixed) {
|
|
884
|
-
this.setRelPosition(element, e_container, target, t_container, true);
|
|
885
|
-
return;
|
|
886
825
|
}
|
|
887
|
-
|
|
888
|
-
element.style.top = `${this._elTop - (this._scrollY - _w.scrollY - t_container.offsetTop)}px`;
|
|
889
826
|
}
|
|
890
827
|
|
|
891
828
|
export default Offset;
|