MCPcopy
hub / github.com/wavetermdev/waveterm / focusedBlockId

Function focusedBlockId

frontend/util/focusutil.ts:48–70  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

46}
47
48export function focusedBlockId(): string {
49 const focused = document.activeElement;
50 if (focused instanceof HTMLElement) {
51 const blockId = findBlockId(focused);
52 if (blockId) {
53 return blockId;
54 }
55 }
56 const sel = document.getSelection();
57 if (sel && sel.anchorNode && sel.rangeCount > 0 && !sel.isCollapsed) {
58 let anchor = sel.anchorNode;
59 if (anchor instanceof Text) {
60 anchor = anchor.parentElement;
61 }
62 if (anchor instanceof HTMLElement) {
63 const blockId = findBlockId(anchor);
64 if (blockId) {
65 return blockId;
66 }
67 }
68 }
69 return null;
70}

Callers 2

nodeFocusWithinMethod · 0.90
block.tsxFile · 0.90

Calls 1

findBlockIdFunction · 0.85

Tested by

no test coverage detected