Dev #2
@@ -944,7 +944,7 @@ export const WorkspaceView: React.FC<WorkspaceViewProps> = ({
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (e.key === 'Enter') {
|
||||
if (e.key === 'Enter' || e.key === 'Tab') {
|
||||
e.preventDefault();
|
||||
const selected = filteredSlashCommands[slashSelectedIndex];
|
||||
if (selected) {
|
||||
@@ -1017,6 +1017,27 @@ export const WorkspaceView: React.FC<WorkspaceViewProps> = ({
|
||||
updateBlock(blockId, { type, content: cleanContent, checked: type === 'todo' ? false : undefined });
|
||||
setSlashBlockId(null);
|
||||
setSlashSearch('');
|
||||
|
||||
// Re-focus immediately into the block's text field and position cursor at end
|
||||
const focusBlock = () => {
|
||||
const el = blockInputRefs.current[blockId];
|
||||
if (el) {
|
||||
el.focus();
|
||||
if ('setSelectionRange' in el && typeof (el as any).value === 'string') {
|
||||
const len = (el as any).value.length;
|
||||
(el as any).setSelectionRange(len, len);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
setLastFocusedBlockId(blockId);
|
||||
setTimeout(() => {
|
||||
if (!focusBlock()) {
|
||||
setTimeout(focusBlock, 30);
|
||||
}
|
||||
}, 20);
|
||||
};
|
||||
|
||||
const getDirectChildTodos = (blocks: DocumentBlock[], parentIndex: number): DocumentBlock[] => {
|
||||
@@ -2415,6 +2436,7 @@ export const WorkspaceView: React.FC<WorkspaceViewProps> = ({
|
||||
<button
|
||||
key={cmd.type}
|
||||
type="button"
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={() => applySlashCommand(block.id, cmd.type)}
|
||||
className={`w-full text-left px-2 py-1.5 rounded-btn text-xs flex items-center justify-between transition-colors ${
|
||||
slashSelectedIndex === idx
|
||||
|
||||
Reference in new issue
Block a user