Skip to content

Commit

Permalink
Mobile: Add padding around beta text editor
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent22 committed Oct 30, 2021
1 parent 6393996 commit 365e152
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,9 @@ packages/lib/commands/synchronize.js.map
packages/lib/components/EncryptionConfigScreen/utils.d.ts
packages/lib/components/EncryptionConfigScreen/utils.js
packages/lib/components/EncryptionConfigScreen/utils.js.map
packages/lib/database-driver-better-sqlite.d.ts
packages/lib/database-driver-better-sqlite.js
packages/lib/database-driver-better-sqlite.js.map
packages/lib/database.d.ts
packages/lib/database.js
packages/lib/database.js.map
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,9 @@ packages/lib/commands/synchronize.js.map
packages/lib/components/EncryptionConfigScreen/utils.d.ts
packages/lib/components/EncryptionConfigScreen/utils.js
packages/lib/components/EncryptionConfigScreen/utils.js.map
packages/lib/database-driver-better-sqlite.d.ts
packages/lib/database-driver-better-sqlite.js
packages/lib/database-driver-better-sqlite.js.map
packages/lib/database.d.ts
packages/lib/database.js
packages/lib/database.js.map
Expand Down
12 changes: 12 additions & 0 deletions packages/app-mobile/components/NoteEditor/CodeMirror.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ function logMessage(...msg: any[]) {
postMessage('onLog', { value: msg });
}

// For an example on how to customize the theme, see:
//
// https://github.com/codemirror/theme-one-dark/blob/main/src/one-dark.ts
//
// Use Safari developer tools to view the content of the CodeMirror iframe while
// the app is running. It seems that what appears as ".ͼ1" in the CSS is the
// equivalent of "&" in the theme object. So to target ".ͼ1.cm-focused", you'd
// use '&.cm-focused' in the theme.
const createTheme = (theme: any): Extension => {
const baseTheme = EditorView.baseTheme({
'&': {
Expand All @@ -40,6 +48,10 @@ const createTheme = (theme: any): Extension => {
fontFamily: theme.fontFamily,
fontSize: `${theme.fontSize}px`,
},

'&.cm-focused': {
outline: 'none',
},
});

const appearanceTheme = EditorView.theme({}, { dark: theme.appearance === 'dark' });
Expand Down
4 changes: 2 additions & 2 deletions packages/app-mobile/components/NoteEditor/NoteEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ function useHtml(css: string): string {
${css}
</style>
</head>
<body style="margin:0; height:100vh; width:100vh; width:100vw; min-width:100vw;">
<div class="CodeMirror" style="height:100%;"></div>
<body style="margin:0; height:100vh; width:100vh; width:100vw; min-width:100vw; box-sizing: border-box; padding: 10px;">
<div class="CodeMirror" style="height:100%;" autocapitalize="on"></div>
</body>
</html>
`
Expand Down

0 comments on commit 365e152

Please sign in to comment.