feat(tiptap): add native table support with round-trip MDC conversion#444
feat(tiptap): add native table support with round-trip MDC conversion#444nvdai2401 wants to merge 3 commits into
Conversation
|
@nvdai2401 is attempting to deploy a commit to the Nuxt Team on Vercel. A member of the Team first needs to authorize it. |
ad3b249 to
7486e13
Compare
|
Hey @larbish @TotomInc, I created this PR to add native table support to the Studio editor. It’s been a long-standing gap and I tried to keep the change as minimal and idiomatic as possible. What’s in: /table slash command inserts a 2x2 GFM table; cells are editable with Tab navigation; existing markdown tables render as editable tables; full round-trip through MDC ↔ markdown (4 integration tests). A floating bubble menu inside tables exposes add/delete row/column and toggle-header actions. Drag-handle “Turn into” is force-disabled for tables (otherwise ProseMirror would silently swap the table for a paragraph). What I’d appreciate eyes on:
Out of scope for v1: column resizing, cell merging/splitting. Happy to tackle those in a follow-up. Branch is up to date with main, all 247 tests pass. |
|
Hello @nvdai2401, thanks a lot for this PR! That's a great feature. I'm currently finishing this PR about migrating the nuxt studio parser to comark.dev. This has a big impact on the transformation between TipTap AST and Comark AST (and no more legacy MDC AST). I should merge it really soon and I'll provide a skill I've maintained during the all migration so you can easily adapt your PR once this branch is merged. I'll keep you posted! |
|
Round-trip mdc conversion is a big upgrade to studio, can actually enable bigger patterns (e.g.: kanban boards and other components) |
|
Hey @nvdai2401, I did merge the comark PR. You can now update your PR to match the new comark logic. I also just pushed a skill that can help: #456 Don't hesitate if you need help 🙏 |
Port the table feature from the pre-comark branch to work with the new comark-based AST system introduced in nuxt-content#355. - Add comark↔TipTap table conversion (table/thead/tbody/tr/th/td) - Register TipTap table extensions (Table, TableRow, TableCell, TableHeader) - Add floating BubbleMenu for row/column operations - Add table to slash menu and disable Turn Into for table nodes - Filter project-registered <UTable> from slash menu to avoid duplicates - Add editor styles for table rendering and cell selection - Add table integration tests with comark round-trip assertions Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
b94b4cc to
33dec5d
Compare
Replace the flat icon-only BubbleMenu toolbar with column/row grip handles that appear on the table borders when a cell is focused. Each grip opens a labeled dropdown menu with Insert/Delete actions and highlights the full column or row via ProseMirror CellSelection. - Add useTableGrips composable for table geometry and cell selection - Add TiptapTableGrips component with column grips (top border) and row grips (left border), each with UDropdownMenu - Pin @tiptap/extension-table to 3.22.4 to match @tiptap/core version - Remove old TiptapTableMenu BubbleMenu component Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Hey @larbish, I've updated the PR and also updated the toolbar menu. Ready for review |
commit: |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Hey @larbish, any comments on this PR? Could I know when we would merge it? |
Summary
Adds native TipTap table editing to the Studio editor, ported to the new comark-based AST system from #355.
Users can:
/tableto insert a 2×2 table with a header rowApproach
Uses upstream
@tiptap/extension-table(pinned to 3.22.4 to match@tiptap/core) with native ProseMirror rendering — no custom NodeView.Comark conversion
comarkToTiptap: mapstable/thead/tbody/tr/th/tdcomark elements to TipTaptable/tableRow/tableHeader/tableCellnodes, flattening thead/tbody wrapperstiptapToComark: reverses the conversion, splitting rows intothead/tbodybased on cell type and unwrapping single-paragraph cellsNotion-style grip handles
TiptapTableGrips.vuerenders grip buttons centered on column top borders and row left borders when the cursor is in a tableUDropdownMenuwith labeled actions (Insert left/right, Insert above/below, Delete column/row, Delete table)CellSelection, giving visual feedbackuseTableGrips.tscomposable encapsulates table geometry calculation and cell selection logicWhat's in scope (v1)
/tableslash command<UTable>componentsNot in scope (deferred)
resizable: falsefor v1)Test plan
/tableinsertion in dev playgroundNotable implementation details
@tiptap/extension-tableexcluded,@tiptap/pm/tablesincluded — prevents prosemirror-tables from loading twice@tiptap/extension-table@3.22.4must match@tiptap/core@3.22.4(peer dependency)getBoundingClientRectcalculations, recalculated on every editor transaction viarequestAnimationFramedebouncingMarkdownRoot → ComarkTreeconversion in dev mode via the existing legacy bridge inhost.ts🤖 Generated with Claude Code