MCPcopy Create free account
hub / github.com/PaperDebugger/paperdebugger / onElementAdded

Function onElementAdded

webapp/_webapp/src/libs/helpers.ts:24–41  ·  view source on GitHub ↗
(selector: string, callback: (element: Element) => void)

Source from the content-addressed store, hash-verified

22}
23
24export function onElementAdded(selector: string, callback: (element: Element) => void) {
25 const observer = new MutationObserver((mutations) => {
26 mutations.forEach((mutation) => {
27 mutation.addedNodes.forEach((node) => {
28 if (node.nodeType === 1 && (node as Element).matches(selector)) {
29 callback(node as Element);
30 }
31 });
32 });
33 });
34
35 observer.observe(document.body, {
36 childList: true,
37 subtree: true,
38 });
39
40 return observer;
41}
42
43export function getCodeMirrorView(): EditorView | null {
44 const cmContent = document.querySelector(".cm-content");

Callers 1

MainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected