Skip to content

Commit 7bc23dc

Browse files
committed
use dict for more type safe theme
1 parent d4006b9 commit 7bc23dc

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

src/components/CodeMirror.res

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ module CM6 = {
155155
external dispatchEffects: (editorView, dispatchEffectsArg) => unit = "dispatch"
156156

157157
@module("@codemirror/view") @scope("EditorView") @val
158-
external theme: {..} => extension = "theme"
158+
external theme: dict<dict<string>> => extension = "theme"
159159

160160
@module("@codemirror/view") @scope("EditorView") @val
161161
external lineWrapping: extension = "lineWrapping"
@@ -667,25 +667,27 @@ let createEditor = (config: editorConfig): editorInstance => {
667667
let extensions = [
668668
CM6.Compartment.make(languageConf, (language: CM6.extension)),
669669
CM6.Commands.history(),
670-
CM6.EditorView.theme({
671-
".cm-content": {
672-
"lineHeight": lineHeight,
673-
"caretColor": cursorColor,
674-
},
675-
".cm-line": {
676-
"lineHeight": lineHeight,
677-
},
678-
".cm-cursor, .cm-dropCursor": {"borderLeftColor": cursorColor},
679-
".cm-activeLine": {
680-
"backgroundColor": "rgba(255, 255, 255, 0.02)",
681-
},
682-
".cm-gutters": {"backgroundColor": "inherit"},
683-
".cm-gutters.cm-gutters-before": {"border": "none"},
684-
".cm-activeLineGutter": {
685-
"color": "#cdcdd6",
686-
"backgroundColor": "inherit",
670+
CM6.EditorView.theme(
671+
dict{
672+
".cm-content": dict{
673+
"lineHeight": lineHeight,
674+
"caretColor": cursorColor,
675+
},
676+
".cm-line": dict{
677+
"lineHeight": lineHeight,
678+
},
679+
".cm-cursor, .cm-dropCursor": dict{"borderLeftColor": cursorColor},
680+
".cm-activeLine": dict{
681+
"backgroundColor": "rgba(255, 255, 255, 0.02)",
682+
},
683+
".cm-gutters": dict{"backgroundColor": "inherit"},
684+
".cm-gutters.cm-gutters-before": dict{"border": "none"},
685+
".cm-activeLineGutter": dict{
686+
"color": "#cdcdd6",
687+
"backgroundColor": "inherit",
688+
},
687689
},
688-
}),
690+
),
689691
CM6.EditorView.drawSelection(),
690692
CM6.EditorView.dropCursor(),
691693
CM6.Language.bracketMatching(),

0 commit comments

Comments
 (0)