Skip to content

Commit

Permalink
doc(form): add doc and example for components extention of block type (
Browse files Browse the repository at this point in the history
  • Loading branch information
skogsmaskin authored Oct 24, 2023
1 parent c51319a commit 5233f35
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions packages/sanity/src/core/form/types/definitionExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,35 @@ declare module '@sanity/types' {

export interface BlockDefinition {
/**
* Components for the block schema type
*
* @hidden
* @beta
* @public
* @remarks - This only applies to the block text type, and not block object types (like images).
* - Don't render arbitrary text nodes inside regular text blocks, as this will confuse the editor with
* what is editable text and not. Make sure to wrap all nodes which are NOT part of the edited text inside a
* container with `contentEditable={false}` and with `style={{userSelection: 'none'}}` so that
* the editor can distinguish between editable text and non-editable text.
* @example Example of custom block component with delete button next to it that removes the block.
* ```ts
* {
* block: (blockProps) => {
* return (
* <Flex>
* <Box flex={1}>{blockProps.renderDefault(blockProps)}</Box>
* <Box contentEditable={false} style={{userSelect: 'none'}}>
* <Button
* icon={TrashIcon}
* onClick={(event) => {
* event.preventDefault()
* blockProps.onRemove()
* }}
* />
* </Box>
* </Flex>
* )
* },
* },
* ```
*/
components?: {
block?: ComponentType<BlockProps>
Expand Down

2 comments on commit 5233f35

@vercel
Copy link

@vercel vercel bot commented on 5233f35 Oct 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

performance-studio – ./

performance-studio-git-next.sanity.build
performance-studio.sanity.build

@vercel
Copy link

@vercel vercel bot commented on 5233f35 Oct 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

test-studio – ./

test-studio.sanity.build
test-studio-git-next.sanity.build

Please sign in to comment.