Are there any sort text Editor Toolbar extensions?

133 views
Skip to first unread message

TonyM

unread,
Oct 3, 2019, 2:42:07 AM10/3/19
to TiddlyWiki
Folks,

In TWC the wonderful QuickEdit included the ability to select a block of text and sort it. Has anyone built an editor toolbar button for this.

I often need to massage some data extracted from elsewhere to make it easier to follow. This would help.

Otherwise are there any ideas on where to start? I do not think we have any text operations for this.

Regards
Tony

Mark S.

unread,
Oct 3, 2019, 3:16:36 PM10/3/19
to TiddlyWiki

Not the edit-in-place solution you're looking for, but you could have a button that wraps your selection, like this:

<$list filter="[[
My Simple Item
Zee other item
Dee other other item

]splitregexp[\n]sort[]]">

</$list>

Then copy the sorted text from preview mode.

c pa

unread,
Oct 3, 2019, 7:24:53 PM10/3/19
to TiddlyWiki
OK this works.
This copies the selected text into a temp tiddler, then sorts the text in the temp tiddler. (That returns a title list) Then joins the list with spaces

title: _cpa/ui/EditorToolbar/sort-text
tags: $:/tags/EditorToolbar
caption:         Sort Selected Text
condition:     [<targetTiddler>!has[type]] [<targetTiddler>type[text/vnd.tiddlywiki]]
description:    Button to sort the selected text
icon:             $:/core/images/bold

text:
<$action-sendmessage
        $message="tm-edit-text-operation"
        $param="excise"
        title="$:/temp/sort-text"
        macro="x"
/>
<$action-sendmessage
        $message="tm-edit-text-operation"
        $param="replace-selection"
        text={{{ [list[$:/temp/sort-text!!text]sort[]join[ ]] }}}
/>

TonyM

unread,
Oct 3, 2019, 8:06:51 PM10/3/19
to TiddlyWiki
Mark and c pa,

Thanks for your ideas. C pa, The idea of sorting the selection as words is interesting and one I would like to keep up my sleeve, however I need to get a hybrid of yours and Marks to sort the lines, keeping the line breaks. It's about sorting lines, in fact it will help sort lines beginning with * , # or even ":" to make bulleted/indented lists alphabetical or sort text as keys about to be pasted into a data tiddler etc...

Further issues arising

Regex as a way to include special characters like line breaks
This prompts me to ask can we use regex to insert a line break where we want in a filter. ie rather than search or transform text/titles with regex can it be used to generate special characters into the filter output?

Line handling in filters and sorting primitives
This makes me question why we do not have the primitives needed for handling rows/lines and sorting them, in filters and sorting tools outside of the filters. This is all simple javascript, I expect already contained within tiddlywiki just not surfaced for users and designers.

You answers and this problem also dovetails with a project to have a leading period "." to render a line in html p tags. We could sort paragraphs as well, this sounds a little odd but it depends what the paragraphs are. 

Line or paragraph based excise, WOW!.
What if we had an excise tool that would automatically generate multiple paragraph based tiddlers, tagging them with a named tag (or equivalent), we could then quickly extract paragraphs to separate tiddlers in a single select step, and use the tag (or equivalent), to reorder them manually. Since they are related by tag the generated tiddlers can be renamed and or given captions separately. In this case after excise we would insert into the source tiddler the list macro to display the paragraphs so tagged. If desired this list could have a template= added to handle the way each paragraph is displayed, including the possibility of making them drag drop reordered in the source tiddler. Even better is the template would be selectable and you could use an edit template, or view template from inside the source tiddler.


Regards
Tony

TonyM

unread,
Oct 3, 2019, 8:45:40 PM10/3/19
to TiddlyWiki
Folks,

I am much of the way there with this hybrid

<$action-sendmessage
        $message="tm-edit-text-operation"
        $param="excise"
        title="$:/temp/sort-text"
        macro="x"
/>
<$set name=result filter="[{$:/temp/sort-text!!text}splitregexp[\n]sort[]]">

<$action-sendmessage
        $message="tm-edit-text-operation"
        $param="replace-selection"
        text=<<result>>
/>
</$set>

However the result
  • Returns the while line between Square brackets
  • Does not restore the new line character, so the sorted result is on a single line.
Regards
Tony

ILYA

unread,
Oct 4, 2019, 12:48:59 AM10/4/19
to tiddl...@googlegroups.com
> Line or paragraph based excise, WOW!.

> What if we had an excise tool that would automatically generate multiple paragraph based tiddlers, tagging them with a named tag (or equivalent), we could then quickly extract paragraphs to separate tiddlers in a single select step, and use the tag (or equivalent), to reorder them manually. 

This would be great it would help me to fix following workflow. I often start from a single tiddler with multiple list of items (ProjectA).

! Requirements

* item2
* item3

! Features

* item3
* item4

! Decissions

* item5
* item6

Then at some point I need to reference one of the items. So I manually create 3 tiddlers (group tiddlers) and transclude them in ProjectA

* ProjectA/Requirements
* ProjectA/Features
* ProjectA/Decissions

I paste following into each one of them.
```
<<list-links "[tag{!!title}sort[]]">>
```

Then the hardest part is to convert each line from initial tiddler into a new separate tiddler tagged with one of the group tiddlers.

Best regards,
ILYA
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

TonyM

unread,
Oct 4, 2019, 3:09:43 AM10/4/19
to TiddlyWiki
ILYA

Much of that can already be done with the excise tool. Have a look in the editor toolbar.

My specific section could do this for large numbers of paragraphs and help with reordering.

Regards
Tony



On Friday, October 4, 2019 at 2:48:59 PM UTC+10, ILYA wrote:
> Line or paragraph based excise, WOW!.

> What if we had an excise tool that would automatically generate multiple paragraph based tiddlers, tagging them with a named tag (or equivalent), we could then quickly extract paragraphs to separate tiddlers in a single select step, and use the tag (or equivalent), to reorder them manually. 

This would be great it would help me to fix following workflow. I often start from a single tiddler with multiple list of items (ProjectA).

! Requirements

* item2
* item3

! Features

* item3
* item4

! Decissions

* item5
* item6

Then at some point I need to reference one of the items. So I manually create 3 tiddlers (group tiddlers) and transclude them in ProjectA

* ProjectA/Requirements
* ProjectA/Features
* ProjectA/Decissions

I paste following into each one of them.
```
<<list-links "[tag{!!title}sort[]]">>
```

Then the hardest part is to convert each line from initial tiddler into a new separate tiddler tagged with one of the group tiddlers.

Best regards,
ILYA

ILYA

unread,
Oct 4, 2019, 12:35:00 PM10/4/19
to TonyM, TiddlyWiki
excise tool cannot turn every line into a new tiddler and tag it with the name of the current.

While the thing you propose should be able to do.
Reply all
Reply to author
Forward
0 new messages