NLdoc.Conversion.Reader.Tiptap.Mark (NLdoc.Conversion.Reader.Tiptap v1.2.30)
View SourceModule for applying Tiptap marks to Spec resource
Summary
Functions
Applies all of Tiptap's marks on text to text and link resources.
Puts a Tiptap mark on a Spec resource.
Types
@type mark() :: map()
Functions
@spec apply(NLdoc.Spec.Link.t(), [mark()]) :: NLdoc.Spec.Link.t()
@spec apply(NLdoc.Spec.Text.t(), [mark()]) :: NLdoc.Spec.Text.t() | NLdoc.Spec.Link.t()
Applies all of Tiptap's marks on text to text and link resources.
Examples
iex> alias NLdoc.Conversion.Reader.Tiptap.Mark
iex> alias NLdoc.Spec.{Link, Text}
iex> Mark.apply(%Text{id: "1", text: "Hello, world!"}, [%{"type" => "bold"}])
%Text{id: "1", text: "Hello, world!", styling: [:bold]}
iex> Mark.apply(%Link{id: "1", text: "Hello, world!", uri: "https://example.com"},
...> [%{"type" => "italic"}, %{"type" => "underline"}])
%Link{id: "1", text: "Hello, world!", uri: "https://example.com",
styling: [:underline, :italic]}
iex> Mark.apply(%Text{id: "1", text: "Hello, world!"}, [%{"type" => "notSupported"}])
%Text{id: "1", text: "Hello, world!"}
@spec put(NLdoc.Spec.Text.t(), mark()) :: NLdoc.Spec.Text.t() | NLdoc.Spec.Link.t()
@spec put(NLdoc.Spec.Link.t(), mark()) :: NLdoc.Spec.Link.t()
Puts a Tiptap mark on a Spec resource.
Examples
iex> alias NLdoc.Conversion.Reader.Tiptap.Mark
iex> alias NLdoc.Spec.{Link, Text}
iex> Mark.put(%Text{id: "1", text: "Hello, world!"}, %{"type" => "bold"})
%Text{id: "1", text: "Hello, world!", styling: [:bold]}
iex> Mark.put(%Link{id: "1", text: "Hello, world!", uri: "https://example.com", styling: [:italic]},
...> %{"type" => "underline"})
%Link{id: "1", text: "Hello, world!", uri: "https://example.com",
styling: [:underline, :italic]}
iex> Mark.put(%Text{id: "1", text: "Hello, world!"}, %{"type" => "notSupported"})
%Text{id: "1", text: "Hello, world!"}