Skip to content

BlockSuite API Documentation / @blocksuite/store / Doc

Class: Doc

Constructors

new Doc()

new Doc(__namedParameters): Doc

Parameters

__namedParameters: DocOptions

Returns

Doc

Defined in

packages/framework/store/src/store/doc/doc.ts:269

Properties

_blockCollection

protected readonly _blockCollection: BlockCollection

Defined in

packages/framework/store/src/store/doc/doc.ts:28


_blocks

protected readonly _blocks: Signal<Record<string, Block>>

Defined in

packages/framework/store/src/store/doc/doc.ts:30


_crud

protected readonly _crud: DocCRUD

Defined in

packages/framework/store/src/store/doc/doc.ts:32


_disposeBlockUpdated

protected readonly _disposeBlockUpdated: Disposable

Defined in

packages/framework/store/src/store/doc/doc.ts:34


_query

protected readonly _query: Query

Defined in

packages/framework/store/src/store/doc/doc.ts:36


_readonly?

protected readonly optional _readonly: boolean

Defined in

packages/framework/store/src/store/doc/doc.ts:41


_schema

protected readonly _schema: Schema

Defined in

packages/framework/store/src/store/doc/doc.ts:43


slots

readonly slots: object & object

Type declaration

historyUpdated

historyUpdated: Slot<void>

yBlockUpdated

yBlockUpdated: Slot<object | object>

Type declaration

blockUpdated

blockUpdated: Slot<object | object | object>

ready

ready: Slot<void>

This is always triggered after doc.load is called.

rootAdded

rootAdded: Slot<string>

This fires when the root block is added via API call or has just been initialized from existing ydoc. useful for internal block UI components to start subscribing following up events. Note that at this moment, the whole block tree may not be fully initialized yet.

rootDeleted

rootDeleted: Slot<string>

Defined in

packages/framework/store/src/store/doc/doc.ts:45


updateBlock()

updateBlock: <T>(model, props) => void(model, callback) => void

Type Parameters

T extends Partial<BlockProps>

Parameters

model: BlockModel<object, SignaledProps<object>>

props: T

Returns

void

Parameters

model: BlockModel<object, SignaledProps<object>>

callback

Returns

void

Defined in

packages/framework/store/src/store/doc/doc.ts:79

Accessors

awarenessStore

get awarenessStore(): AwarenessStore<BlockSuiteFlags>

Returns

AwarenessStore<BlockSuiteFlags>

Defined in

packages/framework/store/src/store/doc/doc.ts:144


awarenessSync

get awarenessSync(): AwarenessEngine

Returns

AwarenessEngine

Defined in

packages/framework/store/src/store/doc/doc.ts:148


blobSync

get blobSync(): BlobEngine

Returns

BlobEngine

Defined in

packages/framework/store/src/store/doc/doc.ts:152


blockCollection

get blockCollection(): BlockCollection

Returns

BlockCollection

Defined in

packages/framework/store/src/store/doc/doc.ts:156


blocks

get blocks(): Signal<Record<string, Block>>

Returns

Signal<Record<string, Block>>

Defined in

packages/framework/store/src/store/doc/doc.ts:160


blockSize

get blockSize(): number

Returns

number

Defined in

packages/framework/store/src/store/doc/doc.ts:164


canRedo

get canRedo(): boolean

Returns

boolean

Defined in

packages/framework/store/src/store/doc/doc.ts:168


canUndo

get canUndo(): boolean

Returns

boolean

Defined in

packages/framework/store/src/store/doc/doc.ts:172


captureSync

get captureSync(): () => void

Returns

Function

Capture current operations to undo stack synchronously.

Returns

void

Defined in

packages/framework/store/src/store/doc/doc.ts:176


clear

get clear(): () => void

Returns

Function

Returns

void

Defined in

packages/framework/store/src/store/doc/doc.ts:180


collection

get collection(): DocCollection

Returns

DocCollection

Defined in

packages/framework/store/src/store/doc/doc.ts:184


docSync

get docSync(): DocEngine

Returns

DocEngine

Defined in

packages/framework/store/src/store/doc/doc.ts:188


generateBlockId

get generateBlockId(): () => string

Returns

Function

Returns

string

Defined in

packages/framework/store/src/store/doc/doc.ts:192


history

get history(): UndoManager

Returns

UndoManager

