1 回答
TA贡献1841条经验 获得超3个赞
您可以检查事件内的编辑器高度change,看看高度是否发生变化。
请运行以下代码片段并检查控制台:
let editorWidth;
let editorHeight;
ClassicEditor
.create(document.querySelector('#Comment'), {
toolbar: [ 'heading', '|', 'bold', 'italic', 'blockQuote' ],
})
.then(editor => {
editor.model.document.on('change', (eventInfo, name, value, oldValue) => {
const newWidth = editor.ui.view.element.offsetWidth;
const newHeight = editor.ui.view.element.offsetHeight;
if(editorWidth !== newWidth || editorHeight !== newHeight) {
console.log('Editor size changed. New size:', newWidth, newHeight);
editorWidth = newWidth;
editorHeight = newHeight;
}
});
})
.catch(error => {
console.error(error);
});
<script src="https://cdn.ckeditor.com/ckeditor5/17.0.0/classic/ckeditor.js"></script>
<div id="Comment"></div>
- 1 回答
- 0 关注
- 96 浏览
添加回答
举报