Skip to content

Commit 1460fe0

Browse files
committed
v0.4.0
1 parent d318972 commit 1460fe0

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

packages/svelte-file-tree/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# svelte-file-tree
22

3+
## 0.4.0
4+
5+
### Minor Changes
6+
7+
- breaking: Tree.copyToClipboard() and Tree.remove() methods now receive an itemId parameter instead of an item.
8+
- breaking: TreeClipboard.ids is now a SvelteSet instead of a Set.
9+
310
## 0.3.0
411

512
### Minor Changes

packages/svelte-file-tree/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "svelte-file-tree",
3-
"version": "0.3.0",
3+
"version": "0.4.0",
44
"type": "module",
55
"scripts": {
66
"dev": "svelte-kit sync && svelte-package --watch",

packages/svelte-file-tree/src/lib/components/Tree.svelte

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,9 @@
234234
}
235235
}
236236
237-
export function copyToClipboard(item: TreeItemState<TFile, TFolder>, operation: PasteOperation) {
238-
const clipboardIds = new Set(selectedIds);
239-
clipboardIds.add(item.node.id);
237+
export function copyToClipboard(itemId: string, operation: PasteOperation) {
238+
const clipboardIds = new SvelteSet(selectedIds);
239+
clipboardIds.add(itemId);
240240
clipboard = {
241241
ids: clipboardIds,
242242
operation,
@@ -462,7 +462,7 @@
462462
}
463463
}
464464
465-
export async function remove(item: TreeItemState<TFile, TFolder>) {
465+
async function _remove(item: TreeItemState<TFile, TFolder>) {
466466
const removed: Array<TreeItemState<TFile, TFolder>> = [];
467467
const removedOwners = new Set<TFolder>();
468468
for (const id of selectedIds) {
@@ -544,6 +544,14 @@
544544
return true;
545545
}
546546
547+
export async function remove(itemId: string) {
548+
const item = getItem(itemId);
549+
if (item === undefined) {
550+
return false;
551+
}
552+
return await _remove(item);
553+
}
554+
547555
function getDropDestinationItem(item: TreeItemState<TFile, TFolder>) {
548556
switch (item.node.type) {
549557
case "file": {
@@ -764,7 +772,7 @@
764772
break;
765773
}
766774
case "Delete": {
767-
remove(item);
775+
_remove(item);
768776
break;
769777
}
770778
case "a": {
@@ -780,15 +788,15 @@
780788
break;
781789
}
782790
783-
copyToClipboard(item, "copy");
791+
copyToClipboard(item.node.id, "copy");
784792
break;
785793
}
786794
case "x": {
787795
if (!isControlOrMeta(event)) {
788796
break;
789797
}
790798
791-
copyToClipboard(item, "cut");
799+
copyToClipboard(item.node.id, "cut");
792800
break;
793801
}
794802
case "v": {
@@ -881,7 +889,7 @@
881889
882890
const source = args.source;
883891
const sourceId = source.data.id;
884-
if (typeof sourceId !== "string") {
892+
if (typeof sourceId !== "string" || !lookup.has(sourceId)) {
885893
return false;
886894
}
887895

packages/svelte-file-tree/src/lib/tree.svelte.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export type PasteOperation = "copy" | "cut";
5959

6060
export type TreeClipboard = {
6161
operation: PasteOperation;
62-
ids: Set<string>;
62+
ids: SvelteSet<string>;
6363
};
6464

6565
export type TreeItemStateProps<

0 commit comments

Comments
 (0)