Skip to content
This repository has been archived by the owner on Jun 22, 2022. It is now read-only.

Add support to paste after close, when emoji is copied #82

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ document.addEventListener('keydown', function (evt) {
jumpto('next')
}
} else if (evt.keyCode === 13) {
evt.preventDefault()
copyFocusedEmoji(evt.target, evt.shiftKey)
} else if (Object.keys(directions).indexOf(evt.keyCode.toString()) >= 0) {
// on navigation, navigate
Expand Down Expand Up @@ -76,7 +77,7 @@ function copyFocusedEmoji (emoji, copyText) {
clipboard.writeText(data)
searchInput.value = ''
search('')
ipc.send('abort')
ipc.send('abort', 'copy')
}

document.addEventListener('keypress', function (evt) {
Expand Down
17 changes: 16 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ var globalShortcut = require('electron').globalShortcut
var mb = menubar({ dir: __dirname + '/app', width: 440, height: 270, icon: __dirname + '/app/Icon-Template.png', preloadWindow: true, windowPosition: 'topRight' })
var Menu = require('electron').Menu
var isDev = require('electron-is-dev')
var os = require('os')
var robot = require('robotjs')


mb.on('show', function () {
mb.window.webContents.send('show')
Expand All @@ -19,8 +22,20 @@ mb.app.on('activate', function () {
})

// when receive the abort message, close the app
ipc.on('abort', function () {
ipc.on('abort', function (event, copy) {
mb.hideWindow()

if (!copy) {
return
}

setTimeout(function () {
if (os.platform() === 'darwin') {
robot.keyTap('v', 'command')
} else {
robot.keyTap('v', 'control')
}
}, 50)
})

// update shortcuts when preferences change
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"dependencies": {
"electron-is-dev": "^0.1.2",
"emojilib": "2.0.3",
"menubar": "^5.1.0"
"menubar": "^5.1.0",
"robotjs": "^0.4.5"
},
"devDependencies": {
"electron": "^1.4.0",
Expand Down