Skip to content
EditorSDK reference

Mount API

Complete reference for mountFlowDropApp(), mountWorkflowEditor(), and mountPlayground() — all options, return values, and lifecycle.

The mount API lets you embed FlowDrop into any HTML container, regardless of framework.

mountFlowDropApp()

Mounts the full FlowDrop application (sidebar, editor, config panel) into a container.

import { mountFlowDropApp } from '@flowdrop/flowdrop/editor';

const app = await mountFlowDropApp(container: HTMLElement, options: FlowDropMountOptions);

Options

interface FlowDropMountOptions {
  // Data
  /** Initial workflow to load */
  workflow?: Workflow;
  /** Available node types (overrides API fetch) */
  nodes?: NodeMetadata[];

  // API
  /** REST API endpoint configuration */
  endpointConfig?: EndpointConfig;
  /** Port data type configuration (overrides API fetch) */
  portConfig?: PortConfig;
  /** Category definitions (overrides API fetch) */
  categories?: CategoryDefinition[];
  /** Authentication provider for API requests */
  authProvider?: AuthProvider;

  // Event handlers — the grouped lifecycle events bag
  eventHandlers?: FlowDropEventHandlers;

  // Features
  features?: FlowDropFeatures;

  // UI options
  /** Show the top navbar @default true */
  showNavbar?: boolean;
  /** Disable the node sidebar */
  disableSidebar?: boolean;
  /** Editor interaction mode. @default 'edit' */
  mode?: 'edit' | 'readonly' | 'locked';
  /** Lock the editor with reasons and actions; see "Editor lock". Unset: not locked. */
  lock?: EditorLock | null;
  /** Called with the action's id when a person presses a button on the lock banner. */
  onLockAction?: (id: string) => void;
  /** Editor height (CSS value or number) */
  height?: string | number;
  /** Editor width (CSS value or number) */
  width?: string | number;

  // Navbar customization
  /** Custom navbar title */
  navbarTitle?: string;
  /** Custom navbar action buttons */
  navbarActions?: NavbarAction[];
  /** Show settings gear icon in navbar */
  showSettings?: boolean;
  /** Show the "Connected" status indicator in the navbar @default true */
  showStatus?: boolean;
  /**
   * White-label the navbar: `logo` is an image URL (or a Svelte component),
   * `name` replaces "FlowDrop" in the page title and the logo's label,
   * `logoAlt` overrides the logo's alt text, `href` links the logo.
   */
  branding?: { logo?: string | Component; name?: string; logoAlt?: string; href?: string };

  // Test mode
  /** Polling options for the editor's docked Playground (Test mode). Since 2.13.0 */
  playground?: { pollingInterval?: number; shouldStopPolling?: (status: PlaygroundSessionStatus) => boolean };

  // Pipeline mode
  /** Pipeline ID for execution status display */
  pipelineId?: string;

  // Theme
  /** Visual theme — named built-in ('classic' | 'minimal' | 'drafter' | 'graphite') or a custom theme object */
  theme?: FlowDropTheme | FlowDropThemeName;

  // Instance
  /** Identifier for this instance. @default 'default' (auto-generated for extra mounts) */
  instanceId?: string;

  // Settings
  /** Initial settings overrides (theme, behavior, editor, ui, api) */
  settings?: PartialSettings;
  /** Custom localStorage key for draft auto-save */
  draftStorageKey?: string;
  /** Where workflow drafts are persisted: 'local' (default), 'session', or a custom adapter */
  draftStorage?: DraftStorageOption;
  /** Which settings tabs to show in the modal (defaults to all) */
  settingsCategories?: SettingsCategory[];
  /** Show the "Sync to Cloud" button in the settings modal */
  showSettingsSyncButton?: boolean;
  /** Show the reset buttons in the settings modal */
  showSettingsResetButton?: boolean;

  // Format adapters
  /** Custom workflow format adapters */
  formatAdapters?: WorkflowFormatAdapter[];
  /** Format ids this host supports — scopes the Workflow Format picker */
  workflowFormats?: string[];
  /** Extra Workflow Settings fields, stored in `workflow.config`. Since 2.15.0 */
  workflowSettingsSchema?: ConfigSchema;
}

The mode option controls canvas interaction: 'edit' (the default) allows editing; 'readonly' and 'locked' disable all canvas interaction. mode is a static host mode: no selection, no banner, no Test mode.

Use lock to lock the editor at runtime instead. A lock carries reasons and actions, shows a banner above the canvas, and still allows selecting, inspecting and Test mode. A pressed banner button calls onLockAction(id). See Editor lock for the shape, what is refused, and how lock differs from mode="locked".

