Ported firefish crop and fade mfm
This commit is contained in:
parent
3d0bf928a7
commit
f9a7cd0daa
5 changed files with 73 additions and 2 deletions
|
|
@ -304,6 +304,16 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section _block">
|
||||
<div class="title">{{ i18n.ts._mfm.crop }}</div>
|
||||
<div class="content">
|
||||
<p>{{ i18n.ts._mfm.cropDescription }}</p>
|
||||
<div class="preview">
|
||||
<Mfm :text="preview_crop" />
|
||||
<MkTextarea v-model="preview_crop"><span>MFM</span></MkTextarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section _block">
|
||||
<div class="title">{{ i18n.ts._mfm.position }}</div>
|
||||
<div class="content">
|
||||
|
|
@ -316,7 +326,7 @@
|
|||
</div>
|
||||
<div class="section _block" style="overflow: hidden">
|
||||
<div class="title">{{ i18n.ts._mfm.followMouse }}</div>
|
||||
<MkInfo warn>{{ i18n.ts._mfm.uncommonFeature }}</MkInfo>
|
||||
<MkInfo warn>{{ i18n.ts._mfm.uncommonFeature }}</MkInfo>
|
||||
<br/>
|
||||
<div class="content">
|
||||
<p>{{ i18n.ts._mfm.followMouseDescription }}</p>
|
||||
|
|
@ -336,6 +346,16 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section _block">
|
||||
<div class="title">{{ i18n.ts._mfm.fade }}</div>
|
||||
<div class="content">
|
||||
<p>{{ i18n.ts._mfm.fadeDescription }}</p>
|
||||
<div class="preview">
|
||||
<Mfm :text="preview_fade" />
|
||||
<MkTextarea v-model="preview_fade"><span>MFM</span></MkTextarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section _block">
|
||||
<div class="title">{{ i18n.ts._mfm.foreground }}</div>
|
||||
<div class="content">
|
||||
|
|
@ -445,6 +465,9 @@ const preview_rotate = ref(
|
|||
'$[rotate 🍮]\n$[rotate.deg=45 🍮]\n$[rotate.x,deg=45 Hello, world!]',
|
||||
);
|
||||
const preview_position = ref('$[position.y=-1 🍮]\n$[position.x=-1 🍮]');
|
||||
const preview_crop = ref(
|
||||
"$[crop.top=50 🍮] $[crop.right=50 🍮] $[crop.bottom=50 🍮] $[crop.left=50 🍮]",
|
||||
);
|
||||
const preview_followmouse = ref('$[followmouse.x 🍮]\n$[followmouse.x,y,rotateByVelocity,speed=0.4 🍮]');
|
||||
const preview_scale = ref(
|
||||
'$[scale.x=1.3 🍮]\n$[scale.x=1.5,y=3 🍮]\n$[scale.y=0.3 🍮]',
|
||||
|
|
@ -454,6 +477,7 @@ const preview_bg = ref('$[bg.color=31748f Background color]');
|
|||
const preview_plain = ref(
|
||||
'<plain>**bold** @mention #hashtag `code` $[x2 🍮]</plain>',
|
||||
);
|
||||
const preview_fade = ref(`$[fade 🍮] $[fade.out 🍮] $[fade.speed=3s 🍮] $[fade.delay=3s 🍮]`);
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
|||
|
|
@ -228,6 +228,22 @@ export default function (props: MfmProps, { emit }: { emit: SetupContext<MfmEven
|
|||
}
|
||||
return h(MkSparkle, {}, genEl(token.children, scale));
|
||||
}
|
||||
case 'fade': {
|
||||
// Dont run with reduced motion on
|
||||
if (!defaultStore.state.animation) {
|
||||
style = '';
|
||||
break;
|
||||
}
|
||||
|
||||
const direction = token.props.args.out
|
||||
? 'alternate-reverse'
|
||||
: 'alternate';
|
||||
const speed = validTime(token.props.args.speed) ?? '1.5s';
|
||||
const delay = validTime(token.props.args.delay) ?? '0s';
|
||||
const loop = safeParseFloat(token.props.args.loop) ?? 'infinite';
|
||||
style = `animation: mfm-fade ${speed} ${delay} linear ${loop}; animation-direction: ${direction};`;
|
||||
break;
|
||||
}
|
||||
case 'rotate': {
|
||||
const degrees = safeParseFloat(token.props.args.deg) ?? 90;
|
||||
style = `transform: rotate(${degrees}deg); transform-origin: center center;`;
|
||||
|
|
@ -262,6 +278,22 @@ export default function (props: MfmProps, { emit }: { emit: SetupContext<MfmEven
|
|||
style = `transform: translateX(${x}em) translateY(${y}em);`;
|
||||
break;
|
||||
}
|
||||
case 'crop': {
|
||||
const top = Number.parseFloat(
|
||||
(token.props.args.top ?? '0').toString(),
|
||||
);
|
||||
const right = Number.parseFloat(
|
||||
(token.props.args.right ?? '0').toString(),
|
||||
);
|
||||
const bottom = Number.parseFloat(
|
||||
(token.props.args.bottom ?? '0').toString(),
|
||||
);
|
||||
const left = Number.parseFloat(
|
||||
(token.props.args.left ?? '0').toString(),
|
||||
);
|
||||
style = `clip-path: inset(${top}% ${right}% ${bottom}% ${left}%);`;
|
||||
break;
|
||||
}
|
||||
case 'scale': {
|
||||
if (!defaultStore.state.advancedMfm) {
|
||||
style = '';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue