From 0b5c731b52eda21af6c925e31c584c02c2be807d Mon Sep 17 00:00:00 2001 From: Xicheng Guo Date: Fri, 12 Jul 2024 10:22:18 +0800 Subject: [PATCH] update MarMap --- src/MarkMap.vue | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/MarkMap.vue b/src/MarkMap.vue index d1c7a54..acc548f 100644 --- a/src/MarkMap.vue +++ b/src/MarkMap.vue @@ -30,6 +30,18 @@ const createOrUpdateMarkmap = (markmapFormat) => { } markmapInstance = Markmap.create('#markmap', undefined, markmapFormat); + + // 滚动到当前节点 + document.querySelectorAll(".markmap-node").forEach((node) => { + node.addEventListener('click', (event) => { + setTimeout(() => { + const activeNode = document.querySelector('.is-active'); + if (activeNode) { + activeNode.scrollIntoView({ behavior: 'auto', block: 'center' }); + } + }, 500) + }); + }); } const convertMarkdown = (markdown) => {