@@ -402,6 +402,14 @@ export const createAutocompleteOptions = (referenceBaseUrl) => ({
402402 ]
403403} ) ;
404404
405+ // Uses window.document explicitly to avoid shadowing by the `document`
406+ // parameter in createNewFileState below.
407+ function createFoldMarker ( open ) {
408+ const span = window . document . createElement ( 'span' ) ;
409+ span . className = open ? 'cm-fold-open' : 'cm-fold-closed' ;
410+ return span ;
411+ }
412+
405413/**
406414 * Creates a new CodeMirror editor state with configurations,
407415 * extensions, and keymaps tailored to the file type and settings.
@@ -416,12 +424,14 @@ export function createNewFileState(filename, document, settings) {
416424 autocloseBracketsQuotes,
417425 onUpdateLinting,
418426 onViewUpdate,
419- referenceBaseUrl
427+ referenceBaseUrl,
428+ fontSize
420429 } = settings ;
421430 const lineNumbersCpt = new Compartment ( ) ;
422431 const lineWrappingCpt = new Compartment ( ) ;
423432 const closeBracketsCpt = new Compartment ( ) ;
424433 const autocompleteCpt = new Compartment ( ) ;
434+ const fontSizeCpt = new Compartment ( ) ;
425435
426436 // Depending on the file mode, we have a different tidier function.
427437 // Keep this binding local to each file state so modes don't accumulate
@@ -469,6 +479,7 @@ export function createNewFileState(filename, document, settings) {
469479 // https://github.com/codemirror/basic-setup/blob/main/src/codemirror.ts
470480 const extensions = [
471481 // The first few extensions can be toggled on or off.
482+ fontSizeCpt . of ( EditorView . theme ( { '&' : { fontSize : `${ fontSize } px` } } ) ) ,
472483 lineNumbersCpt . of ( lineNumbers ? lineNumbersExt ( ) : [ ] ) ,
473484 lineWrappingCpt . of ( linewrap ? EditorView . lineWrapping : [ ] ) ,
474485 closeBracketsCpt . of ( autocloseBracketsQuotes ? closeBrackets ( ) : [ ] ) ,
@@ -495,7 +506,7 @@ export function createNewFileState(filename, document, settings) {
495506 EditorState . allowMultipleSelections . of ( true ) ,
496507 // Gutter extensions
497508 gutters ( { fixed : false } ) ,
498- foldGutter ( ) ,
509+ foldGutter ( { markerDOM : createFoldMarker } ) ,
499510 // Misc extensions
500511 indentOnInput ( ) ,
501512 bracketMatching ( ) ,
@@ -557,7 +568,8 @@ export function createNewFileState(filename, document, settings) {
557568 lineNumbersCpt,
558569 lineWrappingCpt,
559570 closeBracketsCpt,
560- autocompleteCpt
571+ autocompleteCpt,
572+ fontSizeCpt
561573 } ;
562574}
563575
0 commit comments