From f5b39aba8f782bfe85f3e70bb86e6fbc6a6dec23 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 1 Aug 2026 12:15:40 -0400 Subject: [PATCH] fix: `CMD-Enter` in table within toggle block does not add row (#13226) * fix: CMD-Enter in table within toggle block does not add newline * simplify --- shared/editor/commands/toggleBlock.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/shared/editor/commands/toggleBlock.ts b/shared/editor/commands/toggleBlock.ts index 50f0524bb7..324904c787 100644 --- a/shared/editor/commands/toggleBlock.ts +++ b/shared/editor/commands/toggleBlock.ts @@ -4,6 +4,7 @@ import { splitBlock, } from "prosemirror-commands"; import { Slice, Fragment } from "prosemirror-model"; +import { isInTable } from "prosemirror-tables"; import type { Command } from "prosemirror-state"; import { NodeSelection, TextSelection } from "prosemirror-state"; import { liftTarget, ReplaceAroundStep } from "prosemirror-transform"; @@ -202,6 +203,11 @@ export const indentBlock: Command = (state, dispatch) => { return false; } + // If inside a table, allow the table's Tab handler to move cells instead. + if (isInTable(state)) { + return false; + } + const { $from } = state.selection; let before = -1; @@ -242,6 +248,11 @@ export const toggleBlock: Command = (state, dispatch) => { return false; } + // If inside a table, allow the table's handler to add a row instead. + if (isInTable(state)) { + return false; + } + const isToggle = isToggleBlock(state); const toggle = nearest(ancestors($cursor!).filter(isToggle)); if (!toggle) { @@ -353,6 +364,11 @@ export const dedentBlocks: Command = (state, dispatch) => { return false; } + // If inside a table, allow the table's Shift-Tab handler to move cells instead. + if (isInTable(state)) { + return false; + } + const { $from } = state.selection; const isToggle = isToggleBlock(state);