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:207

Properties

_blockCollection

protected readonly _blockCollection: BlockCollection

Defined in

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


_blocks

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

Defined in

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


_crud

protected readonly _crud: DocCRUD

Defined in

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


_disposeBlockUpdated

protected readonly _disposeBlockUpdated: Disposable

Defined in

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


_query

protected readonly _query: Query

Defined in

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


_readonly?

protected readonly optional _readonly: boolean

Defined in

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


_schema

protected readonly _schema: Schema

Defined in

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


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:44

Accessors

awarenessStore

get awarenessStore(): AwarenessStore<BlockSuiteFlags>

Returns

AwarenessStore<BlockSuiteFlags>

Defined in

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


awarenessSync

get awarenessSync(): AwarenessEngine

Returns

AwarenessEngine

Defined in

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


blobSync

get blobSync(): BlobEngine

Returns

BlobEngine

Defined in

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


blockCollection

get blockCollection(): BlockCollection

Returns

BlockCollection

Defined in

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


blocks

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

Returns

Signal<Record<string, Block>>

Defined in

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


blockSize

get blockSize(): number

Returns

number

Defined in

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


canRedo

get canRedo(): boolean

Returns

boolean

Defined in

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


canUndo

get canUndo(): boolean

Returns

boolean

Defined in

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


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:114


clear

get clear(): () => void

Returns

Function

Returns

void

Defined in

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


collection

get collection(): DocCollection

Returns

DocCollection

Defined in

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


docSync

get docSync(): DocEngine

Returns

DocEngine

Defined in

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


generateBlockId

get generateBlockId(): () => string

Returns

Function

Returns

string

Defined in

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


history

get history(): UndoManager

Returns

UndoManager

Defined in

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


id

get id(): string

Returns

string

Defined in

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


isEmpty

get isEmpty(): boolean

Returns

boolean

Defined in

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


loaded

get loaded(): boolean

Returns

boolean

Defined in

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


meta

get meta(): undefined | DocMeta

Returns

undefined | DocMeta

Defined in

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


readonly

get readonly(): boolean

Returns

boolean

Defined in

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


ready

get ready(): boolean

Returns

boolean

Defined in

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


redo

get redo(): () => void

Returns

Function

Returns

void

Defined in

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


resetHistory

get resetHistory(): () => void

Returns

Function

Returns

void

Defined in

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


root

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

Returns

null | BlockModel<object, SignaledProps<object>>

Defined in

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


rootDoc

get rootDoc(): BlockSuiteDoc

Returns

BlockSuiteDoc

Defined in

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


schema

get schema(): Schema

Returns

Schema

Defined in

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


spaceDoc

get spaceDoc(): Doc

Returns

Doc

Defined in

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


Text

get Text(): typeof Text

Returns

typeof Text

Defined in

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


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:195


undo

get undo(): () => void

Returns

Function

Returns

void

Defined in

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


withoutTransact

get withoutTransact(): (callback) => void

Returns

Function

Parameters

callback

Returns

void

Defined in

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

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:346

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:353


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:388


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:411


deleteBlock()

deleteBlock(model, options): void

Parameters

model: BlockModel<object, SignaledProps<object>>

options = ...

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

options.deleteChildren?: boolean

Returns

void

Defined in

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


dispose()

dispose(): void

Returns

void

Defined in

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


getBlock()

getBlock(id): undefined | Block

Parameters

id: string

Returns

undefined | Block

Defined in

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


getBlock$()

getBlock$(id): undefined | Block

Parameters

id: string

Returns

undefined | Block

Defined in

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


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:499


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:507


getBlocks()

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

Returns

BlockModel<object, SignaledProps<object>>[]

Defined in

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


getBlocksByFlavour()

getBlocksByFlavour(blockFlavour): Block[]

Parameters

blockFlavour: string | string[]

Returns

Block[]

Defined in

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


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:526


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:533


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:541


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:552


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:559


getSchemaByFlavour()

getSchemaByFlavour(flavour): undefined | object

Parameters

flavour: Flavour

Returns

undefined | object

Defined in

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


hasBlock()

hasBlock(id): boolean

Parameters

id: string

Returns

boolean

Defined in

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


hasBlockById()

hasBlockById(id): boolean

Parameters

id: string

Returns

boolean

Deprecated

Use hasBlock instead.

Defined in

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


load()

load(initFn?): Doc

Parameters

initFn?

Returns

Doc

Defined in

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


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:589


updateBlock()

updateBlock(model, props)

updateBlock<T>(model, props): void

Type Parameters

T extends Partial<BlockProps>

Parameters

model: BlockModel<object, SignaledProps<object>>

props: T

Returns

void

Defined in

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

updateBlock(model, callback)

updateBlock(model, callback): void

Parameters

model: BlockModel<object, SignaledProps<object>>

callback

Returns

void

Defined in

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