feat: support markdown
This commit is contained in:
parent
bd230ddd4f
commit
85d144a1e9
34 changed files with 2350 additions and 4 deletions
36
ui/components/Markdown/renderer/inlineCode.tsx
Normal file
36
ui/components/Markdown/renderer/inlineCode.tsx
Normal file
|
@ -0,0 +1,36 @@
|
|||
import { css, cx } from "@emotion/css";
|
||||
import type { InlineCode } from "@yozora/ast";
|
||||
import React from "react";
|
||||
import { astClasses } from "../context";
|
||||
|
||||
/**
|
||||
* Render `inline-code`.
|
||||
*
|
||||
* @see https://www.npmjs.com/package/@yozora/ast#inlinecode
|
||||
* @see https://www.npmjs.com/package/@yozora/tokenizer-inline-code
|
||||
*/
|
||||
export class InlineCodeRenderer extends React.Component<InlineCode> {
|
||||
public override shouldComponentUpdate(nextProps: Readonly<InlineCode>): boolean {
|
||||
const props = this.props;
|
||||
return props.value !== nextProps.value;
|
||||
}
|
||||
|
||||
public override render(): React.ReactElement {
|
||||
return <code className={cls}>{this.props.value}</code>;
|
||||
}
|
||||
}
|
||||
|
||||
const cls = cx(
|
||||
astClasses.inlineCode,
|
||||
css({
|
||||
padding: "1px 4px",
|
||||
borderRadius: "4px",
|
||||
margin: 0,
|
||||
background: "hsla(210deg, 15%, 60%, 0.15)",
|
||||
lineHeight: "1.375",
|
||||
color: "var(--colorInlineCode)",
|
||||
fontFamily: "var(--fontFamilyCode)",
|
||||
fontSize: "min(1rem, 18px)",
|
||||
fontWeight: 500,
|
||||
}),
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue