Hello Albert,
> @Yakov
>
> Not sure what do you mean here by "doesn't support". I've tried to type
>> tiddler names starting from cyrillics ([[До) and got the proper
>> suggestions; I've even created a tiddler which name starts from ASCII
>> letters and contain cyrillics (New Tiddler Ъ) and if I type [[Ъ or even
>> [[ъ (not capital letter), I get the right suggestion listed. What
>> exactly didn't work for you?
>>
>
> You see, I'm totally new to RegExp :) The default AtWho matcher[1] matches
> only "A-Za-z0-9" but no diacritic[2] characters like äöü?é etc. I've added
> a small RegExp hack in the current release ("\x7f-\xff"), so now it works.
> I should also modify the highlighter function[3] in a next version.
>
> Ah, ok, now I've found this code bit. May be some [^...] solution is also
of interest, see [1] for example (I guess, we don't need to exclude all the
special symbols). PS actually, see below in this post.
>
> By the way, I've noticed that I have to click the "autosuggest off" button
>> twice to make it switch to "on", this is a small bug, I'd say. Not sure
>> what's the cause.
>>
>
> Hmm, this is strange as it works for me as expected. Does this bug still
> occur in the current release (0.2.4)?
>
> Now this is fixed for existing tiddlers. Once I create a new tiddler, this
behaviour takes place (until it is saved and opened again).
>
> By the way, in TiddlySpace, the "view instead of edit" mode for guests
>> doesn't allow to type any letters, so this doesn't work as demo. If you'd
>> like to show some demo directly in the space, you have to manually create a
>> tiddler with some <html>...</html> containing a textarea where a guest can
>> type and (s)he gets the suggestions.
>>
>
> I wasn't aware of it. I've added a small example tiddler for guests just
> to show them how it works (tiddler suggestion only).
>
> The demo works nicely. However, I've noticed that you "reimplement" the
autosuggesion engine in the script element. What do you think about
implementing a general function, sort of suggestAt(element,mode), which can
be applied to a textarea or an input element and adds autosuggesting to
that element? (I'm not sure if it can be implemented in such a way, can
it?) Once it is implemented, you don't have to worry much about Inline
Editing or PasteUp helper or other alternative editors, as one can write a
little snippet that applies suggestAt to the editor, and it's done (except
for CodeMirror, which is not actually a simple textarea). Likewise, you can
apply this to your demo (hence, for quick testing one will have to just
open the demo page using their browser). The mode param here is to
distinguish "ordinary editor", "tags editor" and may be others.
>
> Well, the easiest RegExp the matches [[some text| would probably be
>> /\[\[[^\|\]]+?\|/, but I'm not sure how this should be passed to .. is
>> it .atwho method that sets the autoSuggestions?
>
>
> Well, this is more tricky for a novice like me. I tried several RegExps
> but without luck. I don't have enough time at the moment to get into it,
> but it is indeed the most important feature to make this plugin (more)
> usable. I have to take more time to dive deeper into RegExp stuff. Hope to
> fix this soon (#1 on my wishlist). If you like to help, you could read the
> documentation about custom callbacks[4] of ".atwho" method. These callbacks
> can be passed to ".atwho" with the "callbacks" property. You can see my
> custom callback for the matcher function ("cbMatcher") in the source code
> of AutoSuggestPlugin. Hope that helps a bit.
>
> Ok, in your current implementation, try this: instead of the line
regexp = new
RegExp(flag+"([^\\x00-\\xff]*)$|"+flag+"(["+chars+"]*[^|\\]])$|"+flag+"["+chars+"]*\\|(["+chars+"]*[^|\\]])$",
"gi");
insert
regexp = new RegExp(flag+ "([^\\|\\n\\]]*)$|"+
flag+"[^\\|\\n\\]]+\\|([^\\|\\n\\]]*)$", "gi");
Test results: your version supports
[[text|
[[some text|
but doesn't support
[[текст|
(which is using cyrillics). Mine supports all this "syntaxes".
Explanation: by creating the "chars" variable you're trying to count all
the possible symbols. What I propose (and proposed earlier in the citation
above) is to use "all except" regexp ([^...] syntax: in the link name we're
expecting any symbol except linebreak, pipe or ], so I used [^\\|\\n\\]].
In the link target, the situation is the same, so I use this thrice. In
fact, you can create a variable for this part and write something like:
var linkSymbol = "[^\\|\\n\\]]"
regexp = new RegExp(flag+"("+linkSymbol+"*)$|"+ flag+linkSymbol+"+\\|("+
linkSymbol+"*)$", "gi");
don't forget to turn
return match[3] || match[2] || match[1];
into
return match[2] || match[1];
as there's only two situations in this case.
If you'd like to have a RegExp exercice, try to implement the same idea in
the cbMatch (and get rid of the chars variables).
>
> I'll add a couple of ideas just see some perspectives. One this is
>> replacing html-entities (special symbols) with actual symbols like this:
>> * let's imagine I'd like to add a left-to-right arrow (→)
>> * I start to type &r
>> * I get a "→" suggestion -- *not* "→"
>> * I chose it and get much clearer wiki-code, without that unreadable
>> "→" stuff
>> Though, I don't know if there's an interface to get a list of all these
>> "abbriviations" (rarr, larr, uarr, darr, harr, times, bull,
>> .......................) and an interface to get there unicode equivalent.
>> Also, "--" -> &nash;/— could be processed in this manner.
>>
>
> A similar thing can be used with MathJax plugin to turn \rho to ρ etc.
>> (though, just autoreplacing can be done instead of autosuggesting
>> replacement, but autosuggesting seems to be more flexible)
>>
>
> Very nice ideas Yakov. I think that those suggestion patterns shouldn't be
> implemented by default as every AtWho listener affects the overall editing
> performance (especially on mobile devices). Recently I thought about user
> defined suggestion patterns which are defined in a separate config tiddler.
> Maybe this could meet your need?
>
> Yes, that's good thinking -- especailly for MathJax which is brought by a
plugin itself.
>
> Another possible application is to combine this with CodeMirror for
>> TiddlyWiki (see [1] for the latest release and discussion). This can be
>> another huge step in turning TW into a dev environment. Fortunately, Mario
>> is here and probably can comment this somehow.
>>
>
> I had the same idea as I started writing this plugin, but this is probably
> beyond my skills :) I also use CodeMirror with TW a lot and would love to
> see this combination. @Mario, what do you think?
>
> Yeap, this would require some digging of the CodeMirror editor DOM. Let's
finish "simple" features first.
> Finally, autoSuggestions can be used in the tags line which seems to be
>> more beatiful and faster than Udo's interface [2] (although, Udo's solution
>> implements some smart algorithm for ranging suggestions).
>>
>
> FIXED in 0.2.2
>
> I'd say "implemented" ;) The workflow shows, however, that ## is a bit
awkward solution for the tags edit area (especially in Russian: Russian
keyboard layout doesn't contain the # symbol -- it contains № instead).
What I can imagine as a really good solution is:
...]] [[here I started some text -> brings suggestions containing "here I
started some text"
... oneWordTag [[here I started some text -> brings suggestions containing
"here I started some text"
...]] here -> brings suggestions containing "here"
[[here I started some text -> brings suggestions containing "here I started
some text"
[[here -> brings suggestions containing "here"
I also thougt about an additional suggestion pattern (maybe ##* or the
> like) which uses smart tag suggestions like "tiddlers that uses these tags
> also use ...". I have to study Udo's algorithm ;)
>
> Yeah, the area for creativity is huge :) I guess, this "smart suggesting"
doesn't need a separate syntax; instead, you can just create a smart order
of the suggestions by default.
>
>
>> * one more idea: autosuggestions of sections/slices can be added! below
>> are some use-cases, "l" represents the cursor:
>> <<tiddler [[some tiddler##l
>> <<tiddler [[some tiddler::l
>> <<tiddler [[some tiddler##l]]
>> <<tiddler [[some tiddler::l]]
>>
>
Wow, what I really like in current implementation is the preview of the
slice values.
I guess, the tricky part for supporting this for an arbitrary tiddler is to
catch the matched value (tiddler name), right?
* there's one more case where tag suggestions are useful: filters there are
>> two cases:
>> ** tag filter. Examples of use-cases (obviously, there's no need for the
>> ## addition in this cases):
>> <<list filter '[tag[l
>> <<list filter '... [tag[l
>> <<list filter '[tag[l]]'>>
>> <<list filter '[tag[l]] ...'>>
>> <<list filter '... [tag[l]]'>>
>> as you can see, these can be described as /\[tag\[([^\]]*)($|\])/mif I'm
>> not mistaking
>> ** other filters that can "eat" tags:
>> <<list filter '[filterName[##|
>> (and versions with or without smth before/after as well)
>> In these two cases, of'course, instead of [[tagName]], either tagName]]or
>> tagName should be inserted.
>>
>
> Very usefull ideas! I've put it on my feature wishlist. As you can see
> I've implemented several experimental suggestions for sections, slices and
> fields in 0.2.4, but they only work with the current tiddler. It is just
> a test and serves more as a basis for further implementations.
>
> By the way, the results of testing with CodeMirror. in CodeMirror editor,
>> the suggestions are shown without any changes of AutoSuggestPlugin (!), and
>> if I click a suggesion with the cursor, it is inserted as expected.
>> However, the behaviour of up/down arrows and enter key is not what is
>> expected: when I press enter (after, say, I've typed [[To and the first
>> suggestion is ToolbarCommands), I get *both *linebreak and the
>> suggestion inserted, resulting in
>> [[To
>> olbarCommands
>> A similar thing happens with arrows: when I press "down" to select
>> another suggestion, the cursor goes down as well, making the suggestion
>> dropdown disappear.
>>
>
> Thank you for testing! And nice that it works more or less out of the box.
> Obviously this behaviour should be related to a conflict with CodeMirrors
> handling of keyboard events, but actually I don't know how to fix this.
>
>
>> I'll report when I test this with the View Mode/Inline Editing plugins
>> [1] (presumably it's enough to add the autoSuggest command to the
>> ViewToolbar slice..)
>
>
> Thank you Yakov, hope it works without any conflicts.
>
> Haven't tested this yet; may be I'll wait until we discuss the suggestAtidea..
Finally, I'd like to share a tweak which I use not to modify
ToolbarCommands. This is especially useful when I share AutoSuggestPlugin
via SharedTiddlersPlugin:
if(!config.autoSuggest_orig_toolbarHandler) {
config.autoSuggest_orig_toolbarHandler = config.macros.toolbar.handler;
if(true) // an option param may be inserted here
config.macros.toolbar.handler =
function(place,macroName,params,wikifier,paramString,tiddler) {
// warning: paramString is not changed as /currently/ it's not used
by config.macros.toolbar.handler
var i, ind;
for(i = 0; i < params.length; i++)
if(params[i].match(/saveTiddler/)) // locate the save/done
command
ind = i;
if(ind || ind === 0)
params.splice(ind,0,"autoSuggest"); // add after save/done
config.autoSuggest_orig_toolbarHandler.apply(this,arguments);
};
}
It hijacks the toolbar macro so that before "done" ("saveTiddler" command)
I always have the "autoSuggest" command.
By the way, this may be of interest [2] (it's an example of usage, the main
link is [3], of'course). And may be this little article, too [4]. It's
short and have some interactive examples, so.. yeap. There's also a number
of useful tools out there, like regexpal [5] and those mentioned in the
footer.
Best regards,
Yakov.
[1]
http://stackoverflow.com/questions/2949861/net-regular-expression-to-match-any-kind-of-letter-from-any-language/15587135
[2]
http://www.regexper.com/#%5C%5B%5C%5B(%5B%5EA-Z%5D*)%24%7C%5C%5B%5C%5B(%5B%5CwB-Z%5C-%5C%2B%5Cs%5D*%5B%5E%7C%5C%5D%5D)%24%7C%5C%5B%5C%5B%5B%5CwB-Z%5C-%5C%2B%5C%5Cs%5D*%5C%7C(%5B%5CwB-Z%5C-%5C%2B%5Cs%5D*%5B%5E%7C%5C%5D%5D)%24
[3] http://www.regexper.com/
[4]
http://www.web-wise-wizard.com/javascript-tutorials/javascript-regular-expressions-regexp.html
[5] http://regexpal.com/
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.