2023-05-22 09:15:43 -07:00
|
|
|
/*
|
|
|
|
MIT License
|
|
|
|
|
|
|
|
Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
|
|
|
|
|
|
This source code is licensed under the MIT license found in the
|
|
|
|
LICENSE file in the /app/soapbox/features/compose/editor directory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import { CodeHighlightNode, CodeNode } from '@lexical/code';
|
|
|
|
import { HashtagNode } from '@lexical/hashtag';
|
|
|
|
import { AutoLinkNode, LinkNode } from '@lexical/link';
|
|
|
|
import { ListItemNode, ListNode } from '@lexical/list';
|
|
|
|
import { HorizontalRuleNode } from '@lexical/react/LexicalHorizontalRuleNode';
|
|
|
|
import { HeadingNode, QuoteNode } from '@lexical/rich-text';
|
|
|
|
|
|
|
|
import { useFeatures, useInstance } from 'soapbox/hooks';
|
|
|
|
|
|
|
|
import { EmojiNode } from './emoji-node';
|
2023-07-20 16:13:42 -07:00
|
|
|
import { ImageNode } from './image-node';
|
2023-05-22 09:15:43 -07:00
|
|
|
import { MentionNode } from './mention-node';
|
|
|
|
|
|
|
|
import type { Klass, LexicalNode } from 'lexical';
|
|
|
|
|
|
|
|
const useNodes = () => {
|
|
|
|
const features = useFeatures();
|
|
|
|
const instance = useInstance();
|
|
|
|
|
|
|
|
const nodes: Array<Klass<LexicalNode>> = [
|
|
|
|
AutoLinkNode,
|
|
|
|
HashtagNode,
|
|
|
|
EmojiNode,
|
|
|
|
MentionNode,
|
|
|
|
];
|
|
|
|
|
|
|
|
if (features.richText) {
|
|
|
|
nodes.push(
|
|
|
|
QuoteNode,
|
|
|
|
CodeNode,
|
|
|
|
CodeHighlightNode,
|
|
|
|
LinkNode,
|
|
|
|
ListItemNode,
|
|
|
|
ListNode,
|
|
|
|
HorizontalRuleNode,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (instance.pleroma.getIn(['metadata', 'markup', 'allow_headings'])) nodes.push(HeadingNode);
|
2023-07-20 16:13:42 -07:00
|
|
|
if (instance.pleroma.getIn(['metadata', 'markup', 'allow_inline_images'])) nodes.push(ImageNode);
|
2023-05-22 09:15:43 -07:00
|
|
|
|
|
|
|
return nodes;
|
|
|
|
};
|
|
|
|
|
|
|
|
export { useNodes };
|