Skip to content

API > @blocksuite/store > Page

Class: Page ​

Extends ​

Constructors ​

constructor ​

new Page(__namedParameters): Page

Parameters ​

ParameterType
__namedParametersPageOptions

Returns ​

Page

Overrides ​

Space.constructor

Defined In ​

packages/store/src/workspace/page.ts:109

Properties ​

_blockMap ​

private _blockMap: Map< string, BaseBlockModel< object > >

Defined In ​

packages/store/src/workspace/page.ts:57


_history ​

private _history: UndoManager

Defined In ​

packages/store/src/workspace/page.ts:55


_idGenerator ​

private readonly _idGenerator: IdGenerator

Defined In ​

packages/store/src/workspace/page.ts:54


_initialized ​

private _initialized: boolean = false

Defined In ​

packages/store/src/workspace/page.ts:58


_proxy ​

protected readonly _proxy: FlatBlockMap

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

Defined In ​

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

Inherited from ​

Space._proxy


_root ​

private _root: null | BaseBlockModel< object > = null

Defined In ​

packages/store/src/workspace/page.ts:56


_shouldTransact ​

private _shouldTransact: boolean = true

Defined In ​

packages/store/src/workspace/page.ts:59


_workspace ​

private readonly _workspace: Workspace

Defined In ​

packages/store/src/workspace/page.ts:53


_yBlocks ​

protected readonly _yBlocks: Map< YBlock >

Defined In ​

packages/store/src/workspace/space.ts:30

Inherited from ​

Space._yBlocks


_ySpaceDoc ​

protected readonly _ySpaceDoc: Doc

Defined In ​

packages/store/src/workspace/space.ts:29

Inherited from ​

Space._ySpaceDoc


awarenessStore ​

readonly awarenessStore: AwarenessStore< BlockSuiteFlags >

Defined In ​

packages/store/src/workspace/space.ts:18

Inherited from ​

Space.awarenessStore


doc ​

readonly doc: BlockSuiteDoc

Defined In ​

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

Inherited from ​

Space.doc


id ​

readonly id: string

Defined In ​

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

Inherited from ​

Space.id


slots ​

readonly slots: object

Type declaration ​

slots.blockUpdated ​

blockUpdated: Slot< {flavour: string; id: string; type: "add";} | {flavour: string; id: string; parent: string; type: "delete";} | {flavour: string; id: string; props: Partial< BlockProps >; type: "update";} >

slots.copied ​

copied: Slot< void >

slots.historyUpdated ​

historyUpdated: Slot< void >

slots.onYEvent ​

onYEvent: Slot< {event: YEvent< Array< unknown > | Text | YBlock >;} >

slots.pasted ​

pasted: Slot< Record< string, unknown >[] >

slots.ready ​

ready: Slot< void >

This fires when the block tree is initialized via API call or underlying existing ydoc binary. 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< BaseBlockModel< 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 | string[] >

slots.textUpdated ​

textUpdated: Slot< YTextEvent >

slots.yBlockUpdated ​

yBlockUpdated: Slot< {id: string; props: {}; type: "add" | "update" | "delete";} >

slots.yUpdated ​

yUpdated: Slot< void >

Defined In ​

packages/store/src/workspace/page.ts:61

Accessors ​

Text ​

get Text(): typeof Text

Defined In ​

packages/store/src/workspace/page.ts:167


blob ​

get blob(): BlobManager

Defined In ​

packages/store/src/workspace/page.ts:141


canRedo ​

get canRedo(): boolean

Defined In ​

packages/store/src/workspace/page.ts:160


canUndo ​

get canUndo(): boolean

Defined In ​

packages/store/src/workspace/page.ts:153


history ​

get history(): UndoManager

Defined In ​

packages/store/src/workspace/page.ts:125


isEmpty ​

get isEmpty(): boolean

Defined In ​

packages/store/src/workspace/page.ts:149


loaded ​

get loaded(): boolean

Defined In ​

packages/store/src/workspace/space.ts:43

Inherited from ​

Space.loaded


meta ​

get meta(): PageMeta

Defined In ​

packages/store/src/workspace/page.ts:137


readonly ​

get readonly(): boolean

Defined In ​

packages/store/src/workspace/page.ts:121


root ​

get root(): null | BaseBlockModel< object >

Defined In ​

packages/store/src/workspace/page.ts:145


schema ​

get schema(): Schema

Defined In ​

packages/store/src/workspace/page.ts:133


spaceDoc ​

get spaceDoc(): Doc

Defined In ​

packages/store/src/workspace/space.ts:47

Inherited from ​

Space.spaceDoc


workspace ​

get workspace(): Workspace

Defined In ​

packages/store/src/workspace/page.ts:129

Methods ​

_createBlockModel ​

