Skip to content

feat: rich document blocks with lossless storage and print output (DEV-118) - #40

Merged
developjik merged 41 commits into
mainfrom
instinct/dev118-rich-blocks
Nov 25, 2026
Merged

developjik merged 41 commits into
mainfrom
instinct/dev118-rich-blocks

Conversation

@developjik

@developjik developjik commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Add table, code and figure blocks beside the four existing prose kinds. Tables edit cells, rows, columns and the header; code labels its language and can be copied; figures refer to the document screen capture and optional pin, with required alt text.
  • Keep structured data in existing SQLite attrs, proposal snapshots, imports and content fingerprints. Preserve unknown block payloads read-only instead of stripping or deleting them.
  • Share escaped HTML/Confluence block rendering and print CSS. Rich/unknown block exports use bundle v2 so old readers reject rather than discard their structured payloads. Existing prose-only single-screen bundles stay v1.

Validation

  • pnpm check passes: 269 unit tests, 40 eval cases, type/eval type checks, build, dependency boundaries and schema contract.
  • All 9 local/mock E2E harnesses passed, including rich editor cell/row/column edits, code language, figure alt, reload, HTML download, PDF generation and mobile layout.
  • Added store tests for all seven kinds across restart, opaque block preservation after unrelated edits, unknown-edit rejection, import reference remapping, escaped output and rich proposal snapshot roundtrip.
  • Added publish test for table/code markup and structured-content hash invalidation.
  • Desktop/mobile editor, downloaded HTML and printed PDF pixels inspected with Korean text.

Boundaries

  • Figure uses an existing screen image. It does not implement DEV-52 state capture or upload arbitrary files.
  • PDF verification uses the existing HTML browser-print path, not a new PDF engine.
  • No real Confluence account, paid model or manual release was used.

Linear: https://linear.app/developjik/issue/DEV-118/spec-studio-리치-블록-표그림코드-블록을-문서에서-편집렌더


Devin Review

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-24T23:26:28.668316Z
We couldn’t complete this review. Comment @codex review to try again.
570376f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

devin-ai-integration[bot]

This comment was marked as resolved.

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

Devin Review found 4 new potential issues.

Devin Review

