fix: stop updating text versions on init (#8191)

This commit is contained in:
David Luzar 2024-07-01 14:04:58 +02:00 committed by GitHub
parent 66a2f24296
commit 1d5b41dabb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 8 deletions

View file

@ -1,5 +1,5 @@
import { isTextElement } from "../element";
import { newElementWith } from "../element/mutateElement";
import { getContainerElement } from "../element/textElement";
import type {
ExcalidrawElement,
ExcalidrawTextElement,
@ -46,14 +46,18 @@ export class Fonts {
let didUpdate = false;
this.scene.mapElements((element) => {
const elementsMap = this.scene.getNonDeletedElementsMap();
for (const element of this.scene.getNonDeletedElements()) {
if (isTextElement(element)) {
didUpdate = true;
ShapeCache.delete(element);
return newElementWith(element, {}, true);
const container = getContainerElement(element, elementsMap);
if (container) {
ShapeCache.delete(container);
}
}
return element;
});
}
if (didUpdate) {
this.scene.triggerUpdate();