mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat(reply modal): add spellcheck for the content, excluding the c/cid at the top
This commit is contained in:
@@ -163,6 +163,20 @@ const ReplyModal = ({ closeModal, showReplyModal, parentCid, postCid, scrollY, s
|
|||||||
|
|
||||||
const contentPrefix = `c/${parentCid && Plebbit.getShortCid(parentCid)}\n`;
|
const contentPrefix = `c/${parentCid && Plebbit.getShortCid(parentCid)}\n`;
|
||||||
|
|
||||||
|
// enable spellcheck after the prefix is set
|
||||||
|
useEffect(() => {
|
||||||
|
if (showReplyModal && textRef.current) {
|
||||||
|
textRef.current.spellcheck = false;
|
||||||
|
textRef.current.value = contentPrefix + (selectedText || '');
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
if (textRef.current) {
|
||||||
|
textRef.current.spellcheck = true;
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
}, [showReplyModal, contentPrefix, selectedText]);
|
||||||
|
|
||||||
const handleContentInput = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
const handleContentInput = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
||||||
const { value } = e.target;
|
const { value } = e.target;
|
||||||
if (!value.startsWith(contentPrefix)) {
|
if (!value.startsWith(contentPrefix)) {
|
||||||
@@ -245,16 +259,7 @@ const ReplyModal = ({ closeModal, showReplyModal, parentCid, postCid, scrollY, s
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.content}>
|
<div className={styles.content}>
|
||||||
<textarea
|
<textarea cols={48} rows={4} wrap='soft' ref={textRef} spellCheck={true} onInput={handleContentInput} onChange={handleContentChange} />
|
||||||
cols={48}
|
|
||||||
rows={4}
|
|
||||||
wrap='soft'
|
|
||||||
ref={textRef}
|
|
||||||
spellCheck={false}
|
|
||||||
defaultValue={contentPrefix + selectedText}
|
|
||||||
onInput={handleContentInput}
|
|
||||||
onChange={handleContentChange}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
{!(isInAllView || isInSubscriptionsView) && offlineAlert}
|
{!(isInAllView || isInSubscriptionsView) && offlineAlert}
|
||||||
<div className={styles.offlineAlert}></div>
|
<div className={styles.offlineAlert}></div>
|
||||||
|
|||||||
Reference in New Issue
Block a user