Automatically match a pair of characters and decorate the text in between
npm install @portabletext/plugin-character-pair-decorator@portabletext/plugin-character-pair-decorator> ✨ Automatically match a pair of characters and decorate the text in between
Import the CharacterPairDecoratorPlugin React component and place it inside the EditorProvider to automatically register the necessary Behaviors:
``tsx
import {
defineSchema,
EditorProvider,
PortableTextEditable,
} from '@portabletext/editor'
import {CharacterPairDecoratorPlugin} from '@portabletext/plugin-character-pair-decorator'
function App() {
return (
schemaDefinition: defineSchema({
decorators: [{name: 'italic'}],
}),
}}
>
context.schema.decorators.find((d) => d.name === 'italic')?.name
}
pair={{char: '#', amount: 1}}
/>
)
}
``