BlockSuite API Documentation / @blocksuite/store / Doc
Class: Doc
Constructors
new Doc()
new Doc(
__namedParameters):Doc
Parameters
• __namedParameters: DocOptions
Returns
Source
packages/framework/store/src/store/doc/doc.ts:206
Properties
_blockCollection
protectedreadonly_blockCollection:BlockCollection
Source
packages/framework/store/src/store/doc/doc.ts:156
_blocks
protectedreadonly_blocks:Map<string,Block>
Source
packages/framework/store/src/store/doc/doc.ts:154
_crud
protectedreadonly_crud:DocCRUD
Source
packages/framework/store/src/store/doc/doc.ts:158
_disposeBlockUpdated
protectedreadonly_disposeBlockUpdated:Disposable
Source
packages/framework/store/src/store/doc/doc.ts:162
_readonly?
protectedoptionalreadonly_readonly:boolean
Source
packages/framework/store/src/store/doc/doc.ts:164
_schema
protectedreadonly_schema:Schema
Source
packages/framework/store/src/store/doc/doc.ts:152
_selector
protectedreadonly_selector:BlockSelector
Source
packages/framework/store/src/store/doc/doc.ts:160
slots
readonlyslots: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>
Source
packages/framework/store/src/store/doc/doc.ts:167
Accessors
Text
getText(): typeofText
Returns
typeof Text
Source
packages/framework/store/src/store/doc/doc.ts:100
_yBlocks
Returns
Source
packages/framework/store/src/store/doc/doc.ts:148
awarenessStore
getawarenessStore():AwarenessStore<BlockSuiteFlags>
Returns
AwarenessStore<BlockSuiteFlags>
Source
packages/framework/store/src/store/doc/doc.ts:112
awarenessSync
getawarenessSync():AwarenessEngine
Returns
AwarenessEngine
Source
packages/framework/store/src/store/doc/doc.ts:58
blobSync
getblobSync():BlobEngine
Returns
BlobEngine
Source
packages/framework/store/src/store/doc/doc.ts:62
blockCollection
getblockCollection():BlockCollection
Returns
Source
packages/framework/store/src/store/doc/doc.ts:27
blocks
getblocks():Map<string,Block>
Returns
Map<string, Block>
Source
packages/framework/store/src/store/doc/doc.ts:144
canRedo
getcanRedo():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc/doc.ts:78
canUndo
getcanUndo():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc/doc.ts:74
captureSync
getcaptureSync(): () =>void
Returns
Function
Capture current operations to undo stack synchronously.
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:128
clear
getclear(): () =>void
Returns
Function
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:140
collection
getcollection():DocCollection
Returns
Source
packages/framework/store/src/store/doc/doc.ts:50
docSync
getdocSync():DocEngine
Returns
DocEngine
Source
packages/framework/store/src/store/doc/doc.ts:54
generateBlockId
getgenerateBlockId(): () =>string
Returns
Function
Returns
string
Source
packages/framework/store/src/store/doc/doc.ts:136
history
gethistory():UndoManager
Returns
Source
packages/framework/store/src/store/doc/doc.ts:46
id
getid():string
Returns
string
Source
packages/framework/store/src/store/doc/doc.ts:96
isEmpty
getisEmpty():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc/doc.ts:70
loaded
getloaded():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc/doc.ts:116
meta
getmeta():undefined|DocMeta
Returns
undefined | DocMeta
Source
packages/framework/store/src/store/doc/doc.ts:66
readonly
getreadonly():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc/doc.ts:31
ready
getready():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc/doc.ts:42
redo
getredo(): () =>void
Returns
Function
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:86
resetHistory
getresetHistory(): () =>void
Returns
Function
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:124
root
getroot():null|BlockModel<object>
Returns
null | BlockModel<object>
Source
packages/framework/store/src/store/doc/doc.ts:90
rootDoc
getrootDoc():BlockSuiteDoc
Returns
Source
packages/framework/store/src/store/doc/doc.ts:108
schema
getschema():Schema
Returns
Source
packages/framework/store/src/store/doc/doc.ts:38
spaceDoc
getspaceDoc():Doc
Returns
Source
packages/framework/store/src/store/doc/doc.ts:104
transact
gettransact(): (fn,shouldTransact) =>void
Returns
Function
Parameters
• fn
• shouldTransact: boolean= undefined
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:120
undo
getundo(): () =>void
Returns
Function
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:82
withoutTransact
getwithoutTransact(): (callback) =>void
Returns
Function
Parameters
• callback
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:132
Methods
_getSiblings()
private_getSiblings<T>(block,fn):null|T
Type parameters
• T
Parameters
• block: string | BlockModel<object>
• fn
Returns
null | T
Source
packages/framework/store/src/store/doc/doc.ts:247
_onBlockAdded()
private_onBlockAdded(id,init):void
Parameters
• id: string
• init: boolean= false
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:264
_onBlockRemoved()
private_onBlockRemoved(id):void
Parameters
• id: string
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:313
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/doc.ts:468
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>
• parentIndex?: number
Returns
string
Source
packages/framework/store/src/store/doc/doc.ts:474
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/doc.ts:445
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/doc.ts:571
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/doc.ts:608
dispose()
dispose():
void
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:339
getBlock()
getBlock(
id):undefined|Block
Parameters
• id: string
Returns
undefined | Block
Source
packages/framework/store/src/store/doc/doc.ts:369
getBlockByFlavour()
getBlockByFlavour(
blockFlavour):BlockModel<object>[]
Parameters
• blockFlavour: string | string[]
Returns
BlockModel<object>[]
Deprecated
Use getBlocksByFlavour instead.
Source
packages/framework/store/src/store/doc/doc.ts:387
getBlockById()
getBlockById<
Model>(id):null|Model
Type parameters
• Model extends BlockModel<object> = BlockModel<object>
Parameters
• id: string
Returns
null | Model
Deprecated
Use getBlock instead.
Source
packages/framework/store/src/store/doc/doc.ts:377
getBlocks()
getBlocks():
BlockModel<object>[]
Returns
BlockModel<object>[]
Source
packages/framework/store/src/store/doc/doc.ts:441
getBlocksByFlavour()
getBlocksByFlavour(
blockFlavour):Block[]
Parameters
• blockFlavour: string | string[]
Returns
Block[]
Source
packages/framework/store/src/store/doc/doc.ts:391
getNext()
getNext(
block):null|BlockModel<object>
Parameters
• block: string | BlockModel<object>
Returns
null | BlockModel<object>
Source
packages/framework/store/src/store/doc/doc.ts:426
getNexts()
getNexts(
block):BlockModel<object>[]
Parameters
• block: string | BlockModel<object>
Returns
BlockModel<object>[]
Source
packages/framework/store/src/store/doc/doc.ts:433
getParent()
getParent(
target):null|BlockModel<object>
Parameters
• target: string | BlockModel<object>
Returns
null | BlockModel<object>
Source
packages/framework/store/src/store/doc/doc.ts:400
getPrev()
getPrev(
block):null|BlockModel<object>
Parameters
• block: string | BlockModel<object>
Returns
null | BlockModel<object>
Source
packages/framework/store/src/store/doc/doc.ts:411
getPrevs()
getPrevs(
block):BlockModel<object>[]
Parameters
• block: string | BlockModel<object>
Returns
BlockModel<object>[]
Source
packages/framework/store/src/store/doc/doc.ts:418
getSchemaByFlavour()
getSchemaByFlavour(
flavour):undefined|object
Parameters
• flavour: Flavour
Returns
undefined | object
Source
packages/framework/store/src/store/doc/doc.ts:347
hasBlock()
hasBlock(
id):boolean
Parameters
• id: string
Returns
boolean
Source
packages/framework/store/src/store/doc/doc.ts:357
hasBlockById()
hasBlockById(
id):boolean
Parameters
• id: string
Returns
boolean
Deprecated
Use hasBlock instead.
Source
packages/framework/store/src/store/doc/doc.ts:365
load()
load(
initFn?):Doc
Parameters
• initFn?
Returns
Source
packages/framework/store/src/store/doc/doc.ts:351
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/doc.ts:505
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/doc.ts:526
updateBlock(model, callback)
updateBlock(
model,callback):void
Parameters
• model: BlockModel<object>
• callback
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:527