| ... | @@ -558,29 +558,6 @@ function ComposerMentionSelectionNormalizePlugin() { | ... | @@ -558,29 +558,6 @@ function ComposerMentionSelectionNormalizePlugin() { |
| 558 | return null; | 558 | return null; |
| 559 | } | 559 | } |
| 560 | | 560 | |
| 561 | function $isCursorAdjacentToMention(): boolean { | | |
| 562 | const selection = $getSelection(); | | |
| 563 | if (!$isRangeSelection(selection) || !selection.isCollapsed()) return false; | | |
| 564 | const anchorNode = selection.anchor.getNode(); | | |
| 565 | | | |
| 566 | if (anchorNode instanceof ComposerMentionNode) return true; | | |
| 567 | | | |
| 568 | if ($isElementNode(anchorNode)) { | | |
| 569 | const childIndex = selection.anchor.offset - 1; | | |
| 570 | if (childIndex >= 0) { | | |
| 571 | const child = anchorNode.getChildAtIndex(childIndex); | | |
| 572 | if (child instanceof ComposerMentionNode) return true; | | |
| 573 | } | | |
| 574 | } | | |
| 575 | | | |
| 576 | if ($isTextNode(anchorNode) && selection.anchor.offset === 0) { | | |
| 577 | const prev = anchorNode.getPreviousSibling(); | | |
| 578 | if (prev instanceof ComposerMentionNode) return true; | | |
| 579 | } | | |
| 580 | | | |
| 581 | return false; | | |
| 582 | } | | |
| 583 | | | |
| 584 | function ComposerMentionBackspacePlugin() { | 561 | function ComposerMentionBackspacePlugin() { |
| 585 | const [editor] = useLexicalComposerContext(); | 562 | const [editor] = useLexicalComposerContext(); |
| 586 | | 563 | |
| ... | @@ -756,7 +733,10 @@ function ComposerPromptEditorInner({ | ... | @@ -756,7 +733,10 @@ function ComposerPromptEditorInner({ |
| 756 | value: nextValue, | 733 | value: nextValue, |
| 757 | cursor: nextCursor, | 734 | cursor: nextCursor, |
| 758 | }; | 735 | }; |
| 759 | onChangeRef.current(nextValue, nextCursor, $isCursorAdjacentToMention()); | 736 | const cursorAdjacentToMention = |
| | 737 | isCollapsedCursorAdjacentToMention(nextValue, nextCursor, "left") || |
| | 738 | isCollapsedCursorAdjacentToMention(nextValue, nextCursor, "right"); |
| | 739 | onChangeRef.current(nextValue, nextCursor, cursorAdjacentToMention); |
| 760 | }); | 740 | }); |
| 761 | }, []); | 741 | }, []); |
| 762 | | 742 | |