fix typescript
This commit is contained in:
1 parent
7022dadd83
commit
358ddca2f0
8 files changed
+386
-452
No files matched your search
+9
-5
@@ -1,4 +1,4 @@
|
||||
import { App, Editor, MarkdownView, Notice } from 'obsidian'
|
||||
import { App, Editor, MarkdownFileInfo, MarkdownView, Notice } from 'obsidian'
|
||||
import BindThemPlugin from './main'
|
||||
|
||||
/**
|
||||
@@ -16,7 +16,7 @@ export class FileHelper {
|
||||
/**
|
||||
* Duplicate the current file
|
||||
*/
|
||||
public async duplicateFile(editor: Editor, view: MarkdownView): Promise<void> {
|
||||
public async duplicateFile(editor: Editor, view: MarkdownView | MarkdownFileInfo): Promise<void> {
|
||||
const activeFile = this.app.workspace.getActiveFile()
|
||||
|
||||
if (activeFile === null) {
|
||||
@@ -30,7 +30,9 @@ export class FileHelper {
|
||||
|
||||
try {
|
||||
const newFile = await this.app.vault.copy(activeFile, newFilePath)
|
||||
await view.leaf.openFile(newFile)
|
||||
if (view instanceof MarkdownView) {
|
||||
await view.leaf.openFile(newFile)
|
||||
}
|
||||
|
||||
editor.setSelections(selections)
|
||||
} catch (e) {
|
||||
@@ -41,7 +43,7 @@ export class FileHelper {
|
||||
/**
|
||||
* Create a new file in the same directory as the current file
|
||||
*/
|
||||
public async newAdjacentFile(editor: Editor, view: MarkdownView): Promise<void> {
|
||||
public async newAdjacentFile(editor: Editor, view: MarkdownView | MarkdownFileInfo): Promise<void> {
|
||||
const activeFile = this.app.workspace.getActiveFile()
|
||||
|
||||
if (activeFile === null) {
|
||||
@@ -53,7 +55,9 @@ export class FileHelper {
|
||||
|
||||
try {
|
||||
const newFile = await this.app.vault.create(newFilePath, '')
|
||||
await view.leaf.openFile(newFile)
|
||||
if (view instanceof MarkdownView) {
|
||||
await view.leaf.openFile(newFile)
|
||||
}
|
||||
} catch (e) {
|
||||
new Notice(String(e))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user