From e8e6d3aa2e4c7919928ae942b6e7e72f958717b5 Mon Sep 17 00:00:00 2001 From: Tomer Shvueli Date: Tue, 6 Jul 2021 13:54:02 -0400 Subject: [PATCH] feat: Give user option to either type out emoji or copy --- package-lock.json | 64 +++++++++++++++++++++++------------------------ public/index.html | 3 ++- src/index.js | 37 ++++++++++++++++++++++----- 3 files changed, 65 insertions(+), 39 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3ec21da..3481ccd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,13 +34,13 @@ } }, "@types/node": { - "version": "14.17.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.3.tgz", - "integrity": "sha512-e6ZowgGJmTuXa3GyaPbTGxX17tnThl2aSSizrFthQ7m9uLGZBXiGhgE55cjRZTF5kjZvYn9EOPOMljdjwbflxw==" + "version": "14.17.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.4.tgz", + "integrity": "sha512-8kQ3+wKGRNN0ghtEn7EGps/B8CzuBz1nXZEIGGLP2GnwbqYn4dbTs7k+VKLTq1HvZLRCIDtN3Snx1Ege8B7L5A==" }, "ansi-regex": { "version": "2.1.1", - "resolved": "https://eis.jfrog.io/eis/api/npm/npm/ansi-regex/-/ansi-regex-2.1.1.tgz", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" }, "aproba": { @@ -85,9 +85,9 @@ } }, "boolean": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/boolean/-/boolean-3.1.0.tgz", - "integrity": "sha512-K6r5tvO1ykeYerI7jIyTvSFw2l6D6DzqkljGj2E2uyYAAdDo2SV4qGJIV75cHIQpTFyb6BB0BEHiDdDrFsNI+g==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/boolean/-/boolean-3.1.2.tgz", + "integrity": "sha512-YN6UmV0FfLlBVvRvNPx3pz5W/mUoYB24J4WSXOKP/OOJpi+Oq6WYqPaNTHzjI0QzwWtnvEd5CGYyQPgp1jFxnw==", "optional": true }, "buffer": { @@ -153,7 +153,7 @@ }, "code-point-at": { "version": "1.1.0", - "resolved": "https://eis.jfrog.io/eis/api/npm/npm/code-point-at/-/code-point-at-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" }, "concat-stream": { @@ -179,13 +179,13 @@ }, "console-control-strings": { "version": "1.1.0", - "resolved": "https://eis.jfrog.io/eis/api/npm/npm/console-control-strings/-/console-control-strings-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" }, "core-js": { - "version": "3.14.0", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.14.0.tgz", - "integrity": "sha512-3s+ed8er9ahK+zJpp9ZtuVcDoFzHNiZsPbNAAE4KXgrRHbjSqqNN6xGSXq6bq7TZIbKj4NLrLb6bJ5i+vSVjHA==", + "version": "3.15.2", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.15.2.tgz", + "integrity": "sha512-tKs41J7NJVuaya8DxIOCnl8QuPHx5/ZVbFo1oKgVl1qHFBBrDctzQGtuLjPpRdNTWmKPH6oEvgN/MUID+l485Q==", "optional": true }, "core-util-is": { @@ -194,9 +194,9 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, "debug": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", - "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", + "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", "requires": { "ms": "2.1.2" } @@ -235,12 +235,12 @@ }, "delegates": { "version": "1.0.0", - "resolved": "https://eis.jfrog.io/eis/api/npm/npm/delegates/-/delegates-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" }, "detect-libc": { "version": "1.0.3", - "resolved": "https://eis.jfrog.io/eis/api/npm/npm/detect-libc/-/detect-libc-1.0.3.tgz", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=" }, "detect-node": { @@ -255,9 +255,9 @@ "integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=" }, "electron": { - "version": "12.0.10", - "resolved": "https://registry.npmjs.org/electron/-/electron-12.0.10.tgz", - "integrity": "sha512-qaNvFG4AgeuT3PkSljQ9MlY7hz87wIwJ5cmSZ1453IVsUd0BV7pcaLViSpR1bRSqxetDDWxCLtCp0N9RXeDZww==", + "version": "12.0.13", + "resolved": "https://registry.npmjs.org/electron/-/electron-12.0.13.tgz", + "integrity": "sha512-2yx102mhqgyaTVH+GCet4hURKOIuI27DcVdlval5T3eOEZMOHNrCbi8/8PZ7MqMfB5PIxJ+grS5S00/n5Zcu2Q==", "requires": { "@electron/get": "^1.0.1", "@types/node": "^14.6.2", @@ -449,7 +449,7 @@ }, "has-unicode": { "version": "2.0.1", - "resolved": "https://eis.jfrog.io/eis/api/npm/npm/has-unicode/-/has-unicode-2.0.1.tgz", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" }, "http-cache-semantics": { @@ -479,7 +479,7 @@ }, "is-fullwidth-code-point": { "version": "1.0.0", - "resolved": "https://eis.jfrog.io/eis/api/npm/npm/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "requires": { "number-is-nan": "^1.0.0" @@ -640,12 +640,12 @@ }, "number-is-nan": { "version": "1.0.1", - "resolved": "https://eis.jfrog.io/eis/api/npm/npm/number-is-nan/-/number-is-nan-1.0.1.tgz", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" }, "object-assign": { "version": "4.1.1", - "resolved": "https://eis.jfrog.io/eis/api/npm/npm/object-assign/-/object-assign-4.1.1.tgz", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" }, "object-keys": { @@ -663,9 +663,9 @@ } }, "open": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/open/-/open-8.2.0.tgz", - "integrity": "sha512-O8uInONB4asyY3qUcEytpgwxQG3O0fJ/hlssoUHsBboOIRVZzT6Wq+Rwj5nffbeUhOdMjpXeISpDDzHCMRDuOQ==", + "version": "8.2.1", + "resolved": "https://registry.npmjs.org/open/-/open-8.2.1.tgz", + "integrity": "sha512-rXILpcQlkF/QuFez2BJDf3GsqpjGKbkUUToAIGo9A0Q6ZkoSGogZJulrUdwRkrAsoQvoZsrjCYt8+zblOk7JQQ==", "requires": { "define-lazy-prop": "^2.0.0", "is-docker": "^2.1.1", @@ -824,7 +824,7 @@ }, "set-blocking": { "version": "2.0.0", - "resolved": "https://eis.jfrog.io/eis/api/npm/npm/set-blocking/-/set-blocking-2.0.0.tgz", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" }, "signal-exit": { @@ -870,7 +870,7 @@ }, "string-width": { "version": "1.0.2", - "resolved": "https://eis.jfrog.io/eis/api/npm/npm/string-width/-/string-width-1.0.2.tgz", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "requires": { "code-point-at": "^1.0.0", @@ -888,7 +888,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "https://eis.jfrog.io/eis/api/npm/npm/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "requires": { "ansi-regex": "^2.0.0" @@ -896,7 +896,7 @@ }, "strip-json-comments": { "version": "2.0.1", - "resolved": "https://eis.jfrog.io/eis/api/npm/npm/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" }, "sumchecker": { @@ -955,7 +955,7 @@ }, "tunnel-agent": { "version": "0.6.0", - "resolved": "https://eis.jfrog.io/eis/api/npm/npm/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", "requires": { "safe-buffer": "^5.0.1" diff --git a/public/index.html b/public/index.html index 6526744..8160d46 100644 --- a/public/index.html +++ b/public/index.html @@ -28,7 +28,8 @@ Use 'Control + E' to summon Geniemoji

Navigation:
Use Arrow Keys to go up and down
- Press Enter to type the Emoji + Press Enter to type the Emoji, + Press Shift + Enter to copy the Emoji diff --git a/src/index.js b/src/index.js index bb34d8a..a39b64a 100644 --- a/src/index.js +++ b/src/index.js @@ -41,13 +41,13 @@ function search() { currentEmojiLength = i // All the matching emojis are appended into answerEmojis. the '.char' is from the emoji.js file answerEmojis += ` -
` // item.char is the emoji and item.name is the emoji name, both from the emojis.js file - }) + }) // If there are no matching emojis, it returns undefined. To not display 'undefined', we do the following if (typeof (answerEmojis) !== 'string') { @@ -74,8 +74,33 @@ document.getElementById('commandInput').addEventListener('keydown', (e) => { }) // This is executed when an emoji button is pressed -function typeEmoji(text) { - electron.ipcRenderer.send('typeEmoji', text); +function typeEmoji(event, text) { + if (event.shiftKey) { + // User held down Shift key while selecting this emoji, let's copy it + copy(text); + } else { + // User selected emoji with no Shift key, type out selected emoji + electron.ipcRenderer.send('typeEmoji', text) + } +} + +// Function to copy text to clipboard +function copy(text) { + // To copy, a text area is created, the emojiChar is added to the text area. This is then selected and copied. After it is copied, the text area is deleted + var textarea = document.createElement("textarea") + textarea.value = text + document.body.appendChild(textarea) + textarea.select() + document.execCommand("copy") + document.body.removeChild(textarea) + document.getElementById('answer').innerHTML = ` +
+ Copied emoji to clipboard!

+ Press Escape to close this window

+ Geniemoji (${appVersion})
+ Developed by Virej Dasani +
+ ` } // For arrow key navigation @@ -90,7 +115,7 @@ document.addEventListener("keydown", (event) => { // circle through emojis // ArrowUp and focus on input field? -> select last emoji if (tabIndex < 1) { - tabIndex = currentEmojiLength + 2 // '+2': tabIndex starts with 1, 1 = input + tabIndex = currentEmojiLength + 2 // '+2': tabIndex starts with 1, 1 = input } // ArrowDown and focus on last emoji? -> select input field if (tabIndex > currentEmojiLength + 2) { @@ -101,4 +126,4 @@ document.addEventListener("keydown", (event) => { // set focus on element to select newEl.focus() } -}) +}) \ No newline at end of file