BlockSuite API Documentation / @blocksuite/blocks / LayerManager
Class: LayerManager
Constructors
new LayerManager()
new LayerManager(
_doc
,_surface
):LayerManager
Parameters
• _doc: Doc
• _surface: SurfaceBlockModel
Returns
Defined in
packages/affine/block-surface/dist/managers/layer-manager.d.ts:69
Properties
blocks
blocks:
EdgelessBlockModel
<GfxCompatibleProps
>[]
Defined in
packages/affine/block-surface/dist/managers/layer-manager.d.ts:44
blocksGrid
blocksGrid:
GridManager
<EdgelessBlockModel
<GfxCompatibleProps
>>
Defined in
packages/affine/block-surface/dist/managers/layer-manager.d.ts:45
canvasElements
canvasElements:
SurfaceElementModel
<BaseElementProps
>[]
Defined in
packages/affine/block-surface/dist/managers/layer-manager.d.ts:46
canvasGrid
canvasGrid:
GridManager
<SurfaceElementModel
<BaseElementProps
>>
Defined in
packages/affine/block-surface/dist/managers/layer-manager.d.ts:47
canvasLayers
canvasLayers:
object
[]
Defined in
packages/affine/block-surface/dist/managers/layer-manager.d.ts:48
frames
frames:
FrameBlockModel
[]
Defined in
packages/affine/block-surface/dist/managers/layer-manager.d.ts:60
framesGrid
framesGrid:
GridManager
<FrameBlockModel
>
Defined in
packages/affine/block-surface/dist/managers/layer-manager.d.ts:61
layers
layers:
Layer
[]
Defined in
packages/affine/block-surface/dist/managers/layer-manager.d.ts:62
slots
slots:
object
layerUpdated
layerUpdated:
Slot
<object
>
Type declaration
initiatingElement
initiatingElement:
GfxModel
type
type:
"delete"
|"add"
|"update"
Defined in
packages/affine/block-surface/dist/managers/layer-manager.d.ts:63
INITAL_INDEX
static
INITAL_INDEX:string
Defined in
packages/affine/block-surface/dist/managers/layer-manager.d.ts:42
Methods
add()
add(
element
):void
Parameters
• element: GfxModel
Returns
void
Defined in
packages/affine/block-surface/dist/managers/layer-manager.d.ts:82
compare()
compare(
a
,b
):SortOrder
Pass to the Array.sort
to sort the elements by their index
Parameters
• a: GfxModel
• b: GfxModel
Returns
Defined in
packages/affine/block-surface/dist/managers/layer-manager.d.ts:86
createIndexGenerator()
createIndexGenerator(
ignoreRule
?): (elementType
) =>string
In some cases, we need to generate a bunch of indexes in advance before acutally adding the elements to the layer manager. Eg. when importing a template. The generateIndex
is a function only depends on the current state of the manager. So we cannot use it because it will always return the same index if the element is not added to manager.
This function return a index generator that can "remember" the index it generated without actually adding the element to the manager.
Parameters
• ignoreRule?: boolean
If true, the generator will not distinguish between block
and canvas
elements.
Returns
Function
Parameters
• elementType: string
Returns
string
Note
The generator cannot work with group
element.
Defined in
packages/affine/block-surface/dist/managers/layer-manager.d.ts:99
delete()
delete(
element
):void
Parameters
• element: GfxModel
Returns
void
Defined in
packages/affine/block-surface/dist/managers/layer-manager.d.ts:100
dispose()
dispose():
void
Returns
void
Defined in
packages/affine/block-surface/dist/managers/layer-manager.d.ts:101
generateIndex()
generateIndex(
elementType
):string
Parameters
• elementType: string
Returns
string
Defined in
packages/affine/block-surface/dist/managers/layer-manager.d.ts:102
getCanvasLayers()
getCanvasLayers():
object
[]
Returns
object
[]
Defined in
packages/affine/block-surface/dist/managers/layer-manager.d.ts:103
getReorderedIndex()
getReorderedIndex(
element
,direction
):string
Parameters
• element: GfxModel
• direction: ReorderingDirection
Returns
string
Defined in
packages/affine/block-surface/dist/managers/layer-manager.d.ts:115
getZIndex()
getZIndex(
element
):number
Parameters
• element: GfxModel
Returns
number
Defined in
packages/affine/block-surface/dist/managers/layer-manager.d.ts:116
update()
update(
element
,props
?):void
Parameters
• element: GfxModel
• props?: Record
<string
, unknown
>
Returns
void
Defined in
packages/affine/block-surface/dist/managers/layer-manager.d.ts:117
create()
static
create(doc
,surface
):LayerManager
Parameters
• doc: Doc
• surface: SurfaceBlockModel
Returns
Defined in
packages/affine/block-surface/dist/managers/layer-manager.d.ts:70