MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / getMode

Function getMode

lib/web/CodeMirror/src/modes.js:40–59  ·  view source on GitHub ↗
(options, spec)

Source from the content-addressed store, hash-verified

38// Given a mode spec (anything that resolveMode accepts), find and
39// initialize an actual mode object.
40export function getMode(options, spec) {
41 spec = resolveMode(spec)
42 let mfactory = modes[spec.name]
43 if (!mfactory) return getMode(options, "text/plain")
44 let modeObj = mfactory(options, spec)
45 if (modeExtensions.hasOwnProperty(spec.name)) {
46 let exts = modeExtensions[spec.name]
47 for (let prop in exts) {
48 if (!exts.hasOwnProperty(prop)) continue
49 if (modeObj.hasOwnProperty(prop)) modeObj["_" + prop] = modeObj[prop]
50 modeObj[prop] = exts[prop]
51 }
52 }
53 modeObj.name = spec.name
54 if (spec.helperType) modeObj.helperType = spec.helperType
55 if (spec.modeProps) for (let prop in spec.modeProps)
56 modeObj[prop] = spec.modeProps[prop]
57
58 return modeObj
59}
60
61// This can be used to attach properties to mode objects from
62// outside the actual mode definition.

Callers 1

loadModeFunction · 0.90

Calls 1

resolveModeFunction · 0.70

Tested by

no test coverage detected