Edit view-manager: add insertAtTitle

This commit is contained in:
Hyeonseo Nam 2023-03-20 03:32:41 +09:00
parent a8cf928692
commit 8a8bd49aa1

View file

@ -83,6 +83,19 @@ export class ViewManager {
}
}
async insertAtTitle(value: string, overwrite = false): Promise<void> {
const file = this.app.workspace.getActiveFile();
let newName = file.basename;
if (overwrite) {
newName = `${value}`;
} else {
newName = `${newName} ${value}`;
}
// @ts-ignore
const newPath = file.getNewPathAfterRename(newName)
await this.app.fileManager.renameFile(file, newPath);
}
async insertAtCursor(value: string, overwrite = false): Promise<void> {
const activeView = this.app.workspace.getActiveViewOfType(MarkdownView);