a tool for shared writing and social publishing

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

+18 -1
+18 -1
components/Blocks.tsx
··· 71 71 <div 72 72 className="shrink-0 h-[50vh]" 73 73 onClick={() => { 74 - focusBlock({ ...lastBlock, type: "text" }, { type: "end" }); 74 + let newEntityID = crypto.randomUUID(); 75 + 76 + if (lastBlock.type === "text") { 77 + focusBlock({ ...lastBlock, type: "text" }, { type: "end" }); 78 + } else { 79 + rep?.rep?.mutate.addBlock({ 80 + parent: props.entityID, 81 + type: "text", 82 + position: generateKeyBetween(lastBlock?.position || null, null), 83 + newEntityID, 84 + }); 85 + 86 + setTimeout(() => { 87 + document 88 + .getElementById(elementId.block(newEntityID).text) 89 + ?.focus(); 90 + }, 10); 91 + } 75 92 }} 76 93 /> 77 94 </div>