UNPKG

6.43 kBMarkdownView Raw
1# React Transcript Editor
2
3<!-- _One liner_ -->
4
5A React component to make transcribing audio and video easier and faster.
6
7[![install size](https://packagephobia.now.sh/badge?p=@bbc/react-transcript-editor)](https://packagephobia.now.sh/result?p=@bbc/react-transcript-editor)
8
9The project uses [this github project board to organise and the co-ordinate development](https://github.com/bbc/react-transcript-editor/projects/1).
10
11_--> Work in progress <--_
12
13<!-- _Screenshot of UI - optional_ -->
14
15## Development env
16
17 <!-- _How to run the development environment_ -->
18
19- npm > `6.1.0`
20- [Node 10 - dubnium](https://scotch.io/tutorials/whats-new-in-node-10-dubnium)
21
22Node version is set in node version manager [`.nvmrc`](https://github.com/creationix/nvm#nvmrc)
23
24<!-- _Coding style convention ref optional, eg which linter to use_ -->
25
26<!-- _Linting, github pre-push hook - optional_ -->
27
28## Setup
29
30<!-- _stack - optional_ -->
31<!-- _How to build and run the code/app_ -->
32
33Fork this repository + git clone + cd into folder
34
35## Usage - development
36
37<!-- git clone git@github.com:bbc/react-transcript-editor.git -->
38
39> To start the development server (with entry point `src/index.js`), run
40
41```
42npm start
43```
44
45Visit [http://localhost:3000](http://localhost:3000)
46
47## Usage - production
48
49<!-- npm install react-transcript-editor -->
50
51<!-- exampel usage - require etc.. -->
52<!-- https://www.npmjs.com/package/@bbc/react-transcript-editor -->
53
54Available on [npm - `@bbc/react-transcript-editor`](https://www.npmjs.com/package/@bbc/react-transcript-editor)
55
56```
57npm install @bbc/react-transcript-editor
58```
59
60```js
61import { TranscriptEditor } from '@bbc/react-transcript-editor';
62
63 <TranscriptEditor
64 transcriptData=// Transcript json
65 mediaUrl=// string url to media file - audio or video
66 isEditable={true}// set to true if you want to be able to edit the text
67 sttJsonType={ 'bbckaldi' } // the type of STT Json transcript supported.
68 handleAnalyticsEvents={ this.handleAnalyticsEvents } // optional - if you want to collect analytics events.
69 fileName=// optional - used for saving and retrieving local storage blob files
70 title=// optional - defaults to ''
71 ref={ this.transcriptEditorRef } // optional - if you want to have access to internal functions such as retrieving content from the editor. eg to save to a server/db.
72 />
73```
74See [`./src/index.js` demo](./src/index.js) as a more detailed example usage of the component.
75
76_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)_
77
78### Typescript projects
79
80If using in a parent project where [typescript](https://www.typescriptlang.org/) is being used you might need to add `//@ts-ignore` before the import statment like this
81
82```js
83//@ts-ignore
84import { TranscriptEditor } from "@bbc/react-transcript-editor";
85```
86
87## System Architecture
88
89<!-- _High level overview of system architecture_ -->
90
91uses [`create-component-lib`](https://www.npmjs.com/package/create-component-lib) as explaied in this [blog post](https://hackernoon.com/creating-a-library-of-react-components-using-create-react-app-without-ejecting-d182df690c6b) to setup the environment to develop this React.
92
93This uses [Create React App 2.0](https://reactjs.org/blog/2018/10/01/create-react-app-v2.html) so we are using [CSS Modules](https://github.com/css-modules/css-modules) to contain the scope of the css for this component.
94<!--
95Uses CSS grid-layout https://medium.com/samsung-internet-dev/common-responsive-layouts-with-css-grid-and-some-without-245a862f48df -->
96
97> Place everything you want to publish to npm inside `src/lib`.
98
99> Outside `src/lib` (but inside src/), you can create example web pages to test or demonstrate the usage of your components.
100
101## Documentation
102
103There's a [docs](./docs) folder in this repository.
104
105[docs/notes](./docs/notes) contains dev notes on various aspects of the project.
106
107[docs/adr](./docs/adr) contains [Architecture Decision Record](https://github.com/joelparkerhenderson/architecture_decision_record).
108
109> An architectural decision record (ADR) is a document that captures an important architectural decision made along with its context and consequences.
110
111We are using [this template for ADR](https://gist.github.com/iaincollins/92923cc2c309c2751aea6f1b34b31d95)
112
113[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).
114
115## Build
116
117<!-- _How to run build_ -->
118
119> To transpile `src/lib` and create a build in the dist folder, run:
120
121```
122npm run build:component
123```
124
125## Demo
126
127Demo can be viewed at [https://bbc.github.io/react-transcript-editor](https://bbc.github.io/react-transcript-editor)
128
129<!-- https://github.com/gitname/react-gh-pages
130-->
131
132## Build - demo
133
134This github repository uses [github pages](https://pages.github.com/) to host a demo of the component, in [docs/demo](./docs/demo)
135
136```
137npm run deploy:ghpages
138```
139
140add to git, and push to origin master to update
141
142<!-- https://help.github.com/articles/user-organization-and-project-pages/#project-pages-sites -->
143
144Alternatively If you simply want to build the demo locally in the `build` folder then just
145
146```
147npm run build:example
148```
149
150## Tests
151
152<!-- _How to carry out tests_ -->
153
154Test coverage using [`jest`](https://jestjs.io/), to run tests
155
156```
157npm run test
158```
159
160## Deployment
161
162<!-- _How to deploy the code/app into test/staging/production_ -->
163
164To push to [npm - `@bbc/react-transcript-editor`](https://www.npmjs.com/package/@bbc/react-transcript-editor)
165
166```
167npm publish:public
168```
169
170This runs `npm run build:component` and `npm publish --access public` under the hood
171
172> Note that only `README.md` and the `dist` folders are published to npm.
173
174## Contributing
175
176See [CONTRIBUTING.md](./CONTRIBUTING.md) guidelines and [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md) guidelines.
177
178## Licence
179
180<!-- mention MIT Licence -->
181
182## Legal Disclaimer
183
184Despite using React and DraftJs, the BBC is not promoting any Facebook products or other commercial interest.