mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-04 08:59:40 +08:00
ab9c477638
* feat: Add maxLength and autoSize in Typography editable config * doc: add version column of maxLength and autoSize * doc: add demo of maxLength and autoSize * doc: simplify version column of autoSize and maxLength * doc: fix version column of autoSize and maxLength * snapshot: add snapshot * snapshot: add snapshot * doc: add version column of maxLength and autoSize * doc: simplify version column of autoSize and maxLength * snapshot: add snapshot * update version column * feat: Add maxLength and autoSize in Typography editable config * doc: add version column of maxLength and autoSize * doc: simplify version column of autoSize and maxLength * doc: fix version column of autoSize and maxLength * snapshot: add snapshot * snapshot: add snapshot * doc: add version column of maxLength and autoSize * doc: simplify version column of autoSize and maxLength * snapshot: add snapshot * update version column * add snapshot
1.5 KiB
1.5 KiB
order | title | ||||
---|---|---|---|---|---|
3 |
|
zh-CN
提供可编辑和可复制等额外的交互能力。
en-US
Provide additional interactive capacity of editable and copyable.
import { Typography } from 'antd';
import { SmileOutlined } from '@ant-design/icons';
const { Text, Paragraph } = Typography;
class Demo extends React.Component {
state = {
str: 'This is an editable text.',
lengthLimitedStr: 'This is an editable text with limited length.',
};
onChange = str => {
console.log('Content change:', str);
this.setState({ str });
};
onLengthLimitedStrChange = lengthLimitedStr => {
this.setState({ lengthLimitedStr });
};
render() {
return (
<>
<Text editable={{ onChange: this.onChange }}>{this.state.str}</Text>
<br />
<Text
editable={{
onChange: this.onLengthLimitedStrChange,
maxLength: 50,
autoSize: { maxRows: 5, minRows: 3 },
}}
>
{this.state.lengthLimitedStr}
</Text>
<br />
<Text copyable>This is a copyable text.</Text>
<br />
<Text copyable={{ text: 'Hello, Ant Design!' }}>Replace copy text.</Text>
<br />
<Text copyable={{ icon: <SmileOutlined /> }}>Custom icon.</Text>
<Paragraph copyable={{ tooltips: ['click here', 'you clicked!!'] }}>
Replace tooltips text.
</Paragraph>
</>
);
}
}
ReactDOM.render(<Demo />, mountNode);