Fixed note creation
This commit is contained in:
16
src/notes.ts
16
src/notes.ts
@@ -24,3 +24,19 @@ export async function openNote(
|
||||
to: { line: pos.line + 10, ch: 0 },
|
||||
})
|
||||
}
|
||||
|
||||
export async function createNote(name: string): Promise<void> {
|
||||
try {
|
||||
const file = await app.vault.create(name + '.md', '# ' + name + '\n')
|
||||
await app.workspace.openLinkText(file.path, '')
|
||||
const view = app.workspace.getActiveViewOfType(MarkdownView)
|
||||
if (!view) {
|
||||
throw new Error('OmniSearch - No active MarkdownView')
|
||||
}
|
||||
const pos = view.editor.offsetToPos(name.length + 5)
|
||||
pos.ch = 0
|
||||
}
|
||||
catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user