Skip to content

BlockSuite API Documentation / @blocksuite/blocks / DocModeService

Class: DocModeService

Generic extension. Extensions are used to set up the dependency injection container. In most cases, you won't need to use this class directly. We provide helper classes like CommandExtension and BlockViewExtension to make it easier to create extensions.

Extends

Implements

Constructors

new DocModeService()

new DocModeService(): DocModeService

Returns

DocModeService

Inherited from

Extension.constructor

Methods

getEditorMode()

getEditorMode(): null | DocMode

Get current editor mode.

Returns

null | DocMode

The editor mode.

Implementation of

DocModeProvider.getEditorMode

Defined in

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


getPrimaryMode()

getPrimaryMode(id): DocMode

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

Parameters

id

string

Returns

DocMode

The primary mode of the document.

Implementation of

DocModeProvider.getPrimaryMode

Defined in

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


onPrimaryModeChange()

onPrimaryModeChange(handler, id): 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

(mode) => void

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

id

string

Returns

Disposable

A disposable to stop the subscription.

Implementation of

DocModeProvider.onPrimaryModeChange

Defined in

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


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

Implementation of

DocModeProvider.setEditorMode

Defined in

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


setPrimaryMode()

setPrimaryMode(mode, id): 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.

id

string

Returns

void

Implementation of

DocModeProvider.setPrimaryMode

Defined in

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


togglePrimaryMode()

togglePrimaryMode(id): "edgeless" | "page"

Toggle the primary mode of the doc.

Parameters

id

string

Returns

"edgeless" | "page"

The new primary mode of the doc.

Implementation of

DocModeProvider.togglePrimaryMode

Defined in

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


setup()

static setup(di): void

Parameters

di

Container

Returns

void

Overrides

Extension.setup

Defined in

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