/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0 */ import React, { useState, useEffect, useRef } from "react"; import MarkdownRender from "./MarkdownRender"; import Link from "./Link"; import "./Markdown.css"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faExternalLinkAlt } from "@fortawesome/free-solid-svg-icons"; import { useTranslation } from "react-i18next"; type MarkdownProps = { id: string; name: string; label: string; defaultValue?: string; register?: Function; required?: boolean; error?: string; hint?: string; }; const Markdown = (props: MarkdownProps) => { const [disabled, toggle] = useState(true); const [boxHeight, setBoxHeight] = useState(142); const text = useRef(null); const { t } = useTranslation(); useEffect(() => { const height = document.querySelector("textarea")?.clientHeight || 142; setBoxHeight(height + 2); }, []); let formGroupClassName = "usa-form-group"; if (props.error) { formGroupClassName += " usa-form-group--error"; } return (
{props.hint} {t("MarkdownSupport")}{" "} {t("AddTextScreen.ViewMarkdownSyntax")}
toggle(!disabled)} className="usa-checkbox__input" />
{props.error && ( {props.error} )}