@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.
Files changed (92) hide show
  1. package/CHANGELOG.md +200 -0
  2. package/dist/commands/executor.js +52 -8
  3. package/dist/commands/types.d.ts +3 -0
  4. package/dist/components/App.svelte +8 -0
  5. package/dist/components/App.svelte.d.ts +6 -0
  6. package/dist/components/CanvasContextMenu.stories.svelte +63 -0
  7. package/dist/components/CanvasContextMenu.stories.svelte.d.ts +19 -0
  8. package/dist/components/CanvasContextMenu.svelte +259 -0
  9. package/dist/components/CanvasContextMenu.svelte.d.ts +16 -0
  10. package/dist/components/CanvasController.svelte +24 -2
  11. package/dist/components/CanvasController.svelte.d.ts +16 -0
  12. package/dist/components/EdgeRefresher.svelte +1 -1
  13. package/dist/components/FlowDropZone.svelte +11 -7
  14. package/dist/components/FlowDropZone.svelte.d.ts +12 -0
  15. package/dist/components/PortCoordinateTracker.svelte +1 -1
  16. package/dist/components/UniversalNode.svelte +12 -13
  17. package/dist/components/WorkflowEditor.svelte +486 -149
  18. package/dist/components/WorkflowEditor.svelte.d.ts +7 -0
  19. package/dist/components/WorkflowInterfaceEditor.svelte +28 -3
  20. package/dist/components/WorkflowInterfaceEntryCard.svelte +112 -2
  21. package/dist/components/WorkflowInterfaceEntryCard.svelte.d.ts +3 -1
  22. package/dist/components/nodes/CaptionNode.stories.svelte +65 -0
  23. package/dist/components/nodes/CaptionNode.stories.svelte.d.ts +18 -0
  24. package/dist/components/nodes/CaptionNode.svelte +313 -0
  25. package/dist/components/nodes/CaptionNode.svelte.d.ts +16 -0
  26. package/dist/components/nodes/NotesNode.svelte +6 -0
  27. package/dist/components/playground/ChatBubble.svelte +2 -0
  28. package/dist/components/playground/ChatInput.svelte +18 -34
  29. package/dist/components/playground/ChatInput.svelte.d.ts +7 -0
  30. package/dist/components/playground/ControlPanel.svelte +27 -0
  31. package/dist/components/playground/ControlPanel.svelte.d.ts +12 -0
  32. package/dist/components/playground/ExecutionLogs.svelte +11 -8
  33. package/dist/components/playground/InterfaceInputForm.svelte +74 -0
  34. package/dist/components/playground/InterfaceInputForm.svelte.d.ts +14 -0
  35. package/dist/components/playground/LogRow.svelte +2 -0
  36. package/dist/components/playground/MessageCard.svelte +15 -3
  37. package/dist/components/playground/MessageNotice.svelte +2 -0
  38. package/dist/components/playground/MessageStream.svelte +87 -23
  39. package/dist/components/playground/OriginBadge.svelte +48 -0
  40. package/dist/components/playground/OriginBadge.svelte.d.ts +7 -0
  41. package/dist/components/playground/Playground.svelte +155 -38
  42. package/dist/components/playground/messageDisplay.d.ts +23 -1
  43. package/dist/components/playground/messageDisplay.js +49 -0
  44. package/dist/config/endpoints.d.ts +65 -0
  45. package/dist/config/endpoints.js +39 -0
  46. package/dist/core/index.d.ts +6 -3
  47. package/dist/core/index.js +2 -1
  48. package/dist/editor/contextMenu.d.ts +107 -0
  49. package/dist/editor/contextMenu.js +134 -0
  50. package/dist/editor/index.d.ts +2 -0
  51. package/dist/editor/index.js +1 -0
  52. package/dist/index.d.ts +1 -1
  53. package/dist/index.js +1 -1
  54. package/dist/messages/defaults.d.ts +63 -0
  55. package/dist/messages/defaults.js +59 -0
  56. package/dist/openapi/v1/openapi.yaml +356 -7
  57. package/dist/playground/commands/registry.js +4 -2
  58. package/dist/playground/index.d.ts +3 -2
  59. package/dist/playground/index.js +2 -1
  60. package/dist/registry/builtinNodeTypes.d.ts +1 -1
  61. package/dist/registry/builtinNodeTypes.js +1 -0
  62. package/dist/registry/builtinNodes.js +13 -0
  63. package/dist/registry/nodeComponentRegistry.d.ts +18 -0
  64. package/dist/registry/nodeComponentRegistry.js +14 -2
  65. package/dist/schemas/v1/workflow.schema.json +22 -1
  66. package/dist/services/historyService.d.ts +1 -1
  67. package/dist/services/historyService.js +2 -2
  68. package/dist/services/playgroundService.d.ts +35 -1
  69. package/dist/services/playgroundService.js +82 -36
  70. package/dist/stores/inlineEditStore.svelte.d.ts +35 -0
  71. package/dist/stores/inlineEditStore.svelte.js +63 -0
  72. package/dist/stores/instanceContainer.svelte.d.ts +6 -0
  73. package/dist/stores/instanceContainer.svelte.js +2 -0
  74. package/dist/stores/playgroundStore.svelte.d.ts +59 -2
  75. package/dist/stores/playgroundStore.svelte.js +128 -2
  76. package/dist/styles/base.css +8 -0
  77. package/dist/styles/tokens.css +8 -0
  78. package/dist/svelte-app.d.ts +15 -0
  79. package/dist/svelte-app.js +6 -4
  80. package/dist/types/index.d.ts +34 -1
  81. package/dist/types/index.js +11 -0
  82. package/dist/types/playground.d.ts +90 -9
  83. package/dist/types/playground.js +12 -4
  84. package/dist/utils/captionText.d.ts +43 -0
  85. package/dist/utils/captionText.js +49 -0
  86. package/dist/utils/focus.d.ts +16 -0
  87. package/dist/utils/focus.js +40 -0
  88. package/dist/utils/nodeTypes.js +1 -0
  89. package/dist/utils/nodeWrapper.js +2 -0
  90. package/dist/utils/workflowInterface.d.ts +83 -1
  91. package/dist/utils/workflowInterface.js +192 -1
  92. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -5,6 +5,206 @@ 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
