Merge commit 'fac734b6a8' into kb_migration

This commit is contained in:
KMY 2023-04-13 18:57:03 +09:00
commit 5a661415e2
22 changed files with 121 additions and 14 deletions

View file

@ -51,6 +51,7 @@ export const COMPOSE_UNMOUNT = 'COMPOSE_UNMOUNT';
export const COMPOSE_SENSITIVITY_CHANGE = 'COMPOSE_SENSITIVITY_CHANGE';
export const COMPOSE_SPOILERNESS_CHANGE = 'COMPOSE_SPOILERNESS_CHANGE';
export const COMPOSE_SPOILER_TEXT_CHANGE = 'COMPOSE_SPOILER_TEXT_CHANGE';
export const COMPOSE_MARKDOWN_CHANGE = 'COMPOSE_MARKDOWN_CHANGE';
export const COMPOSE_VISIBILITY_CHANGE = 'COMPOSE_VISIBILITY_CHANGE';
export const COMPOSE_SEARCHABILITY_CHANGE= 'COMPOSE_SEARCHABILITY_CHANGE';
export const COMPOSE_COMPOSING_CHANGE = 'COMPOSE_COMPOSING_CHANGE';
@ -191,6 +192,7 @@ export function submitCompose(routerHistory) {
media_attributes,
sensitive: getState().getIn(['compose', 'sensitive']),
spoiler_text: getState().getIn(['compose', 'spoiler']) ? getState().getIn(['compose', 'spoiler_text'], '') : '',
markdown: getState().getIn(['compose', 'markdown']),
visibility: getState().getIn(['compose', 'privacy']),
searchability: getState().getIn(['compose', 'searchability']),
poll: getState().getIn(['compose', 'poll'], null),
@ -724,6 +726,12 @@ export function changeComposeSpoilerText(text) {
};
}
export function changeComposeMarkdown() {
return {
type: COMPOSE_MARKDOWN_CHANGE,
};
}
export function changeComposeVisibility(value) {
return {
type: COMPOSE_VISIBILITY_CHANGE,

View file

@ -18,6 +18,7 @@ import PollFormContainer from '../containers/poll_form_container';
import UploadFormContainer from '../containers/upload_form_container';
import WarningContainer from '../containers/warning_container';
import LanguageDropdown from '../containers/language_dropdown_container';
import MarkdownButtonContainer from '../containers/markdown_button_container';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { length } from 'stringz';
import { countableText } from '../util/counter';
@ -288,6 +289,7 @@ class ComposeForm extends ImmutablePureComponent {
<SearchabilityDropdownContainer disabled={this.props.isEditing} />
<SpoilerButtonContainer />
<LanguageDropdown />
<MarkdownButtonContainer />
</div>
<div className='character-counter__wrapper'>

View file

@ -17,6 +17,7 @@ const mapStateToProps = state => ({
suggestions: state.getIn(['compose', 'suggestions']),
spoiler: state.getIn(['compose', 'spoiler']),
spoilerText: state.getIn(['compose', 'spoiler_text']),
markdown: state.getIn(['compose', 'markdown']),
privacy: state.getIn(['compose', 'privacy']),
focusDate: state.getIn(['compose', 'focusDate']),
caretPosition: state.getIn(['compose', 'caretPosition']),

View file

@ -0,0 +1,26 @@
import { connect } from 'react-redux';
import TextIconButton from '../components/text_icon_button';
import { changeComposeMarkdown } from '../../../actions/compose';
import { injectIntl, defineMessages } from 'react-intl';
const messages = defineMessages({
marked: { id: 'compose_form.markdown.marked', defaultMessage: 'Markdown is enabled' },
unmarked: { id: 'compose_form.markdown.unmarked', defaultMessage: 'Markdown is disabled' },
});
const mapStateToProps = (state, { intl }) => ({
label: 'MD',
title: intl.formatMessage(state.getIn(['compose', 'markdown']) ? messages.marked : messages.unmarked),
active: state.getIn(['compose', 'markdown']),
ariaControls: 'cw-markdown-input',
});
const mapDispatchToProps = dispatch => ({
onClick () {
dispatch(changeComposeMarkdown());
},
});
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(TextIconButton));

View file

@ -28,6 +28,7 @@ import {
COMPOSE_SENSITIVITY_CHANGE,
COMPOSE_SPOILERNESS_CHANGE,
COMPOSE_SPOILER_TEXT_CHANGE,
COMPOSE_MARKDOWN_CHANGE,
COMPOSE_VISIBILITY_CHANGE,
COMPOSE_LANGUAGE_CHANGE,
COMPOSE_COMPOSING_CHANGE,
@ -62,6 +63,7 @@ const initialState = ImmutableMap({
sensitive: false,
spoiler: false,
spoiler_text: '',
markdown: false,
privacy: null,
searchability: null,
id: null,
@ -120,6 +122,7 @@ function clearAll(state) {
map.set('text', '');
map.set('spoiler', false);
map.set('spoiler_text', '');
map.set('markdown', false);
map.set('is_submitting', false);
map.set('is_changing_upload', false);
map.set('in_reply_to', null);
@ -328,6 +331,11 @@ export default function compose(state = initialState, action) {
return state
.set('spoiler_text', action.text)
.set('idempotencyKey', uuid());
case COMPOSE_MARKDOWN_CHANGE:
return state.withMutations(map => {
map.set('markdown', !state.get('markdown'));
map.set('idempotencyKey', uuid());
});
case COMPOSE_VISIBILITY_CHANGE:
return state
.set('privacy', action.value)
@ -488,6 +496,7 @@ export default function compose(state = initialState, action) {
map.set('idempotencyKey', uuid());
map.set('sensitive', action.status.get('sensitive'));
map.set('language', action.status.get('language'));
map.set('markdown', action.status.get('markdown'));
map.set('id', null);
if (action.status.get('spoiler_text').length > 0) {
@ -518,6 +527,7 @@ export default function compose(state = initialState, action) {
map.set('idempotencyKey', uuid());
map.set('sensitive', action.status.get('sensitive'));
map.set('language', action.status.get('language'));
map.set('markdown', action.status.get('markdown'));
if (action.spoiler_text.length > 0) {
map.set('spoiler', true);