jasonphillips / draft-js-richbuttons-plugin

A plugin for adding rich formatting controls - https://jasonphillips.github.io/draft-js-richbuttons-plugin/
38 stars 14 forks source link

Error: this.getEditorState is not a function #7

Closed dzeno closed 8 years ago

dzeno commented 8 years ago

I get this error when trying to apply formatting (clicking the icon): this.getEditorState is not a function

Here is how initialize editor: <Editor editorState={this.props.editorState} onChange={this.onChange} handleKeyCommand={this.handleKeyCommand} handleReturn={this.handleReturn} keyBindingFn={myKeyBindingFn} spellCheck={'true'} ref="editor" plugins={richButtonsPlugin} />

hasSean commented 8 years ago

Is the richButtonsPlugin prop that you are passing an array?

I'd guess plugins={richButtonsPlugin} needs to be plugins={[richButtonsPlugin]}.

jasonphillips commented 8 years ago

@hasSean is correct about the prop needing to be an array in your example, although getting that wrong should trigger a different error.

On a hunch, I was able to obtain the error you listed by using the Editor component from the base draft-js library instead of the draft-js-plugins library. Use the latter (follow the examples in this repo) and I think that will solve it for you.

raitucarp commented 7 years ago

I have this error with draft-js-plugins-editor beta when typing return. When I only pass blockBreakout :

const plugins = [blockBreakoutPlugin];

there is no error when I type enter. But, when I add

const plugins = [blockBreakoutPlugin, richButtonsPlugin];

I have an error:

TypeError: getEditorState is not a function
    at Object.handleKeyCommand 

Please elaborate about this error

jasonphillips commented 7 years ago

Thanks - this was a consequence of a key handling change made in the latest draft-js, which also was just recently moved into draft-js-plugins as of version rc1. I've updated (published as v.2.1.0) to fix this, let me know if you still have any problems.

suman-kr commented 3 years ago

I'm still facing this issue. "draft-js-richbuttons-plugin": "^2.2.0" and "@draft-js-plugins/editor": "^4.1.0"