private _createBlockModel( id, flavour, block): BaseBlockModel< object >

Parameters ​

ParameterType
idstring
flavourstring
blockYBlock

Returns ​

BaseBlockModel< object >

Defined In ​

packages/store/src/workspace/page.ts:718


_getYBlock ​

private _getYBlock(id): null | YBlock

Parameters ​

ParameterType
idstring

Returns ​

null | YBlock

Defined In ​

packages/store/src/workspace/page.ts:708


_handleVersion ​

private _handleVersion(): void

Returns ​

void

Defined In ​

packages/store/src/workspace/page.ts:921


_handleYBlockAdd ​

private _handleYBlockAdd(visited, id): void

Parameters ​

ParameterType
visitedSet< string >
idstring

Returns ​

void

Defined In ​

packages/store/src/workspace/page.ts:729


_handleYBlockDelete ​

private _handleYBlockDelete(id): void

Parameters ​

ParameterType
idstring

Returns ​

void

Defined In ​

packages/store/src/workspace/page.ts:771


_handleYBlockUpdate ​

private _handleYBlockUpdate(event): void

Parameters ​

ParameterType
eventYMapEvent< unknown >

Returns ​

void

Defined In ​

packages/store/src/workspace/page.ts:789


_handleYEvent ​

private _handleYEvent(event): void

Parameters ​

ParameterType
eventYEvent< Array< unknown > | Text | YBlock >

Returns ​

void

Defined In ​

packages/store/src/workspace/page.ts:845


_handleYEvents ​

private _handleYEvents(events): void

Parameters ​

ParameterType
eventsYEvent< Text | YBlock >[]

Returns ​

void

Defined In ​

packages/store/src/workspace/page.ts:910


_historyObserver ​

private _historyObserver(): void

Returns ​

void

Defined In ​

packages/store/src/workspace/page.ts:714


_initYBlocks ​

private _initYBlocks(): void

Returns ​

void

Defined In ​

packages/store/src/workspace/page.ts:695


addBlock ​

addBlock( flavour, blockProps = {}, parent?, parentIndex?): string

Parameters ​

ParameterType
flavourstring
blockPropsPartial< BlockSysProps & {} & Omit< BlockProps, "flavour" > >
parent?null | string | BaseBlockModel< object >
parentIndex?number

Returns ​

string

Defined In ​

packages/store/src/workspace/page.ts:340


addBlocks ​

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

Parameters ​

ParameterType
blocks{blockProps: Partial< BlockSysProps & {} & Omit< BlockProps, "id" | "flavour" > >; flavour: string;}[]
parent?null | string | BaseBlockModel< object >
parentIndex?number

Returns ​

string[]

Defined In ​

packages/store/src/workspace/page.ts:317


addSiblingBlocks ​

addSiblingBlocks( targetModel, props, place = 'after'): string[]

Parameters ​

ParameterTypeDefault value
targetModelBaseBlockModel< object >undefined
propsPartial< BaseBlockModel< object > >[]undefined
place"after" | "before"'after'

Returns ​

string[]

Defined In ​

packages/store/src/workspace/page.ts:545


captureSync ​

captureSync(): void

Capture current operations to undo stack synchronously.

Returns ​

void

Defined In ​

packages/store/src/workspace/page.ts:201


clear ​

clear(): void

Returns ​

void

Inherited from ​

Space.clear

Defined In ​

packages/store/src/workspace/space.ts:80


deleteBlock ​

deleteBlock(model, options = ...): void

Parameters ​

ParameterType
modelBaseBlockModel< object >
optionsobject
options.bringChildrenTo?BaseBlockModel< object >
options.deleteChildren?boolean

Returns ​

void

Defined In ​

packages/store/src/workspace/page.ts:577


destroy ​

destroy(): void

Returns ​

void

Inherited from ​

Space.destroy

Defined In ​

packages/store/src/workspace/space.ts:74


dispose ​

dispose(): void

Returns ​

void

Defined In ​

packages/store/src/workspace/page.ts:680


generateBlockId ​

generateBlockId(): string

Returns ​

string

Defined In ​

packages/store/src/workspace/page.ts:209


getBlockByFlavour ​

getBlockByFlavour(blockFlavour): BaseBlockModel< object >[]

Parameters ​

ParameterType
blockFlavourstring | string[]

Returns ​

BaseBlockModel< object >[]

Defined In ​

packages/store/src/workspace/page.ts:217


getBlockById ​

getBlockById(id): null | BaseBlockModel< object >

Parameters ​

ParameterType
idstring

Returns ​

null | BaseBlockModel< object >

Defined In ​

packages/store/src/workspace/page.ts:213


getInitialPropsByFlavour ​

getInitialPropsByFlavour(flavour): Record< string, any >

