pjeby / tag-wrangler

Rename, merge, toggle, and search tags from the Obsidian tag pane
633 stars 19 forks source link

Need(How) to use renameTag via dataviewjs(?) #99

Closed Another5405 closed 1 year ago

Another5405 commented 1 year ago

I always use dataviewjs create HTMLElement for manage things, and the built-in tag panel is messy if you use tag so much and no prefix when start using obsidian.

So I build UI via dataviewjs or quickAdd for any case and handle complex structure, On my try,

const tagwrangler = app.plugins.plugins["tag-wrangler"]; console.log(Object.getOwnPropertyNames(tagwrangler["_events"])); / 0: "_loaded" 1: "_events" 2: "_children" 3: "_lastDataModifiedTime" 4: "onConfigFileChange" 5: "app" 6: "manifest" 7: "pageAliases" 8: "tagPages" /

seem like I can not get the function via dataviewjs

sorry if that have a way to get it but I not notice.

pjeby commented 1 year ago

Tag Wrangler does not provide an API at this time. A future version of Tag Wrangler will support doing renames and other operations from the editor though. That is, you'll be able to right-click (or contextmenu key) a tag in a note and do renames and such from there.

Another5405 commented 1 year ago

Thanks for the reply, the future version sounds fun,but I still hope Tag Wrangler provide API on future.

I use tag as map of content and the problem is , I will need to select part of files which have same tag, and renames these tag. that will be very useful for update map of content.

Currently I will try to use tag plus metadata and update via metaedit, please feel free if Tag Wrangler will not provide API .

pjeby commented 1 year ago

I'm afraid I still don't understand what API you are looking for, exactly. Perhaps if you could show some code for what you are trying to do and what API you would like TW to have, then it might be a possibility for me to add. At the moment though, I have no idea what you want this API to do.

Another5405 commented 1 year ago

Rename tag for deeper classification, for example:

the tag #Food include Chicken Wings, Fried Chicken, Steak, Coke, Sprite

I will like to change the tag for Chicken Wings, Fried Chicken, Steak to #Food/Meat, and change the tag Coke, Sprite to #Food/Drinks.

I can make HTMLElement as UI to able to select specific file (dv.pages("#Food")) and turn the selected files to #Food/Drinks or #Food/Meat (like: await renameTag(files,tag,new tag))

pjeby commented 1 year ago

Ah. I see. Currently TW has no ability to restrict a rename to specific files, so even if there were an API it wouldn't be able to do that. It would only be able to change the tag across all files, not restricted to a particular list of files.

Another5405 commented 1 year ago

OK I got it,thanks for reply.