From 4a6aa865b32bce781bba1759ba5dcab169ff410e Mon Sep 17 00:00:00 2001 From: Simon Huber Date: Mon, 2 Nov 2020 20:08:24 +0100 Subject: [PATCH] Make Escape in keyboard-driven-inputs behave like in AdvancedSearch/Filter (#4961) * Create focus-editor.js * Update search.tid * Update link-dropdown.tid * Update search.tid * Update Standard.tid * Update Shadows.tid * Update System.tid * Update fields.tid * Update tag-picker.tid * Update Filter.tid * Update clear.tid * Update link-dropdown.tid * Delete focus-editor.js --- core/ui/AdvancedSearch/Filter.tid | 2 +- core/ui/AdvancedSearch/FilterButtons/clear.tid | 2 +- core/ui/AdvancedSearch/Shadows.tid | 2 +- core/ui/AdvancedSearch/Standard.tid | 2 +- core/ui/AdvancedSearch/System.tid | 2 +- core/ui/EditTemplate/fields.tid | 12 ++++++++++-- core/ui/EditorToolbar/link-dropdown.tid | 16 +++++++++++----- core/ui/SideBarSegments/search.tid | 6 ++---- core/wiki/macros/tag-picker.tid | 18 +++++++++++++++--- plugins/tiddlywiki/menubar/items/search.tid | 8 +++++++- 10 files changed, 50 insertions(+), 20 deletions(-) diff --git a/core/ui/AdvancedSearch/Filter.tid b/core/ui/AdvancedSearch/Filter.tid index e1c499817..232994cc4 100644 --- a/core/ui/AdvancedSearch/Filter.tid +++ b/core/ui/AdvancedSearch/Filter.tid @@ -5,7 +5,7 @@ caption: {{$:/language/Search/Filter/Caption}} \define lingo-base() $:/language/Search/ \define set-next-input-tab(beforeafter:"after") <$macrocall $name="change-input-tab" stateTitle="$:/state/tab/advanced-search-results" tag="$:/tags/AdvancedSearch" beforeafter="$beforeafter$" defaultState="$:/core/ui/AdvancedSearch/System" actions="""<$action-setfield $tiddler="$:/state/advancedsearch/currentTab" text=<>/>"""/> -\define cancel-search-actions() <$set name="userInput" value={{{ [<__storeTitle__>get[text]] }}}><$list filter="[<__tiddler__>get[text]match]" emptyMessage="""<$action-setfield $tiddler=<<__tiddler__>> text=<>/><$action-setfield $tiddler=<<__refreshTitle__>> text="yes"/>"""><$action-deletetiddler $filter="[[$:/temp/advancedsearch]] [[$:/temp/advancedsearch/input]] [[$:/temp/advancedsearch/selected-item]]" /> +\define cancel-search-actions() <$list filter="[{$:/temp/advancedsearch/input}!match{$:/temp/advancedsearch}]" emptyMessage="""<$action-deletetiddler $filter="[[$:/temp/advancedsearch]] [[$:/temp/advancedsearch/input]] [[$:/temp/advancedsearch/selected-item]]" />"""><$action-setfield $tiddler="$:/temp/advancedsearch/input" text={{$:/temp/advancedsearch}}/><$action-setfield $tiddler="$:/temp/advancedsearch/refresh" text="yes"/> \define input-accept-actions() <$action-navigate $to={{{ [<__tiddler__>get[text]] }}}/> diff --git a/core/ui/AdvancedSearch/FilterButtons/clear.tid b/core/ui/AdvancedSearch/FilterButtons/clear.tid index 8bfb855a5..a524acd24 100644 --- a/core/ui/AdvancedSearch/FilterButtons/clear.tid +++ b/core/ui/AdvancedSearch/FilterButtons/clear.tid @@ -3,7 +3,7 @@ tags: $:/tags/AdvancedSearch/FilterButton <$reveal state="$:/temp/advancedsearch" type="nomatch" text=""> <$button class="tc-btn-invisible"> -<$action-deletetiddler $filter="[[$:/temp/advancedsearch]] [[$:/temp/advancedsearch/input]] [[$:/temp/advancedsearch/selected-item]]" /> +<> <$action-sendmessage $message="tm-focus-selector" $param=""".tc-advanced-search input""" /> {{$:/core/images/close-button}} diff --git a/core/ui/AdvancedSearch/Shadows.tid b/core/ui/AdvancedSearch/Shadows.tid index 40b34263f..1090baaee 100644 --- a/core/ui/AdvancedSearch/Shadows.tid +++ b/core/ui/AdvancedSearch/Shadows.tid @@ -7,7 +7,7 @@ first-search-filter: [all[shadows]searchsort[title]limit[250]] -[[$:/ \define set-next-input-tab(beforeafter:"after") <$macrocall $name="change-input-tab" stateTitle="$:/state/tab/advanced-search-results" tag="$:/tags/AdvancedSearch" beforeafter="$beforeafter$" defaultState="$:/core/ui/AdvancedSearch/System" actions="""<$action-setfield $tiddler="$:/state/advancedsearch/currentTab" text=<>/>"""/> -\define cancel-search-actions() <$action-deletetiddler $filter="[[$:/temp/advancedsearch]] [[$:/temp/advancedsearch/input]] [[$:/temp/advancedsearch/selected-item]]" /><$action-sendmessage $message="tm-focus-selector" $param=""".tc-advanced-search input"""/> +\define cancel-search-actions() <$list filter="[{$:/temp/advancedsearch}!match{$:/temp/advancedsearch/input}]" emptyMessage="""<$action-deletetiddler $filter="[[$:/temp/advancedsearch]] [[$:/temp/advancedsearch/input]] [[$:/temp/advancedsearch/selected-item]]" />"""><$action-setfield $tiddler="$:/temp/advancedsearch/input" text={{$:/temp/advancedsearch}}/><$action-setfield $tiddler="$:/temp/advancedsearch/refresh" text="yes"/><$action-sendmessage $message="tm-focus-selector" $param=""".tc-advanced-search input"""/> \define input-accept-actions() <$action-navigate $to={{{ [<__tiddler__>get[text]] }}}/> diff --git a/core/ui/AdvancedSearch/Standard.tid b/core/ui/AdvancedSearch/Standard.tid index 65bea8850..8fdd83d23 100644 --- a/core/ui/AdvancedSearch/Standard.tid +++ b/core/ui/AdvancedSearch/Standard.tid @@ -7,7 +7,7 @@ caption: {{$:/language/Search/Standard/Caption}} \define next-search-tab(beforeafter:"after") <$macrocall $name="change-input-tab" stateTitle="$:/state/tab/search-results/advancedsearch" tag="$:/tags/SearchResults" beforeafter="$beforeafter$" defaultState={{$:/config/SearchResults/Default}} actions="""<$action-setfield $tiddler="$:/state/advancedsearch/standard/currentTab" text=<>/>"""/> -\define cancel-search-actions() <$action-deletetiddler $filter="[[$:/temp/advancedsearch]] [[$:/temp/advancedsearch/input]] [[$:/temp/advancedsearch/selected-item]]" /><$action-sendmessage $message="tm-focus-selector" $param=""".tc-advanced-search input"""/> +\define cancel-search-actions() <$list filter="[{$:/temp/advancedsearch}!match{$:/temp/advancedsearch/input}]" emptyMessage="""<$action-deletetiddler $filter="[[$:/temp/advancedsearch]] [[$:/temp/advancedsearch/input]] [[$:/temp/advancedsearch/selected-item]]" />"""><$action-setfield $tiddler="$:/temp/advancedsearch/input" text={{$:/temp/advancedsearch}}/><$action-setfield $tiddler="$:/temp/advancedsearch/refresh" text="yes"/><$action-sendmessage $message="tm-focus-selector" $param=""".tc-advanced-search input"""/> \define input-accept-actions() <$action-navigate $to={{{ [<__tiddler__>get[text]] }}}/> diff --git a/core/ui/AdvancedSearch/System.tid b/core/ui/AdvancedSearch/System.tid index 9f6c84803..db4f29151 100644 --- a/core/ui/AdvancedSearch/System.tid +++ b/core/ui/AdvancedSearch/System.tid @@ -6,7 +6,7 @@ first-search-filter: [is[system]searchsort[title]limit[250]] -[[$:/te \define lingo-base() $:/language/Search/ \define set-next-input-tab(beforeafter:"after",stateTitle,tag,defaultState,currentTabTiddler) <$macrocall $name="change-input-tab" stateTitle="$:/state/tab/advanced-search-results" tag="$:/tags/AdvancedSearch" beforeafter="$beforeafter$" defaultState="$:/core/ui/AdvancedSearch/System" actions="""<$action-setfield $tiddler="$:/state/advancedsearch/currentTab" text=<>/>"""/> -\define cancel-search-actions() <$action-deletetiddler $filter="[[$:/temp/advancedsearch]] [[$:/temp/advancedsearch/input]] [[$:/temp/advancedsearch/selected-item]]" /><$action-sendmessage $message="tm-focus-selector" $param=""".tc-advanced-search input"""/> +\define cancel-search-actions() <$list filter="[{$:/temp/advancedsearch}!match{$:/temp/advancedsearch/input}]" emptyMessage="""<$action-deletetiddler $filter="[[$:/temp/advancedsearch]] [[$:/temp/advancedsearch/input]] [[$:/temp/advancedsearch/selected-item]]" />"""><$action-setfield $tiddler="$:/temp/advancedsearch/input" text={{$:/temp/advancedsearch}}/><$action-setfield $tiddler="$:/temp/advancedsearch/refresh" text="yes"/><$action-sendmessage $message="tm-focus-selector" $param=""".tc-advanced-search input"""/> \define input-accept-actions() <$action-navigate $to={{{ [<__tiddler__>get[text]] }}}/> diff --git a/core/ui/EditTemplate/fields.tid b/core/ui/EditTemplate/fields.tid index 5c025ec82..af059d93c 100644 --- a/core/ui/EditTemplate/fields.tid +++ b/core/ui/EditTemplate/fields.tid @@ -23,12 +23,20 @@ $:/config/EditTemplateFields/Visibility/$(currentField)$ \define delete-state-tiddlers() <$action-deletetiddler $filter="[] [] []"/> -\define cancel-search-actions() -<$list filter="[<__storeTitle__>has[text]] [<__tiddler__>has[text]]" variable="ignore" emptyMessage="""<><$action-sendmessage $message="tm-cancel-tiddler"/>"""> +\define cancel-search-actions-inner() +<$list filter="[has[text]] [has[text]]" variable="ignore" emptyMessage="""<><$action-sendmessage $message="tm-cancel-tiddler"/>"""> <> \end +\define cancel-search-actions() +<$set name="userInput" value={{{ [get[text]] }}}> +<$list filter="[get[text]!match]" emptyMessage="""<>"""> +<$action-setfield $tiddler=<> text=<>/><$action-setfield $tiddler=<> text="yes"/> + + +\end + \define new-field() <$vars name={{{ [get[text]] }}}> <$reveal type="nomatch" text="" default=<>> diff --git a/core/ui/EditorToolbar/link-dropdown.tid b/core/ui/EditorToolbar/link-dropdown.tid index 58f3a0781..96dd99b2a 100644 --- a/core/ui/EditorToolbar/link-dropdown.tid +++ b/core/ui/EditorToolbar/link-dropdown.tid @@ -7,7 +7,13 @@ title: $:/core/ui/EditorToolbar/link-dropdown <$action-deletetiddler $filter="[] [] [] [] []"/> \end -\define cancel-search-actions() <$action-deletetiddler $filter="[] [] [] []"/> +\define get-focus-selector() [data-tiddler-title="$(cssEscapedTitle)$"] .tc-create-wikitext-link input + +\define cancel-search-actions-inner() +<$set name="userInput" value={{{ [get[text]] }}}><$list filter="[get[text]!match]" emptyMessage="""<$action-deletetiddler $filter="[] [] [] []"/>"""><$action-setfield $tiddler=<> text=<>/><$action-setfield $tiddler=<> text="yes"/> +\end + +\define cancel-search-actions() <$list filter="[!has[text]] +[!has[text]]" emptyMessage="""<>"""><$action-sendmessage $message="tm-edit-text-operation" $param="wrap-selection" prefix="" suffix=""/> \define external-link() <$button class="tc-btn-invisible" style="width: auto; display: inline-block; background-colour: inherit;" actions=<>> @@ -24,9 +30,9 @@ title: $:/core/ui/EditorToolbar/link-dropdown <$vars linkTiddler=<>> <$keyboard key="((input-tab-right))" actions=<>> -<$keyboard key="((input-tab-left))" actions=<>> -<$macrocall $name="keyboard-driven-input" tiddler=<> storeTitle=<> filterMinLength={{$:/config/Search/MinLength}} - selectionStateTitle=<> refreshTitle=<> type="search" +<$keyboard key="((input-tab-left))" actions=<> class="tc-create-wikitext-link"> +<$macrocall $name="keyboard-driven-input" tiddler=<> storeTitle=<> + selectionStateTitle=<> refreshTitle=<> type="search" filterMinLength="1" tag="input" focus="true" class="tc-popup-handle" inputCancelActions=<> inputAcceptActions=<> placeholder={{$:/language/Search/Search}} default="" configTiddlerFilter="[[$:/state/search/currentTab]!is[missing]get[text]] ~[{$:/config/SearchResults/Default}]" /> @@ -35,7 +41,7 @@ title: $:/core/ui/EditorToolbar/link-dropdown <$reveal tag="span" state=<> type="nomatch" text=""> <> <$button class="tc-btn-invisible" style="width: auto; display: inline-block; background-colour: inherit;"> -<$action-setfield $tiddler=<> text="" /> +<><$set name="cssEscapedTitle" value={{{ [escapecss[]] }}}><$action-sendmessage $message="tm-focus-selector" $param=<>/> {{$:/core/images/close-button}} diff --git a/core/ui/SideBarSegments/search.tid b/core/ui/SideBarSegments/search.tid index bd71b3fcd..281505b5c 100644 --- a/core/ui/SideBarSegments/search.tid +++ b/core/ui/SideBarSegments/search.tid @@ -32,9 +32,7 @@ tags: $:/tags/SideBarSegment \end -\define delete-state-tiddlers() <$action-deletetiddler $filter="[[$:/temp/search]] [] []"/> - -\define cancel-search-actions() <$action-deletetiddler $filter="[<__storeTitle__>] [<__tiddler__>] [<__selectionStateTitle__>]"/> +\define cancel-search-actions() <$list filter="[get[text]!match{$:/temp/search}]" emptyMessage="""<$action-deletetiddler $filter="[[$:/temp/search]] [] []"/>"""><$action-setfield $tiddler="$:/temp/search" text={{{ [get[text]] }}}/><$action-setfield $tiddler="$:/temp/search/refresh" text="yes"/> \define input-accept-actions() <$action-navigate $to={{{ [<__tiddler__>get[text]] }}}/> @@ -66,7 +64,7 @@ tags: $:/tags/SideBarSegment {{$:/core/images/advanced-search-button}} <$button class="tc-btn-invisible"> -<><$action-sendmessage $message="tm-focus-selector" $param=".tc-search input"/> +<><$action-sendmessage $message="tm-focus-selector" $param=".tc-search input"/> {{$:/core/images/close-button}} <> diff --git a/core/wiki/macros/tag-picker.tid b/core/wiki/macros/tag-picker.tid index ac92aa24f..f72006541 100644 --- a/core/wiki/macros/tag-picker.tid +++ b/core/wiki/macros/tag-picker.tid @@ -3,6 +3,8 @@ tags: $:/tags/Macro first-search-filter: [tags[]!is[system]search:titlesort[]] second-search-filter: [tags[]is[system]search:titlesort[]] +\define get-tagpicker-focus-selector() [data-tiddler-title="$(currentTiddlerCSSEscaped)$"] .tc-add-tag-name input + \define delete-tag-state-tiddlers() <$action-deletetiddler $filter="[] [] []"/> \define add-tag-actions(actions) @@ -27,12 +29,20 @@ $actions$ \end -\define clear-tags-actions() -<$list filter="[<__storeTitle__>has[text]] [<__tiddler__>has[text]]" variable="ignore" emptyMessage="""<><$action-sendmessage $message="tm-cancel-tiddler"/>"""> +\define clear-tags-actions-inner() +<$list filter="[has[text]] [has[text]]" variable="ignore" emptyMessage="""<><$action-sendmessage $message="tm-cancel-tiddler"/>"""> <> \end +\define clear-tags-actions() +<$set name="userInput" value={{{ [get[text]] }}}> +<$list filter="[get[text]!match]" emptyMessage="""<>"""> +<$action-setfield $tiddler=<> text=<>/><$action-setfield $tiddler=<> text="yes"/> + + +\end + \define tag-picker-inner(actions) \whitespace trim <$vars tagSelectionState=<> storeTitle=<> refreshTitle=<> nonSystemTagsFilter="[tags[]!is[system]search:titlesort[]]" systemTagsFilter="[tags[]is[system]search:titlesort[]]"> @@ -50,7 +60,9 @@ $actions$ <$button set=<> setTo="" class=""> <$action-sendmessage $message="tm-add-tag" $param=<>/> $actions$ -<> +<$set name="currentTiddlerCSSEscaped" value={{{ [escapecss[]] }}}> +<><$action-sendmessage $message="tm-focus-selector" $param=<>/> + {{$:/language/EditTemplate/Tags/Add/Button}} diff --git a/plugins/tiddlywiki/menubar/items/search.tid b/plugins/tiddlywiki/menubar/items/search.tid index e4e386be0..4614a3ef1 100644 --- a/plugins/tiddlywiki/menubar/items/search.tid +++ b/plugins/tiddlywiki/menubar/items/search.tid @@ -4,7 +4,13 @@ description: Search caption: Search tags: $:/tags/MenuBar -\define cancel-search-actions() <$action-deletetiddler $filter="[<__storeTitle__>] [<__tiddler__>] [<__selectionStateTitle__>]"/> +\define cancel-search-actions() +<$set name="userInput" value={{{ [<__storeTitle__>get[text]] }}}> +<$list filter="[<__tiddler__>get[text]!match]" emptyMessage="""<$action-deletetiddler $filter="[<__storeTitle__>] [<__tiddler__>] [<__selectionStateTitle__>]"/>"""> +<$action-setfield $tiddler=<<__tiddler__>> text=<>/><$action-setfield $tiddler=<<__refreshTitle__>> text="yes"/> + + +\end \define input-accept-actions() <$action-navigate $to={{{ [<__tiddler__>get[text]] }}}/>