Skip to content

Commit

Permalink
Preparing for publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
makary-s committed Mar 4, 2024
1 parent d25af8e commit 075c4b6
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 9 deletions.
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,38 @@ Metafolders builds a tree of notes based on a special (customizable) property th
## Features

- **Linking:** Any note in the navigator can be made a parent or removed from the parents of the active note by pressing a link button.

- **Root note pinning:** The root note can be pinned or changed with the active file. This can be adjusted by pressing the "pin" button.

- Any child tab can be made the root by double-clicking on it (relevant in pinned mode).

- **Root file history:** The plugin panel has its own history of root files, which can be navigated using the "back" and "forward" buttons.

- The previous root note is marked with a special clock icon to visually see where you came from.
- The "home" button returns to the home file (see settings).

- **Opening notes:** A note in the navigator can be opened differently:

- Click - opens in the active tab.
- Click + Ctrl - opens in a new tab.
- Click + Ctrl + Alt - opens in a new section.

- **Title source** - You can specify where the text for the note title will come from (filename, heading, special prop). See settings section.

- **Additional features:**

- Sorting items in a tree by name or dates.
- The plugin state is saved between reloads.
- Tree expansion within the session is preserved even when changing the root file.
- When you hover over a note, it is highlighted throughout the tree, wherever it appears (as it could occur multiple times).

## Settings

- **Parent property name** - You can specify any name for the property that
indicates the parents. By default, it is "up".
- **Parent property name** - You can specify any name for the property that indicates the parents. By default, it is "up".

- **Title source** - You can specify where the text for the file title will come from. Options include:

- File name (default)
- File name
- A property from the front-matter
- The first h1 heading (enter `{{h1}}`)

Expand Down
4 changes: 3 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Plugin,
PluginSettingTab,
Setting,
normalizePath,
WorkspaceLeaf,
} from "obsidian";
import {
Expand Down Expand Up @@ -115,7 +116,8 @@ class SettingTab extends PluginSettingTab {
.onChange(async (value) => {
this.plugin.ctx.settings.set(
"homeFilePath",
value || DEFAULT_SETTINGS.homeFilePath,
normalizePath(value) ||
DEFAULT_SETTINGS.homeFilePath,
);
}),
);
Expand Down
6 changes: 3 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"id": "obsidian-metafolders",
"name": "Metafolders",
"version": "1.0.0",
"version": "1.1.0",
"minAppVersion": "0.15.0",
"description": "Metafolders",
"author": "Makary Sharoyan <yasshig@gmail.com>",
"description": "Multidimensional note navigation",
"author": "Makary Sharoyan",
"authorUrl": "https://github.com/makary-s",
"isDesktopOnly": false
}
4 changes: 3 additions & 1 deletion src/components/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const TopBar = () => {
<ObsIcon kind="home" size="s" />
</Clickable>
) : null}

<Clickable
onClick={p.toggleAutoRefresh}
tooltip={
Expand All @@ -72,14 +73,15 @@ export const TopBar = () => {
size="s"
/>{" "}
</Clickable>
<SortMenu />

<Clickable
onClick={ctx.rootKey.update}
tooltip={"Refresh tree"}
>
<ObsIcon kind={"refresh-cw"} size="s" />{" "}
</Clickable>

<SortMenu />
</div>
<div className="top-panel_history">
<Clickable
Expand Down
2 changes: 2 additions & 0 deletions src/context/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class RootKey {

export class PluginContext {
app: App;
plugin: HierarchyViewPlugin;
settings: AtomObject<PluginSettings>;

currentFile: CurrentChecker;
Expand All @@ -35,6 +36,7 @@ export class PluginContext {

constructor(plugin: HierarchyViewPlugin, settings: PluginSettings) {
this.app = plugin.app;
this.plugin = plugin;

this.settings = new AtomObject(settings);
this.settings.subscribe(() => plugin.saveData(this.settings.current));
Expand Down
1 change: 0 additions & 1 deletion src/models/hierarchy/hierarchy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export type HierarchyCreateProps<T> = {
impl: HierarchyImpl<T>;
};

// TODO: add registry garbage collection
export class Hierarchy<T> {
protected constructor(protected p: HierarchyProps<T>) {}

Expand Down
3 changes: 3 additions & 0 deletions src/utils/hierarchy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ export const addParentLink = async (

const checkLinked = () => checkHasParent(ctx, p.file, p.linkedFile);

// Do not use registerEvent because the subscription happens automatically below.
const eventRef = ctx.app.metadataCache.on("resolved", () => {
if (checkLinked()) finished.resolve();
});
Expand Down Expand Up @@ -251,6 +252,7 @@ export const removeParentLink = async (
content.slice(0, item.position.start.offset) +
content.slice(endOffset);

// Editor API is not needed here.
ctx.app.vault.modify(p.file, newContent);
}
}
Expand All @@ -259,6 +261,7 @@ export const removeParentLink = async (

const checkLinked = () => checkHasParent(ctx, p.file, p.linkedFile);

// Do not use registerEvent because the subscription happens automatically below.
const eventRef = ctx.app.metadataCache.on("resolved", () => {
if (!checkLinked()) finished.resolve();
});
Expand Down
1 change: 1 addition & 0 deletions src/utils/obsidian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const extractMdLinkPath = (link: string): string | undefined => {

export const waitFilesLoaded = (app: App): Promise<void> => {
return new Promise<void>((resolve) => {
// Do not use registerEvent because the subscription happens automatically.
const unsubscribeActiveLeafChange = app.workspace.on(
"active-leaf-change",
() => {
Expand Down

0 comments on commit 075c4b6

Please sign in to comment.