@@ -18,6 +18,7 @@ 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 { css } from '@emotion/css' ;
21
22
import {
22
23
faSave ,
23
24
faFileDownload ,
@@ -71,6 +72,53 @@ export default function SlateTranscriptEditor(props) {
71
72
// used isContentModified to avoid unecessarily run alignment if the slate value contnet has not been modified by the user since
72
73
// last save or alignment
73
74
const [ isContentModified , setIsContentIsModified ] = useState ( false ) ;
75
+ const [ search , setSearch ] = useState ( ) ;
76
+ // const getCurrrentTime = () => {
77
+ // return currentTime;
78
+ // };
79
+ // const decorate = useCallback(
80
+ // ([node, path]) => {
81
+ // console.log('decorate', node, path);
82
+ // const currentTime = 20; //getCurrrentTime();
83
+ // console.log('currentTime', currentTime);
84
+ // const ranges = [];
85
+ // // currentTime
86
+
87
+ // // if (currentTime && Text.isText(node)) {
88
+ // if (node.children && node.children[0] && node.children[0].words) {
89
+ // console.log('inside if');
90
+ // const previousWords = node.children[0].words.filter((word) => {
91
+ // return word.start <= currentTime;
92
+ // });
93
+ // console.log('previousWords', previousWords);
94
+ // // if (search && Text.isText(node)) {
95
+ // // const { text } = node;
96
+ // // const parts = text.split(search);
97
+ // // let offset = 0;
98
+ // if (previousWords) {
99
+ // ranges.push({
100
+ // anchor: { path, offset: previousWords.length },
101
+ // focus: { path, offset: previousWords.length },
102
+ // highlight: true,
103
+ // });
104
+ // }
105
+
106
+ // // parts.forEach((part, i) => {
107
+ // // if (i !== 0) {
108
+ // // ranges.push({
109
+ // // anchor: { path, offset: offset - search.length },
110
+ // // focus: { path, offset },
111
+ // // highlight: true,
112
+ // // });
113
+ // // }
114
+
115
+ // // offset = offset + part.length + search.length;
116
+ // // });
117
+ // }
118
+ // return ranges;
119
+ // },
120
+ // [search]
121
+ // );
74
122
75
123
useEffect ( ( ) => {
76
124
if ( isProcessing ) {
@@ -178,6 +226,7 @@ export default function SlateTranscriptEditor(props) {
178
226
179
227
const handleTimeUpdated = ( e ) => {
180
228
setCurrentTime ( e . target . currentTime ) ;
229
+ console . log ( 'e.target.currentTime' , e . target . currentTime ) ;
181
230
// TODO: setting duration here as a workaround
182
231
setDuration ( mediaRef . current . duration ) ;
183
232
} ;
@@ -213,6 +262,10 @@ export default function SlateTranscriptEditor(props) {
213
262
data-start = { children . props . parent . start }
214
263
data-previous-timings = { children . props . parent . previousTimings }
215
264
title = { children . props . parent . start }
265
+ // className={css`
266
+ // font-weight: ${leaf.bold && 'bold'};
267
+ // background-color: ${leaf.highlight && '#ffeeba'};
268
+ // `}
216
269
{ ...attributes }
217
270
>
218
271
{ children }
@@ -611,6 +664,7 @@ export default function SlateTranscriptEditor(props) {
611
664
} }
612
665
>
613
666
< Editable
667
+ // decorate={decorate}
614
668
readOnly = { typeof props . isEditable === 'boolean' ? ! props . isEditable : false }
615
669
renderElement = { renderElement }
616
670
renderLeaf = { renderLeaf }
0 commit comments