Skip to content

Commit 4bce95d

Browse files
author
Pietro Passarelli
committed
Saving progress
1 parent 286687d commit 4bce95d

File tree

3 files changed

+178
-9
lines changed

3 files changed

+178
-9
lines changed

package-lock.json

Lines changed: 123 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"pretty-quick": "^2.0.1"
5454
},
5555
"dependencies": {
56+
"@emotion/css": "^11.1.3",
5657
"@fortawesome/fontawesome-svg-core": "^1.2.15",
5758
"@fortawesome/free-solid-svg-icons": "^5.12.1",
5859
"@fortawesome/react-fontawesome": "^0.1.5",

src/components/index.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { createEditor, Editor, Transforms } from 'slate';
1818
// Import the Slate components and React plugin.
1919
import { Slate, Editable, withReact, ReactEditor } from 'slate-react';
2020
import { withHistory } from 'slate-history';
21+
import { css } from '@emotion/css';
2122
import {
2223
faSave,
2324
faFileDownload,
@@ -71,6 +72,53 @@ export default function SlateTranscriptEditor(props) {
7172
// used isContentModified to avoid unecessarily run alignment if the slate value contnet has not been modified by the user since
7273
// last save or alignment
7374
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+
// );
74122

75123
useEffect(() => {
76124
if (isProcessing) {
@@ -178,6 +226,7 @@ export default function SlateTranscriptEditor(props) {
178226

179227
const handleTimeUpdated = (e) => {
180228
setCurrentTime(e.target.currentTime);
229+
console.log('e.target.currentTime', e.target.currentTime);
181230
// TODO: setting duration here as a workaround
182231
setDuration(mediaRef.current.duration);
183232
};
@@ -213,6 +262,10 @@ export default function SlateTranscriptEditor(props) {
213262
data-start={children.props.parent.start}
214263
data-previous-timings={children.props.parent.previousTimings}
215264
title={children.props.parent.start}
265+
// className={css`
266+
// font-weight: ${leaf.bold && 'bold'};
267+
// background-color: ${leaf.highlight && '#ffeeba'};
268+
// `}
216269
{...attributes}
217270
>
218271
{children}
@@ -611,6 +664,7 @@ export default function SlateTranscriptEditor(props) {
611664
}}
612665
>
613666
<Editable
667+
// decorate={decorate}
614668
readOnly={typeof props.isEditable === 'boolean' ? !props.isEditable : false}
615669
renderElement={renderElement}
616670
renderLeaf={renderLeaf}

0 commit comments

Comments
 (0)