Skip to content

Commit

Permalink
fix: Fixes casing display issue for custom titles in settings (close #…
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed Mar 16, 2022
1 parent b201aa7 commit 211b323
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,11 @@ class SettingsModal extends Modal {

this.type = v;
if (!this.title)
this.updateTitle(this.admonitionPreview, this.type);
this.updateTitle(
this.admonitionPreview,
this.type?.[0].toUpperCase() +
title.slice(1).toLowerCase()
);
});
});
typeSetting.controlEl.addClass("admonition-type-setting");
Expand Down Expand Up @@ -936,7 +940,11 @@ class SettingsModal extends Modal {
text.setValue(this.title).onChange((v) => {
if (!v.length) {
this.title = null;
this.updateTitle(this.admonitionPreview, this.type);
this.updateTitle(
this.admonitionPreview,
this.type?.[0].toUpperCase() +
title.slice(1).toLowerCase()
);
return;
}

Expand Down Expand Up @@ -1224,8 +1232,7 @@ class SettingsModal extends Modal {
".admonition-title-content"
);
let iconEl = admonitionPreview.querySelector(".admonition-title-icon");
titleSpan.textContent =
title[0].toUpperCase() + title.slice(1).toLowerCase();
titleSpan.textContent = title;
titleSpan.prepend(iconEl);
}
onOpen() {
Expand Down

0 comments on commit 211b323

Please sign in to comment.