Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

fix: fixed the BR tag in the editor block formula HTML caused rendering not right

shuai9d4a06c1bf58
diff --git a/ui/src/components/Editor/utils/index.ts b/ui/src/components/Editor/utils/index.ts
index 56fe47a7..a1ed6ff8 100644
--- a/ui/src/components/Editor/utils/index.ts
+++ b/ui/src/components/Editor/utils/index.ts
@@ -80,6 +80,13 @@ export function createEditorUtils(
export function htmlRender(el: HTMLElement | null) {
if (!el) return;
+ // Replace all br tags with newlines
+ // Fixed an issue where the BR tag in the editor block formula HTML caused rendering errors.
+ el.querySelectorAll('br').forEach((br) => {
+ br.parentNode?.insertBefore(document.createTextNode('\n'), br);
+ br.parentNode?.removeChild(br);
+ });
+
import('mermaid').then(({ default: mermaid }) => {
mermaid.initialize({ startOnLoad: false });