Skip to content

BlockSuite API Documentation / @blocksuite/block-std / BlockComponent

Class: BlockComponent<Model, Service, WidgetName>

Extends

Extended by

Type Parameters

Model extends BlockModel = BlockModel

Service extends BlockService = BlockService

WidgetName extends string = string

Constructors

new BlockComponent()

new BlockComponent<Model, Service, WidgetName>(): BlockComponent<Model, Service, WidgetName>

Returns

BlockComponent<Model, Service, WidgetName>

Inherited from

SignalWatcher(WithDisposable(ShadowlessElement)).constructor

Defined in

node_modules/@lit/reactive-element/development/reactive-element.d.ts:504

Other

_disposables

protected _disposables: DisposableGroup

Inherited from

SignalWatcher(WithDisposable(ShadowlessElement))._disposables

Defined in

packages/framework/global/dist/utils/with-disposable.d.ts:5


[blockComponentSymbol]

[blockComponentSymbol]: boolean = true

Defined in

packages/framework/block-std/src/view/element/block-component.ts:52


disposables

readonly disposables: DisposableGroup

Inherited from

SignalWatcher(WithDisposable(ShadowlessElement)).disposables

Defined in

packages/framework/global/dist/utils/with-disposable.d.ts:6


virtualKeyboardPolicy

virtualKeyboardPolicy: string

Inherited from

SignalWatcher(WithDisposable(ShadowlessElement)).virtualKeyboardPolicy

Defined in

packages/framework/global/dist/types/virtual-keyboard.d.ts:20


connectedCount

static connectedCount: WeakMap<Constructor, WeakMap<Node, number>>

Inherited from

SignalWatcher(WithDisposable(ShadowlessElement)).connectedCount

Defined in

packages/framework/block-std/src/view/element/shadowless-element.ts:9


onDisconnectedMap

static onDisconnectedMap: WeakMap<Constructor, null | () => void>

Inherited from

SignalWatcher(WithDisposable(ShadowlessElement)).onDisconnectedMap

Defined in

packages/framework/block-std/src/view/element/shadowless-element.ts:14


_renderers

Defined in

packages/framework/block-std/src/view/element/block-component.ts:301


blockId

Get Signature

get blockId(): string

Returns

string

Defined in

packages/framework/block-std/src/view/element/block-component.ts:71


childBlocks

Get Signature

get childBlocks(): BlockComponent<BlockModel<object, SignaledProps<object>>, BlockService, string>[]

Returns

BlockComponent<BlockModel<object, SignaledProps<object>>, BlockService, string>[]

Defined in

packages/framework/block-std/src/view/element/block-component.ts:75


doc

Defined in

packages/framework/block-std/src/view/element/block-component.ts:312


flavour

Get Signature

get flavour(): string

Returns

string

Defined in

packages/framework/block-std/src/view/element/block-component.ts:84


host

Get Signature

get host(): EditorHost

Returns

EditorHost

Defined in

packages/framework/block-std/src/view/element/block-component.ts:88


isVersionMismatch

Get Signature

get isVersionMismatch(): boolean

Returns

boolean

Defined in

packages/framework/block-std/src/view/element/block-component.ts:92


model

Get Signature

get model(): Model

Returns

Model

Defined in

packages/framework/block-std/src/view/element/block-component.ts:112


parentComponent

Get Signature

get parentComponent(): null | BlockComponent<BlockModel<object, SignaledProps<object>>, BlockService, string>

Returns

null | BlockComponent<BlockModel<object, SignaledProps<object>>, BlockService, string>

Defined in

packages/framework/block-std/src/view/element/block-component.ts:127


renderChildren

Get Signature

get renderChildren(): (model, filter?) => TemplateResult

Returns

Function

Parameters
model

BlockModel<object, SignaledProps<object>>

filter?

(model) => boolean

Returns

TemplateResult

Defined in

packages/framework/block-std/src/view/element/block-component.ts:133


rootComponent

Get Signature

get rootComponent(): null | BlockComponent<BlockModel<object, SignaledProps<object>>, BlockService, string>

Returns

null | BlockComponent<BlockModel<object, SignaledProps<object>>, BlockService, string>

Defined in

packages/framework/block-std/src/view/element/block-component.ts:137


selected

Get Signature

get selected(): null | BaseSelection

Returns

null | BaseSelection

Defined in

packages/framework/block-std/src/view/element/block-component.ts:146


selection

Get Signature

get selection(): SelectionManager

Returns

SelectionManager

Defined in

packages/framework/block-std/src/view/element/block-component.ts:150


service

Get Signature

get service(): Service

Returns

Service

Defined in

packages/framework/block-std/src/view/element/block-component.ts:154


std

Defined in

packages/framework/block-std/src/view/element/block-component.ts:38


topContenteditableElement

Get Signature

get topContenteditableElement(): null | BlockComponent<BlockModel<object, SignaledProps<object>>, BlockService, string>

Returns

null | BlockComponent<BlockModel<object, SignaledProps<object>>, BlockService, string>

Defined in

packages/framework/block-std/src/view/element/block-component.ts:163


viewType

Defined in

packages/framework/block-std/src/view/element/block-component.ts:315


widgetComponents

