From fb48c57e42bc9881d2f892ded80df788224d9e80 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Sat, 12 Jul 2025 13:19:03 +0200 Subject: [PATCH] Refactoring: remove AsMarkdown() from the old BaseUIElement --- src/UI/Base/Combine.ts | 8 -------- src/UI/Base/Table.ts | 19 ------------------- src/UI/Base/VariableUIElement.ts | 11 ----------- src/UI/BaseUIElement.ts | 4 ---- src/UI/InputElement/Validator.ts | 9 ++------- 5 files changed, 2 insertions(+), 49 deletions(-) diff --git a/src/UI/Base/Combine.ts b/src/UI/Base/Combine.ts index 92691efe0b..44c904944d 100644 --- a/src/UI/Base/Combine.ts +++ b/src/UI/Base/Combine.ts @@ -18,14 +18,6 @@ export default class Combine extends BaseUIElement { }) } - AsMarkdown(): string { - let sep = " " - if (this.HasClass("flex-col")) { - sep = "\n\n" - } - return this.uiElements.map((el) => el.AsMarkdown()).join(sep) - } - Destroy() { super.Destroy() for (const uiElement of this.uiElements) { diff --git a/src/UI/Base/Table.ts b/src/UI/Base/Table.ts index 0eb4c51c47..515cc9931d 100644 --- a/src/UI/Base/Table.ts +++ b/src/UI/Base/Table.ts @@ -23,25 +23,6 @@ export default class Table extends BaseUIElement { this._contents = contents.map((row) => row.map(Translations.W)) } - AsMarkdown(): string { - const headerMarkdownParts = this._header.map((hel) => hel?.AsMarkdown() ?? " ") - const header = Utils.NoNull(headerMarkdownParts).join(" | ") - const headerSep = headerMarkdownParts.map((part) => "-".repeat(part.length + 2)).join(" | ") - const table = this._contents - .map((row) => - row - .map( - (el) => - el?.AsMarkdown()?.replaceAll("\\", "\\\\")?.replaceAll("|", "\\|") ?? - " " - ) - .join(" | ") - ) - .join("\n") - - return "\n\n" + [header, headerSep, table, ""].join("\n") - } - protected InnerConstructElement(): HTMLElement { const table = document.createElement("table") diff --git a/src/UI/Base/VariableUIElement.ts b/src/UI/Base/VariableUIElement.ts index 4da0011bbb..c288d86399 100644 --- a/src/UI/Base/VariableUIElement.ts +++ b/src/UI/Base/VariableUIElement.ts @@ -19,17 +19,6 @@ export class VariableUiElement extends BaseUIElement { this.isDestroyed = true } - AsMarkdown(): string { - const d = this._contents?.data - if (typeof d === "string") { - return d - } - if (d instanceof BaseUIElement) { - return d.AsMarkdown() - } - return new Combine(d).AsMarkdown() - } - protected InnerConstructElement(): HTMLElement { const el = document.createElement("span") const self = this diff --git a/src/UI/BaseUIElement.ts b/src/UI/BaseUIElement.ts index e867612938..f697af7258 100644 --- a/src/UI/BaseUIElement.ts +++ b/src/UI/BaseUIElement.ts @@ -158,10 +158,6 @@ export default abstract class BaseUIElement { } } - public AsMarkdown(): string { - throw "AsMarkdown is not implemented; implement it in the subclass" - } - public Destroy() { this.isDestroyed = true } diff --git a/src/UI/InputElement/Validator.ts b/src/UI/InputElement/Validator.ts index 3dd0fbc076..f37dbbc1b7 100644 --- a/src/UI/InputElement/Validator.ts +++ b/src/UI/InputElement/Validator.ts @@ -1,4 +1,3 @@ -import BaseUIElement from "../BaseUIElement" import { Translation } from "../i18n/Translation" import Translations from "../i18n/Translations" @@ -32,7 +31,7 @@ export abstract class Validator { constructor( name: string, - explanation: string | BaseUIElement, + explanation: string, inputmode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search", textArea?: false | boolean ) { @@ -45,11 +44,7 @@ export abstract class Validator { if (this.name.endsWith("textfielddef")) { this.name = this.name.substring(0, this.name.length - "TextFieldDef".length) } - if (typeof explanation === "string") { - this.explanation = explanation - } else { - this.explanation = explanation.AsMarkdown() - } + this.explanation = explanation } /**