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()