From ceb9b26dfb6dbe3fa554236466a9bf97d59dfdaa Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 5 Jul 2026 09:01:40 +0000 Subject: [PATCH] fix: hide image resize handles inside table cells Images in table cells are scaled to the column width by CSS, so their rendered size no longer follows the drag-resize handles. Hide the handles in that context so we don't present a control that has no visible effect. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Bpy5eV6C2wwf2MNut68BEh --- shared/editor/components/Image.tsx | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/shared/editor/components/Image.tsx b/shared/editor/components/Image.tsx index 3e26763ecf..96500ce27d 100644 --- a/shared/editor/components/Image.tsx +++ b/shared/editor/components/Image.tsx @@ -7,6 +7,7 @@ import { find } from "es-toolkit/compat"; import Flex from "../../components/Flex"; import { s } from "../../styles"; import { isExternalUrl, sanitizeImageSrc } from "../../utils/urls"; +import { findParentNodeClosestToPos } from "../queries/findParentNode"; import { EditorStyleHelper } from "../styles/EditorStyleHelper"; import type { ComponentProps } from "../types"; import { @@ -63,10 +64,32 @@ const Image = (props: Props) => { ref, }); + // Images inside a table cell are scaled to the column width by CSS, so their + // rendered width no longer follows the resize handles — hide the handles to + // avoid offering a control that has no visible effect. + const isInTableCell = React.useMemo(() => { + try { + const pos = props.getPos(); + if (typeof pos !== "number") { + return false; + } + const $pos = props.view.state.doc.resolve(pos); + return !!findParentNodeClosestToPos( + $pos, + (parent) => + parent.type.spec.tableRole === "cell" || + parent.type.spec.tableRole === "header_cell" + ); + } catch { + return false; + } + }, [props.view.state, props.getPos]); + const isFullWidth = layoutClass === "full-width"; const isInlineIcon = !isFullWidth && !!width && width < InlineIconMaxWidth && !error; - const isResizable = !!props.onChangeSize && !error && !isInlineIcon; + const isResizable = + !!props.onChangeSize && !error && !isInlineIcon && !isInTableCell; const isDownloadable = !!props.onDownload && !error; const className = [