draft-js icon indicating copy to clipboard operation
draft-js copied to clipboard

Block style give error

Open Zulfia73 opened this issue 10 years ago • 5 comments

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?

Zulfia73 avatar May 13 '16 12:05 Zulfia73

I wonder if that could be the same as what this PR should be fixing https://github.com/facebook/draft-js/pull/372/files

mitermayer avatar May 13 '16 12:05 mitermayer

@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?

anandc avatar Aug 21 '16 12:08 anandc

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)

robksawyer avatar Nov 16 '17 20:11 robksawyer

Looks like this was fixed on #372. Please reopen if that's not the case.

niveditc avatar Jan 19 '19 22:01 niveditc

nullthrows nullthrows.js:16 getDraftEditorSelectionWithNodes getDraftEditorSelectionWithNodes.js:35 getDraftEditorSelection getDraftEditorSelection.js:33 editOnSelect editOnSelect.js:31 React 16 dispatchEvent

How to solve this

RameshChauhanExpert avatar May 13 '19 09:05 RameshChauhanExpert