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:86
Properties ​
_blockTree ​
private
readonly
_blockTree:BlockTree
Defined In ​
packages/store/src/workspace/page.ts:41
_docLoaded ​
private
_docLoaded:boolean
=false
Indicate whether the underlying subdoc has been loaded.
Defined In ​
packages/store/src/workspace/page.ts:45
_history ​
private
_history:UndoManager
Defined In ​
packages/store/src/workspace/page.ts:42
_idGenerator ​
private
readonly
_idGenerator:IdGenerator
Defined In ​
packages/store/src/workspace/page.ts:40
_ready ​
private
_ready:boolean
=false
Indicate whether the block tree is ready
Defined In ​
packages/store/src/workspace/page.ts:47
_root ​
private
_root:null
|BaseBlockModel
<object
> =null
Defined In ​
packages/store/src/workspace/page.ts:43
_shouldTransact ​
private
_shouldTransact:boolean
=true
Defined In ​
packages/store/src/workspace/page.ts:48
_workspace ​
private
readonly
_workspace:Workspace
Defined In ​
packages/store/src/workspace/page.ts:39
_yBlocks ​
protected
readonly
_yBlocks:Map
<YBlock
>
Defined In ​
packages/store/src/workspace/space.ts:29
Inherited from ​
_ySpaceDoc ​
protected
readonly
_ySpaceDoc:Doc
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 ​
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
;model
:BaseBlockModel
<object
>;parent
:string
;type
:"delete"
;} | {flavour
:string
;id
:string
;type
:"update"
;} >
slots.historyUpdated
​historyUpdated:
Slot
<void
>
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
[] >
Defined In ​
packages/store/src/workspace/page.ts:50
Accessors ​
Text ​
get
Text(): typeofText
Defined In ​
packages/store/src/workspace/page.ts:152
blob ​
get
blob():BlobManager
Defined In ​
packages/store/src/workspace/page.ts:126
canRedo ​
get
canRedo():boolean
Defined In ​
packages/store/src/workspace/page.ts:145
canUndo ​
get
canUndo():boolean
Defined In ​
packages/store/src/workspace/page.ts:138
history ​
get
history():UndoManager
Defined In ​
packages/store/src/workspace/page.ts:110
isEmpty ​
get
isEmpty():boolean
Defined In ​
packages/store/src/workspace/page.ts:134
loaded ​
get
loaded():boolean
Defined In ​
packages/store/src/workspace/space.ts:45
Inherited from ​
meta ​
get
meta():PageMeta
Defined In ​
packages/store/src/workspace/page.ts:122
readonly ​
get
readonly():boolean
Defined In ​
packages/store/src/workspace/page.ts:102
ready ​
get
ready():boolean
Defined In ​
packages/store/src/workspace/page.ts:106
root ​
get
root():null
|BaseBlockModel
<object
>
Defined In ​
packages/store/src/workspace/page.ts:130
schema ​
get
schema():Schema
Defined In ​
packages/store/src/workspace/page.ts:118
spaceDoc ​
get
spaceDoc():Doc
Defined In ​
packages/store/src/workspace/space.ts:49
Inherited from ​
workspace ​
get
workspace():Workspace
Defined In ​
packages/store/src/workspace/page.ts:114
yBlocks ​
get
yBlocks():Map
<State
[keyofState
] >
Defined In ​
packages/store/src/workspace/space.ts:41
Inherited from ​
Methods ​
_getYBlock ​
private
_getYBlock(id
):null
|YBlock
Parameters ​
Parameter | Type |
---|---|
id | string |
Returns ​
null
| YBlock
Defined In ​
packages/store/src/workspace/page.ts:678
_handleVersion ​
private
_handleVersion():void
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:783
_handleYBlockAdd ​
private
_handleYBlockAdd(id
):void
Parameters ​
Parameter | Type |
---|---|
id | string |
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:688
_handleYBlockDelete ​
private
_handleYBlockDelete(id
):void
Parameters ​
Parameter | Type |
---|---|
id | string |
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:737
_handleYEvent ​
private
_handleYEvent(event
):void
Parameters ​
Parameter | Type |
---|---|
event | YEvent < Text | Array < unknown > | YBlock > |
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:754
_handleYEvents ​
private
_handleYEvents(events
):void
Parameters ​
Parameter | Type |
---|---|
events | YEvent < Text | YBlock >[] |
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:773
_historyObserver ​
private
_historyObserver():void
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:684
_initYBlocks ​
private
_initYBlocks():void
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:665
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:325
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:302
addSiblingBlocks ​
addSiblingBlocks(
targetModel
,props
,place
='after'
):string
[]
Parameters ​
Parameter | Type | Default value |
---|---|---|
targetModel | BaseBlockModel < object > | undefined |
props | Partial < BlockProps >[] | undefined |
place | "after" | "before" | 'after' |
Returns ​
string
[]
Defined In ​
packages/store/src/workspace/page.ts:520
captureSync ​
captureSync():
void
Capture current operations to undo stack synchronously.
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:186
clear ​
clear():
void
Returns ​
void
Inherited from ​
Defined In ​
packages/store/src/workspace/space.ts:82
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:552
destroy ​
destroy():
void
Returns ​
void
Inherited from ​
Defined In ​
packages/store/src/workspace/space.ts:76
dispose ​
dispose():
void
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:653
generateBlockId ​
generateBlockId():
string
Returns ​
string
Defined In ​
packages/store/src/workspace/page.ts:194
getBlockByFlavour ​
getBlockByFlavour(
blockFlavour
):BaseBlockModel
<object
>[]
Parameters ​
Parameter | Type |
---|---|
blockFlavour | string | string [] |
Returns ​
BaseBlockModel
< object
>[]
Defined In ​
packages/store/src/workspace/page.ts:202
getBlockById ​
getBlockById(
id
):null
|BaseBlockModel
<object
>
Parameters ​
Parameter | Type |
---|---|
id | string |
Returns ​
null
| BaseBlockModel
< object
>
Defined In ​
packages/store/src/workspace/page.ts:198
getInitialPropsByFlavour ​
getInitialPropsByFlavour(
flavour
):Record
<string
,any
>
Parameters ​
Parameter | Type |
---|---|
flavour | string |
Returns ​
Record
< string
, any
>
Defined In ​
packages/store/src/workspace/page.ts:296
getNextSibling ​
getNextSibling(
block
):null
|BaseBlockModel
<object
>
Parameters ​
Parameter | Type |
---|---|
block | BaseBlockModel < object > |
Returns ​
null
| BaseBlockModel
< object
>
Defined In ​
packages/store/src/workspace/page.ts:264
getNextSiblings ​
getNextSiblings(
block
):BaseBlockModel
<object
>[]
Parameters ​
Parameter | Type |
---|---|
block | BaseBlockModel < object > |
Returns ​
BaseBlockModel
< object
>[]
Defined In ​
packages/store/src/workspace/page.ts:278
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:211
getPreviousSibling ​
getPreviousSibling(
block
):null
|BaseBlockModel
<object
>
Parameters ​
Parameter | Type |
---|---|
block | BaseBlockModel < object > |
Returns ​
null
| BaseBlockModel
< object
>
Defined In ​
packages/store/src/workspace/page.ts:236
getPreviousSiblings ​
getPreviousSiblings(
block
):BaseBlockModel
<object
>[]
Parameters ​
Parameter | Type |
---|---|
block | BaseBlockModel < object > |
Returns ​
BaseBlockModel
< object
>[]
Defined In ​
packages/store/src/workspace/page.ts:250
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:292
load ​
load(
initFn
?):Promise
<Page
>
Parameters ​
Parameter | Type |
---|---|
initFn ? | function |
Returns ​
Promise
< Page
>
Overrides ​
Defined In ​
packages/store/src/workspace/page.ts:793
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:376
redo ​
redo():
void
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:177
remove ​
remove():
void
Returns ​
void
Inherited from ​
Defined In ​
packages/store/src/workspace/space.ts:71
resetHistory ​
resetHistory():
void
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:190
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:162
trySyncFromExistingDoc ​
trySyncFromExistingDoc():
void
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:630
undo ​
undo():
void
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:169
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:468
updateBlock(
model
,callback
):void
Parameters ​
Parameter | Type |
---|---|
model | BaseBlockModel < object > |
callback | function |
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:472
validateVersion ​
validateVersion():
void
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:779
waitForLoaded ​
waitForLoaded():
Promise
<void
>
Returns ​
Promise
< void
>
Deprecated ​
use page.load() instead
Defined In ​
packages/store/src/workspace/page.ts:809
withoutTransact ​
withoutTransact(
callback
):void
Parameters ​
Parameter | Type |
---|---|
callback | function |
Returns ​
void
Defined In ​
packages/store/src/workspace/page.ts:156