Initial RuneStone project
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
// Readers retain editor selection when toolbar buttons take focus.
|
||||
let current: { id: string; read: () => string } | undefined;
|
||||
export function registerSelection(id: string, read: () => string): () => void {
|
||||
const owner = { id, read };
|
||||
current = owner;
|
||||
return () => { if (current === owner) current = undefined; };
|
||||
}
|
||||
export function selectedEditorText(id?: string): string {
|
||||
return current && current.id === id ? current.read() : "";
|
||||
}
|
||||
Reference in New Issue
Block a user