@flowdrop/flowdrop 2.14.0 → 2.15.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,72 @@ 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.15.1] - 2026-10-17
9
+
10
+ ### Fixed
11
+
12
+ - **An autocomplete dropdown that opens above its field stays next to the field.** When there was too
13
+ little room below, the list was meant to open above the field but stuck to the top of the window
14
+ instead, which is where the third field of a cascade usually ended up.
15
+ - **A filled autocomplete field shows its label when the form opens.** It used to show the stored value
16
+ (`org-acme` instead of "Acme Corp") until the field was focused, because labels were only learned from
17
+ suggestions. When the field's config allows an empty query (`fetchOnFocus: true` and `minChars: 0`), it
18
+ now sends that empty query once when the form opens, and again when an undo or external edit brings in
19
+ values it has no label for: one extra request per filled field. Only values in that response get a
20
+ label, so an endpoint that returns just its first page leaves the others showing the stored value, as
21
+ do other configs until a search returns them. The request goes through the auth provider like any
22
+ other, so a `401`/`403` from it reaches `onUnauthorized`/`onForbidden` when the form opens. It runs
23
+ beside the field's own requests: no spinner, no error in the dropdown (a failure is only logged), and
24
+ focusing the field still loads its suggestions as before.
25
+ - **An autocomplete field keeps its loading state while a newer search is in flight.** A cancelled
26
+ request used to clear the spinner of the search that replaced it, and left that search impossible to
27
+ cancel, so results for old dependency values could still land after a dependency field changed.
28
+ - **An autocomplete search that times out says so.** After 5 seconds the request was cancelled like a
29
+ superseded one, leaving an empty list with no error and no retry. It now shows "The request timed
30
+ out" (`form.autocomplete.timedOut`, translatable like the other messages) with the retry button.
31
+ - **Requests that get a `401` at the same time share one `onUnauthorized()` call.** Each used to call it,
32
+ so a form whose autocomplete fields looked up their labels with an expired token refreshed it (or
33
+ asked for a login) once per field. They now wait for the one call and retry with its result; the next
34
+ `401` after it settles calls it again.
35
+
36
+ ## [2.15.0] - 2026-10-16
37
+
38
+ ### Added
39
+
40
+ - **`runCommand` on the object `mountFlowDropApp` and `mountWorkflowEditor` return** (#53).
41
+ `await app.runCommand('layout auto')` runs one Command Console command (a line, or a parsed
42
+ `Command`) against the mount's workflow and resolves with its `CommandResult`. It waits for the
43
+ workflow to load, so it can be called right after mounting, and it is one undo step like the
44
+ console. `{ baseline: true }` makes the result the workflow's clean starting point (not dirty,
45
+ undo history cleared) and is refused with `code: 'DIRTY'` when there are unsaved changes; it does not
46
+ call `onDirtyStateChange` or `onWorkflowChange`, and `undo`/`redo` cannot run as a baseline. A `Command`
47
+ object is checked before it runs: an unknown type or a missing or mistyped field resolves with
48
+ `code: 'INVALID_ARGUMENT'`. The promise never rejects (a command that throws resolves with
49
+ `code: 'INTERNAL_ERROR'`). Works on read-only mounts. A command's UI actions (select, open config, fit/zoom/pan) are applied by the
50
+ `mountFlowDropApp` shell and dropped by `mountWorkflowEditor`.
51
+ - **`onExternalEdit` event handler** (#55). A node's `externalEditLink` can now be handled by the host
52
+ instead of navigating away: the handler receives copies of `(node, link)` and resolves with the node's new config
53
+ (it replaces the config, as one undo step, and is copied) or with nothing to leave the node as it is.
54
+ Field edits still pending in the form are committed before the handler is called. It covers every
55
+ place the link opens: the inspector row ("Runs … ↗"), the form buttons and the empty state. The link
56
+ keeps its `href`, so middle-click and "copy link" still work. `ConfigForm` takes the same `onExternalEdit`
57
+ prop. While the editor is read-only or locked the handler is still called but its result is not written.
58
+ Without the handler nothing changes.
59
+ - **`Command`, `CommandResult`, `CommandErrorCode`, `ConfigValues` and `ExternalEditLink` types** are
60
+ exported from the main entry and `./editor` too, so hosts can type `runCommand` and `onExternalEdit`
61
+ without importing `./core`.
62
+
63
+ ### Deprecated
64
+
65
+ - **`ExternalEditLink.callbackUrlParam`.** It never had any effect, because nothing passes a callback URL.
66
+ Use `onExternalEdit` to get the config back from the host's form.
67
+
68
+ ### Fixed
69
+
70
+ - **`mountFlowDropApp` passes `workflowSettingsSchema` on to the editor** (#54). The option existed on
71
+ `App` but the mount function dropped it, so hosts mounting through the public API (the IIFE build
72
+ included) could not add their own Workflow Settings fields. Their values are stored in `workflow.config`.
73
+
8
74
  ## [2.14.0] - 2026-10-16
9
75
 
10
76
  ### Added
@@ -9,6 +9,7 @@ import { buildEndpointUrl, getEndpointMethod, getRequestHeaders } from '../confi
9
9
  import { NoAuthProvider } from '../types/auth.js';
10
10
  import { getApiSettings } from '../stores/settingsStore.svelte.js';
11
11
  import { logger } from '../utils/logger.js';
12
+ import { refreshAuth } from '../utils/fetchWithAuth.js';
12
13
  import { DEFAULT_API_TIMEOUT_MS } from '../config/constants.js';
13
14
  /**
14
15
  * API error with additional context
@@ -166,7 +167,7 @@ export class EnhancedFlowDropApiClient {
166
167
  // Handle 401 Unauthorized
167
168
  if (response.status === 401) {
168
169
  if (this.authProvider.onUnauthorized) {
169
- const refreshed = await this.authProvider.onUnauthorized();
170
+ const refreshed = await refreshAuth(this.authProvider);
170
171
  if (refreshed && attempt < maxAttempts) {
171
172
  // Rebuild headers via the shared path to pick up the fresh token.
172
173
  fetchConfig.headers = {
@@ -187,11 +187,15 @@ export type ParseResult = {
187
187
  error: string;
188
188
  input: string;
189
189
  };
190
- export type CommandErrorCode = 'NODE_NOT_FOUND' | 'NODE_TYPE_NOT_FOUND' | 'PORT_NOT_FOUND' | 'EDGE_NOT_FOUND' | 'INVALID_CONNECTION' | 'CYCLE_DETECTED' | 'NO_WORKFLOW' | 'PARSE_ERROR'
190
+ export type CommandErrorCode = 'NODE_NOT_FOUND' | 'NODE_TYPE_NOT_FOUND' | 'PORT_NOT_FOUND' | 'EDGE_NOT_FOUND' | 'INVALID_CONNECTION' | 'CYCLE_DETECTED' | 'NO_WORKFLOW'
191
+ /** `runCommand({ baseline: true })` on a workflow with unsaved changes: nothing was run. */
192
+ | 'DIRTY' | 'PARSE_ERROR'
191
193
  /** An argument is out of range, e.g. a layout gap that is not a multiple of the grid. */
192
194
  | 'INVALID_ARGUMENT'
193
195
  /** The graph is past what the command takes on, e.g. too many nodes to tidy at once. */
194
- | 'TOO_LARGE' | 'UNKNOWN_COMMAND' | 'CONFIG_KEY_NOT_FOUND'
196
+ | 'TOO_LARGE' | 'UNKNOWN_COMMAND'
197
+ /** The command threw instead of returning a result (a bug, not bad input): see the console. */
198
+ | 'INTERNAL_ERROR' | 'CONFIG_KEY_NOT_FOUND'
195
199
  /** search_types with a blank query — use list_types for the whole catalog. */
196
200
  | 'EMPTY_QUERY' | 'CONFIG_VALIDATION_ERROR' | 'UNDO_UNAVAILABLE' | 'REDO_UNAVAILABLE'
197
201
  /** A Console `session` command refused: busy, wrong input mode, nothing to act on. */
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Where the mount API's `runCommand` sends a command's UI actions (select a
3
+ * node, open its config panel, fit/zoom/pan the canvas).
4
+ *
5
+ * The editor shell (`App`) registers its handler for its instance while it is
6
+ * mounted. Kept off `FlowDropInstance` on purpose: it is internal, not
7
+ * exported from any entry point, so hosts cannot replace it.
8
+ *
9
+ * @module commands/uiActionTarget
10
+ */
11
+ import type { FlowDropInstance } from '../stores/instanceContainer.svelte.js';
12
+ import type { UIAction } from './types.js';
13
+ type UIActionHandler = (action: UIAction) => void;
14
+ /**
15
+ * Make `handler` the instance's UI-action target. The returned release only
16
+ * clears it while `handler` is still the target, so a shell mounted later
17
+ * keeps its own registration when an earlier one goes away.
18
+ */
19
+ export declare function provideUIActionTarget(instance: FlowDropInstance, handler: UIActionHandler): () => void;
20
+ /** Hand `action` to the instance's target; dropped when there is none. */
21
+ export declare function dispatchUIAction(instance: FlowDropInstance, action: UIAction): void;
22
+ /** Whether a shell has registered a target for the instance (for tests). */
23
+ export declare function hasUIActionTarget(instance: FlowDropInstance): boolean;
24
+ export {};
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Where the mount API's `runCommand` sends a command's UI actions (select a
3
+ * node, open its config panel, fit/zoom/pan the canvas).
4
+ *
5
+ * The editor shell (`App`) registers its handler for its instance while it is
6
+ * mounted. Kept off `FlowDropInstance` on purpose: it is internal, not
7
+ * exported from any entry point, so hosts cannot replace it.
8
+ *
9
+ * @module commands/uiActionTarget
10
+ */
11
+ const targets = new WeakMap();
12
+ /**
13
+ * Make `handler` the instance's UI-action target. The returned release only
14
+ * clears it while `handler` is still the target, so a shell mounted later
15
+ * keeps its own registration when an earlier one goes away.
16
+ */
17
+ export function provideUIActionTarget(instance, handler) {
18
+ targets.set(instance, handler);
19
+ return () => {
20
+ if (targets.get(instance) === handler)
21
+ targets.delete(instance);
22
+ };
23
+ }
24
+ /** Hand `action` to the instance's target; dropped when there is none. */
25
+ export function dispatchUIAction(instance, action) {
26
+ targets.get(instance)?.(action);
27
+ }
28
+ /** Whether a shell has registered a target for the instance (for tests). */
29
+ export function hasUIActionTarget(instance) {
30
+ return targets.has(instance);
31
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Shape check for a `Command` object handed in from outside the editor (the
3
+ * mount API's `runCommand`). The parser only ever builds well-formed commands;
4
+ * a host writing the object by hand, from plain JavaScript, may not, and the
5
+ * executor trusts the shape.
6
+ *
7
+ * @module commands/validate
8
+ */
9
+ /**
10
+ * Check that `value` is a `Command` the executor can run: a known `type`, its
11
+ * required fields present and every field it names of the right kind.
12
+ * Returns the problem, or null when the command is well formed. Fields the
13
+ * command does not define are ignored.
14
+ */
15
+ export declare function validateCommand(value: unknown): string | null;
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Shape check for a `Command` object handed in from outside the editor (the
3
+ * mount API's `runCommand`). The parser only ever builds well-formed commands;
4
+ * a host writing the object by hand, from plain JavaScript, may not, and the
5
+ * executor trusts the shape.
6
+ *
7
+ * @module commands/validate
8
+ */
9
+ const NODE_ID = { nodeId: 'string' };
10
+ const GAPS = { gapX: 'number', gapY: 'number' };
11
+ const PORTS = {
12
+ sourceNodeId: 'string',
13
+ sourcePort: 'string',
14
+ targetNodeId: 'string',
15
+ targetPort: 'string'
16
+ };
17
+ /** One entry per command type, so a new command cannot be added without its rules. */
18
+ const RULES = {
19
+ add_node: { required: { nodeTypeId: 'string' }, optional: { position: 'point' } },
20
+ delete_node: { required: NODE_ID },
21
+ rename_node: { required: { ...NODE_ID, label: 'string' } },
22
+ set_config: {
23
+ required: { ...NODE_ID, key: 'string', value: 'string' },
24
+ optional: { strict: 'boolean' }
25
+ },
26
+ get_config: { required: NODE_ID, optional: { key: 'string' } },
27
+ connect: { required: PORTS },
28
+ disconnect_ports: { required: PORTS },
29
+ disconnect_node: { required: NODE_ID },
30
+ list_nodes: {},
31
+ list_edges: {},
32
+ list_types: {},
33
+ describe_type: { required: { nodeTypeId: 'string' } },
34
+ search_types: { required: { query: 'string' } },
35
+ info: { required: NODE_ID },
36
+ undo: {},
37
+ redo: {},
38
+ config_open: { required: NODE_ID },
39
+ select_node: { required: NODE_ID },
40
+ help: { optional: { command: 'string' } },
41
+ clear: { optional: { all: 'boolean' } },
42
+ swap_node: { required: { ...NODE_ID, newTypeId: 'string' } },
43
+ move_node: { required: { ...NODE_ID, position: 'point' } },
44
+ auto_layout: { optional: { direction: ['horizontal', 'vertical'] } },
45
+ beautify_layout: { optional: { dryRun: 'boolean', ...GAPS } },
46
+ inspect_node_layout: { required: NODE_ID, optional: GAPS },
47
+ beautify_node: {
48
+ required: NODE_ID,
49
+ optional: {
50
+ strategy: ['column', 'ports', 'align', 'clear', 'all'],
51
+ dryRun: 'boolean',
52
+ ...GAPS
53
+ }
54
+ },
55
+ canvas_fit_view: {},
56
+ canvas_zoom_in: {},
57
+ canvas_zoom_out: {},
58
+ canvas_zoom_to: { required: { level: 'number' } },
59
+ canvas_pan_to: { required: { position: 'point' } },
60
+ canvas_reset_view: {}
61
+ };
62
+ const isFiniteNumber = (value) => typeof value === 'number' && Number.isFinite(value);
63
+ function matches(value, kind) {
64
+ if (Array.isArray(kind))
65
+ return typeof value === 'string' && kind.includes(value);
66
+ switch (kind) {
67
+ case 'string':
68
+ return typeof value === 'string';
69
+ case 'number':
70
+ return isFiniteNumber(value);
71
+ case 'boolean':
72
+ return typeof value === 'boolean';
73
+ case 'point': {
74
+ const point = value;
75
+ return (typeof point === 'object' &&
76
+ point !== null &&
77
+ isFiniteNumber(point.x) &&
78
+ isFiniteNumber(point.y));
79
+ }
80
+ }
81
+ return false;
82
+ }
83
+ function describe(kind) {
84
+ if (Array.isArray(kind))
85
+ return `one of ${kind.map((k) => `"${k}"`).join(', ')}`;
86
+ return kind === 'point' ? 'an { x, y } object of numbers' : `a ${kind}`;
87
+ }
88
+ /**
89
+ * Check that `value` is a `Command` the executor can run: a known `type`, its
90
+ * required fields present and every field it names of the right kind.
91
+ * Returns the problem, or null when the command is well formed. Fields the
92
+ * command does not define are ignored.
93
+ */
94
+ export function validateCommand(value) {
95
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
96
+ return 'A command is a console line or a Command object.';
97
+ }
98
+ const command = value;
99
+ const type = command.type;
100
+ if (typeof type !== 'string' || !Object.hasOwn(RULES, type)) {
101
+ return `Unknown command type: ${JSON.stringify(type)}.`;
102
+ }
103
+ const rules = RULES[type];
104
+ for (const [field, kind] of Object.entries(rules.required ?? {})) {
105
+ if (!matches(command[field], kind)) {
106
+ return `${type}: "${field}" must be ${describe(kind)}.`;
107
+ }
108
+ }
109
+ for (const [field, kind] of Object.entries(rules.optional ?? {})) {
110
+ if (command[field] !== undefined && !matches(command[field], kind)) {
111
+ return `${type}: "${field}" must be ${describe(kind)} when given.`;
112
+ }
113
+ }
114
+ return null;
115
+ }
@@ -53,7 +53,13 @@
53
53
  import Navbar from './Navbar.svelte';
54
54
  import DoctorMenu from './DoctorMenu.svelte';
55
55
  import type { NavbarAction, NavbarBranding } from '../types/navbar.js';
56
- import type { NodeMetadata, Workflow, WorkflowNode, ConfigSchema } from '../types/index.js';
56
+ import type {
57
+ NodeMetadata,
58
+ Workflow,
59
+ WorkflowNode,
60
+ ConfigSchema,
61
+ ExternalEditLink
62
+ } from '../types/index.js';
57
63
  import type { InteractiveSwapState, SwapEventContext } from '../utils/nodeSwap.js';
58
64
  import {
59
65
  computeInteractiveState,
@@ -83,6 +89,8 @@
83
89
  initializeTheme
84
90
  } from '../stores/settingsStore.svelte.js';
85
91
  import { logger } from '../utils/logger.js';
92
+ import { runExternalEdit } from '../utils/externalEdit.svelte.js';
93
+ import { provideUIActionTarget } from '../commands/uiActionTarget.js';
86
94
  import { themeScope } from '../utils/themeScope.svelte.js';
87
95
  import {
88
96
  resolveInspectorSurface,
@@ -210,6 +218,8 @@
210
218
  onApiError?: FlowDropEventHandlers['onApiError'];
211
219
  /** Called after a workflow is loaded/imported. */
212
220
  onWorkflowLoad?: FlowDropEventHandlers['onWorkflowLoad'];
221
+ /** Called instead of opening a node's external edit link; resolve with the new config. */
222
+ onExternalEdit?: FlowDropEventHandlers['onExternalEdit'];
213
223
  /** Called before a node swap — return false to cancel. */
214
224
  onBeforeSwap?: FlowDropEventHandlers['onBeforeSwap'];
215
225
  /** Called after a node swap is applied. */
@@ -283,6 +293,7 @@
283
293
  onSaveError,
284
294
  onApiError,
285
295
  onWorkflowLoad,
296
+ onExternalEdit,
286
297
  onBeforeSwap,
287
298
  onAfterSwap,
288
299
  features: propFeatures,
@@ -1128,6 +1139,33 @@
1128
1139
  }
1129
1140
  });
1130
1141
 
1142
+ /**
1143
+ * Hand a node's external edit link to the host (`onExternalEdit`) and write
1144
+ * the config it resolves with. Undefined when the host set no handler, so the
1145
+ * link opens as before.
1146
+ */
1147
+ // Nodes whose host form is open, kept here so reopening the inspector does
1148
+ // not open a second one.
1149
+ const externalEditPending = new Set<string>();
1150
+ const externalEditForConfig = $derived(
1151
+ onExternalEdit
1152
+ ? (node: WorkflowNode, link: ExternalEditLink) =>
1153
+ runExternalEdit({
1154
+ node,
1155
+ link,
1156
+ handler: (n, l) => onExternalEdit(n, l),
1157
+ store: fd.workflow,
1158
+ // Read when the host resolves: the editor may have been locked meanwhile.
1159
+ canWrite: () => canvasEditable,
1160
+ pending: externalEditPending,
1161
+ onWritten: (written) => {
1162
+ workflowEditorRef?.updateNodeData(written.id, written.data);
1163
+ void workflowEditorRef?.refreshEdgePositions(written.id);
1164
+ }
1165
+ })
1166
+ : undefined
1167
+ );
1168
+
1131
1169
  async function saveWorkflow(): Promise<boolean> {
1132
1170
  // Commit any in-flight config edit so the save and its history are
1133
1171
  // consistent (the value itself is already live in the store).
@@ -1660,6 +1698,9 @@
1660
1698
  }
1661
1699
  }
1662
1700
 
1701
+ // Let the mount API's `runCommand` reach this handler for UI actions.
1702
+ $effect(() => provideUIActionTarget(fd, handleConsoleUIAction));
1703
+
1663
1704
  /** Show the Assistant: its tab beside Nodes, or the console group where there is no left slot. */
1664
1705
  function openAssistant(): void {
1665
1706
  if (chatInConsoleGroup) {
@@ -1738,6 +1779,7 @@
1738
1779
  workflowId={fd.workflow.current?.id}
1739
1780
  workflowNodes={fd.workflow.current?.nodes}
1740
1781
  workflowEdges={fd.workflow.current?.edges}
1782
+ onExternalEdit={externalEditForConfig}
1741
1783
  onChange={(updatedConfig, meta) => {
1742
1784
  if (!node.id) return;
1743
1785
  const updatedData = { ...node.data, config: updatedConfig };
@@ -124,6 +124,8 @@ interface Props {
124
124
  onApiError?: FlowDropEventHandlers['onApiError'];
125
125
  /** Called after a workflow is loaded/imported. */
126
126
  onWorkflowLoad?: FlowDropEventHandlers['onWorkflowLoad'];
127
+ /** Called instead of opening a node's external edit link; resolve with the new config. */
128
+ onExternalEdit?: FlowDropEventHandlers['onExternalEdit'];
127
129
  /** Called before a node swap — return false to cancel. */
128
130
  onBeforeSwap?: FlowDropEventHandlers['onBeforeSwap'];
129
131
  /** Called after a node swap is applied. */
@@ -18,6 +18,7 @@
18
18
  WorkflowNode,
19
19
  WorkflowEdge,
20
20
  ConfigEditOptions,
21
+ ExternalEditLink,
21
22
  AuthProvider
22
23
  } from '../types/index.js';
23
24
  import type { UISchemaElement } from '../types/uischema.js';
@@ -107,6 +108,15 @@
107
108
  config: Record<string, unknown>,
108
109
  meta?: { fieldKey?: string; commit?: boolean }
109
110
  ) => void;
111
+ /**
112
+ * Called instead of opening the node's external edit link, when set, with
113
+ * copies of the node and the link, after committing field edits still
114
+ * pending (as a blur would). The host opens its own form; ConfigForm awaits
115
+ * the call (a second click while one is pending is ignored) and logs a
116
+ * rejection. Writing the config the
117
+ * handler resolves with is the caller's job: ConfigForm passes it on as is.
118
+ */
119
+ onExternalEdit?: (node: WorkflowNode, link: ExternalEditLink) => unknown;
110
120
  /** Callback when form is saved */
111
121
  onSave?: (config: Record<string, unknown>) => void;
112
122
  /** Callback when form is cancelled */
@@ -125,6 +135,7 @@
125
135
  authProvider,
126
136
  commitMode = 'blur',
127
137
  onChange,
138
+ onExternalEdit,
128
139
  onSave,
129
140
  onCancel
130
141
  }: Props = $props();
@@ -399,7 +410,8 @@
399
410
  : { name: link.label ?? 'Configure externally' }),
400
411
  title: link.description,
401
412
  href: getExternalEditUrl(),
402
- newTab: link.openInNewTab !== false
413
+ newTab: link.openInNewTab !== false,
414
+ ...(onExternalEdit ? { onActivate: handleExternalEditClick } : {})
403
415
  };
404
416
  });
