obsidian#AbstractTextComponent TypeScript Examples
The following examples show how to use
obsidian#AbstractTextComponent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: settings.ts From obsidian-citation-plugin with MIT License | 6 votes |
addValueChangeCallback<T extends HTMLTextAreaElement | HTMLInputElement>(
component: AbstractTextComponent<T> | DropdownComponent,
settingsKey: string,
cb?: (value: string) => void,
): void {
component.onChange(async (value) => {
(this.plugin.settings as IIndexable)[settingsKey] = value;
this.plugin.saveSettings().then(() => {
if (cb) {
cb(value);
}
});
});
}
Example #2
Source File: BaseModal.ts From obsidian-rss with GNU General Public License v3.0 | 6 votes |
//taken from github.com/valentine195/obsidian-admonition
setValidationError(input: AbstractTextComponent<any>, message?: string) : void {
input.inputEl.addClass("is-invalid");
if (message) {
input.inputEl.parentElement.addClasses([
"has-invalid-message",
"unset-align-items"
]);
input.inputEl.parentElement.parentElement.addClass(
".unset-align-items"
);
let mDiv = input.inputEl.parentElement.querySelector(
".invalid-feedback"
) as HTMLDivElement;
if (!mDiv) {
mDiv = createDiv({ cls: "invalid-feedback" });
}
mDiv.innerText = message;
mDiv.insertAfter(input.inputEl);
}
}
Example #3
Source File: BaseModal.ts From obsidian-rss with GNU General Public License v3.0 | 6 votes |
removeValidationError(input: AbstractTextComponent<any>) : void {
input.inputEl.removeClass("is-invalid");
input.inputEl.parentElement.removeClasses([
"has-invalid-message",
"unset-align-items"
]);
input.inputEl.parentElement.parentElement.removeClass(
".unset-align-items"
);
if (
input.inputEl.parentElement.querySelector(".invalid-feedback")
) {
input.inputEl.parentElement.removeChild(
input.inputEl.parentElement.querySelector(
".invalid-feedback"
)
);
}
}
Example #4
Source File: settings.ts From obsidian-citation-plugin with MIT License | 5 votes |
buildValueInput<T extends HTMLTextAreaElement | HTMLInputElement>(
component: AbstractTextComponent<T> | DropdownComponent,
settingsKey: string,
cb?: (value: string) => void,
): void {
component.setValue((this.plugin.settings as IIndexable)[settingsKey]);
this.addValueChangeCallback(component, settingsKey, cb);
}