1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2026-01-25 12:23:42 +00:00

Compare commits

..

4 Commits

Author SHA1 Message Date
jeremy@jermolene.com
b187819a34 Remove test configuration 2023-06-22 08:46:40 +01:00
jeremy@jermolene.com
2b19bbac47 Temporarily add Google Analytics tracking to tw5.com
So that we can test everything is working with the Vercel preview
2023-06-19 11:56:26 +01:00
jeremy@jermolene.com
c0720d8fae Fix typo 2023-06-19 11:55:54 +01:00
jeremy@jermolene.com
f195bfa9f2 Adopt Google Analytics 4 tag code 2023-06-19 11:40:43 +01:00
446 changed files with 932 additions and 4877 deletions

View File

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

4
.gitignore vendored
View File

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

View File

@@ -5,7 +5,7 @@
# Default to the current version number for building the plugin library # Default to the current version number for building the plugin library
if [ -z "$TW5_BUILD_VERSION" ]; then if [ -z "$TW5_BUILD_VERSION" ]; then
TW5_BUILD_VERSION=v5.3.2 TW5_BUILD_VERSION=v5.3.0
fi fi
echo "Using TW5_BUILD_VERSION as [$TW5_BUILD_VERSION]" echo "Using TW5_BUILD_VERSION as [$TW5_BUILD_VERSION]"
@@ -104,15 +104,13 @@ node $TW5_BUILD_TIDDLYWIKI \
--build favicon static index \ --build favicon static index \
|| exit 1 || exit 1
# /empty.html Empty # /empty.html Empty
# /empty.hta For Internet Explorer # /empty.hta For Internet Explorer
# /empty-external-core.html External core empty
# /tiddlywikicore-<version>.js Core plugin javascript
node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \
./editions/empty \ $TW5_BUILD_MAIN_EDITION \
--verbose \ --verbose \
--output $TW5_BUILD_OUTPUT \ --output $TW5_BUILD_OUTPUT \
--build empty emptyexternalcore \ --build empty \
|| exit 1 || exit 1

View File

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

View File

@@ -575,8 +575,9 @@ var globalCheck =[
" configurable: true", " configurable: true",
" });", " });",
" if(Object.keys(__temp__).length){", " if(Object.keys(__temp__).length){",
" console.log(\"Warning: Global assignment detected\",Object.keys(__temp__));", " console.log(Object.keys(__temp__));",
" delete Object.prototype.__temp__;", " delete Object.prototype.__temp__;",
" throw \"Global assignment is not allowed within modules on node.\";",
" }", " }",
" delete Object.prototype.__temp__;", " delete Object.prototype.__temp__;",
].join('\n'); ].join('\n');
@@ -595,11 +596,11 @@ $tw.utils.evalGlobal = function(code,context,filename,sandbox,allowGlobals) {
// Add the code prologue and epilogue // Add the code prologue and epilogue
code = [ code = [
"(function(" + contextNames.join(",") + ") {", "(function(" + contextNames.join(",") + ") {",
" (function(){" + code + "\n;})();\n", " (function(){\n" + code + "\n;})();",
(!$tw.browser && sandbox && !allowGlobals) ? globalCheck : "", (!$tw.browser && sandbox && !allowGlobals) ? globalCheck : "",
"\nreturn exports;\n", " return exports;\n",
"})" "})"
].join(""); ].join("\n");
// Compile the code into a function // Compile the code into a function
var fn; var fn;
@@ -925,7 +926,7 @@ $tw.modules.execute = function(moduleName,moduleRoot) {
} }
} else { } else {
// line number should be included in e.stack for runtime errors // line number should be included in e.stack for runtime errors
$tw.utils.error("Error executing boot module " + name + ": " + String(e) + "\n\n" + e.stack); $tw.utils.error("Error executing boot module " + name + ": " + JSON.stringify(e) + "\n\n" + e.stack);
} }
} }
} }
@@ -1149,7 +1150,7 @@ $tw.Wiki = function(options) {
shadowTiddlerTitles = null, shadowTiddlerTitles = null,
getShadowTiddlerTitles = function() { getShadowTiddlerTitles = function() {
if(!shadowTiddlerTitles) { if(!shadowTiddlerTitles) {
shadowTiddlerTitles = Object.keys(shadowTiddlers).sort(function(a,b) {return a.localeCompare(b);}); shadowTiddlerTitles = Object.keys(shadowTiddlers);
} }
return shadowTiddlerTitles; return shadowTiddlerTitles;
}, },
@@ -2674,18 +2675,6 @@ $tw.hooks.addHook = function(hookName,definition) {
} }
}; };
/*
Delete hooks from the hashmap
*/
$tw.hooks.removeHook = function(hookName,definition) {
if($tw.utils.hop($tw.hooks.names,hookName)) {
var p = $tw.hooks.names[hookName].indexOf(definition);
if(p !== -1) {
$tw.hooks.names[hookName].splice(p, 1);
}
}
};
/* /*
Invoke the hook by key Invoke the hook by key
*/ */

View File

@@ -1,4 +1,6 @@
title: $:/core/images/new-journal-button title: $:/core/images/new-journal-button
tags: $:/tags/Image tags: $:/tags/Image
<$parameters size="22pt" day=<<now "DD">>><svg width=<<size>> height=<<size>> class="tc-image-new-journal-button tc-image-button" viewBox="0 0 128 128"><g fill-rule="evenodd"><path d="M102.545 112.818v11.818c0 1.306 1.086 2.364 2.425 2.364h6.06c1.34 0 2.425-1.058 2.425-2.364v-11.818h12.12c1.34 0 2.425-1.058 2.425-2.363v-5.91c0-1.305-1.085-2.363-2.424-2.363h-12.121V90.364c0-1.306-1.086-2.364-2.425-2.364h-6.06c-1.34 0-2.425 1.058-2.425 2.364v11.818h-12.12c-1.34 0-2.425 1.058-2.425 2.363v5.91c0 1.305 1.085 2.363 2.424 2.363h12.121zM60.016 4.965c-4.781-2.76-10.897-1.118-13.656 3.66L5.553 79.305A9.993 9.993 0 009.21 92.963l51.04 29.468c4.78 2.76 10.897 1.118 13.655-3.66l40.808-70.681a9.993 9.993 0 00-3.658-13.656L60.016 4.965zm-3.567 27.963a6 6 0 106-10.393 6 6 0 00-6 10.393zm31.697 17.928a6 6 0 106-10.392 6 6 0 00-6 10.392z"/><text class="tc-fill-background" font-family="Helvetica" font-size="47.172" font-weight="bold" transform="rotate(30 25.742 95.82)"><tspan x="42" y="77.485" text-anchor="middle"><$text text=<<day>>/></tspan></text></g></svg></$parameters> <$parameters size="22pt" day=<<now "DD">>>
<svg width=<<size>> height=<<size>> class="tc-image-new-journal-button tc-image-button" viewBox="0 0 128 128"><g fill-rule="evenodd"><path d="M102.545 112.818v11.818c0 1.306 1.086 2.364 2.425 2.364h6.06c1.34 0 2.425-1.058 2.425-2.364v-11.818h12.12c1.34 0 2.425-1.058 2.425-2.363v-5.91c0-1.305-1.085-2.363-2.424-2.363h-12.121V90.364c0-1.306-1.086-2.364-2.425-2.364h-6.06c-1.34 0-2.425 1.058-2.425 2.364v11.818h-12.12c-1.34 0-2.425 1.058-2.425 2.363v5.91c0 1.305 1.085 2.363 2.424 2.363h12.121zM60.016 4.965c-4.781-2.76-10.897-1.118-13.656 3.66L5.553 79.305A9.993 9.993 0 009.21 92.963l51.04 29.468c4.78 2.76 10.897 1.118 13.655-3.66l40.808-70.681a9.993 9.993 0 00-3.658-13.656L60.016 4.965zm-3.567 27.963a6 6 0 106-10.393 6 6 0 00-6 10.393zm31.697 17.928a6 6 0 106-10.392 6 6 0 00-6 10.392z"/><text class="tc-fill-background" font-family="Helvetica" font-size="47.172" font-weight="bold" transform="rotate(30 25.742 95.82)"><tspan x="42" y="77.485" text-anchor="middle"><$text text=<<day>>/></tspan></text></g></svg>
</$parameters>

View File

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

View File

@@ -4,7 +4,7 @@ description: Saves a wiki to a new wiki folder
<<.from-version "5.1.20">> Saves the current wiki as a wiki folder, including tiddlers, plugins and configuration: <<.from-version "5.1.20">> Saves the current wiki as a wiki folder, including tiddlers, plugins and configuration:
``` ```
--savewikifolder <wikifolderpath> [<filter>] [ [<name>=<value>] ]* --savewikifolder <wikifolderpath> [<filter>]
``` ```
* The target wiki folder must be empty or non-existent * The target wiki folder must be empty or non-existent
@@ -12,23 +12,8 @@ description: Saves a wiki to a new wiki folder
* Plugins from the official plugin library are replaced with references to those plugins in the `tiddlywiki.info` file * Plugins from the official plugin library are replaced with references to those plugins in the `tiddlywiki.info` file
* Custom plugins are unpacked into their own folder * Custom plugins are unpacked into their own folder
The following options are supported:
* ''filter'': a filter expression that defines the tiddlers to include in the output.
* ''explodePlugins'': defaults to "yes"
** ''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 exact same original wiki. The difference lies in how plugins are represented in the wiki folder.
A common usage is to convert a TiddlyWiki HTML file into a wiki folder: A common usage is to convert a TiddlyWiki HTML file into a wiki folder:
``` ```
tiddlywiki --load ./mywiki.html --savewikifolder ./mywikifolder tiddlywiki --load ./mywiki.html --savewikifolder ./mywikifolder
``` ```
Save the plugin to the tiddlers directory of the target wiki folder:
```
tiddlywiki --load ./mywiki.html --savewikifolder ./mywikifolder explodePlugins=no
```

View File

@@ -1,5 +1,5 @@
title: $:/language/Help/server title: $:/language/Help/server
description: (deprecated: see 'listen' command) Provides an HTTP server interface to TiddlyWiki description: Provides an HTTP server interface to TiddlyWiki (deprecated in favour of the new listen command)
Legacy command to serve a wiki over HTTP. Legacy command to serve a wiki over HTTP.

View File

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

View File

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

View File

