## IMPROVEMENT (Phase A~D) - A-1: 4단계 Sonnet 디자인 조정 (_adjust_design) — CSS 변수 cascade - A-2: 5단계 HTML 전문 프롬프트 전달 - A-3: shrink/expand 하드코딩 제거 → Sonnet target_ratio 기반 - A-4: rewrite action 구현 - A-5: overflow: visible (area 레벨 텍스트 잘림 방지) - A-6: object-fit cover → contain (이미지 crop 방지) - A-7: table-layout: fixed - A-8: container query 폰트 스케일링 - B-1: details-block 템플릿 신규 (CSS 변수만 사용) - B-2: 인쇄 시 details 자동 펼침 JS - B-3: catalog에 details-block 등록 - B-4/B-5: images[]/tables[] 상세 판단 + fallback 3곳 동기화 - B-8: fallback card-grid → topic-header + char_guide 제거 - C-1: CLAUDE.md gradient 원칙 완화 - C-3: border-radius 9개 파일 var(--radius) 통일 - C-4: box-shadow 2레벨 → 1레벨 - D-0: 이미지 경로 입력 UI + API base_path - D-1: Pillow 의존성 + image_utils.py - D-2~D-4: 이미지 비율/축소방지 프롬프트 전달 - D-5: HTML에 이미지 base64 삽입 ## Phase 2 (다른 Claude 작업) - P2-A: FAISS 블록 검색 (bge-m3, 46개 블록) - P2-B: SVG N개 자동 배치 (svg_calculator.py) - P2-C: Opus 블록 추천 (Kei API 경유) - P2-D: 5단계 재검토 루프 강화 (MAX_REVIEW_ROUNDS=2) - P2-E: details-block fallback 연동 ## 버그 수정 (BF-8~10) - BF-8: 컨테이너 예산 기반 블록 배치 - BF-9: grid와 Sonnet 역할 분리 - BF-10: catalog mtime 캐시 자동 갱신 ## 블록 라이브러리 - 46개 블록 (6 카테고리), catalog/BLOCK_SLOTS/INDEX 동기화 - 구 블록 제거 (quote-block, card-grid, comparison) - 13개 _legacy 블록 보존 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
266 lines
7.5 KiB
HTML
266 lines
7.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="ko">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Design Agent — 슬라이드 생성기</title>
|
|
<link rel="preconnect" href="https://cdn.jsdelivr.net">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css">
|
|
<style>
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
body {
|
|
font-family: 'Pretendard Variable', sans-serif;
|
|
background: #f1f5f9;
|
|
min-height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
padding: 24px;
|
|
color: #1e293b;
|
|
}
|
|
h1 {
|
|
font-size: 1.5rem;
|
|
font-weight: 700;
|
|
margin-bottom: 16px;
|
|
}
|
|
.container {
|
|
width: 100%;
|
|
max-width: 1400px;
|
|
display: grid;
|
|
grid-template-columns: 400px 1fr;
|
|
gap: 24px;
|
|
flex: 1;
|
|
}
|
|
.input-panel {
|
|
background: white;
|
|
border-radius: 8px;
|
|
padding: 20px;
|
|
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 12px;
|
|
}
|
|
.input-panel label {
|
|
font-weight: 600;
|
|
font-size: 0.9rem;
|
|
}
|
|
textarea {
|
|
width: 100%;
|
|
height: 400px;
|
|
border: 1px solid #e2e8f0;
|
|
border-radius: 6px;
|
|
padding: 12px;
|
|
font-family: inherit;
|
|
font-size: 0.85rem;
|
|
line-height: 1.6;
|
|
resize: vertical;
|
|
word-break: keep-all;
|
|
}
|
|
textarea:focus {
|
|
outline: none;
|
|
border-color: #2563eb;
|
|
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
|
|
}
|
|
button {
|
|
padding: 12px 24px;
|
|
background: #2563eb;
|
|
color: white;
|
|
border: none;
|
|
border-radius: 6px;
|
|
font-size: 0.95rem;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
font-family: inherit;
|
|
}
|
|
button:hover { background: #1d4ed8; }
|
|
button:disabled { background: #94a3b8; cursor: not-allowed; }
|
|
.btn-download {
|
|
background: #16a34a;
|
|
margin-top: 8px;
|
|
}
|
|
.btn-download:hover { background: #15803d; }
|
|
.progress {
|
|
font-size: 0.85rem;
|
|
color: #64748b;
|
|
padding: 8px 0;
|
|
}
|
|
.preview-panel {
|
|
background: #e2e8f0;
|
|
border-radius: 8px;
|
|
padding: 20px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 12px;
|
|
overflow: auto;
|
|
}
|
|
.preview-label {
|
|
color: #64748b;
|
|
font-size: 0.85rem;
|
|
font-weight: 600;
|
|
}
|
|
.iframe-wrapper {
|
|
width: 100%;
|
|
aspect-ratio: 16 / 9;
|
|
position: relative;
|
|
overflow: hidden;
|
|
border-radius: 6px;
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.15);
|
|
background: white;
|
|
}
|
|
iframe {
|
|
width: 1280px;
|
|
height: 720px;
|
|
border: none;
|
|
background: white;
|
|
transform-origin: top left;
|
|
/* scale은 JS에서 컨테이너 너비에 맞게 동적 계산 */
|
|
}
|
|
.error {
|
|
color: #dc2626;
|
|
font-size: 0.85rem;
|
|
padding: 8px 12px;
|
|
background: #fef2f2;
|
|
border-radius: 6px;
|
|
display: none;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>Design Agent — 슬라이드 생성기</h1>
|
|
<div class="container">
|
|
<div class="input-panel">
|
|
<label>콘텐츠 입력</label>
|
|
<textarea id="content" placeholder="슬라이드로 변환할 텍스트를 붙여넣으세요..."></textarea>
|
|
<button id="btn-generate" onclick="generate()">슬라이드 생성</button>
|
|
<div id="progress" class="progress"></div>
|
|
<div id="error" class="error"></div>
|
|
<button id="btn-download" class="btn-download" style="display:none" onclick="download()">HTML 다운로드</button>
|
|
</div>
|
|
<div class="preview-panel">
|
|
<div class="preview-label">미리보기</div>
|
|
<div class="iframe-wrapper" id="iframe-wrapper">
|
|
<iframe id="preview"></iframe>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
let generatedHTML = '';
|
|
|
|
function scalePreview() {
|
|
const wrapper = document.getElementById('iframe-wrapper');
|
|
const iframe = document.getElementById('preview');
|
|
if (!wrapper || !iframe) return;
|
|
const wrapperWidth = wrapper.clientWidth;
|
|
const scale = wrapperWidth / 1280;
|
|
iframe.style.transform = 'scale(' + scale + ')';
|
|
wrapper.style.height = (720 * scale) + 'px';
|
|
}
|
|
|
|
window.addEventListener('resize', scalePreview);
|
|
window.addEventListener('load', scalePreview);
|
|
|
|
async function generate() {
|
|
const content = document.getElementById('content').value.trim();
|
|
if (!content) return;
|
|
|
|
const btn = document.getElementById('btn-generate');
|
|
const progress = document.getElementById('progress');
|
|
const error = document.getElementById('error');
|
|
const downloadBtn = document.getElementById('btn-download');
|
|
|
|
btn.disabled = true;
|
|
error.style.display = 'none';
|
|
downloadBtn.style.display = 'none';
|
|
progress.textContent = '시작 중...';
|
|
|
|
// 이미지 참조 감지 → 경로 입력 팝업
|
|
let basePath = '';
|
|
const hasImages = /!\[.*?\]\(.*?\)/.test(content);
|
|
if (hasImages) {
|
|
basePath = prompt(
|
|
'이미지가 포함된 콘텐츠입니다.\n' +
|
|
'이미지 파일이 있는 프로젝트 폴더 경로를 입력해주세요.\n' +
|
|
'예: D:\\ad-hoc\\kei\\content\n\n' +
|
|
'이미지 처리가 필요 없으면 취소를 누르세요.'
|
|
) || '';
|
|
}
|
|
|
|
try {
|
|
const response = await fetch('/api/generate', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ content, base_path: basePath }),
|
|
});
|
|
|
|
const reader = response.body.getReader();
|
|
const decoder = new TextDecoder();
|
|
let buffer = '';
|
|
|
|
while (true) {
|
|
const { done, value } = await reader.read();
|
|
if (done) break;
|
|
|
|
buffer += decoder.decode(value, { stream: true });
|
|
|
|
// SSE 이벤트는 빈 줄(\n\n)로 구분
|
|
const parts = buffer.split(/\r?\n\r?\n/);
|
|
buffer = parts.pop() || '';
|
|
|
|
for (const part of parts) {
|
|
if (!part.trim()) continue;
|
|
|
|
// 각 이벤트에서 event: 와 data: 추출
|
|
let eventType = '';
|
|
let eventData = '';
|
|
|
|
for (const line of part.split(/\r?\n/)) {
|
|
if (line.startsWith('event:')) {
|
|
eventType = line.slice(6).trim();
|
|
} else if (line.startsWith('data:')) {
|
|
eventData = line.slice(5).trim();
|
|
}
|
|
}
|
|
|
|
if (!eventData) continue;
|
|
|
|
try {
|
|
const parsed = JSON.parse(eventData);
|
|
|
|
if (eventType === 'progress') {
|
|
progress.textContent = parsed;
|
|
} else if (eventType === 'result') {
|
|
generatedHTML = parsed;
|
|
document.getElementById('preview').srcdoc = generatedHTML;
|
|
downloadBtn.style.display = 'block';
|
|
progress.textContent = '완료!';
|
|
setTimeout(scalePreview, 100);
|
|
} else if (eventType === 'error') {
|
|
error.textContent = parsed;
|
|
error.style.display = 'block';
|
|
}
|
|
} catch (e) {
|
|
// ping 등 무시
|
|
}
|
|
}
|
|
}
|
|
} catch (e) {
|
|
error.textContent = '오류: ' + e.message;
|
|
error.style.display = 'block';
|
|
} finally {
|
|
btn.disabled = false;
|
|
}
|
|
}
|
|
|
|
function download() {
|
|
if (!generatedHTML) return;
|
|
const blob = new Blob(['\uFEFF' + generatedHTML], { type: 'text/html;charset=utf-8' });
|
|
const url = URL.createObjectURL(blob);
|
|
const a = document.createElement('a');
|
|
a.href = url;
|
|
a.download = 'slide-' + Date.now() + '.html';
|
|
a.click();
|
|
URL.revokeObjectURL(url);
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|