From 1803f4b8614d84fb3a3be9cd6e8c36ae5553aabd Mon Sep 17 00:00:00 2001 From: developjik <67889389+developjik@users.noreply.github.com> Date: Wed, 25 Nov 2026 08:21:26 +0900 Subject: [PATCH 01/41] Add new block types and update schemas --- packages/protocol/src/doc.ts | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/protocol/src/doc.ts b/packages/protocol/src/doc.ts index acf2a20..ddd78a0 100644 --- a/packages/protocol/src/doc.ts +++ b/packages/protocol/src/doc.ts @@ -23,11 +23,10 @@ export type BlockId = z.infer; export type ProposalId = z.infer; /** - * The four block types v1 edits. The schema knows more (table cells, figures, - * code), but a paragraph-level editor that cannot render them would delete - * what it cannot see, so they are added when the editor can. + * The seven editable block types. Unknown imported types remain read-only and + * retain their original fields for lossless export. Structured data lives in attrs. */ -export const BLOCK_TYPES = ['paragraph', 'heading', 'list', 'caption'] as const; +export const BLOCK_TYPES = ['paragraph', 'heading', 'list', 'caption', 'table', 'code', 'figure'] as const; export const BlockTypeSchema = z.enum(BLOCK_TYPES); export type BlockType = z.infer; @@ -36,6 +35,9 @@ export const BLOCK_TYPE_LABEL: Record = { heading: '제목', list: '목록', caption: '캡션', + table: '표', + code: '코드', + figure: '그림', }; /** @@ -60,9 +62,17 @@ export const BlockPinRefSchema = z.object({ export type BlockPinRef = z.infer; -export const BlockSchema = z.object({ +export const RichBlockDataSchema = z.looseObject({ + table: z.object({ rows: z.array(z.array(z.string().max(8000)).min(1).max(30)).min(1).max(100), header: z.boolean() }).refine(t=>t.rows.every(row=>row.length===t.rows[0]?.length), '표의 열 수가 일치해야 합니다').optional(), + code: z.object({ language: z.string().max(40), lineNumbers: z.boolean() }).optional(), + figure: z.object({ screenId: z.string().min(1), pinId: PinIdSchema.optional(), alt: z.string().trim().min(1).max(500) }).optional(), +}); +export type RichBlockData = z.infer; +export const isKnownBlockType = (type:string): type is BlockType => (BLOCK_TYPES as readonly string[]).includes(type); +export const BlockSchema = z.looseObject({ id: BlockIdSchema, - type: BlockTypeSchema, + type: z.string().min(1).max(100), + data: RichBlockDataSchema.optional(), text: z.string().max(8000), pinRefs: z.array(BlockPinRefSchema).max(24), createdAt: z.string().min(1), From 22fae95343babb7557c370bf1c83e063baff7fa4 Mon Sep 17 00:00:00 2001 From: developjik <67889389+developjik@users.noreply.github.com> Date: Wed, 25 Nov 2026 08:21:33 +0900 Subject: [PATCH 02/41] Update README.md --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index 1f87b88..e1f0e83 100644 --- a/README.md +++ b/README.md @@ -559,3 +559,31 @@ screen alias on load. Single-screen downloads keep bundle version 1 and the scre downloads use bundle version 2 so older single-screen readers reject them instead of silently collapsing ownership. New readers accept both versions. Images may appear twice in downloaded bundles; only browser storage compacts the alias. + + +### Rich document blocks (DEV-118) + +The document editor supports paragraph, heading, list, caption, table, code and +figure blocks. Tables have editable cells, a header row toggle and row/column +controls (100 rows, 30 columns maximum). Code has a language label and copy +button. Figures reference the document's own screen image and an optional pin; +alt text is required. They do not upload files or implement DEV-52 state capture. +If that screen has no image, the missing capture is shown explicitly. + +`doc.block.create` and `doc.block.update` accept optional `data`: `table` contains +`rows: string[][]` and `header: boolean`; `code` contains `language` and +`lineNumbers`; `figure` contains `screenId`, optional `pinId`, and nonempty `alt`. +Rich data is stored in the existing block `attrs` JSON, without a DB migration. Exports containing rich or unknown blocks use bundle v2 +so older readers reject them rather than stripping structured fields. +`block.type` stays open when reading: unknown types retain all fields, use a +read-only fallback in the editor and escaped text in output. SQLite stores their +original payload in attrs with its existing `criteria` carrier type. Editing an +unrelated block does not strip unknown data. Unknown blocks cannot be changed, +reordered, linked or deleted through block commands or proposal adoption. + +HTML and Confluence use the same escaped block renderer. HTML embeds print CSS +and prints to PDF using the browser, preserving cells, code whitespace and figure +alt captions. It makes no external image requests. Rich blocks are edited directly, +not rewritten by prose AI proposals; pin references never alter code contents. +`test/e2e/run_rich.sh` verifies editor changes, reload, HTML download, PDF rendering +and mobile layout. The full E2E runner includes this as its ninth harness. From 598694658023cb3b4beb5e243ef5b7a5610221e3 Mon Sep 17 00:00:00 2001 From: developjik <67889389+developjik@users.noreply.github.com> Date: Wed, 25 Nov 2026 08:21:41 +0900 Subject: [PATCH 03/41] Update server.ts --- apps/daemon/src/server.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/daemon/src/server.ts b/apps/daemon/src/server.ts index 3f496ed..a485e7d 100644 --- a/apps/daemon/src/server.ts +++ b/apps/daemon/src/server.ts @@ -1,3 +1,4 @@ +import { bundleVersion } from '@spec-studio/protocol'; import { createServer, type IncomingMessage, type Server, type ServerResponse } from 'node:http'; import { mkdirSync } from 'node:fs'; import { dirname } from 'node:path'; @@ -522,7 +523,7 @@ export async function startDaemon(options: DaemonOptions): Promise { if (req.method !== 'GET') throw new HttpError(405, 'method_not_allowed', 'GET만 허용됩니다.'); const bundle: ProjectBundle = { format: 'spec-studio.bundle', - version: (project.screens?.length ?? 0) > 1 ? 2 : 1, + version: bundleVersion(project), exportedAt: now(), project, }; From 8b071fb122d8bf35637ed574b023eec47d7bc7fc Mon Sep 17 00:00:00 2001 From: developjik <67889389+developjik@users.noreply.github.com> Date: Wed, 25 Nov 2026 08:21:58 +0900 Subject: [PATCH 04/41] Update App.tsx --- apps/web/src/App.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/web/src/App.tsx b/apps/web/src/App.tsx index f208efb..9f153ab 100644 --- a/apps/web/src/App.tsx +++ b/apps/web/src/App.tsx @@ -647,6 +647,9 @@ export default function App() { void runDoc({ type: 'doc.block.update', docId: doc.id, blockId, text }); }; + const updateBlockData = (blockId:string,data:import('@spec-studio/protocol').RichBlockData) => { + if(doc!==null) void runDoc({type:'doc.block.update',docId:doc.id,blockId,data}); + }; const changeBlockType = (blockId: string, blockType: BlockType) => { if (doc === null) return; void runDoc({ @@ -654,6 +657,7 @@ export default function App() { docId: doc.id, blockId, blockType, + ...(blockType==='table'?{data:{table:{rows:[['제목','값'],['','']],header:true}}}:blockType==='code'?{data:{code:{language:'text',lineNumbers:false}}}:blockType==='figure'&&project?.screen?{data:{figure:{screenId:project.screen.id,alt:project.screen.title}}}:{}), }); }; @@ -1632,6 +1636,8 @@ export default function App() { onAddBlock={addBlock} onUpdateText={updateBlockText} onChangeType={changeBlockType} + onUpdateData={updateBlockData} + screens={(project.screens ?? []).filter(s=>s.id===project.screen?.id)} onDeleteBlock={deleteBlock} onMoveBlock={moveBlock} onLinkPin={linkBlockPin} From 891abf9b8c95ed26529cced6fcc7a73add6302f6 Mon Sep 17 00:00:00 2001 From: developjik <67889389+developjik@users.noreply.github.com> Date: Wed, 25 Nov 2026 08:22:07 +0900 Subject: [PATCH 05/41] Update DocPanel.tsx --- apps/web/src/components/DocPanel.tsx | 36 +++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/apps/web/src/components/DocPanel.tsx b/apps/web/src/components/DocPanel.tsx index a7af81b..0a96fe7 100644 --- a/apps/web/src/components/DocPanel.tsx +++ b/apps/web/src/components/DocPanel.tsx @@ -2,6 +2,9 @@ import { proposalQueue, proposalConflicts, proposalIsStale } from '@spec-studio/ import { useEffect, useRef, useState, type FormEvent } from 'react'; import { BLOCK_TYPES, + isKnownBlockType, + type RichBlockData, + type Screen, BLOCK_TYPE_LABEL, PIN_TYPE_LABEL, type Block, @@ -29,6 +32,8 @@ export interface RevertableView { } interface DocPanelProps { + screens: Screen[]; + onUpdateData: (blockId:string,data:RichBlockData)=>void; doc: Doc | null; /** The registry; one tab each, the active one is `doc`. */ docs: Doc[]; @@ -355,6 +360,8 @@ export function DocPanel(props: DocPanelProps) { selectedPinId={selectedPinId} flashed={flash === block.id} first={index === 0} + screens={props.screens} + onUpdateData={props.onUpdateData} onUpdateText={props.onUpdateText} onChangeType={props.onChangeType} onDelete={props.onDeleteBlock} @@ -494,6 +501,8 @@ function truncate(text: string, size = 64): string { } interface BlockRowProps { + screens: Screen[]; + onUpdateData: (blockId:string,data:RichBlockData)=>void; block: Block; position: number; pins: Pin[]; @@ -513,7 +522,8 @@ interface BlockRowProps { } function BlockRow(props: BlockRowProps) { - const { block, pins, doc, editable } = props; + const { block, pins, doc } = props; + const editable = props.editable && isKnownBlockType(block.type); const [text, setText] = useState(block.text); const [linkPin, setLinkPin] = useState(''); @@ -554,6 +564,7 @@ function BlockRow(props: BlockRowProps) { onChange={(event) => props.onChangeType(block.id, event.target.value as BlockType)} data-testid={`block-type-${props.position}`} > + {!isKnownBlockType(block.type)&&} {BLOCK_TYPES.map((type) => (