mirror of
https://github.com/unarray/file-tree-generator.git
synced 2026-07-22 08:40:29 +00:00
Add new methods to plugin
- getEditor - addRibbonIconObject
This commit is contained in:
parent
ec08046d10
commit
c866cf06de
1 changed files with 18 additions and 3 deletions
|
|
@ -1,7 +1,9 @@
|
|||
import { SettingsTab } from "./SettingsTab";
|
||||
import { GenerateTree } from "#/commands";
|
||||
import type { App, Command, PluginManifest } from "obsidian";
|
||||
import { GenerateTree as GenerateTreeCommand } from "#/commands/generate-tree";
|
||||
import type { App, Command, Editor, PluginManifest } from "obsidian";
|
||||
import { Plugin } from "obsidian";
|
||||
import type { RibbonIcon } from "#/ribbon-icons";
|
||||
import { GenerateTree as GenerateTreeIcon } from "#/ribbon-icons/generate-tree";
|
||||
|
||||
export default class FileTreeGenerator extends Plugin {
|
||||
|
||||
|
|
@ -23,9 +25,12 @@ export default class FileTreeGenerator extends Plugin {
|
|||
|
||||
onload = async(): Promise<void> => {
|
||||
this.addCommands(
|
||||
new GenerateTree()
|
||||
new GenerateTreeCommand()
|
||||
);
|
||||
|
||||
this.addRibbonIconObject(new GenerateTreeIcon());
|
||||
|
||||
|
||||
const settingsTab = new SettingsTab(this);
|
||||
|
||||
await settingsTab.loadSettings();
|
||||
|
|
@ -38,4 +43,14 @@ export default class FileTreeGenerator extends Plugin {
|
|||
}
|
||||
};
|
||||
|
||||
public addRibbonIconObject = (ribbonIcon: RibbonIcon): HTMLElement => {
|
||||
return this.addRibbonIcon(ribbonIcon.icon, ribbonIcon.title, ribbonIcon.execute);
|
||||
};
|
||||
|
||||
public getEditor = (): Editor | null => {
|
||||
const editor = this.app.workspace.activeEditor?.editor;
|
||||
|
||||
return editor ? editor : null;
|
||||
};
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue