aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/ui/MessageInput.js
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2023-05-31 06:10:51 +0300
committerGravatar Vitaly Takmazov2023-05-31 06:11:05 +0300
commitf2a7ea3af919548d41383734e8a3667086a44bcc (patch)
treee0d9db07956f10ccc4e27fc9e0d45d88950dbfbb /vnext/src/ui/MessageInput.js
parent395185d093b2d6bb46d02830088e00a3a2ca20c1 (diff)
eslint: enforce semicolons only before statement continuation chars
Diffstat (limited to 'vnext/src/ui/MessageInput.js')
-rw-r--r--vnext/src/ui/MessageInput.js90
1 files changed, 45 insertions, 45 deletions
diff --git a/vnext/src/ui/MessageInput.js b/vnext/src/ui/MessageInput.js
index 3d24e728..6ebf4361 100644
--- a/vnext/src/ui/MessageInput.js
+++ b/vnext/src/ui/MessageInput.js
@@ -1,10 +1,10 @@
-import React, { useState, useEffect, useRef } from 'react';
+import React, { useState, useEffect, useRef } from 'react'
-import Icon from './Icon';
-import Button from './Button';
+import Icon from './Icon'
+import Button from './Button'
-import UploadButton from './UploadButton';
-import toast from 'react-hot-toast';
+import UploadButton from './UploadButton'
+import toast from 'react-hot-toast'
/**
@@ -13,13 +13,13 @@ import toast from 'react-hot-toast';
*/
function moveCaretToEnd(el) {
if (typeof el.selectionStart == 'number') {
- el.selectionStart = el.selectionEnd = el.value.length;
+ el.selectionStart = el.selectionEnd = el.value.length
} else if (typeof el.createTextRange != 'undefined') {
// Internet Explorer
- el.focus();
- var range = el.createTextRange();
- range.collapse(false);
- range.select();
+ el.focus()
+ var range = el.createTextRange()
+ range.collapse(false)
+ range.select()
}
}
@@ -42,74 +42,74 @@ export default function MessageInput({ text, rows, placeholder, onSend }) {
/**
* @type {React.MutableRefObject<HTMLTextAreaElement?>}
*/
- let textareaRef = useRef(null);
+ let textareaRef = useRef(null)
/**
* @type {React.MutableRefObject<HTMLInputElement?>}
*/
- let fileinput = useRef(null);
+ let fileinput = useRef(null)
let updateFocus = () => {
- const isDesktop = window.matchMedia('(min-width: 62.5rem)');
+ const isDesktop = window.matchMedia('(min-width: 62.5rem)')
if (isDesktop.matches) {
- const textarea = textareaRef.current;
+ const textarea = textareaRef.current
if (textarea) {
- textarea.focus();
- moveCaretToEnd(textarea);
+ textarea.focus()
+ moveCaretToEnd(textarea)
}
}
- };
+ }
useEffect(() => {
textChanged({
target: {
value: text
}
- });
- updateFocus();
- }, [text]);
+ })
+ updateFocus()
+ }, [text])
- let [body, setBody] = useState(text);
+ let [body, setBody] = useState(text)
let handleCtrlEnter = (event) => {
if (event.ctrlKey && (event.charCode == 10 || event.charCode == 13)) {
- onSubmit({});
+ onSubmit({})
}
- };
+ }
const textChanged = (event) => {
- setBody(event.target.value);
- const el = textareaRef.current;
+ setBody(event.target.value)
+ const el = textareaRef.current
if (el) {
- const offset = el.offsetHeight - el.clientHeight;
- const height = el.scrollHeight + offset;
- el.style.height = `${height + offset}px`;
+ const offset = el.offsetHeight - el.clientHeight
+ const height = el.scrollHeight + offset
+ el.style.height = `${height + offset}px`
}
- };
- const [attach, setAttach] = useState('');
+ }
+ const [attach, setAttach] = useState('')
let uploadValueChanged = (attach) => {
- setAttach(attach);
- };
+ setAttach(attach)
+ }
let onSubmit = (event) => {
if (event.preventDefault) {
- event.preventDefault();
+ event.preventDefault()
}
- const input = fileinput.current;
+ const input = fileinput.current
if (input && input.files) {
onSend({
body: body,
attach: attach ? input.files[0] : ''
}).then((success) => {
if (success) {
- setAttach('');
- setBody('');
+ setAttach('')
+ setBody('')
if (textareaRef.current) {
- textareaRef.current.style.height = '';
+ textareaRef.current.style.height = ''
}
- updateFocus();
+ updateFocus()
} else {
- toast('Can not update this message');
+ toast('Can not update this message')
}
- }).catch(console.log);
+ }).catch(console.log)
}
- };
+ }
return (
<form className="msg-comment-target" style={{ padding: '12px', width: '100%' }} onSubmit={onSubmit}>
<div style={commentStyle}>
@@ -122,7 +122,7 @@ export default function MessageInput({ text, rows, placeholder, onSend }) {
</div>
</div>
</form>
- );
+ )
}
/**
@@ -133,7 +133,7 @@ const commentStyle = {
flexDirection: 'column',
width: '100%',
marginTop: '10px'
-};
+}
/**
* @type {React.CSSProperties}
@@ -143,7 +143,7 @@ const inputBarStyle = {
alignItems: 'center',
justifyContent: 'space-between',
padding: '3px'
-};
+}
/**
* @type {React.CSSProperties}
@@ -156,4 +156,4 @@ const textInputStyle = {
border: 0,
outline: 'none',
padding: '4px'
-};
+}