wayflow/dom

The low-level canvas editor that createWorkflowEditor is built on — for the editor surface without the workflow chrome.

The bare canvas editor. createWorkflowEditor is built on top of it; reach for createEditor only when you want the editor surface without the workflow chrome (header, palette, modes, models). Most apps don’t need it.

createEditor(container, options?)

Mount a bare editor into container and return an Editor handle.

EditorOptions

OptionTypeDefaultNotes
graphGraphemptyThe initial graph.
viewportViewportThe initial pan and zoom.
readOnlybooleanfalseDisable structural editing (connect, delete, rename, box-select, menu); pan, zoom, selection, and repositioning stay live.
showPortLabelsbooleantrueShow labels beside ports.
nodeRenderersRecord<string, NodeContentRenderer>Custom rendering for a node’s body on the canvas (below).
persistencePersistenceConfigAutosave and load (below).
customValidatorCustomValidatorExtra graph validation beyond the built-in checks.
keyboardTargetHTMLElementthe containerWhere keyboard shortcuts listen.
tooltipFactory / iconFactory / portTypeLabelfunctionHooks for rendering tooltips, icons, and data-type labels.

The Editor handle

createEditor returns the same handle documented under wayflow — minus the workflow-only methods (setModels, onModelsChange, getModelAvailability, requestApproval, runSession).

Persistence

FunctionNotes
createLocalStoragePersistence(key): PersistenceAdapterA persistence adapter backed by localStorage under key.

PersistenceConfig

A PersistenceAdapter, or { adapter, trigger?, debounce? } (a PersistenceOptions).

PersistenceAdapter

MethodNotes
load()Load the saved EditorSnapshot, or null. May be async.
save(snapshot)Persist an EditorSnapshot. May be async.

EditorSnapshot is { graph, viewport? }. With PersistenceOptions you also get trigger ('autosave' / 'manual') and debounce (milliseconds).

Custom node rendering

NodeContentRenderer is the value you put in nodeRenderers. It receives the node’s container and a render context, and optionally returns a cleanup function:

renderer.ts ts
type NodeContentRenderer = (
  container: HTMLElement,
  context: NodeRenderContext,
) => (() => void) | undefined