ClaudeCode.Content.TextBlock (ClaudeCode v0.36.3)

View Source

Represents a text content block within a Claude message.

Text blocks contain plain text content that represents Claude's response or user input.

Summary

Functions

Creates a new Text content block from JSON data.

Types

t()

@type t() :: %ClaudeCode.Content.TextBlock{
  citations: [map()] | nil,
  text: String.t(),
  type: :text
}

Functions

new(data)

@spec new(map()) :: {:ok, t()} | {:error, atom()}

Creates a new Text content block from JSON data.

Examples

iex> Text.new(%{"type" => "text", "text" => "Hello!"})
{:ok, %Text{type: :text, text: "Hello!"}}

iex> Text.new(%{"type" => "tool_use", "text" => "Hi"})
{:error, :invalid_content_type}