Update the browser, editor, settings, and installer
This commit is contained in:
@@ -3,14 +3,16 @@
|
||||
import Icon from "$lib/ui/Icon.svelte";
|
||||
import ContextMenu from "$lib/layout/ContextMenu.svelte";
|
||||
import type { MenuItem } from "$lib/layout/menuTypes";
|
||||
import { installedPlugins, pluginTools, openPluginView, runPluginCommand } from "./external";
|
||||
import { installedPlugins, pluginTools, pluginNavigation, openPluginView, runPluginCommand } from "./external";
|
||||
let { surface, compact = false }: { surface: "commands" | "open"; compact?: boolean } = $props();
|
||||
let anchor = $state<HTMLButtonElement>();
|
||||
let position = $state<{ x: number; y: number } | null>(null);
|
||||
let error = $state("");
|
||||
let pointerWasOpen = false;
|
||||
const label = $derived(surface === "open" ? "Open tab or view" : "Commands");
|
||||
const tools = $derived($pluginTools.filter(tool => tool.surface === surface));
|
||||
const label = $derived(surface === "open" ? "Plug-in views" : "Commands");
|
||||
const tools = $derived($pluginTools.filter(tool => tool.surface === surface
|
||||
&& tool.owner !== "runestone.browser"
|
||||
&& !(surface === "open" && tool.kind === "view" && $pluginNavigation.some(item => item.owner === tool.owner && item.id === tool.id && item.placement === "sidebar"))));
|
||||
const signature = $derived(JSON.stringify([tools, $installedPlugins.plugins.map(row => [row.manifest.id, row.manifest.name])]));
|
||||
const items: MenuItem[] = $derived.by(() => { void signature; return untrack(() => tools.map(tool => ({
|
||||
kind: "action" as const,
|
||||
@@ -28,7 +30,7 @@
|
||||
<button class="access-button" class:compact bind:this={anchor} aria-label={label} aria-haspopup="menu" aria-expanded={position !== null} title={label}
|
||||
onpointerdown={() => pointerWasOpen = position !== null}
|
||||
onclick={event => { const close = event.detail > 0 ? pointerWasOpen : position !== null; const bounds = anchor!.getBoundingClientRect(); position = close ? null : { x: bounds.left, y: bounds.bottom + 4 }; }}>
|
||||
<Icon icon={surface === "open" ? "chevron-down" : "code"} />{#if !compact}<span>{label}</span>{/if}
|
||||
<Icon icon={surface === "open" ? "puzzle" : "code"} />{#if !compact}<span>{label}</span>{/if}
|
||||
{#if compact}<span class="access-tooltip" role="tooltip">{label}</span>{/if}
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user