// Readers retain editor selection when toolbar buttons take focus. const readers = new Map string>(); export function registerSelection(id: string, read: () => string): () => void { readers.set(id, read); return () => { if (readers.get(id) === read) readers.delete(id); }; } export function selectedEditorText(id?: string): string { return id ? readers.get(id)?.() ?? "" : ""; }