/** * Parts the panels of the embed workspace share: the code with a copy button and the steps to use it. */ import React, { useEffect, useState } from 'react'; import { __ } from './i18n'; import { Button, icons } from './ui'; export type EmbedMethod = 'inline' | 'link' | 'external' | 'popup' | 'widget'; /** The code of a way to embed with a copy button. */ export function CodeBox( { label, code }: { label: string; code: string } ) { const [ copied, setCopied ] = useState( false ); useEffect( () => setCopied( false ), [ code ] ); const copy = async (): Promise => { try { await navigator.clipboard.writeText( code ); setCopied( true ); setTimeout( () => setCopied( false ), 1800 ); } catch { // Without the clipboard (no HTTPS) the code stays selectable by hand. } }; return (

{ label }

					{ code }
				
); } /** Numbered steps to use the code. */ export function Steps( { steps }: { steps: React.ReactNode[] } ) { return (

{ __( 'How to embed this form:', 'funnelforms-pro' ) }

    { steps.map( ( step, i ) => (
  1. { step }
  2. ) ) }
); }