defmodule LivebookWeb.OpenLive.SourceComponent do use LivebookWeb, :live_component import Ecto.Changeset @impl true def mount(socket) do {:ok, assign(socket, changeset: changeset())} end defp changeset(attrs \\ %{}) do data = %{source: nil} types = %{source: :string} cast({data, types}, attrs, [:source]) |> validate_required([:source]) end @impl true def render(assigns) do ~H"""
Import notebook by directly pasting the live markdown source.
<.form :let={f} for={@changeset} as={:data} id="import-source" phx-submit="import" phx-change="validate" phx-target={@myself} autocomplete="off" > <.textarea_field field={f[:source]} label="Notebook source" autofocus aria-labelledby="import-from-source" spellcheck="false" rows="5" />