From df00d52d8aa3a273badbe404851900a5e8f408cb Mon Sep 17 00:00:00 2001 From: strasmus1 Date: Mon, 27 Apr 2026 12:15:43 +0000 Subject: [PATCH] Fixed glossary popup html handling, removed glossary entry popups within glossary entries --- gradesa/src/app/admin/glossary/page.js | 2 +- gradesa/src/app/glossary/page.js | 2 +- .../ui/glossary/GlossaryTooltip.jsx | 5 ++- .../components/ui/render-html/render-html.jsx | 32 +++++++++++-------- .../ui/render-html/render-html.test.jsx | 5 +++ 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/gradesa/src/app/admin/glossary/page.js b/gradesa/src/app/admin/glossary/page.js index d89dd53..dcf8df5 100644 --- a/gradesa/src/app/admin/glossary/page.js +++ b/gradesa/src/app/admin/glossary/page.js @@ -78,7 +78,7 @@ export default function GlossaryList() {

{entry.word}

- + Erstellt:{" "} diff --git a/gradesa/src/app/glossary/page.js b/gradesa/src/app/glossary/page.js index 83ef551..296d6ef 100644 --- a/gradesa/src/app/glossary/page.js +++ b/gradesa/src/app/glossary/page.js @@ -34,7 +34,7 @@ export default function GlossaryPage() {

{entry.word}

- +
))} diff --git a/gradesa/src/components/ui/glossary/GlossaryTooltip.jsx b/gradesa/src/components/ui/glossary/GlossaryTooltip.jsx index 25bde00..04da5a8 100644 --- a/gradesa/src/components/ui/glossary/GlossaryTooltip.jsx +++ b/gradesa/src/components/ui/glossary/GlossaryTooltip.jsx @@ -2,6 +2,7 @@ import { useGlossary } from "@/context/glossary.context"; import { useState, useRef, useEffect } from "react"; import styles from "./GlossaryTooltip.module.css"; +import RenderHTML from "@/components/ui/render-html/render-html"; import { createPortal } from "react-dom"; export default function GlossaryTooltip({ word, children }) { @@ -117,7 +118,9 @@ export default function GlossaryTooltip({ word, children }) { }} >

{entry.word}

-

{entry.word_definition}

+
+ +
, portalElement )} diff --git a/gradesa/src/components/ui/render-html/render-html.jsx b/gradesa/src/components/ui/render-html/render-html.jsx index 2e9602f..66e4b00 100644 --- a/gradesa/src/components/ui/render-html/render-html.jsx +++ b/gradesa/src/components/ui/render-html/render-html.jsx @@ -50,24 +50,30 @@ const normalizeAttribs = (attributes = {}) => { * @param {{data: string}} props - Component props containing raw HTML string. * @returns {JSX.Element|null} Parsed React nodes wrapped in a `div`, or `null`. */ -export default function RenderHTML({ data }) { +export default function RenderHTML({ data, disableGlossary = false }) { if (!data) return null; + const renderParagraph = (attributes, children) => + disableGlossary ? ( +

{children}

+ ) : ( + {children} + ); + + const renderListItem = (attributes, children) => + disableGlossary ? ( +
  • {children}
  • + ) : ( + {children} + ); + // Handlers for specific custom tags. Each handler receives normalized // attributes and the already-converted children (as React nodes). const handlers = { - p: (attributes, children) => ( - {children} - ), - li: (attributes, children) => ( - {children} - ), - glossaryparagraph: (attributes, children) => ( - {children} - ), - glossarylistitem: (attributes, children) => ( - {children} - ), + p: renderParagraph, + li: renderListItem, + glossaryparagraph: renderParagraph, + glossarylistitem: renderListItem, column: (attributes, children) => { const safeAttribs = { ...attributes }; safeAttribs.className = [safeAttribs.className, "glossary-column"] diff --git a/gradesa/src/components/ui/render-html/render-html.test.jsx b/gradesa/src/components/ui/render-html/render-html.test.jsx index 3eda650..0e24761 100644 --- a/gradesa/src/components/ui/render-html/render-html.test.jsx +++ b/gradesa/src/components/ui/render-html/render-html.test.jsx @@ -36,6 +36,11 @@ vi.mock("@/components/ui/glossary/GlossaryText", () => ({ ); }, + GlossaryOccurrenceProvider: function GlossaryOccurrenceProvider({ + children, + }) { + return <>{children}; + }, })); describe("RenderHTML Component", () => {