1 回答

TA貢獻1841條經(jīng)驗 獲得超3個贊
您可以檢查事件內(nèi)的編輯器高度change,看看高度是否發(fā)生變化。
請運行以下代碼片段并檢查控制臺:
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 關(guān)注
- 120 瀏覽
添加回答
舉報