Skip to main content

EditorOptions

@blockslides/core


@blockslides/core / EditorOptions

Interface: EditorOptions

Defined in: blockslides/packages/core/src/types.ts:286

Properties

element

element: Element | { mount: HTMLElement; } | (editor) => void | null

Defined in: blockslides/packages/core/src/types.ts:294

The element to bind the editor to:

  • If an Element is passed, the editor will be mounted appended to that element
  • If null is passed, the editor will not be mounted automatically
  • If an object with a mount property is passed, the editor will be mounted to that element
  • If a function is passed, it will be called with the editor's element, which should place the editor within the document

content

content: Content

Defined in: blockslides/packages/core/src/types.ts:302

The content of the editor (HTML, JSON, or a JSON array)


extensions

extensions: Extensions

Defined in: blockslides/packages/core/src/types.ts:306

The extensions to use


theme?

optional theme: string | Theme | ThemeConfig

Defined in: blockslides/packages/core/src/types.ts:321

Editor theme for UI styling

Can be:

  • String: 'light' or 'dark' (built-in themes)
  • Full theme object with all colors
  • Partial theme with extends property to override built-in theme

Default

undefined (no theme applied)

Examples

'light'
'dark'
{ name: 'custom', colors: { background: '#000', ... } }
{ extends: 'dark', colors: { background: '#0a0a0a' } }

injectCSS

injectCSS: boolean

Defined in: blockslides/packages/core/src/types.ts:328

Whether to inject base CSS styles


injectNonce

injectNonce: string | undefined

Defined in: blockslides/packages/core/src/types.ts:332

A nonce to use for CSP while injecting styles


autofocus

autofocus: FocusPosition

Defined in: blockslides/packages/core/src/types.ts:336

The editor's initial focus position


editable

editable: boolean

Defined in: blockslides/packages/core/src/types.ts:340

Whether the editor is editable


editorProps

editorProps: EditorProps

Defined in: blockslides/packages/core/src/types.ts:344

The editor's props


parseOptions

parseOptions: ParseOptions

Defined in: blockslides/packages/core/src/types.ts:348

The editor's content parser options


coreExtensionOptions?

optional coreExtensionOptions: object

Defined in: blockslides/packages/core/src/types.ts:352

The editor's core extension options

clipboardTextSerializer?

optional clipboardTextSerializer: object

clipboardTextSerializer.blockSeparator?

optional blockSeparator: string

delete?

optional delete: object

delete.async?

optional async: boolean

Whether the delete extension should be called asynchronously to avoid blocking the editor while processing deletions

Default
true deletion events are called asynchronously
delete.filterTransaction()?

optional filterTransaction: (transaction) => boolean

Allows filtering the transactions that are processed by the delete extension. If the function returns true, the transaction will be ignored.

Parameters
transaction

Transaction

Returns

boolean


enableInputRules

enableInputRules: EnableRules

Defined in: blockslides/packages/core/src/types.ts:372

Whether to enable input rules behavior


enablePasteRules

enablePasteRules: EnableRules

Defined in: blockslides/packages/core/src/types.ts:376

Whether to enable paste rules behavior


enableCoreExtensions?

optional enableCoreExtensions: boolean | Partial<Record<"drop" | "paste" | "delete" | "editable" | "clipboardTextSerializer" | "commands" | "focusEvents" | "keymap" | "tabindex", false>>

Defined in: blockslides/packages/core/src/types.ts:394

Determines whether core extensions are enabled.

If set to false, all core extensions will be disabled. To disable specific core extensions, provide an object where the keys are the extension names and the values are false. Extensions not listed in the object will remain enabled.

Examples

// Disable all core extensions
enabledCoreExtensions: false
// Disable only the keymap core extension
enabledCoreExtensions: { keymap: false }

Default

true

enableContentCheck

enableContentCheck: boolean

Defined in: blockslides/packages/core/src/types.ts:416

If true, the editor will check the content for errors on initialization. Emitting the contentError event if the content is invalid. Which can be used to show a warning or error message to the user.

Default

false

emitContentError

