NLdoc.Conversion.Reader.Tiptap.Mark (NLdoc.Conversion.Reader.Tiptap v1.2.30)

View Source

Module 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

mark()

@type mark() :: map()

Functions

apply(resource, marks)

@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!"}

put(resource, arg2)

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