livebook/lib/livebook_web/live/output/text_component.ex
Jean Carlos aa8f431608
Added margin on copy button (#796)
* fix handleDocumentFocus error

* format correction

* Update assets/js/session/index.js

Co-authored-by: Jonatan Kłosko <jonatanklosko@gmail.com>

* format correction

* Update assets/js/session/index.js

Co-authored-by: Jonatan Kłosko <jonatanklosko@gmail.com>

* Move basic view to the top

* Added margin on copy button

* Update lib/livebook_web/live/output/text_component.ex

Co-authored-by: Jonatan Kłosko <jonatanklosko@gmail.com>

* Update lib/livebook_web/live/output/text_component.ex

Co-authored-by: Jonatan Kłosko <jonatanklosko@gmail.com>
2021-12-12 20:26:10 +01:00

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><%= [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