From 9df91bf4123a661cfa4a721f13b50b34d35f0f02 Mon Sep 17 00:00:00 2001 From: Hyko Date: Sat, 25 Apr 2026 17:53:16 -0400 Subject: [PATCH] fix(BlockEditor): constrain select-all to current block and resize slash menu - intercept Ctrl/Cmd+A to select only the current block's content, preventing cross-block merge bug - increase slash menu width from 280 to 375 and max-height from 320 to 360 - enlarge icon container, increase gap and padding, and upsize text in slash menu items --- src/shared/components/BlockEditor/Block.client.js | 15 +++++++++++++++ .../components/BlockEditor/SlashMenu.client.js | 12 ++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/shared/components/BlockEditor/Block.client.js b/src/shared/components/BlockEditor/Block.client.js index 629e0dd..bde06e7 100644 --- a/src/shared/components/BlockEditor/Block.client.js +++ b/src/shared/components/BlockEditor/Block.client.js @@ -120,6 +120,21 @@ const Block = forwardRef(function Block( return; } + // Ctrl/Cmd+A : limite la sélection au bloc courant. La sélection native + // s'étend sur plusieurs contentEditable et leur suppression fusionne le + // texte en un seul bloc — bug. On force la sélection à rester ici. + if ((e.ctrlKey || e.metaKey) && (e.key === 'a' || e.key === 'A')) { + if (el) { + e.preventDefault(); + const range = document.createRange(); + range.selectNodeContents(el); + const sel = window.getSelection(); + sel?.removeAllRanges(); + sel?.addRange(range); + } + return; + } + if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); const el = editableRef.current; diff --git a/src/shared/components/BlockEditor/SlashMenu.client.js b/src/shared/components/BlockEditor/SlashMenu.client.js index 23dc537..1b46348 100644 --- a/src/shared/components/BlockEditor/SlashMenu.client.js +++ b/src/shared/components/BlockEditor/SlashMenu.client.js @@ -2,8 +2,8 @@ import React, { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'; -const MENU_WIDTH = 280; -const MENU_MAX_HEIGHT = 320; +const MENU_WIDTH = 375; +const MENU_MAX_HEIGHT = 360; const VIEWPORT_MARGIN = 8; const SHORTCUT_HINT = { @@ -135,16 +135,16 @@ export default function SlashMenu({ data-slash-index={i} onMouseEnter={() => onHoverIndex?.(i)} onClick={() => onSelect?.(def.type)} - className={`w-full flex items-center gap-2.5 px-2 py-1 text-left transition-colors ${active ? 'bg-neutral-100 dark:bg-neutral-800' : ''}`} + className={`w-full flex items-center gap-3 px-2 py-1.5 text-left transition-colors ${active ? 'bg-neutral-100 dark:bg-neutral-800' : ''}`} > - + {def.icon} - + {def.label} {hint && ( - + {hint} )}