1
0
forked from mirror/misskey

prevent calling contextmenu in embed page by stopping at the caller

This commit is contained in:
kakkokari-gtyih 2024-08-20 16:10:37 +09:00
parent 1fff58455c
commit e269dcb4a7
3 changed files with 6 additions and 4 deletions

View File

@ -522,7 +522,7 @@ function toggleReact() {
} }
function onContextmenu(ev: MouseEvent): void { function onContextmenu(ev: MouseEvent): void {
if (props.mock) { if (props.mock || inEmbedPage) {
return; return;
} }

View File

@ -32,6 +32,8 @@ const props = withDefaults(defineProps<{
const behavior = props.behavior ?? inject<MkABehavior>('linkNavigationBehavior', null); const behavior = props.behavior ?? inject<MkABehavior>('linkNavigationBehavior', null);
const inEmbedPage = inject<boolean>('EMBED_PAGE', false);
const el = shallowRef<HTMLElement>(); const el = shallowRef<HTMLElement>();
defineExpose({ $el: el }); defineExpose({ $el: el });
@ -49,6 +51,8 @@ const active = computed(() => {
}); });
function onContextmenu(ev) { function onContextmenu(ev) {
if (inEmbedPage) return;
const selection = window.getSelection(); const selection = window.getSelection();
if (selection && selection.toString() !== '') return; if (selection && selection.toString() !== '') return;
os.contextMenu([{ os.contextMenu([{

View File

@ -26,7 +26,6 @@ import { MenuItem } from '@/types/menu.js';
import { copyToClipboard } from '@/scripts/copy-to-clipboard.js'; import { copyToClipboard } from '@/scripts/copy-to-clipboard.js';
import { pleaseLogin } from '@/scripts/please-login.js'; import { pleaseLogin } from '@/scripts/please-login.js';
import { showMovedDialog } from '@/scripts/show-moved-dialog.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 { getHTMLElementOrNull } from '@/scripts/get-dom-node-or-null.js';
import { focusParent } from '@/scripts/focus.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<void> { export function contextMenu(items: MenuItem[], ev: MouseEvent): Promise<void> {
if ( if (
defaultStore.state.contextMenu === 'native' || defaultStore.state.contextMenu === 'native' ||
(defaultStore.state.contextMenu === 'appWithShift' && !ev.shiftKey) || (defaultStore.state.contextMenu === 'appWithShift' && !ev.shiftKey)
embedPage
) { ) {
return Promise.resolve(); return Promise.resolve();
} }