-
Notifications
You must be signed in to change notification settings - Fork 171
Fix #141 updating speaker names #208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
e8cae83
Merge pull request #2 from bbc/master
pietrop 9a0d3db
Merge pull request #4 from bbc/master
pietrop 2d771e9
Merge pull request #5 from bbc/master
pietrop 820bb02
fixes issue https://github.com/bbc/react-transcript-editor/issues/133
c96fab3
Working
f8fc650
adjusted CSS accordingly
19a07e1
Merge pull request #6 from pietrop/fix-133-speaker-not-editable-in-re…
pietrop 37da17e
moved CustomEditor in separate file
c93ca59
speaker prompt keeps current speaker name
6716cea
brought in changes from previous PRs
2aaae03
names change but component doesn't re-render
d2f90f5
changes don't propagate straight away but they do after you edit text
50d4dde
cleaned up still no auto re-rendering
a3aabb6
works
c4fc17f
changing spekaer triggers auto save callback
58c6f49
Removed space
7279db2
Update packages/components/timed-text-editor/CustomEditor.js
pietrop 1c47e0b
Update packages/components/timed-text-editor/WrapperBlock.js
pietrop 285cf9e
Merge branch 'master' into fix-141-updating-speaker-names
pietrop File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import React from "react"; | ||
| import PropTypes from "prop-types"; | ||
| import { Editor } from "draft-js"; | ||
|
|
||
|
|
||
| import WrapperBlock from './WrapperBlock'; | ||
|
|
||
| // NOTE: custom editor is in a separate class to minimise re-renders | ||
| // if considering refactoring, removing the separate class, please double check | ||
| // that doing so does not introduce uncessary re-renders first. | ||
| class CustomEditor extends React.Component { | ||
| handleWordClick = e => { | ||
| this.props.onWordClick(e); | ||
| }; | ||
|
|
||
| renderBlockWithTimecodes = () => { | ||
| return { | ||
| component: WrapperBlock, | ||
| editable: true, | ||
| props: { | ||
| showSpeakers: this.props.showSpeakers, | ||
| showTimecodes: this.props.showTimecodes, | ||
| timecodeOffset: this.props.timecodeOffset, | ||
| editorState: this.props.editorState, | ||
| setEditorNewContentStateSpeakersUpdate: this.props.setEditorNewContentStateSpeakersUpdate, | ||
| onWordClick: this.handleWordClick, | ||
| handleAnalyticsEvents: this.props.handleAnalyticsEvents, | ||
| isEditable: this.props.isEditable | ||
| } | ||
| }; | ||
| }; | ||
|
|
||
| shouldComponentUpdate(nextProps) { | ||
| // https://stackoverflow.com/questions/39182657/best-performance-method-to-check-if-contentstate-changed-in-draftjs-or-just-edi | ||
| if (nextProps.editorState !== this.props.editorState) { | ||
| console.log('it should update??!') | ||
| return true; | ||
| } | ||
|
|
||
| if (nextProps.isEditable !== this.props.isEditable) { | ||
| return true; | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| handleOnChange = e => { | ||
| this.props.onChange(e); | ||
| }; | ||
|
|
||
| render() { | ||
| return ( | ||
| <Editor | ||
| editorState={this.props.editorState} | ||
| onChange={this.handleOnChange} | ||
| stripPastedStyles | ||
| blockRendererFn={this.renderBlockWithTimecodes} | ||
| handleKeyCommand={this.props.handleKeyCommand} | ||
| keyBindingFn={this.props.customKeyBindingFn} | ||
| spellCheck={this.props.spellCheck} | ||
| /> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| export default CustomEditor; | ||
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
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.