@flowdrop/flowdrop 2.10.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 CHANGED
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.10.1] - 2026-10-07
9
+
10
+ ### Fixed
11
+
12
+ - With `@xyflow/svelte` 1.6.6 or later, the context menu's Delete did nothing
13
+ after the editor loaded a workflow (for example on mount in the Drupal
14
+ module, or after dropping a workflow file on the canvas): the menu closed
15
+ and the node stayed. The editor's other canvas helpers (fit view, zoom,
16
+ pan, sidebar drop position, caption placement, edge refresh, port
17
+ tracking) read the same stale state and were exposed to the same problem.
18
+ They now live inside the canvas, so they always act on the one that is
19
+ showing. The Delete key was never affected.
20
+
8
21
  ## [2.10.0] - 2026-10-07
9
22
 
10
23
  ### Added
@@ -1,7 +1,7 @@
1
1
  <!--
2
2
  CanvasController Component
3
3
  Provides viewport control methods (fitView, zoom, pan) via useSvelteFlow().
4
- Must be rendered inside SvelteFlowProvider context.
4
+ Must be rendered inside <SvelteFlow> (not beside it under a provider).
5
5
  -->
6
6
 
7
7
  <script lang="ts">
@@ -1,7 +1,7 @@
1
1
  <!--
2
2
  EdgeRefresher Component
3
3
  Helper component that uses useUpdateNodeInternals to force edge recalculation
4
- Must be rendered inside SvelteFlowProvider context
4
+ Must be rendered inside <SvelteFlow> (not beside it under a provider).
5
5
  -->
6
6
 
7
7
  <script lang="ts">
@@ -1,11 +1,11 @@
1
1
  <!--
2
2
  Flow Drop Zone Component
