View Source Yex.Text (y_ex v0.5.1)

A shareable type that is optimized for shared editing on text.

Summary

Types

@type t() :: %Yex.Text{reference: any()}

Functions

Link to this function

apply_delta(text, delta)

View Source

Transforms this type to a Quill Delta

Examples Sync two clients by exchanging the complete document structure

iex> doc = Yex.Doc.new()
iex> text = Yex.Doc.get_text(doc, "text")
iex> delta = [%{ "retain" => 1}, %{ "delete" => 3}]
iex> Yex.Text.insert(text,0, "12345")
iex> Yex.Text.apply_delta(text,delta)
iex> Yex.Text.to_delta(text)
[%{"insert" => "15"}]
Link to this function

delete(text, index, length)

View Source
Link to this function

format(text, index, length, attr)

View Source
Link to this function

insert(text, index, content)

View Source
Link to this function

insert(text, index, content, attr)

View Source

Transforms this type to a Quill Delta

Examples Sync two clients by exchanging the complete document structure

iex> doc = Yex.Doc.new()
iex> text = Yex.Doc.get_text(doc, "text")
iex> Yex.Text.insert(text, 0, "12345")
iex> Yex.Text.insert(text, 0, "0", %{"bold" => true})
iex> Yex.Text.to_delta(text)
[%{"insert" => "0", "attributes" => %{"bold" => true}}, %{"insert" => "12345"}]