From f8b6ee6ab99808e0f28ca55f43be330fa7663e67 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 26 May 2023 09:24:21 +0100 Subject: [PATCH] remove safari special-casing for paste (#1470) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, we had a bunch of special-casing around paste to support safari quirks on desktop and ios. Since upgrading radix-ui and useGesture, these are no longer needed and were actually causing issues. This diff removes the special casing for paste and makes it a normal action that get triggered the same way as any other. ### Change Type - [x] `patch` — Bug Fix ### Test Plan 1. Copy text outside of tldraw, paste in tldraw with the context menu, edit menu, and keyboard shortcut 2. Repeat for images outside of tldraw 3. Repeat for shapes inside of tldraw ### Release Notes [fixes a regression introduced during this release] --- packages/ui/api-report.md | 8 ++-- .../ui/src/lib/components/ContextMenu.tsx | 38 ------------------- packages/ui/src/lib/components/Menu.tsx | 33 +--------------- packages/ui/src/lib/hooks/useActions.tsx | 25 ++++++------ .../ui/src/lib/hooks/useClipboardEvents.ts | 18 +++++---- .../ui/src/lib/hooks/useContextMenuSchema.tsx | 2 +- packages/ui/src/lib/hooks/useMenuSchema.tsx | 7 +--- 7 files changed, 30 insertions(+), 101 deletions(-) diff --git a/packages/ui/api-report.md b/packages/ui/api-report.md index d0128c588..2f7efd0a5 100644 --- a/packages/ui/api-report.md +++ b/packages/ui/api-report.md @@ -1025,10 +1025,10 @@ export function useLanguages(): { export function useLocalStorageState(key: string, defaultValue: T): readonly [T, (setter: ((value: T) => T) | T) => void]; // @public (undocumented) -export function useMenuClipboardEvents(source: TLUiEventSource): { - copy: () => void; - cut: () => void; - paste: (data: ClipboardItem[] | DataTransfer, point?: VecLike) => Promise; +export function useMenuClipboardEvents(): { + copy: (source: TLUiEventSource) => void; + cut: (source: TLUiEventSource) => void; + paste: (data: ClipboardItem[] | DataTransfer, source: TLUiEventSource, point?: VecLike) => Promise; }; // @public (undocumented) diff --git a/packages/ui/src/lib/components/ContextMenu.tsx b/packages/ui/src/lib/components/ContextMenu.tsx index 0b2dd0722..a106198b3 100644 --- a/packages/ui/src/lib/components/ContextMenu.tsx +++ b/packages/ui/src/lib/components/ContextMenu.tsx @@ -5,7 +5,6 @@ import * as React from 'react' import { useValue } from 'signia-react' import { MenuChild } from '../hooks/menuHelpers' import { useBreakpoint } from '../hooks/useBreakpoint' -import { useMenuClipboardEvents } from '../hooks/useClipboardEvents' import { useContextMenuSchema } from '../hooks/useContextMenuSchema' import { useMenuIsOpen } from '../hooks/useMenuIsOpen' import { useReadonly } from '../hooks/useReadonly' @@ -61,7 +60,6 @@ function ContextMenuContent() { const [_, handleSubOpenChange] = useMenuIsOpen('context menu sub') const isReadonly = useReadonly() - const { paste } = useMenuClipboardEvents('context-menu') const breakpoint = useBreakpoint() const container = useContainer() @@ -73,42 +71,6 @@ function ContextMenuContent() { switch (item.type) { case 'custom': { switch (item.id) { - case 'MENU_PASTE': { - return ( - <_ContextMenu.Item key={item.id}> -