diff --git a/app/globals.css b/app/globals.css index 15af66c..b184e4a 100644 --- a/app/globals.css +++ b/app/globals.css @@ -142,5 +142,5 @@ } .suggestion-highlight { - @apply bg-yellow-100 hover:bg-yellow-200 dark:hover:bg-yellow-400/50 dark:text-yellow-50 dark:bg-yellow-400/40; + @apply bg-blue-100 hover:bg-blue-200 dark:hover:bg-blue-400/50 dark:text-blue-50 dark:bg-blue-400/40; } diff --git a/components/custom/canvas.tsx b/components/custom/canvas.tsx index 32d45d6..10e94d3 100644 --- a/components/custom/canvas.tsx +++ b/components/custom/canvas.tsx @@ -9,8 +9,13 @@ import { useEffect, useState, } from 'react'; +import { toast } from 'sonner'; import useSWR, { useSWRConfig } from 'swr'; -import { useDebounceCallback, useWindowSize } from 'usehooks-ts'; +import { + useCopyToClipboard, + useDebounceCallback, + useWindowSize, +} from 'usehooks-ts'; import { Document, Suggestion } from '@/db/schema'; import { fetcher } from '@/lib/utils'; @@ -18,13 +23,14 @@ import { fetcher } from '@/lib/utils'; import { DiffView } from './diffview'; import { DocumentSkeleton } from './document-skeleton'; import { Editor } from './editor'; -import { CrossIcon, DeltaIcon, RedoIcon, UndoIcon } from './icons'; +import { CopyIcon, CrossIcon, DeltaIcon, RedoIcon, UndoIcon } from './icons'; import { Markdown } from './markdown'; import { Message as PreviewMessage } from './message'; import { MultimodalInput } from './multimodal-input'; import { Toolbar } from './toolbar'; import { useScrollToBottom } from './use-scroll-to-bottom'; import { VersionFooter } from './version-footer'; +import { Tooltip, TooltipContent, TooltipTrigger } from '../ui/tooltip'; export interface UICanvas { title: string; documentId: string; @@ -233,6 +239,8 @@ export function Canvas({ const { width: windowWidth, height: windowHeight } = useWindowSize(); const isMobile = windowWidth ? windowWidth < 768 : false; + const [_, copyToClipboard] = useCopyToClipboard(); + return ( {!isCurrentVersion && ( @@ -349,7 +362,7 @@ export function Canvas({ } : { opacity: 1, - x: 400, + x: 0, y: 0, height: windowHeight, width: windowWidth ? windowWidth - 400 : 'calc(100dvw-400px)', @@ -411,33 +424,62 @@ export function Canvas({
-
{ - handleVersionChange('prev'); - }} - > - -
-
{ - handleVersionChange('next'); - }} - > - -
-
{ - handleVersionChange('toggle'); - }} - > - -
+ + +
{ + copyToClipboard(canvas.content); + toast.success('Copied to clipboard!'); + }} + > + +
+
+ Copy to clipboard +
+ + +
{ + handleVersionChange('prev'); + }} + > + +
+
+ View Previous version +
+ + +
{ + handleVersionChange('next'); + }} + > + +
+
+ View Next version +
+ + +
{ + handleVersionChange('toggle'); + }} + > + +
+
+ View changes +
@@ -468,6 +510,19 @@ export function Canvas({ {suggestions ? (
) : null} + + + {isCurrentVersion && ( + + )} +
@@ -482,19 +537,6 @@ export function Canvas({ )}
- - - {isCurrentVersion && ( - - )} - ); } diff --git a/components/custom/icons.tsx b/components/custom/icons.tsx index 3d0626a..3dee5a8 100644 --- a/components/custom/icons.tsx +++ b/components/custom/icons.tsx @@ -745,3 +745,20 @@ export const PlusIcon = ({ size = 16 }: { size?: number }) => ( > ); + +export const CopyIcon = ({ size = 16 }: { size?: number }) => ( + + + +); diff --git a/components/custom/toolbar.tsx b/components/custom/toolbar.tsx index 12013b8..cc517af 100644 --- a/components/custom/toolbar.tsx +++ b/components/custom/toolbar.tsx @@ -346,7 +346,7 @@ export const Toolbar = ({ return (