Skip to content

Commit

Permalink
feat(core): add default markdown behaviors to PTE (#8168)
Browse files Browse the repository at this point in the history
  • Loading branch information
christianhg authored Jan 6, 2025
1 parent 9d68dad commit 17aa32c
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -384,6 +385,21 @@ export function PortableTextInput(props: PortableTextInputProps): ReactNode {
<PortableTextMemberItemsProvider memberItems={portableTextMemberItems}>
<EditorProvider
initialConfig={{
behaviors: [
...coreBehaviors,
...createMarkdownBehaviors({
defaultStyle: ({schema}) =>
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,
Expand Down

0 comments on commit 17aa32c

Please sign in to comment.