mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-09-10 15:04:25 +08:00
Remove deprecations in the JSON smart cell example
This commit is contained in:
parent
52a8d31d16
commit
7be8957b8e
1 changed files with 14 additions and 3 deletions
|
@ -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
|
||||||
|
|
Loading…
Add table
Reference in a new issue