Skip to content

PortableTextEditor

The main Portable Text Editor component.

Extends

Constructors

new PortableTextEditor()

new PortableTextEditor(props): PortableTextEditor

Parameters

props

PortableTextEditorProps<undefined>

Returns

PortableTextEditor

Overrides

Component< PortableTextEditorProps<Editor | undefined> >.constructor

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:133

Properties

change$

change$: EditorChanges

An observable of all the editor changes.

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:119


context

context: unknown

If using the new style context, re-declare this in your class to be the React.ContextType of your static contextType. Should be used with type annotation or static contextType.

Example

static contextType = MyContext
// For TS pre-3.7:
context!: React.ContextType<typeof MyContext>
// For TS 3.7 and above:
declare context: React.ContextType<typeof MyContext>

See

React Docs

Inherited from

Component.context

Defined in

node_modules/.pnpm/@types+react@19.0.2/node_modules/@types/react/index.d.ts:941


props

readonly props: Readonly<PortableTextEditorProps<undefined | Editor>>

Inherited from

Component.props

Defined in

node_modules/.pnpm/@types+react@19.0.2/node_modules/@types/react/index.d.ts:957


schemaTypes

schemaTypes: PortableTextMemberSchemaTypes

A lookup table for all the relevant schema types for this portable text type.

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:123


state

state: Readonly<{}>

Inherited from

Component.state

Defined in

node_modules/.pnpm/@types+react@19.0.2/node_modules/@types/react/index.d.ts:958


contextType?

static optional contextType: Context<any>

If set, this.context will be set at runtime to the current value of the given Context.

Example

type MyContext = number
const Ctx = React.createContext<MyContext>(0)
class Foo extends React.Component {
static contextType = Ctx
context!: React.ContextType<typeof Ctx>
render () {
return <>My context's value: {this.context}</>;
}
}

See

https://react.dev/reference/react/Component#static-contexttype

Inherited from

Component.contextType

Defined in

node_modules/.pnpm/@types+react@19.0.2/node_modules/@types/react/index.d.ts:917


displayName

static displayName: string = 'PortableTextEditor'

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:115


propTypes?

static optional propTypes: any

Ignored by React.

Inherited from

Component.propTypes

Defined in

node_modules/.pnpm/@types+react@19.0.2/node_modules/@types/react/index.d.ts:923

Methods

componentDidCatch()?

optional componentDidCatch(error, errorInfo): void

Catches exceptions generated in descendant components. Unhandled exceptions will cause the entire component tree to unmount.

Parameters

error

Error

errorInfo

ErrorInfo

Returns

void

Inherited from

Component.componentDidCatch

Defined in

node_modules/.pnpm/@types+react@19.0.2/node_modules/@types/react/index.d.ts:1190


componentDidMount()?

optional componentDidMount(): void

Called immediately after a component is mounted. Setting state here will trigger re-rendering.

Returns

void

Inherited from

Component.componentDidMount

Defined in

node_modules/.pnpm/@types+react@19.0.2/node_modules/@types/react/index.d.ts:1169


componentDidUpdate()

componentDidUpdate(prevProps): void

Called immediately after updating occurs. Not called for the initial render.

The snapshot is only present if getSnapshotBeforeUpdate is present and returns non-null.

Parameters

prevProps

PortableTextEditorProps<undefined>

Returns

void

Overrides

Component.componentDidUpdate

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:156


componentWillMount()?

optional componentWillMount(): void

Called immediately before mounting occurs, and before Component.render. Avoid introducing any side-effects or subscriptions in this method.

Note: the presence of NewLifecycle.getSnapshotBeforeUpdate getSnapshotBeforeUpdate or StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps prevents this from being invoked.

Returns

void

See

Inherited from

Component.componentWillMount

Defined in

node_modules/.pnpm/@types+react@19.0.2/node_modules/@types/react/index.d.ts:1248