Defined in

packages/framework/store/src/store/doc/doc.ts:196


id

get id(): string

Returns

string

Defined in

packages/framework/store/src/store/doc/doc.ts:200


isEmpty

get isEmpty(): boolean

Returns

boolean

Defined in

packages/framework/store/src/store/doc/doc.ts:204


loaded

get loaded(): boolean

Returns

boolean

Defined in

packages/framework/store/src/store/doc/doc.ts:208


meta

get meta(): undefined | DocMeta

Returns

undefined | DocMeta

Defined in

packages/framework/store/src/store/doc/doc.ts:212


readonly

get readonly(): boolean

Returns

boolean

Defined in

packages/framework/store/src/store/doc/doc.ts:216


ready

get ready(): boolean

Returns

boolean

Defined in

packages/framework/store/src/store/doc/doc.ts:223


redo

get redo(): () => void

Returns

Function

Returns

void

Defined in

packages/framework/store/src/store/doc/doc.ts:227


resetHistory

get resetHistory(): () => void

Returns

Function

Returns

void

Defined in

packages/framework/store/src/store/doc/doc.ts:231


root

get root(): null | BlockModel<object, SignaledProps<object>>

Returns

null | BlockModel<object, SignaledProps<object>>

Defined in

packages/framework/store/src/store/doc/doc.ts:235


rootDoc

get rootDoc(): BlockSuiteDoc

Returns

BlockSuiteDoc

Defined in

packages/framework/store/src/store/doc/doc.ts:241


schema

get schema(): Schema

Returns

Schema

Defined in

packages/framework/store/src/store/doc/doc.ts:245


spaceDoc

get spaceDoc(): Doc

Returns

Doc

Defined in

packages/framework/store/src/store/doc/doc.ts:249


Text

get Text(): typeof Text

Returns

typeof Text

Defined in

packages/framework/store/src/store/doc/doc.ts:253


transact

get transact(): (fn, shouldTransact) => void

Returns

Function

If shouldTransact is false, the transaction will not be push to the history stack.

Parameters

fn

shouldTransact: boolean = ...

Returns

void

Defined in

packages/framework/store/src/store/doc/doc.ts:257


undo

get undo(): () => void

Returns

Function

Returns

void

Defined in

packages/framework/store/src/store/doc/doc.ts:261


withoutTransact

get withoutTransact(): (callback) => void

Returns

Function

Parameters

callback

Returns

void

Defined in

packages/framework/store/src/store/doc/doc.ts:265

Methods

addBlock()

addBlock(flavour, blockProps, parent, parentIndex)

addBlock<Key>(flavour, blockProps?, parent?, parentIndex?): string

Type Parameters

Key extends Flavour

Parameters

flavour: Key

blockProps?: Partial<BlockModels[Key] extends BlockModel<U, SignaledProps<U>> ? U : never>

parent?: null | string | BlockModel<object, SignaledProps<object>>

parentIndex?: number

Returns

string

Defined in

packages/framework/store/src/store/doc/doc.ts:408

addBlock(flavour, blockProps, parent, parentIndex)

addBlock(flavour, blockProps?, parent?, parentIndex?): string

Parameters

flavour: never

blockProps?: Partial<BlockSysProps & Record<string, unknown> & Omit<BlockProps, "flavour">>

parent?: null | string | BlockModel<object, SignaledProps<object>>

parentIndex?: number

Returns

string

Defined in

packages/framework/store/src/store/doc/doc.ts:415


addBlocks()

addBlocks(blocks, parent?, parentIndex?): string[]

Parameters

blocks: object[]

parent?: null | string | BlockModel<object, SignaledProps<object>>

parentIndex?: number

Returns

string[]

Defined in

packages/framework/store/src/store/doc/doc.ts:450


addSiblingBlocks()

addSiblingBlocks(targetModel, props, place): string[]

Parameters

targetModel: BlockModel<object, SignaledProps<object>>

props: Partial<BlockProps>[]

place: "after" | "before" = 'after'

Returns

string[]

Defined in

packages/framework/store/src/store/doc/doc.ts:473


deleteBlock()

deleteBlock(model, options): void

Parameters

model: DraftModel

options = ...

options.bringChildrenTo?: BlockModel<object, SignaledProps<object>>

options.deleteChildren?: boolean

Returns

void

Defined in

