1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2026-01-25 20:33:41 +00:00

Compare commits

..

2 Commits

Author SHA1 Message Date
Jeremy Ruston
0f51406c08 Don't use a fixed ID 2023-09-19 15:06:03 +01:00
Jeremy Ruston
049797b7cf Add barcode reader widget to qrcode plugin 2023-09-16 12:01:49 +01:00
335 changed files with 685 additions and 3611 deletions

View File

@@ -5,7 +5,7 @@ on:
- master - master
- tiddlywiki-com - tiddlywiki-com
env: env:
NODE_VERSION: "18" NODE_VERSION: "12"
jobs: jobs:
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -14,13 +14,7 @@ jobs:
- uses: actions/setup-node@v1 - uses: actions/setup-node@v1
with: with:
node-version: "${{ env.NODE_VERSION }}" node-version: "${{ env.NODE_VERSION }}"
- run: "./bin/ci-test.sh" - run: "./bin/test.sh"
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
build-prerelease: build-prerelease:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' if: github.ref == 'refs/heads/master'
@@ -60,7 +54,6 @@ jobs:
TW5_BUILD_TIDDLYWIKI: "./node_modules/tiddlywiki/tiddlywiki.js" TW5_BUILD_TIDDLYWIKI: "./node_modules/tiddlywiki/tiddlywiki.js"
TW5_BUILD_MAIN_EDITION: "./editions/tw5.com" TW5_BUILD_MAIN_EDITION: "./editions/tw5.com"
TW5_BUILD_OUTPUT: "./output" TW5_BUILD_OUTPUT: "./output"
TW5_BUILD_ARCHIVE: "./output"
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-node@v1 - uses: actions/setup-node@v1

4
.gitignore vendored
View File

@@ -5,6 +5,4 @@
tmp/ tmp/
output/ output/
node_modules/ node_modules/
/test-results/
/playwright-report/
/playwright/.cache/

View File

@@ -5,7 +5,7 @@
# Default to the current version number for building the plugin library # Default to the current version number for building the plugin library
if [ -z "$TW5_BUILD_VERSION" ]; then if [ -z "$TW5_BUILD_VERSION" ]; then
TW5_BUILD_VERSION=v5.3.3 TW5_BUILD_VERSION=v5.3.2
fi fi
echo "Using TW5_BUILD_VERSION as [$TW5_BUILD_VERSION]" echo "Using TW5_BUILD_VERSION as [$TW5_BUILD_VERSION]"
@@ -84,27 +84,10 @@ echo -e -n "title: $:/build\ncommit: $TW5_BUILD_COMMIT\n\n$TW5_BUILD_DETAILS\n"
###################################################### ######################################################
# #
# Core distributions # Core distribution
# #
###################################################### ######################################################
# Conditionally build archive if $TW5_BUILD_ARCHIVE variable is set, otherwise do nothing
#
# /archive/Empty-TiddlyWiki-<version>.html Empty archived version
# /archive/TiddlyWiki-<version>.html Full archived version
if [ -n "$TW5_BUILD_ARCHIVE" ]; then
node $TW5_BUILD_TIDDLYWIKI \
$TW5_BUILD_MAIN_EDITION \
--verbose \
--version \
--load $TW5_BUILD_OUTPUT/build.tid \
--output $TW5_BUILD_ARCHIVE \
--build archive \
|| exit 1
fi
# /index.html Main site # /index.html Main site
# /favicon.ico Favicon for main site # /favicon.ico Favicon for main site
# /static.html Static rendering of default tiddlers # /static.html Static rendering of default tiddlers
@@ -112,7 +95,6 @@ fi
# /static/* Static single tiddlers # /static/* Static single tiddlers
# /static/static.css Static stylesheet # /static/static.css Static stylesheet
# /static/favicon.ico Favicon for static pages # /static/favicon.ico Favicon for static pages
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
$TW5_BUILD_MAIN_EDITION \ $TW5_BUILD_MAIN_EDITION \
--verbose \ --verbose \

View File

@@ -1,16 +0,0 @@
#!/bin/bash
# test TiddlyWiki5 for tiddlywiki.com
node ./tiddlywiki.js \
./editions/test \
--verbose \
--version \
--rendertiddler $:/core/save/all test.html text/plain \
--test \
|| exit 1
npm install playwright @playwright/test
npx playwright install chromium firefox --with-deps
npx playwright test

View File

@@ -2674,18 +2674,6 @@ $tw.hooks.addHook = function(hookName,definition) {
} }
}; };
/*
Delete hooks from the hashmap
*/
$tw.hooks.removeHook = function(hookName,definition) {
if($tw.utils.hop($tw.hooks.names,hookName)) {
var p = $tw.hooks.names[hookName].indexOf(definition);
if(p !== -1) {
$tw.hooks.names[hookName].splice(p, 1);
}
}
};
/* /*
Invoke the hook by key Invoke the hook by key
*/ */

View File

@@ -3,4 +3,4 @@ title: $:/language/Exporters/
StaticRiver: Static HTML StaticRiver: Static HTML
JsonFile: JSON file JsonFile: JSON file
CsvFile: CSV file CsvFile: CSV file
TidFile: TID text file TidFile: ".tid" file

View File

@@ -10,7 +10,7 @@ Sequentially run the command tokens returned from a filter
Examples Examples
``` ```
--commands "[enlist:raw{$:/build-commands-as-text}]" --commands "[enlist{$:/build-commands-as-text}]"
``` ```
``` ```

View File

@@ -19,7 +19,7 @@ The following options are supported:
** ''yes'' will "explode" plugins into separate tiddler files and save them to the plugin directory within the wiki folder ** ''yes'' will "explode" plugins into separate tiddler files and save them to the plugin directory within the wiki folder
** ''no'' will suppress exploding plugins into their constituent tiddler files. It will save the plugin as a single JSON tiddler in the tiddlers folder ** ''no'' will suppress exploding plugins into their constituent tiddler files. It will save the plugin as a single JSON tiddler in the tiddlers folder
Note that both ''explodePlugins'' options will produce wiki folders that build the exact same original wiki. The difference lies in how plugins are represented in the wiki folder. Note that both ''explodePlugins'' options will produce wiki folders that build the same exact same original wiki. The difference lies in how plugins are represented in the wiki folder.
A common usage is to convert a TiddlyWiki HTML file into a wiki folder: A common usage is to convert a TiddlyWiki HTML file into a wiki folder:

View File

@@ -1,5 +1,5 @@
title: $:/language/Docs/Types/image/svg+xml title: $:/language/Docs/Types/image/svg+xml
description: SVG image description: Structured Vector Graphics image
name: image/svg+xml name: image/svg+xml
group: Image group: Image
group-sort: 1 group-sort: 1

View File

@@ -1,5 +1,5 @@
title: $:/language/Docs/Types/image/x-icon title: $:/language/Docs/Types/image/x-icon
description: ICO icon description: ICO format icon file
name: image/x-icon name: image/x-icon
group: Image group: Image
group-sort: 1 group-sort: 1

View File

@@ -46,7 +46,7 @@ Command.prototype.execute = function() {
type = tiddler.fields.type || "text/vnd.tiddlywiki", type = tiddler.fields.type || "text/vnd.tiddlywiki",
contentTypeInfo = $tw.config.contentTypeInfo[type] || {encoding: "utf8"}, contentTypeInfo = $tw.config.contentTypeInfo[type] || {encoding: "utf8"},
filename = path.resolve(pathname,$tw.utils.encodeURIComponentExtended(title)); filename = path.resolve(pathname,$tw.utils.encodeURIComponentExtended(title));
fs.writeFileSync(filename,tiddler.fields.text || "",contentTypeInfo.encoding); fs.writeFileSync(filename,tiddler.fields.text,contentTypeInfo.encoding);
}); });
return null; return null;
}; };

View File

