Skip to content

feat(docs): S-DOCS3 page embed block — inline doc preview in tiptap#247

Merged
AngryJay91 merged 2 commits intomainfrom
feat/SID-E036-DOCS3-page-embed
Apr 15, 2026
Merged

feat(docs): S-DOCS3 page embed block — inline doc preview in tiptap#247
AngryJay91 merged 2 commits intomainfrom
feat/SID-E036-DOCS3-page-embed

Conversation

@AngryJay91
Copy link
Copy Markdown
Contributor

Summary

  • Add PageEmbedExtension Tiptap node with React node view for embedding pages inside docs
  • Slash command /Page Embed triggers the block; inline picker accepts doc slug or ID
  • Fetches /api/docs/[id] → renders icon + title + slug preview card; click navigates via onNavigate
  • Graceful fallback: 404/network error shows "Document unavailable" state with Change button
  • Circular embed guard: isCircularEmbed(docId, currentDocId) prevents A embedding A; error state rendered when triggered
  • DocEditor gains currentDocId and onNavigate props; DocsShellClient wires both from selectedDoc.id + handleSelectDoc

AC checklist

  • Slash command triggers page embed block
  • Inline doc slug/ID picker UI
  • Render: title + icon + /slug preview, click navigates
  • Graceful fallback for deleted/unavailable docs
  • Circular embed detection (A → A)
  • Unit tests: isCircularEmbed — 7 cases, all green
  • Type check 0 errors
  • 728/728 tests pass

Test plan

  • Insert /Page Embed in an open doc — picker input renders
  • Enter a valid doc slug → preview card renders with title, icon, slug
  • Click card → navigates to that doc
  • Enter an invalid slug → "Document not found" fallback renders
  • Open doc A, embed doc A (same currentDocId) → circular error state renders
  • isCircularEmbed unit test: 7/7 pass

🤖 Generated with Claude Code

Add PageEmbedExtension Tiptap node allowing any document to embed
another page as a clickable preview card inside the editor.

AC coverage:
- Slash command trigger (/Page Embed) inserts embed block
- Inline picker: enter doc slug/ID → fetches /api/docs/[id] → renders
  icon + title + slug preview; click navigates via onNavigate
- Graceful fallback: 404/network error shows "Document unavailable"
  with Change button to re-pick
- Circular embed detection: docId === currentDocId shows error state
  (prevents A embedding A)
- isCircularEmbed() pure function — 7 unit tests, all green
- Type check 0 errors, 728/728 tests pass

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sprintable Ready Ready Preview, Comment Apr 15, 2026 0:37am

**BLOCKER 1: /api/docs/[id] 엔드포인트 mismatch 해결**
- GET /api/docs/preview?q=<slug-or-uuid> 신설
  - slug 또는 UUID 모두 허용 (UUID 정규식 판별)
  - RBAC: getAuthContext + project_id 스코프
  - { id, title, icon, slug, embedChain } 반환
- DocsService.getDocPreview(projectId, q) 추가
- page-embed-node.tsx fetchDoc: /api/docs/${id} → /api/docs/preview?q=

**BLOCKER 2: 간접 순환 임베드 감지 (A→B→A)**
- isCircularEmbed 시그니처 확장: embedChain 파라미터 추가
  - 직접: docId === currentDocId
  - 간접: embedChain.includes(currentDocId)
- preview 엔드포인트에서 BFS로 임베드 체인 수집 (maxDepth=5)
  - extractEmbedIds(): HTML에서 data-doc-id 파싱
  - collectTransitiveEmbeds(): Supabase BFS traversal
- fetchDoc에서 간접 cycle 감지 시 error 상태 설정

**🟡 markdown round-trip 보존**
- content-converter.ts: pageEmbed turndown rule 추가
  - <div data-page-embed> → raw HTML 보존 (attr 유지)

**테스트: 28/28 pass, type-check FULL TURBO**
- isCircularEmbed 7→15케이스 (직접 7 + 간접 8)
- preview route: 7케이스 (401/429/400/404/slug/uuid/embedChain)
- extractEmbedIds: 6케이스

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@AngryJay91 AngryJay91 merged commit 4b99d2c into main Apr 15, 2026
3 of 4 checks passed
@AngryJay91 AngryJay91 deleted the feat/SID-E036-DOCS3-page-embed branch April 15, 2026 12:44
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