chore: remove nutjs (#2860)
Signed-off-by: James <james@jan.ai> Co-authored-by: James <james@jan.ai>
This commit is contained in:
parent
0bad1a479f
commit
ce2d8e5405
@ -95,8 +95,7 @@
|
||||
"pacote": "^17.0.4",
|
||||
"request": "^2.88.2",
|
||||
"request-progress": "^3.0.0",
|
||||
"ulidx": "^2.3.0",
|
||||
"@nut-tree/nut-js": "^4.0.0"
|
||||
"ulidx": "^2.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@electron/notarize": "^2.1.0",
|
||||
|
||||
@ -1,23 +1,24 @@
|
||||
import { clipboard, globalShortcut } from 'electron'
|
||||
import { keyboard, Key } from '@nut-tree/nut-js'
|
||||
|
||||
/**
|
||||
* Gets selected text by synthesizing the keyboard shortcut
|
||||
* "CommandOrControl+c" then reading text from the clipboard
|
||||
*/
|
||||
export const getSelectedText = async () => {
|
||||
const currentClipboardContent = clipboard.readText() // preserve clipboard content
|
||||
clipboard.clear()
|
||||
const hotkeys: Key[] = [
|
||||
process.platform === 'darwin' ? Key.LeftCmd : Key.LeftControl,
|
||||
Key.C,
|
||||
]
|
||||
await keyboard.pressKey(...hotkeys)
|
||||
await keyboard.releaseKey(...hotkeys)
|
||||
await new Promise((resolve) => setTimeout(resolve, 200)) // add a delay before checking clipboard
|
||||
const selectedText = clipboard.readText()
|
||||
clipboard.writeText(currentClipboardContent)
|
||||
return selectedText
|
||||
// TODO: Implement this function
|
||||
// const currentClipboardContent = clipboard.readText() // preserve clipboard content
|
||||
// clipboard.clear()
|
||||
// const hotkeys: Key[] = [
|
||||
// process.platform === 'darwin' ? Key.LeftCmd : Key.LeftControl,
|
||||
// Key.C,
|
||||
// ]
|
||||
// await keyboard.pressKey(...hotkeys)
|
||||
// await keyboard.releaseKey(...hotkeys)
|
||||
// await new Promise((resolve) => setTimeout(resolve, 200)) // add a delay before checking clipboard
|
||||
// const selectedText = clipboard.readText()
|
||||
// clipboard.writeText(currentClipboardContent)
|
||||
// return selectedText
|
||||
return ''
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user