broadcast an action

jh-changes
Shin'ya Ueoka 7 years ago
parent 3d35db9fc1
commit 0eed357a5e
  1. 2
      src/background/index.js
  2. 2
      src/console/console-frame.js
  3. 11
      src/console/console.js
  4. 11
      src/content/index.js

@ -96,5 +96,7 @@ browser.runtime.onMessage.addListener((request, sender) => {
items: items items: items
}; };
}); });
default:
return browser.tabs.sendMessage(sender.tab.id, request);
} }
}); });

@ -22,8 +22,8 @@ export default class ConsoleFrame {
type: 'vimvixen.console.show.command', type: 'vimvixen.console.show.command',
text: text text: text
}; };
messages.send(this.element.contentWindow, message);
this.errorShown = false; this.errorShown = false;
return browser.runtime.sendMessage(message);
} }
showError(text) { showError(text) {

@ -195,9 +195,6 @@ const selectCompletion = (target) => {
messages.receive(window, (message) => { messages.receive(window, (message) => {
switch (message.type) { switch (message.type) {
case 'vimvixen.console.show.command':
showCommand(message.text);
break;
case 'vimvixen.console.show.error': case 'vimvixen.console.show.error':
showError(message.text); showError(message.text);
break; break;
@ -206,3 +203,11 @@ messages.receive(window, (message) => {
break; break;
} }
}); });
browser.runtime.onMessage.addListener((action) => {
switch (action.type) {
case 'vimvixen.console.show.command':
return showCommand(action.text);
}
return Promise.resolve();
});

@ -11,19 +11,16 @@ let vvConsole = new ConsoleFrame(window);
browser.runtime.onMessage.addListener((action) => { browser.runtime.onMessage.addListener((action) => {
switch (action.type) { switch (action.type) {
case actions.CMD_OPEN: case actions.CMD_OPEN:
vvConsole.showCommand(''); return vvConsole.showCommand('');
break;
case actions.CMD_TABS_OPEN: case actions.CMD_TABS_OPEN:
if (action.alter) { if (action.alter) {
// alter url // alter url
vvConsole.showCommand('open ' + window.location.href); return vvConsole.showCommand('open ' + window.location.href);
} else { } else {
vvConsole.showCommand('open '); return vvConsole.showCommand('open ');
} }
break;
case actions.CMD_BUFFER: case actions.CMD_BUFFER:
vvConsole.showCommand('buffer '); return vvConsole.showCommand('buffer ');
break;
case actions.SCROLL_LINES: case actions.SCROLL_LINES:
scrolls.scrollLines(window, action.count); scrolls.scrollLines(window, action.count);
break; break;