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(
std):DocModeService
Parameters 
• std: BlockStdScope
Returns 
Overrides 
Defined in 
packages/affine/shared/dist/services/doc-mode-service.d.ts:53
Properties 
std 
std:
BlockStdScope
Defined in 
packages/affine/shared/dist/services/doc-mode-service.d.ts:52
Methods 
getEditorMode() 
getEditorMode():
null
Get current editor mode.
Returns 
null
The editor mode.
Implementation of 
Defined in 
packages/affine/shared/dist/services/doc-mode-service.d.ts:55
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 
The primary mode of the document.
Implementation of 
DocModeProvider.getPrimaryMode
Defined in 
packages/affine/shared/dist/services/doc-mode-service.d.ts:56
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
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:57
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 
Defined in 
packages/affine/shared/dist/services/doc-mode-service.d.ts:58
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:59
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:60
setup() 
staticsetup(di):void
Parameters 
• di: Container
Returns 
void
Overrides 
Defined in 
packages/affine/shared/dist/services/doc-mode-service.d.ts:54