From 7e59c69e91dab213214454aa793ead1d94ae9438 Mon Sep 17 00:00:00 2001 From: "will.chen" Date: Tue, 3 Apr 2018 11:06:45 +0800 Subject: [PATCH 1/2] add customizeUI to prevent candidate cursor missing --- src/config.js | 3 +++ src/index.js | 4 ++++ src/reducer/candidateMode.js | 5 +++-- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 src/config.js diff --git a/src/config.js b/src/config.js new file mode 100644 index 0000000..00e7512 --- /dev/null +++ b/src/config.js @@ -0,0 +1,3 @@ +module.exports = { + candPerRow: 3 +} \ No newline at end of file diff --git a/src/index.js b/src/index.js index 33d8fa5..f74bb69 100644 --- a/src/index.js +++ b/src/index.js @@ -3,6 +3,7 @@ let emojione = require('emojione'); let debug = require('debug')('nime:emojime'); +let config = require('./config'); let { reduceOnKeyDown, @@ -40,11 +41,14 @@ module.exports = { }, response(request, state) { + let res = {success: true, seqNum: request['seqNum']}; if (request['method'] === 'filterKeyDown') { return respOnFilterKeyDown(request, state); } else if (request['method'] === 'onKeyDown') { return respOnKeyDown(request, state); + } else if (request['method'] === 'onActivate') { + return Object.assign({}, res, { customizeUI: { candPerRow: config.candPerRow, candUseCursor: true }}) } return {success: true, seqNum: request['seqNum']}; } diff --git a/src/reducer/candidateMode.js b/src/reducer/candidateMode.js index b599b5e..10a4c9f 100644 --- a/src/reducer/candidateMode.js +++ b/src/reducer/candidateMode.js @@ -2,6 +2,7 @@ let debug = require('debug')('nime:emojime:composition'); let KEYCODE = require('nime/lib/keyCodes'); +let config = require('../config'); function candidateMode(request, preState) { @@ -23,7 +24,7 @@ function candidateMode(request, preState) { } if (keyCode === KEYCODE.VK_DOWN) { - candidateCursor = (candidateCursor + 3) % candidateList.length; + candidateCursor = (candidateCursor + config.candPerRow) % candidateList.length; return Object.assign({}, preState, { action: 'UPDATE_CANDIDATE', candidateCursor @@ -31,7 +32,7 @@ function candidateMode(request, preState) { } if (keyCode === KEYCODE.VK_UP) { - candidateCursor = candidateCursor < 3 ? 0 : candidateCursor - 3; + candidateCursor = candidateCursor < config.candPerRow ? 0 : candidateCursor - config.candPerRow; return Object.assign({}, preState, { action: 'UPDATE_CANDIDATE', candidateCursor From 52207da15989418f0b982fcf7e1975642e75af3e Mon Sep 17 00:00:00 2001 From: "will.chen" Date: Tue, 3 Apr 2018 11:09:10 +0800 Subject: [PATCH 2/2] support fallbackLocale --- ime.json | 1 + 1 file changed, 1 insertion(+) diff --git a/ime.json b/ime.json index f35c167..b993671 100644 --- a/ime.json +++ b/ime.json @@ -3,6 +3,7 @@ "version": "0.3.0", "guid": "{A381D463-9338-4FBD-B83D-66FFB03523B3}", "locale": "zh-TW", + "fallbackLocale": "zh-TW", "icon": "icon.ico", "win8_icon": "", "moduleName": "index",