Tiptapex (Tiptapex v0.1.0)

Copy Markdown View Source

Tiptap v3 rich-text editing for Phoenix LiveView.

Tiptapex packages a full editor integration:

JavaScript setup

The JS ships as raw ESM inside the Hex package. Your app bundles it with its own copy of the @tiptap/* packages (peer dependencies — install them with npm in assets/). Point esbuild's NODE_PATH at both deps and assets/node_modules, then:

import { hooks as tiptapex } from "tiptapex"

const liveSocket = new LiveSocket("/live", Socket, {
  hooks: { ...otherHooks, ...tiptapex },
})

See the README for the full installation walkthrough.

Summary

Functions

Returns true when the given document is nil, empty, or contains no text, media, or horizontal rules.

Returns an empty Tiptap document.

Functions

blank_doc?(doc)

@spec blank_doc?(map() | nil) :: boolean()

Returns true when the given document is nil, empty, or contains no text, media, or horizontal rules.

empty_doc()

@spec empty_doc() :: map()

Returns an empty Tiptap document.

Useful as a default value for new records:

schema "articles" do
  field :body, :map, default: Tiptapex.empty_doc()
end

to_html(doc, opts \\ [])

Delegates to Tiptapex.Renderer.to_html/2.

to_plain_text(doc)

Delegates to Tiptapex.Renderer.to_plain_text/1.