@portabletext/editor
Version:
Portable Text Editor made in React
66 lines • 1.54 kB
TypeScript
import { W as Editor, kt as EditorEmittedEvent, q as Behavior } from "../_chunks-dts/behavior.types.action.js";
import React from "react";
/**
* @beta
*/
declare function BehaviorPlugin(props: {
behaviors: Array<Behavior>;
}): null;
/**
* @beta
*/
declare const EditorRefPlugin: React.ForwardRefExoticComponent<React.RefAttributes<Editor | null>>;
/**
* @public
* Listen for events emitted by the editor. Must be used inside `EditorProvider`. Events available include:
* - 'blurred'
* - 'done loading'
* - 'editable'
* - 'error'
* - 'focused'
* - 'invalid value'
* - 'loading'
* - 'mutation'
* - 'patch'
* - 'read only'
* - 'ready'
* - 'selection'
* - 'value changed'
*
* @example
* Listen and log events.
* ```tsx
* import {EditorProvider} from '@portabletext/editor'
* import {EventListenerPlugin} from '@portabletext/editor/plugins'
*
* function MyComponent() {
* return (
* <EditorProvider>
* <EventListenerPlugin
* on={(event) => {
* console.log(event)
* }
* } />
* { ... }
* </EditorProvider>
* )
* }
* ```
* @example
* Handle events when there is a mutation.
* ```tsx
* <EventListenerPlugin
* on={(event) => {
* if (event.type === 'mutation') {
* console.log('Value changed:', event.snapshot)
* }
* }}
* />
* ```
* @group Components
*/
declare function EventListenerPlugin(props: {
on: (event: EditorEmittedEvent) => void;
}): null;
export { BehaviorPlugin, EditorRefPlugin, EventListenerPlugin };
//# sourceMappingURL=index.d.ts.map