mirror of
https://github.com/khoj-ai/khoj.git
synced 2025-02-17 08:04:21 +00:00
Put cursor on chat input when focus on chat view in Obsidian
This should improve fluidity of keyboard interactions with Khoj on Obsidian. Open Khoj chat view via keybinding or command pallete and ask question using only the keyboard, with no mouse clicks required
This commit is contained in:
parent
093e276908
commit
fbb95ca342
2 changed files with 21 additions and 4 deletions
|
@ -88,7 +88,16 @@ export default class Khoj extends Plugin {
|
|||
await leaf?.setViewState({ type: viewType, active: true });
|
||||
}
|
||||
|
||||
// "Reveal" the leaf in case it is in a collapsed sidebar
|
||||
if (leaf) workspace.revealLeaf(leaf);
|
||||
if (leaf) {
|
||||
if (viewType === KhojView.CHAT) {
|
||||
// focus on the chat input when the chat view is opened
|
||||
let chatView = leaf.view as KhojChatView;
|
||||
let chatInput = <HTMLTextAreaElement>chatView.contentEl.getElementsByClassName("khoj-chat-input")[0];
|
||||
if (chatInput) chatInput.focus();
|
||||
}
|
||||
|
||||
// "Reveal" the leaf in case it is in a collapsed sidebar
|
||||
workspace.revealLeaf(leaf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,15 @@ export abstract class KhojPaneView extends ItemView {
|
|||
await leaf?.setViewState({ type: viewType, active: true });
|
||||
}
|
||||
|
||||
// "Reveal" the leaf in case it is in a collapsed sidebar
|
||||
if (leaf) workspace.revealLeaf(leaf);
|
||||
if (leaf) {
|
||||
if (viewType === KhojView.CHAT) {
|
||||
// focus on the chat input when the chat view is opened
|
||||
let chatInput = <HTMLTextAreaElement>this.contentEl.getElementsByClassName("khoj-chat-input")[0];
|
||||
if (chatInput) chatInput.focus();
|
||||
}
|
||||
|
||||
// "Reveal" the leaf in case it is in a collapsed sidebar
|
||||
workspace.revealLeaf(leaf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue