Skip to content

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

1.0 KB
Raw Blame
export const getMoveAffectedEmbedElements = (
    embedElements: Iterable<Element>,
    operation: Pick<IOperation, "id" | "blockIDs" | "parentID" | "previousID" | "nextID">,
    editingEmbedElement?: Element,
) => {
    const anchorIDs = [operation.id, operation.parentID, operation.previousID, operation.nextID].filter(Boolean);
    const blockIDs = new Set(operation.blockIDs || []);
    if (anchorIDs.length === 0 && blockIDs.size === 0) {
        return [];
    }
    return Array.from(embedElements).filter(item => {
        if (item === editingEmbedElement) {
            return false;
        }
        if (anchorIDs.some(id => item.querySelector(`[data-node-id="${id}"]`))) {
            return true;
        }
        return blockIDs.size > 0 && Array.from(item.querySelectorAll("[data-node-id]"))
            .some(block => blockIDs.has(block.getAttribute("data-node-id")));
    });
};

export const shouldSyncMoveCopies = (isBacklink: boolean, isEmbedChildOperation: boolean) =>
    isBacklink || isEmbedChildOperation;