我正在这样的“管理”面板中使用draft.js
现在,我需要为具有自定义href的代码添加自定义按钮,如下所示:
link = `RCAApp://PATH/${ANYKEY}`
我的代码是这样的:
_toggleBlockType(blockType) {
const { visible } = this.state
const { editorState } = this.props;
const selection = editorState.getSelection();
const start = selection.getStartOffset();
const end = selection.getEndOffset();
if (blockType === 'LINK' && (end !== start)) {
this.setState({
visible: !visible,
});
}
else if (blockType === 'LINK' && (end === start)) {
notification.error({
message: `Error`,
description: `You need to select a word!`,
});
}
this.onChange(
RichUtils.toggleBlockType(
editorState,
blockType
)
);
}
现在我不知道如何将自定义的href注入html文本本身,该文档还不足以理解。