From b52610d692d3e97124bbe6b0d11ee36137772153 Mon Sep 17 00:00:00 2001 From: Ilya Y <75578537+ilya-bkv@users.noreply.github.com> Date: Thu, 17 Aug 2023 13:36:27 +0300 Subject: [PATCH] Fix Media Items description autosave (#184) --- .../Article/AudioPlayer/PlayerPlaylist.tsx | 2 +- src/components/Editor/SimplifiedEditor.tsx | 27 ++++++++++++++----- .../_shared/SolidSwiper/SolidSwiper.tsx | 8 +++++- .../_shared/SolidSwiper/swiper.d.ts | 1 + 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/components/Article/AudioPlayer/PlayerPlaylist.tsx b/src/components/Article/AudioPlayer/PlayerPlaylist.tsx index 9e4c3e5f..7ce74f36 100644 --- a/src/components/Article/AudioPlayer/PlayerPlaylist.tsx +++ b/src/components/Article/AudioPlayer/PlayerPlaylist.tsx @@ -162,7 +162,7 @@ export const PlayerPlaylist = (props: Props) => { initialContent={mi.body} placeholder={`${t('Description')}...`} smallHeight={true} - onAutoSave={(value) => handleMediaItemFieldChange('body', value)} + onChange={(value) => handleMediaItemFieldChange('body', value)} /> void - onAutoSave?: (text: string) => void + onChange?: (text: string) => void placeholder: string submitButtonText?: string quoteEnabled?: boolean @@ -46,11 +49,18 @@ type Props = { const SimplifiedEditor = (props: Props) => { const { t } = useLocalize() - const editorElRef: { - current: HTMLDivElement + const wrapperEditorElRef: { + current: HTMLElement } = { current: null } + + const editorElRef: { + current: HTMLElement + } = { + current: null + } + const { actions: { setEditor } } = useEditorContext() @@ -82,6 +92,8 @@ const SimplifiedEditor = (props: Props) => { } }), ImageFigure, + Image, + Figcaption, Placeholder.configure({ emptyNodeClass: styles.emptyNode, placeholder: props.placeholder @@ -174,16 +186,17 @@ const SimplifiedEditor = (props: Props) => { window.removeEventListener('keydown', handleKeyDown) }) - if (props.onAutoSave) { + if (props.onChange) { createEffect(() => { - if (isFocused()) return - props.onAutoSave(html()) + props.onChange(html()) }) } + const handleInsertLink = () => !editor().state.selection.empty && showModal('editorInsertLink') return (
(wrapperEditorElRef.current = el)} class={clsx(styles.SimplifiedEditor, { [styles.smallHeight]: props.smallHeight, [styles.isFocused]: isFocused() || !isEmpty() @@ -257,7 +270,7 @@ const SimplifiedEditor = (props: Props) => {
- +