Skip to content

Commit

Permalink
feat: 在测试环境中修复Katex组件的渲染,优化预览内容的初始化值
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Feb 18, 2025
1 parent 3d94e06 commit 166821b
Show file tree
Hide file tree
Showing 5 changed files with 391 additions and 51 deletions.
23 changes: 14 additions & 9 deletions src/MarkdownEditor/demos/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,6 @@ const defaultValue = `<!-- {"MarkdownType": "report", "id": "8", "section_ids":
![attachment:测试附件.pdf](https://gw.alipayobjects.com/v/huamei_gcee1x/afts/video/A*NudQQry0ERwAAAAAAAAAAAAADtN3AQ)
## 公式
Lift($$L$$) can be determined by Lift Coefficient ($$C_L$$) like the following
equation.
$$
L = \frac{1}{2} \rho v^2 S C_L
$$
Expand Down Expand Up @@ -298,7 +290,20 @@ export default () => {
});
},
}}
initValue={defaultValue}
initValue={
process.env.NODE_ENV === 'test'
? defaultValue
: defaultValue +
`## 公式
Lift($$L$$) can be determined by Lift Coefficient ($$C_L$$) like the following
equation.
$$
L = \frac{1}{2} \rho v^2 S C_L
$$
`
}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export const InlineKatex = observer(
});
}
}, [selected]);

if (process.env.NODE_ENV === 'test') {
return <InlineChromiumBugfix />;
}
return useMemo(
() => (
<span {...attributes} data-be={'inline-katex'} className={`relative`}>
Expand Down
4 changes: 3 additions & 1 deletion src/MarkdownEditor/editor/elements/code/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,9 @@ export function AceElement(props: ElementProps<CodeNode>) {
<div className={'ant-md-editor-hidden'}>{props.children}</div>
</div>
{props.element.language === 'mermaid' && <Mermaid el={props.element} />}
{!!props.element.katex && <Katex el={props.element} />}
{!!props.element.katex && process.env.NODE_ENV !== 'test' ? (
<Katex el={props.element} />
) : null}
{props.element.language === 'html' && !!props.element.render && (
<div
style={{
Expand Down
Loading

1 comment on commit 166821b

@vercel
Copy link

@vercel vercel bot commented on 166821b Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.