diff options
Diffstat (limited to 'src/console/actions/console.js')
-rw-r--r-- | src/console/actions/console.js | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/console/actions/console.js b/src/console/actions/console.js index f80045f..3713a76 100644 --- a/src/console/actions/console.js +++ b/src/console/actions/console.js @@ -1,3 +1,4 @@ +import messages from 'shared/messages'; import actions from 'console/actions'; const hide = () => { @@ -34,11 +35,30 @@ const showInfo = (text) => { }; const hideCommand = () => { + window.top.postMessage(JSON.stringify({ + type: messages.CONSOLE_UNFOCUS, + }), '*'); return { type: actions.CONSOLE_HIDE_COMMAND, }; }; +const enterCommand = async(text) => { + await browser.runtime.sendMessage({ + type: messages.CONSOLE_ENTER_COMMAND, + text, + }); + return hideCommand(text); +}; + +const enterFind = (text) => { + window.top.postMessage(JSON.stringify({ + type: messages.CONSOLE_ENTER_FIND, + text, + }), '*'); + return hideCommand(); +}; + const setConsoleText = (consoleText) => { return { type: actions.CONSOLE_SET_CONSOLE_TEXT, @@ -46,11 +66,15 @@ const setConsoleText = (consoleText) => { }; }; -const setCompletions = (completionSource, completions) => { +const getCompletions = async(text) => { + let completions = await browser.runtime.sendMessage({ + type: messages.CONSOLE_QUERY_COMPLETIONS, + text, + }); return { type: actions.CONSOLE_SET_COMPLETIONS, - completionSource, completions, + completionSource: text, }; }; @@ -68,5 +92,5 @@ const completionPrev = () => { export { hide, showCommand, showFind, showError, showInfo, hideCommand, setConsoleText, - setCompletions, completionNext, completionPrev + enterCommand, enterFind, getCompletions, completionNext, completionPrev }; |