remove unused rootScale and scale params

This commit is contained in:
Johann150 2023-05-27 10:51:36 +02:00
parent 404bb3b6b6
commit a72f4300aa
Signed by untrusted user: Johann150
GPG key ID: 9EE6577A2A06F8F1

View file

@ -36,10 +36,6 @@ export default defineComponent({
type: Boolean, type: Boolean,
default: true, default: true,
}, },
rootScale: {
type: Number,
default: 1
}
}, },
render() { render() {
@ -53,7 +49,7 @@ export default defineComponent({
return t.match(/^[0-9.]+s$/) ? t : null; return t.match(/^[0-9.]+s$/) ? t : null;
}; };
const genEl = (ast: mfm.MfmNode[], scale: Number) => ast.map((token): VNode | VNode[] => { const genEl = (ast: mfm.MfmNode[]) => ast.map((token): VNode | VNode[] => {
switch (token.type) { switch (token.type) {
case 'text': { case 'text': {
const text = token.props.text.replace(/(\r\n|\n|\r)/g, '\n'); const text = token.props.text.replace(/(\r\n|\n|\r)/g, '\n');
@ -72,17 +68,17 @@ export default defineComponent({
} }
case 'bold': { case 'bold': {
return h('b', genEl(token.children, scale)); return h('b', genEl(token.children));
} }
case 'strike': { case 'strike': {
return h('del', genEl(token.children, scale)); return h('del', genEl(token.children));
} }
case 'italic': { case 'italic': {
return h('i', { return h('i', {
style: 'font-style: oblique;', style: 'font-style: oblique;',
}, genEl(token.children, scale)); }, genEl(token.children));
} }
case 'fn': { case 'fn': {
@ -143,17 +139,17 @@ export default defineComponent({
case 'x2': { case 'x2': {
return h('span', { return h('span', {
class: 'mfm-x2' class: 'mfm-x2'
}, genEl(token.children, scale * 2)); }, genEl(token.children));
} }
case 'x3': { case 'x3': {
return h('span', { return h('span', {
class: 'mfm-x3' class: 'mfm-x3'
}, genEl(token.children, scale * 3)); }, genEl(token.children));
} }
case 'x4': { case 'x4': {
return h('span', { return h('span', {
class: 'mfm-x4' class: 'mfm-x4'
}, genEl(token.children, scale * 4)); }, genEl(token.children));
} }
case 'font': { case 'font': {
const family = const family =
@ -170,7 +166,7 @@ export default defineComponent({
case 'blur': { case 'blur': {
return h('span', { return h('span', {
class: '_mfm_blur_', class: '_mfm_blur_',
}, genEl(token.children, scale)); }, genEl(token.children));
} }
case 'rainbow': { case 'rainbow': {
const speed = validTime(token.props.args.speed) || '1s'; const speed = validTime(token.props.args.speed) || '1s';
@ -179,9 +175,9 @@ export default defineComponent({
} }
case 'sparkle': { case 'sparkle': {
if (!this.$store.state.animatedMfm) { if (!this.$store.state.animatedMfm) {
return genEl(token.children, scale); return genEl(token.children);
} }
return h(MkSparkle, {}, genEl(token.children, scale)); return h(MkSparkle, {}, genEl(token.children));
} }
case 'rotate': { case 'rotate': {
const degrees = (typeof token.props.args.deg === 'string' ? parseInt(token.props.args.deg) : null) || '90'; const degrees = (typeof token.props.args.deg === 'string' ? parseInt(token.props.args.deg) : null) || '90';
@ -198,7 +194,6 @@ export default defineComponent({
const x = Math.min(parseFloat(token.props.args.x ?? '1'), 5); const x = Math.min(parseFloat(token.props.args.x ?? '1'), 5);
const y = Math.min(parseFloat(token.props.args.y ?? '1'), 5); const y = Math.min(parseFloat(token.props.args.y ?? '1'), 5);
style = `transform: scale(${x}, ${y});`; style = `transform: scale(${x}, ${y});`;
scale = scale * Math.max(x, y);
break; break;
} }
case 'fg': { case 'fg': {
@ -215,24 +210,24 @@ export default defineComponent({
} }
} }
if (style == null) { if (style == null) {
return h('span', {}, ['$[', token.props.name, ' ', ...genEl(token.children, scale), ']']); return h('span', {}, ['$[', token.props.name, ' ', ...genEl(token.children), ']']);
} else { } else {
return h('span', { return h('span', {
style: 'display: inline-block;' + style, style: 'display: inline-block;' + style,
}, genEl(token.children, scale)); }, genEl(token.children));
} }
} }
case 'small': { case 'small': {
return h('small', { return h('small', {
class: '_mfm_small_' class: '_mfm_small_'
}, genEl(token.children, scale)); }, genEl(token.children));
} }
case 'center': { case 'center': {
return h('div', { return h('div', {
style: 'text-align:center;', style: 'text-align:center;',
}, genEl(token.children, scale)); }, genEl(token.children));
} }
case 'url': { case 'url': {
@ -248,7 +243,7 @@ export default defineComponent({
key: Math.random(), key: Math.random(),
url: token.props.url, url: token.props.url,
rel: 'nofollow noopener', rel: 'nofollow noopener',
}, genEl(token.children, scale)); }, genEl(token.children));
} }
case 'mention': { case 'mention': {
@ -286,7 +281,7 @@ export default defineComponent({
case 'quote': { case 'quote': {
return h(this.nowrap ? 'span' : 'div', { return h(this.nowrap ? 'span' : 'div', {
class: 'quote', class: 'quote',
}, genEl(token.children, scale)); }, genEl(token.children));
} }
case 'emojiCode': { case 'emojiCode': {
@ -339,6 +334,6 @@ export default defineComponent({
}).flat(); }).flat();
// Parse ast to DOM // Parse ast to DOM
return h('span', genEl(ast, this.rootScale ?? 1)); return h('span', genEl(ast));
}, },
}); });