Options
All
  • Public
  • Public/Protected
  • All
Menu

Draft

The Draft object represents a single draft. When an action is run, the current draft is available as the global variable draft. Scripts can also create new drafts, access and set values, and update the draft to persist changes.

Example: Creating a draft

// create a new draft, assign content and save it
let d = Draft.create();
d.content = "My new draft";
d.update();

Example: Querying drafts

// query a list of drafts in the inbox with the tag "blue"
let drafts = Draft.query("", "inbox", ["blue"])

Hierarchy

  • Draft

Index

Properties

content

content: string

The full text content of the draft.

createdAt

createdAt: Date

createdLatitude

createdLatitude: number

createdLongitude

createdLongitude: number

isArchived

isArchived: boolean

Is the draft current in the archive. If false, the draft is in the inbox.

isFlagged

isFlagged: boolean

Current flagged status.

isTrashed

isTrashed: boolean

Is the draft currently in the trash.

languageGrammar

languageGrammar: "Plain Text" | "Markdown" | "Taskpaper" | "JavaScript" | "Simple List" | "MultiMarkdown" | "GitHub Markdown"

The preferred language grammar (syntax) to use for the draft. Can be any valid installed language grammar.

modifiedAt

modifiedAt: Date

modifiedLatitude

modifiedLatitude: number

modifiedLongitude

modifiedLongitude: number

permalink

permalink: string

URL which can be used to open the draft.

selectionLength

selectionLength: number

The length of the last text selection.

selectionStart

selectionStart: number

The index location in the string of the beginning of the last text selection.

tags

tags: string[]

Array of string tag names assigned to the draft.

title

title: string

The title. This is generally the first line of the draft.

uuid

uuid: string

Unique identifier for the draft.

Methods

addTag

  • addTag(tag: string): void
  • Assign a tag

    Parameters

    • tag: string

    Returns void

getTemplateTag

  • getTemplateTag(tagName: string): string
  • Get the current value of a custom template tag.

    Parameters

    • tagName: string

    Returns string

hasTag

  • hasTag(tag: string): boolean
  • Check whether a tag is currently assigned to the draft.

    Parameters

    • tag: string

    Returns boolean

processTemplate

  • processTemplate(template: string): string
  • Runs the template string through the template engine to evaluate tags (like <a href="draft.html#title">title</a>, <a href="gmailmessage.html#body">body</a>).

    Parameters

    • template: string

    Returns string

removeTag

  • removeTag(tag: string): void
  • Remove a tag if it is assigned to the draft.

    Parameters

    • tag: string

    Returns void

setTemplateTag

  • setTemplateTag(tagName: string, value: string): void
  • Set a custom template tag value for use in templates. For example, calling setTemplateTag("mytag", "mytext") will create a tag [[mytag]], which subsequent action steps in the same action can use in their templates.

    Parameters

    • tagName: string
    • value: string

    Returns void

update

  • update(): void
  • Save changes made to the draft to the database. This must be called to save changes made during an action’s execution.

    Returns void

Static create

  • Create a new draft object. This is an in-memory object only, unless "update()" is called to save the draft.

    Returns Draft

Static find

  • find(uuid: string): Draft
  • Find an existing draft based on UUID.

    Parameters

    • uuid: string

    Returns Draft

Static query

  • query(queryString: string, filter: "inbox" | "archive" | "flagged" | "trash" | "all", tags: string[], omitTags: string[], sort: "created" | "modified" | "accessed", sortDescending: boolean, sortFlaggedToTop: boolean): Draft[]
  • Perform a search for drafts and return an array of matching draft objects.

    Parameters

    • queryString: string

      Search string, as you would type in the search box in the draft list. Will find only drafts with a matching string in their contents. Use empty string ("") not to filter.

    • filter: "inbox" | "archive" | "flagged" | "trash" | "all"

      Filter by one of the allowed values

    • tags: string[]

      Results will only include drafts with one or more of these tags assigned.

    • omitTags: string[]

      Results will omit drafts with any of these tags assigned.

    • sort: "created" | "modified" | "accessed"
    • sortDescending: boolean

      If true, sort descending. Defaults to false.

    • sortFlaggedToTop: boolean

      If true, sort flagged drafts to beginning. Defaults to false.

    Returns Draft[]

Static recentTags

  • recentTags(): string[]
  • Return array of recently used tags. Helpful for building prompts to select tags.

    Returns string[]

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc