$createNodeSelection,
$createParagraphNode, $createRangeSelection,
$getRoot,
- $getSelection, $isDecoratorNode,
+ $getSelection, $isBlockElementNode, $isDecoratorNode,
$isElementNode,
$isTextNode,
$setSelection,
return false;
}
+export function $selectionContainsDirection(selection: BaseSelection | null, direction: 'rtl'|'ltr'): boolean {
+
+ const nodes = [
+ ...(selection?.getNodes() || []),
+ ...$getBlockElementNodesInSelection(selection)
+ ];
+
+ for (const node of nodes) {
+ if ($isBlockElementNode(node) && node.getDirection() === direction) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
export function $getBlockElementNodesInSelection(selection: BaseSelection | null): ElementNode[] {
if (!selection) {
return [];