MCPcopy Index your code
hub / github.com/marijnh/Eloquent-JavaScript / createState

Function createState

src/client/editor.mjs:11–24  ·  view source on GitHub ↗
(code, mode, extensions = [])

Source from the content-addressed store, hash-verified

9let modeCompartment = new Compartment
10
11export function createState(code, mode, extensions = []) {
12 return EditorState.create({
13 doc: code,
14 extensions: [
15 extensions,
16 modeCompartment.of(mode == "html" ? html() : javascript()),
17 minimalSetup,
18 syntaxHighlighting(classHighlighter),
19 bracketMatching(),
20 lineNumbers(),
21 EditorView.contentAttributes.of({"aria-label": "Code editor"})
22 ]
23 })
24}
25
26export function updateLanguage(mode) {
27 return modeCompartment.reconfigure(mode == "html" ? html() : javascript())

Callers 3

constructorMethod · 0.90
setEditorStateMethod · 0.90
activateCodeFunction · 0.90

Calls 1

createMethod · 0.80

Tested by

no test coverage detected