🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots 📖
TypeScript browser-extensionchrome-extensiondocumentationfirefox-extensionguide-generatorlocal-firstmanifest-v3privacy-firstproductivityreactscreenshotstep-by-step-guidetutorialtypescriptworkflowwxt
feat(editor): restructure the editor into mode, tool and property tiers
Luis Ortiz9d17b97472fd
diff --git a/src/core/screenshot/geometry.ts b/src/core/screenshot/geometry.tsindex f3637ff..6a30f66 100644--- a/src/core/screenshot/geometry.ts+++ b/src/core/screenshot/geometry.ts@@ -99,6 +99,7 @@ export type Handle = 'nw' | 'ne' | 'sw' | 'se';export function annotationBounds(a: Annotation): ScreenshotBounds {switch (a.type) {case 'box':+ case 'ellipse':case 'redact':case 'target':return { x: a.x, y: a.y, width: a.w, height: a.h };@@ -134,6 +135,7 @@ export function hitTest(annotations: Annotation[], x: number, y: number): Annotaexport function moveAnnotation(a: Annotation, dx: number, dy: number): Annotation {switch (a.type) {case 'box':+ case 'ellipse':case 'redact':case 'target':case 'text':@@ -146,7 +148,7 @@ export function moveAnnotation(a: Annotation, dx: number, dy: number): Annotatio}export function resizeAnnotation(a: Annotation, handle: Handle, dx: number, dy: number): Annotation {- if (a.type !== 'box' && a.type !== 'redact' && a.type !== 'target') return a;+ if (a.type !== 'box' && a.type !== 'ellipse' && a.type !== 'redact' && a.type !== 'target') return a;const left = handle === 'nw' || handle === 'sw';const top = handle === 'nw' || handle === 'ne';return {diff --git a/src/core/screenshot/render.ts b/src/core/screenshot/render.tsindex d980538..492f42a 100644--- a/src/core/screenshot/render.ts+++ b/src/core/screenshot/render.ts@@ -1,6 +1,7 @@import type { Screenshot } from '@/core/guides/types';import { resolveTarget, resolveViewport } from './geometry';-import type { Annotation } from './types';+import type { Annotation, ArrowEnd } from './types';+import { LINE_WIDTHS } from './types';const TARGET_STROKE = 3.5;const TARGET_RADIUS = 12;@@ -27,13 +28,85 @@ function drawRoundedRect(ctx.closePath();}+function drawArrowEnd(+ ctx: OffscreenCanvasRenderingContext2D,+ x1: number,+ y1: number,+ x2: number,+ y2: number,+ width: number,+ end: ArrowEnd,+) {+ if (end === 'none') return;+ const angle = Math.atan2(y2 - y1, x2 - x1);+ const size = width * 4;+ ctx.save();+ ctx.translate(x2, y2);+ ctx.rotate(angle);+ ctx.beginPath();+ switch (end) {+ case 'bar':+ ctx.moveTo(0, -size / 2);+ ctx.lineTo(0, size / 2);+ ctx.stroke();+ break;+ case 'arrow':+ ctx.moveTo(-size, -size / 2);+ ctx.lineTo(0, 0);+ ctx.lineTo(-size, size / 2);+ ctx.stroke();+ break;+ case 'arrow-solid':+ ctx.moveTo(0, 0);+ ctx.lineTo(-size, -size / 2);+ ctx.lineTo(-size, size / 2);+ ctx.closePath();+ ctx.fill();+ break;+ case 'circle':+ ctx.arc(0, 0, size / 2, 0, Math.PI * 2);+ ctx.stroke();+ break;+ case 'circle-solid':+ ctx.arc(0, 0, size / 2, 0, Math.PI * 2);+ ctx.fill();+ break;+ case 'square':+ ctx.rect(-size / 2, -size / 2, size, size);+ ctx.stroke();+ break;+ case 'square-solid':+ ctx.rect(-size / 2, -size / 2, size, size);+ ctx.fill();+ break;+ }+ ctx.restore();+}+function drawAnnotation(ctx: OffscreenCanvasRenderingContext2D, a: Annotation, originX: number, originY: number) {ctx.save();switch (a.type) {case 'box':+ ctx.lineWidth = LINE_WIDTHS[a.lineWidth ?? 'small'];+ if (a.fill && a.fill !== 'transparent') {+ ctx.fillStyle = a.fill;+ drawRoundedRect(ctx, a.x, a.y, a.w, a.h, a.radius ?? 0);+ ctx.fill();+ }ctx.strokeStyle = a.color;- ctx.lineWidth = 3;- ctx.strokeRect(a.x, a.y, a.w, a.h);+ drawRoundedRect(ctx, a.x, a.y, a.w, a.h, a.radius ?? 0);+ ctx.stroke();+ break;+ case 'ellipse':+ ctx.lineWidth = LINE_WIDTHS[a.lineWidth ?? 'small'];+ ctx.beginPath();+ ctx.ellipse(a.x + a.w / 2, a.y + a.h / 2, Math.abs(a.w / 2), Math.abs(a.h / 2), 0, 0, Math.PI * 2);+ if (a.fill && a.fill !== 'transparent') {+ ctx.fillStyle = a.fill;+ ctx.fill();+ }+ ctx.strokeStyle = a.color;+ ctx.stroke();break;case 'target':ctx.strokeStyle = a.color;@@ -43,31 +116,26 @@ function drawAnnotation(ctx: OffscreenCanvasRenderingContext2D, a: Annotation, octx.stroke();break;case 'arrow': {- const head = 14;- const angle = Math.atan2(a.y2 - a.y1, a.x2 - a.x1);+ const w = LINE_WIDTHS[a.lineWidth ?? 'small'];ctx.strokeStyle = a.color;ctx.fillStyle = a.color;- ctx.lineWidth = 3;+ ctx.lineWidth = w;+ ctx.lineCap = 'round';ctx.beginPath();ctx.moveTo(a.x1, a.y1);ctx.lineTo(a.x2, a.y2);ctx.stroke();- ctx.beginPath();- ctx.moveTo(a.x2, a.y2);- ctx.lineTo(a.x2 - head * Math.cos(angle - Math.PI / 6), a.y2 - head * Math.sin(angle - Math.PI / 6));- ctx.lineTo(a.x2 - head * Math.cos(angle + Math.PI / 6), a.y2 - head * Math.sin(angle + Math.PI / 6));- ctx.closePath();- ctx.fill();+ drawArrowEnd(ctx, a.x1, a.y1, a.x2, a.y2, w, a.end ?? 'arrow-solid');break;}case 'text':ctx.fillStyle = a.color;- ctx.font = `600 ${a.size}px Poppins, sans-serif`;+ ctx.font = `${a.weight ?? 600} ${a.size}px Poppins, sans-serif`;ctx.fillText(a.text, a.x, a.y);break;case 'freehand':ctx.strokeStyle = a.color;- ctx.lineWidth = 4;+ ctx.lineWidth = LINE_WIDTHS[a.lineWidth ?? 'medium'];ctx.lineJoin = 'round';ctx.lineCap = 'round';ctx.beginPath();diff --git a/src/core/screenshot/types.ts b/src/core/screenshot/types.tsindex ba4cc3d..88aa598 100644--- a/src/core/screenshot/types.ts+++ b/src/core/screenshot/types.ts@@ -20,11 +20,80 @@ export interface ClickTarget extends ScreenshotBounds {color: string;}+export type LineWidth = 'small' | 'medium' | 'large';++export const LINE_WIDTHS: Record<LineWidth, number> = { small: 3, medium: 6, large: 10 };++export type ArrowEnd = 'none' | 'bar' | 'arrow' | 'arrow-solid' | 'circle' | 'circle-solid' | 'square' | 'square-solid';++export const ARROW_ENDS: ArrowEnd[] = [+ 'none',+ 'bar',+ 'arrow',+ 'arrow-solid',+ 'circle',+ 'circle-solid',+ 'square',+ 'square-solid',+];++export const SHAPE_COLORS = [+ 'transparent',+ '#FFFFFF',+ '#D4D4D8',+ '#71717A',+ '#000000',+ '#1E1B4B',+ '#2563EB',+ '#7DD3FC',+ '#2DD4BF',+ '#059669',+ '#22C55E',+ '#FACC15',+ '#F97316',+ '#EF4444',+ '#831843',+ '#EC4899',+ '#A855F7',+] as const;+export type Annotation =- | { id: string; type: 'box'; x: number; y: number; w: number; h: number; color: string }- | { id: string; type: 'arrow'; x1: number; y1: number; x2: number; y2: number; color: string }- | { id: string; type: 'text'; x: number; y: number; text: string; color: string; size: number }- | { id: string; type: 'freehand'; points: number[]; color: string }+ | {+ id: string;+ type: 'box';+ x: number;+ y: number;+ w: number;+ h: number;+ color: string;+ fill?: string;+ lineWidth?: LineWidth;+ radius?: number;+ }+ | {+ id: string;+ type: 'ellipse';+ x: number;+ y: number;+ w: number;+ h: number;+ color: string;+ fill?: string;+ lineWidth?: LineWidth;+ }+ | {+ id: string;+ type: 'arrow';+ x1: number;+ y1: number;+ x2: number;+ y2: number;+ color: string;+ lineWidth?: LineWidth;+ end?: ArrowEnd;+ }+ | { id: string; type: 'text'; x: number; y: number; text: string; color: string; size: number; weight?: number }+ | { id: string; type: 'freehand'; points: number[]; color: string; lineWidth?: LineWidth }| { id: string; type: 'redact'; x: number; y: number; w: number; h: number; style: 'blur' | 'solid' }| { id: string; type: 'target'; x: number; y: number; w: number; h: number; color: string; border: TargetBorder };diff --git a/src/locales/en.yml b/src/locales/en.ymlindex a16be2b..db361ed 100644--- a/src/locales/en.yml+++ b/src/locales/en.yml@@ -188,6 +188,29 @@ annotationEditor:textPlaceholder: Type something...targetColor: Target colortargetBorder: Border style+ modeAnnotate: "Annotate"+ toolEraser: "Eraser"+ toolEllipse: "Ellipse"+ lineColor: "line color"+ fillColor: "fill color"+ noFill: "none"+ lineWidth: "line width"+ width_small: "Small"+ width_medium: "Medium"+ width_large: "Large"+ cornerRadius: "corner radius"+ arrowEnd: "end"+ fontSize: "font size"+ undo: "Undo"+ redo: "Redo"+ end_none: "None"+ end_bar: "Bar"+ end_arrow: "Arrow"+ end_arrow_solid: "Arrow solid"+ end_circle: "Circle"+ end_circle_solid: "Circle solid"+ end_square: "Square"+ end_square_solid: "Square solid"done: DoneexportMenu:diff --git a/src/locales/es.yml b/src/locales/es.ymlindex de3c3ff..43addc5 100644--- a/src/locales/es.yml+++ b/src/locales/es.yml@@ -188,6 +188,29 @@ annotationEditor:textPlaceholder: Escribe algo...targetColor: Color del objetivotargetBorder: Estilo del borde+ modeAnnotate: "Anotar"+ toolEraser: "Borrador"+ toolEllipse: "Elipse"+ lineColor: "color de línea"+ fillColor: "relleno"+ noFill: "ninguno"+ lineWidth: "grosor"+ width_small: "Fino"+ width_medium: "Medio"+ width_large: "Grueso"+ cornerRadius: "radio"+ arrowEnd: "punta"+ fontSize: "tamaño"+ undo: "Deshacer"+ redo: "Rehacer"+ end_none: "Ninguna"+ end_bar: "Barra"+ end_arrow: "Flecha"+ end_arrow_solid: "Flecha sólida"+ end_circle: "Círculo"+ end_circle_solid: "Círculo sólido"+ end_square: "Cuadrado"+ end_square_solid: "Cuadrado sólido"done: ListoexportMenu:diff --git a/src/locales/fr.yml b/src/locales/fr.ymlindex 87b1ec3..de1380f 100644--- a/src/locales/fr.yml+++ b/src/locales/fr.yml@@ -188,6 +188,29 @@ annotationEditor:textPlaceholder: "Écrivez quelque chose..."targetColor: Couleur de la cibletargetBorder: Style de bordure+ modeAnnotate: "Annoter"+ toolEraser: "Gomme"+ toolEllipse: "Ellipse"+ lineColor: "couleur"+ fillColor: "remplissage"+ noFill: "aucun"+ lineWidth: "épaisseur"+ width_small: "Fin"+ width_medium: "Moyen"+ width_large: "Épais"+ cornerRadius: "rayon"+ arrowEnd: "extrémité"+ fontSize: "taille"+ undo: "Annuler"+ redo: "Rétablir"+ end_none: "Aucune"+ end_bar: "Barre"+ end_arrow: "Flèche"+ end_arrow_solid: "Flèche pleine"+ end_circle: "Cercle"+ end_circle_solid: "Cercle plein"+ end_square: "Carré"+ end_square_solid: "Carré plein"done: "Terminé"exportMenu:diff --git a/src/locales/pt-BR.yml b/src/locales/pt-BR.ymlindex 0a27d31..95799ff 100644--- a/src/locales/pt-BR.yml+++ b/src/locales/pt-BR.yml@@ -188,6 +188,29 @@ annotationEditor:textPlaceholder: Digite algo...targetColor: Cor do alvotargetBorder: Estilo da borda+ modeAnnotate: "Anotar"+ toolEraser: "Borracha"+ toolEllipse: "Elipse"+ lineColor: "cor da linha"+ fillColor: "preenchimento"+ noFill: "nenhum"+ lineWidth: "espessura"+ width_small: "Fina"+ width_medium: "Média"+ width_large: "Grossa"+ cornerRadius: "raio"+ arrowEnd: "ponta"+ fontSize: "tamanho"+ undo: "Desfazer"+ redo: "Refazer"+ end_none: "Nenhuma"+ end_bar: "Barra"+ end_arrow: "Seta"+ end_arrow_solid: "Seta sólida"+ end_circle: "Círculo"+ end_circle_solid: "Círculo sólido"+ end_square: "Quadrado"+ end_square_solid: "Quadrado sólido"done: ProntoexportMenu:diff --git a/src/ui/shared/AnnotationEditor.tsx b/src/ui/shared/AnnotationEditor.tsxindex ba1df7b..47768a4 100644--- a/src/ui/shared/AnnotationEditor.tsx+++ b/src/ui/shared/AnnotationEditor.tsx@@ -1,14 +1,19 @@import {ArrowUpRight,Check,+ Circle as CircleIcon,Crop,+ Eraser,EyeOff,MousePointer2,+ Pencil,PenTool,+ Redo2,Square,SquareDashed,Trash2,Type,+ Undo2,X,} from 'lucide-react';import type { ComponentType } from 'react';@@ -25,10 +30,11 @@ import {resizeAnnotation,resolveTarget,} from '@/core/screenshot/geometry';-import type { Annotation, ScreenshotEdits, TargetBorder } from '@/core/screenshot/types';-import { TARGET_COLORS } from '@/core/screenshot/types';+import type { Annotation, ArrowEnd, LineWidth, ScreenshotEdits, TargetBorder } from '@/core/screenshot/types';+import { ARROW_ENDS, SHAPE_COLORS, TARGET_COLORS } from '@/core/screenshot/types';-type EditorTool = 'select' | 'box' | 'arrow' | 'text' | 'freehand' | 'redact' | 'crop';+type EditorMode = 'crop' | 'annotate' | 'redact';+type EditorTool = 'select' | 'eraser' | 'box' | 'ellipse' | 'arrow' | 'text' | 'freehand';interface AnnotationEditorProps {screenshot: Screenshot;@@ -56,29 +62,44 @@ const MIN_SHAPE_SIZE = 6;const MIN_CROP_SIZE = 20;const HANDLE_DISPLAY_SIZE = 10;const HANDLE_HIT_PX = 10;+const HISTORY_LIMIT = 49;const SELECTION_GAP = 6;const DRAFT_ID = 'draft';const TARGET_ID = 'click-target';+const MODES: { id: EditorMode; icon: ComponentType<{ size?: number }>; labelKey: string }[] = [+ { id: 'crop', icon: Crop, labelKey: 'annotationEditor.toolCrop' },+ { id: 'annotate', icon: Pencil, labelKey: 'annotationEditor.modeAnnotate' },+ { id: 'redact', icon: EyeOff, labelKey: 'annotationEditor.toolRedact' },+];+const TOOLS: { id: EditorTool; icon: ComponentType<{ size?: number }>; labelKey: string }[] = [{ id: 'select', icon: MousePointer2, labelKey: 'annotationEditor.toolSelect' },- { id: 'box', icon: Square, labelKey: 'annotationEditor.toolBox' },+ { id: 'eraser', icon: Eraser, labelKey: 'annotationEditor.toolEraser' },{ id: 'arrow', icon: ArrowUpRight, labelKey: 'annotationEditor.toolArrow' },+ { id: 'box', icon: Square, labelKey: 'annotationEditor.toolBox' },+ { id: 'ellipse', icon: CircleIcon, labelKey: 'annotationEditor.toolEllipse' },{ id: 'text', icon: Type, labelKey: 'annotationEditor.toolText' },{ id: 'freehand', icon: PenTool, labelKey: 'annotationEditor.toolFreehand' },- { id: 'redact', icon: EyeOff, labelKey: 'annotationEditor.toolRedact' },- { id: 'crop', icon: Crop, labelKey: 'annotationEditor.toolCrop' },];-function initialToolFor(tool: 'annotate' | 'redact' | 'crop' | 'target'): EditorTool {+const LINE_WIDTH_OPTIONS: LineWidth[] = ['small', 'medium', 'large'];++function initialModeFor(tool: 'annotate' | 'redact' | 'crop' | 'target'): EditorMode {if (tool === 'redact') return 'redact';if (tool === 'crop') return 'crop';+ return 'annotate';+}++function initialToolFor(tool: 'annotate' | 'redact' | 'crop' | 'target'): EditorTool {if (tool === 'target') return 'select';return 'box';}-function cursorFor(tool: EditorTool): string {+function cursorFor(mode: EditorMode, tool: EditorTool): string {+ if (mode !== 'annotate') return 'crosshair';if (tool === 'select') return 'default';+ if (tool === 'eraser') return 'pointer';if (tool === 'text') return 'text';return 'crosshair';}@@ -193,6 +214,36 @@ export default function AnnotationEditor({ screenshot, tool, onDone, onCancel }:const [bitmap, setBitmap] = useState<ImageBitmap | null>(null);const [saving, setSaving] = useState(false);const [targetPicker, setTargetPicker] = useState(false);+ const [mode, setMode] = useState<EditorMode>(initialModeFor(tool));+ const [fill, setFill] = useState('transparent');+ const [lineWidth, setLineWidth] = useState<LineWidth>('small');+ const [radius, setRadius] = useState(0);+ const [arrowEnd, setArrowEnd] = useState<ArrowEnd>('arrow-solid');+ const [textSize, setTextSize] = useState(DEFAULT_TEXT_SIZE);+ const [past, setPast] = useState<Annotation[][]>([]);+ const [future, setFuture] = useState<Annotation[][]>([]);++ const annotationsRef = useRef(annotations);+ annotationsRef.current = annotations;++ const pushHistory = useCallback(() => {+ setPast((p) => [...p.slice(-HISTORY_LIMIT), annotationsRef.current]);+ setFuture([]);+ }, []);++ const undo = () => {+ if (!past.length) return;+ setFuture((f) => [annotationsRef.current, ...f]);+ setAnnotations(past[past.length - 1]);+ setPast((p) => p.slice(0, -1));+ };++ const redo = () => {+ if (!future.length) return;+ setPast((p) => [...p, annotationsRef.current]);+ setAnnotations(future[0]);+ setFuture((f) => f.slice(1));+ };const selected = annotations.find((a) => a.id === selectedId);const selectedTarget = selected?.type === 'target' ? selected : null;@@ -246,13 +297,14 @@ export default function AnnotationEditor({ screenshot, tool, onDone, onCancel }:setSelectedId(null);} else if ((e.key === 'Delete' || e.key === 'Backspace') && selectedId) {e.preventDefault();+ pushHistory();setAnnotations((prev) => prev.filter((a) => a.id !== selectedId));setSelectedId(null);}};window.addEventListener('keydown', handler);return () => window.removeEventListener('keydown', handler);- }, [selectedId]);+ }, [selectedId, pushHistory]);useLayoutEffect(() => {const canvas = canvasRef.current;@@ -304,12 +356,14 @@ export default function AnnotationEditor({ screenshot, tool, onDone, onCancel }:const scale = getScale();const handle = hitHandle(selectionBounds(selected, scale), p.x, p.y, HANDLE_HIT_PX * scale);if (handle) {+ pushHistory();dragRef.current = { mode: 'resize', id: selected.id, handle, lastX: p.x, lastY: p.y };return;}}const hit = hitTest(annotations, p.x, p.y);if (hit) {+ pushHistory();setSelectedId(hit.id);dragRef.current = { mode: 'move', id: hit.id, lastX: p.x, lastY: p.y };} else {@@ -318,18 +372,34 @@ export default function AnnotationEditor({ screenshot, tool, onDone, onCancel }:return;}- if (activeTool === 'crop') {+ if (mode === 'crop') {const rect: ScreenshotBounds = { x: p.x, y: p.y, width: 0, height: 0 };dragRef.current = { mode: 'crop', start: p, rect };setCropDraft(rect);return;}+ if (mode === 'redact') {+ const shape: Annotation = { id: DRAFT_ID, type: 'redact', x: p.x, y: p.y, w: 0, h: 0, style: 'blur' };+ dragRef.current = { mode: 'draw', start: p, shape };+ setDraft(shape);+ return;+ }++ if (activeTool === 'eraser') {+ const hit = hitTest(annotations, p.x, p.y);+ if (hit && hit.id !== TARGET_ID) {+ pushHistory();+ setAnnotations((prev) => prev.filter((a) => a.id !== hit.id));+ }+ return;+ }+if (activeTool === 'text') {const rect = canvasRef.current?.getBoundingClientRect();setTextEditor({x: p.x,- y: p.y + DEFAULT_TEXT_SIZE,+ y: p.y + textSize,left: rect ? e.clientX - rect.left : 0,top: rect ? e.clientY - rect.top : 0,});@@ -339,13 +409,13 @@ export default function AnnotationEditor({ screenshot, tool, onDone, onCancel }:let shape: Annotation;if (activeTool === 'box') {- shape = { id: DRAFT_ID, type: 'box', x: p.x, y: p.y, w: 0, h: 0, color };+ shape = { id: DRAFT_ID, type: 'box', x: p.x, y: p.y, w: 0, h: 0, color, fill, lineWidth, radius };+ } else if (activeTool === 'ellipse') {+ shape = { id: DRAFT_ID, type: 'ellipse', x: p.x, y: p.y, w: 0, h: 0, color, fill, lineWidth };} else if (activeTool === 'arrow') {- shape = { id: DRAFT_ID, type: 'arrow', x1: p.x, y1: p.y, x2: p.x, y2: p.y, color };- } else if (activeTool === 'freehand') {- shape = { id: DRAFT_ID, type: 'freehand', points: [p.x, p.y], color };+ shape = { id: DRAFT_ID, type: 'arrow', x1: p.x, y1: p.y, x2: p.x, y2: p.y, color, lineWidth, end: arrowEnd };} else {- shape = { id: DRAFT_ID, type: 'redact', x: p.x, y: p.y, w: 0, h: 0, style: 'blur' };+ shape = { id: DRAFT_ID, type: 'freehand', points: [p.x, p.y], color, lineWidth };}dragRef.current = { mode: 'draw', start: p, shape };setDraft(shape);@@ -388,7 +458,7 @@ export default function AnnotationEditor({ screenshot, tool, onDone, onCancel }:const shape = drag.shape;let next: Annotation = shape;- if (shape.type === 'box' || shape.type === 'redact') {+ if (shape.type === 'box' || shape.type === 'ellipse' || shape.type === 'redact') {next = {...shape,x: Math.min(drag.start.x, p.x),@@ -455,7 +525,7 @@ export default function AnnotationEditor({ screenshot, tool, onDone, onCancel }:y: textEditor.y,text: textValue.trim(),color,- size: DEFAULT_TEXT_SIZE,+ size: textSize,},]);}@@ -491,6 +561,25 @@ export default function AnnotationEditor({ screenshot, tool, onDone, onCancel }:<div className="px-4 py-2.5 bg-primary flex items-center justify-between shrink-0"><span className="text-xs font-medium text-primary-foreground">{i18n.t('annotationEditor.title')}</span><div className="flex items-center gap-1.5">+ <button+ type="button"+ onClick={undo}+ disabled={past.length === 0}+ title={i18n.t('annotationEditor.undo')}+ className="flex items-center justify-center w-7 h-7 rounded-lg text-primary-foreground hover:bg-primary-foreground/15 disabled:opacity-30"+ >+ <Undo2 size={13} />+ </button>+ <button+ type="button"+ onClick={redo}+ disabled={future.length === 0}+ title={i18n.t('annotationEditor.redo')}+ className="flex items-center justify-center w-7 h-7 rounded-lg text-primary-foreground hover:bg-primary-foreground/15 disabled:opacity-30"+ >+ <Redo2 size={13} />+ </button>+ <div className="w-px h-5 bg-primary-foreground/15 mx-1" /><buttontype="button"onClick={onCancel}@@ -511,39 +600,6 @@ export default function AnnotationEditor({ screenshot, tool, onDone, onCancel }:</div></div><div className="flex-1 flex overflow-hidden">- <div className="w-14 shrink-0 bg-card border-r border-border flex flex-col items-center gap-1.5 py-3 overflow-y-auto">- {TOOLS.map(({ id, icon: Icon, labelKey }) => (- <button- key={id}- type="button"- onClick={() => setActiveTool(id)}- title={i18n.t(labelKey)}- className={`flex items-center justify-center w-9 h-9 rounded-md transition-colors ${- activeTool === id- ? 'bg-accent text-primary-foreground'- : 'text-foreground hover:bg-secondary hover:text-accent'- }`}- >- <Icon size={16} />- </button>- ))}- <div className="w-8 h-px bg-border my-1.5" />- <fieldset- className="flex flex-col items-center gap-1.5 border-0 p-0 m-0"- aria-label={i18n.t('annotationEditor.colorLabel')}- >- {COLORS.map((c) => (- <button- key={c}- type="button"- onClick={() => handleColorSelect(c)}- title={c}- className={`w-6 h-6 rounded-full border-2 transition-colors ${color === c ? 'border-accent' : 'border-transparent'}`}- style={{ backgroundColor: c }}- />- ))}- </fieldset>- </div><div className="flex-1 flex items-center justify-center overflow-auto p-6"><div className="relative inline-block"><canvas@@ -551,7 +607,7 @@ export default function AnnotationEditor({ screenshot, tool, onDone, onCancel }:width={screenshot.width}height={screenshot.height}className="block max-w-full max-h-[calc(100vh-140px)] rounded-lg shadow-2xl touch-none"- style={{ cursor: cursorFor(activeTool) }}+ style={{ cursor: cursorFor(mode, activeTool) }}onPointerDown={handlePointerDown}onPointerMove={handlePointerMove}onPointerUp={handlePointerUp}@@ -638,6 +694,135 @@ export default function AnnotationEditor({ screenshot, tool, onDone, onCancel }:</div></div></div>+ <div className="shrink-0 bg-card border-t border-border px-4 py-3 flex flex-col items-center gap-2.5">+ {mode === 'annotate' && (+ <div className="flex items-end gap-5 min-h-[46px]">+ <label className="flex flex-col items-center gap-1 text-[10px] font-semibold text-muted-foreground">+ {i18n.t('annotationEditor.lineColor')}+ <input+ type="color"+ value={color}+ onChange={(e) => handleColorSelect(e.target.value)}+ className="w-7 h-7 rounded-full border border-border bg-transparent p-0 cursor-pointer"+ />+ </label>+ {(activeTool === 'box' || activeTool === 'ellipse') && (+ <label className="flex flex-col items-center gap-1 text-[10px] font-semibold text-muted-foreground">+ {i18n.t('annotationEditor.fillColor')}+ <select+ value={fill}+ onChange={(e) => setFill(e.target.value)}+ className="h-7 rounded-lg border border-border bg-card px-1.5 text-[11px] text-foreground outline-none"+ style={{ color: fill === 'transparent' ? undefined : fill }}+ >+ {SHAPE_COLORS.map((c) => (+ <option key={c} value={c}>+ {c === 'transparent' ? i18n.t('annotationEditor.noFill') : c}+ </option>+ ))}+ </select>+ </label>+ )}+ {activeTool !== 'text' && (+ <label className="flex flex-col items-center gap-1 text-[10px] font-semibold text-muted-foreground">+ {i18n.t('annotationEditor.lineWidth')}+ <select+ value={lineWidth}+ onChange={(e) => setLineWidth(e.target.value as LineWidth)}+ className="h-7 rounded-lg border border-border bg-card px-1.5 text-[11px] text-foreground outline-none capitalize"+ >+ {LINE_WIDTH_OPTIONS.map((w) => (+ <option key={w} value={w}>+ {i18n.t(`annotationEditor.width_${w}`)}+ </option>+ ))}+ </select>+ </label>+ )}+ {activeTool === 'box' && (+ <label className="flex flex-col items-center gap-1 text-[10px] font-semibold text-muted-foreground">+ {i18n.t('annotationEditor.cornerRadius')}+ <input+ type="range"+ min={0}+ max={60}+ value={radius}+ onChange={(e) => setRadius(Number(e.target.value))}+ className="w-24 h-7 accent-accent"+ />+ </label>+ )}+ {activeTool === 'arrow' && (+ <label className="flex flex-col items-center gap-1 text-[10px] font-semibold text-muted-foreground">+ {i18n.t('annotationEditor.arrowEnd')}+ <select+ value={arrowEnd}+ onChange={(e) => setArrowEnd(e.target.value as ArrowEnd)}+ className="h-7 rounded-lg border border-border bg-card px-1.5 text-[11px] text-foreground outline-none"+ >+ {ARROW_ENDS.map((end) => (+ <option key={end} value={end}>+ {i18n.t(`annotationEditor.end_${end.replace('-', '_')}`)}+ </option>+ ))}+ </select>+ </label>+ )}+ {activeTool === 'text' && (+ <label className="flex flex-col items-center gap-1 text-[10px] font-semibold text-muted-foreground">+ {i18n.t('annotationEditor.fontSize')}+ <input+ type="range"+ min={12}+ max={96}+ value={textSize}+ onChange={(e) => setTextSize(Number(e.target.value))}+ className="w-24 h-7 accent-accent"+ />+ </label>+ )}+ </div>+ )}++ {mode === 'annotate' && (+ <div className="flex items-center gap-1">+ {TOOLS.map(({ id, icon: Icon, labelKey }) => (+ <button+ key={id}+ type="button"+ onClick={() => setActiveTool(id)}+ className={`flex items-center gap-1.5 px-3 h-8 rounded-lg text-[12px] font-medium transition-colors ${+ activeTool === id ? 'bg-secondary text-accent' : 'text-foreground hover:bg-secondary/60'+ }`}+ >+ <Icon size={14} />+ {i18n.t(labelKey)}+ </button>+ ))}+ </div>+ )}++ <div className="flex items-center gap-2">+ {MODES.map(({ id, icon: Icon, labelKey }) => (+ <button+ key={id}+ type="button"+ onClick={() => {+ setMode(id);+ setSelectedId(null);+ }}+ className={`flex flex-col items-center justify-center gap-1 w-[74px] h-[60px] rounded-xl border transition-colors ${+ mode === id+ ? 'bg-secondary border-accent text-accent'+ : 'bg-card border-border text-foreground hover:bg-secondary/50'+ }`}+ >+ <Icon size={17} />+ <span className="text-[11px] font-semibold">{i18n.t(labelKey)}</span>+ </button>+ ))}+ </div>+ </div></div>);}