Update editor, themes, menus, backgrounds, and release tooling
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
// Readers retain editor selection when toolbar buttons take focus.
|
||||
let current: { id: string; read: () => string } | undefined;
|
||||
const readers = new Map<string, () => string>();
|
||||
export function registerSelection(id: string, read: () => string): () => void {
|
||||
const owner = { id, read };
|
||||
current = owner;
|
||||
return () => { if (current === owner) current = undefined; };
|
||||
readers.set(id, read);
|
||||
return () => { if (readers.get(id) === read) readers.delete(id); };
|
||||
}
|
||||
export function selectedEditorText(id?: string): string {
|
||||
return current && current.id === id ? current.read() : "";
|
||||
return id ? readers.get(id)?.() ?? "" : "";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user