This commit is contained in:
guanghechen 2024-07-10 16:34:28 +08:00
parent cfa6efc6ed
commit 94d944bd68
25 changed files with 131 additions and 118 deletions

View file

@ -4,7 +4,7 @@ import React from "react";
import { astClasses } from "../../context";
import { CopyButton } from "./CopyButton";
interface IProps {
interface IProperties {
darken: boolean;
lang: string;
value: string;
@ -16,7 +16,7 @@ interface IProps {
failedText?: string;
}
export class CodeRendererInner extends React.PureComponent<IProps> {
export class CodeRendererInner extends React.PureComponent<IProperties> {
public override render(): React.ReactElement {
const { calcContentForCopy } = this;
const { darken, lang, value, preferCodeWrap, showCodeLineno } = this.props;
@ -30,7 +30,7 @@ export class CodeRendererInner extends React.PureComponent<IProps> {
showLineNo={showCodeLineno && !preferCodeWrap}
darken={darken}
/>
<div className={copyBtnCls}>
<div className={copyButtonCls}>
<CopyButton calcContentForCopy={calcContentForCopy} />
</div>
</code>
@ -42,7 +42,7 @@ export class CodeRendererInner extends React.PureComponent<IProps> {
};
}
const copyBtnCls = css({
const copyButtonCls = css({
position: "absolute",
right: "4px",
top: "4px",
@ -58,7 +58,7 @@ const codeCls = cx(
borderRadius: "4px",
margin: "0px 0px 1.25em 0px",
backgroundColor: "var(--colorBgCode)",
[`&:hover > .${copyBtnCls}`]: {
[`&:hover > .${copyButtonCls}`]: {
display: "inline-block",
},
[`&&[data-wrap="true"] > div`]: {

View file

@ -1,7 +1,7 @@
import { css } from "@emotion/css";
import React from "react";
interface IProps {
interface IProperties {
src: string;
alt: string;
title: string | undefined;
@ -11,17 +11,17 @@ interface IProps {
className: string;
}
export class ImageRendererInner extends React.Component<IProps> {
public override shouldComponentUpdate(nextProps: IProps): boolean {
const props = this.props;
export class ImageRendererInner extends React.Component<IProperties> {
public override shouldComponentUpdate(nextProperties: IProperties): boolean {
const properties = this.props;
return (
props.src !== nextProps.src ||
props.alt !== nextProps.alt ||
props.title !== nextProps.title ||
props.srcSet !== nextProps.srcSet ||
props.sizes !== nextProps.sizes ||
props.loading !== nextProps.loading ||
props.className !== nextProps.className
properties.src !== nextProperties.src ||
properties.alt !== nextProperties.alt ||
properties.title !== nextProperties.title ||
properties.srcSet !== nextProperties.srcSet ||
properties.sizes !== nextProperties.sizes ||
properties.loading !== nextProperties.loading ||
properties.className !== nextProperties.className
);
}

View file

@ -3,21 +3,21 @@ import type { Node } from "@yozora/ast";
import React from "react";
import { NodesRenderer } from "../../NodesRenderer";
interface IProps {
interface IProperties {
url: string;
title: string | undefined;
childNodes: Node[] | undefined;
className: string;
}
export class LinkRendererInner extends React.Component<IProps> {
public override shouldComponentUpdate(nextProps: Readonly<IProps>): boolean {
const props = this.props;
export class LinkRendererInner extends React.Component<IProperties> {
public override shouldComponentUpdate(nextProperties: Readonly<IProperties>): boolean {
const properties = this.props;
return (
props.url !== nextProps.url ||
props.title !== nextProps.title ||
props.childNodes !== nextProps.childNodes ||
props.className !== nextProps.className
properties.url !== nextProperties.url ||
properties.title !== nextProperties.title ||
properties.childNodes !== nextProperties.childNodes ||
properties.className !== nextProperties.className
);
}