Skip to content

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)

Python

Merge main into claude/fix-iframe-hash-links-Q2rr5

Abi Rajaf8abe5ccae74
diff --cc frontend/src/components/preview/PreviewComponent.tsx
index f01d29bf,67a678b3..8be4560c
--- a/frontend/src/components/preview/PreviewComponent.tsx
+++ b/frontend/src/components/preview/PreviewComponent.tsx
@@@ -35,15 -33,46 +33,55 @@@ function PreviewComponent(
setClickEvent(event);
}, []);
+ const handleIframeLinkClick = useCallback((event: MouseEvent) => {
+ const target = (event.target as HTMLElement).closest("a");
+ if (!target) return;
+ const href = target.getAttribute("href");
+ if (href && href.startsWith("#")) {
+ event.preventDefault();
+ }
+ }, []);
+
+ const {
+ inSelectAndEditMode,
+ selectedElement,
+ setSelectedElement,
+ } = useAppStore();
+
+ const inSelectAndEditModeRef = useRef(inSelectAndEditMode);
+ useEffect(() => {
+ inSelectAndEditModeRef.current = inSelectAndEditMode;
+ }, [inSelectAndEditMode]);
+
+ // Handle click events to select elements
+ useEffect(() => {
+ if (!inSelectAndEditModeRef.current || !clickEvent) {
+ return;
+ }
+
+ clickEvent.preventDefault();
+
+ const targetElement = clickEvent.target as HTMLElement;
+ if (!targetElement) return;
+
+ // Remove highlight from previous element
+ if (selectedElement) {
+ removeHighlight(selectedElement);
+ }
+
+ // Highlight and store the new selected element
+ addHighlight(targetElement);
+ setSelectedElement(targetElement);
+ }, [clickEvent, setSelectedElement]); // eslint-disable-line react-hooks/exhaustive-deps
+
+ // Clean up highlight when exiting select-and-edit mode
+ useEffect(() => {
+ if (!inSelectAndEditMode && selectedElement) {
+ removeHighlight(selectedElement);
+ setSelectedElement(null);
+ }
+ }, [inSelectAndEditMode]); // eslint-disable-line react-hooks/exhaustive-deps
+
// Apply a fixed viewport per device and scale to fit the available pane.
useEffect(() => {
const updateScale = () => {