javascript - 在浮动 div 中设置 CKEditor 5(Vue 组件)的高度
问题描述
我目前在浮动 div(用户可调整大小)中使用 CKEditor 5 - 因此,事先不知道容器的尺寸。
我想将 CK Editor 组件的高度设置为 100%(以填充整个容器) 请注意,将 'height: 100%' 添加到 ck-editor__editable_inline 没有任何作用
我可以通过以下方式更改高度:
document.getElementsByClassName('ck-editor__editable_inline')[0].style.height
= 'calc(' + this.$refs.rteContainer.clientHeight + 'px - 4.5em)';
(4.5em 偏移量用于我的菜单栏)
到目前为止,这工作正常。但是,当组件被聚焦然后模糊时,尺寸会恢复到其原始状态。
我通过将此函数附加到@blur 来解决这个问题:
setTimeout(() => {
document.getElementsByClassName('ck-editor__editable_inline')[0].style.height = 'calc(' + this.$refs.rteContainer.clientHeight + 'px - 4.5em)';
}, 50);
本质上,我在再次覆盖样式之前设置了 50 毫秒的延迟。
这工作正常,但是当样式恢复到其原始状态然后再次被覆盖时会出现明显的闪烁。
有谁知道实现我想要的更好的方法?提前致谢!
解决方案
推荐阅读
- nlp - 如何设置最大 CPU/内核数以将 BERT 作为服务运行?
- python - 使用 python 发送消息
- reactjs - 会话 cookie 不与 XHR 请求一起发送
- php - 如何在 Markmail 支持中写问题(即开放会议支持)
- angular - 如何使用 cdkDropListEnterPredicate 检查多个条件?
- android - React Native:自定义标题未设置为标题导航
- c++ - Visual Studio 2019 中的自动递增 FileVersion (build nr)
- mysql - 使用 sequelize 和 MySQL 方言生成模型
- node.js - 如何使这个 axios 删除请求起作用?
- sql - 使用公共列 POSTGRESQL 在两个表之间映射不同的值