Add an option for wrapping words in Markdown editor by default (#1107)

This commit is contained in:
Jonatan Kłosko 2022-04-13 23:54:05 +02:00 committed by GitHub
parent d486dbb86b
commit 39a294abbe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 0 deletions

View file

@ -262,6 +262,10 @@ class LiveEditor {
// of the line we would get "defmodule" as a word completion.
wordBasedSuggestions: !this.intellisense,
parameterHints: this.intellisense && settings.editor_auto_signature,
wordWrap:
this.language === "markdown" && settings.editor_markdown_word_wrap
? "on"
: "off",
});
this.editor.addAction({

View file

@ -23,6 +23,9 @@ const EditorSettings = {
const editorHighContrastCheckbox = this.el.querySelector(
`[name="editor_high_contrast"][value="true"]`
);
const editorMarkdownWordWrapCheckbox = this.el.querySelector(
`[name="editor_markdown_word_wrap"][value="true"]`
);
editorAutoCompletionCheckbox.checked = settings.editor_auto_completion;
editorAutoSignatureCheckbox.checked = settings.editor_auto_signature;
@ -30,6 +33,7 @@ const EditorSettings = {
settings.editor_font_size === EDITOR_FONT_SIZE.large ? true : false;
editorHighContrastCheckbox.checked =
settings.editor_theme === EDITOR_THEME.highContrast ? true : false;
editorMarkdownWordWrapCheckbox.checked = settings.editor_markdown_word_wrap;
editorAutoCompletionCheckbox.addEventListener("change", (event) => {
settingsStore.update({ editor_auto_completion: event.target.checked });
@ -54,6 +58,10 @@ const EditorSettings = {
: EDITOR_THEME.default,
});
});
editorMarkdownWordWrapCheckbox.addEventListener("change", (event) => {
settingsStore.update({ editor_markdown_word_wrap: event.target.checked });
});
},
};

View file

@ -17,6 +17,7 @@ const DEFAULT_SETTINGS = {
editor_auto_signature: true,
editor_font_size: EDITOR_FONT_SIZE.normal,
editor_theme: EDITOR_THEME.default,
editor_markdown_word_wrap: true,
};
/**

View file

@ -121,6 +121,10 @@ defmodule LivebookWeb.SettingsLive do
name="editor_high_contrast"
label="Use high contrast theme"
checked={false} />
<.switch_checkbox
name="editor_markdown_word_wrap"
label="Wrap words in Markdown"
checked={false} />
</div>
</div>
</div>