fixed some more stuff
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
|
||||
import '@xyflow/svelte/dist/style.css';
|
||||
|
||||
const nodes = writable([
|
||||
const nodes = writable<Node[]>([
|
||||
{
|
||||
id: '1',
|
||||
type: 'input',
|
||||
@@ -63,6 +63,7 @@
|
||||
};
|
||||
|
||||
const onDrop = (event: DragEvent) => {
|
||||
console.log(event);
|
||||
event.preventDefault();
|
||||
|
||||
if (!event.dataTransfer) {
|
||||
@@ -81,7 +82,8 @@
|
||||
data: { label: `${type} node` }
|
||||
};
|
||||
|
||||
nodes.update((nds) => nds.concat(newNode));
|
||||
$nodes.push(newNode);
|
||||
$nodes = $nodes;
|
||||
};
|
||||
|
||||
$: {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
type $$Props = NodeProps;
|
||||
|
||||
export let id: $$Props['id'];
|
||||
$$restProps;
|
||||
|
||||
const connections = useHandleConnections({
|
||||
nodeId: id,
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
export let data: $$Props['data'];
|
||||
|
||||
const { updateNodeData } = useSvelteFlow();
|
||||
$$restProps;
|
||||
</script>
|
||||
|
||||
<div class="custom">
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
type $$Props = NodeProps;
|
||||
|
||||
export let id: $$Props['id'];
|
||||
export let data: $$Props['data'];
|
||||
$$restProps;
|
||||
|
||||
const { updateNodeData } = useSvelteFlow();
|
||||
const connections = useHandleConnections({
|
||||
@@ -22,8 +24,12 @@
|
||||
$: nodeData = useNodesData<MyNode>($connections[0]?.source);
|
||||
$: textNode = isTextNode($nodeData) ? $nodeData : null;
|
||||
|
||||
$: console.log(textNode?.data, data);
|
||||
|
||||
$: {
|
||||
updateNodeData(id, { text: textNode?.data.text.toUpperCase() || '' });
|
||||
const input = textNode?.data.text.toUpperCase() ?? '';
|
||||
updateNodeData(id, { text: input });
|
||||
console.log('updatedNodeData with', input);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user