{
+ if (!editorRef?.current) return;
+ const handleUpdate = () => {
+ const htmlContent = editorRef?.current.getHTML();
+ const stringified = JSON.stringify(htmlContent);
+ const size = new Blob([stringified]).size;
+ setMessageSize(size + 100);
+ };
+
+ // Add a listener for the editorRef?.current's content updates
+ editorRef?.current.on('update', handleUpdate);
+
+ // Cleanup the listener on unmount
+ return () => {
+ editorRef?.current.off('update', handleUpdate);
+ };
+ }, [editorRef?.current]);
+
useEffect(()=> {
const notifications = messages.filter((message)=> message?.decryptedData
@@ -516,6 +536,7 @@ const sendChatGroup = async ({groupId, typeMessage = undefined, chatReference =
const clearEditorContent = () => {
if (editorRef.current) {
editorRef.current.chain().focus().clearContent().run();
+ setMessageSize(0)
if(isMobile){
setTimeout(() => {
editorRef.current?.chain().blur().run();
@@ -743,19 +764,22 @@ const clearEditorContent = () => {
width: '100%'
}}>
-
+
-
-
{}} members={members} myName={myName} selectedGroup={selectedGroup}/>
+
{
if(isSending) return
setIsFocusedParent(false)
clearEditorContent()
+
// Unfocus the editor
}}
style={{
@@ -786,6 +811,7 @@ const clearEditorContent = () => {
{isFocusedParent && (
{
+ if(messageSize > 4000) return
if(isSending) return
sendMessage()
}}
@@ -818,6 +844,21 @@ const clearEditorContent = () => {
+ {isFocusedParent && messageSize > 750 && (
+
+ 4000 ? 'var(--unread)' : 'unset'
+ }}>{`size ${messageSize} of 4000`}
+
+
+ )}
{/* */}
{/* */}