Skip to content

Commit

Permalink
feat(view): always handle custom context menus
Browse files Browse the repository at this point in the history
  • Loading branch information
purocean committed Jan 15, 2024
1 parent bfe62d3 commit 041f427
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions src/renderer/components/DefaultPreviewerRender.ce.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<script lang="ts" setup>
import { debounce } from 'lodash-es'
import { computed, defineComponent, h, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
import { isElectron } from '@fe/support/env'
import { markdown } from '@fe/services/markdown'
import { triggerHook } from '@fe/core/hook'
import { registerAction, removeAction } from '@fe/core/action'
Expand Down Expand Up @@ -132,25 +131,21 @@ function handleClick (e: MouseEvent) {
}
function handleContextMenu (e: MouseEvent) {
const tagName = (e.target as HTMLElement).tagName
const allowTags = ['TD', 'TH']
if (isElectron || e.altKey || allowTags.includes(tagName)) {
const contextMenuItems = getContextMenuItems(e)
if (contextMenuItems.length > 0) {
e.stopPropagation()
e.preventDefault()
const clientX = e.clientX
const clientY = e.clientY
getRenderIframe().then((iframe) => {
const iframeRect = iframe.getBoundingClientRect()
useContextMenu().show(contextMenuItems, {
mouseX: iframeRect.left + clientX,
mouseY: iframeRect.top + clientY,
})
const contextMenuItems = getContextMenuItems(e)
if (contextMenuItems.length > 0) {
e.stopPropagation()
e.preventDefault()
const clientX = e.clientX
const clientY = e.clientY
getRenderIframe().then((iframe) => {
const iframeRect = iframe.getBoundingClientRect()
useContextMenu().show(contextMenuItems, {
mouseX: iframeRect.left + clientX,
mouseY: iframeRect.top + clientY,
})
}
})
}
}
Expand Down

1 comment on commit 041f427

@vercel
Copy link

@vercel vercel bot commented on 041f427 Jan 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.