This repository was archived by the owner on May 31, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +31
-22
lines changed
examples/undo-example/src Expand file tree Collapse file tree 4 files changed +31
-22
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ type Props = {
88 setEditorState : EditorState => void ,
99}
1010
11- class RedoButton extends Component < Props > {
11+ class Redo extends Component < Props > {
1212 onClick = event => {
1313 event . stopPropagation ( )
1414 this . props . setEditorState ( EditorState . redo ( this . props . editorState ) )
@@ -29,4 +29,4 @@ class RedoButton extends Component<Props> {
2929 }
3030}
3131
32- export default RedoButton
32+ export default Redo
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ type Props = {
88 setEditorState : EditorState => void ,
99}
1010
11- class UndoButton extends Component < Props > {
11+ class Undo extends Component < Props > {
1212 onClick = event => {
1313 event . stopPropagation ( )
1414 this . props . setEditorState ( EditorState . undo ( this . props . editorState ) )
@@ -29,4 +29,4 @@ class UndoButton extends Component<Props> {
2929 }
3030}
3131
32- export default UndoButton
32+ export default Undo
Original file line number Diff line number Diff line change 1+ import React from 'react'
2+ import { Plugin } from '@djsp/core'
3+ import Redo from './components/Redo'
4+ import Undo from './components/Undo'
5+
6+ const RedoButton = ( ) => (
7+ < Plugin >
8+ { ( { editorState, setEditorState } ) => (
9+ < Redo editorState = { editorState } setEditorState = { setEditorState } />
10+ ) }
11+ </ Plugin >
12+ )
13+
14+ const UndoButton = ( ) => (
15+ < Plugin >
16+ { ( { editorState, setEditorState } ) => (
17+ < Undo editorState = { editorState } setEditorState = { setEditorState } />
18+ ) }
19+ </ Plugin >
20+ )
21+
22+ export { RedoButton , UndoButton }
Original file line number Diff line number Diff line change 1- import React , { Component , Fragment } from 'react'
1+ import React , { Component } from 'react'
22import ReactDOM from 'react-dom'
33
44import { EditorState , ContentState } from 'draft-js'
5- import { EditorContainer , Editor , Plugin } from '@djsp/core'
6- import UndoButton from './UndoButton.js'
7- import RedoButton from './RedoButton.js'
5+ import { EditorContainer , Editor } from '@djsp/core'
6+ import { RedoButton , UndoButton } from './Undo'
87import './styles.css'
98
109class App extends Component {
@@ -24,20 +23,8 @@ class App extends Component {
2423 < EditorContainer
2524 editorState = { this . state . editorState }
2625 onChange = { this . onChange } >
27- < Plugin >
28- { ( { editorState, setEditorState } ) => (
29- < Fragment >
30- < UndoButton
31- editorState = { editorState }
32- setEditorState = { setEditorState }
33- />
34- < RedoButton
35- editorState = { editorState }
36- setEditorState = { setEditorState }
37- />
38- </ Fragment >
39- ) }
40- </ Plugin >
26+ < RedoButton />
27+ < UndoButton />
4128 < Editor />
4229 </ EditorContainer >
4330 </ div >
You can’t perform that action at this time.
0 commit comments