style: 修改bbcode插件,渲染图片时设定最大宽度

并修复之前样式不生效的bug
release/desktop
moonrailgun 3 years ago
parent 7e302baedd
commit 053a857271

@ -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';

@ -1,6 +1,5 @@
{ {
"compilerOptions": { "compilerOptions": {
"rootDir": "./src",
"baseUrl": "./src", "baseUrl": "./src",
"esModuleInterop": true, "esModuleInterop": true,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,

Loading…
Cancel
Save