From 17aa32ce78b6d4d9210b06c207ac3f303110504a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gr=C3=B8ngaard?= Date: Mon, 6 Jan 2025 08:23:31 +0100 Subject: [PATCH] feat(core): add default markdown behaviors to PTE (#8168) --- .../inputs/PortableText/PortableTextInput.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/sanity/src/core/form/inputs/PortableText/PortableTextInput.tsx b/packages/sanity/src/core/form/inputs/PortableText/PortableTextInput.tsx index d048caea4c9..85e8191e97a 100644 --- a/packages/sanity/src/core/form/inputs/PortableText/PortableTextInput.tsx +++ b/packages/sanity/src/core/form/inputs/PortableText/PortableTextInput.tsx @@ -14,6 +14,7 @@ import { useEditor, usePortableTextEditor, } from '@portabletext/editor' +import {coreBehaviors, createMarkdownBehaviors} from '@portabletext/editor/behaviors' import {useTelemetry} from '@sanity/telemetry/react' import {isKeySegment, type Path, type PortableTextBlock} from '@sanity/types' import {Box, Flex, Text, useToast} from '@sanity/ui' @@ -384,6 +385,21 @@ export function PortableTextInput(props: PortableTextInputProps): ReactNode { + schema.styles.find((style) => style.value === 'normal')?.value, + blockquoteStyle: ({schema}) => + schema.styles.find((style) => style.value === 'blockquote')?.value, + headingStyle: ({schema, level}) => + schema.styles.find((style) => style.value === `h${level}`)?.value, + orderedListStyle: ({schema}) => + schema.lists.find((list) => list.value === 'number')?.value, + unorderedListStyle: ({schema}) => + schema.lists.find((list) => list.value === 'bullet')?.value, + }), + ], initialValue: value, readOnly: readOnly || !ready, keyGenerator,