Description
Add a button to editor toolbar to insert the user signature as below
--- //[[UserName]] - ddd DD-mmm-YY 0hh:0mm
- for example :
— Jeff - Fri 31-Dec-21 07:43
If the Username for signing edits is not set, then use Anonymouse
Solution
i. Create the action tiddler
- Create a new tiddler with below fields
1.1.caption
: Signature
1.2.condition
:[<targetTiddler>!has[type]] [<targetTiddler>type[text/vnd.tiddlywiki]]
1.3description
Insert user signature
1.4.icon
:$:/core/images/timestamp-on
1.5.list-before
:$:/core/ui/EditorToolbar/stamp
1.6.shortcuts
:((signature))
The below action shall be written in the text field
\define signature() --- [[$(username)$]] - //$(datetime)$//
<$vars datetime=<<now "ddd DD-mmm-YY 0hh:0mm">>
username={{{ [[$:/status/UserName]get[text]else[Anonymouse]] }}}
>
<$action-sendmessage
$message="tm-edit-text-operation"
$param="insert-text"
text=<<signature>>
/>
</$vars>
- Tag it with
$:/tags/EditorToolbar
and save the above tiddler: use any title you like, but here I use$:/kookma/ui/EditorToolbar/signature
as the tiddler title.
ii. Create the keyboard shortcuts
Now, we create keyboard shortcuts, these shortcuts can be customized through $:/ControlPanel > Keyboard Shortcuts tab.
-
create a tiddler titled
$:/config/shortcuts/signature
1.1 in the text field enterctrl+g
as shortcut key (use your own if do not like) -
create a tiddler titled
$:/config/ShortcutInfo/signature
2.1 in the text field enterInser user signature
Code and demo
- to give a try download the attached solution Insert-User-Signature-EditorToolbar-Button.json (1.1 KB)
- drag and drop the downloaded JSON from step 1 into https://tiddlywiki.com/
- create a new tiddler and see it in action
3.1 click on the signature button appears before stamp
3.2 or use shortcut keys (press ctrl+g)
Ref
[1]. [ How to use Stamp to insert literals - e.g. a time-stamped Signature](How to use Stamp to insert literals - e.g. a time-stamped Signature)
[2]. Scripts in Tiddlywiki — codes, macros, and solutions in TW
[3]. https://tiddlywiki.com/#How%20to%20create%20keyboard%20shortcuts