An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: Show new mind maps immediately from slash commands https://github.com/siyuan-note/siyuan/issues/19829
Daniele4d9ba0de211
diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.tsindex 9f30442dd1..b906b1e836 100644--- a/app/src/protyle/hint/index.ts+++ b/app/src/protyle/hint/index.ts@@ -34,6 +34,7 @@ import {transaction, updateTransaction} from "../wysiwyg/transaction";import {insertHTML} from "../util/insertHTML";import {highlightRender} from "../render/highlightRender";import {spinListMindmapDOM} from "../render/listMindmap/create";+import {mountNewListMindmap} from "../render/listMindmap";import {assetMenu, imgMenu} from "../../menus/protyle";import {hideElements} from "../ui/hideElements";import {fetchPost} from "../../util/fetch";@@ -1269,6 +1270,9 @@ ${genHintItemHTML(item)}});} else {focusByWbr(nodeElement, range);+ if (isMindmap && nodeElement.dataset.type === "NodeMindmap") {+ mountNewListMindmap(protyle, nodeElement);+ }}}}diff --git a/app/src/protyle/render/listMindmap/index.ts b/app/src/protyle/render/listMindmap/index.tsindex aefbacfe59..c9cbb4fbac 100644--- a/app/src/protyle/render/listMindmap/index.ts+++ b/app/src/protyle/render/listMindmap/index.ts@@ -38,7 +38,9 @@ import {focusListMindmap} from "./create";import {getListMindmapFoldStates} from "./fold";import {isMobile} from "../../../util/functions";-const roots = new WeakMap<IProtyle, {refresh: () => void, destroy: () => void}>();+const roots = new WeakMap<IProtyle, {refresh: () => void, mountNew: (list: HTMLElement) => void, destroy: () => void}>();++export const mountNewListMindmap = (owner: IProtyle, list: HTMLElement) => roots.get(owner)?.mountNew(list);const canToggleView = (owner: IProtyle, list: HTMLElement) => !owner.disabled && !owner.lite &&list.isConnected && !!list.dataset.nodeId &&@@ -541,6 +543,7 @@ export const initListMindmaps = (owner: IProtyle) => {const root = owner.wysiwyg.element;const instances = new Map<HTMLElement, ListMindmapController>();const loading = new WeakSet<HTMLElement>();+ const newlyCreated = new WeakSet<HTMLElement>();let frame = 0;let disposed = false;const refresh = () => {@@ -579,7 +582,7 @@ export const initListMindmaps = (owner: IProtyle) => {list.removeAttribute("data-mindmap-view-rendered");}};- if (canEdit(owner, list)) {+ if (canEdit(owner, list) && !newlyCreated.has(list)) {loading.add(list);let retry = false;void completeList(owner, list).then(complete => {@@ -595,6 +598,7 @@ export const initListMindmaps = (owner: IProtyle) => {}});} else {+ newlyCreated.delete(list);mount();}});@@ -618,7 +622,12 @@ export const initListMindmaps = (owner: IProtyle) => {}});observer.observe(root, {childList: true, subtree: true, attributes: true, characterData: true});- roots.set(owner, {refresh: schedule, destroy: () => {+ roots.set(owner, {refresh: schedule, mountNew: list => {+ if (root.contains(list)) {+ newlyCreated.add(list);+ refresh();+ }+ }, destroy: () => {disposed = true;unregister();observer.disconnect();