componentWillReceiveProps()?

optional componentWillReceiveProps(nextProps): void

Called when the component may be receiving new props. React may call this even if props have not changed, so be sure to compare new and existing props if you only want to handle changes.

Calling Component.setState generally does not trigger this method.

Note: the presence of NewLifecycle.getSnapshotBeforeUpdate getSnapshotBeforeUpdate or StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps prevents this from being invoked.

Parameters

nextProps

Readonly<PortableTextEditorProps<undefined | Editor>>

Returns

void

See

Inherited from

Component.componentWillReceiveProps

Defined in

node_modules/.pnpm/@types+react@19.0.2/node_modules/@types/react/index.d.ts:1279


componentWillUnmount()?

optional componentWillUnmount(): void

Called immediately before a component is destroyed. Perform any necessary cleanup in this method, such as cancelled network requests, or cleaning up any DOM elements created in componentDidMount.

Returns

void

Inherited from

Component.componentWillUnmount

Defined in

node_modules/.pnpm/@types+react@19.0.2/node_modules/@types/react/index.d.ts:1185


componentWillUpdate()?

optional componentWillUpdate(nextProps, nextState): void

Called immediately before rendering when new props or state is received. Not called for the initial render.

Note: You cannot call Component.setState here.

Note: the presence of NewLifecycle.getSnapshotBeforeUpdate getSnapshotBeforeUpdate or StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps prevents this from being invoked.

Parameters

nextProps

Readonly<PortableTextEditorProps<undefined | Editor>>

nextState

Readonly<{}>

Returns

void

See

Inherited from

Component.componentWillUpdate

Defined in

node_modules/.pnpm/@types+react@19.0.2/node_modules/@types/react/index.d.ts:1311


forceUpdate()

forceUpdate(callback?): void

Parameters

callback?

() => void

Returns

void

Inherited from

Component.forceUpdate

Defined in

node_modules/.pnpm/@types+react@19.0.2/node_modules/@types/react/index.d.ts:954


getSnapshotBeforeUpdate()?

optional getSnapshotBeforeUpdate(prevProps, prevState): any

Runs before React applies the result of Component.render render to the document, and returns an object to be given to componentDidUpdate. Useful for saving things such as scroll position before Component.render render causes changes to it.

Note: the presence of this method prevents any of the deprecated lifecycle events from running.

Parameters

prevProps

Readonly<PortableTextEditorProps<undefined | Editor>>

prevState

Readonly<{}>

Returns

any

Inherited from

Component.getSnapshotBeforeUpdate

Defined in

node_modules/.pnpm/@types+react@19.0.2/node_modules/@types/react/index.d.ts:1226


render()

render(): Element

Returns

Element

Overrides

Component.render

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:216


setEditable()

setEditable(editable): void

Parameters

editable

EditableAPI

Returns

void

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:209


setState()

setState<K>(state, callback?): void

Type Parameters

K extends never

Parameters

state

null | {} | (prevState, props) => null | {} | Pick<{}, K> | Pick<{}, K>

callback?

() => void

Returns

void

Inherited from

Component.setState

Defined in

node_modules/.pnpm/@types+react@19.0.2/node_modules/@types/react/index.d.ts:949


shouldComponentUpdate()?

optional shouldComponentUpdate(nextProps, nextState): boolean

Called to determine whether the change in props and state should trigger a re-render.

Component always returns true. PureComponent implements a shallow comparison on props and state and returns true if any props or states have changed.

If false is returned, Component.render, componentWillUpdate and componentDidUpdate will not be called.

Parameters

nextProps

Readonly<PortableTextEditorProps<undefined | Editor>>

nextState

Readonly<{}>

Returns

boolean

Inherited from

Component.shouldComponentUpdate

Defined in

node_modules/.pnpm/@types+react@19.0.2/node_modules/@types/react/index.d.ts:1180


UNSAFE_componentWillMount()?

