Attribution
This action was inspired by Add to list plus by @dchar. Add to List plus is based on Add to List by @agiletortoise.
In addition to the inspiration, the Add to List plus JavaScript code that presents a dialog to select an existing list, or creates a new one, is used in this action. The viewListAfterSuccess code has similarly been copied.
The action dialog is created and evaluated using MGCheckListPrompt, by @mattgemmell.
Help regarding the Preview (v1.1) was provided by @sylumer, @agiletortoise, and @FlohGro. For more information: End an action, yet still honor the AFTER SUCCESS configuration? - Actions - Help & Questions - Drafts Community
@sylumer suggested that this action be callable from another action. He also provided the necessary guidance.
Overview
This action can be used to add lines from a source draft to target list, i.e., another draft (formatted using markdown). The target list can be: 1) hard-coded, 2) selected from all current lists, or 3) created by this action.
Target lists are drafts that are archived and tagged with a configured value (by default the tag is list). Source drafts can be anywhere in the Drafts application.
Features
-
All lines from the source draft are added individually to the target list.
-
A time prefix (
YYYY-MM-DD HH:MM
orHH:MM
) can be included with each added line. -
Added lines can be appended or prepended.
-
A horizontal rule (-–) can be added before each group of lines added to the target draft.
-
A date line (
YYYY-MM-DD, DayOfWeek
) can be included with each group of lines added to the target draft. If this option is selected, the added date and lines are enclosed by horizontal rules. (This action includes logic to prevent horizontal rules on two consecutive lines.) -
After the target list is updated, it can be displayed in the Drafts editor and/or previewed (i.e., the markdown is rendered). Note: To preview a target list without changing it, run this action with an empty draft in the Drafts editor.
-
Blank lines above and below text in the source draft can be used or ignored. Similarly, interleaving blank lines can be used or ignored.
-
Several of the options mentioned above can be changed at runtime using an action dialog.
-
The default options can be superseded by using an action that calls this action via the Include Action step. The override options in the caller are the same as the options within this action except with an added leading underscore. For example _listTag can be used to override the option listTag. For an example caller, see: Add Lines to List (caller) | Drafts Directory.
Tested With
-
Drafts (iOS), Version 42.2.1 (415) // iOS Version 17.2.1/iPhone 15 Pro Max
-
Drafts (macOS), version 14.6.9 (14D100, Apple Silicon, sandboxed) // Sonoma 14.2.1 (23C71)/MacBookPro18,2
Version History
1.0 - initial version
1.1
a. If the source draft is empty no content is added to the target list but it can still be loaded and/or previewed.
b. The method used to to preview the target list has been changed such that the action ends nornally; thus the action After Success configuration is honored.
2.0
a. The default options can now be superseded by using an action that calls this action via the Include Action step. The override options in the caller are the same as the options within this action except with an added leading underscore. For example _listTag can be used to override the option listTag. For an example caller, see: Add Lines to List (caller) | Drafts Directory.
b. The list dialog prompts and logic were refined.
c. Changed option excludeBlankLines to excludeInnerBlankLines.
d. The icon color was changed from green to red. By default, the icons of calling actions are green.
e. Bug fix: When addCurrentDateToEachBlock = true
and prependLines = false
, the closing horizontal rule was prepended. It is now appended.
3.0
Changed option addCurrentDateToEachLine to addCurrentTimeToEachLine. If true
, a YYYY-MM-DD HH:MM:
or a HH:MM:
prefix is added to each line before it is added to the list. If option addCurrentDateToEachBlock = true
, it will be the latter, HH:MM:
.