mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-26 01:50:28 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
92abcb4f5a
@ -28,7 +28,7 @@ function SaverHandler(options) {
|
||||
this.initSavers();
|
||||
}
|
||||
// Only do dirty tracking if required
|
||||
if(this.dirtyTracking) {
|
||||
if($tw.browser && this.dirtyTracking) {
|
||||
// Compile the dirty tiddler filter
|
||||
this.filterFn = this.wiki.compileFilter(this.wiki.getTiddlerText(this.titleSyncFilter));
|
||||
// Count of tiddlers that have been changed but not yet saved
|
||||
@ -43,6 +43,9 @@ function SaverHandler(options) {
|
||||
});
|
||||
self.numTasksInQueue += filteredChanges.length;
|
||||
self.updateDirtyStatus();
|
||||
if(self.numTasksInQueue > 0) {
|
||||
self.saveWiki({method: "autosave"});
|
||||
}
|
||||
});
|
||||
// Browser event handlers
|
||||
if($tw.browser) {
|
||||
@ -65,13 +68,6 @@ function SaverHandler(options) {
|
||||
downloadType: "text/plain"
|
||||
});
|
||||
});
|
||||
$tw.rootWidget.addEventListener("tw-auto-save-wiki",function(event) {
|
||||
self.saveWiki({
|
||||
method: "autosave",
|
||||
template: event.param,
|
||||
downloadType: "text/plain"
|
||||
});
|
||||
});
|
||||
$tw.rootWidget.addEventListener("tw-download-file",function(event) {
|
||||
self.saveWiki({
|
||||
method: "download",
|
||||
@ -82,7 +78,7 @@ function SaverHandler(options) {
|
||||
}
|
||||
}
|
||||
|
||||
SaverHandler.prototype.titleSyncFilter = "$:/config/SyncFilter";
|
||||
SaverHandler.prototype.titleSyncFilter = "$:/config/SaverFilter";
|
||||
SaverHandler.prototype.titleAutoSave = "$:/config/AutoSave";
|
||||
SaverHandler.prototype.titleSavedNotification = "$:/language/Notifications/Save/Done";
|
||||
|
||||
@ -115,7 +111,7 @@ SaverHandler.prototype.initSavers = function(moduleType) {
|
||||
|
||||
/*
|
||||
Save the wiki contents. Options are:
|
||||
method: "save" or "download"
|
||||
method: "save", "autosave" or "download"
|
||||
template: the tiddler containing the template to save
|
||||
downloadType: the content type for the saved file
|
||||
*/
|
||||
@ -130,6 +126,11 @@ SaverHandler.prototype.saveWiki = function(options) {
|
||||
if(err) {
|
||||
alert("Error while saving:\n\n" + err);
|
||||
} else {
|
||||
// Clear the task queue if we're saving (rather than downloading)
|
||||
if(method !== "download") {
|
||||
self.numTasksInQueue = 0;
|
||||
self.updateDirtyStatus();
|
||||
}
|
||||
$tw.notifier.display(self.titleSavedNotification);
|
||||
if(options.callback) {
|
||||
options.callback();
|
||||
@ -145,11 +146,6 @@ SaverHandler.prototype.saveWiki = function(options) {
|
||||
var saver = this.savers[t];
|
||||
if(saver.info.capabilities.indexOf(method) !== -1 && saver.save(text,method,callback)) {
|
||||
this.logger.log("Saving wiki with method",method,"through saver",saver.info.name);
|
||||
// Clear the task queue if we're saving (rather than downloading)
|
||||
if(method !== "download") {
|
||||
this.numTasksInQueue = 0;
|
||||
this.updateDirtyStatus();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,8 @@ DownloadSaver.prototype.save = function(text,method,callback) {
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
// Callback that we succeeded
|
||||
callback(null);
|
||||
return true;
|
||||
};
|
||||
|
||||
|
@ -33,14 +33,16 @@ FSOSaver.prototype.save = function(text,method,callback) {
|
||||
pathname = pathname.substr(1);
|
||||
// reconstruct UNC path
|
||||
pathname = "\\\\" + document.location.hostname + pathname;
|
||||
} else return false;
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
// Save the file (as UTF-16)
|
||||
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
||||
var file = fso.OpenTextFile(pathname,2,-1,-1);
|
||||
|
||||
file.Write(text);
|
||||
file.Close();
|
||||
// Callback that we succeeded
|
||||
callback(null);
|
||||
return true;
|
||||
};
|
||||
|
||||
|
@ -25,6 +25,8 @@ ManualDownloadSaver.prototype.save = function(text,method,callback) {
|
||||
$tw.modal.display(downloadInstructionsTitle,{
|
||||
downloadLink: "data:text/html," + encodeURIComponent(text)
|
||||
});
|
||||
// Callback that we succeeded
|
||||
callback(null);
|
||||
return true;
|
||||
};
|
||||
|
||||
|
@ -28,6 +28,8 @@ MsDownloadSaver.prototype.save = function(text,method,callback) {
|
||||
// Set up the link
|
||||
var blob = new Blob([text], {type: "text/html"});
|
||||
window.navigator.msSaveBlob(blob,filename);
|
||||
// Callback that we succeeded
|
||||
callback(null);
|
||||
return true;
|
||||
};
|
||||
|
||||
|
@ -43,7 +43,6 @@ TiddlyFoxSaver.prototype.save = function(text,method,callback) {
|
||||
}
|
||||
// Create the message element and put it in the message box
|
||||
var message = document.createElement("div");
|
||||
console.log("Pathname",pathname);
|
||||
message.setAttribute("data-tiddlyfox-path",decodeURIComponent(pathname));
|
||||
message.setAttribute("data-tiddlyfox-content",text);
|
||||
messageBox.appendChild(message);
|
||||
|
@ -35,9 +35,10 @@ TiddlyIESaver.prototype.save = function(text,method,callback) {
|
||||
// reconstruct UNC path
|
||||
pathname = "\\\\" + document.location.hostname + pathname;
|
||||
} else return false;
|
||||
|
||||
// Prompt the user to save the file
|
||||
window.TiddlyIE.save(pathname, text);
|
||||
// Callback that we succeeded
|
||||
callback(null);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -71,8 +71,6 @@ exports.repackPlugin = function(title,additionalTiddlers,excludeTiddlers) {
|
||||
$tw.wiki.deleteTiddler(title);
|
||||
}
|
||||
});
|
||||
// Trigger an autosave
|
||||
$tw.rootWidget.dispatchEvent({type: "tw-auto-save-wiki"});
|
||||
// Return a heartwarming confirmation
|
||||
return "Plugin " + title + " successfully saved";
|
||||
}
|
||||
|
@ -243,8 +243,6 @@ NavigatorWidget.prototype.handleDeleteTiddlerEvent = function(event) {
|
||||
// Remove the closed tiddler from the story
|
||||
this.removeTitleFromStory(storyList,title);
|
||||
this.saveStoryList(storyList);
|
||||
// Send a notification event
|
||||
this.dispatchEvent({type: "tw-auto-save-wiki"});
|
||||
return false;
|
||||
};
|
||||
|
||||
@ -333,8 +331,6 @@ NavigatorWidget.prototype.handleSaveTiddlerEvent = function(event) {
|
||||
if(draftTitle !== this.storyTitle) {
|
||||
this.saveStoryList(storyList);
|
||||
}
|
||||
// Send a notification event
|
||||
this.dispatchEvent({type: "tw-auto-save-wiki"});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -376,13 +372,8 @@ NavigatorWidget.prototype.handleNewTiddlerEvent = function(event) {
|
||||
var storyList = this.getStoryList();
|
||||
// Get the template tiddler if there is one
|
||||
var templateTiddler = this.wiki.getTiddler(event.param);
|
||||
// Create the new tiddler
|
||||
// Title the new tiddler
|
||||
var title = this.wiki.generateNewTitle((templateTiddler && templateTiddler.fields.title) || "New Tiddler");
|
||||
var tiddler = new $tw.Tiddler(this.wiki.getCreationFields(),{
|
||||
text: "Newly created tiddler",
|
||||
title: title
|
||||
},this.wiki.getModificationFields());
|
||||
this.wiki.addTiddler(tiddler);
|
||||
// Create the draft tiddler
|
||||
var draftTitle = this.generateDraftTitle(title),
|
||||
draftTiddler = new $tw.Tiddler({
|
||||
@ -487,8 +478,6 @@ NavigatorWidget.prototype.handlePerformImportEvent = function(event) {
|
||||
}));
|
||||
// Navigate to the $:/Import tiddler
|
||||
this.addToHistory([IMPORT_TITLE]);
|
||||
// Send a notification event
|
||||
this.dispatchEvent({type: "tw-auto-save-wiki"});
|
||||
};
|
||||
|
||||
exports.navigator = NavigatorWidget;
|
||||
|
3
core/wiki/config/SaverFilter.tid
Normal file
3
core/wiki/config/SaverFilter.tid
Normal file
@ -0,0 +1,3 @@
|
||||
title: $:/config/SaverFilter
|
||||
|
||||
[!is[shadow]] -[[$:/HistoryList]] -[[$:/StoryList]] -[[$:/Import]] -[[$:/isEncrypted]] -[prefix[$:/status]] -[prefix[$:/state]] -[prefix[$:/temp]] -[has[draft.of]]
|
@ -1,13 +1,34 @@
|
||||
title: HelloThere
|
||||
|
||||
This is a demo of TiddlyWiki5 incorporating a plugin for the [[markdown-js|https://github.com/evilstreak/markdown-js]] Markdown parser from Dominic Baggott.
|
||||
This is a demo of TiddlyWiki5 incorporating a plugin for the [[markdown-js|https://github.com/evilstreak/markdown-js]] Markdown parser from Dominic Baggott. The MarkdownExample tiddler below is written in Markdown.
|
||||
|
||||
The MarkdownExample tiddler below is written in Markdown. Create wiki links with the usual Markdown link syntax targeting `#` and the target tiddler title:
|
||||
! Installation
|
||||
|
||||
To add the plugin to your own TiddlyWiki5, just drag this link to the browser window:
|
||||
|
||||
[[$:/plugins/tiddlywiki/markdown]]
|
||||
|
||||
! Markdown Dialects
|
||||
|
||||
By default the markdown parser recognises the original dialect of Markdown [[as described by John Gruber|http://daringfireball.net/projects/markdown/]]. An extended dialect called "Maruku" is also included that provides table support and other advanced features. The syntax extensions are modelled on those of [[PHP Markdown Extra|https://michelf.ca/projects/php-markdown/extra/]].
|
||||
|
||||
The configuration tiddler [[$:/config/markdown/dialect]] determines which dialect is used:
|
||||
|
||||
|!Dialect |!Description |
|
||||
|Gruber |Standard Markdown |
|
||||
|Maruku |Extended Maruku Markdown |
|
||||
|
||||
|
||||
! Creating ~WikiLinks
|
||||
|
||||
Create wiki links with the usual Markdown link syntax targeting `#` and the target tiddler title:
|
||||
|
||||
```
|
||||
[link text](#TiddlerTitle)
|
||||
```
|
||||
|
||||
! Images
|
||||
|
||||
Markdown image syntax can be used to reference images by tiddler title or an external URI. For example:
|
||||
|
||||
```
|
||||
@ -15,8 +36,3 @@ Markdown image syntax can be used to reference images by tiddler title or an ext
|
||||
|
||||
![alt text](Motovun Jack.jpg "Title")
|
||||
```
|
||||
|
||||
To add the plugin to your own TiddlyWiki5, just drag this link to the browser window:
|
||||
|
||||
[[$:/plugins/tiddlywiki/markdown]]
|
||||
|
||||
|
@ -9,7 +9,7 @@ type: text/vnd.tiddlywiki
|
||||
|
||||
!! Usability Improvements
|
||||
|
||||
*
|
||||
* [[Amended|https://github.com/Jermolene/TiddlyWiki5/commit/e47852cb141b384ad2a9097eca795545cb5b2494]] behaviour of the [[tw-browser-refresh|WidgetMessage: tw-browser-refresh]] message so that it no longer clears the location hash
|
||||
|
||||
!! Hackability Improvements
|
||||
|
||||
|
@ -183,7 +183,6 @@ $body$
|
||||
">>
|
||||
## <<toc-heading "Widget Messages" "
|
||||
## WidgetMessages
|
||||
## [[tw-auto-save-wiki|WidgetMessage: tw-auto-save-wiki]]
|
||||
## [[tw-cancel-tiddler|WidgetMessage: tw-cancel-tiddler]]
|
||||
## [[tw-clear-password|WidgetMessage: tw-clear-password]]
|
||||
## [[tw-close-all-tiddlers|WidgetMessage: tw-close-all-tiddlers]]
|
||||
|
@ -1,11 +0,0 @@
|
||||
created: 20140811112343634
|
||||
modified: 20140811114420597
|
||||
tags: message
|
||||
title: WidgetMessage: tw-auto-save-wiki
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
The autosave wiki message causes the current saver module to perform a background save if it is required.
|
||||
|
||||
The autosave wiki message should be generated whenever changes are made to the store. For example, the navigator widget generates the autosave wiki message as part of its handling of the [[WidgetMessage: tw-save-tiddler]], [[WidgetMessage: tw-delete-tiddler]] and [[WidgetMessage: tw-perform-import]].
|
||||
|
||||
The autosave wiki message is handled by the TiddlyWiki core SyncMechanism which invokes the current [[SaverModule|SaverModules]]. Not all SaverModules can handle autosaving.
|
@ -4,7 +4,7 @@ tags: message
|
||||
title: WidgetMessage: tw-save-wiki
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
The save wiki message causes the current saver module to perform a full save operation. The save operation can involve user interaction, unlike the [[WidgetMessage: tw-auto-save-wiki]]/
|
||||
The save wiki message causes the current saver module to perform a full save operation. The save operation can involve user interaction.
|
||||
|
||||
The save wiki message is usually generated by the ButtonWidget.
|
||||
|
||||
|
3
plugins/tiddlywiki/markdown/dialect.tid
Normal file
3
plugins/tiddlywiki/markdown/dialect.tid
Normal file
@ -0,0 +1,3 @@
|
||||
title: $:/config/markdown/dialect
|
||||
|
||||
Gruber
|
@ -14,6 +14,9 @@ Wraps up the markdown-js parser for use in TiddlyWiki5
|
||||
|
||||
var markdown = require("$:/plugins/tiddlywiki/markdown/markdown.js");
|
||||
|
||||
var CONFIG_DIALECT_TIDDLER = "$:/config/markdown/dialect",
|
||||
DEFAULT_DIALECT = "Gruber";
|
||||
|
||||
function transformNodes(nodes) {
|
||||
var results = [];
|
||||
for(var index=0; index<nodes.length; index++) {
|
||||
@ -52,7 +55,8 @@ function transformNode(node) {
|
||||
}
|
||||
|
||||
var MarkdownParser = function(type,text,options) {
|
||||
var markdownTree = markdown.toHTMLTree(text);
|
||||
var dialect = options.wiki.getTiddlerText(CONFIG_DIALECT_TIDDLER,DEFAULT_DIALECT),
|
||||
markdownTree = markdown.toHTMLTree(text,dialect);
|
||||
this.tree = transformNodes(markdownTree.slice(1));
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user