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

Function addCodeMirror5LocalInject

src/script.ts:186–216  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

184const hook = codeMirrorState.editorHook();
185
186const addCodeMirror5LocalInject = () => {
187 const f = setInterval(() => {
188 if (injectCodeMirror) {
189 clearInterval(f);
190 return;
191 }
192 let notebook = false;
193 for (const pattern of SUPPORTED_CODEMIRROR_NONGLOBAL_SITES) {
194 if (pattern.pattern.test(window.location.href)) {
195 notebook = pattern.notebook;
196 break;
197 }
198 }
199 const docsByPosition = new Map<CodeMirror.Doc, number>();
200 for (const el of document.getElementsByClassName('CodeMirror')) {
201 const maybeCodeMirror = el as { CodeMirror?: CodeMirror.Editor };
202 if (maybeCodeMirror.CodeMirror === undefined) {
203 continue;
204 }
205 const editor = maybeCodeMirror.CodeMirror;
206 hook(editor);
207 if (notebook) {
208 docsByPosition.set(editor.getDoc(), (el as HTMLElement).getBoundingClientRect().top);
209 }
210 }
211 if (notebook) {
212 const docs = [...docsByPosition.entries()].sort((a, b) => a[1] - b[1]).map(([doc]) => doc);
213 codeMirrorState.docs = docs;
214 }
215 }, 500);
216};
217
218getAllowlist(extensionId).then((allowlist) => {
219 for (const addr of computeAllowlist(allowlist)) {

Callers 1

script.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected