|
@@ -16,14 +16,13 @@ import {
|
|
|
useCurrentUser, useIsSlackConfigured,
|
|
useCurrentUser, useIsSlackConfigured,
|
|
|
useIsUploadableFile, useIsUploadableImage,
|
|
useIsUploadableFile, useIsUploadableImage,
|
|
|
} from '~/stores/context';
|
|
} from '~/stores/context';
|
|
|
-import { useSWRxSlackChannels, useIsSlackEnabled } from '~/stores/editor';
|
|
|
|
|
|
|
+import { useSWRxSlackChannels, useIsSlackEnabled, useIsEnabledUnsavedWarning } from '~/stores/editor';
|
|
|
import { useCurrentPagePath } from '~/stores/page';
|
|
import { useCurrentPagePath } from '~/stores/page';
|
|
|
|
|
|
|
|
import { CustomNavTab } from '../CustomNavigation/CustomNav';
|
|
import { CustomNavTab } from '../CustomNavigation/CustomNav';
|
|
|
import { NotAvailableForGuest } from '../NotAvailableForGuest';
|
|
import { NotAvailableForGuest } from '../NotAvailableForGuest';
|
|
|
import Editor from '../PageEditor/Editor';
|
|
import Editor from '../PageEditor/Editor';
|
|
|
|
|
|
|
|
-
|
|
|
|
|
import { CommentPreview } from './CommentPreview';
|
|
import { CommentPreview } from './CommentPreview';
|
|
|
|
|
|
|
|
import styles from './CommentEditor.module.scss';
|
|
import styles from './CommentEditor.module.scss';
|
|
@@ -70,6 +69,7 @@ export const CommentEditor = (props: CommentEditorProps): JSX.Element => {
|
|
|
const { data: isSlackConfigured } = useIsSlackConfigured();
|
|
const { data: isSlackConfigured } = useIsSlackConfigured();
|
|
|
const { data: isUploadableFile } = useIsUploadableFile();
|
|
const { data: isUploadableFile } = useIsUploadableFile();
|
|
|
const { data: isUploadableImage } = useIsUploadableImage();
|
|
const { data: isUploadableImage } = useIsUploadableImage();
|
|
|
|
|
+ const { mutate: mutateIsEnabledUnsavedWarning } = useIsEnabledUnsavedWarning();
|
|
|
|
|
|
|
|
const [isReadyToUse, setIsReadyToUse] = useState(!isForNewComment);
|
|
const [isReadyToUse, setIsReadyToUse] = useState(!isForNewComment);
|
|
|
const [comment, setComment] = useState(commentBody ?? '');
|
|
const [comment, setComment] = useState(commentBody ?? '');
|
|
@@ -237,7 +237,10 @@ export const CommentEditor = (props: CommentEditorProps): JSX.Element => {
|
|
|
);
|
|
);
|
|
|
}, []);
|
|
}, []);
|
|
|
|
|
|
|
|
- const onChangeHandler = useCallback((newValue: string) => setComment(newValue), []);
|
|
|
|
|
|
|
+ const onChangeHandler = useCallback((newValue: string, isClean: boolean) => {
|
|
|
|
|
+ setComment(newValue);
|
|
|
|
|
+ mutateIsEnabledUnsavedWarning(!isClean);
|
|
|
|
|
+ }, [mutateIsEnabledUnsavedWarning]);
|
|
|
|
|
|
|
|
const renderReady = () => {
|
|
const renderReady = () => {
|
|
|
const commentPreview = getCommentHtml();
|
|
const commentPreview = getCommentHtml();
|