livebook/lib/livebook_web/live/output/text_component.ex
Jonatan Kłosko 902c993098
Adjustments (#1087)
* Fix horizontal scrollbar on smaller screens

* Apply navigation shortcuts without an additional roundtrip

* Shorten the data element selector

* Fix URL in changelog

* Return reference from handle_intellisense
2022-04-04 12:19:11 +02:00

28 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">
<%# 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-el-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