Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots 📖

feat(editor): open the click target editor with the target selected

Luis Ortiz4d55be26b489
diff --git a/src/locales/en.yml b/src/locales/en.yml
index b2dc41d..abe0643 100644
--- a/src/locales/en.yml
+++ b/src/locales/en.yml
@@ -160,7 +160,7 @@ screenshotView:
zoomOut: Zoom out
saved: Saved
editMenu: Edit screenshot
- addClickTarget: Add click target
+ clickTarget: Click target
annotate: Annotate
redact: Redact
crop: Crop
diff --git a/src/locales/es.yml b/src/locales/es.yml
index 71f3b42..99bcdcf 100644
--- a/src/locales/es.yml
+++ b/src/locales/es.yml
@@ -160,7 +160,7 @@ screenshotView:
zoomOut: Alejar
saved: Guardado
editMenu: Editar captura
- addClickTarget: Agregar objetivo de clic
+ clickTarget: Objetivo de clic
annotate: Anotar
redact: Ocultar
crop: Recortar
diff --git a/src/locales/fr.yml b/src/locales/fr.yml
index d81c763..cf44a88 100644
--- a/src/locales/fr.yml
+++ b/src/locales/fr.yml
@@ -160,7 +160,7 @@ screenshotView:
zoomOut: "Zoom arrière"
saved: "Enregistré"
editMenu: "Modifier la capture"
- addClickTarget: "Ajouter une cible de clic"
+ clickTarget: "Cible de clic"
annotate: "Annoter"
redact: "Masquer"
crop: "Recadrer"
diff --git a/src/locales/pt-BR.yml b/src/locales/pt-BR.yml
index 546c7de..fc38788 100644
--- a/src/locales/pt-BR.yml
+++ b/src/locales/pt-BR.yml
@@ -160,7 +160,7 @@ screenshotView:
zoomOut: Diminuir zoom
saved: Salvo
editMenu: Editar captura
- addClickTarget: Adicionar alvo de clique
+ clickTarget: Alvo de clique
annotate: Anotar
redact: Ocultar
crop: Recortar
diff --git a/src/ui/fullview/GuideContent.tsx b/src/ui/fullview/GuideContent.tsx
index 842b41c..f25c6fc 100644
--- a/src/ui/fullview/GuideContent.tsx
+++ b/src/ui/fullview/GuideContent.tsx
@@ -16,7 +16,7 @@ import GuideStepList from './components/GuideStepList';
interface GuideContentProps {
guideId: string;
initialStepId?: string;
- initialTool?: 'annotate' | 'redact' | 'crop';
+ initialTool?: 'annotate' | 'redact' | 'crop' | 'target';
}
interface GuideData {
@@ -38,7 +38,7 @@ export default function GuideContent({ guideId, initialStepId, initialTool }: Gu
const [title, setTitle] = useState('');
const [typingTitle, setTypingTitle] = useState<string | null>(null);
const [editingStepId, setEditingStepId] = useState<string | null>(null);
- const [editingTool, setEditingTool] = useState<'annotate' | 'redact' | 'crop'>('annotate');
+ const [editingTool, setEditingTool] = useState<'annotate' | 'redact' | 'crop' | 'target'>('annotate');
const titleRef = useRef('');
const appliedInitialRef = useRef(false);
@@ -94,7 +94,7 @@ export default function GuideContent({ guideId, initialStepId, initialTool }: Gu
[guideId, loadGuide],
);
- const handleOpenEditor = useCallback((stepId: string, tool: 'annotate' | 'redact' | 'crop') => {
+ const handleOpenEditor = useCallback((stepId: string, tool: 'annotate' | 'redact' | 'crop' | 'target') => {
setEditingStepId(stepId);
setEditingTool(tool);
}, []);
diff --git a/src/ui/fullview/components/GuideStepList.tsx b/src/ui/fullview/components/GuideStepList.tsx
index 931ecc2..6428fc6 100644
--- a/src/ui/fullview/components/GuideStepList.tsx
+++ b/src/ui/fullview/components/GuideStepList.tsx
@@ -11,7 +11,7 @@ interface GuideStepListProps {
screenshots: Map<string, Screenshot>;
onDescriptionChange: (stepId: string, description: string) => void;
onDelete: (stepId: string) => void;
- onOpenEditor: (stepId: string, tool: 'annotate' | 'redact' | 'crop') => void;
+ onOpenEditor: (stepId: string, tool: 'annotate' | 'redact' | 'crop' | 'target') => void;
onReorder: (newSteps: Step[]) => void;
}
diff --git a/src/ui/fullview/router.ts b/src/ui/fullview/router.ts
index 83b5d6c..3675720 100644
--- a/src/ui/fullview/router.ts
+++ b/src/ui/fullview/router.ts
@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
export type Route =
| { page: 'library'; category: 'all' | 'starred' | 'trash' }
- | { page: 'guide'; guideId: string; stepId?: string; tool?: 'annotate' | 'redact' | 'crop' };
+ | { page: 'guide'; guideId: string; stepId?: string; tool?: 'annotate' | 'redact' | 'crop' | 'target' };
function parseHash(hash: string): Route {
const h = hash.replace(/^#\/?/, '');
diff --git a/src/ui/shared/AnnotationEditor.tsx b/src/ui/shared/AnnotationEditor.tsx
index 20b394c..79589db 100644
--- a/src/ui/shared/AnnotationEditor.tsx
+++ b/src/ui/shared/AnnotationEditor.tsx
@@ -32,7 +32,7 @@ type EditorTool = 'select' | 'box' | 'arrow' | 'text' | 'freehand' | 'redact' |
interface AnnotationEditorProps {
screenshot: Screenshot;
- tool: 'annotate' | 'redact' | 'crop';
+ tool: 'annotate' | 'redact' | 'crop' | 'target';
onDone: (edits: ScreenshotEdits) => void;
onCancel: () => void;
}
@@ -69,9 +69,10 @@ const TOOLS: { id: EditorTool; icon: ComponentType<{ size?: number }>; labelKey:
{ id: 'crop', icon: Crop, labelKey: 'annotationEditor.toolCrop' },
];
-function initialToolFor(tool: 'annotate' | 'redact' | 'crop'): EditorTool {
+function initialToolFor(tool: 'annotate' | 'redact' | 'crop' | 'target'): EditorTool {
if (tool === 'redact') return 'redact';
if (tool === 'crop') return 'crop';
+ if (tool === 'target') return 'select';
return 'box';
}
@@ -176,7 +177,7 @@ export default function AnnotationEditor({ screenshot, tool, onDone, onCancel }:
];
});
const [viewport, setViewport] = useState<ScreenshotBounds | undefined>(screenshot.edits?.viewport);
- const [selectedId, setSelectedId] = useState<string | null>(null);
+ const [selectedId, setSelectedId] = useState<string | null>(tool === 'target' ? TARGET_ID : null);
const [color, setColor] = useState<string>(COLORS[0]);
const [draft, setDraft] = useState<Annotation | null>(null);
const [cropDraft, setCropDraft] = useState<ScreenshotBounds | null>(null);
diff --git a/src/ui/shared/ScreenshotView.tsx b/src/ui/shared/ScreenshotView.tsx
index 0b27f0f..0a80c55 100644
--- a/src/ui/shared/ScreenshotView.tsx
+++ b/src/ui/shared/ScreenshotView.tsx
@@ -23,7 +23,7 @@ interface ScreenshotViewProps {
animate?: boolean;
crop?: boolean;
readOnly?: boolean;
- onOpenEditor?: (tool: 'annotate' | 'redact' | 'crop') => void;
+ onOpenEditor?: (tool: 'annotate' | 'redact' | 'crop' | 'target') => void;
}
interface DragState {
@@ -226,13 +226,14 @@ export default function ScreenshotView({
if (drag.moved) scheduleSave(effectiveEdits ?? {});
};
- const handleAddClickTarget = () => {
+ const handleClickTarget = () => {
const nextEdits: ScreenshotEdits = {
...effectiveEdits,
target: resolveTarget(effectiveScreenshot) ?? defaultTargetRect(effectiveScreenshot),
};
setEditsOverride(nextEdits);
scheduleSave(nextEdits);
+ onOpenEditor?.('target');
};
const handleAltChange = (value: string) => {
@@ -390,9 +391,9 @@ export default function ScreenshotView({
</button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" onClick={(e) => e.stopPropagation()}>
- <DropdownMenuItem onSelect={handleAddClickTarget}>
+ <DropdownMenuItem onSelect={handleClickTarget}>
<Target size={14} />
- {i18n.t('screenshotView.addClickTarget')}
+ {i18n.t('screenshotView.clickTarget')}
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => onOpenEditor?.('annotate')}>
<Highlighter size={14} />
diff --git a/src/ui/sidepanel/GuideEditor.tsx b/src/ui/sidepanel/GuideEditor.tsx
index 512f3a7..0bde229 100644
--- a/src/ui/sidepanel/GuideEditor.tsx
+++ b/src/ui/sidepanel/GuideEditor.tsx
@@ -79,7 +79,7 @@ export default function GuideEditor({ guideId, onBack, onGuideMe }: GuideEditorP
);
const openInFullView = useCallback(
- (targetGuideId: string, stepId?: string, tool?: 'annotate' | 'redact' | 'crop') => {
+ (targetGuideId: string, stepId?: string, tool?: 'annotate' | 'redact' | 'crop' | 'target') => {
const params = new URLSearchParams({ guideId: targetGuideId });
if (stepId) params.set('stepId', stepId);
if (tool) params.set('tool', tool);
diff --git a/src/ui/sidepanel/StepCard.tsx b/src/ui/sidepanel/StepCard.tsx
index a2caa6f..413c0cf 100644
--- a/src/ui/sidepanel/StepCard.tsx
+++ b/src/ui/sidepanel/StepCard.tsx
@@ -18,7 +18,7 @@ interface StepCardProps {
onDescriptionChange: (stepId: string, description: string) => void;
onDelete: (stepId: string) => void;
dragHandleProps?: DragHandleProps;
- onOpenEditor?: (stepId: string, tool: 'annotate' | 'redact' | 'crop') => void;
+ onOpenEditor?: (stepId: string, tool: 'annotate' | 'redact' | 'crop' | 'target') => void;
onCopy?: (stepId: string) => void;
}