2023-07-27 08:31:52 +03:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2023-12-18 04:03:05 +02:00
|
|
|
import * as mfm from '@sharkey/sfm-js';
|
2022-09-17 21:27:08 +03:00
|
|
|
import { unique } from '@/misc/prelude/array.js';
|
2021-04-02 04:36:11 +03:00
|
|
|
|
|
|
|
export function extractCustomEmojisFromMfm(nodes: mfm.MfmNode[]): string[] {
|
2021-04-10 18:18:29 +03:00
|
|
|
const emojiNodes = mfm.extract(nodes, (node) => {
|
|
|
|
return (node.type === 'emojiCode' && node.props.name.length <= 100);
|
2023-02-01 10:29:28 +02:00
|
|
|
}) as mfm.MfmEmojiCode[];
|
2021-04-02 04:36:11 +03:00
|
|
|
|
2021-04-10 18:18:29 +03:00
|
|
|
return unique(emojiNodes.map(x => x.props.name));
|
2021-04-02 04:36:11 +03:00
|
|
|
}
|