title: $:/core/macros/export
tags: $:/tags/Macro

\function exportButtonFilename(baseFilename)
[<baseFilename>] [<extension>] +[join[]]
\end

\procedure exportButton(exportFilter:"[!is[system]sort[title]]",lingoBase,baseFilename:"tiddlers")
\whitespace trim
<$let hint={{{ [<lingoBase>addsuffix[Hint]get[text]] }}}
	caption={{{  [<lingoBase>addsuffix[Caption]get[text]] }}}
>
	<span class="tc-popup-keep">
		<$button popup=<<qualify "$:/state/popup/export">>
			tooltip=<<hint>>
			aria-label=<<caption>>
			class=<<tv-config-toolbar-class>>
			selectedClass="tc-selected"
			dragFilter=<<exportFilter>>
		>
			<%if [<tv-config-toolbar-icons>match[yes]] %>
				{{$:/core/images/export-button}}
			<%endif%>
			<%if [<tv-config-toolbar-text>match[yes]] %>
				<span class="tc-btn-text"><$text text=<<caption>>/></span>
			<%endif%>
		</$button>
	</span>
</$let>
<$reveal state=<<qualify "$:/state/popup/export">> type="popup" position="below" animate="yes">
	<div class="tc-drop-down">
		<$set name="count" value={{{ [subfilter<exportFilter>count[]] }}}>
			<$list filter="[all[shadows+tiddlers]tag[$:/tags/Exporter]]">
				<$list filter="[<currentTiddler>has[condition]subfilter{!!condition}limit[1]] ~[<currentTiddler>!has[condition]then[true]]"
					variable="ignore"
				>
					<$button class="tc-btn-invisible">
						<$action-sendmessage $message="tm-download-file"
							$param=<<currentTiddler>>
							exportFilter=<<exportFilter>>
							filename={{{ [<baseFilename>addsuffix{!!extension}] }}}
							type={{!!file-type}}
						/>
						<$action-deletetiddler $tiddler=<<qualify "$:/state/popup/export">>/>
						<$transclude field="description"/>
					</$button>
				</$list>
			</$list>
		</$set>
	</div>
</$reveal>
\end
