I am trying to change font-family and font-size of my CodeMirror editor. I tried changing it by setting the according CSS attributes but it does not seem to work for me:
.codemirror-textarea {
font-family: Arial, monospace;
font-size: 16px;
}
Do I have to import something in order to achieve this or might I have to edit the libraries CSS file directly? What am I doing wrong?
Step 2: JavaScript code to dynamically set the font size.CodeMirror-line span'). css('font-size',v + 'px') }); Update 12/07/2022: The above code will increase the font size, but the line will revert to its original font size when edited (I mean, the active line).
Use a keyboard shortcut to change the font size in the editor. To increase the font size, press ⌃⇧Period on macOS or Alt+Shift+Dot on Windows and Linux. To decrease it, press ⌃⇧Comma on macOS or Alt+Shift+Comma on Windows and Linux.
Or add an extension
const customTheme = EditorView.theme({
'&': {
font:"'JetBrains Mono', monospace",
}
})
const startState = EditorState.create({
doc: page.text,
extensions: [
customTheme,
// ...
]
})
Try setting the CSS on:
.CodeMirror {
font-family: Arial, monospace;
font-size: 16px;
}
This selects the element that contains all the formatted code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With