Skip to content

Commit

Permalink
fix: fixes display of suggestor for Obsidian 1.4+
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed Aug 16, 2023
1 parent 3e5cc4d commit 1ba2348
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ body {
margin-bottom: 1rem;
}

.initiative-tracker.suggestion-item, .initiative-tracker.suggestion-item > svg {
.initiative-tracker.suggestion-item .name,
.initiative-tracker.suggestion-item > svg {
display: flex;
align-items: center;
gap: 0.25rem;
Expand Down
19 changes: 10 additions & 9 deletions src/utils/suggester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,16 +357,17 @@ export class SRDMonsterSuggestionModal extends SuggestionModal<
el: HTMLElement
) {
let { item, match: matches } = result || {};
el.addClass("initiative-tracker");
if (item.player) {
setIcon(el, "user");
}
el.addClasses(["initiative-tracker", "mod-complex"]);
let content = el.createDiv({
cls: "suggestion-content icon initiative-tracker"
});
let name = content.createDiv("name");
if (item.player) {
setIcon(name, "user");
}
if (!item) {
this.suggester.selectedItem = null;
content.setText(this.emptyStateText);
name.setText(this.emptyStateText);
content.parentElement.addClass("is-selected");
return;
}
Expand All @@ -378,16 +379,16 @@ export class SRDMonsterSuggestionModal extends SuggestionModal<
let match = matches.matches.find((m) => m[0] === i);
if (match) {
let element = matchElements[matches.matches.indexOf(match)];
content.appendChild(element);
element.appendText(item.name.substring(match[0], match[1]));
name.appendChild(element);
name.appendText(item.name.substring(match[0], match[1]));

i += match[1] - match[0] - 1;
continue;
}

content.appendText(item.name[i]);
name.appendText(item.name[i]);
}
el.createDiv({
content.createDiv({
cls: "suggestion-note",
text: [item.source].flat().join(", ")
});
Expand Down

0 comments on commit 1ba2348

Please sign in to comment.