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:27
Properties
_blockCollection
protectedreadonly_blockCollection:BlockCollection
Source
packages/framework/store/src/store/doc/doc.ts:22
_blocks
protectedreadonly_blocks:Map<string,Block>
Source
packages/framework/store/src/store/doc/doc.ts:21
_crud
protectedreadonly_crud:DocCRUD
Source
packages/framework/store/src/store/doc/doc.ts:23
_disposeBlockUpdated
protectedreadonly_disposeBlockUpdated:Disposable
Source
packages/framework/store/src/store/doc/doc.ts:25
_schema
protectedreadonly_schema:Schema
Source
packages/framework/store/src/store/doc/doc.ts:20
_selector
protectedreadonly_selector:BlockSelector
Source
packages/framework/store/src/store/doc/doc.ts:24
Accessors
Text
getText(): typeofText
Returns
typeof Text
Source
packages/framework/store/src/store/doc/doc.ts:121
_yBlocks
Returns
Source
packages/framework/store/src/store/doc/doc.ts:270
awarenessStore
getawarenessStore():AwarenessStore<BlockSuiteFlags>
Returns
AwarenessStore<BlockSuiteFlags>
Source
packages/framework/store/src/store/doc/doc.ts:137
blob
getblob():BlobManager
Returns
Source
packages/framework/store/src/store/doc/doc.ts:87
blockCollection
getblockCollection():BlockCollection
Returns
Source
packages/framework/store/src/store/doc/doc.ts:59
blocks
getblocks():Map<string,Block>
Returns
Map<string, Block>
Source
packages/framework/store/src/store/doc/doc.ts:266
canRedo
getcanRedo():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc/doc.ts:99
canUndo
getcanUndo():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc/doc.ts:95
captureSync
getcaptureSync(): () =>void
Returns
Function
Capture current operations to undo stack synchronously.
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:153
clear
getclear(): () =>void
Returns
Function
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:165
collection
getcollection():DocCollection
Returns
Source
packages/framework/store/src/store/doc/doc.ts:79
generateBlockId
getgenerateBlockId(): () =>string
Returns
Function
Returns
string
Source
packages/framework/store/src/store/doc/doc.ts:161
history
gethistory():UndoManager
Returns
Source
packages/framework/store/src/store/doc/doc.ts:75
id
getid():string
Returns
string
Source
packages/framework/store/src/store/doc/doc.ts:117
isEmpty
getisEmpty():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc/doc.ts:91
loaded
getloaded():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc/doc.ts:141
meta
getmeta():undefined|DocMeta
Returns
undefined | DocMeta
Source
packages/framework/store/src/store/doc/doc.ts:83
readonly
getreadonly():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc/doc.ts:63
ready
getready():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc/doc.ts:71
redo
getredo(): () =>void
Returns
Function
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:107
resetHistory
getresetHistory(): () =>void
Returns
Function
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:149
root
getroot():null|BlockModel<object>
Returns
null | BlockModel<object>
Source
packages/framework/store/src/store/doc/doc.ts:111
rootDoc
getrootDoc():BlockSuiteDoc
Returns
Source
packages/framework/store/src/store/doc/doc.ts:129
schema
getschema():Schema
Returns
Source
packages/framework/store/src/store/doc/doc.ts:67
slots
getslots():object
Returns
object
blockUpdated
blockUpdated:
Slot<object|object|object>
historyUpdated
historyUpdated:
Slot<void>
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>
yBlockUpdated
yBlockUpdated:
Slot<object|object>
Source
packages/framework/store/src/store/doc/doc.ts:133
spaceDoc
getspaceDoc():Doc
Returns
Source
packages/framework/store/src/store/doc/doc.ts:125
transact
gettransact(): (fn,shouldTransact) =>void
Returns
Function
Parameters
• fn
• shouldTransact: boolean= undefined
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:145
undo
getundo(): () =>void
Returns
Function
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:103
withoutTransact
getwithoutTransact(): (callback) =>void
Returns
Function
Parameters
• callback
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:157
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:274
_onBlockAdded()
private_onBlockAdded(id,init):void
Parameters
• id: string
• init: boolean= false
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:291
_onBlockRemoved()
private_onBlockRemoved(id):void
Parameters
• id: string
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:342
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:391
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/doc.ts:397
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:368
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:494
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:531
dispose()
dispose():
void
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:55
getBlock()
getBlock(
id):undefined|Block
Parameters
• id: string
Returns
undefined | Block
Source
packages/framework/store/src/store/doc/doc.ts:190
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:208
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:198
getBlocks()
getBlocks():
BlockModel<object>[]
Returns
BlockModel<object>[]
Source
packages/framework/store/src/store/doc/doc.ts:262
getBlocksByFlavour()
getBlocksByFlavour(
blockFlavour):Block[]
Parameters
• blockFlavour: string | string[]
Returns
Block[]
Source
packages/framework/store/src/store/doc/doc.ts:212
getNext()
getNext(
block):null|BlockModel<object>
Parameters
• block: string | BlockModel<object>
Returns
null | BlockModel<object>
Source
packages/framework/store/src/store/doc/doc.ts:247
getNexts()
getNexts(
block):BlockModel<object>[]
Parameters
• block: string | BlockModel<object>
Returns
BlockModel<object>[]
Source
packages/framework/store/src/store/doc/doc.ts:254
getParent()
getParent(
target):null|BlockModel<object>
Parameters
• target: string | BlockModel<object>
Returns
null | BlockModel<object>
Source
packages/framework/store/src/store/doc/doc.ts:221
getPrev()
getPrev(
block):null|BlockModel<object>
Parameters
• block: string | BlockModel<object>
Returns
null | BlockModel<object>
Source
packages/framework/store/src/store/doc/doc.ts:232
getPrevs()
getPrevs(
block):BlockModel<object>[]
Parameters
• block: string | BlockModel<object>
Returns
BlockModel<object>[]
Source
packages/framework/store/src/store/doc/doc.ts:239
getSchemaByFlavour()
getSchemaByFlavour(
flavour):undefined|object
Parameters
• flavour: Flavour
Returns
undefined | object
Source
packages/framework/store/src/store/doc/doc.ts:169
hasBlock()
hasBlock(
id):boolean
Parameters
• id: string
Returns
boolean
Source
packages/framework/store/src/store/doc/doc.ts:178
hasBlockById()
hasBlockById(
id):boolean
Parameters
• id: string
Returns
boolean
Deprecated
Use hasBlock instead.
Source
packages/framework/store/src/store/doc/doc.ts:186
load()
load(
initFn?):Doc
Parameters
• initFn?
Returns
Source
packages/framework/store/src/store/doc/doc.ts:173
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:428
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:449
updateBlock(model, callback)
updateBlock(
model,callback):void
Parameters
• model: BlockModel<object>
• callback
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:450