Skip to content

Commit

Permalink
reinstate the context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
bkrmendy committed Jul 15, 2024
1 parent 2b63c8d commit 2daecfa
Show file tree
Hide file tree
Showing 2 changed files with 381 additions and 8 deletions.
19 changes: 16 additions & 3 deletions editor/src/components/editor/editor-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
/** @jsxFrag React.Fragment */
import { css, jsx, keyframes } from '@emotion/react'
import { chrome as isChrome } from 'platform-detect'
import React from 'react'
import React, { useEffect } from 'react'
import ReactDOM from 'react-dom'
import { DndProvider } from 'react-dnd'
import { HTML5Backend } from 'react-dnd-html5-backend'
import { IS_TEST_ENVIRONMENT } from '../../common/env-vars'
import { assertNever, projectURLForProject } from '../../core/shared/utils'
import {
CanvasContextMenuPortalTargetID,
assertNever,
projectURLForProject,
} from '../../core/shared/utils'
import Keyboard from '../../utils/keyboard'
import { Modifier } from '../../utils/modifiers'
import {
Expand Down Expand Up @@ -81,7 +86,10 @@ import {
useUpdateActiveRemixSceneOnSelectionChange,
} from '../canvas/remix/utopia-remix-root-component'
import { useDefaultCollapsedViews } from './use-default-collapsed-views'
import { useCreateCallbackToShowComponentPicker } from '../navigator/navigator-item/component-picker-context-menu'
import {
ComponentPickerContextMenu,
useCreateCallbackToShowComponentPicker,
} from '../navigator/navigator-item/component-picker-context-menu'
import { useGithubPolling } from '../../core/shared/github/helpers'
import { useAtom } from 'jotai'
import { clearOpenMenuIds } from '../../core/shared/menu-state'
Expand Down Expand Up @@ -453,6 +461,8 @@ export const EditorComponentInner = React.memo((props: EditorProps) => {

useClearSelectionOnNavigation()

const portalTarget = document.getElementById(CanvasContextMenuPortalTargetID)

return (
<>
<ColorThemeComponent />
Expand Down Expand Up @@ -549,6 +559,9 @@ export const EditorComponentInner = React.memo((props: EditorProps) => {
<LockedOverlay />
<SharingDialog />
</SimpleFlexRow>
{portalTarget != null
? ReactDOM.createPortal(<ComponentPickerContextMenu />, portalTarget)
: null}
<EditorCommon
mouseDown={onWindowMouseDown}
mouseUp={onWindowMouseUp}
Expand Down
Loading

0 comments on commit 2daecfa

Please sign in to comment.