Setting up drag/drop or copy/paste from Devonthink

What edition and version of DEVONthink are you using?

Devonthink Office Pro Version 2.9.17

OK, thanks. Same thing here. What is it you are dragging? An RTF? RTFD? Text? Just now I dragged .txt, .rtf, .rtfd, .xlsx, .pdf, .png, .bmp, .gif, and .eml documents one by one from DEVONthink to Tinderbox and even if the content is not imported (e.g., for .eml) the info I posted above is created, with the URL KA, with the x-devonthink-item:// link in the URL. IOW, I cannot make this fail.

Have you tried rebooting your computer recently? Or created a new user and tested the import there?

Iā€™ll try rebooting my computer to see if it works.

Iā€™m selecting a portion of text from an RTF file from within DTP, and dragging it into Tinderbox.

Aha. New information. When you said you ā€œdragged notesā€ I merely assumed you were dragging files.

Yes. Selecting and dragging content will not work. Thatā€™s not how the integration between DEVONthink and Tinderbox works. (By default, DEVONthink never puts metadata such as URL, etc., onto the clipboard when text is copied. You would need to write a JXA or AppleScript thingy to do that for you.)

Drag documents.

You can, of course, drag text out of a document in your database and into the same group or a different group, and DEVONthink will create a document whose content is the dragged text. Then you can drag that new document into Tinderbox.

Sorry if I didnā€™t make that clear before. In lieu of that level of integration between DTP & TB, Iā€™ve been clicking on edit, selecting ā€œCopy Item Link,ā€ and then pasting that URL into TBā€™s URL window for that note section. It requires another few steps, but it does work.

It would be great if I could drag a portion of text from DTP, and have the url (i.e., the Copy Item Link) for that section carry over into TB! Hereā€™s hoping it can happen in future editionsā€¦

BTW, is there any way to make a feature request for the dragging a portion of text from a DTP file, and have the url (i.e., the Copy Item Link) for that dragged section carry over into TB?

Thanks!

You could write Eastgate and ask.

The DEVONthink item link refers to the document, not to portions of a document (i.e., selected text). Also, as I mentioned, DEVONthink does not put metadata onto the clipboard ā€“ the URL or anything else ā€“ when text is dragged or copied from a document.

You would need to ask DEVONtechnologies to change that behavior. Tinderbox cannot do something with metadata thatā€™s not present to begin with.

Got it. Thanks for that information. Iā€™m still getting a grasp of Tinderbox (steep learning curve, indeed!), so thatā€™s very helpfulā€¦ Thank you, again.

I realize it has been a year since weā€™ve resisted this topic, but Iā€™m wondering if thereā€™ve been any new developments that enable users to drag a portion of text from a DEVONthinkPro file, and have the url (i.e., the ā€œCopy Item Linkā€) for that dragged section carry over into TB?

Thanks!

This has always been possible on the DEVONthink side. Select text in a document. Drag that text to the file list (or another group) in DEVONthink to create a new document containing only that text. When youā€™ve collected all the snippets you want using this drag-to-create method, then select all those snippets and drag them to Tinderbox.

DEVONthink is not like Safari ā€“ it does not put the URL onto the clipboard when you copy text. You could write a script to do that, of course, but Iā€™d advise putting the data int TSV or OPML format on the clipboard so that when pasted into Tinderbox you cause Tinderbox to parse the data and put the right contents into the right attributes.

The first method is simpler.

Thank you so much for your post, and please excuse my late reply. I was in transit when you wrote.

I believe Iā€™ve been following the process youā€™ve laid out, but maybe Iā€™m not explaining myself clearly or fully understanding what youā€™re suggesting.

Just to be clear, Iā€™m just trying to figure out the best way to drag-and-drop (or copy and paste) text thatā€™s been copied / dragged from DEVONthink and pasted / dropped into Tinderbox so that it both contains the text into a TB note and automatically carries over the DEVONthink url for that text section/file and includes it into TBā€™s url field.

I understand what you mean when you say, ā€œDEVONthink is not like Safari ā€“ it does not put the URL onto the clipboard when you copy text.ā€ Thatā€™s a shame, since it would probably make this process easier!

Anyway, youā€™ve suggested two methods, and I greatly appreciate that. I confess Iā€™ve never attempted either of them before. Both seem like a bit of a process, and I was seeking a solution to what I described above without the kind of rendering you suggested. Iā€™ll try both of them out, and report back. But I keep wondering if thereā€™s some other, simpler approach ā€“ or of this a feature that the folks at TB might consider. Iā€™m happy to pass it along to TB developers if you think itā€™s something they might be able to doā€¦

