Skip to content

Commit e5800de

Browse files
committed
update doc
1 parent ea5b5d6 commit e5800de

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

README.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,14 @@ React Mentions
4747
```js
4848
import Mentions from 'rc-mentions';
4949

50-
// TODO: update
50+
const { Option } = Mentions;
5151

5252
var Demo = (
53+
<Mentions>
54+
<Option value="light">Light</Option>
55+
<Option value="bamboo">Bamboo</Option>
56+
<Option value="cat">Cat</Option>
57+
</Mentions>
5358
);
5459
React.render(<Demo />, container);
5560
```
@@ -60,13 +65,25 @@ React.render(<Demo />, container);
6065

6166
| name | description | type | default |
6267
|----------|----------------|----------|--------------|
63-
| | | | |
68+
| defaultValue | Default value | string | - |
69+
| value | Set value of mentions | string | - |
70+
| prefix | Set trigger prefix keyword | string \| string[] | '@' |
71+
| autoFocus | Auto get focus when component mounted | boolean | `false` |
72+
| split | Set split string before and after selected mention | string | ' ' |
73+
| validateSearch | Customize trigger search logic | (text: string, props: MentionsProps) => void | - |
74+
| filterOption | Customize filter option logic | false \| (input: string, option: OptionProps) => boolean | - |
75+
| onChange | Trigger when value changed |(text: string) => void | - |
76+
| onSelect | Trigger when user select the option | (option: OptionProps, prefix: string) => void | - |
77+
| onSearch | Trigger when prefix hit | (text: string, prefix: string) => void | - |
78+
| onFocus | Trigger when mentions get focus | React.FocusEventHandler<HTMLTextAreaElement> | - |
79+
| onBlur | Trigger when mentions lose focus | React.FocusEventHandler<HTMLTextAreaElement> | - |
6480

6581
### Methods
6682

67-
| name | description | parameters | return |
68-
|----------|----------------|----------|--------------|
69-
| | | | |
83+
| name | description |
84+
|----------|----------------|
85+
| focus() | Component get focus |
86+
| blur() | Component lose focus |
7087

7188
## Development
7289

assets/index.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
letter-spacing: inherit;
3030
white-space: inherit;
3131
tab-size: inherit;
32+
direction: inherit;
3233
}
3334

3435
> textarea {

src/Mentions.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,14 @@ class Mentions extends React.Component<MentionsProps, MentionsState> {
297297
);
298298
}
299299

300+
public focus() {
301+
this.textarea!.focus();
302+
}
303+
304+
public blur() {
305+
this.textarea!.blur();
306+
}
307+
300308
public render() {
301309
const { value, measureLocation, measurePrefix, measuring, activeIndex } = this.state;
302310
const { prefixCls, className, style, autoFocus } = this.props;

0 commit comments

Comments
 (0)