1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-12-23 23:02:08 +03:00

Lexical: Added RTL/LTR actions

Kinda useless though due to Lexical reconciler :(
This commit is contained in:
Dan Brown
2024-09-16 12:29:46 +01:00
parent 5f46d71af0
commit 03490d6597
5 changed files with 70 additions and 9 deletions

View File

@@ -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 [];