Skip to content

BlockSuite API Documentation / @blocksuite/store / Doc

Class: Doc

Extends

Constructors

new Doc(__namedParameters)

new Doc(__namedParameters): Doc

Parameters

__namedParameters: DocOptions

Returns

Doc

Overrides

Space.constructor

Source

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

Properties

_blockTree

private readonly _blockTree: BlockTree

Source

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


_collection

private readonly _collection: DocCollection

Source

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


_history

private _history: UndoManager

Source

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


_idGenerator

private readonly _idGenerator: IdGenerator

Source

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


_ready

private _ready: boolean = false

Indicate whether the block tree is ready

Source

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


_root

private _root: null | BlockModel<object> = null

Source

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


_shouldTransact

private _shouldTransact: boolean = true

Source

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


_yBlocks

protected readonly _yBlocks: Map<YBlock>

Inherited from

Space._yBlocks

Source

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


_ySpaceDoc

Internal

protected readonly _ySpaceDoc: Doc

Used for convenient access to the underlying Yjs map, can be used interchangeably with ySpace

Inherited from

Space._ySpaceDoc

Source

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


awarenessStore

readonly awarenessStore: AwarenessStore<BlockSuiteFlags>

Inherited from

Space.awarenessStore

Source

packages/framework/store/src/store/space.ts:17


id

readonly id: string

Inherited from

Space.id

Source

packages/framework/store/src/store/space.ts:15


rootDoc

readonly rootDoc: BlockSuiteDoc

Inherited from

Space.rootDoc

Source

packages/framework/store/src/store/space.ts:16


slots

readonly slots: Object

slots.blockUpdated

blockUpdated: Slot<Object | Object | Object>

slots.historyUpdated

historyUpdated: Slot<void>

slots.ready

ready: Slot<void>

This fires when the block tree is initialized via API call or underlying existing ydoc binary. (Equivalent to when you execute Doc.load) Note that this is different with the doc.loaded field, since loaded only indicates that the ydoc is loaded, not the block tree.

slots.rootAdded

rootAdded: Slot<BlockModel<object>>

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.

slots.rootDeleted

rootDeleted: Slot<string>

Source

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

Accessors

Text

get Text(): typeof Text

Returns

typeof Text

Source

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


blob

get blob(): BlobManager

Returns

BlobManager

Source

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


canRedo

get canRedo(): boolean

Returns

boolean

Source

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


canUndo

get canUndo(): boolean

Returns

boolean

Source

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


collection

get collection(): DocCollection

Returns

DocCollection

Source

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


history

get history(): UndoManager

Returns

UndoManager

Source

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


isEmpty

get isEmpty(): boolean

Returns

boolean

Source

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


loaded

get loaded(): boolean

Returns

boolean

Source

packages/framework/store/src/store/space.ts:48


meta

get meta(): undefined | DocMeta

Returns

undefined | DocMeta

Source

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


readonly

get readonly(): boolean

Returns

boolean

Source

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


ready

get ready(): boolean

Returns

boolean

Source

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


root

get root(): null | BlockModel<object>

Returns

null | BlockModel<object>

Source

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


schema

get schema(): Schema

Returns

Schema

Source

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


spaceDoc

get spaceDoc(): Doc

Returns

Doc

Source

packages/framework/store/src/store/space.ts:52


yBlocks

get yBlocks(): Map<State[keyof State]>

Returns

Map<State[keyof State]>

Source

packages/framework/store/src/store/space.ts:44

Methods

_getYBlock()

private _getYBlock(id): null | YBlock

Parameters

id: string

Returns

null | YBlock

Source

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


_handleVersion()

private _handleVersion(): void

Returns

void

Source

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


_handleYBlockAdd()

private _handleYBlockAdd(id): void

Parameters

id: string

Returns

void

Source

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


_handleYBlockDelete()

private _handleYBlockDelete(id): void

Parameters

id: string

Returns

void

Source

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


_handleYEvent()

private _handleYEvent(event): void

Parameters

event: YEvent<Text | Array<unknown> | YBlock>

Returns

void

Source

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


_handleYEvents()

private _handleYEvents(events): void

Parameters

events: YEvent<Text | YBlock>[]

Returns

void

Source

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


_historyObserver()

private _historyObserver(): void

Returns

void

Source

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


_initYBlocks()

private _initYBlocks(): void

Returns

void

