livebook/lib/livebook_web/live/output/markdown_component.ex
Jonatan Kłosko 73a79cbdae
Add support for markdown output (#404)
* Add support for markdown output

* Make cell indicator absolute

* Update output typespec

* Move rendering to the client

* Polishing
2021-06-26 16:47:52 +02:00

25 lines
517 B
Elixir

defmodule LivebookWeb.Output.MarkdownComponent do
use LivebookWeb, :live_component
@impl true
def update(assigns, socket) do
socket = assign(socket, assigns)
{:ok,
push_event(socket, "markdown-renderer:#{socket.assigns.id}:content", %{
content: socket.assigns.content
})}
end
@impl true
def render(assigns) do
~L"""
<div class="markdown"
id="markdown-renderer-<%= @id %>"
phx-hook="MarkdownRenderer"
data-id="<%= @id %>">
</div>
"""
end
end