Skip to content

Commit 6ae73f1

Browse files
author
Pietro Passarelli
committed
Adding list of words in slateJs paragraphs
1 parent 438b10d commit 6ae73f1

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/util/dpe-to-slate/index.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ import { shortTimecode } from '../timecode-converter';
2121

2222
export const generatePreviousTimings = (time) => {
2323
// https://stackoverflow.com/questions/3746725/how-to-create-an-array-containing-1-n
24-
return [...Array(parseInt(time)).keys()];
24+
if (time) {
25+
return [...Array(parseInt(time)).keys()];
26+
} else {
27+
return [0];
28+
}
2529
};
2630

2731
/**
@@ -68,6 +72,8 @@ const convertDpeToSlate = (transcript) => {
6872
children: [
6973
{
7074
text: 'Text',
75+
// Adding list of words in slateJs paragraphs
76+
words: [],
7177
},
7278
],
7379
},
@@ -83,7 +89,13 @@ const convertDpeToSlate = (transcript) => {
8389
// pre-computing the display of the formatting here so that it doesn't need to convert it in leaf render
8490
startTimecode: shortTimecode(paragraph.start),
8591
type: 'timedText',
86-
children: [{ text: generateText(paragraph, words) }],
92+
children: [
93+
{
94+
text: generateText(paragraph, words),
95+
// Adding list of words in slateJs paragraphs
96+
words,
97+
},
98+
],
8799
}));
88100
};
89101

0 commit comments

Comments
 (0)