A fork of https://github.com/ueokande/vim-vixen
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
1.8 KiB
97 lines
1.8 KiB
6 years ago
|
import messages from 'shared/messages';
|
||
7 years ago
|
import actions from 'console/actions';
|
||
7 years ago
|
|
||
6 years ago
|
const hide = () => {
|
||
|
return {
|
||
|
type: actions.CONSOLE_HIDE,
|
||
|
};
|
||
|
};
|
||
|
|
||
7 years ago
|
const showCommand = (text) => {
|
||
7 years ago
|
return {
|
||
|
type: actions.CONSOLE_SHOW_COMMAND,
|
||
|
text: text
|
||
|
};
|
||
7 years ago
|
};
|
||
7 years ago
|
|
||
7 years ago
|
const showFind = () => {
|
||
|
return {
|
||
|
type: actions.CONSOLE_SHOW_FIND,
|
||
|
};
|
||
|
};
|
||
|
|
||
7 years ago
|
const showError = (text) => {
|
||
|
return {
|
||
|
type: actions.CONSOLE_SHOW_ERROR,
|
||
|
text: text
|
||
|
};
|
||
|
};
|
||
|
|
||
7 years ago
|
const showInfo = (text) => {
|
||
|
return {
|
||
|
type: actions.CONSOLE_SHOW_INFO,
|
||
|
text: text
|
||
|
};
|
||
|
};
|
||
|
|
||
7 years ago
|
const hideCommand = () => {
|
||
6 years ago
|
window.top.postMessage(JSON.stringify({
|
||
|
type: messages.CONSOLE_UNFOCUS,
|
||
|
}), '*');
|
||
7 years ago
|
return {
|
||
7 years ago
|
type: actions.CONSOLE_HIDE_COMMAND,
|
||
7 years ago
|
};
|
||
|
};
|
||
|
|
||
6 years ago
|
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();
|
||
|
};
|
||
|
|
||
7 years ago
|
const setConsoleText = (consoleText) => {
|
||
|
return {
|
||
|
type: actions.CONSOLE_SET_CONSOLE_TEXT,
|
||
|
consoleText,
|
||
|
};
|
||
|
};
|
||
|
|
||
6 years ago
|
const getCompletions = async(text) => {
|
||
|
let completions = await browser.runtime.sendMessage({
|
||
|
type: messages.CONSOLE_QUERY_COMPLETIONS,
|
||
|
text,
|
||
|
});
|
||
7 years ago
|
return {
|
||
7 years ago
|
type: actions.CONSOLE_SET_COMPLETIONS,
|
||
7 years ago
|
completions,
|
||
6 years ago
|
completionSource: text,
|
||
7 years ago
|
};
|
||
7 years ago
|
};
|
||
7 years ago
|
|
||
7 years ago
|
const completionNext = () => {
|
||
7 years ago
|
return {
|
||
7 years ago
|
type: actions.CONSOLE_COMPLETION_NEXT,
|
||
7 years ago
|
};
|
||
7 years ago
|
};
|
||
7 years ago
|
|
||
7 years ago
|
const completionPrev = () => {
|
||
7 years ago
|
return {
|
||
7 years ago
|
type: actions.CONSOLE_COMPLETION_PREV,
|
||
7 years ago
|
};
|
||
7 years ago
|
};
|
||
|
|
||
7 years ago
|
export {
|
||
6 years ago
|
hide, showCommand, showFind, showError, showInfo, hideCommand, setConsoleText,
|
||
6 years ago
|
enterCommand, enterFind, getCompletions, completionNext, completionPrev
|
||
7 years ago
|
};
|