mirror of
https://github.com/dragonish/obsidian-heading-decorator.git
synced 2026-07-22 05:42:05 +00:00
perf(outline): improve efficiency
This commit is contained in:
parent
5cde58f449
commit
d52d7bed1f
1 changed files with 4 additions and 4 deletions
8
main.ts
8
main.ts
|
|
@ -63,7 +63,7 @@ const DEFAULT_SETTINGS: HeadingPluginSettings = {
|
|||
export default class HeadingPlugin extends Plugin {
|
||||
settings: HeadingPluginSettings;
|
||||
|
||||
private outlineIdList: string[] = [];
|
||||
private outlineIdSet: Set<string> = new Set();
|
||||
private outlineComponents: OutlineChildComponent[] = [];
|
||||
|
||||
async onload() {
|
||||
|
|
@ -285,7 +285,7 @@ export default class HeadingPlugin extends Plugin {
|
|||
private unloadOutlineComponents() {
|
||||
this.outlineComponents.forEach((child) => child.detach());
|
||||
this.outlineComponents = [];
|
||||
this.outlineIdList = [];
|
||||
this.outlineIdSet.clear();
|
||||
}
|
||||
|
||||
private craeteHeadingViewPlugin(
|
||||
|
|
@ -321,7 +321,7 @@ export default class HeadingPlugin extends Plugin {
|
|||
const leaves = this.app.workspace.getLeavesOfType("outline");
|
||||
leaves.forEach((leaf: ObsidianWorkspaceLeaf) => {
|
||||
const leafId = leaf.id;
|
||||
if (!leafId || this.outlineIdList.includes(leafId)) {
|
||||
if (!leafId || this.outlineIdSet.has(leafId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -333,7 +333,7 @@ export default class HeadingPlugin extends Plugin {
|
|||
return;
|
||||
}
|
||||
|
||||
this.outlineIdList.push(leafId);
|
||||
this.outlineIdSet.add(leafId);
|
||||
const oc = new OutlineChildComponent(leafId, view, viewContent, () => {
|
||||
const headingElements =
|
||||
viewContent.querySelectorAll<HTMLElement>(".tree-item");
|
||||
|
|
|
|||
Loading…
Reference in a new issue