Action
Add to Obsidian
UPDATES
12 months ago
Changed Log Level from Errors to All so successful actions are logged as well as errors; left Notifications for only Errors and the draft disappears since it’s moved to Trash.
Add the current draft to an Obsidian vault as a new Markdown file.
The file name is a “safe version” of the note title based on the first line of the draft; it removes the heading tag (#), path separators (/), and all ASCII control characters (like colon or question mark) that are not allowed in Obsidian file names (\/:*?<>|#).
It automatically adds a tag “note/draft” to identify draft notes so dataview queries can process new draft notes added to Obsidian. You can also add any other tags in your draft.
The File action writes directly to a file in a specific Drafts bookmark folder named “Add”. For example, I associate this bookmark with the inbox folder (“+”) in my Obsidian vault (“Ideaverse”), although you use any folder you want, if you want to separate these drafts from other new notes. When using iCloud sync, you would select the same iCloud folder for both macOS and iOS.
The action group bar uses the label “Add” along with an icon, which I assigned as a white plus on blue circle. For Markdown convenience, it also has buttons for header, list, bold, italic, and link.
You perform an action by tapping the action group bar button, or you can use the command palette (Shift-Cmd+P) or toolbar icon (plus in search).
I also assigned hotkeys to run the Add action (⇧⌘O), and some Markdown formatting: header (⌘H), bold (⌘B), and italic (⌘I)
After successful completion, the draft is moved to your Drafts Trash, where it gets deleted automatically after 30 days. Only error completions (in red) are reflected in brief notifications and action logs, when the action was not successful.
The most common reasons you might get an error are a blank title (first line) or a duplicate file name. Just ensure you have text on the first line as your title, and add a suffix if necessary to make a unique file name, and then Add again.
Steps
-
file
fileNameTemplate [[safe_title]].md
folderTemplate template --- up: "" created: [[date]] tags: note/draft, [[tags]] --- [[draft]]
local true
writeType create
Options
-
After Success Trash Notification Error Log Level Info