2019-06-08 02:26:01 +00:00
|
|
|
<template>
|
2019-06-09 23:33:52 +00:00
|
|
|
<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"
|
2021-12-06 14:08:17 +00:00
|
|
|
@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')
|
2019-06-09 23:33:52 +00:00
|
|
|
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')
|
2019-06-09 23:33:52 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-06-09 23:33:52 +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
|
|
|
|
2021-12-06 14:08:17 +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>
|