livebook/lib/livebook_web/live/output/js_component.ex
Jonatan Kłosko 6615422613
Restructure frame output (#857)
* Restructure frame output

* Reboot JSComponent when ref changes

* Prune outputs from LV, handle frame and stdout updates via component messaging

* Keep ANSI modifiers as keyword list

* Don't re-render pruned outputs

* Improve empty frame styling

* Use more specific id

* Add clarification on trailing CR

* Handle output group borders with CSS

* Keep only relevant outputs in memory

* Adjust borders

* Update lib/livebook/live_markdown/import.ex

Co-authored-by: José Valim <jose.valim@dashbit.co>

* Apply review comments

Co-authored-by: José Valim <jose.valim@dashbit.co>
2022-01-16 20:37:00 +01:00

22 lines
626 B
Elixir

defmodule LivebookWeb.Output.JSComponent do
use LivebookWeb, :live_component
@impl true
def render(assigns) do
~H"""
<div id={"js-output-#{@id}-#{@info.ref}"}
phx-hook="JSOutput"
phx-update="ignore"
data-ref={@info.ref}
data-assets-base-url={Routes.session_url(@socket, :show_asset, @session_id, @info.assets.hash, [])}
data-js-path={@info.assets.js_path}
data-session-token={session_token(@info.pid)}
data-session-id={@session_id}>
</div>
"""
end
defp session_token(pid) do
Phoenix.Token.sign(LivebookWeb.Endpoint, "js output", %{pid: pid})
end
end