Skip to main content

Overview

The getElementEntry method retrieves an element along with its Slate path as a tuple [element, path].

Signature

editor.getElementEntry(options: GetElementEntryOptions): [SlateElement, Path] | null

Parameters

options
GetElementEntryOptions
required

Return Value

Returns a tuple [SlateElement, Path] or null if not found.

Examples

// Get entry by type and path
const entry = editor.getElementEntry({
  blockId: 'accordion-1',
  type: 'accordion-list-item',
  path: [0, 1]
});

if (entry) {
  const [element, path] = entry;
  console.log('Element:', element);
  console.log('Path:', path);
}

Use Cases

const entry = editor.getElementEntry({
  blockId: 'table-1',
  type: 'table-data-cell',
  path: [0, 1, 2]
});

if (entry) {
  const [cell, cellPath] = entry;
  const parentPath = cellPath.slice(0, -1);
  // Now you can work with parent row
}

Type Definition

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