Skip to main content

Overview

The getElementChildren method retrieves the children array of an element.

Signature

editor.getElementChildren(options: GetElementChildrenOptions): SlateElement['children'] | null

Parameters

options
GetElementChildrenOptions
required

Return Value

Returns the children array or null if element not found.

Examples

// Get children of accordion item
const children = editor.getElementChildren({
  blockId: 'accordion-1',
  type: 'accordion-list-item',
  path: [0, 1]
});

if (children) {
  console.log(`Element has ${children.length} children`);
}

Type Definition

type GetElementChildrenOptions = {
  blockId: string;
  type: string;
  path?: number[];
};