duplicate any selection

This commit is contained in:
vcoppe
2024-05-23 14:44:07 +02:00
parent 8b5d1f1fbf
commit 6cbf9a3248
7 changed files with 153 additions and 40 deletions

View File

@@ -1,17 +1,21 @@
import { get, writable } from "svelte/store";
import { ListFileItem, ListRootItem, SelectionTreeType } from "./FileList";
import { ListFileItem, ListItem, ListRootItem, SelectionTreeType } from "./FileList";
import { fileObservers } from "$lib/db";
export const selection = writable<SelectionTreeType>(new SelectionTreeType(new ListRootItem()));
export function select(fileId: string) {
export function selectItem(item: ListItem) {
selection.update(($selection) => {
$selection.clear();
$selection.set(new ListFileItem(fileId), true);
$selection.set(item, true);
return $selection;
});
}
export function selectFile(fileId: string) {
selectItem(new ListFileItem(fileId));
}
export function addSelect(fileId: string) {
selection.update(($selection) => {
$selection.toggle(new ListFileItem(fileId));