diff --git a/packages/pl-fe/src/features/preferences/index.tsx b/packages/pl-fe/src/features/preferences/index.tsx index b1df4b40a..b9509e6e7 100644 --- a/packages/pl-fe/src/features/preferences/index.tsx +++ b/packages/pl-fe/src/features/preferences/index.tsx @@ -99,6 +99,7 @@ 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_html: { id: 'preferences.options.content_type_html', defaultMessage: 'HTML' }, + content_type_wysiwyg: { id: 'preferences.options.content_type_wysiwyg', defaultMessage: 'WYSIWYG' }, brandColor: { id: 'preferences.options.brand_color', defaultMessage: 'Base color' }, }); @@ -161,6 +162,8 @@ const Preferences = () => { 'text/html': intl.formatMessage(messages.content_type_html), }).filter(([key]) => postFormats.includes(key)); + if (postFormats.includes('text/markdown')) options.push(['wysiwyg', intl.formatMessage(messages.content_type_wysiwyg)]); + if (options.length > 1) return Object.fromEntries(options); }, [settings.locale]); diff --git a/packages/pl-fe/src/reducers/compose.ts b/packages/pl-fe/src/reducers/compose.ts index 540a90014..5f3d997ae 100644 --- a/packages/pl-fe/src/reducers/compose.ts +++ b/packages/pl-fe/src/reducers/compose.ts @@ -313,7 +313,11 @@ const importAccount = (compose: Compose, account: CredentialAccount) => { const updateDefaultContentType = (compose: Compose, instance: Instance) => { const postFormats = instance.pleroma.metadata.post_formats; - compose.content_type = postFormats.includes(compose.content_type) ? compose.content_type : postFormats.includes('text/markdown') ? 'text/markdown' : postFormats[0]; + compose.content_type = postFormats.includes(compose.content_type) || (postFormats.includes('text/markdown') && compose.content_type === 'wysiwyg') + ? compose.content_type + : postFormats.includes('text/markdown') + ? 'text/markdown' + : postFormats[0]; }; const updateCompose = (state: State, key: string, updater: (compose: Compose) => void) => @@ -541,7 +545,10 @@ const compose = (state = initialState, action: ComposeAction | EventsAction | In compose.focusDate = new Date(); compose.caretPosition = null; compose.idempotencyKey = crypto.randomUUID(); - compose.content_type = action.contentType || 'text/plain'; + const contentType = action.contentType === 'text/markdown' && state.default.content_type === 'wysiwyg' + ? 'wysiwyg' + : action.contentType || 'text/plain'; + compose.content_type = contentType; compose.quote = action.status.quote_id; compose.group_id = action.status.group_id; compose.language = action.status.language; diff --git a/packages/pl-fe/src/schemas/pl-fe/settings.ts b/packages/pl-fe/src/schemas/pl-fe/settings.ts index a49d115e6..c8f53a30e 100644 --- a/packages/pl-fe/src/schemas/pl-fe/settings.ts +++ b/packages/pl-fe/src/schemas/pl-fe/settings.ts @@ -19,7 +19,7 @@ const settingsSchema = v.object({ deleteModal: v.fallback(v.boolean(), true), missingDescriptionModal: v.fallback(v.boolean(), true), defaultPrivacy: v.fallback(v.picklist(['public', 'unlisted', 'private', 'direct']), 'public'), - defaultContentType: v.fallback(v.picklist(['text/plain', 'text/markdown', 'text/html']), 'text/plain'), + defaultContentType: v.fallback(v.picklist(['text/plain', 'text/markdown', 'text/html', 'wysiwyg']), 'text/plain'), themeMode: v.fallback(v.picklist(['system', 'light', 'dark', 'black']), 'system'), locale: v.fallback( v.pipe(