Using Share menu only gets the $Text, not the $Name

The Share menu (the macOS one) could be a really great way to get information out of TBX on a note-by-note (or more precisely, "as needed) basis, except it only seems to grab $Text, leaving $Name on its own. That’s a shame–is there a way to configure this somewhere?

1 Like

Interesting idea. I think you’d need to expand on a few things. Do you want to always export $Name, or do you want $DisplayName (if $DisplayExpression is defined)? Also, not all apps receiving data from a Share extension can deal with $Name on the clipboard – in fact I think all Tinderbox can do is send a data blob to the macOS extension dispatcher and it’s up to the developer who created the recipient extension (DEVONthink, Curiota, Yoink, Gladys, Mail … whatever) to work with that blob. Tinderbox has no control over the recipient.

FWIW, you have more control over Export than you have over Share.

In fairness, the ‘Share’ menu option is only found in the context menu of the $Text area of the Text pane. IOW the contextual data is $Text … which is what is shared. So, the result is at least logical if not exactly optimal. I think the menu option is there as a free affordance built-in to the underlying Apple frameworks rather than a deliberate ‘share’ mechanism (FWIW, I don’t recollect anyone asking for the feature, it just appeared). - see @PaulWalters next post below. My mistake.

I’d suggest writing into Eastgate with a feature request as it might be possible to alter what is passed to macOS via the share, as @PaulWalters has intimated above.

Appreciate your thoughts, but maybe there’s a better way. Have people set up quick export options or templates to simply send the $DisplayName (I agree with @PaulWalters here) and the $Text to the system clipboard or some other quick mechanism?

File > Share > … is available in any context. What it actually does, of course, depends on the recipient app.

1 Like

Unless you’re sending JSON or XML or some other structure, the clipboard will have a text block that has

$DisplayName
$Text

The clipboard won’t know “oh, this piece is the name of the file, and this piece is the contents”.

If you want to export a file whose name is $DisplayName and whose contents is $Text then Export is the way to go.

The text block is actually fine. Even better would be a text block with $DisplayName formatted as a Markdown header (which requires simply adding a “#” to the line…surely export can do that!). I need to learn Export more, it’s the one aspect of Tbx about which I am mostly clueless.

A stamp using runCommand and the command-line command pbcopy could be built to do what you’re looking to do.

The export you’re looking for is pretty simple. I’ve attached a sample file below that shows how it works.

Short version:

  1. Import the built-in HTML template.
  2. Create a new note in the top level template folder. I called mine “Single Note Export.”
  3. As text for that new template note include: # ^Title^ ^Text^ This text will insert the markdown along with the text you want.

Once you have this template set up, any time you want to copy a note’s info to the clipboard, you click the “preview” tab on the note and select and copy the text. In the test file, the text to be copied should look like this:

Troubleshooting:

  • to see the preview tab, you may have to select Window -> Show Text Pane Selector
  • if the preview tab shows a dropdown menu, select the single note template from the dropdown.
  • if the preview shows text you want without the “#” before the title, press ctl+opt+i, search for “HTMLExportTemplate” and set it’s value to the single note template. (If you only ever use export to do this task, you could set the template to the default.)

Sample file: Sample File.tbx (60.9 KB)

2 Likes

ps–if you want to show the $DisplayName rather than the note’s $Name, simply replace ^Title^ in the template with ^value($DisplayName)^

Here’s the stamp I mentioned above. Sorry to forget to post it.

runCommand("pbcopy ","# "+ $DisplayName + "\n\n" + $Text);

Make a stamp with that content. Select a note. Use the stamp. The “export” is on the clipboard ready to paste someplace else. Stamps can be given keyboard shortcuts to make this faster. To get fancy the stamp could be modified to pipe the clipboard to another app.

This uses the runCommand(command line, inputs) form discussed here in aTbRef

Another version that adds a markdown link-back to the original note in Tinderbox.

runCommand("pbcopy ","# "+ $DisplayName + "\n\n" + $Text + "\n\n [" + $DisplayName + "](" + $NoteURL + ")");
5 Likes