Skip to content

Commit

Permalink
New feature:
Browse files Browse the repository at this point in the history
- Disable narrowing down has been implemented
- New command `Create a new note with the same tags` has been implemented.
  • Loading branch information
vrtmrz committed Mar 14, 2023
1 parent 40df3b6 commit ee7ce6e
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 67 deletions.
141 changes: 83 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This is the plugin that shows your tags like folders.

Install this plugin, press `Ctrl+p`, and choose "Show Tag Folder".

### Behaviour
### Behavior

This plugin creates a tree by tags permutation.

Expand Down Expand Up @@ -56,27 +56,18 @@ When using this filter, this plugin shows only "Pear" (Sweet but not red) and "T

### Settings

#### Always Open
#### Behavior

Open Tag Folder when obsidian launched automatically.

#### Display Method

You can configure how the entry shows.

#### Use title
##### Always Open

When you enable this option, the value in the frontmatter or first level one heading will be shown instead of `NAME`.

#### Frontmatter path
Dotted path to retrieve title from frontmatter.
Open Tag Folder when obsidian launched automatically.

#### Use pinning
##### Use pinning
We can pin the tag if we enable this option.
When this feature is enabled, the pin information is saved in the file set in the next configuration.
Pinned tags are sorted according to `key` in the frontmatter of `taginfo.md`.

#### Pin information file
##### Pin information file
We can change the name of the file in which pin information is saved.
This can be configured also from the context-menu.

Expand All @@ -87,56 +78,41 @@ This can be configured also from the context-menu.
| alt | The tag will be shown as this. But they will not be merged into the same one. No `#` is required. |
| redirect | The tag will be redirected to the configured one and will be merged. No `#` is required. |

##### Disable narrowing down
TagFolder creates the folder structure by collecting combinations of tags that are used in the same note, to make it easier for us to find notes.
When this feature is enabled, collected combinations are no longer structured and show as we have organized them in a manner.

#### Merge redundant combinations
When this feature is enabled, a/b and b/a are merged into a/b if there are no intermediates.

#### Do not simplify empty folders
Keep empty folders, even if they can be simplified.
#### Files

#### Order method (Tags)
##### Display Method

You can order tags by:
- Filename
- Count of items
You can configure how the entry shows.

#### Order method (Items)
##### Order method

You can order items by:
- Displaying name
- Filename
- Modified time
- Fullpath of the file

#### Do not treat nested tags as dedicated levels
##### Use title

If you enable this option, every nested tag is split into normal tags.
When you enable this option, the value in the frontmatter or first level one heading will be shown instead of `NAME`.

`#dev/TagFolder` will be treated like `#dev` and `#TagFolder`.
##### Frontmatter path
Dotted path to retrieve title from frontmatter.

#### Reduce duplicated parents in nested tags
#### Tags

If we have the doc (e.g., `example note`) with nested tags which have the same parents, like `#topic/calculus`, `#topic/electromagnetics`:
##### Order method

- Disabled
```
topic
- > calculus
topic
- > electromagnetics
example note
example note
```
- Enabled
```
topic
- > calculus
- > electromagnetics
example note
example note
```
You can order tags by:
- Filename
- Count of items

#### Use virtual tags
##### Use virtual tags

When we enable this feature, our notes will be tagged as their freshness automatically.
| Icon | Edited ... |
Expand All @@ -147,11 +123,18 @@ When we enable this feature, our notes will be tagged as their freshness automat
| 📚 | Within 7 days |
| 🗄 | Older than 7 days ago |

#### Search tags inside TagFolder when clicking tags
#### Actions

##### Search tags inside TagFolder when clicking tags
We can search tags inside TagFolder when clicking tags instead of opening the default search pane.
With control and shift keys, we can remove the tag from the search condition or add an exclusion of it to that.

#### Hide Items
##### List files in a separated pane
When enabled, files will be shown in a separated pane.

#### Arrangements

##### Hide Items

Configure hiding items.
- Hide nothing
Expand All @@ -167,7 +150,8 @@ If you have these items:
```

This setting affects as like below.
##### Hide nothing
- Hide nothing

```
daily
→ 2021
Expand Down Expand Up @@ -196,7 +180,7 @@ daily
2021-12-01
```

##### Only intermediates of nested tags
- Only intermediates of nested tags
Hide only intermediates of nested tags, so show items only on the last or break of the nested tags.
```
daily
Expand All @@ -214,7 +198,7 @@ daily
→ 12
:
```
##### All intermediates
- All intermediates
Hide all intermediates, so show items only deepest.
```
daily
Expand All @@ -230,17 +214,58 @@ daily
:
```

#### Ignore note Tag
##### Merge redundant combinations
When this feature is enabled, a/b and b/a are merged into a/b if there are no intermediates.

If the note has the tag that is set in here, the note would be treated as there was not.
##### Do not simplify empty folders
Keep empty folders, even if they can be simplified.

#### Ignore Tag
##### Do not treat nested tags as dedicated levels

Tags that were set here would be treated as there were not.
If you enable this option, every nested tag is split into normal tags.

`#dev/TagFolder` will be treated like `#dev` and `#TagFolder`.

#### Target Folders
##### Reduce duplicated parents in nested tags

If we have the doc (e.g., `example note`) with nested tags which have the same parents, like `#topic/calculus`, `#topic/electromagnetics`:

- Disabled
```
topic
- > calculus
topic
- > electromagnetics
example note
example note
```
- Enabled
```
topic
- > calculus
- > electromagnetics
example note
example note
```

#### Filters


##### Target Folders
If we set this, the plugin will only target files in it.

#### Ignore Folders

##### Ignore Folders

