From 6e56932ee410e79c21bf0480f4d70079c9d4b739 Mon Sep 17 00:00:00 2001 From: Yue Date: Fri, 23 Aug 2019 04:50:32 +1200 Subject: [PATCH] fix React warnings on renderMark, renderBlock, renderDecoration (#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. --- packages/slate-react/src/components/editor.js | 5 ++++ .../src/constants/other-handlers.js | 24 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 packages/slate-react/src/constants/other-handlers.js diff --git a/packages/slate-react/src/components/editor.js b/packages/slate-react/src/components/editor.js index a8da532bb5..b1d43a7aed 100644 --- a/packages/slate-react/src/components/editor.js +++ b/packages/slate-react/src/components/editor.js @@ -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' @@ -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 + }, {}), } /** diff --git a/packages/slate-react/src/constants/other-handlers.js b/packages/slate-react/src/constants/other-handlers.js new file mode 100644 index 0000000000..86daa0e00e --- /dev/null +++ b/packages/slate-react/src/constants/other-handlers.js @@ -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