Kotoba.MarkdownPaste (Kotoba v0.5.0)

Copy Markdown View Source

The server's half of pasted Markdown: a LiveComponent that Kotoba.Components.kotoba/1 renders next to each editor, so an app needs no event handler for it.

When a person pastes plain text that reads as Markdown, the editor sends it here (kotoba:markdown), and the reply is the nodes that Kotoba.Content.from_markdown/2 builds for it, with the features of the editor: a pasted README looks as it does on GitHub. Markdown of more than 1 MB is refused, and the editor pastes it as plain text.

Summary

Functions

Returns the JSON of the nodes for pasted Markdown, with the features of the editor (see Kotoba.Content.from_markdown/2), or nil when they do not make a valid document.

Functions

nodes(markdown, map)

@spec nodes(String.t(), %{features: [atom()], nodes: [module()]}) :: [map()] | nil

Returns the JSON of the nodes for pasted Markdown, with the features of the editor (see Kotoba.Content.from_markdown/2), or nil when they do not make a valid document.