Merge remote-tracking branch 'origin/develop' into add-images-to-polls
This commit is contained in:
commit
1329ca3578
11 changed files with 139 additions and 29 deletions
|
@ -43,6 +43,7 @@ export const COMPOSE_UNMOUNT = 'COMPOSE_UNMOUNT';
|
||||||
|
|
||||||
export const COMPOSE_SENSITIVITY_CHANGE = 'COMPOSE_SENSITIVITY_CHANGE';
|
export const COMPOSE_SENSITIVITY_CHANGE = 'COMPOSE_SENSITIVITY_CHANGE';
|
||||||
export const COMPOSE_SPOILERNESS_CHANGE = 'COMPOSE_SPOILERNESS_CHANGE';
|
export const COMPOSE_SPOILERNESS_CHANGE = 'COMPOSE_SPOILERNESS_CHANGE';
|
||||||
|
export const COMPOSE_TYPE_CHANGE = 'COMPOSE_TYPE_CHANGE';
|
||||||
export const COMPOSE_SPOILER_TEXT_CHANGE = 'COMPOSE_SPOILER_TEXT_CHANGE';
|
export const COMPOSE_SPOILER_TEXT_CHANGE = 'COMPOSE_SPOILER_TEXT_CHANGE';
|
||||||
export const COMPOSE_VISIBILITY_CHANGE = 'COMPOSE_VISIBILITY_CHANGE';
|
export const COMPOSE_VISIBILITY_CHANGE = 'COMPOSE_VISIBILITY_CHANGE';
|
||||||
export const COMPOSE_LISTABILITY_CHANGE = 'COMPOSE_LISTABILITY_CHANGE';
|
export const COMPOSE_LISTABILITY_CHANGE = 'COMPOSE_LISTABILITY_CHANGE';
|
||||||
|
@ -175,6 +176,7 @@ export function submitCompose(routerHistory, group) {
|
||||||
sensitive: getState().getIn(['compose', 'sensitive']),
|
sensitive: getState().getIn(['compose', 'sensitive']),
|
||||||
spoiler_text: getState().getIn(['compose', 'spoiler_text'], ''),
|
spoiler_text: getState().getIn(['compose', 'spoiler_text'], ''),
|
||||||
visibility: getState().getIn(['compose', 'privacy']),
|
visibility: getState().getIn(['compose', 'privacy']),
|
||||||
|
content_type: getState().getIn(['compose', 'content_type']),
|
||||||
poll: getState().getIn(['compose', 'poll'], null),
|
poll: getState().getIn(['compose', 'poll'], null),
|
||||||
group_id: group ? group.get('id') : null,
|
group_id: group ? group.get('id') : null,
|
||||||
}, {
|
}, {
|
||||||
|
@ -490,6 +492,13 @@ export function changeComposeSpoilerness() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function changeComposeContentType(value) {
|
||||||
|
return {
|
||||||
|
type: COMPOSE_TYPE_CHANGE,
|
||||||
|
value,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
export function changeComposeSpoilerText(text) {
|
export function changeComposeSpoilerText(text) {
|
||||||
return {
|
return {
|
||||||
type: COMPOSE_SPOILER_TEXT_CHANGE,
|
type: COMPOSE_SPOILER_TEXT_CHANGE,
|
||||||
|
|
|
@ -11,6 +11,7 @@ import PollButtonContainer from '../containers/poll_button_container';
|
||||||
import UploadButtonContainer from '../containers/upload_button_container';
|
import UploadButtonContainer from '../containers/upload_button_container';
|
||||||
import { defineMessages, injectIntl } from 'react-intl';
|
import { defineMessages, injectIntl } from 'react-intl';
|
||||||
import SpoilerButtonContainer from '../containers/spoiler_button_container';
|
import SpoilerButtonContainer from '../containers/spoiler_button_container';
|
||||||
|
import MarkdownButtonContainer from '../containers/markdown_button_container';
|
||||||
import PrivacyDropdownContainer from '../containers/privacy_dropdown_container';
|
import PrivacyDropdownContainer from '../containers/privacy_dropdown_container';
|
||||||
import EmojiPickerDropdown from '../containers/emoji_picker_dropdown_container';
|
import EmojiPickerDropdown from '../containers/emoji_picker_dropdown_container';
|
||||||
import PollFormContainer from '../containers/poll_form_container';
|
import PollFormContainer from '../containers/poll_form_container';
|
||||||
|
@ -303,6 +304,7 @@ class ComposeForm extends ImmutablePureComponent {
|
||||||
<PollButtonContainer />
|
<PollButtonContainer />
|
||||||
<PrivacyDropdownContainer />
|
<PrivacyDropdownContainer />
|
||||||
<SpoilerButtonContainer />
|
<SpoilerButtonContainer />
|
||||||
|
<MarkdownButtonContainer />
|
||||||
</div>
|
</div>
|
||||||
{maxTootChars && <div className='character-counter__wrapper'><CharacterCounter max={maxTootChars} text={text} /></div>}
|
{maxTootChars && <div className='character-counter__wrapper'><CharacterCounter max={maxTootChars} text={text} /></div>}
|
||||||
<div className='compose-form__publish'>
|
<div className='compose-form__publish'>
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
import TextIconButton from '../components/text_icon_button';
|
||||||
|
import { changeComposeContentType } from '../../../actions/compose';
|
||||||
|
import { injectIntl, defineMessages } from 'react-intl';
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
marked: { id: 'compose_form.markdown.marked', defaultMessage: 'Post markdown enabled' },
|
||||||
|
unmarked: { id: 'compose_form.markdown.unmarked', defaultMessage: 'Post markdown disabled' },
|
||||||
|
});
|
||||||
|
|
||||||
|
const mapStateToProps = (state, { intl }) => ({
|
||||||
|
label: 'MD',
|
||||||
|
title: intl.formatMessage(state.getIn(['compose', 'content_type']) === 'text/markdown' ? messages.marked : messages.unmarked),
|
||||||
|
active: state.getIn(['compose', 'content_type']) === 'text/markdown',
|
||||||
|
ariaControls: 'markdown-input',
|
||||||
|
});
|
||||||
|
|
||||||
|
const mapDispatchToProps = dispatch => ({
|
||||||
|
|
||||||
|
onClick() {
|
||||||
|
dispatch(changeComposeContentType(this.active ? 'text/plain' : 'text/markdown'));
|
||||||
|
},
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(TextIconButton));
|
|
@ -12,6 +12,7 @@ const messages = defineMessages({
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
active: state.getIn(['compose', 'sensitive']),
|
active: state.getIn(['compose', 'sensitive']),
|
||||||
|
disabled: state.getIn(['compose', 'spoiler']),
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
const mapDispatchToProps = dispatch => ({
|
||||||
|
@ -26,12 +27,13 @@ class SensitiveButton extends React.PureComponent {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
active: PropTypes.bool,
|
active: PropTypes.bool,
|
||||||
|
disabled: PropTypes.bool,
|
||||||
onClick: PropTypes.func.isRequired,
|
onClick: PropTypes.func.isRequired,
|
||||||
intl: PropTypes.object.isRequired,
|
intl: PropTypes.object.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { active, onClick, intl } = this.props;
|
const { active, disabled, onClick, intl } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='compose-form__sensitive-button'>
|
<div className='compose-form__sensitive-button'>
|
||||||
|
@ -41,6 +43,7 @@ class SensitiveButton extends React.PureComponent {
|
||||||
type='checkbox'
|
type='checkbox'
|
||||||
checked={active}
|
checked={active}
|
||||||
onChange={onClick}
|
onChange={onClick}
|
||||||
|
disabled={disabled}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<span className={classNames('checkbox', { active })} />
|
<span className={classNames('checkbox', { active })} />
|
||||||
|
|
|
@ -32,6 +32,7 @@ describe('compose reducer', () => {
|
||||||
default_sensitive: false,
|
default_sensitive: false,
|
||||||
idempotencyKey: null,
|
idempotencyKey: null,
|
||||||
tagHistory: [],
|
tagHistory: [],
|
||||||
|
content_type: 'text/markdown',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -168,8 +169,18 @@ describe('compose reducer', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should handle COMPOSE_SENSITIVITY_CHANGE on Mark Sensitive click, don\'t toggle if spoiler active', () => {
|
||||||
|
const state = ImmutableMap({ spoiler: true, sensitive: true, idempotencyKey: null });
|
||||||
|
const action = {
|
||||||
|
type: actions.COMPOSE_SENSITIVITY_CHANGE,
|
||||||
|
};
|
||||||
|
expect(reducer(state, action).toJS()).toMatchObject({
|
||||||
|
sensitive: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should handle COMPOSE_SENSITIVITY_CHANGE on Mark Sensitive click, toggle if spoiler inactive', () => {
|
it('should handle COMPOSE_SENSITIVITY_CHANGE on Mark Sensitive click, toggle if spoiler inactive', () => {
|
||||||
const state = ImmutableMap({ sensitive: true });
|
const state = ImmutableMap({ spoiler: false, sensitive: true });
|
||||||
const action = {
|
const action = {
|
||||||
type: actions.COMPOSE_SENSITIVITY_CHANGE,
|
type: actions.COMPOSE_SENSITIVITY_CHANGE,
|
||||||
};
|
};
|
||||||
|
@ -777,4 +788,11 @@ describe('compose reducer', () => {
|
||||||
// });
|
// });
|
||||||
// });
|
// });
|
||||||
|
|
||||||
|
it('sets the post content-type', () => {
|
||||||
|
const action = {
|
||||||
|
type: actions.COMPOSE_TYPE_CHANGE,
|
||||||
|
value: 'text/plain',
|
||||||
|
};
|
||||||
|
expect(reducer(undefined, action).toJS()).toMatchObject({ content_type: 'text/plain' });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,6 +21,7 @@ import {
|
||||||
COMPOSE_TAG_HISTORY_UPDATE,
|
COMPOSE_TAG_HISTORY_UPDATE,
|
||||||
COMPOSE_SENSITIVITY_CHANGE,
|
COMPOSE_SENSITIVITY_CHANGE,
|
||||||
COMPOSE_SPOILERNESS_CHANGE,
|
COMPOSE_SPOILERNESS_CHANGE,
|
||||||
|
COMPOSE_TYPE_CHANGE,
|
||||||
COMPOSE_SPOILER_TEXT_CHANGE,
|
COMPOSE_SPOILER_TEXT_CHANGE,
|
||||||
COMPOSE_VISIBILITY_CHANGE,
|
COMPOSE_VISIBILITY_CHANGE,
|
||||||
COMPOSE_COMPOSING_CHANGE,
|
COMPOSE_COMPOSING_CHANGE,
|
||||||
|
@ -50,6 +51,7 @@ const initialState = ImmutableMap({
|
||||||
sensitive: false,
|
sensitive: false,
|
||||||
spoiler: false,
|
spoiler: false,
|
||||||
spoiler_text: '',
|
spoiler_text: '',
|
||||||
|
content_type: 'text/markdown',
|
||||||
privacy: null,
|
privacy: null,
|
||||||
text: '',
|
text: '',
|
||||||
focusDate: null,
|
focusDate: null,
|
||||||
|
@ -94,6 +96,7 @@ function clearAll(state) {
|
||||||
map.set('text', '');
|
map.set('text', '');
|
||||||
map.set('spoiler', false);
|
map.set('spoiler', false);
|
||||||
map.set('spoiler_text', '');
|
map.set('spoiler_text', '');
|
||||||
|
map.set('content_type', 'text/markdown');
|
||||||
map.set('is_submitting', false);
|
map.set('is_submitting', false);
|
||||||
map.set('is_changing_upload', false);
|
map.set('is_changing_upload', false);
|
||||||
map.set('in_reply_to', null);
|
map.set('in_reply_to', null);
|
||||||
|
@ -114,7 +117,7 @@ function appendMedia(state, media) {
|
||||||
map.set('resetFileKey', Math.floor((Math.random() * 0x10000)));
|
map.set('resetFileKey', Math.floor((Math.random() * 0x10000)));
|
||||||
map.set('idempotencyKey', uuid());
|
map.set('idempotencyKey', uuid());
|
||||||
|
|
||||||
if (prevSize === 0 && state.get('default_sensitive')) {
|
if (prevSize === 0 && (state.get('default_sensitive') || state.get('spoiler'))) {
|
||||||
map.set('sensitive', true);
|
map.set('sensitive', true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -211,7 +214,15 @@ export default function compose(state = initialState, action) {
|
||||||
.set('is_composing', false);
|
.set('is_composing', false);
|
||||||
case COMPOSE_SENSITIVITY_CHANGE:
|
case COMPOSE_SENSITIVITY_CHANGE:
|
||||||
return state.withMutations(map => {
|
return state.withMutations(map => {
|
||||||
|
if (!state.get('spoiler')) {
|
||||||
map.set('sensitive', !state.get('sensitive'));
|
map.set('sensitive', !state.get('sensitive'));
|
||||||
|
}
|
||||||
|
|
||||||
|
map.set('idempotencyKey', uuid());
|
||||||
|
});
|
||||||
|
case COMPOSE_TYPE_CHANGE:
|
||||||
|
return state.withMutations(map => {
|
||||||
|
map.set('content_type', action.value);
|
||||||
map.set('idempotencyKey', uuid());
|
map.set('idempotencyKey', uuid());
|
||||||
});
|
});
|
||||||
case COMPOSE_SPOILERNESS_CHANGE:
|
case COMPOSE_SPOILERNESS_CHANGE:
|
||||||
|
@ -219,6 +230,10 @@ export default function compose(state = initialState, action) {
|
||||||
map.set('spoiler_text', '');
|
map.set('spoiler_text', '');
|
||||||
map.set('spoiler', !state.get('spoiler'));
|
map.set('spoiler', !state.get('spoiler'));
|
||||||
map.set('idempotencyKey', uuid());
|
map.set('idempotencyKey', uuid());
|
||||||
|
|
||||||
|
if (!state.get('sensitive') && state.get('media_attachments').size >= 1) {
|
||||||
|
map.set('sensitive', true);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
case COMPOSE_SPOILER_TEXT_CHANGE:
|
case COMPOSE_SPOILER_TEXT_CHANGE:
|
||||||
return state
|
return state
|
||||||
|
@ -242,6 +257,7 @@ export default function compose(state = initialState, action) {
|
||||||
map.set('focusDate', new Date());
|
map.set('focusDate', new Date());
|
||||||
map.set('caretPosition', null);
|
map.set('caretPosition', null);
|
||||||
map.set('idempotencyKey', uuid());
|
map.set('idempotencyKey', uuid());
|
||||||
|
map.set('content_type', 'text/markdown');
|
||||||
|
|
||||||
if (action.status.get('spoiler_text', '').length > 0) {
|
if (action.status.get('spoiler_text', '').length > 0) {
|
||||||
map.set('spoiler', true);
|
map.set('spoiler', true);
|
||||||
|
@ -325,6 +341,7 @@ export default function compose(state = initialState, action) {
|
||||||
map.set('focusDate', new Date());
|
map.set('focusDate', new Date());
|
||||||
map.set('caretPosition', null);
|
map.set('caretPosition', null);
|
||||||
map.set('idempotencyKey', uuid());
|
map.set('idempotencyKey', uuid());
|
||||||
|
map.set('content_type', 'text/markdown');
|
||||||
|
|
||||||
if (action.status.get('spoiler_text').length > 0) {
|
if (action.status.get('spoiler_text').length > 0) {
|
||||||
map.set('spoiler', true);
|
map.set('spoiler', true);
|
||||||
|
|
|
@ -173,11 +173,11 @@
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overlow: hidden;
|
overlow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
background: hsl( var(--brand-color_h), var(--brand-color_s), 20% );
|
background: hsl(var(--brand-color_h), var(--brand-color_s), 20%);
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
|
|
||||||
&__label {
|
&__label {
|
||||||
color: white;
|
color: #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
|
|
|
@ -1,3 +1,38 @@
|
||||||
|
.status__content {
|
||||||
|
p,
|
||||||
|
li {
|
||||||
|
strong {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p,
|
||||||
|
li {
|
||||||
|
em {
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ul,
|
||||||
|
ol,
|
||||||
|
blockquote {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
margin-left: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul {
|
||||||
|
list-style: disc inside none;
|
||||||
|
}
|
||||||
|
|
||||||
|
ol {
|
||||||
|
list-style: decimal inside none;
|
||||||
|
}
|
||||||
|
|
||||||
|
blockquote p {
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.status__content--with-action {
|
.status__content--with-action {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue