From 8a8bd49aa182682ec629df15fff667e3bc0800a0 Mon Sep 17 00:00:00 2001 From: Hyeonseo Nam Date: Mon, 20 Mar 2023 03:32:41 +0900 Subject: [PATCH] Edit view-manager: add insertAtTitle --- src/view-manager.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/view-manager.ts b/src/view-manager.ts index a634b7c..1da3f86 100644 --- a/src/view-manager.ts +++ b/src/view-manager.ts @@ -83,6 +83,19 @@ export class ViewManager { } } + async insertAtTitle(value: string, overwrite = false): Promise { + 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 { const activeView = this.app.workspace.getActiveViewOfType(MarkdownView);