3
- Handles drag and drop with proper coordinate transformation
4
- Must be used inside SvelteFlowProvider
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 = screenToFlowPosition({
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 SvelteFlowProvider context.
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.
@@ -12,7 +12,6 @@
12
12
  Background,
13
13
  BackgroundVariant,
14
14
  MiniMap,
15
- SvelteFlowProvider,
16
15
  type ColorMode
17
16
  } from '@xyflow/svelte';
18
17
  import '@xyflow/svelte/dist/style.css';
@@ -1051,7 +1050,8 @@
1051
1050
  */
1052
1051
  let nodeIdToRefresh = $state<string | null>(null);
1053
1052
 
1054
- // Canvas viewport controller ref (rendered inside SvelteFlowProvider)
1053
+ // Canvas viewport controller ref. Rendered inside <SvelteFlow>, so it is
1054
+ // remounted with the canvas and always talks to the live instance's store.
1055
1055
  let canvasControllerRef: CanvasController | undefined = $state();
1056
1056
 
1057
1057
  /**
@@ -1099,7 +1099,7 @@
1099
1099
  nodeIdToRefresh = nodeId;
1100
1100
  }
1101
1101
 
1102
- // Canvas viewport methods (forwarded to CanvasController inside SvelteFlowProvider)
1102
+ // Canvas viewport methods (forwarded to CanvasController inside <SvelteFlow>)
1103
1103
 
1104
1104
  export function canvasFitView(): void {
1105
1105
  canvasControllerRef?.canvasFitView();
@@ -1193,152 +1193,152 @@
1193
1193
 
1194
1194
  <svelte:window onkeydown={handleKeydown} />
1195
1195
 
1196
- <SvelteFlowProvider>
1197
- <!-- Canvas viewport controller - provides fitView, zoom, pan methods -->
1198
- <CanvasController bind:this={canvasControllerRef} />
1199
-
1200
- <!-- EdgeRefresher component - handles updateNodeInternals calls -->
1201
- <EdgeRefresher {nodeIdToRefresh} onRefreshComplete={handleEdgeRefreshComplete} />
1202
-
1203
- <!-- Port Coordinate Tracker - maintains port positions for proximity connect -->
1204
- <PortCoordinateTracker
1205
- nodeToUpdate={portCoordNodeToUpdate}
1206
- rebuildTrigger={portCoordRebuildTrigger}
1207
- nodes={flowNodes}
1208
- />
1209
-
1210
- <div class="flowdrop-workflow-editor">
1211
- <!-- Main Editor Area -->
1212
- <div class="flowdrop-workflow-editor__main">
1213
- <!-- Flow Canvas.
1196
+ <div class="flowdrop-workflow-editor">
1197
+ <!-- Main Editor Area -->
1198
+ <div class="flowdrop-workflow-editor__main">
1199
+ <!-- Flow Canvas.
1214
1200
  Capture-phase mousedown so dragging from a port never turns into a
1215
1201
  WebKit text-selection drag — see suppressPortDragSelection. -->
1216
- <div
1217
- class="flowdrop-canvas"
1218
- bind:this={canvasEl}
1219
- onmousedowncapture={suppressPortDragSelection}
1202
+ <div
1203
+ class="flowdrop-canvas"
1204
+ bind:this={canvasEl}
1205
+ onmousedowncapture={suppressPortDragSelection}
1206
+ >
1207
+ <FlowDropZone
1208
+ ondrop={handleNodeDrop}
1209
+ onfiledrop={handleWorkflowFileDrop}
1210
+ toFlowPosition={(point) => canvasControllerRef?.canvasScreenToFlow(point) ?? null}
1220
1211
  >
1221
- <FlowDropZone ondrop={handleNodeDrop} onfiledrop={handleWorkflowFileDrop}>
1222
- {#key svelteFlowKey}
1223
- <SvelteFlow
1224
- id={fd.id}
1225
- bind:nodes={flowNodes}
1226
- bind:edges={flowEdges}
1227
- {nodeTypes}
1228
- {edgeTypes}
1229
- {defaultEdgeOptions}
1230
- onconnect={() => void handleConnect()}
1231
- onbeforedelete={handleBeforeDelete}
1232
- ondelete={handleNodesDelete}
1233
- onnodedragstart={handleNodeDragStart}
1234
- onnodedrag={handleNodeDrag}
1235
- onnodedragstop={handleNodeDragStop}
1236
- onnodecontextmenu={handleNodeContextMenu}
1237
- onselectioncontextmenu={handleSelectionContextMenu}
1238
- onpanecontextmenu={handlePaneContextMenu}
1239
- minZoom={0.2}
1240
- maxZoom={3}
1241
- clickConnect={true}
1242
- elevateEdgesOnSelect={true}
1243
- connectionLineType={ConnectionLineType.Bezier}
1244
- connectionLineComponent={ConnectionLine}
1245
- {snapGrid}
1246
- {initialViewport}
1247
- colorMode={getResolvedTheme() as ColorMode}
1248
- fitView={getEditorSettings().fitViewOnLoad}
1249
- nodesDraggable={canvasEditable}
1250
- nodesConnectable={canvasEditable}
1251
- elementsSelectable={canvasEditable}
1252
- >
1253
- <Controls />
1254
- {#if canvasEditable && props.onToggleConsole}
1255
- <CanvasIconButton
1256
- class="flowdrop-console-toggle"
1257
- label={props.consoleToggleLabel ?? m().layout.commandConsole}
1258
- active={props.consoleOpen}
1259
- onclick={props.onToggleConsole}
1260
- >
1261
- {#snippet icon()}
1262
- <CommandLineIcon />
1263
- {/snippet}
1264
- </CanvasIconButton>
1265
- {/if}
1266
- <!-- Always render Background for consistent bg color in dark/light mode -->
1267
- <Background
1268
- gap={getEditorSettings().gridSize}
1269
- bgColor="var(--fd-canvas-bg)"
1270
- variant={gridVariant}
1271
- lineWidth={1}
1272
- patternColor={getEditorSettings().showGrid
1273
- ? 'var(--fd-grid-pattern-color)'
1274
- : 'transparent'}
1275
- />
1276
- {#if getEditorSettings().showMinimap}
1277
- <MiniMap />
1278
- {/if}
1279
- </SvelteFlow>
1280
- {/key}
1281
- <!-- Drop Zone Indicator -->
1282
- {#if flowNodes.length === 0}
1283
- <CanvasBanner
1284
- title="Drag components here to start building"
1285
- description="Use the sidebar to add components to your workflow"
1286
- >
1287
- {#snippet icon()}
1288
- <svg
1289
- xmlns="http://www.w3.org/2000/svg"
1290
- width="1em"
1291
- height="1em"
1292
- viewBox="0 0 24 24"
1293
- fill="none"
1294
- stroke="currentColor"
1295
- stroke-width="1.5"
1296
- stroke-linecap="round"
1297
- stroke-linejoin="round"
1298
- >
1299
- <circle cx="18" cy="5" r="3" />
1300
- <circle cx="6" cy="12" r="3" />
1301
- <circle cx="18" cy="19" r="3" />
1302
- <line x1="8.59" y1="13.51" x2="15.42" y2="17.49" />
1303
- <line x1="15.41" y1="6.51" x2="8.59" y2="10.49" />
1304
- </svg>
1305
- {/snippet}
1306
- </CanvasBanner>
1307
- {/if}
1308
- </FlowDropZone>
1309
-
1310
- {#if openMenu}
1311
- <CanvasContextMenu
1312
- entries={openMenu.entries}
1313
- x={openMenu.x}
1314
- y={openMenu.y}
1315
- onselect={selectContextMenuEntry}
1316
- onclose={closeContextMenu}
1317
- />
1212
+ {#key svelteFlowKey}
1213
+ <SvelteFlow
1214
+ id={fd.id}
1215
+ bind:nodes={flowNodes}
1216
+ bind:edges={flowEdges}
1217
+ {nodeTypes}
1218
+ {edgeTypes}
1219
+ {defaultEdgeOptions}
1220
+ onconnect={() => void handleConnect()}
1221
+ onbeforedelete={handleBeforeDelete}
1222
+ ondelete={handleNodesDelete}
1223
+ onnodedragstart={handleNodeDragStart}
1224
+ onnodedrag={handleNodeDrag}
1225
+ onnodedragstop={handleNodeDragStop}
1226
+ onnodecontextmenu={handleNodeContextMenu}
1227
+ onselectioncontextmenu={handleSelectionContextMenu}
1228
+ onpanecontextmenu={handlePaneContextMenu}
1229
+ minZoom={0.2}
1230
+ maxZoom={3}
1231
+ clickConnect={true}
1232
+ elevateEdgesOnSelect={true}
1233
+ connectionLineType={ConnectionLineType.Bezier}
1234
+ connectionLineComponent={ConnectionLine}
1235
+ {snapGrid}
1236
+ {initialViewport}
1237
+ colorMode={getResolvedTheme() as ColorMode}
1238
+ fitView={getEditorSettings().fitViewOnLoad}
1239
+ nodesDraggable={canvasEditable}
1240
+ nodesConnectable={canvasEditable}
1241
+ elementsSelectable={canvasEditable}
1242
+ >
1243
+ <!-- Renderless helpers. They live inside <SvelteFlow>, not beside it
1244
+ under a provider: @xyflow/svelte >= 1.6.6 replaces the provider's
1245
+ store with an empty one when a SvelteFlow is destroyed, so after
1246
+ the {#key} remount a helper outside would act on that empty
1247
+ store (context-menu Delete silently did nothing). -->
1248
+ <CanvasController bind:this={canvasControllerRef} />
1249
+ <EdgeRefresher {nodeIdToRefresh} onRefreshComplete={handleEdgeRefreshComplete} />
1250
+ <PortCoordinateTracker
1251
+ nodeToUpdate={portCoordNodeToUpdate}
1252
+ rebuildTrigger={portCoordRebuildTrigger}
1253
+ nodes={flowNodes}
1254
+ />
1255
+ <Controls />
1256
+ {#if canvasEditable && props.onToggleConsole}
1257
+ <CanvasIconButton
1258
+ class="flowdrop-console-toggle"
1259
+ label={props.consoleToggleLabel ?? m().layout.commandConsole}
1260
+ active={props.consoleOpen}
1261
+ onclick={props.onToggleConsole}
1262
+ >
1263
+ {#snippet icon()}
1264
+ <CommandLineIcon />
1265
+ {/snippet}
1266
+ </CanvasIconButton>
1267
+ {/if}
1268
+ <!-- Always render Background for consistent bg color in dark/light mode -->
1269
+ <Background
1270
+ gap={getEditorSettings().gridSize}
1271
+ bgColor="var(--fd-canvas-bg)"
1272
+ variant={gridVariant}
1273
+ lineWidth={1}
1274
+ patternColor={getEditorSettings().showGrid
1275
+ ? 'var(--fd-grid-pattern-color)'
1276
+ : 'transparent'}
1277
+ />
1278
+ {#if getEditorSettings().showMinimap}
1279
+ <MiniMap />
1280
+ {/if}
1281
+ </SvelteFlow>
1282
+ {/key}
1283
+ <!-- Drop Zone Indicator -->
1284
+ {#if flowNodes.length === 0}
1285
+ <CanvasBanner
1286
+ title="Drag components here to start building"
1287
+ description="Use the sidebar to add components to your workflow"
1288
+ >
1289
+ {#snippet icon()}
1290
+ <svg
1291
+ xmlns="http://www.w3.org/2000/svg"
1292
+ width="1em"
1293
+ height="1em"
1294
+ viewBox="0 0 24 24"
1295
+ fill="none"
1296
+ stroke="currentColor"
1297
+ stroke-width="1.5"
1298
+ stroke-linecap="round"
1299
+ stroke-linejoin="round"
1300
+ >
1301
+ <circle cx="18" cy="5" r="3" />
1302
+ <circle cx="6" cy="12" r="3" />
1303
+ <circle cx="18" cy="19" r="3" />
1304
+ <line x1="8.59" y1="13.51" x2="15.42" y2="17.49" />
1305
+ <line x1="15.41" y1="6.51" x2="8.59" y2="10.49" />
1306
+ </svg>
1307
+ {/snippet}
1308
+ </CanvasBanner>
1318
1309
  {/if}
1319
- </div>
1310
+ </FlowDropZone>
1311
+
1312
+ {#if openMenu}
1313
+ <CanvasContextMenu
1314
+ entries={openMenu.entries}
1315
+ x={openMenu.x}
1316
+ y={openMenu.y}
1317
+ onselect={selectContextMenuEntry}
1318
+ onclose={closeContextMenu}
1319
+ />
1320
+ {/if}
1321
+ </div>
1320
1322
 
1321
- <!-- Status Bar: aria-live announces dynamic changes (node/edge counts, cycle warnings) -->
1322
- <div class="flowdrop-status-bar" aria-live="polite" aria-atomic="true">
1323
- <div class="flowdrop-status-bar__content">
1324
- <div class="flowdrop-flex flowdrop-gap--4">
1325
- <span class="flowdrop-text--xs flowdrop-text--gray">{flowNodes.length} nodes</span>
1323
+ <!-- Status Bar: aria-live announces dynamic changes (node/edge counts, cycle warnings) -->
1324
+ <div class="flowdrop-status-bar" aria-live="polite" aria-atomic="true">
1325
+ <div class="flowdrop-status-bar__content">
1326
+ <div class="flowdrop-flex flowdrop-gap--4">
1327
+ <span class="flowdrop-text--xs flowdrop-text--gray">{flowNodes.length} nodes</span>
1328
+ <span class="flowdrop-text--xs flowdrop-text--gray">•</span>
1329
+ <span class="flowdrop-text--xs flowdrop-text--gray">{flowEdges.length} connections</span>
1330
+
1331
+ {#if hasCycles}
1326
1332
  <span class="flowdrop-text--xs flowdrop-text--gray">•</span>
1327
- <span class="flowdrop-text--xs flowdrop-text--gray">{flowEdges.length} connections</span
1333
+ <span class="flowdrop-text--xs flowdrop-font--medium flowdrop-text--error"
1334
+ >⚠️ Cycles detected</span
1328
1335
  >
1329
-
1330
- {#if hasCycles}
1331
- <span class="flowdrop-text--xs flowdrop-text--gray">•</span>
1332
- <span class="flowdrop-text--xs flowdrop-font--medium flowdrop-text--error"
1333
- >⚠️ Cycles detected</span
1334
- >
1335
- {/if}
1336
- </div>
1336
+ {/if}
1337
1337
  </div>
1338
1338
  </div>
1339
1339
  </div>
1340
1340
  </div>
1341
- </SvelteFlowProvider>
1341
+ </div>
1342
1342
 
1343
1343
  <!-- Toast notifications container -->
1344
1344
  <!-- aria-live="polite" ensures screen readers announce toast messages without interrupting -->
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "A drop-in visual workflow editor for any web application. You own the backend. You own the data. You own the orchestration.",
4
4
  "license": "MIT",
5
5
  "private": false,
6
- "version": "2.10.0",
6
+ "version": "2.10.1",
7
7
  "author": "Shibin Das (D34dMan)",
8
8
  "bugs": {
9
9
  "url": "https://github.com/flowdrop-io/flowdrop/issues"
@@ -224,7 +224,7 @@
224
224
  "@vitest/browser": "^3.2.3",
225
225
  "@vitest/coverage-v8": "^3.2.4",
226
226
  "@vitest/ui": "^3.2.4",
227
- "@xyflow/svelte": "^1.2",
227
+ "@xyflow/svelte": "^1.7.0",
228
228
  "codemirror": "^6.0.2",
229
229
  "eslint": "^9.18.0",
230
230
  "eslint-config-prettier": "^10.0.1",