Many thanks again for your assistance!

The work needs to be done on the DEVONthink side ā€“ where the data originate. Tinderbox cannot add something to dragged text (the DEVONthink URL) thatā€™s not there to begin with. Youā€™re better off explaining your requirement to DEVONthink.

1 Like

Aha. I didnā€™t realize that ā€“ it seemed to me that this was something that had be created / solved on the TB end. Anyway, Iā€™ll poke around on their forums and report back with what I turn up. Many thanks again!

Aha. I realized there may be another path, if @mwra and/or @ComplexPoint want to assist.

The ā€œclip selection to Tinderboxā€ workflow / macOS service that @mwra wrote (see this) contains an AppleScript, below. This could be modified with some of the newer AppleScript commands for Tinderbox so that it delivered the copied text as $Text for a new note and the DEVONthink URL as the $ReferenceURL for that note.

    on run {input, parameters}
	try
		tell application "System Events" to set activeApplication to bundle identifier of 1st process whose frontmost is true
		set the clipboard to input as Unicode text
		activate application "Tinderbox 8"
		tell application "Tinderbox 8"
			set docs to documents
			if 0 < length of docs then
				set doc to front document
			else
				set doc to make new document
			end if
			tell front document
				make new note with properties {name:input}
			end tell
		end tell
		activate application id activeApplication
	on error errmsg
		--display dialog "Error while executing service:" & errmsg buttons {"Close"}
	end try
end run
2 Likes

Oh wow. Thank you so much for referencing this!

So, the script in its current form needs to be updated first before one can use it?

Thanks againā€¦

Where in this is the DEVONthink data. Is input just the $Name?

Is this part of a larger script that drives DEVONthink to set input and parameters?

Read the OPā€™s requirements above. They are selecting text in a document stored in DEVONthink and want to create a new note in Tinderbox with the selected text as $Text, and the Reference URL (i.e., so-called ā€œDEVONthink URLā€) added to $ReferenceURL for that note.

I donā€™t know what they want $Name to be ā€“ I assume it would initially be some truncated string ā€“ say, the first 30 characters of $Text?

Of course, @jprint714 can speak.

Well, Iā€™m less sure about the DEVONthink end but a simple proof of concept this works for me ( Tinderbox v8.2.2, AppleScript Debugger v7.0.10, macOS 10.14.6)

set sourceName to "A test note"
set sourceBody to "This is the sample body text"
set sourceDTURL to "x-devonthink-item://C5821A7D-A2C4-4A8F-B6EE-DC4B25D78EE0"

tell application "System Events" to set activeApplication to bundle identifier of 1st process whose frontmost is true
activate application "Tinderbox 8"
tell application "Tinderbox 8"
	set docs to documents
	if 0 < length of docs then
		set doc to front document
	else
		set doc to make new document
	end if
	tell front document
		set myNote to make new note with properties {name:sourceName}
		tell myNote
			set value of attribute named "Text" to sourceBody as Unicode text
			set value of attribute named "ReferenceURL" to sourceDTURL
		end tell
	end tell
end tell
activate application id activeApplication

The result (note, I added the KA manually to show data was there):

So if someone (OP? @jprint714 ) decides exactly how the DEVONthink source data is chosen from the current DEVONthink record and how that is passed to Tinderbox, at least the Tinderbox end can be shown to work.
Iā€™m aware I took out the clipboard part, but I just wanted to prove Tinderbox could make the necessary output. It remains to get necessary DEVONthink on the clipboard and accessible as 3 discrete bits of information. Also, my AppleScript is a bit rusty so iā€™m not suggesting my syntax is stellar - though it does work!

Or something like this:

tell application "DEVONthink 3"
	tell item 1 of (get selection)
		set dtURL to reference URL
		set extURL to URL
	end tell
	set theSelectedText to selected text of think window 1
end tell

set text item delimiters to " "
set theName to firstNWords(theSelectedText, 8)

tell application "Tinderbox 8"
	if not (exists front document) then make new document
	tell front document
		set myNote to make new note with properties {name:theName}
		tell myNote
			set value of attribute "ReferenceURL" to dtURL
			set value of attribute "URL" to extURL
			set value of attribute "Text" to theSelectedText
			set value of attribute "KeyAttributes" to "URL;ReferenceURL"
		end tell
	end tell
end tell

to firstNWords(someText, numWords)
	tell someText
		if its length is 0 then error "Select some text and run again."
		if length of its words < numWords then
			set theName to it
		else
			set theName to (its words 1 thru numWords as text)
		end if
	end tell
end firstNWords
1 Like