2023-07-27 07:31:52 +02:00
|
|
|
<!--
|
2024-02-13 16:59:27 +01:00
|
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 07:31:52 +02:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-02-09 19:48:45 +01:00
|
|
|
<template>
|
2022-12-19 11:01:30 +01:00
|
|
|
<component
|
2023-12-08 09:48:18 +01:00
|
|
|
:is="self ? 'MkA' : 'a'" ref="el" style="word-break: break-all;" class="_link" :[attr]="self ? url.substring(local.length) : url" :rel="rel ?? 'nofollow noopener'" :target="target"
|
2021-11-19 11:36:12 +01:00
|
|
|
:title="url"
|
2024-01-28 22:11:09 +01:00
|
|
|
@click.stop
|
2020-02-09 19:48:45 +01:00
|
|
|
>
|
|
|
|
<slot></slot>
|
2023-09-30 21:53:52 +02:00
|
|
|
<i v-if="target === '_blank'" class="ph-arrow-square-out ph-bold ph-lg" :class="$style.icon"></i>
|
2020-02-09 19:48:45 +01:00
|
|
|
</component>
|
|
|
|
</template>
|
|
|
|
|
2022-01-16 00:38:55 +01:00
|
|
|
<script lang="ts" setup>
|
2023-12-07 06:42:09 +01:00
|
|
|
import { defineAsyncComponent, ref } from 'vue';
|
2023-09-19 09:37:43 +02:00
|
|
|
import { url as local } from '@/config.js';
|
|
|
|
import { useTooltip } from '@/scripts/use-tooltip.js';
|
|
|
|
import * as os from '@/os.js';
|
2020-02-09 19:48:45 +01:00
|
|
|
|
2022-01-16 00:38:55 +01:00
|
|
|
const props = withDefaults(defineProps<{
|
|
|
|
url: string;
|
|
|
|
rel?: null | string;
|
|
|
|
}>(), {
|
|
|
|
});
|
2020-02-09 19:48:45 +01:00
|
|
|
|
2022-01-16 00:38:55 +01:00
|
|
|
const self = props.url.startsWith(local);
|
|
|
|
const attr = self ? 'to' : 'href';
|
|
|
|
const target = self ? null : '_blank';
|
2020-02-09 19:48:45 +01:00
|
|
|
|
2023-12-26 06:19:35 +01:00
|
|
|
const el = ref<HTMLElement>();
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
useTooltip(el, (showing) => {
|
2022-08-30 17:24:33 +02:00
|
|
|
os.popup(defineAsyncComponent(() => import('@/components/MkUrlPreviewPopup.vue')), {
|
2022-01-16 00:38:55 +01:00
|
|
|
showing,
|
|
|
|
url: props.url,
|
2023-12-07 06:42:09 +01:00
|
|
|
source: el.value,
|
2022-01-16 00:38:55 +01:00
|
|
|
}, {}, 'closed');
|
2020-02-09 19:48:45 +01:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2023-01-10 06:45:02 +01:00
|
|
|
<style lang="scss" module>
|
|
|
|
.icon {
|
|
|
|
padding-left: 2px;
|
|
|
|
font-size: .9em;
|
2020-02-09 19:48:45 +01:00
|
|
|
}
|
|
|
|
</style>
|