From 5b07c47f68f5c11933cb92549387f521fee21c0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Wed, 27 Nov 2024 16:52:47 +0100 Subject: [PATCH] pl-fe: allow writing mfm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- .../compose/components/content-type-button.tsx | 12 ++++++++++-- packages/pl-fe/src/features/preferences/index.tsx | 2 +- packages/pl-fe/src/reducers/compose.ts | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/pl-fe/src/features/compose/components/content-type-button.tsx b/packages/pl-fe/src/features/compose/components/content-type-button.tsx index 6bc56fd81..e59fbad0e 100644 --- a/packages/pl-fe/src/features/compose/components/content-type-button.tsx +++ b/packages/pl-fe/src/features/compose/components/content-type-button.tsx @@ -11,6 +11,7 @@ import { useInstance } from 'pl-fe/hooks/use-instance'; const messages = defineMessages({ content_type_plaintext: { id: 'preferences.options.content_type_plaintext', defaultMessage: 'Plain text' }, content_type_markdown: { id: 'preferences.options.content_type_markdown', defaultMessage: 'Markdown' }, + content_type_mfm: { id: 'preferences.options.content_type_mfm', defaultMessage: 'MFM' }, content_type_html: { id: 'preferences.options.content_type_html', defaultMessage: 'HTML' }, content_type_wysiwyg: { id: 'preferences.options.content_type_wysiwyg', defaultMessage: 'WYSIWYG' }, change_content_type: { id: 'compose_form.content_type.change', defaultMessage: 'Change content type' }, @@ -29,7 +30,7 @@ const ContentTypeButton: React.FC = ({ composeId }) => { const handleChange = (contentType: string) => () => dispatch(changeComposeContentType(composeId, contentType)); - const postFormats = instance.pleroma.metadata.post_formats; + const postFormats = instance.configuration.statuses.supported_mime_types; const options = []; @@ -49,6 +50,14 @@ const ContentTypeButton: React.FC = ({ composeId }) => { }); } + if (postFormats.includes('text/x.misskeymarkdown')) { + options.push({ + icon: require('@tabler/icons/outline/sparkles.svg'), + text: intl.formatMessage(messages.content_type_mfm), + value: 'text/x.misskeymarkdown', + }); + } + if (postFormats.includes('text/html')) { options.push({ icon: require('@tabler/icons/outline/html.svg'), @@ -86,7 +95,6 @@ const ContentTypeButton: React.FC = ({ composeId }) => { /> ); - }; export { ContentTypeButton as default }; diff --git a/packages/pl-fe/src/features/preferences/index.tsx b/packages/pl-fe/src/features/preferences/index.tsx index 306cbcbb1..23517cc2e 100644 --- a/packages/pl-fe/src/features/preferences/index.tsx +++ b/packages/pl-fe/src/features/preferences/index.tsx @@ -125,7 +125,7 @@ const Preferences = () => { }), [settings.locale]); const defaultContentTypeOptions = React.useMemo(() => { - const postFormats = instance.pleroma.metadata.post_formats; + const postFormats = instance.configuration.statuses.supported_mime_types; const options = Object.entries({ 'text/plain': intl.formatMessage(messages.content_type_plaintext), diff --git a/packages/pl-fe/src/reducers/compose.ts b/packages/pl-fe/src/reducers/compose.ts index d68a931bb..a4b39a481 100644 --- a/packages/pl-fe/src/reducers/compose.ts +++ b/packages/pl-fe/src/reducers/compose.ts @@ -311,7 +311,7 @@ const importAccount = (compose: Compose, account: CredentialAccount) => { // }; const updateDefaultContentType = (compose: Compose, instance: Instance) => { - const postFormats = instance.pleroma.metadata.post_formats; + const postFormats = instance.configuration.statuses.supported_mime_types; compose.content_type = postFormats.includes(compose.content_type) ? compose.content_type : postFormats.includes('text/markdown') ? 'text/markdown' : postFormats[0]; };