feat(canvas): add persistent node favorites with toolbar star and glow

This commit is contained in:
2026-04-09 14:12:43 +02:00
parent e4d39a21fd
commit b08e448be0
18 changed files with 625 additions and 76 deletions

View File

@@ -0,0 +1,36 @@
function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null && !Array.isArray(value);
}
function toRecord(value: unknown): Record<string, unknown> {
return isRecord(value) ? value : {};
}
export function readNodeFavorite(data: unknown): boolean {
const source = toRecord(data);
return source.isFavorite === true;
}
export function setNodeFavorite(
nextValue: boolean,
currentData: unknown,
): Record<string, unknown> {
const source = toRecord(currentData);
if (nextValue) {
return {
...source,
isFavorite: true,
};
}
const { isFavorite: _isFavorite, ...rest } = source;
return rest;
}
export function preserveNodeFavorite(
nextData: unknown,
previousData: unknown,
): Record<string, unknown> {
return setNodeFavorite(readNodeFavorite(previousData), nextData);
}