excalidraw/src/element/mutateElement.ts

27 lines
850 B
TypeScript
Raw Normal View History

import {
MutableExcalidrawElement,
MutableExcalidrawTextElement,
} from "./types";
2020-03-09 23:37:42 -07:00
// This function tracks updates of text elements for the purposes for collaboration.
// The version is used to compare updates when more than one user is working in
// the same drawing.
export function mutateElement(
element: MutableExcalidrawElement,
callback: (mutatableElement: MutableExcalidrawElement) => void,
): void {
element.version++;
callback(element);
}
2020-03-09 23:37:42 -07:00
// This function tracks updates of text elements for the purposes for collaboration.
// The version is used to compare updates when more than one user is working in
// the same document.
export function mutateTextElement(
element: MutableExcalidrawTextElement,
callback: (mutatableElement: MutableExcalidrawTextElement) => void,
): void {
element.version++;
callback(element);
}