Skip to content

Commit e7ecfd5

Browse files
committed
2.1.4 New: custom property display
1 parent 81ee74c commit e7ecfd5

File tree

7 files changed

+48
-16
lines changed

7 files changed

+48
-16
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 2.1.4
2+
3+
- New: In Settings under Custom Display List, the display of references can be customized to show properties from referenced files. In Settings, provide a comma separated list of case-sensitive property names. If a file has any of these properties when displayed in the reference list, the properties will also be displayed.
4+
15
# 2.1.3
26

37
- Fix: after sorting list of references, they would not respond to being clicked on.

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "obsidian42-strange-new-worlds",
33
"name": "Strange New Worlds",
4-
"version": "2.1.3",
4+
"version": "2.1.4",
55
"minAppVersion": "1.5.11",
66
"description": "Help see how your vault is interconnected with visual indicators.",
77
"author": "TfTHacker",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian42-strange-new-worlds",
3-
"version": "2.1.3",
3+
"version": "2.1.4",
44
"description": "Revealing networked thought and the strange new worlds created by your vault",
55
"scripts": {
66
"dev": "node esbuild.config.mjs",

src/settings.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface Settings {
2525
enableIgnoreObsExcludeFoldersLinksTo: boolean; //Use Obsidians Exclude Files from folder - links to those "excluded" files
2626
requireModifierKeyToActivateSNWView: boolean; //require CTRL hover to activate SNW view
2727
sortOptionDefault: SortOption;
28+
displayCustomPropertyList: string; //list of custom properties to display when showing references
2829
}
2930

3031
export const DEFAULT_SETTINGS: Settings = {
@@ -51,5 +52,6 @@ export const DEFAULT_SETTINGS: Settings = {
5152
enableIgnoreObsExcludeFoldersLinksFrom: false,
5253
enableIgnoreObsExcludeFoldersLinksTo: false,
5354
requireModifierKeyToActivateSNWView: false,
54-
sortOptionDefault: 'name-asc'
55+
sortOptionDefault: 'name-asc',
56+
displayCustomPropertyList: ''
5557
};

src/ui/SettingsTab.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,5 +311,21 @@ export class SettingsTab extends PluginSettingTab {
311311
await this.plugin.saveSettings();
312312
});
313313
});
314+
315+
new Setting(containerEl).setHeading().setName('Custom Display Settings');
316+
317+
new Setting(this.containerEl)
318+
.setName('Custom Property List')
319+
.setDesc(
320+
'Displays properties from referenced files in the references list. The list is comma separated list of case-sensitive property names.'
321+
)
322+
.addText((cb) => {
323+
cb.setPlaceholder('Ex: Project, Summary')
324+
.setValue(this.plugin.settings.displayCustomPropertyList)
325+
.onChange(async (list) => {
326+
this.plugin.settings.displayCustomPropertyList = list;
327+
await this.plugin.saveSettings();
328+
});
329+
});
314330
}
315331
}

src/ui/components/uic-ref-area.tsx

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const sortLinks = (links: Link[], option: SortOption): Link[] => {
7575
});
7676
};
7777

78-
// Creates a DIV for a colection of reference blocks to be displayed
78+
// Creates a DIV for a collection of reference blocks to be displayed
7979
const getRefAreaItems = async (refType: string, key: string, filePath: string): Promise<{ response: HTMLElement; refCount: number }> => {
8080
let countOfRefs = 0;
8181
let linksToLoop: Link[] = null;
@@ -116,6 +116,10 @@ const getRefAreaItems = async (refType: string, key: string, filePath: string):
116116

117117
let itemsDisplayedCounter = 0;
118118

119+
let customProperties = null;
120+
if (plugin.settings.displayCustomPropertyList.trim() != '')
121+
customProperties = plugin.settings.displayCustomPropertyList.split(',').map((x) => x.trim());
122+
119123
for (let index = 0; index < sortedFileKeys.length; index++) {
120124
if (itemsDisplayedCounter > maxItemsToShow) continue;
121125
const file_path = sortedFileKeys[index];
@@ -152,17 +156,22 @@ const getRefAreaItems = async (refType: string, key: string, filePath: string):
152156
responseItemContainerEl.appendChild(refItemFileEl);
153157

154158
// Add custom property field to display
155-
const fileCache = plugin.app.metadataCache.getFileCache(file_path.sourceFile);
156-
if (fileCache?.frontmatter?.['Summary']) {
157-
const customPropertyJsx = (
158-
<div class="snw-custom-property-container">
159-
<span class="snw-custom-property-name">Summary</span>
160-
<span class="snw-custom-property-text">: {fileCache?.frontmatter?.['Summary']}</span>
161-
</div>
162-
);
163-
const fieldEl = createDiv();
164-
render(customPropertyJsx, fieldEl);
165-
refItemFileLabelEl.append(fieldEl);
159+
if (customProperties != null) {
160+
const fileCache = plugin.app.metadataCache.getFileCache(file_path.sourceFile);
161+
customProperties.forEach((propName) => {
162+
const propValue = fileCache?.frontmatter?.[propName];
163+
if (propValue) {
164+
const customPropertyElement = (
165+
<div class="snw-custom-property-container">
166+
<span class="snw-custom-property-name">{propName}</span>
167+
<span class="snw-custom-property-text">: {propValue}</span>
168+
</div>
169+
);
170+
const fieldEl = createDiv();
171+
render(customPropertyElement, fieldEl);
172+
refItemFileLabelEl.append(fieldEl);
173+
}
174+
});
166175
}
167176

168177
const refItemsCollectionE = createDiv();

versions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
"2.1.0": "1.5.11",
99
"2.1.1": "1.5.11",
1010
"2.1.2": "1.5.11",
11-
"2.1.3": "1.5.11"
11+
"2.1.3": "1.5.11",
12+
"2.1.4": "1.5.11"
1213
}

0 commit comments

Comments
 (0)