There are still some warnings about making functions in a loop, but
I’ll fix those as a separate pull request because the fixes are more
than typographic errors.
Re-introduces the “tw-auto-save-wiki” message. The previous approach of
automatically triggering autosave whenever a tiddler changed meant that
changing configuration changes in control panel was triggering an
autosave. Using the explicit message gives us better control of the
situations in which we’ll autosave.
Now we solve the earlier problem of there being outstanding tiddler
change events at the time that we process the “tw-auto-save-wiki” by
deferring the autosave until the outstanding change event comes in.
Mistakenly, I had changed the tiddler widget to refresh itself when the
value of the target tiddler changed. This is not in fact necessary; it
only needs to refresh itself when the identity of the target tiddler
changes.
Fixes#744
Previously we were using a message `tw-auto-save-wiki` to trigger an
autosave. The message was generated by certain UI actions such as
saving a tiddler. The trouble was that the message was being processed
before the wiki change event for the accompanying change had had a
chance to percolate. The end result was that the dirty indicator was
staying lit when using autosave.
The new approach abandons the autosave message and instead triggers the
autosave in the wiki change event when a relevant change occurs.
One happy side effect of these changes is that the dirty indicator now
works as expected with the client server edition - ie, when typing in a
draft tiddler the dirty indicator will flash briefly, and then clear
when the sync mechanism has completed saving the draft.
Fixing problems caused by c4b76ceb0b:
* We still need to initialise the saver-handler even when syncing to a
server, otherwise offline snapshots can’t be saved
* We need to override the default save template a bit further up the
stack, to avoid the server side serving the offline version of the wiki
at `/`
Fixes#717
The issue was that under Windows we generate text nodes that contained
CRLF as a linebreak (rather than just LF as usual).
The subtle problem is that when these strings are placed in the DOM via
createTextNode(), the CR character is treated as a printable character,
not whitespace. When creating DOM notes with innerHTML or as part of a
static HTML document the HTML parser will strip out the CR characters.
The hacky solution is to manually remove CRs before building the text
node.