Skip to content

feat(table): add explicit paragraph insertion before and after tables - #1002

Open
huyanxius wants to merge 5 commits into
mdx-editor:mainfrom
huyanxius:fix/table-prose-entry-741
Open

huyanxius wants to merge 5 commits into
mdx-editor:mainfrom
huyanxius:fix/table-prose-entry-741

Conversation

@huyanxius

Copy link
Copy Markdown
Contributor

Fixes #741.

Summary

Add a table-level menu in the existing upper-left tool cell with Insert paragraph before table and Insert paragraph after table actions. The actions work at document boundaries, between adjacent tables, and beside other blocks.

  • Reuse an immediately adjacent empty paragraph; create one only after explicit activation. Import, hover, focus, and menu cancellation do not add whitespace.
  • Flush pending active-cell typing through the normal cell-exit path before the insertion's Undo boundary. One Undo removes the new paragraph without losing the cell edit.
  • Close the popover before focusing the paragraph. Support keyboard activation, visible focus, Escape, and read-only mode; resolve the current table by node key.
  • Keep existing cell Tab/Shift-Tab/Enter/Shift-Enter behavior unchanged. Isolate native menu-button Enter/Space activation from the parent editor's editing commands.

Validation

Based on current main 4d9499a86cb797cb92d2a6a4718619983e5955e3.

Final fork CI, head 8e39c85d9686ee5a9d991321ea6bf0e5f4b5f320:

  • 159 browser tests passed across Chromium, Firefox, and WebKit, including 30 new executions covering insertion, native Undo/Redo, real Markdown re-import, keyboard use, read-only behavior, and unchanged cell navigation.
  • 210 unit tests passed; existing skip/todo unchanged.
  • Lint, typecheck, JS/docs builds, Lexical package graph, packed React consumers, and cross-version Markdown checks passed.
  • Independent review added lifecycle, nested-container history, stale-node, editability-race, and keyboard-command regressions.

Unchanged-main reproduction confirms the adjacent-table entry gap in Chromium/WebKit; Firefox and terminal-table controls behave differently. This PR provides explicit actions rather than changing that navigation or automatically adding paragraphs.

The Firefox synthetic image-paste fixture correction is the same one already validated in #996; it restores the constructor-dropped clipboard payload without changing image assertions. No dependencies or workflows change. This PR does not include the pending region-paste or reorder implementations. Separate unit-only compatibility checks passed for their combined history/focus paths; combined browser validation was not performed.

@petyosi

petyosi commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Thanks for this. I don't want to add a per-table menu to core. It puts a new tabbable trigger on every table, and #741 is really about moving the cursor out of and around a table. This PR works around that rather than fixing it. A toolbar button can already insert a paragraph next to a table with rootEditor$, $isTableNode, insertBefore and insertAfter.

The real gap this exposes: when focus moves from a cell to editor UI, the cell's save is skipped, so pending typing isn't committed. That affects every toolbar action, and this PR covers it only for the table that owns the menu. For example, edit a cell in table A, then use table B's menu. Table A's edit is missing from getMarkdown(). The trigger has data-toolbar-item, so A's blur save is skipped, and B's activeCellSave is null.

I'd welcome a small PR that commits the active cell editor before any toolbar action, at the root level. Proper keyboard navigation around tables for #741 would be welcome too.

This branch has not been deployed

No deployments
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.

[BUG] Can't insert text between two tables

2 participants