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);