From b673651103ab18ff5c9735d0ce4e042284f1d0f0 Mon Sep 17 00:00:00 2001 From: lin onetwo Date: Mon, 23 Feb 2026 18:58:24 +0800 Subject: [PATCH] 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> --- core/language/en-GB/Import.multids | 2 ++ core/ui/ImportListing.tid | 51 ++++++++++++++++++++---------- 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/core/language/en-GB/Import.multids b/core/language/en-GB/Import.multids index 57c2d09be..4be04be12 100644 --- a/core/language/en-GB/Import.multids +++ b/core/language/en-GB/Import.multids @@ -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 diff --git a/core/ui/ImportListing.tid b/core/ui/ImportListing.tid index 86dba83c8..6803e1d05 100644 --- a/core/ui/ImportListing.tid +++ b/core/ui/ImportListing.tid @@ -49,23 +49,40 @@ title: $:/core/ui/ImportListing \end \whitespace trim -<$let importJson={{{ [{$:/Import}] }}} - importTitles={{{ [jsonindexes[tiddlers]] }}} - importTypes={{{ [(importTitles)] :map[jsonget[tiddlers],,[type]] }}} - anyMatch={{{ [all[shadows+tiddlers]tag[$:/tags/ImportOptions]get[condition]] :map[(importTypes)subfilter] +[!is[blank]limit[1]] }}}> - <%if [!is[blank]] %> -
- <$list filter="[all[shadows+tiddlers]tag[$:/tags/ImportOptions]]" variable="importOption"> - <$let condition={{{ [get[condition]] }}} - hasMatch={{{ [(importTypes)subfilterlimit[1]] }}}> - <%if [!is[blank]] %> - <$transclude tiddler=<>/> - <%endif%> - - -
- <%endif%> - +<%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"> + {{$:/core/images/right-arrow}}<> + + + <$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"> + {{$:/core/images/down-arrow}}<> + + <$let importJson={{{ [{$:/Import}] }}} + importTitles={{{ [jsonindexes[tiddlers]] }}} + importTypes={{{ [(importTitles)] :map[jsonget[tiddlers],,[type]] }}} + anyMatch={{{ [all[shadows+tiddlers]tag[$:/tags/ImportOptions]get[condition]] :map[(importTypes)subfilter] +[!is[blank]limit[1]] }}}> + <%if [!is[blank]] %> +
+ <$list filter="[all[shadows+tiddlers]tag[$:/tags/ImportOptions]]" variable="importOption"> + <$let condition={{{ [get[condition]] }}} + hasMatch={{{ [(importTypes)subfilterlimit[1]] }}}> + <%if [!is[blank]] %> + <$transclude tiddler=<>/> + <%endif%> + + +
+ <%else%> +
+ <> +
+ <%endif%> + + +<%endif%> +