optional UNSAFE_componentWillMount(): void

Called immediately before mounting occurs, and before Component.render. Avoid introducing any side-effects or subscriptions in this method.

This method will not stop working in React 17.

Note: the presence of NewLifecycle.getSnapshotBeforeUpdate getSnapshotBeforeUpdate or StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps prevents this from being invoked.

Returns

void

See

Inherited from

Component.UNSAFE_componentWillMount

Defined in

node_modules/.pnpm/@types+react@19.0.2/node_modules/@types/react/index.d.ts:1263


UNSAFE_componentWillReceiveProps()?

optional UNSAFE_componentWillReceiveProps(nextProps): void

Called when the component may be receiving new props. React may call this even if props have not changed, so be sure to compare new and existing props if you only want to handle changes.

Calling Component.setState generally does not trigger this method.

This method will not stop working in React 17.

Note: the presence of NewLifecycle.getSnapshotBeforeUpdate getSnapshotBeforeUpdate or StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps prevents this from being invoked.

Parameters

nextProps

Readonly<PortableTextEditorProps<undefined | Editor>>

Returns

void

See

Inherited from

Component.UNSAFE_componentWillReceiveProps

Defined in

node_modules/.pnpm/@types+react@19.0.2/node_modules/@types/react/index.d.ts:1297


UNSAFE_componentWillUpdate()?

optional UNSAFE_componentWillUpdate(nextProps, nextState): void

Called immediately before rendering when new props or state is received. Not called for the initial render.

Note: You cannot call Component.setState here.

This method will not stop working in React 17.

Note: the presence of NewLifecycle.getSnapshotBeforeUpdate getSnapshotBeforeUpdate or StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps prevents this from being invoked.

Parameters

nextProps

Readonly<PortableTextEditorProps<undefined | Editor>>

nextState

Readonly<{}>

Returns

void

See

Inherited from

Component.UNSAFE_componentWillUpdate

Defined in

node_modules/.pnpm/@types+react@19.0.2/node_modules/@types/react/index.d.ts:1327


activeAnnotations()

static activeAnnotations(editor): PortableTextObject[]

Parameters

editor

PortableTextEditor

Returns

PortableTextObject[]

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:265


addAnnotation()

static addAnnotation<TSchemaType>(editor, type, value?): undefined | AddedAnnotationPaths

Type Parameters

TSchemaType extends object

Parameters

editor

PortableTextEditor

type

TSchemaType

value?

Returns

undefined | AddedAnnotationPaths

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:278


blur()

static blur(editor): void

Parameters

editor

PortableTextEditor

Returns

void

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:284


delete()

static delete(editor, selection, options?): void

Parameters

editor

PortableTextEditor

selection

EditorSelection

options?

EditableAPIDeleteOptions

Returns

void

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:288


findByPath()

static findByPath(editor, path): [undefined | PortableTextSpan | PortableTextObject | PortableTextTextBlock<PortableTextSpan | PortableTextObject>, undefined | Path]

Parameters

editor

PortableTextEditor

path

Path

Returns

[undefined | PortableTextSpan | PortableTextObject | PortableTextTextBlock<PortableTextSpan | PortableTextObject>, undefined | Path]

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:299


findDOMNode()

static findDOMNode(editor, element): undefined | Node

Parameters

editor

PortableTextEditor

element

PortableTextSpan | PortableTextObject | PortableTextTextBlock<PortableTextSpan | PortableTextObject>

Returns

undefined | Node

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:293


focus()

static focus(editor): void

Parameters

editor

PortableTextEditor

Returns

void

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:302


focusBlock()

static focusBlock(editor): undefined | PortableTextBlock

Parameters

editor

PortableTextEditor

Returns

undefined | PortableTextBlock

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:306


focusChild()

static focusChild(editor): undefined | PortableTextChild

Parameters

editor

PortableTextEditor

Returns

