mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-14 02:34:46 +08:00
When editing reports, tiptap-markdown escapes special characters (*, _, [, ]) which corrupts LaTeX formulas. This fix: 1. Adds unescapeLatexInMath() function to reverse markdown escaping within math delimiters ($...$ and 94410...94410) 2. Applies the unescape function in the editor's onChange callback to clean the markdown before storing it 3. Adds comprehensive tests covering edge cases and round-trip scenarios The fix ensures formulas like $(f * g)[n]$ remain unescaped when editing, preventing display errors after save/reload.
This commit is contained in:
@@ -31,7 +31,7 @@ import GenerativeMenuSwitch from "./generative/generative-menu-switch";
|
||||
import { uploadFn } from "./image-upload";
|
||||
import { TextButtons } from "./selectors/text-buttons";
|
||||
import { slashCommand, suggestionItems } from "./slash-command";
|
||||
import { normalizeMathForEditor } from "~/core/utils/markdown";
|
||||
import { normalizeMathForEditor, unescapeLatexInMath } from "~/core/utils/markdown";
|
||||
// import { defaultEditorContent } from "./content";
|
||||
|
||||
import "~/styles/prosemirror.css";
|
||||
@@ -74,7 +74,8 @@ const ReportEditor = ({ content, onMarkdownChange }: ReportEditorProps) => {
|
||||
const debouncedUpdates = useDebouncedCallback(
|
||||
async (editor: EditorInstance) => {
|
||||
if (onMarkdownChange) {
|
||||
const markdown = editor.storage.markdown.getMarkdown();
|
||||
let markdown = editor.storage.markdown.getMarkdown();
|
||||
markdown = unescapeLatexInMath(markdown);
|
||||
onMarkdownChange(markdown);
|
||||
}
|
||||
setSaveStatus("Saved");
|
||||
|
||||
Reference in New Issue
Block a user