Skip to content

Commit

Permalink
Should meet requirements from Obsidian Review
Browse files Browse the repository at this point in the history
Moved styles to CSS, replaced a cast with instanceof and reduced the amount of any use
  • Loading branch information
Marius Svarverud committed Jul 21, 2024
1 parent bbc4f4f commit 1ba2b96
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.0.3

- Behind the scenes improvements to streamline the codebase

## 1.0.2

- Updated manifest version number
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "structured-tree",
"name": "Structured Tree",
"version": "1.0.2",
"version": "1.0.3",
"minAppVersion": "0.15.0",
"description": "A file explorer for navigating hierarchical notes separated by '.'",
"author": "Marius Svarverud",
Expand Down
8 changes: 7 additions & 1 deletion src/custom-resolver/link-live.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ class LinkWidget extends WidgetType {
}
}

interface DecorationValue {
isReplace: boolean;
// Include other properties as needed
}

interface LinkData {
start: number;
end: number;
Expand Down Expand Up @@ -135,7 +140,8 @@ export class LinkLivePlugin implements PluginValue {

let found = false;
while (iter.value) {
if ((iter.value as any).isReplace) {
const decorValue = iter.value as DecorationValue | Decoration;
if ("isReplace" in decorValue && decorValue.isReplace) {
const link = links.find(({ start }) => start === iter.from);
if (link) {
found = true;
Expand Down
13 changes: 8 additions & 5 deletions src/modal/add-vault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ class FolderSuggester extends PopoverSuggest<TFolder> {
this.suggestions.setSuggestions(suggestionList);
this.open();
this.setAutoDestroy(this.inputEl);
this.suggestEl.style.width = `${this.inputEl.offsetWidth}px`;

// Ensure the class is added
this.suggestEl.classList.add("suggestion-width-dynamic");
// Update the custom property with the current input element's width
this.suggestEl.style.setProperty('--suggestion-width', `${this.inputEl.offsetWidth}px`);

const loc = this.inputEl.getBoundingClientRect();
this.reposition({
left: loc.left,
Expand All @@ -33,13 +38,11 @@ class FolderSuggester extends PopoverSuggest<TFolder> {
bottom: loc.top + this.inputEl.offsetHeight,
});
};
getSuggestions(query: string) {
getSuggestions(query: string): TFolder[] {
const queryLowercase = query.toLowerCase();
return this.app.vault
.getAllLoadedFiles()
.filter(
(file) => file instanceof TFolder && file.path.toLowerCase().contains(queryLowercase)
) as TFolder[];
.filter((file): file is TFolder => file instanceof TFolder && file.path.toLowerCase().includes(queryLowercase));
}
renderSuggestion(value: TFolder, el: HTMLElement): void {
el.createDiv({
Expand Down
4 changes: 4 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@
.dendron-folder-suggest .suggestion-item {
word-break: break-all;
}

.suggestion-width-dynamic {
width: var(--suggestion-width);
}

0 comments on commit 1ba2b96

Please sign in to comment.