From 9d4a06c1bf589f4735c80e594ea08d799282f31b Mon Sep 17 00:00:00 2001 From: shuai Date: Tue, 28 Mar 2023 16:30:00 +0800 Subject: [PATCH] fix: fixed the BR tag in the editor block formula HTML caused rendering not right --- ui/src/components/Editor/utils/index.ts | 7 +++++++ 1 file changed, 7 insertions(+) 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 });