mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat(markdown): when the user is publishing a comment, automatically format it to follow markdown rules
This commit is contained in:
@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import Draggable from 'react-draggable';
|
||||
import { setAccount, useAccount, useComment, useSubplebbit } from '@plebbit/plebbit-react-hooks';
|
||||
import Plebbit from '@plebbit/plebbit-js/dist/browser/index.js';
|
||||
import { formatMarkdown } from '../../lib/utils/post-utils';
|
||||
import { getFormattedTimeAgo } from '../../lib/utils/time-utils';
|
||||
import { isValidURL } from '../../lib/utils/url-utils';
|
||||
import { isAllView, isSubscriptionsView } from '../../lib/utils/view-utils';
|
||||
@@ -155,8 +156,9 @@ const ReplyModal = ({ closeModal, showReplyModal, parentCid, postCid, scrollY, s
|
||||
|
||||
const handleContentChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
||||
const contentWithoutPrefix = e.target.value.slice(contentPrefix.length);
|
||||
if (textRef.current && textRef.current.value !== contentWithoutPrefix) {
|
||||
setPublishReplyOptions({ content: contentWithoutPrefix });
|
||||
const formattedContent = formatMarkdown(contentWithoutPrefix);
|
||||
if (textRef.current && textRef.current.value !== formattedContent) {
|
||||
setPublishReplyOptions({ content: formattedContent });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user