mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-01-03 23:42:28 +03:00
Lexical: Added RTL/LTR actions
Kinda useless though due to Lexical reconciler :(
This commit is contained in:
@@ -2,7 +2,7 @@ import {
|
||||
$createNodeSelection,
|
||||
$createParagraphNode, $createRangeSelection,
|
||||
$getRoot,
|
||||
$getSelection, $isDecoratorNode,
|
||||
$getSelection, $isBlockElementNode, $isDecoratorNode,
|
||||
$isElementNode,
|
||||
$isTextNode,
|
||||
$setSelection,
|
||||
@@ -199,6 +199,22 @@ export function $selectionContainsAlignment(selection: BaseSelection | null, ali
|
||||
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 [];
|
||||
|
||||
Reference in New Issue
Block a user