chore: add newlines before/after table if required
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { INSERT_TABLE_COMMAND, TableNode, TableRowNode } from '@lexical/table'
|
import { INSERT_TABLE_COMMAND, TableNode, TableRowNode } from '@lexical/table'
|
||||||
import { LexicalEditor } from 'lexical'
|
import { $createParagraphNode, LexicalEditor } from 'lexical'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import Button from '../Lexical/UI/Button'
|
import Button from '../Lexical/UI/Button'
|
||||||
import { DialogActions } from '../Lexical/UI/Dialog'
|
import { DialogActions } from '../Lexical/UI/Dialog'
|
||||||
@@ -62,6 +62,13 @@ export function RemoveBrokenTablesPlugin() {
|
|||||||
if (!node.getFirstChild()) {
|
if (!node.getFirstChild()) {
|
||||||
node.remove()
|
node.remove()
|
||||||
}
|
}
|
||||||
|
const hasNextSibling = !!node.getNextSibling()
|
||||||
|
const hasPreviousSibling = !!node.getPreviousSibling()
|
||||||
|
if (!hasNextSibling) {
|
||||||
|
node.insertAfter($createParagraphNode())
|
||||||
|
} else if (!hasPreviousSibling) {
|
||||||
|
node.insertBefore($createParagraphNode())
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}, [editor])
|
}, [editor])
|
||||||
|
|||||||
Reference in New Issue
Block a user