diff --git a/packages/plugin-outline-pane/src/controllers/tree-master.ts b/packages/plugin-outline-pane/src/controllers/tree-master.ts index 38b723a98..074ed3447 100644 --- a/packages/plugin-outline-pane/src/controllers/tree-master.ts +++ b/packages/plugin-outline-pane/src/controllers/tree-master.ts @@ -11,6 +11,10 @@ export interface ITreeBoard { export class TreeMaster { readonly pluginContext: IPublicModelPluginContext; + private boards = new Set(); + + private treeMap = new Map(); + constructor(pluginContext: IPublicModelPluginContext) { this.pluginContext = pluginContext; let startTime: any; @@ -70,8 +74,6 @@ export class TreeMaster { } } - private boards = new Set(); - addBoard(board: ITreeBoard) { this.boards.add(board); } @@ -84,8 +86,6 @@ export class TreeMaster { // todo others purge } - private treeMap = new Map(); - get currentTree(): Tree | null { const doc = this.pluginContext.project.getCurrentDocument(); if (doc) { @@ -100,15 +100,3 @@ export class TreeMaster { return null; } } - -const mastersMap = new Map(); -export function getTreeMaster(pluginContext: IPublicModelPluginContext): TreeMaster { - const key = pluginContext.project.currentDocument?.id || 'unknown'; - let master = mastersMap.get(key); - if (!master) { - master = new TreeMaster(pluginContext); - pluginContext.logger.info('TreeMaster is created'); - mastersMap.set(key, master); - } - return master; -} diff --git a/packages/plugin-outline-pane/src/index.tsx b/packages/plugin-outline-pane/src/index.tsx index bf3c95b1a..701e46540 100644 --- a/packages/plugin-outline-pane/src/index.tsx +++ b/packages/plugin-outline-pane/src/index.tsx @@ -3,7 +3,7 @@ import { IconOutline } from './icons/outline'; import { IPublicModelPluginContext, IPublicModelDocumentModel } from '@alilc/lowcode-types'; import { enUS, zhCN } from './locale'; import { MasterPaneName, BackupPaneName } from './helper/consts'; -import { getTreeMaster } from './controllers/tree-master'; +import { TreeMaster } from './controllers/tree-master'; import { PaneController } from './controllers/pane-controller'; export const OutlinePlugin = (ctx: IPublicModelPluginContext, options: any) => { @@ -26,7 +26,7 @@ export const OutlinePlugin = (ctx: IPublicModelPluginContext, options: any) => { masterPane: false, backupPane: false, }; - const treeMaster = getTreeMaster(ctx); + const treeMaster = new TreeMaster(ctx); let masterPaneController: PaneController | null = null; let backupPaneController: PaneController | null = null; return {