405
417
 
@@ -418,9 +430,38 @@
418
430
  /**
419
431
  * Handle opening external edit link
420
432
  */
433
+ const externalEditPending = new Set<string>();
434
+
435
+ /** A plain copy of reactive state. Typed as `T`: `Snapshot<WorkflowNode>` is too deep for tsc. */
436
+ const copyOf = <T,>(value: T): T => $state.snapshot(value) as T;
437
+
421
438
  function handleExternalEditClick(): void {
422
439
  if (!node || !configEditOptions?.externalEditLink) return;
423
440
 
441
+ if (onExternalEdit) {
442
+ const link = configEditOptions.externalEditLink;
443
+ const nodeId = node.id;
444
+ // One host form per node at a time.
445
+ if (externalEditPending.has(nodeId)) return;
446
+ externalEditPending.add(nodeId);
447
+ // Commit what is still in the edit buffer first: the host then sees it,
448
+ // and a stale buffered value cannot shadow, and later overwrite, the
449
+ // config the host writes back. A click on a link does not always blur the
450
+ // field (Safari does not focus links).
451
+ if (Object.keys(edits).length > 0) handleFormBlur();
452
+ void (async () => {
453
+ try {
454
+ // Copies: the host must not write into the live workflow behind the editor's back.
455
+ await onExternalEdit(copyOf(node), copyOf(link));
456
+ } catch (error) {
457
+ logger.warn('onExternalEdit failed:', error);
458
+ } finally {
459
+ externalEditPending.delete(nodeId);
460
+ }
461
+ })();
462
+ return;
463
+ }
464
+
424
465
  const url = getExternalEditUrl();
425
466
  const openInNewTab = configEditOptions.externalEditLink.openInNewTab !== false;
426
467
 
@@ -1,4 +1,4 @@
1
- import type { ConfigSchema, WorkflowNode, WorkflowEdge, AuthProvider } from '../types/index.js';
1
+ import type { ConfigSchema, WorkflowNode, WorkflowEdge, ExternalEditLink, AuthProvider } from '../types/index.js';
2
2
  import type { UISchemaElement } from '../types/uischema.js';
3
3
  interface Props {
4
4
  /** Optional workflow node (if provided, schema and values are derived from it) */
@@ -51,6 +51,15 @@ interface Props {
51
51
  fieldKey?: string;
52
52
  commit?: boolean;
53
53
  }) => void;
54
+ /**
55
+ * Called instead of opening the node's external edit link, when set, with
56
+ * copies of the node and the link, after committing field edits still
57
+ * pending (as a blur would). The host opens its own form; ConfigForm awaits
58
+ * the call (a second click while one is pending is ignored) and logs a
59
+ * rejection. Writing the config the
60
+ * handler resolves with is the caller's job: ConfigForm passes it on as is.
61
+ */
62
+ onExternalEdit?: (node: WorkflowNode, link: ExternalEditLink) => unknown;
54
63
  /** Callback when form is saved */
55
64
  onSave?: (config: Record<string, unknown>) => void;
56
65
  /** Callback when form is cancelled */
@@ -17,9 +17,23 @@
17
17
  href: string;
18
18
  /** Open in a new tab */
19
19
  newTab?: boolean;
20
+ /**
21
+ * Handle a plain left click instead of following the link. The href stays,
22
+ * so middle-click, modified clicks and "copy link" work as for any link.
23
+ */
24
+ onActivate?: () => void;
20
25
  }