const app = await mountFlowDropApp(container, {
  lock: {
    reasons: [{ kind: 'managed', message: 'A module manages this workflow.' }],
    actions: [{ id: 'edit_anyway', label: 'Edit anyway', primary: true }]
  },
  onLockAction: (id) => {
    if (id === 'edit_anyway') app.setLock(null);
  }
});

Use workflowFormats to scope the Workflow Format picker in the workflow settings panel to the formats your host can actually handle:

await mountFlowDropApp(container, {
  workflowFormats: ['flowdrop']
});

When one or zero ids remain after filtering, the field is hidden instead of shown as a single-choice select, and the workflow keeps its stored format. Omit the option to offer every registered format.

Use workflowSettingsSchema (since 2.15.0) to add your own fields to the Workflow Settings panel. It is a JSON Schema object, like a node's configSchema. The values are stored in workflow.config: they are read from the workflow you pass in, returned by getWorkflow(), and sent to onBeforeSave and the save request with the rest of the workflow.

await mountFlowDropApp(container, {
  workflow,
  workflowSettingsSchema: {
    type: 'object',
    properties: {
      version: { type: 'string', title: 'Version' },
      status: { type: 'boolean', title: 'Enabled', default: true }
    }
  }
});

The panel's own keys are reserved: a property named name, description, format, interface or playground is ignored, with a warning in the console.

Use playground (since 2.13.0) to tune how the editor's docked Playground, the one behind Test mode, follows a run. It takes the same two polling options as mountPlayground(), and nothing else:

KeyDefaultMeaning
pollingInterval1500 (ms)How often the Playground polls the backend while a run is active.
shouldStopPollingstops on idle onlyReceives the session status and returns true to stop polling.

The default stops on idle only, and that is on purpose: an async server may still emit messages after a session reads completed, so stopping earlier could drop them. Set shouldStopPolling when your backend leaves sessions in completed or failed after a turn and never returns to idle; without it, Test mode keeps polling those sessions.

await mountFlowDropApp(container, {
  playground: {
    pollingInterval: 1000,
    shouldStopPolling: (status) => ['idle', 'completed', 'failed'].includes(status)
  }
});

Feature flags (FlowDropFeatures)

interface FlowDropFeatures {
  /** Auto-save the current workflow to localStorage as a draft. @default true */
  autoSaveDraft?: boolean;

  /** How often to auto-save the draft, in milliseconds. @default 30000 */
  autoSaveDraftInterval?: number;

  /** Show toast notifications for save success, failure, and API errors.
   * Disable if you want to handle notifications yourself via event handlers. @default true */
  showToasts?: boolean;
}

See Auto-Save & Drafts for practical examples.

The refused-save flow and onSavedAsCopy are described in Save checks, copies and renames.

See Core Types for FlowDropEventHandlers and FlowDropFeatures.

Return value

interface MountedFlowDropApp {
  /** This mount's state container — drive the editor programmatically. */
  instance: FlowDropInstance;

  /** Destroy the editor and clean up resources */
  destroy(): void;

  /** Check if there are unsaved changes */
  isDirty(): boolean;

  /** Mark the workflow as saved (clears dirty state) */
  markAsSaved(): void;

  /** Get the current workflow data */
  getWorkflow(): Workflow | null;

  /** Trigger save operation */
  save(): Promise<void>;

  /** Trigger export (downloads JSON file) */
  export(): void;

  /** Clear all workflow drafts from draft storage. Returns the number of entries removed. */
  clearAllDrafts(): number;

  /** Lock the editor, or unlock it with null. Same as app.instance.lock.set(...). */
  setLock(lock: EditorLock | null): void;

  /** Run one Command Console command against this workflow. Since 2.15.0 */
  runCommand(command: string | Command, options?: { baseline?: boolean }): Promise<CommandResult>;
}

instance is the state container — workflow, history, playground, interrupts, categories, and the rest. Call into it to drive the editor programmatically, e.g. app.instance.workflow.addNode(...) or app.instance.history.undo().

runCommand(command, options?)

Runs one Command Console command against the mount's workflow, as if it had been typed into the console. Every console command is available this way, for example to lay out a workflow that was loaded without positions:

const app = await mountFlowDropApp(container, { workflow });
await app.runCommand('layout beautify', { baseline: true });

