fix: 편집과 미리보기를 한 화면에서 보고, 저장·게시를 아래에 고정한다
편집기는 탭이었다. 고친 것이 어떻게 보이는지 확인하려면 편집하던 자리를 화면에서 치워야 했고, 돌아오면 스크롤 위치도 잃었다. 두 패널을 나란히 두면 그 왕복이 통째로 없어진다. 작업 상태와 저장·게시는 오른쪽 세로 rail 이었다. 그 자리는 편집기와 미리보기가 함께 쓸 가로 폭을 가져갔고, 편집 칸이 길어질수록 rail 은 위에 붙은 채 본문만 멀어졌다. 화면 아래에 고정하면 폭을 돌려주면서 스크롤 위치와 무관하게 손이 닿는다. 탭을 없앴으므로 각 패널이 스스로 이름을 가져야 한다. `aria-labelledby` 로 제목을 가리켜 landmark 로 만든다 — 탭 목록이 하던 "여기는 편집, 저기는 미리보기" 안내를 대신한다. `aside` 와 「작업 상태」라는 이름은 그대로 둔다. 자리가 바뀐 것이지 이 묶음이 무엇인지가 바뀐 것은 아니다. 미리보기가 늘 떠 있게 되면서 Picker 테스트의 단언도 함께 고쳤다. 「Picker 가 좁아졌는가」를 화면 전체에 묻고 있었는데, 이제는 미리보기 쪽의 같은 Asset 까지 세게 된다. 그 김에 `.studio-asset-panel` 의 `aria-labelledby` 가 role 없는 div 에서 아무 이름도 만들지 못하던 것도 `role="group"` 으로 실효화했다. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0189NzCryfeqDzS81EWidnBx
This commit is contained in:
co-authored by
Claude Opus 5
parent
b3119952d5
commit
60c8c82097
@@ -102,7 +102,7 @@ export function CaseFields({
|
||||
<label className="studio-field"><span>마지막 검증일</span><input type="date" value={draft.lastVerifiedOn ?? ""} onChange={(event) => update({ lastVerifiedOn: event.currentTarget.value || null })} /><FieldNotice issues={issues} path="/lastVerifiedOn" /></label>
|
||||
<label className="studio-field studio-field--wide"><span>본문 Markdown</span><textarea ref={bodyRef} className="studio-markdown-field" value={draft.bodyMarkdown} onChange={(event) => update({ bodyMarkdown: event.currentTarget.value })} /><FieldNotice issues={issues} path="/bodyMarkdown" /></label>
|
||||
</div>
|
||||
<div className="studio-asset-panel" aria-labelledby="studio-asset-panel-title">
|
||||
<div className="studio-asset-panel" role="group" aria-labelledby="studio-asset-panel-title">
|
||||
<p className="studio-eyebrow">EVIDENCE</p>
|
||||
<h3 id="studio-asset-panel-title">본문에 Asset 삽입</h3>
|
||||
<p>목록에서 선택하면 본문 커서 위치에 evidence 구문을 삽입합니다. READY 상태의 Asset만 선택할 수 있습니다.</p>
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import { useRef, useState, type KeyboardEvent } from "react";
|
||||
|
||||
import type { components } from "../../../contracts/studio/generated.ts";
|
||||
import type { Asset } from "../../../contracts/studio/contract.ts";
|
||||
import type { DocumentEditorController } from "./document-editor-controller.ts";
|
||||
import { CASE_FIELD_PATHS, CaseFields } from "./case-fields.tsx";
|
||||
import { COMMON_FIELD_PATHS, CommonDocumentFields } from "./common-document-fields.tsx";
|
||||
import { DocumentStatusRail } from "./document-status-rail.tsx";
|
||||
import { DocumentStatusBar } from "./document-status-bar.tsx";
|
||||
import { InstantPreview } from "./instant-preview.tsx";
|
||||
import { DECISION_FIELD_PATHS, ProjectDecisionFields } from "./project-decision-fields.tsx";
|
||||
import { issuesOutside } from "./field-issues.tsx";
|
||||
@@ -28,22 +26,6 @@ export function DocumentEditor({
|
||||
onAssetsObserved: (assets: readonly Asset[]) => void;
|
||||
onAssetUploaded: (asset: Asset) => void;
|
||||
}) {
|
||||
const [tab, setTab] = useState<"EDIT" | "PREVIEW">("EDIT");
|
||||
const editTab = useRef<HTMLButtonElement>(null);
|
||||
const previewTab = useRef<HTMLButtonElement>(null);
|
||||
const selectTab = (next: "EDIT" | "PREVIEW") => {
|
||||
setTab(next);
|
||||
(next === "EDIT" ? editTab : previewTab).current?.focus();
|
||||
};
|
||||
const keyDown = (event: KeyboardEvent<HTMLButtonElement>) => {
|
||||
let next: "EDIT" | "PREVIEW" | null = null;
|
||||
if (event.key === "ArrowLeft" || event.key === "ArrowRight") next = tab === "EDIT" ? "PREVIEW" : "EDIT";
|
||||
if (event.key === "Home") next = "EDIT";
|
||||
if (event.key === "End") next = "PREVIEW";
|
||||
if (!next) return;
|
||||
event.preventDefault();
|
||||
selectTab(next);
|
||||
};
|
||||
const topics = catalog.filter(({ type }) => type === "TOPIC");
|
||||
const projects = catalog.filter(({ type }) => type === "PROJECT");
|
||||
const relations = catalog.filter(({ type }) => type === "RELATION");
|
||||
@@ -66,35 +48,47 @@ export function DocumentEditor({
|
||||
: DECISION_FIELD_PATHS;
|
||||
const unplaced = issuesOutside(issues, [...COMMON_FIELD_PATHS, ...kindPaths]);
|
||||
|
||||
/*
|
||||
편집과 미리보기를 한 화면에 나란히 둔다. 예전에는 탭이었고, 고친 것이 어떻게 보이는지
|
||||
확인하려면 탭을 옮겨야 했다 — 옮기는 동안 편집 중이던 칸은 화면에서 사라졌고, 돌아오면
|
||||
스크롤 위치도 잃었다. 두 패널을 동시에 두면 그 왕복이 통째로 없어진다.
|
||||
|
||||
탭을 없앴으므로 각 패널은 스스로 이름을 가져야 한다. `aria-labelledby` 로 제목을 가리켜
|
||||
landmark 로 만든다 — 탭 목록이 하던 "여기는 편집, 저기는 미리보기" 안내를 대신한다.
|
||||
*/
|
||||
return (
|
||||
<div className="studio-editor-page">
|
||||
<div className="studio-editor-tabs" role="tablist" aria-label="문서 편집 화면">
|
||||
<button id="studio-edit-tab" ref={editTab} type="button" role="tab" aria-selected={tab === "EDIT"} aria-controls="studio-edit-panel" tabIndex={tab === "EDIT" ? 0 : -1} onClick={() => selectTab("EDIT")} onKeyDown={keyDown}>편집</button>
|
||||
<button id="studio-preview-tab" ref={previewTab} type="button" role="tab" aria-selected={tab === "PREVIEW"} aria-controls="studio-preview-panel" tabIndex={tab === "PREVIEW" ? 0 : -1} onClick={() => selectTab("PREVIEW")} onKeyDown={keyDown}>즉시 미리보기</button>
|
||||
</div>
|
||||
<div className="studio-editor-layout">
|
||||
<div className="studio-editor-workspace">
|
||||
<div id="studio-edit-panel" role="tabpanel" aria-labelledby="studio-edit-tab" hidden={tab !== "EDIT"}>
|
||||
<header className="studio-editor-heading">
|
||||
<p className="studio-eyebrow">{controller.draft.kind} · VERSION {controller.saved.version}</p>
|
||||
<h1>문서 편집</h1>
|
||||
<p>{controller.draft.title || "제목 없는 작업본"}</p>
|
||||
</header>
|
||||
<CommonDocumentFields draft={controller.draft} topics={topics} projects={projects} relations={relations} issues={issues} onUpdate={controller.update} />
|
||||
{controller.draft.kind === "CASE"
|
||||
? <CaseFields draft={controller.draft} issues={issues} onChange={controller.replace} onAssetsObserved={onAssetsObserved} onAssetUploaded={onAssetUploaded} />
|
||||
: controller.draft.kind === "REFERENCE"
|
||||
? <ReferenceFields draft={controller.draft} issues={issues} onChange={controller.replace} />
|
||||
: controller.draft.kind === "QUESTION"
|
||||
? <QuestionFields draft={controller.draft} evidence={evidence} issues={issues} onChange={controller.replace} />
|
||||
: <ProjectDecisionFields draft={controller.draft} issues={issues} onChange={controller.replace} />}
|
||||
</div>
|
||||
<div id="studio-preview-panel" role="tabpanel" aria-labelledby="studio-preview-tab" hidden={tab !== "PREVIEW"}>
|
||||
<div className="studio-editor-split">
|
||||
<section className="studio-editor-workspace" aria-labelledby="studio-edit-title">
|
||||
<header className="studio-editor-heading">
|
||||
<p className="studio-eyebrow">{controller.draft.kind} · VERSION {controller.saved.version}</p>
|
||||
<h1 id="studio-edit-title">문서 편집</h1>
|
||||
<p>{controller.draft.title || "제목 없는 작업본"}</p>
|
||||
</header>
|
||||
<CommonDocumentFields draft={controller.draft} topics={topics} projects={projects} relations={relations} issues={issues} onUpdate={controller.update} />
|
||||
{controller.draft.kind === "CASE"
|
||||
? <CaseFields draft={controller.draft} issues={issues} onChange={controller.replace} onAssetsObserved={onAssetsObserved} onAssetUploaded={onAssetUploaded} />
|
||||
: controller.draft.kind === "REFERENCE"
|
||||
? <ReferenceFields draft={controller.draft} issues={issues} onChange={controller.replace} />
|
||||
: controller.draft.kind === "QUESTION"
|
||||
? <QuestionFields draft={controller.draft} evidence={evidence} issues={issues} onChange={controller.replace} />
|
||||
: <ProjectDecisionFields draft={controller.draft} issues={issues} onChange={controller.replace} />}
|
||||
</section>
|
||||
{/*
|
||||
미리보기는 편집 칸보다 훨씬 짧을 수도, 길 수도 있다. 그대로 두면 본문을 스크롤하는
|
||||
동안 화면 밖으로 나가 버리므로 붙잡아 두고 자기 높이 안에서 따로 스크롤한다.
|
||||
*/}
|
||||
<section className="studio-editor-preview" aria-labelledby="studio-preview-title">
|
||||
<header className="studio-editor-preview__heading">
|
||||
<p className="studio-eyebrow">LIVE</p>
|
||||
<h2 id="studio-preview-title">즉시 미리보기</h2>
|
||||
</header>
|
||||
<div className="studio-editor-preview__body">
|
||||
<InstantPreview draft={controller.draft} catalog={catalog} assets={assets} />
|
||||
</div>
|
||||
</div>
|
||||
<DocumentStatusRail controller={controller} unplacedIssues={unplaced} />
|
||||
</section>
|
||||
</div>
|
||||
<DocumentStatusBar controller={controller} unplacedIssues={unplaced} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
import type { DocumentEditorController } from "./document-editor-controller.ts";
|
||||
import type { FieldIssue } from "./field-issues.tsx";
|
||||
|
||||
const labels = {
|
||||
CLEAN: "저장됨",
|
||||
DIRTY: "저장되지 않음",
|
||||
SAVING: "저장 중…",
|
||||
CONFLICT: "저장 충돌",
|
||||
} as const;
|
||||
|
||||
const kindLabels = {
|
||||
CASE: "CASE",
|
||||
REFERENCE: "REFERENCE",
|
||||
QUESTION: "QUESTION",
|
||||
PROJECT_DECISION: "Decision",
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* 작업 상태와 저장·게시를 화면 아래에 고정한다.
|
||||
*
|
||||
* 예전에는 오른쪽 세로 rail 이었다. 그 자리는 편집기와 미리보기가 함께 쓸 가로 폭을 가져갔고,
|
||||
* 편집 칸이 길어질수록 rail 은 위에 붙은 채 본문만 멀어졌다. 아래에 고정하면 폭을 돌려주면서
|
||||
* 스크롤 위치와 무관하게 저장·게시에 손이 닿는다 — 릴리즈 편집에서 버튼이 아래로 밀려나던
|
||||
* 것과 같은 문제를 여기서는 만들지 않는다.
|
||||
*
|
||||
* `aside` 와 「작업 상태」라는 이름은 그대로 둔다. 자리가 바뀐 것이지 이 묶음이 무엇인지가
|
||||
* 바뀐 것은 아니고, 보조 기술이 이 영역을 부르던 이름도 그대로여야 한다.
|
||||
*/
|
||||
export function DocumentStatusBar({
|
||||
controller,
|
||||
unplacedIssues,
|
||||
}: {
|
||||
controller: DocumentEditorController;
|
||||
/**
|
||||
* 어느 칸에도 붙지 못한 지적. 화면에 없는 칸을 가리키는 것들이며, 여기 남기지 않으면 이유를
|
||||
* 말해 주지 않는 실패만 남는다.
|
||||
*/
|
||||
unplacedIssues: readonly FieldIssue[];
|
||||
}) {
|
||||
const busy = controller.status === "SAVING" || controller.publishing;
|
||||
return (
|
||||
<aside className="studio-document-status-bar" aria-labelledby="studio-document-status-title">
|
||||
<h2 id="studio-document-status-title" className="studio-visually-hidden">작업 상태</h2>
|
||||
<p className={`studio-editor-status studio-editor-status--${controller.status.toLowerCase()}`} role="status" aria-label="편집 상태">{labels[controller.status]}</p>
|
||||
<dl><div><dt>저장 버전</dt><dd>{controller.saved.version}</dd></div><div><dt>종류</dt><dd>{kindLabels[controller.draft.kind]}</dd></div></dl>
|
||||
{/*
|
||||
경고는 하나만 띄운다. 충돌은 그 자체로 무엇을 해야 하는지 말해 주므로 서버가 준 문구보다
|
||||
앞서고, 그 밖의 실패는 서버가 준 이유를 그대로 보여 준다. 둘을 함께 띄우면 같은 실패를
|
||||
두 번 말하게 된다.
|
||||
*/}
|
||||
{controller.status === "CONFLICT" ? (
|
||||
<p className="studio-editor-conflict" role="alert">서버 최신본과 충돌했습니다. 이 세션에서는 다시 열어 비교해 주세요.</p>
|
||||
) : controller.saveError ? (
|
||||
<p className="studio-editor-conflict" role="alert">{controller.saveError}</p>
|
||||
) : controller.publishError ? (
|
||||
<p className="studio-editor-conflict" role="alert">{controller.publishError}</p>
|
||||
) : (
|
||||
<p className="studio-document-status-bar__note">불완전한 초안도 저장할 수 있습니다. Ctrl+S 로도 저장합니다. 게시를 누르면 채워야 할 칸을 그 자리에 표시합니다.</p>
|
||||
)}
|
||||
<div className="studio-document-status-bar__actions">
|
||||
<button type="button" title="Ctrl+S" onClick={() => { void controller.save(); }} disabled={busy || controller.status === "CLEAN" || controller.status === "CONFLICT"}>{controller.status === "SAVING" ? "저장 중…" : "저장"}</button>
|
||||
{/*
|
||||
버튼은 저장과 게시 둘뿐이다. 예전에는 게시까지 검증 → 미리보기 → 게시 세 화면을 차례로
|
||||
밟아야 했다 — 백엔드가 게시 요청에 신선한 검증 id 와 미리보기 id, 그리고 현재 경고를 모두
|
||||
확인했다는 목록을 요구하기 때문이다(`PublishStudioDocumentUseCase`).
|
||||
|
||||
그 셋은 작성자에게 물어볼 것이 없다. 검증은 서버가 판정하고, 미리보기는 그 판정으로부터
|
||||
만들어지며, 경고는 게시를 막지 않는다. 그래서 세 요청을 이 버튼 뒤로 옮겼다. 계약도
|
||||
백엔드도 그대로다 — 사라진 것은 작성자가 밟던 화면이지 서버가 지키던 불변식이 아니다.
|
||||
*/}
|
||||
<button
|
||||
className="studio-primary-button"
|
||||
type="button"
|
||||
onClick={() => { void controller.publish(); }}
|
||||
disabled={busy || controller.status === "CONFLICT"}
|
||||
>
|
||||
{controller.publishing ? "게시 중…" : "게시"}
|
||||
</button>
|
||||
</div>
|
||||
{unplacedIssues.length ? (
|
||||
<ul className="studio-editor-unplaced-issues" aria-label="칸에 붙지 못한 지적">
|
||||
{unplacedIssues.map((issue) => (
|
||||
<li key={`${issue.code}:${issue.path}`} data-severity={issue.severity}>
|
||||
{issue.message} <code>{issue.path}</code>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : null}
|
||||
</aside>
|
||||
);
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
import type { DocumentEditorController } from "./document-editor-controller.ts";
|
||||
import type { FieldIssue } from "./field-issues.tsx";
|
||||
|
||||
const labels = {
|
||||
CLEAN: "저장됨",
|
||||
DIRTY: "저장되지 않음",
|
||||
SAVING: "저장 중…",
|
||||
CONFLICT: "저장 충돌",
|
||||
} as const;
|
||||
|
||||
const kindLabels = {
|
||||
CASE: "CASE",
|
||||
REFERENCE: "REFERENCE",
|
||||
QUESTION: "QUESTION",
|
||||
PROJECT_DECISION: "Decision",
|
||||
} as const;
|
||||
|
||||
export function DocumentStatusRail({
|
||||
controller,
|
||||
unplacedIssues,
|
||||
}: {
|
||||
controller: DocumentEditorController;
|
||||
/**
|
||||
* 어느 칸에도 붙지 못한 지적. 화면에 없는 칸을 가리키는 것들이며, 여기 남기지 않으면 이유를
|
||||
* 말해 주지 않는 실패만 남는다.
|
||||
*/
|
||||
unplacedIssues: readonly FieldIssue[];
|
||||
}) {
|
||||
const busy = controller.status === "SAVING" || controller.publishing;
|
||||
return (
|
||||
<aside className="studio-document-status-rail" aria-labelledby="studio-document-status-title">
|
||||
<p className="studio-eyebrow">WORKING COPY</p>
|
||||
<h2 id="studio-document-status-title">작업 상태</h2>
|
||||
<p className={`studio-editor-status studio-editor-status--${controller.status.toLowerCase()}`} role="status" aria-label="편집 상태">{labels[controller.status]}</p>
|
||||
<dl><div><dt>저장 버전</dt><dd>{controller.saved.version}</dd></div><div><dt>종류</dt><dd>{kindLabels[controller.draft.kind]}</dd></div></dl>
|
||||
<button type="button" title="Ctrl+S" onClick={() => { void controller.save(); }} disabled={busy || controller.status === "CLEAN" || controller.status === "CONFLICT"}>{controller.status === "SAVING" ? "저장 중…" : "저장"}</button>
|
||||
{/*
|
||||
버튼은 저장과 게시 둘뿐이다. 예전에는 게시까지 검증 → 미리보기 → 게시 세 화면을 차례로
|
||||
밟아야 했다 — 백엔드가 게시 요청에 신선한 검증 id 와 미리보기 id, 그리고 현재 경고를 모두
|
||||
확인했다는 목록을 요구하기 때문이다(`PublishStudioDocumentUseCase`).
|
||||
|
||||
그 셋은 작성자에게 물어볼 것이 없다. 검증은 서버가 판정하고, 미리보기는 그 판정으로부터
|
||||
만들어지며, 경고는 게시를 막지 않는다. 그래서 세 요청을 이 버튼 뒤로 옮겼다. 계약도
|
||||
백엔드도 그대로다 — 사라진 것은 작성자가 밟던 화면이지 서버가 지키던 불변식이 아니다.
|
||||
*/}
|
||||
<button
|
||||
className="studio-primary-button"
|
||||
type="button"
|
||||
onClick={() => { void controller.publish(); }}
|
||||
disabled={busy || controller.status === "CONFLICT"}
|
||||
>
|
||||
{controller.publishing ? "게시 중…" : "게시"}
|
||||
</button>
|
||||
{/*
|
||||
경고는 하나만 띄운다. 충돌은 그 자체로 무엇을 해야 하는지 말해 주므로 서버가 준 문구보다
|
||||
앞서고, 그 밖의 실패는 서버가 준 이유를 그대로 보여 준다. 둘을 함께 띄우면 같은 실패를
|
||||
두 번 말하게 된다.
|
||||
*/}
|
||||
{controller.status === "CONFLICT" ? (
|
||||
<p className="studio-editor-conflict" role="alert">서버 최신본과 충돌했습니다. 이 세션에서는 다시 열어 비교해 주세요.</p>
|
||||
) : controller.saveError ? (
|
||||
<p className="studio-editor-conflict" role="alert">{controller.saveError}</p>
|
||||
) : controller.publishError ? (
|
||||
<p className="studio-editor-conflict" role="alert">{controller.publishError}</p>
|
||||
) : (
|
||||
<p>불완전한 초안도 저장할 수 있습니다. Ctrl+S 로도 저장합니다. 게시를 누르면 채워야 할 칸을 그 자리에 표시합니다.</p>
|
||||
)}
|
||||
{unplacedIssues.length ? (
|
||||
<ul className="studio-editor-unplaced-issues" aria-label="칸에 붙지 못한 지적">
|
||||
{unplacedIssues.map((issue) => (
|
||||
<li key={`${issue.code}:${issue.path}`} data-severity={issue.severity}>
|
||||
{issue.message} <code>{issue.path}</code>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : null}
|
||||
</aside>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user