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); + } }} />