| 1 |
/** |
| 2 |
* Help Fucntions. |
| 3 |
* @file: ../includes/page-form-builder/_out/bfb_support_func.js |
| 4 |
*/ |
| 5 |
|
| 6 |
/** |
| 7 |
* Clipboard (UI-only helper) |
| 8 |
* |
| 9 |
* @param text |
| 10 |
* @returns {Promise<boolean>} |
| 11 |
*/ |
| 12 |
async function wpbc_copy_to_clipboard(text) { |
| 13 |
try { |
| 14 |
if ( window.isSecureContext && navigator.clipboard && navigator.clipboard.writeText ) { |
| 15 |
await navigator.clipboard.writeText( String( text || '' ) ); |
| 16 |
return true; |
| 17 |
} |
| 18 |
} catch ( e ) { |
| 19 |
window._wpbc?.dev?.error?.( 'wpbc_copy_to_clipboard', e ); |
| 20 |
} |
| 21 |
|
| 22 |
try { |
| 23 |
const ta = document.createElement( 'textarea' ); |
| 24 |
ta.value = String( text || '' ); |
| 25 |
ta.setAttribute( 'readonly', '' ); |
| 26 |
ta.style.position = 'fixed'; |
| 27 |
ta.style.top = '-9999px'; |
| 28 |
ta.style.opacity = '0'; |
| 29 |
document.body.appendChild( ta ); |
| 30 |
ta.focus(); |
| 31 |
ta.select(); |
| 32 |
const ok = document.execCommand( 'copy' ); |
| 33 |
document.body.removeChild( ta ); |
| 34 |
return !! ok; |
| 35 |
} catch ( _ ) { |
| 36 |
return false; |
| 37 |
} |
| 38 |
} |
| 39 |
|