Skip to main content

@lexical/html/BlockIdHTMLExtension

Interfaces​

BlockIdHTMLConfig​

Defined in: packages/lexical-html/src/BlockIdHTMLExtension.ts:54

Experimental

Properties​

export​

export: boolean

Defined in: packages/lexical-html/src/BlockIdHTMLExtension.ts:59

Experimental

Write BLOCK_ID_ATTRIBUTE on the exported element of every identified block ($generateHtmlFromNodes, copy as HTML, …).

import​

import: boolean

Defined in: packages/lexical-html/src/BlockIdHTMLExtension.ts:69

Experimental

Read BLOCK_ID_ATTRIBUTE back when HTML is imported through DOMImportExtension, onto the block that the element produced. Imported ids are never trusted: an invalid one is ignored, and a valid one goes through the uniqueness rule of BlockIdExtension, so pasting HTML that carries ids already in the document gives the pasted blocks fresh ids. An imported id is dropped from a block that is not identified once it is inserted (a table cell, a nested list).

Variables​

BLOCK_ID_ATTRIBUTE​

const BLOCK_ID_ATTRIBUTE: "data-block-id" = 'data-block-id'

Defined in: packages/lexical-html/src/BlockIdHTMLExtension.ts:51

Experimental

The attribute that carries a block id in HTML.


BlockIdHTMLExtension​

const BlockIdHTMLExtension: LexicalExtension<BlockIdHTMLConfig, "@lexical/html/BlockIdHTML", NamedSignalsOutput<BlockIdHTMLConfig>, unknown>

Defined in: packages/lexical-html/src/BlockIdHTMLExtension.ts:127

Experimental

Opt-in HTML support for BlockIdExtension: exported HTML carries each identified block's id in a data-block-id attribute, and HTML imported through DOMImportExtension reads it back (through the uniqueness rule, so ids in pasted HTML never clash with ids in the document).

This lives in @lexical/html rather than in BlockIdExtension because @lexical/html depends on @lexical/extension. The legacy $generateNodesFromDOM path (importDOM) does not read the attribute.