MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / normalizeThemeSpec

Method normalizeThemeSpec

src/lib/acode.js:119–152  ·  view source on GitHub ↗
(spec)

Source from the content-addressed store, hash-verified

117
118 // CodeMirror editor theme API for plugins
119 const normalizeThemeSpec = (spec) => {
120 if (!spec || typeof spec !== "object" || Array.isArray(spec)) {
121 console.warn(
122 "[editorThemes] register(spec) expects an object: { id, caption?, dark?, getExtension|extensions|extension|theme, config? }",
123 );
124 return null;
125 }
126
127 const id = spec.id || spec.name;
128 if (!id) {
129 console.warn("[editorThemes] register(spec) requires a valid `id`.");
130 return null;
131 }
132
133 const extensionSource =
134 spec.getExtension || spec.extensions || spec.extension || spec.theme;
135 if (extensionSource === undefined || extensionSource === null) {
136 console.warn(
137 `[editorThemes] register('${id}') requires extensions via getExtension/extensions/extension/theme.`,
138 );
139 return null;
140 }
141
142 return {
143 id,
144 caption: spec.caption || spec.label || id,
145 isDark: spec.isDark ?? spec.dark ?? false,
146 getExtension:
147 typeof extensionSource === "function"
148 ? extensionSource
149 : () => extensionSource,
150 config: spec.config ?? null,
151 };
152 };
153
154 const createHighlightStyle = (spec) => {
155 if (!spec) return null;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected