mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 03:57:21 +00:00
Add some handy drag-and-drop macros
And refactor the tag template to use one of them
This commit is contained in:
parent
bea33efd63
commit
5ed7ade44f
@ -1,49 +1,17 @@
|
||||
title: $:/core/ui/TagTemplate
|
||||
|
||||
\define drop-actions()
|
||||
<!-- Save the current ordering of the tiddlers with this tag -->
|
||||
<$set name="order" filter="[<tag>tagging[]]">
|
||||
<!-- Remove any list-after or list-before fields from the tiddlers with this tag -->
|
||||
<$list filter="[<tag>tagging[]]">
|
||||
<$action-deletefield $field="list-before"/>
|
||||
<$action-deletefield $field="list-after"/>
|
||||
</$list>
|
||||
<!-- Assign the list field of the tag with the current ordering -->
|
||||
<$action-setfield $tiddler=<<tag>> $field="list" $value=<<order>>/>
|
||||
<!-- Add the newly inserted item to the list -->
|
||||
<$action-listops $tiddler=<<tag>> $field="list" $subfilter="+[insertbefore:currentTiddler<actionTiddler>]"/>
|
||||
<!-- Make sure the newly added item has the right tag -->
|
||||
<$action-listops $tiddler=<<actionTiddler>> $field="tags" $subfilter="+[<tag>]"/>
|
||||
</$set>
|
||||
\end
|
||||
|
||||
<span class="tc-tag-list-item">
|
||||
<$draggable tag="span" filter="[all[current]tagging[]]">
|
||||
<$set name="transclusion" value=<<currentTiddler>>>
|
||||
<$draggable tag="span" filter="[all[current]tagging[]]">
|
||||
<$macrocall $name="tag-pill-body" tag=<<currentTiddler>> icon={{!!icon}} colour={{!!color}} palette={{$:/palette}} element-tag="""$button""" element-attributes="""popup=<<qualify "$:/state/popup/tag">>"""/>
|
||||
</$draggable>
|
||||
<$reveal state=<<qualify "$:/state/popup/tag">> type="popup" position="below" animate="yes" class="tc-drop-down">
|
||||
<$transclude tiddler="$:/core/ui/ListItemTemplate"/>
|
||||
<$list filter="[all[shadows+tiddlers]tag[$:/tags/TagDropdown]!has[draft.of]]" variable="listItem">
|
||||
<$transclude tiddler=<<listItem>>/>
|
||||
</$list>
|
||||
<hr>
|
||||
<$set name="tag" value=<<currentTiddler>>>
|
||||
<$list filter="[all[current]tagging[]]">
|
||||
<div class="tc-menu-list-item" style="position: relative;">
|
||||
<$droppable actions=<<drop-actions>>>
|
||||
<div class="tc-droppable-placeholder">
|
||||
|
||||
</div>
|
||||
<div>
|
||||
<$link to={{!!title}}>
|
||||
<$view field="title"/>
|
||||
</$link>
|
||||
</div>
|
||||
</$droppable>
|
||||
</div>
|
||||
</$list>
|
||||
</$set>
|
||||
<$macrocall $name="list-tagged-draggable" tag=<<currentTiddler>>/>
|
||||
</$reveal>
|
||||
</$set>
|
||||
</$draggable>
|
||||
</span>
|
||||
|
@ -14,3 +14,87 @@ tags: $:/tags/Macro
|
||||
</$list>
|
||||
</$type$>
|
||||
\end
|
||||
|
||||
\define list-links-draggable-drop-actions()
|
||||
<$action-listops $tiddler=<<targetTiddler>> $field=<<targetField>> $subfilter="+[insertbefore:currentTiddler<actionTiddler>]"/>
|
||||
\end
|
||||
|
||||
\define list-links-draggable(tiddler,field:"list",type:"ul",subtype:"li",class:"",itemTemplate)
|
||||
<$vars targetTiddler="""$tiddler$""" targetField="""$field$""">
|
||||
<$type$ class="$class$">
|
||||
<$list filter="[list[$tiddler$!!$field$]]">
|
||||
<$droppable actions=<<list-links-draggable-drop-actions>> tag="""$subtype$""">
|
||||
<div class="tc-droppable-placeholder">
|
||||
|
||||
</div>
|
||||
<div>
|
||||
<$link to={{!!title}}>
|
||||
<$transclude tiddler="""$itemTemplate$""">
|
||||
<$transclude field="caption">
|
||||
<$view field="title"/>
|
||||
</$transclude>
|
||||
</$transclude>
|
||||
</$link>
|
||||
</div>
|
||||
</$droppable>
|
||||
</$list>
|
||||
<$tiddler tiddler="">
|
||||
<$droppable actions=<<list-links-draggable-drop-actions>> tag="""$subtype$""">
|
||||
<div class="tc-droppable-placeholder">
|
||||
|
||||
</div>
|
||||
<div>
|
||||
|
||||
</div>
|
||||
</$droppable>
|
||||
</$tiddler>
|
||||
</$type$>
|
||||
</$vars>
|
||||
\end
|
||||
|
||||
\define list-tagged-draggable-drop-actions()
|
||||
<!-- Save the current ordering of the tiddlers with this tag -->
|
||||
<$set name="order" filter="[<tag>tagging[]]">
|
||||
<!-- Remove any list-after or list-before fields from the tiddlers with this tag -->
|
||||
<$list filter="[<tag>tagging[]]">
|
||||
<$action-deletefield $field="list-before"/>
|
||||
<$action-deletefield $field="list-after"/>
|
||||
</$list>
|
||||
<!-- Assign the list field of the tag with the current ordering -->
|
||||
<$action-setfield $tiddler=<<tag>> $field="list" $value=<<order>>/>
|
||||
<!-- Add the newly inserted item to the list -->
|
||||
<$action-listops $tiddler=<<tag>> $field="list" $subfilter="+[insertbefore:currentTiddler<actionTiddler>]"/>
|
||||
<!-- Make sure the newly added item has the right tag -->
|
||||
<$action-listops $tiddler=<<actionTiddler>> $field="tags" $subfilter="+[<tag>]"/>
|
||||
</$set>
|
||||
\end
|
||||
|
||||
\define list-tagged-draggable(tag,itemTemplate)
|
||||
<$set name="tag" value="""$tag$""">
|
||||
<$list filter="[<tag>tagging[]]">
|
||||
<div class="tc-menu-list-item">
|
||||
<$droppable actions=<<list-tagged-draggable-drop-actions>>>
|
||||
<div class="tc-droppable-placeholder">
|
||||
|
||||
</div>
|
||||
<div>
|
||||
<$transclude tiddler="""$itemTemplate$""">
|
||||
<$link to={{!!title}}>
|
||||
<$view field="title"/>
|
||||
</$link>
|
||||
</$transclude>
|
||||
</div>
|
||||
</$droppable>
|
||||
</div>
|
||||
</$list>
|
||||
<$tiddler tiddler="">
|
||||
<$droppable actions=<<list-tagged-draggable-drop-actions>>>
|
||||
<div class="tc-droppable-placeholder">
|
||||
|
||||
</div>
|
||||
<div style="height:0.5em;">
|
||||
</div>
|
||||
</$droppable>
|
||||
</$tiddler>
|
||||
</$set>
|
||||
\end
|
||||
|
Loading…
Reference in New Issue
Block a user