mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-09-08 14:04:31 +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
|
||||
def init(attrs, ctx) do
|
||||
json = attrs["json"] || ""
|
||||
|
||||
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
|
||||
|
||||
@impl true
|
||||
|
@ -311,9 +314,17 @@ defmodule KinoGuide.JSONConverterCell do
|
|||
{:noreply, ctx}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_editor_change(json, ctx) do
|
||||
{:ok, assign(ctx, json: json)}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def to_attrs(ctx) do
|
||||
%{"variable" => ctx.assigns.variable}
|
||||
%{
|
||||
"variable" => ctx.assigns.variable,
|
||||
"json" => ctx.assigns.json
|
||||
}
|
||||
end
|
||||
|
||||
@impl true
|
||||
|
|
Loading…
Add table
Reference in a new issue