chore: fix arrow down when a collapsed collapsible is the last node
This commit is contained in:
@@ -27,6 +27,7 @@ import {
|
|||||||
KEY_ARROW_LEFT_COMMAND,
|
KEY_ARROW_LEFT_COMMAND,
|
||||||
KEY_ARROW_RIGHT_COMMAND,
|
KEY_ARROW_RIGHT_COMMAND,
|
||||||
KEY_ARROW_UP_COMMAND,
|
KEY_ARROW_UP_COMMAND,
|
||||||
|
LexicalNode,
|
||||||
NodeKey,
|
NodeKey,
|
||||||
} from 'lexical'
|
} from 'lexical'
|
||||||
import { useEffect } from 'react'
|
import { useEffect } from 'react'
|
||||||
@@ -83,11 +84,16 @@ export default function CollapsiblePlugin(): JSX.Element | null {
|
|||||||
if ($isCollapsibleContainerNode(container)) {
|
if ($isCollapsibleContainerNode(container)) {
|
||||||
const parent = container.getParent()
|
const parent = container.getParent()
|
||||||
if (parent !== null && parent.getLastChild() === container) {
|
if (parent !== null && parent.getLastChild() === container) {
|
||||||
const lastDescendant = container.getLastDescendant()
|
const titleParagraph = container.getFirstDescendant<LexicalNode>()
|
||||||
|
const contentParagraph = container.getLastDescendant<LexicalNode>()
|
||||||
|
|
||||||
if (
|
if (
|
||||||
lastDescendant !== null &&
|
(contentParagraph !== null &&
|
||||||
selection.anchor.key === lastDescendant.getKey() &&
|
selection.anchor.key === contentParagraph.getKey() &&
|
||||||
selection.anchor.offset === lastDescendant.getTextContentSize()
|
selection.anchor.offset === contentParagraph.getTextContentSize()) ||
|
||||||
|
(titleParagraph !== null &&
|
||||||
|
selection.anchor.key === titleParagraph.getKey() &&
|
||||||
|
selection.anchor.offset === titleParagraph.getTextContentSize())
|
||||||
) {
|
) {
|
||||||
container.insertAfter($createParagraphNode())
|
container.insertAfter($createParagraphNode())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user