Add ObjectSelection (#1332)

Add NodeSelection
This commit is contained in:
Dominic Gannaway
2022-02-18 22:40:11 +00:00
committed by acywatson
parent 22a5d8511f
commit d9559c07a4
47 changed files with 791 additions and 360 deletions

View File

@ -16,7 +16,12 @@ import {
TableNode,
TableRowNode,
} from '@lexical/table';
import {$createParagraphNode, $getSelection, $isRootNode} from 'lexical';
import {
$createParagraphNode,
$getSelection,
$isRangeSelection,
$isRootNode,
} from 'lexical';
import {useEffect} from 'react';
import invariant from 'shared/invariant';
@ -38,7 +43,7 @@ export default function TablePlugin(): React$Node {
if (type === 'insertTable') {
const {columns, rows} = payload;
const selection = $getSelection();
if (selection === null) {
if (!$isRangeSelection(selection)) {
return true;
}
const focus = selection.focus;