undefined | PortableTextChild

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:309


getFragment()

static getFragment(editor): undefined | PortableTextBlock[]

Parameters

editor

PortableTextEditor

Returns

undefined | PortableTextBlock[]

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:390


getSelection()

static getSelection(editor): EditorSelection

Parameters

editor

PortableTextEditor

Returns

EditorSelection

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:314


getValue()

static getValue(editor): undefined | PortableTextBlock[]

Parameters

editor

PortableTextEditor

Returns

undefined | PortableTextBlock[]

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:317


hasBlockStyle()

static hasBlockStyle(editor, blockStyle): boolean

Parameters

editor

PortableTextEditor

blockStyle

string

Returns

boolean

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:320


hasListStyle()

static hasListStyle(editor, listStyle): boolean

Parameters

editor

PortableTextEditor

listStyle

string

Returns

boolean

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:323


insertBlock()

static insertBlock<TSchemaType>(editor, type, value?): undefined | Path

Type Parameters

TSchemaType extends object

Parameters

editor

PortableTextEditor

type

TSchemaType

value?

Returns

undefined | Path

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:340


insertBreak()

static insertBreak(editor): void

Parameters

editor

PortableTextEditor

Returns

void

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:347


insertChild()

static insertChild<TSchemaType>(editor, type, value?): undefined | Path

Type Parameters

TSchemaType extends object

Parameters

editor

PortableTextEditor

type

TSchemaType

value?

Returns

undefined | Path

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:332


isAnnotationActive()

static isAnnotationActive(editor, annotationType): boolean

Parameters

editor

PortableTextEditor

annotationType

string

Returns

boolean

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:270


isCollapsedSelection()

static isCollapsedSelection(editor): boolean

Parameters

editor

PortableTextEditor

Returns

boolean

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:326


isExpandedSelection()

static isExpandedSelection(editor): boolean

Parameters

editor

PortableTextEditor

Returns

boolean

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:328


isMarkActive()

static isMarkActive(editor, mark): boolean

Parameters

editor

PortableTextEditor

mark

string

Returns

boolean

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:330


isObjectPath()

static isObjectPath(_editor, path): boolean

Parameters

_editor

PortableTextEditor

path

Path

Returns

boolean

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:356


isSelectionsOverlapping()

static isSelectionsOverlapping(editor, selectionA, selectionB): boolean

Parameters

editor

PortableTextEditor

selectionA

EditorSelection

selectionB

EditorSelection

Returns

boolean

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:404


isVoid()

static isVoid(editor, element): boolean

Parameters

editor

PortableTextEditor

element

PortableTextSpan | PortableTextObject | PortableTextTextBlock<PortableTextSpan | PortableTextObject>

Returns

boolean

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:350


marks()

static marks(editor): string[]

Parameters

editor

PortableTextEditor

Returns

string[]

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:362


redo()

static redo(editor): void

Parameters

editor

PortableTextEditor

Returns

void

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:400


removeAnnotation()

static removeAnnotation<TSchemaType>(editor, type): void

Type Parameters

TSchemaType extends object

Parameters

editor

PortableTextEditor

type

TSchemaType

Returns

void

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:372


select()

static select(editor, selection): void

Parameters

editor

PortableTextEditor

selection

EditorSelection

Returns

void

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:365


toggleBlockStyle()

static toggleBlockStyle(editor, blockStyle): void

Parameters

editor

PortableTextEditor

blockStyle

string

Returns

void

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:376


toggleList()

static toggleList(editor, listStyle): void

Parameters

editor

PortableTextEditor

listStyle

string

Returns

void

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:383


toggleMark()

static toggleMark(editor, mark): void

Parameters

editor

PortableTextEditor

mark

string

Returns

void

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:386


undo()

static undo(editor): void

Parameters

editor

PortableTextEditor

Returns

void

Defined in

packages/editor/src/editor/PortableTextEditor.tsx:396