Open zhangxiubo opened 3 years ago
This is something I've had on my mind for a while. The challenge here is figuring out what a good approach for implementing this would be. What makes it a bit complex is that rather than just think about manipulating tags, it is necessary to think about other ways that an end users might want to interact with a node and consider them together, such as manipulating other fields.
Also, the thinking was eventually to allow defining different types of stream nodes, where each type has a separate template. So care has to be taken to not add too much complexity to the template for each node which may make it difficult to implement different node types in the future.
In terms of adding tags, I have considered all of the following at some point:
tags:
. The problem with such an approach is that it would be one way only, allowing you to add tags.I welcome thoughts on these proposals or any alternative ideas for how to go about this.
PS @zhangxiubo there are a couple of people interested in how you set up your backlinks with Streams macros. If you are able to talk them through it, I can also add that information to the documentation. Thank you.
My personal feeling is that it is a bit cumbersome to use the context menu (exit editing - right click menu - select tag item - edit tag), I would be more inclined to trigger a popup menu (like rename tid) via shortcut keys (very direct). At present, my method is customize TW to allow edit tags directly in the displayed state, so that it is barely convenient to manipulating tags through keyboard.
I have a solution that works and that may be satisfactory to some of the users. At the same time, it has some shortcomings and may not be satisfactory for all users. It consists of a few components modified to work together.
##
) that brings up a popup menu listing tags, filtering with the user input (what follows the trigger pattern) (using the edit-comptext plugin) (config extract follows)
"pattern": "##",
"filter": "[tags[]!is[system]]",
"start": "<<tag \"",
"end": "\">>"
tag
macro, which renders a tag pillbox (visual cue)var newTags=[];
for(var i=0,x=allTags.length;i<x;i++){
var trimmedtag=allTags[i].replace(/<<tag "|">>/g,"");
//console.log("trimmed tag="+trimmedtag);
//console.log("value truefalse="+tagsresolved.includes(trimmedtag));
if( tiddler.text.indexOf(allTags[i]) !==-1 && !tagsresolved.includes(trimmedtag) && ( tiddler.tags === undefined || tiddler.tags.indexOf(trimmedtag) ==-1 )){
newTags.push(trimmedtag);
}
}
//console.log(newTags);
cache[title]=true; // save the processed tiddler on the cache to avoid edit loops
taggedTiddlers.push(new $tw.Tiddler(tiddler,{tags: tiddler.tags ? newTags.concat(tiddler.tags) : newTags })); //only concatenate if the source tiddler has tagsS
//console.log("stringyfied: "+$tw.utils.stringifyList(oldtags));
//$tw.wiki.setText(roottiddler,"tags",undefined,$tw.utils.stringifyList(newTags));
This solution supports tag names that include spaces. Visually, it is quite easy to infer the node has been tagged (pillbox); however it could be misleading... read below.
In terms for shortcomings:
So very much a hack, unsustainable, probably awful for performance, etc... but works well for me. I also tried but did not succeed to have the root tiddler tagged this way instead of the node. I worked around it.
Use case: a user might want to add tags (e.g.
todo
) to a node when editing them in-place; currently the user needs to open the tiddler to manipulate the tags. Perhaps there can be a built-in way to add/remove tags when the inline node editor is active?