blob: 314dfea9c029b93f8c2b55c58ac0520d60c5fac0 (
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
42
43
44
45
46
47
|
import '../console/console-frame.scss';
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;
}
let request = {
type: 'event.keypress',
code: e.which,
ctrl: e.ctrlKey,
}
browser.runtime.sendMessage(request)
.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();
}
});
|