Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fix the problem of plugin outline tree in workspace mode #1572

Merged
merged 1 commit into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 4 additions & 16 deletions packages/plugin-outline-pane/src/controllers/tree-master.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export interface ITreeBoard {
export class TreeMaster {
readonly pluginContext: IPublicModelPluginContext;

private boards = new Set<ITreeBoard>();

private treeMap = new Map<string, Tree>();

constructor(pluginContext: IPublicModelPluginContext) {
this.pluginContext = pluginContext;
let startTime: any;
Expand Down Expand Up @@ -70,8 +74,6 @@ export class TreeMaster {
}
}

private boards = new Set<ITreeBoard>();

addBoard(board: ITreeBoard) {
this.boards.add(board);
}
Expand All @@ -84,8 +86,6 @@ export class TreeMaster {
// todo others purge
}

private treeMap = new Map<string, Tree>();

get currentTree(): Tree | null {
const doc = this.pluginContext.project.getCurrentDocument();
if (doc) {
Expand All @@ -100,15 +100,3 @@ export class TreeMaster {
return null;
}
}

const mastersMap = new Map<string, TreeMaster>();
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;
}
4 changes: 2 additions & 2 deletions packages/plugin-outline-pane/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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 {
Expand Down