Action

newObsidianNote

Posted by sorashima, Last update over 3 years ago

UPDATES

over 3 years ago

Changed to use “encodeURIComponent”.

Send a draft to Obsidian to create a new note.

This action saves the Vault name in Credential. So you don’t have to be a Drafts pro user to change the destination vault.

The first line is the name of the note.
The remaining lines are the content of the note.

“Obsidian URI” is used, so (mobile) Obsidian must be installed on the same device.

Steps

  • script

    const cd = Credential.create("Obsidian", "Obsidian")
    cd.addTextField("Vault", "Vault name")
    cd.authorize()
    
    const u = `obsidian://new?vault=${encodeURIComponent(cd.getValue("Vault"))}&name=${encodeURIComponent(draft.processTemplate("[[display_title]]"))}&content=${encodeURIComponent(draft.processTemplate("[[body]]"))}`
    app.openURL(u)

Options

  • After Success Archive
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.