Merge pull request #306 from ueokande/custom-hint-keys
support custom chars as hintchars
This commit is contained in:
commit
4d4a959162
2 changed files with 15 additions and 12 deletions
|
@ -1,8 +1,7 @@
|
||||||
import * as followControllerActions from 'content/actions/follow-controller';
|
import * as followControllerActions from 'content/actions/follow-controller';
|
||||||
import messages from 'shared/messages';
|
import messages from 'shared/messages';
|
||||||
import HintKeyProducer from 'content/hint-key-producer';
|
import HintKeyProducer from 'content/hint-key-producer';
|
||||||
|
import * as properties from 'shared/settings/properties';
|
||||||
const DEFAULT_HINT_CHARSET = 'abcdefghijklmnopqrstuvwxyz';
|
|
||||||
|
|
||||||
const broadcastMessage = (win, message) => {
|
const broadcastMessage = (win, message) => {
|
||||||
let json = JSON.stringify(message);
|
let json = JSON.stringify(message);
|
||||||
|
@ -84,7 +83,7 @@ export default class FollowController {
|
||||||
this.store.dispatch(followControllerActions.backspace());
|
this.store.dispatch(followControllerActions.backspace());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (DEFAULT_HINT_CHARSET.includes(key)) {
|
if (this.hintchars().includes(key)) {
|
||||||
this.store.dispatch(followControllerActions.keyPress(key));
|
this.store.dispatch(followControllerActions.keyPress(key));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -93,7 +92,7 @@ export default class FollowController {
|
||||||
}
|
}
|
||||||
|
|
||||||
count() {
|
count() {
|
||||||
this.producer = new HintKeyProducer(DEFAULT_HINT_CHARSET);
|
this.producer = new HintKeyProducer(this.hintchars());
|
||||||
let doc = this.win.document;
|
let doc = this.win.document;
|
||||||
let viewWidth = this.win.innerWidth || doc.documentElement.clientWidth;
|
let viewWidth = this.win.innerWidth || doc.documentElement.clientWidth;
|
||||||
let viewHeight = this.win.innerHeight || doc.documentElement.clientHeight;
|
let viewHeight = this.win.innerHeight || doc.documentElement.clientHeight;
|
||||||
|
@ -135,4 +134,9 @@ export default class FollowController {
|
||||||
type: messages.FOLLOW_REMOVE_HINTS,
|
type: messages.FOLLOW_REMOVE_HINTS,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hintchars() {
|
||||||
|
return this.store.getState().setting.properties.hintchars ||
|
||||||
|
properties.defaults.hintchars;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
|
// describe types of a propety as:
|
||||||
|
// mystr: 'string',
|
||||||
|
// mynum: 'number',
|
||||||
|
// mybool: 'boolean',
|
||||||
const types = {
|
const types = {
|
||||||
// TODO describe property types here
|
hintchars: 'string',
|
||||||
// mystr: 'string',
|
|
||||||
// mynum: 'number',
|
|
||||||
// mybool: 'boolean',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// describe default values of a property
|
||||||
const defaults = {
|
const defaults = {
|
||||||
// TODO describe property defaults values
|
hintchars: 'abcdefghijklmnopqrstuvwxyz',
|
||||||
// mystr: 'hello',
|
|
||||||
// mynum: 123,
|
|
||||||
// mybool: true,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export { types, defaults };
|
export { types, defaults };
|
||||||
|
|
Reference in a new issue