mirror of
https://github.com/OctopusSuite/octopus-file-browser.git
synced 2026-10-08 22:05:20 +00:00
Add an opt-in context menu for files and directories
Apps set browser.contextMenu to a list of { label, action, when?, danger? }
items; when(entry, path) scopes an item to directories, files, or any
other match. Right-click, the Menu key, or a touch long press opens it.
The demo adds sample items, including a .json-only one.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Vendored
+9
-1
@@ -13,6 +13,13 @@ export interface OctopusOpenDetail {
|
||||
path: string[];
|
||||
}
|
||||
|
||||
export interface OctopusMenuItem {
|
||||
label: string;
|
||||
action: (entry: OctopusEntry, path: string[]) => void;
|
||||
when?: (entry: OctopusEntry, path: string[]) => boolean;
|
||||
danger?: boolean;
|
||||
}
|
||||
|
||||
export interface OctopusNavigateDetail {
|
||||
path: string[];
|
||||
}
|
||||
@@ -25,6 +32,7 @@ export interface OctopusFileBrowserEventMap {
|
||||
export class OctopusFileBrowser extends HTMLElement {
|
||||
entries: OctopusEntry[];
|
||||
path: string[];
|
||||
contextMenu: OctopusMenuItem[];
|
||||
addEventListener<K extends keyof OctopusFileBrowserEventMap>(
|
||||
type: K,
|
||||
listener: (this: OctopusFileBrowser, event: OctopusFileBrowserEventMap[K]) => void,
|
||||
@@ -39,7 +47,7 @@ export class OctopusFileBrowser extends HTMLElement {
|
||||
|
||||
export function createOctopusFileBrowser(
|
||||
target: Element,
|
||||
options?: { entries?: OctopusEntry[]; path?: string[]; emptyLabel?: string },
|
||||
options?: { entries?: OctopusEntry[]; path?: string[]; contextMenu?: OctopusMenuItem[]; emptyLabel?: string },
|
||||
): OctopusFileBrowser;
|
||||
|
||||
export function fileKindLabel(name?: string): string;
|
||||
|
||||
Reference in New Issue
Block a user