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
protected
readonly
_blockCollection:BlockCollection
Source
packages/framework/store/src/store/doc/doc.ts:156
_blocks
protected
readonly
_blocks:Map
<string
,Block
>
Source
packages/framework/store/src/store/doc/doc.ts:154
_crud
protected
readonly
_crud:DocCRUD
Source
packages/framework/store/src/store/doc/doc.ts:158
_disposeBlockUpdated
protected
readonly
_disposeBlockUpdated:Disposable
Source
packages/framework/store/src/store/doc/doc.ts:162
_readonly?
protected
optional
readonly
_readonly:boolean
Source
packages/framework/store/src/store/doc/doc.ts:164
_schema
protected
readonly
_schema:Schema
Source
packages/framework/store/src/store/doc/doc.ts:152
_selector
protected
readonly
_selector:BlockSelector
Source
packages/framework/store/src/store/doc/doc.ts:160
slots
readonly
slots: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
get
Text(): 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
get
awarenessStore():AwarenessStore
<BlockSuiteFlags
>
Returns
AwarenessStore
<BlockSuiteFlags
>
Source
packages/framework/store/src/store/doc/doc.ts:112
awarenessSync
get
awarenessSync():AwarenessEngine
Returns
AwarenessEngine
Source
packages/framework/store/src/store/doc/doc.ts:58
blobSync
get
blobSync():BlobEngine
Returns
BlobEngine
Source
packages/framework/store/src/store/doc/doc.ts:62
blockCollection
get
blockCollection():BlockCollection
Returns
Source
packages/framework/store/src/store/doc/doc.ts:27
blocks
get
blocks():Map
<string
,Block
>
Returns
Map
<string
, Block
>
Source
packages/framework/store/src/store/doc/doc.ts:144
canRedo
get
canRedo():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc/doc.ts:78
canUndo
get
canUndo():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc/doc.ts:74
captureSync
get
captureSync(): () =>void
Returns
Function
Capture current operations to undo stack synchronously.
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:128
clear
get
clear(): () =>void
Returns
Function
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:140
collection
get
collection():DocCollection
Returns
Source
packages/framework/store/src/store/doc/doc.ts:50
docSync
get
docSync():DocEngine
Returns
DocEngine
Source
packages/framework/store/src/store/doc/doc.ts:54
generateBlockId
get
generateBlockId(): () =>string
Returns
Function
Returns
string
Source
packages/framework/store/src/store/doc/doc.ts:136
history
get
history():UndoManager
Returns
Source
packages/framework/store/src/store/doc/doc.ts:46
id
get
id():string
Returns
string
Source
packages/framework/store/src/store/doc/doc.ts:96
isEmpty
get
isEmpty():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc/doc.ts:70
loaded
get
loaded():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc/doc.ts:116
meta
get
meta():undefined
|DocMeta
Returns
undefined
| DocMeta
Source
packages/framework/store/src/store/doc/doc.ts:66
readonly
get
readonly():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc/doc.ts:31
ready
get
ready():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc/doc.ts:42
redo
get
redo(): () =>void
Returns
Function
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:86
resetHistory
get
resetHistory(): () =>void
Returns
Function
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:124
root
get
root():null
|BlockModel
<object
>
Returns
null
| BlockModel
<object
>
Source
packages/framework/store/src/store/doc/doc.ts:90
rootDoc
get
rootDoc():BlockSuiteDoc
Returns
Source
packages/framework/store/src/store/doc/doc.ts:108
schema
get
schema():Schema
Returns
Source
packages/framework/store/src/store/doc/doc.ts:38
spaceDoc
get
spaceDoc():Doc
Returns
Source
packages/framework/store/src/store/doc/doc.ts:104
transact
get
transact(): (fn
,shouldTransact
) =>void
Returns
Function
Parameters
• fn
• shouldTransact: boolean
= undefined
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:120
undo
get
undo(): () =>void
Returns
Function
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:82
withoutTransact
get
withoutTransact(): (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