md和思维导图转换,搜索跳转等场景增加判断视图是否是指定视图

This commit is contained in:
街角小林 2025-09-03 09:11:11 +08:00
parent aade07e08c
commit ef40690fd6
2 changed files with 13 additions and 4 deletions

View file

@ -272,7 +272,10 @@ export default class SimpleMindMapPlugin extends Plugin {
return file && file === curFilePath
})
if (existLeaf) {
if (existLeaf.view.jumpToNodeByUid) {
if (
existLeaf.view instanceof SmmEditView &&
existLeaf.view.jumpToNodeByUid
) {
existLeaf.view.jumpToNodeByUid(uid)
} else {
self.fileToSubpathMap[curFilePath] = uid

View file

@ -9,6 +9,7 @@ import LZString from 'lz-string'
import { SMM_VIEW_TYPE, SMM_TAG } from './constant.js'
import { around } from 'monkey-around'
import markdown from 'simple-mind-map/src/parse/markdown.js'
import SmmEditView from '../SmmEditView.js'
export default class Menus {
constructor(plugin) {
@ -103,8 +104,10 @@ export default class Menus {
const markdownLeafs =
this.app.workspace.getLeavesOfType(SMM_VIEW_TYPE)
for (const leaf of markdownLeafs) {
if (leaf.view.file.path === renamedFile.path) {
leaf.view.isActive = false
if (
leaf.view instanceof SmmEditView &&
leaf.view.file.path === renamedFile.path
) {
leaf.detach()
break
}
@ -230,7 +233,10 @@ export default class Menus {
const markdownLeafs =
this.app.workspace.getLeavesOfType('markdown')
for (const leaf of markdownLeafs) {
if (leaf.view.file.path === renamedFile.path) {
if (
leaf.view instanceof MarkdownView &&
leaf.view.file.path === renamedFile.path
) {
leaf.detach()
break
}