moderator-toolbox-nxg-for-reddit / util/ui/codemirrorSetup
util/ui/codemirrorSetup¶
Functions¶
createEditor()¶
createEditor(
options):EditorHandle
Defined in: extension/data/util/ui/codemirrorSetup.ts:176
Creates a CodeMirror 6 editor replacing the given textarea. Returns a handle with getValue/setValue/setTheme/destroy.
Parameters¶
options¶
Returns¶
createKeyboardShortcutsHelper()¶
createKeyboardShortcutsHelper():
HTMLElement
Defined in: extension/data/util/ui/codemirrorSetup.ts:290
Creates the keyboard-shortcuts panel injected above CodeMirror editors.
Returns¶
HTMLElement
Interfaces¶
CreateEditorOptions¶
Defined in: extension/data/util/ui/codemirrorSetup.ts:150
Properties¶
autocomplete?¶
optionalautocomplete?:boolean
Defined in: extension/data/util/ui/codemirrorSetup.ts:160
Whether to enable auto-close-brackets.
lineWrapping?¶
optionallineWrapping?:boolean
Defined in: extension/data/util/ui/codemirrorSetup.ts:158
Whether to wrap long lines.
lintSource?¶
optionallintSource?: (text) =>EditorLintDiagnostic[]
Defined in: extension/data/util/ui/codemirrorSetup.ts:169
When provided, the editor runs this on the current text (debounced after changes) and highlights the returned ranges in the text and gutter.
Parameters¶
text¶
string
Returns¶
mimetype¶
mimetype:
string
Defined in: extension/data/util/ui/codemirrorSetup.ts:154
MIME type used to pick a language extension.
onChange?¶
optionalonChange?: () =>void
Defined in: extension/data/util/ui/codemirrorSetup.ts:164
Called whenever the editor content changes. Syncs textarea automatically.
Returns¶
void
readOnly?¶
optionalreadOnly?:boolean
Defined in: extension/data/util/ui/codemirrorSetup.ts:162
Whether the editor is read-only.
textarea¶
textarea:
HTMLTextAreaElement
Defined in: extension/data/util/ui/codemirrorSetup.ts:152
Textarea to replace with the editor. Its initial value is used as the editor content.
theme¶
theme:
"dracula"|"abcdef"|"abyss"|"androidstudio"|"andromeda"|"atomone"|"aura"|"basicDark"|"basicLight"|"bbedit"|"bespin"|"consoleDark"|"consoleLight"|"copilot"|"darcula"|"eclipse"|"githubDark"|"githubLight"|"gruvboxDark"|"gruvboxLight"|"kimbie"|"material"|"materialDark"|"materialLight"|"monokai"|"monokaiDimmed"|"noctisLilac"|"nord"|"okaidia"|"quietlight"|"red"|"solarizedDark"|"solarizedLight"|"sublime"|"tokyoNight"|"tokyoNightDay"|"tokyoNightStorm"|"tomorrowNightBlue"|"vscodeDark"|"vscodeLight"|"whiteDark"|"whiteLight"|"xcodeDark"|"xcodeLight"
Defined in: extension/data/util/ui/codemirrorSetup.ts:156
Initial theme name.
EditorHandle¶
Defined in: extension/data/util/ui/codemirrorSetup.ts:143
Handle returned by createEditor so callers don’t need to import CM6 types.
Methods¶
destroy()¶
destroy():
void
Defined in: extension/data/util/ui/codemirrorSetup.ts:147
Returns¶
void
getValue()¶
getValue():
string
Defined in: extension/data/util/ui/codemirrorSetup.ts:144
Returns¶
string
setTheme()¶
setTheme(
name):void
Defined in: extension/data/util/ui/codemirrorSetup.ts:146
Parameters¶
name¶
"dracula" | "abcdef" | "abyss" | "androidstudio" | "andromeda" | "atomone" | "aura" | "basicDark" | "basicLight" | "bbedit" | "bespin" | "consoleDark" | "consoleLight" | "copilot" | "darcula" | "eclipse" | "githubDark" | "githubLight" | "gruvboxDark" | "gruvboxLight" | "kimbie" | "material" | "materialDark" | "materialLight" | "monokai" | "monokaiDimmed" | "noctisLilac" | "nord" | "okaidia" | "quietlight" | "red" | "solarizedDark" | "solarizedLight" | "sublime" | "tokyoNight" | "tokyoNightDay" | "tokyoNightStorm" | "tomorrowNightBlue" | "vscodeDark" | "vscodeLight" | "whiteDark" | "whiteLight" | "xcodeDark" | "xcodeLight"
Returns¶
void
setValue()¶
setValue(
text):void
Defined in: extension/data/util/ui/codemirrorSetup.ts:145
Parameters¶
text¶
string
Returns¶
void
EditorLintDiagnostic¶
Defined in: extension/data/util/ui/codemirrorSetup.ts:133
One lint finding produced by a CreateEditorOptions.lintSource. Mirrors the @codemirror/lint Diagnostic shape so callers don’t need to import CM6 types.
Properties¶
from¶
from:
number
Defined in: extension/data/util/ui/codemirrorSetup.ts:135
Character offset where the highlight starts.
message¶
message:
string
Defined in: extension/data/util/ui/codemirrorSetup.ts:139
severity¶
severity:
"error"|"warning"
Defined in: extension/data/util/ui/codemirrorSetup.ts:138
to¶
to:
number
Defined in: extension/data/util/ui/codemirrorSetup.ts:137
Character offset where the highlight ends.