diff --git a/src/actors/ContextMenuParent.ts b/src/actors/ContextMenuParent.ts index ea1c642..9340bff 100644 --- a/src/actors/ContextMenuParent.ts +++ b/src/actors/ContextMenuParent.ts @@ -13,7 +13,7 @@ export class ContextMenuParent extends JSWindowActorParent { receiveMessage(event: ContextMenuEvent) { if (event.name == 'contextmenu') { const win = event.target.browsingContext.embedderElement.ownerGlobal - win.windowApi.showContextMenu(event.data, this) + win.windowApi.contextMenu.showContextMenu(event.data, this) } } } diff --git a/src/content/browser/lib/window/api.ts b/src/content/browser/lib/window/api.ts index b889378..ffb2085 100644 --- a/src/content/browser/lib/window/api.ts +++ b/src/content/browser/lib/window/api.ts @@ -16,30 +16,37 @@ export type WindowTriggers = { export const windowApi = { windowTriggers: mitt(), - closeTab, - openTab, - get tabs() { - return tabs.readOnce() + tabs: { + closeTab, + openTab, + get tabs() { + return tabs.readOnce() + }, + setIcon: (browser: XULBrowserElement, iconURL: string) => + tabs + .readOnce() + .find((tab) => tab.getTabId() == browser.browserId) + ?.icon.set(iconURL), }, - setIcon: (browser: XULBrowserElement, iconURL: string) => - tabs - .readOnce() - .find((tab) => tab.getTabId() == browser.browserId) - ?.icon.set(iconURL), - showContextMenu: (menuInfo: ContextMenuInfo, actor: JSWindowActorParent) => { - browserContextMenuInfo.set(menuInfo) - setContextMenuParentActor(actor) + contextMenu: { + showContextMenu: ( + menuInfo: ContextMenuInfo, + actor: JSWindowActorParent, + ) => { + browserContextMenuInfo.set(menuInfo) + setContextMenuParentActor(actor) - requestAnimationFrame(() => { - const contextMenu = document.getElementById( - 'browser_context_menu', - ) as XULMenuPopup - contextMenu.openPopupAtScreen( - menuInfo.position.screenX, - menuInfo.position.screenY, - true, - ) - }) + requestAnimationFrame(() => { + const contextMenu = document.getElementById( + 'browser_context_menu', + ) as XULMenuPopup + contextMenu.openPopupAtScreen( + menuInfo.position.screenX, + menuInfo.position.screenY, + true, + ) + }) + }, }, } diff --git a/src/content/shared/customizableUI/items.ts b/src/content/shared/customizableUI/items.ts index a2597b5..eec468a 100644 --- a/src/content/shared/customizableUI/items.ts +++ b/src/content/shared/customizableUI/items.ts @@ -1,7 +1,6 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - import { readable } from 'svelte/store' import type { Component, ExportComponent } from '.' @@ -67,7 +66,7 @@ export const cuiPreviewItems: CUIPreviewItem[] = [ type: 'icon', icon: 'add-line', enabled: ALWAYS_ENABLE, - action: () => window.windowApi.openTab(), + action: () => window.windowApi.tabs.openTab(), }, }, {