chore: remove nutjs (#2860)

Signed-off-by: James <james@jan.ai>
Co-authored-by: James <james@jan.ai>
This commit is contained in:
NamH 2024-05-02 21:02:05 +07:00 committed by GitHub
parent 0bad1a479f
commit ce2d8e5405
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 15 deletions

View File

@ -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",

View File

@ -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 ''
}
/**