()
| 60 | ] as const; |
| 61 | |
| 62 | export function TranscriptPanel() { |
| 63 | const { |
| 64 | editorState, |
| 65 | setEditorState, |
| 66 | project, |
| 67 | setProject, |
| 68 | editorInstance, |
| 69 | meta, |
| 70 | totalDuration, |
| 71 | previewResolutionBase, |
| 72 | } = useEditorContext(); |
| 73 | |
| 74 | const recordingSegments = () => editorInstance.recordings.segments; |
| 75 | |
| 76 | const [textSizeIndex, setTextSizeIndex] = makePersisted(createSignal(1), { |
| 77 | name: "editorTranscriptTextSize", |
| 78 | }); |
| 79 | const [exportingFormat, setExportingFormat] = |
| 80 | createSignal<CaptionExportFormat | null>(null); |
| 81 | |
| 82 | const exportableCues = createMemo(() => |
| 83 | createCaptionExportCues( |
| 84 | project.captions?.segments ?? [], |
| 85 | project.timeline?.segments ?? [], |
| 86 | recordingSegments(), |
| 87 | ), |
| 88 | ); |
| 89 | |
| 90 | const allWords = createMemo((): FlatWord[] => { |
| 91 | const segments = project.captions?.segments ?? []; |
| 92 | const result: FlatWord[] = []; |
| 93 | for (let segIdx = 0; segIdx < segments.length; segIdx++) { |
| 94 | const seg = segments[segIdx]; |
| 95 | const words = seg.words ?? []; |
| 96 | for (let wordIdx = 0; wordIdx < words.length; wordIdx++) { |
| 97 | const w = words[wordIdx]; |
| 98 | result.push({ |
| 99 | text: w.text, |
| 100 | start: w.start, |
| 101 | end: w.end, |
| 102 | segmentIndex: segIdx, |
| 103 | wordIndex: wordIdx, |
| 104 | }); |
| 105 | } |
| 106 | } |
| 107 | return result; |
| 108 | }); |
| 109 | |
| 110 | const segmentGroups = createMemo((): TranscriptSegmentGroup[] => { |
| 111 | const flatWords = allWords(); |
| 112 | return (project.captions?.segments ?? []).map((_segment, segmentIndex) => ({ |
| 113 | segmentIndex, |
| 114 | words: flatWords.filter((word) => word.segmentIndex === segmentIndex), |
| 115 | })); |
| 116 | }); |
| 117 | |
| 118 | const updateWordText = (flatIndex: number, rawText: string) => { |
| 119 | const target = allWords()[flatIndex]; |
nothing calls this directly
no test coverage detected