API > @blocksuite/store > Page
Class: Page ​
Extends ​
Space
<FlatBlockMap
>
Constructors ​
constructor ​
new Page(
__namedParameters
):Page
Parameters ​
Parameter | Type |
---|---|
__namedParameters | PageOptions |
Returns ​
Overrides ​
Defined In ​
packages/store/src/workspace/page.ts:109
Properties ​
_blockMap ​
private
_blockMap:Map
<string
,BaseBlockModel
<object
> >
Defined In ​
packages/store/src/workspace/page.ts:57
_history ​
private
_history:UndoManager
Defined In ​
packages/store/src/workspace/page.ts:55
_idGenerator ​
private
readonly
_idGenerator:IdGenerator
Defined In ​
packages/store/src/workspace/page.ts:54
_initialized ​
private
_initialized:boolean
=false
Defined In ​
packages/store/src/workspace/page.ts:58
_proxy ​
protected
readonly
_proxy:FlatBlockMap
Used for convenient access to the underlying Yjs map, can be used interchangeably with ySpace
Defined In ​
packages/store/src/workspace/space.ts:28
Inherited from ​
_root ​
private
_root:null
|BaseBlockModel
<object
> =null
Defined In ​
packages/store/src/workspace/page.ts:56
_shouldTransact ​
private
_shouldTransact:boolean
=true
Defined In ​
packages/store/src/workspace/page.ts:59
_workspace ​
private
readonly
_workspace:Workspace
Defined In ​
packages/store/src/workspace/page.ts:53
_yBlocks ​
protected
readonly
_yBlocks:Map
<YBlock
>
Defined In ​
packages/store/src/workspace/space.ts:30
Inherited from ​
_ySpaceDoc ​
protected
readonly
_ySpaceDoc:Doc
Defined In ​
packages/store/src/workspace/space.ts:29
Inherited from ​
awarenessStore ​
readonly
awarenessStore:AwarenessStore
<BlockSuiteFlags
>
Defined In ​
packages/store/src/workspace/space.ts:18
Inherited from ​
doc ​
readonly
doc:BlockSuiteDoc
Defined In ​
packages/store/src/workspace/space.ts:17
Inherited from ​
id ​
readonly
id:string
Defined In ​
packages/store/src/workspace/space.ts:16
Inherited from ​
slots ​
readonly
slots:object
Type declaration ​
slots.blockUpdated
​blockUpdated:
Slot
< {flavour
:string
;id
:string
;type
:"add"
;} | {flavour
:string
;id
:string
;parent
:string
;type
:"delete"
;} | {flavour
:string
;id
:string
;props
:Partial
<BlockProps
>;type
:"update"
;} >
slots.copied
​copied:
Slot
<void
>
slots.historyUpdated
​historyUpdated:
Slot
<void
>
slots.onYEvent
​onYEvent:
Slot
< {event
:YEvent
<Array
<unknown
> |Text
|YBlock
>;} >
slots.pasted
​pasted:
Slot
<Record
<string
,unknown
>[] >
slots.ready
​ready:
Slot
<void
>This fires when the block tree is initialized via API call or underlying existing ydoc binary. Note that this is different with the
doc.loaded
field, sinceloaded
only indicates that the ydoc is loaded, not the block tree.
slots.rootAdded
​rootAdded:
Slot
<BaseBlockModel
<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
|string
[] >
slots.textUpdated
​textUpdated:
Slot
<YTextEvent
>
slots.yBlockUpdated
​yBlockUpdated:
Slot
< {id
:string
;props
: {};type
:"add"
|"update"
|"delete"
;} >
slots.yUpdated
​yUpdated:
Slot
<void
>
Defined In ​
packages/store/src/workspace/page.ts:61
Accessors ​
Text ​
get
Text(): typeofText
Defined In ​
packages/store/src/workspace/page.ts:167
blob ​
get
blob():BlobManager
Defined In ​
packages/store/src/workspace/page.ts:141
canRedo ​
get
canRedo():boolean
Defined In ​
packages/store/src/workspace/page.ts:160
canUndo ​
get
canUndo():boolean
Defined In ​
packages/store/src/workspace/page.ts:153
history ​
get
history():UndoManager
Defined In ​
packages/store/src/workspace/page.ts:125
isEmpty ​
get
isEmpty():boolean
Defined In ​
packages/store/src/workspace/page.ts:149
loaded ​
get
loaded():boolean
Defined In ​
packages/store/src/workspace/space.ts:43
Inherited from ​
meta ​
get
meta():PageMeta
Defined In ​
packages/store/src/workspace/page.ts:137
readonly ​
get
readonly():boolean
Defined In ​
packages/store/src/workspace/page.ts:121
root ​
get
root():null
|BaseBlockModel
<object
>
Defined In ​
packages/store/src/workspace/page.ts:145
schema ​
get
schema():Schema
Defined In ​
packages/store/src/workspace/page.ts:133
spaceDoc ​
get
spaceDoc():Doc
Defined In ​
packages/store/src/workspace/space.ts:47
Inherited from ​
workspace ​
get
workspace():Workspace
Defined In ​
packages/store/src/workspace/page.ts:129
Methods ​
_createBlockModel ​
private
_createBlockModel(id
,flavour
,block
):BaseBlockModel
<object
>
Parameters ​
Parameter | Type |
---|---|
id | string |
flavour | string |
block | YBlock |
Returns ​
BaseBlockModel
< object
>
Defined In ​
packages/store/src/workspace/page.ts:718
_getYBlock ​
private
_getYBlock(id
):null
|YBlock
Parameters ​
Parameter | Type |
---|---|
id | string |
Returns ​
null
| YBlock
Defined In ​
packages/store/src/workspace/page.ts:708
_handleVersion ​
private
_handleVersion():void
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:921
_handleYBlockAdd ​
private
_handleYBlockAdd(visited
,id
):void
Parameters ​
Parameter | Type |
---|---|
visited | Set < string > |
id | string |
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:729
_handleYBlockDelete ​
private
_handleYBlockDelete(id
):void
Parameters ​
Parameter | Type |
---|---|
id | string |
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:771
_handleYBlockUpdate ​
private
_handleYBlockUpdate(event
):void
Parameters ​
Parameter | Type |
---|---|
event | YMapEvent < unknown > |
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:789
_handleYEvent ​
private
_handleYEvent(event
):void
Parameters ​
Parameter | Type |
---|---|
event | YEvent < Array < unknown > | Text | YBlock > |
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:845
_handleYEvents ​
private
_handleYEvents(events
):void
Parameters ​
Parameter | Type |
---|---|
events | YEvent < Text | YBlock >[] |
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:910
_historyObserver ​
private
_historyObserver():void
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:714
_initYBlocks ​
private
_initYBlocks():void
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:695
addBlock ​
addBlock(
flavour
,blockProps
={}
,parent
?,parentIndex
?):string
Parameters ​
Parameter | Type |
---|---|
flavour | string |
blockProps | Partial < BlockSysProps & {} & Omit < BlockProps , "flavour" > > |
parent ? | null | string | BaseBlockModel < object > |
parentIndex ? | number |
Returns ​
string
Defined In ​
packages/store/src/workspace/page.ts:340
addBlocks ​
addBlocks(
blocks
,parent
?,parentIndex
?):string
[]
Parameters ​
Parameter | Type |
---|---|
blocks | {blockProps : Partial < BlockSysProps & {} & Omit < BlockProps , "id" | "flavour" > >; flavour : string ;}[] |
parent ? | null | string | BaseBlockModel < object > |
parentIndex ? | number |
Returns ​
string
[]
Defined In ​
packages/store/src/workspace/page.ts:317
addSiblingBlocks ​
addSiblingBlocks(
targetModel
,props
,place
='after'
):string
[]
Parameters ​
Parameter | Type | Default value |
---|---|---|
targetModel | BaseBlockModel < object > | undefined |
props | Partial < BaseBlockModel < object > >[] | undefined |
place | "after" | "before" | 'after' |
Returns ​
string
[]
Defined In ​
packages/store/src/workspace/page.ts:545
captureSync ​
captureSync():
void
Capture current operations to undo stack synchronously.
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:201
clear ​
clear():
void
Returns ​
void
Inherited from ​
Defined In ​
packages/store/src/workspace/space.ts:80
deleteBlock ​
deleteBlock(
model
,options
=...
):void
Parameters ​
Parameter | Type |
---|---|
model | BaseBlockModel < object > |
options | object |
options.bringChildrenTo ? | BaseBlockModel < object > |
options.deleteChildren ? | boolean |
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:577
destroy ​
destroy():
void
Returns ​
void
Inherited from ​
Defined In ​
packages/store/src/workspace/space.ts:74
dispose ​
dispose():
void
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:680
generateBlockId ​
generateBlockId():
string
Returns ​
string
Defined In ​
packages/store/src/workspace/page.ts:209
getBlockByFlavour ​
getBlockByFlavour(
blockFlavour
):BaseBlockModel
<object
>[]
Parameters ​
Parameter | Type |
---|---|
blockFlavour | string | string [] |
Returns ​
BaseBlockModel
< object
>[]
Defined In ​
packages/store/src/workspace/page.ts:217
getBlockById ​
getBlockById(
id
):null
|BaseBlockModel
<object
>
Parameters ​
Parameter | Type |
---|---|
id | string |
Returns ​
null
| BaseBlockModel
< object
>
Defined In ​
packages/store/src/workspace/page.ts:213
getInitialPropsByFlavour ​
getInitialPropsByFlavour(
flavour
):Record
<string
,any
>
Parameters ​
Parameter | Type |
---|---|
flavour | string |
Returns ​
Record
< string
, any
>
Defined In ​
packages/store/src/workspace/page.ts:311
getNextSibling ​
getNextSibling(
block
):null
|BaseBlockModel
<object
>
Parameters ​
Parameter | Type |
---|---|
block | BaseBlockModel < object > |
Returns ​
null
| BaseBlockModel
< object
>
Defined In ​
packages/store/src/workspace/page.ts:279
getNextSiblings ​
getNextSiblings(
block
):BaseBlockModel
<object
>[]
Parameters ​
Parameter | Type |
---|---|
block | BaseBlockModel < object > |
Returns ​
BaseBlockModel
< object
>[]
Defined In ​
packages/store/src/workspace/page.ts:293
getParent ​
getParent(
target
):null
|BaseBlockModel
<object
>
Parameters ​
Parameter | Type |
---|---|
target | string | BaseBlockModel < object > |
Returns ​
null
| BaseBlockModel
< object
>
Defined In ​
packages/store/src/workspace/page.ts:226
getPreviousSibling ​
getPreviousSibling(
block
):null
|BaseBlockModel
<object
>
Parameters ​
Parameter | Type |
---|---|
block | BaseBlockModel < object > |
Returns ​
null
| BaseBlockModel
< object
>
Defined In ​
packages/store/src/workspace/page.ts:251
getPreviousSiblings ​
getPreviousSiblings(
block
):BaseBlockModel
<object
>[]
Parameters ​
Parameter | Type |
---|---|
block | BaseBlockModel < object > |
Returns ​
BaseBlockModel
< object
>[]
Defined In ​
packages/store/src/workspace/page.ts:265
getSchemaByFlavour ​
getSchemaByFlavour(
flavour
):undefined
| {model
:{ flavour: string; role: "root" | "hub" | "content"; parent?: string[] | undefined; children?: string[] | undefined; props?: ((args_0: InternalPrimitives, ...args_1: unknown[]) => Record<...>) | undefined; toModel?: ((...args: unknown[]) => BaseBlockModel<...>) | undefined; }
;onUpgrade
: (...args
) =>void
;transformer
: (...args
) =>BaseBlockTransformer
<object
>;version
:number
;}
Parameters ​
Parameter | Type |
---|---|
flavour | string |
Returns ​
undefined
| {model
: { flavour: string; role: "root" | "hub" | "content"; parent?: string[] | undefined; children?: string[] | undefined; props?: ((args_0: InternalPrimitives, ...args_1: unknown[]) => Record<...>) | undefined; toModel?: ((...args: unknown[]) => BaseBlockModel<...>) | undefined; }
; onUpgrade
: (...args
) => void
; transformer
: (...args
) => BaseBlockTransformer
< object
>; version
: number
;}
Defined In ​
packages/store/src/workspace/page.ts:307
moveBlocks ​
moveBlocks(
blocksToMove
,newParent
,targetSibling
=null
,shouldInsertBeforeSibling
=true
):void
Parameters ​
Parameter | Type | Default value |
---|---|---|
blocksToMove | BaseBlockModel < object >[] | undefined |
newParent | BaseBlockModel < object > | undefined |
targetSibling | null | BaseBlockModel < object > | null |
shouldInsertBeforeSibling | boolean | true |
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:395
redo ​
redo():
void
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:192
remove ​
remove():
void
Returns ​
void
Inherited from ​
Defined In ​
packages/store/src/workspace/space.ts:69
resetHistory ​
resetHistory():
void
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:205
transact ​
transact(
fn
,shouldTransact
=...
):void
If shouldTransact
is false
, the transaction will not be push to the history stack.
Parameters ​
Parameter | Type |
---|---|
fn | function |
shouldTransact | boolean |
Returns ​
void
Overrides ​
Defined In ​
packages/store/src/workspace/page.ts:177
trySyncFromExistingDoc ​
trySyncFromExistingDoc():
void
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:657
undo ​
undo():
void
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:184
updateBlock ​
updateBlock<
T
>(model
,props
):void
Type parameters ​
Parameter |
---|
T extends Partial < BlockProps > |
Parameters ​
Parameter | Type |
---|---|
model | BaseBlockModel < object > |
props | T |
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:494
validateVersion ​
validateVersion():
void
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:917
waitForLoaded ​
waitForLoaded():
Promise
<Page
>
Returns ​
Promise
< Page
>
Overrides ​
Defined In ​
packages/store/src/workspace/page.ts:931
withoutTransact ​
withoutTransact(
callback
):void
Parameters ​
Parameter | Type |
---|---|
callback | function |
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:171