mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-12 20:43:11 +08:00
export toEditorState of Mention
This commit is contained in:
parent
3fe36f4584
commit
3095f58be8
@ -14,7 +14,8 @@ Basic usage.
|
|||||||
````jsx
|
````jsx
|
||||||
|
|
||||||
import { Mention } from 'antd';
|
import { Mention } from 'antd';
|
||||||
const { toString } = Mention;
|
const { toString, toEditorState } = Mention;
|
||||||
|
|
||||||
|
|
||||||
function onChange(editorState) {
|
function onChange(editorState) {
|
||||||
console.log(toString(editorState));
|
console.log(toString(editorState));
|
||||||
@ -23,7 +24,7 @@ function onChange(editorState) {
|
|||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<Mention
|
<Mention
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
defaultValue="@afc163"
|
defaultValue={toEditorState('@afc163')}
|
||||||
suggestions={['afc163', 'benjycui', 'yiminghe', 'jljsj33', 'dqaria', 'RaoHai']}
|
suggestions={['afc163', 'benjycui', 'yiminghe', 'jljsj33', 'dqaria', 'RaoHai']}
|
||||||
/>,
|
/>,
|
||||||
mountNode
|
mountNode
|
||||||
|
@ -28,11 +28,11 @@ When need to mention someone or something.
|
|||||||
| suggestions | suggestion content | Array<string> or Array<Mention.Nav> | [] |
|
| suggestions | suggestion content | Array<string> or Array<Mention.Nav> | [] |
|
||||||
| suggestionStyle | style of suggestion container | Objet | {} |
|
| suggestionStyle | style of suggestion container | Objet | {} |
|
||||||
| onSearchChange | Callback function called when search content changes | function(value:String) | [] |
|
| 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 | '无匹配结果,轻敲空格完成输入' |
|
| notFoundContent| suggestion when suggestions empty | string | '无匹配结果,轻敲空格完成输入' |
|
||||||
| loading | loading mode | boolean | false |
|
| loading | loading mode | boolean | false |
|
||||||
| multiLines | multilines 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 |
|
| value | core state of mention | EditorState | null |
|
||||||
|
|
||||||
### Nav props
|
### Nav props
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as React from 'react';
|
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';
|
import classnames from 'classnames';
|
||||||
|
|
||||||
export interface MentionProps {
|
export interface MentionProps {
|
||||||
@ -24,6 +24,7 @@ export interface MentionState {
|
|||||||
export default class Mention extends React.Component<MentionProps, MentionState> {
|
export default class Mention extends React.Component<MentionProps, MentionState> {
|
||||||
static Nav = Nav;
|
static Nav = Nav;
|
||||||
static toString = toString;
|
static toString = toString;
|
||||||
|
static toEditorState = toEditorState;
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
prefixCls: 'ant-mention',
|
prefixCls: 'ant-mention',
|
||||||
suggestions: [],
|
suggestions: [],
|
||||||
|
@ -28,11 +28,11 @@ english: Mention
|
|||||||
| suggestions | 建议内容 | Array<string> or Array<Mention.Nav> | [] |
|
| suggestions | 建议内容 | Array<string> or Array<Mention.Nav> | [] |
|
||||||
| suggestionStyle | 弹出下拉框样式 | Objet | {} |
|
| suggestionStyle | 弹出下拉框样式 | Objet | {} |
|
||||||
| onSearchChange | 输入框中 @ 变化时回调 | function(value:String) | [] |
|
| onSearchChange | 输入框中 @ 变化时回调 | function(value:String) | [] |
|
||||||
| onChange | 输入框内容变化时回调 | function(editorState: EditorState, value:String) | null |
|
| onChange | 输入框内容变化时回调 | function(editorState: EditorState) | null |
|
||||||
| notFoundContent| 未找到时的内容 | string | '无匹配结果,轻敲空格完成输入' |
|
| notFoundContent| 未找到时的内容 | string | '无匹配结果,轻敲空格完成输入' |
|
||||||
| loading | 加载中 | boolean | false |
|
| loading | 加载中 | boolean | false |
|
||||||
| multiLines | 多行模式 | boolean | false |
|
| multiLines | 多行模式 | boolean | false |
|
||||||
| defaultValue | 默认值 | string | null |
|
| defaultValue | 默认值 | EditorState, 可以用 Mention.toEditorState(text) 把文字转换成 EditorState | null |
|
||||||
| value | 值 | EditorState | null |
|
| value | 值 | EditorState | null |
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
"rc-collapse": "~1.6.3",
|
"rc-collapse": "~1.6.3",
|
||||||
"rc-dialog": "~6.1.1",
|
"rc-dialog": "~6.1.1",
|
||||||
"rc-dropdown": "~1.4.8",
|
"rc-dropdown": "~1.4.8",
|
||||||
"rc-editor-mention": "0.0.30",
|
"rc-editor-mention": "^0.1.0",
|
||||||
"rc-form": "~0.17.1",
|
"rc-form": "~0.17.1",
|
||||||
"rc-input-number": "~2.5.12",
|
"rc-input-number": "~2.5.12",
|
||||||
"rc-menu": "~4.12.4",
|
"rc-menu": "~4.12.4",
|
||||||
|
Loading…
Reference in New Issue
Block a user