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

Function getElemAsStr

frontend/util/focusutil.ts:17–41  ·  view source on GitHub ↗
(elem: EventTarget)

Source from the content-addressed store, hash-verified

15}
16
17export function getElemAsStr(elem: EventTarget) {
18 if (elem == null) {
19 return "null";
20 }
21 if (!(elem instanceof HTMLElement)) {
22 if (elem instanceof Text) {
23 elem = elem.parentElement;
24 }
25 if (!(elem instanceof HTMLElement)) {
26 return "unknown";
27 }
28 }
29 const blockId = findBlockId(elem);
30 let rtn = elem.tagName.toLowerCase();
31 if (!util.isBlank(elem.id)) {
32 rtn += "#" + elem.id;
33 }
34 if (!util.isBlank(elem.className)) {
35 rtn += "." + elem.className;
36 }
37 if (blockId != null) {
38 rtn += ` [${blockId.substring(0, 8)}]`;
39 }
40 return rtn;
41}
42
43export function hasSelection() {
44 const sel = document.getSelection();

Callers 5

appFocusInFunction · 0.90
appFocusOutFunction · 0.90
appSelectionChangeFunction · 0.90
AppFocusHandlerFunction · 0.90
block.tsxFile · 0.90

Calls 1

findBlockIdFunction · 0.85

Tested by

no test coverage detected