当我与 html 图像一起插入编辑器时,例如:
import React, { PropTypes, Component } from 'react'
import ReactDOM from 'react-dom'
import {Editor, EditorState} from 'draft-js'
var sampleMarkup = `<h1>Hello</h1><b>Bold text</b><i> Italic text</i>
<a href="http://www.facebook.com">Example link</a>
<img src="./someImg.png" />
<p>Hello there</p>
<div class="responsive"><iframe width="560" height="315" src="youtube/link/here" frameborder="0" allowfullscreen></iframe></div>`;
class MyEditor extends Component {
constructor(props){
super(props);
this.state = { editorState:EditorState.createWithContent(html); }
}
render(){
return (
<Editor editorState={this.state.editor} onChange={this.onChange.bind(this)}/>
);
}
onChange(editorState){
this.setState({editorState: editorState});
this.props.onChange(html);
}
}
编辑器不插入标签img
,而是雕刻iframe
。为什么draft.js
这样做以及如何解决它?codepen 上的完整代码:
http ://codepen.io/alex183/pen/xgVzZE?editors=0010