mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 10:07:19 +00:00
Trim saga: The big macros (#6269)
* adding trim: large macros and languageswitcher * adding trim: KeyboardShortcuts.tid * Hidden space to force some macros to be inline This'll be our little secret. This single byte will actually allow the uglifier to trim over thirty bytes while condensing. I know I'm not supposed to optimize TW for some 3rd party plugin, but I'm the one doing the whitespace trim work, so I'll give myself this. * More consistent nested quoting
This commit is contained in:
parent
4a9cf67a25
commit
6701683ddf
@ -5,8 +5,11 @@ caption: {{$:/language/ControlPanel/KeyboardShortcuts/Caption}}
|
||||
\define lingo-base() $:/language/ControlPanel/KeyboardShortcuts/
|
||||
|
||||
\define new-shortcut(title)
|
||||
\whitespace trim
|
||||
<div class="tc-dropdown-item-plain">
|
||||
<$edit-shortcut tiddler="$title$" placeholder={{$:/language/ControlPanel/KeyboardShortcuts/Add/Prompt}} focus="true" style="width:auto;"/> <$button>
|
||||
<$edit-shortcut tiddler="$title$" placeholder={{$:/language/ControlPanel/KeyboardShortcuts/Add/Prompt}} focus="true" style="width:auto;"/>
|
||||
 
|
||||
<$button>
|
||||
<<lingo Add/Caption>>
|
||||
<$action-listops
|
||||
$tiddler="$(shortcutTitle)$"
|
||||
@ -21,6 +24,7 @@ caption: {{$:/language/ControlPanel/KeyboardShortcuts/Caption}}
|
||||
\end
|
||||
|
||||
\define shortcut-list-item(caption)
|
||||
\whitespace trim
|
||||
<td>
|
||||
</td>
|
||||
<td style="text-align:right;font-size:0.7em;">
|
||||
@ -31,16 +35,16 @@ caption: {{$:/language/ControlPanel/KeyboardShortcuts/Caption}}
|
||||
<$button popup=<<qualify "$:/state/dropdown/$(shortcutTitle)$">> class="tc-btn-invisible">
|
||||
{{$:/core/images/edit-button}}
|
||||
</$button>
|
||||
 
|
||||
<$macrocall $name="displayshortcuts" $output="text/html" shortcuts={{$(shortcutTitle)$}} prefix="<kbd>" separator="</kbd> <kbd>" suffix="</kbd>"/>
|
||||
|
||||
<$reveal state=<<qualify "$:/state/dropdown/$(shortcutTitle)$">> type="popup" position="below" animate="yes">
|
||||
<div class="tc-block-dropdown-wrapper">
|
||||
<div class="tc-block-dropdown tc-edit-type-dropdown tc-popup-keep">
|
||||
<$list filter="[list[$(shortcutTitle)$!!text]sort[title]]" variable="shortcut" emptyMessage="""
|
||||
<div class="tc-dropdown-item-plain">
|
||||
//<<lingo NoShortcuts/Caption>>//
|
||||
</div>
|
||||
""">
|
||||
<$list
|
||||
filter="[list[$(shortcutTitle)$!!text]sort[title]]"
|
||||
variable="shortcut"
|
||||
emptyMessage="<div class='tc-dropdown-item-plain'>//<<lingo NoShortcuts/Caption>>//</div>">
|
||||
<div class="tc-dropdown-item-plain">
|
||||
<$button class="tc-btn-invisible" tooltip={{$:/language/ControlPanel/KeyboardShortcuts/Remove/Hint}}>
|
||||
<$action-listops
|
||||
@ -50,6 +54,7 @@ caption: {{$:/language/ControlPanel/KeyboardShortcuts/Caption}}
|
||||
/>
|
||||
<small>{{$:/core/images/close-button}}</small>
|
||||
</$button>
|
||||
 
|
||||
<kbd>
|
||||
<$macrocall $name="displayshortcuts" $output="text/html" shortcuts=<<shortcut>>/>
|
||||
</kbd>
|
||||
@ -65,6 +70,7 @@ caption: {{$:/language/ControlPanel/KeyboardShortcuts/Caption}}
|
||||
\end
|
||||
|
||||
\define shortcut-list(caption,prefix)
|
||||
\whitespace trim
|
||||
<tr>
|
||||
<$list filter="[[$prefix$$(shortcutName)$]]" variable="shortcutTitle">
|
||||
<<shortcut-list-item "$caption$">>
|
||||
@ -73,6 +79,7 @@ caption: {{$:/language/ControlPanel/KeyboardShortcuts/Caption}}
|
||||
\end
|
||||
|
||||
\define shortcut-editor()
|
||||
\whitespace trim
|
||||
<<shortcut-list "All" "$:/config/shortcuts/">>
|
||||
<<shortcut-list "Mac" "$:/config/shortcuts-mac/">>
|
||||
<<shortcut-list "NonMac" "$:/config/shortcuts-not-mac/">>
|
||||
@ -87,6 +94,7 @@ caption: {{$:/language/ControlPanel/KeyboardShortcuts/Caption}}
|
||||
\end
|
||||
|
||||
\define shortcut-item-inner()
|
||||
\whitespace trim
|
||||
<tr>
|
||||
<td>
|
||||
<$reveal type="nomatch" state=<<dropdownStateTitle>> text="open">
|
||||
@ -107,6 +115,7 @@ caption: {{$:/language/ControlPanel/KeyboardShortcuts/Caption}}
|
||||
{{$:/core/images/down-arrow}}
|
||||
</$button>
|
||||
</$reveal>
|
||||
 
|
||||
''<$text text=<<shortcutName>>/>''
|
||||
</td>
|
||||
<td>
|
||||
@ -126,10 +135,12 @@ caption: {{$:/language/ControlPanel/KeyboardShortcuts/Caption}}
|
||||
\end
|
||||
|
||||
\define shortcut-item()
|
||||
\whitespace trim
|
||||
<$set name="dropdownStateTitle" value=<<qualify "$:/state/dropdown/keyboardshortcut/$(shortcutName)$">>>
|
||||
<<shortcut-item-inner>>
|
||||
</$set>
|
||||
\end
|
||||
\whitespace trim
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
|
@ -3,6 +3,7 @@ title: $:/snippets/languageswitcher
|
||||
\define flag-title()
|
||||
$(languagePluginTitle)$/icon
|
||||
\end
|
||||
\whitespace trim
|
||||
|
||||
<$linkcatcher to="$:/language">
|
||||
<div class="tc-chooser tc-language-chooser">
|
||||
@ -18,6 +19,7 @@ $(languagePluginTitle)$/icon
|
||||
</$transclude>
|
||||
</$set>
|
||||
</span>
|
||||
 
|
||||
<$view field="description">
|
||||
<$view field="name">
|
||||
<$view field="title"/>
|
||||
|
@ -2,6 +2,7 @@ title: $:/core/macros/diff
|
||||
tags: $:/tags/Macro
|
||||
|
||||
\define compareTiddlerText(sourceTiddlerTitle,sourceSubTiddlerTitle,destTiddlerTitle,destSubTiddlerTitle)
|
||||
\whitespace trim
|
||||
<$set name="source" tiddler=<<__sourceTiddlerTitle__>> subtiddler=<<__sourceSubTiddlerTitle__>>>
|
||||
<$set name="dest" tiddler=<<__destTiddlerTitle__>> subtiddler=<<__destSubTiddlerTitle__>>>
|
||||
<$diff-text source=<<source>> dest=<<dest>>/>
|
||||
@ -10,6 +11,7 @@ tags: $:/tags/Macro
|
||||
\end
|
||||
|
||||
\define compareTiddlers(sourceTiddlerTitle,sourceSubTiddlerTitle,destTiddlerTitle,destSubTiddlerTitle,exclude)
|
||||
\whitespace trim
|
||||
<table class="tc-diff-tiddlers">
|
||||
<tbody>
|
||||
<$set name="sourceFields" filter="[<__sourceTiddlerTitle__>fields[]sort[]]">
|
||||
@ -22,8 +24,7 @@ tags: $:/tags/Macro
|
||||
<td>
|
||||
<$set name="source" tiddler=<<__sourceTiddlerTitle__>> subtiddler=<<__sourceSubTiddlerTitle__>> field=<<fieldName>>>
|
||||
<$set name="dest" tiddler=<<__destTiddlerTitle__>> subtiddler=<<__destSubTiddlerTitle__>> field=<<fieldName>>>
|
||||
<$diff-text source=<<source>> dest=<<dest>>>
|
||||
</$diff-text>
|
||||
<$diff-text source=<<source>> dest=<<dest>>> </$diff-text>
|
||||
</$set>
|
||||
</$set>
|
||||
</td>
|
||||
|
@ -2,17 +2,21 @@ title: $:/core/macros/keyboard-driven-input
|
||||
tags: $:/tags/Macro
|
||||
|
||||
\define change-input-tab(stateTitle,tag,beforeafter,defaultState,actions)
|
||||
\whitespace trim
|
||||
<$set name="tabsList" filter="[all[shadows+tiddlers]tag<__tag__>!has[draft.of]]">
|
||||
<$vars currentState={{{ [<__stateTitle__>!is[missing]get[text]] ~[<__defaultState__>] }}} firstTab={{{ [enlist<tabsList>nth[1]] }}} lastTab={{{ [enlist<tabsList>last[]] }}}>
|
||||
<$set name="nextTab" value={{{ [all[shadows+tiddlers]tag<__tag__>!has[draft.of]$beforeafter$<currentState>] ~[[$beforeafter$]removeprefix[after]suffix[]addprefix<firstTab>] ~[[$beforeafter$]removeprefix[before]suffix[]addprefix<lastTab>] }}}>
|
||||
<$let
|
||||
currentState={{{ [<__stateTitle__>!is[missing]get[text]] ~[<__defaultState__>] }}}
|
||||
firstTab={{{ [enlist<tabsList>nth[1]] }}}
|
||||
lastTab={{{ [enlist<tabsList>last[]] }}}
|
||||
nextTab={{{ [all[shadows+tiddlers]tag<__tag__>!has[draft.of]$beforeafter$<currentState>] ~[[$beforeafter$]removeprefix[after]suffix[]addprefix<firstTab>] ~[[$beforeafter$]removeprefix[before]suffix[]addprefix<lastTab>] }}}>
|
||||
<$action-setfield $tiddler=<<__stateTitle__>> text=<<nextTab>>/>
|
||||
$actions$
|
||||
</$set>
|
||||
</$vars>
|
||||
</$let>
|
||||
</$set>
|
||||
\end
|
||||
|
||||
\define keyboard-input-actions()
|
||||
\whitespace trim
|
||||
<$list filter="[<__index__>match[]]">
|
||||
<$action-setfield $tiddler=<<__storeTitle__>> text={{{ [<__tiddler__>get<__field__>] }}}/>
|
||||
</$list>
|
||||
@ -22,6 +26,7 @@ $actions$
|
||||
\end
|
||||
|
||||
\define input-next-actions-inner()
|
||||
\whitespace trim
|
||||
<$list filter="[<nextItem>minlength[1]]" variable="ignore">
|
||||
<$action-setfield $tiddler=<<__selectionStateTitle__>> text=<<nextItem>>/>
|
||||
<$list filter="[<__index__>match[]]">
|
||||
@ -35,12 +40,19 @@ $actions$
|
||||
\end
|
||||
|
||||
\define input-next-actions(afterOrBefore:"after",reverse:"")
|
||||
\whitespace trim
|
||||
<$list filter="[<__storeTitle__>get[text]minlength<__filterMinLength__>] [<__filterMinLength__>match[0]] +[limit[1]]" variable="ignore">
|
||||
<$vars userInput={{{ [<__storeTitle__>get[text]] }}} selectedItem={{{ [<__selectionStateTitle__>get[text]] }}}>
|
||||
<$set name="configTiddler" value={{{ [subfilter<__configTiddlerFilter__>] }}}>
|
||||
<$vars primaryListFilter={{{ [<configTiddler>get<__firstSearchFilterField__>] }}} secondaryListFilter={{{ [<configTiddler>get<__secondSearchFilterField__>] }}}>
|
||||
<$let
|
||||
userInput={{{ [<__storeTitle__>get[text]] }}}
|
||||
selectedItem={{{ [<__selectionStateTitle__>get[text]] }}}
|
||||
configTiddler={{{ [subfilter<__configTiddlerFilter__>] }}}
|
||||
primaryListFilter={{{ [<configTiddler>get<__firstSearchFilterField__>] }}}
|
||||
secondaryListFilter={{{ [<configTiddler>get<__secondSearchFilterField__>] }}}>
|
||||
<$set name="filteredList" filter="[subfilter<primaryListFilter>addsuffix[-primaryList]] =[subfilter<secondaryListFilter>addsuffix[-secondaryList]]">
|
||||
<$vars nextItem={{{ [enlist<filteredList>$afterOrBefore$<selectedItem>] ~[enlist<filteredList>$reverse$nth[1]] }}} firstItem={{{ [enlist<filteredList>nth[1]] }}} lastItem={{{ [enlist<filteredList>last[]] }}}>
|
||||
<$let
|
||||
nextItem={{{ [enlist<filteredList>$afterOrBefore$<selectedItem>] ~[enlist<filteredList>$reverse$nth[1]] }}}
|
||||
firstItem={{{ [enlist<filteredList>nth[1]] }}}
|
||||
lastItem={{{ [enlist<filteredList>last[]] }}}>
|
||||
<$list filter="[<selectedItem>match<firstItem>!match<lastItem>]" variable="ignore">
|
||||
<$set name="nextItem" value={{{ [[$afterOrBefore$]match[before]then<userInput>addsuffix[-userInput]] ~[<nextItem>] }}}>
|
||||
<<input-next-actions-inner>>
|
||||
@ -59,11 +71,9 @@ $actions$
|
||||
<$list filter="[<selectedItem>!match<firstItem>!match<lastItem>]" variable="ignore">
|
||||
<<input-next-actions-inner>>
|
||||
</$list>
|
||||
</$vars>
|
||||
</$let>
|
||||
</$set>
|
||||
</$vars>
|
||||
</$set>
|
||||
</$vars>
|
||||
</$let>
|
||||
</$list>
|
||||
\end
|
||||
|
||||
|
@ -2,6 +2,7 @@ title: $:/core/macros/toc
|
||||
tags: $:/tags/Macro
|
||||
|
||||
\define toc-caption()
|
||||
\whitespace trim
|
||||
<$set name="tv-wikilinks" value="no">
|
||||
<$transclude field="caption">
|
||||
<$view field="title"/>
|
||||
@ -10,9 +11,10 @@ tags: $:/tags/Macro
|
||||
\end
|
||||
|
||||
\define toc-body(tag,sort:"",itemClassFilter,exclude,path)
|
||||
\whitespace trim
|
||||
<ol class="tc-toc">
|
||||
<$list filter="""[all[shadows+tiddlers]tag<__tag__>!has[draft.of]$sort$] -[<__tag__>] -[enlist<__exclude__>]""">
|
||||
<$vars item=<<currentTiddler>> path={{{ [<__path__>addsuffix[/]addsuffix<__tag__>] }}}>
|
||||
<$let item=<<currentTiddler>> path={{{ [<__path__>addsuffix[/]addsuffix<__tag__>] }}}>
|
||||
<$set name="excluded" filter="""[enlist<__exclude__>] [<__tag__>]""">
|
||||
<$set name="toc-item-class" filter=<<__itemClassFilter__>> emptyValue="toc-item-selected" value="toc-item">
|
||||
<li class=<<toc-item-class>>>
|
||||
@ -23,7 +25,7 @@ tags: $:/tags/Macro
|
||||
</li>
|
||||
</$set>
|
||||
</$set>
|
||||
</$vars>
|
||||
</$let>
|
||||
</$list>
|
||||
</ol>
|
||||
\end
|
||||
@ -33,6 +35,7 @@ tags: $:/tags/Macro
|
||||
\end
|
||||
|
||||
\define toc-linked-expandable-body(tag,sort:"",itemClassFilter,exclude,path)
|
||||
\whitespace trim
|
||||
<!-- helper function -->
|
||||
<$qualify name="toc-state" title={{{ [[$:/state/toc]addsuffix<__path__>addsuffix[-]addsuffix<currentTiddler>] }}}>
|
||||
<$set name="toc-item-class" filter=<<__itemClassFilter__>> emptyValue="toc-item-selected" value="toc-item">
|
||||
@ -48,6 +51,7 @@ tags: $:/tags/Macro
|
||||
{{$:/core/images/down-arrow}}
|
||||
</$button>
|
||||
</$reveal>
|
||||
 
|
||||
<<toc-caption>>
|
||||
</$link>
|
||||
<$reveal type="match" stateTitle=<<toc-state>> text="open">
|
||||
@ -59,6 +63,7 @@ tags: $:/tags/Macro
|
||||
\end
|
||||
|
||||
\define toc-unlinked-expandable-body(tag,sort:"",itemClassFilter,exclude,path)
|
||||
\whitespace trim
|
||||
<!-- helper function -->
|
||||
<$qualify name="toc-state" title={{{ [[$:/state/toc]addsuffix<__path__>addsuffix[-]addsuffix<currentTiddler>] }}}>
|
||||
<$set name="toc-item-class" filter=<<__itemClassFilter__>> emptyValue="toc-item-selected" value="toc-item">
|
||||
@ -66,12 +71,14 @@ tags: $:/tags/Macro
|
||||
<$reveal type="nomatch" stateTitle=<<toc-state>> text="open">
|
||||
<$button setTitle=<<toc-state>> setTo="open" class="tc-btn-invisible tc-popup-keep">
|
||||
{{$:/core/images/right-arrow}}
|
||||
 
|
||||
<<toc-caption>>
|
||||
</$button>
|
||||
</$reveal>
|
||||
<$reveal type="match" stateTitle=<<toc-state>> text="open">
|
||||
<$button setTitle=<<toc-state>> setTo="close" class="tc-btn-invisible tc-popup-keep">
|
||||
{{$:/core/images/down-arrow}}
|
||||
 
|
||||
<<toc-caption>>
|
||||
</$button>
|
||||
</$reveal>
|
||||
@ -88,7 +95,8 @@ tags: $:/tags/Macro
|
||||
\end
|
||||
|
||||
\define toc-expandable(tag,sort:"",itemClassFilter:"",exclude,path)
|
||||
<$vars tag=<<__tag__>> sort=<<__sort__>> itemClassFilter=<<__itemClassFilter__>> path={{{ [<__path__>addsuffix[/]addsuffix<__tag__>] }}}>
|
||||
\whitespace trim
|
||||
<$let tag=<<__tag__>> sort=<<__sort__>> itemClassFilter=<<__itemClassFilter__>> path={{{ [<__path__>addsuffix[/]addsuffix<__tag__>] }}}>
|
||||
<$set name="excluded" filter="""[enlist<__exclude__>] [<__tag__>]""">
|
||||
<ol class="tc-toc toc-expandable">
|
||||
<$list filter="""[all[shadows+tiddlers]tag<__tag__>!has[draft.of]$sort$] -[<__tag__>] -[enlist<__exclude__>]""">
|
||||
@ -98,10 +106,11 @@ tags: $:/tags/Macro
|
||||
</$list>
|
||||
</ol>
|
||||
</$set>
|
||||
</$vars>
|
||||
</$let>
|
||||
\end
|
||||
|
||||
\define toc-linked-selective-expandable-body(tag,sort:"",itemClassFilter,exclude,path)
|
||||
\whitespace trim
|
||||
<$qualify name="toc-state" title={{{ [[$:/state/toc]addsuffix<__path__>addsuffix[-]addsuffix<currentTiddler>] }}}>
|
||||
<$set name="toc-item-class" filter=<<__itemClassFilter__>> emptyValue="toc-item-selected" value="toc-item" >
|
||||
<li class=<<toc-item-class>>>
|
||||
@ -118,6 +127,7 @@ tags: $:/tags/Macro
|
||||
</$button>
|
||||
</$reveal>
|
||||
</$list>
|
||||
 
|
||||
<<toc-caption>>
|
||||
</$link>
|
||||
<$reveal type="match" stateTitle=<<toc-state>> text="open">
|
||||
@ -129,6 +139,7 @@ tags: $:/tags/Macro
|
||||
\end
|
||||
|
||||
\define toc-unlinked-selective-expandable-body(tag,sort:"",itemClassFilter,exclude,path)
|
||||
\whitespace trim
|
||||
<$qualify name="toc-state" title={{{ [[$:/state/toc]addsuffix<__path__>addsuffix[-]addsuffix<currentTiddler>] }}}>
|
||||
<$set name="toc-item-class" filter=<<__itemClassFilter__>> emptyValue="toc-item-selected" value="toc-item">
|
||||
<li class=<<toc-item-class>>>
|
||||
@ -136,12 +147,14 @@ tags: $:/tags/Macro
|
||||
<$reveal type="nomatch" stateTitle=<<toc-state>> text="open">
|
||||
<$button setTitle=<<toc-state>> setTo="open" class="tc-btn-invisible tc-popup-keep">
|
||||
{{$:/core/images/right-arrow}}
|
||||
 
|
||||
<<toc-caption>>
|
||||
</$button>
|
||||
</$reveal>
|
||||
<$reveal type="match" stateTitle=<<toc-state>> text="open">
|
||||
<$button setTitle=<<toc-state>> setTo="close" class="tc-btn-invisible tc-popup-keep">
|
||||
{{$:/core/images/down-arrow}}
|
||||
 
|
||||
<<toc-caption>>
|
||||
</$button>
|
||||
</$reveal>
|
||||
@ -159,8 +172,9 @@ tags: $:/tags/Macro
|
||||
\end
|
||||
|
||||
\define toc-selective-expandable(tag,sort:"",itemClassFilter,exclude,path)
|
||||
<$vars tag=<<__tag__>> sort=<<__sort__>> itemClassFilter=<<__itemClassFilter__>> path={{{ [<__path__>addsuffix[/]addsuffix<__tag__>] }}}>
|
||||
<$set name="excluded" filter="""[enlist<__exclude__>] [<__tag__>]""">
|
||||
\whitespace trim
|
||||
<$let tag=<<__tag__>> sort=<<__sort__>> itemClassFilter=<<__itemClassFilter__>> path={{{ [<__path__>addsuffix[/]addsuffix<__tag__>] }}}>
|
||||
<$set name="excluded" filter="[enlist<__exclude__>] [<__tag__>]">
|
||||
<ol class="tc-toc toc-selective-expandable">
|
||||
<$list filter="""[all[shadows+tiddlers]tag<__tag__>!has[draft.of]$sort$] -[<__tag__>] -[enlist<__exclude__>]""">
|
||||
<$list filter="[all[current]toc-link[no]]" variable="ignore" emptyMessage=<<toc-selective-expandable-empty-message>> >
|
||||
@ -169,10 +183,11 @@ tags: $:/tags/Macro
|
||||
</$list>
|
||||
</ol>
|
||||
</$set>
|
||||
</$vars>
|
||||
</$let>
|
||||
\end
|
||||
|
||||
\define toc-tabbed-external-nav(tag,sort:"",selectedTiddler:"$:/temp/toc/selectedTiddler",unselectedText,missingText,template:"")
|
||||
\whitespace trim
|
||||
<$tiddler tiddler={{{ [<__selectedTiddler__>get[text]] }}}>
|
||||
<div class="tc-tabbed-table-of-contents">
|
||||
<$linkcatcher to=<<__selectedTiddler__>>>
|
||||
@ -196,8 +211,8 @@ tags: $:/tags/Macro
|
||||
\end
|
||||
|
||||
\define toc-tabbed-internal-nav(tag,sort:"",selectedTiddler:"$:/temp/toc/selectedTiddler",unselectedText,missingText,template:"")
|
||||
\whitespace trim
|
||||
<$linkcatcher to=<<__selectedTiddler__>>>
|
||||
<$macrocall $name="toc-tabbed-external-nav" tag=<<__tag__>> sort=<<__sort__>> selectedTiddler=<<__selectedTiddler__>> unselectedText=<<__unselectedText__>> missingText=<<__missingText__>> template=<<__template__>>/>
|
||||
</$linkcatcher>
|
||||
\end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user