mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 09:25:27 +00:00
fix: underline anchor; prevent jitter on render
This commit is contained in:
@@ -12,7 +12,7 @@ import { unified } from "unified";
|
|||||||
|
|
||||||
import { createElement } from "preact";
|
import { createElement } from "preact";
|
||||||
import { memo } from "preact/compat";
|
import { memo } from "preact/compat";
|
||||||
import { useEffect, useMemo, useState } from "preact/hooks";
|
import { useLayoutEffect, useMemo, useState } from "preact/hooks";
|
||||||
|
|
||||||
import { MarkdownProps } from "./Markdown";
|
import { MarkdownProps } from "./Markdown";
|
||||||
import { handlers } from "./hast";
|
import { handlers } from "./hast";
|
||||||
@@ -163,11 +163,18 @@ const render = unified()
|
|||||||
* Markdown parent container
|
* Markdown parent container
|
||||||
*/
|
*/
|
||||||
const Container = styled.div<{ largeEmoji: boolean }>`
|
const Container = styled.div<{ largeEmoji: boolean }>`
|
||||||
|
// Allow scrolling block math
|
||||||
.math-display {
|
.math-display {
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set emoji size
|
||||||
--emoji-size: ${(props) => (props.largeEmoji ? "3em" : "1.25em")};
|
--emoji-size: ${(props) => (props.largeEmoji ? "3em" : "1.25em")};
|
||||||
|
|
||||||
|
// Underline link hover
|
||||||
|
a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -205,7 +212,7 @@ export default memo(({ content, disallowBigEmoji }: MarkdownProps) => {
|
|||||||
|
|
||||||
const [Content, setContent] = useState<React.ReactElement>(null!);
|
const [Content, setContent] = useState<React.ReactElement>(null!);
|
||||||
|
|
||||||
useEffect(() => {
|
useLayoutEffect(() => {
|
||||||
render
|
render
|
||||||
.process(sanitisedContent)
|
.process(sanitisedContent)
|
||||||
.then((file) => setContent(file.result));
|
.then((file) => setContent(file.result));
|
||||||
|
|||||||
Reference in New Issue
Block a user