Skip to content

Commit 7a6ccd3

Browse files
committed
fix(video-editor): address CodeRabbit review of region clipboard
- Fix handleCopySelected loop so stale ids fall through to the 'nothing to copy' toast instead of silently returning. - Use regionClipboard.kinds.blur label when copying a blur region. - Add 'blur' to regionClipboard.kinds in all 13 locales; broaden the 'annotation' label to neutral terms in es/fr/it/ja-JP/ko-KR/ pt-BR/ru/tr/zh-CN so the toast no longer reads 'Text' for blurs. - Cover the placement-at-region-start boundary in regionPlacement tests.
1 parent 86a08df commit 7a6ccd3

15 files changed

Lines changed: 42 additions & 19 deletions

File tree

src/components/video-editor/VideoEditor.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,13 +1671,17 @@ export default function VideoEditor() {
16711671
for (const [id, regions, extract, kind] of copyTargets) {
16721672
if (!id) continue;
16731673
const region = (regions as readonly { id: string }[]).find((r) => r.id === id);
1674-
if (region) {
1675-
// Each row pairs a region list with its matching extractor, so the cast is sound.
1676-
setCopiedRegion((extract as (r: never) => CopiedRegion)(region as never));
1677-
toast.success(t("regionClipboard.copied", { region: t(`regionClipboard.kinds.${kind}`) }), {
1674+
if (!region) continue; // Stale id — try the next target so the fallback toast stays reachable.
1675+
// Each row pairs a region list with its matching extractor, so the cast is sound.
1676+
setCopiedRegion((extract as (r: never) => CopiedRegion)(region as never));
1677+
// Blur lives in annotationRegions (type "blur") but its toast must label as "blur", not "text".
1678+
const labelKind = (region as { type?: string }).type === "blur" ? "blur" : kind;
1679+
toast.success(
1680+
t("regionClipboard.copied", { region: t(`regionClipboard.kinds.${labelKind}`) }),
1681+
{
16781682
id: "regionClipboard.copied",
1679-
});
1680-
}
1683+
},
1684+
);
16811685
return;
16821686
}
16831687
toast.info(t("regionClipboard.nothingToCopy"));

src/components/video-editor/regionPlacement.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ describe("findFreeGapAt", () => {
2929
expect(gapMs).toBe(0);
3030
});
3131

32+
it("rejects placement that lands exactly on a region's startMs", () => {
33+
const regions = [{ startMs: 5000, endMs: 7000 }];
34+
const { ok } = findFreeGapAt(regions, 5000, totalMs);
35+
expect(ok).toBe(false);
36+
});
37+
3238
it("allows placement adjacent to (exactly at the end of) an existing region", () => {
3339
const regions = [{ startMs: 0, endMs: 2000 }];
3440
const { ok, gapMs } = findFreeGapAt(regions, 2000, totalMs);

src/i18n/locales/ar/editor.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@
8686
"kinds": {
8787
"zoom": "تكبير",
8888
"speed": "سرعة",
89-
"annotation": "نص"
89+
"annotation": "نص",
90+
"blur": "تمويه"
9091
}
9192
}
9293
}

src/i18n/locales/en/editor.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@
8686
"kinds": {
8787
"zoom": "Zoom",
8888
"speed": "Speed",
89-
"annotation": "Text"
89+
"annotation": "Text",
90+
"blur": "Blur"
9091
}
9192
}
9293
}

src/i18n/locales/es/editor.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@
8686
"kinds": {
8787
"zoom": "Zoom",
8888
"speed": "Velocidad",
89-
"annotation": "Texto"
89+
"annotation": "Anotación",
90+
"blur": "Desenfoque"
9091
}
9192
}
9293
}

src/i18n/locales/fr/editor.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@
8686
"kinds": {
8787
"zoom": "Zoom",
8888
"speed": "Vitesse",
89-
"annotation": "Texte"
89+
"annotation": "Annotation",
90+
"blur": "Flou"
9091
}
9192
}
9293
}

src/i18n/locales/it/editor.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@
7070
"kinds": {
7171
"zoom": "Zoom",
7272
"speed": "Velocità",
73-
"annotation": "Testo"
73+
"annotation": "Annotazione",
74+
"blur": "Sfocatura"
7475
}
7576
}
7677
}

src/i18n/locales/ja-JP/editor.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@
8686
"kinds": {
8787
"zoom": "ズーム",
8888
"speed": "速度",
89-
"annotation": "テキスト"
89+
"annotation": "注釈",
90+
"blur": "ぼかし"
9091
}
9192
}
9293
}

src/i18n/locales/ko-KR/editor.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@
8686
"kinds": {
8787
"zoom": "",
8888
"speed": "속도",
89-
"annotation": "텍스트"
89+
"annotation": "주석",
90+
"blur": "블러"
9091
}
9192
}
9293
}

src/i18n/locales/pt-BR/editor.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@
6969
"kinds": {
7070
"zoom": "Zoom",
7171
"speed": "Velocidade",
72-
"annotation": "Texto"
72+
"annotation": "Anotação",
73+
"blur": "Desfoque"
7374
}
7475
}
7576
}

0 commit comments

Comments
 (0)