Hi Dave,
Yes, I am thinking how easily add words to index like LaTex!
@Mohammad I cant find the Topic where I was inspired to to create two select and sort text editor tool bar buttons attached;
text-sorter.json (3.7 KB)
Drop on tiddlywiki.com to test.
- It is not ready for publishing as you have to undo ctrl-z after you first attempt, and do it a second time.
Inside $:/PSaT/text-sorter/down you will see;
<$action-sendmessage
$message="tm-edit-text-operation"
$param="save-selection"
tiddler="$:/temp/selection"
/>
<$let
new-line={{{ [charcode[13],[10]] }}}
sorted={{{ [{$:/temp/selection}splitregexp[\n]sort[]join<new-line>] }}}
>
<$action-sendmessage
$message="tm-edit-text-operation"
$param="replace-selection"
text=<<sorted>>
/>
</$let>
You can see the selection gets saved to tiddler="$:/temp/selection" in the first action.
In effect the various $message=“tm-edit-text-operation” actions have access to the selection in the editor, thus you make use of https://tiddlywiki.com/#WidgetMessage%3A%20tm-edit-text-operation in this case perhaps only save-selection excise are relevant.
However as you can see from the above example any wiki text, macros, tiddler references and actions can be used inside a editor toolbar button.
To provide a button that allows selection from a list look at the stamp or more drop downs.
If I could find the post where I responded with this I raised the possibility of handling clipboards and other methods from the Editor Toolbar.
We tried this in fishing plugin, and found it impossible to do so without JS. But that JS code is basically copy from the tw core’s code, is pretty simple.
Thanks @TW_Tones for this code ! I wil use it back for sure !
Is there a reason why you split text delimited by \n
but you join it back with charcode[13],[10]
which is \r\n
?
When we produce a single file wiki we deliberately strip out the CR \r
character because it saves a lot of file size and it isn’t needed. Even most windows editors are able to deal with it now.
I don’t see a reason, why it should be added.
The answer is because I got it wrong, charcode[10]
would be enough.
The error came from decades of moving between windows text files and linux and mainframe files.
Post Script: Tiddlywiki.com also gives the example of charcode[13],[10]
so no wonder I used it.
With help of great friends here, I was able to answer the original question in this thread!
FACTS
- The content of action tiddler can be any kind of action widgets
- You have to use
tm-edit-text-operation
to access to selection
Solution
- Create an action tiddler with below text and fields
\define myTargetTid() Target
\define tempTid() $:/temp/append-button/selection
<$action-sendmessage
$message="tm-edit-text-operation"
$param="save-selection"
tiddler=<<tempTid>>
/>
<$vars linebreak="
">
<$action-setfield $tiddler=<<myTargetTid>> text={{{ [<myTargetTid>get[text]] [<tempTid>get[text]] +[join<linebreak>] }}}/>
</$vars>
|tags: |$:/tags/EditorToolbar
|
|caption: |append selection |
|condition: | [<targetTiddler>]
|
|description: |Append selection to target tiddler|
|icon: |$:/core/images/new-button
|
- Save it
This will create a new toolbar button allow you to add any selection to a target tiddler.
Screencast
Some ideas to use this button
- take micro notes when editing/writing new tiddler
- create micro todos with date
Lovely work
Some other ideas to use this button
- Harvest content from throughout your wiki to compose a new tiddler based on that information.
- You could have a list of common phrases.
- Use on tiddlywiki.com (or copy of) to collect code snippets.
Mohamad I think companion buttons in the view toolbar (more) to copy either the title of a tiddler, the title wrapped in [[title]] or the text of the current tiddler to the same target. Here some prior art of mine, not checked today that may speed this. copy-text-title-buttons.json (4.1 KB)
PS Feel free to add your your list/solution as you wish @Mohammad
Thank you @TW_Tones .
I am wondering how we can access to tiddler title through tm-text-operation or other methods inside editor!
targetTiddler
variable for the draft tiddler.
Worth remembering that you can always add <$action-log/>
to any action string and see what variables are defined.
Some tips I value related to current tiddler
In addition to target tiddler that @saqimtiaz mentioned storyTiddler variable can help access the current tiddler in the story especialy if currentTiddler has being reused in another list.
But also one thing I discovered is what I call is the focused tiddler. The last navigated to tiddler found here {{$:/HistoryList!!current-tiddler}}
I am not sure it’s appropriate to use in the editor toolbar but it has value. I have supporting tools but again not published.
There is a notable pitfall tv-action-refresh-policy
that may cause the button to need to be clicked twice to work.
TW document: https://tiddlywiki.com/#ActionWidget%20Execution%20Modes
My code: fishing/setexcerpt.tid at 987bdaa22dda38c751a33f903e0aee325d98c33d · oflg/fishing · GitHub
Just a side comment: English is our language here. But often it is very challenging to get right.
@Mohammad, you’d write “@saqimtiaz may have some advice here!”. (Singulars/Plurals are very difficult in English!) It is “advice”, not adviceS
I don’t want to spook @Mohammad. Merely help him as he writes English mostly well.
A side comment, TT.