Skip to content

Commit fa6d651

Browse files
authored
I240 (#242)
* General automated clean up * Updating feature list * Updated Readme * Updated docs for Adapters, Analytics and renaming misspellings.
1 parent c132484 commit fa6d651

File tree

6 files changed

+340
-276
lines changed

6 files changed

+340
-276
lines changed

README.md

Lines changed: 97 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# React Transcript Editor
22

3-
<!-- _One liner_ -->
4-
53
A React component to make transcribing audio and video easier and faster.
64

75
<p>
@@ -16,9 +14,7 @@ A React component to make transcribing audio and video easier and faster.
1614
</a>
1715
</p>
1816
<br/>
19-
2017
The project uses [this github project boards to organise and the co-ordinate development](https://github.com/bbc/react-transcript-editor/projects).
21-
2218
_--> Work in progress <--_
2319

2420
<!-- _Screenshot of UI - optional_ -->
@@ -35,42 +31,39 @@ _--> Work in progress <--_
3531

3632
Node version is set in node version manager [`.nvmrc`](https://github.com/creationix/nvm#nvmrc)
3733

38-
<!-- _Coding style convention ref optional, eg which linter to use_ -->
39-
40-
<!-- _Linting, github pre-push hook - optional_ -->
41-
4234
## Setup
4335

44-
<!-- _stack - optional_ -->
45-
<!-- _How to build and run the code/app_ -->
46-
47-
Fork this repository + git clone + cd into folder
36+
1. Fork this repository
37+
2. Clone this repository to a directory of your choice
38+
3. Run `npm i` to install dependencies
4839

4940
## Usage - development
5041

51-
Git clone this repository and cd into the folder.
42+
We use a tool called [`storybook`](https://storybook.js.org)
43+
to run the components locally. To start the Storybook, run:
5244

53-
To start the storybook run
54-
55-
```
45+
```sh
5646
npm start
5747
```
5848

59-
Visit [http://localhost:6006](http://localhost:6006)
49+
Running that command should open the locally hosted Storybook, but if it doesn't,
50+
visit [http://localhost:6006](http://localhost:6006)
6051

6152
## Usage - production
6253

63-
Available on [npm - `@bbc/react-transcript-editor`](https://www.npmjs.com/package/@bbc/react-transcript-editor)
54+
In order to use a published version of `react-transcript-editor`,
55+
install the published module [`@bbc/react-transcript-editor`](https://www.npmjs.com/package/@bbc/react-transcript-editor)
56+
by running:
6457

65-
```
58+
```sh
6659
npm install @bbc/react-transcript-editor
6760
```
6861

6962
```js
7063
import TranscriptEditor from "@bbc/react-transcript-editor";
7164
```
7265

73-
Minimal data needed for initialization
66+
### Basic use case
7467

7568
```js
7669
<TranscriptEditor
@@ -79,43 +72,52 @@ Minimal data needed for initialization
7972
/>
8073
```
8174

82-
With more attributes
75+
`transcriptData` and `mediaUrl` are non-optional props to use `TranscriptEditor`.
76+
See the full list of options [here](#transcripteditor-props-list).
77+
78+
### Advanced use case
79+
8380
```js
8481
<TranscriptEditor
8582
transcriptData={someJsonFile}
8683
mediaUrl={"https://download.ted.com/talks/KateDarling_2018S-950k.mp4"}
8784
handleAutoSaveChanges={this.handleAutoSaveChanges}
88-
autoSaveContentType={'digitalpaperedit'}
85+
autoSaveContentType={"digitalpaperedit"}
8986
isEditable={true}
9087
spellCheck={false}
9188
sttJsonType={"bbckaldi"}
9289
handleAnalyticsEvents={this.handleAnalyticsEvents}
9390
fileName={"ted-talk.mp4"}
9491
title={"Ted Talk"}
9592
ref={this.transcriptEditorRef}
96-
mediaType={'video'}
93+
mediaType={"video"}
9794
/>
9895
```
9996

100-
| Attributes | Description | required | type |
101-
| :-------------------- | :---------------------------------------------------------------------------------------------------------------------- | :------: | :-------: |
102-
| transcriptData | Transcript json | yes | Json |
103-
| mediaUrl | string url to media file - audio or video | yes | String |
104-
|`handleAutoSaveChanges`| returns content of transcription after a change | no | Function |
105-
| autoSaveContentType | specify the file format for data returned by `handleAutoSaveChanges`,falls back on `sttJsonType`. or `draftjs` | no | string |
106-
| isEditable | set to true if you want to be able to edit the text | no | Boolean |
107-
| spellCheck | set to true if you want the browser to spell check this transcript | no | Boolean |
108-
|`handleAnalyticsEvents`| if you want to collect analytics events. | no | Function |
109-
| fileName | used for saving and retrieving local storage blob files | no | String |
110-
| title | defaults to empty string | no | String |
111-
| ref | if you want to have access to internal functions such as retrieving content from the editor. eg to save to a server/db. | no | React ref |
112-
| mediaType | can be `audio` or `video`, if not provided the component uses the url file type to determine and adjust use of the page layout | no | String |
97+
### TranscriptEditor Props List
98+
99+
| Props | Description | required | type | default |
100+
| :---------------------- | :---------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------: | :-------: | :----------------------------------------------------------------------------: |
101+
| `transcriptData` | Transcript JSON | yes | JSON | |
102+
| `mediaUrl` | URL to media (audio or video) file | yes | String | |
103+
| `handleAutoSaveChanges` | Function to handle the content of transcription after a change | no | Function |
104+
| `autoSaveContentType` | Specify the file format for data returned by `handleAutoSaveChanges` | no | String | falls back to `sttJsonType`, if set, or `draftjs` |
105+
| `isEditable` | Set to `true` to have the ability to edit the text | no | Boolean | False |
106+
| `spellCheck` | Set to `true` to spell-check the transcript | no | Boolean | False |
107+
| `sttJsonType` | The data model type of your `transcriptData` | no | String | `draftjs` |
108+
| `handleAnalyticsEvents` | if you want to collect analytics events. | no | Function | false |
109+
| `fileName` | used for saving and retrieving local storage blob files | no, but disables the [local save feature](#local-save) | String |
110+
| `title` | defaults to empty string | no | String |
111+
| `ref` | If you want to have access to internal functions such as retrieving content from the editor. eg to save to a server/db. | no | React ref |
112+
| `mediaType` | Can be `audio` or `video`. Changes the look of the UI based on media type. | no | String | if not provided the component uses the `medialUrl` to determine the media type |
113113

114114
See [`./demo/app.js` demo](./demo/app.js) as a more detailed example usage of the component.
115115

116-
_Note: `fileName` it is optional but it's needed if working with user uploaded local media in the browser, to be able to save and retrieve from local storage. For instance if you are passing a blob url to `mediaUrl` using `createObjectURL` this url is randomly re-generated on every page refresh so you wouldn't be able to restore a session, as `mediaUrl` is used as the local storage key. See demo app for more detail example of this[`./src/index.js`](./src/index.js)_
116+
#### Local save
117117

118-
_Note: `mediaType` if not defined, the component uses the url to determine the type and adjust the layout accordingly, however this could result in a slight delay when loading the component as it needs to fetch the media to determine it's file type_
118+
`fileName` is optional but it's needed if working with user uploaded local media in the browser,
119+
to be able to save and retrieve from local storage.
120+
For instance if you are passing a blob url to `mediaUrl` using `createObjectURL` this url is randomly re-generated on every page refresh so you wouldn't be able to restore a session, as `mediaUrl` is used as the local storage key. See demo app for more detail example of this[`./src/index.js`](./src/index.js)\_
119121

120122
### Typescript projects
121123

@@ -128,15 +130,17 @@ import { TranscriptEditor } from "@bbc/react-transcript-editor";
128130

129131
#### Internal components
130132

133+
##### Direct imports
134+
131135
You can also import some of the underlying React components directly.
136+
See [the storybook](https://bbc.github.io/react-transcript-editor) for each component details on optional and required attributes.
132137

133138
- `TranscriptEditor`
134139
- `TimedTextEditor`
135140
- `MediaPlayer`
136141
- `VideoPlayer`
137142
- `Settings`
138143
- `KeyboardShortcuts`
139-
140144
- `ProgressBar`
141145
- `PlaybackRate`
142146
- `PlayerControls`
@@ -153,144 +157,142 @@ import TimedTextEditor from "@bbc/react-transcript-editor/TimedTextEditor";
153157
import { TimedTextEditor } from "@bbc/react-transcript-editor";
154158
```
155159

156-
However if you are not using `TranscriptEditor` it is recommended to follow the second option and import individual components like: `@bbc/react-transcript-editor/TimedTextEditor` rather than the entire library. Doing so pulls in only the specific components that you use, which can significantly reduce the amount of code you end up sending to the client. (Similarly to how [`react-bootstrap`](https://react-bootstrap.github.io/getting-started/introduction) works)
160+
##### Import recommendation
157161

158-
See [the storybook](https://bbc.github.io/react-transcript-editor) for each component details on optional and required attributes.
162+
However if you are not using `TranscriptEditor` it is recommended to follow the second option and import individual components like: `@bbc/react-transcript-editor/TimedTextEditor` rather than the entire library.
163+
Doing so pulls in only the specific components that you use, which can significantly reduce the amount of code you end up sending to the client. (Similarly to how [`react-bootstrap`](https://react-bootstrap.github.io/getting-started/introduction) works)
164+
165+
#### Other Node Modules (non-react)
166+
167+
Some of these node modules can be used as standalone imports.
159168

160-
You can also use this node modules as standalone
169+
##### Export Adapter
170+
171+
Converts from draftJs json format to other formats
161172

162173
```js
163174
import exportAdapter from "@bbc/react-transcript-editor/exportAdapter";
164175
```
165176

166-
Converts from draftJs json format to other formats
177+
##### STT JSON Adapter
178+
179+
Converts various stt json formats to draftJs
167180

168181
```js
169182
import sttJsonAdapter from "@bbc/react-transcript-editor/sttJsonAdapter";
170183
```
171184

172-
Converts various stt json formats to draftJs
185+
##### Conversion modules to/from Timecodes
186+
187+
Some modules to convert to and from timecodes
173188

174189
```js
175190
import {
176191
secondsToTimecode,
177192
timecodeToSeconds,
178-
shortTimecode
193+
shortTimecode,
179194
} from "@bbc/react-transcript-editor/timecodeConverter";
180195
```
181196

182-
some modules to convert to and from timecodes
183-
184197
## System Architecture
185198

186-
<!-- _High level overview of system architecture_ -->
187-
188-
- uses [`storybook`](https://storybook.js.org) with the setup as [explained in their docs](https://storybook.js.org/docs/guides/guide-react/) to develop this React.
199+
- Uses [`storybook`](https://storybook.js.org) with the setup as [explained in their docs](https://storybook.js.org/docs/guides/guide-react/) to develop this React.
189200
- This uses [CSS Modules](https://github.com/css-modules/css-modules) to contain the scope of the css for this component.
190-
- [`.storybook/webpack.config.js](./.storybook/webpack.config.js) enanches the storybook webpack config to add support for css modules.
201+
- [`.storybook/webpack.config.js](./.storybook/webpack.config.js) enables the storybook webpack config to add support for css modules.
191202
- The parts of the component are inside [`./packages`](./packages)
192203
- [babel.config.js](./babel.config.js) provides root level system config for [babel 7](https://babeljs.io/docs/en/next/config-files#project-wide-configuration).
193204

194-
<!-- - for build, packaging, and deployment of the npm module, we use webpack with babel 7 -->
195-
196205
## Documentation
197206

198-
There's a [docs](./docs) folder in this repository.
207+
There's a [docs](./docs) folder in this repository, which contains subdirectories to keep:
199208

200-
[docs/notes](./docs/notes) contains dev notes on various aspects of the project.
209+
- [notes](./docs/notes): dev notes on various aspects of the project.
210+
- [adr](./docs/adr): [Architecture Decision Record](https://github.com/joelparkerhenderson/architecture_decision_record).
201211

202-
[docs/adr](./docs/adr) contains [Architecture Decision Record](https://github.com/joelparkerhenderson/architecture_decision_record).
212+
### ADR
203213

204214
> An architectural decision record (ADR) is a document that captures an important architectural decision made along with its context and consequences.
205215
206216
We are using [this template for ADR](https://gist.github.com/iaincollins/92923cc2c309c2751aea6f1b34b31d95)
207217

218+
### QA
219+
208220
[There also QA testing docs](./docs/qa/README.md) to manual test the component before a major release, (QA testing does not require any technical knowledge).
209221

210222
## Build
211223

212-
<!-- _How to run build_ -->
213-
214224
> To transpile `./packages` and create a build in the `./dist` folder, run:
215225
216-
```
226+
```sh
217227
npm run build:component
218228
```
219229

220-
## Demo & storybook
230+
To understand the build process, have a read through [this](./docs/guides/storybook-npm-setup.md).
221231

222-
- **Storybook** can bew viewed at [https://bbc.github.io/react-transcript-editor/](https://bbc.github.io/react-transcript-editor/)
232+
## Demo & storybook
223233

234+
- **Storybook** can be viewed at [https://bbc.github.io/react-transcript-editor/](https://bbc.github.io/react-transcript-editor/)
224235
- **Demo** can be viewed at [https://bbc.github.io/react-transcript-editor/iframe.html?id=demo--default](https://bbc.github.io/react-transcript-editor/iframe.html?id=demo--default)
225236

226-
http://localhost:6006
227-
228-
<!-- https://github.com/gitname/react-gh-pages
229-
-->
237+
To run locally, see [setup](#usage---development).
230238

231-
## Build - storybook
239+
### Build - storybook
232240

233-
To build the storybook as a static site
241+
To build the storybook as a static site, run:
234242

235-
```
243+
```sh
236244
npm run build:storybook
237245
```
238246

239-
## Publish storybook & demo to github pages
247+
This will produce a `build` folder containing the static site of the demo.
248+
To serve the `build` folder locally, run:
240249

241-
This github repository uses [github pages](https://pages.github.com/) to host the storybook and the demo of the component
242-
243-
```
244-
npm run deploy:ghpages
250+
```sh
251+
npm run build:storybook:serve
245252
```
246253

247-
add to git, and push to origin master to update
254+
#### Publishing to a web page
248255

249-
<!-- https://help.github.com/articles/user-organization-and-project-pages/#project-pages-sites -->
256+
##### Github Pages
250257

251-
Alternatively If you simply want to build the demo locally in the `build` folder then just
258+
We use [github pages](https://pages.github.com/) to host the storybook and the [demo](https://help.github.com/articles/user-organization-and-project-pages/#project-pages-sites) of the component.
259+
Make sure to add your changes to git, and push to `origin master` to ensure the code in `master` is reflective of what's online on `Github Pages`.
260+
When you are ready, re-publish the Storybook by running:
252261

253-
```
254-
npm run build:storybook
255-
```
256-
257-
you can then run this command to serve the static site locally
258-
259-
```
260-
npm run build:storybook:serve
262+
```sh
263+
npm run deploy:ghpages
261264
```
262265

263266
## Tests
264267

265-
<!-- _How to carry out tests_ -->
266-
267-
Test coverage using [`jest`](https://jestjs.io/), to run tests
268+
We are using [`jest`](https://jestjs.io/) for the testing framework.
269+
To run tests, run:
268270

269271
```sh
270272
npm run test
271273
```
272274

273-
During development you can use
275+
For convenience, during development you can use:
274276

275277
```sh
276278
npm run test:watch
277279
```
278280

279-
## Travis CI
281+
and watch the test be re-run at every save.
280282

281-
On commit this repo uses the [.travis.yml](./.travis.yml) config tu run the automated test on [travis CI](https://travis-ci.org/bbc/react-transcript-editor).
283+
## Travis CI
282284

283-
## Deployment
285+
On commit this repo uses the [.travis.yml](./.travis.yml) config to run the automated test on [travis CI](https://travis-ci.org/bbc/react-transcript-editor).
284286

285-
<!-- _How to deploy the code/app into test/staging/production_ -->
287+
## Publish to NPM
286288

287-
To push to [npm - `@bbc/react-transcript-editor`](https://www.npmjs.com/package/@bbc/react-transcript-editor)
289+
To publish to [npm - `@bbc/react-transcript-editor`](https://www.npmjs.com/package/@bbc/react-transcript-editor) run:
288290

289-
```
291+
```sh
290292
npm publish:public
291293
```
292294

293-
This runs `npm run build:component` and `npm publish --access public` under the hood
295+
This runs `npm run build:component` and `npm publish --access public` under the hood, building the component and publishing to NPM.
294296

295297
> Note that only `README.md` and the `dist` folders are published to npm.
296298

0 commit comments

Comments
 (0)