mirror of
https://github.com/livebook-dev/livebook.git
synced 2024-11-16 04:46:46 +08:00
6615422613
* 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>
29 lines
1.1 KiB
Elixir
29 lines
1.1 KiB
Elixir
defmodule LivebookWeb.Output.TextComponent do
|
|
use LivebookWeb, :live_component
|
|
|
|
@impl true
|
|
def render(assigns) do
|
|
~H"""
|
|
<div id={"virtualized-text-#{@id}"}
|
|
class="relative"
|
|
phx-hook="VirtualizedLines"
|
|
data-max-height="300"
|
|
data-follow={to_string(@follow)}>
|
|
<%# Add a newline to each element, so that multiple lines can be copied properly %>
|
|
<div data-template class="hidden"
|
|
id={"virtualized-text-#{@id}-template"}
|
|
><%= for line <- ansi_string_to_html_lines(@content) do %><div data-line><%= [line, "\n"] %></div><% end %></div>
|
|
<div data-content class="overflow-auto whitespace-pre font-editor text-gray-500 tiny-scrollbar"
|
|
id={"virtualized-text-#{@id}-content"}
|
|
phx-update="ignore"></div>
|
|
<div class="absolute right-2 top-0 z-10">
|
|
<button class="icon-button bg-gray-100"
|
|
data-element="clipcopy"
|
|
phx-click={JS.dispatch("lb:clipcopy", to: "#virtualized-text-#{@id}-template")}>
|
|
<.remix_icon icon="clipboard-line" class="text-lg" />
|
|
</button>
|
|
</div>
|
|
</div>
|
|
"""
|
|
end
|
|
end
|