Extend Selection to #

‘# 20 Mon Mar

Ipsum shsus shdus shs as s
Hzjd shs shshs s notes…|

‘# 19 sun mar

And so on…’

Hi, I use drafts to take notes, just like above in a cascading fashion. It works great and I export the days entries into calendar every evening using Fantastical.

I would like to streamline the export.

My idea is: Extend selection/carrot, out in both directions to #. Which then I can export selection. Taking in the date and all entries hashtag to hashtag.

Can you help Cheers

Your example looks a little strange, but assuming I understand correctly, the action below I think will do what you want and deal with a couple of edge cases too.

The action is a single script step and is based on using Drafts’ standard navigation marker definitions (headings in Markdown for example, which I think is what you want), and then shares it. There are lots of examples around Fantastical, and I’m not sure what you are doing exactly to “I export the days entries into calendar every evening using Fantastical”, but hopefully this will be a good starting point for you if nothing else.

let intSelectionStart = editor.getSelectedRange()[0];
let intStart = 0;
let intLength = editor.getText().length;

//If we are after the first heading, set the start
if (editor.navigationMarkerBefore(intSelectionStart) != undefined) intStart = editor.navigationMarkerBefore(intSelectionStart).location;

//If we are after the last heading, respecify the base length before calculation
if (editor.navigationMarkerAfter(intSelectionStart) != undefined) intLength = editor.navigationMarkerAfter(intSelectionStart).location;
intLength = intLength - intStart;

//Share the text in the specifed range
Share.shareAsText(editor.getTextInRange(intStart, intLength));
1 Like

Thanks very much it does the export real nice thanks!!!