-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathapp.js
More file actions
executable file
·46 lines (45 loc) · 1.7 KB
/
app.js
File metadata and controls
executable file
·46 lines (45 loc) · 1.7 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
import React from 'react';
import { Editor } from 'slate-mate';
import { options, initialState } from './editor';
import classNames from 'classnames';
export default class Example extends React.Component {
state = { view: null, data: initialState }
render() {
const { view, data } = this.state;
return (
<div className="flex-container">
<div className="head">
<div className="logo">Slate-Mate</div>
<a className="github-button" href="https://github.com/bkniffler/slate-mate/" target="_blank">
View on Github
</a>
<button className={classNames('button', { active: view === 'json' })} onClick={() => this.setState({ view: 'json' }) }>
See JSON
</button>
<button className={classNames('button', { active: !view })} onClick={() => this.setState({ view: null }) }>
See Editor
</button>
<button className="button" onClick={(v) => this.setState({ data: null }) }>
Clear
</button>
</div>
<div className="container-content" style={{ display: view === 'json' ? 'block' : 'none' }}>
<pre style={{ whiteSpace: 'pre-wrap', width: '750px', margin: 'auto' }}>
{JSON.stringify(data, null, 2)}
</pre>
</div>
<div className="container-content" style={{ display: view !== 'json' ? 'block' : 'none' }}>
<div className="TeXEditor-root">
<div className="TeXEditor-editor">
<Editor
{...options}
onChange={data => this.setState({ data }) }
value={data}
/>
</div>
</div>
</div>
</div >
);
}
}