An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
export const isFoldedHeading = (element?: Element) =>
element?.getAttribute("data-type") === "NodeHeading" && element.getAttribute("fold") === "1";
const getHeadingLevel = (element: Element) => {
const subtype = element.getAttribute("data-subtype");
if (!subtype?.startsWith("h")) {
return NaN;
}
return Number.parseInt(subtype.substring(1));
};
export const shouldUnfoldMovedHeading = (heading: Element, nextBlock?: Element) => {
if (!isFoldedHeading(heading) || !nextBlock) {
return false;
}
if (nextBlock.getAttribute("data-type") !== "NodeHeading") {
return true;
}
const headingLevel = getHeadingLevel(heading);
const nextLevel = getHeadingLevel(nextBlock);
return Number.isNaN(headingLevel) || Number.isNaN(nextLevel) || nextLevel > headingLevel;
};