Ignore documents in specific folders.


##### Ignore note Tag

If the note has the tag that is set in here, the note would be treated as there was not.

##### Ignore Tag

Tags that were set here would be treated as there were not.

##### Archive tags
3 changes: 3 additions & 0 deletions TreeItemComponent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@
),
];
let filteredTags = [...tempTags];
if (entry.extraTags) {
filteredTags = [...filteredTags, ...entry.extraTags];
}
for (const removeTag of removeTags) {
const part = removeTag.split("/");
for (const piece of part)
Expand Down
65 changes: 56 additions & 9 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import {
App,
CachedMetadata,
debounce,
Editor,
getAllTags,
MarkdownView,
normalizePath,
Notice,
parseYaml,
Expand Down Expand Up @@ -194,6 +196,7 @@ const expandTree = async (node: TreeItem, reduceNestedParent: boolean): Promise<

const newLeaf: TreeItem = {
tag: tag,
extraTags: node.extraTags,
children: newChildren,
ancestors: [...ancestor, tag],
descendants: null,
Expand Down Expand Up @@ -279,6 +282,7 @@ const splitTag = async (entry: TreeItem, reduceNestedParent: boolean, root?: Tre
if (!parent) {
const newGrandchild: TreeItem = {
tag: tagCdr,
extraTags: tempEntry.extraTags,//?
children: [...tempChildren],
ancestors: [
...newAncestorsBase,
Expand All @@ -292,6 +296,7 @@ const splitTag = async (entry: TreeItem, reduceNestedParent: boolean, root?: Tre
};
const newChild: TreeItem = {
tag: tagCar,
extraTags: tempEntry.extraTags,//?
children: [newGrandchild],
ancestors: [...newAncestorsBase, tagCar],
descendants: null,
Expand Down Expand Up @@ -320,6 +325,7 @@ const splitTag = async (entry: TreeItem, reduceNestedParent: boolean, root?: Tre
} else {
const x: TreeItem = {
tag: tagCdr,
extraTags: tempEntry.extraTags,//?
children: [...tempChildren],
ancestors: [
...newAncestorsBase,
Expand Down Expand Up @@ -638,6 +644,16 @@ export default class TagFolderPlugin extends Plugin {
this.activateView();
},
});
this.addCommand({
id: "tagfolder-create-similar",
name: "Create a new note with the same tags",
editorCallback: async (editor: Editor, view: MarkdownView) => {
const tags = getAllTags(this.app.metadataCache.getFileCache(view.file));
//@ts-ignore
const ww = await this.app.fileManager.createAndOpenMarkdownFile() as TFile;
await this.app.vault.append(ww, tags.join(" "));
},
});
this.metadataCacheChanged = this.metadataCacheChanged.bind(this);
this.watchWorkspaceOpen = this.watchWorkspaceOpen.bind(this);
this.registerEvent(
Expand Down Expand Up @@ -984,15 +1000,31 @@ export default class TagFolderPlugin extends Plugin {
allTags = allTags.filter(
(tag) => !ignoreTags.contains(tag.toLocaleLowerCase())
);
items.push({
tags: allTags,
path: fileCache.file.path,
displayName: this.getDisplayName(fileCache.file),
ancestors: [],
mtime: fileCache.file.stat.mtime,
ctime: fileCache.file.stat.ctime,
filename: fileCache.file.basename,
});
if (this.settings.disableNarrowingDown) {
for (const tags of allTags) {
items.push({
tags: [tags],
extraTags: allTags.filter(e => e != tags),
path: fileCache.file.path,
displayName: this.getDisplayName(fileCache.file),
ancestors: [],
mtime: fileCache.file.stat.mtime,
ctime: fileCache.file.stat.ctime,
filename: fileCache.file.basename,
});
}
} else {
items.push({
tags: allTags,
extraTags: [],
path: fileCache.file.path,
displayName: this.getDisplayName(fileCache.file),
ancestors: [],
mtime: fileCache.file.stat.mtime,
ctime: fileCache.file.stat.ctime,
filename: fileCache.file.basename,
});
}
}
return items;
}
Expand All @@ -1008,6 +1040,7 @@ export default class TagFolderPlugin extends Plugin {
const archivedNotes = archiveTags.map(archiveTag => ([archiveTag, items.filter(item => item.tags.some(tag => tag.toLocaleLowerCase() == archiveTag))])) as [string, ViewItem[]][]
const root: TreeItem = {
tag: "root",
extraTags: [],
children: [...items.filter(e => e.tags.every(tag => !archiveTags.contains(tag.toLocaleLowerCase())))],
ancestors: ["root"],
descendants: null,
Expand All @@ -1020,6 +1053,7 @@ export default class TagFolderPlugin extends Plugin {
for (const [archiveTag, items] of archivedNotes) {
root.children.push(
{
extraTags: [],
tag: archiveTag,
children: items,
ancestors: ["root", archiveTag],
Expand Down Expand Up @@ -1422,6 +1456,19 @@ class TagFolderSettingTab extends PluginSettingTab {
await this.plugin.saveSettings();
});
});
new Setting(containerEl)
.setName("Disable narrowing down")
.setDesc(
"When this feature is enabled, relevant tags will be shown with the title instead of making a sub-structure."
)
.addToggle((toggle) => {
toggle
.setValue(this.plugin.settings.disableNarrowingDown)
.onChange(async (value) => {
this.plugin.settings.disableNarrowingDown = value;
await this.plugin.saveSettings();
});
});
containerEl.createEl("h3", { text: "Files" });
new Setting(containerEl)
.setName("Display method")
Expand Down
Loading

0 comments on commit ee7ce6e

Please sign in to comment.