BlockSuite API Documentation / @blocksuite/store / Doc
Class: Doc
Constructors
new Doc(__namedParameters)
new Doc(
__namedParameters
):Doc
Parameters
• __namedParameters: DocOptions
Returns
Source
packages/framework/store/src/store/doc/doc.ts:27
Properties
_blockCollection
protected
readonly
_blockCollection:BlockCollection
Source
packages/framework/store/src/store/doc/doc.ts:22
_blocks
protected
readonly
_blocks:Map
<string
,Block
>
Source
packages/framework/store/src/store/doc/doc.ts:21
_crud
protected
readonly
_crud:DocCRUD
Source
packages/framework/store/src/store/doc/doc.ts:23
_disposeBlockUpdated
protected
readonly
_disposeBlockUpdated:Disposable
Source
packages/framework/store/src/store/doc/doc.ts:25
_schema
protected
readonly
_schema:Schema
Source
packages/framework/store/src/store/doc/doc.ts:20
_selector
protected
readonly
_selector:BlockSelector
Source
packages/framework/store/src/store/doc/doc.ts:24
Accessors
Text
get
Text(): 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
get
awarenessStore():AwarenessStore
<BlockSuiteFlags
>
Returns
AwarenessStore
<BlockSuiteFlags
>
Source
packages/framework/store/src/store/doc/doc.ts:137
blob
get
blob():BlobManager
Returns
Source
packages/framework/store/src/store/doc/doc.ts:87
blockCollection
get
blockCollection():BlockCollection
Returns
Source
packages/framework/store/src/store/doc/doc.ts:59
blocks
get
blocks():Map
<string
,Block
>
Returns
Map
<string
, Block
>
Source
packages/framework/store/src/store/doc/doc.ts:266
canRedo
get
canRedo():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc/doc.ts:99
canUndo
get
canUndo():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc/doc.ts:95
captureSync
get
captureSync(): () =>void
Returns
Function
Capture current operations to undo stack synchronously.
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:153
clear
get
clear(): () =>void
Returns
Function
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:165
collection
get
collection():DocCollection
Returns
Source
packages/framework/store/src/store/doc/doc.ts:79
generateBlockId
get
generateBlockId(): () =>string
Returns
Function
Returns
string
Source
packages/framework/store/src/store/doc/doc.ts:161
history
get
history():UndoManager
Returns
Source
packages/framework/store/src/store/doc/doc.ts:75
id
get
id():string
Returns
string
Source
packages/framework/store/src/store/doc/doc.ts:117
isEmpty
get
isEmpty():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc/doc.ts:91
loaded
get
loaded():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc/doc.ts:141
meta
get
meta():undefined
|DocMeta
Returns
undefined
| DocMeta
Source
packages/framework/store/src/store/doc/doc.ts:83
readonly
get
readonly():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc/doc.ts:63
ready
get
ready():boolean
Returns
boolean
Source
packages/framework/store/src/store/doc/doc.ts:71
redo
get
redo(): () =>void
Returns
Function
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:107
resetHistory
get
resetHistory(): () =>void
Returns
Function
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:149
root
get
root():null
|BlockModel
<object
>
Returns
null
| BlockModel
<object
>
Source
packages/framework/store/src/store/doc/doc.ts:111
rootDoc
get
rootDoc():BlockSuiteDoc
Returns
Source
packages/framework/store/src/store/doc/doc.ts:129
schema
get
schema():Schema
Returns
Source
packages/framework/store/src/store/doc/doc.ts:67
slots
get
slots():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
get
spaceDoc():Doc
Returns
Source
packages/framework/store/src/store/doc/doc.ts:125
transact
get
transact(): (fn
,shouldTransact
) =>void
Returns
Function
Parameters
• fn
• shouldTransact:
boolean
=undefined
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:145
undo
get
undo(): () =>void
Returns
Function
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:103
withoutTransact
get
withoutTransact(): (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
):void
Parameters
• id: string
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:336
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:380
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:386
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:357
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:483
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:520
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:417
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:438
updateBlock(model, callback)
updateBlock(
model
,callback
):void
Parameters
• model: BlockModel
<object
>
• callback
Returns
void
Source
packages/framework/store/src/store/doc/doc.ts:439