|
@@ -1,11 +1,11 @@
|
|
|
-import React, { type ReactNode, useCallback } from 'react';
|
|
|
|
|
|
|
+import React, { type ReactNode, useCallback, useMemo } from 'react';
|
|
|
|
|
|
|
|
import { Origin } from '@growi/core';
|
|
import { Origin } from '@growi/core';
|
|
|
import { useTranslation } from 'next-i18next';
|
|
import { useTranslation } from 'next-i18next';
|
|
|
|
|
|
|
|
import { useCreatePageAndTransit } from '~/client/services/create-page';
|
|
import { useCreatePageAndTransit } from '~/client/services/create-page';
|
|
|
import { toastError } from '~/client/util/toastr';
|
|
import { toastError } from '~/client/util/toastr';
|
|
|
-import { useIsNotFound, useCurrentPageYjsDraft } from '~/stores/page';
|
|
|
|
|
|
|
+import { useIsNotFound, useCurrentPageYjsDraft, useCurrentPageYjsAwarenessStateSize } from '~/stores/page';
|
|
|
import { EditorMode, useEditorMode, useIsDeviceLargerThanMd } from '~/stores/ui';
|
|
import { EditorMode, useEditorMode, useIsDeviceLargerThanMd } from '~/stores/ui';
|
|
|
|
|
|
|
|
import { shouldCreateWipPage } from '../../utils/should-create-wip-page';
|
|
import { shouldCreateWipPage } from '../../utils/should-create-wip-page';
|
|
@@ -65,6 +65,7 @@ export const PageEditorModeManager = (props: Props): JSX.Element => {
|
|
|
const { mutate: mutateEditorMode } = useEditorMode();
|
|
const { mutate: mutateEditorMode } = useEditorMode();
|
|
|
const { data: isDeviceLargerThanMd } = useIsDeviceLargerThanMd();
|
|
const { data: isDeviceLargerThanMd } = useIsDeviceLargerThanMd();
|
|
|
const { data: currentPageYjsDraft } = useCurrentPageYjsDraft();
|
|
const { data: currentPageYjsDraft } = useCurrentPageYjsDraft();
|
|
|
|
|
+ const { data: currentPageYjsAwarenessStateSize } = useCurrentPageYjsAwarenessStateSize();
|
|
|
|
|
|
|
|
const { isCreating, createAndTransit } = useCreatePageAndTransit();
|
|
const { isCreating, createAndTransit } = useCreatePageAndTransit();
|
|
|
|
|
|
|
@@ -87,6 +88,12 @@ export const PageEditorModeManager = (props: Props): JSX.Element => {
|
|
|
|
|
|
|
|
const _isBtnDisabled = isCreating || isBtnDisabled;
|
|
const _isBtnDisabled = isCreating || isBtnDisabled;
|
|
|
|
|
|
|
|
|
|
+ const circleColor = useMemo(() => {
|
|
|
|
|
+ if (currentPageYjsAwarenessStateSize != null && currentPageYjsAwarenessStateSize > 0) {
|
|
|
|
|
+ return 'bg-primary';
|
|
|
|
|
+ }
|
|
|
|
|
+ }, [currentPageYjsAwarenessStateSize]);
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
|
<div
|
|
<div
|
|
@@ -113,7 +120,7 @@ export const PageEditorModeManager = (props: Props): JSX.Element => {
|
|
|
onClick={editButtonClickedHandler}
|
|
onClick={editButtonClickedHandler}
|
|
|
>
|
|
>
|
|
|
<span className="material-symbols-outlined me-1 fs-5">edit_square</span>{t('Edit')}
|
|
<span className="material-symbols-outlined me-1 fs-5">edit_square</span>{t('Edit')}
|
|
|
- { currentPageYjsDraft?.hasYjsDraft && <span className="position-absolute top-0 start-100 translate-middle p-1 bg-primary rounded-circle" />}
|
|
|
|
|
|
|
+ { circleColor != null && <span className={`position-absolute top-0 start-100 translate-middle p-1 rounded-circle ${circleColor}`} />}
|
|
|
</PageEditorModeButton>
|
|
</PageEditorModeButton>
|
|
|
)}
|
|
)}
|
|
|
</div>
|
|
</div>
|