diff --git a/.changeset/long-poems-relax.md b/.changeset/long-poems-relax.md new file mode 100644 index 0000000000..b45df2624a --- /dev/null +++ b/.changeset/long-poems-relax.md @@ -0,0 +1,5 @@ +--- +'@udecode/plate-comments': major +--- + +Remove `useCommentValue`, which was redundant with the hooks applied automatically in `CommentEditTextarea.tsx`. diff --git a/apps/www/src/registry/default/plate-ui/comment-more-dropdown.tsx b/apps/www/src/registry/default/plate-ui/comment-more-dropdown.tsx index 04725db8a1..0a8ed2e55b 100644 --- a/apps/www/src/registry/default/plate-ui/comment-more-dropdown.tsx +++ b/apps/www/src/registry/default/plate-ui/comment-more-dropdown.tsx @@ -20,9 +20,9 @@ import { export function CommentMoreDropdown() { const editButtonState = useCommentEditButtonState(); - const editProps = useCommentEditButton(editButtonState); + const { props: editProps } = useCommentEditButton(editButtonState); const deleteButtonState = useCommentDeleteButtonState(); - const deleteProps = useCommentDeleteButton(deleteButtonState); + const { props: deleteProps } = useCommentDeleteButton(deleteButtonState); return ( @@ -32,12 +32,8 @@ export function CommentMoreDropdown() { - - Edit comment - - - Delete comment - + Edit comment + Delete comment ); diff --git a/apps/www/src/registry/default/plate-ui/comment-value.tsx b/apps/www/src/registry/default/plate-ui/comment-value.tsx index 3a38d6d3da..314ef81e6b 100644 --- a/apps/www/src/registry/default/plate-ui/comment-value.tsx +++ b/apps/www/src/registry/default/plate-ui/comment-value.tsx @@ -4,7 +4,6 @@ import React from 'react'; import { CommentEditActions, CommentEditTextarea, - useCommentValue, } from '@udecode/plate-comments'; import { cn } from '@/lib/utils'; @@ -12,14 +11,9 @@ import { buttonVariants } from '@/registry/default/plate-ui/button'; import { inputVariants } from '@/registry/default/plate-ui/input'; export function CommentValue() { - const { textareaRef } = useCommentValue(); - return (
- +
{ - const textareaRef = useRef(null); - - useEffect(() => { - const textarea = textareaRef.current!; - textarea.focus(); - - const { length } = textarea.value; - textarea.setSelectionRange(length, length); - }, [textareaRef]); - - return { - textareaRef, - }; -};