Skip to content

Commit

Permalink
fix React warnings on renderMark, renderBlock, renderDecoration (ians…
Browse files Browse the repository at this point in the history
…tormtaylor#2974)

* fix React warnings on renderMark, renderBlock, renderDecoration

* included decorateNode and relocated code into constants in EventHandler

* Put decorateNode and render handlers into a seperate file.

* fix indentation

* overlooked indentation.
  • Loading branch information
yue-l authored and ianstormtaylor committed Aug 22, 2019
1 parent 1f673a9 commit 6e56932
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/slate-react/src/components/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import omit from 'lodash/omit'
import { Editor as Controller } from 'slate'

import EVENT_HANDLERS from '../constants/event-handlers'
import OTHER_HANDLERS from '../constants/other-handlers'
import Content from './content'
import ReactPlugin from '../plugins/react'

Expand Down Expand Up @@ -54,6 +55,10 @@ class Editor extends React.Component {
obj[handler] = Types.func
return obj
}, {}),
...OTHER_HANDLERS.reduce((obj, handler) => {
obj[handler] = Types.func
return obj
}, {}),
}

/**
Expand Down
24 changes: 24 additions & 0 deletions packages/slate-react/src/constants/other-handlers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Other handlers used by Slate plugins.
*
* @type {Array}
*/

const OTHER_HANDLERS = [
'decorateNode',
'renderAnnotation',
'renderBlock',
'renderDecoration',
'renderDocument',
'renderEditor',
'renderInline',
'renderMark',
]

/**
* Export.
*
* @type {Array}
*/

export default OTHER_HANDLERS

0 comments on commit 6e56932

Please sign in to comment.