json-joy
Version:
Collection of libraries for building collaborative editing apps.
41 lines (40 loc) • 1.89 kB
TypeScript
import { ValueSyncStore } from '../../../../util/events/sync-store';
import { type LeafBlock, type Peritext } from '../../../../json-crdt-extensions';
import { BehaviorSubject } from 'rxjs';
import { type ITimestampStruct } from '../../../../json-crdt-patch';
import type { UiLifeCycles } from '../../../web/types';
import type { PeritextEventDetailMap } from '../../../events/types';
import type { PeritextSurfaceState } from '../../../web';
import type { MenuItem } from '../types';
import type { ToolbarPluginOpts } from '../ToolbarPlugin';
export declare class ToolbarState implements UiLifeCycles {
readonly surface: PeritextSurfaceState;
readonly opts: ToolbarPluginOpts;
readonly txt: Peritext;
lastEvent: PeritextEventDetailMap['change']['ev'] | undefined;
lastEventTs: number;
readonly showInlineToolbar: ValueSyncStore<[show: boolean, time: number]>;
/**
* The ID of the active (where the main cursor or focus is placed) leaf block.
*/
readonly activeLeafBlockId$: BehaviorSubject<ITimestampStruct | null>;
constructor(surface: PeritextSurfaceState, opts: ToolbarPluginOpts);
/** ------------------------------------------- {@link UiLifeCycles} */
start(): () => void;
private _setActiveLeafBlockId;
private setLastEv;
readonly getFormattingMenu: () => MenuItem;
readonly annotationsMenu: () => MenuItem;
readonly modifyMenu: () => MenuItem;
readonly copyAsMenu: (type: "copy" | "cut") => MenuItem;
readonly pasteAsMenu: () => MenuItem;
readonly clipboardMenu: () => MenuItem;
readonly getCaretMenu: () => MenuItem;
readonly getSelectionMenu: () => MenuItem;
readonly blockTypeMenu: () => MenuItem;
readonly leafBlockSmallMenu: (ctx: LeafBlockMenuCtx) => MenuItem;
readonly blockClipboardMenu: () => MenuItem;
}
export interface LeafBlockMenuCtx {
block: LeafBlock;
}