Get Signature

get widgetComponents(): Partial<Record<WidgetName, WidgetComponent<BlockModel<object, SignaledProps<object>>, BlockComponent<BlockModel<object, SignaledProps<object>>, BlockService, string>, BlockService>>>

Returns

Partial<Record<WidgetName, WidgetComponent<BlockModel<object, SignaledProps<object>>, BlockComponent<BlockModel<object, SignaledProps<object>>, BlockService, string>, BlockService>>>

Defined in

packages/framework/block-std/src/view/element/block-component.ts:167


widgets

Defined in

packages/framework/block-std/src/view/element/block-component.ts:330


addRenderer()

addRenderer(renderer): void

Parameters

renderer

(content) => unknown

Returns

void

Defined in

packages/framework/block-std/src/view/element/block-component.ts:198


bindHotKey()

bindHotKey(keymap, options?): () => void

Parameters

keymap

Record<string, UIEventHandler>

options?
flavour

boolean

global

boolean

Returns

Function

Returns

void

Defined in

packages/framework/block-std/src/view/element/block-component.ts:202


connectedCallback()

connectedCallback(): void

Returns

void

Overrides

SignalWatcher(WithDisposable(ShadowlessElement)).connectedCallback

Defined in

packages/framework/block-std/src/view/element/block-component.ts:218


disconnectedCallback()

disconnectedCallback(): void

Returns

void

Overrides

SignalWatcher(WithDisposable(ShadowlessElement)).disconnectedCallback

Defined in

packages/framework/block-std/src/view/element/block-component.ts:243


handleEvent()

handleEvent(name, handler, options?): void

Parameters

name

"copy" | "blur" | "click" | "doubleClick" | "tripleClick" | "pointerDown" | "pointerMove" | "pointerUp" | "pointerOut" | "dragStart" | "dragMove" | "dragEnd" | "pinch" | "pan" | "keyDown" | "keyUp" | "selectionChange" | "compositionStart" | "compositionUpdate" | "compositionEnd" | "cut" | "paste" | "nativeDragStart" | "nativeDragMove" | "nativeDragEnd" | "nativeDrop" | "beforeInput" | "focus" | "contextMenu" | "wheel"

handler

UIEventHandler

options?
flavour

boolean

global

boolean

Returns

void

Defined in

packages/framework/block-std/src/view/element/block-component.ts:54


renderBlock()

renderBlock(): unknown

Returns

unknown

Defined in

packages/framework/block-std/src/view/element/block-component.ts:265


renderVersionMismatch()

renderVersionMismatch(expectedVersion, actualVersion): TemplateResult

Render a warning message when the block version is mismatched.

Parameters

expectedVersion

number

If the schema is not found, the expected version is -1. Which means the block is not supported in the current editor.

actualVersion

number

The version of the block's crdt data.

Returns

TemplateResult

Defined in

packages/framework/block-std/src/view/element/block-component.ts:275

rendering

createRenderRoot()

createRenderRoot(): BlockComponent<Model, Service, WidgetName>

Returns

BlockComponent<Model, Service, WidgetName>

Inherited from

SignalWatcher(WithDisposable(ShadowlessElement)).createRenderRoot

Defined in

packages/framework/block-std/src/view/element/shadowless-element.ts:78


render()

render(): unknown

Invoked on each update to perform rendering tasks. This method may return any value renderable by lit-html's ChildPart - typically a TemplateResult. Setting properties inside this method will not trigger the element to update.

Returns

unknown

Overrides

SignalWatcher(WithDisposable(ShadowlessElement)).render

Defined in

packages/framework/block-std/src/view/element/block-component.ts:258

styles

finalizeStyles()

protected static finalizeStyles(styles?): CSSResultOrNative[]

Takes the styles the user supplied via the static styles property and returns the array of styles to apply to the element. Override this method to integrate into a style management system.

Styles are deduplicated preserving the last instance in the list. This is a performance optimization to avoid duplicated styles that can occur especially when composing via subclassing. The last item is kept to try to preserve the cascade order with the assumption that it's most important that last added styles override previous styles.

Parameters

styles?

CSSResultGroup

Returns

CSSResultOrNative[]

Nocollapse

Inherited from

SignalWatcher(WithDisposable(ShadowlessElement)).finalizeStyles

Defined in

packages/framework/block-std/src/view/element/shadowless-element.ts:21

updates

getUpdateComplete()

protected getUpdateComplete(): Promise<boolean>

Override point for the updateComplete promise.

It is not safe to override the updateComplete getter directly due to a limitation in TypeScript which means it is not possible to call a superclass getter (e.g. super.updateComplete.then(...)) when the target language is ES5 (https://github.com/microsoft/TypeScript/issues/338). This method should be overridden instead. For example:

ts
class MyElement extends LitElement {
  override async getUpdateComplete() {
    const result = await super.getUpdateComplete();
    await this._myChild.updateComplete;
    return result;
  }
}

Returns

Promise<boolean>

A promise of a boolean that resolves to true if the update completed without triggering another update.

Overrides

SignalWatcher(WithDisposable(ShadowlessElement)).getUpdateComplete

Defined in

packages/framework/block-std/src/view/element/block-component.ts:252