reopen command line after error

jh-changes
Shin'ya Ueoka 7 years ago
parent e0bff54a82
commit 29f82d3a7f
  1. 10
      src/console/console-frame.js
  2. 8
      src/console/console.js
  3. 2
      src/content/index.js

@ -10,6 +10,8 @@ export default class ConsoleFrame {
this.element = element; this.element = element;
this.errorShown = true;
this.hide(); this.hide();
} }
@ -21,6 +23,7 @@ export default class ConsoleFrame {
text: text text: text
}; };
messages.send(this.element.contentWindow, message); messages.send(this.element.contentWindow, message);
this.errorShown = false;
} }
showError(text) { showError(text) {
@ -31,6 +34,8 @@ export default class ConsoleFrame {
text: text text: text
}; };
messages.send(this.element.contentWindow, message); messages.send(this.element.contentWindow, message);
this.errorShown = true;
this.element.blur();
} }
showFrame() { showFrame() {
@ -40,5 +45,10 @@ export default class ConsoleFrame {
hide() { hide() {
this.element.style.display = 'none'; this.element.style.display = 'none';
this.element.blur(); this.element.blur();
this.errorShown = false;
}
isErrorShown() {
return this.element.style.display === 'block' && this.errorShown;
} }
} }

@ -57,15 +57,15 @@ window.addEventListener('load', () => {
}); });
const showCommand = (text) => { const showCommand = (text) => {
let input = window.document.querySelector('#vimvixen-console-command-input');
input.value = text;
input.focus();
let command = window.document.querySelector('#vimvixen-console-command'); let command = window.document.querySelector('#vimvixen-console-command');
command.style.display = 'block'; command.style.display = 'block';
let error = window.document.querySelector('#vimvixen-console-error'); let error = window.document.querySelector('#vimvixen-console-error');
error.style.display = 'none'; error.style.display = 'none';
let input = window.document.querySelector('#vimvixen-console-command-input');
input.value = text;
input.focus();
} }
const showError = (text) => { const showError = (text) => {

@ -91,7 +91,9 @@ window.addEventListener("keypress", (e) => {
messages.receive(window, (message) => { messages.receive(window, (message) => {
switch (message.type) { switch (message.type) {
case 'vimvixen.command.blur': case 'vimvixen.command.blur':
if (!vvConsole.isErrorShown()) {
vvConsole.hide(); vvConsole.hide();
}
break; break;
case 'vimvixen.command.enter': case 'vimvixen.command.enter':
browser.runtime.sendMessage({ browser.runtime.sendMessage({