Skip to content

Commit

Permalink
Persist editor's font size
Browse files Browse the repository at this point in the history
  • Loading branch information
rossant committed Mar 14, 2024
1 parent 1bbad50 commit 67e6a81
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 0 additions & 1 deletion scripts/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class Editor {
init() {
this.editor = ace.edit("code-editor");
// this.editor.setOptions({
// // fontSize: "12pt"
// });
this.editor.session.setMode("ace/mode/python");
}
Expand Down
11 changes: 11 additions & 0 deletions scripts/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,20 @@ class Model {
await this.storage.init();
await this.editor.init();
await this.grid.init();

// Load editor's font size.
let fontSize = this.storage.loadMetadata("__editorFontSize__");
fontSize = parseInt(fontSize);
if (fontSize) {
this.editor.editor.setFontSize(fontSize);
}
}

save(name) {
// Save editor's font size.
this.storage.storeMetadata(
"__editorFontSize__", parseInt(this.editor.editor.getFontSize()));

console.log(`Saving code listing: "${name}".`);
const code = this.editor.getCode();
const lang = LANG;
Expand Down

0 comments on commit 67e6a81

Please sign in to comment.