chore: small update/fixes for quick ask window (#2279)
Signed-off-by: James <james@jan.ai> Co-authored-by: James <james@jan.ai>
This commit is contained in:
parent
e22fdec230
commit
3320162ea9
@ -1,4 +1,4 @@
|
||||
import { app, BrowserWindow, globalShortcut, Menu, Tray } from 'electron'
|
||||
import { app, BrowserWindow, Menu, Tray } from 'electron'
|
||||
|
||||
import { join } from 'path'
|
||||
/**
|
||||
@ -106,9 +106,6 @@ function createMainWindow() {
|
||||
}
|
||||
|
||||
function registerGlobalShortcuts() {
|
||||
// TODO: Toggle below line when build production
|
||||
// const ret = globalShortcut.register(quickAskHotKey, () => {
|
||||
// const selectedText = ''
|
||||
const ret = registerShortcut(quickAskHotKey, (selectedText: string) => {
|
||||
if (!windowManager.isQuickAskWindowVisible()) {
|
||||
windowManager.showQuickAskWindow()
|
||||
|
||||
@ -6,7 +6,16 @@ export const quickAskWindowConfig: Electron.BrowserWindowConstructorOptions = {
|
||||
width: DEFAULT_WIDTH,
|
||||
height: DEFAULT_HEIGHT,
|
||||
skipTaskbar: true,
|
||||
acceptFirstMouse: true,
|
||||
hasShadow: true,
|
||||
alwaysOnTop: true,
|
||||
show: false,
|
||||
fullscreenable: false,
|
||||
resizable: false,
|
||||
center: true,
|
||||
movable: false,
|
||||
maximizable: false,
|
||||
focusable: true,
|
||||
transparent: true,
|
||||
frame: false,
|
||||
type: 'panel',
|
||||
|
||||
@ -64,7 +64,6 @@ class WindowManager {
|
||||
this._quickAskWindow.on('blur', () => {
|
||||
this.hideQuickAskWindow()
|
||||
})
|
||||
this.hideQuickAskWindow()
|
||||
}
|
||||
|
||||
isMainWindowVisible(): boolean {
|
||||
|
||||
@ -18,10 +18,10 @@ const UserInput: React.FC = () => {
|
||||
const selectedText = useAtomValue(selectedTextAtom)
|
||||
|
||||
useEffect(() => {
|
||||
if (inputRef.current) {
|
||||
inputRef.current.focus()
|
||||
}
|
||||
inputRef.current?.focus()
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
const onKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape') {
|
||||
window.core?.api?.hideQuickAskWindow()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user