Roslovets-Inc/strapi-plugin-ckeditor5

const data = editor.getData() cause laggy when typing fast with large text

Opened this issue · 0 comments

My site is very slow when typing fast with Ckeditor
I investigated and saw that onChange event with editor.getData(); is root cause

onChange={(event, editor) => {
const data = editor.getData();
onChange( { target: { name, value: data } } );
);

I tried it with setTimeout function but still lag if the editor already has large text

onChange={(event, editor) => {
if (inputTimeout) {
window.clearTimeout(inputTimeout);
}
inputTimeout = setTimeout(
() => {
const data = editor.getData();
onChange( { target: { name, value: data } } );
},
5000
);
}}

Do you have any solution to solve it?