Skip to content

Commit 7889fa5

Browse files
committed
✨ feat: add more doc & change as a theme token
1 parent 2d16d11 commit 7889fa5

5 files changed

Lines changed: 39 additions & 20 deletions

File tree

src/Highlight/index.tsx

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,33 @@
1+
import { ConfigProvider } from '../ConfigProvider';
12
import { HighlightBase, HighlightProps } from './defalut';
3+
import { useStyles } from './style';
24
import FullFeatureWrapper from './wrapper';
35

46
const Highlight = (props: HighlightProps) => {
5-
if (props?.containerWrapper) {
6-
return <FullFeatureWrapper {...props} />;
7-
}
8-
return <HighlightBase {...props} />;
7+
const { prefixCls, type, theme, containerWrapper } = props;
8+
const { theme: token } = useStyles({
9+
prefixCls,
10+
type,
11+
theme,
12+
});
13+
14+
return (
15+
<ConfigProvider
16+
componentToken={{
17+
Select: {
18+
colorBgTextHover: token.colorFillSecondary,
19+
colorBgTextActive: token.colorFill,
20+
},
21+
Button: {
22+
colorText: token.colorTextTertiary,
23+
colorBgTextHover: token.colorFillSecondary,
24+
colorBgTextActive: token.colorFill,
25+
},
26+
}}
27+
>
28+
{containerWrapper ? <FullFeatureWrapper {...props} /> : <HighlightBase {...props} />}
29+
</ConfigProvider>
30+
);
931
};
1032

1133
export * from './defalut';

src/Highlight/style.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,6 @@ export const useStyles = createStyles(
102102
transition: opacity 0.1s;
103103
`,
104104
),
105-
expandIcon: css`
106-
color: ${colorText};
107-
&:hover {
108-
.${STUDIO_UI_PREFIX}-btn-icon {
109-
color: ${colorText} !important;
110-
}
111-
}
112-
`,
113105
select: css`
114106
min-width: 100px;
115107
.${STUDIO_UI_PREFIX}-btn {

src/Highlight/wrapper.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
import CopyButton from '@/components/CopyButton';
12
import { DownOutlined, RightOutlined } from '@ant-design/icons';
23
import { ActionIcon, Button, Select, type SelectProps } from '@ant-design/pro-editor';
34
import classNames from 'classnames';
45
import { memo, useState } from 'react';
56
import { DivProps, Flexbox } from 'react-layout-kit';
67
import { getPrefixCls } from '..';
7-
import CopyButton from './components/CopyButton';
88
import { HighlightBase, HighlightProps } from './defalut';
99
import { languageMap } from './hooks/useHighlight';
1010
import { useStyles } from './style';
@@ -46,10 +46,9 @@ export const FullFeatureWrapper = memo<HighlighterWrapperProps & HighlightProps>
4646
});
4747

4848
return (
49-
<div className={classNames(styles.wrapper, className)} style={style} {...props}>
49+
<div className={classNames(styles.wrapper, className)} style={style}>
5050
<Flexbox align={'center'} className={styles.header} horizontal justify={'space-between'}>
5151
<ActionIcon
52-
className={styles.expandIcon}
5352
icon={expand ? <DownOutlined size={14} /> : <RightOutlined size={14} />}
5453
onClick={() => setExpand(!expand)}
5554
size={24}
@@ -74,12 +73,12 @@ export const FullFeatureWrapper = memo<HighlighterWrapperProps & HighlightProps>
7473
suffixIcon={false}
7574
value={lang.toLowerCase()}
7675
/>
77-
{copyable && <CopyButton content={children} prefixCls={prefixCls} theme={theme} />}
76+
{copyable && <CopyButton content={children} />}
7877
</Flexbox>
7978
<HighlightBase
8079
{...props}
8180
language={lang?.toLowerCase()}
82-
style={expand ? {} : { height: 0, overflow: 'hidden' }}
81+
style={expand ? {} : { height: 0, overflow: 'hidden', border: 'none' }}
8382
copyable={false}
8483
showLanguage={false}
8584
/>

src/Markdown/index.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
nav: 组件
33
group: Content
44
title: Markdown
5-
description: Markdown is a React component used to render markdown text. It supports various markdown syntax such as headings, lists, links, images, code blocks and more. It is commonly used in documentation, blogs, and other text-heavy applications.
5+
description: Markdown是一个用于渲染Markdown文本的React组件。它支持各种Markdown语法,如标题、列表、链接、图片、代码块等。它通常用于文档、博客和其他文本密集型应用中。
66
---
77

88
## Default
@@ -11,4 +11,10 @@ description: Markdown is a React component used to render markdown text. It supp
1111

1212
## APIs
1313

14-
<API></API>
14+
| 属性名 | 类型 | 描述 |
15+
| --------------------- | ------------- | -------------------------- |
16+
| children | string | 要渲染的 Markdown 内容。 |
17+
| className | string | Markdown 组件的类名。 |
18+
| fullFeaturedCodeBlock | boolean | 是否启用完整功能的代码块。 |
19+
| onDoubleClick | () => void | 双击事件处理函数。 |
20+
| style | CSSProperties | Markdown 组件的样式。 |

src/Markdown/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export interface MarkdownProps {
2424
}
2525

2626
const Markdown = memo<MarkdownProps>(
27-
({ children, className, style, fullFeaturedCodeBlock, onDoubleClick, ...props }) => {
27+
({ children, className, style, fullFeaturedCodeBlock = true, onDoubleClick, ...props }) => {
2828
const { styles } = useStyles();
2929
const components: any = {
3030
a: Typography.Link,

0 commit comments

Comments
 (0)