defmodule GenEditor.SmartCell do use Kino.JS use Kino.JS.Live use Kino.SmartCell, name: "Test_Print" @impl true def init(attrs, ctx) do ctx = assign(ctx, text: attrs["text"] || "") {:ok, ctx} end @impl true def handle_connect(ctx) do {:ok, %{text: ctx.assigns.text}, ctx} end @impl true def handle_event("update_text", text, ctx) do broadcast_event(ctx, "update_text", text) {:noreply, assign(ctx, text: text)} end @impl true def to_attrs(ctx) do %{"text" => ctx.assigns.text} end @impl true def to_source(attrs) do quote do IO.puts(unquote(attrs["text"])) end |> Kino.SmartCell.quoted_to_string() end asset "main.js" do """ export function init(ctx, payload) { root.innerHTML = `