-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f8aa8bb
commit 42b1f30
Showing
8 changed files
with
290 additions
and
87 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React from 'react'; | ||
import { Editor, RichUtils } from 'draft-js'; | ||
import 'draft-js/dist/Draft.css'; | ||
|
||
const TextEditor = props => { | ||
const { editMode, editorState, onChange } = props; | ||
|
||
const editing = editMode ? 'editing' : ''; | ||
|
||
const handleKeyCommand = command => { | ||
const newState = RichUtils.handleKeyCommand(editorState, command); | ||
if (newState) { | ||
onChange(newState); | ||
} | ||
}; | ||
|
||
const onUnderlineClick = () => { | ||
onChange(RichUtils.toggleInlineStyle(editorState, 'UNDERLINE')); | ||
}; | ||
|
||
const onBoldClick = () => { | ||
onChange(RichUtils.toggleInlineStyle(editorState, 'BOLD')); | ||
}; | ||
|
||
const onItalicClick = () => { | ||
onChange(RichUtils.toggleInlineStyle(editorState, 'ITALIC')); | ||
}; | ||
|
||
return ( | ||
<div className={'textBox ' + editing}> | ||
{editMode && ( | ||
<> | ||
<div> | ||
<button className="editorButton" onClick={onUnderlineClick}> | ||
U | ||
</button> | ||
<button className="editorButton" onClick={onBoldClick}> | ||
<b>B</b> | ||
</button> | ||
<button className="editorButton" onClick={onItalicClick}> | ||
<em>I</em> | ||
</button> | ||
</div> | ||
<div className="line" /> | ||
</> | ||
)} | ||
<Editor | ||
editorState={editorState} | ||
handleKeyCommand={handleKeyCommand} | ||
onChange={onChange} | ||
readOnly={!editMode} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default TextEditor; |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
width: 100%; | ||
position: fixed; | ||
background: white; | ||
z-index: 1; | ||
z-index: 2; | ||
} | ||
|
||
.profile-logo { | ||
|
Oops, something went wrong.