diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-12-19 11:16:29 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-12-19 11:16:29 +0900 |
| commit | 00f979f0e65d92d4ad522146e5543a651485933c (patch) | |
| tree | 37581222706f296b2b13860315eb52143a553e46 /src/misc/extract-mentions.ts | |
| parent | Refactor (diff) | |
| download | misskey-00f979f0e65d92d4ad522146e5543a651485933c.tar.gz misskey-00f979f0e65d92d4ad522146e5543a651485933c.tar.bz2 misskey-00f979f0e65d92d4ad522146e5543a651485933c.zip | |
Fix bug
Diffstat (limited to 'src/misc/extract-mentions.ts')
| -rw-r--r-- | src/misc/extract-mentions.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/misc/extract-mentions.ts b/src/misc/extract-mentions.ts new file mode 100644 index 0000000000..1d844211c0 --- /dev/null +++ b/src/misc/extract-mentions.ts @@ -0,0 +1,19 @@ +import parse from '../mfm/parse'; +import { Node, IMentionNode } from '../mfm/parser'; + +export default function(tokens: ReturnType<typeof parse>): IMentionNode['props'][] { + const mentions: IMentionNode['props'][] = []; + + const extract = (tokens: Node[]) => { + for (const x of tokens.filter(x => x.name === 'mention')) { + mentions.push(x.props); + } + for (const x of tokens.filter(x => x.children)) { + extract(x.children); + } + }; + + extract(tokens); + + return mentions; +} |