Skip to content

TextNode

Default message renderer with markdown, code highlighting, and inline editing support.

  • Markdown rendering via marked, sanitized with DOMPurify
  • Syntax highlighting via highlight.js
  • Streaming, done, and error states (driven by node.status)
  • Inline editing of node content
  • Thought/reasoning panel support

TextNode renders nodes of type 'text' automatically — you don’t need to wire it up yourself. To replace it with a custom component, map the 'text' type in the componentMap prop on TraekCanvas:

<TraekCanvas {engine} componentMap={{ text: MyTextNode }} onSendMessage={handleSend} />

See Custom Node Types for writing custom renderers.

When used directly (it is also exported as TextNode from traek), the main props are:

PropTypeRequiredDescription
nodeMessageNodeYesThe node to render
isActivebooleanYesWhether the node is the active node
isFocusedbooleanNoWhether the node is keyboard-focused
engineTraekEngineNoEngine instance (enables toolbar actions)
onEditSave(nodeId: string, content: string) => voidNoCalled when an inline edit is saved
onEditCancel() => voidNoCalled when an inline edit is cancelled
onStartEdit(nodeId: string) => voidNoCalled when inline editing starts