In this lesson, I explain how to export notes crated in Drafts to Tinderbox. I demonstrate the process and explain how to set up the export action in Drafts. I also explain how to edit the attributes statements in the Apple Script within Drafts to suit your own purposes. For example, I show how you can apply your own prototypes to the exported notes, or change the mapping of the Drafts URI to whatever URL attribute you want. Finally, I demonstrate how note writing in markdown in Drafts works perfectly in Tinderbox.
Note for Tinderbox 8 Users
*Note: If you are still using Tinderbox 8 this process will work, however, you’ll want to change the app reference that the Apple Script in Drafts is calling. You’ll want to edit the tell application "Tinderbox 9" reference, change the 9 to an 8.
As for point 2, it is 8.9+, this will work with older versions of Tinderbox. I should have noted in the video that if you’re on Tinderbox 8 you’ll wan to change the app name that the Apple Script is calling from 9 to 8.
I saw that you created the notes in the frontmost window in TBX - I paste the notes into a dedicated file - so here is an update to the Drafts action to choose the target with a dialog (this way you could ask for other details for the new note too):
-- The action must be initiated from a note in Drafts.app while the title of the note will become the $Name of the TBX note.
-- the script is based on the work of midas0441 (TBX forum)
on execute(draft)
-- adjust the filename and path to your personal file
set theTBXFile to "/Users/yourname/Documents/Tinderbox/ideas.tbx"
set theTitle to title of the draft
set theFullBody to the content of the draft
set theCleanBody to returnContentWithoutFirstLine(theFullBody)
set theCreateDate to ("" & createdAt of the draft)
set theModifyDate to ("" & modifiedAt of the draft)
set theTags to (tags of the draft)
set theListOfTags to convertListToString(theTags, "; ")
set theLinkToDrafts to the permalink of the draft
set theDialogText to "Store to your default file or the frontmost file?"
display dialog theDialogText buttons {"Frontmost", "Default"} default button "Default" with icon caution giving up after 5
if the button returned of the result is "Frontmost" then
set theTarget to false
else
set theTarget to true
end if
tell application id "Cere"
if theTarget then
open theTBXFile
end if
tell front document
if not (exists note "Inbox") then make new note with properties {name:"Inbox"}
set theContainer to note "inbox"
set myNote to make new note with properties {name:theTitle} at theContainer
tell myNote
set value of attribute "Text" to theCleanBody
set value of attribute "Created" to theCreateDate
set value of attribute "Modified" to theModifyDate
set value of attribute "Tags" to theListOfTags
set value of attribute "Prototype" to "pNotiz aus Drafts"
set value of attribute "URL" to theLinkToDrafts
set value of attribute "DisplayedAttributes" to "Created;Modified;Tags;URL"
end tell
end tell
end tell
end execute
on convertListToString(theList, theDelimiter)
set AppleScript's text item delimiters to theDelimiter
set theString to theList as string
set AppleScript's text item delimiters to ""
return theString
end convertListToString
on returnContentWithoutFirstLine(allContent)
set theResult to ""
set theFirstNonEmptyLine to returnTheFirstNonEmptyLine(allContent)
set text item delimiters to return
set theResult to (paragraphs theFirstNonEmptyLine thru -1) of allContent as string
set text item delimiters to ""
return theResult
end returnContentWithoutFirstLine
on returnTheFirstNonEmptyLine(allContent)
set theResult to 2
repeat with i from 2 to the number of paragraphs in allContent
if paragraph i of allContent is not "" then
set theResult to i
exit repeat
end if
end repeat
return theResult
end returnTheFirstNonEmptyLine
even easier to install the action into Drafts - open the URL and click the “Install” button and you are ready to go: AddToTinderbox | Drafts Directory
Thanks for this, @satikusala and @webline, very useful. I love markdown but prefer rich text in Tinderbox. Is there an easy way to convert the markdown text in Drafts to Rich Text as part of this action? I have a Drafts add-on which copies the text as Rich but am not clear how that might be combined into the action.
@satikusala, I tried inserting the script for the rich text copy both before and after the existing scripts, but no difference: the result remains markdown.
there is no option to extract the text as RTF - the only solution I found is converting the text to html and copy this: Markdown to Notes | Drafts Directory
Or you may insert this into the TBX action - converts the markdown in Drafts into HTML.
Keyboard Majestro may be another way to go or use AppleScript to store the content in a temp file, open this file with Marked 2 (via AppleScript), convert it to RTF and copy the result into TBX. Sounds more complex then it is
One other option for RTF would be to export from Drafts to DEVON instead of directly into Tinderbox, then have a smart rule (or manual conversion) to convert to RTF in DEVON. This is done fairly seamlessly. Then drag and drop into Tinderbox as you wish. Just another option to think about. I use DEVON to store all my notes and pdf and then use Tinderbox to explore deeper. This workflow works well if you use a similar workflow.
Tom