diff --git a/README.md b/README.md index 1f87b88..b8aa1fb 100644 --- a/README.md +++ b/README.md @@ -559,3 +559,32 @@ 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 v3 +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 share escaped table/code markup. Confluence figures reference +the uploaded screen overlay attachment rather than embedding data URLs. 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. 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, }; diff --git a/apps/web/src/App.tsx b/apps/web/src/App.tsx index f208efb..1e4ac3e 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 && JSON.stringify(doc.blocks.find(b=>b.id===blockId)?.data)!==JSON.stringify(data)) 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==='figure'&&!doc.blocks.find(b=>b.id===blockId)?.data?.figure&&project?.screen?{data:{...doc.blocks.find(b=>b.id===blockId)?.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} 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) => (