21
26
 
22
- let { prefix, name, title, href, newTab = true }: Props = $props();
27
+ let { prefix, name, title, href, newTab = true, onActivate }: Props = $props();
28
+
29
+ function handleClick(event: MouseEvent): void {
30
+ if (!onActivate) return;
31
+ if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
32
+ return;
33
+ }
34
+ event.preventDefault();
35
+ onActivate();
36
+ }
23
37
  </script>
24
38
 
25
39
  <div class="external-link-row">
@@ -30,6 +44,7 @@
30
44
  target={newTab ? '_blank' : undefined}
31
45
  rel={newTab ? 'noopener noreferrer' : undefined}
32
46
  title={title ?? name}
47
+ onclick={handleClick}
33
48
  data-testid="external-config-link"
34
49
  >
35
50
  <span class="external-link-row__name">{name}</span>
@@ -8,6 +8,11 @@ interface Props {
8
8
  href: string;
9
9
  /** Open in a new tab */
10
10
  newTab?: boolean;
11
+ /**
12
+ * Handle a plain left click instead of following the link. The href stays,
13
+ * so middle-click, modified clicks and "copy link" work as for any link.
14
+ */
15
+ onActivate?: () => void;
11
16
  }
12
17
  declare const ExternalLinkRow: import("svelte").Component<Props, {}, "">;
13
18
  type ExternalLinkRow = ReturnType<typeof ExternalLinkRow>;