2019-06-28 09:27:55 +02:00
|
|
|
// @flow
|
2020-07-24 16:13:42 +02:00
|
|
|
import { SIMPLE_SITE } from 'config';
|
|
|
|
import { FF_MAX_CHARS_IN_DESCRIPTION } from 'constants/form-field';
|
2019-06-28 09:27:55 +02:00
|
|
|
import React from 'react';
|
|
|
|
import { FormField } from 'component/common/form';
|
2019-09-27 20:56:15 +02:00
|
|
|
import usePersistedState from 'effects/use-persisted-state';
|
|
|
|
import Card from 'component/common/card';
|
2019-06-28 09:27:55 +02:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
description: ?string,
|
|
|
|
disabled: boolean,
|
|
|
|
updatePublishForm: ({}) => void,
|
|
|
|
};
|
|
|
|
|
2020-07-29 22:30:26 +02:00
|
|
|
function PublishDescription(props: Props) {
|
2020-07-28 01:12:59 +02:00
|
|
|
const { description, updatePublishForm, disabled } = props;
|
2019-06-28 09:27:55 +02:00
|
|
|
const [advancedEditor, setAdvancedEditor] = usePersistedState('publish-form-description-mode', false);
|
|
|
|
function toggleMarkdown() {
|
|
|
|
setAdvancedEditor(!advancedEditor);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2022-06-03 15:28:12 +02:00
|
|
|
<>
|
|
|
|
{disabled && <h2 className="card__title card__title-disabled">{__('Description')}</h2>}
|
|
|
|
{!disabled && <h2 className="card__title">{__('Description')}</h2>}
|
|
|
|
<Card
|
|
|
|
className="card--description"
|
|
|
|
actions={
|
|
|
|
<FormField
|
|
|
|
type={!SIMPLE_SITE && advancedEditor ? 'markdown' : 'textarea'}
|
|
|
|
name="content_description"
|
|
|
|
placeholder={__(
|
|
|
|
'What is your content about? Use this space to include any other relevant details you may like to share about your content and channel.'
|
|
|
|
)}
|
|
|
|
value={description}
|
|
|
|
disabled={disabled}
|
|
|
|
onChange={(value) =>
|
|
|
|
updatePublishForm({ description: !SIMPLE_SITE && advancedEditor ? value : value.target.value })
|
|
|
|
}
|
|
|
|
quickActionLabel={!SIMPLE_SITE && (advancedEditor ? __('Simple Editor') : __('Advanced Editor'))}
|
|
|
|
quickActionHandler={toggleMarkdown}
|
|
|
|
textAreaMaxLength={FF_MAX_CHARS_IN_DESCRIPTION}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</>
|
2019-06-28 09:27:55 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-07-29 22:30:26 +02:00
|
|
|
export default PublishDescription;
|