import * as _ContextMenu from '@radix-ui/react-context-menu' import { PageRecordType, TLPageId, track, useContainer, useEditor } from '@tldraw/editor' import { useToasts } from '../hooks/useToastsProvider' import { useTranslation } from '../hooks/useTranslation/useTranslation' import { Button } from './primitives/Button' export const MoveToPageMenu = track(function MoveToPageMenu() { const editor = useEditor() const container = useContainer() const pages = editor.getPages() const currentPageId = editor.getCurrentPageId() const msg = useTranslation() const { addToast } = useToasts() return ( <_ContextMenu.Sub> <_ContextMenu.SubTrigger dir="ltr" asChild> ))} <_ContextMenu.Group dir="ltr" className={'tlui-menu__group'} data-testid={`menu-item.new-page`} key="new-page" > <_ContextMenu.Item key="new-page" onSelect={() => { const newPageId = PageRecordType.createId() const ids = editor.getSelectedShapeIds() editor.batch(() => { editor.mark('move_shapes_to_page') editor.createPage({ name: 'Page', id: newPageId }) editor.moveShapesToPage(ids, newPageId) }) }} asChild > ) })