Using the tm-edit-text in toolbar with parameters

63 views
Skip to first unread message

stevesuny

unread,
Apr 1, 2017, 11:47:56 AM4/1/17
to TiddlyWiki
Hi,

I'm trying to create a toolbar widget (?) that wraps the selected text as follows:

<<macroName 'tag' 'this is the selected text' '01Apr114421'>>

So far, I can get this:

<macroName 'tag' 'this is the selected text01Apr114421

Here is my code:

<$set name="timestamp" value=<<now '0DDmmm0hh0mm0ss'>> >
<$set name="end1" value="' 'hyper' '">
<$set name="prefix" value="<
<macroName 'tag' '">
<$set name="suffix" value=<
<timestamp>> >
<$action-sendmessage
    $message="tm-edit-text-operation"
    $param="wrap-selection"
    prefix=<
<prefix>>
    suffix=<
<suffix>>
/>

Mat

unread,
Apr 1, 2017, 2:47:20 PM4/1/17
to TiddlyWiki
Haven't tested anything but I get bad vibes from the odd number of quotes in that third $set.

<:-)

stevesuny

unread,
Apr 2, 2017, 3:32:28 PM4/2/17
to TiddlyWiki
I hacked at it a bit more. At this point, I can get a static timestamp (now too interesting, but proof of concept).

Here's my code:


<$set name="timestamp" value=<<now '0DDmmm0hh0mm0ss'>
> >
<$set name="prefix" value="<
<annotate 'Text' '">

<$set name="suffix" value=<
<timestamp>
> >
<$set name="suffix" value="' '20170401010101'>>">

<$action-sendmessage
    $message="tm-edit-text-operation"
    $param="wrap-selection"
    prefix=<
<prefix>>
    suffix=<
<suffix>>
/>


Put this in a toolbar tiddler ($:/core/ui/EditorToolbar/Annotate-Text) replaces selected text with this in the tiddler currently being edited:

<<annotation 'Text' 'selected text' '20170401010101'>>

I'd love to replace the static timestamp with $timestamp$,  generated by the set comand. Note I still need to close the timestamp with a single quote, and to close the suffix with ">>". I think it is only a matter of making $timestamp$ a parameter...

Thanks!

//steve.
Reply all
Reply to author
Forward
0 new messages