리팩터링
CI / test (push) Successful in 5m38s
CI / e2e (push) Has been skipped
CI / pr_and_merge (push) Successful in 1m12s

This commit is contained in:
2025-12-16 17:49:25 +09:00
parent 87cdc1868b
commit 7491dacba2
19 changed files with 1857 additions and 99 deletions
+27 -2
View File
@@ -1,9 +1,11 @@
import type { Block } from "@/features/editor/state/editorStore";
import type { Block, ProjectConfig } from "@/features/editor/state/editorStore";
interface PublicProjectSnapshot {
slug: string;
title: string;
contentJson: Block[];
status: string;
blocks: Block[];
projectConfig: ProjectConfig | null;
}
function getStore(): Map<string, PublicProjectSnapshot> {
@@ -23,3 +25,26 @@ export function getCachedPublicProject(slug: string): PublicProjectSnapshot | nu
const store = getStore();
return store.get(slug) ?? null;
}
export function parseProjectContentJson(rawContent: any): {
blocks: Block[];
projectConfig: ProjectConfig | null;
} {
let blocks: Block[] = [];
let projectConfig: ProjectConfig | null = null;
if (Array.isArray(rawContent)) {
blocks = rawContent as Block[];
} else if (rawContent && typeof rawContent === "object") {
const maybeBlocks = (rawContent as any).blocks;
if (Array.isArray(maybeBlocks)) {
blocks = maybeBlocks as Block[];
const maybeConfig = (rawContent as any).projectConfig;
if (maybeConfig && typeof maybeConfig === "object") {
projectConfig = maybeConfig as ProjectConfig;
}
}
}
return { blocks, projectConfig };
}