diff --git a/src/app/components/editor/Editor.tsx b/src/app/components/editor/Editor.tsx index bd848dd5..b869f247 100644 --- a/src/app/components/editor/Editor.tsx +++ b/src/app/components/editor/Editor.tsx @@ -20,17 +20,9 @@ import { import { withHistory } from 'slate-history'; import { BlockType } from './types'; import { RenderElement, RenderLeaf } from './Elements'; -import { CustomElement } from './slate'; import * as css from './Editor.css'; import { toggleKeyboardShortcut } from './keyboard'; -const initialValue: CustomElement[] = [ - { - type: BlockType.Paragraph, - children: [{ text: '' }], - }, -]; - const withInline = (editor: Editor): Editor => { const { isInline } = editor; @@ -59,13 +51,13 @@ export const useEditor = (): Editor => { export type EditorChangeHandler = (value: Descendant[]) => void; type CustomEditorProps = { - editableName?: string; top?: ReactNode; bottom?: ReactNode; before?: ReactNode; after?: ReactNode; maxHeight?: string; editor: Editor; + initialValue?: Descendant[]; placeholder?: string; onKeyDown?: KeyboardEventHandler; onKeyUp?: KeyboardEventHandler; @@ -75,13 +67,13 @@ type CustomEditorProps = { export const CustomEditor = forwardRef( ( { - editableName, top, bottom, before, after, maxHeight = '50vh', editor, + initialValue, placeholder, onKeyDown, onKeyUp, @@ -90,6 +82,13 @@ export const CustomEditor = forwardRef( }, ref ) => { + const [defaultValue] = useState(() => [ + { + type: BlockType.Paragraph, + children: [{ text: '' }], + }, + ]); + const renderElement = useCallback( (props: RenderElementProps) => , [] @@ -120,7 +119,7 @@ export const CustomEditor = forwardRef( return (
- + {top} {before && ( @@ -137,7 +136,6 @@ export const CustomEditor = forwardRef( hideTrack > ( useCallback((width) => setHideStickerBtn(width < 500), []) ); - useEffect(() => { - Transforms.insertFragment(editor, draft); - }, [editor, draft]); - useEffect( () => () => { if (!isEmptyEditor(editor)) { const parsedDraft = JSON.parse(JSON.stringify(editor.children)); setDraft(parsedDraft); } else { - setDraft([]); + setDraft(undefined); } resetEditor(editor); resetEditorHistory(editor); @@ -306,8 +302,8 @@ export const RoomInput = forwardRef( /> )} { const stickerUrl = mxcToHttp(ct.session.baseUrl, mxc, useAuthentication).url(); if (!stickerUrl) return; - const info = await getImageInfo( + const info = getImageInfo( await loadImageElement(stickerUrl), await getImageUrlBlob(stickerUrl) ); diff --git a/src/app/features/room/message/thread-selector/ThreadSelector.tsx b/src/app/features/room/message/thread-selector/ThreadSelector.tsx index 41bbc9b0..693612f2 100644 --- a/src/app/features/room/message/thread-selector/ThreadSelector.tsx +++ b/src/app/features/room/message/thread-selector/ThreadSelector.tsx @@ -63,7 +63,6 @@ export function ThreadSelector({ hour24Clock={hour24Clock} dateFormatString={dateFormatString} ts={latestEvent.origin_server_ts} - inheritPriority /> diff --git a/src/app/state/room/roomInputDrafts.ts b/src/app/state/room/roomInputDrafts.ts index f4d57415..13f9b489 100644 --- a/src/app/state/room/roomInputDrafts.ts +++ b/src/app/state/room/roomInputDrafts.ts @@ -34,7 +34,7 @@ export type RoomIdToMsgAction = roomId: string; }; -const createDraftAtom = () => atom([]); +const createDraftAtom = () => atom(undefined); export type DraftAtom = ReturnType; export const composerToDraftAtom = atomFamily(() => createDraftAtom());