generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added info-text setting with markdown support
- Loading branch information
1 parent
75dc9e5
commit 0675acc
Showing
6 changed files
with
114 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/settingsView/SettingComponents/InfoTextSettingComponent.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { AbstractSettingComponent } from './AbstractSettingComponent'; | ||
import { MarkdownRenderer, Setting } from 'obsidian'; | ||
import { InfoText } from '../../SettingHandlers'; | ||
import { getDescription, getTitle } from '../../Utils'; | ||
|
||
export class InfoTextSettingComponent extends AbstractSettingComponent { | ||
settingEl: Setting; | ||
|
||
setting: InfoText; | ||
|
||
render(containerEl: HTMLElement): void { | ||
const title = getTitle(this.setting); | ||
const description = getDescription(this.setting); | ||
|
||
this.settingEl = new Setting(containerEl); | ||
this.settingEl.setClass('style-settings-info-text'); | ||
if (title) { | ||
this.settingEl.setName(title); | ||
} | ||
if (description) { | ||
if (this.setting.markdown) { | ||
MarkdownRenderer.renderMarkdown( | ||
description, | ||
this.settingEl.descEl, | ||
'', | ||
undefined | ||
); | ||
this.settingEl.descEl.addClass('style-settings-markdown'); | ||
} else { | ||
this.settingEl.setDesc(description); | ||
} | ||
} | ||
|
||
this.settingEl.settingEl.dataset.id = this.setting.id; | ||
} | ||
|
||
destroy(): void { | ||
this.settingEl?.settingEl.remove(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters