This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const editor = React.useRef<Editor>(null); | |
const [editorState, setEditorState] = React.useState<EditorState>( | |
EditorState.createEmpty( | |
new CompositeDecorator([ | |
{ | |
strategy: linkStrategy, | |
component: DecoratedLink | |
} | |
]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
import { EditorContext } from "./EditorContext"; | |
import { | |
Box, | |
Paper, | |
TextField, | |
InputAdornment, | |
IconButton | |
} from "@material-ui/core"; | |
import { ToggleButtonGroup, ToggleButton } from "@material-ui/lab"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Box onClick={focusEditor} p={4}> | |
<EditorContext.Provider value={editorState}> | |
<Editor | |
editorState={editorState} | |
onChange={setEditorState} | |
placeholder="Click here to start typing in the editor..." | |
blockRendererFn={renderBlock} | |
ref={editor} | |
/> | |
</EditorContext.Provider> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
import { EditorState } from "draft-js"; | |
export const EditorContext = React.createContext<EditorState>( | |
EditorState.createEmpty() | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"@material-ui/core": "4.9.2", | |
"@material-ui/icons": "4.9.1", | |
"@material-ui/lab": "4.0.0-alpha.42", | |
"@types/draft-js": "0.10.38", | |
"draft-js": "0.11.4", | |
"draft-js-plugins-utils": "2.0.3", |
NewerOlder