2023-07-27 14:31:52 +09:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-02-10 03:48:45 +09:00
|
|
|
<template>
|
2022-12-19 19:01:30 +09:00
|
|
|
<component
|
2023-07-14 07:59:54 +09:00
|
|
|
:is="self ? 'MkA' : 'a'" ref="el" style="word-break: break-all;" class="_link" :[attr]="self ? url.substring(local.length) : url" :rel="rel" :target="target"
|
2021-11-19 19:36:12 +09:00
|
|
|
:title="url"
|
2020-02-10 03:48:45 +09:00
|
|
|
>
|
|
|
|
<slot></slot>
|
2023-01-10 14:45:02 +09:00
|
|
|
<i v-if="target === '_blank'" class="ti ti-external-link" :class="$style.icon"></i>
|
2020-02-10 03:48:45 +09:00
|
|
|
</component>
|
|
|
|
</template>
|
|
|
|
|
2022-01-16 08:38:55 +09:00
|
|
|
<script lang="ts" setup>
|
2022-05-01 22:51:07 +09:00
|
|
|
import { defineAsyncComponent } from 'vue';
|
2021-11-12 02:02:25 +09:00
|
|
|
import { url as local } from '@/config';
|
2022-01-16 08:38:55 +09:00
|
|
|
import { useTooltip } from '@/scripts/use-tooltip';
|
2021-11-12 02:02:25 +09:00
|
|
|
import * as os from '@/os';
|
2020-02-10 03:48:45 +09:00
|
|
|
|
2022-01-16 08:38:55 +09:00
|
|
|
const props = withDefaults(defineProps<{
|
|
|
|
url: string;
|
|
|
|
rel?: null | string;
|
|
|
|
}>(), {
|
|
|
|
});
|
2020-02-10 03:48:45 +09:00
|
|
|
|
2022-01-16 08:38:55 +09:00
|
|
|
const self = props.url.startsWith(local);
|
|
|
|
const attr = self ? 'to' : 'href';
|
|
|
|
const target = self ? null : '_blank';
|
2020-02-10 03:48:45 +09:00
|
|
|
|
2022-01-16 08:38:55 +09:00
|
|
|
const el = $ref();
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-01-16 08:38:55 +09:00
|
|
|
useTooltip($$(el), (showing) => {
|
2022-08-31 00:24:33 +09:00
|
|
|
os.popup(defineAsyncComponent(() => import('@/components/MkUrlPreviewPopup.vue')), {
|
2022-01-16 08:38:55 +09:00
|
|
|
showing,
|
|
|
|
url: props.url,
|
|
|
|
source: el,
|
|
|
|
}, {}, 'closed');
|
2020-02-10 03:48:45 +09:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2023-01-10 14:45:02 +09:00
|
|
|
<style lang="scss" module>
|
|
|
|
.icon {
|
|
|
|
padding-left: 2px;
|
|
|
|
font-size: .9em;
|
2020-02-10 03:48:45 +09:00
|
|
|
}
|
|
|
|
</style>
|