feat: replace height property with class

This commit is contained in:
Mikael Klasson 2026-07-19 13:57:20 +02:00
parent e1640553ae
commit 6fca8bb834
3 changed files with 13 additions and 5 deletions

View file

@ -4,11 +4,12 @@ import {
} from "obsidian";
export interface DialogField {
class?: string; // Custom CSS class to apply. Only for textArea types for now.
close?: boolean;
components?: BaseComponent[];
cta?: boolean;
desc?: string;
height?: string;
// height?: string;
key?: string;
onClick?: (result: DialogData, dialog: Dialog) => void | Promise<void>;
sameLine?: boolean;
@ -74,12 +75,15 @@ export class Dialog extends Modal {
setting.controlEl.addClass("mklasson-text-control");
setting.setName(field);
setting.infoEl.addClass("mklasson-text-info");
if (type == "textArea" || props?.height || value.contains("\n")) {
if (type == "textArea" /*|| props?.height */|| value.contains("\n")) {
setting.addTextArea(textInitialiser);
setting.controlEl.querySelector("textarea")?.addClass("mklasson-textarea");
if (props?.height) {
setting.controlEl.querySelector("textarea")?.setCssProps({"height": props.height});
if (props?.class) {
setting.controlEl.querySelector("textarea")?.addClass(props.class);
}
// if (props?.height) {
// setting.controlEl.querySelector("textarea")?.setCssProps({"height": props.height});
// }
} else {
setting.addText(textInitialiser);
setting.controlEl.querySelector("input")?.addClass("mklasson-text-wide");

View file

@ -705,7 +705,7 @@ class SettingTab extends PluginSettingTab {
} else {
fields[`${matches.length} matches`] = {
type: "textArea",
height: "20em",
class: "mklasson-setting-matches",
text: matches.map(file => file.path).join('\n'),
};
}

View file

@ -36,6 +36,10 @@ textarea.mklasson-textarea {
height: 5rem;
}
textarea.mklasson-setting-matches {
height: 16rem;
}
.mklasson-setting-error {
background-color: var(--background-modifier-error) !important;
}