Fix #4981
This commit is contained in:
parent
9192e98e3f
commit
162a740295
|
@ -8,7 +8,7 @@ import { concat, sum } from '../../../../../prelude/array';
|
||||||
import MkFormula from './formula.vue';
|
import MkFormula from './formula.vue';
|
||||||
import MkCode from './code.vue';
|
import MkCode from './code.vue';
|
||||||
import MkGoogle from './google.vue';
|
import MkGoogle from './google.vue';
|
||||||
import { host, url } from '../../../config';
|
import { host } from '../../../config';
|
||||||
import { preorderF, countNodesF } from '../../../../../prelude/tree';
|
import { preorderF, countNodesF } from '../../../../../prelude/tree';
|
||||||
|
|
||||||
function sumTextsLength(ts: MfmForest): number {
|
function sumTextsLength(ts: MfmForest): number {
|
||||||
|
@ -175,9 +175,6 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||||
props: {
|
props: {
|
||||||
url: token.node.props.url,
|
url: token.node.props.url,
|
||||||
rel: 'nofollow noopener',
|
rel: 'nofollow noopener',
|
||||||
...(token.node.props.url.startsWith(url) ? {} : {
|
|
||||||
target: '_blank'
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
attrs: {
|
attrs: {
|
||||||
style: 'color:var(--mfmUrl);'
|
style: 'color:var(--mfmUrl);'
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<component :is="self ? 'router-link' : 'a'" class="mk-url" :[attr]="self ? url.substr(local.length) : url" :rel="rel" :target="target">
|
<component :is="hasRoute ? 'router-link' : 'a'" class="mk-url" :[attr]="hasRoute ? url.substr(local.length) : url" :rel="rel" :target="target">
|
||||||
<template v-if="!self">
|
<template v-if="!self">
|
||||||
<span class="schema">{{ schema }}//</span>
|
<span class="schema">{{ schema }}//</span>
|
||||||
<span class="hostname">{{ hostname }}</span>
|
<span class="hostname">{{ hostname }}</span>
|
||||||
|
@ -8,7 +8,7 @@
|
||||||
<span class="pathname" v-if="pathname != ''">{{ self ? pathname.substr(1) : pathname }}</span>
|
<span class="pathname" v-if="pathname != ''">{{ self ? pathname.substr(1) : pathname }}</span>
|
||||||
<span class="query">{{ query }}</span>
|
<span class="query">{{ query }}</span>
|
||||||
<span class="hash">{{ hash }}</span>
|
<span class="hash">{{ hash }}</span>
|
||||||
<fa icon="external-link-square-alt" v-if="!self"/>
|
<fa icon="external-link-square-alt" v-if="target === '_blank'"/>
|
||||||
</component>
|
</component>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -18,8 +18,13 @@ import { toUnicode as decodePunycode } from 'punycode';
|
||||||
import { url as local } from '../../../config';
|
import { url as local } from '../../../config';
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
props: ['url', 'rel', 'target'],
|
props: ['url', 'rel'],
|
||||||
data() {
|
data() {
|
||||||
|
const isSelf = this.url.startsWith(local);
|
||||||
|
const hasRoute =
|
||||||
|
this.url.substr(local.length).startsWith('/@') ||
|
||||||
|
this.url.substr(local.length).startsWith('/notes/') ||
|
||||||
|
this.url.substr(local.length).startsWith('/pages/');
|
||||||
return {
|
return {
|
||||||
local,
|
local,
|
||||||
schema: null,
|
schema: null,
|
||||||
|
@ -28,8 +33,10 @@ export default Vue.extend({
|
||||||
pathname: null,
|
pathname: null,
|
||||||
query: null,
|
query: null,
|
||||||
hash: null,
|
hash: null,
|
||||||
self: this.url.startsWith(local),
|
self: isSelf,
|
||||||
attr: this.url.startsWith(local) ? 'to' : 'href'
|
hasRoute: hasRoute,
|
||||||
|
attr: hasRoute ? 'to' : 'href',
|
||||||
|
target: hasRoute ? null : '_blank'
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
|
Loading…
Reference in New Issue