emitContentError: boolean

Defined in: blockslides/packages/core/src/types.ts:425

If true, the editor will emit the contentError event if invalid content is encountered but enableContentCheck is false. This lets you preserve the invalid editor content while still showing a warning or error message to the user.

Default

false

onBeforeCreate()

onBeforeCreate: (props) => void

Defined in: blockslides/packages/core/src/types.ts:429

Called before the editor is constructed.

Parameters

props
editor

SlideEditor

The editor instance

Returns

void


onCreate()

onCreate: (props) => void

Defined in: blockslides/packages/core/src/types.ts:433

Called after the editor is constructed.

Parameters

props
editor

SlideEditor

The editor instance

Returns

void


onMount()

onMount: (props) => void

Defined in: blockslides/packages/core/src/types.ts:437

Called when the editor is mounted.

Parameters

props
editor

SlideEditor

The editor instance

Returns

void


onUnmount()

onUnmount: (props) => void

Defined in: blockslides/packages/core/src/types.ts:441

Called when the editor is unmounted.

Parameters

props
editor

SlideEditor

The editor instance

Returns

void


onContentError()

onContentError: (props) => void

Defined in: blockslides/packages/core/src/types.ts:446

Called when the editor encounters an error while parsing the content. Only enabled if enableContentCheck is true.

Parameters

props
editor

SlideEditor

The editor instance

error

Error

The error that occurred while parsing the content

disableCollaboration

() => void

If called, will re-initialize the editor with the collaboration extension removed. This will prevent syncing back deletions of content not present in the current schema.

Returns

void


onUpdate()

onUpdate: (props) => void

Defined in: blockslides/packages/core/src/types.ts:450

Called when the editor's content is updated.

Parameters

props
editor

SlideEditor

The editor instance

transaction

Transaction

The transaction that caused the update

appendedTransactions

Transaction[]

Appended transactions that were added to the initial transaction by plugins

Returns

void


onSelectionUpdate()

onSelectionUpdate: (props) => void

Defined in: blockslides/packages/core/src/types.ts:454

Called when the editor's selection is updated.

Parameters

props
editor

SlideEditor

The editor instance

transaction

Transaction

The transaction that caused the selection update

Returns

void


onTransaction()

onTransaction: (props) => void

Defined in: blockslides/packages/core/src/types.ts:458

Called after a transaction is applied to the editor.

Parameters

props
editor

SlideEditor

The editor instance

transaction

Transaction

The initial transaction

appendedTransactions

Transaction[]

Appended transactions that were added to the initial transaction by plugins

Returns

void


onFocus()

onFocus: (props) => void

Defined in: blockslides/packages/core/src/types.ts:462

Called on focus events.

Parameters

props
editor

SlideEditor

The editor instance

event

FocusEvent

The focus event

transaction

Transaction

The transaction that caused the focus

Returns

void


onBlur()

onBlur: (props) => void

Defined in: blockslides/packages/core/src/types.ts:466

Called on blur events.

Parameters

props
editor

SlideEditor

The editor instance

event

FocusEvent

The focus event

transaction

Transaction

The transaction that caused the blur

Returns

void


onDestroy()

onDestroy: (props) => void

Defined in: blockslides/packages/core/src/types.ts:470

Called when the editor is destroyed.

Parameters

props

void

Returns

void


onPaste()

onPaste: (e, slice) => void

Defined in: blockslides/packages/core/src/types.ts:474

Called when content is pasted into the editor.

Parameters

e

ClipboardEvent

slice

Slice

Returns

void


onDrop()

onDrop: (e, slice, moved) => void

Defined in: blockslides/packages/core/src/types.ts:478

Called when content is dropped into the editor.

Parameters

e

DragEvent

slice

Slice

moved

boolean

Returns

void


onDelete()

onDelete: (props) => void

Defined in: blockslides/packages/core/src/types.ts:482

Called when content is deleted from the editor.

Parameters

props

object & { type: "node"; node: Node; newFrom: number; newTo: number; } | { type: "mark"; mark: Mark; }

Returns

void