diff --git a/frontend/src/components/window/workspace/Panel.svelte b/frontend/src/components/window/workspace/Panel.svelte index 66247cbc..eb35d3e1 100644 --- a/frontend/src/components/window/workspace/Panel.svelte +++ b/frontend/src/components/window/workspace/Panel.svelte @@ -19,7 +19,6 @@ import type { Editor } from "@graphite/editor"; import { type LayoutKeysGroup, type Key } from "@graphite/messages"; import { platformIsMac, isEventSupported } from "@graphite/utility-functions/platform"; - import { extractPixelData } from "@graphite/utility-functions/rasterization"; import LayoutCol from "@graphite/components/layout/LayoutCol.svelte"; @@ -30,6 +29,7 @@ import TextLabel from "@graphite/components/widgets/labels/TextLabel.svelte"; import UserInputLabel from "@graphite/components/widgets/labels/UserInputLabel.svelte"; + const BUTTON_LEFT = 0; const BUTTON_MIDDLE = 1; const editor = getContext("editor"); @@ -41,6 +41,7 @@ export let panelType: PanelType | undefined = undefined; export let clickAction: ((index: number) => void) | undefined = undefined; export let closeAction: ((index: number) => void) | undefined = undefined; + export let emptySpaceAction: (() => void) | undefined = undefined; let className = ""; export { className as class }; @@ -93,6 +94,11 @@ }); } + function onEmptySpaceAction(e: MouseEvent) { + if (e.target !== e.currentTarget) return; + if (e.button === BUTTON_MIDDLE || (e.button === BUTTON_LEFT && e.detail === 2)) emptySpaceAction?.(); + } + export async function scrollTabIntoView(newIndex: number) { await tick(); tabElements[newIndex]?.div?.()?.scrollIntoView(); @@ -101,7 +107,7 @@ panelType && editor.handle.setActivePanel(panelType)} class={`panel ${className}`.trim()} {classes} style={styleName} {styles}> - + {#each tabLabels as tabLabel, tabIndex} editor.handle.newDocumentDialog()} clickAction={(tabIndex) => editor.handle.selectDocument($portfolio.documents[tabIndex].id)} closeAction={(tabIndex) => editor.handle.closeDocumentWithConfirmation($portfolio.documents[tabIndex].id)} tabActiveIndex={$portfolio.activeDocumentIndex}