From d68e238b0065d730ee82cc5b347873392298c2ff Mon Sep 17 00:00:00 2001 From: DrMint <29893320+DrMint@users.noreply.github.com> Date: Sat, 8 Apr 2023 16:34:27 +0200 Subject: [PATCH] Improve editor and no longer crash if markdawn Line has bad parameters --- src/components/Inputs/ButtonGroup.tsx | 18 ++- src/components/Markdown/Markdawn.tsx | 51 +++++-- src/pages/dev/editor.tsx | 200 ++++++++++++++++++++++---- 3 files changed, 221 insertions(+), 48 deletions(-) diff --git a/src/components/Inputs/ButtonGroup.tsx b/src/components/Inputs/ButtonGroup.tsx index bd9566f..33a4889 100644 --- a/src/components/Inputs/ButtonGroup.tsx +++ b/src/components/Inputs/ButtonGroup.tsx @@ -1,8 +1,10 @@ +// eslint-disable-next-line import/named +import { Placement } from "tippy.js"; import { Button } from "./Button"; import { ToolTip } from "components/ToolTip"; import { cJoin } from "helpers/className"; import { ConditionalWrapper, Wrapper } from "helpers/component"; -import { isDefinedAndNotEmpty } from "helpers/asserts"; +import { isDefined } from "helpers/asserts"; /* * ╭─────────────╮ @@ -12,7 +14,8 @@ import { isDefinedAndNotEmpty } from "helpers/asserts"; interface Props { className?: string; buttonsProps: (Parameters[0] & { - tooltip?: string | null | undefined; + tooltip?: React.ReactNode | null | undefined; + tooltipPlacement?: Placement; })[]; } @@ -23,9 +26,9 @@ export const ButtonGroup = ({ buttonsProps, className }: Props): JSX.Element => {buttonsProps.map((buttonProps, index) => ( + wrapperProps={{ text: buttonProps.tooltip ?? "", placement: buttonProps.tooltipPlacement }}>