Your IP : 216.73.216.86


Current Path : /var/www/homesaver/www/bitrix/js/ui/text-editor/src/helpers/
Upload File :
Current File : /var/www/homesaver/www/bitrix/js/ui/text-editor/src/helpers/get-node-in-selection.js

import { $getSelection, $isNodeSelection, type LexicalNode } from 'ui.lexical.core';

export function getNodeInSelection(predicate: (node: LexicalNode) => boolean): LexicalNode | null
{
	const selection = $getSelection();
	if (!$isNodeSelection(selection))
	{
		return null;
	}

	const nodes = selection.getNodes();
	const node = nodes[0];

	return predicate(node) ? node : null;
}