Skip to main content

Overview

The getElementPath method retrieves the Slate path of a specific element instance.

Signature

editor.getElementPath(options: GetElementPathOptions): Path | null

Parameters

options
GetElementPathOptions
required

Return Value

Returns the Path (number array) or null if not found.

Examples

// Get path of element instance
const item = editor.getElement({
  blockId: 'accordion-1',
  type: 'accordion-list-item',
  path: 'first'
});

if (item) {
  const path = editor.getElementPath({
    blockId: 'accordion-1',
    element: item
  });
  
  console.log('Element path:', path);
}

Type Definition

type GetElementPathOptions = {
  blockId: string;
  element: SlateElement;
};

type Path = number[];