about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/features/compose/components
diff options
context:
space:
mode:
authorReverite <github@reverite.sh>2019-05-21 20:48:57 -0700
committerReverite <github@reverite.sh>2019-05-21 20:48:57 -0700
commitd873e4f3d5878a2b2800758cbe3b9c870c228d51 (patch)
tree23a3a373699381d4bd4f629136b9c82de5df96a3 /app/javascript/flavours/glitch/features/compose/components
parent4cea89bf2e9ce7f73fccfc637191b1e039ad25ee (diff)
parent2332b3f146b0d879daba8a99bd35c8bf425edea3 (diff)
Merge branch 'glitch' into production
Diffstat (limited to 'app/javascript/flavours/glitch/features/compose/components')
-rw-r--r--app/javascript/flavours/glitch/features/compose/components/options.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/features/compose/components/options.js b/app/javascript/flavours/glitch/features/compose/components/options.js
index ee9730961..0c94f5514 100644
--- a/app/javascript/flavours/glitch/features/compose/components/options.js
+++ b/app/javascript/flavours/glitch/features/compose/components/options.js
@@ -29,6 +29,10 @@ const messages = defineMessages({
     defaultMessage: 'Adjust status privacy',
     id: 'privacy.change',
   },
+  content_type: {
+    defaultMessage: 'Content type',
+    id: 'content-type.change',
+  },
   direct_long: {
     defaultMessage: 'Post to mentioned users only',
     id: 'privacy.direct.long',
@@ -41,6 +45,10 @@ const messages = defineMessages({
     defaultMessage: 'Draw something',
     id: 'compose.attach.doodle',
   },
+  html: {
+    defaultMessage: 'HTML',
+    id: 'compose.content-type.html',
+  },
   local_only_long: {
     defaultMessage: 'Do not post to other instances',
     id: 'advanced_options.local-only.long',
@@ -49,6 +57,14 @@ const messages = defineMessages({
     defaultMessage: 'Local-only',
     id: 'advanced_options.local-only.short',
   },
+  markdown: {
+    defaultMessage: 'Markdown',
+    id: 'compose.content-type.markdown',
+  },
+  plain: {
+    defaultMessage: 'Plain text',
+    id: 'compose.content-type.plain',
+  },
   private_long: {
     defaultMessage: 'Post to followers only',
     id: 'privacy.private.long',
@@ -113,6 +129,7 @@ class ComposerOptions extends ImmutablePureComponent {
     intl: PropTypes.object.isRequired,
     onChangeAdvancedOption: PropTypes.func,
     onChangeVisibility: PropTypes.func,
+    onChangeContentType: PropTypes.func,
     onTogglePoll: PropTypes.func,
     onDoodleOpen: PropTypes.func,
     onModalClose: PropTypes.func,
@@ -120,8 +137,10 @@ class ComposerOptions extends ImmutablePureComponent {
     onToggleSpoiler: PropTypes.func,
     onUpload: PropTypes.func,
     privacy: PropTypes.string,
+    contentType: PropTypes.string,
     resetFileKey: PropTypes.number,
     spoiler: PropTypes.bool,
+    showContentTypeChoice: PropTypes.bool,
   };
 
   //  Handles file selection.
@@ -162,6 +181,7 @@ class ComposerOptions extends ImmutablePureComponent {
     const {
       acceptContentTypes,
       advancedOptions,
+      contentType,
       disabled,
       allowMedia,
       hasMedia,
@@ -169,6 +189,7 @@ class ComposerOptions extends ImmutablePureComponent {
       hasPoll,
       intl,
       onChangeAdvancedOption,
+      onChangeContentType,
       onChangeVisibility,
       onTogglePoll,
       onModalClose,
@@ -177,6 +198,7 @@ class ComposerOptions extends ImmutablePureComponent {
       privacy,
       resetFileKey,
       spoiler,
+      showContentTypeChoice,
     } = this.props;
 
     //  We predefine our privacy items so that we can easily pick the
@@ -208,6 +230,24 @@ class ComposerOptions extends ImmutablePureComponent {
       },
     };
 
+    const contentTypeItems = {
+      plain: {
+        icon: 'align-left',
+        name: 'text/plain',
+        text: <FormattedMessage {...messages.plain} />,
+      },
+      html: {
+        icon: 'code',
+        name: 'text/html',
+        text: <FormattedMessage {...messages.html} />,
+      },
+      markdown: {
+        icon: 'arrow-circle-down',
+        name: 'text/markdown',
+        text: <FormattedMessage {...messages.markdown} />,
+      },
+    };
+
     //  The result.
     return (
       <div className='composer--options'>
@@ -272,6 +312,22 @@ class ComposerOptions extends ImmutablePureComponent {
           title={intl.formatMessage(messages.change_privacy)}
           value={privacy}
         />
+        {showContentTypeChoice && (
+          <Dropdown
+            disabled={disabled}
+            icon={(contentTypeItems[contentType.split('/')[1]] || {}).icon}
+            items={[
+              contentTypeItems.plain,
+              contentTypeItems.html,
+              contentTypeItems.markdown,
+            ]}
+            onChange={onChangeContentType}
+            onModalClose={onModalClose}
+            onModalOpen={onModalOpen}
+            title={intl.formatMessage(messages.content_type)}
+            value={contentType}
+          />
+        )}
         {onToggleSpoiler && (
           <TextIconButton
             active={spoiler}