Skip to content

Commit

Permalink
Optimize the examples
Browse files Browse the repository at this point in the history
  • Loading branch information
YaoKaiLun committed Jan 4, 2019
1 parent 53d3e20 commit 9c1d5b2
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 121 deletions.
112 changes: 0 additions & 112 deletions example/App.js

This file was deleted.

13 changes: 10 additions & 3 deletions example/AsyncExample.js
Expand Up @@ -2,22 +2,27 @@ import React from 'react'
import ReactUeditor from '../src'

class AsyncExample extends React.Component {
constructor(props) {
super(props)
constructor() {
super()
this.editorResult = ''
this.state = {
content: '',
}
this.timer = null
}

componentDidMount() {
setTimeout(() => {
this.timer = setTimeout(() => {
this.setState({
content: '我是异步加载回来的数据',
})
}, 2000)
}

componentWillUnmount() {
clearTimeout(this.timer)
}

updateEditorContent = content => {
// 通过 editroResult 获取编辑器最新内容,而不是对 content 进行 setState(因为 ueditor 不是一个受控组件)
this.editorResult = content
Expand All @@ -28,10 +33,12 @@ class AsyncExample extends React.Component {
return (
<div>
<ReactUeditor
debug
getRef={this.getUeditor}
ueditorPath='../vendor/ueditor'
value={content}
onChange={this.updateEditorContent}
extendControls={[]}
/>
</div>
)
Expand Down
5 changes: 3 additions & 2 deletions example/EditorRefExample.js
Expand Up @@ -2,8 +2,8 @@ import React from 'react'
import ReactUeditor from '../src'

class EditorRefExample extends React.Component {
constructor(props) {
super(props)
constructor() {
super()
this.ueditorRef = null
this.state = {
content: '',
Expand Down Expand Up @@ -35,6 +35,7 @@ class EditorRefExample extends React.Component {
getRef={this.getUeditor}
onChange={this.updateEditorContent}
onReady={this.handleReady}
extendControls={[]}
/>
<button onClick={this.getUeditorContent}>获取内容</button>
<p>{content}</p>
Expand Down
1 change: 1 addition & 0 deletions example/ExtendControlsExample.js
Expand Up @@ -29,6 +29,7 @@ class App extends React.Component {
render() {
return (
<ReactUeditor
debug
ueditorPath='../vendor/ueditor'
getRef={this.getUeditor}
extendControls={[
Expand Down
5 changes: 3 additions & 2 deletions example/MediaExample.js
Expand Up @@ -2,8 +2,8 @@ import React from 'react'
import ReactUeditor from '../src'

class MediaExample extends React.Component {
constructor(props) {
super(props)
constructor() {
super()
this.state = {
progress: -1,
}
Expand Down Expand Up @@ -56,6 +56,7 @@ class MediaExample extends React.Component {
onChange={this.updateEditorContent}
progress={progress}
multipleImagesUpload={false}
extendControls={[]}
/>
)
}
Expand Down
1 change: 1 addition & 0 deletions example/PasteImageExample.js
Expand Up @@ -15,6 +15,7 @@ class PasteImageExample extends React.Component {
<ReactUeditor
ueditorPath='../vendor/ueditor'
handlePasteImage={this.handlePasteImage}
extendControls={[]}
/>
)
}
Expand Down
2 changes: 2 additions & 0 deletions example/SimpleExample.js
Expand Up @@ -9,8 +9,10 @@ class SimpleExample extends React.Component {
render() {
return (
<ReactUeditor
debug
ueditorPath='../vendor/ueditor'
onChange={this.updateEditorContent}
extendControls={[]}
/>
)
}
Expand Down
1 change: 1 addition & 0 deletions example/index.html
Expand Up @@ -3,6 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="./favicon.ico" type="image/x-icon" />
<title>ReactUeditor</title>
<style>
html, body, #root {
Expand Down
4 changes: 2 additions & 2 deletions example/index.js
Expand Up @@ -70,8 +70,8 @@ class App extends React.Component {
<Route path='/async-example/' component={AsyncExample} />
<Route path='/media-example/' component={MediaExample} />
<Route path='/editor-ref-example/' component={EditorRefExample} />
<Route path='/extend-controls-example' component={ExtendControlsExample} />
<Route path='/paste-image-example' component={PasteImageExample} />
<Route path='/extend-controls-example/' component={ExtendControlsExample} />
<Route path='/paste-image-example/' component={PasteImageExample} />
</Switch>
</section>
</div>
Expand Down
Binary file added favicon.ico
Binary file not shown.

0 comments on commit 9c1d5b2

Please sign in to comment.