diff --git a/addon/actions/snapshots.js b/addon/actions/snapshots.js index a6621003f..4fafff9dc 100644 --- a/addon/actions/snapshots.js +++ b/addon/actions/snapshots.js @@ -37,15 +37,14 @@ async function createSnapshot() { const items = [] for (let tab of window.tabs) { - items.push({ - id: tab.id, - pinned: tab.pinned, - url: tab.url, - title: tab.title, - lvl: tab.lvl, - ctr: tab.cookieStoreId, - panel: tab.panelId, - }) + let item = { id: tab.id, url: tab.url, title: tab.title } + + if (tab.pinned) item.pinned = true + if (tab.cookieStoreId !== DEFAULT_CTX_ID) item.ctr = tab.cookieStoreId + if (tab.panelId !== DEFAULT_CTX_ID) item.panel = tab.panelId + if (tab.lvl > 0) item.lvl = tab.lvl + + items.push(item) } windows[windowId] = { items } diff --git a/addon/defaults.js b/addon/defaults.js index ec08644fb..d2e88ec5f 100644 --- a/addon/defaults.js +++ b/addon/defaults.js @@ -33,8 +33,8 @@ export const SETTINGS_OPTIONS = { snapLimitUnitOpts: ['snap', 'kb', 'day'], panelTypeOpts: ['tabs', 'ctx'], moveNewTabPinOpts: ['start', 'end', 'none'], - moveNewTabParentOpts: ['sibling', 'first_child', 'last_child', 'start', 'end', 'none'], - moveNewTabOpts: ['start', 'end', 'after', 'first_child', 'last_child', 'none'], + moveNewTabParentOpts: ['before', 'sibling', 'first_child', 'last_child', 'start', 'end', 'none'], + moveNewTabOpts: ['start', 'end', 'before', 'after', 'first_child', 'last_child', 'none'], midClickBookmarkOpts: ['open_new_tab', 'edit', 'delete'], warnOnMultiTabCloseOpts: ['any', 'collapsed', 'none'], warnOnMultiBookmarkDeleteOpts: ['any', 'collapsed', 'none'], diff --git a/addon/locales/en.settings.js b/addon/locales/en.settings.js index fc5731f5c..98e9e7f78 100644 --- a/addon/locales/en.settings.js +++ b/addon/locales/en.settings.js @@ -10,7 +10,7 @@ export default { 'settings.nav_settings_containers': { message: 'Containers' }, 'settings.nav_settings_panels': { message: 'Panels' }, 'settings.nav_settings_tabs': { message: 'Tabs' }, - 'settings.nav_settings_new_tab_position': { message: 'New tab position' }, + 'settings.nav_settings_new_tab_position': { message: 'Position of new tab' }, 'settings.nav_settings_pinned_tabs': { message: 'Pinned tabs' }, 'settings.nav_settings_tabs_tree': { message: 'Tabs tree' }, 'settings.nav_settings_bookmarks': { message: 'Bookmarks' }, @@ -124,13 +124,14 @@ export default { }, // --- New tab position - 'settings.new_tab_position': { message: 'New tab position' }, + 'settings.new_tab_position': { message: 'Position of new tab' }, 'settings.move_new_tab_pin': { message: 'Place new tab opened from pinned tab' }, 'settings.move_new_tab_pin_start': { message: 'panel start' }, 'settings.move_new_tab_pin_end': { message: 'panel end' }, 'settings.move_new_tab_pin_none': { message: 'none' }, 'settings.move_new_tab_parent': { message: 'Place new tab opened from another tab' }, - 'settings.move_new_tab_parent_sibling': { message: 'sibling' }, + 'settings.move_new_tab_parent_before': { message: 'before parent' }, + 'settings.move_new_tab_parent_sibling': { message: 'after parent' }, 'settings.move_new_tab_parent_first_child': { message: 'first child' }, 'settings.move_new_tab_parent_last_child': { message: 'last child' }, 'settings.move_new_tab_parent_start': { message: 'panel start' }, @@ -140,6 +141,7 @@ export default { 'settings.move_new_tab': { message: 'Place new tab (for the other cases)' }, 'settings.move_new_tab_start': { message: 'panel start' }, 'settings.move_new_tab_end': { message: 'panel end' }, + 'settings.move_new_tab_before': { message: 'before active tab' }, 'settings.move_new_tab_after': { message: 'after active tab' }, 'settings.move_new_tab_first_child': { message: 'first child of active tab' }, 'settings.move_new_tab_last_child': { message: 'last child of active tab' }, diff --git a/addon/locales/ru.settings.js b/addon/locales/ru.settings.js index 3c2c7fcb7..886662d1e 100644 --- a/addon/locales/ru.settings.js +++ b/addon/locales/ru.settings.js @@ -131,7 +131,8 @@ export default { 'settings.move_new_tab_pin_end': { message: 'конец пенели' }, 'settings.move_new_tab_pin_none': { message: 'выкл' }, 'settings.move_new_tab_parent': { message: 'Открытые из другой вкладки' }, - 'settings.move_new_tab_parent_sibling': { message: 'по соседству' }, + 'settings.move_new_tab_parent_before': { message: 'перед родительской' }, + 'settings.move_new_tab_parent_sibling': { message: 'после родительской' }, 'settings.move_new_tab_parent_first_child': { message: 'первая дочерняя' }, 'settings.move_new_tab_parent_last_child': { message: 'последняя дочерняя' }, 'settings.move_new_tab_parent_start': { message: 'начало панели' }, @@ -143,7 +144,8 @@ export default { 'settings.move_new_tab': { message: 'Для остальных случаев' }, 'settings.move_new_tab_start': { message: 'начало панели' }, 'settings.move_new_tab_end': { message: 'конец пенели' }, - 'settings.move_new_tab_after': { message: 'после активной вкладки' }, + 'settings.move_new_tab_before': { message: 'перед активной вкладкой' }, + 'settings.move_new_tab_after': { message: 'после активной вкладкой' }, 'settings.move_new_tab_first_child': { message: 'первая дочерняя вкладка активной' }, 'settings.move_new_tab_last_child': { message: 'последняя дочерняя вкладка активной' }, 'settings.move_new_tab_none': { message: 'выкл' }, diff --git a/addon/manifest.json b/addon/manifest.json index 9084973e0..2b19c9a25 100644 --- a/addon/manifest.json +++ b/addon/manifest.json @@ -8,7 +8,7 @@ }, "author": "mbnuqw", "name": "__MSG_ExtName__", - "version": "4.1.2", + "version": "4.2.0", "default_locale": "en", "description": "__MSG_ExtDesc__", "homepage_url": "https://github.com/mbnuqw/sidebery", diff --git a/package.json b/package.json index dcecdc84e..ef814d6ea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sidebery", - "version": "4.1.2", + "version": "4.2.0", "description": "Manage your tabs and bookmarks in sidebar", "main": "index.js", "scripts": { diff --git a/src/sidebar/actions/menu.js b/src/sidebar/actions/menu.js index bce55dc1c..39104f08e 100644 --- a/src/sidebar/actions/menu.js +++ b/src/sidebar/actions/menu.js @@ -9,6 +9,10 @@ const xmlSerializer = new XMLSerializer() */ async function openCtxMenu(type, x, y) { if (!this.state.selected.length) return + if (this.state.tabLongClickFired) { + this.state.tabLongClickFired = false + return + } if (!type) return let nodeType, diff --git a/src/sidebar/actions/misc.js b/src/sidebar/actions/misc.js index 7be70dc72..5d807d526 100644 --- a/src/sidebar/actions/misc.js +++ b/src/sidebar/actions/misc.js @@ -157,12 +157,12 @@ function resetSelection() { let id = this.state.selected[0] if (typeof id === 'number') { for (let id of this.state.selected) { - this.state.tabsMap[id].sel = false + if (this.state.tabsMap[id]) this.state.tabsMap[id].sel = false } if (this.state.nativeHighlight) this.actions.updateHighlightedTabs(120) } else if (typeof id === 'string') { for (let id of this.state.selected) { - this.state.bookmarksMap[id].sel = false + if (this.state.bookmarksMap[id]) this.state.bookmarksMap[id].sel = false } } this.state.selected = [] @@ -208,6 +208,17 @@ function blockCtxMenu() { }, 500) } +/** + * Reset long-click action fired flag + */ +function resetLongClickLock() { + if (this.state.tabLongClickFired) { + setTimeout(() => { + this.state.tabLongClickFired = false + }, 120) + } +} + /** * Start multi selection */ @@ -296,9 +307,6 @@ function askNewBookmarkFolder(defaultValue) { if (!bookmarksPanel) res(defaultValue) this.state.panelIndex = bookmarksPanel.index - - if (defaultValue !== undefined) this.actions.selectItem(defaultValue) - this.state.selectBookmarkFolder = { id: '', ok: () => { @@ -373,6 +381,7 @@ export default { updateSidebarWidth, blockWheel, blockCtxMenu, + resetLongClickLock, startMultiSelection, stopMultiSelection, confirm, diff --git a/src/sidebar/actions/tabs.js b/src/sidebar/actions/tabs.js index 93c0ab032..d6cb7fa59 100644 --- a/src/sidebar/actions/tabs.js +++ b/src/sidebar/actions/tabs.js @@ -315,6 +315,7 @@ async function loadTabsFromInlineData(tabs, dataTabIndex) { } let secondTab = tabs[dataTabIndex + 1] + if (!secondTab) secondTab = tabs[dataTabIndex - 1] if (!secondTab) return this.actions.updatePanelsTabs() await browser.tabs.update(secondTab.id, { active: true }) @@ -978,7 +979,9 @@ async function moveTabsToNewWin(tabIds, incognito = false) { if (toMove.includes(id)) continue tabs.push(tab) toMove.push(id) - tabsInfo.push({ lvl: tab.lvl, panelId: tab.panelId }) + let info = { lvl: tab.lvl, panelId: tab.panelId } + if (tab.pinned) info.pinned = true + tabsInfo.push(info) if (tab.active) activeTab = tab if (tab.folded) { for (let i = tab.index + 1; i < this.state.tabs.length; i++) { @@ -1009,12 +1012,9 @@ async function moveTabsToNewWin(tabIds, incognito = false) { let index = 1 for (let tab of tabs) { if (incognito === this.state.private) { - moving.push( - browser.tabs.move(tab.id, { - windowId: win.id, - index: index++, - }) - ) + let conf = { windowId: win.id } + conf.index = tab.pinned ? 0 : index++ + moving.push(browser.tabs.move(tab.id, conf)) } else { let conf = { windowId: win.id, @@ -2076,7 +2076,10 @@ function getPanelForNewTab(tab) { } } + // If position of new tab should be related with active one + // find the panel of active tab let actTabRel = + this.state.moveNewTab === 'before' || this.state.moveNewTab === 'after' || this.state.moveNewTab === 'first_child' || this.state.moveNewTab === 'last_child' @@ -2115,6 +2118,7 @@ function getIndexForNewTab(panel, tab) { // Place new tab opened from another tab if (parent && !parent.pinned && parent.panelId === panel.id) { + if (this.state.moveNewTabParent === 'before') return parent.index if (this.state.moveNewTabParent === 'sibling' || this.state.moveNewTabParent === 'last_child') { let t let index = parent.index + 1 @@ -2133,6 +2137,11 @@ function getIndexForNewTab(panel, tab) { // Place new tab (for the other cases) if (this.state.moveNewTab === 'start') return panel.startIndex if (this.state.moveNewTab === 'end') return endIndex + if (this.state.moveNewTab === 'before') { + if (!activeTab || activeTab.panelId !== panel.id) return endIndex + else if (activeTab.pinned) return panel.startIndex + else return activeTab.index + } if (this.state.moveNewTab === 'after') { if (!activeTab || activeTab.panelId !== panel.id) { return endIndex @@ -2184,6 +2193,7 @@ function getParentForNewTab(panel, openerTabId) { // Place new tab opened from another tab if (parent && !parent.pinned && parent.panelId === panel.id) { + if (this.state.moveNewTabParent === 'before') return parent.parentId if (this.state.moveNewTabParent === 'sibling') return parent.parentId if (this.state.moveNewTabParent === 'first_child') return openerTabId if (this.state.moveNewTabParent === 'last_child') return openerTabId @@ -2196,7 +2206,8 @@ function getParentForNewTab(panel, openerTabId) { if (this.state.moveNewTab === 'start') return if (this.state.moveNewTab === 'end') return if (activeTab && activeTab.panelId === panel.id && !activeTab.pinned) { - if (this.state.moveNewTab === 'after') return activeTab.parentId + if (this.state.moveNewTab === 'before') return activeTab.parentId + else if (this.state.moveNewTab === 'after') return activeTab.parentId else if (this.state.moveNewTab === 'first_child') return activeTab.id else if (this.state.moveNewTab === 'last_child') return activeTab.id } diff --git a/src/sidebar/components/bookmark.vue b/src/sidebar/components/bookmark.vue index 65f449b41..851653c43 100644 --- a/src/sidebar/components/bookmark.vue +++ b/src/sidebar/components/bookmark.vue @@ -137,6 +137,7 @@ export default { */ onMouseUp(e) { if (e.button === 0) { + if (State.selectBookmarkFolder) return if (e.ctrlKey || e.shiftKey) return if (State.selected.length && !this.node.sel) { diff --git a/src/sidebar/components/pinned-tab.vue b/src/sidebar/components/pinned-tab.vue index 3c070cf16..bc47ae116 100644 --- a/src/sidebar/components/pinned-tab.vue +++ b/src/sidebar/components/pinned-tab.vue @@ -159,7 +159,6 @@ export default { } // Long-click action - this.longClickActionLeftFired = false this.longClickActionLeft = setTimeout(() => { if (State.dragNodes) return let llc = State.tabLongLeftClick @@ -169,7 +168,7 @@ export default { if (llc === 'mute') Actions.remuteTabs([this.tab.id]) if (llc === 'clear_cookies') Actions.clearTabsCookies([this.tab.id]) if (llc === 'new_after') Actions.createTabAfter(this.tab.id) - if (llc !== 'none') this.longClickActionLeftFired = true + if (llc !== 'none') State.tabLongClickFired = true this.longClickActionLeft = null }, 300) }, @@ -192,7 +191,6 @@ export default { } // Long-click action - this.longClickActionRightFired = false this.longClickActionRight = setTimeout(() => { Actions.stopMultiSelection() let lrc = State.tabLongRightClick @@ -202,7 +200,7 @@ export default { if (lrc === 'mute') Actions.remuteTabs([this.tab.id]) if (lrc === 'clear_cookies') Actions.clearTabsCookies([this.tab.id]) if (lrc === 'new_after') Actions.createTabAfter(this.tab.id) - if (lrc !== 'none') this.longClickActionRightFired = true + if (lrc !== 'none') State.tabLongClickFired = true this.longClickActionRight = null }, 300) }, @@ -211,13 +209,10 @@ export default { * Handle mouseup event */ onMouseUp(e) { + if (State.tabLongClickFired) return Actions.resetLongClickLock() + if (e.button === 0) { - if ( - (State.selected.length || State.activateOnMouseUp) && - !this.longClickActionLeftFired && - !e.ctrlKey && - !e.shiftKey - ) { + if ((State.selected.length || State.activateOnMouseUp) && !e.ctrlKey && !e.shiftKey) { browser.tabs.update(this.tab.id, { active: true }) } if (this.longClickActionLeft) { @@ -233,10 +228,10 @@ export default { if (e.ctrlKey || e.shiftKey) return Actions.stopMultiSelection() - if (!State.ctxMenuNative && !this.longClickActionRightFired) { + if (!State.ctxMenuNative) { Actions.selectItem(this.tab.id) + Actions.openCtxMenu('tab', e.clientX, e.clientY) } - if (!State.ctxMenuNative) Actions.openCtxMenu('tab', e.clientX, e.clientY) } }, @@ -244,7 +239,8 @@ export default { * Handle context menu */ onCtxMenu(e) { - if (this.longClickActionRightFired || !State.ctxMenuNative || e.ctrlKey || e.shiftKey) { + if (State.tabLongClickFired || !State.ctxMenuNative || e.ctrlKey || e.shiftKey) { + State.tabLongClickFired = false e.stopPropagation() e.preventDefault() return diff --git a/src/sidebar/components/select-bookmarks-folder-bar.vue b/src/sidebar/components/select-bookmarks-folder-bar.vue index ba953069c..5ad90ed72 100644 --- a/src/sidebar/components/select-bookmarks-folder-bar.vue +++ b/src/sidebar/components/select-bookmarks-folder-bar.vue @@ -1,7 +1,9 @@