Developer
URL Schemes
DraftPad supports some URL schemes which can be used by other apps or from web pages to control DraftPad remotely.
Open DraftPad
To open DraftPad from other apps or web pages, simply invoke this.
draftpad://
Inserting Text
You can insert some text to DraftPad from outside by using "insert" method. There are six parameters, and those can be used together by joining with "&" character.
before
To insert your escapedString BEFORE existing text, do this:
draftpad:///insert?before=escaptedString
after
To insert your escapedString AFTER existing text, do this:
draftpad:///insert?after=escapedString
text
To replace existing text with your escapedString, do this:
draftpad:///insert?text=escapedString
Caution: This will remove the existing text on DraftPad with NO alert to the user. It still can be Undo'ed, but you should show an alert to the user by yourself before executing this method to tell what will be happend, and also you should give a chance to the user to cancel it.
caret (for v1.5.4+)
To insert your escapedString to the current cursor position, do this:
draftpad:///insert?caret=escapedString
The "caret" parameter cannot be used with the "text" parameter. If you have the both, the "caret" parameter will be ignored.
If user's text view currently has no cursor position (this means that the user has tapped "Done" button and has stopped editing), your text will be inserted at the end of the existing text.
If user's text view has text selection, the selected text will be replaced with your inserting text.
loc (for v1.5.3+)
You can specify the location of cursor which is placed right after text inserting, by using "loc" parameter (number for the value).
If you want the cursor to be placed at the very beginning of the text view, do like this:
draftpad:///insert?text=escapedString&loc=0
To place the cursor between the first character and the second character, do like this:
draftpad:///insert?text=escapedString&loc=1
len (for v1.5.3+)
Also, you can specify the length of text selection by using "len" parameter (number for the value). This must be used with "loc."
If you want to select the second character and the third character, do like this:
draftpad:///insert?text=escapedString&loc=1&len=2
Pasting Text from Pasteboard (for v1.3+)
You can paste some text to DraftPad from the pasteboard by using “paste” method. There are four parameters such as "location," "prefix," "suffix," and "pboard." Those can be used together by joining with “&” character.
location
You can specify the location the text will be inserted to by using “location” parameter. This accepts one of the three numbers, “0,” “1,” "2," or “3” as its value.
0 | Replace existing text. |
1 | Paste before existing text. |
2 | Paste after existing text. (default) |
3 (for v1.5.4+) | Paste at the current cursor postion. If the text view has text selection, the selected text will be replaced with your pasting text. If the text view has no cursor position, this works as 2. |
For example, do this to paste before existing text:
draftpad:///paste?location=1
prefix
You can add some specific text as the prefix of the pasting string. The value must be escaped of course. For example, when the string "friend" is in the pasteboard, the next URL makes the new string "Hello my friend" for pasting.
draftpad:///paste?prefix=Hello%20my%20
suffix
Just like the "prefix," this adds some specific text as the suffix to the pasting string. The value must be escaped of course. For example, when the string "friend" is in the pasteboard, the next URL makes the new string "Hello my friend, Lucy." for pasting.
draftpad:///paste?prefix=Hello%20my%20&suffix=%2c%20Lucy%2e
pboard
You can specify the name of the pasteboard which the text will be pasted from. This is needed if the text you want to paste has been copied into an named pasteboard by another app for some purpose.
For example, do this to paste from the pasteboard named "escapedPasteboardName":
draftpad:///paste?pboard=escapedPasteboardName
When you don't use this parameter, DraftPad will try pasting text from the general pasteboard. Usually the general pasteboard is where the copied text stored in.
loc (for v1.5.3+)
You can specify the location of cursor which is placed right after text pasting, by using "loc" parameter (number for the value).
If you want the cursor to be placed at the very beginning of the text view, do like this:
draftpad:///paste?loc=0
To place the cursor between the first character and the second character, do like this:
draftpad:///paste?loc=1
len (for v1.5.3+)
Also, you can specify the length of text selection by using "len" parameter (number for the value). This must be used with "loc."
If you want to select the second character and the third character, do like this:
draftpad:///paste?loc=1&len=2
Importing Assist
You can make DraftPad import an Assist from outside by using "assist" method. There are three parameters such as "title," url," and "option."
draftpad:///assist?title=escapedString&url=escapedAssistURLString&option=0
See Assist Help to learn the format of Assist URL.
"option" parameter accepts one of the seven numbers, from "0" to "6."
0 | None (DraftPad does nothing) |
1 | Copy Current Line or Selection |
2 | Copy All Text |
3 | Cut Current Line or Selection |
4 | Cut All |
5 | Clear Current Line or Selection |
6 | Clear All Text |