@@ -28,8 +28,12 @@ function getAllFilterOperators() {
Export our filter function Export our filter function
*/ */
exports.all = function(source,operator,options) { exports.all = function(source,operator,options) {
// Get our suboperators
var allFilterOperators = getAllFilterOperators();
// Cycle through the suboperators accumulating their results
var results = new $tw.utils.LinkedList(),
subops = operator.operand.split("+");
// Check for common optimisations // Check for common optimisations
var subops = operator.operand.split("+");
if(subops.length === 1 && subops[0] === "") { if(subops.length === 1 && subops[0] === "") {
return source; return source;
} else if(subops.length === 1 && subops[0] === "tiddlers") { } else if(subops.length === 1 && subops[0] === "tiddlers") {
@@ -42,10 +46,6 @@ exports.all = function(source,operator,options) {
return options.wiki.eachShadowPlusTiddlers; return options.wiki.eachShadowPlusTiddlers;
} }
// Do it the hard way // Do it the hard way
// Get our suboperators
var allFilterOperators = getAllFilterOperators();
// Cycle through the suboperators accumulating their results
var results = new $tw.utils.LinkedList();
for(var t=0; t<subops.length; t++) { for(var t=0; t<subops.length; t++) {
var subop = allFilterOperators[subops[t]]; var subop = allFilterOperators[subops[t]];
if(subop) { if(subop) {

View File

@@ -18,20 +18,16 @@ Export our filter functions
exports.decodebase64 = function(source,operator,options) { exports.decodebase64 = function(source,operator,options) {
var results = []; var results = [];
var binary = operator.suffixes && operator.suffixes.indexOf("binary") !== -1;
var urlsafe = operator.suffixes && operator.suffixes.indexOf("urlsafe") !== -1;
source(function(tiddler,title) { source(function(tiddler,title) {
results.push($tw.utils.base64Decode(title,binary,urlsafe)); results.push($tw.utils.base64Decode(title));
}); });
return results; return results;
}; };
exports.encodebase64 = function(source,operator,options) { exports.encodebase64 = function(source,operator,options) {
var results = []; var results = [];
var binary = operator.suffixes && operator.suffixes.indexOf("binary") !== -1;
var urlsafe = operator.suffixes && operator.suffixes.indexOf("urlsafe") !== -1;
source(function(tiddler,title) { source(function(tiddler,title) {
results.push($tw.utils.base64Encode(title,binary,urlsafe)); results.push($tw.utils.base64Encode(title));
}); });
return results; return results;
}; };

View File

@@ -68,54 +68,6 @@ exports["jsontype"] = function(source,operator,options) {
return results; return results;
}; };
exports["jsonset"] = function(source,operator,options) {
var suffixes = operator.suffixes || [],
type = suffixes[0] && suffixes[0][0],
indexes = operator.operands.slice(0,-1),
value = operator.operands[operator.operands.length - 1],
results = [];
if(operator.operands.length === 1 && operator.operands[0] === "") {
value = undefined; // Prevents the value from being assigned
}
switch(type) {
case "string":
// Use value unchanged
break;
case "boolean":
value = (value === "true" ? true : (value === "false" ? false : undefined));
break;
case "number":
value = $tw.utils.parseNumber(value);
break;
case "array":
indexes = operator.operands;
value = [];
break;
case "object":
indexes = operator.operands;
value = {};
break;
case "null":
indexes = operator.operands;
value = null;
break;
case "json":
value = $tw.utils.parseJSONSafe(value,function() {return undefined;});
break;
default:
// Use value unchanged
break;
}
source(function(tiddler,title) {
var data = $tw.utils.parseJSONSafe(title,title);
if(data) {
data = setDataItem(data,indexes,value);
results.push(JSON.stringify(data));
}
});
return results;
};
/* /*
Given a JSON data structure and an array of index strings, return an array of the string representation of the values at the end of the index chain, or "undefined" if any of the index strings are invalid Given a JSON data structure and an array of index strings, return an array of the string representation of the values at the end of the index chain, or "undefined" if any of the index strings are invalid
*/ */
@@ -213,18 +165,6 @@ function getDataItemType(data,indexes) {
} }
} }
function getItemAtIndex(item,index) {
if($tw.utils.hop(item,index)) {
return item[index];
} else if($tw.utils.isArray(item)) {
index = $tw.utils.parseInt(index);
if(index < 0) { index = index + item.length };
return item[index]; // Will be undefined if index was out-of-bounds
} else {
return undefined;
}
}
/* /*
Given a JSON data structure and an array of index strings, return the value at the end of the index chain, or "undefined" if any of the index strings are invalid Given a JSON data structure and an array of index strings, return the value at the end of the index chain, or "undefined" if any of the index strings are invalid
*/ */
@@ -237,7 +177,7 @@ function getDataItem(data,indexes) {
for(var i=0; i<indexes.length; i++) { for(var i=0; i<indexes.length; i++) {
if(item !== undefined) { if(item !== undefined) {
if(item !== null && ["number","string","boolean"].indexOf(typeof item) === -1) { if(item !== null && ["number","string","boolean"].indexOf(typeof item) === -1) {
item = getItemAtIndex(item,indexes[i]); item = item[indexes[i]];
} else { } else {
item = undefined; item = undefined;
} }
@@ -246,39 +186,5 @@ function getDataItem(data,indexes) {
return item; return item;
} }
/*
Given a JSON data structure, an array of index strings and a value, return the data structure with the value added at the end of the index chain. If any of the index strings are invalid then the JSON data structure is returned unmodified. If the root item is targetted then a different data object will be returned
*/
function setDataItem(data,indexes,value) {
// Ignore attempts to assign undefined
if(value === undefined) {
return data;
}
// Check for the root item
if(indexes.length === 0 || (indexes.length === 1 && indexes[0] === "")) {
return value;
}
// Traverse the JSON data structure using the index chain
var current = data;
for(var i = 0; i < indexes.length - 1; i++) {
current = getItemAtIndex(current,indexes[i]);
if(current === undefined) {
// Return the original JSON data structure if any of the index strings are invalid
return data;
}
}
// Add the value to the end of the index chain
var lastIndex = indexes[indexes.length - 1];
if($tw.utils.isArray(current)) {
lastIndex = $tw.utils.parseInt(lastIndex);
if(lastIndex < 0) { lastIndex = lastIndex + current.length };
}
// Only set indexes on objects and arrays
if(typeof current === "object") {
current[lastIndex] = value;
}
return data;
}
})(); })();

View File

@@ -58,7 +58,6 @@ Last entry/entries in list
exports.last = function(source,operator,options) { exports.last = function(source,operator,options) {
var count = $tw.utils.getInt(operator.operand,1), var count = $tw.utils.getInt(operator.operand,1),
results = []; results = [];
if(count === 0) return results;
source(function(tiddler,title) { source(function(tiddler,title) {
results.push(title); results.push(title);
}); });

View File

@@ -14,12 +14,10 @@ The plain text parser processes blocks of source text into a degenerate parse tr
var TextParser = function(type,text,options) { var TextParser = function(type,text,options) {
this.tree = [{ this.tree = [{
type: "genesis", type: "codeblock",
attributes: { attributes: {
$type: {name: "$type", type: "string", value: "$codeblock"}, code: {type: "string", value: text},
code: {name: "code", type: "string", value: text}, language: {type: "string", value: type}
language: {name: "language", type: "string", value: type},
$remappable: {name: "$remappable", type:"string", value: "no"}
} }
}]; }];
this.source = text; this.source = text;
@@ -34,3 +32,4 @@ exports["text/css"] = TextParser;
exports["application/x-tiddler-dictionary"] = TextParser; exports["application/x-tiddler-dictionary"] = TextParser;
})(); })();

View File

@@ -1,120 +0,0 @@
/*\
title: $:/core/modules/parsers/wikiparser/rules/conditional.js
type: application/javascript
module-type: wikirule
Conditional shortcut syntax
```
This is a <% if [{something}] %>Elephant<% elseif [{else}] %>Pelican<% else %>Crocodile<% endif %>
```
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.name = "conditional";
exports.types = {inline: true, block: true};
exports.init = function(parser) {
this.parser = parser;
// Regexp to match
this.matchRegExp = /\<\%\s*if\s+/mg;
this.terminateIfRegExp = /\%\>/mg;
};
exports.findNextMatch = function(startPos) {
// Look for the next <% if shortcut
this.matchRegExp.lastIndex = startPos;
this.match = this.matchRegExp.exec(this.parser.source);
// If not found then return no match
if(!this.match) {
return undefined;
}
// Check for the next %>
this.terminateIfRegExp.lastIndex = this.match.index;
this.terminateIfMatch = this.terminateIfRegExp.exec(this.parser.source);
// If not found then return no match
if(!this.terminateIfMatch) {
return undefined;
}
// Return the position at which the construction was found
return this.match.index;
};
/*
Parse the most recent match
*/
exports.parse = function() {
// Get the filter condition
var filterCondition = this.parser.source.substring(this.match.index + this.match[0].length,this.terminateIfMatch.index);
// Advance the parser position to past the %>
this.parser.pos = this.terminateIfMatch.index + this.terminateIfMatch[0].length;
// Parse the if clause
return this.parseIfClause(filterCondition);
};
exports.parseIfClause = function(filterCondition) {
// Create the list widget
var listWidget = {
type: "list",
tag: "$list",
isBlock: this.is.block,
children: [
{
type: "list-template",
tag: "$list-template"
},
{
type: "list-empty",
tag: "$list-empty"
}
]
};
$tw.utils.addAttributeToParseTreeNode(listWidget,"filter",filterCondition);
$tw.utils.addAttributeToParseTreeNode(listWidget,"variable","condition");
$tw.utils.addAttributeToParseTreeNode(listWidget,"limit","1");
// Check for an immediately following double linebreak
var hasLineBreak = !!$tw.utils.parseTokenRegExp(this.parser.source,this.parser.pos,/([^\S\n\r]*\r?\n(?:[^\S\n\r]*\r?\n|$))/g);
// Parse the body looking for else or endif
var reEndString = "\\<\\%\\s*(endif)\\s*\\%\\>|\\<\\%\\s*(else)\\s*\\%\\>|\\<\\%\\s*(elseif)\\s+([\\s\\S]+?)\\%\\>",
ex;
if(hasLineBreak) {
ex = this.parser.parseBlocksTerminatedExtended(reEndString);
} else {
var reEnd = new RegExp(reEndString,"mg");
ex = this.parser.parseInlineRunTerminatedExtended(reEnd,{eatTerminator: true});
}
// Put the body into the list template
listWidget.children[0].children = ex.tree;
// Check for an else or elseif
if(ex.match) {
if(ex.match[1] === "endif") {
// Nothing to do if we just found an endif
} else if(ex.match[2] === "else") {
// Check for an immediately following double linebreak
hasLineBreak = !!$tw.utils.parseTokenRegExp(this.parser.source,this.parser.pos,/([^\S\n\r]*\r?\n(?:[^\S\n\r]*\r?\n|$))/g);
// If we found an else then we need to parse the body looking for the endif
var reEndString = "\\<\\%\\s*(endif)\\s*\\%\\>",
ex;
if(hasLineBreak) {
ex = this.parser.parseBlocksTerminatedExtended(reEndString);
} else {
var reEnd = new RegExp(reEndString,"mg");
ex = this.parser.parseInlineRunTerminatedExtended(reEnd,{eatTerminator: true});
}
// Put the parsed content inside the list empty template
listWidget.children[1].children = ex.tree;
} else if(ex.match[3] === "elseif") {
// Parse the elseif clause by reusing this parser, passing the new filter condition
listWidget.children[1].children = this.parseIfClause(ex.match[4]);
}
}
// Return the parse tree node
return [listWidget];
};
})();

View File

@@ -194,7 +194,6 @@ Parse any pragmas at the beginning of a block of parse text
WikiParser.prototype.parsePragmas = function() { WikiParser.prototype.parsePragmas = function() {
var currentTreeBranch = this.tree; var currentTreeBranch = this.tree;
while(true) { while(true) {
var savedPos = this.pos;
// Skip whitespace // Skip whitespace
this.skipWhitespace(); this.skipWhitespace();
// Check for the end of the text // Check for the end of the text
@@ -205,7 +204,6 @@ WikiParser.prototype.parsePragmas = function() {
var nextMatch = this.findNextMatch(this.pragmaRules,this.pos); var nextMatch = this.findNextMatch(this.pragmaRules,this.pos);
// If not, just exit // If not, just exit
if(!nextMatch || nextMatch.matchIndex !== this.pos) { if(!nextMatch || nextMatch.matchIndex !== this.pos) {
this.pos = savedPos;
break; break;
} }
// Process the pragma rule // Process the pragma rule
@@ -216,8 +214,6 @@ WikiParser.prototype.parsePragmas = function() {
subTree[0].children = []; subTree[0].children = [];
currentTreeBranch = subTree[0].children; currentTreeBranch = subTree[0].children;
} }
// Skip whitespace after the pragma
this.skipWhitespace();
} }
return currentTreeBranch; return currentTreeBranch;
}; };
@@ -227,7 +223,7 @@ Parse a block from the current position
terminatorRegExpString: optional regular expression string that identifies the end of plain paragraphs. Must not include capturing parenthesis terminatorRegExpString: optional regular expression string that identifies the end of plain paragraphs. Must not include capturing parenthesis
*/ */
WikiParser.prototype.parseBlock = function(terminatorRegExpString) { WikiParser.prototype.parseBlock = function(terminatorRegExpString) {
var terminatorRegExp = terminatorRegExpString ? new RegExp(terminatorRegExpString + "|\\r?\\n\\r?\\n","mg") : /(\r?\n\r?\n)/mg; var terminatorRegExp = terminatorRegExpString ? new RegExp("(" + terminatorRegExpString + "|\\r?\\n\\r?\\n)","mg") : /(\r?\n\r?\n)/mg;
this.skipWhitespace(); this.skipWhitespace();
if(this.pos >= this.sourceLength) { if(this.pos >= this.sourceLength) {
return []; return [];
@@ -267,22 +263,12 @@ WikiParser.prototype.parseBlocksUnterminated = function() {
return tree; return tree;
}; };
/*
Parse blocks of text until a terminating regexp is encountered. Wrapper for parseBlocksTerminatedExtended that just returns the parse tree
*/
WikiParser.prototype.parseBlocksTerminated = function(terminatorRegExpString) {
var ex = this.parseBlocksTerminatedExtended(terminatorRegExpString);
return ex.tree;
};
/* /*
Parse blocks of text until a terminating regexp is encountered Parse blocks of text until a terminating regexp is encountered
*/ */
WikiParser.prototype.parseBlocksTerminatedExtended = function(terminatorRegExpString) { WikiParser.prototype.parseBlocksTerminated = function(terminatorRegExpString) {
var terminatorRegExp = new RegExp(terminatorRegExpString,"mg"), var terminatorRegExp = new RegExp("(" + terminatorRegExpString + ")","mg"),
result = { tree = [];
tree: []
};
// Skip any whitespace // Skip any whitespace
this.skipWhitespace(); this.skipWhitespace();
// Check if we've got the end marker // Check if we've got the end marker
@@ -291,7 +277,7 @@ WikiParser.prototype.parseBlocksTerminatedExtended = function(terminatorRegExpSt
// Parse the text into blocks // Parse the text into blocks
while(this.pos < this.sourceLength && !(match && match.index === this.pos)) { while(this.pos < this.sourceLength && !(match && match.index === this.pos)) {
var blocks = this.parseBlock(terminatorRegExpString); var blocks = this.parseBlock(terminatorRegExpString);
result.tree.push.apply(result.tree,blocks); tree.push.apply(tree,blocks);
// Skip any whitespace // Skip any whitespace
this.skipWhitespace(); this.skipWhitespace();
// Check if we've got the end marker // Check if we've got the end marker
@@ -300,9 +286,8 @@ WikiParser.prototype.parseBlocksTerminatedExtended = function(terminatorRegExpSt
} }
if(match && match.index === this.pos) { if(match && match.index === this.pos) {
this.pos = match.index + match[0].length; this.pos = match.index + match[0].length;
result.match = match;
} }
return result; return tree;
}; };
/* /*
@@ -345,11 +330,6 @@ WikiParser.prototype.parseInlineRunUnterminated = function(options) {
}; };
WikiParser.prototype.parseInlineRunTerminated = function(terminatorRegExp,options) { WikiParser.prototype.parseInlineRunTerminated = function(terminatorRegExp,options) {
var ex = this.parseInlineRunTerminatedExtended(terminatorRegExp,options);
return ex.tree;
};
WikiParser.prototype.parseInlineRunTerminatedExtended = function(terminatorRegExp,options) {
options = options || {}; options = options || {};
var tree = []; var tree = [];
// Find the next occurrence of the terminator // Find the next occurrence of the terminator
@@ -369,10 +349,7 @@ WikiParser.prototype.parseInlineRunTerminatedExtended = function(terminatorRegEx
if(options.eatTerminator) { if(options.eatTerminator) {
this.pos += terminatorMatch[0].length; this.pos += terminatorMatch[0].length;
} }
return { return tree;
match: terminatorMatch,
tree: tree
};
} }
} }
// Process any inline rule, along with the text preceding it // Process any inline rule, along with the text preceding it
@@ -396,9 +373,7 @@ WikiParser.prototype.parseInlineRunTerminatedExtended = function(terminatorRegEx
this.pushTextWidget(tree,this.source.substr(this.pos),this.pos,this.sourceLength); this.pushTextWidget(tree,this.source.substr(this.pos),this.pos,this.sourceLength);
} }
this.pos = this.sourceLength; this.pos = this.sourceLength;
return { return tree;
tree: tree
};
}; };
/* /*

View File

@@ -31,7 +31,7 @@ GitHubSaver.prototype.save = function(text,method,callback) {
headers = { headers = {
"Accept": "application/vnd.github.v3+json", "Accept": "application/vnd.github.v3+json",
"Content-Type": "application/json;charset=UTF-8", "Content-Type": "application/json;charset=UTF-8",
"Authorization": "Basic " + $tw.utils.base64Encode(username + ":" + password), "Authorization": "Basic " + window.btoa(username + ":" + password),
"If-None-Match": "" "If-None-Match": ""
}; };
// Bail if we don't have everything we need // Bail if we don't have everything we need

View File

@@ -40,7 +40,7 @@ exports.startup = function() {
variables = $tw.utils.extend({},paramObject,{currentTiddler: title, "tv-window-id": windowID}); variables = $tw.utils.extend({},paramObject,{currentTiddler: title, "tv-window-id": windowID});
// Open the window // Open the window
var srcWindow, var srcWindow,
srcDocument; srcDocument;
// In case that popup blockers deny opening a new window // In case that popup blockers deny opening a new window
try { try {
srcWindow = window.open("","external-" + windowID,"scrollbars,width=" + width + ",height=" + height + (top ? ",top=" + top : "" ) + (left ? ",left=" + left : "" )), srcWindow = window.open("","external-" + windowID,"scrollbars,width=" + width + ",height=" + height + (top ? ",top=" + top : "" ) + (left ? ",left=" + left : "" )),
@@ -52,7 +52,6 @@ exports.startup = function() {
$tw.windows[windowID] = srcWindow; $tw.windows[windowID] = srcWindow;
// Check for reopening the same window // Check for reopening the same window
if(srcWindow.haveInitialisedWindow) { if(srcWindow.haveInitialisedWindow) {
srcWindow.focus();
return; return;
} }
// Initialise the document // Initialise the document

View File

@@ -24,7 +24,7 @@ Syncer.prototype.titleSyncPollingInterval = "$:/config/SyncPollingInterval";
Syncer.prototype.titleSyncDisableLazyLoading = "$:/config/SyncDisableLazyLoading"; Syncer.prototype.titleSyncDisableLazyLoading = "$:/config/SyncDisableLazyLoading";
Syncer.prototype.titleSavedNotification = "$:/language/Notifications/Save/Done"; Syncer.prototype.titleSavedNotification = "$:/language/Notifications/Save/Done";
Syncer.prototype.titleSyncThrottleInterval = "$:/config/SyncThrottleInterval"; Syncer.prototype.titleSyncThrottleInterval = "$:/config/SyncThrottleInterval";
Syncer.prototype.taskTimerInterval = 0.25 * 1000; // Interval for sync timer Syncer.prototype.taskTimerInterval = 1 * 1000; // Interval for sync timer
Syncer.prototype.throttleInterval = 1 * 1000; // Defer saving tiddlers if they've changed in the last 1s... Syncer.prototype.throttleInterval = 1 * 1000; // Defer saving tiddlers if they've changed in the last 1s...
Syncer.prototype.errorRetryInterval = 5 * 1000; // Interval to retry after an error Syncer.prototype.errorRetryInterval = 5 * 1000; // Interval to retry after an error
Syncer.prototype.fallbackInterval = 10 * 1000; // Unless the task is older than 10s Syncer.prototype.fallbackInterval = 10 * 1000; // Unless the task is older than 10s
@@ -74,11 +74,9 @@ function Syncer(options) {
this.titlesHaveBeenLazyLoaded = {}; // Hashmap of titles of tiddlers that have already been lazily loaded from the server this.titlesHaveBeenLazyLoaded = {}; // Hashmap of titles of tiddlers that have already been lazily loaded from the server
// Timers // Timers
this.taskTimerId = null; // Timer for task dispatch this.taskTimerId = null; // Timer for task dispatch
this.pollTimerId = null; // Timer for polling server
// Number of outstanding requests // Number of outstanding requests
this.numTasksInProgress = 0; this.numTasksInProgress = 0;
// True when we want to force an immediate sync from the server
this.forceSyncFromServer = false;
this.timestampLastSyncFromServer = new Date();
// Listen out for changes to tiddlers // Listen out for changes to tiddlers
this.wiki.addEventListener("change",function(changes) { this.wiki.addEventListener("change",function(changes) {
// Filter the changes to just include ones that are being synced // Filter the changes to just include ones that are being synced
@@ -205,37 +203,33 @@ Syncer.prototype.readTiddlerInfo = function() {
Checks whether the wiki is dirty (ie the window shouldn't be closed) Checks whether the wiki is dirty (ie the window shouldn't be closed)
*/ */
Syncer.prototype.isDirty = function() { Syncer.prototype.isDirty = function() {
var self = this; this.logger.log("Checking dirty status");
function checkIsDirty() { // Check tiddlers that are in the store and included in the filter function
// Check tiddlers that are in the store and included in the filter function var titles = this.getSyncedTiddlers();
var titles = self.getSyncedTiddlers(); for(var index=0; index<titles.length; index++) {
for(var index=0; index<titles.length; index++) { var title = titles[index],
var title = titles[index], tiddlerInfo = this.tiddlerInfo[title];
tiddlerInfo = self.tiddlerInfo[title]; if(this.wiki.tiddlerExists(title)) {
if(self.wiki.tiddlerExists(title)) { if(tiddlerInfo) {
if(tiddlerInfo) { // If the tiddler is known on the server and has been modified locally then it needs to be saved to the server
// If the tiddler is known on the server and has been modified locally then it needs to be saved to the server if(this.wiki.getChangeCount(title) > tiddlerInfo.changeCount) {
if(self.wiki.getChangeCount(title) > tiddlerInfo.changeCount) {
return true;
}
} else {
// If the tiddler isn't known on the server then it needs to be saved to the server
return true; return true;
} }
} } else {
} // If the tiddler isn't known on the server then it needs to be saved to the server
// Check tiddlers that are known from the server but not currently in the store
titles = Object.keys(self.tiddlerInfo);
for(index=0; index<titles.length; index++) {
if(!self.wiki.tiddlerExists(titles[index])) {
// There must be a pending delete
return true; return true;
} }
} }
return false;
} }
var dirtyStatus = checkIsDirty(); // Check tiddlers that are known from the server but not currently in the store
return dirtyStatus; titles = Object.keys(this.tiddlerInfo);
for(index=0; index<titles.length; index++) {
if(!this.wiki.tiddlerExists(titles[index])) {
// There must be a pending delete
return true;
}
}
return false;
}; };
/* /*
@@ -299,16 +293,92 @@ Syncer.prototype.getStatus = function(callback) {
Synchronise from the server by reading the skinny tiddler list and queuing up loads for any tiddlers that we don't already have up to date Synchronise from the server by reading the skinny tiddler list and queuing up loads for any tiddlers that we don't already have up to date
*/ */
Syncer.prototype.syncFromServer = function() { Syncer.prototype.syncFromServer = function() {
if(this.canSyncFromServer()) { var self = this,
this.forceSyncFromServer = true; cancelNextSync = function() {
this.processTaskQueue(); if(self.pollTimerId) {
clearTimeout(self.pollTimerId);
self.pollTimerId = null;
}
},
triggerNextSync = function() {
self.pollTimerId = setTimeout(function() {
self.pollTimerId = null;
self.syncFromServer.call(self);
},self.pollTimerInterval);
},
syncSystemFromServer = (self.wiki.getTiddlerText("$:/config/SyncSystemTiddlersFromServer") === "yes" ? true : false);
if(this.syncadaptor && this.syncadaptor.getUpdatedTiddlers) {
this.logger.log("Retrieving updated tiddler list");
cancelNextSync();
this.syncadaptor.getUpdatedTiddlers(self,function(err,updates) {
triggerNextSync();
if(err) {
self.displayError($tw.language.getString("Error/RetrievingSkinny"),err);
return;
}
if(updates) {
$tw.utils.each(updates.modifications,function(title) {
self.titlesToBeLoaded[title] = true;
});
$tw.utils.each(updates.deletions,function(title) {
if(syncSystemFromServer || !self.wiki.isSystemTiddler(title)) {
delete self.tiddlerInfo[title];
self.logger.log("Deleting tiddler missing from server:",title);
self.wiki.deleteTiddler(title);
}
});
if(updates.modifications.length > 0 || updates.deletions.length > 0) {
self.processTaskQueue();
}
}
});
} else if(this.syncadaptor && this.syncadaptor.getSkinnyTiddlers) {
this.logger.log("Retrieving skinny tiddler list");
cancelNextSync();
this.syncadaptor.getSkinnyTiddlers(function(err,tiddlers) {
triggerNextSync();
// Check for errors
if(err) {
self.displayError($tw.language.getString("Error/RetrievingSkinny"),err);
return;
}
// Keep track of which tiddlers we already know about have been reported this time
var previousTitles = Object.keys(self.tiddlerInfo);
// Process each incoming tiddler
for(var t=0; t<tiddlers.length; t++) {
// Get the incoming tiddler fields, and the existing tiddler
var tiddlerFields = tiddlers[t],
incomingRevision = tiddlerFields.revision + "",
tiddler = self.wiki.tiddlerExists(tiddlerFields.title) && self.wiki.getTiddler(tiddlerFields.title),
tiddlerInfo = self.tiddlerInfo[tiddlerFields.title],
currRevision = tiddlerInfo ? tiddlerInfo.revision : null,
indexInPreviousTitles = previousTitles.indexOf(tiddlerFields.title);
if(indexInPreviousTitles !== -1) {
previousTitles.splice(indexInPreviousTitles,1);
}
// Ignore the incoming tiddler if it's the same as the revision we've already got
if(currRevision !== incomingRevision) {
// Only load the skinny version if we don't already have a fat version of the tiddler
if(!tiddler || tiddler.fields.text === undefined) {
self.storeTiddler(tiddlerFields);
}
// Do a full load of this tiddler
self.titlesToBeLoaded[tiddlerFields.title] = true;
}
}
// Delete any tiddlers that were previously reported but missing this time
$tw.utils.each(previousTitles,function(title) {
if(syncSystemFromServer || !self.wiki.isSystemTiddler(title)) {
delete self.tiddlerInfo[title];
self.logger.log("Deleting tiddler missing from server:",title);
self.wiki.deleteTiddler(title);
}
});
self.processTaskQueue();
});
} }
}; };
Syncer.prototype.canSyncFromServer = function() {
return !!this.syncadaptor.getUpdatedTiddlers || !!this.syncadaptor.getSkinnyTiddlers;
}
/* /*
Force load a tiddler from the server Force load a tiddler from the server
*/ */
@@ -448,39 +518,31 @@ Syncer.prototype.processTaskQueue = function() {
this.updateDirtyStatus(); this.updateDirtyStatus();
// And trigger a timeout if there is a pending task // And trigger a timeout if there is a pending task
if(task === true) { if(task === true) {
this.triggerTimeout(this.taskTimerInterval); this.triggerTimeout();
} else if(this.canSyncFromServer()) {
this.triggerTimeout(this.pollTimerInterval);
} }
} }
} else { } else {
this.updateDirtyStatus(); this.updateDirtyStatus();
this.triggerTimeout(this.taskTimerInterval);
} }
}; };
Syncer.prototype.triggerTimeout = function(interval) { Syncer.prototype.triggerTimeout = function(interval) {
var self = this; var self = this;
if(this.taskTimerId) { if(!this.taskTimerId) {
clearTimeout(this.taskTimerId); this.taskTimerId = setTimeout(function() {
self.taskTimerId = null;
self.processTaskQueue.call(self);
},interval || self.taskTimerInterval);
} }
this.taskTimerId = setTimeout(function() {
self.taskTimerId = null;
self.processTaskQueue.call(self);
},interval || self.taskTimerInterval);
}; };
/* /*
Choose the next sync task. We prioritise saves to the server, then getting updates from the server, then deletes to the server, then loads from the server Choose the next sync task. We prioritise saves, then deletes, then loads from the server
Returns either: Returns either a task object, null if there's no upcoming tasks, or the boolean true if there are pending tasks that aren't yet due
* a task object
* the boolean true if there are pending sync tasks that aren't yet due
* null if there's no pending sync tasks (just the next poll)
*/ */
Syncer.prototype.chooseNextTask = function() { Syncer.prototype.chooseNextTask = function() {
var now = new Date(), var thresholdLastSaved = (new Date()) - this.throttleInterval,
thresholdLastSaved = now - this.throttleInterval,
havePending = null; havePending = null;
// First we look for tiddlers that have been modified locally and need saving back to the server // First we look for tiddlers that have been modified locally and need saving back to the server
var titles = this.getSyncedTiddlers(); var titles = this.getSyncedTiddlers();
@@ -501,11 +563,7 @@ Syncer.prototype.chooseNextTask = function() {
} }
} }
} }
// Second we check for an outstanding sync from server // Second, we check tiddlers that are known from the server but not currently in the store, and so need deleting on the server
if(this.forceSyncFromServer || (this.timestampLastSyncFromServer && (now.valueOf() >= (this.timestampLastSyncFromServer.valueOf() + this.pollTimerInterval)))) {
return new SyncFromServerTask(this);
}
// Third, we check tiddlers that are known from the server but not currently in the store, and so need deleting on the server
titles = Object.keys(this.tiddlerInfo); titles = Object.keys(this.tiddlerInfo);
for(index=0; index<titles.length; index++) { for(index=0; index<titles.length; index++) {
title = titles[index]; title = titles[index];
@@ -515,13 +573,13 @@ Syncer.prototype.chooseNextTask = function() {
return new DeleteTiddlerTask(this,title); return new DeleteTiddlerTask(this,title);
} }
} }
// Finally, check for tiddlers that need loading // Check for tiddlers that need loading
title = Object.keys(this.titlesToBeLoaded)[0]; title = Object.keys(this.titlesToBeLoaded)[0];
if(title) { if(title) {
delete this.titlesToBeLoaded[title]; delete this.titlesToBeLoaded[title];
return new LoadTiddlerTask(this,title); return new LoadTiddlerTask(this,title);
} }
// No tasks are ready now, but might be in the future // No tasks are ready
return havePending; return havePending;
}; };
@@ -531,10 +589,6 @@ function SaveTiddlerTask(syncer,title) {
this.type = "save"; this.type = "save";
} }
SaveTiddlerTask.prototype.toString = function() {
return "SAVE " + this.title;
}
SaveTiddlerTask.prototype.run = function(callback) { SaveTiddlerTask.prototype.run = function(callback) {
var self = this, var self = this,
changeCount = this.syncer.wiki.getChangeCount(this.title), changeCount = this.syncer.wiki.getChangeCount(this.title),
@@ -559,6 +613,7 @@ SaveTiddlerTask.prototype.run = function(callback) {
tiddlerInfo: self.syncer.tiddlerInfo[self.title] tiddlerInfo: self.syncer.tiddlerInfo[self.title]
}); });
} else { } else {
this.syncer.logger.log(" Not Dispatching 'save' task:",this.title,"tiddler does not exist");
$tw.utils.nextTick(callback(null)); $tw.utils.nextTick(callback(null));
} }
}; };
@@ -569,10 +624,6 @@ function DeleteTiddlerTask(syncer,title) {
this.type = "delete"; this.type = "delete";
} }
DeleteTiddlerTask.prototype.toString = function() {
return "DELETE " + this.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);
@@ -596,10 +647,6 @@ function LoadTiddlerTask(syncer,title) {
this.type = "load"; this.type = "load";
} }
LoadTiddlerTask.prototype.toString = function() {
return "LOAD " + this.title;
}
LoadTiddlerTask.prototype.run = function(callback) { LoadTiddlerTask.prototype.run = function(callback) {
var self = this; var self = this;
this.syncer.logger.log("Dispatching 'load' task:",this.title); this.syncer.logger.log("Dispatching 'load' task:",this.title);
@@ -617,91 +664,6 @@ LoadTiddlerTask.prototype.run = function(callback) {
}); });
}; };
function SyncFromServerTask(syncer) {
this.syncer = syncer;
this.type = "syncfromserver";
}
SyncFromServerTask.prototype.toString = function() {
return "SYNCFROMSERVER";
}
SyncFromServerTask.prototype.run = function(callback) {
var self = this;
var syncSystemFromServer = (self.syncer.wiki.getTiddlerText("$:/config/SyncSystemTiddlersFromServer") === "yes" ? true : false);
var successCallback = function() {
self.syncer.forceSyncFromServer = false;
self.syncer.timestampLastSyncFromServer = new Date();
callback(null);
};
if(this.syncer.syncadaptor.getUpdatedTiddlers) {
this.syncer.syncadaptor.getUpdatedTiddlers(self.syncer,function(err,updates) {
if(err) {
self.syncer.displayError($tw.language.getString("Error/RetrievingSkinny"),err);
return callback(err);
}
if(updates) {
$tw.utils.each(updates.modifications,function(title) {
self.syncer.titlesToBeLoaded[title] = true;
});
$tw.utils.each(updates.deletions,function(title) {
if(syncSystemFromServer || !self.syncer.wiki.isSystemTiddler(title)) {
delete self.syncer.tiddlerInfo[title];
self.syncer.logger.log("Deleting tiddler missing from server:",title);
self.syncer.wiki.deleteTiddler(title);
}
});
}
return successCallback();
});
} else if(this.syncer.syncadaptor.getSkinnyTiddlers) {
this.syncer.syncadaptor.getSkinnyTiddlers(function(err,tiddlers) {
// Check for errors
if(err) {
self.syncer.displayError($tw.language.getString("Error/RetrievingSkinny"),err);
return callback(err);
}
// Keep track of which tiddlers we already know about have been reported this time
var previousTitles = Object.keys(self.syncer.tiddlerInfo);
// Process each incoming tiddler
for(var t=0; t<tiddlers.length; t++) {
// Get the incoming tiddler fields, and the existing tiddler
var tiddlerFields = tiddlers[t],
incomingRevision = tiddlerFields.revision + "",
tiddler = self.syncer.wiki.tiddlerExists(tiddlerFields.title) && self.syncer.wiki.getTiddler(tiddlerFields.title),
tiddlerInfo = self.syncer.tiddlerInfo[tiddlerFields.title],
currRevision = tiddlerInfo ? tiddlerInfo.revision : null,
indexInPreviousTitles = previousTitles.indexOf(tiddlerFields.title);
if(indexInPreviousTitles !== -1) {
previousTitles.splice(indexInPreviousTitles,1);
}
// Ignore the incoming tiddler if it's the same as the revision we've already got
if(currRevision !== incomingRevision) {
// Only load the skinny version if we don't already have a fat version of the tiddler
if(!tiddler || tiddler.fields.text === undefined) {
self.syncer.storeTiddler(tiddlerFields);
}
// Do a full load of this tiddler
self.syncer.titlesToBeLoaded[tiddlerFields.title] = true;
}
}
// Delete any tiddlers that were previously reported but missing this time
$tw.utils.each(previousTitles,function(title) {
if(syncSystemFromServer || !self.syncer.wiki.isSystemTiddler(title)) {
delete self.syncer.tiddlerInfo[title];
self.syncer.logger.log("Deleting tiddler missing from server:",title);
self.syncer.wiki.deleteTiddler(title);
}
});
self.syncer.forceSyncFromServer = false;
self.syncer.timestampLastSyncFromServer = new Date();
return successCallback();
});
} else {
return successCallback();
}
};
exports.Syncer = Syncer; exports.Syncer = Syncer;
})(); })();

