/**
 * Singleton registry for the most-recently focused TipTap editor in the
 * admin shell. Lets out-of-tree surfaces (Cmd+K palette, slash commands,
 * future global shortcuts) target the editor a user was last working in
 * without prop-drilling refs through the layout.
 *
 * The `TipTapEditor` component calls `setActiveEditor(editor)` from its
 * `onFocus` callback and clears it on unmount. Subscribers receive a no-op
 * payload — they should re-read via `getActiveEditor()` after the
 * notification.
 */
let activeEditor = null;
const listeners = new Set();
export function setActiveEditor(editor) {
    if (activeEditor === editor)
        return;
    activeEditor = editor;
    for (const listener of listeners)
        listener();
}
export function getActiveEditor() {
    return activeEditor;
}
export function clearActiveEditorIf(editor) {
    if (activeEditor === editor) {
        setActiveEditor(null);
    }
}
export function subscribeActiveEditor(listener) {
    listeners.add(listener);
    return () => {
        listeners.delete(listener);
    };
}
//# sourceMappingURL=active-editor.js.map