mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-06-26 07:13:15 +00:00
Merge branch 'master' into publishing-framework
This commit is contained in:
commit
f1d76a1eee
|
@ -1173,7 +1173,7 @@ $tw.Wiki = function(options) {
|
||||||
var index = tiddlerTitles.indexOf(title);
|
var index = tiddlerTitles.indexOf(title);
|
||||||
if(index !== -1) {
|
if(index !== -1) {
|
||||||
tiddlerTitles.splice(index,1);
|
tiddlerTitles.splice(index,1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Record the new tiddler state
|
// Record the new tiddler state
|
||||||
updateDescriptor["new"] = {
|
updateDescriptor["new"] = {
|
||||||
|
@ -1320,7 +1320,7 @@ $tw.Wiki = function(options) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(pluginInfo[title]) {
|
if(pluginInfo[title]) {
|
||||||
delete pluginInfo[title];
|
delete pluginInfo[title];
|
||||||
results.deletedPlugins.push(title);
|
results.deletedPlugins.push(title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1959,7 +1959,7 @@ $tw.loadTiddlersFromSpecification = function(filepath,excludeRegExp) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log("Warning: a directory in a tiddlywiki.files file does not exist.");
|
console.log("Warning: a directory in a tiddlywiki.files file does not exist.");
|
||||||
console.log("dirPath: " + dirPath);
|
console.log("dirPath: " + dirPath);
|
||||||
console.log("tiddlywiki.files location: " + filepath);
|
console.log("tiddlywiki.files location: " + filepath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2218,7 +2218,7 @@ $tw.loadTiddlersNode = function() {
|
||||||
type = parts[0];
|
type = parts[0];
|
||||||
if(parts.length === 3 && ["plugins","themes","languages"].indexOf(type) !== -1) {
|
if(parts.length === 3 && ["plugins","themes","languages"].indexOf(type) !== -1) {
|
||||||
$tw.loadPlugins([parts[1] + "/" + parts[2]],$tw.config[type + "Path"],$tw.config[type + "EnvVar"]);
|
$tw.loadPlugins([parts[1] + "/" + parts[2]],$tw.config[type + "Path"],$tw.config[type + "EnvVar"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Load the tiddlers from the wiki directory
|
// Load the tiddlers from the wiki directory
|
||||||
|
|
|
@ -130,7 +130,7 @@ Saving/TiddlySpot/Filename: Upload Filename
|
||||||
Saving/TiddlySpot/Heading: ~TiddlySpot
|
Saving/TiddlySpot/Heading: ~TiddlySpot
|
||||||
Saving/TiddlySpot/Hint: //The server URL defaults to `http://<wikiname>.tiddlyspot.com/store.cgi` and can be changed to use a custom server address, e.g. `http://example.com/store.php`.//
|
Saving/TiddlySpot/Hint: //The server URL defaults to `http://<wikiname>.tiddlyspot.com/store.cgi` and can be changed to use a custom server address, e.g. `http://example.com/store.php`.//
|
||||||
Saving/TiddlySpot/Password: Password
|
Saving/TiddlySpot/Password: Password
|
||||||
Saving/TiddlySpot/ReadOnly: Note that [[TiddlySpot|http://tiddlyspot.com]] no longer allows the creation of new sites. For new sites you can use [[TiddlyHost|https://tiddlyhost.com]], a new hosting service which replaces ~TiddlySpot.
|
Saving/TiddlySpot/ReadOnly: Note that [[TiddlySpot|http://tiddlyspot.com]] no longer allows the creation of new sites. For new sites, you can use [[TiddlyHost|https://tiddlyhost.com]], a new hosting service that replaces ~TiddlySpot.
|
||||||
Saving/TiddlySpot/ServerURL: Server URL
|
Saving/TiddlySpot/ServerURL: Server URL
|
||||||
Saving/TiddlySpot/UploadDir: Upload Directory
|
Saving/TiddlySpot/UploadDir: Upload Directory
|
||||||
Saving/TiddlySpot/UserName: Wiki Name
|
Saving/TiddlySpot/UserName: Wiki Name
|
||||||
|
|
|
@ -3,6 +3,8 @@ title: $:/language/EditTemplate/
|
||||||
Body/External/Hint: This tiddler shows content stored outside of the main TiddlyWiki file. You can edit the tags and fields but cannot directly edit the content itself
|
Body/External/Hint: This tiddler shows content stored outside of the main TiddlyWiki file. You can edit the tags and fields but cannot directly edit the content itself
|
||||||
Body/Placeholder: Type the text for this tiddler
|
Body/Placeholder: Type the text for this tiddler
|
||||||
Body/Preview/Type/Output: output
|
Body/Preview/Type/Output: output
|
||||||
|
Body/Preview/Type/DiffShadow: differences from shadow (if any)
|
||||||
|
Body/Preview/Type/DiffCurrent: differences from current
|
||||||
Field/Remove/Caption: remove field
|
Field/Remove/Caption: remove field
|
||||||
Field/Remove/Hint: Remove field
|
Field/Remove/Hint: Remove field
|
||||||
Field/Dropdown/Caption: field list
|
Field/Dropdown/Caption: field list
|
||||||
|
|
|
@ -19,8 +19,8 @@ All parameters are optional with safe defaults, and can be specified in any orde
|
||||||
* ''username'' - optional username for basic authentication
|
* ''username'' - optional username for basic authentication
|
||||||
* ''password'' - optional password for basic authentication
|
* ''password'' - optional password for basic authentication
|
||||||
* ''authenticated-user-header'' - optional name of header to be used for trusted authentication
|
* ''authenticated-user-header'' - optional name of header to be used for trusted authentication
|
||||||
* ''readers'' - comma separated list of principals allowed to read from this wiki
|
* ''readers'' - comma-separated list of principals allowed to read from this wiki
|
||||||
* ''writers'' - comma separated list of principals allowed to write to this wiki
|
* ''writers'' - comma-separated list of principals allowed to write to this wiki
|
||||||
* ''csrf-disable'' - set to "yes" to disable CSRF checks (defaults to "no")
|
* ''csrf-disable'' - set to "yes" to disable CSRF checks (defaults to "no")
|
||||||
* ''sse-enabled'' - set to "yes" to enable Server-sent events (defaults to "no")
|
* ''sse-enabled'' - set to "yes" to enable Server-sent events (defaults to "no")
|
||||||
* ''sitemap'' - optional sitemap describing how the tiddlers will be served. See [[Publishing]] for more details
|
* ''sitemap'' - optional sitemap describing how the tiddlers will be served. See [[Publishing]] for more details
|
||||||
|
@ -31,7 +31,7 @@ All parameters are optional with safe defaults, and can be specified in any orde
|
||||||
* ''tls-key'' - pathname of TLS key file (relative to wiki folder)
|
* ''tls-key'' - pathname of TLS key file (relative to wiki folder)
|
||||||
* ''debug-level'' - optional debug level; set to "debug" to view request details (defaults to "none")
|
* ''debug-level'' - optional debug level; set to "debug" to view request details (defaults to "none")
|
||||||
* ''gzip'' - set to "yes" to enable gzip compression for some http endpoints (defaults to "no")
|
* ''gzip'' - set to "yes" to enable gzip compression for some http endpoints (defaults to "no")
|
||||||
* ''use-browser-cache'' - set to "yes" to allow the browser to cache responses to save bandwith (defaults to "no")
|
* ''use-browser-cache'' - set to "yes" to allow the browser to cache responses to save bandwidth (defaults to "no")
|
||||||
|
|
||||||
For information on opening up your instance to the entire local network, and possible security concerns, see the WebServer tiddler at TiddlyWiki.com.
|
For information on opening up your instance to the entire local network, and possible security concerns, see the WebServer tiddler at TiddlyWiki.com.
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ Notes:
|
||||||
|
|
||||||
* The output directory is not cleared of any existing files
|
* The output directory is not cleared of any existing files
|
||||||
* Any missing directories in the path to the filename are automatically created.
|
* Any missing directories in the path to the filename are automatically created.
|
||||||
* When referring to a tiddler with spaces in its title, take care to use both the quotes required by your shell and also TiddlyWiki's double square brackets : `--render "[[Motovun Jack.jpg]]"`
|
* When referring to a tiddler with spaces in its title, take care to use both the quotes required by your shell and also TiddlyWiki's double square brackets: `--render "[[Motovun Jack.jpg]]"`
|
||||||
* The filename filter is evaluated with the selected items being set to the title of the tiddler currently being rendered, allowing the title to be used as the basis for computing the filename. For example `[encodeuricomponent[]addprefix[static/]]` applies URI encoding to each title, and then adds the prefix `static/`
|
* The filename filter is evaluated with the selected items being set to the title of the tiddler currently being rendered, allowing the title to be used as the basis for computing the filename. For example `[encodeuricomponent[]addprefix[static/]]` applies URI encoding to each title, and then adds the prefix `static/`
|
||||||
* Multiple ''name''/''value'' pairs can be used to pass more than one variable
|
* Multiple ''name''/''value'' pairs can be used to pass more than one variable
|
||||||
* The `--render` command is a more flexible replacement for both the `--rendertiddler` and `--rendertiddlers` commands, which are deprecated
|
* The `--render` command is a more flexible replacement for both the `--rendertiddler` and `--rendertiddlers` commands, which are deprecated
|
||||||
|
|
|
@ -16,7 +16,7 @@ Notes:
|
||||||
|
|
||||||
* The output directory is not cleared of any existing files
|
* The output directory is not cleared of any existing files
|
||||||
* Any missing directories in the path to the filename are automatically created.
|
* Any missing directories in the path to the filename are automatically created.
|
||||||
* When saving a tiddler with spaces in its title, take care to use both the quotes required by your shell and also TiddlyWiki's double square brackets : `--save "[[Motovun Jack.jpg]]"`
|
* When saving a tiddler with spaces in its title, take care to use both the quotes required by your shell and also TiddlyWiki's double square brackets: `--save "[[Motovun Jack.jpg]]"`
|
||||||
* The filename filter is evaluated with the selected items being set to the title of the tiddler currently being saved, allowing the title to be used as the basis for computing the filename. For example `[encodeuricomponent[]addprefix[static/]]` applies URI encoding to each title, and then adds the prefix `static/`
|
* The filename filter is evaluated with the selected items being set to the title of the tiddler currently being saved, allowing the title to be used as the basis for computing the filename. For example `[encodeuricomponent[]addprefix[static/]]` applies URI encoding to each title, and then adds the prefix `static/`
|
||||||
* The `--save` command is a more flexible replacement for both the `--savetiddler` and `--savetiddlers` commands, which are deprecated
|
* The `--save` command is a more flexible replacement for both the `--savetiddler` and `--savetiddlers` commands, which are deprecated
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
title: $:/language/Import/
|
title: $:/language/Import/
|
||||||
|
|
||||||
Editor/Import/Heading: Import images and insert into the editor.
|
Editor/Import/Heading: Import images and insert them into the editor.
|
||||||
Imported/Hint: The following tiddlers were imported:
|
Imported/Hint: The following tiddlers were imported:
|
||||||
Listing/Cancel/Caption: Cancel
|
Listing/Cancel/Caption: Cancel
|
||||||
Listing/Hint: These tiddlers are ready to import:
|
Listing/Hint: These tiddlers are ready to import:
|
||||||
|
@ -23,7 +23,11 @@ Upgrader/Plugins/Suppressed/Incompatible: Blocked incompatible or obsolete plugi
|
||||||
Upgrader/Plugins/Suppressed/Version: Blocked plugin (due to incoming <<incoming>> not being newer than existing <<existing>>).
|
Upgrader/Plugins/Suppressed/Version: Blocked plugin (due to incoming <<incoming>> not being newer than existing <<existing>>).
|
||||||
Upgrader/Plugins/Upgraded: Upgraded plugin from <<incoming>> to <<upgraded>>.
|
Upgrader/Plugins/Upgraded: Upgraded plugin from <<incoming>> to <<upgraded>>.
|
||||||
Upgrader/State/Suppressed: Blocked temporary state tiddler.
|
Upgrader/State/Suppressed: Blocked temporary state tiddler.
|
||||||
|
Upgrader/System/Disabled: Disabled system tiddler.
|
||||||
Upgrader/System/Suppressed: Blocked system tiddler.
|
Upgrader/System/Suppressed: Blocked system tiddler.
|
||||||
Upgrader/System/Warning: Core module tiddler.
|
Upgrader/System/Warning: Core module tiddler.
|
||||||
Upgrader/System/Alert: You are about to import a tiddler that will overwrite a core module tiddler. This is not recommended as it may make the system unstable.
|
Upgrader/System/Alert: You are about to import a tiddler that will overwrite a core module tiddler. This is not recommended as it may make the system unstable.
|
||||||
Upgrader/ThemeTweaks/Created: Migrated theme tweak from <$text text=<<from>>/>.
|
Upgrader/ThemeTweaks/Created: Migrated theme tweak from <$text text=<<from>>/>.
|
||||||
|
Upgrader/Tiddler/Disabled: Disabled tiddler.
|
||||||
|
Upgrader/Tiddler/Selected: User selected.
|
||||||
|
Upgrader/Tiddler/Unselected: Unselected tiddler.
|
||||||
|
|
|
@ -154,7 +154,7 @@ Commander.prototype.extractNamedParameters = function(params,mandatoryParameters
|
||||||
if(errors.length > 0) {
|
if(errors.length > 0) {
|
||||||
return errors.join(" and\n");
|
return errors.join(" and\n");
|
||||||
} else {
|
} else {
|
||||||
return paramsByName;
|
return paramsByName;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ Command.prototype.fetchFile = function(url,options,callback,redirectCount) {
|
||||||
if(response.statusCode === 302 || response.statusCode === 303 || response.statusCode === 307) {
|
if(response.statusCode === 302 || response.statusCode === 303 || response.statusCode === 307) {
|
||||||
return self.fetchFile(response.headers.location,options,callback,redirectCount + 1);
|
return self.fetchFile(response.headers.location,options,callback,redirectCount + 1);
|
||||||
} else {
|
} else {
|
||||||
return callback("Error " + response.statusCode + " retrieving " + url)
|
return callback("Error " + response.statusCode + " retrieving " + url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -36,7 +36,7 @@ Command.prototype.execute = function() {
|
||||||
filter = this.params[0],
|
filter = this.params[0],
|
||||||
template = this.params[1],
|
template = this.params[1],
|
||||||
outputPath = this.commander.outputPath,
|
outputPath = this.commander.outputPath,
|
||||||
pathname = path.resolve(outputPath,this.params[2]),
|
pathname = path.resolve(outputPath,this.params[2]),
|
||||||
type = this.params[3] || "text/html",
|
type = this.params[3] || "text/html",
|
||||||
extension = this.params[4] || ".html",
|
extension = this.params[4] || ".html",
|
||||||
deleteDirectory = (this.params[5] || "").toLowerCase() !== "noclean",
|
deleteDirectory = (this.params[5] || "").toLowerCase() !== "noclean",
|
||||||
|
|
|
@ -97,7 +97,7 @@ WikiFolderMaker.prototype.save = function() {
|
||||||
// A custom plugin
|
// A custom plugin
|
||||||
self.log("Processing custom plugin: " + title);
|
self.log("Processing custom plugin: " + title);
|
||||||
self.saveCustomPlugin(tiddler);
|
self.saveCustomPlugin(tiddler);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Ordinary tiddler
|
// Ordinary tiddler
|
||||||
self.saveTiddler("tiddlers",tiddler);
|
self.saveTiddler("tiddlers",tiddler);
|
||||||
|
|
|
@ -34,7 +34,7 @@ exports.htmlEntities = {quot:34, amp:38, apos:39, lt:60, gt:62, nbsp:160, iexcl:
|
||||||
|
|
||||||
exports.htmlVoidElements = "area,base,br,col,command,embed,hr,img,input,keygen,link,meta,param,source,track,wbr".split(",");
|
exports.htmlVoidElements = "area,base,br,col,command,embed,hr,img,input,keygen,link,meta,param,source,track,wbr".split(",");
|
||||||
|
|
||||||
exports.htmlBlockElements = "address,article,aside,audio,blockquote,canvas,dd,div,dl,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,li,noscript,ol,output,p,pre,section,table,tfoot,ul,video".split(",");
|
exports.htmlBlockElements = "address,article,aside,audio,blockquote,canvas,dd,details,div,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,li,nav,ol,p,pre,section,summary,table,tfoot,ul,video".split(",");
|
||||||
|
|
||||||
exports.htmlUnsafeElements = "script".split(",");
|
exports.htmlUnsafeElements = "script".split(",");
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ var parseTiddlerDiv = function(text /* [,fields] */) {
|
||||||
for(var f=1; f<arguments.length; f++) {
|
for(var f=1; f<arguments.length; f++) {
|
||||||
var fields = arguments[f];
|
var fields = arguments[f];
|
||||||
for(var t in fields) {
|
for(var t in fields) {
|
||||||
result[t] = fields[t];
|
result[t] = fields[t];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ function FramedEngine(options) {
|
||||||
}
|
}
|
||||||
if(this.widget.isDisabled === "yes") {
|
if(this.widget.isDisabled === "yes") {
|
||||||
this.domNode.setAttribute("disabled",true);
|
this.domNode.setAttribute("disabled",true);
|
||||||
}
|
}
|
||||||
// Copy the styles from the dummy textarea
|
// Copy the styles from the dummy textarea
|
||||||
this.copyStyles();
|
this.copyStyles();
|
||||||
// Add event listeners
|
// Add event listeners
|
||||||
|
@ -87,7 +87,6 @@ function FramedEngine(options) {
|
||||||
{name: "input",handlerObject: this,handlerMethod: "handleInputEvent"},
|
{name: "input",handlerObject: this,handlerMethod: "handleInputEvent"},
|
||||||
{name: "keydown",handlerObject: this.widget,handlerMethod: "handleKeydownEvent"},
|
{name: "keydown",handlerObject: this.widget,handlerMethod: "handleKeydownEvent"},
|
||||||
{name: "focus",handlerObject: this,handlerMethod: "handleFocusEvent"}
|
{name: "focus",handlerObject: this,handlerMethod: "handleFocusEvent"}
|
||||||
|
|
||||||
]);
|
]);
|
||||||
// Add drag and drop event listeners if fileDrop is enabled
|
// Add drag and drop event listeners if fileDrop is enabled
|
||||||
if(this.widget.isFileDropEnabled) {
|
if(this.widget.isFileDropEnabled) {
|
||||||
|
@ -183,7 +182,7 @@ Handle a focus event
|
||||||
*/
|
*/
|
||||||
FramedEngine.prototype.handleFocusEvent = function(event) {
|
FramedEngine.prototype.handleFocusEvent = function(event) {
|
||||||
if(this.widget.editCancelPopups) {
|
if(this.widget.editCancelPopups) {
|
||||||
$tw.popup.cancel(0);
|
$tw.popup.cancel(0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -313,7 +313,7 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) {
|
||||||
});
|
});
|
||||||
return newEvent;
|
return newEvent;
|
||||||
};
|
};
|
||||||
|
|
||||||
EditTextWidget.prototype.dispatchDOMEvent = function(newEvent) {
|
EditTextWidget.prototype.dispatchDOMEvent = function(newEvent) {
|
||||||
var dispatchNode = this.engine.iframeNode || this.engine.parentNode;
|
var dispatchNode = this.engine.iframeNode || this.engine.parentNode;
|
||||||
return dispatchNode.dispatchEvent(newEvent);
|
return dispatchNode.dispatchEvent(newEvent);
|
||||||
|
@ -358,7 +358,7 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
event.dataTransfer.dropEffect = "copy";
|
event.dataTransfer.dropEffect = "copy";
|
||||||
return this.dispatchDOMEvent(this.cloneEvent(event,["dataTransfer"]));
|
return this.dispatchDOMEvent(this.cloneEvent(event,["dataTransfer"]));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
@ -375,13 +375,12 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) {
|
||||||
EditTextWidget.prototype.handleDragEndEvent = function(event) {
|
EditTextWidget.prototype.handleDragEndEvent = function(event) {
|
||||||
this.dispatchDOMEvent(this.cloneEvent(event));
|
this.dispatchDOMEvent(this.cloneEvent(event));
|
||||||
};
|
};
|
||||||
|
|
||||||
EditTextWidget.prototype.handleClickEvent = function(event) {
|
EditTextWidget.prototype.handleClickEvent = function(event) {
|
||||||
return !this.dispatchDOMEvent(this.cloneEvent(event));
|
return !this.dispatchDOMEvent(this.cloneEvent(event));
|
||||||
};
|
};
|
||||||
|
|
||||||
return EditTextWidget;
|
return EditTextWidget;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.editTextWidgetFactory = editTextWidgetFactory;
|
exports.editTextWidgetFactory = editTextWidgetFactory;
|
||||||
|
|
23
core/modules/editor/operations/text/insert-text.js
Normal file
23
core/modules/editor/operations/text/insert-text.js
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/*\
|
||||||
|
title: $:/core/modules/editor/operations/text/insert-text.js
|
||||||
|
type: application/javascript
|
||||||
|
module-type: texteditoroperation
|
||||||
|
|
||||||
|
Text editor operation insert text at the caret position. If there is a selection it is replaced.
|
||||||
|
|
||||||
|
\*/
|
||||||
|
(function(){
|
||||||
|
|
||||||
|
/*jslint node: true, browser: true */
|
||||||
|
/*global $tw: false */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
exports["insert-text"] = function(event,operation) {
|
||||||
|
operation.replacement = event.paramObject.text;
|
||||||
|
operation.cutStart = operation.selStart;
|
||||||
|
operation.cutEnd = operation.selEnd;
|
||||||
|
operation.newSelStart = operation.selStart + operation.replacement.length;
|
||||||
|
operation.newSelEnd = operation.newSelStart;
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
|
@ -17,10 +17,21 @@ exports.filter = function(operationSubFunction,options) {
|
||||||
return function(results,source,widget) {
|
return function(results,source,widget) {
|
||||||
if(results.length > 0) {
|
if(results.length > 0) {
|
||||||
var resultsToRemove = [];
|
var resultsToRemove = [];
|
||||||
results.each(function(result) {
|
results.each(function(title) {
|
||||||
var filtered = operationSubFunction(options.wiki.makeTiddlerIterator([result]),widget);
|
var filtered = operationSubFunction(options.wiki.makeTiddlerIterator([title]),{
|
||||||
|
getVariable: function(name) {
|
||||||
|
switch(name) {
|
||||||
|
case "currentTiddler":
|
||||||
|
return "" + title;
|
||||||
|
case "..currentTiddler":
|
||||||
|
return widget.getVariable("currentTiddler");
|
||||||
|
default:
|
||||||
|
return widget.getVariable(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
if(filtered.length === 0) {
|
if(filtered.length === 0) {
|
||||||
resultsToRemove.push(result);
|
resultsToRemove.push(title);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
results.remove(resultsToRemove);
|
results.remove(resultsToRemove);
|
||||||
|
|
|
@ -19,30 +19,32 @@ exports.reduce = function(operationSubFunction,options) {
|
||||||
var index = 0;
|
var index = 0;
|
||||||
results.each(function(title) {
|
results.each(function(title) {
|
||||||
var list = operationSubFunction(options.wiki.makeTiddlerIterator([title]),{
|
var list = operationSubFunction(options.wiki.makeTiddlerIterator([title]),{
|
||||||
getVariable: function(name) {
|
getVariable: function(name) {
|
||||||
switch(name) {
|
switch(name) {
|
||||||
case "currentTiddler":
|
case "currentTiddler":
|
||||||
return "" + title;
|
return "" + title;
|
||||||
case "accumulator":
|
case "..currentTiddler":
|
||||||
return "" + accumulator;
|
return widget.getVariable("currentTiddler");
|
||||||
case "index":
|
case "accumulator":
|
||||||
return "" + index;
|
return "" + accumulator;
|
||||||
case "revIndex":
|
case "index":
|
||||||
return "" + (results.length - 1 - index);
|
return "" + index;
|
||||||
case "length":
|
case "revIndex":
|
||||||
return "" + results.length;
|
return "" + (results.length - 1 - index);
|
||||||
default:
|
case "length":
|
||||||
return widget.getVariable(name);
|
return "" + results.length;
|
||||||
}
|
default:
|
||||||
|
return widget.getVariable(name);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
if(list.length > 0) {
|
if(list.length > 0) {
|
||||||
accumulator = "" + list[0];
|
accumulator = "" + list[0];
|
||||||
}
|
}
|
||||||
++index;
|
++index;
|
||||||
});
|
});
|
||||||
results.clear();
|
results.clear();
|
||||||
results.push(accumulator);
|
results.push(accumulator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,18 +23,20 @@ exports.sort = function(operationSubFunction,options) {
|
||||||
inputTitles = results.toArray(),
|
inputTitles = results.toArray(),
|
||||||
sortKeys = [],
|
sortKeys = [],
|
||||||
indexes = new Array(inputTitles.length),
|
indexes = new Array(inputTitles.length),
|
||||||
compareFn;
|
compareFn;
|
||||||
results.each(function(title) {
|
results.each(function(title) {
|
||||||
var key = operationSubFunction(options.wiki.makeTiddlerIterator([title]),{
|
var key = operationSubFunction(options.wiki.makeTiddlerIterator([title]),{
|
||||||
getVariable: function(name) {
|
getVariable: function(name) {
|
||||||
switch(name) {
|
switch(name) {
|
||||||
case "currentTiddler":
|
case "currentTiddler":
|
||||||
return "" + title;
|
return "" + title;
|
||||||
default:
|
case "..currentTiddler":
|
||||||
return widget.getVariable(name);
|
return widget.getVariable("currentTiddler");
|
||||||
}
|
default:
|
||||||
|
return widget.getVariable(name);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
sortKeys.push(key[0] || "");
|
sortKeys.push(key[0] || "");
|
||||||
});
|
});
|
||||||
results.clear();
|
results.clear();
|
||||||
|
|
|
@ -101,10 +101,10 @@ function parseFilterOperation(operators,filterString,p) {
|
||||||
}
|
}
|
||||||
p = nextBracketPos + 1;
|
p = nextBracketPos + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = nextBracketPos + 1;
|
p = nextBracketPos + 1;
|
||||||
parseOperand(bracket);
|
parseOperand(bracket);
|
||||||
|
|
||||||
// Check for multiple operands
|
// Check for multiple operands
|
||||||
while(filterString.charAt(p) === ",") {
|
while(filterString.charAt(p) === ",") {
|
||||||
p++;
|
p++;
|
||||||
|
@ -116,7 +116,7 @@ function parseFilterOperation(operators,filterString,p) {
|
||||||
throw "Missing [ in filter expression";
|
throw "Missing [ in filter expression";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Push this operator
|
// Push this operator
|
||||||
operators.push(operator);
|
operators.push(operator);
|
||||||
} while(filterString.charAt(p) !== "]");
|
} while(filterString.charAt(p) !== "]");
|
||||||
|
@ -248,7 +248,7 @@ exports.compileFilter = function(filterString) {
|
||||||
} else {
|
} else {
|
||||||
operatorFunction = filterOperators[operator.operator];
|
operatorFunction = filterOperators[operator.operator];
|
||||||
}
|
}
|
||||||
|
|
||||||
$tw.utils.each(operator.operands,function(operand) {
|
$tw.utils.each(operator.operands,function(operand) {
|
||||||
if(operand.indirect) {
|
if(operand.indirect) {
|
||||||
operand.value = self.getTextReference(operand.text,"",currTiddlerTitle);
|
operand.value = self.getTextReference(operand.text,"",currTiddlerTitle);
|
||||||
|
@ -323,6 +323,9 @@ exports.compileFilter = function(filterString) {
|
||||||
} else if(typeof source === "object") { // Array or hashmap
|
} else if(typeof source === "object") { // Array or hashmap
|
||||||
source = self.makeTiddlerIterator(source);
|
source = self.makeTiddlerIterator(source);
|
||||||
}
|
}
|
||||||
|
if(!widget) {
|
||||||
|
widget = $tw.rootWidget;
|
||||||
|
}
|
||||||
var results = new $tw.utils.LinkedList();
|
var results = new $tw.utils.LinkedList();
|
||||||
$tw.utils.each(operationFunctions,function(operationFunction) {
|
$tw.utils.each(operationFunctions,function(operationFunction) {
|
||||||
operationFunction(results,source,widget);
|
operationFunction(results,source,widget);
|
||||||
|
|
27
core/modules/filters/deserializers.js
Normal file
27
core/modules/filters/deserializers.js
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
/*\
|
||||||
|
title: $:/core/modules/filters/deserializers.js
|
||||||
|
type: application/javascript
|
||||||
|
module-type: filteroperator
|
||||||
|
|
||||||
|
Filter operator for returning the names of the deserializers in this wiki
|
||||||
|
|
||||||
|
\*/
|
||||||
|
(function(){
|
||||||
|
|
||||||
|
/*jslint node: true, browser: true */
|
||||||
|
/*global $tw: false */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/*
|
||||||
|
Export our filter function
|
||||||
|
*/
|
||||||
|
exports.deserializers = function(source,operator,options) {
|
||||||
|
var results = [];
|
||||||
|
$tw.utils.each($tw.Wiki.tiddlerDeserializerModules,function(deserializer,type) {
|
||||||
|
results.push(type);
|
||||||
|
});
|
||||||
|
results.sort();
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
|
@ -22,7 +22,7 @@ exports.editiondescription = function(source,operator,options) {
|
||||||
if(editionInfo) {
|
if(editionInfo) {
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
if($tw.utils.hop(editionInfo,title)) {
|
if($tw.utils.hop(editionInfo,title)) {
|
||||||
results.push(editionInfo[title].description || "");
|
results.push(editionInfo[title].description || "");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ exports.fields = function(source,operator,options) {
|
||||||
fieldName,
|
fieldName,
|
||||||
suffixes = (operator.suffixes || [])[0] || [],
|
suffixes = (operator.suffixes || [])[0] || [],
|
||||||
operand = $tw.utils.parseStringArray(operator.operand);
|
operand = $tw.utils.parseStringArray(operator.operand);
|
||||||
|
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
if(tiddler) {
|
if(tiddler) {
|
||||||
if(suffixes.indexOf("include") !== -1) {
|
if(suffixes.indexOf("include") !== -1) {
|
||||||
|
|
|
@ -20,7 +20,18 @@ exports.filter = function(source,operator,options) {
|
||||||
results = [],
|
results = [],
|
||||||
target = operator.prefix !== "!";
|
target = operator.prefix !== "!";
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
var list = filterFn.call(options.wiki,options.wiki.makeTiddlerIterator([title]),options.widget);
|
var list = filterFn.call(options.wiki,options.wiki.makeTiddlerIterator([title]),{
|
||||||
|
getVariable: function(name) {
|
||||||
|
switch(name) {
|
||||||
|
case "currentTiddler":
|
||||||
|
return "" + title;
|
||||||
|
case "..currentTiddler":
|
||||||
|
return options.widget.getVariable("currentTiddler");
|
||||||
|
default:
|
||||||
|
return options.widget.getVariable(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
if((list.length > 0) === target) {
|
if((list.length > 0) === target) {
|
||||||
results.push(title);
|
results.push(title);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,13 +13,13 @@ module-type: formatfilteroperator
|
||||||
Export our filter function
|
Export our filter function
|
||||||
*/
|
*/
|
||||||
exports.date = function(source,operand,options) {
|
exports.date = function(source,operand,options) {
|
||||||
var results = [];
|
var results = [];
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
var value = $tw.utils.parseDate(title);
|
var value = $tw.utils.parseDate(title);
|
||||||
if(value && $tw.utils.isDate(value) && value.toString() !== "Invalid Date") {
|
if(value && $tw.utils.isDate(value) && value.toString() !== "Invalid Date") {
|
||||||
results.push($tw.utils.formatDateString(value,operand || "YYYY MM DD 0hh:0mm"));
|
results.push($tw.utils.formatDateString(value,operand || "YYYY MM DD 0hh:0mm"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,13 +13,13 @@ module-type: formatfilteroperator
|
||||||
Export our filter function
|
Export our filter function
|
||||||
*/
|
*/
|
||||||
exports.relativedate = function(source,operand,options) {
|
exports.relativedate = function(source,operand,options) {
|
||||||
var results = [];
|
var results = [];
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
var value = $tw.utils.parseDate(title);
|
var value = $tw.utils.parseDate(title);
|
||||||
if(value && $tw.utils.isDate(value) && value.toString() !== "Invalid Date") {
|
if(value && $tw.utils.isDate(value) && value.toString() !== "Invalid Date") {
|
||||||
results.push($tw.utils.getRelativeDate((new Date()) - (new Date(value))).description);
|
results.push($tw.utils.getRelativeDate((new Date()) - (new Date(value))).description);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
25
core/modules/filters/format/titlelist.js
Normal file
25
core/modules/filters/format/titlelist.js
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/*\
|
||||||
|
title: $:/core/modules/filters/format/titlelist.js
|
||||||
|
type: application/javascript
|
||||||
|
module-type: formatfilteroperator
|
||||||
|
\*/
|
||||||
|
(function(){
|
||||||
|
|
||||||
|
/*jslint node: true, browser: true */
|
||||||
|
/*global $tw: false */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/*
|
||||||
|
Export our filter function
|
||||||
|
*/
|
||||||
|
exports.titlelist = function(source,operand,options) {
|
||||||
|
var results = [];
|
||||||
|
source(function(tiddler,title) {
|
||||||
|
if(title && title.length) {
|
||||||
|
results.push($tw.utils.stringifyList([title]));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
|
@ -61,7 +61,7 @@ exports.has = function(source,operator,options) {
|
||||||
if(tiddler && $tw.utils.hop(tiddler.fields,operator.operand) && (tiddler.fields[operator.operand].length !== 0)) {
|
if(tiddler && $tw.utils.hop(tiddler.fields,operator.operand) && (tiddler.fields[operator.operand].length !== 0)) {
|
||||||
results.push(title);
|
results.push(title);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
|
|
|
@ -28,7 +28,7 @@ exports.draft = function(source,prefix,options) {
|
||||||
if(tiddler && $tw.utils.hop(tiddler.fields,"draft.of") && (tiddler.fields["draft.of"].length !== 0)) {
|
if(tiddler && $tw.utils.hop(tiddler.fields,"draft.of") && (tiddler.fields["draft.of"].length !== 0)) {
|
||||||
results.push(title);
|
results.push(title);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
|
|
|
@ -31,6 +31,8 @@ exports.reduce = function(source,operator,options) {
|
||||||
switch(name) {
|
switch(name) {
|
||||||
case "currentTiddler":
|
case "currentTiddler":
|
||||||
return "" + title;
|
return "" + title;
|
||||||
|
case "..currentTiddler":
|
||||||
|
return options.widget.getVariable("currentTiddler");
|
||||||
case "accumulator":
|
case "accumulator":
|
||||||
return "" + accumulator;
|
return "" + accumulator;
|
||||||
case "index":
|
case "index":
|
||||||
|
|
|
@ -27,10 +27,13 @@ exports.sortsub = function(source,operator,options) {
|
||||||
iterator(options.wiki.getTiddler(title),title);
|
iterator(options.wiki.getTiddler(title),title);
|
||||||
},{
|
},{
|
||||||
getVariable: function(name) {
|
getVariable: function(name) {
|
||||||
if(name === "currentTiddler") {
|
switch(name) {
|
||||||
return title;
|
case "currentTiddler":
|
||||||
} else {
|
return "" + title;
|
||||||
return options.widget.getVariable(name);
|
case "..currentTiddler":
|
||||||
|
return options.widget.getVariable("currentTiddler");
|
||||||
|
default:
|
||||||
|
return options.widget.getVariable(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -105,13 +105,13 @@ exports.splitregexp = function(source,operator,options) {
|
||||||
flags = (suffix.indexOf("m") !== -1 ? "m" : "") + (suffix.indexOf("i") !== -1 ? "i" : ""),
|
flags = (suffix.indexOf("m") !== -1 ? "m" : "") + (suffix.indexOf("i") !== -1 ? "i" : ""),
|
||||||
regExp;
|
regExp;
|
||||||
try {
|
try {
|
||||||
regExp = new RegExp(operator.operand || "",flags);
|
regExp = new RegExp(operator.operand || "",flags);
|
||||||
} catch(ex) {
|
} catch(ex) {
|
||||||
return ["RegExp error: " + ex];
|
return ["RegExp error: " + ex];
|
||||||
}
|
}
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
Array.prototype.push.apply(result,title.split(regExp));
|
Array.prototype.push.apply(result,title.split(regExp));
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ exports["search-replace"] = function(source,operator,options) {
|
||||||
isRegExp = (suffixes[1] && suffixes[1][0] === "regexp") ? true : false,
|
isRegExp = (suffixes[1] && suffixes[1][0] === "regexp") ? true : false,
|
||||||
searchTerm,
|
searchTerm,
|
||||||
regExp;
|
regExp;
|
||||||
|
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
if(title && (operator.operands.length > 1)) {
|
if(title && (operator.operands.length > 1)) {
|
||||||
//Escape regexp characters if the operand is not a regular expression
|
//Escape regexp characters if the operand is not a regular expression
|
||||||
|
@ -156,7 +156,7 @@ exports.pad = function(source,operator,options) {
|
||||||
var padString = "",
|
var padString = "",
|
||||||
padStringLength = targetLength - title.length;
|
padStringLength = targetLength - title.length;
|
||||||
while (padStringLength > padString.length) {
|
while (padStringLength > padString.length) {
|
||||||
padString += fill;
|
padString += fill;
|
||||||
}
|
}
|
||||||
//make sure we do not exceed the specified length
|
//make sure we do not exceed the specified length
|
||||||
padString = padString.slice(0,padStringLength);
|
padString = padString.slice(0,padStringLength);
|
||||||
|
|
|
@ -50,7 +50,7 @@ exports.tag = function(source,operator,options) {
|
||||||
});
|
});
|
||||||
results = options.wiki.sortByList(results,operator.operand);
|
results = options.wiki.sortByList(results,operator.operand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
|
|
|
@ -193,7 +193,7 @@ Extended filter operators to manipulate the current list.
|
||||||
step = stepSize || 1,
|
step = stepSize || 1,
|
||||||
i = 0,
|
i = 0,
|
||||||
opLength = operands.length,
|
opLength = operands.length,
|
||||||
nextOperandIndex;
|
nextOperandIndex;
|
||||||
for(i; i < opLength; i++) {
|
for(i; i < opLength; i++) {
|
||||||
resultsIndex = results.indexOf(operands[i]);
|
resultsIndex = results.indexOf(operands[i]);
|
||||||
if(resultsIndex !== -1) {
|
if(resultsIndex !== -1) {
|
||||||
|
@ -211,12 +211,12 @@ Extended filter operators to manipulate the current list.
|
||||||
} else {
|
} else {
|
||||||
results.push(operands[0]);
|
results.push(operands[0]);
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Toggles an item in the current list.
|
Toggles an item in the current list.
|
||||||
*/
|
*/
|
||||||
exports.toggle = function(source,operator) {
|
exports.toggle = function(source,operator) {
|
||||||
return cycleValueInArray(prepare_results(source),operator.operands);
|
return cycleValueInArray(prepare_results(source),operator.operands);
|
||||||
}
|
}
|
||||||
|
@ -228,8 +228,8 @@ Extended filter operators to manipulate the current list.
|
||||||
if(step < 0) {
|
if(step < 0) {
|
||||||
operands.reverse();
|
operands.reverse();
|
||||||
step = Math.abs(step);
|
step = Math.abs(step);
|
||||||
}
|
}
|
||||||
return cycleValueInArray(results,operands,step);
|
return cycleValueInArray(results,operands,step);
|
||||||
}
|
}
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -121,7 +121,7 @@ FieldIndexer.prototype.update = function(updateDescriptor) {
|
||||||
indexEntry[value].push(updateDescriptor["new"].tiddler.fields.title);
|
indexEntry[value].push(updateDescriptor["new"].tiddler.fields.title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ TagSubIndexer.prototype.rebuild = function() {
|
||||||
} else {
|
} else {
|
||||||
self.index[tag].titles.push(title);
|
self.index[tag].titles.push(title);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ TagSubIndexer.prototype.lookup = function(tag) {
|
||||||
if(!indexRecord.isSorted) {
|
if(!indexRecord.isSorted) {
|
||||||
if(this.indexer.wiki.sortByList) {
|
if(this.indexer.wiki.sortByList) {
|
||||||
indexRecord.titles = this.indexer.wiki.sortByList(indexRecord.titles,tag);
|
indexRecord.titles = this.indexer.wiki.sortByList(indexRecord.titles,tag);
|
||||||
}
|
}
|
||||||
indexRecord.isSorted = true;
|
indexRecord.isSorted = true;
|
||||||
}
|
}
|
||||||
return indexRecord.titles;
|
return indexRecord.titles;
|
||||||
|
|
|
@ -22,7 +22,7 @@ exports.getInfoTiddlerFields = function(updateInfoTiddlersCallback) {
|
||||||
if($tw.browser) {
|
if($tw.browser) {
|
||||||
// Document location
|
// Document location
|
||||||
var setLocationProperty = function(name,value) {
|
var setLocationProperty = function(name,value) {
|
||||||
infoTiddlerFields.push({title: "$:/info/url/" + name, text: value});
|
infoTiddlerFields.push({title: "$:/info/url/" + name, text: value});
|
||||||
},
|
},
|
||||||
location = document.location;
|
location = document.location;
|
||||||
setLocationProperty("full", (location.toString()).split("#")[0]);
|
setLocationProperty("full", (location.toString()).split("#")[0]);
|
||||||
|
|
|
@ -285,7 +285,7 @@ KeyboardManager.prototype.checkKeyDescriptors = function(event,keyInfoArray) {
|
||||||
};
|
};
|
||||||
|
|
||||||
KeyboardManager.prototype.getEventModifierKeyDescriptor = function(event) {
|
KeyboardManager.prototype.getEventModifierKeyDescriptor = function(event) {
|
||||||
return event.ctrlKey && !event.shiftKey && !event.altKey && !event.metaKey ? "ctrl" :
|
return event.ctrlKey && !event.shiftKey && !event.altKey && !event.metaKey ? "ctrl" :
|
||||||
event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey ? "shift" :
|
event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey ? "shift" :
|
||||||
event.ctrlKey && event.shiftKey && !event.altKey && !event.metaKey ? "ctrl-shift" :
|
event.ctrlKey && event.shiftKey && !event.altKey && !event.metaKey ? "ctrl-shift" :
|
||||||
event.altKey && !event.shiftKey && !event.ctrlKey && !event.metaKey ? "alt" :
|
event.altKey && !event.shiftKey && !event.ctrlKey && !event.metaKey ? "alt" :
|
||||||
|
@ -295,7 +295,7 @@ KeyboardManager.prototype.getEventModifierKeyDescriptor = function(event) {
|
||||||
event.metaKey && !event.ctrlKey && !event.shiftKey && !event.altKey ? "meta" :
|
event.metaKey && !event.ctrlKey && !event.shiftKey && !event.altKey ? "meta" :
|
||||||
event.metaKey && event.ctrlKey && !event.shiftKey && !event.altKey ? "meta-ctrl" :
|
event.metaKey && event.ctrlKey && !event.shiftKey && !event.altKey ? "meta-ctrl" :
|
||||||
event.metaKey && event.ctrlKey && event.shiftKey && !event.altKey ? "meta-ctrl-shift" :
|
event.metaKey && event.ctrlKey && event.shiftKey && !event.altKey ? "meta-ctrl-shift" :
|
||||||
event.metaKey && event.ctrlKey & event.shiftKey && event.altKey ? "meta-ctrl-alt-shift" : "normal";
|
event.metaKey && event.ctrlKey && event.shiftKey && event.altKey ? "meta-ctrl-alt-shift" : "normal";
|
||||||
};
|
};
|
||||||
|
|
||||||
KeyboardManager.prototype.getShortcutTiddlerList = function() {
|
KeyboardManager.prototype.getShortcutTiddlerList = function() {
|
||||||
|
|
|
@ -36,7 +36,7 @@ exports.parse = function() {
|
||||||
// Move past the pragma invocation
|
// Move past the pragma invocation
|
||||||
this.parser.pos = this.matchRegExp.lastIndex;
|
this.parser.pos = this.matchRegExp.lastIndex;
|
||||||
// Parse the filter terminated by a line break
|
// Parse the filter terminated by a line break
|
||||||
var reMatch = /(.*)(\r?\n)|$/mg;
|
var reMatch = /(.*)(?:$|\r?\n)/mg;
|
||||||
reMatch.lastIndex = this.parser.pos;
|
reMatch.lastIndex = this.parser.pos;
|
||||||
var match = reMatch.exec(this.parser.source);
|
var match = reMatch.exec(this.parser.source);
|
||||||
this.parser.pos = reMatch.lastIndex;
|
this.parser.pos = reMatch.lastIndex;
|
||||||
|
|
|
@ -161,7 +161,7 @@ exports.parse = function() {
|
||||||
// Move the caption to the first row if it isn't already
|
// Move the caption to the first row if it isn't already
|
||||||
if(table.children.length !== 1) {
|
if(table.children.length !== 1) {
|
||||||
table.children.pop(); // Take rowContainer out of the children array
|
table.children.pop(); // Take rowContainer out of the children array
|
||||||
table.children.splice(0,0,rowContainer); // Insert it at the bottom
|
table.children.splice(0,0,rowContainer); // Insert it at the bottom
|
||||||
}
|
}
|
||||||
// Set the alignment - TODO: figure out why TW did this
|
// Set the alignment - TODO: figure out why TW did this
|
||||||
// rowContainer.attributes.align = rowCount === 0 ? "top" : "bottom";
|
// rowContainer.attributes.align = rowCount === 0 ? "top" : "bottom";
|
||||||
|
|
|
@ -378,7 +378,7 @@ WikiParser.prototype.pushTextWidget = function(array,text) {
|
||||||
text = $tw.utils.trim(text);
|
text = $tw.utils.trim(text);
|
||||||
}
|
}
|
||||||
if(text) {
|
if(text) {
|
||||||
array.push({type: "text", text: text});
|
array.push({type: "text", text: text});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ UploadSaver.prototype.save = function(text,method,callback) {
|
||||||
url = "http://" + username + ".tiddlyspot.com/store.cgi";
|
url = "http://" + username + ".tiddlyspot.com/store.cgi";
|
||||||
}
|
}
|
||||||
// Assemble the header
|
// Assemble the header
|
||||||
var boundary = "---------------------------" + "AaB03x";
|
var boundary = "---------------------------" + "AaB03x";
|
||||||
var uploadFormName = "UploadPlugin";
|
var uploadFormName = "UploadPlugin";
|
||||||
var head = [];
|
var head = [];
|
||||||
head.push("--" + boundary + "\r\nContent-disposition: form-data; name=\"UploadPlugin\"\r\n");
|
head.push("--" + boundary + "\r\nContent-disposition: form-data; name=\"UploadPlugin\"\r\n");
|
||||||
|
|
|
@ -22,7 +22,7 @@ exports.handler = function(request,response,state) {
|
||||||
response.writeHead(401,{
|
response.writeHead(401,{
|
||||||
"WWW-Authenticate": 'Basic realm="Please provide your username and password to login to ' + state.server.servername + '"'
|
"WWW-Authenticate": 'Basic realm="Please provide your username and password to login to ' + state.server.servername + '"'
|
||||||
});
|
});
|
||||||
response.end();
|
response.end();
|
||||||
} else {
|
} else {
|
||||||
// Redirect to the root wiki if login worked
|
// Redirect to the root wiki if login worked
|
||||||
var location = ($tw.syncadaptor && $tw.syncadaptor.host)? $tw.syncadaptor.host: "/";
|
var location = ($tw.syncadaptor && $tw.syncadaptor.host)? $tw.syncadaptor.host: "/";
|
||||||
|
|
|
@ -42,7 +42,7 @@ function Server(options) {
|
||||||
if(options.variables[variable]) {
|
if(options.variables[variable]) {
|
||||||
this.variables[variable] = options.variables[variable];
|
this.variables[variable] = options.variables[variable];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$tw.utils.extend({},this.defaultVariables,options.variables);
|
$tw.utils.extend({},this.defaultVariables,options.variables);
|
||||||
// Initialise CSRF
|
// Initialise CSRF
|
||||||
|
@ -273,7 +273,7 @@ Server.prototype.requestHandler = function(request,response,options) {
|
||||||
if(!this.csrfDisable && authorizationType === "writers" && request.headers["x-requested-with"] !== "TiddlyWiki") {
|
if(!this.csrfDisable && authorizationType === "writers" && request.headers["x-requested-with"] !== "TiddlyWiki") {
|
||||||
response.writeHead(403,"'X-Requested-With' header required to login to '" + this.servername + "'");
|
response.writeHead(403,"'X-Requested-With' header required to login to '" + this.servername + "'");
|
||||||
response.end();
|
response.end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Check whether anonymous access is granted
|
// Check whether anonymous access is granted
|
||||||
state.allowAnon = this.isAuthorized(authorizationType,null);
|
state.allowAnon = this.isAuthorized(authorizationType,null);
|
||||||
|
@ -282,7 +282,7 @@ Server.prototype.requestHandler = function(request,response,options) {
|
||||||
if(!this.authenticators[0].authenticateRequest(request,response,state)) {
|
if(!this.authenticators[0].authenticateRequest(request,response,state)) {
|
||||||
// Bail if we failed (the authenticator will have sent the response)
|
// Bail if we failed (the authenticator will have sent the response)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Authorize with the authenticated username
|
// Authorize with the authenticated username
|
||||||
if(!this.isAuthorized(authorizationType,state.authenticatedUsername)) {
|
if(!this.isAuthorized(authorizationType,state.authenticatedUsername)) {
|
||||||
|
|
|
@ -17,7 +17,7 @@ exports.name = "favicon";
|
||||||
exports.platforms = ["browser"];
|
exports.platforms = ["browser"];
|
||||||
exports.after = ["startup"];
|
exports.after = ["startup"];
|
||||||
exports.synchronous = true;
|
exports.synchronous = true;
|
||||||
|
|
||||||
// Favicon tiddler
|
// Favicon tiddler
|
||||||
var FAVICON_TITLE = "$:/favicon.ico";
|
var FAVICON_TITLE = "$:/favicon.ico";
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ exports.startup = function() {
|
||||||
var onlyThrottledTiddlersHaveChanged = true;
|
var onlyThrottledTiddlersHaveChanged = true;
|
||||||
for(var title in changes) {
|
for(var title in changes) {
|
||||||
var tiddler = $tw.wiki.getTiddler(title);
|
var tiddler = $tw.wiki.getTiddler(title);
|
||||||
if(!tiddler || !(tiddler.hasField("draft.of") || tiddler.hasField("throttle.refresh"))) {
|
if(!$tw.wiki.isVolatileTiddler(title) && (!tiddler || !(tiddler.hasField("draft.of") || tiddler.hasField("throttle.refresh")))) {
|
||||||
onlyThrottledTiddlersHaveChanged = false;
|
onlyThrottledTiddlersHaveChanged = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ exports.startup = function() {
|
||||||
});
|
});
|
||||||
$tw.rootWidget.addEventListener("tm-show-switcher",function(event) {
|
$tw.rootWidget.addEventListener("tm-show-switcher",function(event) {
|
||||||
$tw.modal.display("$:/core/ui/SwitcherModal",{variables: event.paramObject, event: event});
|
$tw.modal.display("$:/core/ui/SwitcherModal",{variables: event.paramObject, event: event});
|
||||||
});
|
});
|
||||||
// Install the notification mechanism
|
// Install the notification mechanism
|
||||||
$tw.notifier = new $tw.utils.Notifier($tw.wiki);
|
$tw.notifier = new $tw.utils.Notifier($tw.wiki);
|
||||||
$tw.rootWidget.addEventListener("tm-notify",function(event) {
|
$tw.rootWidget.addEventListener("tm-notify",function(event) {
|
||||||
|
@ -68,7 +68,7 @@ exports.startup = function() {
|
||||||
fullScreenDocument[fullscreen._exitFullscreen]();
|
fullScreenDocument[fullscreen._exitFullscreen]();
|
||||||
} else {
|
} else {
|
||||||
fullScreenDocument.documentElement[fullscreen._requestFullscreen](Element.ALLOW_KEYBOARD_INPUT);
|
fullScreenDocument.documentElement[fullscreen._requestFullscreen](Element.ALLOW_KEYBOARD_INPUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ exports.startup = function() {
|
||||||
updateHistory: $tw.wiki.getTiddlerText(CONFIG_UPDATE_HISTORY,"no").trim(),
|
updateHistory: $tw.wiki.getTiddlerText(CONFIG_UPDATE_HISTORY,"no").trim(),
|
||||||
targetTiddler: event.param || event.tiddlerTitle,
|
targetTiddler: event.param || event.tiddlerTitle,
|
||||||
copyToClipboard: $tw.wiki.getTiddlerText(CONFIG_PERMALINKVIEW_COPY_TO_CLIPBOARD,"yes").trim() === "yes" ? "permaview" : "none"
|
copyToClipboard: $tw.wiki.getTiddlerText(CONFIG_PERMALINKVIEW_COPY_TO_CLIPBOARD,"yes").trim() === "yes" ? "permaview" : "none"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -165,7 +165,7 @@ function openStartupTiddlers(options) {
|
||||||
story.addToHistory(target);
|
story.addToHistory(target);
|
||||||
} else if(storyList.length > 0) {
|
} else if(storyList.length > 0) {
|
||||||
story.addToHistory(storyList[0]);
|
story.addToHistory(storyList[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ ClassicStoryView.prototype.navigateTo = function(historyInfo) {
|
||||||
}
|
}
|
||||||
if(duration) {
|
if(duration) {
|
||||||
// Scroll the node into view
|
// Scroll the node into view
|
||||||
this.listWidget.dispatchEvent({type: "tm-scroll", target: targetElement});
|
this.listWidget.dispatchEvent({type: "tm-scroll", target: targetElement});
|
||||||
} else {
|
} else {
|
||||||
targetElement.scrollIntoView();
|
targetElement.scrollIntoView();
|
||||||
}
|
}
|
||||||
|
|
|
@ -601,7 +601,10 @@ SaveTiddlerTask.prototype.run = function(callback) {
|
||||||
tiddler = this.syncer.wiki.tiddlerExists(this.title) && this.syncer.wiki.getTiddler(this.title);
|
tiddler = this.syncer.wiki.tiddlerExists(this.title) && this.syncer.wiki.getTiddler(this.title);
|
||||||
this.syncer.logger.log("Dispatching 'save' task:",this.title);
|
this.syncer.logger.log("Dispatching 'save' task:",this.title);
|
||||||
if(tiddler) {
|
if(tiddler) {
|
||||||
this.syncer.syncadaptor.saveTiddler(tiddler,function(err,adaptorInfo,revision) {
|
this.syncer.syncadaptor.saveTiddler(tiddler,{
|
||||||
|
changeCount: changeCount,
|
||||||
|
tiddlerInfo: self.syncer.tiddlerInfo[self.title]
|
||||||
|
},function(err,adaptorInfo,revision) {
|
||||||
// If there's an error, exit without changing any internal state
|
// If there's an error, exit without changing any internal state
|
||||||
if(err) {
|
if(err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
|
@ -615,8 +618,6 @@ SaveTiddlerTask.prototype.run = function(callback) {
|
||||||
};
|
};
|
||||||
// Invoke the callback
|
// Invoke the callback
|
||||||
callback(null);
|
callback(null);
|
||||||
},{
|
|
||||||
tiddlerInfo: self.syncer.tiddlerInfo[self.title]
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.syncer.logger.log(" Not Dispatching 'save' task:",this.title,"tiddler does not exist");
|
this.syncer.logger.log(" Not Dispatching 'save' task:",this.title,"tiddler does not exist");
|
||||||
|
@ -633,7 +634,9 @@ function DeleteTiddlerTask(syncer,title) {
|
||||||
DeleteTiddlerTask.prototype.run = function(callback) {
|
DeleteTiddlerTask.prototype.run = function(callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.syncer.logger.log("Dispatching 'delete' task:",this.title);
|
this.syncer.logger.log("Dispatching 'delete' task:",this.title);
|
||||||
this.syncer.syncadaptor.deleteTiddler(this.title,function(err) {
|
this.syncer.syncadaptor.deleteTiddler(this.title,{
|
||||||
|
tiddlerInfo: self.syncer.tiddlerInfo[this.title]
|
||||||
|
},function(err,adaptorInfo) {
|
||||||
// If there's an error, exit without changing any internal state
|
// If there's an error, exit without changing any internal state
|
||||||
if(err) {
|
if(err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
|
@ -642,8 +645,6 @@ DeleteTiddlerTask.prototype.run = function(callback) {
|
||||||
delete self.syncer.tiddlerInfo[self.title];
|
delete self.syncer.tiddlerInfo[self.title];
|
||||||
// Invoke the callback
|
// Invoke the callback
|
||||||
callback(null);
|
callback(null);
|
||||||
},{
|
|
||||||
tiddlerInfo: self.syncer.tiddlerInfo[this.title]
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,8 @@ Upgrader module that suppresses certain system tiddlers that shouldn't be import
|
||||||
/*global $tw: false */
|
/*global $tw: false */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var DONT_IMPORT_LIST = ["$:/StoryList","$:/HistoryList"],
|
var DONT_IMPORT_LIST = ["$:/Import"],
|
||||||
DONT_IMPORT_PREFIX_LIST = ["$:/temp/","$:/state/","$:/Import"],
|
UNSELECT_PREFIX_LIST = ["$:/temp/","$:/state/","$:/StoryList","$:/HistoryList"],
|
||||||
WARN_IMPORT_PREFIX_LIST = ["$:/core/modules/"];
|
WARN_IMPORT_PREFIX_LIST = ["$:/core/modules/"];
|
||||||
|
|
||||||
exports.upgrade = function(wiki,titles,tiddlers) {
|
exports.upgrade = function(wiki,titles,tiddlers) {
|
||||||
|
@ -26,11 +26,10 @@ exports.upgrade = function(wiki,titles,tiddlers) {
|
||||||
tiddlers[title] = Object.create(null);
|
tiddlers[title] = Object.create(null);
|
||||||
messages[title] = $tw.language.getString("Import/Upgrader/System/Suppressed");
|
messages[title] = $tw.language.getString("Import/Upgrader/System/Suppressed");
|
||||||
} else {
|
} else {
|
||||||
for(var t=0; t<DONT_IMPORT_PREFIX_LIST.length; t++) {
|
for(var t=0; t<UNSELECT_PREFIX_LIST.length; t++) {
|
||||||
var prefix = DONT_IMPORT_PREFIX_LIST[t];
|
var prefix = UNSELECT_PREFIX_LIST[t];
|
||||||
if(title.substr(0,prefix.length) === prefix) {
|
if(title.substr(0,prefix.length) === prefix) {
|
||||||
tiddlers[title] = Object.create(null);
|
messages[title] = $tw.language.getString("Import/Upgrader/Tiddler/Unselected");
|
||||||
messages[title] = $tw.language.getString("Import/Upgrader/State/Suppressed");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(var t=0; t<WARN_IMPORT_PREFIX_LIST.length; t++) {
|
for(var t=0; t<WARN_IMPORT_PREFIX_LIST.length; t++) {
|
||||||
|
|
|
@ -38,7 +38,7 @@ exports.parseCsvStringWithHeader = function(text,options) {
|
||||||
var columnName = headings[column];
|
var columnName = headings[column];
|
||||||
columnResult[columnName] = $tw.utils.trim(columns[column] || "");
|
columnResult[columnName] = $tw.utils.trim(columns[column] || "");
|
||||||
}
|
}
|
||||||
results.push(columnResult);
|
results.push(columnResult);
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,10 @@ exports.domContains = function(a,b) {
|
||||||
!!(a.compareDocumentPosition(b) & 16);
|
!!(a.compareDocumentPosition(b) & 16);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.domMatchesSelector = function(node,selector) {
|
||||||
|
return node.matches ? node.matches(selector) : node.msMatchesSelector(selector);
|
||||||
|
};
|
||||||
|
|
||||||
exports.removeChildren = function(node) {
|
exports.removeChildren = function(node) {
|
||||||
while(node.hasChildNodes()) {
|
while(node.hasChildNodes()) {
|
||||||
node.removeChild(node.firstChild);
|
node.removeChild(node.firstChild);
|
||||||
|
@ -65,7 +69,7 @@ Get the first parent element that has scrollbars or use the body as fallback.
|
||||||
*/
|
*/
|
||||||
exports.getScrollContainer = function(el) {
|
exports.getScrollContainer = function(el) {
|
||||||
var doc = el.ownerDocument;
|
var doc = el.ownerDocument;
|
||||||
while(el.parentNode) {
|
while(el.parentNode) {
|
||||||
el = el.parentNode;
|
el = el.parentNode;
|
||||||
if(el.scrollTop) {
|
if(el.scrollTop) {
|
||||||
return el;
|
return el;
|
||||||
|
@ -204,7 +208,7 @@ exports.addEventListeners = function(domNode,events) {
|
||||||
if(eventInfo.handlerMethod) {
|
if(eventInfo.handlerMethod) {
|
||||||
handler = function(event) {
|
handler = function(event) {
|
||||||
eventInfo.handlerObject[eventInfo.handlerMethod].call(eventInfo.handlerObject,event);
|
eventInfo.handlerObject[eventInfo.handlerMethod].call(eventInfo.handlerObject,event);
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
handler = eventInfo.handlerObject;
|
handler = eventInfo.handlerObject;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ exports.makeDraggable = function(options) {
|
||||||
domNode = options.domNode;
|
domNode = options.domNode;
|
||||||
// Make the dom node draggable (not necessary for anchor tags)
|
// Make the dom node draggable (not necessary for anchor tags)
|
||||||
if((domNode.tagName || "").toLowerCase() !== "a") {
|
if((domNode.tagName || "").toLowerCase() !== "a") {
|
||||||
domNode.setAttribute("draggable","true");
|
domNode.setAttribute("draggable","true");
|
||||||
}
|
}
|
||||||
// Add event handlers
|
// Add event handlers
|
||||||
$tw.utils.addEventListeners(domNode,[
|
$tw.utils.addEventListeners(domNode,[
|
||||||
|
@ -80,7 +80,7 @@ exports.makeDraggable = function(options) {
|
||||||
}
|
}
|
||||||
// Set up the data transfer
|
// Set up the data transfer
|
||||||
if(dataTransfer.clearData) {
|
if(dataTransfer.clearData) {
|
||||||
dataTransfer.clearData();
|
dataTransfer.clearData();
|
||||||
}
|
}
|
||||||
var jsonData = [];
|
var jsonData = [];
|
||||||
if(titles.length > 1) {
|
if(titles.length > 1) {
|
||||||
|
|
|
@ -145,7 +145,7 @@ Popup.prototype.show = function(options) {
|
||||||
}
|
}
|
||||||
// Add the click handler if we have any popups
|
// Add the click handler if we have any popups
|
||||||
if(this.popups.length > 0) {
|
if(this.popups.length > 0) {
|
||||||
this.rootElement.addEventListener("click",this,true);
|
this.rootElement.addEventListener("click",this,true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ PageScroller.prototype.handleEvent = function(event) {
|
||||||
if(event.paramObject && event.paramObject.selector) {
|
if(event.paramObject && event.paramObject.selector) {
|
||||||
this.scrollSelectorIntoView(null,event.paramObject.selector);
|
this.scrollSelectorIntoView(null,event.paramObject.selector);
|
||||||
} else {
|
} else {
|
||||||
this.scrollIntoView(event.target);
|
this.scrollIntoView(event.target);
|
||||||
}
|
}
|
||||||
return false; // Event was handled
|
return false; // Event was handled
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ PageScroller.prototype.scrollIntoView = function(element,callback) {
|
||||||
if(duration <= 0) {
|
if(duration <= 0) {
|
||||||
t = 1;
|
t = 1;
|
||||||
} else {
|
} else {
|
||||||
t = ((Date.now()) - self.startTime) / duration;
|
t = ((Date.now()) - self.startTime) / duration;
|
||||||
}
|
}
|
||||||
if(t >= 1) {
|
if(t >= 1) {
|
||||||
self.cancelScroll(srcWindow);
|
self.cancelScroll(srcWindow);
|
||||||
|
@ -126,7 +126,7 @@ PageScroller.prototype.scrollSelectorIntoView = function(baseElement,selector,ca
|
||||||
baseElement = baseElement || document.body;
|
baseElement = baseElement || document.body;
|
||||||
var element = baseElement.querySelector(selector);
|
var element = baseElement.querySelector(selector);
|
||||||
if(element) {
|
if(element) {
|
||||||
this.scrollIntoView(element,callback);
|
this.scrollIntoView(element,callback);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -372,7 +372,7 @@ exports.generateTiddlerFilepath = function(title,options) {
|
||||||
// If the resulting filename is blank (eg because the title is just punctuation)
|
// If the resulting filename is blank (eg because the title is just punctuation)
|
||||||
if(!filepath || /^_+$/g.test(filepath)) {
|
if(!filepath || /^_+$/g.test(filepath)) {
|
||||||
// ...then just use the character codes of the title
|
// ...then just use the character codes of the title
|
||||||
filepath = "";
|
filepath = "";
|
||||||
$tw.utils.each(title.split(""),function(char) {
|
$tw.utils.each(title.split(""),function(char) {
|
||||||
if(filepath) {
|
if(filepath) {
|
||||||
filepath += "-";
|
filepath += "-";
|
||||||
|
@ -488,7 +488,7 @@ exports.deleteTiddlerFile = function(fileInfo,callback) {
|
||||||
fs.unlink(fileInfo.filepath,function(err) {
|
fs.unlink(fileInfo.filepath,function(err) {
|
||||||
if(err) {
|
if(err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
// Delete the metafile if present
|
// Delete the metafile if present
|
||||||
if(fileInfo.hasMetaFile && fs.existsSync(fileInfo.filepath + ".meta")) {
|
if(fileInfo.hasMetaFile && fs.existsSync(fileInfo.filepath + ".meta")) {
|
||||||
fs.unlink(fileInfo.filepath + ".meta",function(err) {
|
fs.unlink(fileInfo.filepath + ".meta",function(err) {
|
||||||
|
|
|
@ -45,7 +45,7 @@ Logger.prototype.log = function(/* args */) {
|
||||||
self.saveBufferLogger.buffer += " " + arg;
|
self.saveBufferLogger.buffer += " " + arg;
|
||||||
});
|
});
|
||||||
this.saveBufferLogger.buffer += "\n";
|
this.saveBufferLogger.buffer += "\n";
|
||||||
this.saveBufferLogger.buffer = this.saveBufferLogger.buffer.slice(-this.saveBufferLogger.saveLimit);
|
this.saveBufferLogger.buffer = this.saveBufferLogger.buffer.slice(-this.saveBufferLogger.saveLimit);
|
||||||
}
|
}
|
||||||
if(console !== undefined && console.log !== undefined) {
|
if(console !== undefined && console.log !== undefined) {
|
||||||
return Function.apply.call(console.log, console, [$tw.utils.terminalColour(this.colour),this.componentName + ":"].concat(Array.prototype.slice.call(arguments,0)).concat($tw.utils.terminalColour()));
|
return Function.apply.call(console.log, console, [$tw.utils.terminalColour(this.colour),this.componentName + ":"].concat(Array.prototype.slice.call(arguments,0)).concat($tw.utils.terminalColour()));
|
||||||
|
@ -111,7 +111,7 @@ Logger.prototype.alert = function(/* args */) {
|
||||||
} else {
|
} else {
|
||||||
// Print an orange message to the console if not in the browser
|
// Print an orange message to the console if not in the browser
|
||||||
console.error("\x1b[1;33m" + text + "\x1b[0m");
|
console.error("\x1b[1;33m" + text + "\x1b[0m");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ function Performance(enabled) {
|
||||||
|
|
||||||
Performance.prototype.showGreeting = function() {
|
Performance.prototype.showGreeting = function() {
|
||||||
if($tw.browser) {
|
if($tw.browser) {
|
||||||
this.logger.log("Execute $tw.perf.log(); to see filter execution timings");
|
this.logger.log("Execute $tw.perf.log(); to see filter execution timings");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -150,7 +150,7 @@ Convert a string to title case (ie capitalise each initial letter)
|
||||||
exports.toTitleCase = function(str) {
|
exports.toTitleCase = function(str) {
|
||||||
return (str || "").replace(/(^|\s)\S/g, function(c) {return c.toUpperCase();});
|
return (str || "").replace(/(^|\s)\S/g, function(c) {return c.toUpperCase();});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Find the line break preceding a given position in a string
|
Find the line break preceding a given position in a string
|
||||||
Returns position immediately after that line break, or the start of the string
|
Returns position immediately after that line break, or the start of the string
|
||||||
|
@ -842,7 +842,7 @@ exports.makeDataUri = function(text,type,_canonical_uri) {
|
||||||
parts.push(type);
|
parts.push(type);
|
||||||
parts.push(isBase64 ? ";base64" : "");
|
parts.push(isBase64 ? ";base64" : "");
|
||||||
parts.push(",");
|
parts.push(",");
|
||||||
parts.push(isBase64 ? text : encodeURIComponent(text));
|
parts.push(isBase64 ? text : encodeURIComponent(text));
|
||||||
}
|
}
|
||||||
return parts.join("");
|
return parts.join("");
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,8 +27,11 @@ CreateTiddlerWidget.prototype = new Widget();
|
||||||
Render this widget into the DOM
|
Render this widget into the DOM
|
||||||
*/
|
*/
|
||||||
CreateTiddlerWidget.prototype.render = function(parent,nextSibling) {
|
CreateTiddlerWidget.prototype.render = function(parent,nextSibling) {
|
||||||
|
this.parentDomNode = parent;
|
||||||
this.computeAttributes();
|
this.computeAttributes();
|
||||||
this.execute();
|
this.execute();
|
||||||
|
// Render children
|
||||||
|
this.renderChildren(parent,nextSibling);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -44,7 +47,8 @@ CreateTiddlerWidget.prototype.execute = function() {
|
||||||
this.actionTemplate = this.getAttribute("$template");
|
this.actionTemplate = this.getAttribute("$template");
|
||||||
this.useTemplate = !!this.actionTemplate;
|
this.useTemplate = !!this.actionTemplate;
|
||||||
this.actionOverwrite = this.getAttribute("$overwrite","no");
|
this.actionOverwrite = this.getAttribute("$overwrite","no");
|
||||||
|
// Construct the child widgets
|
||||||
|
this.makeChildWidgets();
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -86,18 +90,20 @@ CreateTiddlerWidget.prototype.invokeAction = function(triggeringWidget,event) {
|
||||||
if (!this.hasBase && this.useTemplate) {
|
if (!this.hasBase && this.useTemplate) {
|
||||||
title = this.wiki.generateNewTitle(this.actionTemplate);
|
title = this.wiki.generateNewTitle(this.actionTemplate);
|
||||||
} else if (!this.hasBase && !this.useTemplate) {
|
} else if (!this.hasBase && !this.useTemplate) {
|
||||||
// If NO $basetitle AND NO $template use initial title
|
// If no $basetitle and no $template then use initial title
|
||||||
// DON'T overwrite any stuff
|
|
||||||
title = this.wiki.generateNewTitle(title);
|
title = this.wiki.generateNewTitle(title);
|
||||||
}
|
}
|
||||||
var templateTiddler = this.wiki.getTiddler(this.actionTemplate) || {};
|
var templateTiddler = this.wiki.getTiddler(this.actionTemplate) || {};
|
||||||
var tiddler = this.wiki.addTiddler(new $tw.Tiddler(templateTiddler.fields,creationFields,fields,modificationFields,{title: title}));
|
this.wiki.addTiddler(new $tw.Tiddler(templateTiddler.fields,creationFields,fields,modificationFields,{title: title}));
|
||||||
|
var draftTitle = this.wiki.generateDraftTitle(title);
|
||||||
if(this.actionSaveTitle) {
|
if(this.actionSaveTitle) {
|
||||||
this.wiki.setTextReference(this.actionSaveTitle,title,this.getVariable("currentTiddler"));
|
this.wiki.setTextReference(this.actionSaveTitle,title,this.getVariable("currentTiddler"));
|
||||||
}
|
}
|
||||||
if(this.actionSaveDraftTitle) {
|
if(this.actionSaveDraftTitle) {
|
||||||
this.wiki.setTextReference(this.actionSaveDraftTitle,this.wiki.generateDraftTitle(title),this.getVariable("currentTiddler"));
|
this.wiki.setTextReference(this.actionSaveDraftTitle,draftTitle,this.getVariable("currentTiddler"));
|
||||||
}
|
}
|
||||||
|
this.setVariable("createTiddler-title",title);
|
||||||
|
this.setVariable("createTiddler-draftTitle",draftTitle);
|
||||||
return true; // Action was invoked
|
return true; // Action was invoked
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ DeleteFieldWidget.prototype.invokeAction = function(triggeringWidget,event) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(hasChanged) {
|
if(hasChanged) {
|
||||||
this.wiki.addTiddler(new $tw.Tiddler(this.wiki.getCreationFields(),tiddler,removeFields,this.wiki.getModificationFields()));
|
this.wiki.addTiddler(new $tw.Tiddler(this.wiki.getCreationFields(),tiddler,removeFields,this.wiki.getModificationFields()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true; // Action was invoked
|
return true; // Action was invoked
|
||||||
|
|
|
@ -80,7 +80,7 @@ ActionListopsWidget.prototype.invokeAction = function(triggeringWidget,
|
||||||
tagfilter = $tw.utils.stringifyList(oldtags) + " " + this.filtertags,
|
tagfilter = $tw.utils.stringifyList(oldtags) + " " + this.filtertags,
|
||||||
newtags = this.wiki.filterTiddlers(tagfilter,this);
|
newtags = this.wiki.filterTiddlers(tagfilter,this);
|
||||||
if($tw.utils.stringifyList(oldtags.sort()) !== $tw.utils.stringifyList(newtags.sort())) {
|
if($tw.utils.stringifyList(oldtags.sort()) !== $tw.utils.stringifyList(newtags.sort())) {
|
||||||
this.wiki.setText(this.target,"tags",undefined,$tw.utils.stringifyList(newtags));
|
this.wiki.setText(this.target,"tags",undefined,$tw.utils.stringifyList(newtags));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true; // Action was invoked
|
return true; // Action was invoked
|
||||||
|
|
|
@ -62,17 +62,17 @@ LogWidget.prototype.log = function() {
|
||||||
$tw.utils.each(this.attributes,function(attribute,name) {
|
$tw.utils.each(this.attributes,function(attribute,name) {
|
||||||
if(name.substring(0,2) !== "$$") {
|
if(name.substring(0,2) !== "$$") {
|
||||||
data[name] = attribute;
|
data[name] = attribute;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
for(var v in this.variables) {
|
for(var v in this.variables) {
|
||||||
allVars[v] = this.getVariable(v,{defaultValue:""});
|
allVars[v] = this.getVariable(v,{defaultValue:""});
|
||||||
}
|
}
|
||||||
if(this.filter) {
|
if(this.filter) {
|
||||||
filteredVars = this.wiki.compileFilter(this.filter).call(this.wiki,this.wiki.makeTiddlerIterator(allVars));
|
filteredVars = this.wiki.compileFilter(this.filter).call(this.wiki,this.wiki.makeTiddlerIterator(allVars));
|
||||||
$tw.utils.each(filteredVars,function(name) {
|
$tw.utils.each(filteredVars,function(name) {
|
||||||
data[name] = allVars[name];
|
data[name] = allVars[name];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
dataCount = $tw.utils.count(data);
|
dataCount = $tw.utils.count(data);
|
||||||
|
|
||||||
|
|
|
@ -227,7 +227,7 @@ ButtonWidget.prototype.execute = function() {
|
||||||
ButtonWidget.prototype.updateDomNodeClasses = function() {
|
ButtonWidget.prototype.updateDomNodeClasses = function() {
|
||||||
var domNodeClasses = this.domNode.className.split(" "),
|
var domNodeClasses = this.domNode.className.split(" "),
|
||||||
oldClasses = this.class.split(" "),
|
oldClasses = this.class.split(" "),
|
||||||
newClasses;
|
newClasses;
|
||||||
this["class"] = this.getAttribute("class","");
|
this["class"] = this.getAttribute("class","");
|
||||||
newClasses = this.class.split(" ");
|
newClasses = this.class.split(" ");
|
||||||
//Remove classes assigned from the old value of class attribute
|
//Remove classes assigned from the old value of class attribute
|
||||||
|
|
|
@ -49,7 +49,7 @@ DroppableWidget.prototype.render = function(parent,nextSibling) {
|
||||||
{name: "dragover", handlerObject: this, handlerMethod: "handleDragOverEvent"},
|
{name: "dragover", handlerObject: this, handlerMethod: "handleDragOverEvent"},
|
||||||
{name: "dragleave", handlerObject: this, handlerMethod: "handleDragLeaveEvent"},
|
{name: "dragleave", handlerObject: this, handlerMethod: "handleDragLeaveEvent"},
|
||||||
{name: "drop", handlerObject: this, handlerMethod: "handleDropEvent"}
|
{name: "drop", handlerObject: this, handlerMethod: "handleDropEvent"}
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
$tw.utils.addClass(this.domNode,this.disabledClass);
|
$tw.utils.addClass(this.domNode,this.disabledClass);
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ DroppableWidget.prototype.execute = function() {
|
||||||
DroppableWidget.prototype.assignDomNodeClasses = function() {
|
DroppableWidget.prototype.assignDomNodeClasses = function() {
|
||||||
var classes = this.getAttribute("class","").split(" ");
|
var classes = this.getAttribute("class","").split(" ");
|
||||||
classes.push("tc-droppable");
|
classes.push("tc-droppable");
|
||||||
this.domNode.className = classes.join(" ");
|
this.domNode.className = classes.join(" ");
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -82,7 +82,7 @@ DropZoneWidget.prototype.resetState = function() {
|
||||||
this.currentlyEntered = [];
|
this.currentlyEntered = [];
|
||||||
this.document.body.removeEventListener("click",this,true);
|
this.document.body.removeEventListener("click",this,true);
|
||||||
this.document.body.removeEventListener("dragenter",this,true);
|
this.document.body.removeEventListener("dragenter",this,true);
|
||||||
this.document.body.removeEventListener("dragleave",this,true);
|
this.document.body.removeEventListener("dragleave",this,true);
|
||||||
this.dragInProgress = false;
|
this.dragInProgress = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ DropZoneWidget.prototype.enterDrag = function(event) {
|
||||||
if(!this.dragInProgress) {
|
if(!this.dragInProgress) {
|
||||||
this.dragInProgress = true;
|
this.dragInProgress = true;
|
||||||
// If we're entering for the first time we need to apply highlighting
|
// If we're entering for the first time we need to apply highlighting
|
||||||
$tw.utils.addClass(this.domNodes[0],"tc-dragover");
|
$tw.utils.addClass(this.domNodes[0],"tc-dragover");
|
||||||
this.document.body.addEventListener("click",this,true);
|
this.document.body.addEventListener("click",this,true);
|
||||||
this.document.body.addEventListener("dragenter",this,true);
|
this.document.body.addEventListener("dragenter",this,true);
|
||||||
this.document.body.addEventListener("dragleave",this,true);
|
this.document.body.addEventListener("dragleave",this,true);
|
||||||
|
|
|
@ -156,7 +156,7 @@ EditBitmapWidget.prototype.loadCanvas = function() {
|
||||||
};
|
};
|
||||||
// Get the current bitmap into an image object
|
// Get the current bitmap into an image object
|
||||||
if(tiddler && tiddler.fields.type && tiddler.fields.text) {
|
if(tiddler && tiddler.fields.type && tiddler.fields.text) {
|
||||||
currImage.src = "data:" + tiddler.fields.type + ";base64," + tiddler.fields.text;
|
currImage.src = "data:" + tiddler.fields.type + ";base64," + tiddler.fields.text;
|
||||||
} else {
|
} else {
|
||||||
currImage.width = DEFAULT_IMAGE_WIDTH;
|
currImage.width = DEFAULT_IMAGE_WIDTH;
|
||||||
currImage.height = DEFAULT_IMAGE_HEIGHT;
|
currImage.height = DEFAULT_IMAGE_HEIGHT;
|
||||||
|
|
|
@ -33,7 +33,7 @@ EditShortcutWidget.prototype.render = function(parent,nextSibling) {
|
||||||
this.inputNode = this.document.createElement("input");
|
this.inputNode = this.document.createElement("input");
|
||||||
// Assign classes
|
// Assign classes
|
||||||
if(this.shortcutClass) {
|
if(this.shortcutClass) {
|
||||||
this.inputNode.className = this.shortcutClass;
|
this.inputNode.className = this.shortcutClass;
|
||||||
}
|
}
|
||||||
// Assign other attributes
|
// Assign other attributes
|
||||||
if(this.shortcutStyle) {
|
if(this.shortcutStyle) {
|
||||||
|
@ -117,7 +117,7 @@ EditShortcutWidget.prototype.handleKeydownEvent = function(event) {
|
||||||
// Ignore the keydown if it was already handled
|
// Ignore the keydown if it was already handled
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ EditShortcutWidget.prototype.refresh = function(changedTiddlers) {
|
||||||
this.updateInputNode();
|
this.updateInputNode();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ ElementWidget.prototype.refresh = function(changedTiddlers) {
|
||||||
if(hasChangedAttributes) {
|
if(hasChangedAttributes) {
|
||||||
if(!this.isReplaced) {
|
if(!this.isReplaced) {
|
||||||
// Update our attributes
|
// Update our attributes
|
||||||
this.assignAttributes(this.domNodes[0],{excludeEventAttributes: true});
|
this.assignAttributes(this.domNodes[0],{excludeEventAttributes: true});
|
||||||
} else {
|
} else {
|
||||||
// If we were replaced then completely refresh ourselves
|
// If we were replaced then completely refresh ourselves
|
||||||
return this.refreshSelf();
|
return this.refreshSelf();
|
||||||
|
|
|
@ -51,7 +51,7 @@ EntityWidget.prototype.refresh = function(changedTiddlers) {
|
||||||
this.refreshSelf();
|
this.refreshSelf();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -37,48 +37,56 @@ EventWidget.prototype.render = function(parent,nextSibling) {
|
||||||
var tag = this.parseTreeNode.isBlock ? "div" : "span";
|
var tag = this.parseTreeNode.isBlock ? "div" : "span";
|
||||||
if(this.elementTag && $tw.config.htmlUnsafeElements.indexOf(this.elementTag) === -1) {
|
if(this.elementTag && $tw.config.htmlUnsafeElements.indexOf(this.elementTag) === -1) {
|
||||||
tag = this.elementTag;
|
tag = this.elementTag;
|
||||||
}
|
}
|
||||||
var domNode = this.document.createElement(tag);
|
var domNode = this.document.createElement(tag);
|
||||||
this.domNode = domNode;
|
this.domNode = domNode;
|
||||||
// Assign classes
|
// Assign classes
|
||||||
this.assignDomNodeClasses();
|
this.assignDomNodeClasses();
|
||||||
// Add our event handler
|
// Add our event handler
|
||||||
$tw.utils.each(this.types,function(type) {
|
$tw.utils.each(this.types,function(type) {
|
||||||
domNode.addEventListener(type,function(event) {
|
domNode.addEventListener(type,function(event) {
|
||||||
var selector = self.getAttribute("selector"),
|
var selector = self.getAttribute("selector"),
|
||||||
actions = self.getAttribute("actions-"+type),
|
actions = self.getAttribute("actions-"+type),
|
||||||
|
stopPropagation = self.getAttribute("stopPropagation","onaction"),
|
||||||
selectedNode = event.target,
|
selectedNode = event.target,
|
||||||
selectedNodeRect,
|
selectedNodeRect,
|
||||||
catcherNodeRect,
|
catcherNodeRect,
|
||||||
variables = {};
|
variables = {};
|
||||||
|
// Firefox can fire dragover and dragenter events on text nodes instead of their parents
|
||||||
|
if(selectedNode.nodeType === 3) {
|
||||||
|
selectedNode = selectedNode.parentNode;
|
||||||
|
}
|
||||||
if(selector) {
|
if(selector) {
|
||||||
// Search ancestors for a node that matches the selector
|
// Search ancestors for a node that matches the selector
|
||||||
while(!selectedNode.matches(selector) && selectedNode !== domNode) {
|
while(!$tw.utils.domMatchesSelector(selectedNode,selector) && selectedNode !== domNode) {
|
||||||
selectedNode = selectedNode.parentNode;
|
selectedNode = selectedNode.parentNode;
|
||||||
}
|
}
|
||||||
// If we found one, copy the attributes as variables, otherwise exit
|
// If we found one, copy the attributes as variables, otherwise exit
|
||||||
if(selectedNode.matches(selector)) {
|
if($tw.utils.domMatchesSelector(selectedNode,selector)) {
|
||||||
$tw.utils.each(selectedNode.attributes,function(attribute) {
|
// Only set up variables if we have actions to invoke
|
||||||
variables["dom-" + attribute.name] = attribute.value.toString();
|
if(actions) {
|
||||||
});
|
$tw.utils.each(selectedNode.attributes,function(attribute) {
|
||||||
//Add a variable with a popup coordinate string for the selected node
|
variables["dom-" + attribute.name] = attribute.value.toString();
|
||||||
variables["tv-popup-coords"] = "(" + selectedNode.offsetLeft + "," + selectedNode.offsetTop +"," + selectedNode.offsetWidth + "," + selectedNode.offsetHeight + ")";
|
});
|
||||||
|
//Add a variable with a popup coordinate string for the selected node
|
||||||
//Add variables for offset of selected node
|
variables["tv-popup-coords"] = "(" + selectedNode.offsetLeft + "," + selectedNode.offsetTop +"," + selectedNode.offsetWidth + "," + selectedNode.offsetHeight + ")";
|
||||||
variables["tv-selectednode-posx"] = selectedNode.offsetLeft.toString();
|
|
||||||
variables["tv-selectednode-posy"] = selectedNode.offsetTop.toString();
|
|
||||||
variables["tv-selectednode-width"] = selectedNode.offsetWidth.toString();
|
|
||||||
variables["tv-selectednode-height"] = selectedNode.offsetHeight.toString();
|
|
||||||
|
|
||||||
//Add variables for event X and Y position relative to selected node
|
//Add variables for offset of selected node
|
||||||
selectedNodeRect = selectedNode.getBoundingClientRect();
|
variables["tv-selectednode-posx"] = selectedNode.offsetLeft.toString();
|
||||||
variables["event-fromselected-posx"] = (event.clientX - selectedNodeRect.left).toString();
|
variables["tv-selectednode-posy"] = selectedNode.offsetTop.toString();
|
||||||
variables["event-fromselected-posy"] = (event.clientY - selectedNodeRect.top).toString();
|
variables["tv-selectednode-width"] = selectedNode.offsetWidth.toString();
|
||||||
|
variables["tv-selectednode-height"] = selectedNode.offsetHeight.toString();
|
||||||
|
|
||||||
//Add variables for event X and Y position relative to event catcher node
|
//Add variables for event X and Y position relative to selected node
|
||||||
catcherNodeRect = self.domNode.getBoundingClientRect();
|
selectedNodeRect = selectedNode.getBoundingClientRect();
|
||||||
variables["event-fromcatcher-posx"] = (event.clientX - catcherNodeRect.left).toString();
|
variables["event-fromselected-posx"] = (event.clientX - selectedNodeRect.left).toString();
|
||||||
variables["event-fromcatcher-posy"] = (event.clientY - catcherNodeRect.top).toString();
|
variables["event-fromselected-posy"] = (event.clientY - selectedNodeRect.top).toString();
|
||||||
|
|
||||||
|
//Add variables for event X and Y position relative to event catcher node
|
||||||
|
catcherNodeRect = self.domNode.getBoundingClientRect();
|
||||||
|
variables["event-fromcatcher-posx"] = (event.clientX - catcherNodeRect.left).toString();
|
||||||
|
variables["event-fromcatcher-posy"] = (event.clientY - catcherNodeRect.top).toString();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -106,6 +114,8 @@ EventWidget.prototype.render = function(parent,nextSibling) {
|
||||||
variables["event-detail"] = event.detail.toString();
|
variables["event-detail"] = event.detail.toString();
|
||||||
}
|
}
|
||||||
self.invokeActionString(actions,self,event,variables);
|
self.invokeActionString(actions,self,event,variables);
|
||||||
|
}
|
||||||
|
if((actions && stopPropagation === "onaction") || stopPropagation === "always") {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
return true;
|
return true;
|
||||||
|
@ -134,7 +144,7 @@ EventWidget.prototype.execute = function() {
|
||||||
EventWidget.prototype.assignDomNodeClasses = function() {
|
EventWidget.prototype.assignDomNodeClasses = function() {
|
||||||
var classes = this.getAttribute("class","").split(" ");
|
var classes = this.getAttribute("class","").split(" ");
|
||||||
classes.push("tc-eventcatcher");
|
classes.push("tc-eventcatcher");
|
||||||
this.domNode.className = classes.join(" ");
|
this.domNode.className = classes.join(" ");
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -58,7 +58,7 @@ FieldManglerWidget.prototype.refresh = function(changedTiddlers) {
|
||||||
this.refreshSelf();
|
this.refreshSelf();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return this.refreshChildren(changedTiddlers);
|
return this.refreshChildren(changedTiddlers);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ FieldManglerWidget.prototype.handleAddTagEvent = function(event) {
|
||||||
if(tag !== "") {
|
if(tag !== "") {
|
||||||
modification.tags = (tiddler.fields.tags || []).slice(0);
|
modification.tags = (tiddler.fields.tags || []).slice(0);
|
||||||
$tw.utils.pushTop(modification.tags,tag);
|
$tw.utils.pushTop(modification.tags,tag);
|
||||||
this.wiki.addTiddler(new $tw.Tiddler(tiddler,modification));
|
this.wiki.addTiddler(new $tw.Tiddler(tiddler,modification));
|
||||||
}
|
}
|
||||||
} else if(typeof event.param === "string" && event.param.trim() !== "" && this.mangleTitle.trim() !== "") {
|
} else if(typeof event.param === "string" && event.param.trim() !== "" && this.mangleTitle.trim() !== "") {
|
||||||
var tag = [];
|
var tag = [];
|
||||||
|
|
|
@ -86,7 +86,7 @@ ImageWidget.prototype.render = function(parent,nextSibling) {
|
||||||
default:
|
default:
|
||||||
src = _canonical_uri;
|
src = _canonical_uri;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Just trigger loading of the tiddler
|
// Just trigger loading of the tiddler
|
||||||
this.wiki.getTiddlerText(this.imageSource);
|
this.wiki.getTiddlerText(this.imageSource);
|
||||||
|
@ -97,7 +97,7 @@ ImageWidget.prototype.render = function(parent,nextSibling) {
|
||||||
var domNode = this.document.createElement(tag);
|
var domNode = this.document.createElement(tag);
|
||||||
domNode.setAttribute("src",src);
|
domNode.setAttribute("src",src);
|
||||||
if(this.imageClass) {
|
if(this.imageClass) {
|
||||||
domNode.setAttribute("class",this.imageClass);
|
domNode.setAttribute("class",this.imageClass);
|
||||||
}
|
}
|
||||||
if(this.imageWidth) {
|
if(this.imageWidth) {
|
||||||
domNode.setAttribute("width",this.imageWidth);
|
domNode.setAttribute("width",this.imageWidth);
|
||||||
|
@ -106,10 +106,10 @@ ImageWidget.prototype.render = function(parent,nextSibling) {
|
||||||
domNode.setAttribute("height",this.imageHeight);
|
domNode.setAttribute("height",this.imageHeight);
|
||||||
}
|
}
|
||||||
if(this.imageTooltip) {
|
if(this.imageTooltip) {
|
||||||
domNode.setAttribute("title",this.imageTooltip);
|
domNode.setAttribute("title",this.imageTooltip);
|
||||||
}
|
}
|
||||||
if(this.imageAlt) {
|
if(this.imageAlt) {
|
||||||
domNode.setAttribute("alt",this.imageAlt);
|
domNode.setAttribute("alt",this.imageAlt);
|
||||||
}
|
}
|
||||||
// Insert element
|
// Insert element
|
||||||
parent.insertBefore(domNode,nextSibling);
|
parent.insertBefore(domNode,nextSibling);
|
||||||
|
@ -138,7 +138,7 @@ ImageWidget.prototype.refresh = function(changedTiddlers) {
|
||||||
this.refreshSelf();
|
this.refreshSelf();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ ImportVariablesWidget.prototype.refresh = function(changedTiddlers) {
|
||||||
this.renderChildren(this.parentDomNode,this.findNextSiblingDomNode());
|
this.renderChildren(this.parentDomNode,this.findNextSiblingDomNode());
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return this.refreshChildren(changedTiddlers);
|
return this.refreshChildren(changedTiddlers);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -44,27 +44,36 @@ KeyboardWidget.prototype.render = function(parent,nextSibling) {
|
||||||
classes.push("tc-keyboard");
|
classes.push("tc-keyboard");
|
||||||
domNode.className = classes.join(" ");
|
domNode.className = classes.join(" ");
|
||||||
// Add a keyboard event handler
|
// Add a keyboard event handler
|
||||||
domNode.addEventListener("keydown",function (event) {
|
$tw.utils.addEventListeners(domNode,[
|
||||||
if($tw.keyboardManager.checkKeyDescriptors(event,self.keyInfoArray)) {
|
{name: "keydown", handlerObject: this, handlerMethod: "handleChangeEvent"}
|
||||||
var handled = self.invokeActions(self,event);
|
]);
|
||||||
if(self.actions) {
|
|
||||||
self.invokeActionString(self.actions,self,event);
|
|
||||||
}
|
|
||||||
self.dispatchMessage(event);
|
|
||||||
if(handled || self.actions || self.message) {
|
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
},false);
|
|
||||||
// Insert element
|
// Insert element
|
||||||
parent.insertBefore(domNode,nextSibling);
|
parent.insertBefore(domNode,nextSibling);
|
||||||
this.renderChildren(domNode,null);
|
this.renderChildren(domNode,null);
|
||||||
this.domNodes.push(domNode);
|
this.domNodes.push(domNode);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
KeyboardWidget.prototype.handleChangeEvent = function(event) {
|
||||||
|
if($tw.keyboardManager.checkKeyDescriptors(event,this.keyInfoArray)) {
|
||||||
|
var handled = this.invokeActions(this,event);
|
||||||
|
if(this.actions) {
|
||||||
|
var variables = {
|
||||||
|
"event-key": event.key,
|
||||||
|
"event-code": event.code,
|
||||||
|
"modifier": $tw.keyboardManager.getEventModifierKeyDescriptor(event)
|
||||||
|
};
|
||||||
|
this.invokeActionString(this.actions,this,event,variables);
|
||||||
|
}
|
||||||
|
this.dispatchMessage(event);
|
||||||
|
if(handled || this.actions || this.message) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
KeyboardWidget.prototype.dispatchMessage = function(event) {
|
KeyboardWidget.prototype.dispatchMessage = function(event) {
|
||||||
this.dispatchEvent({type: this.message, param: this.param, tiddlerTitle: this.getVariable("currentTiddler")});
|
this.dispatchEvent({type: this.message, param: this.param, tiddlerTitle: this.getVariable("currentTiddler")});
|
||||||
};
|
};
|
||||||
|
|
|
@ -77,7 +77,7 @@ LinkWidget.prototype.renderLink = function(parent,nextSibling) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(this.linkClasses) {
|
if(this.linkClasses) {
|
||||||
classes.push(this.linkClasses);
|
classes.push(this.linkClasses);
|
||||||
}
|
}
|
||||||
} else if(this.overrideClasses !== "") {
|
} else if(this.overrideClasses !== "") {
|
||||||
classes.push(this.overrideClasses)
|
classes.push(this.overrideClasses)
|
||||||
|
|
|
@ -61,7 +61,7 @@ LinkCatcherWidget.prototype.refresh = function(changedTiddlers) {
|
||||||
this.refreshSelf();
|
this.refreshSelf();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return this.refreshChildren(changedTiddlers);
|
return this.refreshChildren(changedTiddlers);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ exports.constructor = function(parseTreeNode,options) {
|
||||||
exports.prototype = {};
|
exports.prototype = {};
|
||||||
|
|
||||||
exports.prototype.render = function(event) {
|
exports.prototype.render = function(event) {
|
||||||
Object.getPrototypeOf(Object.getPrototypeOf(this)).render.call(this,event);
|
Object.getPrototypeOf(Object.getPrototypeOf(this)).render.call(this,event);
|
||||||
Object.getPrototypeOf(Object.getPrototypeOf(this)).log.call(this);
|
Object.getPrototypeOf(Object.getPrototypeOf(this)).log.call(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ MacroCallWidget.prototype.execute = function() {
|
||||||
var params = this.parseTreeNode.params ? this.parseTreeNode.params.slice(0) : [];
|
var params = this.parseTreeNode.params ? this.parseTreeNode.params.slice(0) : [];
|
||||||
$tw.utils.each(this.attributes,function(attribute,name) {
|
$tw.utils.each(this.attributes,function(attribute,name) {
|
||||||
if(name.charAt(0) !== "$") {
|
if(name.charAt(0) !== "$") {
|
||||||
params.push({name: name, value: attribute});
|
params.push({name: name, value: attribute});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Get the macro value
|
// Get the macro value
|
||||||
|
|
|
@ -95,7 +95,7 @@ NavigatorWidget.prototype.saveStoryList = function(storyList) {
|
||||||
{title: this.storyTitle},
|
{title: this.storyTitle},
|
||||||
storyTiddler,
|
storyTiddler,
|
||||||
{list: storyList}
|
{list: storyList}
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ NavigatorWidget.prototype.removeTitleFromStory = function(storyList,title) {
|
||||||
while(p !== -1) {
|
while(p !== -1) {
|
||||||
storyList.splice(p,1);
|
storyList.splice(p,1);
|
||||||
p = storyList.indexOf(title);
|
p = storyList.indexOf(title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ NavigatorWidget.prototype.replaceFirstTitleInStory = function(storyList,oldTitle
|
||||||
} while(pos !== -1);
|
} while(pos !== -1);
|
||||||
} else {
|
} else {
|
||||||
storyList.splice(0,0,newTitle);
|
storyList.splice(0,0,newTitle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -522,10 +522,15 @@ NavigatorWidget.prototype.handleImportTiddlersEvent = function(event) {
|
||||||
});
|
});
|
||||||
// Give the active upgrader modules a chance to process the incoming tiddlers
|
// Give the active upgrader modules a chance to process the incoming tiddlers
|
||||||
var messages = this.wiki.invokeUpgraders(incomingTiddlers,importData.tiddlers);
|
var messages = this.wiki.invokeUpgraders(incomingTiddlers,importData.tiddlers);
|
||||||
|
// Deselect any disabled, but _not_ suppressed tiddlers
|
||||||
|
var systemMessage = $tw.language.getString("Import/Upgrader/Tiddler/Unselected");
|
||||||
$tw.utils.each(messages,function(message,title) {
|
$tw.utils.each(messages,function(message,title) {
|
||||||
newFields["message-" + title] = message;
|
newFields["message-" + title] = message;
|
||||||
|
if (message.indexOf(systemMessage) !== -1) {
|
||||||
|
newFields["selection-" + title] = "unchecked";
|
||||||
|
}
|
||||||
});
|
});
|
||||||
// Deselect any suppressed tiddlers
|
// Deselect suppressed tiddlers ... they have been removed and can't be selected anymore
|
||||||
$tw.utils.each(importData.tiddlers,function(tiddler,title) {
|
$tw.utils.each(importData.tiddlers,function(tiddler,title) {
|
||||||
if($tw.utils.count(tiddler) === 0) {
|
if($tw.utils.count(tiddler) === 0) {
|
||||||
newFields["selection-" + title] = "unchecked";
|
newFields["selection-" + title] = "unchecked";
|
||||||
|
@ -557,10 +562,12 @@ NavigatorWidget.prototype.handleImportTiddlersEvent = function(event) {
|
||||||
NavigatorWidget.prototype.handlePerformImportEvent = function(event) {
|
NavigatorWidget.prototype.handlePerformImportEvent = function(event) {
|
||||||
var self = this,
|
var self = this,
|
||||||
importTiddler = this.wiki.getTiddler(event.param),
|
importTiddler = this.wiki.getTiddler(event.param),
|
||||||
importData = this.wiki.getTiddlerDataCached(event.param,{tiddlers: {}}),
|
importData,
|
||||||
importReport = [];
|
importReport = [];
|
||||||
// Add the tiddlers to the store
|
|
||||||
importReport.push($tw.language.getString("Import/Imported/Hint") + "\n");
|
importReport.push($tw.language.getString("Import/Imported/Hint") + "\n");
|
||||||
|
// If you need to modify the import tiddler payload then consider th-importing-tiddler instead
|
||||||
|
importTiddler = $tw.hooks.invokeHook("th-before-importing",importTiddler);
|
||||||
|
importData = this.wiki.getTiddlerDataCached(event.param,{tiddlers: {}}),
|
||||||
$tw.utils.each(importData.tiddlers,function(tiddlerFields) {
|
$tw.utils.each(importData.tiddlers,function(tiddlerFields) {
|
||||||
var title = tiddlerFields.title;
|
var title = tiddlerFields.title;
|
||||||
if(title && importTiddler && importTiddler.fields["selection-" + title] !== "unchecked") {
|
if(title && importTiddler && importTiddler.fields["selection-" + title] !== "unchecked") {
|
||||||
|
@ -569,7 +576,10 @@ NavigatorWidget.prototype.handlePerformImportEvent = function(event) {
|
||||||
} else {
|
} else {
|
||||||
var tiddler = new $tw.Tiddler(tiddlerFields);
|
var tiddler = new $tw.Tiddler(tiddlerFields);
|
||||||
}
|
}
|
||||||
|
// th-importing-tiddler doesn't allow user interaction by default
|
||||||
|
// If you want to use the default UI then use: $:/core/modules/upgraders/ instead
|
||||||
tiddler = $tw.hooks.invokeHook("th-importing-tiddler",tiddler);
|
tiddler = $tw.hooks.invokeHook("th-importing-tiddler",tiddler);
|
||||||
|
// Add the tiddlers to the store
|
||||||
self.wiki.addTiddler(tiddler);
|
self.wiki.addTiddler(tiddler);
|
||||||
importReport.push("# [[" + tiddler.fields.title + "]]");
|
importReport.push("# [[" + tiddler.fields.title + "]]");
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ RawWidget.prototype.render = function(parent,nextSibling) {
|
||||||
var div = this.document.createElement("div");
|
var div = this.document.createElement("div");
|
||||||
div.innerHTML=this.parseTreeNode.html;
|
div.innerHTML=this.parseTreeNode.html;
|
||||||
parent.insertBefore(div,nextSibling);
|
parent.insertBefore(div,nextSibling);
|
||||||
this.domNodes.push(div);
|
this.domNodes.push(div);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -72,7 +72,7 @@ RevealWidget.prototype.positionPopup = function(domNode) {
|
||||||
case "belowright":
|
case "belowright":
|
||||||
left = this.popup.left + this.popup.width;
|
left = this.popup.left + this.popup.width;
|
||||||
top = this.popup.top + this.popup.height;
|
top = this.popup.top + this.popup.height;
|
||||||
break;
|
break;
|
||||||
case "right":
|
case "right":
|
||||||
left = this.popup.left + this.popup.width;
|
left = this.popup.left + this.popup.width;
|
||||||
top = this.popup.top;
|
top = this.popup.top;
|
||||||
|
@ -84,7 +84,7 @@ RevealWidget.prototype.positionPopup = function(domNode) {
|
||||||
case "aboveleft":
|
case "aboveleft":
|
||||||
left = this.popup.left - domNode.offsetWidth;
|
left = this.popup.left - domNode.offsetWidth;
|
||||||
top = this.popup.top - domNode.offsetHeight;
|
top = this.popup.top - domNode.offsetHeight;
|
||||||
break;
|
break;
|
||||||
default: // Below
|
default: // Below
|
||||||
left = this.popup.left;
|
left = this.popup.left;
|
||||||
top = this.popup.top + this.popup.height;
|
top = this.popup.top + this.popup.height;
|
||||||
|
@ -234,7 +234,7 @@ RevealWidget.prototype.refresh = function(changedTiddlers) {
|
||||||
}
|
}
|
||||||
if(changedAttributes["class"]) {
|
if(changedAttributes["class"]) {
|
||||||
this.assignDomNodeClasses();
|
this.assignDomNodeClasses();
|
||||||
}
|
}
|
||||||
return this.refreshChildren(changedTiddlers);
|
return this.refreshChildren(changedTiddlers);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -41,7 +41,7 @@ ScrollableWidget.prototype.handleScrollEvent = function(event) {
|
||||||
if(event.paramObject && event.paramObject.selector) {
|
if(event.paramObject && event.paramObject.selector) {
|
||||||
this.scrollSelectorIntoView(null,event.paramObject.selector);
|
this.scrollSelectorIntoView(null,event.paramObject.selector);
|
||||||
} else {
|
} else {
|
||||||
this.scrollIntoView(event.target);
|
this.scrollIntoView(event.target);
|
||||||
}
|
}
|
||||||
return false; // Handled event
|
return false; // Handled event
|
||||||
};
|
};
|
||||||
|
@ -97,7 +97,7 @@ ScrollableWidget.prototype.scrollIntoView = function(element) {
|
||||||
if(duration <= 0) {
|
if(duration <= 0) {
|
||||||
t = 1;
|
t = 1;
|
||||||
} else {
|
} else {
|
||||||
t = ((Date.now()) - self.startTime) / duration;
|
t = ((Date.now()) - self.startTime) / duration;
|
||||||
}
|
}
|
||||||
if(t >= 1) {
|
if(t >= 1) {
|
||||||
self.cancelScroll();
|
self.cancelScroll();
|
||||||
|
@ -118,7 +118,7 @@ ScrollableWidget.prototype.scrollSelectorIntoView = function(baseElement,selecto
|
||||||
baseElement = baseElement || document.body;
|
baseElement = baseElement || document.body;
|
||||||
var element = baseElement.querySelector(selector);
|
var element = baseElement.querySelector(selector);
|
||||||
if(element) {
|
if(element) {
|
||||||
this.scrollIntoView(element,callback);
|
this.scrollIntoView(element,callback);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ SetWidget.prototype.getValue = function() {
|
||||||
if(this.setSubTiddler) {
|
if(this.setSubTiddler) {
|
||||||
tiddler = this.wiki.getSubTiddler(this.setTiddler,this.setSubTiddler);
|
tiddler = this.wiki.getSubTiddler(this.setTiddler,this.setSubTiddler);
|
||||||
} else {
|
} else {
|
||||||
tiddler = this.wiki.getTiddler(this.setTiddler);
|
tiddler = this.wiki.getTiddler(this.setTiddler);
|
||||||
}
|
}
|
||||||
if(!tiddler) {
|
if(!tiddler) {
|
||||||
value = this.setEmptyValue;
|
value = this.setEmptyValue;
|
||||||
|
@ -84,7 +84,7 @@ SetWidget.prototype.getValue = function() {
|
||||||
if(select !== undefined) {
|
if(select !== undefined) {
|
||||||
value = results[select] || "";
|
value = results[select] || "";
|
||||||
} else {
|
} else {
|
||||||
value = $tw.utils.stringifyList(results);
|
value = $tw.utils.stringifyList(results);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(results.length === 0 && this.setEmptyValue !== undefined) {
|
if(results.length === 0 && this.setEmptyValue !== undefined) {
|
||||||
|
|
|
@ -53,7 +53,7 @@ TextNodeWidget.prototype.refresh = function(changedTiddlers) {
|
||||||
this.refreshSelf();
|
this.refreshSelf();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ TiddlerWidget.prototype.refresh = function(changedTiddlers) {
|
||||||
this.refreshSelf();
|
this.refreshSelf();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return this.refreshChildren(changedTiddlers);
|
return this.refreshChildren(changedTiddlers);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ TranscludeWidget.prototype.refresh = function(changedTiddlers) {
|
||||||
this.refreshSelf();
|
this.refreshSelf();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return this.refreshChildren(changedTiddlers);
|
return this.refreshChildren(changedTiddlers);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ This widget allows multiple variables to be set in one go:
|
||||||
var Widget = require("$:/core/modules/widgets/widget.js").widget;
|
var Widget = require("$:/core/modules/widgets/widget.js").widget;
|
||||||
|
|
||||||
var VarsWidget = function(parseTreeNode,options) {
|
var VarsWidget = function(parseTreeNode,options) {
|
||||||
// Initialise
|
// Initialise
|
||||||
this.initialise(parseTreeNode,options);
|
this.initialise(parseTreeNode,options);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ ViewWidget.prototype.getValue = function(options) {
|
||||||
} else {
|
} else {
|
||||||
var tiddler;
|
var tiddler;
|
||||||
if(this.viewSubtiddler) {
|
if(this.viewSubtiddler) {
|
||||||
tiddler = this.wiki.getSubTiddler(this.viewTitle,this.viewSubtiddler);
|
tiddler = this.wiki.getSubTiddler(this.viewTitle,this.viewSubtiddler);
|
||||||
} else {
|
} else {
|
||||||
tiddler = this.wiki.getTiddler(this.viewTitle);
|
tiddler = this.wiki.getTiddler(this.viewTitle);
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ ViewWidget.prototype.getValue = function(options) {
|
||||||
if(options.asString) {
|
if(options.asString) {
|
||||||
value = tiddler.getFieldString(this.viewField);
|
value = tiddler.getFieldString(this.viewField);
|
||||||
} else {
|
} else {
|
||||||
value = tiddler.fields[this.viewField];
|
value = tiddler.fields[this.viewField];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,7 @@ ViewWidget.prototype.refresh = function(changedTiddlers) {
|
||||||
this.refreshSelf();
|
this.refreshSelf();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ Widget.prototype.getVariableInfo = function(name,options) {
|
||||||
});
|
});
|
||||||
// Only substitute variable references if this variable was defined with the \define pragma
|
// Only substitute variable references if this variable was defined with the \define pragma
|
||||||
if(variable.isMacroDefinition) {
|
if(variable.isMacroDefinition) {
|
||||||
value = this.substituteVariableReferences(value);
|
value = this.substituteVariableReferences(value);
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
text: value,
|
text: value,
|
||||||
|
@ -569,9 +569,10 @@ Widget.prototype.invokeActions = function(triggeringWidget,event) {
|
||||||
// For each child widget
|
// For each child widget
|
||||||
for(var t=0; t<this.children.length; t++) {
|
for(var t=0; t<this.children.length; t++) {
|
||||||
var child = this.children[t];
|
var child = this.children[t];
|
||||||
|
// Rerender the child to ensure the attribute values are up to date
|
||||||
|
child.refreshSelf();
|
||||||
// Invoke the child if it is an action widget
|
// Invoke the child if it is an action widget
|
||||||
if(child.invokeAction) {
|
if(child.invokeAction) {
|
||||||
child.refreshSelf();
|
|
||||||
if(child.invokeAction(triggeringWidget,event)) {
|
if(child.invokeAction(triggeringWidget,event)) {
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ WikifyWidget.prototype.getWidgetTree = function() {
|
||||||
break;
|
break;
|
||||||
case "text":
|
case "text":
|
||||||
resultNode.text = widgetNode.parseTreeNode.text;
|
resultNode.text = widgetNode.parseTreeNode.text;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(Object.keys(widgetNode.attributes || {}).length > 0) {
|
if(Object.keys(widgetNode.attributes || {}).length > 0) {
|
||||||
resultNode.attributes = {};
|
resultNode.attributes = {};
|
||||||
|
|
|
@ -111,7 +111,7 @@ exports.deleteTextReference = function(textRef,currTiddlerTitle) {
|
||||||
exports.addEventListener = function(type,listener) {
|
exports.addEventListener = function(type,listener) {
|
||||||
this.eventListeners = this.eventListeners || {};
|
this.eventListeners = this.eventListeners || {};
|
||||||
this.eventListeners[type] = this.eventListeners[type] || [];
|
this.eventListeners[type] = this.eventListeners[type] || [];
|
||||||
this.eventListeners[type].push(listener);
|
this.eventListeners[type].push(listener);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.removeEventListener = function(type,listener) {
|
exports.removeEventListener = function(type,listener) {
|
||||||
|
@ -221,9 +221,13 @@ exports.isTemporaryTiddler = function(title) {
|
||||||
return title && title.indexOf("$:/temp/") === 0;
|
return title && title.indexOf("$:/temp/") === 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.isVolatileTiddler = function(title) {
|
||||||
|
return title && title.indexOf("$:/temp/volatile/") === 0;
|
||||||
|
};
|
||||||
|
|
||||||
exports.isImageTiddler = function(title) {
|
exports.isImageTiddler = function(title) {
|
||||||
var tiddler = this.getTiddler(title);
|
var tiddler = this.getTiddler(title);
|
||||||
if(tiddler) {
|
if(tiddler) {
|
||||||
var contentTypeInfo = $tw.config.contentTypeInfo[tiddler.fields.type || "text/vnd.tiddlywiki"];
|
var contentTypeInfo = $tw.config.contentTypeInfo[tiddler.fields.type || "text/vnd.tiddlywiki"];
|
||||||
return !!contentTypeInfo && contentTypeInfo.flags.indexOf("image") !== -1;
|
return !!contentTypeInfo && contentTypeInfo.flags.indexOf("image") !== -1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -233,7 +237,7 @@ exports.isImageTiddler = function(title) {
|
||||||
|
|
||||||
exports.isBinaryTiddler = function(title) {
|
exports.isBinaryTiddler = function(title) {
|
||||||
var tiddler = this.getTiddler(title);
|
var tiddler = this.getTiddler(title);
|
||||||
if(tiddler) {
|
if(tiddler) {
|
||||||
var contentTypeInfo = $tw.config.contentTypeInfo[tiddler.fields.type || "text/vnd.tiddlywiki"];
|
var contentTypeInfo = $tw.config.contentTypeInfo[tiddler.fields.type || "text/vnd.tiddlywiki"];
|
||||||
return !!contentTypeInfo && contentTypeInfo.encoding === "base64";
|
return !!contentTypeInfo && contentTypeInfo.encoding === "base64";
|
||||||
} else {
|
} else {
|
||||||
|
@ -730,7 +734,7 @@ exports.getTiddlerDataCached = function(titleOrTiddler,defaultData) {
|
||||||
var self = this,
|
var self = this,
|
||||||
tiddler = titleOrTiddler;
|
tiddler = titleOrTiddler;
|
||||||
if(!(tiddler instanceof $tw.Tiddler)) {
|
if(!(tiddler instanceof $tw.Tiddler)) {
|
||||||
tiddler = this.getTiddler(tiddler);
|
tiddler = this.getTiddler(tiddler);
|
||||||
}
|
}
|
||||||
if(tiddler) {
|
if(tiddler) {
|
||||||
return this.getCacheForTiddler(tiddler.fields.title,"data",function() {
|
return this.getCacheForTiddler(tiddler.fields.title,"data",function() {
|
||||||
|
@ -751,7 +755,7 @@ exports.getTiddlerData = function(titleOrTiddler,defaultData) {
|
||||||
var tiddler = titleOrTiddler,
|
var tiddler = titleOrTiddler,
|
||||||
data;
|
data;
|
||||||
if(!(tiddler instanceof $tw.Tiddler)) {
|
if(!(tiddler instanceof $tw.Tiddler)) {
|
||||||
tiddler = this.getTiddler(tiddler);
|
tiddler = this.getTiddler(tiddler);
|
||||||
}
|
}
|
||||||
if(tiddler && tiddler.fields.text) {
|
if(tiddler && tiddler.fields.text) {
|
||||||
switch(tiddler.fields.type) {
|
switch(tiddler.fields.type) {
|
||||||
|
@ -881,7 +885,7 @@ exports.initParsers = function(moduleType) {
|
||||||
if(!$tw.utils.hop($tw.Wiki.parsers,type) && $tw.config.contentTypeInfo[type].encoding === "base64") {
|
if(!$tw.utils.hop($tw.Wiki.parsers,type) && $tw.config.contentTypeInfo[type].encoding === "base64") {
|
||||||
$tw.Wiki.parsers[type] = $tw.Wiki.parsers["application/octet-stream"];
|
$tw.Wiki.parsers[type] = $tw.Wiki.parsers["application/octet-stream"];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -945,7 +949,7 @@ exports.parseTextReference = function(title,field,index,options) {
|
||||||
}
|
}
|
||||||
if(field === "text" || (!field && !index)) {
|
if(field === "text" || (!field && !index)) {
|
||||||
if(tiddler && tiddler.fields) {
|
if(tiddler && tiddler.fields) {
|
||||||
return this.parseText(tiddler.fields.type,tiddler.fields.text,options);
|
return this.parseText(tiddler.fields.type,tiddler.fields.text,options);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1153,7 +1157,7 @@ exports.search = function(text,options) {
|
||||||
searchTermsRegExps = [new RegExp("(" + anchor + terms.join("\\s+") + ")",flags)];
|
searchTermsRegExps = [new RegExp("(" + anchor + terms.join("\\s+") + ")",flags)];
|
||||||
} else if(options.regexp) {
|
} else if(options.regexp) {
|
||||||
try {
|
try {
|
||||||
searchTermsRegExps = [new RegExp("(" + text + ")",flags)];
|
searchTermsRegExps = [new RegExp("(" + text + ")",flags)];
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
searchTermsRegExps = null;
|
searchTermsRegExps = null;
|
||||||
console.log("Regexp error parsing /(" + text + ")/" + flags + ": ",e);
|
console.log("Regexp error parsing /(" + text + ")/" + flags + ": ",e);
|
||||||
|
@ -1175,7 +1179,7 @@ exports.search = function(text,options) {
|
||||||
if($tw.utils.isArray(options.field)) {
|
if($tw.utils.isArray(options.field)) {
|
||||||
$tw.utils.each(options.field,function(fieldName) {
|
$tw.utils.each(options.field,function(fieldName) {
|
||||||
if(fieldName) {
|
if(fieldName) {
|
||||||
fields.push(fieldName);
|
fields.push(fieldName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -1444,7 +1448,7 @@ historyTitle: title of history tiddler (defaults to $:/HistoryList)
|
||||||
*/
|
*/
|
||||||
exports.addToHistory = function(title,fromPageRect,historyTitle) {
|
exports.addToHistory = function(title,fromPageRect,historyTitle) {
|
||||||
var story = new $tw.Story({wiki: this, historyTitle: historyTitle});
|
var story = new $tw.Story({wiki: this, historyTitle: historyTitle});
|
||||||
story.addToHistory(title,fromPageRect);
|
story.addToHistory(title,fromPageRect);
|
||||||
console.log("$tw.wiki.addToHistory() is deprecated since V5.1.23! Use the this.story.addToHistory() from the story-object!")
|
console.log("$tw.wiki.addToHistory() is deprecated since V5.1.23! Use the this.story.addToHistory() from the story-object!")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1505,6 +1509,13 @@ exports.invokeUpgraders = function(titles,tiddlers) {
|
||||||
|
|
||||||
// Determine whether a plugin by title is dynamically loadable
|
// Determine whether a plugin by title is dynamically loadable
|
||||||
exports.doesPluginRequireReload = function(title) {
|
exports.doesPluginRequireReload = function(title) {
|
||||||
|
var tiddler = this.getTiddler(title);
|
||||||
|
if(tiddler && tiddler.fields.type === "application/json" && tiddler.fields["plugin-type"]) {
|
||||||
|
if(tiddler.fields["plugin-type"] === "import") {
|
||||||
|
// The import plugin never requires reloading
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
return this.doesPluginInfoRequireReload(this.getPluginInfo(title) || this.getTiddlerDataCached(title));
|
return this.doesPluginInfoRequireReload(this.getPluginInfo(title) || this.getTiddlerDataCached(title));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1568,4 +1579,3 @@ exports.unslugify = function(slug) {
|
||||||
};
|
};
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
title: $:/palettes/Blanca
|
title: $:/palettes/Blanca
|
||||||
name: Blanca
|
name: Blanca
|
||||||
|
color-scheme: light
|
||||||
description: A clean white palette to let you focus
|
description: A clean white palette to let you focus
|
||||||
tags: $:/tags/Palette
|
tags: $:/tags/Palette
|
||||||
type: application/x-tiddler-dictionary
|
type: application/x-tiddler-dictionary
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
title: $:/palettes/Blue
|
title: $:/palettes/Blue
|
||||||
name: Blue
|
name: Blue
|
||||||
|
color-scheme: light
|
||||||
description: A blue theme
|
description: A blue theme
|
||||||
tags: $:/tags/Palette
|
tags: $:/tags/Palette
|
||||||
type: application/x-tiddler-dictionary
|
type: application/x-tiddler-dictionary
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
title: $:/palettes/Muted
|
title: $:/palettes/Muted
|
||||||
name: Muted
|
name: Muted
|
||||||
|
color-scheme: light
|
||||||
description: Bright tiddlers on a muted background
|
description: Bright tiddlers on a muted background
|
||||||
tags: $:/tags/Palette
|
tags: $:/tags/Palette
|
||||||
type: application/x-tiddler-dictionary
|
type: application/x-tiddler-dictionary
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
title: $:/palettes/ContrastLight
|
title: $:/palettes/ContrastLight
|
||||||
name: Contrast (Light)
|
name: Contrast (Light)
|
||||||
|
color-scheme: light
|
||||||
description: High contrast and unambiguous (light version)
|
description: High contrast and unambiguous (light version)
|
||||||
tags: $:/tags/Palette
|
tags: $:/tags/Palette
|
||||||
type: application/x-tiddler-dictionary
|
type: application/x-tiddler-dictionary
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
title: $:/palettes/ContrastDark
|
title: $:/palettes/ContrastDark
|
||||||
name: Contrast (Dark)
|
name: Contrast (Dark)
|
||||||
|
color-scheme: dark
|
||||||
description: High contrast and unambiguous (dark version)
|
description: High contrast and unambiguous (dark version)
|
||||||
tags: $:/tags/Palette
|
tags: $:/tags/Palette
|
||||||
type: application/x-tiddler-dictionary
|
type: application/x-tiddler-dictionary
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
title: $:/palettes/CupertinoDark
|
title: $:/palettes/CupertinoDark
|
||||||
tags: $:/tags/Palette
|
tags: $:/tags/Palette
|
||||||
|
color-scheme: dark
|
||||||
name: Cupertino Dark
|
name: Cupertino Dark
|
||||||
description: A macOS inspired dark palette
|
description: A macOS inspired dark palette
|
||||||
type: application/x-tiddler-dictionary
|
type: application/x-tiddler-dictionary
|
||||||
|
|
|
@ -5,6 +5,7 @@ name: DarkPhotos
|
||||||
tags: $:/tags/Palette
|
tags: $:/tags/Palette
|
||||||
title: $:/palettes/DarkPhotos
|
title: $:/palettes/DarkPhotos
|
||||||
type: application/x-tiddler-dictionary
|
type: application/x-tiddler-dictionary
|
||||||
|
color-scheme: light
|
||||||
|
|
||||||
alert-background: #ffe476
|
alert-background: #ffe476
|
||||||
alert-border: #b99e2f
|
alert-border: #b99e2f
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user