mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-06 19:46:00 +08:00
* Adds an option to increase the font size of the editor * Update lib/livebook_web/live/settings_live.ex Co-authored-by: José Valim <jose.valim@gmail.com> * Editor font size options as constants Co-authored-by: José Valim <jose.valim@gmail.com>
51 lines
1.6 KiB
JavaScript
51 lines
1.6 KiB
JavaScript
import {
|
|
loadLocalSettings,
|
|
storeLocalSettings,
|
|
EDITOR_FONT_SIZE,
|
|
} from "../lib/settings";
|
|
|
|
/**
|
|
* A hook for the editor settings.
|
|
*
|
|
* Those settings are user-specific and only relevant on the client
|
|
* side, so we store them locally in the browser storage, so that
|
|
* they are persisted across application runs.
|
|
*/
|
|
const EditorSettings = {
|
|
mounted() {
|
|
const settings = loadLocalSettings();
|
|
|
|
const editorAutoCompletionCheckbox = this.el.querySelector(
|
|
`[name="editor_auto_completion"][value="true"]`
|
|
);
|
|
const editorAutoSignatureCheckbox = this.el.querySelector(
|
|
`[name="editor_auto_signature"][value="true"]`
|
|
);
|
|
const editorFontSizeCheckbox = this.el.querySelector(
|
|
`[name="editor_font_size"][value="true"]`
|
|
);
|
|
|
|
editorAutoCompletionCheckbox.checked = settings.editor_auto_completion;
|
|
editorAutoSignatureCheckbox.checked = settings.editor_auto_signature;
|
|
editorFontSizeCheckbox.checked =
|
|
settings.editor_font_size === EDITOR_FONT_SIZE.large ? true : false;
|
|
|
|
editorAutoCompletionCheckbox.addEventListener("change", (event) => {
|
|
storeLocalSettings({ editor_auto_completion: event.target.checked });
|
|
});
|
|
|
|
editorAutoSignatureCheckbox.addEventListener("change", (event) => {
|
|
storeLocalSettings({ editor_auto_signature: event.target.checked });
|
|
});
|
|
|
|
editorFontSizeCheckbox.addEventListener("change", (event) => {
|
|
storeLocalSettings({
|
|
editor_font_size: event.target.checked
|
|
? EDITOR_FONT_SIZE.large
|
|
: EDITOR_FONT_SIZE.normal,
|
|
});
|
|
});
|
|
},
|
|
};
|
|
|
|
export default EditorSettings;
|