BlockSuite API Documentation / @blocksuite/store / Doc
Class: Doc
Extends
Space<FlatBlockMap>
Constructors
new Doc(__namedParameters)
new Doc(
__namedParameters):Doc
Parameters
• __namedParameters: DocOptions
Returns
Overrides
Source
packages/framework/store/src/store/doc.ts:80
Properties
_blockTree
privatereadonly_blockTree:BlockTree
Source
packages/framework/store/src/store/doc.ts:40
_collection
privatereadonly_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
privatereadonly_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
protectedreadonly_yBlocks:Map<YBlock>
Inherited from
Source
packages/framework/store/src/store/space.ts:28
_ySpaceDoc
Internal
protectedreadonly_ySpaceDoc:Doc
Used for convenient access to the underlying Yjs map, can be used interchangeably with ySpace
Inherited from
Source
packages/framework/store/src/store/space.ts:27
awarenessStore
readonlyawarenessStore:AwarenessStore<BlockSuiteFlags>
Inherited from
Source
packages/framework/store/src/store/space.ts:17
id
readonlyid:string
Inherited from
Source
packages/framework/store/src/store/space.ts:15
rootDoc
readonlyrootDoc:BlockSuiteDoc
Inherited from
Source
packages/framework/store/src/store/space.ts:16
slots
readonlyslots:Object
slots.blockUpdated
blockUpdated:
Slot<Object|Object|Object>
slots.historyUpdated
historyUpdated:
Slot<void>
slots.ready
ready:
Slot<void>
This is always triggered after doc.load is called.
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
getText(): typeofText
Returns
typeof Text
Source
packages/framework/store/src/store/doc.ts:146
blob
getblob():BlobManager
Returns
Source
packages/framework/store/src/store/doc.ts:120
canRedo
getcanRedo():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc.ts:139
canUndo
getcanUndo():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc.ts:132
collection
getcollection():DocCollection
Returns
Source
packages/framework/store/src/store/doc.ts:108
history
gethistory():UndoManager
Returns
Source
packages/framework/store/src/store/doc.ts:104
isEmpty
getisEmpty():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc.ts:128
loaded
getloaded():boolean
Returns
boolean
Source
packages/framework/store/src/store/space.ts:48
meta
getmeta():undefined|DocMeta
Returns
undefined | DocMeta
Source
packages/framework/store/src/store/doc.ts:116
readonly
getreadonly():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc.ts:96
ready
getready():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc.ts:100
root
getroot():null|BlockModel<object>
Returns
null | BlockModel<object>
Source
packages/framework/store/src/store/doc.ts:124
schema
getschema():Schema
Returns
Source
packages/framework/store/src/store/doc.ts:112
spaceDoc
getspaceDoc():Doc
Returns
Source
packages/framework/store/src/store/space.ts:52
yBlocks
getyBlocks():Map<State[keyofState]>
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:702
_handleVersion()
private_handleVersion():void
Returns
void
Source
packages/framework/store/src/store/doc.ts:803
_handleYBlockAdd()
private_handleYBlockAdd(id):void
Parameters
• id: string
Returns
void
Source
packages/framework/store/src/store/doc.ts:712
_handleYBlockDelete()
private_handleYBlockDelete(id):void
Parameters
• id: string
Returns
void
Source
packages/framework/store/src/store/doc.ts:761
_handleYEvent()
private_handleYEvent(event):void
Parameters
• event: YEvent<Text | Array<unknown> | YBlock>
Returns
void
Source
packages/framework/store/src/store/doc.ts:778
_handleYEvents()
private_handleYEvents(events):void
Parameters
• events: YEvent<Text | YBlock>[]
Returns
void
Source
packages/framework/store/src/store/doc.ts:797
_historyObserver()
private_historyObserver():void
Returns
void
Source
packages/framework/store/src/store/doc.ts:708
_initYBlocks()
private_initYBlocks():void
Returns
void
Source
packages/framework/store/src/store/doc.ts:689
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:332
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:338
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:309
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:535
captureSync()
captureSync():
void
Capture current operations to undo stack synchronously.
Returns
void
Source
packages/framework/store/src/store/doc.ts:180
clear()
clear():
void
Returns
void
Inherited from
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:572
destroy()
destroy():
void
Returns
void
Inherited from
Source
packages/framework/store/src/store/space.ts:67
dispose()
dispose():
void
Returns
void
Source
packages/framework/store/src/store/doc.ts:677
generateBlockId()
generateBlockId():
string
Returns
string
Source
packages/framework/store/src/store/doc.ts:188
getBlockByFlavour()
getBlockByFlavour(
blockFlavour):BlockModel<object>[]
Parameters
• blockFlavour: string | string[]
Returns
BlockModel<object>[]
Source
packages/framework/store/src/store/doc.ts:198
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:192
getBlocks()
getBlocks():
BlockModel<object>[]
Returns
BlockModel<object>[]
Source
packages/framework/store/src/store/doc.ts:298
getInitialPropsByFlavour()
getInitialPropsByFlavour(
flavour):Record<string,any>
Parameters
• flavour: string
Returns
Record<string, any>
Source
packages/framework/store/src/store/doc.ts:292
getNextSibling()
getNextSibling(
block):null|BlockModel<object>
Parameters
• block: BlockModel<object>
Returns
null | BlockModel<object>
Source
packages/framework/store/src/store/doc.ts:260
getNextSiblings()
getNextSiblings(
block):BlockModel<object>[]
Parameters
• block: BlockModel<object>
Returns
BlockModel<object>[]
Source
packages/framework/store/src/store/doc.ts:274
getParent()
getParent(
target):null|BlockModel<object>
Parameters
• target: string | BlockModel<object>
Returns
null | BlockModel<object>
Source
packages/framework/store/src/store/doc.ts:207
getPreviousSibling()
getPreviousSibling(
block):null|BlockModel<object>
Parameters
• block: BlockModel<object>
Returns
null | BlockModel<object>
Source
packages/framework/store/src/store/doc.ts:232
getPreviousSiblings()
getPreviousSiblings(
block):BlockModel<object>[]
Parameters
• block: BlockModel<object>
Returns
BlockModel<object>[]
Source
packages/framework/store/src/store/doc.ts:246
getSchemaByFlavour()
getSchemaByFlavour(
flavour):undefined|Object
Parameters
• flavour: string
Returns
undefined | Object
Source
packages/framework/store/src/store/doc.ts:288
load()
load(
initFn?):this
Parameters
• initFn?
Returns
this
Overrides
Source
packages/framework/store/src/store/doc.ts:650
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:395
redo()
redo():
void
Returns
void
Source
packages/framework/store/src/store/doc.ts:171
remove()
remove():
void
Returns
void
Inherited from
Source
packages/framework/store/src/store/space.ts:62
resetHistory()
resetHistory():
void
Returns
void
Source
packages/framework/store/src/store/doc.ts:184
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
Source
packages/framework/store/src/store/doc.ts:156
undo()
undo():
void
Returns
void
Source
packages/framework/store/src/store/doc.ts:163
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:486
updateBlock(model, callback)
updateBlock(
model,callback):void
Parameters
• model: BlockModel<object>
• callback
Returns
void
Source
packages/framework/store/src/store/doc.ts:487
withoutTransact()
withoutTransact(
callback):void
Parameters
• callback
Returns
void
Source
packages/framework/store/src/store/doc.ts:150