Ckedotir BO performance upgrade

This commit is contained in:
Jérémy Munsch 2023-06-19 16:10:46 +02:00
parent 4593185759
commit 081a06b68c
No known key found for this signature in database
GPG key ID: 18361AF3BFEC0FEC

View file

@ -292,15 +292,23 @@ export default defineComponent({
})
// @ts-ignore
.then((editor: ClassicEditor) => {
let timer = null as number|null;
const updateContent = () => {
const data = editor.getData();
self.internalText = data;
self.$emit("input", data);
timer = null;
};
// Display all toolbar elements
// console.log(Array.from(editor.ui.componentFactory.names()));
self.editor = editor;
editor.setData(this.internalText);
editor.model.document.on("change:data", () => {
if(timer) {
clearTimeout(timer);
}
// * Keep track of internal editor
let data = editor.getData();
self.internalText = data;
self.$emit("input", data);
timer = setTimeout(updateContent, 1000) as never as number;
});
})
// @ts-ignore