Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions assets/js/hooks/cell_editor/live_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
8 changes: 8 additions & 0 deletions assets/js/hooks/editor_settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ 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;
editorFontSizeCheckbox.checked =
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 });
Expand All @@ -54,6 +58,10 @@ const EditorSettings = {
: EDITOR_THEME.default,
});
});

editorMarkdownWordWrapCheckbox.addEventListener("change", (event) => {
settingsStore.update({ editor_markdown_word_wrap: event.target.checked });
});
},
};

Expand Down
1 change: 1 addition & 0 deletions assets/js/lib/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

/**
Expand Down
4 changes: 4 additions & 0 deletions lib/livebook_web/live/settings_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down