command is a console line or an already parsed Command, such as { type: 'auto_layout' }. A Command object is checked before it runs: an unknown type, or a field that is missing or of the wrong kind, resolves with INVALID_ARGUMENT and nothing runs. The promise never rejects: a command that fails unexpectedly resolves with INTERNAL_ERROR and logs the cause to the browser console. It resolves to a CommandResult: { ok: true, message, data? } or { ok: false, code, error }. The types are exported from @flowdrop/flowdrop and @flowdrop/flowdrop/editor.

  • It waits for the workflow. The mount resolves before the editor has loaded its workflow, so a call made right after mounting waits for it. If the mount is destroyed first, it resolves with NO_WORKFLOW.
  • One undo step per call, as in the console, and the workflow becomes dirty.
  • baseline: true makes the result the workflow's clean starting point: isDirty() is false afterwards and the undo history starts over from it. Use it to tidy a model the user has not touched yet. It is refused with DIRTY, and nothing runs, when the workflow has unsaved changes. undo and redo cannot run as a baseline (INVALID_ARGUMENT). onDirtyStateChange and onWorkflowChange are not called for a baseline run. A command that changes nothing, such as info, keeps the undo history.
  • Node sizes. Before the canvas has rendered, layout commands use computed node sizes instead of measured ones, so the result can differ slightly from the same command run later.
  • It works on readonly and locked mounts, so you can lay out a model you only display.
  • While the editor is locked with lock, a command that would change the workflow resolves with LOCKED. Reads and view commands still run.
  • Commands that select a node, open its config or move the view act on the editor. mountWorkflowEditor has no editor shell, so they do nothing there.
  • session commands are not available (SESSION_REFUSED).

Call clearAllDrafts() on logout.

Otherwise drafts persist across user sessions on shared devices. It clears the configured draft storage (localStorage unless changed via the draftStorage option).

mountWorkflowEditor()

Mounts just the editor canvas — no navbar, no sidebar. Useful for embedding a minimal editor.

import { mountWorkflowEditor } from '@flowdrop/flowdrop/editor';

const editor = await mountWorkflowEditor(container, {
  workflow: myWorkflow,
  endpointConfig: createEndpointConfig('/api/flowdrop'),
  portConfig: myPortConfig, // optional, overrides API
  categories: myCategories, // optional, overrides API
  instanceId: 'editor-b' // optional — scope to a named instance for multi-editor pages
});

Returns the same MountedFlowDropApp interface as mountFlowDropApp(). instanceId follows the same default-instance semantics as mountFlowDropApp() above.

mountWorkflowEditor() also takes lock and onLockAction, with the same meaning as on mountFlowDropApp(). See Editor lock.

mountPlayground()

Mounts the interactive playground for workflow testing.

import { mountPlayground } from '@flowdrop/flowdrop/playground';

const playground = await mountPlayground(container, {
  workflowId: 'my-workflow-id',
  endpointConfig: createEndpointConfig('/api/flowdrop'),
  mode: 'standalone', // 'standalone' | 'embedded' | 'modal'
  config: {
    pollingInterval: 1500,
    shouldStopPolling: (status) => ['completed', 'failed'].includes(status)
  },
  onSessionStatusChange: (newStatus, previousStatus) => {
    console.log(`${previousStatus} -> ${newStatus}`);
  },
  onClose: () => console.log('Playground closed'), // required for embedded/modal
  height: '600px',
  width: '100%',
  initialSessionId: 'resume-session-id', // optional
  instanceId: 'playground-b' // optional — scope to a named instance
});

instanceId follows the same default-instance semantics as mountFlowDropApp().

Live polling is page-global.

Playground state (sessions, messages, interrupts) is isolated per instance, but only one playground can actively poll at a time. Drive a non-polling playground via pushMessages() instead.

Playground return value

interface MountedPlayground {
  /** Destroy and clean up */
  destroy(): void;
  /** Get the current session */
  getCurrentSession(): PlaygroundSession | null;
  /** Get all sessions */
  getSessions(): PlaygroundSession[];
  /** Get message count in current session */
  getMessageCount(): number;
  /** Check if currently executing */
  isExecuting(): boolean;
  /** Stop polling for messages */
  stopPolling(): void;
  /** Restart polling */
  startPolling(): void;
  /** Push poll response data */
  pushMessages(response: PlaygroundMessagesApiResponse): void;
  /** Reset playground state */
  reset(): void;
}

unmountFlowDropApp() / unmountPlayground()

Clean up a mounted instance. Equivalent to calling .destroy() on the returned object.

import { unmountFlowDropApp } from '@flowdrop/flowdrop/editor';

unmountFlowDropApp(container);

Lifecycle

  1. Mount — Call mountFlowDropApp() with a container element
  2. Interact — Use the returned API to control the editor programmatically
  3. Destroy — Call .destroy() or the unmount function to clean up

Registration of custom nodes and fields can happen before or after mounting. The node and field registries are instance-scoped — resolve them via getInstance() inside the component tree, or the mount handle's .instance outside it.

On this page