From d72eae25ce279e9837b531d9141479d239fa1b9e Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Wed, 16 Sep 2026 16:43:37 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=B0=94=ED=83=95=ED=99=94=EB=A9=B4=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=EB=B3=B8=EC=9D=98=20Studio=20=ED=8E=B8?= =?UTF-8?q?=EC=A7=91=EA=B8=B0=20v2~v4=20=EB=A5=BC=20=EC=96=B9=EB=8A=94?= =?UTF-8?q?=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `~/Desktop/tech-log-frontend` 가 세 번 더 고쳐져 있었다. 소스 열셋이 바뀌고 둘이 새로 생겼다(`markdown-block-editor`, `catalog-property-picker`). 검사 넷도 함께 바뀌었다. 기능이 바뀐 것부터 적는다. **편집기에서 즉시 미리보기가 빠졌다.** v2 에서 「편집/나란히/미리보기」 모드가 생겼고, v4 가 그 모드 자체를 없앴다 — 글 쓰는 화면은 하나이고 공개 렌더는 편집기의 두 번째 상태가 아니라는 판단이다. 직전 리뷰의 완료 조건 하나("preview 는 Desktop/Mobile 을 실제로 전환할 수 있다")가 이로써 다시 미적용이 된다. `InstantPreview` 는 파일로 남아 있으나 편집기 어디서도 부르지 않는다. **본문이 textarea 에서 블록 편집기로 바뀌었다.** 기존 markdown 을 문단·제목·목록·인용· 코드·구분선·raw 로 읽고 같은 `bodyMarkdown` 계약으로 되돌려 쓴다. 읽었다가 그대로 다시 쓰는 왕복이 글을 바꾸면 작성자가 문서를 열어 저장하기만 해도 내용이 상하므로, 이 저장소가 실제로 쓰는 문법(앵커 단 소제목, 이름표 단 코드 울타리, `:::evidence`, 표, 인용, 목록, 구분선)을 하나씩 넣어 왕복을 검사로 고정했다. 빈 줄이 겹친 자리만 한 줄로 접히고 글자는 그대로다 — 그 예외도 검사에 적었다. Project·Topic 이 검색 가능한 고르개로, 상태가 인라인 알약으로 바뀌었고, 메타데이터는 접히는 속성 면으로 내려갔다. `useImperativeHandle` 안에서 부르는 `commit` 이 렌더마다 새로 만들어져 lint 가 막았다. `useCallback` 으로 고정했다 — 바뀌는 것은 `onChange` 하나다. Node 24 로 게이트 재실행: check:types · lint · test:unit(1829) · test:component(152) · test:tech-log(432) 전부 통과. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_015c8cBFUaVr7KLVUx6ujz7D --- .../studio/components/case-fields.tsx | 143 +- .../components/catalog-property-picker.tsx | 88 + .../components/common-document-fields.tsx | 225 +- .../studio/components/concept-fields.tsx | 130 +- .../studio/components/document-editor.tsx | 195 +- .../studio/components/document-status-bar.tsx | 82 +- .../components/editor-context-panel.tsx | 74 +- .../components/markdown-block-editor.tsx | 343 +++ .../studio/components/ordered-text-list.tsx | 86 +- .../components/project-decision-fields.tsx | 97 +- .../studio/components/question-fields.tsx | 112 +- .../studio/components/reference-fields.tsx | 59 +- .../studio/components/setup-fields.tsx | 196 +- .../tech-log/presentation/styles/globals.css | 11 +- .../presentation/styles/studio-editor.css | 2196 +++++++++++++++++ tests/features/tech-log/asset-picker.test.tsx | 88 +- .../tech-log/markdown-block-roundtrip.test.ts | 47 + .../studio-decision-authoring.test.tsx | 32 +- .../tech-log/studio-editor-smoke.test.tsx | 69 +- .../studio-validation-preview.test.tsx | 2 +- 20 files changed, 3322 insertions(+), 953 deletions(-) create mode 100644 src/features/tech-log/presentation/studio/components/catalog-property-picker.tsx create mode 100644 src/features/tech-log/presentation/studio/components/markdown-block-editor.tsx create mode 100644 tests/features/tech-log/markdown-block-roundtrip.test.ts 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 bd12b9d..9087b9f 100644 --- a/src/features/tech-log/presentation/studio/components/case-fields.tsx +++ b/src/features/tech-log/presentation/studio/components/case-fields.tsx @@ -6,12 +6,11 @@ import { useStudioAssetGateway } from "../use-studio.ts"; 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"; +import { MarkdownBlockEditor, type MarkdownBlockEditorHandle } from "./markdown-block-editor.tsx"; type CaseInput = components["schemas"]["CaseInput"]; -/** 이 화면이 자기 칸 아래에 보여 줄 수 있는 경로. */ export const CASE_FIELD_PATHS = [ "/problem", "/conclusion", @@ -27,26 +26,6 @@ const ASSET_KIND_OPTIONS: ReadonlyArray<{ value: AssetKind; label: string }> = [ { value: "ATTACHMENT", label: "첨부파일" }, ]; -/** - * `:::evidence ...` is a block directive, so the parser requires a blank line - * before and after it. Inserting straight into `selectionStart`/`selectionEnd` - * without normalizing the surrounding whitespace would produce a directive - * glued to adjacent text -- a well-formed-looking block that the parser still - * rejects. - */ -function insertAtCursor( - textarea: HTMLTextAreaElement, - directive: string, - commit: (next: string) => void, -) { - const { selectionStart, selectionEnd, value } = textarea; - const prefix = value.slice(0, selectionStart); - const suffix = value.slice(selectionEnd); - const before = prefix.length === 0 || prefix.endsWith("\n\n") ? prefix : `${prefix}\n\n`; - const after = suffix.startsWith("\n") ? suffix : `\n${suffix}`; - commit(`${before}${directive}${after}`); -} - export function CaseFields({ draft, issues, @@ -55,37 +34,21 @@ export function CaseFields({ onAssetUploaded, }: { draft: CaseInput; - /** 마지막 게시 시도가 남긴 지적. 각 칸 아래에는 그 칸의 것만 붙는다. */ issues: readonly FieldIssue[]; onChange(draft: CaseInput): void; - /** - * The editor screen owns the resolution catalog Instant Preview reads, and - * merges what the Picker observes into it -- it never adopts the Picker's - * (searchable, and so narrowable) displayed list wholesale. - */ onAssetsObserved?: (assets: readonly Asset[]) => void; onAssetUploaded?: (asset: Asset) => void; }) { - // Asset UI must use the throwing accessor, not the nullable `assetGateway` - // field directly -- see `use-studio.ts`'s `useStudioAssetGateway` doc. const assetGateway = useStudioAssetGateway(); - const bodyRef = useRef(null); + const bodyEditorRef = useRef(null); const uploadTriggerRef = useRef(null); const [uploadKind, setUploadKind] = useState("IMAGE"); const [uploadOpen, setUploadOpen] = useState(false); const update = (patch: Partial) => onChange({ ...draft, ...patch }); const insertDirective = (directive: string) => { - const textarea = bodyRef.current; - if (!textarea) { - update({ - bodyMarkdown: draft.bodyMarkdown - ? `${draft.bodyMarkdown}\n\n${directive}\n` - : `${directive}\n`, - }); - return; - } - insertAtCursor(textarea, directive, (next) => update({ bodyMarkdown: next })); + if (bodyEditorRef.current) bodyEditorRef.current.insertMarkdown(directive); + else update({ bodyMarkdown: draft.bodyMarkdown ? `${draft.bodyMarkdown}\n\n${directive}` : directive }); }; const closeUpload = () => { @@ -94,37 +57,81 @@ export function CaseFields({ }; return ( -
-

CASE

문제와 검증

-
-