1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2026-01-29 06:11:25 +00:00

Compare commits

..

9 Commits

Author SHA1 Message Date
saqimtiaz
5797855aa1 Merge branch 'saqimtiaz-patch-1' of https://github.com/jermolene/TiddlyWiki5 into fix-defaults-functions 2026-01-25 19:15:15 +01:00
saqimtiaz
d3fded71c2 Merge branch 'master' into fix-defaults-functions 2026-01-25 19:13:53 +01:00
Saq Imtiaz
293dbca5a1 Update #8972.tid 2026-01-25 19:08:11 +01:00
saqimtiaz
4d1645d16d fix: correctly resolve default values for functions 2026-01-25 18:32:22 +01:00
Saq Imtiaz
b58c14b906 Update #8972.tid 2026-01-25 17:45:28 +01:00
Saq Imtiaz
ad5d3c3cde Update function default values in FunctionDefaultValues.tid 2026-01-25 17:37:17 +01:00
Saq Imtiaz
f0d8852121 Add FunctionDefaultValues test for default parameters 2026-01-25 17:35:12 +01:00
Saq Imtiaz
48c6694d30 Enhance release notes for version 5.4.0
Updated GitHub links and contributors for release notes.
2026-01-25 17:30:35 +01:00
Saq Imtiaz
a993cea80c Fix: bug in multivalue default params 2026-01-25 17:28:22 +01:00
7 changed files with 34 additions and 45 deletions

View File

@@ -316,25 +316,8 @@ $tw.utils.htmlDecode = function(s) {
return s.toString().replace(/&lt;/mg,"<").replace(/&nbsp;/mg,"\xA0").replace(/&gt;/mg,">").replace(/&quot;/mg,"\"").replace(/&amp;/mg,"&");
};
/*
Get the browser location.hash. We don't use location.hash because of the way that Firefox auto-urldecodes it (see http://stackoverflow.com/questions/1703552/encoding-of-window-location-hash)
*/
$tw.utils.getLocationHash = function() {
const href = window.location.href,
idx = href.indexOf("#");
if(idx === -1) {
return "#";
}
const afterHash = href.substring(idx + 1);
if(afterHash.startsWith("#") || afterHash.startsWith("%23")) {
// Special case: ignore location hash if it itself starts with a #
return "#";
}
return href.substring(idx);
};
/** @deprecated Use window.location.hash instead. */
$tw.utils.getLocationHash = () => window.location.hash;
/** @deprecated Pad a string to a given length with "0"s. Length defaults to 2 */
$tw.utils.pad = function(value,length = 2) {

View File

@@ -82,8 +82,8 @@ SelectWidget.prototype.handleChangeEvent = function(event) {
if(this.selectMultiple == false) {
var value = this.getSelectDomNode().value;
} else {
var value = this.getSelectValues();
value = $tw.utils.stringifyList(value);
var value = this.getSelectValues()
value = $tw.utils.stringifyList(value);
}
this.wiki.setText(this.selectTitle,this.selectField,this.selectIndex,value);
// Trigger actions
@@ -118,7 +118,7 @@ SelectWidget.prototype.setSelectValue = function() {
}
}
// Assign it to the select element if it's different than the current value
if(this.selectMultiple) {
if (this.selectMultiple) {
value = value === undefined ? "" : value;
var select = this.getSelectDomNode();
var child,
@@ -156,14 +156,14 @@ SelectWidget.prototype.getSelectValues = function() {
select = this.getSelectDomNode();
result = [];
options = select && select.options;
for(var i=0; i<options.length; i++) {
for (var i=0; i<options.length; i++) {
opt = options[i];
if(opt.selected) {
if (opt.selected) {
result.push(opt.value || opt.text);
}
}
return result;
};
}
/*
Compute the internal state of the widget
@@ -192,7 +192,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
SelectWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes();
// If we're using a different tiddler/field/index then completely refresh ourselves
if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes.tooltip || changedAttributes.default || changedAttributes.tabindex || changedAttributes.disabled) {
if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes.tooltip || changedAttributes.tabindex || changedAttributes.disabled) {
this.refreshSelf();
return true;
} else {

View File

@@ -160,7 +160,7 @@ Widget.prototype.getVariableInfo = function(name,options) {
});
// Parameters are an array of {name:, value:, multivalue:} pairs (name and multivalue are optional)
$tw.utils.each(params,function(param) {
if(param.multiValue) {
if(param.multiValue && param.multiValue.length) {
variables[param.name] = param.multiValue;
} else {
variables[param.name] = param.value || "";
@@ -233,8 +233,10 @@ Widget.prototype.resolveVariableParameters = function(formalParams,actualParams)
paramMultiValue = typeof param === "string" ? [param] : (param.multiValue || [paramValue]);
}
// If we've still not got a value, use the default, if any
paramValue = paramValue || paramInfo["default"] || "";
paramMultiValue = paramMultiValue || [paramValue];
if(!paramValue) {
paramValue = paramInfo["default"] || "";
paramMultiValue = [paramValue];
}
// Store the parameter name and value
results.push({name: paramInfo.name, value: paramValue, multiValue: paramMultiValue});
}

View File

@@ -0,0 +1,16 @@
title: Functions/FunctionDefaultValues
description: Use defaults for missing parameters in functions in filters
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
\function .test(prefix:Default) [[ Content]addprefix<prefix>]
<$text text={{{ [.test[Special]] }}}/>,<$text text={{{ [.test[]] }}}/>
+
title: ExpectedResult
<p>Special Content,Default Content</p>

View File

@@ -4,8 +4,8 @@ release: 5.4.0
tags: $:/tags/ChangeNote
change-type: enhancement
change-category: hackability
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/8972
github-contributors: Jermolene
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/8972 https://github.com/TiddlyWiki/TiddlyWiki5/pull/9614
github-contributors: Jermolene saqimtiaz
This PR introduces a new filter run prefix `:let` that assigns the result of the filter run to a variable that is made available for the remaining filter runs of the filter expression. It solves the problem that previously it was impossible to compute values for filter operator parameters; parameters could only be a literal string, text reference or variable reference.

View File

@@ -1,12 +0,0 @@
change-category: usability
change-type: bugfix
created: 20260125195754439
description: Refresh widget if "default" parameter input value is changed
github-contributors: pmario
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/9217
modified: 20260125195754439
release: 5.4.0
tags: $:/tags/ChangeNote
title: $:/changenotes/5.4.0/#9217
type: text/vnd.tiddlywiki

View File

@@ -4,7 +4,7 @@ release: 5.4.0
tags: $:/tags/ChangeNote
change-type: deprecation
change-category: developer
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/9251 https://github.com/TiddlyWiki/TiddlyWiki5/pull/9622
github-contributors: Leilei332 saqimtiaz
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/9251
github-contributors: Leilei332
Deprecate some utility functions. Some of them are moved to [[$:/core/modules/utils/deprecated.js]].