[feat] solution/frontend: 붙여넣기 아이템 셋 — 가요 다방·오늘의 한 장·반나절 산책
gunsan_365_story_db.xlsx 365행을 뜯어 보니 고유 주제는 52개이고 한 주제가 7회씩 돈다
(접미사 10개만 회전). 날짜 축으로 카드를 늘어놓으면 이레마다 같은 카드가 돌아온다 —
그래서 묶는 축을 주제로 잡고 날짜는 일력 한 장에만 썼다. 같은 파일 DB_Guide 가 가사·원문
전재를 금지해 가요 스키마에 lyrics 필드를 아예 두지 않았다. 없는 칸은 채울 수 없다.
- canvas/dataSpec.ts: 스키마·예시·프롬프트 단일 표. 레지스트리와 같은 결이라 한 줄을 더하면
캔버스·[콘텐츠] 탭·프롬프트가 동시에 는다. 파싱은 절대 throw 하지 않는다 — 편집 중인 JSON 은
늘 깨져 있고 그때 캔버스가 죽으면 고칠 방법이 없다
- shared/types/builder: SectionItem.data 는 파싱본이 아니라 원문 문자열이다. 파싱본만 들면
JSON 이 깨진 순간 사장님이 쓴 걸 잃는다
- variants/{songs,daily,course}: 턴테이블·일력·승차권. 카드 격자를 쓰지 않고 전부 가로로 넘긴다
- RightTabsPanel: JSON 칸 + 프롬프트 복사/보기·예시 넣기·줄맞춤. 프롬프트에 상호와 주소에서 뽑은
시·군·구를 박아 내보낸다 — 빈칸을 남기면 못 채우고 그대로 보내고 모델이 엉뚱한 곳을 지어낸다
- dataSpec.locate: JSON.parse 오류가 두 형식이다. position 형만 보면 조각 인용 형에서 위치를
통째로 잃는다 — 조각을 원문에서 되찾아 센다
- SECTION_DATA_MAX_CHARS: 테마 상한 64KB(site_service._THEME_MAX_BYTES)를 세 섹션이 함께
넘길 수 있고 거절은 발행 직전에야 드러난다. 화면에서 먼저 끊는다
- industryData: 네 업종에 꺼진 채로 넣는다. 내용 없이 켜져 있으면 발행본에 빈 섹션이 나간다
- index.html: Gugi·Gowun Batang·Nanum Pen Script. 없으면 고딕으로 떨어져 감성이 사라진다
발행 사이트(solution/site)는 아직 variantId 도 data 도 읽지 않는다 — 지금은 빌더 캔버스 전용이다.
tsc·eslint·vite build 통과(frontend·admin), 세 배리에이션 SSR 렌더 확인, 파서 경계 12건 확인
This commit is contained in:
1 parent
c250b656fd
commit
23162783f9
15 files changed
+1424
-2
No files matched your search
@@ -2,6 +2,7 @@ import {useState} from 'react';
|
||||
import {
|
||||
AlertTriangle,
|
||||
Check,
|
||||
ClipboardCopy,
|
||||
Image as ImageIcon,
|
||||
Info,
|
||||
FileText,
|
||||
@@ -10,7 +11,9 @@ import {
|
||||
Pencil,
|
||||
Plus,
|
||||
Shapes,
|
||||
Sparkles,
|
||||
Trash2,
|
||||
Wand2,
|
||||
X,
|
||||
} from 'lucide-react';
|
||||
import type {InfoField} from '@o2o/shared';
|
||||
@@ -20,9 +23,16 @@ import {Input} from '@/components/ui/input';
|
||||
import {PasteFactsPanel, RecollectPanel} from '@/features/onboarding';
|
||||
import {cn} from '@/lib/utils';
|
||||
import {useBuilderStore, useUnverifiedFields, type RightTab} from '@/stores/builder';
|
||||
import {INDUSTRY_CONFIGS} from '@/data/industryData';
|
||||
import {FaqPanel} from './FaqPanel';
|
||||
import {SectionDesignPanel} from './SectionDesignPanel';
|
||||
import {resolveVariant} from './canvas/registry';
|
||||
import {
|
||||
buildPrompt,
|
||||
dataSpecFor,
|
||||
parseSectionData,
|
||||
SECTION_DATA_MAX_CHARS,
|
||||
} from './canvas/dataSpec';
|
||||
|
||||
const TABS: {id: RightTab; label: string; icon: typeof Info}[] = [
|
||||
{id: 'content', label: '콘텐츠', icon: FileText},
|
||||
@@ -148,7 +158,8 @@ function ContentTab() {
|
||||
className="w-full resize-y rounded-md border border-input bg-background px-3 py-2 text-xs leading-relaxed outline-none focus:border-ring focus:ring-2 focus:ring-ring/30"
|
||||
/>
|
||||
</label>}
|
||||
{!supportsTitle && !supportsDescription && !supportsBody && (
|
||||
{dataSpecFor(section.type) && <SectionDataPanel sectionId={section.id} sectionType={section.type} />}
|
||||
{!supportsTitle && !supportsDescription && !supportsBody && !dataSpecFor(section.type) && (
|
||||
<p className="rounded-md border border-dashed border-border p-3 text-center text-[11px] text-muted-foreground">
|
||||
이 레이아웃에는 직접 입력하는 문구가 없습니다. 수집된 데이터만 표시합니다.
|
||||
</p>
|
||||
@@ -160,6 +171,159 @@ function ContentTab() {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 붙여넣기 아이템의 JSON 입력.
|
||||
*
|
||||
* ★ 원문을 그대로 저장한다. 깨진 JSON 도 담아 두고, 왜 깨졌는지만 아래에 말한다 —
|
||||
* 저장을 막으면 사장님은 고칠 기회 없이 쓰던 걸 잃는다.
|
||||
*/
|
||||
function SectionDataPanel({sectionId, sectionType}: {sectionId: string; sectionType: string}) {
|
||||
const spec = dataSpecFor(sectionType);
|
||||
const sections = useBuilderStore((s) => s.sections);
|
||||
const updateSectionData = useBuilderStore((s) => s.updateSectionData);
|
||||
const storeName = useBuilderStore((s) => s.storeName);
|
||||
const location = useBuilderStore((s) => s.location);
|
||||
const industry = useBuilderStore((s) => s.industry);
|
||||
const [copied, setCopied] = useState(false);
|
||||
const [showPrompt, setShowPrompt] = useState(false);
|
||||
|
||||
const section = sections.find((item) => item.id === sectionId);
|
||||
if (!spec || !section) return null;
|
||||
|
||||
const raw = section.data ?? '';
|
||||
const parsed = parseSectionData(sectionType, raw);
|
||||
const tooLong = raw.length > SECTION_DATA_MAX_CHARS;
|
||||
|
||||
// 상호·주소가 이미 박혀 있는 프롬프트. 사장님이 빈칸을 채울 일이 없어야 한다.
|
||||
const promptText = buildPrompt(spec, {
|
||||
storeName,
|
||||
location,
|
||||
industryLabel: INDUSTRY_CONFIGS[industry].name,
|
||||
});
|
||||
|
||||
const copyPrompt = async () => {
|
||||
const text = promptText;
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
setCopied(true);
|
||||
setTimeout(() => setCopied(false), 1600);
|
||||
} catch {
|
||||
// 클립보드가 막힌 브라우저 — 프롬프트를 화면에 띄워 직접 긁을 수 있게 한다.
|
||||
window.prompt('아래 프롬프트를 복사해 ChatGPT 에 붙여넣으세요', text);
|
||||
}
|
||||
};
|
||||
|
||||
/** 유효한 JSON 만 2칸 들여쓰기로 다시 쓴다. 깨져 있으면 손대지 않는다. */
|
||||
const tidy = () => {
|
||||
try {
|
||||
updateSectionData(sectionId, JSON.stringify(JSON.parse(raw), null, 2));
|
||||
} catch {
|
||||
// 그대로 둔다 — 아래 오류 줄이 이미 어디가 깨졌는지 말하고 있다.
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-2 rounded-md border border-border bg-muted/30 p-2.5">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<Sparkles className="size-3.5 text-primary" />
|
||||
<span className="text-xs font-bold">{spec.label} 내용 (JSON)</span>
|
||||
</div>
|
||||
<p className="text-[10px] leading-relaxed text-muted-foreground">
|
||||
프롬프트를 복사해 ChatGPT·Claude 에 그대로 붙여넣으면 JSON 을 줍니다. 받은 JSON 을 아래에 붙여넣으세요.
|
||||
</p>
|
||||
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
<Button type="button" size="sm" variant="primary" className="h-7 gap-1 text-[11px]" onClick={copyPrompt}>
|
||||
<ClipboardCopy className="size-3" />
|
||||
{copied ? '복사됨' : '프롬프트 복사'}
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="h-7 gap-1 text-[11px]"
|
||||
onClick={() => updateSectionData(sectionId, spec.sample)}
|
||||
>
|
||||
<Wand2 className="size-3" />
|
||||
예시 넣기
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
className="h-7 text-[11px]"
|
||||
onClick={() => setShowPrompt((v) => !v)}
|
||||
>
|
||||
{showPrompt ? '프롬프트 접기' : '프롬프트 보기'}
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="h-7 text-[11px]"
|
||||
onClick={tidy}
|
||||
disabled={!raw.trim() || Boolean(parsed.error)}
|
||||
>
|
||||
줄맞춤
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{showPrompt && (
|
||||
<div className="space-y-1">
|
||||
<p className="text-[10px] text-muted-foreground">
|
||||
아래 내용이 그대로 복사됩니다. 상호와 지역은 이미 채워져 있습니다.
|
||||
</p>
|
||||
<textarea
|
||||
readOnly
|
||||
value={promptText}
|
||||
rows={12}
|
||||
spellCheck={false}
|
||||
onFocus={(event) => event.currentTarget.select()}
|
||||
className="w-full resize-y rounded-md border border-border bg-background/60 px-2.5 py-2 font-mono text-[10px] leading-relaxed text-muted-foreground outline-none"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<textarea
|
||||
value={raw}
|
||||
onChange={(event) => updateSectionData(sectionId, event.target.value)}
|
||||
placeholder={`{ "kind": "${spec.kind}", "items": [ ... ] }`}
|
||||
rows={10}
|
||||
spellCheck={false}
|
||||
className="w-full resize-y rounded-md border border-input bg-background px-2.5 py-2 font-mono text-[11px] leading-relaxed outline-none focus:border-ring focus:ring-2 focus:ring-ring/30"
|
||||
/>
|
||||
|
||||
{parsed.error ? (
|
||||
<p className="flex items-start gap-1.5 text-[10px] leading-relaxed text-destructive">
|
||||
<AlertTriangle className="mt-px size-3 shrink-0" />
|
||||
{parsed.error}
|
||||
</p>
|
||||
) : raw.trim() ? (
|
||||
<p className="text-[10px] text-muted-foreground">
|
||||
{spec.label} {parsed.items.length}개 · 출처 {parsed.sourced}개
|
||||
{parsed.unverified > 0 && ` · 확인필요 ${parsed.unverified}개`}
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
{parsed.kindMismatch && (
|
||||
<p className="flex items-start gap-1.5 text-[10px] leading-relaxed text-warning">
|
||||
<AlertTriangle className="mt-px size-3 shrink-0" />
|
||||
이 JSON 은 "{parsed.kindMismatch}" 아이템 것입니다. {spec.label} 섹션에는 kind 가 "{spec.kind}" 인
|
||||
JSON 을 넣어 주세요.
|
||||
</p>
|
||||
)}
|
||||
|
||||
{tooLong && (
|
||||
<p className="flex items-start gap-1.5 text-[10px] leading-relaxed text-destructive">
|
||||
<AlertTriangle className="mt-px size-3 shrink-0" />
|
||||
너무 깁니다({raw.length.toLocaleString()}자). {SECTION_DATA_MAX_CHARS.toLocaleString()}자 아래로 줄여
|
||||
주세요 — 이 상태로는 디자인 설정이 서버에 저장되지 않습니다.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function PhotosTab() {
|
||||
const photos = useBuilderStore((s) => s.photos);
|
||||
const setPrimaryPhoto = useBuilderStore((s) => s.setPrimaryPhoto);
|
||||
|
||||
Reference in new issue
Block a user