Remove deprecations in the JSON smart cell example

This commit is contained in:
Jonatan Kłosko 2024-08-24 21:40:10 +09:00
parent 52a8d31d16
commit 7be8957b8e

View file

@ -284,12 +284,15 @@ defmodule KinoGuide.JSONConverterCell do
@impl true @impl true
def init(attrs, ctx) do def init(attrs, ctx) do
json = attrs["json"] || ""
ctx = ctx =
assign(ctx, assign(ctx,
variable: Kino.SmartCell.prefixed_var_name("data", attrs["variable"]) variable: Kino.SmartCell.prefixed_var_name("data", attrs["variable"]),
json: json
) )
{:ok, ctx, editor: [attribute: "json", language: "json"]} {:ok, ctx, editor: [source: json, language: "json"]}
end end
@impl true @impl true
@ -311,9 +314,17 @@ defmodule KinoGuide.JSONConverterCell do
{:noreply, ctx} {:noreply, ctx}
end end
@impl true
def handle_editor_change(json, ctx) do
{:ok, assign(ctx, json: json)}
end
@impl true @impl true
def to_attrs(ctx) do def to_attrs(ctx) do
%{"variable" => ctx.assigns.variable} %{
"variable" => ctx.assigns.variable,
"json" => ctx.assigns.json
}
end end
@impl true @impl true