mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-01-03 23:42:28 +03:00
Lexical: Added basic URL field header option list
May show bad option label names on chrome/safari. This was an easy first pass without loads of extra custom UI since we're using native datalists.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {$getRoot, $isTextNode, LexicalEditor, LexicalNode} from "lexical";
|
||||
import {$getRoot, $isElementNode, $isTextNode, ElementNode, LexicalEditor, LexicalNode} from "lexical";
|
||||
import {LexicalNodeMatcher} from "../nodes";
|
||||
import {$createCustomParagraphNode} from "../nodes/custom-paragraph";
|
||||
import {$generateNodesFromDOM} from "@lexical/html";
|
||||
@@ -31,6 +31,26 @@ export function $getParentOfType(node: LexicalNode, matcher: LexicalNodeMatcher)
|
||||
return null;
|
||||
}
|
||||
|
||||
export function $getAllNodesOfType(matcher: LexicalNodeMatcher, root?: ElementNode): LexicalNode[] {
|
||||
if (!root) {
|
||||
root = $getRoot();
|
||||
}
|
||||
|
||||
const matches = [];
|
||||
|
||||
for (const child of root.getChildren()) {
|
||||
if (matcher(child)) {
|
||||
matches.push(child);
|
||||
}
|
||||
|
||||
if ($isElementNode(child)) {
|
||||
matches.push(...$getAllNodesOfType(matcher, child));
|
||||
}
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the nearest root/block level node for the given position.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user