diff --git a/packages/editor/src/core/extensions/callout/block.tsx b/packages/editor/src/core/extensions/callout/block.tsx index 7f4a8503de0..75b29c87057 100644 --- a/packages/editor/src/core/extensions/callout/block.tsx +++ b/packages/editor/src/core/extensions/callout/block.tsx @@ -1,5 +1,6 @@ import { NodeViewContent, NodeViewProps, NodeViewWrapper } from "@tiptap/react"; -import React, { useState } from "react"; +import React, { useState, useMemo } from "react"; +import { v4 as uuidv4 } from "uuid"; // constants import { COLORS_LIST } from "@/constants/common"; // local components @@ -22,11 +23,14 @@ export const CustomCalloutBlock: React.FC = (props) // states const [isEmojiPickerOpen, setIsEmojiPickerOpen] = useState(false); const [isColorPickerOpen, setIsColorPickerOpen] = useState(false); + // unique id + const uniqueId = useMemo(() => uuidv4(), []); // derived values const activeBackgroundColor = COLORS_LIST.find((c) => node.attrs["data-background"] === c.key)?.backgroundColor; return ( = ({ node }) => { const [copied, setCopied] = useState(false); + const uniqueId = useMemo(() => uuidv4(), []); + const copyToClipboard = async (e: React.MouseEvent) => { try { await navigator.clipboard.writeText(node.textContent); @@ -35,7 +38,7 @@ export const CodeBlockComponent: React.FC = ({ node }) => { }; return ( - +