Skip to main content

Overview

The getParentElementPath method retrieves the Slate path of an element’s parent.

Signature

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

Parameters

options
GetElementPathOptions
required

Return Value

Returns the parent Path or null if not found.

Examples

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

if (content) {
  const parentPath = editor.getParentElementPath({
    blockId: 'accordion-1',
    element: content
  });
  
  // parentPath will be [0, 1] (the accordion-list-item)
}

Type Definition

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