summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-08-05 12:33:51 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-08-05 12:33:51 +0900
commitcd28504dd8e4623ed864de2ad76e88e1022b08b1 (patch)
tree3b0553c92b6e5d10478e565817c766a9ad1a5859 /src
parentMerge branch 'master' of https://github.com/syuilo/misskey (diff)
downloadmisskey-cd28504dd8e4623ed864de2ad76e88e1022b08b1.tar.gz
misskey-cd28504dd8e4623ed864de2ad76e88e1022b08b1.tar.bz2
misskey-cd28504dd8e4623ed864de2ad76e88e1022b08b1.zip
Add new MFM syntax
Diffstat (limited to 'src')
-rw-r--r--src/client/app/common/views/components/misskey-flavored-markdown.ts11
-rw-r--r--src/mfm/html.ts6
-rw-r--r--src/mfm/parse/elements/motion.ts20
-rw-r--r--src/mfm/parse/index.ts7
4 files changed, 42 insertions, 2 deletions
diff --git a/src/client/app/common/views/components/misskey-flavored-markdown.ts b/src/client/app/common/views/components/misskey-flavored-markdown.ts
index f9c97bd35a..683b4e806c 100644
--- a/src/client/app/common/views/components/misskey-flavored-markdown.ts
+++ b/src/client/app/common/views/components/misskey-flavored-markdown.ts
@@ -69,6 +69,17 @@ export default Vue.component('misskey-flavored-markdown', {
}]
}, token.big);
+ case 'motion':
+ return (createElement as any)('span', {
+ attrs: {
+ style: 'display: inline-block;'
+ },
+ directives: [this.$store.state.settings.disableAnimatedMfm ? {} : {
+ name: 'animate-css',
+ value: { classes: 'rubberBand', iteration: 'infinite' }
+ }]
+ }, token.motion);
+
case 'url':
return createElement(MkUrl, {
props: {
diff --git a/src/mfm/html.ts b/src/mfm/html.ts
index dfe291b3a5..c11bd55cf4 100644
--- a/src/mfm/html.ts
+++ b/src/mfm/html.ts
@@ -18,6 +18,12 @@ const handlers: { [key: string]: (window: any, token: any, mentionedRemoteUsers:
document.body.appendChild(b);
},
+ motion({ document }, { big }) {
+ const b = document.createElement('strong');
+ b.textContent = big;
+ document.body.appendChild(b);
+ },
+
code({ document }, { code }) {
const pre = document.createElement('pre');
const inner = document.createElement('code');
diff --git a/src/mfm/parse/elements/motion.ts b/src/mfm/parse/elements/motion.ts
new file mode 100644
index 0000000000..555a989750
--- /dev/null
+++ b/src/mfm/parse/elements/motion.ts
@@ -0,0 +1,20 @@
+/**
+ * Motion
+ */
+
+export type TextElementMotion = {
+ type: 'motion'
+ content: string
+ motion: string
+};
+
+export default function(text: string) {
+ const match = text.match(/^\(\(\((.+?)\)\)\)/);
+ if (!match) return null;
+ const motion = match[0];
+ return {
+ type: 'motion',
+ content: motion,
+ motion: match[1]
+ } as TextElementMotion;
+}
diff --git a/src/mfm/parse/index.ts b/src/mfm/parse/index.ts
index 066c062559..99c00ae649 100644
--- a/src/mfm/parse/index.ts
+++ b/src/mfm/parse/index.ts
@@ -14,6 +14,7 @@ import { TextElementQuote } from './elements/quote';
import { TextElementSearch } from './elements/search';
import { TextElementTitle } from './elements/title';
import { TextElementUrl } from './elements/url';
+import { TextElementMotion } from './elements/motion';
const elements = [
require('./elements/big'),
@@ -27,7 +28,8 @@ const elements = [
require('./elements/inline-code'),
require('./elements/quote'),
require('./elements/emoji'),
- require('./elements/search')
+ require('./elements/search'),
+ require('./elements/motion')
].map(element => element.default as TextElementProcessor);
export type TextElement = { type: 'text', content: string }
@@ -42,7 +44,8 @@ export type TextElement = { type: 'text', content: string }
| TextElementQuote
| TextElementSearch
| TextElementTitle
- | TextElementUrl;
+ | TextElementUrl
+ | TextElementMotion;
export type TextElementProcessor = (text: string, i: number) => TextElement | TextElement[];
export default (source: string): TextElement[] => {