EditorEnvironment
The editor environment: window-wide capabilities the host provides once per
page with configureEditorEnvironment. Per-document needs go through
EditorHost instead.
Every member is optional: what the host leaves out is switched off quietly — no error, no notice, no fallback of the editor's own. An editor mounted with no environment configured at all is light, English, editable, and has no copy, external-link, spelling or host-key behaviour.
Properties
Section titled “Properties”colorScheme?
Section titled “colorScheme?”
optionalcolorScheme?:object
The window's light / dark scheme: its value now, and a subscription to changes (returns the unsubscribe).
current()
Section titled “current()”current():
ColorScheme
Returns
Section titled “Returns”subscribe()
Section titled “subscribe()”subscribe(
cb): () =>void
Parameters
Section titled “Parameters”(scheme) => void
Returns
Section titled “Returns”() => void
copyText?
Section titled “copyText?”
optionalcopyText?: (text) =>unknown
Put text on the clipboard (code-block copy button). The host reports success / failure itself.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”unknown
handleKey?
Section titled “handleKey?”
optionalhandleKey?: (view,event) =>boolean
Offered every key the editor's keymap sees, before CodeMirror's defaults: return true when the host ran a binding for it (the key is consumed).
Parameters
Section titled “Parameters”EditorView
KeyboardEvent
Returns
Section titled “Returns”boolean
language?
Section titled “language?”
optionallanguage?:"zh"|"ja"|"ko"|"en"
The language of the editor's own UI words. Read whenever a word is drawn, so set it before the first editor mounts; already-drawn words do not redraw on a change. Left out, or not one the editor ships: English.
openExternal?
Section titled “openExternal?”
optionalopenExternal?: (url) =>unknown
Open an external (non-file) link target, e.g. Cmd/Ctrl+click on https://…. The host owns the policy.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”unknown
refusedLink?
Section titled “refusedLink?”
optionalrefusedLink?: (url,scheme) =>unknown
The editor refused to follow a script-capable link (javascript: /
vbscript: / data: …, however obfuscated); scheme is the
scheme as a browser reads it. For telling the user only: the URL MUST NOT
be opened. Absent: the refusal is silent.
Parameters
Section titled “Parameters”string
scheme
Section titled “scheme”string
Returns
Section titled “Returns”unknown
spell?
Section titled “spell?”
optionalspell?:SpellService
The spell-checking service behind the editor's own squiggles and suggestions. Absent: no spell checking.