diff --git a/src/components/Views/Edit.tsx b/src/components/Views/Edit.tsx
index 4658f545..8461eaa2 100644
--- a/src/components/Views/Edit.tsx
+++ b/src/components/Views/Edit.tsx
@@ -21,13 +21,13 @@ import deepEqual from 'fast-deep-equal'
import { AutoSaveNotice } from '../Editor/AutoSaveNotice'
import { PublishSettings } from './PublishSettings'
import { createStore } from 'solid-js/store'
+import SimplifiedEditor from '../Editor/SimplifiedEditor'
type Props = {
shout: Shout
}
export const MAX_HEADER_LIMIT = 100
-export const MAX_LEAD_LIMIT = 400
export const EMPTY_TOPIC: Topic = {
id: -1,
slug: ''
@@ -64,6 +64,8 @@ export const EditView = (props: Props) => {
slug: props.shout.slug,
shoutId: props.shout.id,
title: props.shout.title,
+ lead: props.shout.lead,
+ description: props.shout.description,
subtitle: props.shout.subtitle,
selectedTopics: shoutTopics,
mainTopic: shoutTopics.find((topic) => topic.slug === props.shout.mainTopic) || EMPTY_TOPIC,
@@ -75,7 +77,6 @@ export const EditView = (props: Props) => {
}
const subtitleInput: { current: HTMLTextAreaElement } = { current: null }
- const leadInput: { current: HTMLTextAreaElement } = { current: null }
const [prevForm, setPrevForm] = createStore(clone(form))
const [saving, setSaving] = createSignal(false)
@@ -226,7 +227,6 @@ export const EditView = (props: Props) => {
}
const showLeadInput = () => {
setIsLeadVisible(true)
- leadInput.current.focus()
}
return (
@@ -320,16 +320,13 @@ export const EditView = (props: Props) => {
/>
- {
- leadInput.current = el
- }}
- allowEnterKey={true}
- value={(value) => setForm('lead', value)}
- class={styles.leadInput}
- placeholder={t('Description')}
- initialValue={form.subtitle}
- maxLength={MAX_LEAD_LIMIT}
+ setForm('lead', value)}
/>
diff --git a/src/components/Views/PublishSettings/PublishSettings.tsx b/src/components/Views/PublishSettings/PublishSettings.tsx
index 287b67f5..baa4e5ce 100644
--- a/src/components/Views/PublishSettings/PublishSettings.tsx
+++ b/src/components/Views/PublishSettings/PublishSettings.tsx
@@ -10,7 +10,7 @@ import { useLocalize } from '../../../context/localize'
import { Modal } from '../../Nav/Modal'
import { Topic } from '../../../graphql/types.gen'
import { apiClient } from '../../../utils/apiClient'
-import { EMPTY_TOPIC, MAX_LEAD_LIMIT } from '../Edit'
+import { EMPTY_TOPIC } from '../Edit'
import { useSession } from '../../../context/session'
import { Icon } from '../../_shared/Icon'
import stylesBeside from '../../Feed/Beside.module.scss'
@@ -19,6 +19,7 @@ import { router } from '../../../stores/router'
import { GrowingTextarea } from '../../_shared/GrowingTextarea'
import { createStore } from 'solid-js/store'
import { UploadedFile } from '../../../pages/types'
+import SimplifiedEditor, { MAX_DESCRIPTION_LIMIT } from '../../Editor/SimplifiedEditor'
type Props = {
shoutId: number
@@ -35,12 +36,12 @@ export const PublishSettings = (props: Props) => {
const { t } = useLocalize()
const { user } = useSession()
- const composeLead = () => {
- if (!props.form.lead) {
+ const composeDescription = () => {
+ if (!props.form.description) {
const leadText = props.form.body.replaceAll(/<\/?[^>]+(>|$)/gi, ' ')
- return shorten(leadText, MAX_LEAD_LIMIT).trim()
+ return shorten(leadText, MAX_DESCRIPTION_LIMIT).trim()
}
- return props.form.lead
+ return props.form.description
}
const initialData: Partial = {
@@ -49,7 +50,7 @@ export const PublishSettings = (props: Props) => {
slug: props.form.slug,
title: props.form.title,
subtitle: props.form.subtitle,
- lead: composeLead()
+ description: composeDescription()
}
const {
@@ -183,15 +184,15 @@ export const PublishSettings = (props: Props) => {
allowEnterKey={false}
maxLength={100}
/>
- setSettingsForm('lead', value)}
- allowEnterKey={false}
- maxLength={MAX_LEAD_LIMIT}
+ label={t('Description')}
+ initialContent={composeDescription()}
+ onChange={(value) => setForm('description', value)}
+ maxLength={MAX_DESCRIPTION_LIMIT}
/>
diff --git a/src/components/_shared/GrowingTextarea/GrowingTextarea.module.scss b/src/components/_shared/GrowingTextarea/GrowingTextarea.module.scss
index 967f3d1d..db819c9e 100644
--- a/src/components/_shared/GrowingTextarea/GrowingTextarea.module.scss
+++ b/src/components/_shared/GrowingTextarea/GrowingTextarea.module.scss
@@ -9,7 +9,7 @@
padding: 16px 12px;
border-radius: 2px;
border: 2px solid var(--black-100);
- background: var(--white-500, #fff);
+ background: var(--white-500);
}
&.hasFieldName {
diff --git a/src/context/editor.tsx b/src/context/editor.tsx
index 28316a7d..d65080c2 100644
--- a/src/context/editor.tsx
+++ b/src/context/editor.tsx
@@ -21,12 +21,13 @@ export type ShoutForm = {
slug: string
title: string
subtitle: string
+ lead?: string
+ description?: string
selectedTopics: Topic[]
mainTopic?: Topic
body: string
coverImageUrl: string
media?: string
- lead?: string
}
type EditorContextType = {
@@ -136,6 +137,8 @@ export const EditorProvider = (props: { children: JSX.Element }) => {
slug: formToUpdate.slug,
subtitle: formToUpdate.subtitle,
title: formToUpdate.title,
+ lead: formToUpdate.lead,
+ description: formToUpdate.description,
cover: formToUpdate.coverImageUrl,
media: formToUpdate.media
},
diff --git a/src/graphql/mutation/article-update.ts b/src/graphql/mutation/article-update.ts
index da53afe7..a41c5c1a 100644
--- a/src/graphql/mutation/article-update.ts
+++ b/src/graphql/mutation/article-update.ts
@@ -9,6 +9,8 @@ export default gql`
slug
title
subtitle
+ lead
+ description
body
visibility
}
diff --git a/src/graphql/query/article-load.ts b/src/graphql/query/article-load.ts
index 1fac1b12..d16589ba 100644
--- a/src/graphql/query/article-load.ts
+++ b/src/graphql/query/article-load.ts
@@ -5,6 +5,8 @@ export default gql`
loadShout(slug: $slug, shout_id: $shoutId) {
id
title
+ lead
+ description
visibility
subtitle
slug
diff --git a/src/graphql/query/articles-load-by.ts b/src/graphql/query/articles-load-by.ts
index 9e8dd616..5db2edca 100644
--- a/src/graphql/query/articles-load-by.ts
+++ b/src/graphql/query/articles-load-by.ts
@@ -5,6 +5,8 @@ export default gql`
loadShouts(options: $options) {
id
title
+ lead
+ description
subtitle
slug
layout
diff --git a/src/graphql/types.gen.ts b/src/graphql/types.gen.ts
index ccf57ba9..61516a6b 100644
--- a/src/graphql/types.gen.ts
+++ b/src/graphql/types.gen.ts
@@ -554,6 +554,7 @@ export type Shout = {
createdAt: Scalars['DateTime']
deletedAt?: Maybe
deletedBy?: Maybe
+ description?: Maybe
id: Scalars['Int']
lang?: Maybe
layout?: Maybe
@@ -577,7 +578,9 @@ export type ShoutInput = {
body?: InputMaybe
community?: InputMaybe
cover?: InputMaybe
+ description?: InputMaybe
layout?: InputMaybe
+ lead?: InputMaybe
mainTopic?: InputMaybe
media?: InputMaybe
slug?: InputMaybe