BlockSuite API Documentation / @blocksuite/block-std / SelectionManager
Class: SelectionManager
A life cycle watcher is an extension that watches the life cycle of the editor. It is used to perform actions when the editor is created, mounted, rendered, or unmounted.
When creating a life cycle watcher, you must define a key that is unique to the watcher. The key is used to identify the watcher in the dependency injection container.
class MyLifeCycleWatcher extends LifeCycleWatcher {
static override readonly key = 'my-life-cycle-watcher';
In the life cycle watcher, the methods will be called in the following order:
created
: Called when the std is created.rendered
: Called whenstd.render
is called.mounted
: Called when the editor host is mounted.unmounted
: Called when the editor host is unmounted.
Extends
Constructors
new SelectionManager()
new SelectionManager(
std
):SelectionManager
Parameters
std
Returns
Overrides
Defined in
packages/framework/block-std/src/selection/manager.ts:75
Properties
disposables
disposables:
DisposableGroup
Defined in
packages/framework/block-std/src/selection/manager.ts:52
slots
slots:
object
changed
changed:
Slot
<BaseSelection
[]>
remoteChanged
remoteChanged:
Slot
<Map
<number
,BaseSelection
[]>>
Defined in
packages/framework/block-std/src/selection/manager.ts:54
std
readonly
std:BlockStdScope
Inherited from
Defined in
packages/framework/block-std/src/extension/lifecycle-watcher.ts:30
key
readonly
static
key:"selectionManager"
='selectionManager'
Overrides
Defined in
packages/framework/block-std/src/selection/manager.ts:20
Accessors
id
Get Signature
get id():
string
Returns
string
Defined in
packages/framework/block-std/src/selection/manager.ts:63
remoteSelections
Get Signature
get remoteSelections():
Map
<number
,BaseSelection
[]>
Returns
Map
<number
, BaseSelection
[]>
Defined in
packages/framework/block-std/src/selection/manager.ts:67
value
Get Signature
get value():
BaseSelection
[]
Returns
Defined in
packages/framework/block-std/src/selection/manager.ts:71
Methods
clear()
clear(
types
?):void
Parameters
types?
string
[]
Returns
void
Defined in
packages/framework/block-std/src/selection/manager.ts:136
create()
create<
T
>(type
, ...args
):SelectionInstance
[T
]
Type Parameters
• T extends keyof Selection
Parameters
type
T
args
...ConstructorParameters
<Selection
[T
]>
Returns
SelectionInstance
[T
]
Defined in
packages/framework/block-std/src/selection/manager.ts:147
created()
created():
void
Called when std is created.
Returns
void
Inherited from
Defined in
packages/framework/block-std/src/extension/lifecycle-watcher.ts:54
dispose()
dispose():
void
Returns
void
Defined in
packages/framework/block-std/src/selection/manager.ts:161
filter()
filter<
T
>(type
):SelectionInstance
[T
][]
Type Parameters
• T extends keyof Selection
Parameters
type
T
Returns
SelectionInstance
[T
][]
Defined in
packages/framework/block-std/src/selection/manager.ts:166
filter$()
filter$<
T
>(type
):ReadonlySignal
<SelectionInstance
[T
][]>
Type Parameters
• T extends keyof Selection
Parameters
type
T
Returns
ReadonlySignal
<SelectionInstance
[T
][]>
Defined in
packages/framework/block-std/src/selection/manager.ts:170
find()
find<
T
>(type
):undefined
|SelectionInstance
[T
]
Type Parameters
• T extends keyof Selection
Parameters
type
T
Returns
undefined
| SelectionInstance
[T
]
Defined in
packages/framework/block-std/src/selection/manager.ts:178
find$()
find$<
T
>(type
):ReadonlySignal
<undefined
|SelectionInstance
[T
]>
Type Parameters
• T extends keyof Selection
Parameters
type
T
Returns
ReadonlySignal
<undefined
| SelectionInstance
[T
]>
Defined in
packages/framework/block-std/src/selection/manager.ts:182
fromJSON()
fromJSON(
json
):void
Parameters
json
Record
<string
, unknown
>[]
Returns
void
Defined in
packages/framework/block-std/src/selection/manager.ts:190
getGroup()
getGroup(
group
):BaseSelection
[]
Parameters
group
string
Returns
Defined in
packages/framework/block-std/src/selection/manager.ts:197
mounted()
mounted():
void
Called when editor host is mounted. Which means the editor host emit the connectedCallback
lifecycle event.
Returns
void
Overrides
Defined in
packages/framework/block-std/src/selection/manager.ts:201
register()
register(
ctor
):SelectionManager
Parameters
ctor
SelectionConstructor
| SelectionConstructor
[]
Returns
Defined in
packages/framework/block-std/src/selection/manager.ts:217
rendered()
rendered():
void
Called when std.render
is called.
Returns
void
Inherited from
Defined in
packages/framework/block-std/src/extension/lifecycle-watcher.ts:65
set()
set(
selections
):void
Parameters
selections
Returns
void
Defined in
packages/framework/block-std/src/selection/manager.ts:224
setGroup()
setGroup(
group
,selections
):void
Parameters
group
string
selections
Returns
void
Defined in
packages/framework/block-std/src/selection/manager.ts:232
unmounted()
unmounted():
void
Called when editor host is unmounted. Which means the editor host emit the disconnectedCallback
lifecycle event.
Returns
void
Overrides
Defined in
packages/framework/block-std/src/selection/manager.ts:237
update()
update(
fn
):void
Parameters
fn
(currentSelections
) => BaseSelection
[]
Returns
void
Defined in
packages/framework/block-std/src/selection/manager.ts:245
setup()
static
setup(di
):void
Parameters
di
Container
Returns
void
Inherited from
Defined in
packages/framework/block-std/src/extension/lifecycle-watcher.ts:34