From e0ccb967b2d724dcb08e02e91dd7c66b7799fe73 Mon Sep 17 00:00:00 2001 From: celine Date: Tue, 2 Jul 2024 23:12:40 -0400 Subject: [PATCH] if last block in card is NOT a text block and blank space at bottom of card is clicked, make a new text block at the bottom of the card and focus it --- components/Blocks.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/components/Blocks.tsx b/components/Blocks.tsx index 6417f4f4..42bcd659 100644 --- a/components/Blocks.tsx +++ b/components/Blocks.tsx @@ -71,7 +71,24 @@ export function Blocks(props: { entityID: string }) {
{ - focusBlock({ ...lastBlock, type: "text" }, { type: "end" }); + let newEntityID = crypto.randomUUID(); + + if (lastBlock.type === "text") { + focusBlock({ ...lastBlock, type: "text" }, { type: "end" }); + } else { + rep?.rep?.mutate.addBlock({ + parent: props.entityID, + type: "text", + position: generateKeyBetween(lastBlock?.position || null, null), + newEntityID, + }); + + setTimeout(() => { + document + .getElementById(elementId.block(newEntityID).text) + ?.focus(); + }, 10); + } }} />
-- 2.51.2