Readonly
actionArray of versions representing the entire saved version history for this draft.
Date the draft was created. This property is generally maintained by Drafts automatically and is it not recommended it be set directly unless needed to maintain information from an external source when importing.
Date the draft was last modified. This property is generally maintained by Drafts automatically and is it not recommended it be set directly unless needed to maintain information from an external source when importing.
Static
recentReadonly
linkedConvenience method to return the linked items in the content, as located by the syntax definitions' linkDefinitions
. In Markdown syntaxes, these map to [[wiki-style]]
cross-links.
Numeric latitude where the draft was created. This value will be 0
if no location information was available.
Numeric longitude where the draft was created. This value will be 0
if no location information was available.
Numeric longitude where the draft was last modified. This value will be 0
if no location information was available.
Numeric longitude where the draft was last modified. This value will be 0
if no location information was available.
Array of navigation markers in the content. Navigation markers are defined by the syntax definition assigned to the draft, and are used in the Navigation feature.
The next navigation marker in the content, relative to the character location. This is a convenience method to assist in navigating by marker.
The previous navigation marker in the content, relative to the character location. This is a convenience method to assist in navigating by marker.
The full text content.
Readonly
displayGenerally, the first line of the draft, but cleaned up as it would be displayed in the draft list in the user interface, removing Markdown header characters, etc.
Is the draft current in the archive. If false
, the draft is in the inbox.
Current flagged status.
Is the draft currently in the trash.
Readonly
linesThe lines of content separated into an array on \n
line feeds. This is a convenience method an equivalent to content.split('\n');
Readonly
permalinkURL which can be used to open the draft. URLs are cross-platform, but specific to an individual user's drafts datastore.
Readonly
selectionThe length of the last text selection.
Readonly
selectionThe index location in the string of the beginning of the last text selection.
The syntax definition used when displaying this draft in the editor.
Readonly
titleThe first line.
Readonly
urlsConvenience method to scan the draft content for valid URLs, and return all found URLs as an array. This will return valid full URL strings - both for http(s)
and custom URLs found in the text.
Readonly
uuidUnique identifier.
Insert text into the draft's content
at the line indicated. This is a convenience function.
The text to in
The index of the line number at which to insert the text. Line numbers are zero-based, so 0
is the first line. Drafts will range-check the line.
Static
createStatic
findStatic
queryPerform a search for drafts and return an array of matching draft objects.
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. Support query string structured details available in User Guide.
Filter by one of the allowed values
Results will only include drafts with all the listed tags assigned.
Results will omit drafts with any of these tags assigned.
If true
, sort descending. Defaults to false
.
If true
, sort flagged drafts to beginning. Defaults to false
.
Static
querySearch for drafts containing the title string in the first line of their content. This mimics the logic used by the /open?title=Title
URL scheme to locate drafts by title when triggering embedded cross-links.
Readonly
completedArray of completed task lines found in the content of the draft, based on active syntax definition for the draft. See Task documentation for usage details.
Readonly
incompleteArray of incomplete task lines found in the content of the draft, based on active syntax definition for the draft. See Task documentation for usage details.
Readonly
tasksArray of task lines found in the content of the draft, based on active syntax definition for the draft. See Task documentation for usage details. Includes all found tasks, regardless of status.
Update the text representing the task to a next valid state as defined by syntax. If this task has only two states, this is effectively a toggle, if more than two states exist, the next state will be set, including cycling around to the initial state. Note that the task object is not updated to reflect changes made.
boolean If true
, advance was successful
Update the text representing the task to a completed state as defined by syntax. Note that the task object is not updated to reflect changes made.
boolean If true
, completion was successful
Update the text representing the task to a initial state as defined by syntax. Note that the task object is not updated to reflect changes made.
boolean If true
, reset was successful
Runs the template string through the Mustache template engine to evaluate tags. Allows additional values and partials to be provided to the context.
Template string
An object containing additional values you wish to make available in the Mustache context.
An object containing string keys and values which will contain additional templates you which to make available for use as partials and layouts.
Runs the template string through the Drafts Template engine to evaluate tags.
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. These values are also available in Mustache templates, but as {{mytag}}
.
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
Querying drafts