Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

728 B
Raw Blame
type TSlashHint = (key: string, protyle: IProtyle, source: THintSource) => IHintData[];

type TBuiltinSlashValue = (value: string, protyle: IProtyle) => boolean;

const builtinSlashHints = new WeakMap<TSlashHint, TBuiltinSlashValue>();

// 标记内置斜杠菜单及其过滤包装,保留候选项的命令语义。
export const registerBuiltinSlashHint = <T extends TSlashHint>(hint: T,
                                                            isBuiltinValue: TBuiltinSlashValue = () => true): T => {
    builtinSlashHints.set(hint, isBuiltinValue);
    return hint;
};

export const isBuiltinSlashHint = (hint: TSlashHint, value: string, protyle: IProtyle) =>
    builtinSlashHints.get(hint)?.(value, protyle) ?? false;