1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2026-02-23 18:39:50 +00:00

Compare commits

..

1 Commits

Author SHA1 Message Date
lin onetwo
b673651103 Fixes slow when import html on upgrade (#9689)
* Short-circuit the import option; only show it when you click a button

* Add aira-label

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* perf(import): lazy evaluate import options panel, shortcircuit when no options, and flatten let widgets

- Only parse $:/Import JSON when user expands the import options panel
- Skip all import option logic if no $:/tags/ImportOptions tiddlers exist
- Merge nested let widgets into single multi-variable let for better performance and readability
- Add lingo for import options panel and no-match message

This greatly improves import speed for large wikis, especially when no import options are present.

* fix(import): use correct transclusion for aria-label on import options panel buttons\n\nBind aria-label using {{$:/language/Import/Listing/ImportOptions/Caption}} instead of macro literal, matching TiddlyWiki convention and ensuring accessibility tools read the correct label.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-23 11:58:24 +01:00
5 changed files with 43 additions and 40 deletions

View File

@@ -15,6 +15,8 @@ Listing/Preview/TextRaw: Text (Raw)
Listing/Preview/Fields: Fields
Listing/Preview/Diff: Diff
Listing/Preview/DiffFields: Diff (Fields)
Listing/ImportOptions/Caption: Import options
Listing/ImportOptions/NoMatch: No import options apply to these files.
Listing/Rename/Tooltip: Rename tiddler before importing
Listing/Rename/Prompt: Rename to:
Listing/Rename/ConfirmRename: Rename tiddler

View File

@@ -415,10 +415,9 @@ Widget.prototype.computeAttribute = function(attribute,options) {
value;
if(attribute.type === "filtered") {
value = this.wiki.filterTiddlers(attribute.filter,this);
if(!value.length) {
value = [""];
if(!options.asList) {
value = value[0] || "";
}
value = options.asList ? value : value[0];
} else if(attribute.type === "indirect") {
value = this.wiki.getTextReference(attribute.textReference,"",this.getVariable("currentTiddler"));
if(value && options.asList) {

View File

@@ -49,23 +49,40 @@ title: $:/core/ui/ImportListing
\end
\whitespace trim
<$let importJson={{{ [{$:/Import}] }}}
importTitles={{{ [<importJson>jsonindexes[tiddlers]] }}}
importTypes={{{ [(importTitles)] :map[<importJson>jsonget[tiddlers],<currentTiddler>,[type]] }}}
anyMatch={{{ [all[shadows+tiddlers]tag[$:/tags/ImportOptions]get[condition]] :map[(importTypes)subfilter<currentTiddler>] +[!is[blank]limit[1]] }}}>
<%if [<anyMatch>!is[blank]] %>
<div class="tc-import-option">
<$list filter="[all[shadows+tiddlers]tag[$:/tags/ImportOptions]]" variable="importOption">
<$let condition={{{ [<importOption>get[condition]] }}}
hasMatch={{{ [(importTypes)subfilter<condition>limit[1]] }}}>
<%if [<hasMatch>!is[blank]] %>
<$transclude tiddler=<<importOption>>/>
<%endif%>
</$let>
</$list>
</div>
<%endif%>
</$let>
<%if [all[shadows+tiddlers]tag[$:/tags/ImportOptions]limit[1]] %>
<$reveal type="nomatch" state="$:/state/import/options" text="yes" tag="div">
<$button class="tc-btn-invisible tc-btn-dropdown" set="$:/state/import/options" setTo="yes" aria-label={{$:/language/Import/Listing/ImportOptions/Caption}} aria-expanded="false">
<span class="tc-small-gap-right">{{$:/core/images/right-arrow}}</span><<lingo Listing/ImportOptions/Caption>>
</$button>
</$reveal>
<$reveal type="match" state="$:/state/import/options" text="yes" tag="div">
<$button class="tc-btn-invisible tc-btn-dropdown" set="$:/state/import/options" setTo="no" aria-label={{$:/language/Import/Listing/ImportOptions/Caption}} aria-expanded="true">
<span class="tc-small-gap-right">{{$:/core/images/down-arrow}}</span><<lingo Listing/ImportOptions/Caption>>
</$button>
<$let importJson={{{ [{$:/Import}] }}}
importTitles={{{ [<importJson>jsonindexes[tiddlers]] }}}
importTypes={{{ [(importTitles)] :map[<importJson>jsonget[tiddlers],<currentTiddler>,[type]] }}}
anyMatch={{{ [all[shadows+tiddlers]tag[$:/tags/ImportOptions]get[condition]] :map[(importTypes)subfilter<currentTiddler>] +[!is[blank]limit[1]] }}}>
<%if [<anyMatch>!is[blank]] %>
<div class="tc-import-option">
<$list filter="[all[shadows+tiddlers]tag[$:/tags/ImportOptions]]" variable="importOption">
<$let condition={{{ [<importOption>get[condition]] }}}
hasMatch={{{ [(importTypes)subfilter<condition>limit[1]] }}}>
<%if [<hasMatch>!is[blank]] %>
<$transclude tiddler=<<importOption>>/>
<%endif%>
</$let>
</$list>
</div>
<%else%>
<div class="tc-import-option">
<<lingo Listing/ImportOptions/NoMatch>>
</div>
<%endif%>
</$let>
</$reveal>
<%endif%>
<div class="tc-table-wrapper">
<table class="tc-import-table">
<tbody>

View File

@@ -5,6 +5,11 @@ tags: [[$:/tags/wiki-test-spec]]
title: Output
\procedure testproc()
This is ''wikitext''
\end
<$tiddler tiddler="Data">
<$transclude $index="testindex"/>
-

View File

@@ -1,20 +0,0 @@
title: Transclude/MissingTiddlerAttributeFiltered
description: Missing Tiddler Attribute Filtered
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
<$transclude tiddler={{{ [[sometiddler]get[nosuchfield]] }}}/>
-
<$transclude tiddler="">fallback content</$transclude>
-
<$transclude tiddler={{{ [[sometiddler]get[nosuchfield]] }}}>fallback content</$transclude>
+
title: ExpectedResult
<p>
-
fallback content
-
fallback content</p>