Merge branch 'editor/flow_fixies' into 'main'

Editor flow fixes

See merge request discoursio/discoursio-webapp!79
This commit is contained in:
Igor 2023-05-10 07:44:33 +00:00
commit a73918b8f6
7 changed files with 28 additions and 8 deletions

View File

@ -76,7 +76,6 @@ export const FullArticle = (props: ArticleProps) => {
}) })
const canEdit = () => props.article.authors?.some((a) => a.slug === user()?.slug) const canEdit = () => props.article.authors?.some((a) => a.slug === user()?.slug)
// eslint-disable-next-line unicorn/consistent-function-scoping // eslint-disable-next-line unicorn/consistent-function-scoping
const handleBookmarkButtonClick = (ev) => { const handleBookmarkButtonClick = (ev) => {
// TODO: implement bookmark clicked // TODO: implement bookmark clicked
@ -254,7 +253,7 @@ export const FullArticle = (props: ArticleProps) => {
</div> </div>
</div> </div>
<div class={styles.help}> <div class={styles.help}>
<Show when={isAuthenticated()}> <Show when={isAuthenticated() && !canEdit()}>
<button class="button">{t('Cooperate')}</button> <button class="button">{t('Cooperate')}</button>
</Show> </Show>
<Show when={canEdit()}> <Show when={canEdit()}>

View File

@ -55,6 +55,7 @@ export const InlineForm = (props: Props) => {
<input <input
autofocus={props.autoFocus ?? true} autofocus={props.autoFocus ?? true}
type="text" type="text"
value={props.initialValue ?? ''}
placeholder={props.placeholder} placeholder={props.placeholder}
onKeyPress={(e) => handleKeyPress(e)} onKeyPress={(e) => handleKeyPress(e)}
onInput={(e) => handleFormInput(e.currentTarget.value)} onInput={(e) => handleFormInput(e.currentTarget.value)}

View File

@ -16,7 +16,7 @@
.close { .close {
filter: invert(1); filter: invert(1);
margin: -1.6rem 0 0 -1.6rem; margin: -1.6rem 0 0 -2.4rem;
} }
.actionsHolder { .actionsHolder {
@ -56,6 +56,11 @@
} }
} }
a {
text-decoration: none;
border-bottom: none;
}
.linkWithIcon { .linkWithIcon {
margin-left: -1.6rem; margin-left: -1.6rem;
} }

View File

@ -84,6 +84,7 @@ export const Panel = (props: Props) => {
<p> <p>
<a <a
class={styles.linkWithIcon} class={styles.linkWithIcon}
onClick={() => toggleEditorPanel()}
href={getPagePath(router, 'edit', { shoutId: props.shoutId.toString() })} href={getPagePath(router, 'edit', { shoutId: props.shoutId.toString() })}
> >
<Icon name="pencil-outline" class={styles.icon} /> <Icon name="pencil-outline" class={styles.icon} />
@ -103,7 +104,10 @@ export const Panel = (props: Props) => {
<a>{t('Invite co-authors')}</a> <a>{t('Invite co-authors')}</a>
</p> </p>
<p> <p>
<a href={getPagePath(router, 'editSettings', { shoutId: props.shoutId.toString() })}> <a
onClick={() => toggleEditorPanel()}
href={getPagePath(router, 'editSettings', { shoutId: props.shoutId.toString() })}
>
{t('Publication settings')} {t('Publication settings')}
</a> </a>
</p> </p>

View File

@ -16,7 +16,7 @@ export const DraftsView = () => {
const loadDrafts = async () => { const loadDrafts = async () => {
const loadedDrafts = await apiClient.getDrafts() const loadedDrafts = await apiClient.getDrafts()
setDrafts(loadedDrafts) setDrafts(loadedDrafts.reverse())
} }
onMount(() => { onMount(() => {

View File

@ -13,6 +13,7 @@ import styles from './Edit.module.scss'
import { useSession } from '../../context/session' import { useSession } from '../../context/session'
import { Modal } from '../Nav/Modal' import { Modal } from '../Nav/Modal'
import { hideModal, showModal } from '../../stores/ui' import { hideModal, showModal } from '../../stores/ui'
import { imageProxy } from '../../utils/imageProxy'
type EditViewProps = { type EditViewProps = {
shout: Shout shout: Shout
@ -28,7 +29,6 @@ const scrollTop = () => {
export const EditView = (props: EditViewProps) => { export const EditView = (props: EditViewProps) => {
const { t } = useLocalize() const { t } = useLocalize()
const { user } = useSession() const { user } = useSession()
const [isScrolled, setIsScrolled] = createSignal(false) const [isScrolled, setIsScrolled] = createSignal(false)
const [topics, setTopics] = createSignal<Topic[]>(null) const [topics, setTopics] = createSignal<Topic[]>(null)
const [coverImage, setCoverImage] = createSignal<string>(null) const [coverImage, setCoverImage] = createSignal<string>(null)
@ -82,7 +82,7 @@ export const EditView = (props: EditViewProps) => {
const handleUploadModalContentCloseSetCover = (imgUrl: string) => { const handleUploadModalContentCloseSetCover = (imgUrl: string) => {
hideModal() hideModal()
setCoverImage(imgUrl) setCoverImage(imageProxy(imgUrl))
setForm('coverImageUrl', imgUrl) setForm('coverImageUrl', imgUrl)
} }
@ -227,7 +227,11 @@ export const EditView = (props: EditViewProps) => {
<Show when={coverImage() ?? form.coverImageUrl}> <Show when={coverImage() ?? form.coverImageUrl}>
<div class={styles.shoutCardCoverContainer}> <div class={styles.shoutCardCoverContainer}>
<div class={styles.shoutCardCover}> <div class={styles.shoutCardCover}>
<img src={coverImage() || form.coverImageUrl} alt={form.title} loading="lazy" /> <img
src={coverImage() || imageProxy(form.coverImageUrl)}
alt={form.title}
loading="lazy"
/>
</div> </div>
</div> </div>
</Show> </Show>

View File

@ -80,6 +80,10 @@ export const EditorProvider = (props: { children: JSX.Element }) => {
} }
const saveShout = async () => { const saveShout = async () => {
if (isEditorPanelVisible()) {
toggleEditorPanel()
}
if (!validate()) { if (!validate()) {
return return
} }
@ -113,6 +117,9 @@ export const EditorProvider = (props: { children: JSX.Element }) => {
} }
const publishShout = async () => { const publishShout = async () => {
if (isEditorPanelVisible()) {
toggleEditorPanel()
}
if (!validate()) { if (!validate()) {
return return
} }