{"version":3,"file":"ShortcutCopy.CBbf1jOC.mjs","names":["useRef","_Fragment"],"sources":["https:/framerusercontent.com/modules/D5VLVU5Fun6ReCX4sn5R/ajUfY4sdDWbjco9h5Pkw/ShortcutCopy.js"],"sourcesContent":["// import { useEffect, useRef } from \"react\"\n// import { addPropertyControls, ControlType } from \"framer\"\n// // Main component\n// export default function ShortcutTrigger(props) {\n//     const { targetFrame, shortcutKey, copyString } = props\n//     const frameRef = useRef(null)\n//     // Function to simulate a click event\n//     const simulateClick = (element) => {\n//         if (element) {\n//             const event = new MouseEvent(\"click\", {\n//                 bubbles: true,\n//                 cancelable: true,\n//                 view: window,\n//             })\n//             element.dispatchEvent(event)\n//         }\n//     }\n//     // Handles keyboard shortcut\n//     const handleKeyDown = (event) => {\n//         if (event.key.toLowerCase() === shortcutKey.toLowerCase()) {\n//             if (copyString) {\n//                 navigator.clipboard.writeText(copyString)\n//                 console.log(`Copied: ${copyString}`)\n//             }\n//             if (frameRef.current) {\n//                 simulateClick(frameRef.current) // Now uses a full MouseEvent\n//             }\n//         }\n//     }\n//     useEffect(() => {\n//         document.addEventListener(\"keydown\", handleKeyDown)\n//         return () => document.removeEventListener(\"keydown\", handleKeyDown)\n//     }, [shortcutKey, copyString])\n//     return (\n//         <>\n//             {targetFrame ? (\n//                 <div ref={frameRef}>{targetFrame}</div>\n//             ) : (\n//                 <div\n//                     style={{\n//                         padding: 20,\n//                         background: \"#f0f0f0\",\n//                         textAlign: \"center\",\n//                     }}\n//                 >\n//                     Select a target frame in the properties panel\n//                 </div>\n//             )}\n//         </>\n//     )\n// }\n// // Property controls\n// addPropertyControls(ShortcutTrigger, {\n//     targetFrame: {\n//         type: ControlType.ComponentInstance,\n//         title: \"Target Frame\",\n//         description:\n//             \"Select the frame that will be triggered when the shortcut is pressed.\",\n//     },\n//     shortcutKey: {\n//         type: ControlType.String,\n//         title: \"Shortcut Key\",\n//         defaultValue: \"c\",\n//     },\n//     copyString: {\n//         type: ControlType.String,\n//         title: \"Text to Copy\",\n//         defaultValue: \"Hello, Framer!\",\n//     },\n// })\nimport{jsx as _jsx,Fragment as _Fragment}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";// Main component\nexport default function ShortcutTrigger(props){const{targetFrame,shortcutKey,copyString}=props;const frameRef=useRef(null);// Function to simulate a real click\nconst simulateClick=element=>{if(!element)return;requestAnimationFrame(()=>{const rect=element.getBoundingClientRect();const x=rect.left+rect.width/2;const y=rect.top+rect.height/2;// Step 1: Simulate a real pointer event\nconst pointerDown=new PointerEvent(\"pointerdown\",{bubbles:true,cancelable:true,composed:true,view:window,pointerId:1,isPrimary:true,clientX:x,clientY:y});const pointerUp=new PointerEvent(\"pointerup\",{bubbles:true,cancelable:true,composed:true,view:window,pointerId:1,isPrimary:true,clientX:x,clientY:y});// Step 2: Dispatch pointer events to simulate real interaction\nelement.dispatchEvent(pointerDown);element.dispatchEvent(pointerUp);// Step 3: Now dispatch a real MouseEvent (click)\nconst clickEvent=new MouseEvent(\"click\",{bubbles:true,cancelable:true,composed:true,view:window,clientX:x,clientY:y});element.dispatchEvent(clickEvent);});};// Handles keyboard shortcut\nconst handleKeyDown=event=>{if(event.key.toLowerCase()===shortcutKey.toLowerCase()){if(copyString){navigator.clipboard.writeText(copyString);console.log(`Copied: ${copyString}`);}if(frameRef.current){simulateClick(frameRef.current)// Fully mimics a real click now!\n;}}};useEffect(()=>{document.addEventListener(\"keydown\",handleKeyDown);return()=>document.removeEventListener(\"keydown\",handleKeyDown);},[shortcutKey,copyString]);return /*#__PURE__*/_jsx(_Fragment,{children:targetFrame?/*#__PURE__*/_jsx(\"div\",{ref:frameRef,children:targetFrame}):/*#__PURE__*/_jsx(\"div\",{style:{padding:20,background:\"#f0f0f0\",textAlign:\"center\"},children:\"Select a target frame in the properties panel\"})});}// Property controls\naddPropertyControls(ShortcutTrigger,{targetFrame:{type:ControlType.ComponentInstance,title:\"Target Frame\",description:\"Select the frame that will be triggered when the shortcut is pressed.\"},shortcutKey:{type:ControlType.String,title:\"Shortcut Key\",defaultValue:\"c\"},copyString:{type:ControlType.String,title:\"Text to Copy\",defaultValue:\"Hello, Framer!\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ShortcutTrigger\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ShortcutCopy.map"],"mappings":"6MAuEA,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,cAAY,cAAY,cAAY,EAAY,EAASA,EAAO,KAAK,CACpH,EAAc,GAAS,CAAK,GAAe,0BAA0B,CAAC,IAAM,EAAK,EAAQ,uBAAuB,CAAO,EAAE,EAAK,KAAK,EAAK,MAAM,EAAQ,EAAE,EAAK,IAAI,EAAK,OAAO,EAC7K,EAAY,IAAI,aAAa,cAAc,CAAC,QAAQ,GAAK,WAAW,GAAK,SAAS,GAAK,KAAK,EAAO,UAAU,EAAE,UAAU,GAAK,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAO,EAAU,IAAI,aAAa,YAAY,CAAC,QAAQ,GAAK,WAAW,GAAK,SAAS,GAAK,KAAK,EAAO,UAAU,EAAE,UAAU,GAAK,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAC/S,EAAQ,cAAc,EAAY,CAAC,EAAQ,cAAc,EAAU,CACnE,IAAM,EAAW,IAAI,WAAW,QAAQ,CAAC,QAAQ,GAAK,WAAW,GAAK,SAAS,GAAK,KAAK,EAAO,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAQ,cAAc,EAAW,EAAG,EACpJ,EAAc,GAAO,CAAI,EAAM,IAAI,aAAa,GAAG,EAAY,aAAa,GAAK,IAAY,EAAU,UAAU,UAAU,EAAW,CAAC,QAAQ,IAAI,WAAW,IAAa,EAAK,EAAS,SAAS,EAAc,EAAS,QAAQ,GACpE,OAA9J,OAAe,SAAS,iBAAiB,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