Skip to content

Commit

Permalink
feat: start codeblock with last selected language
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchezcarlosjr committed Nov 19, 2023
1 parent 4b2eb5b commit 46831c1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/app/notebook/cellTypes/CodeBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 46831c1

Please sign in to comment.