@@ -1,46 +0,0 @@
/*\
title: $:/core/modules/commands/jsrepl.js
type: application/javascript
module-type: command
Command to launch node.js REPL with access to $tw
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.info = {
name: "jsrepl",
synchronous: true
};
var Command = function(params,commander,callback) {
var self = this;
this.params = params;
this.commander = commander;
this.callback = callback;
};
Command.prototype.execute = function() {
var self = this;
var repl = require("repl");
this.runtime = repl.start({
prompt: this.params.length ? this.params[0] : "$tw-jsrepl> ",
useColors: true,
ignoreUndefined: true
});
// If REPL is reset (.clear) - context needs resetting
this.runtime.on("reset", function() {
self.runtime.context.$tw = $tw;
});
// Initial context settings
this.runtime.context.$tw = $tw;
return null;
};
exports.Command = Command;
})();

View File

@@ -5,14 +5,7 @@ module-type: command
Command to save the current wiki as a wiki folder Command to save the current wiki as a wiki folder
--savewikifolder <wikifolderpath> [ [<name>=<value>] ]* --savewikifolder <wikifolderpath> [<filter>]
The following options are supported:
* ''filter'': a filter expression defining the tiddlers to be included in the output
* ''explodePlugins'': set to "no" to suppress exploding plugins into their constituent shadow tiddlers (defaults to "yes")
Supports backward compatibility with --savewikifolder <wikifolderpath> [<filter>] [ [<name>=<value>] ]*
\*/ \*/
(function(){ (function(){
@@ -42,28 +35,14 @@ Command.prototype.execute = function() {
if(this.params.length < 1) { if(this.params.length < 1) {
return "Missing wiki folder path"; return "Missing wiki folder path";
} }
var regFilter = /^[a-zA-Z0-9\.\-_]+=/g, // dynamic parameters var wikifoldermaker = new WikiFolderMaker(this.params[0],this.params[1],this.commander);
namedParames,
tiddlerFilter,
options = {};
if (regFilter.test(this.params[1])) {
namedParames = this.commander.extractNamedParameters(this.params.slice(1));
tiddlerFilter = namedParames.filter || "[all[tiddlers]]";
} else {
namedParames = this.commander.extractNamedParameters(this.params.slice(2));
tiddlerFilter = this.params[1];
}
tiddlerFilter = tiddlerFilter || "[all[tiddlers]]";
options.explodePlugins = namedParames.explodePlugins || "yes";
var wikifoldermaker = new WikiFolderMaker(this.params[0],tiddlerFilter,this.commander,options);
return wikifoldermaker.save(); return wikifoldermaker.save();
}; };
function WikiFolderMaker(wikiFolderPath,wikiFilter,commander,options) { function WikiFolderMaker(wikiFolderPath,wikiFilter,commander) {
this.wikiFolderPath = wikiFolderPath; this.wikiFolderPath = wikiFolderPath;
this.wikiFilter = wikiFilter; this.wikiFilter = wikiFilter || "[all[tiddlers]]";
this.commander = commander; this.commander = commander;
this.explodePlugins = options.explodePlugins;
this.wiki = commander.wiki; this.wiki = commander.wiki;
this.savedPaths = []; // So that we can detect filename clashes this.savedPaths = []; // So that we can detect filename clashes
} }
@@ -114,13 +93,10 @@ WikiFolderMaker.prototype.save = function() {
self.log("Adding built-in plugin: " + libraryDetails.name); self.log("Adding built-in plugin: " + libraryDetails.name);
newWikiInfo[libraryDetails.type] = newWikiInfo[libraryDetails.type] || []; newWikiInfo[libraryDetails.type] = newWikiInfo[libraryDetails.type] || [];
$tw.utils.pushTop(newWikiInfo[libraryDetails.type],libraryDetails.name); $tw.utils.pushTop(newWikiInfo[libraryDetails.type],libraryDetails.name);
} else if(self.explodePlugins !== "no") { } else {
// A custom plugin // A custom plugin
self.log("Processing custom plugin: " + title); self.log("Processing custom plugin: " + title);
self.saveCustomPlugin(tiddler); self.saveCustomPlugin(tiddler);
} else if(self.explodePlugins === "no") {
self.log("Processing custom plugin to tiddlders folder: " + title);
self.saveTiddler("tiddlers", tiddler);
} }
} else { } else {
// Ordinary tiddler // Ordinary tiddler

View File

@@ -60,7 +60,7 @@ function FramedEngine(options) {
this.domNode.value = this.value; this.domNode.value = this.value;
} }
// Set the attributes // Set the attributes
if(this.widget.editType && this.widget.editTag !== "textarea") { if(this.widget.editType) {
this.domNode.setAttribute("type",this.widget.editType); this.domNode.setAttribute("type",this.widget.editType);
} }
if(this.widget.editPlaceholder) { if(this.widget.editPlaceholder) {
@@ -72,6 +72,9 @@ function FramedEngine(options) {
if(this.widget.editRows) { if(this.widget.editRows) {
this.domNode.setAttribute("rows",this.widget.editRows); this.domNode.setAttribute("rows",this.widget.editRows);
} }
if(this.widget.editDir) {
this.domNode.setAttribute("dir",this.widget.editDir);
}
if(this.widget.editTabIndex) { if(this.widget.editTabIndex) {
this.iframeNode.setAttribute("tabindex",this.widget.editTabIndex); this.iframeNode.setAttribute("tabindex",this.widget.editTabIndex);
} }
@@ -120,6 +123,7 @@ FramedEngine.prototype.copyStyles = function() {
this.domNode.style["-webkit-text-fill-color"] = "currentcolor"; this.domNode.style["-webkit-text-fill-color"] = "currentcolor";
// Ensure we don't force text direction to LTR // Ensure we don't force text direction to LTR
this.domNode.style.removeProperty("direction"); this.domNode.style.removeProperty("direction");
this.domNode.style.removeProperty("unicodeBidi");
}; };
/* /*

View File

@@ -34,7 +34,7 @@ function SimpleEngine(options) {
this.domNode.value = this.value; this.domNode.value = this.value;
} }
// Set the attributes // Set the attributes
if(this.widget.editType && this.widget.editTag !== "textarea") { if(this.widget.editType) {
this.domNode.setAttribute("type",this.widget.editType); this.domNode.setAttribute("type",this.widget.editType);
} }
if(this.widget.editPlaceholder) { if(this.widget.editPlaceholder) {
@@ -52,6 +52,9 @@ function SimpleEngine(options) {
if(this.widget.editTabIndex) { if(this.widget.editTabIndex) {
this.domNode.setAttribute("tabindex",this.widget.editTabIndex); this.domNode.setAttribute("tabindex",this.widget.editTabIndex);
} }
if(this.widget.editDir) {
this.domNode.setAttribute("dir",this.widget.editDir);
}
if(this.widget.editAutoComplete) { if(this.widget.editAutoComplete) {
this.domNode.setAttribute("autocomplete",this.widget.editAutoComplete); this.domNode.setAttribute("autocomplete",this.widget.editAutoComplete);
} }

View File

@@ -183,6 +183,7 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) {
this.editFocusSelectFromStart = $tw.utils.parseNumber(this.getAttribute("focusSelectFromStart","0")); this.editFocusSelectFromStart = $tw.utils.parseNumber(this.getAttribute("focusSelectFromStart","0"));
this.editFocusSelectFromEnd = $tw.utils.parseNumber(this.getAttribute("focusSelectFromEnd","0")); this.editFocusSelectFromEnd = $tw.utils.parseNumber(this.getAttribute("focusSelectFromEnd","0"));
this.editTabIndex = this.getAttribute("tabindex"); this.editTabIndex = this.getAttribute("tabindex");
this.editDir = this.getAttribute("dir");
this.editCancelPopups = this.getAttribute("cancelPopups","") === "yes"; this.editCancelPopups = this.getAttribute("cancelPopups","") === "yes";
this.editInputActions = this.getAttribute("inputActions"); this.editInputActions = this.getAttribute("inputActions");
this.editRefreshTitle = this.getAttribute("refreshTitle"); this.editRefreshTitle = this.getAttribute("refreshTitle");
@@ -220,7 +221,7 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) {
EditTextWidget.prototype.refresh = function(changedTiddlers) { EditTextWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes(); var changedAttributes = this.computeAttributes();
// Completely rerender if any of our attributes have changed // Completely rerender if any of our attributes have changed
if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes["default"] || changedAttributes["class"] || changedAttributes.placeholder || changedAttributes.size || changedAttributes.autoHeight || changedAttributes.minHeight || changedAttributes.focusPopup || changedAttributes.rows || changedAttributes.tabindex || changedAttributes.cancelPopups || changedAttributes.inputActions || changedAttributes.refreshTitle || changedAttributes.autocomplete || changedTiddlers[HEIGHT_MODE_TITLE] || changedTiddlers[ENABLE_TOOLBAR_TITLE] || changedTiddlers["$:/palette"] || changedAttributes.disabled || changedAttributes.fileDrop) { if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes["default"] || changedAttributes["class"] || changedAttributes.placeholder || changedAttributes.size || changedAttributes.autoHeight || changedAttributes.minHeight || changedAttributes.focusPopup || changedAttributes.rows || changedAttributes.tabindex || changedAttributes.dir || changedAttributes.cancelPopups || changedAttributes.inputActions || changedAttributes.refreshTitle || changedAttributes.autocomplete || changedTiddlers[HEIGHT_MODE_TITLE] || changedTiddlers[ENABLE_TOOLBAR_TITLE] || changedTiddlers["$:/palette"] || changedAttributes.disabled || changedAttributes.fileDrop) {
this.refreshSelf(); this.refreshSelf();
return true; return true;
} else if (changedTiddlers[this.editRefreshTitle]) { } else if (changedTiddlers[this.editRefreshTitle]) {

View File

@@ -1,32 +0,0 @@
/*\
title: $:/core/modules/filterrunprefixes/then.js
type: application/javascript
module-type: filterrunprefix
Replace results of previous runs unless empty
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Export our filter prefix function
*/
exports.then = function(operationSubFunction) {
return function(results,source,widget) {
if(results.length !== 0) {
// Only run if previous run(s) produced results
var thisRunResult = operationSubFunction(source,widget);
if(thisRunResult.length !== 0) {
// Replace results only if this run actually produces a result
results.clear();
results.pushTop(thisRunResult);
}
}
};
};
})();

View File

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

View File

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

View File

@@ -68,54 +68,6 @@ exports["jsontype"] = function(source,operator,options) {
return results; return results;
}; };
exports["jsonset"] = function(source,operator,options) {
var suffixes = operator.suffixes || [],
type = suffixes[0] && suffixes[0][0],
indexes = operator.operands.slice(0,-1),
value = operator.operands[operator.operands.length - 1],
results = [];
if(operator.operands.length === 1 && operator.operands[0] === "") {
value = undefined; // Prevents the value from being assigned
}
switch(type) {
case "string":
// Use value unchanged
break;
case "boolean":
value = (value === "true" ? true : (value === "false" ? false : undefined));
break;
case "number":
value = $tw.utils.parseNumber(value);
break;
case "array":
indexes = operator.operands;
value = [];
break;
case "object":
indexes = operator.operands;
value = {};
break;
case "null":
indexes = operator.operands;
value = null;
break;
case "json":
value = $tw.utils.parseJSONSafe(value,function() {return undefined;});
break;
default:
// Use value unchanged
break;
}
source(function(tiddler,title) {
var data = $tw.utils.parseJSONSafe(title,title);
if(data) {
data = setDataItem(data,indexes,value);
results.push(JSON.stringify(data));
}
});
return results;
};
/* /*
Given a JSON data structure and an array of index strings, return an array of the string representation of the values at the end of the index chain, or "undefined" if any of the index strings are invalid Given a JSON data structure and an array of index strings, return an array of the string representation of the values at the end of the index chain, or "undefined" if any of the index strings are invalid
*/ */
@@ -234,34 +186,5 @@ function getDataItem(data,indexes) {
return item; return item;
} }
/*
Given a JSON data structure, an array of index strings and a value, return the data structure with the value added at the end of the index chain. If any of the index strings are invalid then the JSON data structure is returned unmodified. If the root item is targetted then a different data object will be returned
*/
function setDataItem(data,indexes,value) {
// Ignore attempts to assign undefined
if(value === undefined) {
return data;
}
// Check for the root item
if(indexes.length === 0 || (indexes.length === 1 && indexes[0] === "")) {
return value;
}
// Traverse the JSON data structure using the index chain
var current = data;
for(var i = 0; i < indexes.length - 1; i++) {
var index = indexes[i];
if($tw.utils.hop(current,index)) {
current = current[index];
} else {
// 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];
current[lastIndex] = value;
return data;
}
})(); })();

View File

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

View File

@@ -1,36 +0,0 @@
/*\
title: $:/core/modules/filters/substitute.js
type: application/javascript
module-type: filteroperator
Filter operator for substituting variables and embedded filter expressions with their corresponding values
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Export our filter function
*/
exports.substitute = function(source,operator,options) {
var results = [],
operands = [];
$tw.utils.each(operator.operands,function(operand,index){
operands.push({
name: (index + 1).toString(),
value: operand
});
});
source(function(tiddler,title) {
if(title) {
results.push(options.wiki.getSubstitutedText(title,options.widget,{substitutions:operands}));
}
});
return results;
};
})();

View File

