-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathindex.js
More file actions
56 lines (48 loc) · 1.31 KB
/
index.js
File metadata and controls
56 lines (48 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import React from 'react';
import ReactDOM from 'react-dom';
import BasicHtmlEditor from '../src/BasicHtmlEditor';
let html = `
<h1>This is a Title</h1>
<p id="Here">Here's some text, it's useful</p>
<p>More text, some inline <strong>styling</strong> for <em>some</em> elements</p>
<a href='https://www.google.ru' rel='noreferrer noopener' target='_self'>Some new link</a>
<p>Here's <em>some text, <strong>it's useful</strong></em></p>
`;
class BasicHtmlEditorExample extends React.Component {
constructor(props) {
super(props);
this.state = {
html: props.html
};
}
updateHtml(html) {
this.setState({
html
});
}
render() {
return (
<div>
<BasicHtmlEditor
value={ this.state.html }
onChange={ (html) => this.updateHtml(html) }
debounce={ 500 }
/>
<div style={{ margin: '30px 10px 10px 10px' }}>
<code>Exported HTML as text</code>
<hr/>
{this.state.html}
</div>
<div style={{ margin: '30px 10px 10px 10px' }}>
<code>Exported HTML</code>
<hr/>
<div dangerouslySetInnerHTML={{ __html: this.state.html }} />
</div>
</div>
);
}
}
ReactDOM.render(
<BasicHtmlEditorExample html={html}/>,
document.getElementById('app')
);