added slider and some ui fixes

This commit is contained in:
David Meincke
2023-05-30 17:10:35 +02:00
parent 28631e8251
commit e3515901e4
13 changed files with 281 additions and 297 deletions
@@ -11,12 +11,15 @@ export class CodeEditor extends BaseElement {
public input: string = "";
public language: string = "";
public editor!: monaco.editor.IStandaloneCodeEditor;
public lastInputCache: any;
onInit(): void {
this.initWorkers();
this.input = this.setInitInput();
this.language = this.tagName.substring(0, this.tagName.indexOf("-")).toLocaleLowerCase();
this.lastInputCache = localStorage.getItem(this.language + "LastInputCache");
this.input = this.setInitInput();
this.setInitSettings();
const prefersDarkScheme = window.matchMedia("(prefers-color-scheme: dark)");
@@ -38,6 +41,8 @@ export class CodeEditor extends BaseElement {
this.editor.onDidChangeModelContent((e) => {
if (!isSessionPage()) {
this.input = this.editor.getValue();
this.lastInputCache = this.input;
localStorage.setItem(this.language + "LastInputCache", this.input);
debounce.ensureDebounce(() => {
sessionApi.setSessionData(this.language, this.input);
this.outputFrame.setContent(this.language, this.input);
@@ -54,13 +59,21 @@ export class CodeEditor extends BaseElement {
setInput(input: any) {
if (this.input !== input) {
this.input = input;
this.lastInputCache = this.input;
localStorage.setItem(this.language + "LastInputCache", this.input);
this.editor.setValue(input);
this.outputFrame.setContent(this.language, this.input);
}
}
setInitInput(): string {
return "";
if (!isSessionPage() && sessionApi.hasSession()) {
return this.lastInputCache;
}
else {
return "";
}
}
setInitSettings(): void {