From b35f50338e0d25ceaa536945e84d338b85e8851e Mon Sep 17 00:00:00 2001 From: yu530feng Date: Fri, 18 Nov 2022 22:06:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=85=8D=E7=BD=AEscroll:=20false?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=AE=B9=E5=99=A8height:=20100%=E4=B8=8D?= =?UTF-8?q?=E7=94=9F=E6=95=88=EF=BC=8C=E6=A0=B7=E5=BC=8F=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=EF=BC=8C=E9=81=BF=E5=85=8D=E6=82=AC=E6=B5=AE=E6=A1=86=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E5=87=BA=E7=8E=B0=E9=94=99=E4=BD=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/assets/textarea.less | 5 +++++ packages/core/src/text-area/TextArea.ts | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/core/src/assets/textarea.less b/packages/core/src/assets/textarea.less index f232f500e..6ccef8cd4 100644 --- a/packages/core/src/assets/textarea.less +++ b/packages/core/src/assets/textarea.less @@ -7,6 +7,11 @@ height: 100%; } +.no-scroll{ + position: absolute; + width: 100%; +} + .w-e-text-container .w-e-scroll { height: 100%; // overflow-y: auto; // 在 js 中设置,根据 config 判断是否增加 scroll diff --git a/packages/core/src/text-area/TextArea.ts b/packages/core/src/text-area/TextArea.ts index b325b5482..0c84f4664 100644 --- a/packages/core/src/text-area/TextArea.ts +++ b/packages/core/src/text-area/TextArea.ts @@ -69,10 +69,15 @@ class TextArea { editor.on('change', this.changeViewState.bind(this)) // editor onchange 时触发用户配置的 onChange (需要在 changeViewState 后执行) - const { onChange } = editor.getConfig() + const { onChange, scroll } = editor.getConfig() if (onChange) { editor.on('change', () => onChange(editor)) } + // scroll: false时,容器height: 100%不生效,样式设置,避免悬浮框位置出现错位问题 + if (!scroll) { + $box.css('position', 'relative') + $container.addClass('no-scroll') + } // 监听 onfocus onblur this.onFocusAndOnBlur()