@@ -18,7 +18,17 @@ import { createEditor, Editor, Transforms } from 'slate';
18
18
// Import the Slate components and React plugin.
19
19
import { Slate , Editable , withReact , ReactEditor } from 'slate-react' ;
20
20
import { withHistory } from 'slate-history' ;
21
- import { faSave , faShare , faUndo , faSync , faInfoCircle , faMehBlank , faPause , faMusic , faClosedCaptioning } from '@fortawesome/free-solid-svg-icons' ;
21
+ import {
22
+ faSave ,
23
+ faFileDownload ,
24
+ faUndo ,
25
+ faSync ,
26
+ faInfoCircle ,
27
+ // faMehBlank,
28
+ faPause ,
29
+ // faMusic,
30
+ // faClosedCaptioning,
31
+ } from '@fortawesome/free-solid-svg-icons' ;
22
32
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' ;
23
33
import { shortTimecode } from '../util/timecode-converter' ;
24
34
import download from '../util/downlaod/index.js' ;
@@ -27,10 +37,11 @@ import convertDpeToSlate from '../util/dpe-to-slate';
27
37
import insertTimecodesInline from '../util/inline-interval-timecodes' ;
28
38
import pluck from '../util/pluk' ;
29
39
import subtitlesExportOptionsList from '../util/export-adapters/subtitles-generator/list.js' ;
30
- import updateTimestamps from '../util/update-timestamps' ;
40
+ // import updateTimestamps from '../util/update-timestamps';
41
+ import updateTimestamps from '../util/export-adapters/slate-to-dpe/update-timestamps' ;
31
42
import exportAdapter from '../util/export-adapters' ;
32
43
import isEmpty from '../util/is-empty' ;
33
-
44
+ import generatePreviousTimingsUpToCurrent from '../util/generate-previous-timings-up-to-current' ;
34
45
const PLAYBACK_RATE_VALUES = [ 0.2 , 0.25 , 0.5 , 0.75 , 1 , 1.25 , 1.5 , 1.75 , 2 , 2.25 , 2.5 , 3 , 3.5 ] ;
35
46
const SEEK_BACK_SEC = 15 ;
36
47
const PAUSE_WHILTE_TYPING_TIMEOUT_MILLISECONDS = 1500 ;
@@ -306,14 +317,14 @@ export default function SlateTranscriptEditor(props) {
306
317
if ( e . target . classList . contains ( 'timecode' ) ) {
307
318
const start = e . target . dataset . start ;
308
319
if ( mediaRef && mediaRef . current ) {
309
- mediaRef . current . currentTime = parseInt ( start ) ;
320
+ mediaRef . current . currentTime = parseFloat ( start ) ;
310
321
mediaRef . current . play ( ) ;
311
322
}
312
323
} else if ( e . target . dataset . slateString ) {
313
324
if ( e . target . parentNode . dataset . start ) {
314
325
const start = e . target . parentNode . dataset . start ;
315
326
if ( mediaRef && mediaRef . current && start ) {
316
- mediaRef . current . currentTime = parseInt ( start ) ;
327
+ mediaRef . current . currentTime = parseFloat ( start ) ;
317
328
mediaRef . current . play ( ) ;
318
329
}
319
330
}
@@ -397,19 +408,19 @@ export default function SlateTranscriptEditor(props) {
397
408
* to provide current paragaph's highlight.
398
409
* @param {Number } currentTime - float in seconds
399
410
*/
400
- const generatePreviousTimingsUpToCurrent = ( currentTime ) => {
401
- // edge case - empty transcription
402
- if ( isEmpty ( props . transcriptData ) ) {
403
- return '' ;
404
- }
405
- const lastWordStartTime = props . transcriptData . words [ props . transcriptData . words . length - 1 ] . start ;
406
- const lastWordStartTimeInt = parseInt ( lastWordStartTime ) ;
407
- const emptyListOfTimes = Array ( lastWordStartTimeInt ) ;
408
- const listOfTimesInt = [ ...emptyListOfTimes . keys ( ) ] ;
409
- const listOfTimesUpToCurrentTimeInt = listOfTimesInt . splice ( 0 , currentTime , 0 ) ;
410
- const stringlistOfTimesUpToCurrentTimeInt = listOfTimesUpToCurrentTimeInt . join ( ' ' ) ;
411
- return stringlistOfTimesUpToCurrentTimeInt ;
412
- } ;
411
+ // const generatePreviousTimingsUpToCurrent = (currentTime) => {
412
+ // // edge case - empty transcription
413
+ // if (isEmpty(props.transcriptData)) {
414
+ // return '';
415
+ // }
416
+ // const lastWordStartTime = props.transcriptData.words[props.transcriptData.words.length - 1].start;
417
+ // const lastWordStartTimeInt = parseInt(lastWordStartTime);
418
+ // const emptyListOfTimes = Array(lastWordStartTimeInt);
419
+ // const listOfTimesInt = [...emptyListOfTimes.keys()];
420
+ // const listOfTimesUpToCurrentTimeInt = listOfTimesInt.splice(0, currentTime, 0);
421
+ // const stringlistOfTimesUpToCurrentTimeInt = listOfTimesUpToCurrentTimeInt.join(' ');
422
+ // return stringlistOfTimesUpToCurrentTimeInt;
423
+ // };
413
424
414
425
const handleSetPauseWhileTyping = ( ) => {
415
426
setIsPauseWhiletyping ( ! isPauseWhiletyping ) ;
@@ -447,9 +458,7 @@ export default function SlateTranscriptEditor(props) {
447
458
< style scoped >
448
459
{ `
449
460
/* Next words */
450
- .timecode[data-previous-timings*="${
451
- mediaRef && mediaRef . current && mediaRef . current . duration && generatePreviousTimingsUpToCurrent ( parseInt ( currentTime ) )
452
- } "]{
461
+ .timecode[data-previous-timings*="${ generatePreviousTimingsUpToCurrent ( parseInt ( currentTime ) , value ) } "]{
453
462
color: #9E9E9E;
454
463
}
455
464
` }
@@ -613,8 +622,16 @@ export default function SlateTranscriptEditor(props) {
613
622
overlay = { < Tooltip id = "tooltip-disabled" > Export options</ Tooltip > }
614
623
>
615
624
< span className = "d-inline-block" >
616
- < DropdownButton disabled = { isProcessing } id = "dropdown-basic-button" title = { < FontAwesomeIcon icon = { faShare } /> } variant = "light" >
625
+ < DropdownButton
626
+ disabled = { isProcessing }
627
+ id = "dropdown-basic-button"
628
+ title = { < FontAwesomeIcon icon = { faFileDownload } /> }
629
+ variant = "light"
630
+ >
617
631
{ /* TODO: need to run re-alignement if exportin with timecodes true, otherwise they'll be inaccurate */ }
632
+ < Dropdown . Item style = { { color : 'black' } } disabled >
633
+ < b > Text Export</ b >
634
+ </ Dropdown . Item >
618
635
< Dropdown . Item
619
636
onClick = { ( ) => {
620
637
handleExport ( {
@@ -752,6 +769,27 @@ export default function SlateTranscriptEditor(props) {
752
769
Word (OHMS)
753
770
</ Dropdown . Item >
754
771
< Dropdown . Divider />
772
+
773
+ < Dropdown . Item style = { { color : 'black' } } disabled >
774
+ < b > Closed Captions Export</ b >
775
+ </ Dropdown . Item >
776
+ { subtitlesExportOptionsList . map ( ( { type, label, ext } , index ) => {
777
+ return (
778
+ < Dropdown . Item
779
+ key = { index + label }
780
+ onClick = { ( ) => {
781
+ handleExport ( { type, ext, isDownload : true } ) ;
782
+ } }
783
+ >
784
+ { label } (< code > .{ ext } </ code > )
785
+ </ Dropdown . Item >
786
+ ) ;
787
+ } ) }
788
+ < Dropdown . Divider />
789
+ < Dropdown . Item style = { { color : 'black' } } disabled >
790
+ < b > Developer options</ b >
791
+ </ Dropdown . Item >
792
+
755
793
< Dropdown . Item
756
794
onClick = { ( ) => {
757
795
handleExport ( {
@@ -782,7 +820,7 @@ export default function SlateTranscriptEditor(props) {
782
820
</ span >
783
821
</ OverlayTrigger >
784
822
</ Col >
785
- < Col xs = { 2 } sm = { 12 } md = { 12 } lg = { 12 } xl = { 12 } className = { 'p-1 mx-auto' } >
823
+ { /* <Col xs={2} sm={12} md={12} lg={12} xl={12} className={'p-1 mx-auto'}>
786
824
<OverlayTrigger
787
825
OverlayTrigger
788
826
delay={TOOTLIP_LONGER_DELAY}
@@ -809,7 +847,7 @@ export default function SlateTranscriptEditor(props) {
809
847
}) }
810
848
</DropdownButton>
811
849
</OverlayTrigger>
812
- </ Col >
850
+ </Col> */ }
813
851
< Col xs = { 2 } sm = { 12 } md = { 12 } lg = { 12 } xl = { 12 } className = { 'p-1 mx-auto' } >
814
852
< OverlayTrigger
815
853
OverlayTrigger
@@ -822,23 +860,23 @@ export default function SlateTranscriptEditor(props) {
822
860
</ Button >
823
861
</ OverlayTrigger >
824
862
</ Col >
825
- < Col xs = { 2 } sm = { 12 } md = { 12 } lg = { 12 } xl = { 12 } className = { 'p-1 mx-auto' } >
826
- < OverlayTrigger
827
- delay = { TOOTLIP_DELAY }
828
- placement = { 'bottom' }
829
- overlay = {
830
- < Tooltip id = "tooltip-disabled" >
831
- To insert a paragraph break, and split a pargraph in two, put the cursor at a point where you'd want to add a paragraph break in
832
- the text and either click this button or hit enter key
833
- </ Tooltip >
834
- }
835
- >
836
- < Button disabled = { isProcessing } onClick = { breakParagraph } variant = "light" >
837
- { /* <FontAwesomeIcon icon={ faICursor } /> */ } ↵
838
- </ Button >
839
- </ OverlayTrigger >
840
- </ Col >
841
- < Col xs = { 2 } sm = { 12 } md = { 12 } lg = { 12 } xl = { 12 } className = { 'p-1 mx-auto' } >
863
+ { /* <Col xs={2} sm={12} md={12} lg={12} xl={12} className={'p-1 mx-auto'}>
864
+ <OverlayTrigger
865
+ delay={TOOTLIP_DELAY}
866
+ placement={'bottom'}
867
+ overlay={
868
+ <Tooltip id="tooltip-disabled">
869
+ To insert a paragraph break, and split a pargraph in two, put the cursor at a point where you'd want to add a paragraph break in
870
+ the text and either click this button or hit enter key
871
+ </Tooltip>
872
+ }
873
+ >
874
+ <Button disabled={isProcessing} onClick={breakParagraph} variant="light">
875
+ ↵
876
+ </Button>
877
+ </OverlayTrigger>
878
+ </Col> */ }
879
+ { /* <Col xs={2} sm={12} md={12} lg={12} xl={12} className={'p-1 mx-auto'}>
842
880
<OverlayTrigger
843
881
delay={TOOTLIP_DELAY}
844
882
placement={'bottom'}
@@ -850,16 +888,16 @@ export default function SlateTranscriptEditor(props) {
850
888
<FontAwesomeIcon icon={faMehBlank} />
851
889
</Button>
852
890
</OverlayTrigger>
853
- </ Col >
854
- < Col xs = { 2 } sm = { 12 } md = { 12 } lg = { 12 } xl = { 12 } className = { 'p-1 mx-auto' } >
891
+ </Col> */ }
892
+ { /* <Col xs={2} sm={12} md={12} lg={12} xl={12} className={'p-1 mx-auto'}>
855
893
<OverlayTrigger delay={TOOTLIP_DELAY} placement={'bottom'} overlay={<Tooltip id="tooltip-disabled">Insert a ♫ in the text</Tooltip>}>
856
894
<span className="d-inline-block">
857
895
<Button onClick={handleInsertMusicNote} variant={'light'}>
858
896
<FontAwesomeIcon icon={faMusic} />
859
897
</Button>
860
898
</span>
861
899
</OverlayTrigger>
862
- </ Col >
900
+ </Col> */ }
863
901
< Col xs = { 2 } sm = { 12 } md = { 12 } lg = { 12 } xl = { 12 } className = { 'p-1 mx-auto' } >
864
902
< OverlayTrigger
865
903
delay = { TOOTLIP_DELAY }
0 commit comments