A basic $dfs (#1351)

This commit is contained in:
Gerard Rovira
2022-02-23 18:34:52 +00:00
committed by acywatson
parent e72688de8e
commit a6867f18bc
3 changed files with 65 additions and 55 deletions

View File

@ -9,11 +9,10 @@
import type {LexicalEditor, LexicalNode} from 'lexical';
import {$dfs__DEPRECATED} from '@lexical/helpers/nodes';
import {$dfs} from '@lexical/helpers/nodes';
import {$textContentCurry} from '@lexical/helpers/root';
import withSubscriptions from '@lexical/react/withSubscriptions';
import {
$getRoot,
$getSelection,
$isLeafNode,
$isRangeSelection,
@ -127,15 +126,10 @@ function findOffset(
}
function $wrapOverflowedNodes(offset: number): void {
const root = $getRoot();
const dfsNodes = $dfs();
const dfsNodesLength = dfsNodes.length;
let accumulatedLength = 0;
const dfsNodes = [];
$dfs__DEPRECATED(root, (node: LexicalNode) => {
dfsNodes.push(node);
return node;
});
for (let i = 0; i < dfsNodes.length; i += 1) {
for (let i = 0; i < dfsNodesLength; i += 1) {
const node = dfsNodes[i];
if ($isOverflowNode(node)) {
const previousLength = accumulatedLength;