Skip to content

Commit

Permalink
feat(impliedRelations): ✨ Working Mermaid diagrams to visualise the i…
Browse files Browse the repository at this point in the history
…mplied relations
  • Loading branch information
SkepticMystic committed Apr 20, 2022
1 parent eb266a7 commit eb3c416
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
14 changes: 8 additions & 6 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -38621,12 +38621,9 @@ function addRegexNoteSettings(plugin, alternativeHierarchyDetails) {
function addRelationSettings(plugin, containerEl) {
const { settings } = plugin;
const relationDetails = details("Relationships", containerEl);
// MarkdownRenderer.renderMarkdown(
// "```mermaid\nflowchart BT\nMe -->|up| Dad\nDad -->|same| Aunt\nMe -->|up| Aunt\n```",
// containerEl,
// "",
// null
// );
function mermaidDiagram(diagramStr) {
obsidian.MarkdownRenderer.renderMarkdown(diagramStr, relationDetails.createDiv(), "", null);
}
relationDetails.createEl("p", {
text: "Here you can toggle on/off different types of implied relationships. All of your explicit (real) relationships will still show, but you can choose which implied ones get filled in.\nAll implied relationships are given a CSS class of the type of implied relation, so you can style them differently. For example `.BC-Aunt`.",
});
Expand All @@ -38640,6 +38637,7 @@ function addRelationSettings(plugin, containerEl) {
await plugin.saveSettings();
await refreshIndex(plugin);
}));
mermaidDiagram("```mermaid\nflowchart LR\nMe -->|up| Dad\nSister -->|up| Dad\nMe <-.->|same| Sister\n```");
new obsidian.Setting(relationDetails)
.setName("Siblings' Siblings")
.setDesc("Treat your siblings' siblings as your siblings")
Expand All @@ -38650,6 +38648,7 @@ function addRelationSettings(plugin, containerEl) {
await plugin.saveSettings();
await refreshIndex(plugin);
}));
mermaidDiagram("```mermaid\nflowchart LR\nMe -->|same| Sister\nMe -->|same| Brother\nSister <-.->|same| Brother\n```");
new obsidian.Setting(relationDetails)
.setName("Siblings' Parent is Parent")
.setDesc("Your siblings' parents are your parents")
Expand All @@ -38660,6 +38659,7 @@ function addRelationSettings(plugin, containerEl) {
await plugin.saveSettings();
await refreshIndex(plugin);
}));
mermaidDiagram("```mermaid\nflowchart LR\nSister -->|up| Dad\nSister <-->|same| Me\nMe -.->|up| Dad\n```");
new obsidian.Setting(relationDetails)
.setName("Aunt/Uncle")
.setDesc("Treat your parent's siblings as your parents (aunts/uncles)")
Expand All @@ -38670,6 +38670,7 @@ function addRelationSettings(plugin, containerEl) {
await plugin.saveSettings();
await refreshIndex(plugin);
}));
mermaidDiagram("```mermaid\nflowchart LR\nMe -->|up| Dad\nDad -->|same| Uncle\nMe -.->|up| Uncle\n```");
new obsidian.Setting(relationDetails)
.setName("Cousins")
.setDesc("Treat the cousins of a note as siblings (parents' siblings' children are cousins)")
Expand All @@ -38680,6 +38681,7 @@ function addRelationSettings(plugin, containerEl) {
await plugin.saveSettings();
await refreshIndex(plugin);
}));
mermaidDiagram("```mermaid\nflowchart LR\nMe -->|up| Dad\nDad -->|same| Uncle\nUncle -->|down| Cousin\nMe <-.->|same| Cousin\n```");
new obsidian.Setting(relationDetails)
.setName("Make Current Note an Implied Sibling")
.setDesc("Techincally, the current note is always it's own implied sibling. By default, it is not show as such. Toggle this on to make it show.")
Expand Down
30 changes: 23 additions & 7 deletions src/Settings/RelationSettings.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import { details } from "./BreadcrumbsSettingTab";
import type BCPlugin from "../main";
import { Setting } from "obsidian";
import { MarkdownRenderer, Setting } from "obsidian";
import { refreshIndex } from "../refreshIndex";


export function addRelationSettings(
plugin: BCPlugin,
containerEl: HTMLElement
) {
const { settings } = plugin;
const relationDetails = details("Relationships", containerEl);

// MarkdownRenderer.renderMarkdown(
// "```mermaid\nflowchart BT\nMe -->|up| Dad\nDad -->|same| Aunt\nMe -->|up| Aunt\n```",
// containerEl,
// "",
// null
// );
function mermaidDiagram(diagramStr: string) {
MarkdownRenderer.renderMarkdown(
diagramStr,
relationDetails.createDiv(),
"",
null
);
}


relationDetails.createEl("p", {
text: "Here you can toggle on/off different types of implied relationships. All of your explicit (real) relationships will still show, but you can choose which implied ones get filled in.\nAll implied relationships are given a CSS class of the type of implied relation, so you can style them differently. For example `.BC-Aunt`.",
Expand All @@ -33,6 +37,9 @@ export function addRelationSettings(
await refreshIndex(plugin);
})
);

mermaidDiagram("```mermaid\nflowchart LR\nMe -->|up| Dad\nSister -->|up| Dad\nMe <-.->|same| Sister\n```")

new Setting(relationDetails)
.setName("Siblings' Siblings")
.setDesc("Treat your siblings' siblings as your siblings")
Expand All @@ -46,6 +53,8 @@ export function addRelationSettings(
})
);

mermaidDiagram("```mermaid\nflowchart LR\nMe -->|same| Sister\nMe -->|same| Brother\nSister <-.->|same| Brother\n```")

new Setting(relationDetails)
.setName("Siblings' Parent is Parent")
.setDesc("Your siblings' parents are your parents")
Expand All @@ -59,6 +68,8 @@ export function addRelationSettings(
})
);

mermaidDiagram("```mermaid\nflowchart LR\nSister -->|up| Dad\nSister <-->|same| Me\nMe -.->|up| Dad\n```")

new Setting(relationDetails)
.setName("Aunt/Uncle")
.setDesc("Treat your parent's siblings as your parents (aunts/uncles)")
Expand All @@ -71,6 +82,9 @@ export function addRelationSettings(
await refreshIndex(plugin);
})
);

mermaidDiagram("```mermaid\nflowchart LR\nMe -->|up| Dad\nDad -->|same| Uncle\nMe -.->|up| Uncle\n```")

new Setting(relationDetails)
.setName("Cousins")
.setDesc(
Expand All @@ -86,6 +100,8 @@ export function addRelationSettings(
})
);

mermaidDiagram("```mermaid\nflowchart LR\nMe -->|up| Dad\nDad -->|same| Uncle\nUncle -->|down| Cousin\nMe <-.->|same| Cousin\n```")

new Setting(relationDetails)
.setName("Make Current Note an Implied Sibling")
.setDesc(
Expand Down

0 comments on commit eb3c416

Please sign in to comment.