Parameters ​

ParameterType
flavourstring

Returns ​

Record< string, any >

Defined In ​

packages/store/src/workspace/page.ts:311


getNextSibling ​

getNextSibling(block): null | BaseBlockModel< object >

Parameters ​

ParameterType
blockBaseBlockModel< object >

Returns ​

null | BaseBlockModel< object >

Defined In ​

packages/store/src/workspace/page.ts:279


getNextSiblings ​

getNextSiblings(block): BaseBlockModel< object >[]

Parameters ​

ParameterType
blockBaseBlockModel< object >

Returns ​

BaseBlockModel< object >[]

Defined In ​

packages/store/src/workspace/page.ts:293


getParent ​

getParent(target): null | BaseBlockModel< object >

Parameters ​

ParameterType
targetstring | BaseBlockModel< object >

Returns ​

null | BaseBlockModel< object >

Defined In ​

packages/store/src/workspace/page.ts:226


getPreviousSibling ​

getPreviousSibling(block): null | BaseBlockModel< object >

Parameters ​

ParameterType
blockBaseBlockModel< object >

Returns ​

null | BaseBlockModel< object >

Defined In ​

packages/store/src/workspace/page.ts:251


getPreviousSiblings ​

getPreviousSiblings(block): BaseBlockModel< object >[]

Parameters ​

ParameterType
blockBaseBlockModel< object >

Returns ​

BaseBlockModel< object >[]

Defined In ​

packages/store/src/workspace/page.ts:265


getSchemaByFlavour ​

getSchemaByFlavour(flavour): undefined | {model: { flavour: string; role: "root" | "hub" | "content"; parent?: string[] | undefined; children?: string[] | undefined; props?: ((args_0: InternalPrimitives, ...args_1: unknown[]) => Record<...>) | undefined; toModel?: ((...args: unknown[]) => BaseBlockModel<...>) | undefined; }; onUpgrade: (...args) => void; transformer: (...args) => BaseBlockTransformer< object >; version: number;}

Parameters ​

ParameterType
flavourstring

Returns ​

undefined | {model: { flavour: string; role: "root" | "hub" | "content"; parent?: string[] | undefined; children?: string[] | undefined; props?: ((args_0: InternalPrimitives, ...args_1: unknown[]) => Record<...>) | undefined; toModel?: ((...args: unknown[]) => BaseBlockModel<...>) | undefined; }; onUpgrade: (...args) => void; transformer: (...args) => BaseBlockTransformer< object >; version: number;}

Defined In ​

packages/store/src/workspace/page.ts:307


moveBlocks ​

moveBlocks( blocksToMove, newParent, targetSibling = null, shouldInsertBeforeSibling = true): void

Parameters ​

ParameterTypeDefault value
blocksToMoveBaseBlockModel< object >[]undefined
newParentBaseBlockModel< object >undefined
targetSiblingnull | BaseBlockModel< object >null
shouldInsertBeforeSiblingbooleantrue

Returns ​

void

Defined In ​

packages/store/src/workspace/page.ts:395


redo ​

redo(): void

Returns ​

void

Defined In ​

packages/store/src/workspace/page.ts:192


remove ​

remove(): void

Returns ​

void

Inherited from ​

Space.remove

Defined In ​

packages/store/src/workspace/space.ts:69


resetHistory ​

resetHistory(): void

Returns ​

void

Defined In ​

packages/store/src/workspace/page.ts:205


transact ​

transact(fn, shouldTransact = ...): void

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

Parameters ​

ParameterType
fnfunction
shouldTransactboolean

Returns ​

void

Overrides ​

Space.transact

Defined In ​

packages/store/src/workspace/page.ts:177


trySyncFromExistingDoc ​

trySyncFromExistingDoc(): void

Returns ​

void

Defined In ​

packages/store/src/workspace/page.ts:657


undo ​

undo(): void

Returns ​

void

Defined In ​

packages/store/src/workspace/page.ts:184


updateBlock ​

updateBlock<T>(model, props): void

Type parameters ​

Parameter
T extends Partial< BlockProps >

Parameters ​

ParameterType
modelBaseBlockModel< object >
propsT

Returns ​

void

Defined In ​

packages/store/src/workspace/page.ts:494


validateVersion ​

validateVersion(): void

Returns ​

void

Defined In ​

packages/store/src/workspace/page.ts:917


waitForLoaded ​

waitForLoaded(): Promise< Page >

Returns ​

Promise< Page >

Overrides ​

Space.waitForLoaded

Defined In ​

packages/store/src/workspace/page.ts:931


withoutTransact ​

withoutTransact(callback): void

Parameters ​

ParameterType
callbackfunction

Returns ​

void

Defined In ​

packages/store/src/workspace/page.ts:171