defmodule LivebookWeb.OpenLive.SourceComponent do use LivebookWeb, :live_component @impl true def mount(socket) do {:ok, assign(socket, source: "")} end @impl true def render(assigns) do ~H"""

Import notebook by directly pasting the live markdown source.

<.form :let={f} for={%{"source" => @source}} as={:data} id="import-source" phx-submit="import" phx-change="validate" phx-target={@myself} autocomplete="off" > <.textarea_field type="textarea" field={f[:source]} label="Notebook source" resizable={false} autofocus aria-labelledby="import-from-source" spellcheck="false" rows="5" />
""" end @impl true def handle_event("validate", %{"data" => %{"source" => source}}, socket) do {:noreply, assign(socket, source: source)} end def handle_event("import", %{"data" => %{"source" => source}}, socket) do send(self(), {:import_source, source, []}) {:noreply, socket} end end