@flowdrop/flowdrop 2.9.0 → 2.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +200 -0
- package/dist/commands/executor.js +52 -8
- package/dist/commands/types.d.ts +3 -0
- package/dist/components/App.svelte +8 -0
- package/dist/components/App.svelte.d.ts +6 -0
- package/dist/components/CanvasContextMenu.stories.svelte +63 -0
- package/dist/components/CanvasContextMenu.stories.svelte.d.ts +19 -0
- package/dist/components/CanvasContextMenu.svelte +259 -0
- package/dist/components/CanvasContextMenu.svelte.d.ts +16 -0
- package/dist/components/CanvasController.svelte +24 -2
- package/dist/components/CanvasController.svelte.d.ts +16 -0
- package/dist/components/EdgeRefresher.svelte +1 -1
- package/dist/components/FlowDropZone.svelte +11 -7
- package/dist/components/FlowDropZone.svelte.d.ts +12 -0
- package/dist/components/PortCoordinateTracker.svelte +1 -1
- package/dist/components/UniversalNode.svelte +12 -13
- package/dist/components/WorkflowEditor.svelte +486 -149
- package/dist/components/WorkflowEditor.svelte.d.ts +7 -0
- package/dist/components/WorkflowInterfaceEditor.svelte +28 -3
- package/dist/components/WorkflowInterfaceEntryCard.svelte +112 -2
- package/dist/components/WorkflowInterfaceEntryCard.svelte.d.ts +3 -1
- package/dist/components/nodes/CaptionNode.stories.svelte +65 -0
- package/dist/components/nodes/CaptionNode.stories.svelte.d.ts +18 -0
- package/dist/components/nodes/CaptionNode.svelte +313 -0
- package/dist/components/nodes/CaptionNode.svelte.d.ts +16 -0
- package/dist/components/nodes/NotesNode.svelte +6 -0
- package/dist/components/playground/ChatBubble.svelte +2 -0
- package/dist/components/playground/ChatInput.svelte +18 -34
- package/dist/components/playground/ChatInput.svelte.d.ts +7 -0
- package/dist/components/playground/ControlPanel.svelte +27 -0
- package/dist/components/playground/ControlPanel.svelte.d.ts +12 -0
- package/dist/components/playground/ExecutionLogs.svelte +11 -8
- package/dist/components/playground/InterfaceInputForm.svelte +74 -0
- package/dist/components/playground/InterfaceInputForm.svelte.d.ts +14 -0
- package/dist/components/playground/LogRow.svelte +2 -0
- package/dist/components/playground/MessageCard.svelte +15 -3
- package/dist/components/playground/MessageNotice.svelte +2 -0
- package/dist/components/playground/MessageStream.svelte +87 -23
- package/dist/components/playground/OriginBadge.svelte +48 -0
- package/dist/components/playground/OriginBadge.svelte.d.ts +7 -0
- package/dist/components/playground/Playground.svelte +155 -38
- package/dist/components/playground/messageDisplay.d.ts +23 -1
- package/dist/components/playground/messageDisplay.js +49 -0
- package/dist/config/endpoints.d.ts +65 -0
- package/dist/config/endpoints.js +39 -0
- package/dist/core/index.d.ts +6 -3
- package/dist/core/index.js +2 -1
- package/dist/editor/contextMenu.d.ts +107 -0
- package/dist/editor/contextMenu.js +134 -0
- package/dist/editor/index.d.ts +2 -0
- package/dist/editor/index.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/messages/defaults.d.ts +63 -0
- package/dist/messages/defaults.js +59 -0
- package/dist/openapi/v1/openapi.yaml +356 -7
- package/dist/playground/commands/registry.js +4 -2
- package/dist/playground/index.d.ts +3 -2
- package/dist/playground/index.js +2 -1
- package/dist/registry/builtinNodeTypes.d.ts +1 -1
- package/dist/registry/builtinNodeTypes.js +1 -0
- package/dist/registry/builtinNodes.js +13 -0
- package/dist/registry/nodeComponentRegistry.d.ts +18 -0
- package/dist/registry/nodeComponentRegistry.js +14 -2
- package/dist/schemas/v1/workflow.schema.json +22 -1
- package/dist/services/historyService.d.ts +1 -1
- package/dist/services/historyService.js +2 -2
- package/dist/services/playgroundService.d.ts +35 -1
- package/dist/services/playgroundService.js +82 -36
- package/dist/stores/inlineEditStore.svelte.d.ts +35 -0
- package/dist/stores/inlineEditStore.svelte.js +63 -0
- package/dist/stores/instanceContainer.svelte.d.ts +6 -0
- package/dist/stores/instanceContainer.svelte.js +2 -0
- package/dist/stores/playgroundStore.svelte.d.ts +59 -2
- package/dist/stores/playgroundStore.svelte.js +128 -2
- package/dist/styles/base.css +8 -0
- package/dist/styles/tokens.css +8 -0
- package/dist/svelte-app.d.ts +15 -0
- package/dist/svelte-app.js +6 -4
- package/dist/types/index.d.ts +34 -1
- package/dist/types/index.js +11 -0
- package/dist/types/playground.d.ts +90 -9
- package/dist/types/playground.js +12 -4
- package/dist/utils/captionText.d.ts +43 -0
- package/dist/utils/captionText.js +49 -0
- package/dist/utils/focus.d.ts +16 -0
- package/dist/utils/focus.js +40 -0
- package/dist/utils/nodeTypes.js +1 -0
- package/dist/utils/nodeWrapper.js +2 -0
- package/dist/utils/workflowInterface.d.ts +83 -1
- package/dist/utils/workflowInterface.js +192 -1
- package/package.json +2 -2
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
CanvasContextMenu Component
|
|
3
|
+
The editor's right-click / Shift+F10 menu. Renders already-resolved entries
|
|
4
|
+
(see editor/contextMenu.ts) as an ARIA menu positioned at the pointer and
|
|
5
|
+
clamped inside the viewport. It is a manual popover, so it sits in the top
|
|
6
|
+
layer and no ancestor's overflow or stacking context can clip or cover it;
|
|
7
|
+
that is also why it is positioned in viewport coordinates. A manual popover
|
|
8
|
+
does not light-dismiss, so it closes itself on outside pointerdown, wheel
|
|
9
|
+
(zoom/pan), window blur, Escape, and after an entry runs.
|
|
10
|
+
Styled with BEM syntax.
|
|
11
|
+
-->
|
|
12
|
+
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
import type { Attachment } from 'svelte/attachments';
|
|
15
|
+
import { on } from 'svelte/events';
|
|
16
|
+
import Icon from '@iconify/svelte';
|
|
17
|
+
import { m } from '../messages/index.js';
|
|
18
|
+
import { isSeparator, type ContextMenuEntry } from '../editor/contextMenu.js';
|
|
19
|
+
|
|
20
|
+
interface Props {
|
|
21
|
+
/** Resolved entries (separators already cleaned). */
|
|
22
|
+
entries: ContextMenuEntry[];
|
|
23
|
+
/** Left edge of the menu, in viewport (client) px. */
|
|
24
|
+
x: number;
|
|
25
|
+
/** Top edge of the menu, in viewport (client) px. */
|
|
26
|
+
y: number;
|
|
27
|
+
/** Run an entry. The menu closes afterwards. */
|
|
28
|
+
onselect: (entry: ContextMenuEntry) => void;
|
|
29
|
+
/** Close without running anything. */
|
|
30
|
+
onclose: () => void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const { entries, x, y, onselect, onclose }: Props = $props();
|
|
34
|
+
|
|
35
|
+
let menuEl: HTMLDivElement | undefined = $state();
|
|
36
|
+
|
|
37
|
+
/** Element that had focus when the menu opened; focus returns there on keyboard close. */
|
|
38
|
+
let previouslyFocused: HTMLElement | null = null;
|
|
39
|
+
|
|
40
|
+
function items(): HTMLButtonElement[] {
|
|
41
|
+
return Array.from(
|
|
42
|
+
menuEl?.querySelectorAll<HTMLButtonElement>(
|
|
43
|
+
'[role="menuitem"]:not([aria-disabled="true"])'
|
|
44
|
+
) ?? []
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function restoreFocus(): void {
|
|
49
|
+
if (previouslyFocused && previouslyFocused.isConnected) {
|
|
50
|
+
previouslyFocused.focus({ preventScroll: true });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function closeAndRestore(): void {
|
|
55
|
+
onclose();
|
|
56
|
+
restoreFocus();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function run(entry: ContextMenuEntry): void {
|
|
60
|
+
if (isSeparator(entry) || entry.disabled) return;
|
|
61
|
+
onselect(entry);
|
|
62
|
+
restoreFocus();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Opening, once per menu: remember the focus to return to, show the
|
|
67
|
+
* popover, focus the first item and wire the dismissals a manual popover
|
|
68
|
+
* does not do itself.
|
|
69
|
+
*/
|
|
70
|
+
const open: Attachment<HTMLDivElement> = (el) => {
|
|
71
|
+
previouslyFocused =
|
|
72
|
+
document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
73
|
+
// Optional: jsdom has no Popover API.
|
|
74
|
+
el.showPopover?.();
|
|
75
|
+
el.querySelector<HTMLButtonElement>('[role="menuitem"]:not([aria-disabled="true"])')?.focus({
|
|
76
|
+
preventScroll: true
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const removers = [
|
|
80
|
+
on(
|
|
81
|
+
window,
|
|
82
|
+
'pointerdown',
|
|
83
|
+
(event) => {
|
|
84
|
+
if (event.target instanceof Node && el.contains(event.target)) return;
|
|
85
|
+
onclose();
|
|
86
|
+
},
|
|
87
|
+
{ capture: true }
|
|
88
|
+
),
|
|
89
|
+
on(window, 'wheel', () => onclose(), { capture: true, passive: true }),
|
|
90
|
+
on(window, 'blur', () => onclose())
|
|
91
|
+
];
|
|
92
|
+
return () => removers.forEach((remove) => remove());
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Placement, again whenever the requested position changes: slide back
|
|
97
|
+
* inside the viewport rather than flipping. The popover is showing by now
|
|
98
|
+
* (see `open`), so it can be measured. Written to the style directly: the
|
|
99
|
+
* position is a measurement result, not state anything else reads.
|
|
100
|
+
*/
|
|
101
|
+
const place: Attachment<HTMLDivElement> = (el) => {
|
|
102
|
+
el.style.left = `${Math.max(0, Math.min(x, window.innerWidth - el.offsetWidth))}px`;
|
|
103
|
+
el.style.top = `${Math.max(0, Math.min(y, window.innerHeight - el.offsetHeight))}px`;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
function handleKeydown(event: KeyboardEvent): void {
|
|
107
|
+
const list = items();
|
|
108
|
+
const index = list.indexOf(document.activeElement as HTMLButtonElement);
|
|
109
|
+
|
|
110
|
+
switch (event.key) {
|
|
111
|
+
case 'ArrowDown':
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
list[(index + 1) % list.length]?.focus();
|
|
114
|
+
break;
|
|
115
|
+
case 'ArrowUp':
|
|
116
|
+
event.preventDefault();
|
|
117
|
+
list[(index - 1 + list.length) % list.length]?.focus();
|
|
118
|
+
break;
|
|
119
|
+
case 'Home':
|
|
120
|
+
event.preventDefault();
|
|
121
|
+
list[0]?.focus();
|
|
122
|
+
break;
|
|
123
|
+
case 'End':
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
list[list.length - 1]?.focus();
|
|
126
|
+
break;
|
|
127
|
+
case 'Escape':
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
event.stopPropagation();
|
|
130
|
+
closeAndRestore();
|
|
131
|
+
break;
|
|
132
|
+
case 'Tab':
|
|
133
|
+
event.preventDefault();
|
|
134
|
+
closeAndRestore();
|
|
135
|
+
break;
|
|
136
|
+
// Enter and Space activate the focused button natively (click).
|
|
137
|
+
default:
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
// Keep menu keys away from the canvas (arrow keys would nudge the node, Backspace would delete it).
|
|
141
|
+
event.stopPropagation();
|
|
142
|
+
}
|
|
143
|
+
</script>
|
|
144
|
+
|
|
145
|
+
<div
|
|
146
|
+
bind:this={menuEl}
|
|
147
|
+
popover="manual"
|
|
148
|
+
class="canvas-context-menu nodrag nopan nowheel"
|
|
149
|
+
role="menu"
|
|
150
|
+
tabindex="-1"
|
|
151
|
+
aria-label={m().contextMenu.menuLabel}
|
|
152
|
+
onkeydown={handleKeydown}
|
|
153
|
+
{@attach open}
|
|
154
|
+
{@attach place}
|
|
155
|
+
oncontextmenu={(event) => event.preventDefault()}
|
|
156
|
+
>
|
|
157
|
+
{#each entries as entry (entry.id)}
|
|
158
|
+
{#if isSeparator(entry)}
|
|
159
|
+
<div class="canvas-context-menu__separator" role="separator"></div>
|
|
160
|
+
{:else}
|
|
161
|
+
<button
|
|
162
|
+
type="button"
|
|
163
|
+
class="canvas-context-menu__item"
|
|
164
|
+
role="menuitem"
|
|
165
|
+
tabindex="-1"
|
|
166
|
+
aria-disabled={entry.disabled ? 'true' : undefined}
|
|
167
|
+
onclick={() => run(entry)}
|
|
168
|
+
>
|
|
169
|
+
<span class="canvas-context-menu__icon" aria-hidden="true">
|
|
170
|
+
{#if entry.icon}
|
|
171
|
+
<Icon icon={entry.icon} />
|
|
172
|
+
{/if}
|
|
173
|
+
</span>
|
|
174
|
+
<span class="canvas-context-menu__label">{entry.label}</span>
|
|
175
|
+
{#if entry.shortcut}
|
|
176
|
+
<span class="canvas-context-menu__shortcut" aria-hidden="true">{entry.shortcut}</span>
|
|
177
|
+
{/if}
|
|
178
|
+
</button>
|
|
179
|
+
{/if}
|
|
180
|
+
{/each}
|
|
181
|
+
</div>
|
|
182
|
+
|
|
183
|
+
<style>
|
|
184
|
+
.canvas-context-menu {
|
|
185
|
+
/* Reset the popover user-agent styles: it is placed by the script, in the viewport. */
|
|
186
|
+
position: fixed;
|
|
187
|
+
inset: auto;
|
|
188
|
+
margin: 0;
|
|
189
|
+
overflow: visible;
|
|
190
|
+
min-width: 11rem;
|
|
191
|
+
max-width: 18rem;
|
|
192
|
+
padding: 0.25rem;
|
|
193
|
+
background-color: var(--fd-background);
|
|
194
|
+
border: 1px solid var(--fd-border);
|
|
195
|
+
border-radius: var(--fd-radius-lg);
|
|
196
|
+
box-shadow: var(--fd-shadow-lg);
|
|
197
|
+
color: var(--fd-foreground);
|
|
198
|
+
font-size: var(--fd-text-sm);
|
|
199
|
+
outline: none;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.canvas-context-menu__item {
|
|
203
|
+
display: flex;
|
|
204
|
+
align-items: center;
|
|
205
|
+
gap: 0.5rem;
|
|
206
|
+
width: 100%;
|
|
207
|
+
padding: 0.375rem 0.5rem;
|
|
208
|
+
border: none;
|
|
209
|
+
border-radius: var(--fd-radius-sm);
|
|
210
|
+
background: none;
|
|
211
|
+
color: inherit;
|
|
212
|
+
font: inherit;
|
|
213
|
+
text-align: left;
|
|
214
|
+
cursor: pointer;
|
|
215
|
+
transition: background-color var(--fd-transition-fast);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.canvas-context-menu__item:hover,
|
|
219
|
+
.canvas-context-menu__item:focus-visible {
|
|
220
|
+
background-color: var(--fd-subtle);
|
|
221
|
+
outline: none;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.canvas-context-menu__item[aria-disabled='true'] {
|
|
225
|
+
color: var(--fd-muted-foreground);
|
|
226
|
+
cursor: not-allowed;
|
|
227
|
+
opacity: 0.6;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.canvas-context-menu__item[aria-disabled='true']:hover {
|
|
231
|
+
background: none;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.canvas-context-menu__icon {
|
|
235
|
+
display: inline-flex;
|
|
236
|
+
width: 1rem;
|
|
237
|
+
flex-shrink: 0;
|
|
238
|
+
color: var(--fd-muted-foreground);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.canvas-context-menu__label {
|
|
242
|
+
flex: 1;
|
|
243
|
+
white-space: nowrap;
|
|
244
|
+
overflow: hidden;
|
|
245
|
+
text-overflow: ellipsis;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.canvas-context-menu__shortcut {
|
|
249
|
+
margin-left: 1rem;
|
|
250
|
+
color: var(--fd-muted-foreground);
|
|
251
|
+
font-size: var(--fd-text-xs);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.canvas-context-menu__separator {
|
|
255
|
+
height: 1px;
|
|
256
|
+
margin: 0.25rem 0.25rem;
|
|
257
|
+
background-color: var(--fd-border-muted);
|
|
258
|
+
}
|
|
259
|
+
</style>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ContextMenuEntry } from '../editor/contextMenu.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** Resolved entries (separators already cleaned). */
|
|
4
|
+
entries: ContextMenuEntry[];
|
|
5
|
+
/** Left edge of the menu, in viewport (client) px. */
|
|
6
|
+
x: number;
|
|
7
|
+
/** Top edge of the menu, in viewport (client) px. */
|
|
8
|
+
y: number;
|
|
9
|
+
/** Run an entry. The menu closes afterwards. */
|
|
10
|
+
onselect: (entry: ContextMenuEntry) => void;
|
|
11
|
+
/** Close without running anything. */
|
|
12
|
+
onclose: () => void;
|
|
13
|
+
}
|
|
14
|
+
declare const CanvasContextMenu: import("svelte").Component<Props, {}, "">;
|
|
15
|
+
type CanvasContextMenu = ReturnType<typeof CanvasContextMenu>;
|
|
16
|
+
export default CanvasContextMenu;
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
CanvasController Component
|
|
3
3
|
Provides viewport control methods (fitView, zoom, pan) via useSvelteFlow().
|
|
4
|
-
Must be rendered inside
|
|
4
|
+
Must be rendered inside <SvelteFlow> (not beside it under a provider).
|
|
5
5
|
-->
|
|
6
6
|
|
|
7
7
|
<script lang="ts">
|
|
8
8
|
import { useSvelteFlow } from '@xyflow/svelte';
|
|
9
9
|
import { getEditorSettings } from '../stores/settingsStore.svelte.js';
|
|
10
10
|
|
|
11
|
-
const {
|
|
11
|
+
const {
|
|
12
|
+
fitView,
|
|
13
|
+
zoomIn,
|
|
14
|
+
zoomOut,
|
|
15
|
+
setZoom,
|
|
16
|
+
setCenter,
|
|
17
|
+
setViewport,
|
|
18
|
+
screenToFlowPosition,
|
|
19
|
+
deleteElements
|
|
20
|
+
} = useSvelteFlow();
|
|
12
21
|
|
|
13
22
|
export function canvasFitView(): void {
|
|
14
23
|
fitView({ padding: 0.2, duration: 300 });
|
|
@@ -34,4 +43,17 @@
|
|
|
34
43
|
const defaultZoom = getEditorSettings().defaultZoom;
|
|
35
44
|
setViewport({ x: 0, y: 0, zoom: defaultZoom }, { duration: 300 });
|
|
36
45
|
}
|
|
46
|
+
|
|
47
|
+
/** Convert a viewport (client) point to flow coordinates. */
|
|
48
|
+
export function canvasScreenToFlow(point: { x: number; y: number }): { x: number; y: number } {
|
|
49
|
+
return screenToFlowPosition(point);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Delete nodes through xyflow so `onbeforedelete` (confirm setting) and
|
|
54
|
+
* `ondelete` (edge removal + history entry) run exactly as for the Delete key.
|
|
55
|
+
*/
|
|
56
|
+
export async function canvasDeleteNodes(ids: string[]): Promise<void> {
|
|
57
|
+
await deleteElements({ nodes: ids.map((id) => ({ id })) });
|
|
58
|
+
}
|
|
37
59
|
</script>
|
|
@@ -18,6 +18,14 @@ declare const CanvasController: $$__sveltets_2_IsomorphicComponent<{
|
|
|
18
18
|
canvasZoomTo?: (level: number) => void;
|
|
19
19
|
canvasPanTo?: (x: number, y: number) => void;
|
|
20
20
|
canvasResetView?: () => void;
|
|
21
|
+
canvasScreenToFlow?: (point: {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
}) => {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
};
|
|
28
|
+
canvasDeleteNodes?: (ids: string[]) => Promise<void>;
|
|
21
29
|
}, {
|
|
22
30
|
[evt: string]: CustomEvent<any>;
|
|
23
31
|
}, {}, {
|
|
@@ -27,6 +35,14 @@ declare const CanvasController: $$__sveltets_2_IsomorphicComponent<{
|
|
|
27
35
|
canvasZoomTo: (level: number) => void;
|
|
28
36
|
canvasPanTo: (x: number, y: number) => void;
|
|
29
37
|
canvasResetView: () => void;
|
|
38
|
+
canvasScreenToFlow: (point: {
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
}) => {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
};
|
|
45
|
+
canvasDeleteNodes: (ids: string[]) => Promise<void>;
|
|
30
46
|
}, string>;
|
|
31
47
|
type CanvasController = InstanceType<typeof CanvasController>;
|
|
32
48
|
export default CanvasController;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
Flow Drop Zone Component
|
|
3
|
-
Handles drag and drop with proper coordinate transformation
|
|
4
|
-
|
|
3
|
+
Handles drag and drop with proper coordinate transformation.
|
|
4
|
+
It wraps the canvas, so it sits outside <SvelteFlow>'s context: the parent
|
|
5
|
+
passes the screen-to-flow conversion in as `toFlowPosition`.
|
|
5
6
|
-->
|
|
6
7
|
|
|
7
8
|
<script lang="ts">
|
|
8
|
-
import { useSvelteFlow } from '@xyflow/svelte';
|
|
9
9
|
import type { Snippet } from 'svelte';
|
|
10
10
|
import { m } from '../messages/index.js';
|
|
11
11
|
|
|
@@ -13,14 +13,17 @@
|
|
|
13
13
|
ondrop: (nodeTypeData: string, position: { x: number; y: number }) => void;
|
|
14
14
|
/** Optional callback invoked when a JSON file is dropped onto the canvas. */
|
|
15
15
|
onfiledrop?: (file: File) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Convert a viewport (client) point to flow coordinates, accounting for
|
|
18
|
+
* zoom and pan. Returns null while no canvas is mounted; the drop is then
|
|
19
|
+
* ignored.
|
|
20
|
+
*/
|
|
21
|
+
toFlowPosition: (point: { x: number; y: number }) => { x: number; y: number } | null;
|
|
16
22
|
children: Snippet;
|
|
17
23
|
}
|
|
18
24
|
|
|
19
25
|
let props: Props = $props();
|
|
20
26
|
|
|
21
|
-
// Access SvelteFlow instance for coordinate transformation
|
|
22
|
-
const { screenToFlowPosition } = useSvelteFlow();
|
|
23
|
-
|
|
24
27
|
/**
|
|
25
28
|
* Handle drag over event
|
|
26
29
|
*/
|
|
@@ -55,10 +58,11 @@
|
|
|
55
58
|
const nodeTypeData = e.dataTransfer?.getData('application/json');
|
|
56
59
|
if (nodeTypeData) {
|
|
57
60
|
// Convert screen coordinates to flow coordinates (accounts for zoom and pan)
|
|
58
|
-
const position =
|
|
61
|
+
const position = props.toFlowPosition({
|
|
59
62
|
x: e.clientX,
|
|
60
63
|
y: e.clientY
|
|
61
64
|
});
|
|
65
|
+
if (!position) return;
|
|
62
66
|
|
|
63
67
|
// Call the parent handler with the converted position
|
|
64
68
|
props.ondrop(nodeTypeData, position);
|
|
@@ -6,6 +6,18 @@ interface Props {
|
|
|
6
6
|
}) => void;
|
|
7
7
|
/** Optional callback invoked when a JSON file is dropped onto the canvas. */
|
|
8
8
|
onfiledrop?: (file: File) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Convert a viewport (client) point to flow coordinates, accounting for
|
|
11
|
+
* zoom and pan. Returns null while no canvas is mounted; the drop is then
|
|
12
|
+
* ignored.
|
|
13
|
+
*/
|
|
14
|
+
toFlowPosition: (point: {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
}) => {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
} | null;
|
|
9
21
|
children: Snippet;
|
|
10
22
|
}
|
|
11
23
|
declare const FlowDropZone: import("svelte").Component<Props, {}, "">;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
Port Coordinate Tracker Component
|
|
3
3
|
Bridge component that exposes SvelteFlow's getInternalNode to the parent.
|
|
4
|
-
Must be rendered inside
|
|
4
|
+
Must be rendered inside <SvelteFlow> (not beside it under a provider).
|
|
5
5
|
|
|
6
6
|
Uses the same pattern as EdgeRefresher - a renderless component that hooks
|
|
7
7
|
into the SvelteFlow context.
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import type { WorkflowNode } from '../types/index.js';
|
|
12
12
|
import { resolveBuiltinAlias } from '../registry/builtinNodes.js';
|
|
13
13
|
import NodeStatusOverlay from './NodeStatusOverlay.svelte';
|
|
14
|
-
import { shouldShowNodeStatus } from '../utils/nodeWrapper.js';
|
|
14
|
+
import { shouldShowNodeStatus, getOptimalStatusPosition } from '../utils/nodeWrapper.js';
|
|
15
15
|
import { resolveComponentName } from '../utils/nodeTypes.js';
|
|
16
16
|
import { getInstance } from '../stores/getInstance.svelte.js';
|
|
17
17
|
|
|
@@ -59,10 +59,12 @@
|
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
61
|
* Determine if status overlay should be shown.
|
|
62
|
-
* Hide for note nodes as they have their own styling.
|
|
62
|
+
* Hide for note and caption nodes as they have their own styling.
|
|
63
63
|
*/
|
|
64
64
|
let shouldShowStatus = $derived(
|
|
65
|
-
shouldShowNodeStatus(executionInfo) &&
|
|
65
|
+
shouldShowNodeStatus(executionInfo) &&
|
|
66
|
+
resolvedComponentName !== 'note' &&
|
|
67
|
+
resolvedComponentName !== 'caption'
|
|
66
68
|
);
|
|
67
69
|
|
|
68
70
|
// Keyboard activation lives on xyflow's node wrapper — the single focusable,
|
|
@@ -81,6 +83,11 @@
|
|
|
81
83
|
if (event.target !== wrapper) return;
|
|
82
84
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
83
85
|
event.preventDefault();
|
|
86
|
+
// Nodes that edit their text in place (caption) start typing instead.
|
|
87
|
+
if (fd.nodes.editsInPlace(resolvedComponentName)) {
|
|
88
|
+
fd.inlineEdit.request(id);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
84
91
|
data.onConfigOpen?.({
|
|
85
92
|
id,
|
|
86
93
|
type: resolvedComponentName,
|
|
@@ -125,16 +132,7 @@
|
|
|
125
132
|
}
|
|
126
133
|
|
|
127
134
|
// Fallback based on node type
|
|
128
|
-
|
|
129
|
-
case 'tool':
|
|
130
|
-
return 'top-left';
|
|
131
|
-
case 'note':
|
|
132
|
-
return 'bottom-right';
|
|
133
|
-
case 'simple':
|
|
134
|
-
case 'square':
|
|
135
|
-
default:
|
|
136
|
-
return 'top-right';
|
|
137
|
-
}
|
|
135
|
+
return getOptimalStatusPosition(resolvedComponentName) ?? 'top-right';
|
|
138
136
|
}
|
|
139
137
|
|
|
140
138
|
/**
|
|
@@ -152,6 +150,7 @@
|
|
|
152
150
|
switch (resolvedComponentName) {
|
|
153
151
|
case 'tool':
|
|
154
152
|
case 'note':
|
|
153
|
+
case 'caption':
|
|
155
154
|
case 'square':
|
|
156
155
|
return 'sm';
|
|
157
156
|
case 'simple':
|