mirror of
https://github.com/unarray/file-tree-generator.git
synced 2026-07-22 08:40:29 +00:00
Use this new API documention
- Removing all ts-ignore in relation with this API doc - Use this new API doc
This commit is contained in:
parent
f85c0415ea
commit
7b8377584f
3 changed files with 14 additions and 16 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { SettingsTab } from "./SettingsTab";
|
||||
import { GenerateTree as GenerateTreeCommand } from "#/commands/generate-tree";
|
||||
import type { App, Command, Editor, PluginManifest } from "obsidian";
|
||||
import type { App, Command, MarkdownFileInfo, PluginManifest } from "obsidian";
|
||||
import { Plugin } from "obsidian";
|
||||
import type { RibbonIcon } from "#/ribbon-icons";
|
||||
import { GenerateTree as GenerateTreeIcon } from "#/ribbon-icons/generate-tree";
|
||||
|
|
@ -47,10 +47,10 @@ export default class FileTreeGenerator extends Plugin {
|
|||
return this.addRibbonIcon(ribbonIcon.icon, ribbonIcon.title, ribbonIcon.execute);
|
||||
};
|
||||
|
||||
public getEditor = (): Editor | null => {
|
||||
const editor = this.app.workspace.activeEditor?.editor;
|
||||
public getActiveEditor = (): MarkdownFileInfo | null => {
|
||||
const activeEditor = this.app.workspace.activeEditor;
|
||||
|
||||
return editor ? editor : null;
|
||||
return activeEditor ? activeEditor : null;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -48,13 +48,7 @@ export class GenerateTree extends Modal {
|
|||
(button) => button
|
||||
.setTooltip("Open plugin settings")
|
||||
.onClick(() => {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
||||
this.app.setting.open();
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
||||
this.app.setting.openTabById("file-tree-generator");
|
||||
})
|
||||
)
|
||||
|
|
|
|||
|
|
@ -10,23 +10,27 @@ export class GenerateTree implements RibbonIcon {
|
|||
public readonly title: RibbonIconTitle = "Generate file tree";
|
||||
|
||||
public execute = (): void => {
|
||||
const editor = FileTreeGenerator.getInstance().getEditor();
|
||||
const activeEditor = FileTreeGenerator.getInstance().getActiveEditor();
|
||||
|
||||
if (!editor) {
|
||||
if (!activeEditor) {
|
||||
new Notice("❌ Can only be used during editing");
|
||||
return;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
||||
const viewType = FileTreeGenerator.getInstance().app.workspace.activeEditor.currentMode.type as string;
|
||||
const viewType = activeEditor.currentMode.type;
|
||||
|
||||
if (viewType !== "source") {
|
||||
new Notice("❌ Can only be used during editing");
|
||||
return;
|
||||
}
|
||||
|
||||
const editor = activeEditor.editor;
|
||||
|
||||
if (!editor) {
|
||||
new Notice("❌ Can only be used during editing");
|
||||
return;
|
||||
}
|
||||
|
||||
new GenerateTreeModal(FileTreeGenerator.getInstance().app, editor).open();
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue