Reuse of Drafts scripting in Obsidian plugin dev?

A message for the Obsidian nerds out there–I have a limited understanding of javascript, but with Greg’s excellent documentation and help around this forum, I have managed to create some useful actions for myself. One of my uses of Drafts has been for light project management. I’d like to move most of that over to Obsidian to take advantage of some of the features there. One key action from Drafts I’d like to recreate does this:

  1. Search through specific drafts for every line tagged “#week
  2. send those lines (and their notes on subsequent lines) to a JSON file, structured by project (which comes from the Draft title) and week of the year.

How feasible might it be in Obsidian to recreate this? I need the JSON file because it feeds my evening review system in Drafts, which I’d like to keep.

Hi @derekvan, it’s definitely possible, but you’ll likely need to rework the code to work with the Obsidian APIs. An initial likely difference is dealing with the current Draft. Drafts stores everything inside of a database where as Obsidian works with files. The code you use to pull the contents from the draft or editor won’t be compatible in Obsidian. But the fundamental elements of what you’re doing should be feasible.

1 Like

Ok, well, it turns out the solution for me here was just to continue using drafts! That is, I use file bookmarks to bring in the text files from obsidian, then process the text using my existing Drafts scripts.

Other drafts scripts I created can largely be recreated using the Templater plugin JavaScript capabilities.