Skip to content

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

feat(annotations): create and edit annotations from the inspector

Etienne Lescotd5fd05a25257
diff --git a/src/components/ai-edition/AnnotationLayer.tsx b/src/components/ai-edition/AnnotationLayer.tsx
index 9876158f6..94b688171 100644
--- a/src/components/ai-edition/AnnotationLayer.tsx
+++ b/src/components/ai-edition/AnnotationLayer.tsx
@@ -78,6 +78,7 @@ export function AnnotationLayer({
onSizeChange={onSizeChange}
onBlurDataChange={annotation.type === "blur" ? onBlurDataChange : undefined}
onBlurDataCommit={annotation.type === "blur" ? onCommit : undefined}
+ onCommit={onCommit}
onClick={handleClick}
zIndex={annotation.zIndex}
isSelectedBoost={annotation.id === selectedAnnotationId}
diff --git a/src/components/ai-edition/AnnotationOverlay.tsx b/src/components/ai-edition/AnnotationOverlay.tsx
index 22077eb74..9901a2020 100644
--- a/src/components/ai-edition/AnnotationOverlay.tsx
+++ b/src/components/ai-edition/AnnotationOverlay.tsx
@@ -38,6 +38,13 @@ function buildBlurFreehandPath(points: Array<{ x: number; y: number }>, closed =
return closed ? `${path} Z` : path;
}
+/**
+ * Le compositeur natif est-il responsable des pixels d'annotation ? Constante plutôt que valeur
+ * en dur, pour que le point de bascule soit nommé et qu'on retrouve d'un coup tout ce qui en
+ * dépend le jour où l'on nettoiera le code de peinture devenu inatteignable.
+ */
+const NATIVE_PAINTS_ANNOTATIONS = true;
+
interface AnnotationOverlayProps {
annotation: AxcutAnnotationRegion;
isSelected: boolean;
@@ -47,6 +54,8 @@ interface AnnotationOverlayProps {
onSizeChange: (id: string, size: { width: number; height: number }) => void;
onBlurDataChange?: (id: string, blurData: BlurData) => void;
onBlurDataCommit?: () => void;
+ /** Écriture disque, appelée une fois en fin de geste — le drag/resize ne fait que du live. */
+ onCommit?: () => void;
onClick: (id: string) => void;
zIndex: number;
isSelectedBoost: boolean;
@@ -63,6 +72,7 @@ export function AnnotationOverlay({
onSizeChange,
onBlurDataChange,
onBlurDataCommit,
+ onCommit,
onClick,
zIndex,
isSelectedBoost,
@@ -273,6 +283,17 @@ export function AnnotationOverlay({
};
const renderContent = () => {
+ // Le compositeur natif dessine désormais les quatre types d'annotation, PREVIEW COMPRISE.
+ // Les peindre aussi ici donnait deux copies superposées ; et comme les deux ne suivent pas
+ // la même horloge, celle du DOM collait au curseur pendant qu'un fantôme restait en place
+ // jusqu'au relâchement, avant de se recaler avec un écart de taille. Ce composant ne garde
+ // donc que le chrome d'édition — cadre de sélection et poignées — qui n'a rien à faire
+ // dans le rendu final.
+ //
+ // Le code de peinture ci-dessous est laissé en place, inatteignable : le supprimer touche
+ // à ~400 lignes et à la saisie du tracé libre, qui est de toute façon en cours de retrait.
+ // À nettoyer dans un passage dédié plutôt qu'au milieu d'un correctif.
+ if (NATIVE_PAINTS_ANNOTATIONS) return null;
switch (annotation.type) {
case "text": {
const animationState = getTextAnimationState(annotation, currentTimeMs);
@@ -492,12 +513,20 @@ export function AnnotationOverlay({
}}
onDrag={(_e, d) => {
setLiveRect((prev) => ({ ...prev, x: d.x, y: d.y }));
+ // Pousse la position PENDANT le geste : c'est le natif qui peint, il doit donc suivre
+ // le curseur. `onPositionChange` ne met à jour qu'en mémoire ; l'écriture disque se
+ // fait une seule fois, au relâchement (`onCommit`).
+ onPositionChange(annotation.id, {
+ x: (d.x / containerWidth) * 100,
+ y: (d.y / containerHeight) * 100,
+ });
}}
onDragStop={(_e, d) => {
setLiveRect((prev) => ({ ...prev, x: d.x, y: d.y }));
const xPercent = (d.x / containerWidth) * 100;
const yPercent = (d.y / containerHeight) * 100;
onPositionChange(annotation.id, { x: xPercent, y: yPercent });
+ onCommit?.();
setTimeout(() => {
isDraggingRef.current = false;
}, 100);
@@ -509,6 +538,15 @@ export function AnnotationOverlay({
width: ref.offsetWidth,
height: ref.offsetHeight,
});
+ // Même raison que le drag : le natif doit suivre la poignée en direct.
+ onPositionChange(annotation.id, {
+ x: (position.x / containerWidth) * 100,
+ y: (position.y / containerHeight) * 100,
+ });
+ onSizeChange(annotation.id, {
+ width: (ref.offsetWidth / containerWidth) * 100,
+ height: (ref.offsetHeight / containerHeight) * 100,
+ });
}}
onResizeStop={(_e, _direction, ref, _delta, position) => {
setLiveRect({
@@ -523,6 +561,7 @@ export function AnnotationOverlay({
const heightPercent = (ref.offsetHeight / containerHeight) * 100;
onPositionChange(annotation.id, { x: xPercent, y: yPercent });
onSizeChange(annotation.id, { width: widthPercent, height: heightPercent });
+ onCommit?.();
}}
onClick={() => {
if (isDraggingRef.current) return;
diff --git a/src/components/ai-edition/NewEditorShell.tsx b/src/components/ai-edition/NewEditorShell.tsx
index eb21e5752..04b247edd 100644
--- a/src/components/ai-edition/NewEditorShell.tsx
+++ b/src/components/ai-edition/NewEditorShell.tsx
@@ -1232,12 +1232,13 @@ export function NewEditorShell() {
}
onSelectAnnotation={(id) => tl.selectRegion("annotation", id)}
onAnnotationPositionChange={(id, position) => {
+ // Live seulement : appelé à chaque mouvement de souris pour que le
+ // compositeur natif suive le geste. L'écriture disque se fait une fois,
+ // au relâchement, via `onAnnotationCommit`.
tl.updateAnnotationLive(id, { position });
- void tl.commitAnnotationChange();
}}
onAnnotationSizeChange={(id, size) => {
tl.updateAnnotationLive(id, { size });
- void tl.commitAnnotationChange();
}}
onAnnotationBlurDataChange={(id, blurData) =>
tl.updateAnnotationLive(id, { blurData })
diff --git a/src/components/ai-edition/RightPanes.tsx b/src/components/ai-edition/RightPanes.tsx
index 9e5bc92ce..91d172068 100644
--- a/src/components/ai-edition/RightPanes.tsx
+++ b/src/components/ai-edition/RightPanes.tsx
@@ -1750,7 +1750,10 @@ function Toggle({
);
}
-function SliderCell({
+/** Le slider commun des panneaux — exporté pour que l'inspecteur V4 s'en serve au lieu de
+ * restyler un `<input type="range">` isolé qui ne ressemblait à rien de l'app. Il porte aussi
+ * la bonne cadence : `onChange` en direct, `onCommit` à la fin du geste. */
+export function SliderCell({
label,
value,
min,
diff --git a/src/components/ai-edition/v4/FloatingInspector.tsx b/src/components/ai-edition/v4/FloatingInspector.tsx
index cf2c3513b..716c81bdc 100644
--- a/src/components/ai-edition/v4/FloatingInspector.tsx
+++ b/src/components/ai-edition/v4/FloatingInspector.tsx
@@ -19,7 +19,7 @@ import { toast } from "sonner";
import { parseCustomPlaybackSpeedInput } from "@/components/video-editor/customPlaybackSpeed";
import { MAX_PLAYBACK_SPEED, SPEED_OPTIONS } from "@/components/video-editor/types";
import { useScopedT } from "@/contexts/I18nContext";
-import type { AxcutClip } from "@/lib/ai-edition/schema";
+import type { AxcutAnnotationRegion, AxcutClip } from "@/lib/ai-edition/schema";
import { useEditorSettings } from "@/lib/ai-edition/store/useEditorSettings";
import type { useTimeline } from "@/lib/ai-edition/store/useTimeline";
import { coalescedTrimGroups } from "@/lib/ai-edition/timeline/trim-mapping";
@@ -28,6 +28,7 @@ import {
BackgroundPane,
CursorPane,
LayoutPane,
+ SliderCell,
TranscriptPane,
VideoEffectsPane,
} from "../RightPanes";
@@ -275,6 +276,61 @@ function paneRow(label: string, control: React.ReactNode) {
);
}
+type AnnotationKind = AxcutAnnotationRegion["type"];
+type ArrowDirectionKind = NonNullable<AxcutAnnotationRegion["figureData"]>["arrowDirection"];
+
+/** Les huit directions de `ArrowSvgs.tsx`, dans l'ordre où elles y sont définies. */
+const ARROW_DIRECTIONS: ArrowDirectionKind[] = [
+ "up",
+ "down",
+ "left",
+ "right",
+ "up-right",
+ "up-left",
+ "down-right",
+ "down-left",
+];
+
+/** Défauts du schéma, pour compléter un `blurData` absent sans écraser ce qui existe. */
+const BLUR_DEFAULTS = {
+ type: "mosaic",
+ shape: "rectangle",
+ color: "white",
+ intensity: 12,
+ blockSize: 12,
+} as const;
+
+/**
+ * Patch à appliquer quand l'utilisateur change le type d'une annotation.
+ *
+ * `content` est un slot UNIQUE partagé par le texte et l'image : la zone de saisie y écrit, et le
+ * rendu d'image y lit une data URL. Changer de type sans déplacer la valeur déversait donc le
+ * base64 de l'image, souvent plusieurs mégaoctets, dans le champ texte. Chaque contenu est rangé
+ * dans son slot typé (`textContent` / `imageContent`) en sortant et restauré en entrant, si bien
+ * qu'un aller-retour entre deux types ne perd rien.
+ */
+function convertAnnotationKind(
+ region: AxcutAnnotationRegion,
+ next: AnnotationKind,
+): Partial<AxcutAnnotationRegion> {
+ if (region.type === next) return {};
+ const parked: Partial<AxcutAnnotationRegion> =
+ region.type === "text"
+ ? { textContent: region.content ?? "" }
+ : region.type === "image"
+ ? { imageContent: region.content ?? "" }
+ : {};
+ // Flèche et flou n'ont pas de contenu : on vide `content` plutôt que d'y laisser traîner le
+ // texte ou le base64 du type précédent.
+ const restored =
+ next === "text"
+ ? (region.textContent ?? "")
+ : next === "image"
+ ? (region.imageContent ?? "")
+ : "";
+ return { ...parked, type: next, content: restored };
+}
+
const ZOOM_DEPTHS = [1, 2, 3, 4, 5, 6] as const;
// The ladder the shared editor already ships (`SPEED_OPTIONS`), plus 1× so the select can
// express "back to normal". It stops at 5×; the free field in `SpeedControl` is what reaches
@@ -515,6 +571,9 @@ function SelectionPane({ tl, onClose }: { tl: TimelineApi; onClose: () => void }
const region = tl.annotationRegions.find((a) => a.id === selection.id);
if (!region) return null;
const colors = ["#ffffff", "#0f172a", "#10b981", "#f59e0b", "#f43f5e", "#6366f1"];
+ // `transparent` est la façon dont le CSS — et donc le schéma — dit « pas de fond ».
+ const hasBackground =
+ !!region.style?.backgroundColor && region.style.backgroundColor !== "transparent";
return (
<div style={{ display: "flex", flexDirection: "column", minHeight: 0 }}>
{paneHeader(
@@ -524,58 +583,355 @@ function SelectionPane({ tl, onClose }: { tl: TimelineApi; onClose: () => void }
tc("actions.close"),
)}
<div style={bodyStyle}>
- <div style={{ display: "flex", flexDirection: "column", gap: 6 }}>
- <span style={{ fontSize: 12.5, color: "var(--fg-2)", fontWeight: 500 }}>
- {ts("annotation.textContent")}
- </span>
- <textarea
- value={region.content ?? ""}
- placeholder={ts("annotation.textPlaceholder")}
- onChange={(e) => tl.updateAnnotationLive(region.id, { content: e.target.value })}
- onBlur={() => void tl.commitAnnotationChange()}
- rows={2}
- style={{
- resize: "vertical",
- padding: "8px 10px",
- borderRadius: 9,
- border: "1px solid var(--border)",
- background: "var(--surface)",
- color: "var(--fg)",
- font: "500 13px var(--font-display)",
- }}
- />
- </div>
+ {/* Type switch. Only text annotations could ever be created, so image, arrow and
+ blur were unreachable even though the compositor renders all four and every
+ label here already shipped translated. Converting keeps the span and box, so
+ a mistake costs one more click rather than redrawing the region. */}
{paneRow(
- ts("annotation.color"),
- <div style={{ display: "flex", gap: 6 }}>
- {colors.map((c) => (
- <button
- key={c}
- type="button"
- title={c}
- aria-label={te("inspector.setColor", { color: c })}
- aria-pressed={region.style?.color === c}
- onClick={() => {
+ ts("annotation.title"),
+ <select
+ value={region.type}
+ onChange={(e) => {
+ tl.updateAnnotationLive(
+ region.id,
+ convertAnnotationKind(region, e.target.value as AnnotationKind),
+ );
+ void tl.commitAnnotationChange();
+ }}
+ style={selectStyle}
+ >
+ <option value="text">{ts("annotation.typeText")}</option>
+ <option value="image">{ts("annotation.typeImage")}</option>
+ <option value="figure">{ts("annotation.typeArrow")}</option>
+ <option value="blur">{ts("annotation.typeBlur")}</option>
+ </select>,
+ )}
+ {region.type === "text" ? (
+ <div style={{ display: "flex", flexDirection: "column", gap: 6 }}>
+ <span style={{ fontSize: 12.5, color: "var(--fg-2)", fontWeight: 500 }}>
+ {ts("annotation.textContent")}
+ </span>
+ <textarea
+ value={region.content ?? ""}
+ placeholder={ts("annotation.textPlaceholder")}
+ onChange={(e) => tl.updateAnnotationLive(region.id, { content: e.target.value })}
+ onBlur={() => void tl.commitAnnotationChange()}
+ rows={2}
+ style={{
+ resize: "vertical",
+ padding: "8px 10px",
+ borderRadius: 9,
+ border: "1px solid var(--border)",
+ background: "var(--surface)",
+ color: "var(--fg)",
+ font: "500 13px var(--font-display)",
+ }}
+ />
+ </div>
+ ) : null}
+ {region.type === "image" ? (
+ <div style={{ display: "flex", flexDirection: "column", gap: 6 }}>
+ {/* Read as a data URL, which is what the renderer expects: `content` holds
+ "Separate storage for image data URL" (types.ts) and both the preview
+ overlay and the compositor read it from there. */}
+ <label
+ style={{ ...secondaryBtnStyle, textAlign: "center", cursor: "pointer" }}
+ htmlFor={`ann-img-${region.id}`}
+ >
+ {ts("annotation.uploadImage")}
+ </label>
+ <input
+ id={`ann-img-${region.id}`}
+ type="file"
+ accept="image/jpeg,image/png,image/gif,image/webp"
+ style={{ display: "none" }}
+ onChange={(e) => {
+ const file = e.target.files?.[0];
+ if (!file) return;
+ if (!/^image\/(jpeg|png|gif|webp)$/.test(file.type)) {
+ toast.error(ts("annotation.imageFormatsOnly"));
+ return;
+ }
+ const reader = new FileReader();
+ reader.onload = () => {
+ tl.updateAnnotationLive(region.id, { content: String(reader.result) });
+ void tl.commitAnnotationChange();
+ toast.success(ts("annotation.imageUploadSuccess"));
+ };
+ reader.readAsDataURL(file);
+ }}
+ />
+ <span style={{ font: "400 11px/1.4 var(--font-sans)", color: "var(--fg-2)" }}>
+ {ts("annotation.supportedFormats")}
+ </span>
+ </div>
+ ) : null}
+ {region.type === "figure" ? (
+ <>
+ {paneRow(
+ ts("annotation.arrowDirection"),
+ <select
+ value={region.figureData?.arrowDirection ?? "right"}
+ onChange={(e) => {
+ tl.updateAnnotationLive(region.id, {
+ figureData: {
+ ...(region.figureData ?? { color: "#34B27B", strokeWidth: 4 }),
+ arrowDirection: e.target.value as ArrowDirectionKind,
+ },
+ });
+ void tl.commitAnnotationChange();
+ }}
+ style={selectStyle}
+ >
+ {ARROW_DIRECTIONS.map((d) => (
+ <option key={d} value={d}>
+ {d}
+ </option>
+ ))}
+ </select>,
+ )}
+ {paneRow(
+ ts("annotation.arrowColor"),
+ <input
+ type="color"
+ value={region.figureData?.color ?? "#34B27B"}
+ onChange={(e) =>
tl.updateAnnotationLive(region.id, {
- style: { ...region.style, color: c },
+ figureData: {
+ ...(region.figureData ?? { arrowDirection: "right", strokeWidth: 4 }),
+ color: e.target.value,
+ },
+ })
+ }
+ onBlur={() => void tl.commitAnnotationChange()}
+ style={{ width: 34, height: 28, padding: 0, border: "none", background: "none" }}
+ />,
+ )}
+ <SliderCell
+ label={ts("annotation.strokeWidth", {
+ width: region.figureData?.strokeWidth ?? 4,
+ })}
+ value={region.figureData?.strokeWidth ?? 4}
+ min={1}
+ max={20}
+ onChange={(next) =>
+ tl.updateAnnotationLive(region.id, {
+ figureData: {
+ ...(region.figureData ?? { arrowDirection: "right", color: "#34B27B" }),
+ strokeWidth: next,
+ },
+ })
+ }
+ onCommit={() => void tl.commitAnnotationChange()}
+ />
+ </>
+ ) : null}
+ {region.type === "blur" ? (
+ <>
+ {paneRow(
+ ts("annotation.blurType"),
+ <select
+ value={region.blurData?.type ?? "mosaic"}
+ onChange={(e) => {
+ tl.updateAnnotationLive(region.id, {
+ blurData: {
+ ...(region.blurData ?? BLUR_DEFAULTS),
+ type: e.target.value as "blur" | "mosaic",
+ },
});
void tl.commitAnnotationChange();
}}
+ style={selectStyle}
+ >
+ <option value="blur">{ts("annotation.blurTypeBlur")}</option>
+ <option value="mosaic">{ts("annotation.blurTypeMosaic")}</option>
+ </select>,
+ )}
+ {paneRow(
+ ts("annotation.blurShape"),
+ <select
+ value={region.blurData?.shape ?? "rectangle"}
+ onChange={(e) => {
+ tl.updateAnnotationLive(region.id, {
+ blurData: {
+ ...(region.blurData ?? BLUR_DEFAULTS),
+ shape: e.target.value as "rectangle" | "oval" | "freehand",
+ },
+ });
+ void tl.commitAnnotationChange();
+ }}
+ style={selectStyle}
+ >
+ <option value="rectangle">{ts("annotation.blurShapeRectangle")}</option>
+ <option value="oval">{ts("annotation.blurShapeOval")}</option>
+ {/* Le tracé libre n'est plus proposé à la création : sa saisie était cassée et
+ le rendu ne couvrait que la boîte englobante. Un outil de confidentialité
+ à moitié fiable vaut moins que pas d'outil, parce qu'on lui fait confiance.
+ L'option reste visible pour une annotation qui l'utilise déjà, avec la
+ phrase qui dit ce que le rendu en fait — plutôt que de la faire disparaître
+ d'un projet existant. */}
+ {region.blurData?.shape === "freehand" ? (
+ <option value="freehand">{ts("annotation.blurShapeFreehand")}</option>
+ ) : null}
+ </select>,
+ )}
+ {region.blurData?.shape === "freehand" ? (
+ // Say it rather than let the user discover it: the compositor masks the
+ // bounding box for a freehand shape, deliberately over-covering instead
+ // of leaving anything the user marked private visible in the export.
+ <p
style={{
- width: 22,
- height: 22,
- borderRadius: "50%",
- background: c,
- border:
- region.style?.color === c
- ? "2px solid var(--accent)"
- : "1px solid var(--border-hi)",
- cursor: "pointer",
+ margin: 0,
+ font: "400 11px/1.45 var(--font-sans)",
+ color: "var(--fg-2)",
}}
- />
- ))}
- </div>,
- )}
+ >
+ {te("inspector.freehandRendersAsBox")}
+ </p>
+ ) : null}
+ </>
+ ) : null}
+ {region.type === "text"
+ ? paneRow(
+ ts("annotation.size"),
+ <input
+ type="number"
+ min={8}
+ max={200}
+ step={1}
+ // Le nombre saisi vaut « pixels à 1080 » (cf. annotationScale.ts) : preview et
+ // rendu le multiplient tous deux par la hauteur de leur boîte, donc ce champ
+ // veut dire la même chose des deux côtés.
+ value={region.style?.fontSize ?? 32}
+ onChange={(e) =>
+ tl.updateAnnotationLive(region.id, {
+ style: { ...region.style, fontSize: Number(e.target.value) },
+ })
+ }
+ onBlur={() => void tl.commitAnnotationChange()}
+ style={{ ...selectStyle, width: 84, textAlign: "right" }}
+ />,
+ )
+ : null}
+ {region.type === "text"
+ ? paneRow(
+ ts("annotation.background"),
+ <div style={{ display: "flex", alignItems: "center", gap: 6 }}>
+ <input
+ type="color"
+ value={
+ region.style?.backgroundColor &&
+ region.style.backgroundColor !== "transparent"
+ ? region.style.backgroundColor
+ : "#000000"
+ }
+ // Live pendant le glissement, une seule écriture disque au relâchement :
+ // un `<input type="color">` émet `onChange` en continu, et committer à
+ // chaque événement rendait le sélecteur inutilisable.
+ onChange={(e) =>
+ tl.updateAnnotationLive(region.id, {
+ style: { ...region.style, backgroundColor: e.target.value },
+ })
+ }
+ onBlur={() => void tl.commitAnnotationChange()}
+ style={{
+ width: 34,
+ height: 28,
+ padding: 0,
+ border: "none",
+ background: "none",
+ }}
+ />
+ {/* Une case à cocher plutôt qu'un bouton « effacer » : avoir un fond ou non est
+ un état, pas une action. La couleur choisie est conservée quand on décoche,
+ donc recocher la rend telle quelle au lieu d'obliger à la re-sélectionner. */}
+ <label
+ style={{
+ display: "inline-flex",
+ alignItems: "center",
+ gap: 6,
+ fontSize: 12.5,
+ color: "var(--fg-2)",
+ cursor: "pointer",
+ }}
+ >
+ <input
+ type="checkbox"
+ checked={hasBackground}
+ onChange={(e) => {
+ tl.updateAnnotationLive(region.id, {
+ style: {
+ ...region.style,
+ backgroundColor: e.target.checked
+ ? (region.style?.backgroundColor ?? "#000000") === "transparent"
+ ? "#000000"
+ : (region.style?.backgroundColor ?? "#000000")
+ : "transparent",
+ },
+ });
+ void tl.commitAnnotationChange();
+ }}
+ />
+ {ts("annotation.active")}
+ </label>
+ </div>,
+ )
+ : null}
+ {region.type === "text"
+ ? paneRow(
+ ts("annotation.color"),
+ // Sélecteur système plutôt que six pastilles : le texte d'une annotation doit
+ // pouvoir prendre n'importe quelle couleur, et une palette figée oblige à
+ // choisir parmi ce que quelqu'un d'autre a décidé. Les raccourcis restent à
+ // côté pour les teintes courantes.
+ <div style={{ display: "flex", alignItems: "center", gap: 6 }}>
+ <input
+ type="color"
+ aria-label={ts("annotation.colorWheel")}
+ value={region.style?.color ?? "#ffffff"}
+ onChange={(e) =>
+ tl.updateAnnotationLive(region.id, {
+ style: { ...region.style, color: e.target.value },
+ })
+ }
+ onBlur={() => void tl.commitAnnotationChange()}
+ style={{
+ width: 34,
+ height: 28,
+ padding: 0,
+ border: "none",
+ background: "none",
+ }}
+ />
+ {colors.map((c) => (
+ <button
+ key={c}
+ type="button"
+ title={c}
+ aria-label={te("inspector.setColor", { color: c })}
+ aria-pressed={region.style?.color === c}
+ onClick={() => {
+ tl.updateAnnotationLive(region.id, {
+ style: { ...region.style, color: c },
+ });
+ void tl.commitAnnotationChange();
+ }}
+ style={{
+ width: 18,
+ height: 18,
+ borderRadius: "50%",
+ background: c,
+ border:
+ region.style?.color === c
+ ? "2px solid var(--accent)"
+ : "1px solid var(--border-hi)",
+ cursor: "pointer",
+ }}
+ />
+ ))}
+ </div>,
+ )
+ : null}
<button type="button" onClick={deleteAndClose} style={deleteBtnStyle}>
<Trash2 size={14} />
{ts("annotation.deleteAnnotation")}
diff --git a/src/i18n/locales/ar/editor.json b/src/i18n/locales/ar/editor.json
index 32e2500fa..f5e1a7ddc 100644
--- a/src/i18n/locales/ar/editor.json
+++ b/src/i18n/locales/ar/editor.json
@@ -218,7 +218,8 @@
"cropDescription": "أعد تأطير التسجيل — اختر نسبة العرض إلى الارتفاع وقم بالتكبير على المنطقة التي تريد الاحتفاظ بها.",
"openCrop": "فتح القص…",
"cameraFullscreenDescription": "أثناء تشغيل هذه المنطقة تملأ الكاميرا الإطار بالكامل — بلا حدود ولا استدارة ولا خلفية — ثم تعود بسلاسة في النهاية. اسحب حواف المنطقة على المخطط الزمني لتغيير وقت بدايتها ومدتها.",
- "deleteRegion": "حذف المنطقة"
+ "deleteRegion": "حذف المنطقة",
+ "freehandRendersAsBox": "الشكل الحر يُغطى بمستطيله المحيط في التصدير — تغطية زائدة، وليست ناقصة."
},
"leftPanel": {
"mediaTitle": "الوسائط",
diff --git a/src/i18n/locales/ar/settings.json b/src/i18n/locales/ar/settings.json
index 7b553beeb..1132e5798 100644
--- a/src/i18n/locales/ar/settings.json
+++ b/src/i18n/locales/ar/settings.json
@@ -164,7 +164,7 @@
"strokeWidth": "عرض الخط: {{width}}px",
"arrowColor": "لون السهم",
"blurType": "نوع التمويه",
- "blurTypeBlur": "تمويه",
+ "blurTypeBlur": "غاوسي",
"blurTypeMosaic": "فسيفساء",
"blurColor": "لون التمويه",
"blurColorWhite": "أبيض",
diff --git a/src/i18n/locales/en/editor.json b/src/i18n/locales/en/editor.json
index d07999ae3..aa3fd48fb 100644
--- a/src/i18n/locales/en/editor.json
+++ b/src/i18n/locales/en/editor.json
@@ -218,7 +218,8 @@
"cropDescription": "Reframe the recording — pick an aspect ratio and zoom into the region you want to keep.",
"openCrop": "Open crop…",
"cameraFullscreenDescription": "While this region plays, the camera takes the whole frame — no border, no rounding, no background — and eases back at the end. Drag the region's edges on the timeline to change when it starts and how long it lasts.",
- "deleteRegion": "Delete region"
+ "deleteRegion": "Delete region",
+ "freehandRendersAsBox": "In the export, a freehand shape is covered by its bounding box — over-covered, never under."
},
"leftPanel": {
"mediaTitle": "Media",
diff --git a/src/i18n/locales/en/settings.json b/src/i18n/locales/en/settings.json
index 3d9b623f2..5cb834889 100644
--- a/src/i18n/locales/en/settings.json
+++ b/src/i18n/locales/en/settings.json
@@ -164,8 +164,8 @@
"strokeWidth": "Stroke Width: {{width}}px",
"arrowColor": "Arrow Color",
"blurType": "Blur Type",
- "blurTypeBlur": "Blur",
- "blurTypeMosaic": "Mosaic Blur",
+ "blurTypeBlur": "Gaussian",
+ "blurTypeMosaic": "Mosaic",
"blurColor": "Blur Color",
"blurColorWhite": "White",
"blurColorBlack": "Black",
diff --git a/src/i18n/locales/es/editor.json b/src/i18n/locales/es/editor.json
index 7caaf8e1e..3fc863588 100644
--- a/src/i18n/locales/es/editor.json
+++ b/src/i18n/locales/es/editor.json
@@ -218,7 +218,8 @@
"cropDescription": "Reencuadra la grabación: elige una relación de aspecto y haz zoom en la región que deseas conservar.",
"openCrop": "Abrir recorte…",
"cameraFullscreenDescription": "Mientras se reproduce esta región, la cámara ocupa todo el cuadro —sin borde, sin redondeo, sin fondo— y vuelve suavemente al final. Arrastra los bordes de la región en la línea de tiempo para cambiar cuándo empieza y cuánto dura.",
- "deleteRegion": "Eliminar región"
+ "deleteRegion": "Eliminar región",
+ "freehandRendersAsBox": "En la exportación, una forma libre se cubre con su caja contenedora: cubre de más, nunca de menos."
},
"leftPanel": {
"mediaTitle": "Medios",
diff --git a/src/i18n/locales/es/settings.json b/src/i18n/locales/es/settings.json
index 846d7071c..dc6a51c76 100644
--- a/src/i18n/locales/es/settings.json
+++ b/src/i18n/locales/es/settings.json
@@ -164,8 +164,8 @@
"strokeWidth": "Grosor del trazo: {{width}}px",
"arrowColor": "Color de la flecha",
"blurType": "Tipo de desenfoque",
- "blurTypeBlur": "Desenfoque",
- "blurTypeMosaic": "Desenfoque mosaico",
+ "blurTypeBlur": "Gaussiano",
+ "blurTypeMosaic": "Mosaico",
"blurColor": "Color del desenfoque",
"blurColorWhite": "Blanco",
"blurColorBlack": "Negro",
diff --git a/src/i18n/locales/fr/editor.json b/src/i18n/locales/fr/editor.json
index 3dab52641..3f84a8550 100644
--- a/src/i18n/locales/fr/editor.json
+++ b/src/i18n/locales/fr/editor.json
@@ -218,7 +218,8 @@
"cropDescription": "Recadrer l'enregistrement — choisissez un format et zoomez sur la région à conserver.",
"openCrop": "Ouvrir le recadrage…",
"cameraFullscreenDescription": "Pendant cette zone, la caméra occupe tout le cadre — sans bordure, sans arrondi, sans arrière-plan — puis revient en douceur à la fin. Faites glisser les bords de la zone sur la timeline pour changer son début et sa durée.",
- "deleteRegion": "Supprimer la zone"
+ "deleteRegion": "Supprimer la zone",
+ "freehandRendersAsBox": "À l'export, un tracé libre est couvert par sa boîte englobante — on couvre trop, jamais trop peu."
},
"leftPanel": {
"mediaTitle": "Médias",
diff --git a/src/i18n/locales/fr/settings.json b/src/i18n/locales/fr/settings.json
index d3bcf5854..15aaf4e52 100644
--- a/src/i18n/locales/fr/settings.json
+++ b/src/i18n/locales/fr/settings.json
@@ -164,8 +164,8 @@
"strokeWidth": "Épaisseur du trait : {{width}}px",
"arrowColor": "Couleur de la flèche",
"blurType": "Type de flou",
- "blurTypeBlur": "Flou",
- "blurTypeMosaic": "Flou mosaique",
+ "blurTypeBlur": "Gaussien",
+ "blurTypeMosaic": "Mosaïque",
"blurColor": "Couleur du flou",
"blurColorWhite": "Blanc",
"blurColorBlack": "Noir",
diff --git a/src/i18n/locales/it/editor.json b/src/i18n/locales/it/editor.json
index 68c877585..fa1365d28 100644
--- a/src/i18n/locales/it/editor.json
+++ b/src/i18n/locales/it/editor.json
@@ -218,7 +218,8 @@
"cropDescription": "Reinquadra la registrazione — scegli un rapporto d'aspetto e ingrandisci l'area da mantenere.",
"openCrop": "Apri ritaglio…",
"cameraFullscreenDescription": "Mentre questa regione è in riproduzione, la camera occupa l'intero fotogramma — senza bordo, senza arrotondamento, senza sfondo — e rientra dolcemente alla fine. Trascina i bordi della regione sulla timeline per cambiarne l'inizio e la durata.",
- "deleteRegion": "Elimina regione"
+ "deleteRegion": "Elimina regione",
+ "freehandRendersAsBox": "Nell'esportazione, una forma libera è coperta dal suo rettangolo di delimitazione: copre di più, mai di meno."
},
"leftPanel": {
"mediaTitle": "Contenuti multimediali",
diff --git a/src/i18n/locales/it/settings.json b/src/i18n/locales/it/settings.json
index 293d7f200..62e4a6781 100644
--- a/src/i18n/locales/it/settings.json
+++ b/src/i18n/locales/it/settings.json
@@ -164,8 +164,8 @@
"strokeWidth": "Larghezza tratto: {{width}}px",
"arrowColor": "Colore freccia",
"blurType": "Tipo sfocatura",
- "blurTypeBlur": "Sfocatura",
- "blurTypeMosaic": "Sfocatura mosaico",
+ "blurTypeBlur": "Gaussiano",
+ "blurTypeMosaic": "Mosaico",
"blurColor": "Colore sfocatura",
"blurColorWhite": "Bianco",
"blurColorBlack": "Nero",
diff --git a/src/i18n/locales/ja-JP/editor.json b/src/i18n/locales/ja-JP/editor.json
index 75669e76c..de6283dc1 100644
--- a/src/i18n/locales/ja-JP/editor.json
+++ b/src/i18n/locales/ja-JP/editor.json
@@ -218,7 +218,8 @@
"cropDescription": "録画をリフレーム — アスペクト比を選び、保持したい範囲にズームします。",
"openCrop": "切り抜きを開く…",
"cameraFullscreenDescription": "この区間の再生中は、カメラが画面全体を占めます(枠・角丸・背景なし)。終わりでは滑らかに元に戻ります。タイムライン上で区間の端をドラッグすると、開始位置と長さを変更できます。",
- "deleteRegion": "区間を削除"
+ "deleteRegion": "区間を削除",
+ "freehandRendersAsBox": "書き出しでは、フリーハンドの形は外接する矩形で覆われます。覆いすぎることはあっても、足りないことはありません。"
},
"leftPanel": {
"mediaTitle": "メディア",
diff --git a/src/i18n/locales/ja-JP/settings.json b/src/i18n/locales/ja-JP/settings.json
index d9de9bf14..ffcff9c3c 100644
--- a/src/i18n/locales/ja-JP/settings.json
+++ b/src/i18n/locales/ja-JP/settings.json
@@ -164,8 +164,8 @@
"strokeWidth": "線の太さ: {{width}}px",
"arrowColor": "矢印の色",
"blurType": "ぼかしの種類",
- "blurTypeBlur": "ぼかし",
- "blurTypeMosaic": "モザイクぼかし",
+ "blurTypeBlur": "ガウス",
+ "blurTypeMosaic": "モザイク",
"blurColor": "ぼかしの色",
"blurColorWhite": "白",
"blurColorBlack": "黒",
diff --git a/src/i18n/locales/ko-KR/editor.json b/src/i18n/locales/ko-KR/editor.json
index 5e88691c6..ed83e85e9 100644
--- a/src/i18n/locales/ko-KR/editor.json
+++ b/src/i18n/locales/ko-KR/editor.json
@@ -218,7 +218,8 @@
"cropDescription": "녹화 화면을 다시 프레이밍 — 화면 비율을 선택하고 유지할 영역으로 확대합니다.",
"openCrop": "자르기 열기…",
"cameraFullscreenDescription": "이 구간이 재생되는 동안 카메라가 화면 전체를 채웁니다. 테두리, 둥근 모서리, 배경이 없으며 끝에서 부드럽게 돌아옵니다. 타임라인에서 구간의 가장자리를 끌어 시작 위치와 길이를 조정하세요.",
- "deleteRegion": "구간 삭제"
+ "deleteRegion": "구간 삭제",
+ "freehandRendersAsBox": "내보내기에서 자유형 도형은 외곽 사각형으로 덮입니다. 더 많이 덮되, 부족하게 덮지는 않습니다."
},
"leftPanel": {
"mediaTitle": "미디어",
diff --git a/src/i18n/locales/ko-KR/settings.json b/src/i18n/locales/ko-KR/settings.json
index 123c1ed60..80ef36cbd 100644
--- a/src/i18n/locales/ko-KR/settings.json
+++ b/src/i18n/locales/ko-KR/settings.json
@@ -164,8 +164,8 @@
"strokeWidth": "선 두께: {{width}}px",
"arrowColor": "화살표 색상",
"blurType": "블러 종류",
- "blurTypeBlur": "블러",
- "blurTypeMosaic": "모자이크 블러",
+ "blurTypeBlur": "가우시안",
+ "blurTypeMosaic": "모자이크",
"blurColor": "블러 색상",
"blurColorWhite": "흰색",
"blurColorBlack": "검정",
diff --git a/src/i18n/locales/pt-BR/editor.json b/src/i18n/locales/pt-BR/editor.json
index 44ed2ed79..165426e4e 100644
--- a/src/i18n/locales/pt-BR/editor.json
+++ b/src/i18n/locales/pt-BR/editor.json
@@ -218,7 +218,8 @@
"cropDescription": "Reenquadre a gravação — escolha uma proporção e dê zoom na região que deseja manter.",
"openCrop": "Abrir corte…",
"cameraFullscreenDescription": "Enquanto esta região é reproduzida, a câmera ocupa o quadro inteiro — sem borda, sem arredondamento, sem fundo — e volta suavemente no fim. Arraste as bordas da região na linha do tempo para mudar quando ela começa e quanto dura.",
- "deleteRegion": "Excluir região"
+ "deleteRegion": "Excluir região",
+ "freehandRendersAsBox": "Na exportação, uma forma livre é coberta pela sua caixa delimitadora — cobre demais, nunca de menos."
},
"leftPanel": {
"mediaTitle": "Mídia",
diff --git a/src/i18n/locales/pt-BR/settings.json b/src/i18n/locales/pt-BR/settings.json
index d5af323e8..9108aa593 100644
--- a/src/i18n/locales/pt-BR/settings.json
+++ b/src/i18n/locales/pt-BR/settings.json
@@ -164,7 +164,7 @@
"strokeWidth": "Largura do Traço: {{width}}px",
"arrowColor": "Cor da Seta",
"blurType": "Tipo de Desfoque",
- "blurTypeBlur": "Desfoque",
+ "blurTypeBlur": "Gaussiano",
"blurTypeMosaic": "Mosaico",
"blurColor": "Cor do Desfoque",
"blurColorWhite": "Branco",
diff --git a/src/i18n/locales/ru/editor.json b/src/i18n/locales/ru/editor.json
index d238125a9..06592ef81 100644
--- a/src/i18n/locales/ru/editor.json
+++ b/src/i18n/locales/ru/editor.json
@@ -218,7 +218,8 @@
"cropDescription": "Перекадрируйте запись — выберите соотношение сторон и увеличьте область, которую нужно сохранить.",
"openCrop": "Открыть обрезку…",
"cameraFullscreenDescription": "Пока играет этот участок, камера занимает весь кадр — без рамки, скруглений и фона — и плавно возвращается в конце. Перетаскивайте края участка на таймлайне, чтобы изменить его начало и длительность.",
- "deleteRegion": "Удалить участок"
+ "deleteRegion": "Удалить участок",
+ "freehandRendersAsBox": "При экспорте произвольная форма закрывается своим ограничивающим прямоугольником — с запасом, а не с недостатком."
},
"leftPanel": {
"mediaTitle": "Медиа",
diff --git a/src/i18n/locales/ru/settings.json b/src/i18n/locales/ru/settings.json
index 3b5b91361..688e26c16 100644
--- a/src/i18n/locales/ru/settings.json
+++ b/src/i18n/locales/ru/settings.json
@@ -164,8 +164,8 @@
"strokeWidth": "Толщина линии: {{width}}px",
"arrowColor": "Цвет стрелки",
"blurType": "Тип размытия",
- "blurTypeBlur": "Размытие",
- "blurTypeMosaic": "Мозаичное размытие",
+ "blurTypeBlur": "Гауссово",
+ "blurTypeMosaic": "Мозаика",
"blurColor": "Цвет размытия",
"blurColorWhite": "Белый",
"blurColorBlack": "Чёрный",
diff --git a/src/i18n/locales/tr/editor.json b/src/i18n/locales/tr/editor.json
index 957315e93..d0b927586 100644
--- a/src/i18n/locales/tr/editor.json
+++ b/src/i18n/locales/tr/editor.json
@@ -218,7 +218,8 @@
"cropDescription": "Kaydı yeniden çerçeveleyin — bir en boy oranı seçin ve saklamak istediğiniz bölgeye yakınlaşın.",
"openCrop": "Kırpmayı aç…",
"cameraFullscreenDescription": "Bu bölge oynarken kamera tüm kareyi kaplar — kenarlık, yuvarlatma ve arka plan olmadan — ve sonunda yumuşakça geri döner. Ne zaman başlayacağını ve ne kadar süreceğini değiştirmek için zaman çizelgesinde bölgenin kenarlarını sürükleyin.",
- "deleteRegion": "Bölgeyi sil"
+ "deleteRegion": "Bölgeyi sil",
+ "freehandRendersAsBox": "Dışa aktarmada serbest çizim, sınırlayıcı dikdörtgeniyle kapatılır — eksik değil, fazla kapatır."
},
"leftPanel": {
"mediaTitle": "Medya",
diff --git a/src/i18n/locales/tr/settings.json b/src/i18n/locales/tr/settings.json
index 007fa8759..124eba364 100644
--- a/src/i18n/locales/tr/settings.json
+++ b/src/i18n/locales/tr/settings.json
@@ -180,8 +180,8 @@
"blurColorBlack": "Siyah",
"blurColorWhite": "Beyaz",
"blurType": "Bulanıklık Türü",
- "blurTypeBlur": "Bulanık",
- "blurTypeMosaic": "Mozaik Bulanıklık",
+ "blurTypeBlur": "Gauss",
+ "blurTypeMosaic": "Mozaik",
"mosaicBlockSize": "Mozaik Blok Boyutu"
},
"fontStyles": {
diff --git a/src/i18n/locales/vi/editor.json b/src/i18n/locales/vi/editor.json
index 092824dee..5b16f995b 100644
--- a/src/i18n/locales/vi/editor.json
+++ b/src/i18n/locales/vi/editor.json
@@ -218,7 +218,8 @@
"cropDescription": "Đóng khung lại bản ghi — chọn tỷ lệ khung hình và phóng to vào vùng bạn muốn giữ lại.",
"openCrop": "Mở cắt…",
"cameraFullscreenDescription": "Khi vùng này phát, máy quay chiếm trọn khung hình — không viền, không bo góc, không nền — rồi trở lại mượt mà ở cuối. Kéo hai mép của vùng trên dòng thời gian để thay đổi thời điểm bắt đầu và độ dài.",
- "deleteRegion": "Xóa vùng"
+ "deleteRegion": "Xóa vùng",
+ "freehandRendersAsBox": "Khi xuất, hình vẽ tay được che bằng khung bao của nó — che dư, không bao giờ che thiếu."
},
"leftPanel": {
"mediaTitle": "Media",
diff --git a/src/i18n/locales/vi/settings.json b/src/i18n/locales/vi/settings.json
index 90bb6b988..09da2ce4f 100644
--- a/src/i18n/locales/vi/settings.json
+++ b/src/i18n/locales/vi/settings.json
@@ -162,7 +162,7 @@
"strokeWidth": "Độ dày nét: {{width}}px",
"arrowColor": "Màu mũi tên",
"blurType": "Loại làm mờ",
- "blurTypeBlur": "Làm mờ",
+ "blurTypeBlur": "Gaussian",
"blurTypeMosaic": "Khảm",
"blurColor": "Màu làm mờ",
"blurColorWhite": "Trắng",
diff --git a/src/i18n/locales/zh-CN/editor.json b/src/i18n/locales/zh-CN/editor.json
index ac53cf0e4..b9c0ebe2f 100644
--- a/src/i18n/locales/zh-CN/editor.json
+++ b/src/i18n/locales/zh-CN/editor.json
@@ -218,7 +218,8 @@
"cropDescription": "重新构图录制内容 — 选择宽高比并缩放到要保留的区域。",
"openCrop": "打开裁剪…",
"cameraFullscreenDescription": "该区间播放时,摄像头会占满整个画面 — 没有边框、圆角和背景 — 并在结束时平滑还原。在时间轴上拖动区间边缘可调整其起始位置和时长。",
- "deleteRegion": "删除区间"
+ "deleteRegion": "删除区间",
+ "freehandRendersAsBox": "导出时,手绘形状会以其外接矩形遮挡——宁可多遮,绝不少遮。"
},
"leftPanel": {
"mediaTitle": "媒体",
diff --git a/src/i18n/locales/zh-CN/settings.json b/src/i18n/locales/zh-CN/settings.json
index a8acb6380..fe2cfd47b 100644
--- a/src/i18n/locales/zh-CN/settings.json
+++ b/src/i18n/locales/zh-CN/settings.json
@@ -180,8 +180,8 @@
"blurColorBlack": "黑色",
"blurColorWhite": "白色",
"blurType": "模糊类型",
- "blurTypeBlur": "模糊",
- "blurTypeMosaic": "马赛克模糊",
+ "blurTypeBlur": "高斯",
+ "blurTypeMosaic": "马赛克",
"mosaicBlockSize": "马赛克块大小"
},
"fontStyles": {
diff --git a/src/i18n/locales/zh-TW/editor.json b/src/i18n/locales/zh-TW/editor.json
index 3411b6021..478e4ef33 100644
--- a/src/i18n/locales/zh-TW/editor.json
+++ b/src/i18n/locales/zh-TW/editor.json
@@ -218,7 +218,8 @@
"cropDescription": "重新構圖錄製內容 — 選擇長寬比並縮放至想保留的區域。",
"openCrop": "開啟裁切…",
"cameraFullscreenDescription": "此區間播放時,攝影機會佔滿整個畫面 — 沒有邊框、圓角與背景 — 並在結束時平順還原。在時間軸上拖曳區間邊緣,即可調整開始位置與長度。",
- "deleteRegion": "刪除區間"
+ "deleteRegion": "刪除區間",
+ "freehandRendersAsBox": "匯出時,手繪形狀會以其外接矩形遮蔽——寧可多遮,絕不少遮。"
},
"leftPanel": {
"mediaTitle": "媒體",
diff --git a/src/i18n/locales/zh-TW/settings.json b/src/i18n/locales/zh-TW/settings.json
index 3a627499b..3873c450a 100644
--- a/src/i18n/locales/zh-TW/settings.json
+++ b/src/i18n/locales/zh-TW/settings.json
@@ -181,8 +181,8 @@
"blurColorBlack": "黑色",
"blurColorWhite": "白色",
"blurType": "模糊類型",
- "blurTypeBlur": "模糊",
- "blurTypeMosaic": "馬賽克模糊",
+ "blurTypeBlur": "高斯",
+ "blurTypeMosaic": "馬賽克",
"mosaicBlockSize": "馬賽克區塊大小"
},
"fontStyles": {
diff --git a/src/native/sceneDescription.test.ts b/src/native/sceneDescription.test.ts
index d88007bcc..8249c5d5f 100644
--- a/src/native/sceneDescription.test.ts
+++ b/src/native/sceneDescription.test.ts
@@ -1243,7 +1243,7 @@ describe("buildSceneDescription.annotations", () => {
});
});
- it("carries the text payload, preferring textContent over the legacy content field", () => {
+ it("carries the text payload, reading the field the inspector actually writes", () => {
const scene = buildSceneDescription(
docWithAnnotations([
{
@@ -1260,8 +1260,12 @@ describe("buildSceneDescription.annotations", () => {
},
]),
);
+ // `content` wins: that is the field the inspector's textarea writes to. Asserting the
+ // other way round is what let the empty-string bug through -- `addAnnotation` seeds
+ // `textContent: ""`, so a `??` chain returned that empty string and the compositor drew
+ // nothing.
expect(scene.annotations[0].text).toMatchObject({
- content: "live",
+ content: "migrated",
color: "#ffffff",
backgroundColor: "transparent",
// 32 px authored against ANNOTATION_REFERENCE_HEIGHT (1080) -> fraction of the rect.
@@ -1271,6 +1275,28 @@ describe("buildSceneDescription.annotations", () => {
});
});
+ it("falls back to textContent when content is empty", () => {
+ // Le cas qui casse avec `??` : `content` vaut "" (ni null ni undefined), donc seul un
+ // `||` retombe sur l'autre champ.
+ const scene = buildSceneDescription(
+ docWithAnnotations([
+ {
+ id: "ann1",
+ startMs: 0,
+ endMs: 1000,
+ type: "text",
+ content: "",
+ textContent: "depuis un ancien document",
+ position: { x: 0, y: 0 },
+ size: { width: 10, height: 10 },
+ style,
+ zIndex: 0,
+ },
+ ]),
+ );
+ expect(scene.annotations[0].text?.content).toBe("depuis un ancien document");
+ });
+
it("defaults a figure's arrow data when the document omits it", () => {
const scene = buildSceneDescription(
docWithAnnotations([
diff --git a/src/native/sceneDescription.ts b/src/native/sceneDescription.ts
index a4214c8d7..868722229 100644
--- a/src/native/sceneDescription.ts
+++ b/src/native/sceneDescription.ts
@@ -706,9 +706,13 @@ export function buildSceneDescription(
return {
...base,
text: {
- // `textContent` is the live field the inspector edits; `content` is the
- // older single-field form still present on migrated documents.
- content: region.textContent ?? region.content ?? "",
+ // `content` first, and with `||` rather than `??`. The inspector's textarea
+ // writes to `content`; `textContent` is the parallel slot, which
+ // `addAnnotation` initialises to "". Since "" is neither null nor undefined,
+ // `textContent ?? content` returned that empty string for every annotation
+ // created since — so the compositor was handed nothing to draw and text
+ // vanished from the preview the moment the DOM overlay stopped painting it.
+ content: region.content || region.textContent || "",
color: style.color,
backgroundColor: style.backgroundColor,
fontSizeRel: annotationFontSizeFraction(style.fontSize),