diff --git a/airflow-core/src/airflow/ui/src/components/EditableMarkdownArea.tsx b/airflow-core/src/airflow/ui/src/components/EditableMarkdownArea.tsx new file mode 100644 index 0000000000000..a77bfcd617e93 --- /dev/null +++ b/airflow-core/src/airflow/ui/src/components/EditableMarkdownArea.tsx @@ -0,0 +1,66 @@ +/*! + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { Box, VStack, Editable, Text } from "@chakra-ui/react"; +import type { ChangeEvent } from "react"; + +import ReactMarkdown from "./ReactMarkdown"; + +const EditableMarkdownArea = ({ + mdContent, + onBlur, + placeholder, + setMdContent, +}: { + readonly mdContent?: string | null; + readonly onBlur?: () => void; + readonly placeholder?: string | null; + readonly setMdContent: (value: string) => void; +}) => ( + + ) => setMdContent(event.target.value)} + value={mdContent ?? ""} + > + + {Boolean(mdContent) ? ( + {mdContent} + ) : ( + {placeholder} + )} + + + + +); + +export default EditableMarkdownArea; diff --git a/airflow-core/src/airflow/ui/src/components/EditableMarkdownButton.tsx b/airflow-core/src/airflow/ui/src/components/EditableMarkdownButton.tsx index 72ac8f3245c8f..226e050337b5b 100644 --- a/airflow-core/src/airflow/ui/src/components/EditableMarkdownButton.tsx +++ b/airflow-core/src/airflow/ui/src/components/EditableMarkdownButton.tsx @@ -16,13 +16,13 @@ * specific language governing permissions and limitations * under the License. */ -import { Box, Heading, VStack, Editable, Text, Flex } from "@chakra-ui/react"; -import { type ChangeEvent, type ReactElement, useState } from "react"; +import { Box, Heading, VStack, Flex } from "@chakra-ui/react"; +import { type ReactElement, useState } from "react"; import { useTranslation } from "react-i18next"; import { Button, Dialog } from "src/components/ui"; -import ReactMarkdown from "./ReactMarkdown"; +import EditableMarkdownArea from "./EditableMarkdownArea"; import ActionButton from "./ui/ActionButton"; const EditableMarkdownButton = ({ @@ -71,34 +71,11 @@ const EditableMarkdownButton = ({ - ) => setMdContent(event.target.value)} - value={mdContent ?? ""} - > - - {Boolean(mdContent) ? ( - {mdContent} - ) : ( - {placeholder} - )} - - - - +