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", "pacote": "^17.0.4",
"request": "^2.88.2", "request": "^2.88.2",
"request-progress": "^3.0.0", "request-progress": "^3.0.0",
"ulidx": "^2.3.0", "ulidx": "^2.3.0"
"@nut-tree/nut-js": "^4.0.0"
}, },
"devDependencies": { "devDependencies": {
"@electron/notarize": "^2.1.0", "@electron/notarize": "^2.1.0",

View File

@ -1,23 +1,24 @@
import { clipboard, globalShortcut } from 'electron' import { clipboard, globalShortcut } from 'electron'
import { keyboard, Key } from '@nut-tree/nut-js'
/** /**
* Gets selected text by synthesizing the keyboard shortcut * Gets selected text by synthesizing the keyboard shortcut
* "CommandOrControl+c" then reading text from the clipboard * "CommandOrControl+c" then reading text from the clipboard
*/ */
export const getSelectedText = async () => { export const getSelectedText = async () => {
const currentClipboardContent = clipboard.readText() // preserve clipboard content // TODO: Implement this function
clipboard.clear() // const currentClipboardContent = clipboard.readText() // preserve clipboard content
const hotkeys: Key[] = [ // clipboard.clear()
process.platform === 'darwin' ? Key.LeftCmd : Key.LeftControl, // const hotkeys: Key[] = [
Key.C, // process.platform === 'darwin' ? Key.LeftCmd : Key.LeftControl,
] // Key.C,
await keyboard.pressKey(...hotkeys) // ]
await keyboard.releaseKey(...hotkeys) // await keyboard.pressKey(...hotkeys)
await new Promise((resolve) => setTimeout(resolve, 200)) // add a delay before checking clipboard // await keyboard.releaseKey(...hotkeys)
const selectedText = clipboard.readText() // await new Promise((resolve) => setTimeout(resolve, 200)) // add a delay before checking clipboard
clipboard.writeText(currentClipboardContent) // const selectedText = clipboard.readText()
return selectedText // clipboard.writeText(currentClipboardContent)
// return selectedText
return ''
} }
/** /**