Add setting to render ligatures in codemirror cell editor (#2609)

This commit is contained in:
Juergen Braungardt 2024-05-17 11:14:47 +02:00 committed by GitHub
parent 56a71989be
commit 7a31e892de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 17 additions and 1 deletions

View file

@ -276,6 +276,12 @@ export default class LiveEditor {
"&": { fontSize: `${settings.editor_font_size}px` }, "&": { fontSize: `${settings.editor_font_size}px` },
}); });
const ligaturesTheme = EditorView.theme({
"&": {
fontVariantLigatures: `${settings.editor_ligatures ? "normal" : "none"}`,
},
});
const lineWrappingEnabled = const lineWrappingEnabled =
this.language === "markdown" && settings.editor_markdown_word_wrap; this.language === "markdown" && settings.editor_markdown_word_wrap;
@ -319,6 +325,7 @@ export default class LiveEditor {
EditorView.contentAttributes.of({ tabIndex: -1 }), EditorView.contentAttributes.of({ tabIndex: -1 }),
fontSizeTheme, fontSizeTheme,
settings.editor_theme === "light" ? lightTheme : theme, settings.editor_theme === "light" ? lightTheme : theme,
ligaturesTheme,
collab(this.collabClient), collab(this.collabClient),
collabMarkers(this.collabClient), collabMarkers(this.collabClient),
autocompletion({ autocompletion({

View file

@ -20,7 +20,6 @@ function buildEditorTheme(colors, { dark }) {
backgroundColor: colors.background, backgroundColor: colors.background,
fontSize: "14px", fontSize: "14px",
fontFamily: fonts.mono, fontFamily: fonts.mono,
fontVariantLigatures: "none",
}, },
"&.cm-focused": { "&.cm-focused": {

View file

@ -20,6 +20,9 @@ const EditorSettings = {
const editorFontSizeCheckbox = this.el.querySelector( const editorFontSizeCheckbox = this.el.querySelector(
`[name="editor_font_size"][value="true"]`, `[name="editor_font_size"][value="true"]`,
); );
const editorLigaturesCheckbox = this.el.querySelector(
`[name="editor_ligatures"][value="true"]`,
);
const editorLightThemeCheckbox = this.el.querySelector( const editorLightThemeCheckbox = this.el.querySelector(
`[name="editor_light_theme"][value="true"]`, `[name="editor_light_theme"][value="true"]`,
); );
@ -32,6 +35,7 @@ const EditorSettings = {
editorAutoSignatureCheckbox.checked = settings.editor_auto_signature; editorAutoSignatureCheckbox.checked = settings.editor_auto_signature;
editorFontSizeCheckbox.checked = editorFontSizeCheckbox.checked =
settings.editor_font_size === EDITOR_FONT_SIZE.large ? true : false; settings.editor_font_size === EDITOR_FONT_SIZE.large ? true : false;
editorLigaturesCheckbox.checked = settings.editor_ligatures;
editorLightThemeCheckbox.checked = editorLightThemeCheckbox.checked =
settings.editor_theme === EDITOR_THEME.light ? true : false; settings.editor_theme === EDITOR_THEME.light ? true : false;
editorMarkdownWordWrapCheckbox.checked = settings.editor_markdown_word_wrap; editorMarkdownWordWrapCheckbox.checked = settings.editor_markdown_word_wrap;
@ -53,6 +57,10 @@ const EditorSettings = {
}); });
}); });
editorLigaturesCheckbox.addEventListener("change", (event) => {
settingsStore.update({ editor_ligatures: event.target.checked });
});
editorLightThemeCheckbox.addEventListener("change", (event) => { editorLightThemeCheckbox.addEventListener("change", (event) => {
settingsStore.update({ settingsStore.update({
editor_theme: event.target.checked editor_theme: event.target.checked

View file

@ -24,6 +24,7 @@ const DEFAULTSETTINGS = {
editor_auto_signature: true, editor_auto_signature: true,
editor_font_size: EDITOR_FONT_SIZE.normal, editor_font_size: EDITOR_FONT_SIZE.normal,
editor_theme: EDITOR_THEME.default, editor_theme: EDITOR_THEME.default,
editor_ligatures: false,
editor_markdown_word_wrap: true, editor_markdown_word_wrap: true,
editor_mode: EDITOR_MODE.default, editor_mode: EDITOR_MODE.default,
custom_view_show_section: true, custom_view_show_section: true,

View file

@ -156,6 +156,7 @@ defmodule LivebookWeb.SettingsLive do
value={false} value={false}
/> />
<.switch_field name="editor_font_size" label="Increase font size" value={false} /> <.switch_field name="editor_font_size" label="Increase font size" value={false} />
<.switch_field name="editor_ligatures" label="Render ligatures" value={false} />
<.switch_field name="editor_light_theme" label="Use light theme" value={false} /> <.switch_field name="editor_light_theme" label="Use light theme" value={false} />
<.switch_field <.switch_field
name="editor_markdown_word_wrap" name="editor_markdown_word_wrap"