import type { CmdKey } from '@milkdown/core' import type { Ctx } from '@milkdown/ctx' import { commandsCtx } from '@milkdown/core' type InferParams = T extends CmdKey ? U : never /// Call a command. You can pass the command key and the payload to the macro. export function callCommand>( slice: string, payload?: InferParams ): (ctx: Ctx) => boolean export function callCommand( slice: CmdKey, payload?: T ): (ctx: Ctx) => boolean export function callCommand( slice: string | CmdKey, payload?: any ): (ctx: Ctx) => boolean export function callCommand( slice: string | CmdKey, payload?: any ): (ctx: Ctx) => boolean { return (ctx: Ctx) => { return ctx.get(commandsCtx).call(slice, payload) } }