MCPcopy Create free account
hub / github.com/Exafunction/codeium-chrome / addCodeMirror5GlobalInject

Function addCodeMirror5GlobalInject

src/script.ts:134–173  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

132];
133
134const addCodeMirror5GlobalInject = () =>
135 Object.defineProperty(window, 'CodeMirror', {
136 get: function () {
137 return this._codeium_CodeMirror;
138 },
139 set: function (cm?: { version?: string }) {
140 this._codeium_CodeMirror = cm;
141 if (injectCodeMirror) {
142 return;
143 }
144 if (!cm?.version?.startsWith('5.')) {
145 console.warn("Codeium doesn't support CodeMirror 6");
146 return;
147 }
148 // We rely on the fact that the Jupyter variable is defined first.
149 if (Object.prototype.hasOwnProperty.call(this, 'Jupyter')) {
150 injectCodeMirror = true;
151 const jupyterState = jupyterInject(extensionId, this.Jupyter);
152 addListeners(cm as CodeMirror, jupyterState.codeMirrorManager);
153 console.log('Activated Codeium');
154 } else {
155 let multiplayer = false;
156 for (const pattern of SUPPORTED_CODEMIRROR_SITES) {
157 if (pattern.pattern.test(window.location.href)) {
158 console.log('Codeium: Activating CodeMirror');
159 injectCodeMirror = true;
160 multiplayer = pattern.multiplayer;
161 break;
162 }
163
164 injectCodeMirror = true;
165 break;
166 }
167 if (injectCodeMirror) {
168 new CodeMirrorState(extensionId, cm as CodeMirror, multiplayer);
169 console.log('Activated Codeium');
170 }
171 }
172 },
173 });
174
175// In this case, the CodeMirror 5 editor is accessible as a property of elements
176// with the class CodeMirror.

Callers 1

script.tsFile · 0.85

Calls 1

addListenersFunction · 0.90

Tested by

no test coverage detected