2020-02-09 20:48:45 +02:00
|
|
|
<template>
|
2022-01-16 01:38:55 +02:00
|
|
|
<component :is="self ? 'MkA' : 'a'" ref="el" class="xlcxczvw _link" :[attr]="self ? url.substr(local.length) : url" :rel="rel" :target="target"
|
2021-11-19 12:36:12 +02:00
|
|
|
:title="url"
|
2020-02-09 20:48:45 +02:00
|
|
|
>
|
|
|
|
<slot></slot>
|
2021-04-20 17:22:59 +03:00
|
|
|
<i v-if="target === '_blank'" class="fas fa-external-link-square-alt icon"></i>
|
2020-02-09 20:48:45 +02:00
|
|
|
</component>
|
|
|
|
</template>
|
|
|
|
|
2022-01-16 01:38:55 +02:00
|
|
|
<script lang="ts" setup>
|
2022-05-01 16:51:07 +03:00
|
|
|
import { defineAsyncComponent } from 'vue';
|
2021-11-11 19:02:25 +02:00
|
|
|
import { url as local } from '@/config';
|
2022-01-16 01:38:55 +02:00
|
|
|
import { useTooltip } from '@/scripts/use-tooltip';
|
2021-11-11 19:02:25 +02:00
|
|
|
import * as os from '@/os';
|
2020-02-09 20:48:45 +02:00
|
|
|
|
2022-01-16 01:38:55 +02:00
|
|
|
const props = withDefaults(defineProps<{
|
|
|
|
url: string;
|
|
|
|
rel?: null | string;
|
|
|
|
}>(), {
|
|
|
|
});
|
2020-02-09 20:48:45 +02:00
|
|
|
|
2022-01-16 01:38:55 +02:00
|
|
|
const self = props.url.startsWith(local);
|
|
|
|
const attr = self ? 'to' : 'href';
|
|
|
|
const target = self ? null : '_blank';
|
2020-02-09 20:48:45 +02:00
|
|
|
|
2022-01-16 01:38:55 +02:00
|
|
|
const el = $ref();
|
2020-10-17 14:12:00 +03:00
|
|
|
|
2022-01-16 01:38:55 +02:00
|
|
|
useTooltip($$(el), (showing) => {
|
2022-05-01 16:51:07 +03:00
|
|
|
os.popup(defineAsyncComponent(() => import('@/components/url-preview-popup.vue')), {
|
2022-01-16 01:38:55 +02:00
|
|
|
showing,
|
|
|
|
url: props.url,
|
|
|
|
source: el,
|
|
|
|
}, {}, 'closed');
|
2020-02-09 20:48:45 +02:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.xlcxczvw {
|
|
|
|
word-break: break-all;
|
|
|
|
|
|
|
|
> .icon {
|
|
|
|
padding-left: 2px;
|
|
|
|
font-size: .9em;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|