From 02fff0cd039f7245684eb5586726e975fbb1de2d Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Wed, 9 Sep 2026 19:27:25 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20UX=20=EB=A6=AC=EB=B7=B0=EC=9D=98=20?= =?UTF-8?q?=EB=82=A8=EC=9D=80=20=EB=84=A4=20=ED=95=AD=EB=AA=A9=EC=9D=84=20?= =?UTF-8?q?=EB=B0=98=EC=98=81=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit H2. 편집기. 7,540px 폼에 섹션으로 갈 수단이 목차도 접기도 앵커도 없었다. 화면에 실제로 있는 `section[aria-labelledby]` 를 읽어 목차를 만든다 — 목록을 손으로 적지 않으므로 섹션이 바뀌어도 이 파일은 그대로다. 미리보기가 sticky 로 문서 맨 위에 고정돼, 폼 중반에서 지금 쓰는 문단이 미리보기 어디인지 볼 방법이 없었다. 커서가 지난 마지막 `##` 을 찾아 미리보기의 같은 제목으로 옮긴다. 스크롤 비율을 맞추는 방식은 두 쪽 길이가 다르면 늘 어긋난다. 손으로 넘기는 중에는 따라가지 않는다. 반복 그룹은 접을 수 있고 순서는 끌어서 바꾼다. 「위로/아래로」는 남긴다 — 끌기는 키보드로 할 수 없고, 그것만 두면 키보드로 쓰는 사람에게서 순서 바꾸기를 빼앗는다. 대신 작게 적는다. H3. 주제와 프로젝트를 탭으로 나눈다. 한 화면이 성격이 다른 두 엔티티를 같은 문법으로 다뤘다. 「추가」 버튼 둘이 같은 이름·같은 모양으로 한 줄에 있었고, 주제 행은 프로젝트에 맞춘 그리드라 절반이 빈칸이었다. 버튼 이름을 「주제 추가」·「프로젝트 추가」로 가르고, 프로젝트 행에서 같은 주소를 두 번 가리키던 「내용 편집」 하나를 없애고, 주제 행에 편집 버튼을 둔다. M10. 프로필에 연락·구독 수단. 계약은 처음부터 `contacts` 를 주고 있었고 화면이 읽지 않았다 — 읽고 나서 할 수 있는 일이 하나도 없었다. 프로필이 게시 전이면 빈 목록이고 그때는 구역을 그리지 않는다. M11. 공개 화면 HTML 에 Studio 청크 셋이 modulepreload 로 붙어 있었다. 읽기만 하는 사람이 편집기 번들을 내려받았다. 빌드에서 그 셋만 뺀다 — 공개 라우트의 미리 받기는 그대로 둔다. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01PTnWufiY9ATv57egkKKVAV --- .../http/http-public-content-gateway.ts | 22 +++++ .../tech-log/adapters/static/public-query.ts | 4 + .../ports/public-content-queries.ts | 10 ++ .../public/pages/profile-page.tsx | 28 +++++- .../studio/components/document-editor.tsx | 26 ++++- .../studio/components/editor-section-toc.tsx | 95 +++++++++++++++++++ .../studio/components/ordered-text-list.tsx | 80 ++++++++++++++-- .../studio/components/taxonomy-manager.tsx | 77 +++++++++++---- .../components/use-preview-scroll-sync.ts | 74 +++++++++++++++ .../presentation/styles/studio-editor.css | 33 +++++++ .../tech-log/presentation/styles/studio.css | 6 ++ vite.config.ts | 11 +++ 12 files changed, 438 insertions(+), 28 deletions(-) create mode 100644 src/features/tech-log/presentation/studio/components/editor-section-toc.tsx create mode 100644 src/features/tech-log/presentation/studio/components/use-preview-scroll-sync.ts diff --git a/src/features/tech-log/adapters/http/http-public-content-gateway.ts b/src/features/tech-log/adapters/http/http-public-content-gateway.ts index 6b4cded..ad52569 100644 --- a/src/features/tech-log/adapters/http/http-public-content-gateway.ts +++ b/src/features/tech-log/adapters/http/http-public-content-gateway.ts @@ -6,6 +6,7 @@ import type { Project, PublicContentQueries, PublicRecord, + PublicContact, PublicTopic, PublicTopicDetail, QuestionRecord, @@ -442,6 +443,26 @@ export function createHttpPublicContentGateway( * one object with a named slot per kind rather than a list, because each slot * has its own shape; the order below is the order the screen renders them in. */ + /** 프로필이 게시되지 않았으면 404 다 — 그것은 오류가 아니라 "아직 없다" 이므로 빈 목록으로 돌린다. */ + async function listContacts(): Promise { + const profile = await read>[] }>>( + "getPublicProfile", + {}, + ); + if (profile === NOT_FOUND) return []; + return Object.freeze( + (profile.contacts ?? []) + .map((contact) => + Object.freeze({ + type: String(contact.type ?? ""), + label: String(contact.label ?? ""), + url: String(contact.url ?? ""), + }), + ) + .filter((contact) => contact.label.length > 0 && contact.url.length > 0), + ) as PublicContact[]; + } + async function listTopics(): Promise { const page = await read("listPublicTopics", {}); if (page === NOT_FOUND) return []; @@ -676,6 +697,7 @@ export function createHttpPublicContentGateway( getRecord, getProject, getRelease, + listContacts, listTopics, getTopicDetail, getProjectRecords, diff --git a/src/features/tech-log/adapters/static/public-query.ts b/src/features/tech-log/adapters/static/public-query.ts index 7a1fed5..24db871 100644 --- a/src/features/tech-log/adapters/static/public-query.ts +++ b/src/features/tech-log/adapters/static/public-query.ts @@ -381,6 +381,10 @@ export const publicContentQueries = Object.freeze({ async getProjectActivity(projectSlug: string) { return getProjectActivity(projectSlug); }, + /* 정적 카탈로그에는 프로필이 없다. 빈 목록이면 화면이 그 구역을 그리지 않는다. */ + async listContacts() { + return []; + }, async listTopics() { return listTopics(); }, diff --git a/src/features/tech-log/application/ports/public-content-queries.ts b/src/features/tech-log/application/ports/public-content-queries.ts index d26336e..401d63e 100644 --- a/src/features/tech-log/application/ports/public-content-queries.ts +++ b/src/features/tech-log/application/ports/public-content-queries.ts @@ -220,6 +220,9 @@ export type Release = { }; /** 계약 `TopicListItem`. 목록 화면이 쓰는 만큼만 옮긴다. */ +/** 계약 `ContactLink`. */ +export type PublicContact = { type: string; label: string; url: string }; + export type PublicTopic = { name: string; slug: string; @@ -352,6 +355,13 @@ export type PublicContentQueries = Readonly<{ * 있었고, Studio 에서 주제를 만들어도 바뀌지 않았다. */ listTopics(): Promise; + /** + * 프로필의 연락·구독 수단. 프로필이 아직 게시 전이면 빈 목록이다. + * + *

읽고 나서 할 수 있는 것이 하나도 없었다 — 이메일도 GitHub 도 피드도 없었다. 계약은 + * 처음부터 `contacts` 를 주고 있었고 화면이 그것을 읽지 않았을 뿐이다. + */ + listContacts(): Promise; /** 주제 한 편. 주제가 없으면 `undefined`. */ getTopicDetail(slug: string): Promise; getLatestEntries(): Promise; diff --git a/src/features/tech-log/presentation/public/pages/profile-page.tsx b/src/features/tech-log/presentation/public/pages/profile-page.tsx index feda2d8..71fe346 100644 --- a/src/features/tech-log/presentation/public/pages/profile-page.tsx +++ b/src/features/tech-log/presentation/public/pages/profile-page.tsx @@ -33,13 +33,15 @@ export function ProfilePage() { const entries = (await queries.searchPublicContent("")).filter( (item) => item.contentType === "PROJECT", ); - const [resolved, topics] = await Promise.all([ + const [resolved, topics, contacts] = await Promise.all([ Promise.all(entries.map((item) => queries.getProject(item.path.replace("/projects/", "")))), queries.listTopics(), + queries.listContacts(), ]); return { currentProjects: resolved.filter((project) => project !== undefined), topics, + contacts, }; }); @@ -118,6 +120,30 @@ export function ProfilePage() { )} + {/* + 읽고 나서 할 수 있는 것. + + 이메일도 GitHub 도 피드도 없어서, 이 기록들을 읽은 사람이 그다음에 할 수 있는 일이 + 하나도 없었다. 계약은 처음부터 `contacts` 를 주고 있었고 화면이 그것을 읽지 않았다. + + 프로필이 아직 게시되지 않았으면 빈 목록이고, 그때는 구역을 그리지 않는다 — 제목만 + 있는 빈 목록은 아무것도 말하지 않는다. + */} + {view.ready && view.data.contacts.length > 0 ? ( +

+

Contact

+

연락과 구독

+ +
+ ) : null} ); } diff --git a/src/features/tech-log/presentation/studio/components/document-editor.tsx b/src/features/tech-log/presentation/studio/components/document-editor.tsx index d7fcf67..1893065 100644 --- a/src/features/tech-log/presentation/studio/components/document-editor.tsx +++ b/src/features/tech-log/presentation/studio/components/document-editor.tsx @@ -1,4 +1,6 @@ import type { components } from "../../../contracts/studio/generated.ts"; +import { usePreviewScrollSync } from "./use-preview-scroll-sync.ts"; +import { EditorSectionToc } from "./editor-section-toc.tsx"; import type { Asset } from "../../../contracts/studio/contract.ts"; import type { TopicVariantEdit } from "../../../contracts/management/contract.ts"; import type { DocumentEditorController } from "./document-editor-controller.ts"; @@ -60,6 +62,17 @@ export function DocumentEditor({ PROJECT_DECISION: DECISION_FIELD_PATHS, }; const kindPaths = KIND_PATHS[controller.draft.kind]; + /* + 미리보기가 편집 중인 절을 따라온다. 본문을 쓰는 종류에서만 뜻이 있다 — 구조화된 칸만 있는 + 종류는 미리보기에 맞출 소제목이 없다. + */ + usePreviewScrollSync( + "studio-editor-workspace", + "studio-editor-preview-body", + controller.draft.kind === "CASE" + || controller.draft.kind === "CONCEPT" + || controller.draft.kind === "SETUP", + ); const unplaced = issuesOutside(issues, [...COMMON_FIELD_PATHS, ...kindPaths]); /* @@ -73,12 +86,21 @@ export function DocumentEditor({ return (
-
+

{controller.draft.kind} · VERSION {controller.saved.version}

문서 편집

{controller.draft.title || "제목 없는 작업본"}

+ {/* + 7,540px 짜리 폼에 섹션으로 이동할 수단이 하나도 없었다. 공개 상세 화면이 이미 + sticky 목차를 갖고 있고, 같은 일을 여기서 한다. + */} + {controller.draft.kind === "CASE" ? @@ -101,7 +123,7 @@ export function DocumentEditor({

LIVE

즉시 미리보기

-
+
diff --git a/src/features/tech-log/presentation/studio/components/editor-section-toc.tsx b/src/features/tech-log/presentation/studio/components/editor-section-toc.tsx new file mode 100644 index 0000000..4c4e1c8 --- /dev/null +++ b/src/features/tech-log/presentation/studio/components/editor-section-toc.tsx @@ -0,0 +1,95 @@ +import { useEffect, useState } from "react"; + +/** + * 편집 폼의 섹션 목차. + * + *

Question 문서 하나를 재어 보면 폼이 7,540px 이고 textarea 가 21개다. 그중 「확인한 사실 2」와 + * 「선택지 4」는 크기·테두리·배경이 전부 같아 눈으로 구분되지 않고, 섹션으로 이동할 수단이 목차도 + * 접기도 앵커도 없이 하나도 없었다 — 아래쪽을 고치려면 매번 스크롤로 찾아 내려가야 했다. + * + *

공개 상세 화면이 이미 sticky 목차를 갖고 있다. 같은 일을 편집 폼에 한다. 다만 섹션은 폼이 + * 그리는 것이라 여기서 목록을 손으로 적지 않고, 화면에 실제로 있는 `section[aria-labelledby]` 를 + * 읽는다 — 종류가 늘거나 섹션이 바뀌어도 이 파일은 그대로다. + */ +export function EditorSectionToc({ containerId }: { containerId: string }) { + const [sections, setSections] = useState>([]); + const [activeId, setActiveId] = useState(null); + + useEffect(() => { + const container = document.getElementById(containerId); + if (!container) return; + + const read = () => { + const found: Array<{ id: string; label: string }> = []; + for (const section of container.querySelectorAll("section[aria-labelledby]")) { + const labelId = section.getAttribute("aria-labelledby"); + const heading = labelId ? document.getElementById(labelId) : null; + const label = heading?.textContent?.trim(); + if (labelId && label) found.push({ id: labelId, label }); + } + setSections((current) => + current.length === found.length && current.every((item, at) => item.id === found[at]?.id) + ? current + : found, + ); + }; + + read(); + /* + 섹션은 종류를 바꾸거나 자료를 넣으면 바뀐다. 폼이 다시 그려질 때마다 목차를 다시 읽되, + 읽은 결과가 같으면 상태를 바꾸지 않는다 — 그러지 않으면 관찰이 렌더를 부르고 렌더가 다시 + 관찰을 부른다. + */ + const observer = new MutationObserver(read); + observer.observe(container, { childList: true, subtree: true }); + return () => observer.disconnect(); + }, [containerId]); + + useEffect(() => { + if (sections.length === 0) return; + /* + IntersectionObserver 가 없는 환경이 있다(jsdom 이 그렇다). 없으면 목차는 그대로 두고 지금 + 어디인지만 표시하지 않는다 — 이동은 여전히 된다. + */ + if (typeof IntersectionObserver !== "function") return; + const observer = new IntersectionObserver( + (entries) => { + const visible = entries + .filter((entry) => entry.isIntersecting) + .sort((left, right) => left.boundingClientRect.top - right.boundingClientRect.top)[0]; + if (visible) setActiveId(visible.target.id); + }, + { rootMargin: "-20% 0px -70% 0px" }, + ); + for (const section of sections) { + const heading = document.getElementById(section.id); + if (heading) observer.observe(heading); + } + return () => observer.disconnect(); + }, [sections]); + + if (sections.length < 2) return null; + + return ( +

+ ); +} diff --git a/src/features/tech-log/presentation/studio/components/ordered-text-list.tsx b/src/features/tech-log/presentation/studio/components/ordered-text-list.tsx index e8381bc..909528d 100644 --- a/src/features/tech-log/presentation/studio/components/ordered-text-list.tsx +++ b/src/features/tech-log/presentation/studio/components/ordered-text-list.tsx @@ -1,3 +1,5 @@ +import { useState } from "react"; + import type { components } from "../../../contracts/studio/generated.ts"; import { createNewItemId } from "../../../domain/studio/local-id.ts"; @@ -7,7 +9,22 @@ function ordered(items: OrderedText[]): OrderedText[] { return items.map((item, order) => ({ ...item, order })); } +/** + * 순서 있는 항목 목록. + * + *

Question 문서 하나가 7,540px 이고 textarea 가 21개였다. 반복 그룹이 여섯이고 각 항목마다 + * 「위로 · 아래로 · 삭제」 셋이 붙어 버튼이 51개였다 — 폼의 대부분이 순서를 바꾸는 버튼이었고, + * 정작 21개 입력칸은 크기·테두리·배경이 전부 같아 「확인한 사실 2」와 「선택지 4」가 눈으로 + * 구분되지 않았다. + * + *

두 가지를 바꾼다. 그룹을 접을 수 있게 해서 지금 쓰지 않는 것은 한 줄로 줄이고, 순서 바꾸기는 + * 끌어서 한다. 「위로/아래로」는 남긴다 — 끌기는 키보드로 할 수 없고, 그것만 두면 키보드로 쓰는 + * 사람에게서 순서 바꾸기를 통째로 빼앗는다. 대신 작게 적는다. + */ export function OrderedTextList({ label, fieldId, items, onChange }: { label: string; fieldId?: string; items: OrderedText[]; onChange(items: OrderedText[]): void }) { + const [collapsed, setCollapsed] = useState(false); + const [draggingIndex, setDraggingIndex] = useState(null); + const move = (index: number, delta: -1 | 1) => { const target = index + delta; if (target < 0 || target >= items.length) return; @@ -15,17 +32,62 @@ export function OrderedTextList({ label, fieldId, items, onChange }: { label: st [next[index], next[target]] = [next[target]!, next[index]!]; onChange(ordered(next)); }; + + /** 끌어 놓은 자리로 옮긴다. 두 항목을 맞바꾸지 않고 빼서 끼운다 — 세 칸을 건너뛸 때 그 사이가 뒤집히지 않는다. */ + const dropAt = (target: number) => { + if (draggingIndex === null || draggingIndex === target) return; + const next = [...items]; + const [moved] = next.splice(draggingIndex, 1); + if (moved) next.splice(target, 0, moved); + onChange(ordered(next)); + setDraggingIndex(null); + }; + return (

- {label} - {items.length === 0 ?

아직 입력한 항목이 없습니다.

: null} - {items.map((item, index) => ( -
-