Add UI components to Lexical Playground (#1211)

* Add UI components to Lexical Playground

* Add autofocus plugin

* Fix test
This commit is contained in:
Dominic Gannaway
2022-02-02 14:21:56 +00:00
committed by acywatson
parent 1b6e5d254e
commit fa107c93fb
10 changed files with 369 additions and 5 deletions

View File

@ -26,8 +26,9 @@ export default function TablePlugin(): React$Node {
useEffect(() => {
const removeCommandListener = editor.addListener(
'command',
(type) => {
(type, payload) => {
if (type === 'insertTable') {
const {columns, rows} = payload;
$log('handleAddTable');
const selection = $getSelection();
if (selection === null) {
@ -37,7 +38,7 @@ export default function TablePlugin(): React$Node {
if (focusNode !== null) {
const topLevelNode = focusNode.getTopLevelElementOrThrow();
const tableNode = $createTableNodeWithDimensions(3, 3);
const tableNode = $createTableNodeWithDimensions(rows, columns);
topLevelNode.insertAfter(tableNode);
tableNode.insertAfter($createParagraphNode());
const firstCell = tableNode