mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Fix undo / redo
This commit is contained in:
parent
0c21f1ae07
commit
eb9b6ac837
5 changed files with 118 additions and 70 deletions
|
@ -1233,3 +1233,27 @@ export const sizeOf = (
|
|||
? value.size
|
||||
: Object.keys(value).length;
|
||||
};
|
||||
|
||||
/**
|
||||
* Deep freeze an object to prevent any modifications to the object or its nested properties.
|
||||
*/
|
||||
export const deepFreeze = <T>(obj: T): T => {
|
||||
// Return if obj is null or not an object
|
||||
if (obj === null || typeof obj !== "object") {
|
||||
return obj;
|
||||
}
|
||||
|
||||
// Freeze the object itself
|
||||
Object.freeze(obj);
|
||||
|
||||
// Freeze all properties
|
||||
Object.getOwnPropertyNames(obj).forEach((prop) => {
|
||||
const value = (obj as any)[prop];
|
||||
|
||||
if (value && typeof value === "object") {
|
||||
deepFreeze(value);
|
||||
}
|
||||
});
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue