mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2024-12-14 06:00:44 +01:00
Add jump syntax (#4007)
* Add jump syntax * Fix typo: spin -> jump * Fix typo
This commit is contained in:
parent
5fac7c1718
commit
62d41023e1
5 changed files with 50 additions and 0 deletions
|
@ -31,3 +31,11 @@
|
||||||
0% { transform: rotate(0deg); }
|
0% { transform: rotate(0deg); }
|
||||||
100% { transform: rotate(360deg); }
|
100% { transform: rotate(360deg); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes jump {
|
||||||
|
0% { transform: translateY(0); }
|
||||||
|
25% { transform: translateY(-16px); }
|
||||||
|
50% { transform: translateY(0); }
|
||||||
|
75% { transform: translateY(-8px); }
|
||||||
|
100% { transform: translateY(0); }
|
||||||
|
}
|
||||||
|
|
|
@ -135,6 +135,17 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||||
}, genEl(token.children));
|
}, genEl(token.children));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 'jump': {
|
||||||
|
motionCount++;
|
||||||
|
const isLong = sumTextsLength(token.children) > 5 || countNodesF(token.children) > 3;
|
||||||
|
const isMany = motionCount > 3;
|
||||||
|
return (createElement as any)('span', {
|
||||||
|
attrs: {
|
||||||
|
style: (this.$store.state.settings.disableAnimatedMfm || isLong || isMany) ? 'display: inline-block;' : 'display: inline-block; animation: jump 0.75s linear infinite;'
|
||||||
|
},
|
||||||
|
}, genEl(token.children));
|
||||||
|
}
|
||||||
|
|
||||||
case 'flip': {
|
case 'flip': {
|
||||||
return (createElement as any)('span', {
|
return (createElement as any)('span', {
|
||||||
attrs: {
|
attrs: {
|
||||||
|
|
|
@ -61,6 +61,12 @@ export default (tokens: MfmForest, mentionedRemoteUsers: INote['mentionedRemoteU
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
jump(token) {
|
||||||
|
const el = doc.createElement('i');
|
||||||
|
appendChildren(token.children, el);
|
||||||
|
return el;
|
||||||
|
},
|
||||||
|
|
||||||
flip(token) {
|
flip(token) {
|
||||||
const el = doc.createElement('span');
|
const el = doc.createElement('span');
|
||||||
appendChildren(token.children, el);
|
appendChildren(token.children, el);
|
||||||
|
|
|
@ -92,6 +92,7 @@ const mfm = P.createLanguage({
|
||||||
r.big,
|
r.big,
|
||||||
r.small,
|
r.small,
|
||||||
r.spin,
|
r.spin,
|
||||||
|
r.jump,
|
||||||
r.bold,
|
r.bold,
|
||||||
r.strike,
|
r.strike,
|
||||||
r.italic,
|
r.italic,
|
||||||
|
@ -126,6 +127,7 @@ const mfm = P.createLanguage({
|
||||||
r.emoji,
|
r.emoji,
|
||||||
r.mathInline,
|
r.mathInline,
|
||||||
r.spin,
|
r.spin,
|
||||||
|
r.jump,
|
||||||
r.text
|
r.text
|
||||||
).atLeast(1).tryParse(x), {})),
|
).atLeast(1).tryParse(x), {})),
|
||||||
//#endregion
|
//#endregion
|
||||||
|
@ -154,6 +156,15 @@ const mfm = P.createLanguage({
|
||||||
).atLeast(1).tryParse(x), {})),
|
).atLeast(1).tryParse(x), {})),
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
//#region Jump
|
||||||
|
jump: r =>
|
||||||
|
P.regexp(/<jump>(.+?)<\/jump>/, 1)
|
||||||
|
.map(x => createTree('jump', P.alt(
|
||||||
|
r.emoji,
|
||||||
|
r.text
|
||||||
|
).atLeast(1).tryParse(x), {})),
|
||||||
|
//#endregion
|
||||||
|
|
||||||
//#region Block code
|
//#region Block code
|
||||||
blockCode: r =>
|
blockCode: r =>
|
||||||
newline.then(
|
newline.then(
|
||||||
|
@ -189,6 +200,7 @@ const mfm = P.createLanguage({
|
||||||
r.big,
|
r.big,
|
||||||
r.small,
|
r.small,
|
||||||
r.spin,
|
r.spin,
|
||||||
|
r.jump,
|
||||||
r.bold,
|
r.bold,
|
||||||
r.strike,
|
r.strike,
|
||||||
r.italic,
|
r.italic,
|
||||||
|
@ -240,6 +252,7 @@ const mfm = P.createLanguage({
|
||||||
r.big,
|
r.big,
|
||||||
r.small,
|
r.small,
|
||||||
r.spin,
|
r.spin,
|
||||||
|
r.jump,
|
||||||
r.bold,
|
r.bold,
|
||||||
r.strike,
|
r.strike,
|
||||||
r.link,
|
r.link,
|
||||||
|
@ -297,6 +310,7 @@ const mfm = P.createLanguage({
|
||||||
r.big,
|
r.big,
|
||||||
r.small,
|
r.small,
|
||||||
r.spin,
|
r.spin,
|
||||||
|
r.jump,
|
||||||
r.bold,
|
r.bold,
|
||||||
r.strike,
|
r.strike,
|
||||||
r.italic,
|
r.italic,
|
||||||
|
@ -347,6 +361,7 @@ const mfm = P.createLanguage({
|
||||||
r.bold,
|
r.bold,
|
||||||
r.small,
|
r.small,
|
||||||
r.spin,
|
r.spin,
|
||||||
|
r.jump,
|
||||||
r.strike,
|
r.strike,
|
||||||
r.italic,
|
r.italic,
|
||||||
r.mention,
|
r.mention,
|
||||||
|
@ -410,6 +425,7 @@ const mfm = P.createLanguage({
|
||||||
r.big,
|
r.big,
|
||||||
r.small,
|
r.small,
|
||||||
r.spin,
|
r.spin,
|
||||||
|
r.jump,
|
||||||
r.bold,
|
r.bold,
|
||||||
r.strike,
|
r.strike,
|
||||||
r.italic,
|
r.italic,
|
||||||
|
|
|
@ -262,6 +262,15 @@ describe('MFM', () => {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('jump', () => {
|
||||||
|
const tokens = analyze('<jump>:foo:</jump>');
|
||||||
|
assert.deepStrictEqual(tokens, [
|
||||||
|
tree('jump', [
|
||||||
|
leaf('emoji', { name: 'foo' })
|
||||||
|
], {}),
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
describe('motion', () => {
|
describe('motion', () => {
|
||||||
it('by triple brackets', () => {
|
it('by triple brackets', () => {
|
||||||
const tokens = analyze('(((foo)))');
|
const tokens = analyze('(((foo)))');
|
||||||
|
|
Loading…
Reference in a new issue