+
21
+ ## [2.10.0] - 2026-10-07
22
+
23
+ ### Added
24
+
25
+ - Interface entries take an optional `turn`: what the port is for in a chat
26
+ turn. Inputs may be `message`, `history`, `session_id` or `message_id` (at
27
+ most one input per value); outputs may be `reply` (any number). A `history`
28
+ entry reads its window from `meta.limit` (default 10). The interface editor
29
+ gains a **Chat turn** selector under "More options" that offers only the
30
+ values valid for the entry's side, warns inline when another input already
31
+ has the value, and adds a "Messages to include" field for `history`. The
32
+ chosen turn shows on the collapsed card. "None" removes the key; a turn this
33
+ editor does not know is listed as it is and round-trips untouched. New type
34
+ `WorkflowInterfaceTurn` and constants `WORKFLOW_INTERFACE_INPUT_TURNS`,
35
+ `WORKFLOW_INTERFACE_OUTPUT_TURNS` and `DEFAULT_HISTORY_TURN_LIMIT` from
36
+ `core`. `validateWorkflowInterface` reports `interface-turn-duplicate` and
37
+ `interface-turn-direction` (warnings). `WorkflowInterfaceEntry.turn` is typed
38
+ `WorkflowInterfaceTurn | (string & {})`: a value from a newer server is a
39
+ valid `turn` and round-trips; check it against the known values before indexing by it.
40
+ - Playground messages carry an `origin` (`user`, `workflow`, `engine`,
41
+ `playground` or `interrupt`): which component posted the row. Rows posted by
42
+ the engine, a console observer or the interrupt system get a small,
43
+ muted origin badge; user and workflow rows, and rows from servers that do not
44
+ send `origin`, get none. New types `PlaygroundMessageOrigin` and
45
+ `ResolvedMessageDisplay`; `PlaygroundMessageDisplay` is now exported from
46
+ `core` and `playground`.
47
+ - The message `display` hint accepts `default` (same as no hint) and `hidden`.
48
+ Hidden rows are kept in the store but not rendered in the message stream or
49
+ the execution logs panel. Hidden is not private: the row has reached the
50
+ browser, so it hides noise, never secrets.
51
+ - Three or more adjacent log-layout rows in the message stream fold into a
52
+ collapsible group ("n log lines"), open by default.
53
+ - Canvas context menu. Right-clicking a node opens a menu with Configure and
54
+ Delete; right-clicking a multi-selection offers "Delete n nodes". Delete runs
55
+ through the same path as the Delete key, so the confirm-delete setting
56
+ applies, connected edges go with the node, and one undo restores both.
57
+ Right-clicking an unselected node selects it first. The menu only opens in
58
+ edit mode (read-only and locked editors keep the browser's own menu), is
59
+ keyboard operable (arrow keys, Home/End, Enter, Escape), and closes on an
60
+ outside click, zoom, pan or window blur. It is a popover in the top layer,
61
+ so no canvas overflow or stacking context can clip or cover it.
62
+ - Shift+F10 and the Menu key open the context menu from the keyboard: on a
63
+ focused node it opens that node's menu, elsewhere on the canvas it opens the
64
+ canvas menu at the centre of the view.
65
+ - `contextMenu.items` mount option (and `contextMenu` prop on `App` and
66
+ `WorkflowEditor`). It receives the built-in entries and the click context
67
+ (`target`, `nodes`, grid-snapped flow `position`, `nodeTypes`, `actions`) and
68
+ returns the final list, so a host can add, remove or reorder entries. If it
69
+ throws or returns a non-array the built-in entries are used; an entry's `run`
70
+ may be async, and its errors (thrown or rejected) are logged and never break the canvas.
71
+ `actions.deleteNodes` returns a promise, so an async `run` can await the deletion
72
+ (including the confirm prompt) before doing more. The `ContextMenuContext`,
73
+ `ContextMenuEntry`, `ContextMenuActions`, `ContextMenuOptions` and
74
+ `ContextMenuTarget` types are exported from `@flowdrop/flowdrop/editor`.
75
+ - `messages.contextMenu` strings (`menuLabel`, `configure`, `delete`,
76
+ `deleteNodes`) so the menu can be translated.
77
+ - Caption node (`caption`): a short, high-contrast line of text (one or two
78
+ lines) that names or marks nearby nodes, for anything a note would be too
79
+ heavy for. It has no ports, no config panel and no status overlay, and its
80
+ text is the node's label. The width follows the text, rounded up to the grid
81
+ and kept between two grid steps (40px on the default grid) and 500px; the
82
+ height is 40px for one line and 60px for two, and longer text is cut off with
83
+ an ellipsis and shown in full as a tooltip. Right-click empty canvas and
84
+ choose "Add caption" (shown when the editor's node types include a node type
85
+ whose `type` is `caption`, or lists `caption` in `supportedTypes`; a backend
86
+ without one gets no menu entry). The new caption opens for typing; Enter or
87
+ clicking away saves, Escape cancels, and an empty or cancelled new caption is
88
+ removed without an undo entry. To edit an existing caption, double-click it,
89
+ press Enter on the focused node, or choose "Edit text" from its menu (which
90
+ replaces Configure for captions). Newlines and pasted formatting are never
91
+ stored, and saving an edit is one undo step ("Add caption" / "Edit caption").
92
+ `CaptionNode` is exported from `@flowdrop/flowdrop/editor`.
93
+ - `--fd-caption-node-bg` and `--fd-caption-node-fg` (default to the theme's
94
+ foreground and background, so the caption reads as inverted in light and dark)
95
+ and `--fd-caption-node-max-width` (500px) tokens for the caption node.
96
+ - `editsInPlace` option on node component registrations (`NodeComponentRegistration`,
97
+ `PluginNodeDefinition` and `registerCustom`): a node that sets it edits its
98
+ text in place, so Enter on the focused node, a double-click and the node
99
+ context menu's "Edit text" ask it to start typing instead of opening the
100
+ config panel. `fd.nodes.editsInPlace(type)` reads it, and `fd.inlineEdit` is
101
+ the channel: a component calls `register(id, start)` on mount (it gets back
102
+ the unregister function), and `request(id)` calls that starter, or holds the
103
+ request until the node registers.
104
+ - `messages.contextMenu.addCaption`, `editText`, `shortcutEnter` and
105
+ `shortcutDelete` (the key hints beside an entry), and a `messages.nodes.caption`
106
+ branch (`placeholder`, `editLabel`), so the caption's strings can be translated.
107
+
108
+ - The Playground reads its input from the workflow interface's turn ports.
109
+ An input with `turn: message` gets the chat box (its content fills that
110
+ port). Turn ports but no `message` input: the inputs without a turn render
111
+ as a form (built from each entry's schema fragment and `dataType`) with a
112
+ Run button, and the turn sends `inputs` and no content. Nothing to fill:
113
+ Run alone. A workflow with a `message` port and other inputs gets the chat
114
+ box with the form above it. Turn-filled ports (`history`, `session_id`,
115
+ `message_id`, and any turn value a newer server adds) never appear in the
116
+ form. A workflow whose interface declares no `turn` at all, and every
117
+ server that predates turn ports, keeps the previous behaviour exactly.
118
+ `showChatInput: false` still hides the chat box; it cannot add one to a
119
+ workflow without a `message` port, and `predefinedMessage` is ignored
120
+ there, because its server refuses message content. Blank required inputs
121
+ are refused before the request; a server refusal (such as the 400 for
122
+ content sent to a form-only workflow) is shown with the server's message
123
+ and leaves Run usable. When the host passes no workflow, or one without an
124
+ `interface` key, the Playground loads it through `workflows.get`; a failure
125
+ keeps the previous behaviour. New: `resolvePlaygroundInputMode()`,
126
+ `interfaceFormEntries()`, `interfaceFormSchema()` and type
127
+ `PlaygroundInputMode` (`playground`; the type also from `core`); store
128
+ getters `fd.playground.inputMode` and `fd.playground.interfaceFormEntries`;
129
+ `messages.playground.inputForm` (`title`, `missingRequired`). The form's
130
+ values and what a turn would send now live in the store:
131
+ `fd.playground.formValues` / `setFormValues()`, and `fd.playground.turnInputs`
132
+ (the inputs, or the required ones still missing, so a Run control can open the
133
+ form instead of failing); new pure `collectInterfaceInputs()` and type
134
+ `InterfaceInputsResult` (`playground`). `fd.playground.lastTurn` /
135
+ `setLastTurn()` hold the sessions door's answer for the turn just taken.
136
+ Run works again for every turn of a session: the one gate any Run control
137
+ reads is `fd.playground.canRun` (not executing, no turn request in flight,
138
+ and not waiting for the legacy `enableRun` message), with `turnPending`,
139
+ `runLocked`, `setTurnPending()`, `lockRunUntilEnabled()` and
140
+ `releaseRunLock()` behind it. `ChatInput` and `ControlPanel` take
141
+ `awaitEnableRun` (default `true`, the old protocol: a Run click locks Run
142
+ until a message with `enableRun` metadata arrives); the Playground turns it
143
+ off for turn-port workflows, whose server never sends it.
144
+ - Optional `sessions` endpoint group: one session's own HTTP surface
145
+ (`get`, `delete`, `messages`, `turn`, `stop`, optional `reset`), served by
146
+ FlowDrop Drupal under `/api/flowdrop/sessions/{sessionId}/…` from the
147
+ release that ships it. When a host configures the group, every per-session
148
+ call goes there; when it does not, the calls stay on the matching
149
+ `playground` keys, so nothing changes against servers that predate it.
150
+ Listing and creating sessions for a workflow stay on `playground`. The
151
+ group is not in `defaultEndpointConfig` (hosts merge groups over the
152
+ defaults, so a default would move every host to paths its server may not
153
+ serve); hosts opt in with the new `sessionsEndpoints` constant. New
154
+ `resolveSessionEndpoint()` and types `SessionEndpointKey`,
155
+ `ResolvedSessionEndpoint`. `/reset` is offered when the winning group has
156
+ a reset path.
157
+ - `PlaygroundService.sendTurn(config, sessionId, {content?, inputs?})` takes
158
+ a turn through whichever door is configured and returns the answer tagged:
159
+ `{kind: 'message', message}` from `playground.sendMessage`,
160
+ `{kind: 'turn', result}` from `sessions.turn` (new type
161
+ `PlaygroundTurnResult`; `PlaygroundTurnResponse`). The Playground uses it.
162
+ `PlaygroundMessageRequest.content` is optional (a form-only workflow takes
163
+ `inputs` alone). Which kind comes back follows the endpoint group the
164
+ request went to, not the shape of the payload. OpenAPI documents the `/sessions/{sessionId}` paths and
165
+ the turn result.
166
+
167
+ ### Upgrade notes
168
+
169
+ Type-only changes. Nothing changes at runtime, but TypeScript code can stop
170
+ compiling:
171
+
172
+ - `PlaygroundMessageDisplay` gained `'default'` and `'hidden'`. An exhaustive
173
+ `switch` over it (with a `never` check) must handle both.
174
+ - `PlaygroundStoreActions` gained `setTurnPending`, `lockRunUntilEnabled`,
175
+ `releaseRunLock`, `setFormValues` and `setLastTurn`. Code that implements the
176
+ interface itself, such as a hand-written mock, must add them.
177
+ - `PlaygroundMessageRequest.content` is now optional (see Added), so code that
178
+ reads it as a `string` must handle `undefined`.
179
+
180
+ ### Deprecated
181
+
182
+ - `PlaygroundService.sendMessage()`: use `sendTurn()`. It throws when the
183
+ configured door answers with a turn result instead of a message row.
184
+
185
+ ### Fixed
186
+
187
+ - The Playground read its translated strings with `m()` inside event
188
+ handlers, which throws outside component initialisation: slash commands,
189
+ a refused launch from Run, and Run's fallback message failed with
190
+ `lifecycle_outside_component`. The strings are now read through a getter
191
+ taken at init.
192
+ - `describe_type`, `get_config` and `set_config` now see the allowed values of a
193
+ config key declared as a `oneOf` (or `anyOf`) of `{ const, title }`, the
194
+ shape the form already renders as a select (#41). The values are reported as
195
+ `enum`, with the titles in a new optional `enumTitles` map on
196
+ `ConfigKeyDescription`; a value outside them gets the same `allowedValues`
197
+ warning as an `enum` violation, and `CONFIG_VALIDATION_ERROR` in strict mode.
198
+ `enum` wins when both are present; a `oneOf` of sub-schemas is ignored.
199
+ - `layout auto` no longer collapses a workflow into one column when a node
200
+ with no edges (a note) comes first in the node list: the start node is the
201
+ first node with no incoming and at least one outgoing edge (#45). A workflow
202
+ without any such node lays out as before.
203
+ - Legacy Run (`awaitEnableRun`) no longer stays locked when `predefinedMessage`
204
+ is a slash command such as `/help`: the command runs without taking a turn,
205
+ so no `enableRun` message ever arrived to unlock Run. The lock is released
206
+ once the command has been sent.
207
+
8
208
  ## [2.9.0] - 2026-10-04
9
209
 
10
210
  ### Fixed
@@ -153,6 +153,36 @@ function describePort(p) {
153
153
  out.description = p.description;
154
154
  return out;
155
155
  }
156
+ /**
157
+ * The allowed values of a config key, as a plain list plus titles.
158
+ *
159
+ * `enum` wins when present. Otherwise a `oneOf` (or `anyOf`) whose every entry
160
+ * is `{ const, title? }` counts as the allowed values: the form already renders
161
+ * that shape as a select, so the agent tools must treat it the same way. A
162
+ * `oneOf` holding anything else (sub-schemas) says nothing about allowed values
163
+ * and is ignored.
164
+ */
165
+ function allowedValuesOf(property) {
166
+ if (property.enum && property.enum.length > 0)
167
+ return { values: property.enum };
168
+ for (const alternatives of [property.oneOf, property.anyOf]) {
169
+ if (!Array.isArray(alternatives) || alternatives.length === 0)
170
+ continue;
171
+ const isConst = (e) => typeof e === 'object' && e !== null && 'const' in e;
172
+ if (!alternatives.every(isConst))
173
+ continue;
174
+ const labels = {};
175
+ for (const entry of alternatives) {
176
+ if (typeof entry.title === 'string' && entry.title)
177
+ labels[String(entry.const)] = entry.title;
178
+ }
179
+ return {
180
+ values: alternatives.map((e) => e.const),
181
+ ...(Object.keys(labels).length > 0 ? { labels } : {})
182
+ };
183
+ }
184
+ return undefined;
185
+ }
156
186
  function describeConfigKey(key, property, required) {
157
187
  const out = { key };
158
188
  if (property) {
@@ -164,8 +194,12 @@ function describeConfigKey(key, property, required) {
164
194
  out.title = property.title;
165
195
  if (property.description)
166
196
  out.description = property.description;
167
- if (property.enum && property.enum.length > 0)
168
- out.enum = property.enum;
197
+ const allowed = allowedValuesOf(property);
198
+ if (allowed) {
199
+ out.enum = allowed.values;
200
+ if (allowed.labels)
201
+ out.enumTitles = allowed.labels;
202
+ }
169
203
  if (property.default !== undefined)
170
204
  out.default = property.default;
171
205
  }
@@ -325,13 +359,14 @@ function validateConfigValue(key, value, property) {
325
359
  if (!property)
326
360
  return [];
327
361
  const warnings = [];
328
- // Enum validation
329
- if (property.enum && property.enum.length > 0) {
330
- if (!property.enum.includes(value)) {
362
+ // Enum validation (a oneOf of consts counts as an enum)
363
+ const allowed = allowedValuesOf(property)?.values;
364
+ if (allowed) {
365
+ if (!allowed.includes(value)) {
331
366
  warnings.push({
332
367
  type: 'enum',
333
- message: `Value ${JSON.stringify(value)} is not in allowed values: ${property.enum.map((v) => JSON.stringify(v)).join(', ')}`,
334
- allowedValues: property.enum
368
+ message: `Value ${JSON.stringify(value)} is not in allowed values: ${allowed.map((v) => JSON.stringify(v)).join(', ')}`,
369
+ allowedValues: allowed
335
370
  });
336
371
  }
337
372
  }
@@ -1217,7 +1252,16 @@ function executeAutoLayout(command, context) {
1217
1252
  for (const e of layoutEdges) {
1218
1253
  inDegree.set(e.target, (inDegree.get(e.target) ?? 0) + 1);
1219
1254
  }
1220
- const startNode = workflow.nodes.find((n) => (inDegree.get(n.id) ?? 0) === 0)?.id ??
1255
+ // Prefer a root that also has an outgoing edge: a node with no edges at all
1256
+ // (a note, a caption) is in-degree 0 too, and starting the layering there
1257
+ // reaches nothing, which flattens the whole workflow into one column.
1258
+ const outDegree = new Map();
1259
+ for (const e of layoutEdges) {
1260
+ outDegree.set(e.source, (outDegree.get(e.source) ?? 0) + 1);
1261
+ }
1262
+ const startNode = workflow.nodes.find((n) => (inDegree.get(n.id) ?? 0) === 0 && (outDegree.get(n.id) ?? 0) > 0)
1263
+ ?.id ??
1264
+ workflow.nodes.find((n) => (inDegree.get(n.id) ?? 0) === 0)?.id ??
1221
1265
  workflow.nodes.reduce((leftmost, n) => (n.position.x < leftmost.position.x ? n : leftmost)).id;
1222
1266
  const flow = {
1223
1267
  component_type: 'flow',
@@ -211,7 +211,10 @@ export interface ConfigKeyDescription {
211
211
  type?: string | string[];
212
212
  title?: string;
213
213
  description?: string;
214
+ /** Allowed values: the schema's `enum`, or the consts of a `oneOf`/`anyOf` of `{ const, title }`. */
214
215
  enum?: unknown[];
216
+ /** Display titles for the allowed values, keyed by the value as a string. Only present when the schema gave titles. */
217
+ enumTitles?: Record<string, string>;
215
218
  default?: unknown;
216
219
  required?: boolean;
217
220
  }
@@ -5,6 +5,7 @@
5
5
  -->
6
6
 
7
7
  <script lang="ts">
8
+ import type { ContextMenuOptions } from '../editor/contextMenu.js';
8
9
  import { onMount, tick, untrack } from 'svelte';
9
10
  import MainLayout from './layouts/MainLayout.svelte';
10
11
  import WorkflowEditor from './WorkflowEditor.svelte';
@@ -183,6 +184,11 @@
183
184
  * function call you'd rather not invoke unless the prop is actually read.
184
185
  */
185
186
  messages?: MessagesOverride | (() => MessagesOverride);
187
+ /**
188
+ * Customise the canvas context menu. `items` receives the built-in entries
189
+ * and returns the final list. The menu only opens in `'edit'` mode.
190
+ */
191
+ contextMenu?: ContextMenuOptions;
186
192
  /** Per-instance state container (created by mount functions). Defaults to the page-default instance. */
187
193
  instance?: FlowDropInstance;
188
194
  }
@@ -222,6 +228,7 @@
222
228
  workflowSettingsSchema,
223
229
  workflowFormats,
224
230
  messages: messagesOverride,
231
+ contextMenu,
225
232
  instance
226
233
  }: Props = $props();
227
234
 
@@ -1613,6 +1620,7 @@
1613
1620
  {pipelineId}
1614
1621
  {refreshTrigger}
1615
1622
  builtinEditors={features.builtinEditors}
1623
+ {contextMenu}
1616
1624
  gridVariant={themeConfig?.canvas?.grid ?? 'dots'}
1617
1625
  consoleOpen={consoleActive}
1618
1626
  onToggleConsole={consoleGroupOffered ? toggleConsole : undefined}
@@ -1,3 +1,4 @@
1
+ import type { ContextMenuOptions } from '../editor/contextMenu.js';
1
2
  import type { NavbarAction } from '../types/navbar.js';
2
3
  import type { NodeMetadata, Workflow, ConfigSchema } from '../types/index.js';
3
4
  import type { SwapStrategy } from '../utils/nodeSwap.js';
@@ -128,6 +129,11 @@ interface Props {
128
129
  * function call you'd rather not invoke unless the prop is actually read.
129
130
  */
130
131
  messages?: MessagesOverride | (() => MessagesOverride);
132
+ /**
133
+ * Customise the canvas context menu. `items` receives the built-in entries
134
+ * and returns the final list. The menu only opens in `'edit'` mode.
135
+ */
136
+ contextMenu?: ContextMenuOptions;
131
137
  /** Per-instance state container (created by mount functions). Defaults to the page-default instance. */
132
138
  instance?: FlowDropInstance;
133
139
  }
@@ -0,0 +1,63 @@
1
+ <script module lang="ts">
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ import CanvasContextMenu from './CanvasContextMenu.svelte';
4
+ import CanvasDecorator from '../stories/CanvasDecorator.svelte';
5
+ import type { ContextMenuEntry } from '../editor/contextMenu.js';
6
+
7
+ const { Story } = defineMeta({
8
+ title: 'Editor/CanvasContextMenu',
9
+ tags: ['autodocs'],
10
+ parameters: {
11
+ layout: 'centered'
12
+ }
13
+ });
14
+
15
+ const noop = (): void => {};
16
+
17
+ const nodeEntries: ContextMenuEntry[] = [
18
+ { id: 'configure', label: 'Configure', shortcut: 'Enter', run: noop },
19
+ { id: 'separator-node', separator: true },
20
+ { id: 'delete', label: 'Delete', shortcut: 'Delete', run: noop }
21
+ ];
22
+
23
+ const selectionEntries: ContextMenuEntry[] = [
24
+ { id: 'delete', label: 'Delete 3 nodes', shortcut: 'Delete', run: noop }
25
+ ];
26
+
27
+ const consumerEntries: ContextMenuEntry[] = [
28
+ ...nodeEntries,
29
+ { id: 'separator-consumer', separator: true },
30
+ { id: 'open-docs', label: 'Open documentation', icon: 'mdi:book-open-variant', run: noop }
31
+ ];
32
+
33
+ const disabledEntries: ContextMenuEntry[] = [
34
+ { id: 'configure', label: 'Configure', shortcut: 'Enter', run: noop },
35
+ { id: 'publish', label: 'Publish (not allowed here)', disabled: true, run: noop },
36
+ { id: 'separator-node', separator: true },
37
+ { id: 'delete', label: 'Delete', shortcut: 'Delete', run: noop }
38
+ ];
39
+ </script>
40
+
41
+ <Story name="Node">
42
+ <CanvasDecorator>
43
+ <CanvasContextMenu entries={nodeEntries} x={40} y={40} onselect={noop} onclose={noop} />
44
+ </CanvasDecorator>
45
+ </Story>
46
+
47
+ <Story name="Selection">
48
+ <CanvasDecorator>
49
+ <CanvasContextMenu entries={selectionEntries} x={40} y={40} onselect={noop} onclose={noop} />
50
+ </CanvasDecorator>
51
+ </Story>
52
+
53
+ <Story name="Consumer entry">
54
+ <CanvasDecorator>
55
+ <CanvasContextMenu entries={consumerEntries} x={40} y={40} onselect={noop} onclose={noop} />
56
+ </CanvasDecorator>
57
+ </Story>
58
+
59
+ <Story name="Disabled entry">
60
+ <CanvasDecorator>
61
+ <CanvasContextMenu entries={disabledEntries} x={40} y={40} onselect={noop} onclose={noop} />
62
+ </CanvasDecorator>
63
+ </Story>
@@ -0,0 +1,19 @@
1
+ import CanvasContextMenu from './CanvasContextMenu.svelte';
2
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
3
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
+ $$bindings?: Bindings;
5
+ } & Exports;
6
+ (internal: unknown, props: {
7
+ $$events?: Events;
8
+ $$slots?: Slots;
9
+ }): Exports & {
10
+ $set?: any;
11
+ $on?: any;
12
+ };
13
+ z_$$bindings?: Bindings;
14
+ }
15
+ declare const CanvasContextMenu: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
16
+ [evt: string]: CustomEvent<any>;
17
+ }, {}, {}, string>;
18
+ type CanvasContextMenu = InstanceType<typeof CanvasContextMenu>;
19
+ export default CanvasContextMenu;