Skip to content

BlockSuite API Documentation / @blocksuite/blocks / DocModeProvider

Interface: DocModeProvider

Properties

getEditorMode()

getEditorMode: () => null | DocMode

Get current editor mode.

Returns

null | DocMode

The editor mode.

Defined in

packages/affine/shared/dist/services/doc-mode-service.d.ts:48


getPrimaryMode()

getPrimaryMode: (docId) => DocMode

Get the primary mode of the doc. Normally, it would be used to query the mode of other doc.

Parameters

docId: string

The id of the doc.

Returns

DocMode

The primary mode of the document.

Defined in

packages/affine/shared/dist/services/doc-mode-service.d.ts:21


onPrimaryModeChange()

onPrimaryModeChange: (handler, docId) => Disposable

Subscribe to changes in the primary mode of the doc. For example: Embed-linked-doc-block will subscribe to the primary mode of the linked doc, and will display different UI according to the primary mode of the linked doc.

Parameters

handler

The handler to call when the primary mode of certain doc changes.

docId: string

The id of the doc.

Returns

Disposable

A disposable to stop the subscription.

Defined in

packages/affine/shared/dist/services/doc-mode-service.d.ts:37


setEditorMode()

setEditorMode: (mode) => void

Set the editor mode. Normally, it would be used to set the mode of the current editor. When patch or override the doc mode service, can pass a callback to set the editor mode.

Parameters

mode: DocMode

The mode to set.

Returns

void

Defined in

packages/affine/shared/dist/services/doc-mode-service.d.ts:43


setPrimaryMode()

setPrimaryMode: (mode, docId) => void

Set the primary mode of the doc. This would not affect the current editor mode. If you want to switch the editor mode, use setEditorMode instead.

Parameters

mode: DocMode

The mode to set.

docId: string

The id of the doc.

Returns

void

Defined in

packages/affine/shared/dist/services/doc-mode-service.d.ts:14


togglePrimaryMode()

togglePrimaryMode: (docId) => DocMode

Toggle the primary mode of the doc.

Parameters

docId: string

The id of the doc.

Returns

DocMode

The new primary mode of the doc.

Defined in

packages/affine/shared/dist/services/doc-mode-service.d.ts:27