# `Yex.TextPrelim`
[🔗](https://github.com/satoren/y_ex/blob/main/lib/shared_type/text.ex#L243)

A preliminary text representation used for initializing text content.
This module provides functionality for creating text content with formatting
before it is inserted into a shared document.

## Use Cases
- Creating formatted text content before inserting into a document
- Serializing text content for transfer between documents
- Initializing text content with specific formatting attributes

## Examples
    iex> doc = Yex.Doc.new()
    iex> map = Yex.Doc.get_map(doc, "map")
    iex> Yex.Map.set(map, "key", Yex.TextPrelim.from("Hello World"))
    iex> {:ok, %Yex.Text{} = text} = Yex.Map.fetch(map, "key")
    iex> Yex.Text.to_delta(text)
    [%{insert: "Hello World"}]

# `t`

```elixir
@type t() :: %Yex.TextPrelim{delta: Yex.Text.delta()}
```

# `from`

```elixir
@spec from(binary()) :: t()
@spec from(Yex.Text.delta()) :: t()
```

Creates a new TextPrelim from either a binary string or a delta format.

## Examples with a binary string
    iex> doc = Yex.Doc.new()
    iex> map = Yex.Doc.get_map(doc, "map")
    iex> Yex.Map.set(map, "key", Yex.TextPrelim.from("Hello World"))
    iex> {:ok, %Yex.Text{} = text} = Yex.Map.fetch(map, "key")
    iex> Yex.Text.to_delta(text)
    [%{insert: "Hello World"}]

## Examples with formatted delta
    iex> doc = Yex.Doc.new()
    iex> map = Yex.Doc.get_map(doc, "map")
    iex> Yex.Map.set(map, "key", Yex.TextPrelim.from([%{insert: "Hello"},%{insert: " World", attributes: %{ "bold" => true }},]))
    iex> {:ok, %Yex.Text{} = text} = Yex.Map.fetch(map, "key")
    iex> Yex.Text.to_delta(text)
    [%{insert: "Hello"}, %{attributes: %{"bold" => true}, insert: " World"}]

## Parameters
  * `text` - Either a binary string or a delta format array

---

*Consult [api-reference.md](api-reference.md) for complete listing*
