File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
packages/web/src/javascripts/Components/SuperEditor/Plugins/CollapsiblePlugin Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import {
2727 KEY_ARROW_LEFT_COMMAND ,
2828 KEY_ARROW_RIGHT_COMMAND ,
2929 KEY_ARROW_UP_COMMAND ,
30+ LexicalNode ,
3031 NodeKey ,
3132} from 'lexical'
3233import { useEffect } from 'react'
@@ -83,11 +84,16 @@ export default function CollapsiblePlugin(): JSX.Element | null {
8384 if ( $isCollapsibleContainerNode ( container ) ) {
8485 const parent = container . getParent ( )
8586 if ( parent !== null && parent . getLastChild ( ) === container ) {
86- const lastDescendant = container . getLastDescendant ( )
87+ const titleParagraph = container . getFirstDescendant < LexicalNode > ( )
88+ const contentParagraph = container . getLastDescendant < LexicalNode > ( )
89+
8790 if (
88- lastDescendant !== null &&
89- selection . anchor . key === lastDescendant . getKey ( ) &&
90- selection . anchor . offset === lastDescendant . getTextContentSize ( )
91+ ( contentParagraph !== null &&
92+ selection . anchor . key === contentParagraph . getKey ( ) &&
93+ selection . anchor . offset === contentParagraph . getTextContentSize ( ) ) ||
94+ ( titleParagraph !== null &&
95+ selection . anchor . key === titleParagraph . getKey ( ) &&
96+ selection . anchor . offset === titleParagraph . getTextContentSize ( ) )
9197 ) {
9298 container . insertAfter ( $createParagraphNode ( ) )
9399 }
You can’t perform that action at this time.
0 commit comments