npm.io
7.0.40 • Published 3d ago

@portabletext/plugin-one-line

Licence
MIT
Version
7.0.40
Deps
0
Size
14 kB
Vulns
0
Weekly
0
Stars
262

@portabletext/plugin-one-line

Restrict the Portable Text Editor to a single line

Installation

npm install @portabletext/plugin-one-line

Usage

The plugin blocks insert.break events and provides smart handling of other insert.* events like insert.block.

Configure it with as high priority as possible to make sure other plugins don't overwrite insert.* events before this plugin gets a chance to do so.

Import the OneLinePlugin React component and place it inside the EditorProvider to automatically register the necessary Behaviors:

import {
  defineSchema,
  EditorProvider,
  PortableTextEditable,
} from '@portabletext/editor'
import {OneLinePlugin} from '@portabletext/plugin-one-line'

function App() {
  return (
    <EditorProvider initialConfig={{schemaDefinition: defineSchema({})}}>
      <PortableTextEditable />
      <OneLinePlugin />
    </EditorProvider>
  )
}

Keywords