From 4e8a2f102a4b2f5f1902bfb82a27bc6ddcd1eb1d Mon Sep 17 00:00:00 2001 From: celine Date: Mon, 19 Jan 2026 17:14:06 -0500 Subject: [PATCH] make things blocks easier to manuever in canvas --- components/Blocks/Block.tsx | 13 ++++++-- components/Blocks/ButtonBlock.tsx | 1 - components/Blocks/EmbedBlock.tsx | 4 ++- components/Canvas.tsx | 54 ++++++++++++++++++++----------- 4 files changed, 49 insertions(+), 23 deletions(-) diff --git a/components/Blocks/Block.tsx b/components/Blocks/Block.tsx index 292d6e79..2b300e8c 100644 --- a/components/Blocks/Block.tsx +++ b/components/Blocks/Block.tsx @@ -68,7 +68,6 @@ export const Block = memo(function Block( // Block handles all block level events like // mouse events, keyboard events and longPress, and setting AreYouSure state // and shared styling like padding and flex for list layouting - let { rep } = useReplicache(); let mouseHandlers = useBlockMouseHandlers(props); let handleDrop = useHandleDrop({ parent: props.parent, @@ -77,6 +76,16 @@ export const Block = memo(function Block( }); let entity_set = useEntitySetContext(); + let { isLongPress, longPressHandlers } = useLongPress(() => { + if (isTextBlock[props.type]) return; + if (isLongPress.current) { + focusBlock( + { type: props.type, value: props.entityID, parent: props.parent }, + { type: "start" }, + ); + } + }); + let selected = useUIState( (s) => !!s.selectedBlocks.find((b) => b.value === props.entityID), ); @@ -107,7 +116,7 @@ export const Block = memo(function Block( return (
{ {
s.focusedEntity?.entityID === props.entityID, @@ -397,9 +399,10 @@ function CanvasBlock(props: { return (
{/* the gripper show on hover, but longpress logic needs to be added for mobile*/} - {!props.preview && permissions.write && } + {!props.preview && permissions.write && ( + + )} + + {/*mouseHandlers are being added here so they don't interfere with the dragHandlers in the div above*/}