diff --git a/packages/app-mobile/components/global-style.ts b/packages/app-mobile/components/global-style.ts index b1e7d50f74..191c3b2392 100644 --- a/packages/app-mobile/components/global-style.ts +++ b/packages/app-mobile/components/global-style.ts @@ -15,6 +15,7 @@ const baseStyle = { fontSizeSmaller: 14, disabledOpacity: 0.2, lineHeight: '1.6em', + listTabSize: '1.7em', // The default, may be overridden in settings: noteViewerFontSize: 16, }; diff --git a/packages/editor/CodeMirror/createEditor.ts b/packages/editor/CodeMirror/createEditor.ts index 0fa7fff4ed..411ff4abcb 100644 --- a/packages/editor/CodeMirror/createEditor.ts +++ b/packages/editor/CodeMirror/createEditor.ts @@ -268,8 +268,6 @@ const createEditor = ( }, }), - EditorState.tabSize.of(4), - // Apply styles to entire lines (block-display decorations) decoratorExtension, dropCursor(), diff --git a/packages/editor/CodeMirror/theme.ts b/packages/editor/CodeMirror/theme.ts index 745cd6b643..304f820661 100644 --- a/packages/editor/CodeMirror/theme.ts +++ b/packages/editor/CodeMirror/theme.ts @@ -106,6 +106,14 @@ const createTheme = (theme: EditorTheme): Extension[] => { marginLeft: `${theme.marginLeft}px`, marginRight: `${theme.marginRight}px`, }, + + '& .cm-listItem': { + // Needs to be !important because the tab-size is directly set on the element style + // attribute by CodeMirror. And the `EditorState.tabSize` function only accepts a + // number, while we need a "em" value to make it match the viewer tab size. + tabSize: `${theme.listTabSize} !important`, + }, + '&.cm-focused .cm-cursor': baseCursorStyle, // The desktop app sets the font for these elements to a specific font. diff --git a/packages/editor/types.ts b/packages/editor/types.ts index 0d2b08994b..5fb64f96c7 100644 --- a/packages/editor/types.ts +++ b/packages/editor/types.ts @@ -146,6 +146,7 @@ export interface EditorTheme extends Theme { contentMaxWidth?: number; marginLeft?: number; marginRight?: number; + listTabSize?: string; } export interface EditorSettings { diff --git a/packages/lib/theme.ts b/packages/lib/theme.ts index 1f470abf0b..2125199393 100644 --- a/packages/lib/theme.ts +++ b/packages/lib/theme.ts @@ -52,6 +52,7 @@ const globalStyle = (() => { mainPadding: 12, topRowHeight: 50, editorPaddingLeft: 8, + listTabSize: '1.7em', margin: margin, marginRight: margin, diff --git a/packages/renderer/noteStyle.ts b/packages/renderer/noteStyle.ts index fa33dbb391..34535004b3 100644 --- a/packages/renderer/noteStyle.ts +++ b/packages/renderer/noteStyle.ts @@ -216,7 +216,7 @@ export default function(theme: any, options: Options = null) { } ul, ol { padding-left: 0; - margin-left: 1.7em; + margin-left: ${theme.listTabSize}; } li { margin-bottom: .4em;