Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ import { Box, Heading, VStack } from "@chakra-ui/react";
import { type ReactElement, useState } from "react";

import { Button, Dialog } from "src/components/ui";
import { ResizableWrapper } from "src/components/ui/ResizableWrapper";
import { ResizableWrapper, MARKDOWN_DIALOG_STORAGE_KEY } from "src/components/ui/ResizableWrapper";

import ReactMarkdown from "./ReactMarkdown";

const STORAGE_KEY = "airflow-markdown-dialog-size";

const DisplayMarkdownButton = ({
header,
icon,
Expand All @@ -52,7 +50,7 @@ const DisplayMarkdownButton = ({
size="md"
>
<Dialog.Content backdrop maxHeight="none" maxWidth="none" padding={0} width="auto">
<ResizableWrapper storageKey={STORAGE_KEY}>
<ResizableWrapper storageKey={MARKDOWN_DIALOG_STORAGE_KEY}>
<Dialog.Header bg="brand.muted" flexShrink={0}>
<Heading size="xl">{header}</Heading>
<Dialog.CloseTrigger closeButtonProps={{ size: "xl" }} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ const EditableMarkdownArea = ({
}

return (
<Box mt={4} px={4} width="100%">
<Box height="100%" p={4} width="100%">
<Editable.Root
height="100%"
onBlur={onBlur}
onChange={(event: ChangeEvent<HTMLInputElement>) => {
const { value } = event.target;
Expand All @@ -59,7 +60,7 @@ const EditableMarkdownArea = ({
alignItems="flex-start"
as={VStack}
gap="0"
height="200px"
height="100%"
overflowY="auto"
width="100%"
>
Expand All @@ -71,7 +72,7 @@ const EditableMarkdownArea = ({
</Editable.Preview>
<Editable.Textarea
data-testid="markdown-input"
height="200px"
height="100%"
overflowY="auto"
placeholder={placeholder ?? ""}
resize="none"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { useTranslation } from "react-i18next";
import { PiNoteBlankLight, PiNoteLight } from "react-icons/pi";

import { Button, Dialog } from "src/components/ui";
import { ResizableWrapper, MARKDOWN_DIALOG_STORAGE_KEY } from "src/components/ui/ResizableWrapper";

import EditableMarkdownArea from "./EditableMarkdownArea";
import ActionButton from "./ui/ActionButton";
Expand Down Expand Up @@ -88,30 +89,36 @@ const EditableMarkdownButton = ({
size="md"
unmountOnExit={true}
>
<Dialog.Content backdrop>
<Dialog.Header bg="brand.muted">
<Heading size="xl">{header}</Heading>
<Dialog.CloseTrigger closeButtonProps={{ size: "xl" }} />
</Dialog.Header>
<Dialog.Body alignItems="flex-start" as={VStack} gap="0">
<EditableMarkdownArea
mdContent={mdContent}
placeholder={placeholder}
setMdContent={setMdContent}
/>
<Flex justifyContent="end" mt={3} width="100%">
<Button
colorPalette="brand"
loading={isPending}
onClick={() => {
onConfirm();
setIsOpen(false);
}}
>
{noteIcon} {translate("modal.confirm")}
</Button>
</Flex>
</Dialog.Body>
<Dialog.Content backdrop maxHeight="90vh" maxWidth="90vw" padding={0} width="auto">
<ResizableWrapper storageKey={MARKDOWN_DIALOG_STORAGE_KEY}>
<Dialog.Header bg="brand.muted" flexShrink={0}>
<Heading size="xl">{header}</Heading>
<Dialog.CloseTrigger closeButtonProps={{ size: "xl" }} />
</Dialog.Header>
<Dialog.Body alignItems="flex-start" as={VStack} flex="1" gap="0" overflow="hidden" p={0}>
<Box flex="1" overflow="hidden" width="100%">
<EditableMarkdownArea
mdContent={mdContent}
placeholder={placeholder}
setMdContent={setMdContent}
/>
</Box>
<Box bg="bg.panel" flexShrink={0} width="100%">
<Flex justifyContent="end" p={4}>
<Button
colorPalette="brand"
loading={isPending}
onClick={() => {
onConfirm();
setIsOpen(false);
}}
>
{noteIcon} {translate("modal.confirm")}
</Button>
</Flex>
</Box>
</Dialog.Body>
</ResizableWrapper>
</Dialog.Content>
</Dialog.Root>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ type ResizableWrapperProps = {
const DEFAULT_SIZE = { height: 400, width: 500 };
const MAX_SIZE: [number, number] = [1200, 800];

export const MARKDOWN_DIALOG_STORAGE_KEY = "airflow-markdown-dialog-size";

export const ResizableWrapper = ({
children,
defaultSize = DEFAULT_SIZE,
Expand Down