Skip to content

Commit

Permalink
feat: allow edit of mentions
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomáš Kubát committed Oct 23, 2024
1 parent 83ddb91 commit 0c554ad
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions plugin/src/BeautifulMentionsPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ export function BeautifulMentionsPlugin(props: BeautifulMentionsPluginProps) {

const handleClose = useCallback(() => {
setTrigger(null);
setSelectedBeautifulMentionNode(null);
}, []);

const handleSelectOption = useCallback(
Expand Down Expand Up @@ -356,7 +357,7 @@ export function BeautifulMentionsPlugin(props: BeautifulMentionsPluginProps) {
_nodeToReplace: TextNode | null,
closeMenu?: () => void,
) => {
if (!trigger) {
if (!selectedBeautifulMentionNode) {
return;
}
handleSelectMenuItem(
Expand All @@ -373,10 +374,6 @@ export function BeautifulMentionsPlugin(props: BeautifulMentionsPluginProps) {
restoreSelection,
],
);
const handleCloseEdit = useCallback(() => {
setTrigger(null);
setSelectedBeautifulMentionNode(null);
}, []);

const checkForMentionMatch = useCallback(
(text: string) => {
Expand Down Expand Up @@ -701,8 +698,6 @@ export function BeautifulMentionsPlugin(props: BeautifulMentionsPluginProps) {
if (selection && $isBeautifulMentionNode(selection[0])) {
setSelectedBeautifulMentionNode(selection[0]);
setTrigger(selection[0].getTrigger());
} else {
setSelectedBeautifulMentionNode(null);
}

return false;
Expand Down Expand Up @@ -874,7 +869,7 @@ export function BeautifulMentionsPlugin(props: BeautifulMentionsPluginProps) {
options={optionsForEditation}
menuRenderFn={menuRenderFn}
onSelectOption={handleSelectMenuItemAsEdit}
onClose={handleCloseEdit}
onClose={handleClose}
nodeKey={selectedBeautifulMentionNode.getKey()}
/>
)}
Expand Down

0 comments on commit 0c554ad

Please sign in to comment.