import { __ } from "@wordpress/i18n";
import {
	useBlockProps,
	RichText,
	InspectorControls,
	__experimentalLinkControl as LinkControl,
} from "@wordpress/block-editor";
import { PanelBody } from "@wordpress/components";
import "./editor.scss";
import { BlockControls, AlignmentToolbar } from "@wordpress/block-editor";

import { Tip } from "@wordpress/components";
export default function Edit({ attributes, setAttributes }) {
	return (
		<>
			<BlockControls>
				<AlignmentToolbar
					value={attributes.align}
					onChange={(value) => setAttributes({ align: value })}
				/>
			</BlockControls>
			<InspectorControls>
				<PanelBody title="Lien" initialOpen={true}>
					<div>
						<LinkControl
							value={attributes.link}
							onChange={(value) => {
								setAttributes({ link: value });
							}}
						/>
					</div>
				</PanelBody>
			</InspectorControls>
			<RichText
				{...useBlockProps({
					className: `cta align--${attributes.align}`,
				})}
				tagName="a"
				placeholder="Ajouter un lien"
				value={attributes.text}
				onChange={(text) => setAttributes({ text })}
				allowedFormats={[]}
			/>
		</>
	);
}
