1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2026-01-25 04:14:40 +00:00

Compare commits

...

13 Commits

Author SHA1 Message Date
Jeremy Ruston
f29de0cb44 Split the tests for clarity 2026-01-23 23:05:05 +00:00
Jeremy Ruston
a14cd291ac Do things properly, and set a data tag on the mapped element 2026-01-23 23:02:06 +00:00
Jeremy Ruston
b27d102d55 Support a class to be automatically added to transformed elements 2026-01-23 22:26:51 +00:00
Jeremy Ruston
9aaab87b87 Initial Commit 2026-01-23 22:23:48 +00:00
Saq Imtiaz
eb3a80968e docs: changenotes for previously merged PRs (#9599)
* docs: changenotes for previously merged PRs

* fix: added text field for changenotes
2026-01-21 09:08:50 +01:00
Mario Pietsch
62ae4b24bc allow space after const {}. Set keyword spacing to warning (#9589) 2026-01-20 22:03:43 +01:00
yaisog
ded76aa84f Fixes Ctrl-Enter not working in EditTemplate tag name input (#9600)
* Assign save-tiddler-actions to inputAcceptVariantActions

* Add changenote
2026-01-20 20:22:42 +01:00
XLBilly
e42ed6808e Split escapecss into two platforms (#9475)
* Split escapecss into to platforms

This will reduce core size slightly

* Update change note
2026-01-20 12:13:48 +01:00
yaisog
844564180f Fix LetWidget to always set all staged variables on first render (#9494)
* Always set all staged variables on first render

* Add changenote
2026-01-20 10:24:56 +00:00
Saq Imtiaz
a670de0e95 Fixes regressions in list-tagged-draggable (#9596)
* Fix regressions in list-tagged-draggable

* Remove trailing newline from list.tid
2026-01-20 10:01:02 +01:00
Bram Chen
faee49ee01 Update chinese language files (#9576)
* Update chinese language files
* add chinese translations for alert aria message

* Update chinese language files
* update related change note
2026-01-20 07:33:05 +01:00
yaisog
dd20be49f0 Make impact note for #9337 less verbose / repetitive (#9481)
* Make impact note less verbose / repetitive for #9337

* Correct some fields
2026-01-20 07:16:21 +01:00
Simon Huber
a27f74bbdc Fixes bug in sidebar tab Open to allow disabling drag and drop (#9504)
the variable is called `tv-enable-drag-and-drop` - not `tv-allow-drag-and-drop`
2026-01-20 07:06:29 +01:00
22 changed files with 285 additions and 114 deletions

View File

@@ -0,0 +1,95 @@
/*\
title: $:/core-server/modules/utils/escapecss.js
type: application/javascript
module-type: utils-node
Provides CSS.escape() functionality.
\*/
"use strict";
exports.escapeCSS = (function() {
// see also https://drafts.csswg.org/cssom/#serialize-an-identifier
/* eslint-disable */
/*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */
return function(value) {
if (arguments.length == 0) {
throw new TypeError('`CSS.escape` requires an argument.');
}
var string = String(value);
var length = string.length;
var index = -1;
var codeUnit;
var result = '';
var firstCodeUnit = string.charCodeAt(0);
while (++index < length) {
codeUnit = string.charCodeAt(index);
// Note: theres no need to special-case astral symbols, surrogate
// pairs, or lone surrogates.
// If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
// (U+FFFD).
if (codeUnit == 0x0000) {
result += '\uFFFD';
continue;
}
if (
// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
// U+007F, […]
(codeUnit >= 0x0001 && codeUnit <= 0x001F) || codeUnit == 0x007F ||
// If the character is the first character and is in the range [0-9]
// (U+0030 to U+0039), […]
(index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039) ||
// If the character is the second character and is in the range [0-9]
// (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
(
index == 1 &&
codeUnit >= 0x0030 && codeUnit <= 0x0039 &&
firstCodeUnit == 0x002D
)
) {
// https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
result += '\\' + codeUnit.toString(16) + ' ';
continue;
}
if (
// If the character is the first character and is a `-` (U+002D), and
// there is no second character, […]
index == 0 &&
length == 1 &&
codeUnit == 0x002D
) {
result += '\\' + string.charAt(index);
continue;
}
// If the character is not handled by one of the above rules and is
// greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
// is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
// U+005A), or [a-z] (U+0061 to U+007A), […]
if (
codeUnit >= 0x0080 ||
codeUnit == 0x002D ||
codeUnit == 0x005F ||
codeUnit >= 0x0030 && codeUnit <= 0x0039 ||
codeUnit >= 0x0041 && codeUnit <= 0x005A ||
codeUnit >= 0x0061 && codeUnit <= 0x007A
) {
// the character itself
result += string.charAt(index);
continue;
}
// Otherwise, the escaped character.
// https://drafts.csswg.org/cssom/#escape-a-character
result += '\\' + string.charAt(index);
}
return result;
};
/* eslint-enable */
})();

View File

@@ -1,7 +1,7 @@
/*\
title: $:/core/modules/utils/escapecss.js
type: application/javascript
module-type: utils
module-type: utils-browser
Provides CSS.escape() functionality.
@@ -9,92 +9,6 @@ Provides CSS.escape() functionality.
"use strict";
// TODO -- resolve this construction
exports.escapeCSS = (function() {
// use browser's native CSS.escape() function if available
if ($tw.browser && window.CSS && window.CSS.escape) {
return window.CSS.escape;
}
// otherwise, a utility method is provided
// see also https://drafts.csswg.org/cssom/#serialize-an-identifier
/*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */
return function(value) {
if (arguments.length == 0) {
throw new TypeError('`CSS.escape` requires an argument.');
}
var string = String(value);
var length = string.length;
var index = -1;
var codeUnit;
var result = '';
var firstCodeUnit = string.charCodeAt(0);
while (++index < length) {
codeUnit = string.charCodeAt(index);
// Note: theres no need to special-case astral symbols, surrogate
// pairs, or lone surrogates.
// If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
// (U+FFFD).
if (codeUnit == 0x0000) {
result += '\uFFFD';
continue;
}
if (
// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
// U+007F, […]
(codeUnit >= 0x0001 && codeUnit <= 0x001F) || codeUnit == 0x007F ||
// If the character is the first character and is in the range [0-9]
// (U+0030 to U+0039), […]
(index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039) ||
// If the character is the second character and is in the range [0-9]
// (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
(
index == 1 &&
codeUnit >= 0x0030 && codeUnit <= 0x0039 &&
firstCodeUnit == 0x002D
)
) {
// https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
result += '\\' + codeUnit.toString(16) + ' ';
continue;
}
if (
// If the character is the first character and is a `-` (U+002D), and
// there is no second character, […]
index == 0 &&
length == 1 &&
codeUnit == 0x002D
) {
result += '\\' + string.charAt(index);
continue;
}
// If the character is not handled by one of the above rules and is
// greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
// is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
// U+005A), or [a-z] (U+0061 to U+007A), […]
if (
codeUnit >= 0x0080 ||
codeUnit == 0x002D ||
codeUnit == 0x005F ||
codeUnit >= 0x0030 && codeUnit <= 0x0039 ||
codeUnit >= 0x0041 && codeUnit <= 0x005A ||
codeUnit >= 0x0061 && codeUnit <= 0x007A
) {
// the character itself
result += string.charAt(index);
continue;
}
// Otherwise, the escaped character.
// https://drafts.csswg.org/cssom/#escape-a-character
result += '\\' + string.charAt(index);
}
return result;
};
return window.CSS.escape;
})();

View File

@@ -25,7 +25,6 @@ Render this widget into the DOM
*/
ElementWidget.prototype.render = function(parent,nextSibling) {
this.parentDomNode = parent;
this.computeAttributes();
// Neuter blacklisted elements
this.tag = this.parseTreeNode.tag;
if($tw.config.htmlUnsafeElements.indexOf(this.tag) !== -1) {
@@ -42,6 +41,8 @@ ElementWidget.prototype.render = function(parent,nextSibling) {
headingLevel = Math.min(Math.max(headingLevel + 1 + baseLevel,1),6);
this.tag = "h" + headingLevel;
}
// Compute the attributes, mapping the element tag if needed
this.computeAttributes();
// Select the namespace for the tag
var XHTML_NAMESPACE = "http://www.w3.org/1999/xhtml",
tagNamespaces = {
@@ -99,4 +100,25 @@ ElementWidget.prototype.refresh = function(changedTiddlers) {
return this.refreshChildren(changedTiddlers) || hasChangedAttributes;
};
/*
Override the base computeAttributes method
*/
ElementWidget.prototype.computeAttributes = function() {
// Call the base class to compute the initial values of the attributes
var changedAttributes = Widget.prototype.computeAttributes.call(this);
// Check for element mapping
var mappedTag = this.getVariable("tv-map-" + this.tag),
mappedClass = this.getVariable("tv-map-" + this.tag + "-class");
if(mappedTag) {
this.tag = mappedTag.trim();
// Add an attribute to indicate the original tag
this.attributes["data-element-mapping-from"] = this.parseTreeNode.tag;
// Check for a mapped class
if(mappedClass) {
this.attributes["class"] = mappedClass.trim() + (this.attributes["class"] ? " " + this.attributes["class"] : "");
}
}
return changedAttributes;
};
exports.element = ElementWidget;

View File

@@ -7,7 +7,6 @@ This widget allows defining multiple variables at once, while allowing
the later variables to depend upon the earlier ones.
```
\define helloworld() Hello world!
<$let currentTiddler="target" value={{!!value}} currentTiddler="different">
{{!!value}} will be different from <<value>>
</$let>
@@ -56,7 +55,7 @@ LetWidget.prototype.computeAttributes = function() {
});
// Run through again, setting variables and looking for differences
$tw.utils.each(this.currentValueFor,function(value,name) {
if(!$tw.utils.isArrayEqual(self.attributes[name],value)) {
if(self.attributes[name] === undefined || !$tw.utils.isArrayEqual(self.attributes[name],value)) {
self.attributes[name] = value;
self.setVariable(name,value);
changedAttributes[name] = true;
@@ -68,7 +67,7 @@ LetWidget.prototype.computeAttributes = function() {
LetWidget.prototype.getVariableInfo = function(name,options) {
// Special handling: If this variable exists in this very $let, we can
// use it, but only if it's been staged.
if ($tw.utils.hop(this.currentValueFor,name)) {
if($tw.utils.hop(this.currentValueFor,name)) {
var value = this.currentValueFor[name];
return {
text: value[0] || "",

View File

@@ -15,7 +15,7 @@ caption: {{$:/language/SideBar/Open/Caption}}
\define droppable-item(button)
\whitespace trim
<$droppable actions=<<drop-actions>> enable=<<tv-allow-drag-and-drop>> tag="div">
<$droppable actions=<<drop-actions>> enable=<<tv-enable-drag-and-drop>> tag="div">
<<placeholder>>
<div>
$button$

View File

@@ -92,7 +92,7 @@ tags: $:/tags/Macro
</$set>
\end
\define list-tagged-draggable(tag,subFilter,emptyMessage,itemTemplate,elementTag:"div",storyview:"",displayField:"caption")
\define list-tagged-draggable(tag,subFilter,emptyMessage,itemTemplate,elementTag:"div",storyview:"",displayField:"title")
\whitespace trim
<span class="tc-tagged-draggable-list">
<$set name="tag" value=<<__tag__>>>
@@ -115,7 +115,6 @@ tags: $:/tags/Macro
<$view field="title"/>
</$transclude>
</$let>
<$view field="title"/>
</$link>
</$transclude>
</$genesis>

View File

@@ -21,7 +21,7 @@ second-search-filter: [subfilter<tagListFilter>is[system]search:title<userInput>
<!-- clean up temporary tiddlers, so the next "pick" starts with a clean input -->
<!-- This could probably be optimized / removed if we would use different temp-tiddlers
(future improvement because keeping track is comlex for humans)
(future improvement because keeping track is complex for humans)
-->
\procedure delete-tag-state-tiddlers()
<$action-deletetiddler $filter="[<newTagNameTiddler>] [<storeTitle>] [<tagSelectionState>]"/>
@@ -111,6 +111,7 @@ The second ESC tries to close the "draft tiddler"
refreshTitle=<<refreshTitle>>
selectionStateTitle=<<tagSelectionState>>
inputAcceptActions=<<add-tag-actions>>
inputAcceptVariantActions=<<save-tiddler-actions>>
inputCancelActions=<<clear-tags-actions>>
tag="input"
placeholder={{$:/language/EditTemplate/Tags/Add/Placeholder}}

View File

@@ -0,0 +1,18 @@
title: ElementMapping/Basic
description: Mapping one element to another
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
<!-- Map <p> to <div>, adding the class my-class -->
\define tv-map-p() div
This is a paragraph
+
title: ExpectedResult
<div data-element-mapping-from="p">This is a paragraph</div>

View File

@@ -0,0 +1,19 @@
title: ElementMapping/BasicWithClass
description: Mapping one element to another with an added class
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
<!-- Map <p> to <div>, adding the class my-class -->
\define tv-map-p() div
\define tv-map-p-class() my-class
This is a paragraph
+
title: ExpectedResult
<div class="my-class" data-element-mapping-from="p">This is a paragraph</div>

View File

@@ -0,0 +1,17 @@
change-category: nodejs
change-type: feature
created: 20260120154012282
description: Allows server routes to be prioritized via ordering.
github-contributors: saqimtiaz
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/9206
modified: 20260120160656948
release: 5.4.0
tags: $:/tags/ChangeNote
title: $:/changenotes/5.4.0/#9206
type: text/vnd.tiddlywiki
This PR adds support for an info property to server route module exports. The info object may include a priority field, which determines the routes order of precedence.
Priorities are numeric and follow a descending order: routes with higher priority values are processed first, similar to how saver modules are prioritized.
To maintain backward compatibility with existing code, any module that omits info or info.priority is assigned a default priority of 100. Core server routes have been updated to explicitly use this default value of 100.

View File

@@ -0,0 +1,13 @@
change-category: nodejs
change-type: feature
created: 20260120154249928
description: Allows server routes to support multiple HTTP methods.
github-contributors: saqimtiaz
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/9207
modified: 20260120160159661
release: 5.4.0
tags: $:/tags/ChangeNote
title: $:/changenotes/5.4.0/#9207
type: text/vnd.tiddlywiki
Allows server routes to support multiple HTTP methods by introducing an `exports.methods` array.

View File

@@ -0,0 +1,13 @@
change-category: widget
change-type: deprecation
created: 20260120154533983
description: The deprecated events and actions-* atrributes for the eventcatcher widget have been removed.
github-contributors: saqimtiaz
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/9259
modified: 20260120160236297
release: 5.4.0
tags: $:/tags/ChangeNote
title: $:/changenotes/5.4.0/#9259
type: text/vnd.tiddlywiki
Deprecates and removes the `events` and `actions-*` attributes for the $eventcatcher widget.

View File

@@ -0,0 +1,8 @@
changenote: $:/changenotes/5.4.0/#9259
created: 20260120154817011
description: Deprecated events and actons-* attributes from the eventcatcher widget
impact-type: deprecation
modified: 20260120154900978
tags: $:/tags/ImpactNote
title: $:/changenotes/5.4.0/#9259/impacts/deprecate-eventcatcher-attributes
type: text/vnd.tiddlywiki

View File

@@ -0,0 +1,29 @@
change-category: hackability
change-type: feature
created: 20260120154445701
description: Adds info tiddlers for viewport dimensions that are updated on window resize.
github-contributors: saqimtiaz
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/9260
modified: 20260120160515462
release: 5.4.0
tags: $:/tags/ChangeNote
title: $:/changenotes/5.4.0/#9260
type: text/vnd.tiddlywiki
Adds info tiddlers for viewport dimensions that are updated on window resize.
!! Example: Main and a user-created window with windowID my-window
|Window | Info tiddler | Meaning |h
|system/main |`$:/info/browser/window/system/main/outer/width` | Full browser window including chrome, tabs, toolbars |
|system/main |`$:/info/browser/window/system/main/outer/height` | Full browser window including chrome, tabs, toolbars |
|system/main |`$:/info/browser/window/system/main/inner/width` | Viewport width including scrollbars |
|system/main |`$:/info/browser/window/system/main/inner/height` | Viewport height including scrollbars |
|system/main |`$:/info/browser/window/system/main/client/width` | Content width excluding scrollbars |
|system/main |`$:/info/browser/window/system/main/client/height` | Content height excluding scrollbars |
|user/my-window |`$:/info/browser/window/user/my-window/outer/width` | Full browser window including chrome, tabs, toolbars |
|user/my-window |`$:/info/browser/window/user/my-window/outer/height` | Full browser window including chrome, tabs, toolbars |
|user/my-window |`$:/info/browser/window/user/my-window/inner/width` | Viewport width including scrollbars |
|user/my-window |`$:/info/browser/window/user/my-window/inner/height` | Viewport height including scrollbars |
|user/my-window |`$:/info/browser/window/user/my-window/client/width` | Content width excluding scrollbars |
|user/my-window |`$:/info/browser/window/user/my-window/client/height` | Content height excluding scrollbars |

View File

@@ -1,17 +1,7 @@
title: $:/changenotes/5.4.0/#9337/compatibility-break/math-filters
title: $:/changenotes/5.4.0/#9337/impacts/math-filters
changenote: $:/changenotes/5.4.0/#9337
created - 20251112152513384
modified - 20251112152513384
created: 20251112152513384
modified: 20251209160312626
tags: $:/tags/ImpactNote
description: filter output with empty input changes for some math filter operators
impact-type: compatibility-break
These math operators will now output an empty list when the input list is empty:
* sum[] - previously returned 0
* product[] - previously returned 1
* maxall[] - previously returned -Infinity
* minall[] - previously returned Infinity
* average[] - previously returned NaN
* variance[] - previously returned NaN
* standard-deviation[] - previously returned NaN
description: filter output changes for some math filter operators when input list is empty
impact-type: compatibility-break

View File

@@ -4,7 +4,8 @@ release: 5.4.0
tags: $:/tags/ChangeNote
change-type: enhancement
change-category: translation
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/9375
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/9375 https://github.com/TiddlyWiki/TiddlyWiki5/pull/9576
github-contributors: BramChen
* change camel-case hint text for chinese translations
* change camel-case hint text for chinese translations
* add alerts ARIA message

View File

@@ -0,0 +1,10 @@
title: $:/changenotes/5.4.0/#9494
description: Fix LetWidget to always set all staged variables on first render
release: 5.4.0
tags: $:/tags/ChangeNote
change-type: bugfix
change-category: widget
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/9494
github-contributors: yaisog
This PR corrects a bug where the LetWidget did not set variables if their value was the empty output of a filtered transclusion.

View File

@@ -0,0 +1,10 @@
title: $:/changenotes/5.4.0/#9600
description: Fix Ctrl-Enter not working in EditTemplate tag name input
release: 5.4.0
tags: $:/tags/ChangeNote
change-type: bugfix
change-category: internal
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/9600
github-contributors: yaisog
The tag name input now calls `<<save-tiddler-actions>>` from the EditTemplate when Ctrl-Enter (or whichever key is assigned to input-accept-variant) is pressed.

View File

@@ -0,0 +1,10 @@
title: $:/changenotes/5.4.0/#9475
description: Split escapecss.js into two platforms
release: 5.4.0
tags: $:/tags/ChangeNote
change-type: performance
change-category: internal
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/9475
github-contributors: Leilei332
Split [[$:/core/modules/utils/escapecss.js]] for two platforms: one for the browser, the other for Node.js. The `CSS.escape` polyfill is moved to `core-server`.

View File

@@ -104,7 +104,7 @@ js.configs.recommended,
"init-declarations": "off",
"@stylistic/jsx-quotes": "error",
"@stylistic/key-spacing": "off",
"@stylistic/keyword-spacing": ["error", {
"@stylistic/keyword-spacing": ["warn", {
before: true,
after: false,
overrides: {
@@ -114,6 +114,7 @@ js.configs.recommended,
return: { after: true },
throw: { after: true },
try: { after: true },
const: { after: true }
},
}],
"@stylistic/line-comment-position": "off",

View File

@@ -1,5 +1,6 @@
title: $:/language/
Alerts: 警报信息
AboveStory/ClassicPlugin/Warning: 您似乎要加载为 ~TiddlyWiki 经典版设计的插件。请注意,[[这些插件无法运行于 TiddlyWiki 5.x.x 版|https://tiddlywiki.com/#TiddlyWikiClassic]]。检测到 ~TiddlyWiki 经典版插件:
BinaryWarning/Prompt: 此条目包含二进制数据
ClassicWarning/Hint: 此条目以经典版 TiddlyWiki 标记格式撰写,不完全兼容新版 TiddlyWiki 的格式详细信息请参阅https://tiddlywiki.com/static/Upgrading。

View File

@@ -1,5 +1,6 @@
title: $:/language/
Alerts: 警示訊息
AboveStory/ClassicPlugin/Warning: 您似乎要載入為 ~TiddlyWiki 經典版設計的插件。請注意,[[這些插件無法運行於 TiddlyWiki 5.x.x 版|https://tiddlywiki.com/#TiddlyWikiClassic]]。偵測到 ~TiddlyWiki 經典版插件:
BinaryWarning/Prompt: 此條目包含二進位資料
ClassicWarning/Hint: 此條目以經典版 TiddlyWiki 標記格式撰寫,不完全相容新版 TiddlyWiki 的格式詳細資訊請參閱https://tiddlywiki.com/static/Upgrading。