This repository has been archived by the owner on Feb 26, 2022. It is now read-only.
forked from bbc/react-transcript-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* first pass at scafolding main components * added TimedTextEditor example * testing css modules * got css modules to work turns out it needs to be ComponentName.module.css for the file name * Added README info on css moduels * added video to MediaPreview component * added ADR for Timed text * Added Kaldi Transcript to Timed ditor Component first pass at making adapter to convert kaldi bbc transcript json to draft.js content block, + add support to diplay editable text in the component usind draftjs * removed load button removed load button in TimedTextEditor, using componentDidMount instead so that content of transcript passed as prop can be loaded without extra step * testing if demo works on github pages added build sstep for demo * demo test * demo * test demo * bug fix - editing text accdidentally commented out on change editor state in timed text editor, and was not allowing to edit text anymore * Adding CSS flex grid and basic styling copyed some styling from oTranscribe * Added fallback fonts for demo * added overflow to text * demo improvements can now load local transcript json and local media for user testing * bug fix - kaldi/octo BBC Octo Labs API Response wraps Kaldi response around , while kaldi contains word attribute at root * fixed transpiling fixed transpaling for the component + added some notes in docs * Added ADR for components communication strategy * Feature/entities (bbc#1) * node 10.x LTS * reformat with prettier, some eslint fixes * paragraph margins * words as entities, onclick handler for transcript navigation * Refactor - generate entities function to separate module so that can be reused by other adapters for other STT services. * Tests - and added unit tests for generate entities function for troubleshooting and making sure it worked as expected
- Loading branch information
Showing
69 changed files
with
22,485 additions
and
5,788 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
{ "presets": ["react-app"] } | ||
{ | ||
"presets": [ | ||
"@babel/preset-react" | ||
] | ||
} |
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 |
---|---|---|
@@ -1 +1,20 @@ | ||
{ "extends": "react-app" } | ||
{ | ||
"extends": "react-app", | ||
"env": { | ||
"browser": true, | ||
"commonjs": true, | ||
"node": true, | ||
"es6": true | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 6, | ||
"sourceType": "module" | ||
}, | ||
"rules": { | ||
"no-console": "off", | ||
"jsx-a11y/href-no-hash": 0, | ||
"strict": ["error", "global"], | ||
"curly": "warn", | ||
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }] | ||
} | ||
} |
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 |
---|---|---|
|
@@ -84,4 +84,4 @@ typings/ | |
.env | ||
|
||
# next.js build output | ||
.next | ||
.next |
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 @@ | ||
lts/dubnium |
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,12 @@ | ||
import React from 'react'; | ||
import ProgressBar from "./ProgressBar/ProgressBar"; | ||
import PlayerControls from "./PlayerControls/PlayerControls"; | ||
|
||
class MediaController extends React.Component { | ||
render() { | ||
return React.createElement("div", null, React.createElement("h2", null, "MediaController"), React.createElement(ProgressBar, null), React.createElement(PlayerControls, null)); | ||
} | ||
|
||
} | ||
|
||
export default MediaController; |
10 changes: 10 additions & 0 deletions
10
dist/TranscriptEditor/MediaController/PlayerControls/PlayerControls.js
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,10 @@ | ||
import React from 'react'; | ||
|
||
class PlayerControls extends React.Component { | ||
render() { | ||
return React.createElement("h3", null, "PlayerControls"); | ||
} | ||
|
||
} | ||
|
||
export default PlayerControls; |
10 changes: 10 additions & 0 deletions
10
dist/TranscriptEditor/MediaController/ProgressBar/ProgressBar.js
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,10 @@ | ||
import React from 'react'; | ||
|
||
class ProgressBar extends React.Component { | ||
render() { | ||
return React.createElement("h3", null, "ProgressBar"); | ||
} | ||
|
||
} | ||
|
||
export default ProgressBar; |
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,34 @@ | ||
import React from 'react'; | ||
import styles from './MediaPreview.module.css'; // inspired by https://github.com/bbc/nm2/blob/master/src/components/chapter/video/Video.jsx | ||
|
||
class MediaPreview extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.videoRef = React.createRef(); | ||
} | ||
|
||
render() { | ||
// conditional, if media player not defined then don't show | ||
let mediaPlayer; | ||
|
||
if (this.props.mediaUrl !== "") { | ||
mediaPlayer = React.createElement("video", { | ||
id: "video", | ||
playsInline: true // autoPlay | ||
, | ||
controls: true, | ||
src: this.props.mediaUrl, | ||
type: "video/mp4", | ||
"data-testid": "media-player-id", | ||
ref: this.videoRef | ||
}); | ||
} | ||
|
||
return React.createElement("section", { | ||
className: styles.videoSection | ||
}, mediaPlayer); | ||
} | ||
|
||
} | ||
|
||
export default MediaPreview; |
33 changes: 33 additions & 0 deletions
33
dist/TranscriptEditor/MediaPreview/MediaPreview.module.css
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,33 @@ | ||
.videoSection { | ||
height: 100%; | ||
width: 100%; | ||
} | ||
|
||
video { | ||
/* height: 90vh; */ | ||
width: 100%; | ||
/* overflow: hidden; */ | ||
/* position:absolute; */ | ||
/* z-index:-1; */ | ||
/* object-fit: cover; */ | ||
} | ||
|
||
|
||
/* .videoControls{ | ||
height: 10vh; | ||
width: 100%; | ||
background-color: black; | ||
color:white; | ||
position: absolute; | ||
bottom: 0; | ||
display: flex; | ||
justify-content: center; | ||
} | ||
*/ | ||
|
||
/* .playPause{ | ||
color:white; | ||
text-transform: uppercase; | ||
} */ | ||
|
||
|
28 changes: 28 additions & 0 deletions
28
dist/TranscriptEditor/MediaPreview/MediaPreview.unit.test.js
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,28 @@ | ||
import React from 'react'; | ||
import { render, cleanup } from 'react-testing-library'; | ||
import { shallow } from 'enzyme'; | ||
import MediaPreview from './MediaPreview'; | ||
afterEach(cleanup); | ||
const fakeVideoUrl = 'https://storage.googleapis.com/coverr-main/mp4/Pigeon-Impossible.mp4'; | ||
test('GIVEN a chapter title I expect that WHEN the Video component is rendered THEN the correct title is displayed', () => { | ||
const { | ||
container | ||
} = render(React.createElement(MediaPreview, { | ||
mediaUrl: fakeVideoUrl | ||
})); | ||
expect(container.innerHTML).toContain('videoSection'); | ||
}); | ||
test('GIVEN a video as a chapter with src video url THEN the video is rendered with it\'s source url', () => { | ||
const { | ||
getByTestId | ||
} = render(React.createElement(MediaPreview, { | ||
mediaUrl: fakeVideoUrl | ||
})); | ||
expect(getByTestId('media-player-id').attributes.src.value).toBe(fakeVideoUrl); | ||
}); | ||
test('WHEN the Video component is rendered THEN a video element is displayed', () => { | ||
const wrapper = shallow(React.createElement(MediaPreview, { | ||
mediaUrl: fakeVideoUrl | ||
})); | ||
expect(wrapper.find('video').type()).toBe('video'); | ||
}); |
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,11 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
class SettingsPanel extends React.Component { | ||
render() { | ||
return React.createElement("h2", null, "SettingsPanel"); | ||
} | ||
|
||
} | ||
|
||
export default SettingsPanel; |
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,59 @@ | ||
import React from 'react'; | ||
import { // Draft, | ||
Editor, EditorState, // ContentState, | ||
convertFromRaw } from 'draft-js'; | ||
import styles from './TimedTextEditor.module.css'; | ||
import bbcKaldiToDraft from './adapters/bbc-kaldi/index.js'; | ||
|
||
class TimedTextEditor extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
editorState: EditorState.createEmpty(), | ||
transcriptData: this.props.transcriptData | ||
}; | ||
|
||
this.onChange = editorState => this.setState({ | ||
editorState | ||
}); | ||
} | ||
|
||
componentDidMount() { | ||
this.loadData(); | ||
} | ||
|
||
componentWillReceiveProps(nexProps) { | ||
this.setState({ | ||
transcriptData: nexProps.transcriptData | ||
}, () => { | ||
this.loadData(); | ||
}); | ||
} | ||
|
||
loadData() { | ||
if (this.props.transcriptData !== "") { | ||
let blocks = bbcKaldiToDraft(this.props.transcriptData); | ||
const entityMap = {}; | ||
const contentState = convertFromRaw({ | ||
blocks, | ||
entityMap | ||
}); | ||
const editorState = EditorState.createWithContent(contentState); | ||
this.setState({ | ||
editorState | ||
}); | ||
} | ||
} | ||
|
||
render() { | ||
return React.createElement("section", { | ||
className: styles.editor | ||
}, React.createElement(Editor, { | ||
editorState: this.state.editorState, | ||
onChange: this.onChange | ||
})); | ||
} | ||
|
||
} | ||
|
||
export default TimedTextEditor; |
8 changes: 8 additions & 0 deletions
8
dist/TranscriptEditor/TimedTextEditor/TimedTextEditor.module.css
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,8 @@ | ||
/* | ||
Giving the editor a oveflow | ||
https://github.com/facebook/draft-js/issues/528 | ||
*/ | ||
.editor :global(.public-DraftEditor-content) { | ||
max-height: 70vh; | ||
overflow: auto; | ||
} |
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,4 @@ | ||
# Adaprters | ||
|
||
To convert STT json transcript into draft.js code block. | ||
Used by TimedTextEditor. |
7 changes: 7 additions & 0 deletions
7
dist/TranscriptEditor/TimedTextEditor/adapters/bbc-kaldi/example-usage.js
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,7 @@ | ||
const bbcKaldiToDraft = require('./index.js'); // using require, because of testing outside of React app | ||
|
||
|
||
const kaldiTedTalkTranscript = require('../../../../../sample-data/KateDarling_2018S-bbc-kaldi.json'); | ||
|
||
let result = bbcKaldiToDraft(kaldiTedTalkTranscript); | ||
console.log(result); |
Oops, something went wrong.