From eb61bd578be9941228fc192f374f43c057a62d47 Mon Sep 17 00:00:00 2001 From: Yasuaki Uechi Date: Mon, 11 Dec 2017 21:40:45 +0900 Subject: [PATCH] Fix keyboard shortcut related issue #17 --- Polyglot.safariextension/Info.plist | 4 ++-- Polyglot.safariextension/Settings.plist | 2 ++ Polyglot.safariextension/global.js | 10 +++++++++- Polyglot.safariextension/injected.js | 8 ++++---- docs/manifest.plist | 8 ++++---- package-lock.json | 3 +-- package.json | 12 ++++++++---- 7 files changed, 30 insertions(+), 17 deletions(-) diff --git a/Polyglot.safariextension/Info.plist b/Polyglot.safariextension/Info.plist index 6d1f4af..7d8880b 100644 --- a/Polyglot.safariextension/Info.plist +++ b/Polyglot.safariextension/Info.plist @@ -13,9 +13,9 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleShortVersionString - 2.1.0 + 2.2.0 CFBundleVersion - 2.1.0 + 2.2.0 Chrome Context Menu Items diff --git a/Polyglot.safariextension/Settings.plist b/Polyglot.safariextension/Settings.plist index eb14079..966b782 100644 --- a/Polyglot.safariextension/Settings.plist +++ b/Polyglot.safariextension/Settings.plist @@ -3,6 +3,8 @@ + DefaultValue + en Key targetLanguage Title diff --git a/Polyglot.safariextension/global.js b/Polyglot.safariextension/global.js index 92ad07c..5b0cab1 100644 --- a/Polyglot.safariextension/global.js +++ b/Polyglot.safariextension/global.js @@ -1,8 +1,16 @@ const { translate } = require('./api'); // Get settings +const settingsKeys = [ + 'keyValue', + 'useCtrlKey', + 'useMetaKey', + 'useShiftKey', + 'useAltKey', + 'targetLanguage', +]; let settings = {}; -Object.keys(safari.extension.settings).forEach(key => { +settingsKeys.forEach(key => { settings[key] = safari.extension.settings[key]; }); diff --git a/Polyglot.safariextension/injected.js b/Polyglot.safariextension/injected.js index c4a4b5d..a2f0ce5 100644 --- a/Polyglot.safariextension/injected.js +++ b/Polyglot.safariextension/injected.js @@ -39,10 +39,10 @@ function handleKeypress(e) { return; } - const applyMeta = settings.useMetaKey ? e.metaKey : true; - const applyShift = settings.useShiftKey ? e.shiftKey : true; - const applyCtrl = settings.useCtrlKey ? e.ctrlKey : true; - const applyAlt = settings.useAltKey ? e.altKey : true; + const applyMeta = settings.useMetaKey === 'true' ? e.metaKey : true; + const applyShift = settings.useShiftKey === 'true' ? e.shiftKey : true; + const applyCtrl = settings.useCtrlKey === 'true' ? e.ctrlKey : true; + const applyAlt = settings.useAltKey === 'true' ? e.altKey : true; const applyKey = settings.keyValue.charCodeAt(0) === e.keyCode; if (applyMeta && applyShift && applyCtrl && applyAlt && applyKey) { e.preventDefault(); diff --git a/docs/manifest.plist b/docs/manifest.plist index d820f2b..0ef0be8 100644 --- a/docs/manifest.plist +++ b/docs/manifest.plist @@ -6,15 +6,15 @@ CFBundleIdentifier - co.randompaper.safari.polyglot + io.uechi.safari.polyglot Developer Identifier 58XDWHK3JX CFBundleVersion - 2.1.0 + 2.2.0 CFBundleShortVersionString - 2.1.0 + 2.2.0 URL - https://github.com/uetchy/Polyglot/releases/download/v2.1.0/Polyglot.safariextz + https://github.com/uetchy/Polyglot/releases/download/v2.2.0/Polyglot.safariextz Update From Gallery diff --git a/package-lock.json b/package-lock.json index 855c548..6f314c5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,8 +1,7 @@ { "name": "Polyglot", - "version": "2.0.1", - "lockfileVersion": 1, "requires": true, + "lockfileVersion": 1, "dependencies": { "acorn": { "version": "5.2.1", diff --git a/package.json b/package.json index 9999067..b782944 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,7 @@ "scripts": { "start": "webpack -w", "build": "webpack", - "format": - "prettier --write --no-semi --single-quote '{!(node_modules)/**/!(*.entry).{js,jsx},*.js}'" + "format": "prettier --write --no-semi --single-quote '{!(node_modules)/**/!(*.entry).{js,jsx},*.js}'" }, "dependencies": { "whatwg-fetch": "^2.0.1" @@ -19,7 +18,12 @@ "webpack": "^3.10.0" }, "babel": { - "presets": ["es2015", "stage-3"], - "plugins": ["transform-runtime"] + "presets": [ + "es2015", + "stage-3" + ], + "plugins": [ + "transform-runtime" + ] } }