export toEditorState of Mention

This commit is contained in:
RaoHai 2016-07-19 13:39:05 +08:00
parent 3fe36f4584
commit 3095f58be8
5 changed files with 10 additions and 8 deletions

View File

@ -14,7 +14,8 @@ Basic usage.
````jsx
import { Mention } from 'antd';
const { toString } = Mention;
const { toString, toEditorState } = Mention;
function onChange(editorState) {
console.log(toString(editorState));
@ -23,7 +24,7 @@ function onChange(editorState) {
ReactDOM.render(
<Mention
onChange={onChange}
defaultValue="@afc163"
defaultValue={toEditorState('@afc163')}
suggestions={['afc163', 'benjycui', 'yiminghe', 'jljsj33', 'dqaria', 'RaoHai']}
/>,
mountNode

View File

@ -28,11 +28,11 @@ When need to mention someone or something.
| suggestions | suggestion content | Array<string> or Array<Mention.Nav> | [] |
| suggestionStyle | style of suggestion container | Objet | {} |
| onSearchChange | Callback function called when search content changes | function(value:String) | [] |
| onChange | Callback function called when content of input changes | function(editorState: EditorState, value:String) | null |
| onChange | Callback function called when content of input changes | function(editorState: EditorState) | null |
| notFoundContent| suggestion when suggestions empty | string | '无匹配结果,轻敲空格完成输入' |
| loading | loading mode | boolean | false |
| multiLines | multilines mode | boolean | false |
| defaultValue | default value | string | null |
| defaultValue | default value | EditorState, you can use `Mention.toEditorState` to convert text to `EditorState` | null |
| value | core state of mention | EditorState | null |
### Nav props

View File

@ -1,5 +1,5 @@
import * as React from 'react';
import RcMention, { Nav, toString } from 'rc-editor-mention';
import RcMention, { Nav, toString, toEditorState } from 'rc-editor-mention';
import classnames from 'classnames';
export interface MentionProps {
@ -24,6 +24,7 @@ export interface MentionState {
export default class Mention extends React.Component<MentionProps, MentionState> {
static Nav = Nav;
static toString = toString;
static toEditorState = toEditorState;
static defaultProps = {
prefixCls: 'ant-mention',
suggestions: [],

View File

@ -28,11 +28,11 @@ english: Mention
| suggestions | 建议内容 | Array<string> or Array<Mention.Nav> | [] |
| suggestionStyle | 弹出下拉框样式 | Objet | {} |
| onSearchChange | 输入框中 @ 变化时回调 | function(value:String) | [] |
| onChange | 输入框内容变化时回调 | function(editorState: EditorState, value:String) | null |
| onChange | 输入框内容变化时回调 | function(editorState: EditorState) | null |
| notFoundContent| 未找到时的内容 | string | '无匹配结果,轻敲空格完成输入' |
| loading | 加载中 | boolean | false |
| multiLines | 多行模式 | boolean | false |
| defaultValue | 默认值 | string | null |
| defaultValue | 默认值 | EditorState, 可以用 Mention.toEditorState(text) 把文字转换成 EditorState | null |
| value | 值 | EditorState | null |

View File

@ -47,7 +47,7 @@
"rc-collapse": "~1.6.3",
"rc-dialog": "~6.1.1",
"rc-dropdown": "~1.4.8",
"rc-editor-mention": "0.0.30",
"rc-editor-mention": "^0.1.0",
"rc-form": "~0.17.1",
"rc-input-number": "~2.5.12",
"rc-menu": "~4.12.4",