Block style give error
I want add text direction(legt, right, center). And I used getBlockStyle(blockStyleFn), but i have error
nullthrows.js?2b54:18 Uncaught Error: Got unexpected null or undefined
I have code:
Block Style
`const getBlockStyle = (block) => {
console.log(block.getType())
switch (block.getType()) {
case 'leftAlign':
return 'emailAlignLeft';
case 'centerAlign':
return 'emailAlignCenter';
case 'rightAlign':
return 'emailAlignRight';
default:
return '';
}
}`
When my left-button clicked, call this event:
onLeft(self) { self.onChange(RichUtils.toggleBlockType(self.state.editorState, 'leftAlign')); }
this my onChange
this.onChange = (editorState) => {console.log(editorState.toJS()); this.setState({editorState})};
never mind on self
what i do wrong?
I wonder if that could be the same as what this PR should be fixing https://github.com/facebook/draft-js/pull/372/files
@Zulfia73 I am also facing the same issue, trying to add alignment option for current block but got the same error "nullthrows.js?2b54:18 Uncaught Error: Got unexpected null or undefined". Are you able to fix it somehow?
Whenever I use the plugin form filler and then click into my draft js (version 0.10.4) editor, I get the following.
nullthrows.js:16 Uncaught Error: Got unexpected null or undefined
at nullthrows (nullthrows.js:16)
at getDraftEditorSelectionWithNodes (getDraftEditorSelectionWithNodes.js:35)
at getDraftEditorSelection (getDraftEditorSelection.js:33)
at editOnSelect (editOnSelect.js:30)
at DraftEditor.react.js:146
at HTMLUnknownElement.boundFunc (ReactErrorUtils.js:63)
at Object../node_modules/react-dom/lib/ReactErrorUtils.js.ReactErrorUtils.invokeGuardedCallback (ReactErrorUtils.js:69)
at executeDispatch (EventPluginUtils.js:83)
at Object.executeDispatchesInOrder (EventPluginUtils.js:106)
at executeDispatchesAndRelease (EventPluginHub.js:41)
Looks like this was fixed on #372. Please reopen if that's not the case.
nullthrows nullthrows.js:16 getDraftEditorSelectionWithNodes getDraftEditorSelectionWithNodes.js:35 getDraftEditorSelection getDraftEditorSelection.js:33 editOnSelect editOnSelect.js:31 React 16 dispatchEvent
How to solve this