Give way in narrow windows and use one icon for each action
Phase 5-6. - Side panes give way when the window becomes narrow: the outline below 1100 pixels, the side pane below 800 pixels. They come back when the window grows. A pane that the user opens in a narrow window stays open, and the saved layout keeps the wide-window choice. - One function has one icon. The SDK icon set gets duplicate, template, and tab. The reveal action has one label for each platform (Show in Explorer, Show in Finder, Show in file manager). - The file menu follows one order: open, clipboard, organize, show and copy path, history, then Delete and Delete permanently in the error color after a separator. The tree copies paths through a Copy path submenu, as the tab menu does. - The tree uses the shared chevron. Search hits come in groups by file, with counts and marked matches. Bookmarks show the name, the folder, and a remove button. - All boolean settings use one switch design (src/lib/ui/switch.css). Browser settings apply at once, and the Save button is gone. The Settings window opens with the focus on its search. - Targets of at least 24 pixels: the tab close button, outline rows, switches, and the settings search. - Catalog rows in French, Japanese, and Simplified Chinese. - Docs: UI-052, ui-design.md, and the user guide. Tests: the new layout/panesAndSettings. Tests that closed or opened panes by hand around narrow windows now rely on the new behavior, or wait for the panes to give way before they reopen one. Tests that read the old menu labels or the browser Save button use the new ones.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
/* Global styles. Each file lives beside the code that uses it. The order of the imports is the cascade order. */
|
||||
@import "./lib/theme/tokens.css";
|
||||
@import "./lib/ui/menu.css";
|
||||
@import "./lib/ui/switch.css";
|
||||
@import "./lib/theme/base.css";
|
||||
@import "./lib/ui/tooltip.css";
|
||||
@import "./lib/layout/reading.css";
|
||||
|
||||
@@ -1,89 +1,88 @@
|
||||
<script lang="ts">
|
||||
import { t } from "$lib/i18n";
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import Icon from '$lib/ui/Icon.svelte';
|
||||
import { showActionMenu } from '$lib/ui/managedActionMenu';
|
||||
import WebData from './WebData.svelte';
|
||||
import { state as browserState, request } from './client';
|
||||
let selected = $state('user'), name = $state(''), message = $state('');
|
||||
let search = $state('duckduckgo'), adblock = $state(true), internalLinks = $state(true), rules = $state('');
|
||||
let homepage = $state(''), filterLists = $state(''), ready = $state(false), busy = $state(false);
|
||||
const engines = [{ id: 'duckduckgo', name: 'DuckDuckGo' }, { id: 'google', name: 'Google' }, { id: 'bing', name: 'Bing' }];
|
||||
let closePicker = () => {};
|
||||
onDestroy(() => closePicker());
|
||||
function picker(event: MouseEvent, profile = false) {
|
||||
closePicker();
|
||||
const anchor = event.currentTarget as HTMLButtonElement;
|
||||
const bounds = anchor.getBoundingClientRect();
|
||||
closePicker = showActionMenu({ x: bounds.left, y: bounds.bottom + 4, label: profile ? $t('Profile') : $t('Search engine'),
|
||||
parent: anchor.closest('dialog') ?? undefined,
|
||||
items: (profile ? $browserState?.profiles || [] : engines).map(choice => ({ label: choice.name,
|
||||
radio: true, checked: choice.id === (profile ? selected : search),
|
||||
run: () => { if (profile) selected = choice.id; else search = choice.id; } })) }).close;
|
||||
}
|
||||
onMount(() => { void request('state').then(value => {
|
||||
selected = value.profiles[0].id; search = value.settings.search; adblock = value.settings.adblock;
|
||||
internalLinks = value.settings.linkDestination === 'internal'; rules = value.settings.personalRules;
|
||||
homepage = value.settings.homepage || ''; filterLists = (value.settings.filterLists || []).join('\n'); ready = true;
|
||||
}).catch(error => message = String(error)); });
|
||||
async function act(command: string, args: Record<string, unknown>) {
|
||||
try { const next = await request(command, args); message = $t('Changes saved.'); return next; } catch (error) { message = String(error); return null; }
|
||||
}
|
||||
async function create(duplicate: boolean) {
|
||||
if (!name.trim()) { message = $t('Enter a profile name.'); return; }
|
||||
const result = await act(duplicate ? 'duplicateProfile' : 'createProfile', duplicate ? { profileId: selected, name } : { name });
|
||||
if (result) { selected = result.profiles.at(-1)!.id; name = ''; }
|
||||
}
|
||||
async function save() {
|
||||
busy = true; message = $t('Saving browser settings…');
|
||||
try {
|
||||
await act('settings', { search, adblock, linkDestination: internalLinks ? 'internal' : 'external', personalRules: rules,
|
||||
homepage, filterLists: filterLists.split(/\r?\n/).map(value => value.trim()).filter(Boolean) });
|
||||
} finally { busy = false; }
|
||||
}
|
||||
</script>
|
||||
<div class="settings">
|
||||
<h2>{$t("Browser")}</h2><p>{$t("Choose how you browse within RuneStone.")}</p>
|
||||
<h3>{$t("General")}</h3>
|
||||
<form onsubmit={event => { event.preventDefault(); if (ready && !busy) void save(); }}>
|
||||
<fieldset disabled={!ready || busy}>
|
||||
<div class="card">
|
||||
<label class="row"><span>{$t("Open web links in RuneStone")}<small>{$t("Turn this off to use your system browser.")}</small></span><input class="switch" type="checkbox" role="switch" aria-label={$t("Open web links in RuneStone")} bind:checked={internalLinks}></label>
|
||||
<label class="row"><span>{$t("Homepage")}<small>{$t("The page to open in each new browser tab. Leave blank for an empty page.")}</small></span><input class="address" type="url" aria-label={$t("Homepage")} placeholder="https://example.com" maxlength="8192" bind:value={homepage}></label>
|
||||
<div class="row"><span>{$t("Search engine")}</span><button type="button" class="picker" aria-label={$t("Search engine")} aria-haspopup="menu" onclick={event => picker(event)}>{engines.find(engine => engine.id === search)?.name ?? 'DuckDuckGo'}<Icon icon="chevron-down" /></button></div>
|
||||
<label class="row"><span>{$t("Block ads and trackers")}<small>{$t("Apply the filter lists and personal rules to all browser tabs.")}</small></span><input class="switch" type="checkbox" role="switch" aria-label={$t("Block ads and trackers")} bind:checked={adblock}></label>
|
||||
<label class="row list-row"><span>{$t("Ad blocking lists")}<small>{$t("One HTTPS filter list URL per line, up to eight lists. New lists download when you save.")}</small></span><textarea aria-label={$t("Ad blocking lists")} rows="4" maxlength="66000" placeholder="https://easylist.to/easylist/easylist.txt" bind:value={filterLists}></textarea></label>
|
||||
</div>
|
||||
<label class="rules">{$t("Personal filter rules")}<small>{$t("Use one rule per line. Block a domain with ||ads.example.com^, allow it with @@||ads.example.com^, or hide an element with example.com##.advertisement. Save to apply the rules.")}</small><textarea rows="4" maxlength="100000" placeholder={'! Block an advertising domain\n||ads.example.com^\n! Hide an element on one site\nexample.com##.advertisement'} bind:value={rules}></textarea></label>
|
||||
<button type="submit"><Icon icon="save" />{busy ? $t('Saving…') : $t('Save browser settings')}</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
<h3>{$t("Profiles")}</h3><p>{$t("New profiles start blank. Duplicate a profile to copy its stored browsing data and bookmarks.")}</p>
|
||||
<div class="card profiles">
|
||||
<div class="profile-choice"><span>{$t("Profile")}</span><button type="button" class="picker" aria-label={$t("Profile")} aria-haspopup="menu" disabled={!ready} onclick={event => picker(event, true)}>{$browserState?.profiles.find(profile => profile.id === selected)?.name ?? $t('Profile')}<Icon icon="chevron-down" /></button></div>
|
||||
<label>{$t("New profile name")}<input bind:value={name} maxlength="60" placeholder={$t("Profile name")}></label>
|
||||
<div class="actions"><button onclick={() => void create(false)}><Icon icon="plus" />{$t("New blank profile")}</button><button onclick={() => void create(true)}><Icon icon="copy" />{$t("Duplicate profile")}</button></div>
|
||||
<p class="note">{$t("Duplication briefly restarts browser tabs. The copies remain separate. Agent permissions are not copied.")}</p>
|
||||
</div>
|
||||
<h3>{$t("Web data")}</h3><p>{$t("Clear data for the selected profile. Its browser tabs will close. Bookmarks remain.")}</p>
|
||||
<div class="actions"><button onclick={() => void act('clearData', { profileId: selected, kind: 'cache' })}>{$t("Clear cache")}</button><button onclick={() => void act('clearData', { profileId: selected, kind: 'cookies' })}>{$t("Clear cookies")}</button><button onclick={() => void act('clearData', { profileId: selected, kind: 'history' })}>{$t("Clear history")}</button></div>
|
||||
<p role="status">{message}</p>
|
||||
{#if ready}<WebData profileId={selected} />{/if}
|
||||
</div>
|
||||
<style>
|
||||
.settings{color:var(--rs-text);font-family:var(--rs-font-ui)}h2{margin:0;font-size:var(--rs-settings-heading-size);font-weight:500;color:var(--rs-text-strong)}h3{margin:var(--rs-settings-section-gap) 0 var(--rs-settings-gap);font-size:14px;font-weight:500}
|
||||
p{color:var(--rs-text-dim);font-size:var(--rs-settings-description-size);line-height:1.6}.card{padding:0 var(--rs-settings-row-padding);background:var(--rs-bg-elevated);border:1px solid var(--rs-border);border-radius:var(--rs-control-radius)}
|
||||
.row{display:flex;justify-content:space-between;align-items:center;gap:var(--rs-settings-gap);padding:var(--rs-settings-row-padding) 0}.row+.row{border-top:1px solid var(--rs-border)}
|
||||
input,textarea,button{border:1px solid var(--rs-border);border-radius:var(--rs-control-radius);background:var(--rs-bg);color:var(--rs-text);font:inherit;box-sizing:border-box;min-height:var(--rs-settings-control-height);padding:4px 8px}
|
||||
button{display:inline-flex;align-items:center;gap:7px;background:var(--rs-bg-elevated);cursor:pointer}button:hover{background:var(--rs-bg-active)}button:focus-visible,input:focus-visible,textarea:focus-visible{outline:2px solid var(--rs-focus);outline-offset:1px}
|
||||
.picker{justify-content:space-between;min-width:140px;max-width:100%;overflow-wrap:anywhere;text-align:left}
|
||||
.rules{display:flex;flex-direction:column;gap:7px;margin:16px 0}.profiles{padding-top:16px;padding-bottom:8px}.profiles label,.profile-choice{display:flex;flex-direction:column;gap:7px;margin-bottom:14px}
|
||||
.actions{display:flex;flex-wrap:wrap;gap:8px}.note{margin-bottom:0}
|
||||
fieldset{border:0;margin:0;padding:0;min-width:0}small{display:block;color:var(--rs-text-dim);font-size:var(--rs-settings-description-size);line-height:1.5;margin-top:5px}
|
||||
.row>span{flex:1}.address,.list-row textarea{width:260px;max-width:48%;box-sizing:border-box}.list-row{align-items:flex-start}textarea{resize:vertical}
|
||||
.switch{appearance:none;position:relative;flex:none;width:44px;height:26px;border:0;border-radius:999px;background:var(--rs-text-dim);padding:0;cursor:pointer;transition:background .15s}
|
||||
.switch::before{content:'';position:absolute;top:3px;left:3px;width:20px;height:20px;border-radius:50%;background:var(--rs-bg);box-shadow:0 1px 3px #0004;transition:transform .15s}
|
||||
.switch:checked{background:var(--rs-accent)}.switch:checked::before{transform:translateX(18px)}:disabled{opacity:.6;cursor:wait}
|
||||
@media(prefers-reduced-motion:reduce){.switch,.switch::before{transition:none}}
|
||||
@media(max-width:600px){.row{flex-wrap:wrap}.address,.list-row textarea{width:100%;max-width:100%}}
|
||||
</style>
|
||||
<script lang="ts">
|
||||
import { t } from "$lib/i18n";
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import Icon from '$lib/ui/Icon.svelte';
|
||||
import { showActionMenu } from '$lib/ui/managedActionMenu';
|
||||
import WebData from './WebData.svelte';
|
||||
import { state as browserState, request } from './client';
|
||||
let selected = $state('user'), name = $state(''), message = $state('');
|
||||
let search = $state('duckduckgo'), adblock = $state(true), internalLinks = $state(true), rules = $state('');
|
||||
let homepage = $state(''), filterLists = $state(''), ready = $state(false), busy = $state(false);
|
||||
const engines = [{ id: 'duckduckgo', name: 'DuckDuckGo' }, { id: 'google', name: 'Google' }, { id: 'bing', name: 'Bing' }];
|
||||
let closePicker = () => {};
|
||||
onDestroy(() => closePicker());
|
||||
function picker(event: MouseEvent, profile = false) {
|
||||
closePicker();
|
||||
const anchor = event.currentTarget as HTMLButtonElement;
|
||||
const bounds = anchor.getBoundingClientRect();
|
||||
closePicker = showActionMenu({ x: bounds.left, y: bounds.bottom + 4, label: profile ? $t('Profile') : $t('Search engine'),
|
||||
parent: anchor.closest('dialog') ?? undefined,
|
||||
items: (profile ? $browserState?.profiles || [] : engines).map(choice => ({ label: choice.name,
|
||||
radio: true, checked: choice.id === (profile ? selected : search),
|
||||
run: () => { if (profile) selected = choice.id; else { search = choice.id; void save(); } } })) }).close;
|
||||
}
|
||||
onMount(() => { void request('state').then(value => {
|
||||
selected = value.profiles[0].id; search = value.settings.search; adblock = value.settings.adblock;
|
||||
internalLinks = value.settings.linkDestination === 'internal'; rules = value.settings.personalRules;
|
||||
homepage = value.settings.homepage || ''; filterLists = (value.settings.filterLists || []).join('\n'); ready = true;
|
||||
}).catch(error => message = String(error)); });
|
||||
async function act(command: string, args: Record<string, unknown>) {
|
||||
try { const next = await request(command, args); message = $t('Changes saved.'); return next; } catch (error) { message = String(error); return null; }
|
||||
}
|
||||
async function create(duplicate: boolean) {
|
||||
if (!name.trim()) { message = $t('Enter a profile name.'); return; }
|
||||
const result = await act(duplicate ? 'duplicateProfile' : 'createProfile', duplicate ? { profileId: selected, name } : { name });
|
||||
if (result) { selected = result.profiles.at(-1)!.id; name = ''; }
|
||||
}
|
||||
// Settings apply at once: a switch or a choice on change, a text field when it loses focus.
|
||||
// A change during a save starts one more save after it.
|
||||
let pending = false;
|
||||
async function save() {
|
||||
if (!ready) return;
|
||||
if (busy) { pending = true; return; }
|
||||
busy = true; message = $t('Saving browser settings…');
|
||||
try {
|
||||
await act('settings', { search, adblock, linkDestination: internalLinks ? 'internal' : 'external', personalRules: rules,
|
||||
homepage, filterLists: filterLists.split(/\r?\n/).map(value => value.trim()).filter(Boolean) });
|
||||
} finally { busy = false; }
|
||||
if (pending) { pending = false; void save(); }
|
||||
}
|
||||
</script>
|
||||
<div class="settings">
|
||||
<h2>{$t("Browser")}</h2><p>{$t("Choose how you browse within RuneStone.")}</p>
|
||||
<h3>{$t("General")}</h3>
|
||||
<fieldset disabled={!ready} onchange={() => void save()}>
|
||||
<div class="card">
|
||||
<label class="row"><span>{$t("Open web links in RuneStone")}<small>{$t("Turn this off to use your system browser.")}</small></span><input class="rs-switch" type="checkbox" role="switch" aria-label={$t("Open web links in RuneStone")} bind:checked={internalLinks}></label>
|
||||
<label class="row"><span>{$t("Homepage")}<small>{$t("The page to open in each new browser tab. Leave blank for an empty page.")}</small></span><input class="address" type="url" aria-label={$t("Homepage")} placeholder="https://example.com" maxlength="8192" bind:value={homepage}></label>
|
||||
<div class="row"><span>{$t("Search engine")}</span><button type="button" class="picker" aria-label={$t("Search engine")} aria-haspopup="menu" onclick={event => picker(event)}>{engines.find(engine => engine.id === search)?.name ?? 'DuckDuckGo'}<Icon icon="chevron-down" /></button></div>
|
||||
<label class="row"><span>{$t("Block ads and trackers")}<small>{$t("Apply the filter lists and personal rules to all browser tabs.")}</small></span><input class="rs-switch" type="checkbox" role="switch" aria-label={$t("Block ads and trackers")} bind:checked={adblock}></label>
|
||||
<label class="row list-row"><span>{$t("Ad blocking lists")}<small>{$t("One HTTPS filter list URL per line, up to eight lists. New lists download when you leave the field.")}</small></span><textarea aria-label={$t("Ad blocking lists")} rows="4" maxlength="66000" placeholder="https://easylist.to/easylist/easylist.txt" bind:value={filterLists}></textarea></label>
|
||||
</div>
|
||||
<label class="rules">{$t("Personal filter rules")}<small>{$t("Use one rule per line. Block a domain with ||ads.example.com^, allow it with @@||ads.example.com^, or hide an element with example.com##.advertisement. Save to apply the rules.")}</small><textarea rows="4" maxlength="100000" placeholder={'! Block an advertising domain\n||ads.example.com^\n! Hide an element on one site\nexample.com##.advertisement'} bind:value={rules}></textarea></label>
|
||||
</fieldset>
|
||||
<h3>{$t("Profiles")}</h3><p>{$t("New profiles start blank. Duplicate a profile to copy its stored browsing data and bookmarks.")}</p>
|
||||
<div class="card profiles">
|
||||
<div class="profile-choice"><span>{$t("Profile")}</span><button type="button" class="picker" aria-label={$t("Profile")} aria-haspopup="menu" disabled={!ready} onclick={event => picker(event, true)}>{$browserState?.profiles.find(profile => profile.id === selected)?.name ?? $t('Profile')}<Icon icon="chevron-down" /></button></div>
|
||||
<label>{$t("New profile name")}<input bind:value={name} maxlength="60" placeholder={$t("Profile name")}></label>
|
||||
<div class="actions"><button onclick={() => void create(false)}><Icon icon="plus" />{$t("New blank profile")}</button><button onclick={() => void create(true)}><Icon icon="duplicate" />{$t("Duplicate profile")}</button></div>
|
||||
<p class="note">{$t("Duplication briefly restarts browser tabs. The copies remain separate. Agent permissions are not copied.")}</p>
|
||||
</div>
|
||||
<h3>{$t("Web data")}</h3><p>{$t("Clear data for the selected profile. Its browser tabs will close. Bookmarks remain.")}</p>
|
||||
<div class="actions"><button onclick={() => void act('clearData', { profileId: selected, kind: 'cache' })}>{$t("Clear cache")}</button><button onclick={() => void act('clearData', { profileId: selected, kind: 'cookies' })}>{$t("Clear cookies")}</button><button onclick={() => void act('clearData', { profileId: selected, kind: 'history' })}>{$t("Clear history")}</button></div>
|
||||
<p role="status">{message}</p>
|
||||
{#if ready}<WebData profileId={selected} />{/if}
|
||||
</div>
|
||||
<style>
|
||||
.settings{color:var(--rs-text);font-family:var(--rs-font-ui)}h2{margin:0;font-size:var(--rs-settings-heading-size);font-weight:500;color:var(--rs-text-strong)}h3{margin:var(--rs-settings-section-gap) 0 var(--rs-settings-gap);font-size:14px;font-weight:500}
|
||||
p{color:var(--rs-text-dim);font-size:var(--rs-settings-description-size);line-height:1.6}.card{padding:0 var(--rs-settings-row-padding);background:var(--rs-bg-elevated);border:1px solid var(--rs-border);border-radius:var(--rs-control-radius)}
|
||||
.row{display:flex;justify-content:space-between;align-items:center;gap:var(--rs-settings-gap);padding:var(--rs-settings-row-padding) 0}.row+.row{border-top:1px solid var(--rs-border)}
|
||||
input:not(.rs-switch),textarea,button{border:1px solid var(--rs-border);border-radius:var(--rs-control-radius);background:var(--rs-bg);color:var(--rs-text);font:inherit;box-sizing:border-box;min-height:var(--rs-settings-control-height);padding:4px 8px}
|
||||
button{display:inline-flex;align-items:center;gap:7px;background:var(--rs-bg-elevated);cursor:pointer}button:hover{background:var(--rs-bg-active)}button:focus-visible,input:focus-visible,textarea:focus-visible{outline:2px solid var(--rs-focus);outline-offset:1px}
|
||||
.picker{justify-content:space-between;min-width:140px;max-width:100%;overflow-wrap:anywhere;text-align:left}
|
||||
.rules{display:flex;flex-direction:column;gap:7px;margin:16px 0}.profiles{padding-top:16px;padding-bottom:8px}.profiles label,.profile-choice{display:flex;flex-direction:column;gap:7px;margin-bottom:14px}
|
||||
.actions{display:flex;flex-wrap:wrap;gap:8px}.note{margin-bottom:0}
|
||||
fieldset{border:0;margin:0;padding:0;min-width:0}small{display:block;color:var(--rs-text-dim);font-size:var(--rs-settings-description-size);line-height:1.5;margin-top:5px}
|
||||
.row>span{flex:1}.address,.list-row textarea{width:260px;max-width:48%;box-sizing:border-box}.list-row{align-items:flex-start}textarea{resize:vertical}␍
|
||||
@media(max-width:600px){.row{flex-wrap:wrap}.address,.list-row textarea{width:100%;max-width:100%}}
|
||||
</style>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { tr } from '../i18n/index.ts';
|
||||
import { revealLabel } from '../ui/menuItems.ts';
|
||||
import { actionIcon, type ActionIcon } from "../ui/actionIcons";
|
||||
import { attachTooltip } from "../ui/tooltip";
|
||||
const tooltipCleanups = new WeakMap<HTMLElement, () => void>();
|
||||
@@ -137,7 +138,7 @@ export function imageControls(root: HTMLElement, actions: ImageActions = {}, mea
|
||||
...(actions.edit ? [{ label: tr("Edit image source"), icon: "code" as const, run: () => void run(actions.edit!) }] : []),
|
||||
...(actions.open ? [{ label: tr("Open in new tab"), icon: "external" as const, run: () => void run(() => actions.open!(image)) }] : []),
|
||||
{ label: tr("Copy path"), icon: "link", run: () => void run(() => navigator.clipboard.writeText(image.dataset.mdSrc || "")) },
|
||||
...(actions.reveal && !/^https?:/i.test(image.dataset.mdSrc || "") ? [{ label: tr("Show in Explorer"), icon: "external" as const, run: () => void run(() => actions.reveal!(image)) }] : []),
|
||||
...(actions.reveal && !/^https?:/i.test(image.dataset.mdSrc || "") ? [{ label: tr(revealLabel()), icon: "folder" as const, run: () => void run(() => actions.reveal!(image)) }] : []),
|
||||
];
|
||||
openingMenu = true;
|
||||
try { menu = showActionMenu({ x, y, items, label: tr("Image actions") }, undefined, restore); }
|
||||
|
||||
@@ -136,7 +136,7 @@ export function tableSelectionControls(root: HTMLElement, wrapper: HTMLElement,
|
||||
{ label: tr("Add row below"), icon: "row-after", run: () => structural("row", "after") }, sep,
|
||||
{ label: tr("Move row up"), icon: "up", disabled: row <= 1, run: () => structural("row", "previous") },
|
||||
{ label: tr("Move row down"), icon: "down", disabled: row === 0 || row === lastRow, run: () => structural("row", "next") }, sep,
|
||||
{ label: tr("Duplicate row"), icon: "copy", run: () => structural("row", "duplicate") },
|
||||
{ label: tr("Duplicate row"), icon: "duplicate", run: () => structural("row", "duplicate") },
|
||||
{ label: tr("Delete row"), icon: "trash", run: () => structural("row", "delete") },
|
||||
] },
|
||||
{ label: tr("Column"), icon: "column", children: [
|
||||
@@ -145,7 +145,7 @@ export function tableSelectionControls(root: HTMLElement, wrapper: HTMLElement,
|
||||
{ label: tr("Move column left"), icon: "move-left", disabled: column === 0, run: () => structural("column", "previous") },
|
||||
{ label: tr("Move column right"), icon: "move-right", disabled: column === lastColumn, run: () => structural("column", "next") }, sep,
|
||||
...alignmentItems, sep,
|
||||
{ label: tr("Duplicate column"), icon: "copy", run: () => structural("column", "duplicate") },
|
||||
{ label: tr("Duplicate column"), icon: "duplicate", run: () => structural("column", "duplicate") },
|
||||
{ label: tr("Delete column"), icon: "trash", run: () => structural("column", "delete") },
|
||||
] }, sep,
|
||||
{ label: tr("Sort by column (A to Z)"), icon: "sort-asc", disabled: lastRow < 2, run: () => { range ??= cellRange; apply(text => sortTableColumn(text, column)); } },
|
||||
|
||||
@@ -1109,12 +1109,6 @@ export const messageRows: [string, string, string, string][] = [
|
||||
"システムのパス",
|
||||
"系统路径"
|
||||
],
|
||||
[
|
||||
"Show in system explorer",
|
||||
"Afficher dans l’explorateur système",
|
||||
"システムのエクスプローラーで表示",
|
||||
"在系统文件管理器中显示"
|
||||
],
|
||||
[
|
||||
"Blank note",
|
||||
"Note vide",
|
||||
@@ -1325,30 +1319,6 @@ export const messageRows: [string, string, string, string][] = [
|
||||
"ブックマークを削除",
|
||||
"删除书签"
|
||||
],
|
||||
[
|
||||
"Copy workspace paths",
|
||||
"Copier les chemins de travail",
|
||||
"ワークスペース内のパスをコピー",
|
||||
"复制工作区路径"
|
||||
],
|
||||
[
|
||||
"Copy workspace path",
|
||||
"Copier le chemin de travail",
|
||||
"ワークスペース内のパスをコピー",
|
||||
"复制工作区路径"
|
||||
],
|
||||
[
|
||||
"Copy system paths",
|
||||
"Copier les chemins système",
|
||||
"システムのパスをコピー",
|
||||
"复制系统路径"
|
||||
],
|
||||
[
|
||||
"Copy system path",
|
||||
"Copier le chemin système",
|
||||
"システムのパスをコピー",
|
||||
"复制系统路径"
|
||||
],
|
||||
[
|
||||
"Rename",
|
||||
"Renommer",
|
||||
@@ -1847,12 +1817,6 @@ export const messageRows: [string, string, string, string][] = [
|
||||
"広告ブロックリスト",
|
||||
"广告屏蔽列表"
|
||||
],
|
||||
[
|
||||
"One HTTPS filter list URL per line, up to eight lists. New lists download when you save.",
|
||||
"Une URL HTTPS par ligne, huit listes maximum. Les nouvelles listes sont téléchargées lors de l’enregistrement.",
|
||||
"1行に1つのHTTPSフィルターリストURLを入力します。最大8件。保存時に新しいリストをダウンロードします。",
|
||||
"每行一个 HTTPS 过滤列表网址,最多八个。保存时下载新列表。"
|
||||
],
|
||||
[
|
||||
"Personal filter rules",
|
||||
"Règles de filtrage personnelles",
|
||||
@@ -1949,18 +1913,6 @@ export const messageRows: [string, string, string, string][] = [
|
||||
"ブラウザー設定を保存中…",
|
||||
"正在保存浏览器设置…"
|
||||
],
|
||||
[
|
||||
"Saving…",
|
||||
"Enregistrement…",
|
||||
"保存中…",
|
||||
"正在保存…"
|
||||
],
|
||||
[
|
||||
"Save browser settings",
|
||||
"Enregistrer les paramètres du navigateur",
|
||||
"ブラウザー設定を保存",
|
||||
"保存浏览器设置"
|
||||
],
|
||||
[
|
||||
"Individual web data",
|
||||
"Données web individuelles",
|
||||
@@ -3466,6 +3418,12 @@ export const messageRows: [string, string, string, string][] = [
|
||||
["Resize the outline", "Redimensionner le plan", "アウトラインのサイズを変更", "调整大纲大小"],
|
||||
["Resize the terminal", "Redimensionner le terminal", "ターミナルのサイズを変更", "调整终端大小"],
|
||||
["Leave the text, then press Tab", "Quitter le texte, puis appuyer sur Tab", "テキストから出て、Tab キーを押す", "离开文本,然后按 Tab"],
|
||||
["One HTTPS filter list URL per line, up to eight lists. New lists download when you leave the field.", "Une URL HTTPS par ligne, huit listes maximum. Les nouvelles listes sont téléchargées quand vous quittez le champ.", "1行に1つのHTTPSフィルターリストURLを入力します。最大8件。欄から移動すると新しいリストをダウンロードします。", "每行一个 HTTPS 过滤列表网址,最多八个。离开此字段时下载新列表。"],
|
||||
["1 result", "1 résultat", "1 件の結果", "1 个结果"],
|
||||
["{count} results in {files} files", "{count} résultats dans {files} fichiers", "{files} 個のファイルに {count} 件の結果", "{files} 个文件中有 {count} 个结果"],
|
||||
["Remove bookmark: {name}", "Retirer le signet : {name}", "ブックマークを削除: {name}", "移除书签:{name}"],
|
||||
["Show in Finder", "Afficher dans le Finder", "Finder で表示", "在访达中显示"],
|
||||
["Show in file manager", "Afficher dans le gestionnaire de fichiers", "ファイルマネージャーで表示", "在文件管理器中显示"],
|
||||
];
|
||||
export const catalogs: Record<Exclude<Locale, 'en'>, Record<string, string>> = {
|
||||
fr: Object.fromEntries(messageRows.map(row => [row[0], row[1]])),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { t } from "$lib/i18n";
|
||||
import BrowserSlot from "$lib/plugins/BrowserSlot.svelte";
|
||||
import IconButton from "$lib/ui/IconButton.svelte";
|
||||
import type { WorkspaceSession } from "$lib/workspace/session.svelte";
|
||||
import type { TreeEntry } from "$lib/workspace/types";
|
||||
|
||||
@@ -11,6 +12,13 @@
|
||||
|
||||
let { session, onOpen }: Props = $props();
|
||||
const bookmarks = $derived(session.marks.current.bookmarks);
|
||||
let error = $state("");
|
||||
const parts = (rel: string) => ({ name: rel.split("/").pop() ?? rel, folder: rel.includes("/") ? rel.slice(0, rel.lastIndexOf("/")) : "" });
|
||||
|
||||
async function remove(rel: string) {
|
||||
try { await session.marks.update(marks => ({ ...marks, bookmarks: marks.bookmarks.filter(path => path !== rel) })); error = ""; }
|
||||
catch (reason) { error = String(reason); }
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="pane">
|
||||
@@ -21,22 +29,17 @@
|
||||
{:else}
|
||||
<ul>
|
||||
{#each bookmarks as rel (rel)}
|
||||
{@const item = parts(rel)}
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
onclick={() =>
|
||||
onOpen({
|
||||
name: rel.split("/").pop() ?? rel,
|
||||
rel_path: rel,
|
||||
kind: "file",
|
||||
})}
|
||||
>
|
||||
{rel}
|
||||
<button type="button" title={rel} onclick={() => onOpen({ name: item.name, rel_path: rel, kind: "file" })}>
|
||||
<span class="name">{item.name}</span>{#if item.folder}<span class="folder">{item.folder}</span>{/if}
|
||||
</button>
|
||||
<IconButton icon="close" label={$t("Remove bookmark: {name}", { name: item.name })} onclick={() => void remove(rel)} />
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
{#if error}<p class="error" role="alert">{error}</p>{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
@@ -69,18 +72,33 @@
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
button {
|
||||
width: 100%;
|
||||
li {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
padding-right: 6px;
|
||||
}
|
||||
|
||||
li > button {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
min-height: 24px;
|
||||
border-radius: var(--rs-control-radius);
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--rs-text);
|
||||
text-align: left;
|
||||
padding: 6px 10px;
|
||||
padding: 4px 10px;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
li > button:hover {
|
||||
background: var(--rs-bg-active);
|
||||
color: var(--rs-text-strong);
|
||||
}
|
||||
|
||||
.name, .folder { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.folder { color: var(--rs-text-dim); font-size: 12px; }
|
||||
.error { margin: 8px 10px; color: var(--rs-error); }
|
||||
</style>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
if (item.kind === "sep") return { separator: true };
|
||||
if (item.kind === "group") return { label: item.label, icon: item.icon, children: convert(item.items),
|
||||
...(item.run ? { run: () => { close(true); item.run?.(); } } : {}) };
|
||||
return { label: item.label, icon: item.icon, disabled: item.disabled, run: () => {
|
||||
return { label: item.label, icon: item.icon, disabled: item.disabled, danger: item.danger, run: () => {
|
||||
close(true);
|
||||
item.run();
|
||||
} };
|
||||
|
||||
+65
-101
@@ -35,6 +35,7 @@
|
||||
import type { MenuItem } from "./menuTypes";
|
||||
import TreeNode from "./TreeNode.svelte";
|
||||
import IconButton from "$lib/ui/IconButton.svelte";
|
||||
import { revealLabel } from "$lib/ui/menuItems";
|
||||
import { dropWorkspaceImage, highlightImageDrop } from "$lib/editor/workspaceImageDrop";
|
||||
import { pluginDocuments, pluginDocumentTypes, inspectPluginDocuments, createPluginDocument } from "$lib/plugins/external";
|
||||
|
||||
@@ -785,7 +786,7 @@
|
||||
...(templates.length || onManageTemplates ? [{ kind: "group" as const, label: $t("New note"), icon: "file-plus" as const, run: () => { void fromTemplate(); }, items: [
|
||||
{ kind: "action" as const, label: $t("Blank note"), icon: "file-plus" as const, run: () => { void fromTemplate(); } },
|
||||
...templates.map(template => ({ kind: "action" as const, label: template.name, icon: "file-plus" as const, run: () => { void fromTemplate(template); } })),
|
||||
...(onManageTemplates ? [{ kind: "sep" as const }, { kind: "action" as const, label: $t("Manage templates…"), icon: "copy" as const, run: onManageTemplates }] : []),
|
||||
...(onManageTemplates ? [{ kind: "sep" as const }, { kind: "action" as const, label: $t("Manage templates…"), icon: "template" as const, run: onManageTemplates }] : []),
|
||||
] }] : [{ kind: "action" as const, label: $t("New note"), icon: "file-plus" as const, run: () => { void fromTemplate(); } }]),
|
||||
{
|
||||
kind: "action",
|
||||
@@ -815,141 +816,104 @@
|
||||
];
|
||||
}
|
||||
|
||||
function folderActions(parent: string): MenuItem[] {
|
||||
// The file menu has one order: open, clipboard, organize, show and copy path, history, then Delete in the error color.
|
||||
function terminalItem(parent: string): MenuItem {
|
||||
return { kind: "action", label: $t("Open in terminal"), icon: "terminal", run: () => { void workspaceOpenTerminal(parent).catch(reason => error = String(reason)); } };
|
||||
}
|
||||
|
||||
function pasteItem(parent: string): MenuItem {
|
||||
return { kind: "action", label: $t("Paste"), icon: "paste", disabled: !clipboard || clipboard.root !== workspaceRoot || moving, run: () => { void pasteEntries(parent); } };
|
||||
}
|
||||
|
||||
function moveHistoryItems(): MenuItem[] {
|
||||
return [
|
||||
{ kind: "action", label: $t("Open in terminal"), icon: "terminal", run: () => { void workspaceOpenTerminal(parent).catch(reason => error = String(reason)); } },
|
||||
{ kind: "action", label: $t("Paste"), icon: "paste", disabled: !clipboard || clipboard.root !== workspaceRoot || moving, run: () => { void pasteEntries(parent); } },
|
||||
{ kind: "sep" },
|
||||
{ kind: "action", label: undoMoves.at(-1)?.action === "rename" ? $t("Undo rename") : $t("Undo file move"), icon: "undo", disabled: !undoMoves.length || moving, run: () => { void replayMoves(); } },
|
||||
{ kind: "action", label: redoMoves.at(-1)?.action === "rename" ? $t("Redo rename") : $t("Redo file move"), icon: "redo", disabled: !redoMoves.length || moving, run: () => { void replayMoves(true); } },
|
||||
];
|
||||
}
|
||||
|
||||
function revealItem(entries: TreeEntry[] | null): MenuItem {
|
||||
return {
|
||||
kind: "action",
|
||||
label: $t(revealLabel()),
|
||||
icon: "folder",
|
||||
run: () => {
|
||||
void (async () => {
|
||||
if (!entries) { await workspaceReveal("").catch((err) => { error = err instanceof Error ? err.message : String(err); }); return; }
|
||||
const result = await runTreeActions(entries, item => workspaceReveal(item.rel_path));
|
||||
error = result.failures.length ? result.failures.join("\n") : null;
|
||||
})();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function menuItems(entry: TreeEntry | null): MenuItem[] {
|
||||
if (!entry) {
|
||||
return [
|
||||
...paneMenuItems(""),
|
||||
{ kind: "sep" },
|
||||
...folderActions(""),
|
||||
terminalItem(""),
|
||||
{ kind: "sep" },
|
||||
{
|
||||
kind: "action",
|
||||
label: $t("Show in Explorer"),
|
||||
icon: "folder",
|
||||
run: () => {
|
||||
void workspaceReveal("").catch((err) => {
|
||||
error = err instanceof Error ? err.message : String(err);
|
||||
});
|
||||
},
|
||||
},
|
||||
pasteItem(""),
|
||||
{ kind: "sep" },
|
||||
revealItem(null),
|
||||
{ kind: "sep" },
|
||||
...moveHistoryItems(),
|
||||
];
|
||||
}
|
||||
const entries = actionEntries(entry, selection.paths, visiblePaths, findEntry);
|
||||
const multiple = entries.length > 1;
|
||||
const pinned = entries.every(item => pins.has(item.rel_path));
|
||||
const bookmarked = entries.every(item => bookmarks.has(item.rel_path));
|
||||
const createItems =
|
||||
!multiple && entry.kind === "folder"
|
||||
? [...paneMenuItems(entry.rel_path), { kind: "sep" as const }]
|
||||
: [];
|
||||
const parent = entry.kind === "folder" ? entry.rel_path : parentRel(entry.rel_path);
|
||||
const copySystemPaths = async () => {
|
||||
try {
|
||||
const paths = await Promise.all(entries.map(item => workspaceAbsPath(item.rel_path)));
|
||||
await copyText(paths.join("\n"), multiple ? $t("Copied system paths") : $t("Copied system path"));
|
||||
} catch (err) {
|
||||
error = err instanceof Error ? err.message : String(err);
|
||||
}
|
||||
};
|
||||
return [
|
||||
...createItems,
|
||||
...(!multiple && entry.kind === "file" && /\.md$/i.test(entry.name) && onSaveTemplate ? [
|
||||
{ kind: "action" as const, label: $t("Save as template"), icon: "copy" as const, run: () => onSaveTemplate?.(entry) },
|
||||
] : []),
|
||||
...(!multiple && entry.kind === "folder" ? [...paneMenuItems(entry.rel_path), { kind: "sep" as const }] : []),
|
||||
...(!multiple && entry.kind === "file" ? [
|
||||
{ kind: "action" as const, label: $t("Open in new tab"), icon: "file-plus" as const, run: () => onOpenFile(entry, true) },
|
||||
{ kind: "action" as const, label: $t("Open in new tab"), icon: "tab" as const, run: () => onOpenFile(entry, true) },
|
||||
{ kind: "action" as const, label: $t("Open in default app"), icon: "external" as const, run: () => { void workspaceOpenDefault(entry.rel_path).catch(reason => error = String(reason)); } },
|
||||
] : []),
|
||||
...folderActions(entry.kind === "folder" ? entry.rel_path : parentRel(entry.rel_path)),
|
||||
terminalItem(parent),
|
||||
{ kind: "sep" },
|
||||
{ kind: "action", label: $t("Cut"), icon: "cut", run: () => { clipboard = { root: workspaceRoot, paths: selectionRoots(entries).map(item => item.rel_path), cut: true }; } },
|
||||
{ kind: "action", label: $t("Copy"), icon: "copy", run: () => { clipboard = { root: workspaceRoot, paths: selectionRoots(entries).map(item => item.rel_path), cut: false }; } },
|
||||
{
|
||||
kind: "action",
|
||||
label: multiple ? $t("Make copies ({count})", { count: entries.length }) : $t("Make a copy"),
|
||||
icon: "copy",
|
||||
run: () => { void copyEntries(entries); },
|
||||
},
|
||||
pasteItem(parent),
|
||||
{ kind: "action", label: multiple ? $t("Make copies ({count})", { count: entries.length }) : $t("Make a copy"), icon: "duplicate", run: () => { void copyEntries(entries); } },
|
||||
{ kind: "sep" },
|
||||
{ kind: "action", label: $t("Rename"), icon: "rename", disabled: multiple, run: () => { startRename(entry); } },
|
||||
{
|
||||
kind: "action",
|
||||
label: bookmarked ? (multiple ? $t("Remove bookmarks") : $t("Remove bookmark")) : $t("Bookmark"),
|
||||
icon: "bookmark",
|
||||
run: () => {
|
||||
void persistMarks(current => ({
|
||||
...current,
|
||||
bookmarks: setSelectedMarks(current.bookmarks, entries, !bookmarked),
|
||||
}));
|
||||
},
|
||||
run: () => { void persistMarks(current => ({ ...current, bookmarks: setSelectedMarks(current.bookmarks, entries, !bookmarked) })); },
|
||||
},
|
||||
{ kind: "sep" },
|
||||
{
|
||||
kind: "action",
|
||||
label: multiple ? $t("Copy workspace paths") : $t("Copy workspace path"),
|
||||
icon: "copy",
|
||||
run: () => {
|
||||
void copyText(entries.map(item => item.rel_path).join("\n"), multiple ? $t("Copied workspace paths") : $t("Copied workspace path"));
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: "action",
|
||||
label: multiple ? $t("Copy system paths") : $t("Copy system path"),
|
||||
icon: "copy",
|
||||
run: () => {
|
||||
void (async () => {
|
||||
try {
|
||||
const paths = await Promise.all(entries.map(item => workspaceAbsPath(item.rel_path)));
|
||||
await copyText(paths.join("\n"), multiple ? $t("Copied system paths") : $t("Copied system path"));
|
||||
} catch (err) {
|
||||
error = err instanceof Error ? err.message : String(err);
|
||||
}
|
||||
})();
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: "action",
|
||||
label: $t("Show in Explorer"),
|
||||
icon: "folder",
|
||||
run: () => {
|
||||
void (async () => {
|
||||
const result = await runTreeActions(entries, item => workspaceReveal(item.rel_path));
|
||||
error = result.failures.length ? result.failures.join("\n") : null;
|
||||
})();
|
||||
},
|
||||
},
|
||||
{ kind: "sep" },
|
||||
{
|
||||
kind: "action",
|
||||
label: pinned ? $t("Unpin") : $t("Pin"),
|
||||
icon: "pin",
|
||||
run: () => {
|
||||
void persistMarks(current => ({
|
||||
...current,
|
||||
pins: setSelectedMarks(current.pins, entries, !pinned),
|
||||
}));
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: "action",
|
||||
label: $t("Rename"),
|
||||
icon: "rename",
|
||||
disabled: multiple,
|
||||
run: () => {
|
||||
startRename(entry);
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: "action",
|
||||
label: multiple ? $t("Delete ({count})", { count: entries.length }) : $t("Delete"),
|
||||
icon: "trash",
|
||||
run: () => { void deleteEntries(entries); },
|
||||
},
|
||||
{
|
||||
kind: "action",
|
||||
label: multiple ? $t("Delete permanently ({count})", { count: entries.length }) : $t("Delete permanently"),
|
||||
icon: "trash",
|
||||
run: () => { void deleteEntries(entries, true); },
|
||||
run: () => { void persistMarks(current => ({ ...current, pins: setSelectedMarks(current.pins, entries, !pinned) })); },
|
||||
},
|
||||
...(!multiple && entry.kind === "file" && /\.md$/i.test(entry.name) && onSaveTemplate ? [
|
||||
{ kind: "action" as const, label: $t("Save as template"), icon: "template" as const, run: () => onSaveTemplate?.(entry) },
|
||||
] : []),
|
||||
{ kind: "sep" },
|
||||
revealItem(entries),
|
||||
{ kind: "group", label: $t("Copy path"), icon: "copy", items: [
|
||||
{ kind: "action", label: $t("Workspace path"), icon: "copy", run: () => { void copyText(entries.map(item => item.rel_path).join("\n"), multiple ? $t("Copied workspace paths") : $t("Copied workspace path")); } },
|
||||
{ kind: "action", label: $t("System path"), icon: "copy", run: () => { void copySystemPaths(); } },
|
||||
] },
|
||||
{ kind: "sep" },
|
||||
...moveHistoryItems(),
|
||||
{ kind: "sep" },
|
||||
{ kind: "action", label: multiple ? $t("Delete ({count})", { count: entries.length }) : $t("Delete"), icon: "trash", danger: true, run: () => { void deleteEntries(entries); } },
|
||||
{ kind: "action", label: multiple ? $t("Delete permanently ({count})", { count: entries.length }) : $t("Delete permanently"), icon: "trash", danger: true, run: () => { void deleteEntries(entries, true); } },
|
||||
];
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -126,6 +126,7 @@
|
||||
background: transparent;
|
||||
color: var(--rs-text);
|
||||
text-align: left;
|
||||
min-height: 24px;
|
||||
padding: 3px 8px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
|
||||
@@ -12,8 +12,31 @@
|
||||
let { onOpen, searchRequest }: Props = $props();
|
||||
let query = $state("");
|
||||
let hits = $state<SearchHit[]>([]);
|
||||
let searched = $state("");
|
||||
let error = $state<string | null>(null);
|
||||
|
||||
// Hits in groups by file, in the order of the first hit of each file.
|
||||
const groups = $derived.by(() => {
|
||||
const files = new Map<string, SearchHit[]>();
|
||||
for (const hit of hits) files.set(hit.rel_path, [...files.get(hit.rel_path) ?? [], hit]);
|
||||
return [...files].map(([path, items]) => ({ path, name: path.split("/").pop() ?? path, folder: path.includes("/") ? path.slice(0, path.lastIndexOf("/")) : "", items }));
|
||||
});
|
||||
|
||||
/** The parts of a hit line, with the parts that match the query marked. */
|
||||
function parts(text: string, term: string) {
|
||||
const lower = text.toLowerCase(), needle = term.toLowerCase();
|
||||
if (!needle) return [{ text, match: false }];
|
||||
const result: { text: string; match: boolean }[] = [];
|
||||
let from = 0;
|
||||
for (let index = lower.indexOf(needle); index >= 0; index = lower.indexOf(needle, index + needle.length)) {
|
||||
if (index > from) result.push({ text: text.slice(from, index), match: false });
|
||||
result.push({ text: text.slice(index, index + needle.length), match: true });
|
||||
from = index + needle.length;
|
||||
}
|
||||
if (from < text.length) result.push({ text: text.slice(from), match: false });
|
||||
return result;
|
||||
}
|
||||
|
||||
let generation = 0;
|
||||
$effect(() => { if (searchRequest) { query = searchRequest.text; void run(searchRequest.text); } });
|
||||
|
||||
@@ -28,6 +51,7 @@
|
||||
const results = await workspaceSearch(q);
|
||||
if (version !== generation) return;
|
||||
hits = results;
|
||||
searched = q;
|
||||
error = null;
|
||||
} catch (err) {
|
||||
if (version !== generation) return;
|
||||
@@ -51,24 +75,23 @@
|
||||
{#if error}
|
||||
<p class="error">{error}</p>
|
||||
{/if}
|
||||
<ul>
|
||||
{#each hits as hit (hit.rel_path + hit.line + hit.text)}
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
onclick={() =>
|
||||
onOpen(
|
||||
{
|
||||
name: hit.rel_path.split("/").pop() ?? hit.rel_path,
|
||||
rel_path: hit.rel_path,
|
||||
kind: "file",
|
||||
},
|
||||
hit.line,
|
||||
)}
|
||||
>
|
||||
<span class="path">{hit.rel_path}:{hit.line}</span>
|
||||
<span class="text">{hit.text}</span>
|
||||
</button>
|
||||
{#if searched}
|
||||
<p class="summary" role="status">{hits.length === 1 ? $t("1 result") : $t("{count} results in {files} files", { count: hits.length, files: groups.length })}</p>
|
||||
{/if}
|
||||
<ul class="results">
|
||||
{#each groups as group (group.path)}
|
||||
<li class="file">
|
||||
<div class="file-name" title={group.path}><span class="name">{group.name}</span>{#if group.folder}<span class="folder">{group.folder}</span>{/if}<span class="count">{group.items.length}</span></div>
|
||||
<ul>
|
||||
{#each group.items as hit (hit.line + hit.text)}
|
||||
<li>
|
||||
<button type="button" onclick={() => onOpen({ name: group.name, rel_path: hit.rel_path, kind: "file" }, hit.line)}>
|
||||
<span class="line">{hit.line}</span>
|
||||
<span class="text">{#each parts(hit.text, searched) as part}{#if part.match}<mark>{part.text}</mark>{:else}{part.text}{/if}{/each}</span>
|
||||
</button>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
@@ -110,37 +133,75 @@
|
||||
ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.results {
|
||||
padding: 0 0 12px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.summary {
|
||||
margin: 0 10px 6px;
|
||||
color: var(--rs-text-dim);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.file + .file { margin-top: 6px; }
|
||||
|
||||
.file-name {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
padding: 4px 10px;
|
||||
}
|
||||
|
||||
.name { color: var(--rs-text-strong); font-weight: 600; white-space: nowrap; }
|
||||
.folder { min-width: 0; overflow: hidden; color: var(--rs-text-dim); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.count { margin-left: auto; padding: 0 6px; border-radius: 9px; background: var(--rs-bg-active); color: var(--rs-text); font-size: 11px; }
|
||||
|
||||
button {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
min-height: 24px;
|
||||
border-radius: var(--rs-control-radius);
|
||||
border: 0;
|
||||
background: transparent;
|
||||
text-align: left;
|
||||
padding: 6px 10px;
|
||||
padding: 3px 10px 3px 18px;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background: var(--rs-bg-active);
|
||||
}
|
||||
|
||||
.path {
|
||||
display: block;
|
||||
color: var(--rs-accent);
|
||||
font-size: 12px;
|
||||
.line {
|
||||
flex: 0 0 auto;
|
||||
min-width: 2ch;
|
||||
color: var(--rs-text-dim);
|
||||
font-size: 11px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.text {
|
||||
display: block;
|
||||
color: var(--rs-text-dim);
|
||||
min-width: 0;
|
||||
color: var(--rs-text);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* A match uses the search match fill of the theme, so the text keeps its contrast. */
|
||||
mark {
|
||||
border-radius: 2px;
|
||||
background: var(--rs-item-selection-bg);
|
||||
box-shadow: inset 0 -2px 0 var(--rs-accent);
|
||||
color: var(--rs-text-strong);
|
||||
}
|
||||
|
||||
.error {
|
||||
margin: 8px 10px;
|
||||
color: var(--rs-error);
|
||||
|
||||
@@ -70,9 +70,12 @@
|
||||
const selectedPlugin = $derived(pluginSections.find(item => item.id === selected?.id));
|
||||
|
||||
$effect(() => { seconds = settings.autosaveSeconds; });
|
||||
let searchInput: HTMLInputElement | undefined = $state();
|
||||
onMount(() => {
|
||||
const previous = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
||||
dialog.showModal();
|
||||
// The first focus goes to the settings search, not to the first window control.
|
||||
searchInput?.focus();
|
||||
return () => { dialog.close(); previous?.focus(); };
|
||||
});
|
||||
|
||||
@@ -117,7 +120,7 @@
|
||||
<div class="body">
|
||||
{#if !help}
|
||||
<aside>
|
||||
<label class="search"><Icon icon="search" /><input aria-label={$t("Search settings")} placeholder={$t("Search settings…")} bind:value={query} /></label>
|
||||
<label class="search"><Icon icon="search" /><input bind:this={searchInput} aria-label={$t("Search settings")} placeholder={$t("Search settings…")} bind:value={query} /></label>
|
||||
<p class="nav-heading">{$t("Preferences")}</p>
|
||||
<nav aria-label={$t("Settings categories")}>
|
||||
{#each matches as item}
|
||||
@@ -142,25 +145,25 @@
|
||||
<div class="card">
|
||||
<div class="setting-row">
|
||||
<div><label for="show-file-title">{$t("File name title")}</label><p id="file-title-description">{$t("Show the file name above each Markdown note in Write and Read.")}</p></div>
|
||||
<input id="show-file-title" class="switch" type="checkbox" role="switch" aria-describedby="file-title-description" checked={settings.showFileTitle} onchange={event => apply({ ...settings, showFileTitle: event.currentTarget.checked })} />
|
||||
<input id="show-file-title" class="rs-switch" type="checkbox" role="switch" aria-describedby="file-title-description" checked={settings.showFileTitle} onchange={event => apply({ ...settings, showFileTitle: event.currentTarget.checked })} />
|
||||
</div>
|
||||
</div>
|
||||
<h3>{$t("Tables")}</h3>
|
||||
<div class="card">
|
||||
<div class="setting-row">
|
||||
<div><label for="table-formulas">{$t("Table formulas")}</label><p id="table-formulas-description">{$t("Calculate table cells that start with =. When this is off, formulas show as text.")}</p></div>
|
||||
<input id="table-formulas" class="switch" type="checkbox" role="switch" aria-describedby="table-formulas-description" checked={settings.tableFormulas} onchange={event => apply({ ...settings, tableFormulas: event.currentTarget.checked })} />
|
||||
<input id="table-formulas" class="rs-switch" type="checkbox" role="switch" aria-describedby="table-formulas-description" checked={settings.tableFormulas} onchange={event => apply({ ...settings, tableFormulas: event.currentTarget.checked })} />
|
||||
</div>
|
||||
</div>
|
||||
<h3>{$t("Files")}</h3>
|
||||
<div class="card">
|
||||
<div class="setting-row">
|
||||
<div><label for="show-internal-folder">{$t("Show .runestone folder")}</label><p id="internal-folder-description">{$t("Show workspace settings and plugin data in the file tree.")}</p></div>
|
||||
<input id="show-internal-folder" class="switch" type="checkbox" role="switch" aria-describedby="internal-folder-description" checked={settings.showInternalFolder} onchange={event => apply({ ...settings, showInternalFolder: event.currentTarget.checked })} />
|
||||
<input id="show-internal-folder" class="rs-switch" type="checkbox" role="switch" aria-describedby="internal-folder-description" checked={settings.showInternalFolder} onchange={event => apply({ ...settings, showInternalFolder: event.currentTarget.checked })} />
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<div><label for="autosave-enabled">{$t("Auto-save")}</label><p id="autosave-description">{$t("Save changed notes and scripts, including background tabs.")}</p></div>
|
||||
<input id="autosave-enabled" class="switch" type="checkbox" role="switch" aria-describedby="autosave-description" checked={settings.autosaveEnabled} onchange={event => { apply({ ...settings, autosaveEnabled: event.currentTarget.checked }); event.currentTarget.checked = settings.autosaveEnabled; }} />
|
||||
<input id="autosave-enabled" class="rs-switch" type="checkbox" role="switch" aria-describedby="autosave-description" checked={settings.autosaveEnabled} onchange={event => { apply({ ...settings, autosaveEnabled: event.currentTarget.checked }); event.currentTarget.checked = settings.autosaveEnabled; }} />
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<div><label for="autosave-seconds">{$t("Auto-save interval")}</label><p id="interval-description">{$t("Time between saves, even while you type. Choose 1–300 seconds.")}</p></div>
|
||||
@@ -209,7 +212,7 @@
|
||||
aside { width: 220px; flex-shrink: 0; padding: 12px 8px; background: var(--rs-bg-elevated); border-right: 1px solid var(--rs-border); display: flex; flex-direction: column; overflow: auto; }
|
||||
.search { display: flex; gap: var(--rs-settings-gap); align-items: center; min-height: var(--rs-settings-control-height); background: var(--rs-bg-active); border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); padding: 4px 8px; color: var(--rs-text-dim); }
|
||||
.search:focus-within { outline: 2px solid var(--rs-focus); }
|
||||
.search input { width: 100%; min-width: 0; border: 0; padding: 0; outline: none; background: transparent; color: var(--rs-text); }
|
||||
.search input { align-self: stretch; width: 100%; min-width: 0; min-height: 24px; border: 0; padding: 0; outline: none; background: transparent; color: var(--rs-text); }
|
||||
.nav-heading { margin: 16px 8px 6px; font-size: 11px; color: var(--rs-text-dim); }
|
||||
nav { display: flex; flex-direction: column; gap: 2px; }
|
||||
nav button { display: flex; align-items: center; gap: var(--rs-settings-gap); width: 100%; min-height: var(--rs-settings-control-height); padding: 5px 8px; border: 0; border-radius: var(--rs-control-radius); background: transparent; text-align: left; }
|
||||
@@ -229,10 +232,6 @@
|
||||
.setting-row p { margin: 3px 0 0; font-size: var(--rs-settings-description-size); }
|
||||
.language-row { flex-wrap: wrap; }
|
||||
.language-picker { display:flex; align-items:center; gap:var(--rs-settings-gap); max-width:100%; }
|
||||
.switch { appearance: none; width: 38px; height: 22px; flex: 0 0 38px; margin: 0; border-radius: 20px; background: var(--rs-bg-active); border: 1px solid var(--rs-text-dim); cursor: pointer; }
|
||||
.switch::before { content: ""; display: block; width: 16px; height: 16px; margin: 2px; background: var(--rs-text); border-radius: 50%; transition: transform .12s; }
|
||||
.switch:checked { background: var(--rs-accent); border-color: var(--rs-accent); }
|
||||
.switch:checked::before { transform: translateX(16px); background: var(--rs-bg); }
|
||||
.interval { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; font-size: 11px; color: var(--rs-text-dim); }
|
||||
.interval input { width: 72px; min-height: var(--rs-settings-control-height); padding: 4px 6px; border: 1px solid var(--rs-border); border-radius: var(--rs-control-radius); background: var(--rs-bg); color: var(--rs-text); font-size: 13px; }
|
||||
.interval input:disabled { color: var(--rs-text-dim); }
|
||||
|
||||
@@ -497,10 +497,10 @@
|
||||
border-radius: var(--rs-control-radius);
|
||||
background: transparent;
|
||||
color: var(--rs-text-dim);
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
margin-right: 4px;
|
||||
flex: 0 0 22px;
|
||||
flex: 0 0 24px;
|
||||
}
|
||||
|
||||
.close:hover {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import { renameSelection } from "$lib/workspace/renamePath";
|
||||
import TreeNode from "./TreeNode.svelte";
|
||||
import Icon from "$lib/ui/Icon.svelte";
|
||||
import { actionIcons } from "$lib/ui/actionIcons";
|
||||
import { pluginDocuments } from "$lib/plugins/external";
|
||||
|
||||
type Props = {
|
||||
@@ -134,7 +135,8 @@
|
||||
{#if edges?.bottom != null && edges.bottom > 0}<span class="selection-step bottom"></span>{/if}
|
||||
</span>
|
||||
{/if}
|
||||
<span class="twist" class:open={isOpen} class:folder={entry.kind === "folder"}></span>
|
||||
<!-- Folders use the shared chevron, as headings and menus do. -->
|
||||
<span class="twist" class:open={isOpen} class:folder={entry.kind === "folder"}>{#if entry.kind === "folder"}<svg viewBox="0 0 24 24" aria-hidden="true">{@html actionIcons.chevron}</svg>{/if}</span>
|
||||
{#if $pluginDocuments[entry.rel_path]}
|
||||
<span class="document-icon" title={$pluginDocuments[entry.rel_path].title}><Icon icon={$pluginDocuments[entry.rel_path].icon === "kanban" ? "kanban" : "files"} /></span>
|
||||
{/if}
|
||||
@@ -316,18 +318,21 @@
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.twist.folder::before {
|
||||
content: "";
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-style: solid;
|
||||
border-width: 5px 0 5px 8px;
|
||||
border-color: transparent transparent transparent currentColor;
|
||||
transform: rotate(0deg);
|
||||
.twist svg {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
fill: none;
|
||||
stroke: currentColor;
|
||||
stroke-width: 2;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
transition: transform .12s;
|
||||
}
|
||||
|
||||
.twist.folder.open::before {
|
||||
transform: rotate(90deg);
|
||||
.twist.open svg { transform: rotate(90deg); }
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.twist svg { transition: none; }
|
||||
}
|
||||
|
||||
.name {
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
import { tabsToClose, type TabCloseScope } from "$lib/workspace/tabActions";
|
||||
import { orderWorkbenchTabs, type WorkbenchTab } from "$lib/workspace/workbenchTabs";
|
||||
import { actionMenu, type ActionMenuItem } from "$lib/ui/actionMenu";
|
||||
import { revealLabel } from "$lib/ui/menuItems";
|
||||
import { createNote, noteTemplates, saveNoteTemplate, type NoteTemplate } from "$lib/workspace/templates";
|
||||
import { requestText } from "$lib/workspace/dialogs.svelte";
|
||||
import TextDialog from "./TextDialog.svelte";
|
||||
@@ -678,7 +679,7 @@
|
||||
const items: ActionMenuItem[] = [];
|
||||
if (tab.kind === "text" && isMarkdownPath(tab.relPath)) {
|
||||
items.push(
|
||||
{ label: $t("Save as template"), icon: "copy", run: () => { void saveTemplate({ name: tab.name, rel_path: tab.relPath, kind: "file" }); } },
|
||||
{ label: $t("Save as template"), icon: "template", run: () => { void saveTemplate({ name: tab.name, rel_path: tab.relPath, kind: "file" }); } },
|
||||
{ label: $t("View"), icon: "book", children: [
|
||||
{ label: $t("Write"), icon: "paragraph", radio: true, checked: viewMode === "write", run: () => setDocumentView(documentPanes.active, "write") },
|
||||
{ label: $t("Source"), icon: "code", radio: true, checked: viewMode === "source", run: () => setDocumentView(documentPanes.active, "source") },
|
||||
@@ -691,13 +692,13 @@
|
||||
items.push({ separator: true },
|
||||
{ label: $t("Rename…"), icon: "rename", run: () => { void renameActive(); } },
|
||||
);
|
||||
if (tab.kind === "text") items.push({ label: $t("Save a copy…"), icon: "copy", run: () => { void saveCopy(); } });
|
||||
if (tab.kind === "text") items.push({ label: $t("Save a copy…"), icon: "duplicate", run: () => { void saveCopy(); } });
|
||||
items.push({ separator: true },
|
||||
{ label: $t("Copy path"), icon: "copy", children: [
|
||||
{ label: $t("Workspace path"), icon: "copy", run: () => { void copyTabPath(tab.relPath, false); } },
|
||||
{ label: $t("System path"), icon: "copy", run: () => { void copyTabPath(tab.relPath, true); } },
|
||||
] },
|
||||
{ label: $t("Show in system explorer"), icon: "folder", run: () => { void workspaceReveal(tab.relPath).catch(err => { error = String(err); }); } },
|
||||
{ label: $t(revealLabel()), icon: "folder", run: () => { void workspaceReveal(tab.relPath).catch(err => { error = String(err); }); } },
|
||||
);
|
||||
return items;
|
||||
}
|
||||
@@ -1041,7 +1042,7 @@
|
||||
if (valid()) status = $t("Bookmarked {name}", { name: file.name });
|
||||
}) },
|
||||
{ label: $t("Open in default app"), icon: "external", run: run(file => workspaceOpenDefault(file.rel_path)) },
|
||||
{ label: $t("Show in system explorer"), icon: "folder", run: run(file => workspaceReveal(file.rel_path)) },
|
||||
{ label: $t(revealLabel()), icon: "folder", run: run(file => workspaceReveal(file.rel_path)) },
|
||||
{ label: $t("Reveal file in navigation"), icon: "folder", run: run(async file => { closePluginSidebar(); leftView = "files"; leftOpen = true; await tick(); await fileTree?.revealPath(file.rel_path); }) },
|
||||
];
|
||||
}
|
||||
@@ -1132,9 +1133,34 @@
|
||||
} catch { error = $t("Could not read your layout. Default layout applies for this window."); }
|
||||
});
|
||||
|
||||
// Side panes give way when the window becomes narrow: the outline below 1100 pixels, and the side pane below 800 pixels.
|
||||
// They come back when the window grows again. A pane that the user opens in a narrow window stays open.
|
||||
// At startup the saved layout applies as it is.
|
||||
let windowWidth = $state(window.innerWidth);
|
||||
let measured = false;
|
||||
const narrow = { left: false, right: false };
|
||||
const wide = { left: true, right: true };
|
||||
$effect(() => {
|
||||
if (!layoutReady || transferredWindow) return;
|
||||
try { saveWorkbenchLayout(localStorage, { leftOpen, rightOpen, leftWidth, rightWidth, leftView }); }
|
||||
const left = windowWidth < 800, right = windowWidth < 1100;
|
||||
untrack(() => {
|
||||
if (!measured) { measured = true; Object.assign(narrow, { left, right }); Object.assign(wide, { left: leftOpen, right: rightOpen }); return; }
|
||||
if (right !== narrow.right) {
|
||||
if (right) { wide.right = rightOpen; rightOpen = false; } else rightOpen = wide.right;
|
||||
narrow.right = right;
|
||||
}
|
||||
if (left !== narrow.left) {
|
||||
if (left) { wide.left = leftOpen; leftOpen = false; } else leftOpen = wide.left;
|
||||
narrow.left = left;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// The saved layout keeps the choice of a wide window.
|
||||
$effect(() => {
|
||||
if (!layoutReady || transferredWindow) return;
|
||||
const saved = { leftOpen: narrow.left ? wide.left : leftOpen, rightOpen: narrow.right ? wide.right : rightOpen };
|
||||
try { saveWorkbenchLayout(localStorage, { ...saved, leftWidth, rightWidth, leftView }); }
|
||||
catch { error = $t("Could not save your layout. Layout changes apply for this window only."); }
|
||||
});
|
||||
|
||||
@@ -1209,7 +1235,7 @@
|
||||
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={onKeydown} onbeforeunload={(event) => { if (hasDirty) { event.preventDefault(); event.returnValue = ""; } }} />
|
||||
<svelte:window bind:innerWidth={windowWidth} onkeydown={onKeydown} onbeforeunload={(event) => { if (hasDirty) { event.preventDefault(); event.returnValue = ""; } }} />
|
||||
<TextDialog />
|
||||
<WorkspacePicker bind:this={workspacePicker} currentRoot={workspace?.root} anchor={workspaceAnchor} onOpen={openPath} />
|
||||
{#if preferences}<SettingsDialog {settings} help={preferences === "help"} onSave={updateSettings} onClose={() => preferences = null} />{/if}
|
||||
|
||||
@@ -6,6 +6,8 @@ export type MenuAction = {
|
||||
run: () => void;
|
||||
disabled?: boolean;
|
||||
icon?: ActionIcon;
|
||||
/** The action removes data. The menu shows it in the error color. */
|
||||
danger?: boolean;
|
||||
};
|
||||
|
||||
export type MenuSep = { kind: "sep" };
|
||||
|
||||
@@ -133,7 +133,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<input id={`external-${plugin.manifest.id}`} type="checkbox" role="switch" checked={builtInPackages.includes(plugin.manifest.id) || plugin.enabled} disabled={busy || plugin.removal || builtInPackages.includes(plugin.manifest.id)} onchange={event => { const value = event.currentTarget.checked; event.currentTarget.checked = plugin.enabled; void toggle(plugin.manifest.id, value, plugin.hash); }} />
|
||||
<input id={`external-${plugin.manifest.id}`} class="rs-switch" type="checkbox" role="switch" checked={builtInPackages.includes(plugin.manifest.id) || plugin.enabled} disabled={busy || plugin.removal || builtInPackages.includes(plugin.manifest.id)} onchange={event => { const value = event.currentTarget.checked; event.currentTarget.checked = plugin.enabled; void toggle(plugin.manifest.id, value, plugin.hash); }} />
|
||||
<IconButton icon="folder-open" label={$t("Show files")} disabled={busy || plugin.removal} onclick={() => reveal(plugin.manifest.id)} />
|
||||
{#if plugin.removal}
|
||||
<button disabled={busy} onclick={() => run(async () => { await invoke("plugins_retry_remove", { id: plugin.manifest.id }); await refreshPlugins(); message = $t("Plugin file cleanup completed."); })}><Icon icon="refresh" />{$t("Retry cleanup")}</button>
|
||||
|
||||
@@ -128,7 +128,7 @@
|
||||
{#if notice}<p>{$t(notice)}</p>{/if}
|
||||
<h3>{$t("Transparency")}</h3>
|
||||
<div class="card">
|
||||
<label><span>{$t("Transparent surfaces")}</span><input type="checkbox" role="switch" checked={appearance.transparency?.enabled !== false} onchange={event => change({ ...appearance, transparency: { amount: appearance.transparency?.amount ?? 18, enabled: event.currentTarget.checked } })} /></label>
|
||||
<label><span>{$t("Transparent surfaces")}</span><input class="rs-switch" type="checkbox" role="switch" checked={appearance.transparency?.enabled !== false} onchange={event => change({ ...appearance, transparency: { amount: appearance.transparency?.amount ?? 18, enabled: event.currentTarget.checked } })} /></label>
|
||||
<div class="setting-row"><label for="surface-transparency">{$t("Transparency amount")}</label><div class="overlay-controls"><input id="surface-transparency" type="range" min="0" max="100" step="1" disabled={appearance.transparency?.enabled === false} value={appearance.transparency?.amount ?? 18} oninput={event => change({ ...appearance, transparency: { enabled: true, amount: event.currentTarget.valueAsNumber } })} /><output for="surface-transparency">{appearance.transparency?.amount ?? 18}%</output></div></div>
|
||||
</div>
|
||||
<p>{$t("Turn off transparency to use opaque surfaces and reduce compositing work. Text and icons remain opaque.")}</p>
|
||||
|
||||
@@ -113,7 +113,7 @@
|
||||
<div class="actions">
|
||||
<button class="primary" disabled={!dirty && draft.id !== null} onclick={() => void save()}><Icon icon="save" />{$t('Save')}</button>
|
||||
<button disabled={!dirty} onclick={discard}><Icon icon="undo" />{$t('Discard')}</button>
|
||||
<button onclick={() => void duplicate()}><Icon icon="copy" />{$t('Duplicate')}</button>
|
||||
<button onclick={() => void duplicate()}><Icon icon="duplicate" />{$t('Duplicate')}</button>
|
||||
</div>
|
||||
</header>
|
||||
<p class="note">
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
<path d="M4 12h16m-6-6 6 6-6 6" />
|
||||
{:else if icon === "copy"}
|
||||
<rect x="8" y="8" width="12" height="12" rx="2" /><path d="M16 8V4H4v12h4" />
|
||||
{:else if icon === "duplicate"}
|
||||
<rect x="8" y="8" width="12" height="12" rx="2" /><path d="M16 8V4H4v12h4M14 11v6M11 14h6" />
|
||||
{:else if icon === "stop"}
|
||||
<rect x="5" y="5" width="14" height="14" rx="2" />
|
||||
{:else if icon === "help"}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
| "arrow-left"
|
||||
| "arrow-right"
|
||||
| "copy"
|
||||
| "duplicate"
|
||||
| "stop"
|
||||
| "settings"
|
||||
| "sun"
|
||||
|
||||
@@ -7,7 +7,7 @@ function checkMark() {
|
||||
return svg;
|
||||
}
|
||||
|
||||
export type ActionMenuItem = { label: string; icon?: ActionIcon; shortcut?: string; run?: () => void; children?: ActionMenuItem[]; disabled?: boolean; checked?: boolean; radio?: boolean; title?: string } | { separator: true };
|
||||
export type ActionMenuItem = { label: string; icon?: ActionIcon; shortcut?: string; run?: () => void; children?: ActionMenuItem[]; disabled?: boolean; checked?: boolean; radio?: boolean; title?: string; danger?: boolean } | { separator: true };
|
||||
|
||||
export function actionMenu(x: number, y: number, items: ActionMenuItem[], onClose: () => void, label = "Table actions", parent: HTMLElement = document.body) {
|
||||
const root = document.createElement("div"); root.className = "rs-menu table-cell-menu"; root.setAttribute("role", "menu"); root.setAttribute("aria-label", label);
|
||||
@@ -46,6 +46,7 @@ export function actionMenu(x: number, y: number, items: ActionMenuItem[], onClos
|
||||
const button = document.createElement("button"); button.type = "button"; button.setAttribute("role", "menuitem"); button.disabled = !!item.disabled;
|
||||
if (item.checked !== undefined) { button.setAttribute("role", item.radio ? "menuitemradio" : "menuitemcheckbox"); button.setAttribute("aria-checked", String(item.checked)); }
|
||||
if (item.title) button.title = item.title;
|
||||
if (item.danger) button.classList.add("danger");
|
||||
const label = document.createElement("span"); label.className = "action-label"; label.textContent = item.label;
|
||||
const icon = item.radio ? (item.checked ? checkMark() : document.createElement("span"))
|
||||
: item.checked ? actionIcon("task") : item.icon ? actionIcon(item.icon) : document.createElement("span");
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
/* Disabled rows stay readable: dim text at full opacity. */
|
||||
.rs-menu > button:disabled, .rs-picker .rs-picker-row:disabled { color: var(--rs-text-dim); cursor: default; }
|
||||
.rs-menu.rs-menu-text > button > .action-icon { display: none; }
|
||||
/* An action that removes data, such as Delete, uses the error color. */
|
||||
.rs-menu > button.danger:not(:disabled) { color: var(--rs-error); }
|
||||
/* Hover gets only the quiet fill. The current radio row shows a check mark, not a fill. */
|
||||
.rs-menu > button:not(:disabled):is(:hover, :focus-visible, [aria-expanded="true"]),
|
||||
.rs-picker .rs-picker-row:not(:disabled):is(:hover, :focus-visible, :focus-within, [aria-selected="true"], [aria-current="true"]) {
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
import { tr } from "../i18n/index.ts";
|
||||
import { keys } from "./shortcuts.ts";
|
||||
import { message, tr } from "../i18n/index.ts";
|
||||
import { isMac, keys } from "./shortcuts.ts";
|
||||
import type { ActionMenuItem } from "./actionMenu.ts";
|
||||
|
||||
// The common text actions of the editor and reading menus. Each menu supplies only its commands.
|
||||
|
||||
/** The one label of the action that shows a file in the file manager of the platform. Translate it with `$t` or `tr`. */
|
||||
export function revealLabel(): string {
|
||||
if (isMac()) return message("Show in Finder");
|
||||
return typeof navigator !== "undefined" && /Windows/.test(navigator.userAgent) ? message("Show in Explorer") : message("Show in file manager");
|
||||
}
|
||||
|
||||
/** Undo and Redo, then a separator. */
|
||||
export function historyItems(history: { canUndo: boolean; canRedo: boolean; undo(): void; redo(): void }): ActionMenuItem[] {
|
||||
return [
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/* The one switch design for boolean settings: <input type="checkbox" role="switch" class="rs-switch">. */
|
||||
.rs-switch {
|
||||
appearance: none;
|
||||
position: relative;
|
||||
flex: 0 0 40px;
|
||||
width: 40px;
|
||||
height: 24px;
|
||||
margin: 0;
|
||||
border: 1px solid var(--rs-text-dim);
|
||||
border-radius: 12px;
|
||||
background: var(--rs-bg-active);
|
||||
cursor: pointer;
|
||||
transition: background .12s, border-color .12s;
|
||||
}
|
||||
|
||||
.rs-switch::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
left: 3px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border-radius: 50%;
|
||||
background: var(--rs-text);
|
||||
transition: transform .12s;
|
||||
}
|
||||
|
||||
.rs-switch:checked { background: var(--rs-accent); border-color: var(--rs-accent); }
|
||||
.rs-switch:checked::before { transform: translateX(16px); background: var(--rs-on-accent); }
|
||||
/* A disabled switch keeps full opacity. Its border and knob are dim. */
|
||||
.rs-switch:disabled { cursor: default; border-color: var(--rs-border); }
|
||||
.rs-switch:disabled::before { background: var(--rs-text-dim); }
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.rs-switch, .rs-switch::before { transition: none; }
|
||||
}
|
||||
Reference in New Issue
Block a user