Compare commits
211 Commits
fix-global
...
coalesce-p
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
74a18c39ab | ||
|
|
7b32f02cb3 | ||
|
|
575d80dfe9 | ||
|
|
bc3d64f4b8 | ||
|
|
aa4aeb187c | ||
|
|
fb85e91f82 | ||
|
|
100eaeff30 | ||
|
|
518c5d3ef6 | ||
|
|
38187d26f4 | ||
|
|
8ac4a448ef | ||
|
|
83dfec471d | ||
|
|
1015a1605d | ||
|
|
f08d3d6030 | ||
|
|
232afb4249 | ||
|
|
22f7af05de | ||
|
|
17665233a2 | ||
|
|
a8f477a3ab | ||
|
|
9d10e2b3a7 | ||
|
|
907aed3eab | ||
|
|
83220be7d9 | ||
|
|
a3cba681e0 | ||
|
|
4f01a53917 | ||
|
|
5cb31b7adb | ||
|
|
6a9dc9dcd5 | ||
|
|
46a22ef585 | ||
|
|
3d712127ad | ||
|
|
a3e5ace458 | ||
|
|
6fa81feeba | ||
|
|
95e270a8a6 | ||
|
|
e2d4388c48 | ||
|
|
f68fa89a29 | ||
|
|
d2d00ffa4d | ||
|
|
c6a72875ba | ||
|
|
aaf7dc355d | ||
|
|
e131dd3761 | ||
|
|
f697f008b1 | ||
|
|
cdfa4b6082 | ||
|
|
8051a3dea2 | ||
|
|
267521ad1b | ||
|
|
e82229210e | ||
|
|
c13c321a61 | ||
|
|
0d2aeb8253 | ||
|
|
9d94459c5d | ||
|
|
5c283f843b | ||
|
|
51862f8128 | ||
|
|
15e53b8cd1 | ||
|
|
4a9b3009dd | ||
|
|
c9be572baf | ||
|
|
4e06c31022 | ||
|
|
5578fa5f94 | ||
|
|
2b0675cac5 | ||
|
|
155db0f6f8 | ||
|
|
4e67aafeb7 | ||
|
|
e60ddf0b0a | ||
|
|
f7359671aa | ||
|
|
c61c34e9df | ||
|
|
6b47cbed32 | ||
|
|
c282208668 | ||
|
|
622512c380 | ||
|
|
f56f5dcc56 | ||
|
|
fc1e9b6c43 | ||
|
|
fe17f16675 | ||
|
|
b08281a20b | ||
|
|
5dc468f1ea | ||
|
|
c2e61fffe0 | ||
|
|
53d493b876 | ||
|
|
3b84088b27 | ||
|
|
a21f45b93a | ||
|
|
8f661423f7 | ||
|
|
6bd69cc53f | ||
|
|
233b871fdf | ||
|
|
64812f5c06 | ||
|
|
22f9df5850 | ||
|
|
1cb607249e | ||
|
|
ca41a8db04 | ||
|
|
d1c7f79dd2 | ||
|
|
862cb01be7 | ||
|
|
f22e047fa2 | ||
|
|
0716ed4c30 | ||
|
|
62bb8affa4 | ||
|
|
4c2979286b | ||
|
|
ad9cb8a0a8 | ||
|
|
de6b866f22 | ||
|
|
06b1cc4bca | ||
|
|
0cd3c9a8ac | ||
|
|
37c625384a | ||
|
|
a4850ba3d9 | ||
|
|
145a8d6992 | ||
|
|
9012d36859 | ||
|
|
ab72cc7b09 | ||
|
|
bf8b3cff03 | ||
|
|
e4bf7c5f44 | ||
|
|
215bd4e015 | ||
|
|
758089cbb3 | ||
|
|
6567843927 | ||
|
|
1001590326 | ||
|
|
4b56cb4298 | ||
|
|
e593f80278 | ||
|
|
902c7f55ba | ||
|
|
801e8e312c | ||
|
|
23a576b8bd | ||
|
|
6a52081d6b | ||
|
|
246751be1b | ||
|
|
4ebaba8e89 | ||
|
|
8617fa39dc | ||
|
|
f89b52e521 | ||
|
|
efaa8dd1e8 | ||
|
|
326ae61929 | ||
|
|
c185e373c5 | ||
|
|
2ffbfd84a5 | ||
|
|
faef02df7a | ||
|
|
c93d56667e | ||
|
|
3855a9f013 | ||
|
|
4d548580e6 | ||
|
|
9773dff1e3 | ||
|
|
c6604c0c56 | ||
|
|
e521ee2133 | ||
|
|
a7bd134c35 | ||
|
|
d3f5695601 | ||
|
|
efa4f34131 | ||
|
|
fffbedd6b9 | ||
|
|
ff1437e439 | ||
|
|
32966c9e91 | ||
|
|
96b0543351 | ||
|
|
b7562f0c7b | ||
|
|
4c9c85aec5 | ||
|
|
7726982d71 | ||
|
|
774058912d | ||
|
|
106e1c68df | ||
|
|
12f42ad62f | ||
|
|
66a8e2dbf2 | ||
|
|
327ecf8f66 | ||
|
|
35e45f3b90 | ||
|
|
93bc9e4309 | ||
|
|
23b75bbc5d | ||
|
|
68da654eb3 | ||
|
|
1eceb5f47f | ||
|
|
def508a220 | ||
|
|
3fb71e2553 | ||
|
|
d17525ec8e | ||
|
|
5bb8155422 | ||
|
|
bb2973fc29 | ||
|
|
bbaa0890b5 | ||
|
|
b4a862c618 | ||
|
|
1be8f0a933 | ||
|
|
773c1f83f2 | ||
|
|
9ee1ef7e23 | ||
|
|
8effb3f218 | ||
|
|
780e5d33a4 | ||
|
|
526e997aa4 | ||
|
|
e4d8849f22 | ||
|
|
bd99cf3385 | ||
|
|
711d1658e2 | ||
|
|
b82f012c0c | ||
|
|
f383863654 | ||
|
|
697dc8db4c | ||
|
|
49c96901f3 | ||
|
|
7d8766d2b9 | ||
|
|
6255856205 | ||
|
|
6f307ae01e | ||
|
|
213a850715 | ||
|
|
217af20fcd | ||
|
|
6d0b4108a4 | ||
|
|
642f8da6ed | ||
|
|
e16635a5ad | ||
|
|
db79bf2380 | ||
|
|
2b16fa7b5c | ||
|
|
64c9d17181 | ||
|
|
ceee20fd59 | ||
|
|
0889f13fef | ||
|
|
fa9bfa07a0 | ||
|
|
dbe233fc87 | ||
|
|
3965e2c027 | ||
|
|
c22cd3f4c6 | ||
|
|
dc282db31b | ||
|
|
70309c67d1 | ||
|
|
ba5bfd1ad0 | ||
|
|
3c66af9fdc | ||
|
|
6877082090 | ||
|
|
9201d2bedc | ||
|
|
229e681550 | ||
|
|
779ac28bd0 | ||
|
|
78ecc20c5e | ||
|
|
8b6bc6664b | ||
|
|
674bd1822c | ||
|
|
6c67dc8235 | ||
|
|
72a4adbd6b | ||
|
|
aaf0bffb39 | ||
|
|
9bbd8a70c2 | ||
|
|
cc57cf2fe9 | ||
|
|
34bc9c72c6 | ||
|
|
aeb502657b | ||
|
|
48705db21f | ||
|
|
587aa28853 | ||
|
|
b926a33b55 | ||
|
|
44ccfe83c9 | ||
|
|
cef0ac680d | ||
|
|
b8a235697f | ||
|
|
ed82536a55 | ||
|
|
d99b1897c3 | ||
|
|
3684cfd178 | ||
|
|
643819f5f5 | ||
|
|
52f7f6382b | ||
|
|
575930b31d | ||
|
|
73f256a411 | ||
|
|
1b5b8905d8 | ||
|
|
825f4eaae1 | ||
|
|
d0da1ef9d9 | ||
|
|
3e213569e2 | ||
|
|
4bdac09872 | ||
|
|
4c9eaeaaf2 |
11
.github/workflows/ci.yml
vendored
@@ -5,7 +5,7 @@ on:
|
||||
- master
|
||||
- tiddlywiki-com
|
||||
env:
|
||||
NODE_VERSION: "12"
|
||||
NODE_VERSION: "18"
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -14,7 +14,13 @@ jobs:
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: "${{ env.NODE_VERSION }}"
|
||||
- run: "./bin/test.sh"
|
||||
- run: "./bin/ci-test.sh"
|
||||
- uses: actions/upload-artifact@v3
|
||||
if: always()
|
||||
with:
|
||||
name: playwright-report
|
||||
path: playwright-report/
|
||||
retention-days: 30
|
||||
build-prerelease:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref == 'refs/heads/master'
|
||||
@@ -54,6 +60,7 @@ jobs:
|
||||
TW5_BUILD_TIDDLYWIKI: "./node_modules/tiddlywiki/tiddlywiki.js"
|
||||
TW5_BUILD_MAIN_EDITION: "./editions/tw5.com"
|
||||
TW5_BUILD_OUTPUT: "./output"
|
||||
TW5_BUILD_ARCHIVE: "./output"
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v1
|
||||
|
||||
4
.gitignore
vendored
@@ -5,4 +5,6 @@
|
||||
tmp/
|
||||
output/
|
||||
node_modules/
|
||||
|
||||
/test-results/
|
||||
/playwright-report/
|
||||
/playwright/.cache/
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# Default to the current version number for building the plugin library
|
||||
|
||||
if [ -z "$TW5_BUILD_VERSION" ]; then
|
||||
TW5_BUILD_VERSION=v5.3.1
|
||||
TW5_BUILD_VERSION=v5.3.3
|
||||
fi
|
||||
|
||||
echo "Using TW5_BUILD_VERSION as [$TW5_BUILD_VERSION]"
|
||||
@@ -84,10 +84,27 @@ echo -e -n "title: $:/build\ncommit: $TW5_BUILD_COMMIT\n\n$TW5_BUILD_DETAILS\n"
|
||||
|
||||
######################################################
|
||||
#
|
||||
# Core distribution
|
||||
# Core distributions
|
||||
#
|
||||
######################################################
|
||||
|
||||
# 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
|
||||
# /favicon.ico Favicon for main site
|
||||
# /static.html Static rendering of default tiddlers
|
||||
@@ -95,6 +112,7 @@ echo -e -n "title: $:/build\ncommit: $TW5_BUILD_COMMIT\n\n$TW5_BUILD_DETAILS\n"
|
||||
# /static/* Static single tiddlers
|
||||
# /static/static.css Static stylesheet
|
||||
# /static/favicon.ico Favicon for static pages
|
||||
|
||||
node $TW5_BUILD_TIDDLYWIKI \
|
||||
$TW5_BUILD_MAIN_EDITION \
|
||||
--verbose \
|
||||
@@ -104,13 +122,15 @@ node $TW5_BUILD_TIDDLYWIKI \
|
||||
--build favicon static index \
|
||||
|| exit 1
|
||||
|
||||
# /empty.html Empty
|
||||
# /empty.hta For Internet Explorer
|
||||
# /empty.html Empty
|
||||
# /empty.hta For Internet Explorer
|
||||
# /empty-external-core.html External core empty
|
||||
# /tiddlywikicore-<version>.js Core plugin javascript
|
||||
node $TW5_BUILD_TIDDLYWIKI \
|
||||
./editions/empty \
|
||||
--verbose \
|
||||
--output $TW5_BUILD_OUTPUT \
|
||||
--build empty \
|
||||
--build empty emptyexternalcore \
|
||||
|| exit 1
|
||||
|
||||
|
||||
|
||||
16
bin/ci-test.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/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
|
||||
17
boot/boot.js
@@ -575,9 +575,8 @@ var globalCheck =[
|
||||
" configurable: true",
|
||||
" });",
|
||||
" if(Object.keys(__temp__).length){",
|
||||
" console.log(Object.keys(__temp__));",
|
||||
" console.log(\"Warning: Global assignment detected\",Object.keys(__temp__));",
|
||||
" delete Object.prototype.__temp__;",
|
||||
" throw \"Global assignment is not allowed within modules on node.\";",
|
||||
" }",
|
||||
" delete Object.prototype.__temp__;",
|
||||
].join('\n');
|
||||
@@ -926,7 +925,7 @@ $tw.modules.execute = function(moduleName,moduleRoot) {
|
||||
}
|
||||
} else {
|
||||
// line number should be included in e.stack for runtime errors
|
||||
$tw.utils.error("Error executing boot module " + name + ": " + JSON.stringify(e) + "\n\n" + e.stack);
|
||||
$tw.utils.error("Error executing boot module " + name + ": " + String(e) + "\n\n" + e.stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2675,6 +2674,18 @@ $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
|
||||
*/
|
||||
|
||||
@@ -4,7 +4,7 @@ type: text/plain
|
||||
TiddlyWiki created by Jeremy Ruston, (jeremy [at] jermolene [dot] com)
|
||||
|
||||
Copyright (c) 2004-2007, Jeremy Ruston
|
||||
Copyright (c) 2007-2023, UnaMesa Association
|
||||
Copyright (c) 2007-2024, UnaMesa Association
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
||||
@@ -3,4 +3,4 @@ title: $:/language/Exporters/
|
||||
StaticRiver: Static HTML
|
||||
JsonFile: JSON file
|
||||
CsvFile: CSV file
|
||||
TidFile: ".tid" file
|
||||
TidFile: TID text file
|
||||
|
||||
@@ -4,6 +4,7 @@ _canonical_uri: The full URI of an external image tiddler
|
||||
author: Name of the author of a plugin
|
||||
bag: The name of the bag from which a tiddler came
|
||||
caption: The text to be displayed on a tab or button
|
||||
class: The CSS class applied to a tiddler when rendering it - see [[Custom styles by user-class]]. Also used for [[Modals]]
|
||||
code-body: The view template will display the tiddler as code if set to ''yes''
|
||||
color: The CSS color value associated with a tiddler
|
||||
component: The name of the component responsible for an [[alert tiddler|AlertMechanism]]
|
||||
|
||||
@@ -10,7 +10,7 @@ Sequentially run the command tokens returned from a filter
|
||||
Examples
|
||||
|
||||
```
|
||||
--commands "[enlist{$:/build-commands-as-text}]"
|
||||
--commands "[enlist:raw{$:/build-commands-as-text}]"
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
@@ -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
|
||||
** ''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 same 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 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:
|
||||
|
||||
@@ -31,4 +31,4 @@ Save the plugin to the tiddlers directory of the target wiki folder:
|
||||
|
||||
```
|
||||
tiddlywiki --load ./mywiki.html --savewikifolder ./mywikifolder explodePlugins=no
|
||||
```
|
||||
```
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
title: $:/language/Help/server
|
||||
description: Provides an HTTP server interface to TiddlyWiki (deprecated in favour of the new listen command)
|
||||
description: (deprecated: see 'listen' command) Provides an HTTP server interface to TiddlyWiki
|
||||
|
||||
Legacy command to serve a wiki over HTTP.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
title: $:/language/Docs/Types/image/svg+xml
|
||||
description: Structured Vector Graphics image
|
||||
description: SVG image
|
||||
name: image/svg+xml
|
||||
group: Image
|
||||
group-sort: 1
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
title: $:/language/Docs/Types/image/x-icon
|
||||
description: ICO format icon file
|
||||
description: ICO icon
|
||||
name: image/x-icon
|
||||
group: Image
|
||||
group-sort: 1
|
||||
|
||||
@@ -46,7 +46,7 @@ Command.prototype.execute = function() {
|
||||
type = tiddler.fields.type || "text/vnd.tiddlywiki",
|
||||
contentTypeInfo = $tw.config.contentTypeInfo[type] || {encoding: "utf8"},
|
||||
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;
|
||||
};
|
||||
|
||||
@@ -60,7 +60,7 @@ function FramedEngine(options) {
|
||||
this.domNode.value = this.value;
|
||||
}
|
||||
// Set the attributes
|
||||
if(this.widget.editType) {
|
||||
if(this.widget.editType && this.widget.editTag !== "textarea") {
|
||||
this.domNode.setAttribute("type",this.widget.editType);
|
||||
}
|
||||
if(this.widget.editPlaceholder) {
|
||||
|
||||
@@ -34,7 +34,7 @@ function SimpleEngine(options) {
|
||||
this.domNode.value = this.value;
|
||||
}
|
||||
// Set the attributes
|
||||
if(this.widget.editType) {
|
||||
if(this.widget.editType && this.widget.editTag !== "textarea") {
|
||||
this.domNode.setAttribute("type",this.widget.editType);
|
||||
}
|
||||
if(this.widget.editPlaceholder) {
|
||||
|
||||
@@ -28,12 +28,8 @@ function getAllFilterOperators() {
|
||||
Export our filter function
|
||||
*/
|
||||
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
|
||||
var subops = operator.operand.split("+");
|
||||
if(subops.length === 1 && subops[0] === "") {
|
||||
return source;
|
||||
} else if(subops.length === 1 && subops[0] === "tiddlers") {
|
||||
@@ -46,6 +42,10 @@ exports.all = function(source,operator,options) {
|
||||
return options.wiki.eachShadowPlusTiddlers;
|
||||
}
|
||||
// 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++) {
|
||||
var subop = allFilterOperators[subops[t]];
|
||||
if(subop) {
|
||||
|
||||
@@ -18,16 +18,20 @@ Export our filter functions
|
||||
|
||||
exports.decodebase64 = function(source,operator,options) {
|
||||
var results = [];
|
||||
var binary = operator.suffixes && operator.suffixes.indexOf("binary") !== -1;
|
||||
var urlsafe = operator.suffixes && operator.suffixes.indexOf("urlsafe") !== -1;
|
||||
source(function(tiddler,title) {
|
||||
results.push($tw.utils.base64Decode(title));
|
||||
results.push($tw.utils.base64Decode(title,binary,urlsafe));
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
exports.encodebase64 = function(source,operator,options) {
|
||||
var results = [];
|
||||
var binary = operator.suffixes && operator.suffixes.indexOf("binary") !== -1;
|
||||
var urlsafe = operator.suffixes && operator.suffixes.indexOf("urlsafe") !== -1;
|
||||
source(function(tiddler,title) {
|
||||
results.push($tw.utils.base64Encode(title));
|
||||
results.push($tw.utils.base64Encode(title,binary,urlsafe));
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
@@ -68,6 +68,54 @@ exports["jsontype"] = function(source,operator,options) {
|
||||
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
|
||||
*/
|
||||
@@ -165,6 +213,18 @@ 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
|
||||
*/
|
||||
@@ -177,7 +237,7 @@ function getDataItem(data,indexes) {
|
||||
for(var i=0; i<indexes.length; i++) {
|
||||
if(item !== undefined) {
|
||||
if(item !== null && ["number","string","boolean"].indexOf(typeof item) === -1) {
|
||||
item = item[indexes[i]];
|
||||
item = getItemAtIndex(item,indexes[i]);
|
||||
} else {
|
||||
item = undefined;
|
||||
}
|
||||
@@ -186,5 +246,39 @@ function getDataItem(data,indexes) {
|
||||
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;
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
@@ -58,6 +58,7 @@ Last entry/entries in list
|
||||
exports.last = function(source,operator,options) {
|
||||
var count = $tw.utils.getInt(operator.operand,1),
|
||||
results = [];
|
||||
if(count === 0) return results;
|
||||
source(function(tiddler,title) {
|
||||
results.push(title);
|
||||
});
|
||||
|
||||
@@ -14,10 +14,12 @@ The plain text parser processes blocks of source text into a degenerate parse tr
|
||||
|
||||
var TextParser = function(type,text,options) {
|
||||
this.tree = [{
|
||||
type: "codeblock",
|
||||
type: "genesis",
|
||||
attributes: {
|
||||
code: {type: "string", value: text},
|
||||
language: {type: "string", value: type}
|
||||
$type: {name: "$type", type: "string", value: "$codeblock"},
|
||||
code: {name: "code", type: "string", value: text},
|
||||
language: {name: "language", type: "string", value: type},
|
||||
$remappable: {name: "$remappable", type:"string", value: "no"}
|
||||
}
|
||||
}];
|
||||
this.source = text;
|
||||
@@ -32,4 +34,3 @@ exports["text/css"] = TextParser;
|
||||
exports["application/x-tiddler-dictionary"] = TextParser;
|
||||
|
||||
})();
|
||||
|
||||
|
||||
120
core/modules/parsers/wikiparser/rules/conditional.js
Normal file
@@ -0,0 +1,120 @@
|
||||
/*\
|
||||
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];
|
||||
};
|
||||
|
||||
})();
|
||||
@@ -49,11 +49,11 @@ exports.parse = function() {
|
||||
if(this.match[3]) {
|
||||
params = $tw.utils.parseParameterDefinition(this.match[4]);
|
||||
}
|
||||
// Is this a multiline definition?
|
||||
// Is the remainder of the line blank after the parameter close paren?
|
||||
var reEnd;
|
||||
if(this.match[5]) {
|
||||
// If so, the end of the body is marked with \end
|
||||
reEnd = new RegExp("(\\r?\\n[^\\S\\n\\r]*\\\\end[^\\S\\n\\r]*(?:" + $tw.utils.escapeRegExp(this.match[2]) + ")?(?:$|\\r?\\n))","mg");
|
||||
// If so, it is a multiline definition and the end of the body is marked with \end
|
||||
reEnd = new RegExp("((:?^|\\r?\\n)[^\\S\\n\\r]*\\\\end[^\\S\\n\\r]*(?:" + $tw.utils.escapeRegExp(this.match[2]) + ")?(?:$|\\r?\\n))","mg");
|
||||
} else {
|
||||
// Otherwise, the end of the definition is marked by the end of the line
|
||||
reEnd = /($|\r?\n)/mg;
|
||||
|
||||
@@ -54,11 +54,11 @@ exports.parse = function() {
|
||||
paramMatch = reParam.exec(paramString);
|
||||
}
|
||||
}
|
||||
// Is this a multiline definition?
|
||||
// Is the remainder of the \define line blank after the parameter close paren?
|
||||
var reEnd;
|
||||
if(this.match[3]) {
|
||||
// If so, the end of the body is marked with \end
|
||||
reEnd = new RegExp("(\\r?\\n[^\\S\\n\\r]*\\\\end[^\\S\\n\\r]*(?:" + $tw.utils.escapeRegExp(this.match[1]) + ")?(?:$|\\r?\\n))","mg");
|
||||
// If so, it is a multiline definition and the end of the body is marked with \end
|
||||
reEnd = new RegExp("((?:^|\\r?\\n)[^\\S\\n\\r]*\\\\end[^\\S\\n\\r]*(?:" + $tw.utils.escapeRegExp(this.match[1]) + ")?(?:$|\\r?\\n))","mg");
|
||||
} else {
|
||||
// Otherwise, the end of the definition is marked by the end of the line
|
||||
reEnd = /($|\r?\n)/mg;
|
||||
|
||||
@@ -194,6 +194,7 @@ Parse any pragmas at the beginning of a block of parse text
|
||||
WikiParser.prototype.parsePragmas = function() {
|
||||
var currentTreeBranch = this.tree;
|
||||
while(true) {
|
||||
var savedPos = this.pos;
|
||||
// Skip whitespace
|
||||
this.skipWhitespace();
|
||||
// Check for the end of the text
|
||||
@@ -204,6 +205,7 @@ WikiParser.prototype.parsePragmas = function() {
|
||||
var nextMatch = this.findNextMatch(this.pragmaRules,this.pos);
|
||||
// If not, just exit
|
||||
if(!nextMatch || nextMatch.matchIndex !== this.pos) {
|
||||
this.pos = savedPos;
|
||||
break;
|
||||
}
|
||||
// Process the pragma rule
|
||||
@@ -214,6 +216,8 @@ WikiParser.prototype.parsePragmas = function() {
|
||||
subTree[0].children = [];
|
||||
currentTreeBranch = subTree[0].children;
|
||||
}
|
||||
// Skip whitespace after the pragma
|
||||
this.skipWhitespace();
|
||||
}
|
||||
return currentTreeBranch;
|
||||
};
|
||||
@@ -223,7 +227,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
|
||||
*/
|
||||
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();
|
||||
if(this.pos >= this.sourceLength) {
|
||||
return [];
|
||||
@@ -264,11 +268,21 @@ WikiParser.prototype.parseBlocksUnterminated = function() {
|
||||
};
|
||||
|
||||
/*
|
||||
Parse blocks of text until a terminating regexp is encountered
|
||||
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 terminatorRegExp = new RegExp("(" + terminatorRegExpString + ")","mg"),
|
||||
tree = [];
|
||||
var ex = this.parseBlocksTerminatedExtended(terminatorRegExpString);
|
||||
return ex.tree;
|
||||
};
|
||||
|
||||
/*
|
||||
Parse blocks of text until a terminating regexp is encountered
|
||||
*/
|
||||
WikiParser.prototype.parseBlocksTerminatedExtended = function(terminatorRegExpString) {
|
||||
var terminatorRegExp = new RegExp(terminatorRegExpString,"mg"),
|
||||
result = {
|
||||
tree: []
|
||||
};
|
||||
// Skip any whitespace
|
||||
this.skipWhitespace();
|
||||
// Check if we've got the end marker
|
||||
@@ -277,7 +291,7 @@ WikiParser.prototype.parseBlocksTerminated = function(terminatorRegExpString) {
|
||||
// Parse the text into blocks
|
||||
while(this.pos < this.sourceLength && !(match && match.index === this.pos)) {
|
||||
var blocks = this.parseBlock(terminatorRegExpString);
|
||||
tree.push.apply(tree,blocks);
|
||||
result.tree.push.apply(result.tree,blocks);
|
||||
// Skip any whitespace
|
||||
this.skipWhitespace();
|
||||
// Check if we've got the end marker
|
||||
@@ -286,8 +300,9 @@ WikiParser.prototype.parseBlocksTerminated = function(terminatorRegExpString) {
|
||||
}
|
||||
if(match && match.index === this.pos) {
|
||||
this.pos = match.index + match[0].length;
|
||||
result.match = match;
|
||||
}
|
||||
return tree;
|
||||
return result;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -330,6 +345,11 @@ WikiParser.prototype.parseInlineRunUnterminated = function(options) {
|
||||
};
|
||||
|
||||
WikiParser.prototype.parseInlineRunTerminated = function(terminatorRegExp,options) {
|
||||
var ex = this.parseInlineRunTerminatedExtended(terminatorRegExp,options);
|
||||
return ex.tree;
|
||||
};
|
||||
|
||||
WikiParser.prototype.parseInlineRunTerminatedExtended = function(terminatorRegExp,options) {
|
||||
options = options || {};
|
||||
var tree = [];
|
||||
// Find the next occurrence of the terminator
|
||||
@@ -349,7 +369,10 @@ WikiParser.prototype.parseInlineRunTerminated = function(terminatorRegExp,option
|
||||
if(options.eatTerminator) {
|
||||
this.pos += terminatorMatch[0].length;
|
||||
}
|
||||
return tree;
|
||||
return {
|
||||
match: terminatorMatch,
|
||||
tree: tree
|
||||
};
|
||||
}
|
||||
}
|
||||
// Process any inline rule, along with the text preceding it
|
||||
@@ -373,7 +396,9 @@ WikiParser.prototype.parseInlineRunTerminated = function(terminatorRegExp,option
|
||||
this.pushTextWidget(tree,this.source.substr(this.pos),this.pos,this.sourceLength);
|
||||
}
|
||||
this.pos = this.sourceLength;
|
||||
return tree;
|
||||
return {
|
||||
tree: tree
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@@ -31,7 +31,7 @@ GitHubSaver.prototype.save = function(text,method,callback) {
|
||||
headers = {
|
||||
"Accept": "application/vnd.github.v3+json",
|
||||
"Content-Type": "application/json;charset=UTF-8",
|
||||
"Authorization": "Basic " + window.btoa(username + ":" + password),
|
||||
"Authorization": "Basic " + $tw.utils.base64Encode(username + ":" + password),
|
||||
"If-None-Match": ""
|
||||
};
|
||||
// Bail if we don't have everything we need
|
||||
|
||||
@@ -40,7 +40,7 @@ exports.startup = function() {
|
||||
variables = $tw.utils.extend({},paramObject,{currentTiddler: title, "tv-window-id": windowID});
|
||||
// Open the window
|
||||
var srcWindow,
|
||||
srcDocument;
|
||||
srcDocument;
|
||||
// In case that popup blockers deny opening a new window
|
||||
try {
|
||||
srcWindow = window.open("","external-" + windowID,"scrollbars,width=" + width + ",height=" + height + (top ? ",top=" + top : "" ) + (left ? ",left=" + left : "" )),
|
||||
@@ -52,6 +52,7 @@ exports.startup = function() {
|
||||
$tw.windows[windowID] = srcWindow;
|
||||
// Check for reopening the same window
|
||||
if(srcWindow.haveInitialisedWindow) {
|
||||
srcWindow.focus();
|
||||
return;
|
||||
}
|
||||
// Initialise the document
|
||||
|
||||
@@ -24,7 +24,7 @@ Syncer.prototype.titleSyncPollingInterval = "$:/config/SyncPollingInterval";
|
||||
Syncer.prototype.titleSyncDisableLazyLoading = "$:/config/SyncDisableLazyLoading";
|
||||
Syncer.prototype.titleSavedNotification = "$:/language/Notifications/Save/Done";
|
||||
Syncer.prototype.titleSyncThrottleInterval = "$:/config/SyncThrottleInterval";
|
||||
Syncer.prototype.taskTimerInterval = 1 * 1000; // Interval for sync timer
|
||||
Syncer.prototype.taskTimerInterval = 0.25 * 1000; // Interval for sync timer
|
||||
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.fallbackInterval = 10 * 1000; // Unless the task is older than 10s
|
||||
@@ -74,9 +74,11 @@ function Syncer(options) {
|
||||
this.titlesHaveBeenLazyLoaded = {}; // Hashmap of titles of tiddlers that have already been lazily loaded from the server
|
||||
// Timers
|
||||
this.taskTimerId = null; // Timer for task dispatch
|
||||
this.pollTimerId = null; // Timer for polling server
|
||||
// Number of outstanding requests
|
||||
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
|
||||
this.wiki.addEventListener("change",function(changes) {
|
||||
// Filter the changes to just include ones that are being synced
|
||||
@@ -203,33 +205,37 @@ Syncer.prototype.readTiddlerInfo = function() {
|
||||
Checks whether the wiki is dirty (ie the window shouldn't be closed)
|
||||
*/
|
||||
Syncer.prototype.isDirty = function() {
|
||||
this.logger.log("Checking dirty status");
|
||||
// Check tiddlers that are in the store and included in the filter function
|
||||
var titles = this.getSyncedTiddlers();
|
||||
for(var index=0; index<titles.length; index++) {
|
||||
var title = titles[index],
|
||||
tiddlerInfo = this.tiddlerInfo[title];
|
||||
if(this.wiki.tiddlerExists(title)) {
|
||||
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(this.wiki.getChangeCount(title) > tiddlerInfo.changeCount) {
|
||||
var self = this;
|
||||
function checkIsDirty() {
|
||||
// Check tiddlers that are in the store and included in the filter function
|
||||
var titles = self.getSyncedTiddlers();
|
||||
for(var index=0; index<titles.length; index++) {
|
||||
var title = titles[index],
|
||||
tiddlerInfo = self.tiddlerInfo[title];
|
||||
if(self.wiki.tiddlerExists(title)) {
|
||||
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(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;
|
||||
}
|
||||
} 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 false;
|
||||
}
|
||||
// Check tiddlers that are known from the server but not currently in the store
|
||||
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;
|
||||
var dirtyStatus = checkIsDirty();
|
||||
return dirtyStatus;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -293,92 +299,16 @@ 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
|
||||
*/
|
||||
Syncer.prototype.syncFromServer = function() {
|
||||
var self = this,
|
||||
cancelNextSync = function() {
|
||||
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();
|
||||
});
|
||||
if(this.canSyncFromServer()) {
|
||||
this.forceSyncFromServer = true;
|
||||
this.processTaskQueue();
|
||||
}
|
||||
};
|
||||
|
||||
Syncer.prototype.canSyncFromServer = function() {
|
||||
return !!this.syncadaptor.getUpdatedTiddlers || !!this.syncadaptor.getSkinnyTiddlers;
|
||||
}
|
||||
|
||||
/*
|
||||
Force load a tiddler from the server
|
||||
*/
|
||||
@@ -510,7 +440,7 @@ Syncer.prototype.processTaskQueue = function() {
|
||||
} else {
|
||||
self.updateDirtyStatus();
|
||||
// Process the next task
|
||||
self.processTaskQueue.call(self);
|
||||
self.processTaskQueue.call(self);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -518,31 +448,39 @@ Syncer.prototype.processTaskQueue = function() {
|
||||
this.updateDirtyStatus();
|
||||
// And trigger a timeout if there is a pending task
|
||||
if(task === true) {
|
||||
this.triggerTimeout();
|
||||
this.triggerTimeout(this.taskTimerInterval);
|
||||
} else if(this.canSyncFromServer()) {
|
||||
this.triggerTimeout(this.pollTimerInterval);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.updateDirtyStatus();
|
||||
this.updateDirtyStatus();
|
||||
this.triggerTimeout(this.taskTimerInterval);
|
||||
}
|
||||
};
|
||||
|
||||
Syncer.prototype.triggerTimeout = function(interval) {
|
||||
var self = this;
|
||||
if(!this.taskTimerId) {
|
||||
this.taskTimerId = setTimeout(function() {
|
||||
self.taskTimerId = null;
|
||||
self.processTaskQueue.call(self);
|
||||
},interval || self.taskTimerInterval);
|
||||
if(this.taskTimerId) {
|
||||
clearTimeout(this.taskTimerId);
|
||||
}
|
||||
this.taskTimerId = setTimeout(function() {
|
||||
self.taskTimerId = null;
|
||||
self.processTaskQueue.call(self);
|
||||
},interval || self.taskTimerInterval);
|
||||
};
|
||||
|
||||
/*
|
||||
Choose the next sync task. We prioritise saves, then deletes, then loads from the server
|
||||
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
|
||||
|
||||
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
|
||||
Returns either:
|
||||
* 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() {
|
||||
var thresholdLastSaved = (new Date()) - this.throttleInterval,
|
||||
var now = new Date(),
|
||||
thresholdLastSaved = now - this.throttleInterval,
|
||||
havePending = null;
|
||||
// First we look for tiddlers that have been modified locally and need saving back to the server
|
||||
var titles = this.getSyncedTiddlers();
|
||||
@@ -556,14 +494,18 @@ Syncer.prototype.chooseNextTask = function() {
|
||||
isReadyToSave = !tiddlerInfo || !tiddlerInfo.timestampLastSaved || tiddlerInfo.timestampLastSaved < thresholdLastSaved;
|
||||
if(hasChanged) {
|
||||
if(isReadyToSave) {
|
||||
return new SaveTiddlerTask(this,title);
|
||||
return new SaveTiddlerTask(this,title);
|
||||
} else {
|
||||
havePending = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Second, we check tiddlers that are known from the server but not currently in the store, and so need deleting on the server
|
||||
// Second we check for an outstanding sync from 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);
|
||||
for(index=0; index<titles.length; index++) {
|
||||
title = titles[index];
|
||||
@@ -573,13 +515,13 @@ Syncer.prototype.chooseNextTask = function() {
|
||||
return new DeleteTiddlerTask(this,title);
|
||||
}
|
||||
}
|
||||
// Check for tiddlers that need loading
|
||||
// Finally, check for tiddlers that need loading
|
||||
title = Object.keys(this.titlesToBeLoaded)[0];
|
||||
if(title) {
|
||||
delete this.titlesToBeLoaded[title];
|
||||
return new LoadTiddlerTask(this,title);
|
||||
}
|
||||
// No tasks are ready
|
||||
// No tasks are ready now, but might be in the future
|
||||
return havePending;
|
||||
};
|
||||
|
||||
@@ -589,6 +531,10 @@ function SaveTiddlerTask(syncer,title) {
|
||||
this.type = "save";
|
||||
}
|
||||
|
||||
SaveTiddlerTask.prototype.toString = function() {
|
||||
return "SAVE " + this.title;
|
||||
}
|
||||
|
||||
SaveTiddlerTask.prototype.run = function(callback) {
|
||||
var self = this,
|
||||
changeCount = this.syncer.wiki.getChangeCount(this.title),
|
||||
@@ -613,7 +559,6 @@ SaveTiddlerTask.prototype.run = function(callback) {
|
||||
tiddlerInfo: self.syncer.tiddlerInfo[self.title]
|
||||
});
|
||||
} else {
|
||||
this.syncer.logger.log(" Not Dispatching 'save' task:",this.title,"tiddler does not exist");
|
||||
$tw.utils.nextTick(callback(null));
|
||||
}
|
||||
};
|
||||
@@ -624,6 +569,10 @@ function DeleteTiddlerTask(syncer,title) {
|
||||
this.type = "delete";
|
||||
}
|
||||
|
||||
DeleteTiddlerTask.prototype.toString = function() {
|
||||
return "DELETE " + this.title;
|
||||
}
|
||||
|
||||
DeleteTiddlerTask.prototype.run = function(callback) {
|
||||
var self = this;
|
||||
this.syncer.logger.log("Dispatching 'delete' task:",this.title);
|
||||
@@ -647,6 +596,10 @@ function LoadTiddlerTask(syncer,title) {
|
||||
this.type = "load";
|
||||
}
|
||||
|
||||
LoadTiddlerTask.prototype.toString = function() {
|
||||
return "LOAD " + this.title;
|
||||
}
|
||||
|
||||
LoadTiddlerTask.prototype.run = function(callback) {
|
||||
var self = this;
|
||||
this.syncer.logger.log("Dispatching 'load' task:",this.title);
|
||||
@@ -664,6 +617,91 @@ 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;
|
||||
|
||||
})();
|
||||
|
||||
@@ -313,7 +313,7 @@ exports.collectDOMVariables = function(selectedNode,domNode,event) {
|
||||
variables["dom-" + attribute.name] = attribute.value.toString();
|
||||
});
|
||||
|
||||
if(selectedNode.offsetLeft) {
|
||||
if("offsetLeft" in selectedNode) {
|
||||
// Add variables with a (relative and absolute) popup coordinate string for the selected node
|
||||
var nodeRect = {
|
||||
left: selectedNode.offsetLeft,
|
||||
@@ -338,12 +338,12 @@ exports.collectDOMVariables = function(selectedNode,domNode,event) {
|
||||
}
|
||||
}
|
||||
|
||||
if(domNode && domNode.offsetWidth) {
|
||||
if(domNode && ("offsetWidth" in domNode)) {
|
||||
variables["tv-widgetnode-width"] = domNode.offsetWidth.toString();
|
||||
variables["tv-widgetnode-height"] = domNode.offsetHeight.toString();
|
||||
}
|
||||
|
||||
if(event && event.clientX && event.clientY) {
|
||||
if(event && ("clientX" in event) && ("clientY" in event)) {
|
||||
if(selectedNode) {
|
||||
// Add variables for event X and Y position relative to selected node
|
||||
selectedNodeRect = selectedNode.getBoundingClientRect();
|
||||
|
||||
@@ -187,7 +187,7 @@ HttpClientRequest.prototype.send = function(callback) {
|
||||
for (var i=0; i<len; i++) {
|
||||
binary += String.fromCharCode(bytes[i]);
|
||||
}
|
||||
resultVariables.data = window.btoa(binary);
|
||||
resultVariables.data = $tw.utils.base64Encode(binary,true);
|
||||
}
|
||||
self.wiki.addTiddler(new $tw.Tiddler(self.wiki.getTiddler(requestTrackerTitle),{
|
||||
status: completionCode,
|
||||
|
||||
@@ -104,7 +104,11 @@ TW_Element.prototype.setAttribute = function(name,value) {
|
||||
if(this.isRaw) {
|
||||
throw "Cannot setAttribute on a raw TW_Element";
|
||||
}
|
||||
this.attributes[name] = value + "";
|
||||
if(name === "style") {
|
||||
this.style = value;
|
||||
} else {
|
||||
this.attributes[name] = value + "";
|
||||
}
|
||||
};
|
||||
|
||||
TW_Element.prototype.setAttributeNS = function(namespace,name,value) {
|
||||
|
||||
@@ -819,18 +819,41 @@ exports.hashString = function(str) {
|
||||
},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
|
||||
*/
|
||||
exports.base64Decode = function(string64) {
|
||||
return base64utf8.base64.decode.call(base64utf8,string64);
|
||||
exports.base64Decode = function(string64,binary,urlsafe) {
|
||||
var encoded = urlsafe ? string64.replace(/_/g,'/').replace(/-/g,'+') : string64;
|
||||
if(binary) return exports.atob(encoded)
|
||||
else return base64utf8.base64.decode.call(base64utf8,encoded);
|
||||
};
|
||||
|
||||
/*
|
||||
Encode a string to base64
|
||||
*/
|
||||
exports.base64Encode = function(string64) {
|
||||
return base64utf8.base64.encode.call(base64utf8,string64);
|
||||
exports.base64Encode = function(string64,binary,urlsafe) {
|
||||
var encoded;
|
||||
if(binary) encoded = exports.btoa(string64);
|
||||
else encoded = base64utf8.base64.encode.call(base64utf8,string64);
|
||||
if(urlsafe) {
|
||||
encoded = encoded.replace(/\+/g,'-').replace(/\//g,'_');
|
||||
}
|
||||
return encoded;
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@@ -70,6 +70,11 @@ BrowseWidget.prototype.render = function(parent,nextSibling) {
|
||||
}
|
||||
return false;
|
||||
},false);
|
||||
// Assign data- attributes
|
||||
this.assignAttributes(domNode,{
|
||||
sourcePrefix: "data-",
|
||||
destPrefix: "data-"
|
||||
});
|
||||
// Insert element
|
||||
parent.insertBefore(domNode,nextSibling);
|
||||
this.renderChildren(domNode,null);
|
||||
@@ -95,6 +100,11 @@ BrowseWidget.prototype.execute = function() {
|
||||
Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering
|
||||
*/
|
||||
BrowseWidget.prototype.refresh = function(changedTiddlers) {
|
||||
var changedAttributes = this.computeAttributes();
|
||||
if($tw.utils.count(changedAttributes) > 0) {
|
||||
this.refreshSelf();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
@@ -59,6 +59,11 @@ ButtonWidget.prototype.render = function(parent,nextSibling) {
|
||||
$tw.utils.pushTop(classes,"tc-popup-handle");
|
||||
}
|
||||
domNode.className = classes.join(" ");
|
||||
// Assign data- attributes
|
||||
this.assignAttributes(domNode,{
|
||||
sourcePrefix: "data-",
|
||||
destPrefix: "data-"
|
||||
});
|
||||
// Assign other attributes
|
||||
if(this.style) {
|
||||
domNode.setAttribute("style",this.style);
|
||||
@@ -250,7 +255,7 @@ ButtonWidget.prototype.updateDomNodeClasses = function() {
|
||||
//Add new classes from updated class attribute.
|
||||
$tw.utils.pushTop(domNodeClasses,newClasses);
|
||||
this.domNode.className = domNodeClasses.join(" ");
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering
|
||||
@@ -260,8 +265,15 @@ 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"]) {
|
||||
this.refreshSelf();
|
||||
return true;
|
||||
} else if(changedAttributes["class"]) {
|
||||
this.updateDomNodeClasses();
|
||||
} else {
|
||||
if(changedAttributes["class"]) {
|
||||
this.updateDomNodeClasses();
|
||||
}
|
||||
this.assignAttributes(this.domNodes[0],{
|
||||
changedAttributes: changedAttributes,
|
||||
sourcePrefix: "data-",
|
||||
destPrefix: "data-"
|
||||
});
|
||||
}
|
||||
return this.refreshChildren(changedTiddlers);
|
||||
};
|
||||
|
||||
@@ -53,6 +53,11 @@ CheckboxWidget.prototype.render = function(parent,nextSibling) {
|
||||
this.labelDomNode.appendChild(this.inputDomNode);
|
||||
this.spanDomNode = this.document.createElement("span");
|
||||
this.labelDomNode.appendChild(this.spanDomNode);
|
||||
// Assign data- attributes
|
||||
this.assignAttributes(this.inputDomNode,{
|
||||
sourcePrefix: "data-",
|
||||
destPrefix: "data-"
|
||||
});
|
||||
// Add a click event handler
|
||||
$tw.utils.addEventListeners(this.inputDomNode,[
|
||||
{name: "change", handlerObject: this, handlerMethod: "handleChangeEvent"}
|
||||
@@ -116,7 +121,7 @@ CheckboxWidget.prototype.getValue = function() {
|
||||
} else {
|
||||
list = $tw.utils.parseStringArray(this.checkboxDefault || "") || [];
|
||||
}
|
||||
} else if (this.checkboxListIndex) {
|
||||
} else if(this.checkboxListIndex) {
|
||||
list = $tw.utils.parseStringArray(this.wiki.extractTiddlerDataItem(tiddler,this.checkboxListIndex,this.checkboxDefault || "")) || [];
|
||||
} else {
|
||||
list = this.wiki.filterTiddlers(this.checkboxFilter,this) || [];
|
||||
@@ -215,6 +220,8 @@ CheckboxWidget.prototype.handleChangeEvent = function(event) {
|
||||
if($tw.utils.isArray(fieldContents)) {
|
||||
// Make a copy so we can modify it without changing original that's refrenced elsewhere
|
||||
listContents = fieldContents.slice(0);
|
||||
} else if(fieldContents === undefined) {
|
||||
listContents = [];
|
||||
} else if(typeof fieldContents === "string") {
|
||||
listContents = $tw.utils.parseStringArray(fieldContents);
|
||||
// No need to copy since parseStringArray returns a fresh array, not refrenced elsewhere
|
||||
@@ -323,6 +330,11 @@ CheckboxWidget.prototype.refresh = function(changedTiddlers) {
|
||||
$tw.utils.removeClass(this.labelDomNode,"tc-checkbox-checked");
|
||||
}
|
||||
}
|
||||
this.assignAttributes(this.inputDomNode,{
|
||||
changedAttributes: changedAttributes,
|
||||
sourcePrefix: "data-",
|
||||
destPrefix: "data-"
|
||||
});
|
||||
return this.refreshChildren(changedTiddlers) || refreshed;
|
||||
}
|
||||
};
|
||||
@@ -330,3 +342,4 @@ CheckboxWidget.prototype.refresh = function(changedTiddlers) {
|
||||
exports.checkbox = CheckboxWidget;
|
||||
|
||||
})();
|
||||
|
||||
@@ -52,6 +52,11 @@ DraggableWidget.prototype.render = function(parent,nextSibling) {
|
||||
classes.push("tc-draggable");
|
||||
}
|
||||
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
|
||||
parent.insertBefore(domNode,nextSibling);
|
||||
this.renderChildren(domNode,null);
|
||||
@@ -108,13 +113,19 @@ DraggableWidget.prototype.updateDomNodeClasses = function() {
|
||||
Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering
|
||||
*/
|
||||
DraggableWidget.prototype.refresh = function(changedTiddlers) {
|
||||
var changedAttributes = this.computeAttributes(),
|
||||
changedAttributesCount = $tw.utils.count(changedAttributes);
|
||||
if(changedAttributesCount === 1 && changedAttributes["class"]) {
|
||||
this.updateDomNodeClasses();
|
||||
} else if(changedAttributesCount > 0) {
|
||||
var changedAttributes = this.computeAttributes();
|
||||
if(changedAttributes.tag || changedAttributes.selector || changedAttributes.dragimagetype || changedAttributes.enable || changedAttributes.startactions || changedAttributes.endactions) {
|
||||
this.refreshSelf();
|
||||
return true;
|
||||
} else {
|
||||
if(changedAttributes["class"]) {
|
||||
this.assignDomNodeClasses();
|
||||
}
|
||||
this.assignAttributes(this.domNodes[0],{
|
||||
changedAttributes: changedAttributes,
|
||||
sourcePrefix: "data-",
|
||||
destPrefix: "data-"
|
||||
});
|
||||
}
|
||||
return this.refreshChildren(changedTiddlers);
|
||||
};
|
||||
|
||||
@@ -42,6 +42,11 @@ DroppableWidget.prototype.render = function(parent,nextSibling) {
|
||||
domNode = this.document.createElement(tag);
|
||||
this.domNode = domNode;
|
||||
this.assignDomNodeClasses();
|
||||
// Assign data- attributes and style. attributes
|
||||
this.assignAttributes(domNode,{
|
||||
sourcePrefix: "data-",
|
||||
destPrefix: "data-"
|
||||
});
|
||||
// Add event handlers
|
||||
if(this.droppableEnable) {
|
||||
$tw.utils.addEventListeners(domNode,[
|
||||
@@ -166,8 +171,15 @@ DroppableWidget.prototype.refresh = function(changedTiddlers) {
|
||||
if(changedAttributes.tag || changedAttributes.enable || changedAttributes.disabledClass || changedAttributes.actions || changedAttributes.effect) {
|
||||
this.refreshSelf();
|
||||
return true;
|
||||
} else if(changedAttributes["class"]) {
|
||||
this.assignDomNodeClasses();
|
||||
} else {
|
||||
if(changedAttributes["class"]) {
|
||||
this.assignDomNodeClasses();
|
||||
}
|
||||
this.assignAttributes(this.domNodes[0],{
|
||||
changedAttributes: changedAttributes,
|
||||
sourcePrefix: "data-",
|
||||
destPrefix: "data-"
|
||||
});
|
||||
}
|
||||
return this.refreshChildren(changedTiddlers);
|
||||
};
|
||||
|
||||
@@ -90,7 +90,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
|
||||
EditWidget.prototype.refresh = function(changedTiddlers) {
|
||||
var changedAttributes = this.computeAttributes();
|
||||
// Refresh if an attribute has changed, or the type associated with the target tiddler has changed
|
||||
if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes.tabindex || changedAttributes.cancelPopups || changedAttributes.inputActions || changedAttributes.refreshTitle || changedAttributes.autocomplete || (changedTiddlers[this.editTitle] && this.getEditorType() !== this.editorType)) {
|
||||
if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes.tabindex || changedAttributes.cancelPopups || changedAttributes.inputActions || changedAttributes.refreshTitle || changedAttributes.autocomplete || (this.getEditorType() !== this.editorType)) {
|
||||
this.refreshSelf();
|
||||
return true;
|
||||
} else {
|
||||
|
||||
@@ -58,24 +58,25 @@ ImageWidget.prototype.render = function(parent,nextSibling) {
|
||||
if(this.wiki.isImageTiddler(this.imageSource)) {
|
||||
var type = tiddler.fields.type,
|
||||
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(text) {
|
||||
// Render the appropriate element for the image type
|
||||
switch(type) {
|
||||
case "application/pdf":
|
||||
// Render the appropriate element for the image type by looking up the encoding in the content type info
|
||||
var encoding = typeInfo.encoding || "utf8";
|
||||
if (encoding === "base64") {
|
||||
// .pdf .png .jpg etc.
|
||||
src = "data:" + deserializerType + ";base64," + text;
|
||||
if (deserializerType === "application/pdf") {
|
||||
tag = "embed";
|
||||
src = "data:application/pdf;base64," + text;
|
||||
break;
|
||||
case "image/svg+xml":
|
||||
src = "data:image/svg+xml," + encodeURIComponent(text);
|
||||
break;
|
||||
default:
|
||||
src = "data:" + type + ";base64," + text;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// .svg .tid .xml etc.
|
||||
src = "data:" + deserializerType + "," + encodeURIComponent(text);
|
||||
}
|
||||
} else if(_canonical_uri) {
|
||||
switch(type) {
|
||||
switch(deserializerType) {
|
||||
case "application/pdf":
|
||||
tag = "embed";
|
||||
src = _canonical_uri;
|
||||
@@ -99,6 +100,9 @@ ImageWidget.prototype.render = function(parent,nextSibling) {
|
||||
if(this.imageClass) {
|
||||
domNode.setAttribute("class",this.imageClass);
|
||||
}
|
||||
if(this.imageUsemap) {
|
||||
domNode.setAttribute("usemap",this.imageUsemap);
|
||||
}
|
||||
if(this.imageWidth) {
|
||||
domNode.setAttribute("width",this.imageWidth);
|
||||
}
|
||||
@@ -138,6 +142,7 @@ ImageWidget.prototype.execute = function() {
|
||||
this.imageWidth = this.getAttribute("width");
|
||||
this.imageHeight = this.getAttribute("height");
|
||||
this.imageClass = this.getAttribute("class");
|
||||
this.imageUsemap = this.getAttribute("usemap");
|
||||
this.imageTooltip = this.getAttribute("tooltip");
|
||||
this.imageAlt = this.getAttribute("alt");
|
||||
this.lazyLoading = this.getAttribute("loading");
|
||||
@@ -148,7 +153,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
|
||||
*/
|
||||
ImageWidget.prototype.refresh = function(changedTiddlers) {
|
||||
var changedAttributes = this.computeAttributes();
|
||||
if(changedAttributes.source || changedAttributes.width || changedAttributes.height || changedAttributes["class"] || changedAttributes.tooltip || changedTiddlers[this.imageSource]) {
|
||||
if(changedAttributes.source || changedAttributes.width || changedAttributes.height || changedAttributes["class"] || changedAttributes.usemap || changedAttributes.tooltip || changedTiddlers[this.imageSource]) {
|
||||
this.refreshSelf();
|
||||
return true;
|
||||
} else {
|
||||
|
||||
@@ -43,6 +43,11 @@ LinkWidget.prototype.render = function(parent,nextSibling) {
|
||||
} else {
|
||||
// Just insert the link text
|
||||
var domNode = this.document.createElement("span");
|
||||
// Assign data- attributes
|
||||
this.assignAttributes(domNode,{
|
||||
sourcePrefix: "data-",
|
||||
destPrefix: "data-"
|
||||
});
|
||||
parent.insertBefore(domNode,nextSibling);
|
||||
this.renderChildren(domNode,null);
|
||||
this.domNodes.push(domNode);
|
||||
@@ -138,6 +143,11 @@ LinkWidget.prototype.renderLink = function(parent,nextSibling) {
|
||||
widget: this
|
||||
});
|
||||
}
|
||||
// Assign data- attributes
|
||||
this.assignAttributes(domNode,{
|
||||
sourcePrefix: "data-",
|
||||
destPrefix: "data-"
|
||||
});
|
||||
// Insert the link into the DOM and render any children
|
||||
parent.insertBefore(domNode,nextSibling);
|
||||
this.renderChildren(domNode,null);
|
||||
@@ -207,8 +217,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
|
||||
*/
|
||||
LinkWidget.prototype.refresh = function(changedTiddlers) {
|
||||
var changedAttributes = this.computeAttributes();
|
||||
if(changedAttributes.to || changedTiddlers[this.to] || changedAttributes["aria-label"] || changedAttributes.tooltip ||
|
||||
changedAttributes["class"] || changedAttributes.tabindex || changedAttributes.draggable || changedAttributes.tag) {
|
||||
if($tw.utils.count(changedAttributes) > 0 || changedTiddlers[this.to]) {
|
||||
this.refreshSelf();
|
||||
return true;
|
||||
}
|
||||
@@ -218,3 +227,4 @@ LinkWidget.prototype.refresh = function(changedTiddlers) {
|
||||
exports.link = LinkWidget;
|
||||
|
||||
})();
|
||||
|
||||
@@ -28,6 +28,18 @@ Inherit from the base widget class
|
||||
*/
|
||||
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
|
||||
*/
|
||||
@@ -38,8 +50,8 @@ ListWidget.prototype.render = function(parent,nextSibling) {
|
||||
$tw.modules.applyMethods("storyview",this.storyViews);
|
||||
}
|
||||
this.parentDomNode = parent;
|
||||
this.computeAttributes();
|
||||
this.execute();
|
||||
var changedAttributes = this.computeAttributes();
|
||||
this.execute(changedAttributes);
|
||||
this.renderChildren(parent,nextSibling);
|
||||
// Construct the storyview
|
||||
var StoryView = this.storyViews[this.storyViewName];
|
||||
@@ -59,7 +71,8 @@ ListWidget.prototype.render = function(parent,nextSibling) {
|
||||
/*
|
||||
Compute the internal state of the widget
|
||||
*/
|
||||
ListWidget.prototype.execute = function() {
|
||||
ListWidget.prototype.execute = function(changedAttributes) {
|
||||
var self = this;
|
||||
// Get our attributes
|
||||
this.template = this.getAttribute("template");
|
||||
this.editTemplate = this.getAttribute("editTemplate");
|
||||
@@ -67,6 +80,10 @@ ListWidget.prototype.execute = function() {
|
||||
this.counterName = this.getAttribute("counter");
|
||||
this.storyViewName = this.getAttribute("storyview");
|
||||
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
|
||||
this.list = this.getTiddlerList();
|
||||
var members = [],
|
||||
@@ -85,18 +102,57 @@ ListWidget.prototype.execute = function() {
|
||||
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() {
|
||||
var limit = $tw.utils.getInt(this.getAttribute("limit",""),undefined);
|
||||
var defaultFilter = "[!is[system]sort[title]]";
|
||||
return this.wiki.filterTiddlers(this.getAttribute("filter",defaultFilter),this);
|
||||
var results = 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() {
|
||||
var parser,
|
||||
emptyMessage = this.getAttribute("emptyMessage","");
|
||||
// this.wiki.parseText() calls
|
||||
// new Parser(..), which should only be done, if needed, because it's heavy!
|
||||
if (emptyMessage === "") {
|
||||
return [];
|
||||
emptyMessage = this.getAttribute("emptyMessage");
|
||||
// If emptyMessage attribute is not present or empty then look for an explicit empty template
|
||||
if(!emptyMessage) {
|
||||
if(this.explicitEmptyTemplate) {
|
||||
return this.explicitEmptyTemplate;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
parser = this.wiki.parseText("text/vnd.tiddlywiki",emptyMessage,{parseAsInline: true});
|
||||
if(parser) {
|
||||
@@ -106,6 +162,24 @@ 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
|
||||
*/
|
||||
@@ -114,6 +188,7 @@ ListWidget.prototype.makeItemTemplate = function(title,index) {
|
||||
var tiddler = this.wiki.getTiddler(title),
|
||||
isDraft = tiddler && tiddler.hasField("draft.of"),
|
||||
template = this.template,
|
||||
join = this.join,
|
||||
templateTree;
|
||||
if(isDraft && this.editTemplate) {
|
||||
template = this.editTemplate;
|
||||
@@ -122,22 +197,29 @@ ListWidget.prototype.makeItemTemplate = function(title,index) {
|
||||
if(template) {
|
||||
templateTree = [{type: "transclude", attributes: {tiddler: {type: "string", value: template}}}];
|
||||
} else {
|
||||
// Check for child nodes of the list widget
|
||||
if(this.parseTreeNode.children && this.parseTreeNode.children.length > 0) {
|
||||
templateTree = this.parseTreeNode.children;
|
||||
} else {
|
||||
// Check for a <$list-item> widget
|
||||
if(this.explicitListTemplate) {
|
||||
templateTree = this.explicitListTemplate;
|
||||
} else if(this.hasTemplateInBody) {
|
||||
templateTree = this.parseTreeNode.children;
|
||||
}
|
||||
}
|
||||
if(!templateTree || templateTree.length === 0) {
|
||||
// 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: [
|
||||
{type: "text", text: title}
|
||||
{type: "text", text: title}
|
||||
]}]}];
|
||||
}
|
||||
}
|
||||
// Return the list item
|
||||
var parseTreeNode = {type: "listitem", itemTitle: title, variableName: this.variableName, children: templateTree};
|
||||
var parseTreeNode = {type: "listitem", itemTitle: title, variableName: this.variableName, children: templateTree, join: join};
|
||||
parseTreeNode.isLast = index === this.list.length - 1;
|
||||
if(this.counterName) {
|
||||
parseTreeNode.counter = (index + 1).toString();
|
||||
parseTreeNode.counterName = this.counterName;
|
||||
parseTreeNode.isFirst = index === 0;
|
||||
parseTreeNode.isLast = index === this.list.length - 1;
|
||||
}
|
||||
return parseTreeNode;
|
||||
};
|
||||
@@ -153,7 +235,7 @@ ListWidget.prototype.refresh = function(changedTiddlers) {
|
||||
this.storyview.refreshStart(changedTiddlers,changedAttributes);
|
||||
}
|
||||
// Completely refresh if any of our attributes have changed
|
||||
if(changedAttributes.filter || changedAttributes.variable || changedAttributes.counter || changedAttributes.template || changedAttributes.editTemplate || changedAttributes.emptyMessage || changedAttributes.storyview || changedAttributes.history) {
|
||||
if(changedAttributes.filter || changedAttributes.variable || changedAttributes.counter || changedAttributes.template || changedAttributes.editTemplate || changedAttributes.join || changedAttributes.emptyMessage || changedAttributes.storyview || changedAttributes.history) {
|
||||
this.refreshSelf();
|
||||
result = true;
|
||||
} else {
|
||||
@@ -225,6 +307,8 @@ ListWidget.prototype.handleListChanges = function(changedTiddlers) {
|
||||
// If we are providing an counter variable then we must refresh the items, otherwise we can rearrange them
|
||||
var hasRefreshed = false,t;
|
||||
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
|
||||
for(t=0; t<this.list.length; t++) {
|
||||
if(hasRefreshed || !this.children[t] || this.children[t].parseTreeNode.itemTitle !== this.list[t]) {
|
||||
@@ -232,6 +316,9 @@ ListWidget.prototype.handleListChanges = function(changedTiddlers) {
|
||||
this.removeListItem(t);
|
||||
}
|
||||
this.insertListItem(t,this.list[t]);
|
||||
if(!hasRefreshed && t === oldLength) {
|
||||
mustRefreshOldLast = true;
|
||||
}
|
||||
hasRefreshed = true;
|
||||
} else {
|
||||
// Refresh the item we're reusing
|
||||
@@ -239,6 +326,12 @@ ListWidget.prototype.handleListChanges = function(changedTiddlers) {
|
||||
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(!hasRefreshed && this.children.length > this.list.length) {
|
||||
this.removeListItem(this.list.length-1);
|
||||
@@ -246,10 +339,29 @@ ListWidget.prototype.handleListChanges = function(changedTiddlers) {
|
||||
}
|
||||
} else {
|
||||
// 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++) {
|
||||
isLast = t === this.list.length-1;
|
||||
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) {
|
||||
// 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]);
|
||||
hasRefreshed = true;
|
||||
} else {
|
||||
@@ -258,9 +370,15 @@ ListWidget.prototype.handleListChanges = function(changedTiddlers) {
|
||||
this.removeListItem(n);
|
||||
hasRefreshed = true;
|
||||
}
|
||||
// Refresh the item we're reusing
|
||||
var refreshed = this.children[t].refresh(changedTiddlers);
|
||||
hasRefreshed = hasRefreshed || refreshed;
|
||||
// Refresh the item we're reusing, or recreate if necessary
|
||||
if(mustRecreateLastItem && (isLast || wasLast)) {
|
||||
this.removeListItem(t);
|
||||
this.insertListItem(t,this.list[t]);
|
||||
hasRefreshed = true;
|
||||
} else {
|
||||
var refreshed = this.children[t].refresh(changedTiddlers);
|
||||
hasRefreshed = hasRefreshed || refreshed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -350,8 +468,17 @@ ListItemWidget.prototype.execute = function() {
|
||||
this.setVariable(this.parseTreeNode.counterName + "-first",this.parseTreeNode.isFirst ? "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
|
||||
this.makeChildWidgets();
|
||||
this.makeChildWidgets(children);
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -363,4 +490,37 @@ ListItemWidget.prototype.refresh = function(changedTiddlers) {
|
||||
|
||||
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;
|
||||
|
||||
})();
|
||||
|
||||
@@ -42,31 +42,24 @@ Compute the internal state of the widget
|
||||
*/
|
||||
ParametersWidget.prototype.execute = function() {
|
||||
var self = this;
|
||||
this.parametersDepth = Math.max(parseInt(this.getAttribute("$depth","1"),10) || 1,1);
|
||||
// Find the parent transclusions
|
||||
var pointer = this.parentWidget,
|
||||
depth = this.parametersDepth;
|
||||
while(pointer) {
|
||||
if(pointer instanceof TranscludeWidget) {
|
||||
depth--;
|
||||
if(depth <= 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
pointer = pointer.parentWidget;
|
||||
}
|
||||
var pointer = this.getContainingTransclude();
|
||||
// Process each parameter
|
||||
if(pointer instanceof TranscludeWidget) {
|
||||
if(pointer) {
|
||||
// It's important to remember this, because when we refresh, we'll need to make sure this widget is starting at the same index.
|
||||
this.initialParameterIndex = pointer.parameterIndex;
|
||||
// Get the value for each defined parameter
|
||||
$tw.utils.each($tw.utils.getOrderedAttributesFromParseTreeNode(self.parseTreeNode),function(attr,index) {
|
||||
$tw.utils.each($tw.utils.getOrderedAttributesFromParseTreeNode(self.parseTreeNode),function(attr) {
|
||||
var name = attr.name;
|
||||
// If the attribute name starts with $$ then reduce to a single dollar
|
||||
if(name.substr(0,2) === "$$") {
|
||||
name = name.substr(1);
|
||||
}
|
||||
var value = pointer.getTransclusionParameter(name,index,self.getAttribute(attr.name,""));
|
||||
var value = pointer.getTransclusionParameter(name,self.getAttribute(attr.name,""));
|
||||
self.setVariable(name,value);
|
||||
});
|
||||
// We remember where we left the unnamed parameter index.
|
||||
this.finalParameterIndex = pointer.parameterIndex;
|
||||
// Assign any metaparameters
|
||||
$tw.utils.each(pointer.getTransclusionMetaParameters(),function(getValue,name) {
|
||||
var variableName = self.getAttribute("$" + name);
|
||||
@@ -84,13 +77,29 @@ Refresh the widget by ensuring our attributes are up to date
|
||||
*/
|
||||
ParametersWidget.prototype.refresh = function(changedTiddlers) {
|
||||
var changedAttributes = this.computeAttributes();
|
||||
if(Object.keys(changedAttributes).length) {
|
||||
var pointer = this.getContainingTransclude();
|
||||
var currentParameterIndex;
|
||||
if(pointer) {
|
||||
currentParameterIndex = pointer.parameterIndex;
|
||||
}
|
||||
if(Object.keys(changedAttributes).length || currentParameterIndex !== this.initialParameterIndex) {
|
||||
this.refreshSelf();
|
||||
return true;
|
||||
} else if(pointer) {
|
||||
// We set the index for unnamed parameters for our $transclude widget in case any later $parameters show up. They need to be able to confirm their indices are starting in the right place, because if not, they need to refresh.
|
||||
pointer.parameterIndex = this.finalParameterIndex;
|
||||
}
|
||||
return this.refreshChildren(changedTiddlers);
|
||||
};
|
||||
|
||||
ParametersWidget.prototype.getContainingTransclude = function() {
|
||||
var pointer = this.parentWidget;
|
||||
while(pointer && !(pointer instanceof TranscludeWidget)) {
|
||||
pointer = pointer.parentWidget;
|
||||
}
|
||||
return pointer;
|
||||
};
|
||||
|
||||
exports.parameters = ParametersWidget;
|
||||
|
||||
})();
|
||||
|
||||
@@ -40,6 +40,10 @@ RadioWidget.prototype.render = function(parent,nextSibling) {
|
||||
);
|
||||
this.inputDomNode = this.document.createElement("input");
|
||||
this.inputDomNode.setAttribute("type","radio");
|
||||
this.assignAttributes(this.inputDomNode,{
|
||||
sourcePrefix: "data-",
|
||||
destPrefix: "data-"
|
||||
});
|
||||
if(isChecked) {
|
||||
this.inputDomNode.checked = true;
|
||||
}
|
||||
|
||||
@@ -50,6 +50,10 @@ RangeWidget.prototype.render = function(parent,nextSibling) {
|
||||
this.inputDomNode.setAttribute("disabled",true);
|
||||
}
|
||||
this.inputDomNode.value = this.getValue();
|
||||
this.assignAttributes(this.inputDomNode,{
|
||||
sourcePrefix: "data-",
|
||||
destPrefix: "data-"
|
||||
});
|
||||
// Add a click event handler
|
||||
$tw.utils.addEventListeners(this.inputDomNode,[
|
||||
{name:"mousedown", handlerObject:this, handlerMethod:"handleMouseDownEvent"},
|
||||
|
||||
@@ -12,6 +12,8 @@ Scrollable widget
|
||||
/*global $tw: false */
|
||||
"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 ScrollableWidget = function(parseTreeNode,options) {
|
||||
@@ -171,6 +173,53 @@ ScrollableWidget.prototype.render = function(parent,nextSibling) {
|
||||
parent.insertBefore(this.outerDomNode,nextSibling);
|
||||
this.renderChildren(this.innerDomNode,null);
|
||||
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"
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -178,6 +227,7 @@ Compute the internal state of the widget
|
||||
*/
|
||||
ScrollableWidget.prototype.execute = function() {
|
||||
// Get attributes
|
||||
this.scrollableBind = this.getAttribute("bind");
|
||||
this.fallthrough = this.getAttribute("fallthrough","yes");
|
||||
this["class"] = this.getAttribute("class");
|
||||
// Make child widgets
|
||||
@@ -193,7 +243,22 @@ ScrollableWidget.prototype.refresh = function(changedTiddlers) {
|
||||
this.refreshSelf();
|
||||
return true;
|
||||
}
|
||||
return this.refreshChildren(changedTiddlers);
|
||||
// If the bound tiddler has changed, update the eventListener and update scroll position
|
||||
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;
|
||||
|
||||
@@ -40,7 +40,31 @@ SelectWidget.prototype.render = function(parent,nextSibling) {
|
||||
this.parentDomNode = parent;
|
||||
this.computeAttributes();
|
||||
this.execute();
|
||||
this.renderChildren(parent,nextSibling);
|
||||
//Create element
|
||||
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();
|
||||
if(this.selectFocus == "yes") {
|
||||
this.getSelectDomNode().focus();
|
||||
@@ -113,7 +137,7 @@ SelectWidget.prototype.setSelectValue = function() {
|
||||
Get the DOM node of the select element
|
||||
*/
|
||||
SelectWidget.prototype.getSelectDomNode = function() {
|
||||
return this.children[0].domNodes[0];
|
||||
return this.domNodes[0];
|
||||
};
|
||||
|
||||
// Return an array of the selected opion values
|
||||
@@ -149,27 +173,7 @@ SelectWidget.prototype.execute = function() {
|
||||
this.selectTooltip = this.getAttribute("tooltip");
|
||||
this.selectFocus = this.getAttribute("focus");
|
||||
// Make the child widgets
|
||||
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]);
|
||||
this.makeChildWidgets();
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -178,17 +182,21 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
|
||||
SelectWidget.prototype.refresh = function(changedTiddlers) {
|
||||
var changedAttributes = this.computeAttributes();
|
||||
// If we're using a different tiddler/field/index then completely refresh ourselves
|
||||
if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes.tooltip) {
|
||||
if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes.tooltip || changedAttributes.tabindex) {
|
||||
this.refreshSelf();
|
||||
return true;
|
||||
// If the target tiddler value has changed, just update setting and refresh the children
|
||||
} else {
|
||||
if(changedAttributes.class) {
|
||||
this.selectClass = this.getAttribute("class");
|
||||
this.getSelectDomNode().setAttribute("class",this.selectClass);
|
||||
}
|
||||
|
||||
this.assignAttributes(this.getSelectDomNode(),{
|
||||
changedAttributes: changedAttributes,
|
||||
sourcePrefix: "data-",
|
||||
destPrefix: "data-"
|
||||
});
|
||||
var childrenRefreshed = this.refreshChildren(changedTiddlers);
|
||||
// If the target tiddler value has changed, just update setting and refresh the children
|
||||
if(changedTiddlers[this.selectTitle] || childrenRefreshed) {
|
||||
this.setSelectValue();
|
||||
}
|
||||
|
||||
@@ -41,30 +41,43 @@ TranscludeWidget.prototype.execute = function() {
|
||||
this.collectAttributes();
|
||||
this.collectStringParameters();
|
||||
this.collectSlotFillParameters();
|
||||
// Get the target text and parse tree nodes that we are transcluding
|
||||
var target = this.getTransclusionTarget(),
|
||||
parseTreeNodes;
|
||||
this.sourceText = target.text;
|
||||
this.parserType = target.type;
|
||||
this.parseAsInline = target.parseAsInline;
|
||||
// Determine whether we're being used in inline or block mode
|
||||
var parseAsInline = !this.parseTreeNode.isBlock;
|
||||
if(this.transcludeMode === "inline") {
|
||||
parseAsInline = true;
|
||||
} else if(this.transcludeMode === "block") {
|
||||
parseAsInline = false;
|
||||
}
|
||||
// Set 'thisTiddler'
|
||||
this.setVariable("thisTiddler",this.transcludeTitle);
|
||||
var parseTreeNodes, target;
|
||||
// Process the transclusion according to the output type
|
||||
switch(this.transcludeOutput || "text/html") {
|
||||
case "text/html":
|
||||
// Return the parse tree nodes
|
||||
// Return the parse tree nodes of the target
|
||||
target = this.parseTransclusionTarget(parseAsInline);
|
||||
this.parseAsInline = target.parseAsInline;
|
||||
parseTreeNodes = target.parseTreeNodes;
|
||||
break;
|
||||
case "text/raw":
|
||||
// Just return the raw text
|
||||
parseTreeNodes = [{type: "text", text: this.sourceText}];
|
||||
target = this.getTransclusionTarget();
|
||||
parseTreeNodes = [{type: "text", text: target.text}];
|
||||
break;
|
||||
default:
|
||||
// text/plain
|
||||
var plainText = this.wiki.renderText("text/plain",this.parserType,this.sourceText,{parentWidget: this});
|
||||
parseTreeNodes = [{type: "text", text: plainText}];
|
||||
// "text/plain" is the plain text result of wikifying the text
|
||||
target = this.parseTransclusionTarget(parseAsInline);
|
||||
var widgetNode = this.wiki.makeWidget(target.parser,{
|
||||
parentWidget: this,
|
||||
document: $tw.fakeDocument
|
||||
});
|
||||
var container = $tw.fakeDocument.createElement("div");
|
||||
widgetNode.render(container,null);
|
||||
parseTreeNodes = [{type: "text", text: container.textContent}];
|
||||
break;
|
||||
}
|
||||
this.sourceText = target.text;
|
||||
this.parserType = target.type;
|
||||
// Set the legacy transclusion context variables only if we're not transcluding a variable
|
||||
if(!this.transcludeVariable) {
|
||||
var recursionMarker = this.makeRecursionMarker();
|
||||
@@ -96,6 +109,7 @@ TranscludeWidget.prototype.collectAttributes = function() {
|
||||
this.recursionMarker = this.getAttribute("recursionMarker","yes");
|
||||
} else {
|
||||
this.transcludeVariable = this.getAttribute("$variable");
|
||||
this.transcludeVariableIsFunction = false;
|
||||
this.transcludeType = this.getAttribute("$type");
|
||||
this.transcludeOutput = this.getAttribute("$output","text/html");
|
||||
this.transcludeTitle = this.getAttribute("$tiddler",this.getVariable("currentTiddler"));
|
||||
@@ -161,17 +175,46 @@ TranscludeWidget.prototype.collectSlotFillParameters = function() {
|
||||
};
|
||||
|
||||
/*
|
||||
Get transcluded parse tree nodes as an object {text:,type:,parseTreeNodes:,parseAsInline:}
|
||||
Get transcluded details as an object {text:,type:}
|
||||
*/
|
||||
TranscludeWidget.prototype.getTransclusionTarget = function() {
|
||||
var self = this;
|
||||
// Determine whether we're being used in inline or block mode
|
||||
var parseAsInline = !this.parseTreeNode.isBlock;
|
||||
if(this.transcludeMode === "inline") {
|
||||
parseAsInline = true;
|
||||
} else if(this.transcludeMode === "block") {
|
||||
parseAsInline = false;
|
||||
var text;
|
||||
// Return the text and type of the target
|
||||
if(this.hasAttribute("$variable")) {
|
||||
if(this.transcludeVariable) {
|
||||
// Transcluding a variable
|
||||
var variableInfo = this.getVariableInfo(this.transcludeVariable,{params: this.getOrderedTransclusionParameters()});
|
||||
this.transcludeVariableIsFunction = variableInfo.srcVariable && variableInfo.srcVariable.isFunctionDefinition;
|
||||
text = variableInfo.text;
|
||||
this.transcludeFunctionResult = text;
|
||||
return {
|
||||
text: variableInfo.text,
|
||||
type: this.transcludeType
|
||||
};
|
||||
}
|
||||
} else {
|
||||
// Transcluding a text reference
|
||||
var parserInfo = this.wiki.getTextReferenceParserInfo(
|
||||
this.transcludeTitle,
|
||||
this.transcludeField,
|
||||
this.transcludeIndex,
|
||||
{
|
||||
subTiddler: this.transcludeSubTiddler,
|
||||
defaultType: this.transcludeType
|
||||
});
|
||||
return {
|
||||
text: parserInfo.text,
|
||||
type: parserInfo.type
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
Get transcluded parse tree nodes as an object {text:,type:,parseTreeNodes:,parseAsInline:}
|
||||
*/
|
||||
TranscludeWidget.prototype.parseTransclusionTarget = function(parseAsInline) {
|
||||
var self = this;
|
||||
var parser;
|
||||
// Get the parse tree
|
||||
if(this.hasAttribute("$variable")) {
|
||||
@@ -179,21 +222,24 @@ TranscludeWidget.prototype.getTransclusionTarget = function() {
|
||||
// Transcluding a variable
|
||||
var variableInfo = this.getVariableInfo(this.transcludeVariable,{params: this.getOrderedTransclusionParameters()}),
|
||||
srcVariable = variableInfo && variableInfo.srcVariable;
|
||||
if(srcVariable && srcVariable.isFunctionDefinition) {
|
||||
this.transcludeVariableIsFunction = true;
|
||||
this.transcludeFunctionResult = (variableInfo.resultList ? variableInfo.resultList[0] : variableInfo.text) || "";
|
||||
}
|
||||
if(variableInfo.text) {
|
||||
if(srcVariable && srcVariable.isFunctionDefinition) {
|
||||
var result = (variableInfo.resultList ? variableInfo.resultList[0] : variableInfo.text) || "";
|
||||
parser = {
|
||||
tree: [{
|
||||
type: "text",
|
||||
text: result
|
||||
text: this.transcludeFunctionResult
|
||||
}],
|
||||
source: result,
|
||||
source: this.transcludeFunctionResult,
|
||||
type: "text/vnd.tiddlywiki"
|
||||
};
|
||||
if(parseAsInline) {
|
||||
parser.tree[0] = {
|
||||
type: "text",
|
||||
text: result
|
||||
text: this.transcludeFunctionResult
|
||||
};
|
||||
} else {
|
||||
parser.tree[0] = {
|
||||
@@ -201,7 +247,7 @@ TranscludeWidget.prototype.getTransclusionTarget = function() {
|
||||
tag: "p",
|
||||
children: [{
|
||||
type: "text",
|
||||
text: result
|
||||
text: this.transcludeFunctionResult
|
||||
}]
|
||||
}
|
||||
}
|
||||
@@ -237,7 +283,7 @@ TranscludeWidget.prototype.getTransclusionTarget = function() {
|
||||
}
|
||||
$tw.utils.addAttributeToParseTreeNode(parser.tree[0],name,param["default"])
|
||||
});
|
||||
} else if(srcVariable && (srcVariable.isMacroDefinition || !srcVariable.isFunctionDefinition)) {
|
||||
} else if(srcVariable && !srcVariable.isFunctionDefinition) {
|
||||
// For macros and ordinary variables, wrap the parse tree in a vars widget assigning the parameters to variables named "__paramname__"
|
||||
parser = {
|
||||
tree: [
|
||||
@@ -269,22 +315,13 @@ TranscludeWidget.prototype.getTransclusionTarget = function() {
|
||||
});
|
||||
}
|
||||
// Return the parse tree
|
||||
if(parser) {
|
||||
return {
|
||||
parseTreeNodes: parser.tree,
|
||||
parseAsInline: parseAsInline,
|
||||
text: parser.source,
|
||||
type: parser.type
|
||||
};
|
||||
} else {
|
||||
// If there's no parse tree then return the missing slot value
|
||||
return {
|
||||
parseTreeNodes: (this.slotFillParseTrees["ts-missing"] || []),
|
||||
parseAsInline: parseAsInline,
|
||||
text: null,
|
||||
type: null
|
||||
};
|
||||
}
|
||||
return {
|
||||
parser: parser,
|
||||
parseTreeNodes: parser ? parser.tree : (this.slotFillParseTrees["ts-missing"] || []),
|
||||
parseAsInline: parseAsInline,
|
||||
text: parser && parser.source,
|
||||
type: parser && parser.type
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -321,14 +358,26 @@ TranscludeWidget.prototype.getOrderedTransclusionParameters = function() {
|
||||
};
|
||||
|
||||
/*
|
||||
Fetch the value of a parameter
|
||||
The parameter index indicates is used by internal $parameter widgets to sequentially assign unnamed parameters.
|
||||
*/
|
||||
TranscludeWidget.prototype.getTransclusionParameter = function(name,index,defaultValue) {
|
||||
Object.defineProperty(TranscludeWidget.prototype, 'parameterIndex', {
|
||||
get: function() { return this.claimedIndices || 0; },
|
||||
set: function(value) { this.claimedIndices = value; }
|
||||
});
|
||||
|
||||
/*
|
||||
Fetch the value of a parameter given either its name or index
|
||||
*/
|
||||
TranscludeWidget.prototype.getTransclusionParameter = function(name,defaultValue) {
|
||||
if(name in this.stringParametersByName) {
|
||||
return this.stringParametersByName[name];
|
||||
} else {
|
||||
// Let's see if this name was already assigned an index
|
||||
var index = this.parameterIndex;
|
||||
var name = "" + index;
|
||||
if(name in this.stringParametersByName) {
|
||||
// This parameter now corresponds to this index. No other parameters may correspond to it.
|
||||
this.claimedIndices = index + 1;
|
||||
return this.stringParametersByName[name];
|
||||
}
|
||||
}
|
||||
@@ -399,12 +448,21 @@ TranscludeWidget.prototype.parserNeedsRefresh = function() {
|
||||
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
|
||||
*/
|
||||
TranscludeWidget.prototype.refresh = function(changedTiddlers) {
|
||||
var changedAttributes = this.computeAttributes();
|
||||
if(($tw.utils.count(changedAttributes) > 0) || (!this.transcludeVariable && changedTiddlers[this.transcludeTitle] && this.parserNeedsRefresh())) {
|
||||
// Reset the parameter index so that internal $parameter widgets can double-check their unnamed parameter indices.
|
||||
this.parameterIndex = 0;
|
||||
if(($tw.utils.count(changedAttributes) > 0) || (this.transcludeVariableIsFunction && this.functionNeedsRefresh()) || (!this.transcludeVariable && changedTiddlers[this.transcludeTitle] && this.parserNeedsRefresh())) {
|
||||
this.refreshSelf();
|
||||
return true;
|
||||
} else {
|
||||
|
||||
@@ -153,7 +153,7 @@ Widget.prototype.getVariableInfo = function(name,options) {
|
||||
} else if(variable.isFunctionDefinition) {
|
||||
// Function evaluations
|
||||
params = self.resolveVariableParameters(variable.params,actualParams);
|
||||
var variables = Object.create(null);
|
||||
var variables = options.variables || Object.create(null);
|
||||
// Apply default parameter values
|
||||
$tw.utils.each(variable.params,function(param,index) {
|
||||
if(param["default"]) {
|
||||
@@ -413,16 +413,34 @@ Widget.prototype.getAttribute = function(name,defaultText) {
|
||||
};
|
||||
|
||||
/*
|
||||
Assign the computed attributes of the widget to a domNode
|
||||
Assign the common attributes of the widget to a domNode
|
||||
options include:
|
||||
excludeEventAttributes: ignores attributes whose name begins with "on"
|
||||
sourcePrefix: prefix of attributes that are to be directly assigned (defaults to the empty string meaning all attributes)
|
||||
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) {
|
||||
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) {
|
||||
// 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
|
||||
if(options.excludeEventAttributes && name.substr(0,2) === "on") {
|
||||
if(options.excludeEventAttributes && name.substr(0,2).toLowerCase() === EVENT_ATTRIBUTE_PREFIX) {
|
||||
value = undefined;
|
||||
}
|
||||
if(value !== undefined) {
|
||||
@@ -432,26 +450,24 @@ Widget.prototype.assignAttributes = function(domNode,options) {
|
||||
namespace = "http://www.w3.org/1999/xlink";
|
||||
name = name.substr(6);
|
||||
}
|
||||
// Handle styles
|
||||
if(name.substr(0,6) === "style." && name.length > 6) {
|
||||
domNode.style[$tw.utils.unHyphenateCss(name.substr(6))] = value;
|
||||
} else {
|
||||
// Setting certain attributes can cause a DOM error (eg xmlns on the svg element)
|
||||
try {
|
||||
domNode.setAttributeNS(namespace,name,value);
|
||||
} catch(e) {
|
||||
}
|
||||
// Setting certain attributes can cause a DOM error (eg xmlns on the svg element)
|
||||
try {
|
||||
domNode.setAttributeNS(namespace,name,value);
|
||||
} catch(e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Not all parse tree nodes have the orderedAttributes property
|
||||
};
|
||||
// If the parse tree node has the orderedAttributes property then use that order
|
||||
if(this.parseTreeNode.orderedAttributes) {
|
||||
$tw.utils.each(this.parseTreeNode.orderedAttributes,function(attribute,index) {
|
||||
assignAttribute(attribute.name,self.attributes[attribute.name]);
|
||||
});
|
||||
if(attribute.name in changedAttributes) {
|
||||
assignAttribute(attribute.name,self.getAttribute(attribute.name));
|
||||
}
|
||||
});
|
||||
// Otherwise update each changed attribute irrespective of order
|
||||
} else {
|
||||
$tw.utils.each(Object.keys(self.attributes).sort(),function(name) {
|
||||
assignAttribute(name,self.attributes[name]);
|
||||
$tw.utils.each(changedAttributes,function(value,name) {
|
||||
assignAttribute(name,self.getAttribute(name));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1287,7 +1287,7 @@ exports.search = function(text,options) {
|
||||
console.log("Regexp error parsing /(" + text + ")/" + flags + ": ",e);
|
||||
}
|
||||
} else if(options.some) {
|
||||
terms = text.trim().split(/ +/);
|
||||
terms = text.trim().split(/[^\S\xA0]+/);
|
||||
if(terms.length === 1 && terms[0] === "") {
|
||||
searchTermsRegExps = null;
|
||||
} else {
|
||||
@@ -1298,7 +1298,7 @@ exports.search = function(text,options) {
|
||||
searchTermsRegExps.push(new RegExp("(" + regExpStr + ")",flags));
|
||||
}
|
||||
} else { // default: words
|
||||
terms = text.split(/ +/);
|
||||
terms = text.split(/[^\S\xA0]+/);
|
||||
if(terms.length === 1 && terms[0] === "") {
|
||||
searchTermsRegExps = null;
|
||||
} else {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
title: $:/core/templates/html-json-skinny-tiddler
|
||||
|
||||
<$list filter="[<numTiddlers>compare:number:gteq[1]] ~[<counter>!match[1]]">`,`<$text text=<<newline>>/></$list>
|
||||
<$jsontiddler tiddler=<<currentTiddler>> exclude="text" escapeUnsafeScriptChars="yes"/>
|
||||
<$text text=<<join>>/><$jsontiddler tiddler=<<currentTiddler>> exclude="text" escapeUnsafeScriptChars="yes"/>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
title: $:/core/templates/html-json-tiddler
|
||||
|
||||
<$list filter="[<counter>!match[1]]">`,`<$text text=<<newline>>/></$list><$jsontiddler tiddler=<<currentTiddler>> escapeUnsafeScriptChars="yes"/>
|
||||
<$jsontiddler tiddler=<<currentTiddler>> escapeUnsafeScriptChars="yes"/>
|
||||
@@ -6,14 +6,12 @@ title: $:/core/templates/store.area.template.html
|
||||
<$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 -->
|
||||
`<script class="tiddlywiki-tiddler-store" type="application/json">[`
|
||||
<$vars newline={{{ [charcode[10]] }}}>
|
||||
<$let newline={{{ [charcode[10]] }}} join=`,$(newline)$`>
|
||||
<$text text=<<newline>>/>
|
||||
<$list filter=<<saveTiddlerFilter>> counter="counter" template="$:/core/templates/html-json-tiddler"/>
|
||||
<$vars numTiddlers={{{ [subfilter<saveTiddlerFilter>count[]] }}}>
|
||||
<$list filter={{{ [<skinnySaveTiddlerFilter>] }}} counter="counter" template="$:/core/templates/html-json-skinny-tiddler"/>
|
||||
</$vars>
|
||||
<$list filter=<<saveTiddlerFilter>> join=<<join>> template="$:/core/templates/html-json-tiddler"/>
|
||||
<$list filter="[subfilter<skinnySaveTiddlerFilter>]" template="$:/core/templates/html-json-skinny-tiddler"/>
|
||||
<$text text=<<newline>>/>
|
||||
</$vars>
|
||||
</$let>
|
||||
`]</script>`
|
||||
`<div id="storeArea" style="display:none;">`
|
||||
`</div>`
|
||||
@@ -22,8 +20,8 @@ title: $:/core/templates/store.area.template.html
|
||||
<!-- Old-style DIV/PRE-based store area -->
|
||||
<$reveal type="nomatch" state="$:/isEncrypted" text="yes">
|
||||
`<div id="storeArea" style="display:none;">`
|
||||
<$list filter=<<saveTiddlerFilter>> template="$:/core/templates/html-div-tiddler"/>
|
||||
<$list filter={{{ [<skinnySaveTiddlerFilter>] }}} template="$:/core/templates/html-div-skinny-tiddler"/>
|
||||
<$list filter={{{ [<saveTiddlerFilter>] }}} template="$:/core/templates/html-div-tiddler"/>
|
||||
<$list filter="[subfilter<skinnySaveTiddlerFilter>]" template="$:/core/templates/html-div-skinny-tiddler"/>
|
||||
`</div>`
|
||||
</$reveal>
|
||||
</$list>
|
||||
|
||||
@@ -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="$:/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="$:/DefaultTiddlers"><<lingo DefaultTiddlers/Prompt>></$link> |<<lingo DefaultTiddlers/TopHint>><br> <$edit class="tc-edit-texteditor" tiddler="$:/DefaultTiddlers"/><br>//<<lingo DefaultTiddlers/BottomHint>>// |
|
||||
|<$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="$:/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/Text"><<lingo NewJournal/Text/Prompt>></$link> |<$edit tiddler="$:/config/NewJournal/Text" class="tc-edit-texteditor" default=""/> |
|
||||
|<$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/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/AutoFocus"><<lingo AutoFocus/Prompt>></$link> |{{$:/snippets/minifocusswitcher}} |
|
||||
|
||||
@@ -10,15 +10,17 @@ $:/config/EditorToolbarButtons/Visibility/$(currentTiddler)$
|
||||
|
||||
\whitespace trim
|
||||
<$let
|
||||
edit-preview-state={{{ [{$:/config/ShowEditPreview/PerTiddler}!match[yes]then[$:/state/showeditpreview]] :else[<qualify "$:/state/showeditpreview">] }}}
|
||||
editPreviewStateTiddler={{{ [{$:/config/ShowEditPreview/PerTiddler}!match[yes]then[$:/state/showeditpreview]] :else[<qualify "$:/state/showeditpreview">] }}}
|
||||
importTitle=<<qualify $:/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>> >
|
||||
<$reveal stateTitle=<<edit-preview-state>> type="match" text="yes" tag="div">
|
||||
<div class="tc-tiddler-preview">
|
||||
<div>
|
||||
<div class={{{ [<editPreviewStateTiddler>get[text]match[yes]then[tc-tiddler-preview]else[tc-tiddler-preview-hidden]] [[tc-tiddler-editor]] +[join[ ]] }}}>
|
||||
|
||||
<$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}}>
|
||||
|
||||
<$transclude tiddler={{$:/state/editpreviewtype}} mode="inline">
|
||||
@@ -29,13 +31,12 @@ $:/config/EditorToolbarButtons/Visibility/$(currentTiddler)$
|
||||
|
||||
</div>
|
||||
|
||||
</$list>
|
||||
|
||||
</div>
|
||||
</$reveal>
|
||||
|
||||
<$reveal stateTitle=<<edit-preview-state>> type="nomatch" text="yes" tag="div">
|
||||
</div>
|
||||
|
||||
<$transclude tiddler="$:/core/ui/EditTemplate/body/editor" mode="inline"/>
|
||||
|
||||
</$reveal>
|
||||
</$dropzone>
|
||||
|
||||
</$let>
|
||||
|
||||
@@ -54,7 +54,7 @@ $:/config/EditTemplateFields/Visibility/$(currentField)$
|
||||
\whitespace trim
|
||||
<$vars name={{{ [<newFieldNameTiddler>get[text]] }}}>
|
||||
<$reveal type="nomatch" text="" default=<<name>>>
|
||||
<$button tooltip=<<lingo Fields/Add/Button/Hint>>>
|
||||
<$button tooltip={{$:/language/EditTemplate/Fields/Add/Button/Hint}}>
|
||||
<$action-sendmessage $message="tm-add-field"
|
||||
$name=<<name>>
|
||||
$value={{{ [subfilter<get-field-value-tiddler-filter>get[text]] }}}/>
|
||||
@@ -89,7 +89,7 @@ $value={{{ [subfilter<get-field-value-tiddler-filter>get[text]] }}}/>
|
||||
</td>
|
||||
<td class="tc-edit-field-remove">
|
||||
<$button class="tc-btn-invisible" tooltip={{$:/language/EditTemplate/Field/Remove/Hint}} aria-label={{$:/language/EditTemplate/Field/Remove/Caption}}>
|
||||
<$action-deletefield $field=<<currentField>>/><$set name="currentTiddlerCSSescaped" value={{{ [<currentTiddler>escapecss[]] }}}><$action-sendmessage $message="tm-focus-selector" $param=<<current-tiddler-new-field-selector>>/></$set>
|
||||
<$action-deletefield $field=<<currentField>>/>
|
||||
{{$:/core/images/delete-button}}
|
||||
</$button>
|
||||
</td>
|
||||
|
||||
@@ -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>
|
||||
<div class="tc-type-selector-dropdown-wrapper">
|
||||
<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="[<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="[<typeInputTiddler>] [<storeTitle>] [<refreshTitle>] [<selectionStateTitle>]"/></$button>
|
||||
</$fieldmangler></div>
|
||||
|
||||
<div class="tc-block-dropdown-wrapper">
|
||||
|
||||
@@ -9,11 +9,8 @@ button-classes: tc-text-editor-toolbar-item-start-group
|
||||
shortcuts: ((preview))
|
||||
|
||||
\whitespace trim
|
||||
<$reveal state=<<edit-preview-state>> type="match" text="yes" tag="span">
|
||||
{{$:/core/images/preview-open}}
|
||||
<$action-setfield $tiddler=<<edit-preview-state>> $value="no"/>
|
||||
</$reveal>
|
||||
<$reveal state=<<edit-preview-state>> type="nomatch" text="yes" tag="span">
|
||||
{{$:/core/images/preview-closed}}
|
||||
<$action-setfield $tiddler=<<edit-preview-state>> $value="yes"/>
|
||||
</$reveal>
|
||||
<span>
|
||||
<$transclude $tiddler={{{ [<editPreviewStateTiddler>get[text]match[yes]then[$:/core/images/preview-open]else[$:/core/images/preview-closed]] }}} />
|
||||
</span>
|
||||
<$action-setfield $tiddler=<<editPreviewStateTiddler>> $value={{{ [<editPreviewStateTiddler>get[text]toggle[yes],[no]] }}} />
|
||||
<$action-sendmessage $message="tm-edit-text-operation" $param="focus-editor"/>
|
||||
@@ -20,7 +20,7 @@ code-body: yes
|
||||
|
||||
<$navigator story="$:/StoryList" history="$:/HistoryList" openLinkFromInsideRiver={{$:/config/Navigation/openLinkFromInsideRiver}} openLinkFromOutsideRiver={{$:/config/Navigation/openLinkFromOutsideRiver}} relinkOnRename={{$:/config/RelinkOnRename}}>
|
||||
|
||||
<$dropzone enable=<<tv-enable-drag-and-drop>>>
|
||||
<$dropzone enable=<<tv-enable-drag-and-drop>> class="tc-dropzone tc-page-container-inner">
|
||||
|
||||
<$list filter="[all[shadows+tiddlers]tag[$:/tags/PageTemplate]!has[draft.of]]" variable="listItem">
|
||||
|
||||
|
||||
@@ -4,11 +4,8 @@ tags: $:/tags/ViewTemplate
|
||||
\whitespace trim
|
||||
<$reveal type="nomatch" stateTitle=<<folded-state>> text="hide" tag="div" retain="yes" animate="yes">
|
||||
<div class="tc-subtitle">
|
||||
<$list filter="[all[shadows+tiddlers]tag[$:/tags/ViewTemplate/Subtitle]!has[draft.of]]" variable="subtitleTiddler" counter="indexSubtitleTiddler">
|
||||
<$list filter="[<indexSubtitleTiddler-first>match[no]]" variable="ignore">
|
||||
|
||||
</$list>
|
||||
<$transclude tiddler=<<subtitleTiddler>> mode="inline"/>
|
||||
<$list filter="[all[shadows+tiddlers]tag[$:/tags/ViewTemplate/Subtitle]!has[draft.of]]" variable="subtitleTiddler">
|
||||
<$transclude tiddler=<<subtitleTiddler>> mode="inline"/><$list-join> </$list-join>
|
||||
</$list>
|
||||
</div>
|
||||
</$reveal>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
title: $:/config/OfficialPluginLibrary
|
||||
tags: $:/tags/PluginLibrary
|
||||
url: https://tiddlywiki.com/library/v5.3.1/index.html
|
||||
url: https://tiddlywiki.com/library/v5.3.3/index.html
|
||||
caption: {{$:/language/OfficialPluginLibrary}}
|
||||
|
||||
{{$:/language/OfficialPluginLibrary/Hint}}
|
||||
|
||||
@@ -13,7 +13,7 @@ tags: $:/tags/Macro
|
||||
|
||||
$(colour-picker-update-recent)$
|
||||
|
||||
$actions$
|
||||
<$transclude $variable="__actions__"/>
|
||||
|
||||
<span style="display:inline-block; background-color: $(colour-picker-value)$; width: 100%; height: 100%; border-radius: 50%;"/>
|
||||
|
||||
@@ -23,7 +23,7 @@ $actions$
|
||||
\define colour-picker-recent-inner(actions)
|
||||
\whitespace trim
|
||||
<$set name="colour-picker-value" value="$(recentColour)$">
|
||||
<$macrocall $name="colour-picker-inner" actions="""$actions$"""/>
|
||||
<$macrocall $name="colour-picker-inner" actions=<<__actions__>>/>
|
||||
</$set>
|
||||
\end
|
||||
|
||||
@@ -31,7 +31,7 @@ $actions$
|
||||
\whitespace trim
|
||||
{{$:/language/ColourPicker/Recent}}<$list filter="[list[$:/config/ColourPicker/Recent]]" variable="recentColour">
|
||||
 
|
||||
<$macrocall $name="colour-picker-recent-inner" actions="""$actions$"""/>
|
||||
<$macrocall $name="colour-picker-recent-inner" actions=<<__actions__>>/>
|
||||
</$list>
|
||||
\end
|
||||
|
||||
@@ -39,13 +39,13 @@ $actions$
|
||||
\whitespace trim
|
||||
<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">
|
||||
 
|
||||
<$macrocall $name="colour-picker-inner" actions="""$actions$"""/>
|
||||
<$macrocall $name="colour-picker-inner" actions=<<__actions__>>/>
|
||||
</$list>
|
||||
|
||||
---
|
||||
@@ -54,7 +54,7 @@ $actions$
|
||||
 
|
||||
<$edit-text tiddler="$:/config/ColourPicker/New" type="color" tag="input"/>
|
||||
<$set name="colour-picker-value" value={{$:/config/ColourPicker/New}}>
|
||||
<$macrocall $name="colour-picker-inner" actions="""$actions$"""/>
|
||||
<$macrocall $name="colour-picker-inner" actions=<<__actions__>>/>
|
||||
</$set>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -5,13 +5,13 @@ title: $:/core/macros/image-picker
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
\define image-picker-thumbnail(actions)
|
||||
<$button tag="a" tooltip="""$(imageTitle)$""">$actions$<$transclude tiddler=<<imageTitle>>/></$button>
|
||||
<$button tag="a" tooltip="""$(imageTitle)$"""><$transclude $variable="__actions__"/><$transclude tiddler=<<imageTitle>>/></$button>
|
||||
\end
|
||||
|
||||
\define image-picker-list(filter,actions)
|
||||
\whitespace trim
|
||||
<$list filter="""$filter$""" variable="imageTitle">
|
||||
<$macrocall $name="image-picker-thumbnail" actions="""$actions$"""/>
|
||||
<$macrocall $name="image-picker-thumbnail" actions=<<__actions__>>/>
|
||||
 
|
||||
</$list>
|
||||
\end
|
||||
@@ -25,15 +25,15 @@ type: text/vnd.tiddlywiki
|
||||
{{$:/language/SystemTiddlers/Include/Prompt}}
|
||||
</$checkbox>
|
||||
<$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 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>
|
||||
</$vars>
|
||||
</div>
|
||||
\end
|
||||
|
||||
\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
|
||||
|
||||
@@ -4,17 +4,17 @@ tags: $:/tags/Macro
|
||||
\define list-links(filter,type:"ul",subtype:"li",class:"",emptyMessage,field:"caption")
|
||||
\whitespace trim
|
||||
<$genesis $type=<<__type__>> class=<<__class__>>>
|
||||
<$list filter=<<__filter__>> emptyMessage=<<__emptyMessage__>>>
|
||||
<$genesis $type=<<__subtype__>>>
|
||||
<$link to={{!!title}}>
|
||||
<$let tv-wikilinks="no">
|
||||
<$transclude field=<<__field__>>>
|
||||
<$view field="title"/>
|
||||
</$transclude>
|
||||
</$let>
|
||||
</$link>
|
||||
</$genesis>
|
||||
</$list>
|
||||
<$list filter=<<__filter__>> emptyMessage=<<__emptyMessage__>>>
|
||||
<$genesis $type=<<__subtype__>>>
|
||||
<$link to={{!!title}}>
|
||||
<$let tv-wikilinks="no">
|
||||
<$transclude field=<<__field__>>>
|
||||
<$view field="title"/>
|
||||
</$transclude>
|
||||
</$let>
|
||||
</$link>
|
||||
</$genesis>
|
||||
</$list>
|
||||
</$genesis>
|
||||
\end
|
||||
|
||||
@@ -25,34 +25,42 @@ tags: $:/tags/Macro
|
||||
\define list-links-draggable(tiddler,field:"list",emptyMessage,type:"ul",subtype:"li",class:"",itemTemplate)
|
||||
\whitespace trim
|
||||
<span class="tc-links-draggable-list">
|
||||
<$vars targetTiddler="""$tiddler$""" targetField="""$field$""">
|
||||
<$genesis $type=<<__type__>> class="$class$">
|
||||
<$list filter="[list[$tiddler$!!$field$]]" emptyMessage=<<__emptyMessage__>>>
|
||||
<$droppable actions=<<list-links-draggable-drop-actions>> tag="""$subtype$""" enable=<<tv-enable-drag-and-drop>>>
|
||||
<div class="tc-droppable-placeholder"/>
|
||||
<div>
|
||||
<$transclude tiddler="""$itemTemplate$""">
|
||||
<$link to={{!!title}}>
|
||||
<$let tv-wikilinks="no">
|
||||
<$transclude field="caption">
|
||||
<$view field="title"/>
|
||||
</$transclude>
|
||||
</$let>
|
||||
</$link>
|
||||
</$transclude>
|
||||
</div>
|
||||
</$droppable>
|
||||
</$list>
|
||||
<$tiddler tiddler="">
|
||||
<$droppable actions=<<list-links-draggable-drop-actions>> tag="div" enable=<<tv-enable-drag-and-drop>>>
|
||||
<div class="tc-droppable-placeholder">
|
||||
{{$:/core/images/blank}}
|
||||
</div>
|
||||
<div style="height:0.5em;"/>
|
||||
</$droppable>
|
||||
</$tiddler>
|
||||
</$genesis>
|
||||
</$vars>
|
||||
<$vars targetTiddler="""$tiddler$""" targetField="""$field$""">
|
||||
<$genesis $type=<<__type__>> class="$class$">
|
||||
<$list filter="[list[$tiddler$!!$field$]]" emptyMessage=<<__emptyMessage__>>>
|
||||
<$droppable
|
||||
actions=<<list-links-draggable-drop-actions>>
|
||||
tag="""$subtype$"""
|
||||
enable=<<tv-enable-drag-and-drop>>
|
||||
>
|
||||
<div class="tc-droppable-placeholder"/>
|
||||
<div>
|
||||
<$transclude tiddler="""$itemTemplate$""">
|
||||
<$link to={{!!title}}>
|
||||
<$let tv-wikilinks="no">
|
||||
<$transclude field="caption">
|
||||
<$view field="title"/>
|
||||
</$transclude>
|
||||
</$let>
|
||||
</$link>
|
||||
</$transclude>
|
||||
</div>
|
||||
</$droppable>
|
||||
</$list>
|
||||
<$tiddler tiddler="">
|
||||
<$droppable
|
||||
actions=<<list-links-draggable-drop-actions>>
|
||||
tag="div"
|
||||
enable=<<tv-enable-drag-and-drop>>
|
||||
>
|
||||
<div class="tc-droppable-placeholder">
|
||||
{{$:/core/images/blank}}
|
||||
</div>
|
||||
<div style="height:0.5em;"/>
|
||||
</$droppable>
|
||||
</$tiddler>
|
||||
</$genesis>
|
||||
</$vars>
|
||||
</span>
|
||||
\end
|
||||
|
||||
@@ -60,50 +68,59 @@ tags: $:/tags/Macro
|
||||
\whitespace trim
|
||||
<!-- Save the current ordering of the tiddlers with this tag -->
|
||||
<$set name="order" filter="[<__tag__>tagging[]]">
|
||||
<!-- Remove any list-after or list-before fields from the tiddlers with this tag -->
|
||||
<$list filter="[<__tag__>tagging[]]">
|
||||
<$action-deletefield $field="list-before"/>
|
||||
<$action-deletefield $field="list-after"/>
|
||||
</$list>
|
||||
<!-- Save the new order to the Tag Tiddler -->
|
||||
<$action-listops $tiddler=<<__tag__>> $field="list" $filter="+[enlist<order>] +[insertbefore<actionTiddler>,<currentTiddler>]"/>
|
||||
<!-- Make sure the newly added item has the right tag -->
|
||||
<!-- Removing this line makes dragging tags within the dropdown work as intended -->
|
||||
<!--<$action-listops $tiddler=<<actionTiddler>> $tags=<<__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__>]">
|
||||
<$fieldmangler tiddler=<<actionTiddler>>>
|
||||
<$action-sendmessage $message="tm-add-tag" $param=<<__tag__>>/>
|
||||
</$fieldmangler>
|
||||
</$list>
|
||||
<!-- Remove any list-after or list-before fields from the tiddlers with this tag -->
|
||||
<$list filter="[<__tag__>tagging[]]">
|
||||
<$action-deletefield $field="list-before"/>
|
||||
<$action-deletefield $field="list-after"/>
|
||||
</$list>
|
||||
<!-- Save the new order to the Tag Tiddler -->
|
||||
<$action-listops $tiddler=<<__tag__>> $field="list" $filter="+[enlist<order>] +[insertbefore<actionTiddler>,<currentTiddler>]"/>
|
||||
<!-- Make sure the newly added item has the right tag -->
|
||||
<!-- Removing this line makes dragging tags within the dropdown work as intended -->
|
||||
<!--<$action-listops $tiddler=<<actionTiddler>> $tags=<<__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__>]">
|
||||
<$fieldmangler tiddler=<<actionTiddler>>>
|
||||
<$action-sendmessage $message="tm-add-tag" $param=<<__tag__>>/>
|
||||
</$fieldmangler>
|
||||
</$list>
|
||||
</$set>
|
||||
\end
|
||||
|
||||
\define list-tagged-draggable(tag,subFilter,emptyMessage,itemTemplate,elementTag:"div",storyview:"")
|
||||
\whitespace trim
|
||||
<span class="tc-tagged-draggable-list">
|
||||
<$set name="tag" value=<<__tag__>>>
|
||||
<$list filter="[<__tag__>tagging[]$subFilter$]" emptyMessage=<<__emptyMessage__>> storyview=<<__storyview__>>>
|
||||
<$genesis $type=<<__elementTag__>> class="tc-menu-list-item">
|
||||
<$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__>>>
|
||||
<$transclude tiddler="""$itemTemplate$""">
|
||||
<$link to={{!!title}}>
|
||||
<$view field="title"/>
|
||||
</$link>
|
||||
</$transclude>
|
||||
</$genesis>
|
||||
</$droppable>
|
||||
</$genesis>
|
||||
</$list>
|
||||
<$tiddler tiddler="">
|
||||
<$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;">
|
||||
</$genesis>
|
||||
</$droppable>
|
||||
</$tiddler>
|
||||
</$set>
|
||||
<$set name="tag" value=<<__tag__>>>
|
||||
<$list
|
||||
filter="[<__tag__>tagging[]$subFilter$]"
|
||||
emptyMessage=<<__emptyMessage__>>
|
||||
storyview=<<__storyview__>>
|
||||
>
|
||||
<$genesis $type=<<__elementTag__>> class="tc-menu-list-item">
|
||||
<$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__>>>
|
||||
<$transclude tiddler="""$itemTemplate$""">
|
||||
<$link to={{!!title}}>
|
||||
<$view field="title"/>
|
||||
</$link>
|
||||
</$transclude>
|
||||
</$genesis>
|
||||
</$droppable>
|
||||
</$genesis>
|
||||
</$list>
|
||||
<$tiddler tiddler="">
|
||||
<$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>
|
||||
\end
|
||||
|
||||
@@ -4,7 +4,15 @@ code-body: yes
|
||||
|
||||
\define tabs-button()
|
||||
\whitespace trim
|
||||
<$button set=<<tabsState>> setTo=<<currentTab>> default=<<__default__>> selectedClass="tc-tab-selected" tooltip={{!!tooltip}} role="switch">
|
||||
<$button
|
||||
set=<<tabsState>>
|
||||
setTo=<<currentTab>>
|
||||
default=<<__default__>>
|
||||
selectedClass="tc-tab-selected"
|
||||
tooltip={{!!tooltip}}
|
||||
role="switch"
|
||||
data-tab-title=<<currentTab>>
|
||||
>
|
||||
<$tiddler tiddler=<<save-currentTiddler>>>
|
||||
<$set name="tv-wikilinks" value="no">
|
||||
<$transclude tiddler=<<__buttonTemplate__>> mode="inline">
|
||||
|
||||
@@ -16,7 +16,7 @@ second-search-filter: [tags[]is[system]search:title<userInput>sort[]]
|
||||
emptyMessage="<$action-listops $tiddler=<<saveTiddler>> $field=<<__tagField__>> $subfilter='-[<tag>]'/>"
|
||||
>
|
||||
<$action-listops $tiddler=<<saveTiddler>> $field=<<__tagField__>> $subfilter="[<tag>trim[]]"/>
|
||||
$actions$
|
||||
<$transclude $variable="__actions__"/>
|
||||
</$list>
|
||||
</$set>
|
||||
<<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]] }}}>
|
||||
<$button set=<<newTagNameTiddler>> setTo="" class="">
|
||||
<$action-listops $tiddler=<<saveTiddler>> $field=<<__tagField__>> $subfilter="[<tag>trim[]]"/>
|
||||
$actions$
|
||||
<$transclude $variable="__actions__"/>
|
||||
<$set name="currentTiddlerCSSEscaped" value={{{ [<saveTiddler>escapecss[]] }}}>
|
||||
<<delete-tag-state-tiddlers>><$action-sendmessage $message="tm-focus-selector" $param=<<get-tagpicker-focus-selector>>/>
|
||||
</$set>
|
||||
|
||||
@@ -10,7 +10,7 @@ color:$(foregroundColor)$;
|
||||
<!-- This has no whitespace trim to avoid modifying $actions$. Closing tags omitted for brevity. -->
|
||||
\define tag-pill-inner(tag,icon,colour,fallbackTarget,colourA,colourB,element-tag,element-attributes,actions)
|
||||
\whitespace trim
|
||||
<$vars
|
||||
<$let
|
||||
foregroundColor=<<contrastcolour target:"""$colour$""" fallbackTarget:"""$fallbackTarget$""" colourA:"""$colourA$""" colourB:"""$colourB$""">>
|
||||
backgroundColor=<<__colour__>>
|
||||
>
|
||||
@@ -23,6 +23,7 @@ color:$(foregroundColor)$;
|
||||
<$transclude tiddler=<<__icon__>>/>
|
||||
<$view tiddler=<<__tag__>> field="title" format="text" />
|
||||
</$element-tag$>
|
||||
</$let>
|
||||
\end
|
||||
|
||||
\define tag-pill-body(tag,icon,colour,palette,element-tag,element-attributes,actions)
|
||||
|
||||
@@ -118,7 +118,7 @@ tags: $:/tags/Macro
|
||||
<$set name="toc-item-class" filter=<<__itemClassFilter__>> emptyValue="toc-item-selected" value="toc-item" >
|
||||
<li class=<<toc-item-class>>>
|
||||
<$link to={{{ [<currentTiddler>get[target]else<currentTiddler>] }}}>
|
||||
<$list filter="[all[current]tagging[]$sort$limit[1]]" variable="ignore" emptyMessage="<$button class='tc-btn-invisible'>{{$:/core/images/blank}}</$button>">
|
||||
<$list filter="[all[current]tagging[]$sort$limit[1]] -[subfilter<__exclude__>]" variable="ignore" emptyMessage="<$button class='tc-btn-invisible'>{{$:/core/images/blank}}</$button>">
|
||||
<$reveal type="nomatch" stateTitle=<<toc-state>> text="open">
|
||||
<$button setTitle=<<toc-state>> setTo="open" class="tc-btn-invisible tc-popup-keep">
|
||||
<$transclude tiddler=<<toc-closed-icon>> />
|
||||
@@ -145,7 +145,7 @@ tags: $:/tags/Macro
|
||||
<$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">
|
||||
<li class=<<toc-item-class>>>
|
||||
<$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>""">
|
||||
<$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>""">
|
||||
<$reveal type="nomatch" stateTitle=<<toc-state>> text="open">
|
||||
<$button setTitle=<<toc-state>> setTo="open" class="tc-btn-invisible tc-popup-keep">
|
||||
<$transclude tiddler=<<toc-closed-icon>> />
|
||||
|
||||
|
Before Width: | Height: | Size: 6.4 KiB |
BIN
editions/de-AT-server/tiddlers/system/favicon.png
Normal file
|
After Width: | Height: | Size: 5.6 KiB |
@@ -1,2 +1,2 @@
|
||||
title: $:/favicon.ico
|
||||
type: image/x-icon
|
||||
type: image/png
|
||||
@@ -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.
|
||||
|
||||
<div style="font-size:0.7em;text-align:center;margin-top:3em;margin-bottom:3em;">
|
||||
<a href="http://groups.google.com/group/TiddlyWiki" class="tc-btn-big-green" style="background-color:#FF8C19;" target="_blank">
|
||||
{{$:/core/images/mail}} ~TiddlyWiki Mailing List
|
||||
<a href="https://talk.tiddlywiki.org/" class="tc-btn-big-green" style="background-color:#FF8C19;" target="_blank">
|
||||
{{$:/core/images/help}} ~TiddlyWiki Forum
|
||||
</a>
|
||||
<a href="https://twitter.com/TiddlyWiki" class="tc-btn-big-green" style="background-color:#5E9FCA;" target="_blank">
|
||||
{{$:/core/images/twitter}} @~TiddlyWiki on Twitter
|
||||
|
||||
@@ -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.
|
||||
|
||||
* [[tiddlywiki.com/dev|https://tiddlywiki.com/dev]] Offizielle Entwickler Doku.
|
||||
* [[TiddlyWikiDev group|http://groups.google.com/group/TiddlyWikiDev]] Google Diskussionsforum für Entwickler.
|
||||
* [[TiddlyWikiDev group|https://talk.tiddlywiki.org/c/devs/]] Diskussionsforum für Entwickler.
|
||||
* https://github.com/Jermolene/TiddlyWiki5 .. Github Repository.
|
||||
|
||||
|
Before Width: | Height: | Size: 6.4 KiB |
BIN
editions/dev/tiddlers/images/favicon.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
@@ -1,2 +1,2 @@
|
||||
title: $:/favicon.ico
|
||||
type: image/x-icon
|
||||
type: image/png
|
||||
@@ -1,9 +1,14 @@
|
||||
created: 20141122200310516
|
||||
modified: 20201213161842776
|
||||
modified: 20230923031318421
|
||||
tags: Mechanisms
|
||||
title: HookMechanism
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
The hook mechanism provides a way for plugins to intercept and modify default functionality. Hooks are added as follows:
|
||||
The hook mechanism provides a way for plugins to intercept and modify default functionality.
|
||||
|
||||
!! Add a hook
|
||||
|
||||
Hooks are added as follows:
|
||||
|
||||
```js
|
||||
/*
|
||||
@@ -13,6 +18,8 @@ handler: function to be called when hook is invoked
|
||||
$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...)`
|
||||
|
||||
* ''value'': an optional value that is to be transformed by the hook function
|
||||
@@ -20,11 +27,29 @@ 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''.
|
||||
|
||||
!!! 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.
|
||||
|
||||
Note that the ''value'' passed to the subsequent hook function will be the return value of the previous hook function.
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
!!! 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
|
||||
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
"empty": [
|
||||
"--render","$:/core/save/all","empty.html","text/plain",
|
||||
"--render","$:/core/save/all","empty.hta","text/plain"],
|
||||
"emptyexternalcore": [
|
||||
"--render","$:/core/save/offline-external-js","empty-external-core.html","text/plain",
|
||||
"--render","$:/core/templates/tiddlywiki5.js","[[tiddlywikicore-]addsuffix<version>addsuffix[.js]]","text/plain"],
|
||||
"externalimages": [
|
||||
"--savetiddlers","[is[image]]","images",
|
||||
"--setfield","[is[image]]","_canonical_uri","$:/core/templates/canonical-uri-external-image","text/plain",
|
||||
@@ -20,7 +23,7 @@
|
||||
"static": [
|
||||
"--render","$:/core/templates/static.template.html","static.html","text/plain",
|
||||
"--render","$:/core/templates/alltiddlers.template.html","alltiddlers.html","text/plain",
|
||||
"--render","[!is[system]]","[encodeuricomponent[]addprefix[static/]addsuffix[.html]]","text/plain",
|
||||
"--render","[!is[system]]","[encodeuricomponent[]addprefix[static/]addsuffix[.html]]","text/plain","$:/core/templates/static.tiddler.html",
|
||||
"--render","$:/core/templates/static.template.css","static/static.css","text/plain"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 6.4 KiB |
BIN
editions/es-ES-server/tiddlers/system/favicon.png
Normal file
|
After Width: | Height: | Size: 5.6 KiB |
@@ -1,2 +1,2 @@
|
||||
title: $:/favicon.ico
|
||||
type: image/x-icon
|
||||
type: image/png
|
||||
@@ -12,7 +12,9 @@ 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.
|
||||
|
||||
!!Usuarios
|
||||
!! Usuarios
|
||||
|
||||
[[Foro oficial de TiddlyWiki| https://talk.tiddlywiki.org/]]
|
||||
|
||||
[[Grupo principal de TiddlyWiki| http://groups.google.com/group/TiddlyWiki]]
|
||||
|
||||
@@ -25,10 +27,7 @@ o síguenos [[en Twitter|http://twitter.com/TiddlyWiki]] si quieres recibir las
|
||||
|
||||
!! Desarrolladores
|
||||
|
||||
[[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.
|
||||
[[Foro de desarrollo de TiddlyWiki|https://talk.tiddlywiki.org/c/devs]]
|
||||
|
||||
Accede a nuestra [[página de desarrollo|https://github.com/Jermolene/TiddlyWiki5]] en GitHub y haz tu contribución.
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
<div style="font-size:0.7em;text-align:center;margin-top:3em;margin-bottom:3em;">
|
||||
<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}} ~TiddlyWiki en Google Groups
|
||||
<a href="https://talk.tiddlywiki.org/" class="tc-btn-big-green" style="background-color:#FF8C19;" target="_blank" rel="noopener noreferrer">
|
||||
{{$:/core/images/mail}} Foro oficial de ~TiddlyWiki
|
||||
</a>
|
||||
<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
|
||||
|
||||
@@ -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 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]].
|
||||
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/]].
|
||||
|
||||
Por el mismo motivo, se aconseja el uso de acentos graves <code>`...`</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.
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 6.4 KiB |
BIN
editions/es-ES/tiddlers/images/favicon.png
Normal file
|
After Width: | Height: | Size: 5.6 KiB |
@@ -1,2 +1,2 @@
|
||||
title: $:/favicon.ico
|
||||
type: image/x-icon
|
||||
type: image/png
|
||||
|
Before Width: | Height: | Size: 6.4 KiB |
BIN
editions/es-ES/tiddlers/images/green_favicon.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
@@ -1,2 +1,2 @@
|
||||
title: $:/green_favicon.ico
|
||||
type: image/x-icon
|
||||
type: image/png
|
||||
|
Before Width: | Height: | Size: 6.4 KiB |
@@ -1,2 +0,0 @@
|
||||
title: $:/favicon.ico
|
||||
type: image/x-icon
|
||||
BIN
editions/fr-FR-server/tiddlers/system/favicon.png
Normal file
|
After Width: | Height: | Size: 5.6 KiB |
2
editions/fr-FR-server/tiddlers/system/favicon.png.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
title: $:/favicon.ico
|
||||
type: image/png
|
||||
|
Before Width: | Height: | Size: 6.4 KiB |
@@ -1,2 +0,0 @@
|
||||
title: $:/favicon.ico
|
||||
type: image/x-icon
|
||||
BIN
editions/fr-FR/tiddlers/images/favicon.png
Normal file
|
After Width: | Height: | Size: 5.6 KiB |
2
editions/fr-FR/tiddlers/images/favicon.png.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
title: $:/favicon.ico
|
||||
type: image/png
|
||||
|
Before Width: | Height: | Size: 6.4 KiB |
BIN
editions/fr-FR/tiddlers/images/green_favicon.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
@@ -1,2 +1,2 @@
|
||||
title: $:/green_favicon.ico
|
||||
type: image/x-icon
|
||||
type: image/png
|
||||