forked from FoundKeyGang/FoundKey
文字数が多い場合は動きを無効に
This commit is contained in:
parent
005d25a07b
commit
5bbc95d659
2 changed files with 36 additions and 17 deletions
|
@ -183,6 +183,7 @@
|
|||
"showdown-highlightjs-extension": "0.1.2",
|
||||
"single-line-log": "1.1.2",
|
||||
"speakeasy": "2.0.0",
|
||||
"stringz": "1.0.0",
|
||||
"style-loader": "0.21.0",
|
||||
"stylus": "0.54.5",
|
||||
"stylus-loader": "3.0.2",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Vue from 'vue';
|
||||
import * as emojilib from 'emojilib';
|
||||
import { length } from 'stringz';
|
||||
import parse from '../../../../../mfm/parse';
|
||||
import getAcct from '../../../../../misc/acct/render';
|
||||
import { url } from '../../../config';
|
||||
|
@ -43,7 +44,7 @@ export default Vue.component('misskey-flavored-markdown', {
|
|||
// Parse ast to DOM
|
||||
const els = flatten(ast.map(token => {
|
||||
switch (token.type) {
|
||||
case 'text':
|
||||
case 'text': {
|
||||
const text = token.content.replace(/(\r\n|\n|\r)/g, '\n');
|
||||
|
||||
if (this.shouldBreak) {
|
||||
|
@ -54,41 +55,48 @@ export default Vue.component('misskey-flavored-markdown', {
|
|||
} else {
|
||||
return createElement('span', text.replace(/\n/g, ' '));
|
||||
}
|
||||
}
|
||||
|
||||
case 'bold':
|
||||
case 'bold': {
|
||||
return createElement('b', token.bold);
|
||||
}
|
||||
|
||||
case 'big':
|
||||
case 'big': {
|
||||
const isLong = length(token.big) > 10;
|
||||
return (createElement as any)('strong', {
|
||||
attrs: {
|
||||
style: 'display: inline-block; font-size: 200%;'
|
||||
},
|
||||
directives: [this.$store.state.settings.disableAnimatedMfm ? {} : {
|
||||
directives: [this.$store.state.settings.disableAnimatedMfm || isLong ? {} : {
|
||||
name: 'animate-css',
|
||||
value: { classes: 'tada', iteration: 'infinite' }
|
||||
}]
|
||||
}, token.big);
|
||||
}
|
||||
|
||||
case 'motion':
|
||||
case 'motion': {
|
||||
const isLong = length(token.motion) > 10;
|
||||
return (createElement as any)('span', {
|
||||
attrs: {
|
||||
style: 'display: inline-block;'
|
||||
},
|
||||
directives: [this.$store.state.settings.disableAnimatedMfm ? {} : {
|
||||
directives: [this.$store.state.settings.disableAnimatedMfm || isLong ? {} : {
|
||||
name: 'animate-css',
|
||||
value: { classes: 'rubberBand', iteration: 'infinite' }
|
||||
}]
|
||||
}, token.motion);
|
||||
}
|
||||
|
||||
case 'url':
|
||||
case 'url': {
|
||||
return createElement(MkUrl, {
|
||||
props: {
|
||||
url: token.content,
|
||||
target: '_blank'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
case 'link':
|
||||
case 'link': {
|
||||
return createElement('a', {
|
||||
attrs: {
|
||||
class: 'link',
|
||||
|
@ -97,8 +105,9 @@ export default Vue.component('misskey-flavored-markdown', {
|
|||
title: token.url
|
||||
}
|
||||
}, token.title);
|
||||
}
|
||||
|
||||
case 'mention':
|
||||
case 'mention': {
|
||||
return (createElement as any)('a', {
|
||||
attrs: {
|
||||
href: `${url}/@${getAcct(token)}`,
|
||||
|
@ -110,16 +119,18 @@ export default Vue.component('misskey-flavored-markdown', {
|
|||
value: token.content
|
||||
}]
|
||||
}, token.content);
|
||||
}
|
||||
|
||||
case 'hashtag':
|
||||
case 'hashtag': {
|
||||
return createElement('a', {
|
||||
attrs: {
|
||||
href: `${url}/tags/${encodeURIComponent(token.hashtag)}`,
|
||||
target: '_blank'
|
||||
}
|
||||
}, token.content);
|
||||
}
|
||||
|
||||
case 'code':
|
||||
case 'code': {
|
||||
return createElement('pre', {
|
||||
class: 'code'
|
||||
}, [
|
||||
|
@ -129,15 +140,17 @@ export default Vue.component('misskey-flavored-markdown', {
|
|||
}
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
||||
case 'inline-code':
|
||||
case 'inline-code': {
|
||||
return createElement('code', {
|
||||
domProps: {
|
||||
innerHTML: token.html
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
case 'quote':
|
||||
case 'quote': {
|
||||
const text2 = token.quote.replace(/(\r\n|\n|\r)/g, '\n');
|
||||
|
||||
if (this.shouldBreak) {
|
||||
|
@ -156,28 +169,33 @@ export default Vue.component('misskey-flavored-markdown', {
|
|||
}
|
||||
}, text2.replace(/\n/g, ' '));
|
||||
}
|
||||
}
|
||||
|
||||
case 'title':
|
||||
case 'title': {
|
||||
return createElement('div', {
|
||||
attrs: {
|
||||
class: 'title'
|
||||
}
|
||||
}, token.title);
|
||||
}
|
||||
|
||||
case 'emoji':
|
||||
case 'emoji': {
|
||||
const emoji = emojilib.lib[token.emoji];
|
||||
return createElement('span', emoji ? emoji.char : token.content);
|
||||
}
|
||||
|
||||
case 'search':
|
||||
case 'search': {
|
||||
return createElement(MkGoogle, {
|
||||
props: {
|
||||
q: token.query
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
default:
|
||||
default: {
|
||||
console.log('unknown ast type:', token.type);
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
const _els = [];
|
||||
|
|
Loading…
Reference in a new issue