Source

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


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> ? U : never>

parent?: null | string | BlockModel<object>

parentIndex?: number

Returns

string

Source

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

addBlock(flavour, blockProps, parent, parentIndex)

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

Parameters

flavour: never

blockProps?: Partial<BlockSysProps & Object & Omit<BlockProps, "flavour">>

parent?: null | string | BlockModel<object>

parentIndex?: number

Returns

string

Source

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


addBlocks()

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

Parameters

blocks: Object[]

parent?: null | string | BlockModel<object>

parentIndex?: number

Returns

string[]

Source

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


addSiblingBlocks()

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

Parameters

targetModel: BlockModel<object>

props: Partial<BlockProps>[]

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

Returns

string[]

Source

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


captureSync()

captureSync(): void

Capture current operations to undo stack synchronously.

Returns

void

Source

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


clear()

clear(): void

Returns

void

Inherited from

Space.clear

Source

packages/framework/store/src/store/space.ts:73


deleteBlock()

deleteBlock(model, options): void

Parameters

model: BlockModel<object>

options= undefined

options.bringChildrenTo?: BlockModel<object>

options.deleteChildren?: boolean

Returns

void

Source

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


destroy()

destroy(): void

Returns

void

Inherited from

Space.destroy

Source

packages/framework/store/src/store/space.ts:67


dispose()

dispose(): void

Returns

void

Source

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


generateBlockId()

generateBlockId(): string

Returns

string

Source

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


getBlockByFlavour()

getBlockByFlavour(blockFlavour): BlockModel<object>[]

Parameters

blockFlavour: string | string[]

Returns

BlockModel<object>[]

Source

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


getBlockById()

getBlockById<Model>(id): null | Model

Type parameters

Model extends BlockModel<object> = BlockModel<object>

Parameters

id: string

Returns

null | Model

Source

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


getBlocks()

getBlocks(): BlockModel<object>[]

Returns

BlockModel<object>[]

Source

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


getInitialPropsByFlavour()

getInitialPropsByFlavour(flavour): Record<string, any>

Parameters

flavour: string

Returns

Record<string, any>

Source

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


getNextSibling()

getNextSibling(block): null | BlockModel<object>

Parameters

block: BlockModel<object>

Returns

null | BlockModel<object>

Source

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


getNextSiblings()

getNextSiblings(block): BlockModel<object>[]

Parameters

block: BlockModel<object>

Returns

BlockModel<object>[]

Source

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


getParent()

getParent(target): null | BlockModel<object>

Parameters

target: string | BlockModel<object>

Returns

null | BlockModel<object>

Source

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


getPreviousSibling()

getPreviousSibling(block): null | BlockModel<object>

Parameters

block: BlockModel<object>

Returns

null | BlockModel<object>

Source

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


getPreviousSiblings()

getPreviousSiblings(block): BlockModel<object>[]

Parameters

block: BlockModel<object>

Returns

BlockModel<object>[]

Source

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


getSchemaByFlavour()

getSchemaByFlavour(flavour): undefined | Object

Parameters

flavour: string

Returns

undefined | Object

Source

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


load()

load(initFn?): this

Parameters

initFn?

Returns

this

Overrides

Space.load

Source

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


moveBlocks()

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

Parameters

blocksToMove: BlockModel<object>[]

newParent: BlockModel<object>

targetSibling: null | BlockModel<object>= null

shouldInsertBeforeSibling: boolean= true

Returns

void

Source

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


redo()

redo(): void

Returns

void

Source

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


remove()

remove(): void

Returns

void

Inherited from

Space.remove

Source

packages/framework/store/src/store/space.ts:62


resetHistory()

resetHistory(): void

Returns

void

Source

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


transact()

transact(fn, shouldTransact): void

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

Parameters

fn

shouldTransact: boolean= undefined

Returns

void

Overrides

Space.transact

Source

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


undo()

undo(): void

Returns

void

Source

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


updateBlock()

updateBlock(model, props)

updateBlock<T>(model, props): void

Type parameters

T extends Partial<BlockProps>

Parameters

model: BlockModel<object>

props: T

Returns

void

Source

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

updateBlock(model, callback)

updateBlock(model, callback): void

Parameters

model: BlockModel<object>

callback

Returns

void

Source

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


withoutTransact()

withoutTransact(callback): void

Parameters

callback

Returns

void

Source

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