On Sunday, April 10, 2016 at 11:07:16 PM UTC+8, Yakov wrote:
>
> Hi Vincent,
>
>
> Now, the "boring" part.
>
> 1. create a one-line tiddler with text alpha __beta__ gamma. Click to
> edit the only block. Add a new line (enter) and apply (ctrl+enter). Enter
> the ordinary edit mode (click "edit"). Press esc to cancel. What is
> expected: the changes are already applied, and since I haven't changed
> anything in the ordinary edit mode I will just leave. What actually
> happens: the editor asks if we should leave without saving changes (as
> thought as they were done in the edit mode, not in twve).
>
>
> I think that's because the tiddler was not saved after the new-line being
> added. This behavior is of TiddlyWiki (without AutoSave), not of *twve*.
>
> Not quite. The thing about autosave is what would be on leaving TW, not
> the tiddler edit mode. This looks like no store.notify was called (and
> hence no store.saveTiddler was called) and because of that no refreshing
> was done, though I'm not totally sure.
>
The *twve* stores *every* accepted change back to the tiddler text, right
at the time being accepted, even in the case of one single character. You
do not see a whole tiddler refreshing because *twve* avoids it and does
partial refreshing for you. I decided to do partial refreshing because it
improves performance significantly. Technically it avoids whole tiddler
refreshing by using the unrecommended way:
tiddler.set(...the changed text and other necessary info....);
store.setDirty(true);
It is the *store.setDirty(true)* that informs the TiddlyWiki that something
has been changed. I do think it makes sense to do so even after a single
character change.
So, if you disable the *autoSave* option, which is commonly desired
probably, then before you manually save it the tiddler remains *dirty* after
any change, and what you described shall happen naturally.
Thanks a lot for sharing the idea of a formatter, something that I still
can't figure out by myself. I will spend time studying it and see what I
can do. This is really helping and highly appreciated. Thanks again for
sharing.
Have fun!
Vincent
> Recently I've came to an idea how to create a formatter that can create an
> editable text and save changes back to wikitext. The main idea is to use
> such engine for MathQuill [1] in TWc which I've already implemented to some
> extent, but here I'll just show the template for such formatter, may be
> you'll find this useful. Now I understand TWc Wikifier relatively well, so
> if you have some questions, I'll probably be able to answer. So here's the
> text of the tiddler containing a test, the code and some comments:
>
> /***
> |Version|0.9|
> A simple formatter is implemented here. This formatter creates DOM that
> can be "reflexively edited": editing changes not only DOM, but also
> wikitext which it was generated from.
> |test formatter|<ff>val 3</ff> (was: {{{<ff>val 2</ff>}}})|
> * recalcs slices (changes are applied); refreshing doesn't affect
> distructively; several consiquent edits via one formatter work correctly
> * ''test'' several edits via several formatters; test with transclusion,
> including sections (both should work correctly)
> ***/
> //{{{
> var reflexiveFormatterTerm =
> {
> name: "reflexiveFormatterTest2",
> openWrapper: "<ff>",
> closeWrapper: "</ff>"
>
> };(function($){ // concatenate to reflexiveFormatterTerm ($ = this)
>
> $.match = $.openWrapper;
> $.lookaheadRegExp = new RegExp($.openWrapper + "(.*?)" +
> $.closeWrapper, "mg");
> $.handler = function(w)
> {
> $.lookaheadRegExp.lastIndex = w.matchStart;
> var wholeThingMatch = this.lookaheadRegExp.exec(w.source);
> if(!wholeThingMatch) return;
> // wikitext "corresponding to the formatter" with wrapper
> var wholeThing = wholeThingMatch[0],
> // wikitext "corresponding to the formatter" without wrapper
> mainThing = wholeThingMatch[1];
> w.nextMatch = this.lookaheadRegExp.lastIndex;
>
> var sourceTiddler = w.tiddler,
> startPosition = w.matchStart,
> initialLength = w.matchLength
> ...
--
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 https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/86cb3f84-6e8d-4eca-8b70-61e6481d785c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.