TitlePicker - a standalone component for EditorMagic

228 views
Skip to first unread message

Mat

unread,
Apr 11, 2020, 9:24:07 AM4/11/20
to tiddl...@googlegroups.com
OK, as noted when I presented it, EditorMagic is not ready for prime time. So, I'll take it one step at a time - here is: 


It's supposed to be somewhat comparable to the regular tag picker, i.e in the editor you type e.g [[foo and get suggestions for all tiddlers starting with the "fragment" foo (e.g tiddlers foo and foobar). If you click a suggestion, say foobar, the [[foo is replaced with [[foobar]]

In spite of much effort it only works "to some extent". Now, it is made with only two small tiddlers: the EditTemplate and the TitlePicker, so I'd really appreciate any help you can give.

Please test around and see what you think.

<:-)

Mat

unread,
Apr 12, 2020, 7:54:01 AM4/12/20
to tiddl...@googlegroups.com
OK, I've updated the TitlePicker somewhat.

It can now present suggestions for every instance of unclosed links (e.g [[foo ) in a text.

[Update: The following is no longer considered an issue. I.e a limitation will have to be that the search term much not include spaces. You'll still get title suggestions that can include spaces tho.]


I have a tiddler named "tidone" and another tiddler named "tidone with spaces". I correctly get suggestions for both if I type in this sentence: 

[[tidone with spa is a tiddler

The problem is that the mechanism only identifies "tidone" as the fragment, not the full "tidone with spaces". So, if I click the suggested "tidone with spaces", then this happens to the text:

[[tidone with spaces]] with spa is a tiddler

I.e only "tidone" was replaced instead of "tidone with spa". I don't know how to get around this.

Ideas anyone?

<:-)

Ste Wilson

unread,
Apr 12, 2020, 4:41:12 PM4/12/20
to TiddlyWiki
No idea.. But that is very very cool!

Mat

unread,
Apr 12, 2020, 5:32:26 PM4/12/20
to tiddl...@googlegroups.com
Ste Wilson wrote:
No idea.. But that is very very cool!

Thanx.  I've been sweating over this all day (...not to mention other days) but there are a few things I just can't overcome and I'm beginning to think that tackling what I thought was the most "basic case" for EditorMagic, i.e picking titles, might just be the toughest one because of the special role that brackets have in TW.

<:-)

Mat

unread,
Apr 12, 2020, 8:30:58 PM4/12/20
to TiddlyWiki
OK, a few knots loosened up. It seems to function pretty well now but I'm possibly not pushing its limits. Please try it out and come with feedback.


<:-)

TiddlyTweeter

unread,
Apr 13, 2020, 2:31:15 AM4/13/20
to TiddlyWiki
Ciao Mat

Useful tool! 

But on Firefox and Chrome (on a Windows tablet) the "pick list" correctly comes up but when I click on an item it does not get inserted.

Best wishes
TT

TonyM

unread,
Apr 13, 2020, 2:44:22 AM4/13/20
to TiddlyWiki
Mat,

Good on you for pursuing this. At the moment on Chrome the choices appear above the edit area and clicking does not insert.

It made me think how when only one option remains the instinct is to hit tab to complete the entry as one would do in other command lines prompts. Would keyboard selection make this simpler?

I am here to help as much as I can but I am no expert here.

Regards
Tony

TonyM

unread,
Apr 13, 2020, 2:53:03 AM4/13/20
to TiddlyWiki
Mat,

I assume you are aware of the link button in the editor toolbar, perhaps you could get your "sniffer" that responds to "[[" to cause that link button to popup. I am kind of thinking what if your solution provides the popup on set text combinations to editor toolbar buttons that fulfill the result. Thus perhaps this could become part of the core where all editor toolbar buttons can have a trigger set and you/we can write new editor toolbar buttons to fulfill your design ideas.

It would almost be like setting keyboard shortcuts from the text for each editor toolbar button.

Just a thought.

Regards
Tony

Birthe C

unread,
Apr 13, 2020, 3:33:42 AM4/13/20
to TiddlyWiki
Mat,

It works well for me. I am using linux and Firefox. Writing the [[word
the "picklist" comes up. To get the link inserted I need to have a space after [[word.

Birthe

TiddlyTweeter

unread,
Apr 13, 2020, 3:49:06 AM4/13/20
to TiddlyWiki
Nice spotting Birthe!

Confirm works for me too if you add trailing space. (Both F & C.)

TT

Mat

unread,
Apr 13, 2020, 5:02:59 AM4/13/20
to tiddl...@googlegroups.com
Trailing space - ah, sorry, yes, I thought I had found a clever way to solve a problem:


TL;DR: I need a regexp to find: the fragment (i.e the partial title) that is always prefixed with [[, but which does NOT have an eventual ]].


The longer description of the problem and why I thought a trailing space was a solution:

foo [[tidone]] [[tido

For the above text, clicking the suggested tidone would cause this:

foo [[tidone]] ne]] [[tidone]]

...ie. the replacement is done regardless if [[tido is followed by an eventual ]] or not. That is because of this filter:

[<text>split<linkfragment>join<link>]

...so I figured a space would distinguish the [[tido to be replaced from the ones not to be replaced but as you've discovered it was not a sufficient solution. 

Hopefully if I exchange split for splitregexp with a clever regexp it can be resolved.

<:-) 

Mat

unread,
Apr 13, 2020, 6:02:02 AM4/13/20
to tiddl...@googlegroups.com
So, here's the exact question:

How do I modify the expression:

\define expression() $(triggex)$$(fragment)$

<$action-setfield $tiddler=<<current>>
  text
={{{ [<text>splitregexp<expression>join<link>] }}}
/>

triggex is \[\[
fragment is e.g foo in [[foo

What is needed is something that ensures the fragment does not end with an eventual ]] or any other forbidden title characters.

<:-)

TiddlyTweeter

unread,
Apr 13, 2020, 8:07:44 AM4/13/20
to TiddlyWiki
Ciao Mat

I'm pretty sure regex can do what you want. But I need clarify what you need matching before I start trying a test or two.

At the moment what the user enters in tid ONLY the first word appears to be passed to match titles ..? That all titles starting "tidone" are listed even though a user entered a more specific match string. Is that the intended behaviour? Hopefully this makes it clearer...

Annotation 2020-04-13 134316.jpg

Best wishes
TT

Mat

unread,
Apr 13, 2020, 8:23:18 AM4/13/20
to TiddlyWiki
@TT - Much appreciated.

Yes, unfortunately I am forced to use only a single word (i.e up until space character) as the fragment because when I look for tiddlers that is prefixed with the fragment... what is that prefix e.g here:

[[tidone with spaces in its name but where does the name end in this long string?

...so, yes, I had to limit it so the first space character (or, I guess, end of text) is the delimiter.

<:-)

P.S My computer is about to give up. Screen only works when folded up in certain angles. Must buy new one today but who knows what happens. Happens every 1.5 years almost like clockwork.

TonyM

unread,
Apr 13, 2020, 10:43:18 AM4/13/20
to TiddlyWiki
Mat

Have look to see if there is a software setting for what to do when you open close your lid. If you turn it off perhaps the screen will stay on regardless of what the sensor thinks.

Tony

Mat

unread,
Apr 13, 2020, 10:54:43 AM4/13/20
to TiddlyWiki
@Tony, thanks. I think the problem is some glitching connection between screen and motherboard, so it's not the screen "turning off", it's 2/3 the screen messing up and fading out etc. Thanks anyway. 

BTW my point in mentioning the problem in the first place was just in case I'm slow in replying to something and someone wondered why.


<:-)

Mat

unread,
Apr 14, 2020, 4:32:33 AM4/14/20
to tiddl...@googlegroups.com
Still hoping for help to find the right regex, I've made it very simple to test regexes and directly see the result.

So, you modify the yellow regexp until it finds only the unfinished links e.g [[foo (where [[ is the trigger and foo is the fragment)

tabort.png


The result is "previewed" directly just below the suggested titles without having to click anything.

Anyone is welcome to experiment.

<:-)

Vaughn Papenhausen

unread,
Apr 29, 2020, 2:49:47 PM4/29/20
to TiddlyWiki
Would it help to auto-close the link syntax as Roam does? I.e. whenever you type "[[" it would automatically turn it into "[[*]]" (with the cursor in the position of the asterisk do that you could start typing immediately), that way you know where the string begins and ends?

Mat

unread,
Apr 29, 2020, 6:08:48 PM4/29/20
to TiddlyWiki
Vaughn Papenhausen wrote:
Would it help to auto-close the link syntax as Roam does? I.e. whenever you type "[[" it would automatically turn it into "[[*]]" (with the cursor in the position of the asterisk do that you could start typing immediately), that way you know where the string begins and ends?

Now why didn't I think of that!? GREAT idea as it would totally solve the regex dilemma, even make it trivial. The only problem I can see is that in order for the [[ to be converted into [[]] there has to be some action taking place, such as the user clicking something. Now, in a sense, the user is doing something - he is typing, so just maybe this action is enough?

- anybody knows? Could the typing of [[ be "action enough" to trigger an action widget? 

<:-)

Ste Wilson

unread,
Apr 30, 2020, 7:27:11 AM4/30/20
to tiddl...@googlegroups.com
I'm sure this has been done..when I started using TiddlyWiki (so three years ago?) someone had an autocomplete something...i ended up not using it because all my Titles Have Caps and in the text, I don't want that but...I'll have a look

Ste Wilson

unread,
Apr 30, 2020, 7:31:18 AM4/30/20
to TiddlyWiki
Reply all
Reply to author
Forward
0 new messages