fix: selecting text in a note causing it to open

Closes transfem-org/Sharkey#175
This commit is contained in:
Mar0xy 2023-11-27 22:06:25 +01:00
parent 51ec675e00
commit 3d0b754332
No known key found for this signature in database
GPG key ID: 56569BBE47D2C828
2 changed files with 9 additions and 3 deletions

View file

@ -226,8 +226,11 @@ const currentClip = inject<Ref<Misskey.entities.Clip> | null>('currentClip', nul
let note = $ref(deepClone(props.note)); let note = $ref(deepClone(props.note));
function noteclick(id: string) { function noteclick(id: string) {
const selection = document.getSelection();
if (selection?.toString().length === 0) {
router.push(`/notes/${id}`); router.push(`/notes/${id}`);
} }
}
// plugin // plugin
if (noteViewInterruptors.length > 0) { if (noteViewInterruptors.length > 0) {

View file

@ -16,7 +16,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkLoading v-if="translating" mini/> <MkLoading v-if="translating" mini/>
<div v-else> <div v-else>
<b>{{ i18n.t('translatedFrom', { x: translation.sourceLang }) }}: </b> <b>{{ i18n.t('translatedFrom', { x: translation.sourceLang }) }}: </b>
<Mfm :text="translation.text" :author="note.user" :nyaize="'account'" :emojiUrls="note.emojis"/> <Mfm :text="translation.text" :author="note.user" :nyaize="'respect'" :emojiUrls="note.emojis"/>
</div> </div>
</div> </div>
<MkA v-if="note.renoteId" :class="$style.rp" :to="`/notes/${note.renoteId}`" v-on:click.stop>RN: ...</MkA> <MkA v-if="note.renoteId" :class="$style.rp" :to="`/notes/${note.renoteId}`" v-on:click.stop>RN: ...</MkA>
@ -63,8 +63,11 @@ const props = defineProps<{
const router = useRouter(); const router = useRouter();
function noteclick(id: string) { function noteclick(id: string) {
const selection = document.getSelection();
if (selection?.toString().length === 0) {
router.push(`/notes/${id}`); router.push(`/notes/${id}`);
} }
}
const parsed = $computed(() => props.note.text ? mfm.parse(props.note.text) : null); const parsed = $computed(() => props.note.text ? mfm.parse(props.note.text) : null);
const animated = $computed(() => parsed ? checkAnimationFromMfm(parsed) : null); const animated = $computed(() => parsed ? checkAnimationFromMfm(parsed) : null);