Only display HTML if supported

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2024-05-17 23:30:57 +02:00
parent c4d085c767
commit d30d276a0f
2 changed files with 15 additions and 9 deletions

View file

@ -4,7 +4,7 @@ import { defineMessages, useIntl } from 'react-intl';
import { changeComposeContentType } from 'soapbox/actions/compose';
import DropdownMenu from 'soapbox/components/dropdown-menu';
import { Button } from 'soapbox/components/ui';
import { useAppDispatch, useCompose } from 'soapbox/hooks';
import { useAppDispatch, useCompose, useInstance } from 'soapbox/hooks';
const messages = defineMessages({
content_type_plaintext: { id: 'preferences.options.content_type_plaintext', defaultMessage: 'Plain text' },
@ -21,6 +21,7 @@ interface IContentTypeButton {
const ContentTypeButton: React.FC<IContentTypeButton> = ({ composeId }) => {
const intl = useIntl();
const dispatch = useAppDispatch();
const instance = useInstance();
const contentType = useCompose(composeId).content_type;
@ -36,17 +37,21 @@ const ContentTypeButton: React.FC<IContentTypeButton> = ({ composeId }) => {
text: intl.formatMessage(messages.content_type_markdown),
value: 'text/markdown',
},
{
];
if (instance.pleroma.metadata.post_formats?.includes('text/html')) {
options.push({
icon: require('@tabler/icons/outline/html.svg'),
text: intl.formatMessage(messages.content_type_html),
value: 'text/html',
},
{
icon: require('@tabler/icons/outline/text-caption.svg'),
text: intl.formatMessage(messages.content_type_wysiwyg),
value: 'wysiwyg',
},
];
});
}
options.push({
icon: require('@tabler/icons/outline/text-caption.svg'),
text: intl.formatMessage(messages.content_type_wysiwyg),
value: 'wysiwyg',
});
const option = options.find(({ value }) => value === contentType);

View file

@ -114,6 +114,7 @@ const pleromaSchema = coerceObject({
.optional(),
enabled: z.boolean().catch(false),
}),
post_formats: z.string().array().optional().catch(undefined),
restrict_unauthenticated: coerceObject({
activities: coerceObject({
local: z.boolean().catch(false),