caption: <$text text={{{ [[$:/language]get[text]removeprefix[$:/languages/]else[en-GB]search[zh]then[标签]else[Tags]] }}} />
created: 20231010182024353
modified: 20231010200036469
tags:
title: $:/plugins/Gk0Wk/CPL-Repo/views/galleries/tags
type: text/vnd.tiddlywiki

\import $:/plugins/Gk0Wk/CPL-Repo/views/plugins/list-item
\import $:/plugins/Gk0Wk/CPL-Repo/views/plugins/size
\import $:/plugins/Gk0Wk/CPL-Repo/views/plugins/paged-list

\define tag-plain(text:"",icon:"",color:"",bg:"")
\whitespace trim
<span class="tc-tag-label" style="background-color:$bg$;color:$color$;fill:$color$;user-select:none;margin-right:6px;">
	{{$icon$}}$text$
</span>
\end

\define tag-plain-removable(saveTiddler,saveField:"tags",text:"",icon:"",color:"",bg:"")
\whitespace trim
<span class="tc-tag-label" style="background-color:$bg$;color:$color$;fill:$color$;user-select:none;margin:4px 6px 2px 0;padding:4px 10px;">
	{{$icon$}}$text$
	<$button class="tc-btn-invisible tc-remove-tag-button" style="background-color:$bg$;color:$color$;fill:$color$;">
		<$action-listops $tiddler=<<__saveTiddler__>> $field=<<__saveField__>> $subfilter="-[<__text__>]"/>{{$:/core/images/close-button}}
	</$button>
</span>
\end

<$let bg={{{ [{$:/palette}getindex[tag-background]] }}} color={{{ [{$:/palette}getindex[foreground]] }}} saveTiddler="$:/temp/CPL-Repo/search-tag-input">
<!-- 展示待检索的标签，以及搜索按钮 -->
<div style="width:100%;display:flex;backdrop-filter:contrast(1.3);">
    <div class="cpl-search-tags" style="flex-grow:1;width:0;display:flex;align-items:center;padding:4px 8px;flex-wrap:wrap;">
        <!-- 已有的标签，可删除 -->
        <$list filter="[<saveTiddler>get[text]enlist-input[]]" variable="tag">
        <$macrocall $name="tag-plain-removable" text=<<tag>> icon="$:/core/images/tag-button" bg=<<bg>> color=<<color>> saveTiddler=<<saveTiddler>> saveField="text" />
        </$list>
        <div class="cpl-search-tags-input">
            <!-- 输入 -->
            <$macrocall
                $name="keyboard-driven-input"
                tiddler="$:/temp/CPL-Repo/add-search-tag-input"
                tag="input"
                placeholder={{$:/language/EditTemplate/Tags/Add/Placeholder}}
                focusPopup="$:/temp/CPL-Repo/add-search-tag-popup"
                class="tc-edit-texteditor tc-popup-handle"
                tabindex=<<tabIndex>>
                focus="yes"
                filterMinLength="2"
                configTiddlerFilter="[[$:/core/macros/tag-picker]]"
            />
            <!-- 弹出 -->
            <$reveal state="$:/temp/CPL-Repo/add-search-tag-popup" type="nomatch" text="" default="">
            <div class="tc-block-dropdown tc-block-tags-dropdown">
                <$list filter="[{$:/temp/CPL-Repo/tags}jsonget[]search{$:/temp/CPL-Repo/add-search-tag-input}]" variable="tag">
                <$button class="tc-btn-invisible" tag="a" tooltip={{$:/language/EditTemplate/Tags/Add/Button/Hint}}>
                    <$macrocall $name="tag-plain" text=<<tag>> icon="$:/core/images/tag-button" bg=<<bg>> color=<<color>> />
                    <$action-listops $tiddler=<<saveTiddler>> $field="text" $subfilter="[<tag>]"/>
                </$button>
                </$list>
            </div>
            </$reveal>
        </div>
    </div>
    <!-- 搜索按钮 -->
    <$button class="tc-primary-btn tc-btn-big-green cpl-plugin-search-go" disabled={{$:/temp/CPL-Repo/searching-plugin}}>
        <$text text={{{ [[$:/language]get[text]removeprefix[$:/languages/]else[en-GB]search[zh]] :then[{$:/temp/CPL-Repo/searching-plugin}match[yes]then[搜索中...]else[搜索]] :else[{$:/temp/CPL-Repo/searching-plugin}match[yes]then[Searching...]else[Search]] }}} />
        <$action-sendmessage
            $message="cpl-search-plugins"
            mode="tags"
            text={{{ [<saveTiddler>get[text]] }}}
            saveTo="$:/temp/CPL-Repo/searchplugin-tags/result"
        />
    </$button>
</div>
<$list filter="[[$:/temp/CPL-Repo/searching-plugin]is[tiddler]!field:text[yes]]">
<div class="cpl-status-banner cpl-status-banner-error">
	<$text text={{{ [<chinese>match[yes]then[出现了一些问题]else[Some errors occured]] }}}/>: <$text text={{!!text}}/>
</div>
</$list>
<$list filter="[[$:/temp/CPL-Repo/searchplugin-tags/result]is[tiddler]then[yes]else[no]]" variable="go">
<!-- 有搜索结果 -->
<$list filter="[<go>match[yes]]" variable="t">
<<paged-plugin-list filter:"[{$:/temp/CPL-Repo/searchplugin-tags/result}jsonget[]]" field:"tag-gallery" class1:"cpl-plugin-info-box" class2:"cpl-paged-plugin-list-control">>
</$list>
<!-- 没有搜索结果，展示全部 -->
<$list filter="[<go>match[no]]" variable="t">
<<paged-plugin-list filter:"[{$:/temp/CPL-Repo/plugins-index}jsonindexes[]!prefix[$:/language]]" field:"tag-gallery" class1:"cpl-plugin-info-box" class2:"cpl-paged-plugin-list-control">>
</$list>
</$list>
</$let>