|
|
@ -2,11 +2,17 @@ import React from 'react';
|
|
|
|
import { Image } from '@capital/component';
|
|
|
|
import { Image } from '@capital/component';
|
|
|
|
import type { TagProps } from '../bbcode/type';
|
|
|
|
import type { TagProps } from '../bbcode/type';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const imageStyle: React.CSSProperties = {
|
|
|
|
|
|
|
|
maxHeight: 320,
|
|
|
|
|
|
|
|
maxWidth: 320,
|
|
|
|
|
|
|
|
width: 'auto',
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export const ImgTag: React.FC<TagProps> = React.memo((props) => {
|
|
|
|
export const ImgTag: React.FC<TagProps> = React.memo((props) => {
|
|
|
|
const { node } = props;
|
|
|
|
const { node } = props;
|
|
|
|
const text = node.content.join('');
|
|
|
|
const text = node.content.join('');
|
|
|
|
const url = node.attrs.url ?? text;
|
|
|
|
const url = node.attrs.url ?? text;
|
|
|
|
|
|
|
|
|
|
|
|
return <Image className="max-h-80 w-auto" preview={true} src={url} />;
|
|
|
|
return <Image style={imageStyle} preview={true} src={url} />;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
ImgTag.displayName = 'ImgTag';
|
|
|
|
ImgTag.displayName = 'ImgTag';
|
|
|
|