commands.d.ts 1.4 KB

123456789101112131415161718192021222324252627
  1. import type { Ctx, MilkdownPlugin, SliceType } from '@milkdown/ctx';
  2. import type { Command } from '@milkdown/prose/state';
  3. export type Cmd<T = undefined> = (payload?: T) => Command;
  4. export type CmdKey<T = undefined> = SliceType<Cmd<T>>;
  5. type InferParams<T> = T extends CmdKey<infer U> ? U : never;
  6. export declare class CommandManager {
  7. #private;
  8. setCtx: (ctx: Ctx) => void;
  9. get ctx(): Ctx | null;
  10. create<T>(meta: CmdKey<T>, value: Cmd<T>): import("@milkdown/ctx").Slice<Cmd<T>, string>;
  11. get<T extends CmdKey<any>>(slice: string): Cmd<InferParams<T>>;
  12. get<T>(slice: CmdKey<T>): Cmd<T>;
  13. get(slice: string | CmdKey<any>): Cmd<any>;
  14. remove<T extends CmdKey<any>>(slice: string): void;
  15. remove<T>(slice: CmdKey<T>): void;
  16. remove(slice: string | CmdKey<any>): void;
  17. call<T extends CmdKey<any>>(slice: string, payload?: InferParams<T>): boolean;
  18. call<T>(slice: CmdKey<T>, payload?: T): boolean;
  19. call(slice: string | CmdKey<any>, payload?: any): boolean;
  20. }
  21. export declare function createCmdKey<T = undefined>(key?: string): CmdKey<T>;
  22. export declare const commandsCtx: SliceType<CommandManager, "commands">;
  23. export declare const commandsTimerCtx: SliceType<import("@milkdown/ctx").TimerType[], "commandsTimer">;
  24. export declare const CommandsReady: import("@milkdown/ctx").TimerType;
  25. export declare const commands: MilkdownPlugin;
  26. export {};
  27. //# sourceMappingURL=commands.d.ts.map