From 871d2bad17e5060c3d970b3dab3cb5434abccee6 Mon Sep 17 00:00:00 2001 From: syuilo <syuilotan@yahoo.co.jp> Date: Sun, 7 Feb 2021 00:11:16 +0900 Subject: [PATCH] Improve contextmenu handling --- src/client/components/global/url.vue | 1 + src/client/ui/deck/main-column.vue | 7 +++++++ src/client/ui/default.vue | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/src/client/components/global/url.vue b/src/client/components/global/url.vue index c7e93094f5..2650cd33fd 100644 --- a/src/client/components/global/url.vue +++ b/src/client/components/global/url.vue @@ -2,6 +2,7 @@ <component :is="self ? 'MkA' : 'a'" class="ieqqeuvs _link" :[attr]="self ? url.substr(local.length) : url" :rel="rel" :target="target" @mouseover="onMouseover" @mouseleave="onMouseleave" + @contextmenu.stop="() => {}" > <template v-if="!self"> <span class="schema">{{ schema }}//</span> diff --git a/src/client/ui/deck/main-column.vue b/src/client/ui/deck/main-column.vue index f0d5567b6e..6d798c130c 100644 --- a/src/client/ui/deck/main-column.vue +++ b/src/client/ui/deck/main-column.vue @@ -57,6 +57,13 @@ export default defineComponent({ }, onContextmenu(e) { + const isLink = (el: HTMLElement) => { + if (el.tagName === 'A') return true; + if (el.parentElement) { + return isLink(el.parentElement); + } + }; + if (isLink(e.target)) return; if (['INPUT', 'TEXTAREA'].includes(e.target.tagName) || e.target.attributes['contenteditable']) return; if (window.getSelection().toString() !== '') return; const path = this.$route.path; diff --git a/src/client/ui/default.vue b/src/client/ui/default.vue index 7626ddaa58..220dee9d6d 100644 --- a/src/client/ui/default.vue +++ b/src/client/ui/default.vue @@ -187,6 +187,13 @@ export default defineComponent({ }, onContextmenu(e) { + const isLink = (el: HTMLElement) => { + if (el.tagName === 'A') return true; + if (el.parentElement) { + return isLink(el.parentElement); + } + }; + if (isLink(e.target)) return; if (['INPUT', 'TEXTAREA'].includes(e.target.tagName) || e.target.attributes['contenteditable']) return; if (window.getSelection().toString() !== '') return; const path = this.$route.path;