Change: reuse editor in openEditor
This commit is contained in:
parent
f86a678a1f
commit
3b24e6a928
|
@ -403,13 +403,12 @@ function openEditor(params) {
|
||||||
searchParams.set(key, params[key]);
|
searchParams.set(key, params[key]);
|
||||||
}
|
}
|
||||||
const search = searchParams.toString();
|
const search = searchParams.toString();
|
||||||
const url = chrome.runtime.getURL('edit.html') + (search && `?${search}`);
|
return openURL({
|
||||||
if (chrome.windows && prefs.get('openEditInWindow')) {
|
url: 'edit.html' + (search && `?${search}`),
|
||||||
// FIXME: should we reuse the editor window?
|
newWindow: prefs.get('openEditInWindow'),
|
||||||
chrome.windows.create(Object.assign({url}, prefs.get('windowPosition')));
|
windowPosition: prefs.get('windowPosition'),
|
||||||
} else {
|
currentWindow: null
|
||||||
openURL({url});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function openManage({options = false, search} = {}) {
|
function openManage({options = false, search} = {}) {
|
||||||
|
|
|
@ -99,6 +99,7 @@ const updateTab = promisify(chrome.tabs.update.bind(chrome.tabs));
|
||||||
const moveTabs = promisify(chrome.tabs.move.bind(chrome.tabs));
|
const moveTabs = promisify(chrome.tabs.move.bind(chrome.tabs));
|
||||||
// FIXME: is it possible that chrome.windows is undefined?
|
// FIXME: is it possible that chrome.windows is undefined?
|
||||||
const updateWindow = promisify(chrome.windows.update.bind(chrome.windows));
|
const updateWindow = promisify(chrome.windows.update.bind(chrome.windows));
|
||||||
|
const createWindow = promisify(chrome.windows.create.bind(chrome.windows));
|
||||||
|
|
||||||
function getTab(id) {
|
function getTab(id) {
|
||||||
return new Promise(resolve =>
|
return new Promise(resolve =>
|
||||||
|
@ -238,6 +239,8 @@ function openURL(options) {
|
||||||
index,
|
index,
|
||||||
active,
|
active,
|
||||||
currentWindow = true,
|
currentWindow = true,
|
||||||
|
newWindow = false,
|
||||||
|
windowPosition
|
||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
if (!url.includes('://')) {
|
if (!url.includes('://')) {
|
||||||
|
@ -271,6 +274,9 @@ function openURL(options) {
|
||||||
if (emptyTab && !chromeInIncognito) {
|
if (emptyTab && !chromeInIncognito) {
|
||||||
return activateTab(tab, {url, index}); // FIXME: should we move current empty tab?
|
return activateTab(tab, {url, index}); // FIXME: should we move current empty tab?
|
||||||
}
|
}
|
||||||
|
if (newWindow) {
|
||||||
|
return createWindow(Object.assign({url}, windowPosition));
|
||||||
|
}
|
||||||
const options = {url, index, active};
|
const options = {url, index, active};
|
||||||
// FF57+ supports openerTabId, but not in Android (indicated by the absence of chrome.windows)
|
// FF57+ supports openerTabId, but not in Android (indicated by the absence of chrome.windows)
|
||||||
// FIXME: is it safe to assume that the current tab is the opener?
|
// FIXME: is it safe to assume that the current tab is the opener?
|
||||||
|
|
Loading…
Reference in New Issue
Block a user