From 46831c172aa69745b227d7f02cc73c2d44d83a8d Mon Sep 17 00:00:00 2001 From: sanchezcarlosjr <24639141+sanchezcarlosjr@users.noreply.github.com> Date: Sun, 19 Nov 2023 08:15:02 -0800 Subject: [PATCH] feat: start codeblock with last selected language --- src/app/notebook/cellTypes/CodeBlock.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app/notebook/cellTypes/CodeBlock.ts b/src/app/notebook/cellTypes/CodeBlock.ts index f5cd046..c8508ae 100644 --- a/src/app/notebook/cellTypes/CodeBlock.ts +++ b/src/app/notebook/cellTypes/CodeBlock.ts @@ -24,6 +24,7 @@ globalThis.createTable = async (parent: HTMLElement, detail?: {type: string, dis } export class CodeBlock extends InteractiveBlock { + static lastSelectedLanguage = 'javascript'; private cell: HTMLDivElement; private input: HTMLInputElement | null = null; private language: Language; @@ -36,7 +37,7 @@ export class CodeBlock extends InteractiveBlock { this.code = editorJsTool.data.code ?? ""; this.outputCell = editorJsTool.data.output ?? ""; this.cell = document.createElement('div'); - this.language = this.languageFactory((editorJsTool.data.language === undefined) ? editorJsTool.config.language : editorJsTool.data.language); + this.language = this.languageFactory((editorJsTool.data.language === undefined) ? CodeBlock.lastSelectedLanguage : editorJsTool.data.language); } private languageFactory(language: string): Language { @@ -291,6 +292,7 @@ export class CodeBlock extends InteractiveBlock { this.clear(); // @ts-ignore this.language = this.languageFactory(event.target?.value); + CodeBlock.lastSelectedLanguage = this.language.name; this.loadLanguage(); }); wrapper.appendChild(languagesSelect);