Use search settings on paster
This commit is contained in:
parent
8ae1311ef6
commit
27d0a7f37d
3 changed files with 11 additions and 9 deletions
|
@ -1,20 +1,20 @@
|
||||||
import * as actions from '../actions';
|
import * as actions from '../actions';
|
||||||
import * as keyUtils from '../../shared/utils/keys';
|
import * as keyUtils from '../../shared/utils/keys';
|
||||||
import * as operations from '../../shared/operations';
|
import * as operations from '../../shared/operations';
|
||||||
import { Properties } from '../../shared/Settings';
|
import { Search, Properties, DefaultSetting } from '../../shared/Settings';
|
||||||
|
|
||||||
export interface State {
|
export interface State {
|
||||||
keymaps: { key: keyUtils.Key[], op: operations.Operation }[];
|
keymaps: { key: keyUtils.Key[], op: operations.Operation }[];
|
||||||
|
search: Search;
|
||||||
properties: Properties;
|
properties: Properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// defaultState does not refer due to the state is load from
|
||||||
|
// background on load.
|
||||||
const defaultState: State = {
|
const defaultState: State = {
|
||||||
keymaps: [],
|
keymaps: [],
|
||||||
properties: {
|
search: DefaultSetting.search,
|
||||||
complete: '',
|
properties: DefaultSetting.properties,
|
||||||
smoothscroll: false,
|
|
||||||
hintchars: '',
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function reducer(
|
export default function reducer(
|
||||||
|
@ -31,6 +31,7 @@ export default function reducer(
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
properties: action.settings.properties,
|
properties: action.settings.properties,
|
||||||
|
search: action.settings.search,
|
||||||
};
|
};
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import * as messages from '../shared/messages';
|
import * as messages from '../shared/messages';
|
||||||
import * as urls from '../shared/urls';
|
import * as urls from '../shared/urls';
|
||||||
|
import { Search } from '../shared/Settings';
|
||||||
|
|
||||||
const yank = (win: Window) => {
|
const yank = (win: Window) => {
|
||||||
let input = win.document.createElement('input');
|
let input = win.document.createElement('input');
|
||||||
|
@ -15,7 +16,7 @@ const yank = (win: Window) => {
|
||||||
input.remove();
|
input.remove();
|
||||||
};
|
};
|
||||||
|
|
||||||
const paste = (win: Window, newTab: boolean, searchSettings: any) => {
|
const paste = (win: Window, newTab: boolean, search: Search) => {
|
||||||
let textarea = win.document.createElement('textarea');
|
let textarea = win.document.createElement('textarea');
|
||||||
win.document.body.append(textarea);
|
win.document.body.append(textarea);
|
||||||
|
|
||||||
|
@ -26,7 +27,7 @@ const paste = (win: Window, newTab: boolean, searchSettings: any) => {
|
||||||
|
|
||||||
if (win.document.execCommand('paste')) {
|
if (win.document.execCommand('paste')) {
|
||||||
let value = textarea.textContent as string;
|
let value = textarea.textContent as string;
|
||||||
let url = urls.searchUrl(value, searchSettings);
|
let url = urls.searchUrl(value, search);
|
||||||
browser.runtime.sendMessage({
|
browser.runtime.sendMessage({
|
||||||
type: messages.OPEN_URL,
|
type: messages.OPEN_URL,
|
||||||
url,
|
url,
|
||||||
|
|
|
@ -117,7 +117,7 @@ export const valueOf = (o: any): Settings => {
|
||||||
return settings;
|
return settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
const DefaultSetting: Settings = {
|
export const DefaultSetting: Settings = {
|
||||||
keymaps: {
|
keymaps: {
|
||||||
'0': { 'type': 'scroll.home' },
|
'0': { 'type': 'scroll.home' },
|
||||||
':': { 'type': 'command.show' },
|
':': { 'type': 'command.show' },
|
||||||
|
|
Reference in a new issue