Skip to content

Commit

Permalink
add copy to paraphrased segment button
Browse files Browse the repository at this point in the history
  • Loading branch information
kartikvirendrar committed Sep 9, 2024
1 parent f5bf7e8 commit 02984c3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/containers/Organization/Video/ParaphraseRightPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ import {
setSubtitles,
} from "redux/actions";
import GlossaryDialog from "common/GlossaryDialog";
import { bookmarkSegment, onExpandTimeline, paraphrase } from "utils/subtitleUtils";
import { bookmarkSegment, onCopyToParaphrasedSegment, onExpandTimeline, paraphrase } from "utils/subtitleUtils";
import LoopIcon from "@mui/icons-material/Loop";
import { ArrowForward } from "@mui/icons-material";

const ParaphraseRightPanel = ({ currentIndex, currentSubs,setCurrentIndex, showTimeline, segment }) => {
const { taskId } = useParams();
Expand Down Expand Up @@ -301,6 +302,11 @@ const ParaphraseRightPanel = ({ currentIndex, currentSubs,setCurrentIndex, showT
// eslint-disable-next-line
}, [currentIndexToSplitTextBlock, selectionStart, limit, currentOffset]);

const copyToParaphrasedText = useCallback((index) => {
const sub = onCopyToParaphrasedSegment(index);
dispatch(setSubtitles(sub, C.SUBTITLES));
}, [limit, currentOffset]);

useEffect(() => {
setSourceText(subtitles);
}, [subtitles]);
Expand Down Expand Up @@ -808,6 +814,7 @@ const ParaphraseRightPanel = ({ currentIndex, currentSubs,setCurrentIndex, showT
type={"endTime"}
/>
{currentIndex === index &&
<div style={{display:"flex"}}>
<Tooltip title="Paraphrase Segment" placement="bottom">
<IconButton
className={classes.optionIconBtn}
Expand All @@ -818,6 +825,16 @@ const ParaphraseRightPanel = ({ currentIndex, currentSubs,setCurrentIndex, showT
<LoopIcon className={classes.rightPanelSvg} />
</IconButton>
</Tooltip>
<Tooltip title="Copy to Paraphrased Segment" placement="bottom">
<IconButton
className={classes.optionIconBtn}
onClick={() => copyToParaphrasedText(index)}
style={{ marginTop: "10px"}}
>
<ArrowForward className={classes.rightPanelSvg} />
</IconButton>
</Tooltip>
</div>
}
</div>

Expand Down
6 changes: 6 additions & 0 deletions src/utils/subtitleUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ export const onSubtitleDelete = (index) => {
return copySub;
};

export const onCopyToParaphrasedSegment = (index) => {
const subtitles = store.getState().commonReducer.subtitles;
subtitles[index].paraphrased_text = subtitles[index].text;
return subtitles;
};

export const onSplit = (
currentIndex,
selectionStart,
Expand Down

0 comments on commit 02984c3

Please sign in to comment.