Skip to content

Commit a3d5300

Browse files
committed
feat: Disable some UI options for Markdown formatting
1 parent a4a6caf commit a3d5300

File tree

4 files changed

+40
-8
lines changed

4 files changed

+40
-8
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ You can also check the
1111

1212
# Unreleased
1313

14-
Nothing yet.
14+
- Features
15+
- Disabled some UI options for Markdown formatting in title and description
16+
fields
1517

1618
# [5.7.1] - 2025-04-25
1719

app/components/form.tsx

+23-6
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,15 @@ export const MarkdownInput = ({
546546
name,
547547
value,
548548
onChange,
549+
disableToolbar,
549550
}: {
550551
label?: string | ReactNode;
552+
disableToolbar?: {
553+
textStyles?: boolean;
554+
blockType?: boolean;
555+
listToggles?: boolean;
556+
link?: boolean;
557+
};
551558
} & FieldProps) => {
552559
const classes = useMarkdownInputStyles();
553560

@@ -562,12 +569,22 @@ export const MarkdownInput = ({
562569
toolbarContents: () => (
563570
<div>
564571
<Box sx={{ display: "flex", gap: 2 }}>
565-
<BoldItalicUnderlineToggles />
566-
<BlockTypeMenu />
567-
<Divider flexItem orientation="vertical" />
568-
<ListToggles />
569-
<Divider flexItem orientation="vertical" />
570-
<LinkDialogToggle />
572+
{disableToolbar?.textStyles ? null : (
573+
<BoldItalicUnderlineToggles />
574+
)}
575+
{disableToolbar?.blockType ? null : <BlockTypeMenu />}
576+
{disableToolbar?.listToggles ? null : (
577+
<>
578+
<Divider flexItem orientation="vertical" />
579+
<ListToggles />
580+
</>
581+
)}
582+
{disableToolbar?.link ? null : (
583+
<>
584+
<Divider flexItem orientation="vertical" />
585+
<LinkDialogToggle />
586+
</>
587+
)}
571588
</Box>
572589
{label && name ? <Label htmlFor={name}>{label}</Label> : null}
573590
</div>

app/configurator/components/annotation-options.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ const AnnotationOptions = (props: AnnotationOptionsProps) => {
9999
locale={locale}
100100
label={getFieldLabel(locale)}
101101
value={meta[activeField][locale]}
102+
disableToolbar={{
103+
blockType: true,
104+
listToggles: activeField === "title",
105+
link: activeField === "title",
106+
}}
102107
/>
103108
</Box>
104109
))}

app/configurator/components/field.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -628,21 +628,29 @@ export const MetaInputField = ({
628628
metaKey,
629629
locale,
630630
value,
631+
disableToolbar,
631632
}: {
632633
type: "chart" | "layout";
633634
inputType: "text" | "markdown";
634635
label: string | ReactNode;
635636
metaKey: string;
636637
locale: string;
637638
value?: string;
639+
disableToolbar?: ComponentProps<typeof MarkdownInput>["disableToolbar"];
638640
}) => {
639641
const field = useMetaField({ type, metaKey, locale, value });
640642

641643
switch (inputType) {
642644
case "text":
643645
return <Input label={label} {...field} />;
644646
case "markdown":
645-
return <MarkdownInput label={label} {...field} />;
647+
return (
648+
<MarkdownInput
649+
label={label}
650+
{...field}
651+
disableToolbar={disableToolbar}
652+
/>
653+
);
646654
default:
647655
const _exhaustiveCheck: never = inputType;
648656
return _exhaustiveCheck;

0 commit comments

Comments
 (0)