From 165eff6734a8d10ef10524b6fec7f1eed5ecab2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Sat, 22 Jul 2023 00:23:14 +0200 Subject: [PATCH] Fix smart cell editor when no language is specified --- assets/js/hooks/cell_editor.js | 8 ++++++-- lib/livebook/runtime.ex | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/assets/js/hooks/cell_editor.js b/assets/js/hooks/cell_editor.js index 12c18170b..d24b7a7d7 100644 --- a/assets/js/hooks/cell_editor.js +++ b/assets/js/hooks/cell_editor.js @@ -1,5 +1,9 @@ import LiveEditor from "./cell_editor/live_editor"; -import { getAttributeOrThrow, parseBoolean } from "../lib/attribute"; +import { + getAttributeOrDefault, + getAttributeOrThrow, + parseBoolean, +} from "../lib/attribute"; const CellEditor = { mounted() { @@ -70,7 +74,7 @@ const CellEditor = { return { cellId: getAttributeOrThrow(this.el, "data-cell-id"), tag: getAttributeOrThrow(this.el, "data-tag"), - language: getAttributeOrThrow(this.el, "data-language"), + language: getAttributeOrDefault(this.el, "data-language", null), intellisense: getAttributeOrThrow( this.el, "data-intellisense", diff --git a/lib/livebook/runtime.ex b/lib/livebook/runtime.ex index 121958904..7f39282d3 100644 --- a/lib/livebook/runtime.ex +++ b/lib/livebook/runtime.ex @@ -364,7 +364,7 @@ defprotocol Livebook.Runtime do @typedoc """ Smart cell editor configuration. """ - @type editor :: %{language: String.t(), placement: :bottom | :top, source: String.t()} + @type editor :: %{language: String.t() | nil, placement: :bottom | :top, source: String.t()} @typedoc """ An opaque file reference.