blob: 45bf6b56cb00242098f4efd4fc765b0339cbc927 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
export type ScopeEntry = {
hasSelection: () => boolean;
clear: () => void;
};
let activeScope: ScopeEntry | null = null;
export function activateScope({ entry }: { entry: ScopeEntry }): () => void {
if (activeScope && activeScope !== entry) {
activeScope.clear();
}
activeScope = entry;
return () => {
if (activeScope === entry) {
activeScope = null;
}
};
}
export function clearActiveScope(): boolean {
if (!activeScope?.hasSelection()) {
return false;
}
activeScope.clear();
return true;
}
|