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:
+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>
|
||||
|
||||
Reference in New Issue
Block a user