diff --git a/src/features/tech-log/domain/content-format/project-public-render-model.ts b/src/features/tech-log/domain/content-format/project-public-render-model.ts
index 9ebb1f4..54dfe39 100644
--- a/src/features/tech-log/domain/content-format/project-public-render-model.ts
+++ b/src/features/tech-log/domain/content-format/project-public-render-model.ts
@@ -115,6 +115,16 @@ function catalogEntry(
return entry ?? null;
}
+/**
+ * 목록에 없는 대상의 자리.
+ *
+ *
계약의 `DisplayTarget` 은 비울 수 없다. 이름을 비워 두면 화면은 그 줄을 그리지 않는다 —
+ * 지어낸 이름을 넣는 것보다 낫다. 지어내면 작성자는 멀쩡한 줄을 보고 아무 문제가 없다고 읽는다.
+ */
+function placeholderTarget(): CatalogEntry {
+ return { id: "", type: "TOPIC", label: "", dependencyRevision: "missing" };
+}
+
function displayTarget(
entry: CatalogEntry,
): components["schemas"]["DisplayTarget"] {
@@ -232,9 +242,20 @@ export function projectWorkingCopy(
context: ProjectionContext,
supportsEvidenceKey: SupportsEvidenceKey,
): AuthoringRenderModel {
- const topic = catalogEntry(catalog, input.topicId, "TOPIC", true);
- const project = catalogEntry(catalog, input.projectId, "PROJECT", false);
- if (!topic) fail("TOPIC catalog entry is required");
+ /*
+ 주제와 프로젝트가 목록에 없다고 미리보기를 통째로 버리지 않는다.
+
+ 주제를 보관으로 내리거나 지우면 그 주제를 가리키던 작업본이 즉시 이 자리에서 터졌다 —
+ 작성자는 「초안을 미리 볼 수 없습니다 / TOPIC catalog entry not found: cf1fe22a…」라는
+ UUID 만 보고, 무엇을 고쳐야 하는지도 어디서 고쳐야 하는지도 알 수 없었다. 미리보기가
+ 죽으면 고칠 화면까지 함께 죽는다.
+
+ 이름 없는 자리로 대신한다. 맥락 덩어리는 이름이 빈 주제를 그리지 않으므로 화면은 조용히
+ 주제 줄만 빠지고, 무엇이 잘못됐는지는 편집 폼의 그 칸이 말한다(`missingTopicIssue`).
+ */
+ const topic =
+ catalogEntry(catalog, input.topicId, "TOPIC", false, false) ?? placeholderTarget();
+ const project = catalogEntry(catalog, input.projectId, "PROJECT", false, false);
if (input.kind === "PROJECT_DECISION" && !project) {
fail("Decision 은 프로젝트에 속합니다. 기본 정보에서 프로젝트를 골라 주세요.");
}
@@ -395,3 +416,23 @@ export function projectWorkingCopy(
};
}
}
+
+
+/**
+ * 고른 주제가 목록에 없다면 그 사실을 한 문장으로.
+ *
+ *
미리보기는 이제 이 경우에 죽지 않고 주제 줄만 비운다. 그러면 작성자에게는 아무 일도 없었던
+ * 것처럼 보이므로, 고쳐야 할 칸이 스스로 말해야 한다.
+ */
+export function missingTopicIssue(
+ topicId: string | null,
+ catalog: ReadonlyArray,
+): string | null {
+ if (!topicId) return null;
+ const found = catalog.some(
+ (entry) => entry.id === topicId && entry.type === "TOPIC",
+ );
+ return found
+ ? null
+ : "고른 주제를 목록에서 찾을 수 없습니다. 보관됐거나 지워진 주제입니다 — 다시 골라 주세요.";
+}
diff --git a/src/features/tech-log/presentation/studio/components/asset-picker-dialog.tsx b/src/features/tech-log/presentation/studio/components/asset-picker-dialog.tsx
new file mode 100644
index 0000000..9436a3c
--- /dev/null
+++ b/src/features/tech-log/presentation/studio/components/asset-picker-dialog.tsx
@@ -0,0 +1,108 @@
+import { useEffect, useRef, useState } from "react";
+
+import type { StudioAssetGateway } from "../../../application/ports/studio-asset-gateway.ts";
+import type { Asset } from "../../../contracts/studio/contract.ts";
+import { AssetPicker } from "./asset-picker.tsx";
+
+/** 본문이 그림을 가리키는 방법. 이 수를 세면 "지금 몇 개를 쓰는가" 가 나온다. */
+const EVIDENCE_DIRECTIVE = /^:::evidence\b/gmu;
+
+export function countBodyAssets(bodyMarkdown: string): number {
+ return bodyMarkdown.match(EVIDENCE_DIRECTIVE)?.length ?? 0;
+}
+
+/**
+ * 자료는 고르러 들어가는 것이지 폼에 펼쳐 두는 것이 아니다.
+ *
+ *
편집 폼 아래에 고를 수 있는 자료가 전부 펼쳐져 있었다. 36개면 36줄이고, 줄마다 파일 이름과
+ * 삭제 단추가 따라붙어 본문보다 자료 목록이 길었다 — 좁은 화면에서는 그 덩어리가 여러 줄로
+ * 깨지면서 삭제 단추만 따로 떨어지기도 했다. 글을 쓰는 화면이 자료 관리 화면이 되어 있었다.
+ *
+ *
폼에는 지금 몇 개를 쓰는지와 넣는 단추만 둔다. 고르는 일은 창 안에서 한다 — 검색과 목록은
+ * 그대로 쓰되 글의 흐름을 막지 않는다.
+ *
+ *
관리(이름·대체 텍스트·사용처·삭제)는 Asset 화면이 맡는다. 같은 자료를 두 화면이 다루되
+ * 하는 일이 다르다: 여기는 글에 넣기, 저기는 관리하기.
+ */
+export function AssetPickerDialog({
+ gateway,
+ usedCount,
+ onInsert,
+ onAssetsObserved,
+}: {
+ gateway: StudioAssetGateway;
+ /** 본문이 지금 가리키는 자료 수. */
+ usedCount: number;
+ onInsert(directive: string): void;
+ onAssetsObserved?(assets: readonly Asset[]): void;
+}) {
+ const [open, setOpen] = useState(false);
+ const dialogRef = useRef(null);
+ const triggerRef = useRef(null);
+
+ useEffect(() => {
+ const dialog = dialogRef.current;
+ if (!dialog) return;
+ /*
+ `showModal` 이 없는 환경이 있다(jsdom 이 그렇다). 없으면 창을 그냥 보이는 상태로 둔다 —
+ 고르지 못하게 막는 것보다 낫다.
+ */
+ if (open) {
+ if (typeof dialog.showModal === "function") dialog.showModal();
+ else dialog.setAttribute("open", "");
+ } else if (dialog.open) {
+ if (typeof dialog.close === "function") dialog.close();
+ else dialog.removeAttribute("open");
+ }
+ }, [open]);
+
+ const close = () => {
+ setOpen(false);
+ // 닫고 나면 초점이 갈 곳이 있어야 한다. 열었던 단추로 돌려준다.
+ queueMicrotask(() => triggerRef.current?.focus());
+ };
+
+ return (
+
+
+ {usedCount > 0 ? `본문에서 자료 ${usedCount}개를 씁니다` : "본문에 넣은 자료가 없습니다"}
+
+
+
+
+
+ );
+}
diff --git a/src/features/tech-log/presentation/studio/components/case-fields.tsx b/src/features/tech-log/presentation/studio/components/case-fields.tsx
index 6a01c3b..bd12b9d 100644
--- a/src/features/tech-log/presentation/studio/components/case-fields.tsx
+++ b/src/features/tech-log/presentation/studio/components/case-fields.tsx
@@ -3,7 +3,8 @@ import { useRef, useState } from "react";
import type { components } from "../../../contracts/studio/generated.ts";
import type { Asset, AssetKind } from "../../../contracts/studio/contract.ts";
import { useStudioAssetGateway } from "../use-studio.ts";
-import { AssetPicker, buildEvidenceDirective } from "./asset-picker.tsx";
+import { buildEvidenceDirective } from "./asset-picker.tsx";
+import { AssetPickerDialog, countBodyAssets } from "./asset-picker-dialog.tsx";
import { AssetUploadDialog } from "./asset-upload-dialog.tsx";
import { MarkdownToolbar } from "./markdown-toolbar.tsx";
import { FieldNotice, type FieldIssue } from "./field-issues.tsx";
@@ -122,7 +123,7 @@ export function CaseFields({
Asset 업로드
-
+
{uploadOpen ? (
): void;
}) {
+ const missingTopic = missingTopicIssue(draft.topicId ?? null, topics);
+
return (
DOCUMENT
기본 정보
@@ -61,7 +64,15 @@ export function CommonDocumentFields({
남은 자리는 그 옆에 따로 보여 준다.
*/}
-
+ {/*
+ 고른 주제가 목록에 없을 수 있다 — 보관으로 내렸거나 지워진 주제다. 예전에는 그 상태가
+ 미리보기를 통째로 죽여 UUID 만 보여 줬다. 지금은 미리보기가 살아 있으므로, 무엇이
+ 잘못됐는지는 이 칸이 말해야 한다.
+
+ 없는 값을 셀렉트에 임시 항목으로 남겨 둔다. 남기지 않으면 셀렉트가 「선택하지 않음」으로
+ 보여서, 작성자는 고른 적 없는 주제 때문에 경고가 뜬다고 읽는다.
+ */}
+
{/*
diff --git a/src/features/tech-log/presentation/studio/components/concept-fields.tsx b/src/features/tech-log/presentation/studio/components/concept-fields.tsx
index 8c41cc4..9d4e04e 100644
--- a/src/features/tech-log/presentation/studio/components/concept-fields.tsx
+++ b/src/features/tech-log/presentation/studio/components/concept-fields.tsx
@@ -3,7 +3,8 @@ import { useRef, useState } from "react";
import type { components } from "../../../contracts/studio/generated.ts";
import type { Asset, AssetKind } from "../../../contracts/studio/contract.ts";
import { useStudioAssetGateway } from "../use-studio.ts";
-import { AssetPicker, buildEvidenceDirective } from "./asset-picker.tsx";
+import { buildEvidenceDirective } from "./asset-picker.tsx";
+import { AssetPickerDialog, countBodyAssets } from "./asset-picker-dialog.tsx";
import { AssetUploadDialog } from "./asset-upload-dialog.tsx";
import { MarkdownToolbar } from "./markdown-toolbar.tsx";
import { FieldNotice, type FieldIssue } from "./field-issues.tsx";
@@ -111,7 +112,7 @@ export function ConceptFields({
Asset 업로드
-
+
{uploadOpen ? (
-
+
{uploadOpen ? (
boolean>> =
/**
* 어느 일에 속한 화면인가.
*
- *
여섯 자리가 같은 무게로 늘어서 있었다. 「작업본」과 「릴리즈」가 같은 크기로 나란하면
- * 어디부터 봐야 하는지를 화면이 말해 주지 않는다 — 정보 구조가 평평해 보이는 것이 그 때문이다.
+ *
목적지 여섯이 같은 무게로 늘어서 있었다. 묶음 이름으로 구분선을 그어 봤지만, 처음 들어온
+ * 사람은 여전히 여섯 중 어디부터 가야 하는지를 스스로 판단해야 했다 — 나뉘어 보이는 것과 적어
+ * 보이는 것은 다르다.
*
- *
글을 쓰는 일, 구조를 손보는 일, 자료를 관리하는 일, 내보내는 일 넷으로 묶는다. 계약이
- * 이름과 순서를 갖고 있으므로 여기서는 묶음만 정한다 — `Record<…>` 라 계약에 탐색 항목이
- * 늘면 컴파일러가 빈 자리를 잡는다.
+ *
위에는 네 가지 일만 둔다. 그 안의 화면은 그 일을 고른 뒤에 나타난다. 「자료」처럼 화면이
+ * 하나뿐인 일은 두 번 적지 않는다 — 묶음 이름과 그 안의 유일한 항목이 같은 말이면 목록만 길어진다.
+ *
+ *
`Record<…>` 라 계약에 탐색 항목이 늘면 컴파일러가 빈 자리를 잡는다.
*/
-const GROUP_OF: Record = {
+type StudioGroup = "작업" | "구조" | "자료" | "게시";
+
+const GROUP_OF: Record = {
TECH_LOG_STUDIO_DOCUMENTS: "작업",
TECH_LOG_STUDIO_DOCUMENT_NEW: "작업",
TECH_LOG_STUDIO_TAXONOMY: "구조",
@@ -40,40 +44,67 @@ const GROUP_OF: Record = {
TECH_LOG_STUDIO_RELEASES: "게시",
};
-const GROUP_ORDER = ["작업", "구조", "자료", "게시"] as const;
+const GROUP_ORDER: ReadonlyArray = ["작업", "구조", "자료", "게시"];
+
+/** 그 일을 고르면 먼저 열리는 화면. */
+const GROUP_HOME: Record = {
+ 작업: "/studio/documents",
+ 구조: "/studio/taxonomy",
+ 자료: "/studio/assets",
+ 게시: "/studio/publications",
+};
const navigation = techLogNavigation("STUDIO").map((entry) => ({
+ routeId: entry.routeId,
href: entry.path,
label: entry.label,
group: GROUP_OF[entry.routeId] ?? "작업",
active: activeRules[entry.routeId] ?? ((path: string) => path === entry.path),
}));
+/** 지금 보고 있는 일. 어느 화면에도 걸리지 않으면(대시보드 등) 「작업」으로 둔다. */
+function currentGroup(path: string): StudioGroup {
+ const match = navigation.find((item) => item.active(path));
+ return match?.group ?? "작업";
+}
+
function StudioNavigation({
currentPath,
label,
}: Readonly<{ currentPath: string; label: string }>) {
+ const here = currentGroup(currentPath);
+ const inGroup = navigation.filter((item) => item.group === here);
return (