@@ -305,11 +305,10 @@ exports.parseAttribute = function(source,pos) {
start: pos start: pos
}; };
// Define our regexps // Define our regexps
var reAttributeName = /([^\/\s>"'`=]+)/g, var reAttributeName = /([^\/\s>"'=]+)/g,
reUnquotedAttribute = /([^\/\s<>"'`=]+)/g, reUnquotedAttribute = /([^\/\s<>"'=]+)/g,
reFilteredValue = /\{\{\{([\S\s]+?)\}\}\}/g, reFilteredValue = /\{\{\{([\S\s]+?)\}\}\}/g,
reIndirectValue = /\{\{([^\}]+)\}\}/g, reIndirectValue = /\{\{([^\}]+)\}\}/g;
reSubstitutedValue = /(?:```([\s\S]*?)```|`([^`]|[\S\s]*?)`)/g;
// Skip whitespace // Skip whitespace
pos = $tw.utils.skipWhiteSpace(source,pos); pos = $tw.utils.skipWhiteSpace(source,pos);
// Get the attribute name // Get the attribute name
@@ -362,15 +361,8 @@ exports.parseAttribute = function(source,pos) {
node.type = "macro"; node.type = "macro";
node.value = macroInvocation; node.value = macroInvocation;
} else { } else {
var substitutedValue = $tw.utils.parseTokenRegExp(source,pos,reSubstitutedValue); node.type = "string";
if(substitutedValue) { node.value = "true";
pos = substitutedValue.end;
node.type = "substituted";
node.rawValue = substitutedValue.match[1] || substitutedValue.match[2];
} else {
node.type = "string";
node.value = "true";
}
} }
} }
} }

View File

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

View File

@@ -0,0 +1,51 @@
/*\
title: $:/core/modules/parsers/wikiparser/rules/dir.js
type: application/javascript
module-type: wikirule
Wiki pragma rule for specifying text direction
```
\dir rtl
\dir ltr
\dir auto
```
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.name = "dir";
exports.types = {pragma: true};
/*
Instantiate parse rule
*/
exports.init = function(parser) {
this.parser = parser;
// Regexp to match
this.matchRegExp = /^\\dir[^\S\n]*(\S+)\r?\n/mg;
};
/*
Parse the most recent match
*/
exports.parse = function() {
var self = this;
// Move past the pragma invocation
this.parser.pos = this.matchRegExp.lastIndex;
// Parse tree nodes to return
return [{
type: "element",
tag: this.parser.parseAsInline ? "span" : "div",
attributes: {
dir: {type: "string", value: this.match[1]}
},
children: []
}];
};
})();

View File

@@ -35,7 +35,7 @@ Instantiate parse rule
exports.init = function(parser) { exports.init = function(parser) {
this.parser = parser; this.parser = parser;
// Regexp to match // Regexp to match
this.matchRegExp = /\\(function|procedure|widget)\s+([^(\s]+)\((\s*([^)]*))?\)(\s*\r?\n)?/mg; this.matchRegExp = /^\\(function|procedure|widget)\s+([^(\s]+)\((\s*([^)]*))?\)(\s*\r?\n)?/mg;
}; };
/* /*
@@ -53,7 +53,7 @@ exports.parse = function() {
var reEnd; var reEnd;
if(this.match[5]) { if(this.match[5]) {
// If so, the end of the body is marked with \end // 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"); reEnd = new RegExp("(\\r?\\n\\\\end[^\\S\\n\\r]*(?:" + $tw.utils.escapeRegExp(this.match[2]) + ")?(?:$|\\r?\\n))","mg");
} else { } else {
// Otherwise, the end of the definition is marked by the end of the line // Otherwise, the end of the definition is marked by the end of the line
reEnd = /($|\r?\n)/mg; reEnd = /($|\r?\n)/mg;

View File

@@ -26,7 +26,7 @@ Instantiate parse rule
exports.init = function(parser) { exports.init = function(parser) {
this.parser = parser; this.parser = parser;
// Regexp to match // Regexp to match
this.matchRegExp = /\\parameters\s*\(([^)]*)\)(\s*\r?\n)?/mg; this.matchRegExp = /^\\parameters\s*\(([^)]*)\)(\s*\r?\n)?/mg;
}; };
/* /*

View File

@@ -81,9 +81,6 @@ exports.parse = function() {
} }
return [tiddlerNode]; return [tiddlerNode];
} else { } else {
// No template or text reference is provided, so we'll use a blank target. Otherwise we'll generate
// a transclude widget that transcludes the current tiddler, often leading to recursion errors
transcludeNode.attributes["$tiddler"] = {name: "$tiddler", type: "string", value: ""};
return [transcludeNode]; return [transcludeNode];
} }
} }

View File

@@ -79,9 +79,6 @@ exports.parse = function() {
} }
return [tiddlerNode]; return [tiddlerNode];
} else { } else {
// No template or text reference is provided, so we'll use a blank target. Otherwise we'll generate
// a transclude widget that transcludes the current tiddler, often leading to recursion errors
transcludeNode.attributes["$tiddler"] = {name: "$tiddler", type: "string", value: ""};
return [transcludeNode]; return [transcludeNode];
} }
} }

View File

@@ -36,6 +36,7 @@ options: see below:
*/ */
var WikiParser = function(type,text,options) { var WikiParser = function(type,text,options) {
this.wiki = options.wiki; this.wiki = options.wiki;
this.parseAsInline = options.parseAsInline;
var self = this; var self = this;
// Check for an externally linked tiddler // Check for an externally linked tiddler
if($tw.browser && (text || "") === "" && options._canonical_uri) { if($tw.browser && (text || "") === "" && options._canonical_uri) {
@@ -194,7 +195,6 @@ Parse any pragmas at the beginning of a block of parse text
WikiParser.prototype.parsePragmas = function() { WikiParser.prototype.parsePragmas = function() {
var currentTreeBranch = this.tree; var currentTreeBranch = this.tree;
while(true) { while(true) {
var savedPos = this.pos;
// Skip whitespace // Skip whitespace
this.skipWhitespace(); this.skipWhitespace();
// Check for the end of the text // Check for the end of the text
@@ -205,7 +205,6 @@ WikiParser.prototype.parsePragmas = function() {
var nextMatch = this.findNextMatch(this.pragmaRules,this.pos); var nextMatch = this.findNextMatch(this.pragmaRules,this.pos);
// If not, just exit // If not, just exit
if(!nextMatch || nextMatch.matchIndex !== this.pos) { if(!nextMatch || nextMatch.matchIndex !== this.pos) {
this.pos = savedPos;
break; break;
} }
// Process the pragma rule // Process the pragma rule
@@ -225,7 +224,7 @@ Parse a block from the current position
terminatorRegExpString: optional regular expression string that identifies the end of plain paragraphs. Must not include capturing parenthesis terminatorRegExpString: optional regular expression string that identifies the end of plain paragraphs. Must not include capturing parenthesis
*/ */
WikiParser.prototype.parseBlock = function(terminatorRegExpString) { WikiParser.prototype.parseBlock = function(terminatorRegExpString) {
var terminatorRegExp = terminatorRegExpString ? new RegExp(terminatorRegExpString + "|\\r?\\n\\r?\\n","mg") : /(\r?\n\r?\n)/mg; var terminatorRegExp = terminatorRegExpString ? new RegExp("(" + terminatorRegExpString + "|\\r?\\n\\r?\\n)","mg") : /(\r?\n\r?\n)/mg;
this.skipWhitespace(); this.skipWhitespace();
if(this.pos >= this.sourceLength) { if(this.pos >= this.sourceLength) {
return []; return [];
@@ -265,22 +264,12 @@ WikiParser.prototype.parseBlocksUnterminated = function() {
return tree; return tree;
}; };
/*
Parse blocks of text until a terminating regexp is encountered. Wrapper for parseBlocksTerminatedExtended that just returns the parse tree
*/
WikiParser.prototype.parseBlocksTerminated = function(terminatorRegExpString) {
var ex = this.parseBlocksTerminatedExtended(terminatorRegExpString);
return ex.tree;
};
/* /*
Parse blocks of text until a terminating regexp is encountered Parse blocks of text until a terminating regexp is encountered
*/ */
WikiParser.prototype.parseBlocksTerminatedExtended = function(terminatorRegExpString) { WikiParser.prototype.parseBlocksTerminated = function(terminatorRegExpString) {
var terminatorRegExp = new RegExp(terminatorRegExpString,"mg"), var terminatorRegExp = new RegExp("(" + terminatorRegExpString + ")","mg"),
result = { tree = [];
tree: []
};
// Skip any whitespace // Skip any whitespace
this.skipWhitespace(); this.skipWhitespace();
// Check if we've got the end marker // Check if we've got the end marker
@@ -289,7 +278,7 @@ WikiParser.prototype.parseBlocksTerminatedExtended = function(terminatorRegExpSt
// Parse the text into blocks // Parse the text into blocks
while(this.pos < this.sourceLength && !(match && match.index === this.pos)) { while(this.pos < this.sourceLength && !(match && match.index === this.pos)) {
var blocks = this.parseBlock(terminatorRegExpString); var blocks = this.parseBlock(terminatorRegExpString);
result.tree.push.apply(result.tree,blocks); tree.push.apply(tree,blocks);
// Skip any whitespace // Skip any whitespace
this.skipWhitespace(); this.skipWhitespace();
// Check if we've got the end marker // Check if we've got the end marker
@@ -298,9 +287,8 @@ WikiParser.prototype.parseBlocksTerminatedExtended = function(terminatorRegExpSt
} }
if(match && match.index === this.pos) { if(match && match.index === this.pos) {
this.pos = match.index + match[0].length; this.pos = match.index + match[0].length;
result.match = match;
} }
return result; return tree;
}; };
/* /*
@@ -343,11 +331,6 @@ WikiParser.prototype.parseInlineRunUnterminated = function(options) {
}; };
WikiParser.prototype.parseInlineRunTerminated = function(terminatorRegExp,options) { WikiParser.prototype.parseInlineRunTerminated = function(terminatorRegExp,options) {
var ex = this.parseInlineRunTerminatedExtended(terminatorRegExp,options);
return ex.tree;
};
WikiParser.prototype.parseInlineRunTerminatedExtended = function(terminatorRegExp,options) {
options = options || {}; options = options || {};
var tree = []; var tree = [];
// Find the next occurrence of the terminator // Find the next occurrence of the terminator
@@ -367,10 +350,7 @@ WikiParser.prototype.parseInlineRunTerminatedExtended = function(terminatorRegEx
if(options.eatTerminator) { if(options.eatTerminator) {
this.pos += terminatorMatch[0].length; this.pos += terminatorMatch[0].length;
} }
return { return tree;
match: terminatorMatch,
tree: tree
};
} }
} }
// Process any inline rule, along with the text preceding it // Process any inline rule, along with the text preceding it
@@ -394,9 +374,7 @@ WikiParser.prototype.parseInlineRunTerminatedExtended = function(terminatorRegEx
this.pushTextWidget(tree,this.source.substr(this.pos),this.pos,this.sourceLength); this.pushTextWidget(tree,this.source.substr(this.pos),this.pos,this.sourceLength);
} }
this.pos = this.sourceLength; this.pos = this.sourceLength;
return { return tree;
tree: tree
};
}; };
/* /*

View File

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

View File

@@ -15,7 +15,6 @@ Startup logic concerned with managing plugins
// Export name and synchronous status // Export name and synchronous status
exports.name = "plugins"; exports.name = "plugins";
exports.after = ["load-modules"]; exports.after = ["load-modules"];
exports.before = ["startup"];
exports.synchronous = true; exports.synchronous = true;
var TITLE_REQUIRE_RELOAD_DUE_TO_PLUGIN_CHANGE = "$:/status/RequireReloadDueToPluginChange"; var TITLE_REQUIRE_RELOAD_DUE_TO_PLUGIN_CHANGE = "$:/status/RequireReloadDueToPluginChange";

View File

@@ -38,7 +38,6 @@ exports.startup = function() {
url: params.url, url: params.url,
method: params.method, method: params.method,
body: params.body, body: params.body,
binary: params.binary,
oncompletion: params.oncompletion, oncompletion: params.oncompletion,
onprogress: params.onprogress, onprogress: params.onprogress,
bindStatus: params["bind-status"], bindStatus: params["bind-status"],

View File

@@ -27,11 +27,6 @@ exports.startup = function() {
if($tw.browser) { if($tw.browser) {
$tw.browser.isIE = (/msie|trident/i.test(navigator.userAgent)); $tw.browser.isIE = (/msie|trident/i.test(navigator.userAgent));
$tw.browser.isFirefox = !!document.mozFullScreenEnabled; $tw.browser.isFirefox = !!document.mozFullScreenEnabled;
// 2023-07-21 Edge returns UA below. So we use "isChromeLike"
//'mozilla/5.0 (windows nt 10.0; win64; x64) applewebkit/537.36 (khtml, like gecko) chrome/114.0.0.0 safari/537.36 edg/114.0.1823.82'
$tw.browser.isChromeLike = navigator.userAgent.toLowerCase().indexOf("chrome") > -1;
$tw.browser.hasTouch = !!window.matchMedia && window.matchMedia("(pointer: coarse)").matches;
$tw.browser.isMobileChrome = $tw.browser.isChromeLike && $tw.browser.hasTouch;
} }
// Platform detection // Platform detection
$tw.platform = {}; $tw.platform = {};

View File

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

View File

@@ -80,7 +80,7 @@ exports.makeDraggable = function(options) {
if(dataTransfer.setDragImage) { if(dataTransfer.setDragImage) {
if(dragImageType === "pill") { if(dragImageType === "pill") {
dataTransfer.setDragImage(dragImage.firstChild,-16,-16); dataTransfer.setDragImage(dragImage.firstChild,-16,-16);
} else if(dragImageType === "blank") { } else if (dragImageType === "blank") {
dragImage.removeChild(dragImage.firstChild); dragImage.removeChild(dragImage.firstChild);
dataTransfer.setDragImage(dragImage,0,0); dataTransfer.setDragImage(dragImage,0,0);
} else { } else {
@@ -106,9 +106,7 @@ exports.makeDraggable = function(options) {
dataTransfer.setData("text/vnd.tiddler",jsonData); dataTransfer.setData("text/vnd.tiddler",jsonData);
dataTransfer.setData("text/plain",titleString); dataTransfer.setData("text/plain",titleString);
dataTransfer.setData("text/x-moz-url","data:text/vnd.tiddler," + encodeURIComponent(jsonData)); dataTransfer.setData("text/x-moz-url","data:text/vnd.tiddler," + encodeURIComponent(jsonData));
} } else {
// If browser is Chrome-like and has a touch-input device do NOT .setData
if(!($tw.browser.isMobileChrome)) {
dataTransfer.setData("URL","data:text/vnd.tiddler," + encodeURIComponent(jsonData)); dataTransfer.setData("URL","data:text/vnd.tiddler," + encodeURIComponent(jsonData));
} }
dataTransfer.setData("Text",titleString); dataTransfer.setData("Text",titleString);

View File

@@ -90,7 +90,6 @@ wiki: wiki to be used for executing action strings
url: URL for request url: URL for request
method: method eg GET, POST method: method eg GET, POST
body: text of request body body: text of request body
binary: set to "yes" to force binary processing of response payload
oncompletion: action string to be invoked on completion oncompletion: action string to be invoked on completion
onprogress: action string to be invoked on progress updates onprogress: action string to be invoked on progress updates
bindStatus: optional title of tiddler to which status ("pending", "complete", "error") should be written bindStatus: optional title of tiddler to which status ("pending", "complete", "error") should be written
@@ -107,11 +106,10 @@ function HttpClientRequest(options) {
this.wiki = options.wiki; this.wiki = options.wiki;
this.completionActions = options.oncompletion; this.completionActions = options.oncompletion;
this.progressActions = options.onprogress; this.progressActions = options.onprogress;
this.bindStatus = options["bindStatus"]; this.bindStatus = options["bind-status"];
this.bindProgress = options["bindProgress"]; this.bindProgress = options["bind-progress"];
this.method = options.method || "GET"; this.method = options.method || "GET";
this.body = options.body || ""; this.body = options.body || "";
this.binary = options.binary || "";
this.variables = options.variables; this.variables = options.variables;
var url = options.url; var url = options.url;
$tw.utils.each(options.queryStrings,function(value,name) { $tw.utils.each(options.queryStrings,function(value,name) {
@@ -134,7 +132,7 @@ HttpClientRequest.prototype.send = function(callback) {
var self = this, var self = this,
setBinding = function(title,text) { setBinding = function(title,text) {
if(title) { if(title) {
self.wiki.addTiddler(new $tw.Tiddler({title: title, text: text})); this.wiki.addTiddler(new $tw.Tiddler({title: title, text: text}));
} }
}; };
if(this.url) { if(this.url) {
@@ -158,8 +156,6 @@ HttpClientRequest.prototype.send = function(callback) {
type: this.method, type: this.method,
headers: this.requestHeaders, headers: this.requestHeaders,
data: this.body, data: this.body,
returnProp: this.binary === "" ? "responseText" : "response",
responseType: this.binary === "" ? "text" : "arraybuffer",
callback: function(err,data,xhr) { callback: function(err,data,xhr) {
var hasSucceeded = xhr.status >= 200 && xhr.status < 300, var hasSucceeded = xhr.status >= 200 && xhr.status < 300,
completionCode = hasSucceeded ? "complete" : "error", completionCode = hasSucceeded ? "complete" : "error",
@@ -179,16 +175,6 @@ HttpClientRequest.prototype.send = function(callback) {
data: (data || "").toString(), data: (data || "").toString(),
headers: JSON.stringify(headers) headers: JSON.stringify(headers)
}; };
/* Convert data from binary to base64 */
if (xhr.responseType === "arraybuffer") {
var binary = "",
bytes = new Uint8Array(data),
len = bytes.byteLength;
for (var i=0; i<len; i++) {
binary += String.fromCharCode(bytes[i]);
}
resultVariables.data = $tw.utils.base64Encode(binary,true);
}
self.wiki.addTiddler(new $tw.Tiddler(self.wiki.getTiddler(requestTrackerTitle),{ self.wiki.addTiddler(new $tw.Tiddler(self.wiki.getTiddler(requestTrackerTitle),{
status: completionCode, status: completionCode,
})); }));
@@ -226,7 +212,6 @@ Make an HTTP request. Options are:
callback: function invoked with (err,data,xhr) callback: function invoked with (err,data,xhr)
progress: optional function invoked with (lengthComputable,loaded,total) progress: optional function invoked with (lengthComputable,loaded,total)
returnProp: string name of the property to return as first argument of callback returnProp: string name of the property to return as first argument of callback
responseType: "text" or "arraybuffer"
*/ */
exports.httpRequest = function(options) { exports.httpRequest = function(options) {
var type = options.type || "GET", var type = options.type || "GET",
@@ -279,7 +264,6 @@ exports.httpRequest = function(options) {
} }
} }
} }
request.responseType = options.responseType || "text";
// Set up the state change handler // Set up the state change handler
request.onreadystatechange = function() { request.onreadystatechange = function() {
if(this.readyState === 4) { if(this.readyState === 4) {

View File

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

View File

@@ -116,7 +116,7 @@ CheckboxWidget.prototype.getValue = function() {
} else { } else {
list = $tw.utils.parseStringArray(this.checkboxDefault || "") || []; 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 || "")) || []; list = $tw.utils.parseStringArray(this.wiki.extractTiddlerDataItem(tiddler,this.checkboxListIndex,this.checkboxDefault || "")) || [];
} else { } else {
list = this.wiki.filterTiddlers(this.checkboxFilter,this) || []; list = this.wiki.filterTiddlers(this.checkboxFilter,this) || [];
@@ -215,8 +215,6 @@ CheckboxWidget.prototype.handleChangeEvent = function(event) {
if($tw.utils.isArray(fieldContents)) { if($tw.utils.isArray(fieldContents)) {
// Make a copy so we can modify it without changing original that's refrenced elsewhere // Make a copy so we can modify it without changing original that's refrenced elsewhere
listContents = fieldContents.slice(0); listContents = fieldContents.slice(0);
} else if(fieldContents === undefined) {
listContents = [];
} else if(typeof fieldContents === "string") { } else if(typeof fieldContents === "string") {
listContents = $tw.utils.parseStringArray(fieldContents); listContents = $tw.utils.parseStringArray(fieldContents);
// No need to copy since parseStringArray returns a fresh array, not refrenced elsewhere // No need to copy since parseStringArray returns a fresh array, not refrenced elsewhere

View File

@@ -48,6 +48,7 @@ EditWidget.prototype.execute = function() {
this.editPlaceholder = this.getAttribute("placeholder"); this.editPlaceholder = this.getAttribute("placeholder");
this.editTabIndex = this.getAttribute("tabindex"); this.editTabIndex = this.getAttribute("tabindex");
this.editFocus = this.getAttribute("focus",""); this.editFocus = this.getAttribute("focus","");
this.editDir = this.getAttribute("dir");
this.editCancelPopups = this.getAttribute("cancelPopups",""); this.editCancelPopups = this.getAttribute("cancelPopups","");
this.editInputActions = this.getAttribute("inputActions"); this.editInputActions = this.getAttribute("inputActions");
this.editRefreshTitle = this.getAttribute("refreshTitle"); this.editRefreshTitle = this.getAttribute("refreshTitle");
@@ -90,7 +91,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
EditWidget.prototype.refresh = function(changedTiddlers) { EditWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes(); var changedAttributes = this.computeAttributes();
// Refresh if an attribute has changed, or the type associated with the target tiddler has changed // 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.dir || changedAttributes.cancelPopups || changedAttributes.inputActions || changedAttributes.refreshTitle || changedAttributes.autocomplete || (changedTiddlers[this.editTitle] && this.getEditorType() !== this.editorType)) {
this.refreshSelf(); this.refreshSelf();
return true; return true;
} else { } else {

View File

@@ -58,25 +58,24 @@ ImageWidget.prototype.render = function(parent,nextSibling) {
if(this.wiki.isImageTiddler(this.imageSource)) { if(this.wiki.isImageTiddler(this.imageSource)) {
var type = tiddler.fields.type, var type = tiddler.fields.type,
text = tiddler.fields.text, text = tiddler.fields.text,
_canonical_uri = tiddler.fields._canonical_uri, _canonical_uri = tiddler.fields._canonical_uri;
typeInfo = $tw.config.contentTypeInfo[type] || {},
deserializerType = typeInfo.deserializerType || type;
// If the tiddler has body text then it doesn't need to be lazily loaded // If the tiddler has body text then it doesn't need to be lazily loaded
if(text) { if(text) {
// Render the appropriate element for the image type by looking up the encoding in the content type info // Render the appropriate element for the image type
var encoding = typeInfo.encoding || "utf8"; switch(type) {
if (encoding === "base64") { case "application/pdf":
// .pdf .png .jpg etc.
src = "data:" + deserializerType + ";base64," + text;
if (deserializerType === "application/pdf") {
tag = "embed"; tag = "embed";
} src = "data:application/pdf;base64," + text;
} else { break;
// .svg .tid .xml etc. case "image/svg+xml":
src = "data:" + deserializerType + "," + encodeURIComponent(text); src = "data:image/svg+xml," + encodeURIComponent(text);
break;
default:
src = "data:" + type + ";base64," + text;
break;
} }
} else if(_canonical_uri) { } else if(_canonical_uri) {
switch(deserializerType) { switch(type) {
case "application/pdf": case "application/pdf":
tag = "embed"; tag = "embed";
src = _canonical_uri; src = _canonical_uri;

View File

@@ -49,7 +49,7 @@ ImportVariablesWidget.prototype.execute = function(tiddlerList) {
this.tiddlerList = tiddlerList || this.wiki.filterTiddlers(this.filter,this); this.tiddlerList = tiddlerList || this.wiki.filterTiddlers(this.filter,this);
// Accumulate the <$set> widgets from each tiddler // Accumulate the <$set> widgets from each tiddler
$tw.utils.each(this.tiddlerList,function(title) { $tw.utils.each(this.tiddlerList,function(title) {
var parser = widgetPointer.wiki.parseTiddler(title,{parseAsInline:true, configTrimWhiteSpace:true}); var parser = widgetPointer.wiki.parseTiddler(title,{parseAsInline:true});
if(parser) { if(parser) {
var parseTreeNode = parser.tree[0]; var parseTreeNode = parser.tree[0];
while(parseTreeNode && ["setvariable","set","parameters"].indexOf(parseTreeNode.type) !== -1) { while(parseTreeNode && ["setvariable","set","parameters"].indexOf(parseTreeNode.type) !== -1) {

View File

@@ -28,18 +28,6 @@ Inherit from the base widget class
*/ */
ListWidget.prototype = new Widget(); ListWidget.prototype = new Widget();
ListWidget.prototype.initialise = function(parseTreeNode,options) {
// Bail if parseTreeNode is undefined, meaning that the ListWidget constructor was called without any arguments so that it can be subclassed
if(parseTreeNode === undefined) {
return;
}
// First call parent constructor to set everything else up
Widget.prototype.initialise.call(this,parseTreeNode,options);
// Now look for <$list-template> and <$list-empty> widgets as immediate child widgets
// This is safe to do during initialization because parse trees never change after creation
this.findExplicitTemplates();
}
/* /*
Render this widget into the DOM Render this widget into the DOM
*/ */
@@ -72,7 +60,6 @@ ListWidget.prototype.render = function(parent,nextSibling) {
Compute the internal state of the widget Compute the internal state of the widget
*/ */
ListWidget.prototype.execute = function() { ListWidget.prototype.execute = function() {
var self = this;
// Get our attributes // Get our attributes
this.template = this.getAttribute("template"); this.template = this.getAttribute("template");
this.editTemplate = this.getAttribute("editTemplate"); this.editTemplate = this.getAttribute("editTemplate");
@@ -98,51 +85,18 @@ ListWidget.prototype.execute = function() {
this.history = []; this.history = [];
}; };
ListWidget.prototype.findExplicitTemplates = function() {
var self = this;
this.explicitListTemplate = null;
this.explicitEmptyTemplate = null;
this.hasTemplateInBody = false;
var searchChildren = function(childNodes) {
$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 === "element" && node.tag === "p") {
searchChildren(node.children);
} else {
self.hasTemplateInBody = true;
}
});
};
searchChildren(this.parseTreeNode.children);
}
ListWidget.prototype.getTiddlerList = function() { ListWidget.prototype.getTiddlerList = function() {
var limit = $tw.utils.getInt(this.getAttribute("limit",""),undefined);
var defaultFilter = "[!is[system]sort[title]]"; var defaultFilter = "[!is[system]sort[title]]";
var results = this.wiki.filterTiddlers(this.getAttribute("filter",defaultFilter),this); return this.wiki.filterTiddlers(this.getAttribute("filter",defaultFilter),this);
if(limit !== undefined) {
if(limit >= 0) {
results = results.slice(0,limit);
} else {
results = results.slice(limit);
}
}
return results;
}; };
ListWidget.prototype.getEmptyMessage = function() { ListWidget.prototype.getEmptyMessage = function() {
var parser, var parser,
emptyMessage = this.getAttribute("emptyMessage"); emptyMessage = this.getAttribute("emptyMessage","");
// If emptyMessage attribute is not present or empty then look for an explicit empty template // this.wiki.parseText() calls
if(!emptyMessage) { // new Parser(..), which should only be done, if needed, because it's heavy!
if(this.explicitEmptyTemplate) { if (emptyMessage === "") {
return this.explicitEmptyTemplate; return [];
} else {
return [];
}
} }
parser = this.wiki.parseText("text/vnd.tiddlywiki",emptyMessage,{parseAsInline: true}); parser = this.wiki.parseText("text/vnd.tiddlywiki",emptyMessage,{parseAsInline: true});
if(parser) { if(parser) {
@@ -168,19 +122,12 @@ ListWidget.prototype.makeItemTemplate = function(title,index) {
if(template) { if(template) {
templateTree = [{type: "transclude", attributes: {tiddler: {type: "string", value: template}}}]; templateTree = [{type: "transclude", attributes: {tiddler: {type: "string", value: template}}}];
} else { } else {
// Check for child nodes of the list widget
if(this.parseTreeNode.children && this.parseTreeNode.children.length > 0) { if(this.parseTreeNode.children && this.parseTreeNode.children.length > 0) {
// Check for a <$list-item> widget templateTree = this.parseTreeNode.children;
if(this.explicitListTemplate) { } else {
templateTree = this.explicitListTemplate;
} else if(this.hasTemplateInBody) {
templateTree = this.parseTreeNode.children;
}
}
if(!templateTree || templateTree.length === 0) {
// Default template is a link to the title // Default template is a link to the title
templateTree = [{type: "element", tag: this.parseTreeNode.isBlock ? "div" : "span", children: [{type: "link", attributes: {to: {type: "string", value: title}}, children: [ templateTree = [{type: "element", tag: this.parseTreeNode.isBlock ? "div" : "span", children: [{type: "link", attributes: {to: {type: "string", value: title}}, children: [
{type: "text", text: title} {type: "text", text: title}
]}]}]; ]}]}];
} }
} }
@@ -278,8 +225,6 @@ ListWidget.prototype.handleListChanges = function(changedTiddlers) {
// If we are providing an counter variable then we must refresh the items, otherwise we can rearrange them // If we are providing an counter variable then we must refresh the items, otherwise we can rearrange them
var hasRefreshed = false,t; var hasRefreshed = false,t;
if(this.counterName) { if(this.counterName) {
var mustRefreshOldLast = false;
var oldLength = this.children.length;
// Cycle through the list and remove and re-insert the first item that has changed, and all the remaining items // Cycle through the list and remove and re-insert the first item that has changed, and all the remaining items
for(t=0; t<this.list.length; t++) { for(t=0; t<this.list.length; t++) {
if(hasRefreshed || !this.children[t] || this.children[t].parseTreeNode.itemTitle !== this.list[t]) { if(hasRefreshed || !this.children[t] || this.children[t].parseTreeNode.itemTitle !== this.list[t]) {
@@ -287,9 +232,6 @@ ListWidget.prototype.handleListChanges = function(changedTiddlers) {
this.removeListItem(t); this.removeListItem(t);
} }
this.insertListItem(t,this.list[t]); this.insertListItem(t,this.list[t]);
if(!hasRefreshed && t === oldLength) {
mustRefreshOldLast = true;
}
hasRefreshed = true; hasRefreshed = true;
} else { } else {
// Refresh the item we're reusing // Refresh the item we're reusing
@@ -297,12 +239,6 @@ ListWidget.prototype.handleListChanges = function(changedTiddlers) {
hasRefreshed = hasRefreshed || refreshed; hasRefreshed = hasRefreshed || refreshed;
} }
} }
// If items were inserted then we must recreate the item that used to be at the last position as it is no longer last
if(mustRefreshOldLast && oldLength > 0) {
var oldLastIdx = oldLength-1;
this.removeListItem(oldLastIdx);
this.insertListItem(oldLastIdx,this.list[oldLastIdx]);
}
// If there are items to remove and we have not refreshed then recreate the item that will now be at the last position // If there are items to remove and we have not refreshed then recreate the item that will now be at the last position
if(!hasRefreshed && this.children.length > this.list.length) { if(!hasRefreshed && this.children.length > this.list.length) {
this.removeListItem(this.list.length-1); this.removeListItem(this.list.length-1);
@@ -427,27 +363,4 @@ ListItemWidget.prototype.refresh = function(changedTiddlers) {
exports.listitem = ListItemWidget; exports.listitem = ListItemWidget;
/*
Make <$list-template> and <$list-empty> widgets that do nothing
*/
var ListTemplateWidget = function(parseTreeNode,options) {
// Main initialisation inherited from widget.js
this.initialise(parseTreeNode,options);
};
ListTemplateWidget.prototype = new Widget();
ListTemplateWidget.prototype.render = function() {}
ListTemplateWidget.prototype.refresh = function() { return false; }
exports["list-template"] = ListTemplateWidget;
var ListEmptyWidget = function(parseTreeNode,options) {
// Main initialisation inherited from widget.js
this.initialise(parseTreeNode,options);
};
ListEmptyWidget.prototype = new Widget();
ListEmptyWidget.prototype.render = function() {}
ListEmptyWidget.prototype.refresh = function() { return false; }
exports["list-empty"] = ListEmptyWidget;
})(); })();

View File

@@ -42,6 +42,9 @@ RevealWidget.prototype.render = function(parent,nextSibling) {
if(this.style) { if(this.style) {
domNode.setAttribute("style",this.style); domNode.setAttribute("style",this.style);
} }
if(this.direction) {
domNode.setAttribute("dir",this.direction);
}
parent.insertBefore(domNode,nextSibling); parent.insertBefore(domNode,nextSibling);
this.renderChildren(domNode,null); this.renderChildren(domNode,null);
if(!domNode.isTiddlyWikiFakeDom && this.type === "popup" && this.isOpen) { if(!domNode.isTiddlyWikiFakeDom && this.type === "popup" && this.isOpen) {
@@ -123,6 +126,7 @@ RevealWidget.prototype.execute = function() {
this["default"] = this.getAttribute("default",""); this["default"] = this.getAttribute("default","");
this.animate = this.getAttribute("animate","no"); this.animate = this.getAttribute("animate","no");
this.retain = this.getAttribute("retain","no"); this.retain = this.getAttribute("retain","no");
this.direction = this.getAttribute("dir");
this.openAnimation = this.animate === "no" ? undefined : "open"; this.openAnimation = this.animate === "no" ? undefined : "open";
this.closeAnimation = this.animate === "no" ? undefined : "close"; this.closeAnimation = this.animate === "no" ? undefined : "close";
this.updatePopupPosition = this.getAttribute("updatePopupPosition","no") === "yes"; this.updatePopupPosition = this.getAttribute("updatePopupPosition","no") === "yes";
@@ -214,7 +218,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
*/ */
RevealWidget.prototype.refresh = function(changedTiddlers) { RevealWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes(); var changedAttributes = this.computeAttributes();
if(changedAttributes.state || changedAttributes.type || changedAttributes.text || changedAttributes.position || changedAttributes.positionAllowNegative || changedAttributes["default"] || changedAttributes.animate || changedAttributes.stateTitle || changedAttributes.stateField || changedAttributes.stateIndex) { if(changedAttributes.state || changedAttributes.type || changedAttributes.text || changedAttributes.position || changedAttributes.positionAllowNegative || changedAttributes["default"] || changedAttributes.animate || changedAttributes.stateTitle || changedAttributes.stateField || changedAttributes.stateIndex || changedAttributes.dir) {
this.refreshSelf(); this.refreshSelf();
return true; return true;
} else { } else {

View File

@@ -145,7 +145,6 @@ SelectWidget.prototype.execute = function() {
this.selectDefault = this.getAttribute("default"); this.selectDefault = this.getAttribute("default");
this.selectMultiple = this.getAttribute("multiple", false); this.selectMultiple = this.getAttribute("multiple", false);
this.selectSize = this.getAttribute("size"); this.selectSize = this.getAttribute("size");
this.selectTabindex = this.getAttribute("tabindex");
this.selectTooltip = this.getAttribute("tooltip"); this.selectTooltip = this.getAttribute("tooltip");
this.selectFocus = this.getAttribute("focus"); this.selectFocus = this.getAttribute("focus");
// Make the child widgets // Make the child widgets
@@ -163,9 +162,6 @@ SelectWidget.prototype.execute = function() {
if(this.selectSize) { if(this.selectSize) {
$tw.utils.addAttributeToParseTreeNode(selectNode,"size",this.selectSize); $tw.utils.addAttributeToParseTreeNode(selectNode,"size",this.selectSize);
} }
if(this.selectTabindex) {
$tw.utils.addAttributeToParseTreeNode(selectNode,"tabindex",this.selectTabindex);
}
if(this.selectTooltip) { if(this.selectTooltip) {
$tw.utils.addAttributeToParseTreeNode(selectNode,"title",this.selectTooltip); $tw.utils.addAttributeToParseTreeNode(selectNode,"title",this.selectTooltip);
} }

View File

@@ -41,43 +41,27 @@ TranscludeWidget.prototype.execute = function() {
this.collectAttributes(); this.collectAttributes();
this.collectStringParameters(); this.collectStringParameters();
this.collectSlotFillParameters(); this.collectSlotFillParameters();
// Determine whether we're being used in inline or block mode // Get the parse tree nodes that we are transcluding
var parseAsInline = !this.parseTreeNode.isBlock; var target = this.getTransclusionTarget(),
if(this.transcludeMode === "inline") { parseTreeNodes = target.parseTreeNodes;
parseAsInline = true; this.sourceText = target.text;
} else if(this.transcludeMode === "block") { this.parserType = target.type;
parseAsInline = false; this.parseAsInline = target.parseAsInline;
}
// Set 'thisTiddler'
this.setVariable("thisTiddler",this.transcludeTitle);
var parseTreeNodes, target;
// Process the transclusion according to the output type // Process the transclusion according to the output type
switch(this.transcludeOutput || "text/html") { switch(this.transcludeOutput || "text/html") {
case "text/html": case "text/html":
// Return the parse tree nodes of the target // No further processing required
target = this.parseTransclusionTarget(parseAsInline);
this.parseAsInline = target.parseAsInline;
parseTreeNodes = target.parseTreeNodes;
break; break;
case "text/raw": case "text/raw":
// Just return the raw text // Just return the raw text
target = this.getTransclusionTarget(); parseTreeNodes = [{type: "text", text: this.sourceText}];
parseTreeNodes = [{type: "text", text: target.text}];
break; break;
default: default:
// "text/plain" is the plain text result of wikifying the text // text/plain
target = this.parseTransclusionTarget(parseAsInline); var plainText = this.wiki.renderText("text/plain",this.parserType,this.sourceText,{parentWidget: this});
var widgetNode = this.wiki.makeWidget(target.parser,{ parseTreeNodes = [{type: "text", text: plainText}];
parentWidget: this,
document: $tw.fakeDocument
});
var container = $tw.fakeDocument.createElement("div");
widgetNode.render(container,null);
parseTreeNodes = [{type: "text", text: container.textContent}];
break; break;
} }
this.sourceText = target.text;
this.parserType = target.type;
// Set the legacy transclusion context variables only if we're not transcluding a variable // Set the legacy transclusion context variables only if we're not transcluding a variable
if(!this.transcludeVariable) { if(!this.transcludeVariable) {
var recursionMarker = this.makeRecursionMarker(); var recursionMarker = this.makeRecursionMarker();
@@ -109,7 +93,6 @@ TranscludeWidget.prototype.collectAttributes = function() {
this.recursionMarker = this.getAttribute("recursionMarker","yes"); this.recursionMarker = this.getAttribute("recursionMarker","yes");
} else { } else {
this.transcludeVariable = this.getAttribute("$variable"); this.transcludeVariable = this.getAttribute("$variable");
this.transcludeVariableIsFunction = false;
this.transcludeType = this.getAttribute("$type"); this.transcludeType = this.getAttribute("$type");
this.transcludeOutput = this.getAttribute("$output","text/html"); this.transcludeOutput = this.getAttribute("$output","text/html");
this.transcludeTitle = this.getAttribute("$tiddler",this.getVariable("currentTiddler")); this.transcludeTitle = this.getAttribute("$tiddler",this.getVariable("currentTiddler"));
@@ -175,46 +158,17 @@ TranscludeWidget.prototype.collectSlotFillParameters = function() {
}; };
/* /*
Get transcluded details as an object {text:,type:} Get transcluded parse tree nodes as an object {parser:,text:,type:}
*/ */
TranscludeWidget.prototype.getTransclusionTarget = function() { TranscludeWidget.prototype.getTransclusionTarget = function() {
var self = this; var self = this;
var text; // Determine whether we're being used in inline or block mode
// Return the text and type of the target var parseAsInline = !this.parseTreeNode.isBlock;
if(this.hasAttribute("$variable")) { if(this.transcludeMode === "inline") {
if(this.transcludeVariable) { parseAsInline = true;
// Transcluding a variable } else if(this.transcludeMode === "block") {
var variableInfo = this.getVariableInfo(this.transcludeVariable,{params: this.getOrderedTransclusionParameters()}); parseAsInline = false;
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; var parser;
// Get the parse tree // Get the parse tree
if(this.hasAttribute("$variable")) { if(this.hasAttribute("$variable")) {
@@ -222,24 +176,21 @@ TranscludeWidget.prototype.parseTransclusionTarget = function(parseAsInline) {
// Transcluding a variable // Transcluding a variable
var variableInfo = this.getVariableInfo(this.transcludeVariable,{params: this.getOrderedTransclusionParameters()}), var variableInfo = this.getVariableInfo(this.transcludeVariable,{params: this.getOrderedTransclusionParameters()}),
srcVariable = variableInfo && variableInfo.srcVariable; srcVariable = variableInfo && variableInfo.srcVariable;
if(srcVariable && srcVariable.isFunctionDefinition) {
this.transcludeVariableIsFunction = true;
this.transcludeFunctionResult = (variableInfo.resultList ? variableInfo.resultList[0] : variableInfo.text) || "";
}
if(variableInfo.text) { if(variableInfo.text) {
if(srcVariable && srcVariable.isFunctionDefinition) { if(srcVariable.isFunctionDefinition) {
var result = (variableInfo.resultList ? variableInfo.resultList[0] : variableInfo.text) || "";
parser = { parser = {
tree: [{ tree: [{
type: "text", type: "text",
text: this.transcludeFunctionResult text: result
}], }],
source: this.transcludeFunctionResult, source: result,
type: "text/vnd.tiddlywiki" type: "text/vnd.tiddlywiki"
}; };
if(parseAsInline) { if(parseAsInline) {
parser.tree[0] = { parser.tree[0] = {
type: "text", type: "text",
text: this.transcludeFunctionResult text: result
}; };
} else { } else {
parser.tree[0] = { parser.tree[0] = {
@@ -247,7 +198,7 @@ TranscludeWidget.prototype.parseTransclusionTarget = function(parseAsInline) {
tag: "p", tag: "p",
children: [{ children: [{
type: "text", type: "text",
text: this.transcludeFunctionResult text: result
}] }]
} }
} }
@@ -256,7 +207,7 @@ TranscludeWidget.prototype.parseTransclusionTarget = function(parseAsInline) {
if(variableInfo.isCacheable && srcVariable[cacheKey]) { if(variableInfo.isCacheable && srcVariable[cacheKey]) {
parser = srcVariable[cacheKey]; parser = srcVariable[cacheKey];
} else { } else {
parser = this.wiki.parseText(this.transcludeType,variableInfo.text || "",{parseAsInline: parseAsInline, configTrimWhiteSpace: srcVariable && srcVariable.configTrimWhiteSpace}); parser = this.wiki.parseText(this.transcludeType,variableInfo.text || "",{parseAsInline: parseAsInline, configTrimWhiteSpace: srcVariable.configTrimWhiteSpace});
if(variableInfo.isCacheable) { if(variableInfo.isCacheable) {
srcVariable[cacheKey] = parser; srcVariable[cacheKey] = parser;
} }
@@ -264,7 +215,7 @@ TranscludeWidget.prototype.parseTransclusionTarget = function(parseAsInline) {
} }
if(parser) { if(parser) {
// Add parameters widget for procedures and custom widgets // Add parameters widget for procedures and custom widgets
if(srcVariable && (srcVariable.isProcedureDefinition || srcVariable.isWidgetDefinition)) { if(srcVariable.isProcedureDefinition || srcVariable.isWidgetDefinition) {
parser = { parser = {
tree: [ tree: [
{ {
@@ -283,7 +234,7 @@ TranscludeWidget.prototype.parseTransclusionTarget = function(parseAsInline) {
} }
$tw.utils.addAttributeToParseTreeNode(parser.tree[0],name,param["default"]) $tw.utils.addAttributeToParseTreeNode(parser.tree[0],name,param["default"])
}); });
} else if(srcVariable && !srcVariable.isFunctionDefinition) { } else if(srcVariable.isMacroDefinition || !srcVariable.isFunctionDefinition) {
// For macros and ordinary variables, wrap the parse tree in a vars widget assigning the parameters to variables named "__paramname__" // For macros and ordinary variables, wrap the parse tree in a vars widget assigning the parameters to variables named "__paramname__"
parser = { parser = {
tree: [ tree: [
@@ -314,14 +265,27 @@ TranscludeWidget.prototype.parseTransclusionTarget = function(parseAsInline) {
defaultType: this.transcludeType defaultType: this.transcludeType
}); });
} }
// Set 'thisTiddler'
this.setVariable("thisTiddler",this.transcludeTitle);
// Return the parse tree // Return the parse tree
return { if(parser) {
parser: parser, return {
parseTreeNodes: parser ? parser.tree : (this.slotFillParseTrees["ts-missing"] || []), parser: parser,
parseAsInline: parseAsInline, parseTreeNodes: parser.tree,
text: parser && parser.source, parseAsInline: parseAsInline,
type: parser && parser.type text: parser.source,
}; type: parser.type
};
} else {
// If there's no parse tree then return the missing slot value
return {
parser: null,
parseTreeNodes: (this.slotFillParseTrees["ts-missing"] || []),
parseAsInline: parseAsInline,
text: null,
type: null
};
}
}; };
/* /*
@@ -436,19 +400,12 @@ TranscludeWidget.prototype.parserNeedsRefresh = function() {
return (this.sourceText === undefined || parserInfo.sourceText !== this.sourceText || parserInfo.parserType !== this.parserType) return (this.sourceText === undefined || parserInfo.sourceText !== this.sourceText || parserInfo.parserType !== this.parserType)
}; };
TranscludeWidget.prototype.functionNeedsRefresh = function() {
var oldResult = this.transcludeFunctionResult;
var variableInfo = this.getVariableInfo(this.transcludeVariable,{params: this.getOrderedTransclusionParameters()});
var newResult = (variableInfo.resultList ? variableInfo.resultList[0] : variableInfo.text) || "";
return oldResult !== newResult;
}
/* /*
Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering
*/ */
TranscludeWidget.prototype.refresh = function(changedTiddlers) { TranscludeWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes(); var changedAttributes = this.computeAttributes();
if(($tw.utils.count(changedAttributes) > 0) || (this.transcludeVariableIsFunction && this.functionNeedsRefresh()) || (!this.transcludeVariable && changedTiddlers[this.transcludeTitle] && this.parserNeedsRefresh())) { if(($tw.utils.count(changedAttributes) > 0) || (!this.transcludeVariable && changedTiddlers[this.transcludeTitle] && this.parserNeedsRefresh())) {
this.refreshSelf(); this.refreshSelf();
return true; return true;
} else { } else {

View File

@@ -182,7 +182,8 @@ Widget.prototype.getVariableInfo = function(name,options) {
} }
return { return {
text: text, text: text,
resultList: [text] resultList: [text],
srcVariable: {}
}; };
}; };
@@ -379,8 +380,6 @@ Widget.prototype.computeAttribute = function(attribute) {
} else if(attribute.type === "macro") { } else if(attribute.type === "macro") {
var variableInfo = this.getVariableInfo(attribute.value.name,{params: attribute.value.params}); var variableInfo = this.getVariableInfo(attribute.value.name,{params: attribute.value.params});
value = variableInfo.text; value = variableInfo.text;
} else if(attribute.type === "substituted") {
value = this.wiki.getSubstitutedText(attribute.rawValue,this) || "";
} else { // String attribute } else { // String attribute
value = attribute.value; value = attribute.value;
} }
@@ -719,23 +718,44 @@ Widget.prototype.findFirstDomNode = function() {
}; };
/* /*
Remove any DOM nodes created by this widget or its children Entry into destroy procedure
*/
Widget.prototype.destroyChildren = function() {
$tw.utils.each(this.children,function(childWidget) {
childWidget.destroy();
});
};
/*
Legacy entry into destroy procedure
*/ */
Widget.prototype.removeChildDomNodes = function() { Widget.prototype.removeChildDomNodes = function() {
// If this widget has directly created DOM nodes, delete them and exit. This assumes that any child widgets are contained within the created DOM nodes, which would normally be the case this.destroy();
};
/*
Default destroy
*/
Widget.prototype.destroy = function() {
// call children to remove their resources
this.destroyChildren();
// remove our resources
this.children = [];
this.removeLocalDomNodes();
};
/*
Remove any DOM nodes created by this widget
*/
Widget.prototype.removeLocalDomNodes = function() {
// If this widget has directly created DOM nodes, delete them and exit.
if(this.domNodes.length > 0) { if(this.domNodes.length > 0) {
$tw.utils.each(this.domNodes,function(domNode) { $tw.utils.each(this.domNodes,function(domNode) {
domNode.parentNode.removeChild(domNode); domNode.parentNode.removeChild(domNode);
}); });
this.domNodes = []; this.domNodes = [];
} else {
// Otherwise, ask the child widgets to delete their DOM nodes
$tw.utils.each(this.children,function(childWidget) {
childWidget.removeChildDomNodes();
});
} }
}; };
/* /*
Invoke the action widgets that are descendents of the current widget. Invoke the action widgets that are descendents of the current widget.
*/ */

View File

@@ -1063,34 +1063,6 @@ exports.getTextReferenceParserInfo = function(title,field,index,options) {
return parserInfo; return parserInfo;
} }
/*
Parse a block of text of a specified MIME type
text: text on which to perform substitutions
widget
options: see below
Options include:
substitutions: an optional array of substitutions
*/
exports.getSubstitutedText = function(text,widget,options) {
options = options || {};
text = text || "";
var self = this,
substitutions = options.substitutions || [],
output;
// Evaluate embedded filters and substitute with first result
output = text.replace(/\$\{([\S\s]+?)\}\$/g, function(match,filter) {
return self.filterTiddlers(filter,widget)[0] || "";
});
// Process any substitutions provided in options
$tw.utils.each(substitutions,function(substitute) {
output = $tw.utils.replaceString(output,new RegExp("\\$" + $tw.utils.escapeRegExp(substitute.name) + "\\$","mg"),substitute.value);
});
// Substitute any variable references with their values
return output.replace(/\$\(([^\)\$]+)\)\$/g, function(match,varname) {
return widget.getVariable(varname,{defaultValue: ""})
});
};
/* /*
Make a widget tree for a parse tree Make a widget tree for a parse tree
parser: parser object parser: parser object

View File

@@ -12,7 +12,8 @@ tc-page-container tc-page-view-$(storyviewTitle)$ tc-language-$(languageTitle)$
tv-config-toolbar-class={{$:/config/Toolbar/ButtonClass}} tv-config-toolbar-class={{$:/config/Toolbar/ButtonClass}}
tv-show-missing-links={{$:/config/MissingLinks}} tv-show-missing-links={{$:/config/MissingLinks}}
storyviewTitle={{$:/view}} storyviewTitle={{$:/view}}
languageTitle={{{ [{$:/language}get[name]] }}}> languageTitle={{{ [{$:/language}get[name]] }}}
tv-text-direction={{$:/config/DefaultTextDirection}}>
<div class=<<containerClasses>>> <div class=<<containerClasses>>>

View File

@@ -1,4 +1,3 @@
code-body: yes
title: $:/core/ui/AlertTemplate title: $:/core/ui/AlertTemplate
\whitespace trim \whitespace trim

View File

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

View File

@@ -1,4 +1,3 @@
code-body: yes
title: $:/core/ui/EditTemplate title: $:/core/ui/EditTemplate
\define delete-edittemplate-state-tiddlers() \define delete-edittemplate-state-tiddlers()
@@ -30,6 +29,7 @@ title: $:/core/ui/EditTemplate
data-tiddler-title=<<currentTiddler>> data-tiddler-title=<<currentTiddler>>
data-tags={{!!tags}} data-tags={{!!tags}}
class={{{ [all[shadows+tiddlers]tag[$:/tags/ClassFilters/TiddlerTemplate]!is[draft]] :map:flat[subfilter{!!text}] tc-tiddler-frame tc-tiddler-edit-frame [<currentTiddler>is[tiddler]then[tc-tiddler-exists]] [<currentTiddler>is[missing]!is[shadow]then[tc-tiddler-missing]] [<currentTiddler>is[shadow]then[tc-tiddler-exists tc-tiddler-shadow]] [<currentTiddler>is[system]then[tc-tiddler-system]] [{!!class}] [<currentTiddler>tags[]encodeuricomponent[]addprefix[tc-tagged-]] +[join[ ]] }}} class={{{ [all[shadows+tiddlers]tag[$:/tags/ClassFilters/TiddlerTemplate]!is[draft]] :map:flat[subfilter{!!text}] tc-tiddler-frame tc-tiddler-edit-frame [<currentTiddler>is[tiddler]then[tc-tiddler-exists]] [<currentTiddler>is[missing]!is[shadow]then[tc-tiddler-missing]] [<currentTiddler>is[shadow]then[tc-tiddler-exists tc-tiddler-shadow]] [<currentTiddler>is[system]then[tc-tiddler-system]] [{!!class}] [<currentTiddler>tags[]encodeuricomponent[]addprefix[tc-tagged-]] +[join[ ]] }}}
dir=<<tv-text-direction>>
role="region" role="region"
aria-label={{$:/language/EditTemplate/Caption}}> aria-label={{$:/language/EditTemplate/Caption}}>
<$fieldmangler> <$fieldmangler>

View File

@@ -9,6 +9,7 @@ title: $:/core/ui/EditTemplate/body/editor
placeholder={{$:/language/EditTemplate/Body/Placeholder}} placeholder={{$:/language/EditTemplate/Body/Placeholder}}
tabindex={{$:/config/EditTabIndex}} tabindex={{$:/config/EditTabIndex}}
focus={{{ [{$:/config/AutoFocus}match[text]then[true]] ~[[false]] }}} focus={{{ [{$:/config/AutoFocus}match[text]then[true]] ~[[false]] }}}
dir=<<tv-text-direction>>
cancelPopups="yes" cancelPopups="yes"
fileDrop={{{ [{$:/config/DragAndDrop/Enable}match[no]] :else[subfilter{$:/config/Editor/EnableImportFilter}then[yes]else[no]] }}} fileDrop={{{ [{$:/config/DragAndDrop/Enable}match[no]] :else[subfilter{$:/config/Editor/EnableImportFilter}then[yes]else[no]] }}}

View File

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

View File

@@ -5,7 +5,7 @@ tags: $:/tags/EditTemplate
$:/config/EditToolbarButtons/Visibility/$(listItem)$ $:/config/EditToolbarButtons/Visibility/$(listItem)$
\end \end
\whitespace trim \whitespace trim
<div class="tc-tiddler-title tc-tiddler-edit-title"> <div class="tc-tiddler-title tc-tiddler-edit-title" dir=<<tv-text-direction>>>
<$view field="title"/> <$view field="title"/>
<span class="tc-tiddler-controls tc-titlebar"><$list filter="[all[shadows+tiddlers]tag[$:/tags/EditToolbar]!has[draft.of]]" variable="listItem"><$let tv-config-toolbar-class={{{ [enlist<tv-config-toolbar-class>] [<listItem>encodeuricomponent[]addprefix[tc-btn-]] +[join[ ]]}}}><$reveal type="nomatch" state=<<config-title>> text="hide"><$transclude tiddler=<<listItem>>/></$reveal></$let></$list></span> <span class="tc-tiddler-controls tc-titlebar"><$list filter="[all[shadows+tiddlers]tag[$:/tags/EditToolbar]!has[draft.of]]" variable="listItem"><$let tv-config-toolbar-class={{{ [enlist<tv-config-toolbar-class>] [<listItem>encodeuricomponent[]addprefix[tc-btn-]] +[join[ ]]}}}><$reveal type="nomatch" state=<<config-title>> text="hide"><$transclude tiddler=<<listItem>>/></$reveal></$let></$list></span>
<div style="clear: both;"></div> <div style="clear: both;"></div>

View File

@@ -74,7 +74,7 @@ $value={{{ [subfilter<get-field-value-tiddler-filter>get[text]] }}}/>
\whitespace trim \whitespace trim
<$set name="newFieldValueTiddlerPrefix" value=<<newFieldValueTiddlerPrefix>> emptyValue=<<qualify "$:/temp/NewFieldValue">> > <$set name="newFieldValueTiddlerPrefix" value=<<newFieldValueTiddlerPrefix>> emptyValue=<<qualify "$:/temp/NewFieldValue">> >
<div class="tc-edit-fields"> <div class="tc-edit-fields" dir=<<tv-text-direction>>>
<table class={{{ [all[current]fields[]] :filter[lookup[$:/config/EditTemplateFields/Visibility/]!match[hide]] +[count[]!match[0]] +[then[tc-edit-fields]] ~[[tc-edit-fields tc-edit-fields-small]] }}}> <table class={{{ [all[current]fields[]] :filter[lookup[$:/config/EditTemplateFields/Visibility/]!match[hide]] +[count[]!match[0]] +[then[tc-edit-fields]] ~[[tc-edit-fields tc-edit-fields-small]] }}}>
<tbody> <tbody>
<$list filter="[all[current]fields[]] +[sort[title]]" variable="currentField" storyview="pop"> <$list filter="[all[current]fields[]] +[sort[title]]" variable="currentField" storyview="pop">
@@ -89,7 +89,7 @@ $value={{{ [subfilter<get-field-value-tiddler-filter>get[text]] }}}/>
</td> </td>
<td class="tc-edit-field-remove"> <td class="tc-edit-field-remove">
<$button class="tc-btn-invisible" tooltip={{$:/language/EditTemplate/Field/Remove/Hint}} aria-label={{$:/language/EditTemplate/Field/Remove/Caption}}> <$button class="tc-btn-invisible" tooltip={{$:/language/EditTemplate/Field/Remove/Hint}} aria-label={{$:/language/EditTemplate/Field/Remove/Caption}}>
<$action-deletefield $field=<<currentField>>/> <$action-deletefield $field=<<currentField>>/><$set name="currentTiddlerCSSescaped" value={{{ [<currentTiddler>escapecss[]] }}}><$action-sendmessage $message="tm-focus-selector" $param=<<current-tiddler-new-field-selector>>/></$set>
{{$:/core/images/delete-button}} {{$:/core/images/delete-button}}
</$button> </$button>
</td> </td>
@@ -101,7 +101,7 @@ $value={{{ [subfilter<get-field-value-tiddler-filter>get[text]] }}}/>
</div> </div>
<$fieldmangler> <$fieldmangler>
<div class="tc-edit-field-add"> <div class="tc-edit-field-add" dir=<<tv-text-direction>>>
<em class="tc-edit tc-small-gap-right"> <em class="tc-edit tc-small-gap-right">
<<lingo Fields/Add/Prompt>> <<lingo Fields/Add/Prompt>>
</em> </em>

View File

@@ -14,7 +14,7 @@ tags: $:/tags/EditTemplate
<$list filter="[all[current]shadowsource[]]" variable="pluginTitle"> <$list filter="[all[current]shadowsource[]]" variable="pluginTitle">
<$set name="pluginLink" value=<<pluginLinkBody>>> <$set name="pluginLink" value=<<pluginLinkBody>>>
<div class="tc-message-box"> <div class="tc-message-box" dir=<<tv-text-direction>>>
<<lingo Warning>> <<lingo Warning>>
@@ -29,7 +29,7 @@ tags: $:/tags/EditTemplate
<$list filter="[all[current]shadowsource[]]" variable="pluginTitle"> <$list filter="[all[current]shadowsource[]]" variable="pluginTitle">
<$set name="pluginLink" value=<<pluginLinkBody>>> <$set name="pluginLink" value=<<pluginLinkBody>>>
<div class="tc-message-box"> <div class="tc-message-box" dir=<<tv-text-direction>>>
<<lingo OverriddenWarning>> <<lingo OverriddenWarning>>

View File

@@ -27,7 +27,7 @@ color:$(foregroundColor)$;
\define edit-tags-template(tagField:"tags") \define edit-tags-template(tagField:"tags")
\whitespace trim \whitespace trim
<div class="tc-edit-tags"> <div class="tc-edit-tags" dir=<<tv-text-direction>>>
<$list filter="[list[!!$tagField$]sort[title]]" storyview="pop"> <$list filter="[list[!!$tagField$]sort[title]]" storyview="pop">
<$macrocall $name="tag-body" colour={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerColourFilter]!is[draft]get[text]] }}} palette={{$:/palette}} icon={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerIconFilter]!is[draft]get[text]] }}} tagField=<<__tagField__>>/> <$macrocall $name="tag-body" colour={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerColourFilter]!is[draft]get[text]] }}} palette={{$:/palette}} icon={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerIconFilter]!is[draft]get[text]] }}} tagField=<<__tagField__>>/>
</$list> </$list>

View File

@@ -2,13 +2,13 @@ title: $:/core/ui/EditTemplate/title
tags: $:/tags/EditTemplate tags: $:/tags/EditTemplate
\whitespace trim \whitespace trim
<$edit-text field="draft.title" class="tc-titlebar tc-edit-texteditor" focus={{{ [{$:/config/AutoFocus}match[title]then[true]] ~[[false]] }}} tabindex={{$:/config/EditTabIndex}} cancelPopups="yes"/> <$edit-text field="draft.title" class="tc-titlebar tc-edit-texteditor" focus={{{ [{$:/config/AutoFocus}match[title]then[true]] ~[[false]] }}} tabindex={{$:/config/EditTabIndex}} cancelPopups="yes" dir=<<tv-text-direction>>/>
<$vars pattern="""[\|\[\]{}]""" bad-chars="""`| [ ] { }`"""> <$vars pattern="""[\|\[\]{}]""" bad-chars="""`| [ ] { }`""">
<$list filter="[all[current]regexp:draft.title<pattern>]" variable="listItem"> <$list filter="[all[current]regexp:draft.title<pattern>]" variable="listItem">
<div class="tc-message-box"> <div class="tc-message-box" dir=<<tv-text-direction>>>
{{$:/core/images/warning}}&#32;{{$:/language/EditTemplate/Title/BadCharacterWarning}} {{$:/core/images/warning}}&#32;{{$:/language/EditTemplate/Title/BadCharacterWarning}}
@@ -18,7 +18,7 @@ tags: $:/tags/EditTemplate
</$vars> </$vars>
<$reveal state="!!draft.title" type="nomatch" text={{!!draft.of}} tag="div"> <$reveal state="!!draft.title" type="nomatch" text={{!!draft.of}} tag="div" dir=<<tv-text-direction>>>
<$list filter="[{!!draft.title}!is[missing]]" variable="listItem"> <$list filter="[{!!draft.title}!is[missing]]" variable="listItem">

View File

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

View File

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

View File

@@ -1,6 +1,5 @@
title: $:/core/ui/ImportPreviews/Text title: $:/core/ui/ImportPreviews/Text
tags: $:/tags/ImportPreview tags: $:/tags/ImportPreview
caption: {{$:/language/Import/Listing/Preview/Text}} caption: {{$:/language/Import/Listing/Preview/Text}}
code-body: yes
<$transclude tiddler=<<currentTiddler>> subtiddler=<<payloadTiddler>> mode="block"/> <$transclude tiddler=<<currentTiddler>> subtiddler=<<payloadTiddler>> mode="block"/>

View File

@@ -3,14 +3,15 @@ tags: $:/tags/MoreSideBar
caption: {{$:/language/SideBar/Tags/Caption}} caption: {{$:/language/SideBar/Tags/Caption}}
\whitespace trim \whitespace trim
<$let tv-config-toolbar-icons="yes" tv-config-toolbar-text="yes" tv-config-toolbar-class=""> <$let tv-config-toolbar-icons="yes" tv-config-toolbar-text="yes" tv-config-toolbar-class="">
<div class="tc-tiny-v-gap-bottom"> <div class="tc-tiny-v-gap-bottom">
{{$:/core/ui/Buttons/tag-manager}} {{$:/core/ui/Buttons/tag-manager}}
</div> </div>
</$let> </$let>
<$list filter={{$:/core/Filters/AllTags!!filter}}> <$list filter={{$:/core/Filters/AllTags!!filter}}>
<div class="tc-tiny-v-gap-bottom"> <div class="tc-tiny-v-gap-bottom">
<$transclude tiddler="$:/core/ui/TagTemplate"/> <$transclude tiddler="$:/core/ui/TagTemplate"/>
</div> </div>
</$list> </$list>
<hr class="tc-untagged-separator"> <hr class="tc-untagged-separator">

View File

@@ -1,5 +1,4 @@
title: $:/core/ui/PageStylesheet title: $:/core/ui/PageStylesheet
code-body: yes
\import [subfilter{$:/core/config/GlobalImportFilter}] \import [subfilter{$:/core/config/GlobalImportFilter}]
\whitespace trim \whitespace trim

View File

@@ -2,7 +2,6 @@ title: $:/core/ui/PageTemplate
name: {{$:/language/PageTemplate/Name}} name: {{$:/language/PageTemplate/Name}}
description: {{$:/language/PageTemplate/Description}} description: {{$:/language/PageTemplate/Description}}
icon: $:/core/images/layout-button icon: $:/core/images/layout-button
code-body: yes
\whitespace trim \whitespace trim
\import [subfilter{$:/core/config/GlobalImportFilter}] \import [subfilter{$:/core/config/GlobalImportFilter}]
@@ -14,13 +13,14 @@ code-body: yes
tv-enable-drag-and-drop={{$:/config/DragAndDrop/Enable}} tv-enable-drag-and-drop={{$:/config/DragAndDrop/Enable}}
tv-show-missing-links={{$:/config/MissingLinks}} tv-show-missing-links={{$:/config/MissingLinks}}
storyviewTitle={{$:/view}} storyviewTitle={{$:/view}}
languageTitle={{{ [{$:/language}get[name]] }}}> languageTitle={{{ [{$:/language}get[name]] }}}
tv-text-direction={{$:/config/DefaultTextDirection}}>
<div class={{{ [all[shadows+tiddlers]tag[$:/tags/ClassFilters/PageTemplate]!is[draft]] :map:flat[subfilter{!!text}] tc-page-container [[tc-page-view-]addsuffix<storyviewTitle>] [[tc-language-]addsuffix<languageTitle>] :and[unique[]join[ ]] }}} > <div class={{{ [all[shadows+tiddlers]tag[$:/tags/ClassFilters/PageTemplate]!is[draft]] :map:flat[subfilter{!!text}] tc-page-container [[tc-page-view-]addsuffix<storyviewTitle>] [[tc-language-]addsuffix<languageTitle>] :and[unique[]join[ ]] }}} >
<$navigator story="$:/StoryList" history="$:/HistoryList" openLinkFromInsideRiver={{$:/config/Navigation/openLinkFromInsideRiver}} openLinkFromOutsideRiver={{$:/config/Navigation/openLinkFromOutsideRiver}} relinkOnRename={{$:/config/RelinkOnRename}}> <$navigator story="$:/StoryList" history="$:/HistoryList" openLinkFromInsideRiver={{$:/config/Navigation/openLinkFromInsideRiver}} openLinkFromOutsideRiver={{$:/config/Navigation/openLinkFromOutsideRiver}} relinkOnRename={{$:/config/RelinkOnRename}}>
<$dropzone enable=<<tv-enable-drag-and-drop>> class="tc-dropzone tc-page-container-inner"> <$dropzone enable=<<tv-enable-drag-and-drop>>>
<$list filter="[all[shadows+tiddlers]tag[$:/tags/PageTemplate]!has[draft.of]]" variable="listItem"> <$list filter="[all[shadows+tiddlers]tag[$:/tags/PageTemplate]!has[draft.of]]" variable="listItem">

View File

@@ -1,5 +1,4 @@
title: $:/core/ui/RootTemplate title: $:/core/ui/RootTemplate
code-body: yes
<$transclude tiddler={{{ [{$:/layout}has[text]] ~[[$:/core/ui/PageTemplate]] }}} mode="inline"/> <$transclude tiddler={{{ [{$:/layout}has[text]] ~[[$:/core/ui/PageTemplate]] }}} mode="inline"/>

View File

@@ -1,4 +1,3 @@
title: $:/core/ui/StoryTiddlerTemplate title: $:/core/ui/StoryTiddlerTemplate
code-body: yes
<$transclude tiddler={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/StoryTiddlerTemplateFilter]!is[draft]get[text]] :and[has[title]else[$:/core/ui/ViewTemplate]] }}} /> <$transclude tiddler={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/StoryTiddlerTemplateFilter]!is[draft]get[text]] :and[has[title]else[$:/core/ui/ViewTemplate]] }}} />

View File

@@ -2,29 +2,22 @@ title: $:/core/ui/TagPickerTagTemplate
\whitespace trim \whitespace trim
<$button class=<<button-classes>> tag="a" tooltip={{$:/language/EditTemplate/Tags/Add/Button/Hint}}> <$button class=<<button-classes>> tag="a" tooltip={{$:/language/EditTemplate/Tags/Add/Button/Hint}}>
<$list filter="[<saveTiddler>minlength[1]]"> <$list filter="[<saveTiddler>minlength[1]]">
<$action-listops $tiddler=<<saveTiddler>> $field=<<tagField>> $subfilter="[<tag>]"/> <$action-listops $tiddler=<<saveTiddler>> $field=<<tagField>> $subfilter="[<tag>]"/>
</$list> </$list>
<$set name="currentTiddlerCSSEscaped" value={{{ [<saveTiddler>escapecss[]] }}}> <$set name="currentTiddlerCSSEscaped" value={{{ [<saveTiddler>escapecss[]] }}}>
<$action-sendmessage $message="tm-focus-selector" $param=<<get-tagpicker-focus-selector>> preventScroll="true"/> <$action-sendmessage $message="tm-focus-selector" $param=<<get-tagpicker-focus-selector>> preventScroll="true"/>
</$set> </$set>
<<delete-tag-state-tiddlers>> <<delete-tag-state-tiddlers>>
<$list filter="[<refreshTitle>minlength[1]]"> <$list filter="[<refreshTitle>minlength[1]]">
<$action-setfield $tiddler=<<refreshTitle>> text="yes"/> <$action-setfield $tiddler=<<refreshTitle>> text="yes"/>
</$list> </$list>
<<actions>> <<actions>>
<$set name="backgroundColor" <$set name="backgroundColor" value={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerColourFilter]!is[draft]get[text]] }}}>
value={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerColourFilter]!is[draft]get[text]] }}} <$wikify name="foregroundColor" text="""<$macrocall $name="contrastcolour" target=<<backgroundColor>> fallbackTarget=<<fallbackTarget>> colourA=<<colourA>> colourB=<<colourB>>/>""">
> <span class="tc-tag-label tc-btn-invisible" style=<<tag-pill-styles>> data-tag-title=<<currentTiddler>> >
<$wikify name="foregroundColor" {{||$:/core/ui/TiddlerIcon}}<$view field="title" format="text"/>
text="""<$macrocall $name="contrastcolour" target=<<backgroundColor>> fallbackTarget=<<fallbackTarget>> colourA=<<colourA>> colourB=<<colourB>>/>""" </span>
> </$wikify>
<span class="tc-tag-label tc-btn-invisible" </$set>
style=<<tag-pill-styles>>
data-tag-title=<<currentTiddler>>
>
{{||$:/core/ui/TiddlerIcon}}<$view field="title" format="text"/>
</span>
</$wikify>
</$set>
</$button> </$button>

View File

@@ -3,23 +3,16 @@ title: $:/core/ui/TagTemplate
\whitespace trim \whitespace trim
<span class="tc-tag-list-item" data-tag-title=<<currentTiddler>>> <span class="tc-tag-list-item" data-tag-title=<<currentTiddler>>>
<$set name="transclusion" value=<<currentTiddler>>> <$set name="transclusion" value=<<currentTiddler>>>
<$macrocall $name="tag-pill-body" <$macrocall $name="tag-pill-body" tag=<<currentTiddler>> icon={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerIconFilter]!is[draft]get[text]] }}} colour={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerColourFilter]!is[draft]get[text]] }}} palette={{$:/palette}} element-tag="""$button""" element-attributes="""popup=<<qualify "$:/state/popup/tag">> dragFilter='[all[current]tagging[]]' tag='span'"""/>
tag=<<currentTiddler>> <$reveal state=<<qualify "$:/state/popup/tag">> type="popup" position="below" animate="yes" class="tc-drop-down">
icon={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerIconFilter]!is[draft]get[text]] }}} <$set name="tv-show-missing-links" value="yes">
colour={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerColourFilter]!is[draft]get[text]] }}} <$transclude tiddler="$:/core/ui/ListItemTemplate"/>
palette={{$:/palette}} </$set>
element-tag="$button" <$list filter="[all[shadows+tiddlers]tag[$:/tags/TagDropdown]!has[draft.of]]" variable="listItem">
element-attributes="""popup=<<qualify "$:/state/popup/tag">> dragFilter="[all[current]tagging[]]" tag='span'""" <$transclude tiddler=<<listItem>>/>
/> </$list>
<$reveal state=<<qualify "$:/state/popup/tag">> type="popup" position="below" animate="yes" class="tc-drop-down"> <hr>
<$set name="tv-show-missing-links" value="yes"> <$macrocall $name="list-tagged-draggable" tag=<<currentTiddler>>/>
<$transclude tiddler="$:/core/ui/ListItemTemplate"/> </$reveal>
</$set>
<$list filter="[all[shadows+tiddlers]tag[$:/tags/TagDropdown]!has[draft.of]]" variable="listItem">
<$transclude tiddler=<<listItem>>/>
</$list>
<hr>
<$macrocall $name="list-tagged-draggable" tag=<<currentTiddler>>/>
</$reveal>
</$set> </$set>
</span> </span>

View File

@@ -1,5 +1,4 @@
title: $:/core/ui/ViewTemplate title: $:/core/ui/ViewTemplate
code-body: yes
\whitespace trim \whitespace trim
\define folded-state() \define folded-state()
@@ -8,7 +7,7 @@ $:/state/folded/$(currentTiddler)$
\define cancel-delete-tiddler-actions(message) <$action-sendmessage $message="tm-$message$-tiddler"/> \define cancel-delete-tiddler-actions(message) <$action-sendmessage $message="tm-$message$-tiddler"/>
\import [all[shadows+tiddlers]tag[$:/tags/Macro/View]!is[draft]] [all[shadows+tiddlers]tag[$:/tags/Global/View]!is[draft]] \import [all[shadows+tiddlers]tag[$:/tags/Macro/View]!is[draft]] [all[shadows+tiddlers]tag[$:/tags/Global/View]!is[draft]]
<$vars storyTiddler=<<currentTiddler>> tiddlerInfoState=<<qualify "$:/state/popup/tiddler-info">>> <$vars storyTiddler=<<currentTiddler>> tiddlerInfoState=<<qualify "$:/state/popup/tiddler-info">>>
<div data-tiddler-title=<<currentTiddler>> data-tags={{!!tags}} class={{{ [all[shadows+tiddlers]tag[$:/tags/ClassFilters/TiddlerTemplate]!is[draft]] :map:flat[subfilter{!!text}] tc-tiddler-frame tc-tiddler-view-frame [<currentTiddler>is[tiddler]then[tc-tiddler-exists]] [<currentTiddler>is[missing]!is[shadow]then[tc-tiddler-missing]] [<currentTiddler>is[shadow]then[tc-tiddler-exists tc-tiddler-shadow]] [<currentTiddler>is[shadow]is[tiddler]then[tc-tiddler-overridden-shadow]] [<currentTiddler>is[system]then[tc-tiddler-system]] [{!!class}] [<currentTiddler>tags[]encodeuricomponent[]addprefix[tc-tagged-]] +[join[ ]] }}} role="article"> <div dir=<<tv-text-direction>> data-tiddler-title=<<currentTiddler>> data-tags={{!!tags}} class={{{ [all[shadows+tiddlers]tag[$:/tags/ClassFilters/TiddlerTemplate]!is[draft]] :map:flat[subfilter{!!text}] tc-tiddler-frame tc-tiddler-view-frame [<currentTiddler>is[tiddler]then[tc-tiddler-exists]] [<currentTiddler>is[missing]!is[shadow]then[tc-tiddler-missing]] [<currentTiddler>is[shadow]then[tc-tiddler-exists tc-tiddler-shadow]] [<currentTiddler>is[shadow]is[tiddler]then[tc-tiddler-overridden-shadow]] [<currentTiddler>is[system]then[tc-tiddler-system]] [{!!class}] [<currentTiddler>tags[]encodeuricomponent[]addprefix[tc-tagged-]] +[join[ ]] }}} role="article">
<$list filter="[all[shadows+tiddlers]tag[$:/tags/ViewTemplate]!is[draft]]" variable="listItem"> <$list filter="[all[shadows+tiddlers]tag[$:/tags/ViewTemplate]!is[draft]]" variable="listItem">
<$transclude tiddler=<<listItem>>/> <$transclude tiddler=<<listItem>>/>
</$list> </$list>

View File

@@ -3,7 +3,7 @@ tags: $:/tags/ViewTemplate
\import [all[shadows+tiddlers]tag[$:/tags/Macro/View/Body]!is[draft]] [all[shadows+tiddlers]tag[$:/tags/Global/View/Body]!is[draft]] \import [all[shadows+tiddlers]tag[$:/tags/Macro/View/Body]!is[draft]] [all[shadows+tiddlers]tag[$:/tags/Global/View/Body]!is[draft]]
<$reveal tag="div" class="tc-tiddler-body" type="nomatch" stateTitle=<<folded-state>> text="hide" retain="yes" animate="yes"> <$reveal tag="div" class="tc-tiddler-body" type="nomatch" stateTitle=<<folded-state>> text="hide" retain="yes" animate="yes" dir=<<tv-text-direction>>>
<$transclude tiddler={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/ViewTemplateBodyFilter]!is[draft]get[text]] :and[!is[blank]else[$:/core/ui/ViewTemplate/body/default]] }}} /> <$transclude tiddler={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/ViewTemplateBodyFilter]!is[draft]get[text]] :and[!is[blank]else[$:/core/ui/ViewTemplate/body/default]] }}} />

View File

@@ -1,5 +1,4 @@
title: $:/core/ui/ViewTemplate/body/default title: $:/core/ui/ViewTemplate/body/default
code-body: yes
<$transclude> <$transclude>

View File

@@ -3,7 +3,7 @@ tags: $:/tags/ViewTemplate
\whitespace trim \whitespace trim
<$reveal type="nomatch" stateTitle=<<folded-state>> text="hide" tag="div" retain="yes" animate="yes"> <$reveal type="nomatch" stateTitle=<<folded-state>> text="hide" tag="div" retain="yes" animate="yes">
<div class="tc-subtitle"> <div class="tc-subtitle" dir=<<tv-text-direction>>>
<$list filter="[all[shadows+tiddlers]tag[$:/tags/ViewTemplate/Subtitle]!has[draft.of]]" variable="subtitleTiddler" counter="indexSubtitleTiddler"> <$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 filter="[<indexSubtitleTiddler-first>match[no]]" variable="ignore">
&nbsp; &nbsp;

View File

@@ -3,5 +3,5 @@ tags: $:/tags/ViewTemplate
\whitespace trim \whitespace trim
<$reveal type="nomatch" stateTitle=<<folded-state>> text="hide" tag="div" retain="yes" animate="yes"> <$reveal type="nomatch" stateTitle=<<folded-state>> text="hide" tag="div" retain="yes" animate="yes">
<div class="tc-tags-wrapper"><$list filter="[all[current]tags[]sort[title]]" template="$:/core/ui/TagTemplate" storyview="pop"/></div> <div class="tc-tags-wrapper" dir=<<tv-text-direction>>><$list filter="[all[current]tags[]sort[title]]" template="$:/core/ui/TagTemplate" storyview="pop"/></div>
</$reveal> </$reveal>

View File

@@ -6,7 +6,7 @@ tags: $:/tags/ViewTemplate
fill:$(foregroundColor)$; fill:$(foregroundColor)$;
\end \end
<div class="tc-tiddler-title"> <div class="tc-tiddler-title">
<div class="tc-titlebar"> <div class="tc-titlebar" dir=<<tv-text-direction>>>
<span class="tc-tiddler-controls"> <span class="tc-tiddler-controls">
<$list filter="[all[shadows+tiddlers]tag[$:/tags/ViewToolbar]!has[draft.of]] :filter[lookup[$:/config/ViewToolbarButtons/Visibility/]!match[hide]]" storyview="pop" variable="listItem"><$set name="tv-config-toolbar-class" filter="[<tv-config-toolbar-class>] [<listItem>encodeuricomponent[]addprefix[tc-btn-]]"><$transclude tiddler=<<listItem>>/></$set></$list> <$list filter="[all[shadows+tiddlers]tag[$:/tags/ViewToolbar]!has[draft.of]] :filter[lookup[$:/config/ViewToolbarButtons/Visibility/]!match[hide]]" storyview="pop" variable="listItem"><$set name="tv-config-toolbar-class" filter="[<tv-config-toolbar-class>] [<listItem>encodeuricomponent[]addprefix[tc-btn-]]"><$transclude tiddler=<<listItem>>/></$set></$list>
</span> </span>

View File

@@ -0,0 +1,2 @@
title: $:/config/DefaultTextDirection
text: auto

View File

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

View File

@@ -2,8 +2,7 @@ title: $:/config/ViewTemplateBodyFilters/
tags: $:/tags/ViewTemplateBodyFilter tags: $:/tags/ViewTemplateBodyFilter
stylesheet: [tag[$:/tags/Stylesheet]then[$:/core/ui/ViewTemplate/body/rendered-plain-text]] stylesheet: [tag[$:/tags/Stylesheet]then[$:/core/ui/ViewTemplate/body/rendered-plain-text]]
core-ui-tags: [tag[$:/tags/PageTemplate]] [tag[$:/tags/EditTemplate]] [tag[$:/tags/ViewTemplate]] [tag[$:/tags/KeyboardShortcut]] [tag[$:/tags/ImportPreview]] [tag[$:/tags/EditPreview]][tag[$:/tags/EditorToolbar]] [tag[$:/tags/Actions]] :then[[$:/core/ui/ViewTemplate/body/code]] system: [prefix[$:/boot/]] [prefix[$:/config/]] [prefix[$:/core/macros]] [prefix[$:/core/save/]] [prefix[$:/core/templates/]] [prefix[$:/core/ui/]split[/]count[]compare:number:eq[4]] [prefix[$:/info/]] [prefix[$:/language/]] [prefix[$:/languages/]] [prefix[$:/snippets/]] [prefix[$:/state/]] [prefix[$:/status/]] [prefix[$:/info/]] [prefix[$:/temp/]] +[!is[image]limit[1]then[$:/core/ui/ViewTemplate/body/code]]
system: [prefix[$:/boot/]] [prefix[$:/config/]] [prefix[$:/core/macros]] [prefix[$:/core/save/]] [prefix[$:/core/templates/]] [prefix[$:/info/]] [prefix[$:/language/]] [prefix[$:/languages/]] [prefix[$:/snippets/]] [prefix[$:/state/]] [prefix[$:/status/]] [prefix[$:/info/]] [prefix[$:/temp/]] +[!is[image]limit[1]then[$:/core/ui/ViewTemplate/body/code]]
code-body: [field:code-body[yes]then[$:/core/ui/ViewTemplate/body/code]] code-body: [field:code-body[yes]then[$:/core/ui/ViewTemplate/body/code]]
import: [field:plugin-type[import]then[$:/core/ui/ViewTemplate/body/import]] import: [field:plugin-type[import]then[$:/core/ui/ViewTemplate/body/import]]
plugin: [has[plugin-type]then[$:/core/ui/ViewTemplate/body/plugin]] plugin: [has[plugin-type]then[$:/core/ui/ViewTemplate/body/plugin]]

View File

@@ -9,51 +9,26 @@ color:$(foregroundColor)$;
<!-- This has no whitespace trim to avoid modifying $actions$. Closing tags omitted for brevity. --> <!-- 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) \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$""">> foregroundColor=<<contrastcolour target:"""$colour$""" fallbackTarget:"""$fallbackTarget$""" colourA:"""$colourA$""" colourB:"""$colourB$""">>
backgroundColor=<<__colour__>> backgroundColor="""$colour$"""
> ><$element-tag$
<$element-tag$
$element-attributes$ $element-attributes$
class="tc-tag-label tc-btn-invisible" class="tc-tag-label tc-btn-invisible"
style=<<tag-pill-styles>> style=<<tag-pill-styles>>
> >$actions$<$transclude tiddler="""$icon$"""/><$view tiddler=<<__tag__>> field="title" format="text" /></$element-tag$>
<<__actions__>>
<$transclude tiddler=<<__icon__>>/>
<$view tiddler=<<__tag__>> field="title" format="text" />
</$element-tag$>
</$let>
\end \end
\define tag-pill-body(tag,icon,colour,palette,element-tag,element-attributes,actions) \define tag-pill-body(tag,icon,colour,palette,element-tag,element-attributes,actions)
\whitespace trim <$macrocall $name="tag-pill-inner" tag=<<__tag__>> icon="""$icon$""" colour="""$colour$""" fallbackTarget={{$palette$##tag-background}} colourA={{$palette$##foreground}} colourB={{$palette$##background}} element-tag="""$element-tag$""" element-attributes="""$element-attributes$""" actions="""$actions$"""/>
<$macrocall $name="tag-pill-inner"
tag=<<__tag__>>
icon=<<__icon__>>
colour=<<__colour__>>
fallbackTarget={{$palette$##tag-background}}
colourA={{$palette$##foreground}}
colourB={{$palette$##background}}
element-tag=<<__element-tag__>>
element-attributes=<<__element-attributes__>>
actions=<<__actions__>>
/>
\end \end
\define tag-pill(tag,element-tag:"span",element-attributes:"",actions:"") \define tag-pill(tag,element-tag:"span",element-attributes:"",actions:"")
\whitespace trim \whitespace trim
<span class="tc-tag-list-item" data-tag-title=<<__tag__>>> <span class="tc-tag-list-item" data-tag-title=<<__tag__>>>
<$let currentTiddler=<<__tag__>>> <$let currentTiddler=<<__tag__>>>
<$macrocall $name="tag-pill-body" <$macrocall $name="tag-pill-body" tag=<<__tag__>> icon={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerIconFilter]!is[draft]get[text]] }}} colour={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerColourFilter]!is[draft]get[text]] }}} palette={{$:/palette}} element-tag="""$element-tag$""" element-attributes="""$element-attributes$""" actions="""$actions$"""/>
tag=<<__tag__>> </$let>
icon={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerIconFilter]!is[draft]get[text]] }}}
colour={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerColourFilter]!is[draft]get[text]] }}}
palette={{$:/palette}}
element-tag=<<__element-tag__>>
element-attributes=<<__element-attributes__>>
actions=<<__actions__>>/>
</$let>
</span> </span>
\end \end

View File

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

View File

@@ -1,2 +1,3 @@
title: $:/tags/ViewTemplateBodyFilter title: $:/tags/ViewTemplateBodyFilter
list: $:/config/ViewTemplateBodyFilters/hide-body $:/config/ViewTemplateBodyFilters/code-body $:/config/ViewTemplateBodyFilters/stylesheet $:/config/ViewTemplateBodyFilters/core-ui-advanced-search $:/config/ViewTemplateBodyFilters/core-ui-tags $:/config/ViewTemplateBodyFilters/system $:/config/ViewTemplateBodyFilters/import $:/config/ViewTemplateBodyFilters/plugin $:/config/ViewTemplateBodyFilters/default list: $:/config/ViewTemplateBodyFilters/hide-body $:/config/ViewTemplateBodyFilters/code-body $:/config/ViewTemplateBodyFilters/stylesheet $:/config/ViewTemplateBodyFilters/system $:/config/ViewTemplateBodyFilters/import $:/config/ViewTemplateBodyFilters/plugin $:/config/ViewTemplateBodyFilters/default

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

View File

@@ -3,7 +3,7 @@
{ {
"file": "../../../tw5.com/tiddlers/images/New Release Banner.png", "file": "../../../tw5.com/tiddlers/images/New Release Banner.png",
"fields": { "fields": {
"type": "image/jpeg", "type": "image/jpg",
"title": "New Release Banner", "title": "New Release Banner",
"tags": "picture" "tags": "picture"
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

View File

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

View File

@@ -12,9 +12,6 @@
"empty": [ "empty": [
"--render","$:/core/save/all","empty.html","text/plain", "--render","$:/core/save/all","empty.html","text/plain",
"--render","$:/core/save/all","empty.hta","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": [ "externalimages": [
"--savetiddlers","[is[image]]","images", "--savetiddlers","[is[image]]","images",
"--setfield","[is[image]]","_canonical_uri","$:/core/templates/canonical-uri-external-image","text/plain", "--setfield","[is[image]]","_canonical_uri","$:/core/templates/canonical-uri-external-image","text/plain",
@@ -23,7 +20,7 @@
"static": [ "static": [
"--render","$:/core/templates/static.template.html","static.html","text/plain", "--render","$:/core/templates/static.template.html","static.html","text/plain",
"--render","$:/core/templates/alltiddlers.template.html","alltiddlers.html","text/plain", "--render","$:/core/templates/alltiddlers.template.html","alltiddlers.html","text/plain",
"--render","[!is[system]]","[encodeuricomponent[]addprefix[static/]addsuffix[.html]]","text/plain","$:/core/templates/static.tiddler.html", "--render","[!is[system]]","[encodeuricomponent[]addprefix[static/]addsuffix[.html]]","text/plain",
"--render","$:/core/templates/static.template.css","static/static.css","text/plain"] "--render","$:/core/templates/static.template.css","static/static.css","text/plain"]
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

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