blob: 12d079fc3aace06760f2a08d20e7d13829fd8c83 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
import '../console/console-frame.scss';
import * as inputActions from '../actions/input';
import * as consoleFrames from '../console/frames';
import actions from '../actions';
import contentReducer from '../reducers/content';
consoleFrames.initialize(window.document);
browser.runtime.onMessage.addListener((action) => {
contentReducer(undefined, action);
return Promise.resolve();
});
window.addEventListener("keypress", (e) => {
if (e.target instanceof HTMLInputElement) {
return;
}
browser.runtime.sendMessage(inputActions.keyPress(e.which, e.ctrlKey))
.catch((err) => {
console.error("Vim Vixen:", err);
return consoleFrames.showError(err.message);
});
});
browser.runtime.onMessage.addListener((action) => {
switch (action.type) {
case actions.CONSOLE_HIDE:
window.focus();
return consoleFrames.blur(window.document);
case 'vimvixen.command.enter':
return browser.runtime.sendMessage({
type: 'event.cmd.enter',
text: action.value
}).catch((err) => {
console.error("Vim Vixen:", err);
return consoleFrames.showError(err.message);
});
default:
return Promise.resolve();
}
});
|