View Source Yex.Text (y_ex v0.6.2)
A shareable type that is optimized for shared editing on text.
Summary
Types
@type delta() :: [%{:insert => Yex.input_type(), optional(:attributes) => map()}] | [%{delete: integer()}] | [%{:retain => integer(), optional(:attributes) => map()}]
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"}]
@spec insert(t(), integer(), Yex.input_type()) :: :ok | :error
@spec insert(t(), integer(), Yex.input_type(), map()) :: :ok | :error
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"}]