Drafts 21 Released - Better undo and advanced HTML Previews

Drafts 21 has been released:

Details below. For a complete history of updates, visit:

1 Like

Drafts 21 (iOS) Release Notes:

What’s New

  • Undo for most commands in the draft list. Most actions and operations on the draft list are now undoable. After moving a draft to the trash, moving between inbox and archive, flagging, add-remove tags, etc., you can undo that operation. To access undo: Shake to Undo, use Command-Z on an external keyboard, or three-finger swipes left-right to undo/redo (iOS 13 only).
  • Advanced HTML Previews HTML Previews (via action step or script) now provide access to the JavaScript functions that can be called from scripts embedded in the preview document to pass values out for use in Drafts script steps, or to control flow (Cancel/Continue). Using these functions, you can build user-interfaces for actions using HTML forms, and gather and submit data or user selections for use in other script steps. Available functions:
    • Drafts.send(key, value): Send data out to the action context. These values will be available to subsequent scripts using the context.previewValues object. So, if you call Drafts.send("mydata", {"a": 1, "b": true}) in your preview, you can later retrieve those values in a script step using context.previewValues["mydata"].
    • Drafts.continue() and Drafts.cancel(): Equivalent to pressing the continue/cancel buttons in the preview UI. Allows automatic continuation of script with a form submission, for example, in the HTML document.
    • HTML Previews now offer an additional “Hide Interface” option that removes toolbars. Used only when the script features above are used to control flow.
    • More details in Advanced HTML Previews article
    • Example Actions:
      • HTML Preview Form Example: Bare bones example of how to display an HTML form in a preview and use values from it in a script.
      • HTML > Markdown: Uses the Turndown JavaScript library - which depends on the DOM and browser - within a preview to convert HTML content to Markdown.
  • Scripting Additions:
    • app.currentWorkspace property returns a Workspace object configured as the current drafts list is configured. Note this is not the same as a named workspace object, even if you have recently applied a workspace to the list. Calling update() on this retrieved copy will create a new workspace. It is recommended this be used primarily as a read-only version of the workspace to use to pass to another function, such as app.selectDraft(). Docs
    • app.isPro boolean to determine if the app is pro unlocked. Docs
    • app.selectDraft() can now optionally take a workspace parameter to set the initial search/filtering in the select window. Docs
    • draft.append(text, separator) and draft.prepend(text, separator) convenience functions on draft object. separator is optional and defaults to a line feed. Docs

Other Changes and Updates

  • Change: Refactor some of the code for the FileManager script object. The writeString and writeJSON methods no longer replace files, just update contents so the creation date is maintained and it interferes less with other apps using the same folders.
  • New: “Insert Text” action steps should register an undo point to allow that insertion to be undone atomically.
  • Fix: Clicking on a non-HTTP link in an HTML Preview should close the preview as if the cancel button were pressed.
  • Change: Improve keyboard navigation and selection in Drafts select view (used in Share extension and app.selectDraft()).
  • Fix: Calls to editor.setSelectedRange could inadvertently scroll to the end of the draft.
  • New: Context menu on drafts in the trash can.

Drafts 21 (macOS) Release Notes:

What’s New

  • Undo for most commands in the draft list. Most actions and operations on the draft list are now undoable. After moving a draft to the trash, moving between inbox and archive, flagging, add-remove tags, etc., you can undo that operation. To access undo: Edit > Undo in main menu, or use Command-Z the keyboard.
  • Advanced HTML Previews HTML Previews (via action step or script) now provide access to the JavaScript functions that can be called from scripts embedded in the preview document to pass values out for use in Drafts script steps, or to control flow (Cancel/Continue). Using these functions, you can build user-interfaces for actions using HTML forms, and gather and submit data or user selections for use in other script steps. Available functions:
    • Drafts.send(key, value): Send data out to the action context. These values will be available to subsequent scripts using the context.previewValues object. So, if you call Drafts.send("mydata", {"a": 1, "b": true}) in your preview, you can later retrieve those values in a script step using context.previewValues["mydata"].
    • Drafts.continue() and Drafts.cancel(): Equivalent to pressing the continue/cancel buttons in the preview UI. Allows automatic continuation of script with a form submission, for example, in the HTML document.
    • HTML Previews now offer an additional “Hide Interface” option that removes toolbars. Used only when the script features above are used to control flow.
    • More details in Advanced HTML Previews article
    • Example Actions:
      • HTML Preview Form Example: Bare bones example of how to display an HTML form in a preview and use values from it in a script.
      • HTML > Markdown: Uses the Turndown JavaScript library - which depends on the DOM and browser - within a preview to convert HTML content to Markdown.
  • Scripting Additions:
    • app.currentWorkspace property returns a Workspace object configured as the current drafts list is configured. Note this is not the same as a named workspace object, even if you have recently applied a workspace to the list. Calling update() on this retrieved copy will create a new workspace. It is recommended this be used primarily as a read-only version of the workspace to use to pass to another function, such as app.selectDraft(). Docs
    • app.isPro boolean to determine if the app is pro unlocked. Docs
    • app.selectDraft() can now optionally take a workspace parameter to set the initial search/filtering in the select window. Docs
    • draft.append(text, separator) and draft.prepend(text, separator) convenience functions on draft object. separator is optional and defaults to a line feed. Docs

Other Changes and Updates

  • Change: Refactor some of the code for the FileManager script object. The writeString and writeJSON methods no longer replace files, just update contents so the creation date is maintained and it interferes less with other apps using the same folders.
  • New: “Insert Text” action steps should register an undo point to allow that insertion to be undone atomically.
  • Fix: Clicking on a non-HTTP link in an HTML Preview should close the preview as if the cancel button were pressed.
  • Fix: app.currentThemeMode not always correct.
  • Change: Change “Move to Trash” keyboard shortcut to avoid conflict with delete to beginning of line text shortcut.
  • Change: Improve keyboard navigation and selection in Drafts select window (used in Capture window and app.selectDraft()).
  • Fix: Web capture template not saving changes properly.
  • Fix: If focus mode was disabled in secondary windows, the new draft creation timeout would fire too quickly in those windows when returning to the app.