1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-09 08:50:26 +00:00
TiddlyWiki5/core/ui/EditorToolbar/link-dropdown.tid
Théophile Desmedt e8a23e9bcc
Improve link-dropdown.tid - Replace vars and set with let widget, streamline function usage (#8821)
* cleanup: Apply substitution more systematically

* change vars and set to let widget

* use attribute substitution instead of a function
2024-12-15 22:11:36 +00:00

73 lines
3.8 KiB
Plaintext

title: $:/core/ui/EditorToolbar/link-dropdown
\procedure lingo-base() $:/language/Buttons/Link/
\procedure add-link-actions()
\whitespace trim
<$action-sendmessage $message="tm-edit-text-operation" $param="make-link" text={{{ [<linkTiddler>get[text]] }}} />
<$action-deletetiddler $filter="[<dropdown-state>] [<searchTiddler>] [<linkTiddler>] [<storeTitle>] [<searchListState>]"/>
\end
\procedure cancel-search-actions-inner()
<$let userInput={{{ [<storeTitle>get[text]] }}}><$list filter="[<searchTiddler>get[text]!match<userInput>]" emptyMessage="<$action-deletetiddler $filter='[<searchTiddler>] [<linkTiddler>] [<storeTitle>] [<searchListState>]'/>"><$action-setfield $tiddler=<<searchTiddler>> text=<<userInput>>/><$action-setfield $tiddler=<<refreshTitle>> text="yes"/></$list></$let>
\end
\procedure cancel-search-actions() <$list filter="[<storeTitle>!has[text]] :and[<searchTiddler>!has[text]]" emptyMessage="<<cancel-search-actions-inner>>"><$action-sendmessage $message="tm-edit-text-operation" $param="focus-editor"/></$list>
\procedure external-link()
\whitespace trim
<$button class="tc-btn-invisible tc-btn-mini" style="width: auto; display: inline-block; background-colour: inherit;" actions=<<add-link-actions>>>
{{$:/core/images/chevron-right}}
</$button>
\end
\procedure set-next-input-tab() <$transclude $variable="change-input-tab-after" stateTitle="$:/state/tab/search-results/sidebar" tag="$:/tags/SearchResults" defaultState={{$:/config/SearchResults/Default}} actions="<$action-setfield $tiddler='$:/state/search/currentTab' text=<<nextTab>>/>"/>
\procedure set-previous-input-tab() <$transclude $variable="change-input-tab-before" stateTitle="$:/state/tab/search-results/sidebar" tag="$:/tags/SearchResults" defaultState={{$:/config/SearchResults/Default}} actions="<$action-setfield $tiddler='$:/state/search/currentTab' text=<<nextTab>>/>"/>
\procedure body(config-title)
\whitespace trim
''<<lingo Hint>>''
<$let searchTiddler=`$(config-title)$/search` linkTiddler=`$(config-title)$/link` linktext="" searchListState=<<qualify "$:/temp/link-search/selected-item">> refreshTitle=<<qualify "$:/temp/link-search/refresh">> storeTitle=<<qualify "$:/temp/link-search/input">>>
<$let linkTiddler=<<searchTiddler>>>
<$keyboard key="((input-tab-right))" actions=<<set-next-input-tab>>>
<$keyboard key="((input-tab-left))" actions=<<set-previous-input-tab>> class="tc-create-wikitext-link">
<$transclude $variable="keyboard-driven-input" tiddler=<<searchTiddler>> storeTitle=<<storeTitle>>
selectionStateTitle=<<searchListState>> refreshTitle=<<refreshTitle>> type="search" filterMinLength="1"
tag="input" focus="true" class="tc-popup-handle" inputCancelActions=<<cancel-search-actions>>
inputAcceptActions=<<add-link-actions>> placeholder={{$:/language/Search/Search}} default=""
configTiddlerFilter="[[$:/state/search/currentTab]!is[missing]get[text]] :else[{$:/config/SearchResults/Default}]" />
</$keyboard>
</$keyboard>
&#32;
<$reveal tag="span" state=<<storeTitle>> type="nomatch" text="">
<<external-link>>
&#32;
<$button class="tc-btn-invisible tc-btn-mini" style="width: auto; display: inline-block; background-colour: inherit;">
<<cancel-search-actions>><$action-sendmessage $message="tm-focus-selector" $param=`[data-tiddler-title=${[<storyTiddler>escapecss[]]}$] .tc-create-wikitext-link input`/>
{{$:/core/images/close-button}}
</$button>
</$reveal>
</$let>
<$reveal tag="div" state=<<storeTitle>> type="nomatch" text="">
<$linkcatcher actions=<<add-link-actions>> to=<<linkTiddler>>>
<$let userInput={{{ [<storeTitle>get[text]] }}} configTiddler={{{ [[$:/state/search/currentTab]!is[missing]get[text]] :else[{$:/config/SearchResults/Default}] }}}>
{{$:/core/ui/SearchResults}}
</$let>
</$linkcatcher>
</$reveal>
</$let>
\end
<$transclude $variable="body" config-title=<<qualify "$:/state/Link/">>/>