包详细信息

@portabletext/plugin-character-pair-decorator

portabletext2.8kMIT1.0.13

Automatically match a pair of characters and decorate the text in between

portabletext, plugin, 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:

import {
  defineSchema,
  EditorProvider,
  PortableTextEditable,
} from '@portabletext/editor'
import {CharacterPairDecoratorPlugin} from '@portabletext/plugin-character-pair-decorator'

function App() {
  return (
    <EditorProvider
      initialConfig={{
        schemaDefinition: defineSchema({
          decorators: [{name: 'italic'}],
        }),
      }}
    >
      <PortableTextEditable />
      <CharacterPairDecoratorPlugin
        decorator={({schema}) =>
          schema.decorators.find((d) => d.name === 'italic')?.name
        }
        pair={{char: '#', amount: 1}}
      />
    </EditorProvider>
  )
}