View File

@@ -313,7 +313,7 @@ exports.collectDOMVariables = function(selectedNode,domNode,event) {
variables["dom-" + attribute.name] = attribute.value.toString(); variables["dom-" + attribute.name] = attribute.value.toString();
}); });
if("offsetLeft" in selectedNode) { if(selectedNode.offsetLeft) {
// Add variables with a (relative and absolute) popup coordinate string for the selected node // Add variables with a (relative and absolute) popup coordinate string for the selected node
var nodeRect = { var nodeRect = {
left: selectedNode.offsetLeft, left: selectedNode.offsetLeft,
@@ -338,12 +338,12 @@ exports.collectDOMVariables = function(selectedNode,domNode,event) {
} }
} }
if(domNode && ("offsetWidth" in domNode)) { if(domNode && domNode.offsetWidth) {
variables["tv-widgetnode-width"] = domNode.offsetWidth.toString(); variables["tv-widgetnode-width"] = domNode.offsetWidth.toString();
variables["tv-widgetnode-height"] = domNode.offsetHeight.toString(); variables["tv-widgetnode-height"] = domNode.offsetHeight.toString();
} }
if(event && ("clientX" in event) && ("clientY" in event)) { if(event && event.clientX && event.clientY) {
if(selectedNode) { if(selectedNode) {
// Add variables for event X and Y position relative to selected node // Add variables for event X and Y position relative to selected node
selectedNodeRect = selectedNode.getBoundingClientRect(); selectedNodeRect = selectedNode.getBoundingClientRect();

View File

@@ -187,7 +187,7 @@ HttpClientRequest.prototype.send = function(callback) {
for (var i=0; i<len; i++) { for (var i=0; i<len; i++) {
binary += String.fromCharCode(bytes[i]); binary += String.fromCharCode(bytes[i]);
} }
resultVariables.data = $tw.utils.base64Encode(binary,true); resultVariables.data = window.btoa(binary);
} }
self.wiki.addTiddler(new $tw.Tiddler(self.wiki.getTiddler(requestTrackerTitle),{ self.wiki.addTiddler(new $tw.Tiddler(self.wiki.getTiddler(requestTrackerTitle),{
status: completionCode, status: completionCode,

View File

@@ -104,11 +104,7 @@ TW_Element.prototype.setAttribute = function(name,value) {
if(this.isRaw) { if(this.isRaw) {
throw "Cannot setAttribute on a raw TW_Element"; throw "Cannot setAttribute on a raw TW_Element";
} }
if(name === "style") { this.attributes[name] = value + "";
this.style = value;
} else {
this.attributes[name] = value + "";
}
}; };
TW_Element.prototype.setAttributeNS = function(namespace,name,value) { TW_Element.prototype.setAttributeNS = function(namespace,name,value) {

View File

@@ -819,41 +819,18 @@ exports.hashString = function(str) {
},0); },0);
}; };
/*
Base64 utility functions that work in either browser or Node.js
*/
if(typeof window !== 'undefined') {
exports.btoa = function(binstr) { return window.btoa(binstr); }
exports.atob = function(b64) { return window.atob(b64); }
} else {
exports.btoa = function(binstr) {
return Buffer.from(binstr, 'binary').toString('base64');
}
exports.atob = function(b64) {
return Buffer.from(b64, 'base64').toString('binary');
}
}
/* /*
Decode a base64 string Decode a base64 string
*/ */
exports.base64Decode = function(string64,binary,urlsafe) { exports.base64Decode = function(string64) {
var encoded = urlsafe ? string64.replace(/_/g,'/').replace(/-/g,'+') : string64; return base64utf8.base64.decode.call(base64utf8,string64);
if(binary) return exports.atob(encoded)
else return base64utf8.base64.decode.call(base64utf8,encoded);
}; };
/* /*
Encode a string to base64 Encode a string to base64
*/ */
exports.base64Encode = function(string64,binary,urlsafe) { exports.base64Encode = function(string64) {
var encoded; return base64utf8.base64.encode.call(base64utf8,string64);
if(binary) encoded = exports.btoa(string64);
else encoded = base64utf8.base64.encode.call(base64utf8,string64);
if(urlsafe) {
encoded = encoded.replace(/\+/g,'-').replace(/\//g,'_');
}
return encoded;
}; };
/* /*

View File

@@ -70,11 +70,6 @@ BrowseWidget.prototype.render = function(parent,nextSibling) {
} }
return false; return false;
},false); },false);
// Assign data- attributes
this.assignAttributes(domNode,{
sourcePrefix: "data-",
destPrefix: "data-"
});
// Insert element // Insert element
parent.insertBefore(domNode,nextSibling); parent.insertBefore(domNode,nextSibling);
this.renderChildren(domNode,null); this.renderChildren(domNode,null);
@@ -100,11 +95,6 @@ BrowseWidget.prototype.execute = function() {
Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering
*/ */
BrowseWidget.prototype.refresh = function(changedTiddlers) { BrowseWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes();
if($tw.utils.count(changedAttributes) > 0) {
this.refreshSelf();
return true;
}
return false; return false;
}; };

View File

@@ -59,11 +59,6 @@ ButtonWidget.prototype.render = function(parent,nextSibling) {
$tw.utils.pushTop(classes,"tc-popup-handle"); $tw.utils.pushTop(classes,"tc-popup-handle");
} }
domNode.className = classes.join(" "); domNode.className = classes.join(" ");
// Assign data- attributes
this.assignAttributes(domNode,{
sourcePrefix: "data-",
destPrefix: "data-"
});
// Assign other attributes // Assign other attributes
if(this.style) { if(this.style) {
domNode.setAttribute("style",this.style); domNode.setAttribute("style",this.style);
@@ -255,7 +250,7 @@ ButtonWidget.prototype.updateDomNodeClasses = function() {
//Add new classes from updated class attribute. //Add new classes from updated class attribute.
$tw.utils.pushTop(domNodeClasses,newClasses); $tw.utils.pushTop(domNodeClasses,newClasses);
this.domNode.className = domNodeClasses.join(" "); this.domNode.className = domNodeClasses.join(" ");
}; }
/* /*
Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering
@@ -265,15 +260,8 @@ ButtonWidget.prototype.refresh = function(changedTiddlers) {
if(changedAttributes.actions || changedAttributes.to || changedAttributes.message || changedAttributes.param || changedAttributes.set || changedAttributes.setTo || changedAttributes.popup || changedAttributes.hover || changedAttributes.selectedClass || changedAttributes.style || changedAttributes.dragFilter || changedAttributes.dragTiddler || (this.set && changedTiddlers[this.set]) || (this.popup && changedTiddlers[this.popup]) || (this.popupTitle && changedTiddlers[this.popupTitle]) || changedAttributes.popupAbsCoords || changedAttributes.setTitle || changedAttributes.setField || changedAttributes.setIndex || changedAttributes.popupTitle || changedAttributes.disabled || changedAttributes["default"]) { if(changedAttributes.actions || changedAttributes.to || changedAttributes.message || changedAttributes.param || changedAttributes.set || changedAttributes.setTo || changedAttributes.popup || changedAttributes.hover || changedAttributes.selectedClass || changedAttributes.style || changedAttributes.dragFilter || changedAttributes.dragTiddler || (this.set && changedTiddlers[this.set]) || (this.popup && changedTiddlers[this.popup]) || (this.popupTitle && changedTiddlers[this.popupTitle]) || changedAttributes.popupAbsCoords || changedAttributes.setTitle || changedAttributes.setField || changedAttributes.setIndex || changedAttributes.popupTitle || changedAttributes.disabled || changedAttributes["default"]) {
this.refreshSelf(); this.refreshSelf();
return true; return true;
} else { } else if(changedAttributes["class"]) {
if(changedAttributes["class"]) { this.updateDomNodeClasses();
this.updateDomNodeClasses();
}
this.assignAttributes(this.domNodes[0],{
changedAttributes: changedAttributes,
sourcePrefix: "data-",
destPrefix: "data-"
});
} }
return this.refreshChildren(changedTiddlers); return this.refreshChildren(changedTiddlers);
}; };

View File

@@ -53,11 +53,6 @@ CheckboxWidget.prototype.render = function(parent,nextSibling) {
this.labelDomNode.appendChild(this.inputDomNode); this.labelDomNode.appendChild(this.inputDomNode);
this.spanDomNode = this.document.createElement("span"); this.spanDomNode = this.document.createElement("span");
this.labelDomNode.appendChild(this.spanDomNode); this.labelDomNode.appendChild(this.spanDomNode);
// Assign data- attributes
this.assignAttributes(this.inputDomNode,{
sourcePrefix: "data-",
destPrefix: "data-"
});
// Add a click event handler // Add a click event handler
$tw.utils.addEventListeners(this.inputDomNode,[ $tw.utils.addEventListeners(this.inputDomNode,[
{name: "change", handlerObject: this, handlerMethod: "handleChangeEvent"} {name: "change", handlerObject: this, handlerMethod: "handleChangeEvent"}
@@ -330,11 +325,6 @@ CheckboxWidget.prototype.refresh = function(changedTiddlers) {
$tw.utils.removeClass(this.labelDomNode,"tc-checkbox-checked"); $tw.utils.removeClass(this.labelDomNode,"tc-checkbox-checked");
} }
} }
this.assignAttributes(this.inputDomNode,{
changedAttributes: changedAttributes,
sourcePrefix: "data-",
destPrefix: "data-"
});
return this.refreshChildren(changedTiddlers) || refreshed; return this.refreshChildren(changedTiddlers) || refreshed;
} }
}; };
@@ -342,4 +332,3 @@ CheckboxWidget.prototype.refresh = function(changedTiddlers) {
exports.checkbox = CheckboxWidget; exports.checkbox = CheckboxWidget;
})(); })();

View File

@@ -52,11 +52,6 @@ DraggableWidget.prototype.render = function(parent,nextSibling) {
classes.push("tc-draggable"); classes.push("tc-draggable");
} }
domNode.setAttribute("class",classes.join(" ")); domNode.setAttribute("class",classes.join(" "));
// Assign data- attributes and style. attributes
this.assignAttributes(domNode,{
sourcePrefix: "data-",
destPrefix: "data-"
});
// Insert the node into the DOM and render any children // Insert the node into the DOM and render any children
parent.insertBefore(domNode,nextSibling); parent.insertBefore(domNode,nextSibling);
this.renderChildren(domNode,null); this.renderChildren(domNode,null);
@@ -113,19 +108,13 @@ DraggableWidget.prototype.updateDomNodeClasses = function() {
Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering
*/ */
DraggableWidget.prototype.refresh = function(changedTiddlers) { DraggableWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes(); var changedAttributes = this.computeAttributes(),
if(changedAttributes.tag || changedAttributes.selector || changedAttributes.dragimagetype || changedAttributes.enable || changedAttributes.startactions || changedAttributes.endactions) { changedAttributesCount = $tw.utils.count(changedAttributes);
if(changedAttributesCount === 1 && changedAttributes["class"]) {
this.updateDomNodeClasses();
} else if(changedAttributesCount > 0) {
this.refreshSelf(); this.refreshSelf();
return true; return true;
} else {
if(changedAttributes["class"]) {
this.assignDomNodeClasses();
}
this.assignAttributes(this.domNodes[0],{
changedAttributes: changedAttributes,
sourcePrefix: "data-",
destPrefix: "data-"
});
} }
return this.refreshChildren(changedTiddlers); return this.refreshChildren(changedTiddlers);
}; };

View File

@@ -42,11 +42,6 @@ DroppableWidget.prototype.render = function(parent,nextSibling) {
domNode = this.document.createElement(tag); domNode = this.document.createElement(tag);
this.domNode = domNode; this.domNode = domNode;
this.assignDomNodeClasses(); this.assignDomNodeClasses();
// Assign data- attributes and style. attributes
this.assignAttributes(domNode,{
sourcePrefix: "data-",
destPrefix: "data-"
});
// Add event handlers // Add event handlers
if(this.droppableEnable) { if(this.droppableEnable) {
$tw.utils.addEventListeners(domNode,[ $tw.utils.addEventListeners(domNode,[
@@ -171,15 +166,8 @@ DroppableWidget.prototype.refresh = function(changedTiddlers) {
if(changedAttributes.tag || changedAttributes.enable || changedAttributes.disabledClass || changedAttributes.actions || changedAttributes.effect) { if(changedAttributes.tag || changedAttributes.enable || changedAttributes.disabledClass || changedAttributes.actions || changedAttributes.effect) {
this.refreshSelf(); this.refreshSelf();
return true; return true;
} else { } else if(changedAttributes["class"]) {
if(changedAttributes["class"]) { this.assignDomNodeClasses();
this.assignDomNodeClasses();
}
this.assignAttributes(this.domNodes[0],{
changedAttributes: changedAttributes,
sourcePrefix: "data-",
destPrefix: "data-"
});
} }
return this.refreshChildren(changedTiddlers); return this.refreshChildren(changedTiddlers);
}; };

View File

@@ -58,25 +58,24 @@ ImageWidget.prototype.render = function(parent,nextSibling) {
if(this.wiki.isImageTiddler(this.imageSource)) { if(this.wiki.isImageTiddler(this.imageSource)) {
var type = tiddler.fields.type, var type = tiddler.fields.type,
text = tiddler.fields.text, text = tiddler.fields.text,
_canonical_uri = tiddler.fields._canonical_uri, _canonical_uri = tiddler.fields._canonical_uri;
typeInfo = $tw.config.contentTypeInfo[type] || {},
deserializerType = typeInfo.deserializerType || type;
// If the tiddler has body text then it doesn't need to be lazily loaded // If the tiddler has body text then it doesn't need to be lazily loaded
if(text) { if(text) {
// Render the appropriate element for the image type by looking up the encoding in the content type info // Render the appropriate element for the image type
var encoding = typeInfo.encoding || "utf8"; switch(type) {
if (encoding === "base64") { case "application/pdf":
// .pdf .png .jpg etc.
src = "data:" + deserializerType + ";base64," + text;
if (deserializerType === "application/pdf") {
tag = "embed"; tag = "embed";
} src = "data:application/pdf;base64," + text;
} else { break;
// .svg .tid .xml etc. case "image/svg+xml":
src = "data:" + deserializerType + "," + encodeURIComponent(text); src = "data:image/svg+xml," + encodeURIComponent(text);
break;
default:
src = "data:" + type + ";base64," + text;
break;
} }
} else if(_canonical_uri) { } else if(_canonical_uri) {
switch(deserializerType) { switch(type) {
case "application/pdf": case "application/pdf":
tag = "embed"; tag = "embed";
src = _canonical_uri; src = _canonical_uri;
@@ -100,9 +99,6 @@ ImageWidget.prototype.render = function(parent,nextSibling) {
if(this.imageClass) { if(this.imageClass) {
domNode.setAttribute("class",this.imageClass); domNode.setAttribute("class",this.imageClass);
} }
if(this.imageUsemap) {
domNode.setAttribute("usemap",this.imageUsemap);
}
if(this.imageWidth) { if(this.imageWidth) {
domNode.setAttribute("width",this.imageWidth); domNode.setAttribute("width",this.imageWidth);
} }
@@ -142,7 +138,6 @@ ImageWidget.prototype.execute = function() {
this.imageWidth = this.getAttribute("width"); this.imageWidth = this.getAttribute("width");
this.imageHeight = this.getAttribute("height"); this.imageHeight = this.getAttribute("height");
this.imageClass = this.getAttribute("class"); this.imageClass = this.getAttribute("class");
this.imageUsemap = this.getAttribute("usemap");
this.imageTooltip = this.getAttribute("tooltip"); this.imageTooltip = this.getAttribute("tooltip");
this.imageAlt = this.getAttribute("alt"); this.imageAlt = this.getAttribute("alt");
this.lazyLoading = this.getAttribute("loading"); this.lazyLoading = this.getAttribute("loading");
@@ -153,7 +148,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
*/ */
ImageWidget.prototype.refresh = function(changedTiddlers) { ImageWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes(); var changedAttributes = this.computeAttributes();
if(changedAttributes.source || changedAttributes.width || changedAttributes.height || changedAttributes["class"] || changedAttributes.usemap || changedAttributes.tooltip || changedTiddlers[this.imageSource]) { if(changedAttributes.source || changedAttributes.width || changedAttributes.height || changedAttributes["class"] || changedAttributes.tooltip || changedTiddlers[this.imageSource]) {
this.refreshSelf(); this.refreshSelf();
return true; return true;
} else { } else {

View File

@@ -43,11 +43,6 @@ LinkWidget.prototype.render = function(parent,nextSibling) {
} else { } else {
// Just insert the link text // Just insert the link text
var domNode = this.document.createElement("span"); var domNode = this.document.createElement("span");
// Assign data- attributes
this.assignAttributes(domNode,{
sourcePrefix: "data-",
destPrefix: "data-"
});
parent.insertBefore(domNode,nextSibling); parent.insertBefore(domNode,nextSibling);
this.renderChildren(domNode,null); this.renderChildren(domNode,null);
this.domNodes.push(domNode); this.domNodes.push(domNode);
@@ -143,11 +138,6 @@ LinkWidget.prototype.renderLink = function(parent,nextSibling) {
widget: this widget: this
}); });
} }
// Assign data- attributes
this.assignAttributes(domNode,{
sourcePrefix: "data-",
destPrefix: "data-"
});
// Insert the link into the DOM and render any children // Insert the link into the DOM and render any children
parent.insertBefore(domNode,nextSibling); parent.insertBefore(domNode,nextSibling);
this.renderChildren(domNode,null); this.renderChildren(domNode,null);
@@ -217,7 +207,8 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
*/ */
LinkWidget.prototype.refresh = function(changedTiddlers) { LinkWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes(); var changedAttributes = this.computeAttributes();
if($tw.utils.count(changedAttributes) > 0) { if(changedAttributes.to || changedTiddlers[this.to] || changedAttributes["aria-label"] || changedAttributes.tooltip ||
changedAttributes["class"] || changedAttributes.tabindex || changedAttributes.draggable || changedAttributes.tag) {
this.refreshSelf(); this.refreshSelf();
return true; return true;
} }
@@ -227,4 +218,3 @@ LinkWidget.prototype.refresh = function(changedTiddlers) {
exports.link = LinkWidget; exports.link = LinkWidget;
})(); })();

View File

@@ -28,18 +28,6 @@ Inherit from the base widget class
*/ */
ListWidget.prototype = new Widget(); ListWidget.prototype = new Widget();
ListWidget.prototype.initialise = function(parseTreeNode,options) {
// Bail if parseTreeNode is undefined, meaning that the ListWidget constructor was called without any arguments so that it can be subclassed
if(parseTreeNode === undefined) {
return;
}
// First call parent constructor to set everything else up
Widget.prototype.initialise.call(this,parseTreeNode,options);
// Now look for <$list-template> and <$list-empty> widgets as immediate child widgets
// This is safe to do during initialization because parse trees never change after creation
this.findExplicitTemplates();
}
/* /*
Render this widget into the DOM Render this widget into the DOM
*/ */
@@ -50,8 +38,8 @@ ListWidget.prototype.render = function(parent,nextSibling) {
$tw.modules.applyMethods("storyview",this.storyViews); $tw.modules.applyMethods("storyview",this.storyViews);
} }
this.parentDomNode = parent; this.parentDomNode = parent;
var changedAttributes = this.computeAttributes(); this.computeAttributes();
this.execute(changedAttributes); this.execute();
this.renderChildren(parent,nextSibling); this.renderChildren(parent,nextSibling);
// Construct the storyview // Construct the storyview
var StoryView = this.storyViews[this.storyViewName]; var StoryView = this.storyViews[this.storyViewName];
@@ -71,8 +59,7 @@ ListWidget.prototype.render = function(parent,nextSibling) {
/* /*
Compute the internal state of the widget Compute the internal state of the widget
*/ */
ListWidget.prototype.execute = function(changedAttributes) { ListWidget.prototype.execute = function() {
var self = this;
// Get our attributes // Get our attributes
this.template = this.getAttribute("template"); this.template = this.getAttribute("template");
this.editTemplate = this.getAttribute("editTemplate"); this.editTemplate = this.getAttribute("editTemplate");
@@ -80,10 +67,6 @@ ListWidget.prototype.execute = function(changedAttributes) {
this.counterName = this.getAttribute("counter"); this.counterName = this.getAttribute("counter");
this.storyViewName = this.getAttribute("storyview"); this.storyViewName = this.getAttribute("storyview");
this.historyTitle = this.getAttribute("history"); this.historyTitle = this.getAttribute("history");
// Create join template only if needed
if(this.join === undefined || (changedAttributes && changedAttributes.join)) {
this.join = this.makeJoinTemplate();
}
// Compose the list elements // Compose the list elements
this.list = this.getTiddlerList(); this.list = this.getTiddlerList();
var members = [], var members = [],
@@ -102,57 +85,18 @@ ListWidget.prototype.execute = function(changedAttributes) {
this.history = []; this.history = [];
}; };
ListWidget.prototype.findExplicitTemplates = function() {
var self = this;
this.explicitListTemplate = null;
this.explicitEmptyTemplate = null;
this.explicitJoinTemplate = null;
this.hasTemplateInBody = false;
var searchChildren = function(childNodes) {
var foundInlineTemplate = false;
$tw.utils.each(childNodes,function(node) {
if(node.type === "list-template") {
self.explicitListTemplate = node.children;
} else if(node.type === "list-empty") {
self.explicitEmptyTemplate = node.children;
} else if(node.type === "list-join") {
self.explicitJoinTemplate = node.children;
} else if(node.type === "element" && node.tag === "p") {
searchChildren(node.children);
foundInlineTemplate = true;
} else {
foundInlineTemplate = true;
}
});
return foundInlineTemplate;
};
this.hasTemplateInBody = searchChildren(this.parseTreeNode.children);
}
ListWidget.prototype.getTiddlerList = function() { ListWidget.prototype.getTiddlerList = function() {
var limit = $tw.utils.getInt(this.getAttribute("limit",""),undefined);
var defaultFilter = "[!is[system]sort[title]]"; var defaultFilter = "[!is[system]sort[title]]";
var results = this.wiki.filterTiddlers(this.getAttribute("filter",defaultFilter),this); return this.wiki.filterTiddlers(this.getAttribute("filter",defaultFilter),this);
if(limit !== undefined) {
if(limit >= 0) {
results = results.slice(0,limit);
} else {
results = results.slice(limit);
}
}
return results;
}; };
ListWidget.prototype.getEmptyMessage = function() { ListWidget.prototype.getEmptyMessage = function() {
var parser, var parser,
emptyMessage = this.getAttribute("emptyMessage"); emptyMessage = this.getAttribute("emptyMessage","");
// If emptyMessage attribute is not present or empty then look for an explicit empty template // this.wiki.parseText() calls
if(!emptyMessage) { // new Parser(..), which should only be done, if needed, because it's heavy!
if(this.explicitEmptyTemplate) { if (emptyMessage === "") {
return this.explicitEmptyTemplate; return [];
} else {
return [];
}
} }
parser = this.wiki.parseText("text/vnd.tiddlywiki",emptyMessage,{parseAsInline: true}); parser = this.wiki.parseText("text/vnd.tiddlywiki",emptyMessage,{parseAsInline: true});
if(parser) { if(parser) {
@@ -162,24 +106,6 @@ ListWidget.prototype.getEmptyMessage = function() {
} }
}; };
/*
Compose the template for a join between list items
*/
ListWidget.prototype.makeJoinTemplate = function() {
var parser,
join = this.getAttribute("join","");
if(join) {
parser = this.wiki.parseText("text/vnd.tiddlywiki",join,{parseAsInline:true})
if(parser) {
return parser.tree;
} else {
return [];
}
} else {
return this.explicitJoinTemplate; // May be null, and that's fine
}
};
/* /*
Compose the template for a list item Compose the template for a list item
*/ */
@@ -188,7 +114,6 @@ ListWidget.prototype.makeItemTemplate = function(title,index) {
var tiddler = this.wiki.getTiddler(title), var tiddler = this.wiki.getTiddler(title),
isDraft = tiddler && tiddler.hasField("draft.of"), isDraft = tiddler && tiddler.hasField("draft.of"),
template = this.template, template = this.template,
join = this.join,
templateTree; templateTree;
if(isDraft && this.editTemplate) { if(isDraft && this.editTemplate) {
template = this.editTemplate; template = this.editTemplate;
@@ -197,29 +122,22 @@ ListWidget.prototype.makeItemTemplate = function(title,index) {
if(template) { if(template) {
templateTree = [{type: "transclude", attributes: {tiddler: {type: "string", value: template}}}]; templateTree = [{type: "transclude", attributes: {tiddler: {type: "string", value: template}}}];
} else { } else {
// Check for child nodes of the list widget
if(this.parseTreeNode.children && this.parseTreeNode.children.length > 0) { if(this.parseTreeNode.children && this.parseTreeNode.children.length > 0) {
// Check for a <$list-item> widget templateTree = this.parseTreeNode.children;
if(this.explicitListTemplate) { } else {
templateTree = this.explicitListTemplate;
} else if(this.hasTemplateInBody) {
templateTree = this.parseTreeNode.children;
}
}
if(!templateTree || templateTree.length === 0) {
// Default template is a link to the title // Default template is a link to the title
templateTree = [{type: "element", tag: this.parseTreeNode.isBlock ? "div" : "span", children: [{type: "link", attributes: {to: {type: "string", value: title}}, children: [ templateTree = [{type: "element", tag: this.parseTreeNode.isBlock ? "div" : "span", children: [{type: "link", attributes: {to: {type: "string", value: title}}, children: [
{type: "text", text: title} {type: "text", text: title}
]}]}]; ]}]}];
} }
} }
// Return the list item // Return the list item
var parseTreeNode = {type: "listitem", itemTitle: title, variableName: this.variableName, children: templateTree, join: join}; var parseTreeNode = {type: "listitem", itemTitle: title, variableName: this.variableName, children: templateTree};
parseTreeNode.isLast = index === this.list.length - 1;
if(this.counterName) { if(this.counterName) {
parseTreeNode.counter = (index + 1).toString(); parseTreeNode.counter = (index + 1).toString();
parseTreeNode.counterName = this.counterName; parseTreeNode.counterName = this.counterName;
parseTreeNode.isFirst = index === 0; parseTreeNode.isFirst = index === 0;
parseTreeNode.isLast = index === this.list.length - 1;
} }
return parseTreeNode; return parseTreeNode;
}; };
@@ -235,7 +153,7 @@ ListWidget.prototype.refresh = function(changedTiddlers) {
this.storyview.refreshStart(changedTiddlers,changedAttributes); this.storyview.refreshStart(changedTiddlers,changedAttributes);
} }
// Completely refresh if any of our attributes have changed // Completely refresh if any of our attributes have changed
if(changedAttributes.filter || changedAttributes.variable || changedAttributes.counter || changedAttributes.template || changedAttributes.editTemplate || changedAttributes.join || changedAttributes.emptyMessage || changedAttributes.storyview || changedAttributes.history) { if(changedAttributes.filter || changedAttributes.variable || changedAttributes.counter || changedAttributes.template || changedAttributes.editTemplate || changedAttributes.emptyMessage || changedAttributes.storyview || changedAttributes.history) {
this.refreshSelf(); this.refreshSelf();
result = true; result = true;
} else { } else {
@@ -307,8 +225,6 @@ ListWidget.prototype.handleListChanges = function(changedTiddlers) {
// If we are providing an counter variable then we must refresh the items, otherwise we can rearrange them // If we are providing an counter variable then we must refresh the items, otherwise we can rearrange them
var hasRefreshed = false,t; var hasRefreshed = false,t;
if(this.counterName) { if(this.counterName) {
var mustRefreshOldLast = false;
var oldLength = this.children.length;
// Cycle through the list and remove and re-insert the first item that has changed, and all the remaining items // Cycle through the list and remove and re-insert the first item that has changed, and all the remaining items
for(t=0; t<this.list.length; t++) { for(t=0; t<this.list.length; t++) {
if(hasRefreshed || !this.children[t] || this.children[t].parseTreeNode.itemTitle !== this.list[t]) { if(hasRefreshed || !this.children[t] || this.children[t].parseTreeNode.itemTitle !== this.list[t]) {
@@ -316,9 +232,6 @@ ListWidget.prototype.handleListChanges = function(changedTiddlers) {
this.removeListItem(t); this.removeListItem(t);
} }
this.insertListItem(t,this.list[t]); this.insertListItem(t,this.list[t]);
if(!hasRefreshed && t === oldLength) {
mustRefreshOldLast = true;
}
hasRefreshed = true; hasRefreshed = true;
} else { } else {
// Refresh the item we're reusing // Refresh the item we're reusing
@@ -326,12 +239,6 @@ ListWidget.prototype.handleListChanges = function(changedTiddlers) {
hasRefreshed = hasRefreshed || refreshed; hasRefreshed = hasRefreshed || refreshed;
} }
} }
// If items were inserted then we must recreate the item that used to be at the last position as it is no longer last
if(mustRefreshOldLast && oldLength > 0) {
var oldLastIdx = oldLength-1;
this.removeListItem(oldLastIdx);
this.insertListItem(oldLastIdx,this.list[oldLastIdx]);
}
// If there are items to remove and we have not refreshed then recreate the item that will now be at the last position // If there are items to remove and we have not refreshed then recreate the item that will now be at the last position
if(!hasRefreshed && this.children.length > this.list.length) { if(!hasRefreshed && this.children.length > this.list.length) {
this.removeListItem(this.list.length-1); this.removeListItem(this.list.length-1);
@@ -339,29 +246,10 @@ ListWidget.prototype.handleListChanges = function(changedTiddlers) {
} }
} else { } else {
// Cycle through the list, inserting and removing list items as needed // Cycle through the list, inserting and removing list items as needed
var mustRecreateLastItem = false;
if(this.join && this.join.length) {
if(this.children.length !== this.list.length) {
mustRecreateLastItem = true;
} else if(prevList[prevList.length-1] !== this.list[this.list.length-1]) {
mustRecreateLastItem = true;
}
}
var isLast = false, wasLast = false;
for(t=0; t<this.list.length; t++) { for(t=0; t<this.list.length; t++) {
isLast = t === this.list.length-1;
var index = this.findListItem(t,this.list[t]); var index = this.findListItem(t,this.list[t]);
wasLast = index === this.children.length-1;
if(wasLast && (index !== t || this.children.length !== this.list.length)) {
mustRecreateLastItem = !!(this.join && this.join.length);
}
if(index === undefined) { if(index === undefined) {
// The list item must be inserted // The list item must be inserted
if(isLast && mustRecreateLastItem && t>0) {
// First re-create previosly-last item that will no longer be last
this.removeListItem(t-1);
this.insertListItem(t-1,this.list[t-1]);
}
this.insertListItem(t,this.list[t]); this.insertListItem(t,this.list[t]);
hasRefreshed = true; hasRefreshed = true;
} else { } else {
@@ -370,15 +258,9 @@ ListWidget.prototype.handleListChanges = function(changedTiddlers) {
this.removeListItem(n); this.removeListItem(n);
hasRefreshed = true; hasRefreshed = true;
} }
// Refresh the item we're reusing, or recreate if necessary // Refresh the item we're reusing
if(mustRecreateLastItem && (isLast || wasLast)) { var refreshed = this.children[t].refresh(changedTiddlers);
this.removeListItem(t); hasRefreshed = hasRefreshed || refreshed;
this.insertListItem(t,this.list[t]);
hasRefreshed = true;
} else {
var refreshed = this.children[t].refresh(changedTiddlers);
hasRefreshed = hasRefreshed || refreshed;
}
} }
} }
} }
@@ -468,17 +350,8 @@ ListItemWidget.prototype.execute = function() {
this.setVariable(this.parseTreeNode.counterName + "-first",this.parseTreeNode.isFirst ? "yes" : "no"); this.setVariable(this.parseTreeNode.counterName + "-first",this.parseTreeNode.isFirst ? "yes" : "no");
this.setVariable(this.parseTreeNode.counterName + "-last",this.parseTreeNode.isLast ? "yes" : "no"); this.setVariable(this.parseTreeNode.counterName + "-last",this.parseTreeNode.isLast ? "yes" : "no");
} }
// Add join if needed
var children = this.parseTreeNode.children,
join = this.parseTreeNode.join;
if(join && join.length && !this.parseTreeNode.isLast) {
children = children.slice(0);
$tw.utils.each(join,function(joinNode) {
children.push(joinNode);
})
}
// Construct the child widgets // Construct the child widgets
this.makeChildWidgets(children); this.makeChildWidgets();
}; };
/* /*
@@ -490,37 +363,4 @@ ListItemWidget.prototype.refresh = function(changedTiddlers) {
exports.listitem = ListItemWidget; exports.listitem = ListItemWidget;
/*
Make <$list-template> and <$list-empty> widgets that do nothing
*/
var ListTemplateWidget = function(parseTreeNode,options) {
// Main initialisation inherited from widget.js
this.initialise(parseTreeNode,options);
};
ListTemplateWidget.prototype = new Widget();
ListTemplateWidget.prototype.render = function() {}
ListTemplateWidget.prototype.refresh = function() { return false; }
exports["list-template"] = ListTemplateWidget;
var ListEmptyWidget = function(parseTreeNode,options) {
// Main initialisation inherited from widget.js
this.initialise(parseTreeNode,options);
};
ListEmptyWidget.prototype = new Widget();
ListEmptyWidget.prototype.render = function() {}
ListEmptyWidget.prototype.refresh = function() { return false; }
exports["list-empty"] = ListEmptyWidget;
var ListJoinWidget = function(parseTreeNode,options) {
// Main initialisation inherited from widget.js
this.initialise(parseTreeNode,options);
};
ListJoinWidget.prototype = new Widget();
ListJoinWidget.prototype.render = function() {}
ListJoinWidget.prototype.refresh = function() { return false; }
exports["list-join"] = ListJoinWidget;
})(); })();

View File

@@ -40,10 +40,6 @@ RadioWidget.prototype.render = function(parent,nextSibling) {
); );
this.inputDomNode = this.document.createElement("input"); this.inputDomNode = this.document.createElement("input");
this.inputDomNode.setAttribute("type","radio"); this.inputDomNode.setAttribute("type","radio");
this.assignAttributes(this.inputDomNode,{
sourcePrefix: "data-",
destPrefix: "data-"
});
if(isChecked) { if(isChecked) {
this.inputDomNode.checked = true; this.inputDomNode.checked = true;
} }

View File

@@ -50,10 +50,6 @@ RangeWidget.prototype.render = function(parent,nextSibling) {
this.inputDomNode.setAttribute("disabled",true); this.inputDomNode.setAttribute("disabled",true);
} }
this.inputDomNode.value = this.getValue(); this.inputDomNode.value = this.getValue();
this.assignAttributes(this.inputDomNode,{
sourcePrefix: "data-",
destPrefix: "data-"
});
// Add a click event handler // Add a click event handler
$tw.utils.addEventListeners(this.inputDomNode,[ $tw.utils.addEventListeners(this.inputDomNode,[
{name:"mousedown", handlerObject:this, handlerMethod:"handleMouseDownEvent"}, {name:"mousedown", handlerObject:this, handlerMethod:"handleMouseDownEvent"},

View File

@@ -12,8 +12,6 @@ Scrollable widget
/*global $tw: false */ /*global $tw: false */
"use strict"; "use strict";
var DEBOUNCE_INTERVAL = 100; // Delay after last scroll event before updating the bound tiddler
var Widget = require("$:/core/modules/widgets/widget.js").widget; var Widget = require("$:/core/modules/widgets/widget.js").widget;
var ScrollableWidget = function(parseTreeNode,options) { var ScrollableWidget = function(parseTreeNode,options) {
@@ -173,53 +171,6 @@ ScrollableWidget.prototype.render = function(parent,nextSibling) {
parent.insertBefore(this.outerDomNode,nextSibling); parent.insertBefore(this.outerDomNode,nextSibling);
this.renderChildren(this.innerDomNode,null); this.renderChildren(this.innerDomNode,null);
this.domNodes.push(this.outerDomNode); this.domNodes.push(this.outerDomNode);
// If the scroll position is bound to a tiddler
if(this.scrollableBind) {
// After a delay for rendering, scroll to the bound position
this.updateScrollPositionFromBoundTiddler();
// Set up event listener
this.currentListener = this.listenerFunction.bind(this);
this.outerDomNode.addEventListener("scroll", this.currentListener);
}
};
ScrollableWidget.prototype.listenerFunction = function(event) {
self = this;
clearTimeout(this.timeout);
this.timeout = setTimeout(function() {
var existingTiddler = self.wiki.getTiddler(self.scrollableBind),
newTiddlerFields = {
title: self.scrollableBind,
"scroll-left": self.outerDomNode.scrollLeft.toString(),
"scroll-top": self.outerDomNode.scrollTop.toString()
};
if(!existingTiddler || (existingTiddler.fields["title"] !== newTiddlerFields["title"]) || (existingTiddler.fields["scroll-left"] !== newTiddlerFields["scroll-left"] || existingTiddler.fields["scroll-top"] !== newTiddlerFields["scroll-top"])) {
self.wiki.addTiddler(new $tw.Tiddler(existingTiddler,newTiddlerFields));
}
}, DEBOUNCE_INTERVAL);
}
ScrollableWidget.prototype.updateScrollPositionFromBoundTiddler = function() {
// Bail if we're running on the fakedom
if(!this.outerDomNode.scrollTo) {
return;
}
var tiddler = this.wiki.getTiddler(this.scrollableBind);
if(tiddler) {
var scrollLeftTo = this.outerDomNode.scrollLeft;
if(parseFloat(tiddler.fields["scroll-left"]).toString() === tiddler.fields["scroll-left"]) {
scrollLeftTo = parseFloat(tiddler.fields["scroll-left"]);
}
var scrollTopTo = this.outerDomNode.scrollTop;
if(parseFloat(tiddler.fields["scroll-top"]).toString() === tiddler.fields["scroll-top"]) {
scrollTopTo = parseFloat(tiddler.fields["scroll-top"]);
}
this.outerDomNode.scrollTo({
top: scrollTopTo,
left: scrollLeftTo,
behavior: "instant"
})
}
}; };
/* /*
@@ -227,7 +178,6 @@ Compute the internal state of the widget
*/ */
ScrollableWidget.prototype.execute = function() { ScrollableWidget.prototype.execute = function() {
// Get attributes // Get attributes
this.scrollableBind = this.getAttribute("bind");
this.fallthrough = this.getAttribute("fallthrough","yes"); this.fallthrough = this.getAttribute("fallthrough","yes");
this["class"] = this.getAttribute("class"); this["class"] = this.getAttribute("class");
// Make child widgets // Make child widgets
@@ -243,22 +193,7 @@ ScrollableWidget.prototype.refresh = function(changedTiddlers) {
this.refreshSelf(); this.refreshSelf();
return true; return true;
} }
// If the bound tiddler has changed, update the eventListener and update scroll position return this.refreshChildren(changedTiddlers);
if(changedAttributes["bind"]) {
if(this.currentListener) {
this.outerDomNode.removeEventListener("scroll", this.currentListener, false);
}
this.scrollableBind = this.getAttribute("bind");
this.currentListener = this.listenerFunction.bind(this);
this.outerDomNode.addEventListener("scroll", this.currentListener);
}
// Refresh children
var result = this.refreshChildren(changedTiddlers);
// If the bound tiddler has changed, update scroll position
if(changedAttributes["bind"] || changedTiddlers[this.getAttribute("bind")]) {
this.updateScrollPositionFromBoundTiddler();
}
return result;
}; };
exports.scrollable = ScrollableWidget; exports.scrollable = ScrollableWidget;

View File

@@ -40,31 +40,7 @@ SelectWidget.prototype.render = function(parent,nextSibling) {
this.parentDomNode = parent; this.parentDomNode = parent;
this.computeAttributes(); this.computeAttributes();
this.execute(); this.execute();
//Create element this.renderChildren(parent,nextSibling);
var domNode = this.document.createElement("select");
if(this.selectClass) {
domNode.className = this.selectClass;
}
// Assign data- attributes
this.assignAttributes(domNode,{
sourcePrefix: "data-",
destPrefix: "data-"
});
if(this.selectMultiple) {
domNode.setAttribute("multiple","multiple");
}
if(this.selectSize) {
domNode.setAttribute("size",this.selectSize);
}
if(this.selectTabindex) {
domNode.setAttribute("tabindex",this.selectTabindex);
}
if(this.selectTooltip) {
domNode.setAttribute("title",this.selectTooltip);
}
this.parentDomNode.insertBefore(domNode,nextSibling);
this.renderChildren(domNode,null);
this.domNodes.push(domNode);
this.setSelectValue(); this.setSelectValue();
if(this.selectFocus == "yes") { if(this.selectFocus == "yes") {
this.getSelectDomNode().focus(); this.getSelectDomNode().focus();
@@ -137,7 +113,7 @@ SelectWidget.prototype.setSelectValue = function() {
Get the DOM node of the select element Get the DOM node of the select element
*/ */
SelectWidget.prototype.getSelectDomNode = function() { SelectWidget.prototype.getSelectDomNode = function() {
return this.domNodes[0]; return this.children[0].domNodes[0];
}; };
// Return an array of the selected opion values // Return an array of the selected opion values
@@ -173,7 +149,27 @@ SelectWidget.prototype.execute = function() {
this.selectTooltip = this.getAttribute("tooltip"); this.selectTooltip = this.getAttribute("tooltip");
this.selectFocus = this.getAttribute("focus"); this.selectFocus = this.getAttribute("focus");
// Make the child widgets // Make the child widgets
this.makeChildWidgets(); var selectNode = {
type: "element",
tag: "select",
children: this.parseTreeNode.children
};
if(this.selectClass) {
$tw.utils.addAttributeToParseTreeNode(selectNode,"class",this.selectClass);
}
if(this.selectMultiple) {
$tw.utils.addAttributeToParseTreeNode(selectNode,"multiple","multiple");
}
if(this.selectSize) {
$tw.utils.addAttributeToParseTreeNode(selectNode,"size",this.selectSize);
}
if(this.selectTabindex) {
$tw.utils.addAttributeToParseTreeNode(selectNode,"tabindex",this.selectTabindex);
}
if(this.selectTooltip) {
$tw.utils.addAttributeToParseTreeNode(selectNode,"title",this.selectTooltip);
}
this.makeChildWidgets([selectNode]);
}; };
/* /*
@@ -182,21 +178,17 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
SelectWidget.prototype.refresh = function(changedTiddlers) { SelectWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes(); var changedAttributes = this.computeAttributes();
// If we're using a different tiddler/field/index then completely refresh ourselves // If we're using a different tiddler/field/index then completely refresh ourselves
if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes.tooltip || changedAttributes.tabindex) { if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes.tooltip) {
this.refreshSelf(); this.refreshSelf();
return true; return true;
// If the target tiddler value has changed, just update setting and refresh the children
} else { } else {
if(changedAttributes.class) { if(changedAttributes.class) {
this.selectClass = this.getAttribute("class"); this.selectClass = this.getAttribute("class");
this.getSelectDomNode().setAttribute("class",this.selectClass); this.getSelectDomNode().setAttribute("class",this.selectClass);
} }
this.assignAttributes(this.getSelectDomNode(),{
changedAttributes: changedAttributes,
sourcePrefix: "data-",
destPrefix: "data-"
});
var childrenRefreshed = this.refreshChildren(changedTiddlers); var childrenRefreshed = this.refreshChildren(changedTiddlers);
// If the target tiddler value has changed, just update setting and refresh the children
if(changedTiddlers[this.selectTitle] || childrenRefreshed) { if(changedTiddlers[this.selectTitle] || childrenRefreshed) {
this.setSelectValue(); this.setSelectValue();
} }

View File

@@ -109,7 +109,6 @@ TranscludeWidget.prototype.collectAttributes = function() {
this.recursionMarker = this.getAttribute("recursionMarker","yes"); this.recursionMarker = this.getAttribute("recursionMarker","yes");
} else { } else {
this.transcludeVariable = this.getAttribute("$variable"); this.transcludeVariable = this.getAttribute("$variable");
this.transcludeVariableIsFunction = false;
this.transcludeType = this.getAttribute("$type"); this.transcludeType = this.getAttribute("$type");
this.transcludeOutput = this.getAttribute("$output","text/html"); this.transcludeOutput = this.getAttribute("$output","text/html");
this.transcludeTitle = this.getAttribute("$tiddler",this.getVariable("currentTiddler")); this.transcludeTitle = this.getAttribute("$tiddler",this.getVariable("currentTiddler"));
@@ -185,9 +184,7 @@ TranscludeWidget.prototype.getTransclusionTarget = function() {
if(this.transcludeVariable) { if(this.transcludeVariable) {
// Transcluding a variable // Transcluding a variable
var variableInfo = this.getVariableInfo(this.transcludeVariable,{params: this.getOrderedTransclusionParameters()}); var variableInfo = this.getVariableInfo(this.transcludeVariable,{params: this.getOrderedTransclusionParameters()});
this.transcludeVariableIsFunction = variableInfo.srcVariable && variableInfo.srcVariable.isFunctionDefinition;
text = variableInfo.text; text = variableInfo.text;
this.transcludeFunctionResult = text;
return { return {
text: variableInfo.text, text: variableInfo.text,
type: this.transcludeType type: this.transcludeType
@@ -222,24 +219,21 @@ TranscludeWidget.prototype.parseTransclusionTarget = function(parseAsInline) {
// Transcluding a variable // Transcluding a variable
var variableInfo = this.getVariableInfo(this.transcludeVariable,{params: this.getOrderedTransclusionParameters()}), var variableInfo = this.getVariableInfo(this.transcludeVariable,{params: this.getOrderedTransclusionParameters()}),
srcVariable = variableInfo && variableInfo.srcVariable; srcVariable = variableInfo && variableInfo.srcVariable;
if(srcVariable && srcVariable.isFunctionDefinition) {
this.transcludeVariableIsFunction = true;
this.transcludeFunctionResult = (variableInfo.resultList ? variableInfo.resultList[0] : variableInfo.text) || "";
}
if(variableInfo.text) { if(variableInfo.text) {
if(srcVariable && srcVariable.isFunctionDefinition) { if(srcVariable && srcVariable.isFunctionDefinition) {
var result = (variableInfo.resultList ? variableInfo.resultList[0] : variableInfo.text) || "";
parser = { parser = {
tree: [{ tree: [{
type: "text", type: "text",
text: this.transcludeFunctionResult text: result
}], }],
source: this.transcludeFunctionResult, source: result,
type: "text/vnd.tiddlywiki" type: "text/vnd.tiddlywiki"
}; };
if(parseAsInline) { if(parseAsInline) {
parser.tree[0] = { parser.tree[0] = {
type: "text", type: "text",
text: this.transcludeFunctionResult text: result
}; };
} else { } else {
parser.tree[0] = { parser.tree[0] = {
@@ -247,7 +241,7 @@ TranscludeWidget.prototype.parseTransclusionTarget = function(parseAsInline) {
tag: "p", tag: "p",
children: [{ children: [{
type: "text", type: "text",
text: this.transcludeFunctionResult text: result
}] }]
} }
} }
@@ -436,19 +430,12 @@ TranscludeWidget.prototype.parserNeedsRefresh = function() {
return (this.sourceText === undefined || parserInfo.sourceText !== this.sourceText || parserInfo.parserType !== this.parserType) return (this.sourceText === undefined || parserInfo.sourceText !== this.sourceText || parserInfo.parserType !== this.parserType)
}; };
TranscludeWidget.prototype.functionNeedsRefresh = function() {
var oldResult = this.transcludeFunctionResult;
var variableInfo = this.getVariableInfo(this.transcludeVariable,{params: this.getOrderedTransclusionParameters()});
var newResult = (variableInfo.resultList ? variableInfo.resultList[0] : variableInfo.text) || "";
return oldResult !== newResult;
}
/* /*
Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering
*/ */
TranscludeWidget.prototype.refresh = function(changedTiddlers) { TranscludeWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes(); var changedAttributes = this.computeAttributes();
if(($tw.utils.count(changedAttributes) > 0) || (this.transcludeVariableIsFunction && this.functionNeedsRefresh()) || (!this.transcludeVariable && changedTiddlers[this.transcludeTitle] && this.parserNeedsRefresh())) { if(($tw.utils.count(changedAttributes) > 0) || (!this.transcludeVariable && changedTiddlers[this.transcludeTitle] && this.parserNeedsRefresh())) {
this.refreshSelf(); this.refreshSelf();
return true; return true;
} else { } else {

View File

@@ -413,34 +413,16 @@ Widget.prototype.getAttribute = function(name,defaultText) {
}; };
/* /*
Assign the common attributes of the widget to a domNode Assign the computed attributes of the widget to a domNode
options include: options include:
sourcePrefix: prefix of attributes that are to be directly assigned (defaults to the empty string meaning all attributes) excludeEventAttributes: ignores attributes whose name begins with "on"
destPrefix: prefix to be applied to attribute names that are to be directly assigned (defaults to the emtpy string which means no prefix is added)
changedAttributes: hashmap by attribute name of attributes to process (if missing, process all attributes)
excludeEventAttributes: ignores attributes whose name would begin with "on"
*/ */
Widget.prototype.assignAttributes = function(domNode,options) { Widget.prototype.assignAttributes = function(domNode,options) {
options = options || {}; options = options || {};
var self = this, var self = this;
changedAttributes = options.changedAttributes || this.attributes,
sourcePrefix = options.sourcePrefix || "",
destPrefix = options.destPrefix || "",
EVENT_ATTRIBUTE_PREFIX = "on";
var assignAttribute = function(name,value) { var assignAttribute = function(name,value) {
// Process any style attributes before considering sourcePrefix and destPrefix
if(name.substr(0,6) === "style." && name.length > 6) {
domNode.style[$tw.utils.unHyphenateCss(name.substr(6))] = value;
return;
}
// Check if the sourcePrefix is a match
if(name.substr(0,sourcePrefix.length) === sourcePrefix) {
name = destPrefix + name.substr(sourcePrefix.length);
} else {
value = undefined;
}
// Check for excluded attribute names // Check for excluded attribute names
if(options.excludeEventAttributes && name.substr(0,2).toLowerCase() === EVENT_ATTRIBUTE_PREFIX) { if(options.excludeEventAttributes && name.substr(0,2) === "on") {
value = undefined; value = undefined;
} }
if(value !== undefined) { if(value !== undefined) {
@@ -450,24 +432,26 @@ Widget.prototype.assignAttributes = function(domNode,options) {
namespace = "http://www.w3.org/1999/xlink"; namespace = "http://www.w3.org/1999/xlink";
name = name.substr(6); name = name.substr(6);
} }
// Setting certain attributes can cause a DOM error (eg xmlns on the svg element) // Handle styles
try { if(name.substr(0,6) === "style." && name.length > 6) {
domNode.setAttributeNS(namespace,name,value); domNode.style[$tw.utils.unHyphenateCss(name.substr(6))] = value;
} catch(e) { } else {
// Setting certain attributes can cause a DOM error (eg xmlns on the svg element)
try {
domNode.setAttributeNS(namespace,name,value);
} catch(e) {
}
} }
} }
}; }
// If the parse tree node has the orderedAttributes property then use that order // Not all parse tree nodes have the orderedAttributes property
if(this.parseTreeNode.orderedAttributes) { if(this.parseTreeNode.orderedAttributes) {
$tw.utils.each(this.parseTreeNode.orderedAttributes,function(attribute,index) { $tw.utils.each(this.parseTreeNode.orderedAttributes,function(attribute,index) {
if(attribute.name in changedAttributes) { assignAttribute(attribute.name,self.attributes[attribute.name]);
assignAttribute(attribute.name,self.getAttribute(attribute.name));
}
}); });
// Otherwise update each changed attribute irrespective of order
} else { } else {
$tw.utils.each(changedAttributes,function(value,name) { $tw.utils.each(Object.keys(self.attributes).sort(),function(name) {
assignAttribute(name,self.getAttribute(name)); assignAttribute(name,self.attributes[name]);
}); });
} }
}; };

View File

@@ -1287,7 +1287,7 @@ exports.search = function(text,options) {
console.log("Regexp error parsing /(" + text + ")/" + flags + ": ",e); console.log("Regexp error parsing /(" + text + ")/" + flags + ": ",e);
} }
} else if(options.some) { } else if(options.some) {
terms = text.trim().split(/[^\S\xA0]+/); terms = text.trim().split(/ +/);
if(terms.length === 1 && terms[0] === "") { if(terms.length === 1 && terms[0] === "") {
searchTermsRegExps = null; searchTermsRegExps = null;
} else { } else {
@@ -1298,7 +1298,7 @@ exports.search = function(text,options) {
searchTermsRegExps.push(new RegExp("(" + regExpStr + ")",flags)); searchTermsRegExps.push(new RegExp("(" + regExpStr + ")",flags));
} }
} else { // default: words } else { // default: words
terms = text.split(/[^\S\xA0]+/); terms = text.split(/ +/);
if(terms.length === 1 && terms[0] === "") { if(terms.length === 1 && terms[0] === "") {
searchTermsRegExps = null; searchTermsRegExps = null;
} else { } else {

View File

@@ -1,3 +1,4 @@
title: $:/core/templates/html-json-skinny-tiddler title: $:/core/templates/html-json-skinny-tiddler
<$text text=<<join>>/><$jsontiddler tiddler=<<currentTiddler>> exclude="text" escapeUnsafeScriptChars="yes"/> <$list filter="[<numTiddlers>compare:number:gteq[1]] ~[<counter>!match[1]]">`,`<$text text=<<newline>>/></$list>
<$jsontiddler tiddler=<<currentTiddler>> exclude="text" escapeUnsafeScriptChars="yes"/>

View File

@@ -1,3 +1,3 @@
title: $:/core/templates/html-json-tiddler title: $:/core/templates/html-json-tiddler
<$jsontiddler tiddler=<<currentTiddler>> escapeUnsafeScriptChars="yes"/> <$list filter="[<counter>!match[1]]">`,`<$text text=<<newline>>/></$list><$jsontiddler tiddler=<<currentTiddler>> escapeUnsafeScriptChars="yes"/>

View File

@@ -6,12 +6,14 @@ title: $:/core/templates/store.area.template.html
<$list filter="[[storeAreaFormat]is[variable]getvariable[]else[json]match[json]]"> <$list filter="[[storeAreaFormat]is[variable]getvariable[]else[json]match[json]]">
<!-- New-style JSON store area, with an old-style store area for compatibility with v5.1.x tooling --> <!-- New-style JSON store area, with an old-style store area for compatibility with v5.1.x tooling -->
`<script class="tiddlywiki-tiddler-store" type="application/json">[` `<script class="tiddlywiki-tiddler-store" type="application/json">[`
<$let newline={{{ [charcode[10]] }}} join=`,$(newline)$`> <$vars newline={{{ [charcode[10]] }}}>
<$text text=<<newline>>/> <$text text=<<newline>>/>
<$list filter=<<saveTiddlerFilter>> join=<<join>> template="$:/core/templates/html-json-tiddler"/> <$list filter=<<saveTiddlerFilter>> counter="counter" template="$:/core/templates/html-json-tiddler"/>
<$list filter="[subfilter<skinnySaveTiddlerFilter>]" template="$:/core/templates/html-json-skinny-tiddler"/> <$vars numTiddlers={{{ [subfilter<saveTiddlerFilter>count[]] }}}>
<$list filter={{{ [<skinnySaveTiddlerFilter>] }}} counter="counter" template="$:/core/templates/html-json-skinny-tiddler"/>
</$vars>
<$text text=<<newline>>/> <$text text=<<newline>>/>
</$let> </$vars>
`]</script>` `]</script>`
`<div id="storeArea" style="display:none;">` `<div id="storeArea" style="display:none;">`
`</div>` `</div>`
@@ -20,8 +22,8 @@ title: $:/core/templates/store.area.template.html
<!-- Old-style DIV/PRE-based store area --> <!-- Old-style DIV/PRE-based store area -->
<$reveal type="nomatch" state="$:/isEncrypted" text="yes"> <$reveal type="nomatch" state="$:/isEncrypted" text="yes">
`<div id="storeArea" style="display:none;">` `<div id="storeArea" style="display:none;">`
<$list filter={{{ [<saveTiddlerFilter>] }}} template="$:/core/templates/html-div-tiddler"/> <$list filter=<<saveTiddlerFilter>> template="$:/core/templates/html-div-tiddler"/>
<$list filter="[subfilter<skinnySaveTiddlerFilter>]" template="$:/core/templates/html-div-skinny-tiddler"/> <$list filter={{{ [<skinnySaveTiddlerFilter>] }}} template="$:/core/templates/html-div-skinny-tiddler"/>
`</div>` `</div>`
</$reveal> </$reveal>
</$list> </$list>

View File

@@ -26,10 +26,10 @@ caption: {{$:/language/ControlPanel/Basics/Caption}}
|<$link to="$:/SiteSubtitle"><<lingo Subtitle/Prompt>></$link> |<$edit-text tiddler="$:/SiteSubtitle" default="" tag="input"/> | |<$link to="$:/SiteSubtitle"><<lingo Subtitle/Prompt>></$link> |<$edit-text tiddler="$:/SiteSubtitle" default="" tag="input"/> |
|<$link to="$:/status/UserName"><<lingo Username/Prompt>></$link> |<$edit-text tiddler="$:/status/UserName" default="" tag="input"/> | |<$link to="$:/status/UserName"><<lingo Username/Prompt>></$link> |<$edit-text tiddler="$:/status/UserName" default="" tag="input"/> |
|<$link to="$:/config/AnimationDuration"><<lingo AnimDuration/Prompt>></$link> |<$edit-text tiddler="$:/config/AnimationDuration" default="" tag="input"/> | |<$link to="$:/config/AnimationDuration"><<lingo AnimDuration/Prompt>></$link> |<$edit-text tiddler="$:/config/AnimationDuration" default="" tag="input"/> |
|<$link to="$:/DefaultTiddlers"><<lingo DefaultTiddlers/Prompt>></$link> |<<lingo DefaultTiddlers/TopHint>><br> <$edit class="tc-edit-texteditor" tiddler="$:/DefaultTiddlers" autoHeight="yes"/><br>//<<lingo DefaultTiddlers/BottomHint>>// | |<$link to="$:/DefaultTiddlers"><<lingo DefaultTiddlers/Prompt>></$link> |<<lingo DefaultTiddlers/TopHint>><br> <$edit class="tc-edit-texteditor" tiddler="$:/DefaultTiddlers"/><br>//<<lingo DefaultTiddlers/BottomHint>>// |
|<$link to="$:/language/DefaultNewTiddlerTitle"><<lingo NewTiddler/Title/Prompt>></$link> |<$edit-text tiddler="$:/language/DefaultNewTiddlerTitle" default="" tag="input"/> | |<$link to="$:/language/DefaultNewTiddlerTitle"><<lingo NewTiddler/Title/Prompt>></$link> |<$edit-text tiddler="$:/language/DefaultNewTiddlerTitle" default="" tag="input"/> |
|<$link to="$:/config/NewJournal/Title"><<lingo NewJournal/Title/Prompt>></$link> |<$edit-text tiddler="$:/config/NewJournal/Title" default="" tag="input"/> | |<$link to="$:/config/NewJournal/Title"><<lingo NewJournal/Title/Prompt>></$link> |<$edit-text tiddler="$:/config/NewJournal/Title" default="" tag="input"/> |
|<$link to="$:/config/NewJournal/Text"><<lingo NewJournal/Text/Prompt>></$link> |<$edit tiddler="$:/config/NewJournal/Text" class="tc-edit-texteditor" default="" autoHeight="yes"/> | |<$link to="$:/config/NewJournal/Text"><<lingo NewJournal/Text/Prompt>></$link> |<$edit tiddler="$:/config/NewJournal/Text" class="tc-edit-texteditor" default=""/> |
|<$link to="$:/config/NewTiddler/Tags"><<lingo NewTiddler/Tags/Prompt>></$link> |<$vars currentTiddler="$:/config/NewTiddler/Tags" tagField="text">{{||$:/core/ui/EditTemplate/tags}}<$list filter="[<currentTiddler>tags[]] +[limit[1]]" variable="ignore"><$button tooltip={{$:/language/ControlPanel/Basics/RemoveTags/Hint}}><<lingo RemoveTags>><$action-listops $tiddler=<<currentTiddler>> $field="text" $subfilter={{{ [<currentTiddler>get[tags]] }}}/><$action-setfield $tiddler=<<currentTiddler>> tags=""/></$button></$list></$vars> | |<$link to="$:/config/NewTiddler/Tags"><<lingo NewTiddler/Tags/Prompt>></$link> |<$vars currentTiddler="$:/config/NewTiddler/Tags" tagField="text">{{||$:/core/ui/EditTemplate/tags}}<$list filter="[<currentTiddler>tags[]] +[limit[1]]" variable="ignore"><$button tooltip={{$:/language/ControlPanel/Basics/RemoveTags/Hint}}><<lingo RemoveTags>><$action-listops $tiddler=<<currentTiddler>> $field="text" $subfilter={{{ [<currentTiddler>get[tags]] }}}/><$action-setfield $tiddler=<<currentTiddler>> tags=""/></$button></$list></$vars> |
|<$link to="$:/config/NewJournal/Tags"><<lingo NewJournal/Tags/Prompt>></$link> |<$vars currentTiddler="$:/config/NewJournal/Tags" tagField="text">{{||$:/core/ui/EditTemplate/tags}}<$list filter="[<currentTiddler>tags[]] +[limit[1]]" variable="ignore"><$button tooltip={{$:/language/ControlPanel/Basics/RemoveTags/Hint}}><<lingo RemoveTags>><$action-listops $tiddler=<<currentTiddler>> $field="text" $subfilter={{{ [<currentTiddler>get[tags]] }}}/><$action-setfield $tiddler=<<currentTiddler>> tags=""/></$button></$list></$vars> | |<$link to="$:/config/NewJournal/Tags"><<lingo NewJournal/Tags/Prompt>></$link> |<$vars currentTiddler="$:/config/NewJournal/Tags" tagField="text">{{||$:/core/ui/EditTemplate/tags}}<$list filter="[<currentTiddler>tags[]] +[limit[1]]" variable="ignore"><$button tooltip={{$:/language/ControlPanel/Basics/RemoveTags/Hint}}><<lingo RemoveTags>><$action-listops $tiddler=<<currentTiddler>> $field="text" $subfilter={{{ [<currentTiddler>get[tags]] }}}/><$action-setfield $tiddler=<<currentTiddler>> tags=""/></$button></$list></$vars> |
|<$link to="$:/config/AutoFocus"><<lingo AutoFocus/Prompt>></$link> |{{$:/snippets/minifocusswitcher}} | |<$link to="$:/config/AutoFocus"><<lingo AutoFocus/Prompt>></$link> |{{$:/snippets/minifocusswitcher}} |

View File

@@ -10,17 +10,15 @@ $:/config/EditorToolbarButtons/Visibility/$(currentTiddler)$
\whitespace trim \whitespace trim
<$let <$let
editPreviewStateTiddler={{{ [{$:/config/ShowEditPreview/PerTiddler}!match[yes]then[$:/state/showeditpreview]] :else[<qualify "$:/state/showeditpreview">] }}} edit-preview-state={{{ [{$:/config/ShowEditPreview/PerTiddler}!match[yes]then[$:/state/showeditpreview]] :else[<qualify "$:/state/showeditpreview">] }}}
importTitle=<<qualify $:/ImportImage>> importTitle=<<qualify $:/ImportImage>>
importState=<<qualify $:/state/ImportImage>> > importState=<<qualify $:/state/ImportImage>> >
<$dropzone importTitle=<<importTitle>> autoOpenOnImport="no" contentTypesFilter={{$:/config/Editor/ImportContentTypesFilter}} class="tc-dropzone-editor" enable={{{ [{$:/config/DragAndDrop/Enable}match[no]] :else[subfilter{$:/config/Editor/EnableImportFilter}then[yes]else[no]] }}} filesOnly="yes" actions=<<importFileActions>> > <$dropzone importTitle=<<importTitle>> autoOpenOnImport="no" contentTypesFilter={{$:/config/Editor/ImportContentTypesFilter}} class="tc-dropzone-editor" enable={{{ [{$:/config/DragAndDrop/Enable}match[no]] :else[subfilter{$:/config/Editor/EnableImportFilter}then[yes]else[no]] }}} filesOnly="yes" actions=<<importFileActions>> >
<div> <$reveal stateTitle=<<edit-preview-state>> type="match" text="yes" tag="div">
<div class={{{ [<editPreviewStateTiddler>get[text]match[yes]then[tc-tiddler-preview]else[tc-tiddler-preview-hidden]] [[tc-tiddler-editor]] +[join[ ]] }}}> <div class="tc-tiddler-preview">
<$transclude tiddler="$:/core/ui/EditTemplate/body/editor" mode="inline"/> <$transclude tiddler="$:/core/ui/EditTemplate/body/editor" mode="inline"/>
<$list filter="[<editPreviewStateTiddler>get[text]match[yes]]" variable="ignore">
<div class="tc-tiddler-preview-preview" data-tiddler-title={{!!draft.title}} data-tags={{!!tags}}> <div class="tc-tiddler-preview-preview" data-tiddler-title={{!!draft.title}} data-tags={{!!tags}}>
<$transclude tiddler={{$:/state/editpreviewtype}} mode="inline"> <$transclude tiddler={{$:/state/editpreviewtype}} mode="inline">
@@ -31,12 +29,13 @@ $:/config/EditorToolbarButtons/Visibility/$(currentTiddler)$
</div> </div>
</$list>
</div> </div>
</$reveal>
</div> <$reveal stateTitle=<<edit-preview-state>> type="nomatch" text="yes" tag="div">
<$transclude tiddler="$:/core/ui/EditTemplate/body/editor" mode="inline"/>
</$reveal>
</$dropzone> </$dropzone>
</$let> </$let>

View File

@@ -54,7 +54,7 @@ $:/config/EditTemplateFields/Visibility/$(currentField)$
\whitespace trim \whitespace trim
<$vars name={{{ [<newFieldNameTiddler>get[text]] }}}> <$vars name={{{ [<newFieldNameTiddler>get[text]] }}}>
<$reveal type="nomatch" text="" default=<<name>>> <$reveal type="nomatch" text="" default=<<name>>>
<$button tooltip={{$:/language/EditTemplate/Fields/Add/Button/Hint}}> <$button tooltip=<<lingo Fields/Add/Button/Hint>>>
<$action-sendmessage $message="tm-add-field" <$action-sendmessage $message="tm-add-field"
$name=<<name>> $name=<<name>>
$value={{{ [subfilter<get-field-value-tiddler-filter>get[text]] }}}/> $value={{{ [subfilter<get-field-value-tiddler-filter>get[text]] }}}/>
@@ -89,7 +89,7 @@ $value={{{ [subfilter<get-field-value-tiddler-filter>get[text]] }}}/>
</td> </td>
<td class="tc-edit-field-remove"> <td class="tc-edit-field-remove">
<$button class="tc-btn-invisible" tooltip={{$:/language/EditTemplate/Field/Remove/Hint}} aria-label={{$:/language/EditTemplate/Field/Remove/Caption}}> <$button class="tc-btn-invisible" tooltip={{$:/language/EditTemplate/Field/Remove/Hint}} aria-label={{$:/language/EditTemplate/Field/Remove/Caption}}>
<$action-deletefield $field=<<currentField>>/> <$action-deletefield $field=<<currentField>>/><$set name="currentTiddlerCSSescaped" value={{{ [<currentTiddler>escapecss[]] }}}><$action-sendmessage $message="tm-focus-selector" $param=<<current-tiddler-new-field-selector>>/></$set>
{{$:/core/images/delete-button}} {{$:/core/images/delete-button}}
</$button> </$button>
</td> </td>

View File

@@ -10,7 +10,7 @@ first-search-filter: [all[shadows+tiddlers]prefix[$:/language/Docs/Types/]sort[d
<em class="tc-edit tc-small-gap-right"><<lingo Type/Prompt>></em> <em class="tc-edit tc-small-gap-right"><<lingo Type/Prompt>></em>
<div class="tc-type-selector-dropdown-wrapper"> <div class="tc-type-selector-dropdown-wrapper">
<div class="tc-type-selector"><$fieldmangler> <div class="tc-type-selector"><$fieldmangler>
<$macrocall $name="keyboard-driven-input" tiddler=<<currentTiddler>> storeTitle=<<typeInputTiddler>> refreshTitle=<<refreshTitle>> selectionStateTitle=<<typeSelectionTiddler>> field="type" tag="input" default="" placeholder={{$:/language/EditTemplate/Type/Placeholder}} focusPopup=<<qualify "$:/state/popup/type-dropdown">> class="tc-edit-typeeditor tc-edit-texteditor tc-popup-handle" tabindex={{$:/config/EditTabIndex}} focus={{{ [{$:/config/AutoFocus}match[type]then[true]] ~[[false]] }}} cancelPopups="yes" configTiddlerFilter="[[$:/core/ui/EditTemplate/type]]" inputCancelActions=<<input-cancel-actions>>/><$button popup=<<qualify "$:/state/popup/type-dropdown">> class="tc-btn-invisible tc-btn-dropdown tc-small-gap" tooltip={{$:/language/EditTemplate/Type/Dropdown/Hint}} aria-label={{$:/language/EditTemplate/Type/Dropdown/Caption}}>{{$:/core/images/down-arrow}}</$button><$button message="tm-remove-field" param="type" class="tc-btn-invisible tc-btn-icon" tooltip={{$:/language/EditTemplate/Type/Delete/Hint}} aria-label={{$:/language/EditTemplate/Type/Delete/Caption}}>{{$:/core/images/delete-button}}<$action-deletetiddler $filter="[<typeInputTiddler>] [<storeTitle>] [<refreshTitle>] [<selectionStateTitle>]"/></$button> <$macrocall $name="keyboard-driven-input" tiddler=<<currentTiddler>> storeTitle=<<typeInputTiddler>> refreshTitle=<<refreshTitle>> selectionStateTitle=<<typeSelectionTiddler>> field="type" tag="input" default="" placeholder={{$:/language/EditTemplate/Type/Placeholder}} focusPopup=<<qualify "$:/state/popup/type-dropdown">> class="tc-edit-typeeditor tc-edit-texteditor tc-popup-handle" tabindex={{$:/config/EditTabIndex}} focus={{{ [{$:/config/AutoFocus}match[type]then[true]] ~[[false]] }}} cancelPopups="yes" configTiddlerFilter="[[$:/core/ui/EditTemplate/type]]" inputCancelActions=<<input-cancel-actions>>/><$button popup=<<qualify "$:/state/popup/type-dropdown">> class="tc-btn-invisible tc-btn-dropdown tc-small-gap" tooltip={{$:/language/EditTemplate/Type/Dropdown/Hint}} aria-label={{$:/language/EditTemplate/Type/Dropdown/Caption}}>{{$:/core/images/down-arrow}}</$button><$button message="tm-remove-field" param="type" class="tc-btn-invisible tc-btn-icon" tooltip={{$:/language/EditTemplate/Type/Delete/Hint}} aria-label={{$:/language/EditTemplate/Type/Delete/Caption}}>{{$:/core/images/delete-button}}<$action-deletetiddler $filter="[<storeTitle>] [<refreshTitle>] [<selectionStateTitle>]"/></$button>
</$fieldmangler></div> </$fieldmangler></div>
<div class="tc-block-dropdown-wrapper"> <div class="tc-block-dropdown-wrapper">

View File

@@ -9,8 +9,11 @@ button-classes: tc-text-editor-toolbar-item-start-group
shortcuts: ((preview)) shortcuts: ((preview))
\whitespace trim \whitespace trim
<span> <$reveal state=<<edit-preview-state>> type="match" text="yes" tag="span">
<$transclude $tiddler={{{ [<editPreviewStateTiddler>get[text]match[yes]then[$:/core/images/preview-open]else[$:/core/images/preview-closed]] }}} /> {{$:/core/images/preview-open}}
</span> <$action-setfield $tiddler=<<edit-preview-state>> $value="no"/>
<$action-setfield $tiddler=<<editPreviewStateTiddler>> $value={{{ [<editPreviewStateTiddler>get[text]toggle[yes],[no]] }}} /> </$reveal>
<$action-sendmessage $message="tm-edit-text-operation" $param="focus-editor"/> <$reveal state=<<edit-preview-state>> type="nomatch" text="yes" tag="span">
{{$:/core/images/preview-closed}}
<$action-setfield $tiddler=<<edit-preview-state>> $value="yes"/>
</$reveal>

View File

@@ -20,7 +20,7 @@ code-body: yes
<$navigator story="$:/StoryList" history="$:/HistoryList" openLinkFromInsideRiver={{$:/config/Navigation/openLinkFromInsideRiver}} openLinkFromOutsideRiver={{$:/config/Navigation/openLinkFromOutsideRiver}} relinkOnRename={{$:/config/RelinkOnRename}}> <$navigator story="$:/StoryList" history="$:/HistoryList" openLinkFromInsideRiver={{$:/config/Navigation/openLinkFromInsideRiver}} openLinkFromOutsideRiver={{$:/config/Navigation/openLinkFromOutsideRiver}} relinkOnRename={{$:/config/RelinkOnRename}}>
<$dropzone enable=<<tv-enable-drag-and-drop>> class="tc-dropzone tc-page-container-inner"> <$dropzone enable=<<tv-enable-drag-and-drop>>>
<$list filter="[all[shadows+tiddlers]tag[$:/tags/PageTemplate]!has[draft.of]]" variable="listItem"> <$list filter="[all[shadows+tiddlers]tag[$:/tags/PageTemplate]!has[draft.of]]" variable="listItem">

View File

@@ -4,8 +4,11 @@ tags: $:/tags/ViewTemplate
\whitespace trim \whitespace trim
<$reveal type="nomatch" stateTitle=<<folded-state>> text="hide" tag="div" retain="yes" animate="yes"> <$reveal type="nomatch" stateTitle=<<folded-state>> text="hide" tag="div" retain="yes" animate="yes">
<div class="tc-subtitle"> <div class="tc-subtitle">
<$list filter="[all[shadows+tiddlers]tag[$:/tags/ViewTemplate/Subtitle]!has[draft.of]]" variable="subtitleTiddler"> <$list filter="[all[shadows+tiddlers]tag[$:/tags/ViewTemplate/Subtitle]!has[draft.of]]" variable="subtitleTiddler" counter="indexSubtitleTiddler">
<$transclude tiddler=<<subtitleTiddler>> mode="inline"/><$list-join>&nbsp;</$list-join> <$list filter="[<indexSubtitleTiddler-first>match[no]]" variable="ignore">
&nbsp;
</$list>
<$transclude tiddler=<<subtitleTiddler>> mode="inline"/>
</$list> </$list>
</div> </div>
</$reveal> </$reveal>

View File

@@ -1,6 +1,6 @@
title: $:/config/OfficialPluginLibrary title: $:/config/OfficialPluginLibrary
tags: $:/tags/PluginLibrary tags: $:/tags/PluginLibrary
url: https://tiddlywiki.com/library/v5.3.3/index.html url: https://tiddlywiki.com/library/v5.3.2/index.html
caption: {{$:/language/OfficialPluginLibrary}} caption: {{$:/language/OfficialPluginLibrary}}
{{$:/language/OfficialPluginLibrary/Hint}} {{$:/language/OfficialPluginLibrary/Hint}}

View File

@@ -13,7 +13,7 @@ tags: $:/tags/Macro
$(colour-picker-update-recent)$ $(colour-picker-update-recent)$
<$transclude $variable="__actions__"/> $actions$
<span style="display:inline-block; background-color: $(colour-picker-value)$; width: 100%; height: 100%; border-radius: 50%;"/> <span style="display:inline-block; background-color: $(colour-picker-value)$; width: 100%; height: 100%; border-radius: 50%;"/>
@@ -23,7 +23,7 @@ $(colour-picker-update-recent)$
\define colour-picker-recent-inner(actions) \define colour-picker-recent-inner(actions)
\whitespace trim \whitespace trim
<$set name="colour-picker-value" value="$(recentColour)$"> <$set name="colour-picker-value" value="$(recentColour)$">
<$macrocall $name="colour-picker-inner" actions=<<__actions__>>/> <$macrocall $name="colour-picker-inner" actions="""$actions$"""/>
</$set> </$set>
\end \end
@@ -31,7 +31,7 @@ $(colour-picker-update-recent)$
\whitespace trim \whitespace trim
{{$:/language/ColourPicker/Recent}}<$list filter="[list[$:/config/ColourPicker/Recent]]" variable="recentColour"> {{$:/language/ColourPicker/Recent}}<$list filter="[list[$:/config/ColourPicker/Recent]]" variable="recentColour">
&#32; &#32;
<$macrocall $name="colour-picker-recent-inner" actions=<<__actions__>>/> <$macrocall $name="colour-picker-recent-inner" actions="""$actions$"""/>
</$list> </$list>
\end \end
@@ -39,13 +39,13 @@ $(colour-picker-update-recent)$
\whitespace trim \whitespace trim
<div class="tc-colour-chooser"> <div class="tc-colour-chooser">
<$macrocall $name="colour-picker-recent" actions=<<__actions__>>/> <$macrocall $name="colour-picker-recent" actions="""$actions$"""/>
--- ---
<$list filter="LightPink Pink Crimson LavenderBlush PaleVioletRed HotPink DeepPink MediumVioletRed Orchid Thistle Plum Violet Magenta Fuchsia DarkMagenta Purple MediumOrchid DarkViolet DarkOrchid Indigo BlueViolet MediumPurple MediumSlateBlue SlateBlue DarkSlateBlue Lavender GhostWhite Blue MediumBlue MidnightBlue DarkBlue Navy RoyalBlue CornflowerBlue LightSteelBlue LightSlateGrey SlateGrey DodgerBlue AliceBlue SteelBlue LightSkyBlue SkyBlue DeepSkyBlue LightBlue PowderBlue CadetBlue Azure LightCyan PaleTurquoise Cyan Aqua DarkTurquoise DarkSlateGrey DarkCyan Teal MediumTurquoise LightSeaGreen Turquoise Aquamarine MediumAquamarine MediumSpringGreen MintCream SpringGreen MediumSeaGreen SeaGreen Honeydew LightGreen PaleGreen DarkSeaGreen LimeGreen Lime ForestGreen Green DarkGreen Chartreuse LawnGreen GreenYellow DarkOliveGreen YellowGreen OliveDrab Beige LightGoldenrodYellow Ivory LightYellow Yellow Olive DarkKhaki LemonChiffon PaleGoldenrod Khaki Gold Cornsilk Goldenrod DarkGoldenrod FloralWhite OldLace Wheat Moccasin Orange PapayaWhip BlanchedAlmond NavajoWhite AntiqueWhite Tan BurlyWood Bisque DarkOrange Linen Peru PeachPuff SandyBrown Chocolate SaddleBrown Seashell Sienna LightSalmon Coral OrangeRed DarkSalmon Tomato MistyRose Salmon Snow LightCoral RosyBrown IndianRed Red Brown FireBrick DarkRed Maroon White WhiteSmoke Gainsboro LightGrey Silver DarkGrey Grey DimGrey Black" variable="colour-picker-value"> <$list filter="LightPink Pink Crimson LavenderBlush PaleVioletRed HotPink DeepPink MediumVioletRed Orchid Thistle Plum Violet Magenta Fuchsia DarkMagenta Purple MediumOrchid DarkViolet DarkOrchid Indigo BlueViolet MediumPurple MediumSlateBlue SlateBlue DarkSlateBlue Lavender GhostWhite Blue MediumBlue MidnightBlue DarkBlue Navy RoyalBlue CornflowerBlue LightSteelBlue LightSlateGrey SlateGrey DodgerBlue AliceBlue SteelBlue LightSkyBlue SkyBlue DeepSkyBlue LightBlue PowderBlue CadetBlue Azure LightCyan PaleTurquoise Cyan Aqua DarkTurquoise DarkSlateGrey DarkCyan Teal MediumTurquoise LightSeaGreen Turquoise Aquamarine MediumAquamarine MediumSpringGreen MintCream SpringGreen MediumSeaGreen SeaGreen Honeydew LightGreen PaleGreen DarkSeaGreen LimeGreen Lime ForestGreen Green DarkGreen Chartreuse LawnGreen GreenYellow DarkOliveGreen YellowGreen OliveDrab Beige LightGoldenrodYellow Ivory LightYellow Yellow Olive DarkKhaki LemonChiffon PaleGoldenrod Khaki Gold Cornsilk Goldenrod DarkGoldenrod FloralWhite OldLace Wheat Moccasin Orange PapayaWhip BlanchedAlmond NavajoWhite AntiqueWhite Tan BurlyWood Bisque DarkOrange Linen Peru PeachPuff SandyBrown Chocolate SaddleBrown Seashell Sienna LightSalmon Coral OrangeRed DarkSalmon Tomato MistyRose Salmon Snow LightCoral RosyBrown IndianRed Red Brown FireBrick DarkRed Maroon White WhiteSmoke Gainsboro LightGrey Silver DarkGrey Grey DimGrey Black" variable="colour-picker-value">
&#32; &#32;
<$macrocall $name="colour-picker-inner" actions=<<__actions__>>/> <$macrocall $name="colour-picker-inner" actions="""$actions$"""/>
</$list> </$list>
--- ---
@@ -54,7 +54,7 @@ $(colour-picker-update-recent)$
&#32; &#32;
<$edit-text tiddler="$:/config/ColourPicker/New" type="color" tag="input"/> <$edit-text tiddler="$:/config/ColourPicker/New" type="color" tag="input"/>
<$set name="colour-picker-value" value={{$:/config/ColourPicker/New}}> <$set name="colour-picker-value" value={{$:/config/ColourPicker/New}}>
<$macrocall $name="colour-picker-inner" actions=<<__actions__>>/> <$macrocall $name="colour-picker-inner" actions="""$actions$"""/>
</$set> </$set>
</div> </div>

View File

@@ -5,13 +5,13 @@ title: $:/core/macros/image-picker
type: text/vnd.tiddlywiki type: text/vnd.tiddlywiki
\define image-picker-thumbnail(actions) \define image-picker-thumbnail(actions)
<$button tag="a" tooltip="""$(imageTitle)$"""><$transclude $variable="__actions__"/><$transclude tiddler=<<imageTitle>>/></$button> <$button tag="a" tooltip="""$(imageTitle)$""">$actions$<$transclude tiddler=<<imageTitle>>/></$button>
\end \end
\define image-picker-list(filter,actions) \define image-picker-list(filter,actions)
\whitespace trim \whitespace trim
<$list filter="""$filter$""" variable="imageTitle"> <$list filter="""$filter$""" variable="imageTitle">
<$macrocall $name="image-picker-thumbnail" actions=<<__actions__>>/> <$macrocall $name="image-picker-thumbnail" actions="""$actions$"""/>
&#32; &#32;
</$list> </$list>
\end \end
@@ -25,15 +25,15 @@ type: text/vnd.tiddlywiki
{{$:/language/SystemTiddlers/Include/Prompt}} {{$:/language/SystemTiddlers/Include/Prompt}}
</$checkbox> </$checkbox>
<$reveal state=<<state-system>> type="match" text="hide" default="hide" tag="div"> <$reveal state=<<state-system>> type="match" text="hide" default="hide" tag="div">
<$macrocall $name="image-picker-list" filter="""$filter$ +[!is[system]]""" actions=<<__actions__>>/> <$macrocall $name="image-picker-list" filter="""$filter$ +[!is[system]]""" actions="""$actions$"""/>
</$reveal> </$reveal>
<$reveal state=<<state-system>> type="nomatch" text="hide" default="hide" tag="div"> <$reveal state=<<state-system>> type="nomatch" text="hide" default="hide" tag="div">
<$macrocall $name="image-picker-list" filter="""$filter$""" actions=<<__actions__>>/> <$macrocall $name="image-picker-list" filter="""$filter$""" actions="""$actions$"""/>
</$reveal> </$reveal>
</$vars> </$vars>
</div> </div>
\end \end
\define image-picker-include-tagged-images(actions) \define image-picker-include-tagged-images(actions)
<$macrocall $name="image-picker" filter="[all[shadows+tiddlers]is[image]] [all[shadows+tiddlers]tag[$:/tags/Image]] -[type[application/pdf]] +[!has[draft.of]sort[title]]" actions=<<__actions__>>/> <$macrocall $name="image-picker" filter="[all[shadows+tiddlers]is[image]] [all[shadows+tiddlers]tag[$:/tags/Image]] -[type[application/pdf]] +[!has[draft.of]sort[title]]" actions="""$actions$"""/>
\end \end

View File

@@ -4,17 +4,17 @@ tags: $:/tags/Macro
\define list-links(filter,type:"ul",subtype:"li",class:"",emptyMessage,field:"caption") \define list-links(filter,type:"ul",subtype:"li",class:"",emptyMessage,field:"caption")
\whitespace trim \whitespace trim
<$genesis $type=<<__type__>> class=<<__class__>>> <$genesis $type=<<__type__>> class=<<__class__>>>
<$list filter=<<__filter__>> emptyMessage=<<__emptyMessage__>>> <$list filter=<<__filter__>> emptyMessage=<<__emptyMessage__>>>
<$genesis $type=<<__subtype__>>> <$genesis $type=<<__subtype__>>>
<$link to={{!!title}}> <$link to={{!!title}}>
<$let tv-wikilinks="no"> <$let tv-wikilinks="no">
<$transclude field=<<__field__>>> <$transclude field=<<__field__>>>
<$view field="title"/> <$view field="title"/>
</$transclude> </$transclude>
</$let> </$let>
</$link> </$link>
</$genesis> </$genesis>
</$list> </$list>
</$genesis> </$genesis>
\end \end
@@ -25,42 +25,34 @@ tags: $:/tags/Macro
\define list-links-draggable(tiddler,field:"list",emptyMessage,type:"ul",subtype:"li",class:"",itemTemplate) \define list-links-draggable(tiddler,field:"list",emptyMessage,type:"ul",subtype:"li",class:"",itemTemplate)
\whitespace trim \whitespace trim
<span class="tc-links-draggable-list"> <span class="tc-links-draggable-list">
<$vars targetTiddler="""$tiddler$""" targetField="""$field$"""> <$vars targetTiddler="""$tiddler$""" targetField="""$field$""">
<$genesis $type=<<__type__>> class="$class$"> <$genesis $type=<<__type__>> class="$class$">
<$list filter="[list[$tiddler$!!$field$]]" emptyMessage=<<__emptyMessage__>>> <$list filter="[list[$tiddler$!!$field$]]" emptyMessage=<<__emptyMessage__>>>
<$droppable <$droppable actions=<<list-links-draggable-drop-actions>> tag="""$subtype$""" enable=<<tv-enable-drag-and-drop>>>
actions=<<list-links-draggable-drop-actions>> <div class="tc-droppable-placeholder"/>
tag="""$subtype$""" <div>
enable=<<tv-enable-drag-and-drop>> <$transclude tiddler="""$itemTemplate$""">
> <$link to={{!!title}}>
<div class="tc-droppable-placeholder"/> <$let tv-wikilinks="no">
<div> <$transclude field="caption">
<$transclude tiddler="""$itemTemplate$"""> <$view field="title"/>
<$link to={{!!title}}> </$transclude>
<$let tv-wikilinks="no"> </$let>
<$transclude field="caption"> </$link>
<$view field="title"/> </$transclude>
</$transclude> </div>
</$let> </$droppable>
</$link> </$list>
</$transclude> <$tiddler tiddler="">
</div> <$droppable actions=<<list-links-draggable-drop-actions>> tag="div" enable=<<tv-enable-drag-and-drop>>>
</$droppable> <div class="tc-droppable-placeholder">
</$list> {{$:/core/images/blank}}
<$tiddler tiddler=""> </div>
<$droppable <div style="height:0.5em;"/>
actions=<<list-links-draggable-drop-actions>> </$droppable>
tag="div" </$tiddler>
enable=<<tv-enable-drag-and-drop>> </$genesis>
> </$vars>
<div class="tc-droppable-placeholder">
{{$:/core/images/blank}}
</div>
<div style="height:0.5em;"/>
</$droppable>
</$tiddler>
</$genesis>
</$vars>
</span> </span>
\end \end
@@ -68,59 +60,50 @@ tags: $:/tags/Macro
\whitespace trim \whitespace trim
<!-- Save the current ordering of the tiddlers with this tag --> <!-- Save the current ordering of the tiddlers with this tag -->
<$set name="order" filter="[<__tag__>tagging[]]"> <$set name="order" filter="[<__tag__>tagging[]]">
<!-- Remove any list-after or list-before fields from the tiddlers with this tag --> <!-- Remove any list-after or list-before fields from the tiddlers with this tag -->
<$list filter="[<__tag__>tagging[]]"> <$list filter="[<__tag__>tagging[]]">
<$action-deletefield $field="list-before"/> <$action-deletefield $field="list-before"/>
<$action-deletefield $field="list-after"/> <$action-deletefield $field="list-after"/>
</$list> </$list>
<!-- Save the new order to the Tag Tiddler --> <!-- Save the new order to the Tag Tiddler -->
<$action-listops $tiddler=<<__tag__>> $field="list" $filter="+[enlist<order>] +[insertbefore<actionTiddler>,<currentTiddler>]"/> <$action-listops $tiddler=<<__tag__>> $field="list" $filter="+[enlist<order>] +[insertbefore<actionTiddler>,<currentTiddler>]"/>
<!-- Make sure the newly added item has the right tag --> <!-- Make sure the newly added item has the right tag -->
<!-- Removing this line makes dragging tags within the dropdown work as intended --> <!-- Removing this line makes dragging tags within the dropdown work as intended -->
<!--<$action-listops $tiddler=<<actionTiddler>> $tags=<<__tag__>>/>--> <!--<$action-listops $tiddler=<<actionTiddler>> $tags=<<__tag__>>/>-->
<!-- Using the following 5 lines as replacement makes dragging titles from outside into the dropdown apply the tag --> <!-- Using the following 5 lines as replacement makes dragging titles from outside into the dropdown apply the tag -->
<$list filter="[<actionTiddler>!contains:tags<__tag__>]"> <$list filter="[<actionTiddler>!contains:tags<__tag__>]">
<$fieldmangler tiddler=<<actionTiddler>>> <$fieldmangler tiddler=<<actionTiddler>>>
<$action-sendmessage $message="tm-add-tag" $param=<<__tag__>>/> <$action-sendmessage $message="tm-add-tag" $param=<<__tag__>>/>
</$fieldmangler> </$fieldmangler>
</$list> </$list>
</$set> </$set>
\end \end
\define list-tagged-draggable(tag,subFilter,emptyMessage,itemTemplate,elementTag:"div",storyview:"") \define list-tagged-draggable(tag,subFilter,emptyMessage,itemTemplate,elementTag:"div",storyview:"")
\whitespace trim \whitespace trim
<span class="tc-tagged-draggable-list"> <span class="tc-tagged-draggable-list">
<$set name="tag" value=<<__tag__>>> <$set name="tag" value=<<__tag__>>>
<$list <$list filter="[<__tag__>tagging[]$subFilter$]" emptyMessage=<<__emptyMessage__>> storyview=<<__storyview__>>>
filter="[<__tag__>tagging[]$subFilter$]" <$genesis $type=<<__elementTag__>> class="tc-menu-list-item">
emptyMessage=<<__emptyMessage__>> <$droppable actions="""<$macrocall $name="list-tagged-draggable-drop-actions" tag=<<__tag__>>/>""" enable=<<tv-enable-drag-and-drop>>>
storyview=<<__storyview__>> <$genesis $type=<<__elementTag__>> class="tc-droppable-placeholder"/>
> <$genesis $type=<<__elementTag__>>>
<$genesis $type=<<__elementTag__>> class="tc-menu-list-item"> <$transclude tiddler="""$itemTemplate$""">
<$droppable <$link to={{!!title}}>
actions="""<$macrocall $name="list-tagged-draggable-drop-actions" tag=<<__tag__>>/>""" <$view field="title"/>
enable=<<tv-enable-drag-and-drop>> </$link>
> </$transclude>
<$genesis $type=<<__elementTag__>> class="tc-droppable-placeholder"/> </$genesis>
<$genesis $type=<<__elementTag__>>> </$droppable>
<$transclude tiddler="""$itemTemplate$"""> </$genesis>
<$link to={{!!title}}> </$list>
<$view field="title"/> <$tiddler tiddler="">
</$link> <$droppable actions="""<$macrocall $name="list-tagged-draggable-drop-actions" tag=<<__tag__>>/>""" enable=<<tv-enable-drag-and-drop>>>
</$transclude> <$genesis $type=<<__elementTag__>> class="tc-droppable-placeholder"/>
</$genesis> <$genesis $type=<<__elementTag__>> style="height:0.5em;">
</$droppable> </$genesis>
</$genesis> </$droppable>
</$list> </$tiddler>
<$tiddler tiddler=""> </$set>
<$droppable
actions="""<$macrocall $name="list-tagged-draggable-drop-actions" tag=<<__tag__>>/>"""
enable=<<tv-enable-drag-and-drop>>
>
<$genesis $type=<<__elementTag__>> class="tc-droppable-placeholder"/>
<$genesis $type=<<__elementTag__>> style="height:0.5em;"/>
</$droppable>
</$tiddler>
</$set>
</span> </span>
\end \end

View File

@@ -4,15 +4,7 @@ code-body: yes
\define tabs-button() \define tabs-button()
\whitespace trim \whitespace trim
<$button <$button set=<<tabsState>> setTo=<<currentTab>> default=<<__default__>> selectedClass="tc-tab-selected" tooltip={{!!tooltip}} role="switch">
set=<<tabsState>>
setTo=<<currentTab>>
default=<<__default__>>
selectedClass="tc-tab-selected"
tooltip={{!!tooltip}}
role="switch"
data-tab-title=<<currentTab>>
>
<$tiddler tiddler=<<save-currentTiddler>>> <$tiddler tiddler=<<save-currentTiddler>>>
<$set name="tv-wikilinks" value="no"> <$set name="tv-wikilinks" value="no">
<$transclude tiddler=<<__buttonTemplate__>> mode="inline"> <$transclude tiddler=<<__buttonTemplate__>> mode="inline">

View File

@@ -16,7 +16,7 @@ second-search-filter: [tags[]is[system]search:title<userInput>sort[]]
emptyMessage="<$action-listops $tiddler=<<saveTiddler>> $field=<<__tagField__>> $subfilter='-[<tag>]'/>" emptyMessage="<$action-listops $tiddler=<<saveTiddler>> $field=<<__tagField__>> $subfilter='-[<tag>]'/>"
> >
<$action-listops $tiddler=<<saveTiddler>> $field=<<__tagField__>> $subfilter="[<tag>trim[]]"/> <$action-listops $tiddler=<<saveTiddler>> $field=<<__tagField__>> $subfilter="[<tag>trim[]]"/>
<$transclude $variable="__actions__"/> $actions$
</$list> </$list>
</$set> </$set>
<<delete-tag-state-tiddlers>> <<delete-tag-state-tiddlers>>
@@ -102,7 +102,7 @@ second-search-filter: [tags[]is[system]search:title<userInput>sort[]]
<$set name="tag" value={{{ [<newTagNameTiddler>get[text]] }}}> <$set name="tag" value={{{ [<newTagNameTiddler>get[text]] }}}>
<$button set=<<newTagNameTiddler>> setTo="" class=""> <$button set=<<newTagNameTiddler>> setTo="" class="">
<$action-listops $tiddler=<<saveTiddler>> $field=<<__tagField__>> $subfilter="[<tag>trim[]]"/> <$action-listops $tiddler=<<saveTiddler>> $field=<<__tagField__>> $subfilter="[<tag>trim[]]"/>
<$transclude $variable="__actions__"/> $actions$
<$set name="currentTiddlerCSSEscaped" value={{{ [<saveTiddler>escapecss[]] }}}> <$set name="currentTiddlerCSSEscaped" value={{{ [<saveTiddler>escapecss[]] }}}>
<<delete-tag-state-tiddlers>><$action-sendmessage $message="tm-focus-selector" $param=<<get-tagpicker-focus-selector>>/> <<delete-tag-state-tiddlers>><$action-sendmessage $message="tm-focus-selector" $param=<<get-tagpicker-focus-selector>>/>
</$set> </$set>

View File

@@ -118,7 +118,7 @@ tags: $:/tags/Macro
<$set name="toc-item-class" filter=<<__itemClassFilter__>> emptyValue="toc-item-selected" value="toc-item" > <$set name="toc-item-class" filter=<<__itemClassFilter__>> emptyValue="toc-item-selected" value="toc-item" >
<li class=<<toc-item-class>>> <li class=<<toc-item-class>>>
<$link to={{{ [<currentTiddler>get[target]else<currentTiddler>] }}}> <$link to={{{ [<currentTiddler>get[target]else<currentTiddler>] }}}>
<$list filter="[all[current]tagging[]$sort$limit[1]] -[subfilter<__exclude__>]" variable="ignore" emptyMessage="<$button class='tc-btn-invisible'>{{$:/core/images/blank}}</$button>"> <$list filter="[all[current]tagging[]$sort$limit[1]]" variable="ignore" emptyMessage="<$button class='tc-btn-invisible'>{{$:/core/images/blank}}</$button>">
<$reveal type="nomatch" stateTitle=<<toc-state>> text="open"> <$reveal type="nomatch" stateTitle=<<toc-state>> text="open">
<$button setTitle=<<toc-state>> setTo="open" class="tc-btn-invisible tc-popup-keep"> <$button setTitle=<<toc-state>> setTo="open" class="tc-btn-invisible tc-popup-keep">
<$transclude tiddler=<<toc-closed-icon>> /> <$transclude tiddler=<<toc-closed-icon>> />
@@ -145,7 +145,7 @@ tags: $:/tags/Macro
<$qualify name="toc-state" title={{{ [[$:/state/toc]addsuffix<__path__>addsuffix[-]addsuffix<currentTiddler>] }}}> <$qualify name="toc-state" title={{{ [[$:/state/toc]addsuffix<__path__>addsuffix[-]addsuffix<currentTiddler>] }}}>
<$set name="toc-item-class" filter=<<__itemClassFilter__>> emptyValue="toc-item-selected" value="toc-item"> <$set name="toc-item-class" filter=<<__itemClassFilter__>> emptyValue="toc-item-selected" value="toc-item">
<li class=<<toc-item-class>>> <li class=<<toc-item-class>>>
<$list filter="[all[current]tagging[]$sort$limit[1]] -[subfilter<__exclude__>]" variable="ignore" emptyMessage="""<$button class="tc-btn-invisible">{{$:/core/images/blank}}</$button><span class="toc-item-muted"><<toc-caption>></span>"""> <$list filter="[all[current]tagging[]$sort$limit[1]]" variable="ignore" emptyMessage="""<$button class="tc-btn-invisible">{{$:/core/images/blank}}</$button><span class="toc-item-muted"><<toc-caption>></span>""">
<$reveal type="nomatch" stateTitle=<<toc-state>> text="open"> <$reveal type="nomatch" stateTitle=<<toc-state>> text="open">
<$button setTitle=<<toc-state>> setTo="open" class="tc-btn-invisible tc-popup-keep"> <$button setTitle=<<toc-state>> setTo="open" class="tc-btn-invisible tc-popup-keep">
<$transclude tiddler=<<toc-closed-icon>> /> <$transclude tiddler=<<toc-closed-icon>> />

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@@ -1,2 +1,2 @@
title: $:/favicon.ico title: $:/favicon.ico
type: image/png type: image/x-icon

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

View File

@@ -21,8 +21,8 @@ Willkommen bei ''~TiddlyWiki'', dem einzigartigen [[nicht-linearen|Philosophy vo
Anders, als bei herkömmlichen Online-Diensten, lässt Ihnen ~TiddlyWiki die Freiheit, wo sie ihre Daten speichern. Da ~TiddlyWiki alle Daten als simplen Text speichert, sind Notizen, die Sie heute machen, garantiert in Jahrzehnten noch einfach lesbar. Anders, als bei herkömmlichen Online-Diensten, lässt Ihnen ~TiddlyWiki die Freiheit, wo sie ihre Daten speichern. Da ~TiddlyWiki alle Daten als simplen Text speichert, sind Notizen, die Sie heute machen, garantiert in Jahrzehnten noch einfach lesbar.
<div style="font-size:0.7em;text-align:center;margin-top:3em;margin-bottom:3em;"> <div style="font-size:0.7em;text-align:center;margin-top:3em;margin-bottom:3em;">
<a href="https://talk.tiddlywiki.org/" class="tc-btn-big-green" style="background-color:#FF8C19;" target="_blank"> <a href="http://groups.google.com/group/TiddlyWiki" class="tc-btn-big-green" style="background-color:#FF8C19;" target="_blank">
{{$:/core/images/help}} ~TiddlyWiki Forum {{$:/core/images/mail}} ~TiddlyWiki Mailing List
</a> </a>
<a href="https://twitter.com/TiddlyWiki" class="tc-btn-big-green" style="background-color:#5E9FCA;" target="_blank"> <a href="https://twitter.com/TiddlyWiki" class="tc-btn-big-green" style="background-color:#5E9FCA;" target="_blank">
{{$:/core/images/twitter}} @~TiddlyWiki on Twitter {{$:/core/images/twitter}} @~TiddlyWiki on Twitter

View File

@@ -7,5 +7,5 @@ type: text/vnd.tiddlywiki
Es gibt mehrere Ressourcen für Entwickler, um mehr über das TiddlyWiki Projekt zu erfahren, zu diskutieren und vor allem mitzuhelfen. Es gibt mehrere Ressourcen für Entwickler, um mehr über das TiddlyWiki Projekt zu erfahren, zu diskutieren und vor allem mitzuhelfen.
* [[tiddlywiki.com/dev|https://tiddlywiki.com/dev]] Offizielle Entwickler Doku. * [[tiddlywiki.com/dev|https://tiddlywiki.com/dev]] Offizielle Entwickler Doku.
* [[TiddlyWikiDev group|https://talk.tiddlywiki.org/c/devs/]] Diskussionsforum für Entwickler. * [[TiddlyWikiDev group|http://groups.google.com/group/TiddlyWikiDev]] Google Diskussionsforum für Entwickler.
* https://github.com/Jermolene/TiddlyWiki5 .. Github Repository. * https://github.com/Jermolene/TiddlyWiki5 .. Github Repository.

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@@ -1,2 +1,2 @@
title: $:/favicon.ico title: $:/favicon.ico
type: image/png type: image/x-icon

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

View File

@@ -1,14 +1,9 @@
created: 20141122200310516 created: 20141122200310516
modified: 20230923031318421 modified: 20201213161842776
tags: Mechanisms
title: HookMechanism title: HookMechanism
type: text/vnd.tiddlywiki type: text/vnd.tiddlywiki
The hook mechanism provides a way for plugins to intercept and modify default functionality. The hook mechanism provides a way for plugins to intercept and modify default functionality. Hooks are added as follows:
!! Add a hook
Hooks are added as follows:
```js ```js
/* /*
@@ -18,8 +13,6 @@ handler: function to be called when hook is invoked
$tw.hooks.addHook(name,handler); $tw.hooks.addHook(name,handler);
``` ```
!!! Params and return
The handler function will be called with parameters that depend on the specific hook in question, but they always follow the pattern `handler(value,params...)` The handler function will be called with parameters that depend on the specific hook in question, but they always follow the pattern `handler(value,params...)`
* ''value'': an optional value that is to be transformed by the hook function * ''value'': an optional value that is to be transformed by the hook function
@@ -27,29 +20,11 @@ The handler function will be called with parameters that depend on the specific
If required by the hook in question, the handler function must return the modified ''value''. If required by the hook in question, the handler function must return the modified ''value''.
!!! Multiple handlers
Multiple handlers can be assigned to the same name using repeated calls. When a hook is invoked by name all registered functions will be called sequentially in their order of addition. Multiple handlers can be assigned to the same name using repeated calls. When a hook is invoked by name all registered functions will be called sequentially in their order of addition.
Note that the ''value'' passed to the subsequent hook function will be the return value of the previous hook function. Note that the ''value'' passed to the subsequent hook function will be the return value of the previous hook function.
Be careful not to `addHook` in widget's `render` method, which will be call several times. You could `addHook` in methods that only called once, e.g. the constructor of widget class. Otherwise you should `removeHook` then add it again. Though not essential care should be taken to ensure that hooks are added before they are invoked. For example: [[Hook: th-opening-default-tiddlers-list]] should ideally be added before the story startup module is invoked otherwise any hook specified additions to the default tiddlers will not be seen on the initial loading of the page, though will be visible if the user clicks the home button.
!!! Timing of registration
Though not essential care should be taken to ensure that hooks are added before they are invoked.
For example: [[Hook: th-opening-default-tiddlers-list]] should ideally be added before the story startup module is invoked. Otherwise any hook specified additions to the default tiddlers will not be seen on the initial loading of the page, though will be visible if the user clicks the home button.
!! Remove a hook
You should clean up the callback when your widget is going to unmount.
```js
$tw.hooks.removeHook(handler)
```
The `handler` should be the same function instance you used in `addHook` (check by `===`). You can save it to `this.xxxHookHandler` on your widget, and call `removeHook` in [[destroy method|Widget `destroy` method examples]].
!! Example !! Example

View File

@@ -23,7 +23,7 @@
"static": [ "static": [
"--render","$:/core/templates/static.template.html","static.html","text/plain", "--render","$:/core/templates/static.template.html","static.html","text/plain",
"--render","$:/core/templates/alltiddlers.template.html","alltiddlers.html","text/plain", "--render","$:/core/templates/alltiddlers.template.html","alltiddlers.html","text/plain",
"--render","[!is[system]]","[encodeuricomponent[]addprefix[static/]addsuffix[.html]]","text/plain","$:/core/templates/static.tiddler.html", "--render","[!is[system]]","[encodeuricomponent[]addprefix[static/]addsuffix[.html]]","text/plain",
"--render","$:/core/templates/static.template.css","static/static.css","text/plain"] "--render","$:/core/templates/static.template.css","static/static.css","text/plain"]
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@@ -1,2 +1,2 @@
title: $:/favicon.ico title: $:/favicon.ico
type: image/png type: image/x-icon

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

View File

@@ -12,9 +12,7 @@ Son listas de correo en las que hablamos de ~TiddlyWiki: pedimos ayuda, anunciam
Puedes participar a través de la página web asociada, o suscribirte via mail. Puedes participar a través de la página web asociada, o suscribirte via mail.
!! Usuarios !!Usuarios
[[Foro oficial de TiddlyWiki| https://talk.tiddlywiki.org/]]
[[Grupo principal de TiddlyWiki| http://groups.google.com/group/TiddlyWiki]] [[Grupo principal de TiddlyWiki| http://groups.google.com/group/TiddlyWiki]]
@@ -27,7 +25,10 @@ o síguenos [[en Twitter|http://twitter.com/TiddlyWiki]] si quieres recibir las
!! Desarrolladores !! Desarrolladores
[[Foro de desarrollo de TiddlyWiki|https://talk.tiddlywiki.org/c/devs]] [[Grupo de desarrollo de TiddlyWiki|http://groups.google.com/group/TiddlyWikiDev]]
>No necesitas tener cuenta en Google para acceder al grupo. Suscríbete igualmente enviando un mail a:
*mailto:tiddlywikidev+subscribe@googlegroups.com.
Accede a nuestra [[página de desarrollo|https://github.com/Jermolene/TiddlyWiki5]] en GitHub y haz tu contribución. Accede a nuestra [[página de desarrollo|https://github.com/Jermolene/TiddlyWiki5]] en GitHub y haz tu contribución.

View File

@@ -20,8 +20,8 @@ BIenvenido a TiddlyWiki, un bloc de notas [[no lineal|Philosophy of Tiddlers]]
Al revés que los servicios online convencionales, TiddlyWiki te deja escoger dónde quieres guardar tus datos, garantizándote que, por más que pase el tiempo, podrás seguir usando en el futuro las notas que tomes hoy. Al revés que los servicios online convencionales, TiddlyWiki te deja escoger dónde quieres guardar tus datos, garantizándote que, por más que pase el tiempo, podrás seguir usando en el futuro las notas que tomes hoy.
<div style="font-size:0.7em;text-align:center;margin-top:3em;margin-bottom:3em;"> <div style="font-size:0.7em;text-align:center;margin-top:3em;margin-bottom:3em;">
<a href="https://talk.tiddlywiki.org/" class="tc-btn-big-green" style="background-color:#FF8C19;" target="_blank" rel="noopener noreferrer"> <a href="http://groups.google.com/group/TiddlyWiki" class="tc-btn-big-green" style="background-color:#FF8C19;" target="_blank" rel="noopener noreferrer">
{{$:/core/images/mail}} Foro oficial de ~TiddlyWiki {{$:/core/images/mail}} ~TiddlyWiki en Google Groups
</a> </a>
<a href="https://www.youtube.com/c/JeremyRuston" class="tc-btn-big-green" style="background-color:#e52d27;" target="_blank" rel="noopener noreferrer"> <a href="https://www.youtube.com/c/JeremyRuston" class="tc-btn-big-green" style="background-color:#e52d27;" target="_blank" rel="noopener noreferrer">
{{$:/core/images/video}} ~TiddlyWiki en ~YouTube {{$:/core/images/video}} ~TiddlyWiki en ~YouTube

View File

@@ -8,7 +8,7 @@ type: text/vnd.tiddlywiki
Se recomienda el uso de las [[macros de documentación|Documentation Macros]] para facilitar las futuras tareas de mantenimiento del texto frente a nuevos cambios y actualizaciones. Se recomienda el uso de las [[macros de documentación|Documentation Macros]] para facilitar las futuras tareas de mantenimiento del texto frente a nuevos cambios y actualizaciones.
Se recomienda precaución en el uso arbitrario de estilos directos de formato (''negrita'', //cursiva// ...etc). Si se puede usar una macro, conviene usarla. Si no existe la macro adecuada, se puede crear o, si no se sabe cómo, pedir su creación en el [[Foro de TiddlyWiki|https://talk.tiddlywiki.org/]]. Se recomienda precaución en el uso arbitrario de estilos directos de formato (''negrita'', //cursiva// ...etc). Si se puede usar una macro, conviene usarla. Si no existe la macro adecuada, se puede crear o, si no se sabe cómo, pedir su creación en el [[Grupo de Google|http://groups.google.com/group/TiddlyWiki]].
Por el mismo motivo, se aconseja el uso de acentos graves <code>&#96;...&#96;</code> para transcribir fragmentos de código y ~WikiText, pero no para nombres de cosas tales como campos, operadores, variables o widgets. Estas tienen su macro correspondiente. Por el mismo motivo, se aconseja el uso de acentos graves <code>&#96;...&#96;</code> para transcribir fragmentos de código y ~WikiText, pero no para nombres de cosas tales como campos, operadores, variables o widgets. Estas tienen su macro correspondiente.

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@@ -1,2 +1,2 @@
title: $:/favicon.ico title: $:/favicon.ico
type: image/png type: image/x-icon

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@@ -1,2 +1,2 @@
title: $:/green_favicon.ico title: $:/green_favicon.ico
type: image/png type: image/x-icon

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@@ -0,0 +1,2 @@
title: $:/favicon.ico
type: image/x-icon

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

View File

@@ -1,2 +0,0 @@
title: $:/favicon.ico
type: image/png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@@ -0,0 +1,2 @@
title: $:/favicon.ico
type: image/x-icon

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

View File

@@ -1,2 +0,0 @@
title: $:/favicon.ico
type: image/png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@@ -1,2 +1,2 @@
title: $:/green_favicon.ico title: $:/green_favicon.ico
type: image/png type: image/x-icon

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

View File

@@ -15,7 +15,7 @@
"static": [ "static": [
"--render","$:/core/templates/static.template.html","static.html","text/plain", "--render","$:/core/templates/static.template.html","static.html","text/plain",
"--render","$:/core/templates/alltiddlers.template.html","alltiddlers.html","text/plain", "--render","$:/core/templates/alltiddlers.template.html","alltiddlers.html","text/plain",
"--render","[!is[system]]","[encodeuricomponent[]addprefix[static/]addsuffix[.html]]","text/plain","$:/core/templates/static.tiddler.html", "--render","[!is[system]]","[encodeuricomponent[]addprefix[static/]addsuffix[.html]]","text/plain",
"--render","$:/core/templates/static.template.css","static/static.css","text/plain"] "--render","$:/core/templates/static.template.css","static/static.css","text/plain"]
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@@ -0,0 +1,2 @@
title: $:/favicon.ico
type: image/x-icon

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

View File

@@ -1,2 +0,0 @@
title: $:/favicon.ico
type: image/png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@@ -1,2 +1,2 @@
title: $:/green_favicon.ico title: $:/green_favicon.ico
type: image/png type: image/x-icon

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

View File

@@ -15,7 +15,7 @@
"static": [ "static": [
"--render","$:/core/templates/static.template.html","static.html","text/plain", "--render","$:/core/templates/static.template.html","static.html","text/plain",
"--render","$:/core/templates/alltiddlers.template.html","alltiddlers.html","text/plain", "--render","$:/core/templates/alltiddlers.template.html","alltiddlers.html","text/plain",
"--render","[!is[system]]","[encodeuricomponent[]addprefix[static/]addsuffix[.html]]","text/plain","$:/core/templates/static.tiddler.html", "--render","[!is[system]]","[encodeuricomponent[]addprefix[static/]addsuffix[.html]]","text/plain",
"--render","$:/core/templates/static.template.css","static/static.css","text/plain"] "--render","$:/core/templates/static.template.css","static/static.css","text/plain"]
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Some files were not shown because too many files have changed in this diff Show More