|
19 | 19 | import type { Editor } from "@graphite/editor"; |
20 | 20 | import { type LayoutKeysGroup, type Key } from "@graphite/messages"; |
21 | 21 | import { platformIsMac, isEventSupported } from "@graphite/utility-functions/platform"; |
22 | | -
|
23 | 22 | import { extractPixelData } from "@graphite/utility-functions/rasterization"; |
24 | 23 |
|
25 | 24 | import LayoutCol from "@graphite/components/layout/LayoutCol.svelte"; |
|
30 | 29 | import TextLabel from "@graphite/components/widgets/labels/TextLabel.svelte"; |
31 | 30 | import UserInputLabel from "@graphite/components/widgets/labels/UserInputLabel.svelte"; |
32 | 31 |
|
| 32 | + const BUTTON_LEFT = 0; |
33 | 33 | const BUTTON_MIDDLE = 1; |
34 | 34 |
|
35 | 35 | const editor = getContext<Editor>("editor"); |
|
41 | 41 | export let panelType: PanelType | undefined = undefined; |
42 | 42 | export let clickAction: ((index: number) => void) | undefined = undefined; |
43 | 43 | export let closeAction: ((index: number) => void) | undefined = undefined; |
| 44 | + export let emptySpaceAction: (() => void) | undefined = undefined; |
44 | 45 |
|
45 | 46 | let className = ""; |
46 | 47 | export { className as class }; |
|
93 | 94 | }); |
94 | 95 | } |
95 | 96 |
|
| 97 | + function onEmptySpaceAction(e: MouseEvent) { |
| 98 | + if (e.target !== e.currentTarget) return; |
| 99 | + if (e.button === BUTTON_MIDDLE || (e.button === BUTTON_LEFT && e.detail === 2)) emptySpaceAction?.(); |
| 100 | + } |
| 101 | +
|
96 | 102 | export async function scrollTabIntoView(newIndex: number) { |
97 | 103 | await tick(); |
98 | 104 | tabElements[newIndex]?.div?.()?.scrollIntoView(); |
|
101 | 107 |
|
102 | 108 | <LayoutCol on:pointerdown={() => panelType && editor.handle.setActivePanel(panelType)} class={`panel ${className}`.trim()} {classes} style={styleName} {styles}> |
103 | 109 | <LayoutRow class="tab-bar" classes={{ "min-widths": tabMinWidths }}> |
104 | | - <LayoutRow class="tab-group" scrollableX={true}> |
| 110 | + <LayoutRow class="tab-group" scrollableX={true} on:click={onEmptySpaceAction} on:auxclick={onEmptySpaceAction}> |
105 | 111 | {#each tabLabels as tabLabel, tabIndex} |
106 | 112 | <LayoutRow |
107 | 113 | class="tab" |
|
0 commit comments