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
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"}]
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"}]