From e269dcb4a71c83b9f4aa89a771497a77bfd20780 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Tue, 20 Aug 2024 16:10:37 +0900 Subject: [PATCH] prevent calling contextmenu in embed page by stopping at the caller --- packages/frontend/src/components/MkNote.vue | 2 +- packages/frontend/src/components/global/MkA.vue | 4 ++++ packages/frontend/src/os.ts | 4 +--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/frontend/src/components/MkNote.vue b/packages/frontend/src/components/MkNote.vue index 17ca33e94c..84d7a7a10d 100644 --- a/packages/frontend/src/components/MkNote.vue +++ b/packages/frontend/src/components/MkNote.vue @@ -522,7 +522,7 @@ function toggleReact() { } function onContextmenu(ev: MouseEvent): void { - if (props.mock) { + if (props.mock || inEmbedPage) { return; } diff --git a/packages/frontend/src/components/global/MkA.vue b/packages/frontend/src/components/global/MkA.vue index 3a45ca429f..07066ae056 100644 --- a/packages/frontend/src/components/global/MkA.vue +++ b/packages/frontend/src/components/global/MkA.vue @@ -32,6 +32,8 @@ const props = withDefaults(defineProps<{ const behavior = props.behavior ?? inject('linkNavigationBehavior', null); +const inEmbedPage = inject('EMBED_PAGE', false); + const el = shallowRef(); defineExpose({ $el: el }); @@ -49,6 +51,8 @@ const active = computed(() => { }); function onContextmenu(ev) { + if (inEmbedPage) return; + const selection = window.getSelection(); if (selection && selection.toString() !== '') return; os.contextMenu([{ diff --git a/packages/frontend/src/os.ts b/packages/frontend/src/os.ts index 9e9514541e..f42e2ed3c5 100644 --- a/packages/frontend/src/os.ts +++ b/packages/frontend/src/os.ts @@ -26,7 +26,6 @@ import { MenuItem } from '@/types/menu.js'; import { copyToClipboard } from '@/scripts/copy-to-clipboard.js'; import { pleaseLogin } from '@/scripts/please-login.js'; import { showMovedDialog } from '@/scripts/show-moved-dialog.js'; -import { embedPage } from '@/config.js'; import { getHTMLElementOrNull } from '@/scripts/get-dom-node-or-null.js'; import { focusParent } from '@/scripts/focus.js'; @@ -658,8 +657,7 @@ export function popupMenu(items: MenuItem[], src?: HTMLElement | EventTarget | n export function contextMenu(items: MenuItem[], ev: MouseEvent): Promise { if ( defaultStore.state.contextMenu === 'native' || - (defaultStore.state.contextMenu === 'appWithShift' && !ev.shiftKey) || - embedPage + (defaultStore.state.contextMenu === 'appWithShift' && !ev.shiftKey) ) { return Promise.resolve(); }