Refactor & handle node lifecycle
This commit is contained in:
@@ -3,6 +3,8 @@ import ComboWidget from "$lib/widgets/ComboWidget.svelte";
|
||||
import RangeWidget from "$lib/widgets/RangeWidget.svelte";
|
||||
import TextWidget from "$lib/widgets/TextWidget.svelte";
|
||||
import { type WidgetUIState } from "$lib/stores/nodeState";
|
||||
import { get } from "svelte/store"
|
||||
import layoutState from "$lib/stores/layoutState"
|
||||
|
||||
export function download(filename: string, text: string, type: string = "text/plain") {
|
||||
const blob = new Blob([text], { type: type });
|
||||
@@ -39,3 +41,32 @@ export function getComponentForWidgetState(item: WidgetUIState): any {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export function startDrag(evt: MouseEvent) {
|
||||
const dragItemId: string = evt.target.dataset["dragItemId"];
|
||||
const ls = get(layoutState)
|
||||
|
||||
if (evt.button !== 0) {
|
||||
if (ls.currentSelection.length <= 1 && !ls.isMenuOpen)
|
||||
ls.currentSelection = [dragItemId]
|
||||
return;
|
||||
}
|
||||
|
||||
const item = ls.allItems[dragItemId].dragItem
|
||||
|
||||
if (evt.ctrlKey) {
|
||||
const index = ls.currentSelection.indexOf(item.id)
|
||||
if (index === -1)
|
||||
ls.currentSelection.push(item.id);
|
||||
else
|
||||
ls.currentSelection.splice(index, 1);
|
||||
ls.currentSelection = ls.currentSelection;
|
||||
}
|
||||
else {
|
||||
ls.currentSelection = [item.id]
|
||||
}
|
||||
layoutState.set(ls)
|
||||
};
|
||||
|
||||
export function stopDrag(evt: MouseEvent) {
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user