@ -1,7 +1,7 @@
|
||||
import clsx from 'clsx';
|
||||
import { CLEAR_EDITOR_COMMAND, TextNode, type LexicalEditor, $getRoot } from 'lexical';
|
||||
import { CLEAR_EDITOR_COMMAND, TextNode, type LexicalEditor } from 'lexical';
|
||||
import React, { Suspense, useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
||||
import { FormattedMessage, defineMessages, useIntl } from 'react-intl';
|
||||
import { Link, useHistory } from 'react-router-dom';
|
||||
import { length } from 'stringz';
|
||||
|
||||
@ -86,6 +86,7 @@ const ComposeForm = <ID extends string>({ id, shouldCondense, autoFocus, clickab
|
||||
is_uploading: isUploading,
|
||||
schedule: scheduledAt,
|
||||
group_id: groupId,
|
||||
text,
|
||||
} = compose;
|
||||
|
||||
const prevSpoiler = usePrevious(spoiler);
|
||||
@ -102,7 +103,6 @@ const ComposeForm = <ID extends string>({ id, shouldCondense, autoFocus, clickab
|
||||
const editorRef = useRef<LexicalEditor>(null);
|
||||
const { isDraggedOver } = useDraggedFiles(formRef);
|
||||
|
||||
const text = editorRef.current?.getEditorState().read(() => $getRoot().getTextContent()) ?? '';
|
||||
const fulltext = [spoilerText, countableText(text)].join('');
|
||||
|
||||
const isEmpty = !(fulltext.trim() || anyMedia);
|
||||
|
||||
@ -81,7 +81,7 @@ class EmojiNode extends DecoratorNode<JSX.Element> {
|
||||
decorate(): JSX.Element {
|
||||
const emoji = this.__emoji;
|
||||
if (isNativeEmoji(emoji)) {
|
||||
return <Component emoji={emoji.native} alt={emoji.colons} className='emojione h-4 w-4' />;
|
||||
return <Component emoji={emoji.native} alt={emoji.colons} className='emojione h-4 w-4' />;
|
||||
} else {
|
||||
return <Component src={emoji.imageUrl} alt={emoji.colons} className='emojione h-4 w-4' />;
|
||||
}
|
||||
|
||||
@ -15,9 +15,10 @@ const StatePlugin: React.FC<IStatePlugin> = ({ composeId }) => {
|
||||
|
||||
useEffect(() => {
|
||||
editor.registerUpdateListener(({ editorState }) => {
|
||||
const isEmpty = editorState.read(() => $getRoot().getTextContent()) === '';
|
||||
const text = editorState.read(() => $getRoot().getTextContent());
|
||||
const isEmpty = text === '';
|
||||
const data = isEmpty ? null : JSON.stringify(editorState.toJSON());
|
||||
dispatch(setEditorState(composeId, data));
|
||||
dispatch(setEditorState(composeId, data, text));
|
||||
});
|
||||
}, [editor]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user