fchat-rising/bbcode/UrlTagView.vue

79 lines
2.0 KiB
Vue
Raw Permalink Normal View History

2019-06-08 02:26:01 +00:00
<template>
<span>
2019-06-08 02:26:01 +00:00
<i class="fa fa-link"></i>
2019-07-12 22:11:55 +00:00
<!-- No prevent for @click on purpose -->
2019-06-08 02:26:01 +00:00
<a
:href="url"
rel="nofollow noreferrer noopener"
target="_blank"
class="user-link"
@click="handleClick"
2019-07-12 22:11:55 +00:00
@mouseover.prevent="show()"
@mouseenter.prevent="show()"
@mouseleave.prevent="dismiss()"
2021-03-25 21:54:10 +00:00
@click.middle.prevent.stop="toggleStickyness()"
2019-06-08 02:26:01 +00:00
>{{text}}</a>
<span
class="link-domain bbcode-pseudo"
> [{{domain}}]</span>
</span>
</template>
<script lang="ts">
import {Component, Hook, Prop} from '@f-list/vue-ts';
import Vue from 'vue';
2020-03-15 16:23:39 +00:00
import {EventBus} from '../chat/preview/event-bus';
2019-06-08 02:26:01 +00:00
// import core from './core';
@Component
export default class UrlTagView extends Vue {
@Prop({required: true})
readonly url!: string;
@Prop({required: true})
readonly text!: string;
@Prop({required: true})
readonly domain!: string;
2021-09-07 06:02:31 +00:00
readonly type!: 'UrlTagView';
2019-07-06 16:49:19 +00:00
@Hook('beforeDestroy')
beforeDestroy(): void {
2019-06-08 02:26:01 +00:00
this.dismiss();
}
2021-09-07 06:02:31 +00:00
@Hook('mounted')
mounted(): void {
(this.$el as any).bbcodeTag = 'url';
(this.$el as any).bbcodeParam = this.url;
}
2019-07-06 16:49:19 +00:00
@Hook('deactivated')
deactivate(): void {
2019-06-08 02:26:01 +00:00
this.dismiss();
}
2019-07-12 22:11:55 +00:00
dismiss(force: boolean = false): void {
EventBus.$emit('imagepreview-dismiss', {url: this.url, force});
2019-06-08 02:26:01 +00:00
}
show(): void {
2019-06-08 02:26:01 +00:00
EventBus.$emit('imagepreview-show', {url: this.url});
}
2019-07-04 19:34:21 +00:00
toggleStickyness(): void {
EventBus.$emit('imagepreview-toggle-stickyness', {url: this.url});
}
2019-07-12 22:11:55 +00:00
handleClick(e: MouseEvent): void {
if (e.altKey) {
this.toggleStickyness();
e.preventDefault();
} else {
this.dismiss(true);
}
2019-07-12 22:11:55 +00:00
}
2019-06-08 02:26:01 +00:00
}
</script>