2020-02-09 19:48:45 +01:00
|
|
|
<template>
|
2023-04-08 02:01:42 +02:00
|
|
|
<component
|
|
|
|
:is="self ? 'MkA' : 'a'"
|
|
|
|
ref="el"
|
|
|
|
class="xlcxczvw _link"
|
2023-10-17 03:57:20 +02:00
|
|
|
:[attr]="self ? url.substring(local.length) : url"
|
2023-04-08 02:01:42 +02:00
|
|
|
:rel="rel"
|
|
|
|
:target="target"
|
|
|
|
:title="url"
|
|
|
|
@click.stop
|
|
|
|
>
|
|
|
|
<slot></slot>
|
|
|
|
<i
|
|
|
|
v-if="target === '_blank'"
|
2023-10-17 03:57:20 +02:00
|
|
|
:class="icon('ph-arrow-square-out icon')"
|
2023-04-08 02:01:42 +02:00
|
|
|
></i>
|
|
|
|
</component>
|
2020-02-09 19:48:45 +01:00
|
|
|
</template>
|
|
|
|
|
2022-01-16 00:38:55 +01:00
|
|
|
<script lang="ts" setup>
|
2023-08-12 02:44:46 +02:00
|
|
|
import { defineAsyncComponent, ref } from "vue";
|
2023-04-08 02:01:42 +02:00
|
|
|
import { url as local } from "@/config";
|
|
|
|
import { useTooltip } from "@/scripts/use-tooltip";
|
|
|
|
import * as os from "@/os";
|
2023-10-17 03:57:20 +02:00
|
|
|
import icon from "@/scripts/icon";
|
2020-02-09 19:48:45 +01:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const props = withDefaults(
|
|
|
|
defineProps<{
|
|
|
|
url: string;
|
|
|
|
rel?: null | string;
|
|
|
|
}>(),
|
2023-07-06 03:28:27 +02:00
|
|
|
{},
|
2023-04-08 02:01:42 +02:00
|
|
|
);
|
2020-02-09 19:48:45 +01:00
|
|
|
|
2022-01-16 00:38:55 +01:00
|
|
|
const self = props.url.startsWith(local);
|
2023-04-08 02:01:42 +02:00
|
|
|
const attr = self ? "to" : "href";
|
|
|
|
const target = self ? null : "_blank";
|
2020-02-09 19:48:45 +01:00
|
|
|
|
2023-08-12 02:44:46 +02:00
|
|
|
const el = ref();
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2023-08-12 02:44:46 +02:00
|
|
|
useTooltip(el, (showing) => {
|
2023-04-08 02:01:42 +02:00
|
|
|
os.popup(
|
|
|
|
defineAsyncComponent(
|
2023-07-06 03:28:27 +02:00
|
|
|
() => import("@/components/MkUrlPreviewPopup.vue"),
|
2023-04-08 02:01:42 +02:00
|
|
|
),
|
|
|
|
{
|
|
|
|
showing,
|
|
|
|
url: props.url,
|
2023-08-12 02:44:46 +02:00
|
|
|
source: el.value,
|
2023-04-08 02:01:42 +02:00
|
|
|
},
|
|
|
|
{},
|
2023-07-06 03:28:27 +02:00
|
|
|
"closed",
|
2023-04-08 02:01:42 +02:00
|
|
|
);
|
2020-02-09 19:48:45 +01:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.xlcxczvw {
|
|
|
|
word-break: break-all;
|
|
|
|
|
|
|
|
> .icon {
|
|
|
|
padding-left: 2px;
|
2023-04-08 02:01:42 +02:00
|
|
|
font-size: 0.9em;
|
2020-02-09 19:48:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|