This commit is contained in:
vcoppe
2025-10-26 12:12:23 +01:00
parent 17e5347d55
commit 722cf58486
12 changed files with 401 additions and 385 deletions

View File

@@ -2,15 +2,15 @@
import { ScrollArea } from '$lib/components/ui/scroll-area/index';
import * as ContextMenu from '$lib/components/ui/context-menu';
import FileListNode from './FileListNode.svelte';
import { setContext } from 'svelte';
import { ListFileItem, ListLevel, ListRootItem, allowedPastes } from './file-list';
import { onMount, setContext } from 'svelte';
import { ListFileItem, ListLevel, ListRootItem } from './file-list';
import { ClipboardPaste, FileStack, Plus } from '@lucide/svelte';
import Shortcut from '$lib/components/Shortcut.svelte';
import { i18n } from '$lib/i18n.svelte';
import { settings } from '$lib/logic/settings';
import { fileStateCollection } from '$lib/logic/file-state';
import { createFile, pasteSelection } from '$lib/logic/file-actions';
import { selection, copied } from '$lib/logic/selection';
import { allowedPastes } from './sortable-file-list';
let {
orientation,
@@ -27,30 +27,28 @@
setContext('orientation', orientation);
setContext('recursive', recursive);
const { treeFileView } = settings;
// treeFileView.subscribe(($vertical) => {
// if ($vertical) {
// selection.update(($selection) => {
// $selection.forEach((item) => {
// if ($selection.hasAnyChildren(item, false)) {
// $selection.toggle(item);
// }
// });
// return $selection;
// });
// } else {
// selection.update(($selection) => {
// $selection.forEach((item) => {
// if (!(item instanceof ListFileItem)) {
// $selection.toggle(item);
// $selection.set(new ListFileItem(item.getFileId()), true);
// }
// });
// return $selection;
// });
// }
// });
onMount(() => {
if (orientation === 'vertical') {
selection.update(($selection) => {
$selection.forEach((item) => {
if ($selection.hasAnyChildren(item, false)) {
$selection.toggle(item);
}
});
return $selection;
});
} else {
selection.update(($selection) => {
$selection.forEach((item) => {
if (!(item instanceof ListFileItem)) {
$selection.toggle(item);
$selection.set(new ListFileItem(item.getFileId()), true);
}
});
return $selection;
});
}
});
</script>
<ScrollArea
@@ -71,7 +69,7 @@
<ContextMenu.Trigger class="grow" />
<ContextMenu.Content>
<ContextMenu.Item onclick={createFile}>
<Plus size="16" class="mr-1" />
<Plus size="16" />
{i18n._('menu.new_file')}
<Shortcut key="+" ctrl={true} />
</ContextMenu.Item>
@@ -80,7 +78,7 @@
onclick={() => selection.selectAll()}
disabled={$fileStateCollection.size === 0}
>
<FileStack size="16" class="mr-1" />
<FileStack size="16" />
{i18n._('menu.select_all')}
<Shortcut key="A" ctrl={true} />
</ContextMenu.Item>
@@ -91,7 +89,7 @@
!allowedPastes[$copied[0].level].includes(ListLevel.ROOT)}
onclick={pasteSelection}
>
<ClipboardPaste size="16" class="mr-1" />
<ClipboardPaste size="16" />
{i18n._('menu.paste')}
<Shortcut key="V" ctrl={true} />
</ContextMenu.Item>