packages/framework/store/src/store/doc/doc.ts:510


dispose()

dispose(): void

Returns

void

Defined in

packages/framework/store/src/store/doc/doc.ts:541


getBlock()

getBlock(id): undefined | Block

Parameters

id: string

Returns

undefined | Block

Defined in

packages/framework/store/src/store/doc/doc.ts:549


getBlock$()

getBlock$(id): undefined | Block

Parameters

id: string

Returns

undefined | Block

Defined in

packages/framework/store/src/store/doc/doc.ts:553


getBlockByFlavour()

getBlockByFlavour(blockFlavour): BlockModel<object, SignaledProps<object>>[]

Parameters

blockFlavour: string | string[]

Returns

BlockModel<object, SignaledProps<object>>[]

Deprecated

Use getBlocksByFlavour instead.

Defined in

packages/framework/store/src/store/doc/doc.ts:561


getBlockById()

getBlockById<Model>(id): null | Model

Type Parameters

Model extends BlockModel<object, SignaledProps<object>> = BlockModel<object, SignaledProps<object>>

Parameters

id: string

Returns

null | Model

Deprecated

Use getBlock instead.

Defined in

packages/framework/store/src/store/doc/doc.ts:569


getBlocks()

getBlocks(): BlockModel<object, SignaledProps<object>>[]

Returns

BlockModel<object, SignaledProps<object>>[]

Defined in

packages/framework/store/src/store/doc/doc.ts:575


getBlocksByFlavour()

getBlocksByFlavour(blockFlavour): Block[]

Parameters

blockFlavour: string | string[]

Returns

Block[]

Defined in

packages/framework/store/src/store/doc/doc.ts:579


getNext()

getNext(block): null | BlockModel<object, SignaledProps<object>>

Parameters

block: string | BlockModel<object, SignaledProps<object>>

Returns

null | BlockModel<object, SignaledProps<object>>

Defined in

packages/framework/store/src/store/doc/doc.ts:588


getNexts()

getNexts(block): BlockModel<object, SignaledProps<object>>[]

Parameters

block: string | BlockModel<object, SignaledProps<object>>

Returns

BlockModel<object, SignaledProps<object>>[]

Defined in

packages/framework/store/src/store/doc/doc.ts:595


getParent()

getParent(target): null | BlockModel<object, SignaledProps<object>>

Parameters

target: string | BlockModel<object, SignaledProps<object>>

Returns

null | BlockModel<object, SignaledProps<object>>

Defined in

packages/framework/store/src/store/doc/doc.ts:603


getPrev()

getPrev(block): null | BlockModel<object, SignaledProps<object>>

Parameters

block: string | BlockModel<object, SignaledProps<object>>

Returns

null | BlockModel<object, SignaledProps<object>>

Defined in

packages/framework/store/src/store/doc/doc.ts:614


getPrevs()

getPrevs(block): BlockModel<object, SignaledProps<object>>[]

Parameters

block: string | BlockModel<object, SignaledProps<object>>

Returns

BlockModel<object, SignaledProps<object>>[]

Defined in

packages/framework/store/src/store/doc/doc.ts:621


getSchemaByFlavour()

getSchemaByFlavour(flavour): undefined | object

Parameters

flavour: Flavour

Returns

undefined | object

Defined in

packages/framework/store/src/store/doc/doc.ts:629


hasBlock()

hasBlock(id): boolean

Parameters

id: string

Returns

boolean

Defined in

packages/framework/store/src/store/doc/doc.ts:633


hasBlockById()

hasBlockById(id): boolean

Parameters

id: string

Returns

boolean

Deprecated

Use hasBlock instead.

Defined in

packages/framework/store/src/store/doc/doc.ts:641


load()

load(initFn?): Doc

Parameters

initFn?

Returns

Doc

Defined in

packages/framework/store/src/store/doc/doc.ts:645


moveBlocks()

moveBlocks(blocksToMove, newParent, targetSibling, shouldInsertBeforeSibling): void

Parameters

blocksToMove: BlockModel<object, SignaledProps<object>>[]

newParent: BlockModel<object, SignaledProps<object>>

targetSibling: null | BlockModel<object, SignaledProps<object>> = null

shouldInsertBeforeSibling: boolean = true

Returns

void

Defined in

packages/framework/store/src/store/doc/doc.ts:651