Skip to content

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

509 B
Raw Blame
const textInputTypes = new Set([
    "insertText",
    "insertReplacementText",
    "insertCompositionText",
]);

export const isTextInputType = (inputType: string, data: string | null): data is string => {
    return !!data && textInputTypes.has(inputType);
};

export const getMultilineInputText = (inputType: string, data: string | null) => {
    if (!isTextInputType(inputType, data) || !/[\r\n\u2028\u2029]/.test(data)) {
        return;
    }
    return data.replace(/\r\n|\r|\u2028|\u2029/g, "\n");
};