Comment thread packages/core/src/transfer.ts Resolved
if (!isKnownBlockType(current.type)) throw new DomainError('invalid_input', '알 수 없는 블록은 읽기 전용입니다');
const block = BlockSchema.parse({
...current,
data: command.data ? {...current.data,...command.data} : current.data ?? (command.blockType==='table'?{table:{rows:[['',''],['','']],header:true}}:command.blockType==='code'?{code:{language:'text',lineNumbers:false}}:undefined),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 리치 블록을 편집할 때 가져온 확장 데이터 유실

가져온 표의 셀을 SQLite 모드에서 편집하면, 저장 명령이 표의 확장 속성을 제거합니다. 편집기가 함께 전송한 숨겨진 코드나 그림의 확장 속성도 사라집니다.

Learn more

BlockSchema는 알려진 블록의 data를 검증하되 검증 결과 대신 원본을 유지하므로, 가져온 표의 중첩 확장 속성도 처음에는 남아 있습니다. RichBlockEditor는 셀을 편집할 때 표만이 아니라 블록의 전체 data를 보냅니다. 데몬의 명령 파서는 RichBlockDataSchema를 사용하며, 이 스키마의 중첩 객체들은 정의되지 않은 키를 제거합니다. 코어는 기존 data와 명령의 data를 한 단계만 병합하므로 파싱된 표 객체가 기존 표 객체를 통째로 대체합니다.

Example: data.table에 columnWidths: [120, 240]가 있는 표를 가져옵니다. 셀 내용을 고친 뒤 다시 내보내면 새 셀 값은 있지만 columnWidths가 없습니다.

Recommended fix: 리치 데이터 명령의 중첩 스키마에서도 확장 키를 유지하고, 편집기는 변경한 종류의 데이터만 전송하세요. 알려진 필드의 검증과 그림의 선택적 pinId 제거 동작은 유지하세요. 번들 가져오기부터 실제 데몬 명령과 재내보내기까지 테스트하세요.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

? `<h3>${escapeXml(block.text)}${mark}</h3>`
: `<p>${multiline(block.text)}${mark}${meta}</p>`;
const figure=block.type==='figure'?block.data?.figure:undefined;
const body=figure ? (overlay&&figure.screenId===screen.id ? `<p><ac:image ac:alt="${escapeXml(figure.alt)}"><ri:attachment ri:filename="${escapeXml(overlay.fileName)}" /></ac:image></p><p>${escapeXml(figure.alt)}${figure.pinId?' · '+escapeXml(figure.pinId):''}</p>` : '<p>연결된 화면 캡처 첨부를 사용할 수 없습니다.</p>') : renderRichBlock(block,screen);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Confluence에 발행한 그림에서 본문 누락

그림 블록의 내용란에 설명을 쓰고 Confluence에 발행하면, 그림과 대체 텍스트만 표시되고 설명은 빠집니다. 캡처를 표시할 수 없는 경우에도 설명이 빠집니다.

Learn more

그림 블록 편집기는 대체 텍스트와 별도로 블록의 내용란을 제공합니다. 정적 그림 렌더러는 이미지가 있든 없든 내용란의 텍스트를 그림 캡션에 넣습니다. Confluence의 그림 전용 분기는 첨부 파일을 사용할 수 있으면 대체 텍스트와 핀 ID만 쓰고, 사용할 수 없으면 안내 문구만 쓰므로 두 경우 모두 텍스트를 잃습니다.

Example: 대체 텍스트가 주문 상세 화면이고 내용란이 결제 실패 시 재시도 버튼을 표시한다인 그림을 발행하면, Confluence 페이지에 결제 실패 규칙이 나오지 않습니다.

Recommended fix: 이미지·대체 안내 분기와 캡션 생성을 분리하세요. 두 분기에서 모두 이스케이프한 block.text를 캡션에 포함하고, 첨부가 있을 때는 ac:image 참조를 유지하세요. 발행 테스트에 비어 있지 않은 그림 본문을 추가하세요.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +76 to +78
export function bundleVersion(project: Project):1|2|3 {
if(project.docs.some(doc=>doc.blocks.some(block=>!['paragraph','heading','list','caption'].includes(block.type)||block.data!==undefined))) return 3;
return (project.screens?.length??0)>1 ? 2 : 1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 리치 번들 버전이 PR 설명과 다름

PR 설명은 리치 블록이 포함된 번들을 v2로 내보낸다고 안내하지만, 코드는 v3을 사용합니다. v2까지 읽는 도구에서는 이 번들을 열 수 없으므로 배포 안내에 호환성 경계를 명시하세요.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

Devin Review

const blocks: Block[] = doc.blocks.map((block) => ({
...block,
id: blockIds.get(block.id)!,
...(isKnownBlockType(block.type)&&block.data?.figure?{data:{...block.data,figure:{...block.data.figure,screenId:screenIds.get(block.data.figure.screenId)??block.data.figure.screenId,...(block.data.figure.pinId?{pinId:pinIds.get(block.data.figure.pinId)??block.data.figure.pinId}:{})}}}:{}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 알 수 없는 블록의 ID 재매핑 테스트 누락

저장소 테스트는 ID 재매핑이 끝난 뒤 알 수 없는 블록을 추가합니다. 같은 화면 ID를 참조하는 그림 블록과 알 수 없는 블록을 함께 가져와, 그림 블록의 화면 ID만 바뀌는지 확인하면 원본 보존을 검증할 수 있습니다.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Ensure proper formatting by adding a newline at the end of the file.
@developjik
developjik merged commit aa7f91c into main Nov 25, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant