Skip to content

Commit

Permalink
chore: remove nutjs (#2860)
Browse files Browse the repository at this point in the history
Signed-off-by: James <james@jan.ai>
Co-authored-by: James <james@jan.ai>
  • Loading branch information
namchuai and James authored May 2, 2024
1 parent 0bad1a4 commit ce2d8e5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
3 changes: 1 addition & 2 deletions electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
27 changes: 14 additions & 13 deletions electron/utils/selectedText.ts
Original file line number Diff line number Diff line change
@@ -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 ''
}

/**
Expand Down

0 comments on commit ce2d8e5

Please sign in to comment.