From bdbdf0a619ec8fd29c438b1996caf31dd1c7529c Mon Sep 17 00:00:00 2001 From: Takashi Fujita Date: Fri, 17 Apr 2026 09:23:47 +0900 Subject: [PATCH] focus next block after adding embed and button blocks Fixes #3 --- components/Blocks/ButtonBlock.tsx | 20 ++++++++++++++++++++ components/Blocks/EmbedBlock.tsx | 19 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/components/Blocks/ButtonBlock.tsx b/components/Blocks/ButtonBlock.tsx index c4207a2b..fa6ba4de 100644 --- a/components/Blocks/ButtonBlock.tsx +++ b/components/Blocks/ButtonBlock.tsx @@ -10,6 +10,7 @@ import { useSmoker } from "components/Toast"; import { Separator } from "components/Layout"; import { Input } from "components/Input"; import { isUrl } from "src/utils/isURL"; +import { focusBlock } from "src/utils/focusBlock"; import { ButtonPrimary } from "components/Buttons"; import { BlockButtonSmall } from "components/Icons/BlockButtonSmall"; import { CheckTiny } from "components/Icons/CheckTiny"; @@ -116,6 +117,25 @@ const ButtonBlockSettings = (props: BlockProps) => { value: url, }, }); + + let textEntity = v7(); + await rep.mutate.addBlock({ + permission_set: entity_set.set, + factID: v7(), + parent: props.parent, + type: "text", + position: generateKeyBetween(props.position, props.nextPosition), + newEntityID: textEntity, + }); + + focusBlock( + { + value: textEntity, + type: "text", + parent: props.parent, + }, + { type: "start" }, + ); }; return ( diff --git a/components/Blocks/EmbedBlock.tsx b/components/Blocks/EmbedBlock.tsx index d84e5aca..93eda1fa 100644 --- a/components/Blocks/EmbedBlock.tsx +++ b/components/Blocks/EmbedBlock.tsx @@ -321,6 +321,25 @@ const BlockLinkInput = (props: BlockProps) => { } finally { setLoading(false); } + + let textEntity = v7(); + await rep.mutate.addBlock({ + permission_set: entity_set.set, + factID: v7(), + parent: props.parent, + type: "text", + position: generateKeyBetween(props.position, props.nextPosition), + newEntityID: textEntity, + }); + + focusBlock( + { + value: textEntity, + type: "text", + parent: props.parent, + }, + { type: "start" }, + ); }; let smoker = useSmoker(); -- 2.51.2