remove actions from content
This commit is contained in:
parent
c7a3dd16e6
commit
27702ef402
4 changed files with 12 additions and 27 deletions
|
@ -56,18 +56,11 @@ const keyQueueChanged = (sendToTab, state) => {
|
||||||
return browser.tabs.sendMessage(sendToTab.id, action);
|
return browser.tabs.sendMessage(sendToTab.id, action);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleMessage = (action, sendToTab) => {
|
|
||||||
backgroundStore.dispatch(action);
|
|
||||||
|
|
||||||
return browser.tabs.sendMessage(sendToTab.id, action);
|
|
||||||
};
|
|
||||||
|
|
||||||
browser.runtime.onMessage.addListener((action, sender) => {
|
|
||||||
handleMessage(action, sender.tab);
|
|
||||||
});
|
|
||||||
|
|
||||||
browser.runtime.onMessage.addListener((message) => {
|
browser.runtime.onMessage.addListener((message) => {
|
||||||
switch (message.type) {
|
switch (message.type) {
|
||||||
|
case messages.KEYDOWN:
|
||||||
|
backgroundStore.dispatch(inputActions.keyPress(message.code, message.ctrl));
|
||||||
|
break;
|
||||||
case messages.CONSOLE_BLURRED:
|
case messages.CONSOLE_BLURRED:
|
||||||
backgroundStore.dispatch(consoleActions.hide());
|
backgroundStore.dispatch(consoleActions.hide());
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import './console-frame.scss';
|
import './console-frame.scss';
|
||||||
import * as consoleActions from '../actions/console';
|
|
||||||
|
|
||||||
const initialize = (doc) => {
|
const initialize = (doc) => {
|
||||||
let iframe = doc.createElement('iframe');
|
let iframe = doc.createElement('iframe');
|
||||||
|
@ -11,17 +10,9 @@ const initialize = (doc) => {
|
||||||
return iframe;
|
return iframe;
|
||||||
}
|
}
|
||||||
|
|
||||||
const showCommand = (text) => {
|
|
||||||
return browser.runtime.sendMessage(consoleActions.showCommand(text));
|
|
||||||
};
|
|
||||||
|
|
||||||
const showError = (text) => {
|
|
||||||
return browser.runtime.sendMessage(consoleActions.showError(text));
|
|
||||||
}
|
|
||||||
|
|
||||||
const blur = (doc) => {
|
const blur = (doc) => {
|
||||||
let iframe = doc.getElementById('vimvixen-console-frame');
|
let iframe = doc.getElementById('vimvixen-console-frame');
|
||||||
iframe.blur();
|
iframe.blur();
|
||||||
}
|
}
|
||||||
|
|
||||||
export { initialize, showCommand, showError, blur };
|
export { initialize, blur };
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import '../console/console-frame.scss';
|
import '../console/console-frame.scss';
|
||||||
import * as inputActions from '../actions/input';
|
|
||||||
import * as consoleFrames from '../console/frames';
|
import * as consoleFrames from '../console/frames';
|
||||||
import * as scrolls from '../content/scrolls';
|
import * as scrolls from '../content/scrolls';
|
||||||
import * as histories from '../content/histories';
|
import * as histories from '../content/histories';
|
||||||
|
@ -13,10 +12,10 @@ window.addEventListener("keypress", (e) => {
|
||||||
if (e.target instanceof HTMLInputElement) {
|
if (e.target instanceof HTMLInputElement) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
browser.runtime.sendMessage(inputActions.keyPress(e.which, e.ctrlKey))
|
browser.runtime.sendMessage({
|
||||||
.catch((err) => {
|
type: messages.KEYDOWN,
|
||||||
console.error("Vim Vixen:", err);
|
code: e.which,
|
||||||
return consoleFrames.showError(err.message);
|
ctrl: e.ctrl
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -4,5 +4,7 @@ export default {
|
||||||
|
|
||||||
CONSOLE_BLURRED: 'console.blured',
|
CONSOLE_BLURRED: 'console.blured',
|
||||||
CONSOLE_ENTERED: 'console.entered',
|
CONSOLE_ENTERED: 'console.entered',
|
||||||
CONSOLE_CHANGEED: 'console.changed'
|
CONSOLE_CHANGEED: 'console.changed',
|
||||||
|
|
||||||
|
KEYDOWN: 'keydown'
|
||||||
};
|
};
|
||||||
|
|
Reference in a new issue