I have a very simple action, lightly modified from the TaskPaper group by @drdrang, to (1) load a taskpaper file from dropbox, (2) add a ‘taskpaper’ tag to the file, (3) set a ‘taskpaper’ workspace and (4) set the syntax highlighting for the draft to TaskPaper.
If I run the action from Drafts itself, everything works as expected in iOS and macOS. But I want to call this action from the iOS Drafts widget, and if I run the action from there: (1) the tag is not applied, and (2) the syntax highlighting doesn’t change. Any ideas?
Here’s the code:
// Get TaskPaper file for current month and set the draft to it. let workspace = Workspace.find("TaskPaper"); app.applyWorkspace(workspace); // Dropbox folder where task file is. var path = '/work/SUBFOLDER/'; // Assemble filename from today's date. var today = new Date(); var yr = today.getFullYear().toString(); var filename = path + 'FILENAME.' + yr + '.taskpaper'; // Get the file from Dropbox and set draft to it. var db = Dropbox.create(); var content = db.read(filename); editor.setText(content); let syntax = Syntax.find("builtIn", "TaskPaper"); draft.syntax = syntax; draft.addTag("taskpaper") draft.update();