Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

Update blur handling

446f6e6e7986a08dfe839e
diff --git a/src/components/video-editor/VideoEditor.tsx b/src/components/video-editor/VideoEditor.tsx
index 1ded512bb..91c9c624f 100644
--- a/src/components/video-editor/VideoEditor.tsx
+++ b/src/components/video-editor/VideoEditor.tsx
@@ -1865,18 +1865,25 @@ export default function VideoEditor() {
}
// Copy/paste region attributes. Skipped while typing in a field so native
- // text copy/paste keeps working.
+ // text copy/paste keeps working. Also only intercepted when there's an
+ // actual region selected (copy) or something on the clipboard (paste);
+ // otherwise the browser handles native copy/paste of any page selection.
const editingText = isTextEditingTarget(e.target);
if (!editingText) {
if (matchesShortcut(e, shortcuts.copySelected, isMac)) {
- e.preventDefault();
- handleCopySelected();
- return;
- }
- if (matchesShortcut(e, shortcuts.paste, isMac)) {
- e.preventDefault();
- handlePaste();
- return;
+ const hasRegionSelected =
+ selectedZoomId || selectedSpeedId || selectedAnnotationId || selectedBlurId;
+ if (hasRegionSelected) {
+ e.preventDefault();
+ handleCopySelected();
+ return;
+ }
+ } else if (matchesShortcut(e, shortcuts.paste, isMac)) {
+ if (getCopiedRegion()) {
+ e.preventDefault();
+ handlePaste();
+ return;
+ }
}
}
@@ -1936,7 +1943,18 @@ export default function VideoEditor() {
window.addEventListener("keydown", handleKeyDown, { capture: true });
return () => window.removeEventListener("keydown", handleKeyDown, { capture: true });
- }, [undo, redo, shortcuts, isMac, handleCopySelected, handlePaste]);
+ }, [
+ undo,
+ redo,
+ shortcuts,
+ isMac,
+ handleCopySelected,
+ handlePaste,
+ selectedZoomId,
+ selectedSpeedId,
+ selectedAnnotationId,
+ selectedBlurId,
+ ]);
useEffect(() => {
if (selectedZoomId && !zoomRegions.some((region) => region.id === selectedZoomId)) {
diff --git a/src/components/video-editor/regionClipboard.ts b/src/components/video-editor/regionClipboard.ts
index b1dd06c8c..876da4387 100644
--- a/src/components/video-editor/regionClipboard.ts
+++ b/src/components/video-editor/regionClipboard.ts
@@ -4,6 +4,7 @@ import type {
AnnotationSize,
AnnotationTextStyle,
AnnotationType,
+ BlurData,
FigureData,
PlaybackSpeed,
Rotation3DPreset,
@@ -35,6 +36,7 @@ export type CopiedAnnotation = {
style: AnnotationTextStyle;
size: AnnotationSize;
figureData?: FigureData;
+ blurData?: BlurData;
// Content & placement — used only when pasting as a brand-new region.
type: AnnotationType;
content: string;
@@ -72,12 +74,22 @@ export function extractSpeedAttributes(region: SpeedRegion): CopiedSpeed {
return { kind: "speed", speed: region.speed };
}
+/** Deep-clones blur data, including its nested freehand points array. */
+function cloneBlurData(blurData?: BlurData): BlurData | undefined {
+ if (!blurData) return undefined;
+ return {
+ ...blurData,
+ freehandPoints: blurData.freehandPoints ? [...blurData.freehandPoints] : undefined,
+ };
+}
+
export function extractAnnotationAttributes(region: AnnotationRegion): CopiedAnnotation {
return {
kind: "annotation",
style: { ...region.style },
size: { ...region.size },
figureData: region.figureData ? { ...region.figureData } : undefined,
+ blurData: cloneBlurData(region.blurData),
type: region.type,
content: region.content,
textContent: region.textContent,
@@ -119,6 +131,9 @@ export function replaceAnnotationAttributes(
// (e.g. pasting a figure's attributes onto a text annotation keeps the text figure-less).
figureData:
region.type === "figure" && attrs.figureData ? { ...attrs.figureData } : region.figureData,
+ // Likewise, only carry blur settings onto a blur target.
+ blurData:
+ region.type === "blur" && attrs.blurData ? cloneBlurData(attrs.blurData) : region.blurData,
};
}
@@ -138,5 +153,6 @@ export function buildPastedAnnotation(
size: { ...attrs.size },
style: { ...attrs.style },
figureData: attrs.figureData ? { ...attrs.figureData } : undefined,
+ blurData: cloneBlurData(attrs.blurData),
};
}
diff --git a/src/components/video-editor/regionPlacement.ts b/src/components/video-editor/regionPlacement.ts
index 7343def0f..673d3fe7f 100644
--- a/src/components/video-editor/regionPlacement.ts
+++ b/src/components/video-editor/regionPlacement.ts
@@ -7,9 +7,9 @@
*
* Placement is valid as long as `startPos` does not fall inside an
* existing region and there is some room before the next one. Landing
- * exactly on the start of an existing region is fine (adjacency is
- * allowed); landing strictly between a region's start and end, or
- * having zero space left before the next region, is not.
+ * exactly on the end of an existing region is fine (adjacency is
+ * allowed); landing on a region's start or strictly between its start
+ * and end, or having zero space left before the next region, is not.
*/
export function findFreeGapAt(
regions: ReadonlyArray<{ startMs: number; endMs: number }>,